New upstream version 18.02
[deb_dpdk.git] / doc / guides / howto / virtio_user_as_exceptional_path.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright(c) 2016 Intel Corporation.
3
4 .. _virtio_user_as_excpetional_path:
5
6 Virtio_user as Exceptional Path
7 ===============================
8
9 The virtual device, virtio-user, was originally introduced with vhost-user
10 backend, as a high performance solution for IPC (Inter-Process Communication)
11 and user space container networking.
12
13 Virtio_user with vhost-kernel backend is a solution for exceptional path,
14 such as KNI which exchanges packets with kernel networking stack. This
15 solution is very promising in:
16
17 *   Maintenance
18
19     All kernel modules needed by this solution, vhost and vhost-net (kernel),
20     are upstreamed and extensively used kernel module.
21
22 *   Features
23
24     vhost-net is born to be a networking solution, which has lots of networking
25     related featuers, like multi queue, tso, multi-seg mbuf, etc.
26
27 *   Performance
28
29     similar to KNI, this solution would use one or more kthreads to
30     send/receive packets to/from user space DPDK applications, which has little
31     impact on user space polling thread (except that it might enter into kernel
32     space to wake up those kthreads if necessary).
33
34 The overview of an application using virtio-user as exceptional path is shown
35 in :numref:`figure_virtio_user_as_exceptional_path`.
36
37 .. _figure_virtio_user_as_exceptional_path:
38
39 .. figure:: img/virtio_user_as_exceptional_path.*
40
41    Overview of a DPDK app using virtio-user as excpetional path
42
43
44 Sample Usage
45 ------------
46
47 As a prerequisite, the vhost/vhost-net kernel CONFIG should be chosen before
48 compiling the kernel and those kernel modules should be inserted.
49
50 #.  Compile DPDK and bind a physical NIC to igb_uio/uio_pci_generic/vfio-pci.
51
52     This physical NIC is for communicating with outside.
53
54 #.  Run testpmd.
55
56     .. code-block:: console
57
58         $(testpmd) -l 2-3 -n 4 \
59                 --vdev=virtio_user0,path=/dev/vhost-net,queue_size=1024 \
60                 -- -i --txqflags=0x0 --enable-lro \
61                 --enable-rx-cksum --rxd=1024 --txd=1024
62
63     This command runs testpmd with two ports, one physical NIC to communicate
64     with outside, and one virtio-user to communicate with kernel.
65
66 * ``--enable-lro``
67
68     This is used to negotiate VIRTIO_NET_F_GUEST_TSO4 and
69     VIRTIO_NET_F_GUEST_TSO6 feature so that large packets from kernel can be
70     transmitted to DPDK application and further TSOed by physical NIC.
71
72 * ``--enable-rx-cksum``
73
74     This is used to negotiate VIRTIO_NET_F_GUEST_CSUM so that packets from
75     kernel can be deemed as valid Rx checksumed.
76
77 * ``queue_size``
78
79     256 by default. To avoid shortage of descriptors, we can increase it to 1024.
80
81 * ``queues``
82
83     Number of multi-queues. Each qeueue will be served by a kthread. For example:
84
85     .. code-block:: console
86
87         $(testpmd) -l 2-3 -n 4 \
88                 --vdev=virtio_user0,path=/dev/vhost-net,queues=2,queue_size=1024 \
89                 -- -i --txqflags=0x0 --enable-lro \
90                 --enable-rx-cksum --txq=2 --rxq=2 --rxd=1024 \
91                 --txd=1024
92
93 #. Start testpmd:
94
95     .. code-block:: console
96
97         (testpmd) start
98
99 #.  Configure IP address and start tap:
100
101     .. code-block:: console
102
103         ifconfig tap0 1.1.1.1/24 up
104
105 .. note::
106
107     The tap device will be named tap0, tap1, etc, by kernel.
108
109 Then, all traffic from physical NIC can be forwarded into kernel stack, and all
110 traffic on the tap0 can be sent out from physical NIC.
111
112 Limitations
113 -----------
114
115 This solution is only available on Linux systems.