doc: sample application user guide
[dpdk.git] / doc / guides / sample_app_ug / l3_forward_virtual.rst
1 ..  BSD LICENSE
2     Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
3     All rights reserved.
4
5     Redistribution and use in source and binary forms, with or without
6     modification, are permitted provided that the following conditions
7     are met:
8
9     * Redistributions of source code must retain the above copyright
10     notice, this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright
12     notice, this list of conditions and the following disclaimer in
13     the documentation and/or other materials provided with the
14     distribution.
15     * Neither the name of Intel Corporation nor the names of its
16     contributors may be used to endorse or promote products derived
17     from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 L3 Forwarding in a Virtualization Environment Sample Application
32 ================================================================
33
34 The L3 Forwarding in a Virtualization Environment sample application is a simple example of packet processing using the Intel® DPDK.
35 The application performs L3 forwarding that takes advantage of Single Root I/O Virtualization (SR-IOV) features
36 in a virtualized environment.
37
38 Overview
39 --------
40
41 The application demonstrates the use of the hash and LPM libraries in the Intel® DPDK to implement packet forwarding.
42 The initialization and run-time paths are very similar to those of the L3 forwarding application
43 (see Chapter 10 "L3 Forwarding Sample Application" for more information).
44 The forwarding decision is taken based on information read from the input packet.
45
46 The lookup method is either hash-based or LPM-based and is selected at compile time.
47 When the selected lookup method is hash-based, a hash object is used to emulate the flow classification stage.
48 The hash object is used in correlation with the flow table to map each input packet to its flow at runtime.
49
50 The hash lookup key is represented by the DiffServ 5-tuple composed of the following fields read from the input packet:
51 Source IP Address, Destination IP Address, Protocol, Source Port and Destination Port.
52 The ID of the output interface for the input packet is read from the identified flow table entry.
53 The set of flows used by the application is statically configured and loaded into the hash at initialization time.
54 When the selected lookup method is LPM based, an LPM object is used to emulate the forwarding stage for IPv4 packets.
55 The LPM object is used as the routing table to identify the next hop for each input packet at runtime.
56
57 The LPM lookup key is represented by the Destination IP Address field read from the input packet.
58 The ID of the output interface for the input packet is the next hop returned by the LPM lookup.
59 The set of LPM rules used by the application is statically configured and loaded into the LPM object at the initialization time.
60
61 .. note::
62
63     Please refer to Section 9.1.1 "Virtual Function Setup Instructions" for virtualized test case setup.
64
65 Compiling the Application
66 -------------------------
67
68 To compile the application:
69
70 #.  Go to the sample application directory:
71
72     .. code-block:: console
73
74         export RTE_SDK=/path/to/rte_sdk
75         cd ${RTE_SDK}/examples/l3fwd-vf
76
77 #.  Set the target (a default target is used if not specified). For example:
78
79     .. code-block:: console
80
81         export RTE_TARGET=x86_64-native-linuxapp-gcc
82
83     See the *Intel® DPDK Getting Started Guide* for possible RTE_TARGET values.
84
85 #.  Build the application:
86
87     .. code-block:: console
88
89         make
90
91 .. note::
92
93     The compiled application is written to the build subdirectory.
94     To have the application written to a different location,
95     the O=/path/to/build/directory option may be specified in the make command.
96
97 Running the Application
98 -----------------------
99
100 The application has a number of command line options:
101
102 .. code-block:: console
103
104     ./build/l3fwd-vf [EAL options] -- -p PORTMASK  --config(port,queue,lcore)[,(port,queue,lcore)] [--no-numa]
105
106 where,
107
108 *   --p PORTMASK: Hexadecimal bitmask of ports to configure
109
110 *   --config (port,queue,lcore)[,(port,queue,lcore]: determines which queues from which ports are mapped to which cores
111
112 *   --no-numa: optional, disables numa awareness
113
114 For example, consider a dual processor socket platform where cores 0,2,4,6, 8, and 10 appear on socket 0,
115 while cores 1,3,5,7,9, and 11 appear on socket 1.
116 Let's say that the programmer wants to use memory from both NUMA nodes,
117 the platform has only two ports and the programmer wants to use one core from each processor socket to do the packet processing
118 since only one Rx/Tx queue pair can be used in virtualization mode.
119
120 To enable L3 forwarding between two ports, using one core from each processor,
121 while also taking advantage of local memory accesses by optimizing around NUMA,
122 the programmer can pin to the appropriate cores and allocate memory from the appropriate NUMA node.
123 This is achieved using the following command:
124
125 .. code-block:: console
126
127    ./build/l3fwd-vf -c 0x03 -n 3 -- -p 0x3 --config="(0,0,0),(1,0,1)"
128
129 In this command:
130
131 *   The -c option enables cores 0 and 1
132
133 *   The -p option enables ports 0 and 1
134
135 *   The --config option enables one queue on each port and maps each (port,queue) pair to a specific core.
136     Logic to enable multiple RX queues using RSS and to allocate memory from the correct NUMA nodes
137     is included in the application and is done transparently.
138     The following table shows the mapping in this example:
139
140     +----------+-----------+-----------+------------------------------------+
141     | **Port** | **Queue** | **lcore** | **Description**                    |
142     |          |           |           |                                    |
143     +==========+===========+===========+====================================+
144     | 0        | 0         | 0         | Map queue 0 from port 0 to lcore 0 |
145     |          |           |           |                                    |
146     +----------+-----------+-----------+------------------------------------+
147     | 1        | 1         | 1         | Map queue 0 from port 1 to lcore 1 |
148     |          |           |           |                                    |
149     +----------+-----------+-----------+------------------------------------+
150
151 Refer to the *Intel® DPDK Getting Started Guide* for general information on running applications
152 and the Environment Abstraction Layer (EAL) options.
153
154 Explanation
155 -----------
156
157 The operation of this application is similar to that of the basic L3 Forwarding Sample Application.
158 See Section 10.4 "Explanation" for more information.