xref: /dpdk/doc/guides/linux_gsg/linux_drivers.rst (revision 5411ef8e29a6b37e51fb725adf3028f665b78549)
15be776dfSFerruh Yigit..  SPDX-License-Identifier: BSD-3-Clause
20db52e66SShahaf Shuler    Copyright(c) 2010-2015 Intel Corporation.
35feecc57SShahaf Shuler    Copyright 2017 Mellanox Technologies, Ltd
40db52e66SShahaf Shuler    All rights reserved.
50db52e66SShahaf Shuler
6c265d586SBruce Richardson.. include:: <isonum.txt>
7c265d586SBruce Richardson
80db52e66SShahaf Shuler.. _linux_gsg_linux_drivers:
90db52e66SShahaf Shuler
100db52e66SShahaf ShulerLinux Drivers
110db52e66SShahaf Shuler=============
120db52e66SShahaf Shuler
130db52e66SShahaf ShulerDifferent PMDs may require different kernel drivers in order to work properly.
149180da67SAnatoly BurakovDepending on the PMD being used, a corresponding kernel driver should be loaded,
159180da67SAnatoly Burakovand network ports should be bound to that driver.
160db52e66SShahaf Shuler
1774673f4bSBruce Richardson.. _linux_gsg_binding_kernel:
1874673f4bSBruce Richardson
1974673f4bSBruce RichardsonBinding and Unbinding Network Ports to/from the Kernel Modules
2074673f4bSBruce Richardson--------------------------------------------------------------
2174673f4bSBruce Richardson
2274673f4bSBruce Richardson.. note::
2374673f4bSBruce Richardson
2474673f4bSBruce Richardson   PMDs which use the bifurcated driver should not be unbound from their kernel drivers.
2574673f4bSBruce Richardson   This section is for PMDs which use the UIO or VFIO drivers.
2674673f4bSBruce Richardson   See :ref:`bifurcated_driver` section for more details.
2774673f4bSBruce Richardson
28465fd836SBruce Richardson.. note::
2974673f4bSBruce Richardson
30465fd836SBruce Richardson   It is recommended that ``vfio-pci`` be used as the kernel module for DPDK-bound ports in all cases.
31465fd836SBruce Richardson   If an IOMMU is unavailable, the ``vfio-pci`` can be used in :ref:`no-iommu<vfio_noiommu>` mode.
32465fd836SBruce Richardson   If, for some reason, vfio is unavailable, then UIO-based modules, ``igb_uio`` and ``uio_pci_generic`` may be used.
33465fd836SBruce Richardson   See section :ref:`uio` for details.
34465fd836SBruce Richardson
35465fd836SBruce RichardsonMost devices require that the hardware to be used by DPDK be unbound from the kernel driver it uses,
36465fd836SBruce Richardsonand instead be bound to the ``vfio-pci`` kernel module before the application is run.
37465fd836SBruce RichardsonFor such PMDs, any network ports or other hardware under Linux* control will be ignored and cannot be used by the application.
38465fd836SBruce Richardson
39465fd836SBruce RichardsonTo bind ports to the ``vfio-pci`` module
4074673f4bSBruce Richardsonfor DPDK use, or to return ports to Linux control,
4174673f4bSBruce Richardsona utility script called ``dpdk-devbind.py`` is provided in the ``usertools`` subdirectory.
4274673f4bSBruce RichardsonThis utility can be used to provide a view of the current state of the network ports on the system,
4374673f4bSBruce Richardsonand to bind and unbind those ports from the different kernel modules,
4474673f4bSBruce Richardsonincluding the VFIO and UIO modules.
4574673f4bSBruce RichardsonThe following are some examples of how the script can be used.
4674673f4bSBruce RichardsonA full description of the script and its parameters can be obtained
4774673f4bSBruce Richardsonby calling the script with the ``--help`` or ``--usage`` options.
4874673f4bSBruce RichardsonNote that the UIO or VFIO kernel modules to be used,
4974673f4bSBruce Richardsonshould be loaded into the kernel before running the ``dpdk-devbind.py`` script.
5074673f4bSBruce Richardson
5144bb0d67SBruce Richardson.. note::
5274673f4bSBruce Richardson
5374673f4bSBruce Richardson   Due to the way VFIO works, there are certain limitations
5474673f4bSBruce Richardson   to which devices can be used with VFIO.
5574673f4bSBruce Richardson   Mainly it comes down to how IOMMU groups work.
5674673f4bSBruce Richardson   Any Virtual Function device can usually be used with VFIO on its own,
5774673f4bSBruce Richardson   but physical devices may require either all ports bound to VFIO,
5874673f4bSBruce Richardson   or some of them bound to VFIO while others not being bound to anything at all.
5974673f4bSBruce Richardson
6074673f4bSBruce Richardson   If your device is behind a PCI-to-PCI bridge,
6174673f4bSBruce Richardson   the bridge will then be part of the IOMMU group in which your device is in.
6274673f4bSBruce Richardson   Therefore, the bridge driver should also be unbound from the bridge PCI device
6374673f4bSBruce Richardson   for VFIO to work with devices behind the bridge.
6474673f4bSBruce Richardson
6544bb0d67SBruce Richardson.. note::
6674673f4bSBruce Richardson
6774673f4bSBruce Richardson   While any user can run the ``dpdk-devbind.py`` script
6874673f4bSBruce Richardson   to view the status of the network ports,
6974673f4bSBruce Richardson   binding or unbinding network ports requires root privileges.
7074673f4bSBruce Richardson
7174673f4bSBruce RichardsonTo see the status of all network ports on the system:
7274673f4bSBruce Richardson
7374673f4bSBruce Richardson.. code-block:: console
7474673f4bSBruce Richardson
7574673f4bSBruce Richardson    ./usertools/dpdk-devbind.py --status
7674673f4bSBruce Richardson
7774673f4bSBruce Richardson    Network devices using DPDK-compatible driver
7874673f4bSBruce Richardson    ============================================
79465fd836SBruce Richardson    0000:82:00.0 '82599EB 10-GbE NIC' drv=vfio-pci unused=ixgbe
80465fd836SBruce Richardson    0000:82:00.1 '82599EB 10-GbE NIC' drv=vfio-pci unused=ixgbe
8174673f4bSBruce Richardson
8274673f4bSBruce Richardson    Network devices using kernel driver
8374673f4bSBruce Richardson    ===================================
84465fd836SBruce Richardson    0000:04:00.0 'I350 1-GbE NIC' if=em0  drv=igb unused=vfio-pci *Active*
85465fd836SBruce Richardson    0000:04:00.1 'I350 1-GbE NIC' if=eth1 drv=igb unused=vfio-pci
86465fd836SBruce Richardson    0000:04:00.2 'I350 1-GbE NIC' if=eth2 drv=igb unused=vfio-pci
87465fd836SBruce Richardson    0000:04:00.3 'I350 1-GbE NIC' if=eth3 drv=igb unused=vfio-pci
8874673f4bSBruce Richardson
8974673f4bSBruce Richardson    Other network devices
9074673f4bSBruce Richardson    =====================
9174673f4bSBruce Richardson    <none>
9274673f4bSBruce Richardson
93465fd836SBruce RichardsonTo bind device ``eth1``,``04:00.1``, to the ``vfio-pci`` driver:
9474673f4bSBruce Richardson
9574673f4bSBruce Richardson.. code-block:: console
9674673f4bSBruce Richardson
97465fd836SBruce Richardson    ./usertools/dpdk-devbind.py --bind=vfio-pci 04:00.1
9874673f4bSBruce Richardson
9974673f4bSBruce Richardsonor, alternatively,
10074673f4bSBruce Richardson
10174673f4bSBruce Richardson.. code-block:: console
10274673f4bSBruce Richardson
103465fd836SBruce Richardson    ./usertools/dpdk-devbind.py --bind=vfio-pci eth1
10474673f4bSBruce Richardson
105465fd836SBruce RichardsonWhen specifying device ids, wildcards can be used for the final part of the address.
106465fd836SBruce RichardsonTo restore device ``82:00.0`` and ``82:00.1`` to their original kernel binding:
10774673f4bSBruce Richardson
10874673f4bSBruce Richardson.. code-block:: console
10974673f4bSBruce Richardson
110465fd836SBruce Richardson    ./usertools/dpdk-devbind.py --bind=ixgbe 82:00.*
11174673f4bSBruce Richardson
1120db52e66SShahaf ShulerVFIO
1130db52e66SShahaf Shuler----
1140db52e66SShahaf Shuler
11557ff39f4SAnatoly BurakovVFIO is a robust and secure driver that relies on IOMMU protection.
1160db52e66SShahaf ShulerTo make use of VFIO, the ``vfio-pci`` module must be loaded:
1170db52e66SShahaf Shuler
1180db52e66SShahaf Shuler.. code-block:: console
1190db52e66SShahaf Shuler
1200db52e66SShahaf Shuler    sudo modprobe vfio-pci
1210db52e66SShahaf Shuler
1229180da67SAnatoly BurakovVFIO kernel is usually present by default in all distributions,
1230db52e66SShahaf Shulerhowever please consult your distributions documentation to make sure that is the case.
1240db52e66SShahaf Shuler
12579603b8cSBruce RichardsonTo make use of full VFIO functionality,
12679603b8cSBruce Richardsonboth kernel and BIOS must support and be configured
12779603b8cSBruce Richardsonto use IO virtualization (such as Intel\ |reg| VT-d).
12879603b8cSBruce Richardson
12979603b8cSBruce Richardson.. note::
13079603b8cSBruce Richardson
13179603b8cSBruce Richardson   In most cases, specifying "iommu=on" as kernel parameter should be enough to
13279603b8cSBruce Richardson   configure the Linux kernel to use IOMMU.
13379603b8cSBruce Richardson
13479603b8cSBruce RichardsonFor proper operation of VFIO when running DPDK applications as a non-privileged user, correct permissions should also be set up.
13579603b8cSBruce RichardsonFor more information, please refer to :ref:`Running_Without_Root_Privileges`.
13679603b8cSBruce Richardson
13779603b8cSBruce Richardson
138a243f085SBruce Richardson.. _vfio_noiommu:
139a243f085SBruce Richardson
140a243f085SBruce RichardsonVFIO no-IOMMU mode
141a243f085SBruce Richardson~~~~~~~~~~~~~~~~~~
142a243f085SBruce Richardson
143a243f085SBruce RichardsonIf there is no IOMMU available on the system, VFIO can still be used,
144a243f085SBruce Richardsonbut it has to be loaded with an additional module parameter:
145a243f085SBruce Richardson
146a243f085SBruce Richardson.. code-block:: console
147a243f085SBruce Richardson
148a243f085SBruce Richardson   modprobe vfio enable_unsafe_noiommu_mode=1
149a243f085SBruce Richardson
150a243f085SBruce RichardsonAlternatively, one can also enable this option in an already loaded kernel module:
151a243f085SBruce Richardson
152a243f085SBruce Richardson.. code-block:: console
153a243f085SBruce Richardson
154a243f085SBruce Richardson   echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
155a243f085SBruce Richardson
156a243f085SBruce RichardsonAfter that, VFIO can be used with hardware devices as usual.
157a243f085SBruce Richardson
158a243f085SBruce Richardson.. note::
159a243f085SBruce Richardson
160a243f085SBruce Richardson   It may be required to unload all VFIO related-modules before probing
161a243f085SBruce Richardson   the module again with ``enable_unsafe_noiommu_mode=1`` parameter.
162a243f085SBruce Richardson
163a243f085SBruce Richardson.. warning::
164a243f085SBruce Richardson
165a243f085SBruce Richardson   Since no-IOMMU mode forgoes IOMMU protection, it is inherently unsafe.
166a243f085SBruce Richardson   That said, it does make it possible for the user
167a243f085SBruce Richardson   to keep the degree of device access and programming that VFIO has,
168a243f085SBruce Richardson   in situations where IOMMU is not available.
169a243f085SBruce Richardson
17079603b8cSBruce RichardsonVFIO Memory Mapping Limits
17179603b8cSBruce Richardson~~~~~~~~~~~~~~~~~~~~~~~~~~~
17279603b8cSBruce Richardson
173016763c2SNithin DabilpuramFor DMA mapping of either external memory or hugepages, VFIO interface is used.
174016763c2SNithin DabilpuramVFIO does not support partial unmap of once mapped memory. Hence DPDK's memory is
175016763c2SNithin Dabilpurammapped in hugepage granularity or system page granularity. Number of DMA
176016763c2SNithin Dabilpurammappings is limited by kernel with user locked memory limit of a process (rlimit)
177016763c2SNithin Dabilpuramfor system/hugepage memory. Another per-container overall limit applicable both
178016763c2SNithin Dabilpuramfor external memory and system memory was added in kernel 5.1 defined by
179016763c2SNithin DabilpuramVFIO module parameter ``dma_entry_limit`` with a default value of 64K.
180016763c2SNithin DabilpuramWhen application is out of DMA entries, these limits need to be adjusted to
181016763c2SNithin Dabilpuramincrease the allowed limit.
182016763c2SNithin Dabilpuram
183*5411ef8eSNipun GuptaWhen ``--no-huge`` option is used,
184*5411ef8eSNipun Guptathe page size used is of smaller size of ``4K`` or ``64K``
185*5411ef8eSNipun Guptaand we shall need to increase ``dma_entry_limit``.
186*5411ef8eSNipun Gupta
187*5411ef8eSNipun GuptaTo update the ``dma_entry_limit``,
188*5411ef8eSNipun Gupta``vfio_iommu_type1`` has to be loaded with additional module parameter:
189*5411ef8eSNipun Gupta
190*5411ef8eSNipun Gupta.. code-block:: console
191*5411ef8eSNipun Gupta
192*5411ef8eSNipun Gupta   modprobe vfio_iommu_type1 dma_entry_limit=512000
193*5411ef8eSNipun Gupta
194*5411ef8eSNipun GuptaAlternatively, one can also change this value in an already loaded kernel module:
195*5411ef8eSNipun Gupta
196*5411ef8eSNipun Gupta.. code-block:: console
197*5411ef8eSNipun Gupta
198*5411ef8eSNipun Gupta   echo 512000 > /sys/module/vfio_iommu_type1/parameters/dma_entry_limit
199*5411ef8eSNipun Gupta
20079603b8cSBruce RichardsonCreating Virtual Functions using vfio-pci
20179603b8cSBruce Richardson~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20279603b8cSBruce Richardson
2039180da67SAnatoly BurakovSince Linux version 5.7,
2049180da67SAnatoly Burakovthe ``vfio-pci`` module supports the creation of virtual functions.
2059180da67SAnatoly BurakovAfter the PF is bound to ``vfio-pci`` module,
2069180da67SAnatoly Burakovthe user can create the VFs using the ``sysfs`` interface,
2079180da67SAnatoly Burakovand these VFs will be bound to ``vfio-pci`` module automatically.
208598be723SHaiyue Wang
2099180da67SAnatoly BurakovWhen the PF is bound to ``vfio-pci``,
2109180da67SAnatoly Burakovby default it will have a randomly generated VF token.
2119180da67SAnatoly BurakovFor security reasons, this token is write only,
2129180da67SAnatoly Burakovso the user cannot read it from the kernel directly.
2139180da67SAnatoly BurakovTo access the VFs, the user needs to create a new token,
2149180da67SAnatoly Burakovand use it to initialize both VF and PF devices.
2159180da67SAnatoly BurakovThe tokens are in UUID format,
2169180da67SAnatoly Burakovso any UUID generation tool can be used to create a new token.
217598be723SHaiyue Wang
2189180da67SAnatoly BurakovThis VF token can be passed to DPDK by using EAL parameter ``--vfio-vf-token``.
2199180da67SAnatoly BurakovThe token will be used for all PF and VF ports within the application.
2209180da67SAnatoly Burakov
2219180da67SAnatoly Burakov#. Generate the VF token by uuid command
222598be723SHaiyue Wang
223598be723SHaiyue Wang   .. code-block:: console
224598be723SHaiyue Wang
225598be723SHaiyue Wang      14d63f20-8445-11ea-8900-1f9ce7d5650d
226598be723SHaiyue Wang
2279180da67SAnatoly Burakov#. Load the ``vfio-pci`` module with ``enable_sriov`` parameter set
228598be723SHaiyue Wang
2299180da67SAnatoly Burakov   .. code-block:: console
230598be723SHaiyue Wang
2319180da67SAnatoly Burakov      sudo modprobe vfio-pci enable_sriov=1
232598be723SHaiyue Wang
233efb57dd5SAnatoly Burakov   Alternatively, pass the ``enable_sriov`` parameter through the ``sysfs`` if the module is already loaded or is built-in:
234efb57dd5SAnatoly Burakov
235efb57dd5SAnatoly Burakov   .. code-block:: console
236efb57dd5SAnatoly Burakov
237efb57dd5SAnatoly Burakov      echo 1 | sudo tee /sys/module/vfio_pci/parameters/enable_sriov
238efb57dd5SAnatoly Burakov
2399180da67SAnatoly Burakov#. Bind the PCI devices to ``vfio-pci`` driver
2409180da67SAnatoly Burakov
2419180da67SAnatoly Burakov   .. code-block:: console
2429180da67SAnatoly Burakov
2439180da67SAnatoly Burakov      ./usertools/dpdk-devbind.py -b vfio-pci 0000:86:00.0
2449180da67SAnatoly Burakov
2459180da67SAnatoly Burakov#. Create the desired number of VF devices
2469180da67SAnatoly Burakov
2479180da67SAnatoly Burakov   .. code-block:: console
2489180da67SAnatoly Burakov
2499180da67SAnatoly Burakov      echo 2 > /sys/bus/pci/devices/0000:86:00.0/sriov_numvfs
2509180da67SAnatoly Burakov
2519180da67SAnatoly Burakov#. Start the DPDK application that will manage the PF device
2529180da67SAnatoly Burakov
2539180da67SAnatoly Burakov   .. code-block:: console
2549180da67SAnatoly Burakov
255db27370bSStephen Hemminger      <build_dir>/app/dpdk-testpmd -l 22-25 -n 4 -a 86:00.0 \
256598be723SHaiyue Wang      --vfio-vf-token=14d63f20-8445-11ea-8900-1f9ce7d5650d --file-prefix=pf -- -i
257598be723SHaiyue Wang
2589180da67SAnatoly Burakov#. Start the DPDK application that will manage the VF device
2599180da67SAnatoly Burakov
2609180da67SAnatoly Burakov   .. code-block:: console
2619180da67SAnatoly Burakov
262db27370bSStephen Hemminger      <build_dir>/app/dpdk-testpmd -l 26-29 -n 4 -a 86:02.0 \
263598be723SHaiyue Wang      --vfio-vf-token=14d63f20-8445-11ea-8900-1f9ce7d5650d --file-prefix=vf0 -- -i
264598be723SHaiyue Wang
2659180da67SAnatoly Burakov.. note::
2669180da67SAnatoly Burakov
2679180da67SAnatoly Burakov   Linux versions earlier than version 5.7 do not support the creation of
2689180da67SAnatoly Burakov   virtual functions within the VFIO framework.
2699180da67SAnatoly Burakov
2708a8979c9SAnatoly BurakovTroubleshooting VFIO
271a243f085SBruce Richardson~~~~~~~~~~~~~~~~~~~~
2728a8979c9SAnatoly Burakov
2738a8979c9SAnatoly BurakovIn certain situations, using ``dpdk-devbind.py`` script
2748a8979c9SAnatoly Burakovto bind a device to VFIO driver may fail.
2758a8979c9SAnatoly BurakovThe first place to check is the kernel messages:
2768a8979c9SAnatoly Burakov
2778a8979c9SAnatoly Burakov.. code-block:: console
2788a8979c9SAnatoly Burakov
2798a8979c9SAnatoly Burakov   dmesg | tail
2808a8979c9SAnatoly Burakov   ...
2818a8979c9SAnatoly Burakov   [ 1297.875090] vfio-pci: probe of 0000:31:00.0 failed with error -22
2828a8979c9SAnatoly Burakov   ...
2838a8979c9SAnatoly Burakov
2848a8979c9SAnatoly BurakovIn most cases, the ``error -22`` indicates that the VFIO subsystem
2858a8979c9SAnatoly Burakovcould not be enabled because there is no IOMMU support.
2868a8979c9SAnatoly Burakov
2878a8979c9SAnatoly BurakovTo check whether the kernel has been booted with correct parameters,
2888a8979c9SAnatoly Burakovone can check the kernel command-line:
2898a8979c9SAnatoly Burakov
2908a8979c9SAnatoly Burakov.. code-block:: console
2918a8979c9SAnatoly Burakov
2928a8979c9SAnatoly Burakov   cat /proc/cmdline
2938a8979c9SAnatoly Burakov
2948a8979c9SAnatoly BurakovPlease refer to earlier sections on how to configure kernel parameters
2958a8979c9SAnatoly Burakovcorrectly for your system.
2968a8979c9SAnatoly Burakov
2978a8979c9SAnatoly BurakovIf the kernel is configured correctly, one also has to make sure that
298c265d586SBruce Richardsonthe BIOS configuration has virtualization features (such as Intel\ |reg| VT-d).
2998a8979c9SAnatoly BurakovThere is no standard way to check if the platform is configured correctly,
3008a8979c9SAnatoly Burakovso please check with your platform documentation to see if it has such features,
3018a8979c9SAnatoly Burakovand how to enable them.
3028a8979c9SAnatoly Burakov
3038a8979c9SAnatoly BurakovIn certain distributions, default kernel configuration is such that
3048a8979c9SAnatoly Burakovthe no-IOMMU mode is disabled altogether at compile time.
3058a8979c9SAnatoly BurakovThis can be checked in the boot configuration of your system:
3068a8979c9SAnatoly Burakov
3078a8979c9SAnatoly Burakov.. code-block:: console
3088a8979c9SAnatoly Burakov
3098a8979c9SAnatoly Burakov   cat /boot/config-$(uname -r) | grep NOIOMMU
3108a8979c9SAnatoly Burakov   # CONFIG_VFIO_NOIOMMU is not set
3118a8979c9SAnatoly Burakov
3128a8979c9SAnatoly BurakovIf ``CONFIG_VFIO_NOIOMMU`` is not enabled in the kernel configuration,
3138a8979c9SAnatoly BurakovVFIO driver will not support the no-IOMMU mode,
3148a8979c9SAnatoly Burakovand other alternatives (such as UIO drivers) will have to be used.
315e077832eSBruce Richardson
31617c839f7STomasz DuszynskiVFIO Platform
31717c839f7STomasz Duszynski-------------
31817c839f7STomasz Duszynski
31917c839f7STomasz DuszynskiVFIO Platform is a kernel driver that extends capabilities of VFIO
32017c839f7STomasz Duszynskiby adding support for platform devices that reside behind an IOMMU.
32117c839f7STomasz DuszynskiLinux usually learns about platform devices directly from device tree
32217c839f7STomasz Duszynskiduring boot-up phase,
32317c839f7STomasz Duszynskiunlike for example, PCI devices which have necessary information built-in.
32417c839f7STomasz Duszynski
32517c839f7STomasz DuszynskiTo make use of VFIO platform, the ``vfio-platform`` module must be loaded first:
32617c839f7STomasz Duszynski
32717c839f7STomasz Duszynski.. code-block:: console
32817c839f7STomasz Duszynski
32917c839f7STomasz Duszynski   sudo modprobe vfio-platform
33017c839f7STomasz Duszynski
33117c839f7STomasz Duszynski.. note::
33217c839f7STomasz Duszynski
33317c839f7STomasz Duszynski   By default ``vfio-platform`` assumes that platform device has dedicated reset driver.
33417c839f7STomasz Duszynski   If such driver is missing or device does not require one,
33517c839f7STomasz Duszynski   this option can be turned off by setting ``reset_required=0`` module parameter.
33617c839f7STomasz Duszynski
33717c839f7STomasz DuszynskiAfterwards platform device needs to be bound to ``vfio-platform``.
33817c839f7STomasz DuszynskiThis is standard procedure requiring two steps.
33917c839f7STomasz DuszynskiFirst ``driver_override``, which is available inside platform device directory,
34017c839f7STomasz Duszynskineeds to be set to ``vfio-platform``:
34117c839f7STomasz Duszynski
34217c839f7STomasz Duszynski.. code-block:: console
34317c839f7STomasz Duszynski
34417c839f7STomasz Duszynski   sudo echo vfio-platform > /sys/bus/platform/devices/DEV/driver_override
34517c839f7STomasz Duszynski
34617c839f7STomasz DuszynskiNext ``DEV`` device must be bound to ``vfio-platform`` driver:
34717c839f7STomasz Duszynski
34817c839f7STomasz Duszynski.. code-block:: console
34917c839f7STomasz Duszynski
35017c839f7STomasz Duszynski   sudo echo DEV > /sys/bus/platform/drivers/vfio-platform/bind
35117c839f7STomasz Duszynski
35217c839f7STomasz DuszynskiOn application startup, DPDK platform bus driver scans ``/sys/bus/platform/devices``
35317c839f7STomasz Duszynskisearching for devices that have ``driver`` symbolic link
35417c839f7STomasz Duszynskipointing to ``vfio-platform`` driver.
35517c839f7STomasz DuszynskiFinally, scanned devices are matched against available PMDs.
35617c839f7STomasz DuszynskiMatching is successful if either PMD name or PMD alias matches kernel driver name
35717c839f7STomasz Duszynskior PMD name matches platform device name, all in that order.
35817c839f7STomasz Duszynski
35917c839f7STomasz DuszynskiVFIO Platform depends on ARM/ARM64 and is usually enabled on distributions
36017c839f7STomasz Duszynskirunning on these systems.
36117c839f7STomasz DuszynskiConsult your distributions documentation to make sure that is the case.
36217c839f7STomasz Duszynski
36317c839f7STomasz Duszynski
364a243f085SBruce Richardson.. _bifurcated_driver:
365a243f085SBruce Richardson
366a243f085SBruce RichardsonBifurcated Driver
367a243f085SBruce Richardson-----------------
368a243f085SBruce Richardson
369a243f085SBruce RichardsonPMDs which use the bifurcated driver co-exists with the device kernel driver.
370a243f085SBruce RichardsonOn such model the NIC is controlled by the kernel, while the data
371a243f085SBruce Richardsonpath is performed by the PMD directly on top of the device.
372a243f085SBruce Richardson
373a243f085SBruce RichardsonSuch model has the following benefits:
374a243f085SBruce Richardson
375a243f085SBruce Richardson - It is secure and robust, as the memory management and isolation
376a243f085SBruce Richardson   is done by the kernel.
377a243f085SBruce Richardson - It enables the user to use legacy linux tools such as ``ethtool`` or
378a243f085SBruce Richardson   ``ifconfig`` while running DPDK application on the same network ports.
379a243f085SBruce Richardson - It enables the DPDK application to filter only part of the traffic,
380a243f085SBruce Richardson   while the rest will be directed and handled by the kernel driver.
381a243f085SBruce Richardson   The flow bifurcation is performed by the NIC hardware.
382a243f085SBruce Richardson   As an example, using :ref:`flow_isolated_mode` allows to choose
383a243f085SBruce Richardson   strictly what is received in DPDK.
384a243f085SBruce Richardson
385a243f085SBruce RichardsonMore about the bifurcated driver can be found in
3860f91f952SThomas MonjalonNVIDIA `bifurcated PMD
3870f91f952SThomas Monjalon<https://www.dpdk.org/wp-content/uploads/sites/35/2016/10/Day02-Session04-RonyEfraim-Userspace2016.pdf>`_ presentation.
388a243f085SBruce Richardson
389e077832eSBruce Richardson.. _uio:
390e077832eSBruce Richardson
391e077832eSBruce RichardsonUIO
392e077832eSBruce Richardson---
393e077832eSBruce Richardson
394e077832eSBruce Richardson.. warning::
395e077832eSBruce Richardson
396e077832eSBruce Richardson   Using UIO drivers is inherently unsafe due to this method lacking IOMMU protection,
397e077832eSBruce Richardson   and can only be done by root user.
398e077832eSBruce Richardson
399e077832eSBruce RichardsonIn situations where using VFIO is not an option, there are alternative drivers one can use.
400e077832eSBruce RichardsonIn many cases, the standard ``uio_pci_generic`` module included in the Linux kernel
401e077832eSBruce Richardsoncan be used as a substitute for VFIO. This module can be loaded using the command:
402e077832eSBruce Richardson
403e077832eSBruce Richardson.. code-block:: console
404e077832eSBruce Richardson
405e077832eSBruce Richardson   sudo modprobe uio_pci_generic
406e077832eSBruce Richardson
407e077832eSBruce Richardson.. note::
408e077832eSBruce Richardson
409e077832eSBruce Richardson   ``uio_pci_generic`` module doesn't support the creation of virtual functions.
410e077832eSBruce Richardson
411e077832eSBruce RichardsonAs an alternative to the ``uio_pci_generic``, there is the ``igb_uio`` module
412e077832eSBruce Richardsonwhich can be found in the repository `dpdk-kmods <http://git.dpdk.org/dpdk-kmods>`_.
413e077832eSBruce RichardsonIt can be loaded as shown below:
414e077832eSBruce Richardson
415e077832eSBruce Richardson.. code-block:: console
416e077832eSBruce Richardson
417e077832eSBruce Richardson   sudo modprobe uio
418e077832eSBruce Richardson   sudo insmod igb_uio.ko
419e077832eSBruce Richardson
420e077832eSBruce Richardson.. note::
421e077832eSBruce Richardson
422e077832eSBruce Richardson    For some devices which lack support for legacy interrupts, e.g. virtual function
423e077832eSBruce Richardson    (VF) devices, the ``igb_uio`` module may be needed in place of ``uio_pci_generic``.
424e077832eSBruce Richardson
425e077832eSBruce Richardson.. note::
426e077832eSBruce Richardson
427e077832eSBruce Richardson   If UEFI secure boot is enabled,
428e077832eSBruce Richardson   the Linux kernel may disallow the use of UIO on the system.
429e077832eSBruce Richardson   Therefore, devices for use by DPDK should be bound to the ``vfio-pci`` kernel module
430e077832eSBruce Richardson   rather than any UIO-based module.
431e077832eSBruce Richardson   For more details see :ref:`linux_gsg_binding_kernel` below.
432e077832eSBruce Richardson
433e077832eSBruce Richardson.. note::
434e077832eSBruce Richardson
435e077832eSBruce Richardson   If the devices used for DPDK are bound to a UIO-based kernel module,
436e077832eSBruce Richardson   please make sure that the IOMMU is disabled or is in passthrough mode.
437e077832eSBruce Richardson   One can add ``intel_iommu=off`` or ``amd_iommu=off`` or ``intel_iommu=on iommu=pt``
438e077832eSBruce Richardson   in GRUB command line on x86_64 systems,
439e077832eSBruce Richardson   or add ``iommu.passthrough=1`` on aarch64 systems.
440