0bbcd3fd9a31cfb5a40b1e15ea7f8e8b1c5d4b49
[deb_dpdk.git] / doc / guides / howto / virtio_user_as_exceptional_path.rst
1 ..  BSD LICENSE
2     Copyright(c) 2016 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 .. _virtio_user_as_excpetional_path:
32
33 Virtio_user as Exceptional Path
34 ===============================
35
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.
39
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:
43
44 *   Maintenance
45
46     All kernel modules needed by this solution, vhost and vhost-net (kernel),
47     are upstreamed and extensively used kernel module.
48
49 *   Features
50
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.
53
54 *   Performance
55
56     similar to KNI, this solution would use one or more kthreads to
57     send/receive packets 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).
60
61 The overview of an application using virtio-user as exceptional path is shown
62 in :numref:`figure_virtio_user_as_exceptional_path`.
63
64 .. _figure_virtio_user_as_exceptional_path:
65
66 .. figure:: img/virtio_user_as_exceptional_path.*
67
68    Overview of a DPDK app using virtio-user as excpetional path
69
70
71 Sample Usage
72 ------------
73
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.
76
77 #.  Compile DPDK and bind a physical NIC to igb_uio/uio_pci_generic/vfio-pci.
78
79     This physical NIC is for communicating with outside.
80
81 #.  Run testpmd.
82
83     .. code-block:: console
84
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
89
90     This command runs testpmd with two ports, one physical NIC to communicate
91     with outside, and one virtio-user to communicate with kernel.
92
93 * ``--enable-lro``
94
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 DPDK application and further TSOed by physical NIC.
98
99 * ``--enable-rx-cksum``
100
101     This is used to negotiate VIRTIO_NET_F_GUEST_CSUM so that packets from
102     kernel can be deemed as valid Rx checksumed.
103
104 * ``queue_size``
105
106     256 by default. To avoid shortage of descriptors, we can increase it to 1024.
107
108 * ``queues``
109
110     Number of multi-queues. Each qeueue will be served by a kthread. For example:
111
112     .. code-block:: console
113
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 \
118                 --txd=1024
119
120 #. Start testpmd:
121
122     .. code-block:: console
123
124         (testpmd) start
125
126 #.  Configure IP address and start tap:
127
128     .. code-block:: console
129
130         ifconfig tap0 1.1.1.1/24 up
131
132 .. note::
133
134     The tap device will be named tap0, tap1, etc, by kernel.
135
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.
138
139 Limitations
140 -----------
141
142 This solution is only available on Linux systems.