2 Copyright(c) 2016 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 .. _virtio_user_as_excpetional_path:
33 Virtio_user as Exceptional Path
34 ===============================
36 The virtual device, virtio-user, was originally introduced with vhost-user
37 backend, as a high performance solution for IPC (Inter-Process Communication)
38 and user space container networking.
40 Virtio_user with vhost-kernel backend is a solution for exceptional path,
41 such as KNI which exchanges packets with kernel networking stack. This
42 solution is very promising in:
46 All kernel modules needed by this solution, vhost and vhost-net (kernel),
47 are upstreamed and extensively used kernel module.
51 vhost-net is born to be a networking solution, which has lots of networking
52 related featuers, like multi queue, tso, multi-seg mbuf, etc.
56 similar to KNI, this solution would use one or more kthreads to
57 send/receive packets to/from user space DPDK applications, which has little
58 impact on user space polling thread (except that it might enter into kernel
59 space to wake up those kthreads if necessary).
61 The overview of an application using virtio-user as exceptional path is shown
62 in :numref:`figure_virtio_user_as_exceptional_path`.
64 .. _figure_virtio_user_as_exceptional_path:
66 .. figure:: img/virtio_user_as_exceptional_path.*
68 Overview of a DPDK app using virtio-user as excpetional path
74 As a prerequisite, the vhost/vhost-net kernel CONFIG should be chosen before
75 compiling the kernel and those kernel modules should be inserted.
77 #. Compile DPDK and bind a physical NIC to igb_uio/uio_pci_generic/vfio-pci.
79 This physical NIC is for communicating with outside.
83 .. code-block:: console
85 $(testpmd) -l 2-3 -n 4 \
86 --vdev=virtio_user0,path=/dev/vhost-net,queue_size=1024 \
87 -- -i --txqflags=0x0 --disable-hw-vlan --enable-lro \
88 --enable-rx-cksum --rxd=1024 --txd=1024
90 This command runs testpmd with two ports, one physical NIC to communicate
91 with outside, and one virtio-user to communicate with kernel.
95 This is used to negotiate VIRTIO_NET_F_GUEST_TSO4 and
96 VIRTIO_NET_F_GUEST_TSO6 feature so that large packets from kernel can be
97 transmitted to DPDK application and further TSOed by physical NIC.
99 * ``--enable-rx-cksum``
101 This is used to negotiate VIRTIO_NET_F_GUEST_CSUM so that packets from
102 kernel can be deemed as valid Rx checksumed.
106 256 by default. To avoid shortage of descriptors, we can increase it to 1024.
110 Number of multi-queues. Each qeueue will be served by a kthread. For example:
112 .. code-block:: console
114 $(testpmd) -l 2-3 -n 4 \
115 --vdev=virtio_user0,path=/dev/vhost-net,queues=2,queue_size=1024 \
116 -- -i --txqflags=0x0 --disable-hw-vlan --enable-lro \
117 --enable-rx-cksum --txq=2 --rxq=2 --rxd=1024 \
122 .. code-block:: console
126 #. Configure IP address and start tap:
128 .. code-block:: console
130 ifconfig tap0 1.1.1.1/24 up
134 The tap device will be named tap0, tap1, etc, by kernel.
136 Then, all traffic from physical NIC can be forwarded into kernel stack, and all
137 traffic on the tap0 can be sent out from physical NIC.
142 This solution is only available on Linux systems.