2 Copyright(c) 2010-2015 Intel Corporation.
3 Copyright(c) 2017 Mellanox Corporation.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
16 * Neither the name of Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived
18 from this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 .. _linux_gsg_linux_drivers:
37 Different PMDs may require different kernel drivers in order to work properly.
38 Depends on the PMD being used, a corresponding kernel driver should be load
39 and bind to the network ports.
44 A small kernel module to set up the device, map device memory to user-space and register interrupts.
45 In many cases, the standard ``uio_pci_generic`` module included in the Linux kernel
46 can provide the uio capability. This module can be loaded using the command:
48 .. code-block:: console
50 sudo modprobe uio_pci_generic
54 ``uio_pci_generic`` module doesn't support the creation of virtual functions.
56 As an alternative to the ``uio_pci_generic``, the DPDK also includes the igb_uio
57 module which can be found in the kmod subdirectory referred to above. It can
58 be loaded as shown below:
60 .. code-block:: console
63 sudo insmod kmod/igb_uio.ko
67 For some devices which lack support for legacy interrupts, e.g. virtual function
68 (VF) devices, the ``igb_uio`` module may be needed in place of ``uio_pci_generic``.
70 Since DPDK release 1.7 onward provides VFIO support, use of UIO is optional
71 for platforms that support using VFIO.
76 A more robust and secure driver in compare to the ``UIO``, relying on IOMMU protection.
77 To make use of VFIO, the ``vfio-pci`` module must be loaded:
79 .. code-block:: console
81 sudo modprobe vfio-pci
83 Note that in order to use VFIO, your kernel must support it.
84 VFIO kernel modules have been included in the Linux kernel since version 3.6.0 and are usually present by default,
85 however please consult your distributions documentation to make sure that is the case.
87 Also, to use VFIO, both kernel and BIOS must support and be configured to use IO virtualization (such as IntelĀ® VT-d).
91 ``vfio-pci`` module doesn't support the creation of virtual functions.
93 For proper operation of VFIO when running DPDK applications as a non-privileged user, correct permissions should also be set up.
94 This can be done by using the DPDK setup script (called dpdk-setup.sh and located in the usertools directory).
98 VFIO can be used without IOMMU. While this is just as unsafe as using UIO, it does make it possible for the user to keep the degree of device access and programming that VFIO has, in situations where IOMMU is not available.
103 PMDs which use the bifurcated driver co-exists with the device kernel driver.
104 On such model the NIC is controlled by the kernel, while the data
105 path is performed by the PMD directly on top of the device.
107 Such model has the following benefits:
109 - It is secure and robust, as the memory management and isolation
110 is done by the kernel.
111 - It enables the user to use legacy linux tools such as ``ethtool`` or
112 ``ifconfig`` while running DPDK application on the same network ports.
113 - It enables the DPDK application to filter only part of the traffic,
114 While the rest will be directed and handled by the kernel driver.
116 More about the bifurcated driver can be found in
117 `Mellanox Bifurcated DPDK PMD
118 <https://dpdksummit.com/Archive/pdf/2016Userspace/Day02-Session04-RonyEfraim-Userspace2016.pdf>`__.
120 .. _linux_gsg_binding_kernel:
122 Binding and Unbinding Network Ports to/from the Kernel Modules
123 --------------------------------------------------------------
127 PMDs Which use the bifurcated driver should not be unbind from their kernel drivers. this section is for PMDs which use the UIO or VFIO drivers.
129 As of release 1.4, DPDK applications no longer automatically unbind all supported network ports from the kernel driver in use.
130 Instead, in case the PMD being used use the UIO or VFIO drivers, all ports that are to be used by an DPDK application must be bound to the
131 ``uio_pci_generic``, ``igb_uio`` or ``vfio-pci`` module before the application is run.
132 For such PMDs, any network ports under Linux* control will be ignored and cannot be used by the application.
134 To bind ports to the ``uio_pci_generic``, ``igb_uio`` or ``vfio-pci`` module for DPDK use,
135 and then subsequently return ports to Linux* control,
136 a utility script called dpdk-devbind.py is provided in the usertools subdirectory.
137 This utility can be used to provide a view of the current state of the network ports on the system,
138 and to bind and unbind those ports from the different kernel modules, including the uio and vfio modules.
139 The following are some examples of how the script can be used.
140 A full description of the script and its parameters can be obtained by calling the script with the ``--help`` or ``--usage`` options.
141 Note that the uio or vfio kernel modules to be used, should be loaded into the kernel before
142 running the ``dpdk-devbind.py`` script.
146 Due to the way VFIO works, there are certain limitations to which devices can be used with VFIO.
147 Mainly it comes down to how IOMMU groups work.
148 Any Virtual Function device can be used with VFIO on its own, but physical devices will require either all ports bound to VFIO,
149 or some of them bound to VFIO while others not being bound to anything at all.
151 If your device is behind a PCI-to-PCI bridge, the bridge will then be part of the IOMMU group in which your device is in.
152 Therefore, the bridge driver should also be unbound from the bridge PCI device for VFIO to work with devices behind the bridge.
156 While any user can run the dpdk-devbind.py script to view the status of the network ports,
157 binding or unbinding network ports requires root privileges.
159 To see the status of all network ports on the system:
161 .. code-block:: console
163 ./usertools/dpdk-devbind.py --status
165 Network devices using DPDK-compatible driver
166 ============================================
167 0000:82:00.0 '82599EB 10-GbE NIC' drv=uio_pci_generic unused=ixgbe
168 0000:82:00.1 '82599EB 10-GbE NIC' drv=uio_pci_generic unused=ixgbe
170 Network devices using kernel driver
171 ===================================
172 0000:04:00.0 'I350 1-GbE NIC' if=em0 drv=igb unused=uio_pci_generic *Active*
173 0000:04:00.1 'I350 1-GbE NIC' if=eth1 drv=igb unused=uio_pci_generic
174 0000:04:00.2 'I350 1-GbE NIC' if=eth2 drv=igb unused=uio_pci_generic
175 0000:04:00.3 'I350 1-GbE NIC' if=eth3 drv=igb unused=uio_pci_generic
177 Other network devices
178 =====================
181 To bind device ``eth1``,``04:00.1``, to the ``uio_pci_generic`` driver:
183 .. code-block:: console
185 ./usertools/dpdk-devbind.py --bind=uio_pci_generic 04:00.1
189 .. code-block:: console
191 ./usertools/dpdk-devbind.py --bind=uio_pci_generic eth1
193 To restore device ``82:00.0`` to its original kernel binding:
195 .. code-block:: console
197 ./usertools/dpdk-devbind.py --bind=ixgbe 82:00.0