2 Copyright(c) 2017 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.
32 ======================
34 KNI PMD is wrapper to the :ref:`librte_kni <kni>` library.
36 This PMD enables using KNI without having a KNI specific application,
37 any forwarding application can use PMD interface for KNI.
39 Sending packets to any DPDK controlled interface or sending to the
40 Linux networking stack will be transparent to the DPDK application.
42 To create a KNI device ``net_kni#`` device name should be used, and this
43 will create ``kni#`` Linux virtual network interface.
45 There is no physical device backend for the virtual KNI device.
47 Packets sent to the KNI Linux interface will be received by the DPDK
48 application, and DPDK application may forward packets to a physical NIC
49 or to a virtual device (like another KNI interface or PCAP interface).
51 To forward any traffic from physical NIC to the Linux networking stack,
52 an application should control a physical port and create one virtual KNI port,
53 and forward between two.
55 Using this PMD requires KNI kernel module be inserted.
61 EAL ``--vdev`` argument can be used to create KNI device instance, like::
63 testpmd --vdev=net_kni0 --vdev=net_kn1 -- -i
65 Above command will create ``kni0`` and ``kni1`` Linux network interfaces,
66 those interfaces can be controlled by standard Linux tools.
68 When testpmd forwarding starts, any packets sent to ``kni0`` interface
69 forwarded to the ``kni1`` interface and vice versa.
71 There is no hard limit on number of interfaces that can be created.
74 Default interface configuration
75 -------------------------------
77 ``librte_kni`` can create Linux network interfaces with different features,
78 feature set controlled by a configuration struct, and KNI PMD uses a fixed
81 .. code-block:: console
84 force bind kernel thread to a core : NO
85 mbuf size: MAX_PACKET_SZ
87 KNI control path is not supported with the PMD, since there is no physical
88 backend device by default.
94 ``no_request_thread``, by default PMD creates a phtread for each KNI interface
95 to handle Linux network interface control commands, like ``ifconfig kni0 up``
97 With ``no_request_thread`` option, pthread is not created and control commands
100 By default request thread is enabled. And this argument should not be used
101 most of the time, unless this PMD used with customized DPDK application to handle
106 testpmd --vdev "net_kni0,no_request_thread=1" -- -i
112 If KNI kernel module (rte_kni.ko) not inserted, following error log printed::
114 "KNI: KNI subsystem has not been initialized. Invoke rte_kni_init() first"
120 It is possible to test PMD quickly using KNI kernel module loopback feature:
122 * Insert KNI kernel module with loopback support:
124 .. code-block:: console
126 insmod build/kmod/rte_kni.ko lo_mode=lo_mode_fifo_skb
128 * Start testpmd with no physical device but two KNI virtual devices:
130 .. code-block:: console
132 ./testpmd --vdev net_kni0 --vdev net_kni1 -- -i
134 .. code-block:: console
137 Configuring Port 0 (socket 0)
138 KNI: pci: 00:00:00 c580:b8
139 Port 0: 1A:4A:5B:7C:A2:8C
140 Configuring Port 1 (socket 0)
141 KNI: pci: 00:00:00 600:b9
142 Port 1: AE:95:21:07:93:DD
143 Checking link statuses...
144 Port 0 Link Up - speed 10000 Mbps - full-duplex
145 Port 1 Link Up - speed 10000 Mbps - full-duplex
149 * Observe Linux interfaces
151 .. code-block:: console
153 $ ifconfig kni0 && ifconfig kni1
154 kni0: flags=4098<BROADCAST,MULTICAST> mtu 1500
155 ether ae:8e:79:8e:9b:c8 txqueuelen 1000 (Ethernet)
156 RX packets 0 bytes 0 (0.0 B)
157 RX errors 0 dropped 0 overruns 0 frame 0
158 TX packets 0 bytes 0 (0.0 B)
159 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
161 kni1: flags=4098<BROADCAST,MULTICAST> mtu 1500
162 ether 9e:76:43:53:3e:9b txqueuelen 1000 (Ethernet)
163 RX packets 0 bytes 0 (0.0 B)
164 RX errors 0 dropped 0 overruns 0 frame 0
165 TX packets 0 bytes 0 (0.0 B)
166 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
169 * Start forwarding with tx_first:
171 .. code-block:: console
173 testpmd> start tx_first
175 * Quit and check forwarding stats:
177 .. code-block:: console
180 Telling cores to stop...
181 Waiting for lcores to finish...
183 ---------------------- Forward statistics for port 0 ----------------------
184 RX-packets: 35637905 RX-dropped: 0 RX-total: 35637905
185 TX-packets: 35637947 TX-dropped: 0 TX-total: 35637947
186 ----------------------------------------------------------------------------
188 ---------------------- Forward statistics for port 1 ----------------------
189 RX-packets: 35637915 RX-dropped: 0 RX-total: 35637915
190 TX-packets: 35637937 TX-dropped: 0 TX-total: 35637937
191 ----------------------------------------------------------------------------
193 +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
194 RX-packets: 71275820 RX-dropped: 0 RX-total: 71275820
195 TX-packets: 71275884 TX-dropped: 0 TX-total: 71275884
196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++