New upstream version 18.11-rc1
[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 --tx-offloads=0x0000002c --enable-lro \
61                 --txd=1024 --rxd=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 * ``queue_size``
73
74     256 by default. To avoid shortage of descriptors, we can increase it to 1024.
75
76 * ``queues``
77
78     Number of multi-queues. Each qeueue will be served by a kthread. For example:
79
80     .. code-block:: console
81
82         $(testpmd) -l 2-3 -n 4 \
83                 --vdev=virtio_user0,path=/dev/vhost-net,queues=2,queue_size=1024 \
84                 -- -i --tx-offloads=0x0000002c --enable-lro \
85                 --txq=2 --rxq=2 --txd=1024 --rxd=1024
86
87 #. Enable Rx checksum offloads in testpmd:
88
89     .. code-block:: console
90
91         (testpmd) port stop 0
92         (testpmd) port config 0 rx_offload tcp_cksum on
93         (testpmd) port config 0 rx_offload udp_cksum on
94         (testpmd) port start 0
95
96 #. Start testpmd:
97
98     .. code-block:: console
99
100         (testpmd) start
101
102 #.  Configure IP address and start tap:
103
104     .. code-block:: console
105
106         ifconfig tap0 1.1.1.1/24 up
107
108 .. note::
109
110     The tap device will be named tap0, tap1, etc, by kernel.
111
112 Then, all traffic from physical NIC can be forwarded into kernel stack, and all
113 traffic on the tap0 can be sent out from physical NIC.
114
115 Limitations
116 -----------
117
118 This solution is only available on Linux systems.