2 Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
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
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.
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.
31 L3 Forwarding in a Virtualization Environment Sample Application
32 ================================================================
34 The L3 Forwarding in a Virtualization Environment sample application is a simple example of packet processing using the DPDK.
35 The application performs L3 forwarding that takes advantage of Single Root I/O Virtualization (SR-IOV) features
36 in a virtualized environment.
41 The application demonstrates the use of the hash and LPM libraries in the DPDK to implement packet forwarding.
42 The initialization and run-time paths are very similar to those of the :doc:`l3_forward`.
43 The forwarding decision is taken based on information read from the input packet.
45 The lookup method is either hash-based or LPM-based and is selected at compile time.
46 When the selected lookup method is hash-based, a hash object is used to emulate the flow classification stage.
47 The hash object is used in correlation with the flow table to map each input packet to its flow at runtime.
49 The hash lookup key is represented by the DiffServ 5-tuple composed of the following fields read from the input packet:
50 Source IP Address, Destination IP Address, Protocol, Source Port and Destination Port.
51 The ID of the output interface for the input packet is read from the identified flow table entry.
52 The set of flows used by the application is statically configured and loaded into the hash at initialization time.
53 When the selected lookup method is LPM based, an LPM object is used to emulate the forwarding stage for IPv4 packets.
54 The LPM object is used as the routing table to identify the next hop for each input packet at runtime.
56 The LPM lookup key is represented by the Destination IP Address field read from the input packet.
57 The ID of the output interface for the input packet is the next hop returned by the LPM lookup.
58 The set of LPM rules used by the application is statically configured and loaded into the LPM object at the initialization time.
62 Please refer to :ref:`l2_fwd_vf_setup` for virtualized test case setup.
64 Compiling the Application
65 -------------------------
67 To compile the application:
69 #. Go to the sample application directory:
71 .. code-block:: console
73 export RTE_SDK=/path/to/rte_sdk
74 cd ${RTE_SDK}/examples/l3fwd-vf
76 #. Set the target (a default target is used if not specified). For example:
78 .. code-block:: console
80 export RTE_TARGET=x86_64-native-linuxapp-gcc
82 See the *DPDK Getting Started Guide* for possible RTE_TARGET values.
84 #. Build the application:
86 .. code-block:: console
92 The compiled application is written to the build subdirectory.
93 To have the application written to a different location,
94 the O=/path/to/build/directory option may be specified in the make command.
96 Running the Application
97 -----------------------
99 The application has a number of command line options:
101 .. code-block:: console
103 ./build/l3fwd-vf [EAL options] -- -p PORTMASK --config(port,queue,lcore)[,(port,queue,lcore)] [--no-numa]
107 * --p PORTMASK: Hexadecimal bitmask of ports to configure
109 * --config (port,queue,lcore)[,(port,queue,lcore]: determines which queues from which ports are mapped to which cores
111 * --no-numa: optional, disables numa awareness
113 For example, consider a dual processor socket platform where cores 0,2,4,6, 8, and 10 appear on socket 0,
114 while cores 1,3,5,7,9, and 11 appear on socket 1.
115 Let's say that the programmer wants to use memory from both NUMA nodes,
116 the platform has only two ports and the programmer wants to use one core from each processor socket to do the packet processing
117 since only one Rx/Tx queue pair can be used in virtualization mode.
119 To enable L3 forwarding between two ports, using one core from each processor,
120 while also taking advantage of local memory accesses by optimizing around NUMA,
121 the programmer can pin to the appropriate cores and allocate memory from the appropriate NUMA node.
122 This is achieved using the following command:
124 .. code-block:: console
126 ./build/l3fwd-vf -c 0x03 -n 3 -- -p 0x3 --config="(0,0,0),(1,0,1)"
130 * The -c option enables cores 0 and 1
132 * The -p option enables ports 0 and 1
134 * The --config option enables one queue on each port and maps each (port,queue) pair to a specific core.
135 Logic to enable multiple RX queues using RSS and to allocate memory from the correct NUMA nodes
136 is included in the application and is done transparently.
137 The following table shows the mapping in this example:
139 +----------+-----------+-----------+------------------------------------+
140 | **Port** | **Queue** | **lcore** | **Description** |
142 +==========+===========+===========+====================================+
143 | 0 | 0 | 0 | Map queue 0 from port 0 to lcore 0 |
145 +----------+-----------+-----------+------------------------------------+
146 | 1 | 1 | 1 | Map queue 0 from port 1 to lcore 1 |
148 +----------+-----------+-----------+------------------------------------+
150 Refer to the *DPDK Getting Started Guide* for general information on running applications
151 and the Environment Abstraction Layer (EAL) options.
156 The operation of this application is similar to that of the basic L3 Forwarding Sample Application.
157 See :ref:`l3_fwd_explanation` for more information.