doc: use SPDX license tag for vhost PMD guide
[dpdk.git] / doc / guides / nics / vhost.rst
1 ..  SPDX-License-Identifier: BSD-3-Clause
2     Copyright(c) 2016 IGEL Co., Ltd.
3
4 Poll Mode Driver that wraps vhost library
5 =========================================
6
7 This PMD is a thin wrapper of the DPDK vhost library.
8 The user can handle virtqueues as one of normal DPDK port.
9
10 Vhost Implementation in DPDK
11 ----------------------------
12
13 Please refer to Chapter "Vhost Library" of *DPDK Programmer's Guide* to know detail of vhost.
14
15 Features and Limitations of vhost PMD
16 -------------------------------------
17
18 Currently, the vhost PMD provides the basic functionality of packet reception, transmission and event handling.
19
20 *   It has multiple queues support.
21
22 *   It supports ``RTE_ETH_EVENT_INTR_LSC`` and ``RTE_ETH_EVENT_QUEUE_STATE`` events.
23
24 *   It supports Port Hotplug functionality.
25
26 *   Don't need to stop RX/TX, when the user wants to stop a guest or a virtio-net driver on guest.
27
28 Vhost PMD arguments
29 -------------------
30
31 The user can specify below arguments in `--vdev` option.
32
33 #.  ``iface``:
34
35     It is used to specify a path to connect to a QEMU virtio-net device.
36
37 #.  ``queues``:
38
39     It is used to specify the number of queues virtio-net device has.
40     (Default: 1)
41
42 #.  ``iommu-support``:
43
44     It is used to enable iommu support in vhost library.
45     (Default: 0 (disabled))
46
47 #.  ``postcopy-support``:
48
49     It is used to enable postcopy live-migration support in vhost library.
50     (Default: 0 (disabled))
51
52 #.  ``tso``:
53
54     It is used to enable tso support in vhost library.
55     (Default: 0 (disabled))
56
57 Vhost PMD event handling
58 ------------------------
59
60 This section describes how to handle vhost PMD events.
61
62 The user can register an event callback handler with ``rte_eth_dev_callback_register()``.
63 The registered callback handler will be invoked with one of below event types.
64
65 #.  ``RTE_ETH_EVENT_INTR_LSC``:
66
67     It means link status of the port was changed.
68
69 #.  ``RTE_ETH_EVENT_QUEUE_STATE``:
70
71     It means some of queue statuses were changed. Call ``rte_eth_vhost_get_queue_event()`` in the callback handler.
72     Because changing multiple statuses may occur only one event, call the function repeatedly as long as it doesn't return negative value.
73
74 Vhost PMD with testpmd application
75 ----------------------------------
76
77 This section demonstrates vhost PMD with testpmd DPDK sample application.
78
79 #.  Launch the testpmd with vhost PMD:
80
81     .. code-block:: console
82
83         ./testpmd -l 0-3 -n 4 --vdev 'net_vhost0,iface=/tmp/sock0,queues=1' -- -i
84
85     Other basic DPDK preparations like hugepage enabling here.
86     Please refer to the *DPDK Getting Started Guide* for detailed instructions.
87
88 #.  Launch the QEMU:
89
90     .. code-block:: console
91
92        qemu-system-x86_64 <snip>
93                    -chardev socket,id=chr0,path=/tmp/sock0 \
94                    -netdev vhost-user,id=net0,chardev=chr0,vhostforce,queues=1 \
95                    -device virtio-net-pci,netdev=net0
96
97     This command attaches one virtio-net device to QEMU guest.
98     After initialization processes between QEMU and DPDK vhost library are done, status of the port will be linked up.