xref: /dpdk/doc/guides/tools/devbind.rst (revision ad709fa90178579e8533537f70c6a71ffe08a753)
1cc778567SHemant Agrawal..  SPDX-License-Identifier: BSD-3-Clause
29d3ad924SChristian Ehrhardt    Copyright(c) 2016 Canonical Limited. All rights reserved.
39d3ad924SChristian Ehrhardt
49d3ad924SChristian Ehrhardtdpdk-devbind Application
59d3ad924SChristian Ehrhardt========================
69d3ad924SChristian Ehrhardt
79d3ad924SChristian EhrhardtThe ``dpdk-devbind`` tool is a Data Plane Development Kit (DPDK) utility
89d3ad924SChristian Ehrhardtthat helps binding and unbinding devices from specific drivers.
99d3ad924SChristian EhrhardtAs well as checking their status in that regard.
109d3ad924SChristian Ehrhardt
119d3ad924SChristian Ehrhardt
129d3ad924SChristian EhrhardtRunning the Application
139d3ad924SChristian Ehrhardt-----------------------
149d3ad924SChristian Ehrhardt
159d3ad924SChristian EhrhardtThe tool has a number of command line options:
169d3ad924SChristian Ehrhardt
179d3ad924SChristian Ehrhardt.. code-block:: console
189d3ad924SChristian Ehrhardt
199d3ad924SChristian Ehrhardt   dpdk-devbind [options] DEVICE1 DEVICE2 ....
209d3ad924SChristian Ehrhardt
219d3ad924SChristian EhrhardtOPTIONS
229d3ad924SChristian Ehrhardt-------
239d3ad924SChristian Ehrhardt
249d3ad924SChristian Ehrhardt* ``--help, --usage``
259d3ad924SChristian Ehrhardt
269d3ad924SChristian Ehrhardt        Display usage information and quit
279d3ad924SChristian Ehrhardt
289d3ad924SChristian Ehrhardt* ``-s, --status``
299d3ad924SChristian Ehrhardt
309d3ad924SChristian Ehrhardt        Print the current status of all known network interfaces.
319d3ad924SChristian Ehrhardt        For each device, it displays the PCI domain, bus, slot and function,
329d3ad924SChristian Ehrhardt        along with a text description of the device. Depending upon whether the
33*ad709fa9SStephen Hemminger        device is being used by a kernel driver, the ``vfio-pci`` driver, or no
349d3ad924SChristian Ehrhardt        driver, other relevant information will be displayed:
359d3ad924SChristian Ehrhardt        - the Linux interface name e.g. ``if=eth0``
36*ad709fa9SStephen Hemminger        - the driver being used e.g. ``drv=vfio-pci``
37*ad709fa9SStephen Hemminger        - any suitable drivers not currently using that device e.g. ``unused=vfio-pci``
389d3ad924SChristian Ehrhardt        NOTE: if this flag is passed along with a bind/unbind option, the
399d3ad924SChristian Ehrhardt        status display will always occur after the other operations have taken
409d3ad924SChristian Ehrhardt        place.
419d3ad924SChristian Ehrhardt
429d3ad924SChristian Ehrhardt* ``-b driver, --bind=driver``
439d3ad924SChristian Ehrhardt
449d3ad924SChristian Ehrhardt        Select the driver to use or "none" to unbind the device
459d3ad924SChristian Ehrhardt
469d3ad924SChristian Ehrhardt* ``-u, --unbind``
479d3ad924SChristian Ehrhardt
489d3ad924SChristian Ehrhardt        Unbind a device (Equivalent to ``-b none``)
499d3ad924SChristian Ehrhardt
509d3ad924SChristian Ehrhardt* ``--force``
519d3ad924SChristian Ehrhardt
529d3ad924SChristian Ehrhardt        By default, devices which are used by Linux - as indicated by having
539d3ad924SChristian Ehrhardt        routes in the routing table - cannot be modified. Using the ``--force``
549d3ad924SChristian Ehrhardt        flag overrides this behavior, allowing active links to be forcibly
559d3ad924SChristian Ehrhardt        unbound.
569d3ad924SChristian Ehrhardt        WARNING: This can lead to loss of network connection and should be used
579d3ad924SChristian Ehrhardt        with caution.
589d3ad924SChristian Ehrhardt
599d3ad924SChristian Ehrhardt
609d3ad924SChristian Ehrhardt.. warning::
619d3ad924SChristian Ehrhardt
629d3ad924SChristian Ehrhardt    Due to the way VFIO works, there are certain limitations to which devices can be used with VFIO.
639d3ad924SChristian Ehrhardt    Mainly it comes down to how IOMMU groups work.
649d3ad924SChristian Ehrhardt    Any Virtual Function device can be used with VFIO on its own, but physical devices will require either all ports bound to VFIO,
659d3ad924SChristian Ehrhardt    or some of them bound to VFIO while others not being bound to anything at all.
669d3ad924SChristian Ehrhardt
679d3ad924SChristian Ehrhardt    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.
689d3ad924SChristian Ehrhardt    Therefore, the bridge driver should also be unbound from the bridge PCI device for VFIO to work with devices behind the bridge.
699d3ad924SChristian Ehrhardt
709d3ad924SChristian Ehrhardt.. warning::
719d3ad924SChristian Ehrhardt
729d3ad924SChristian Ehrhardt    While any user can run the ``dpdk-devbind.py`` script to view the status of the network ports,
739d3ad924SChristian Ehrhardt    binding or unbinding network ports requires root privileges.
749d3ad924SChristian Ehrhardt
759d3ad924SChristian Ehrhardt
769d3ad924SChristian EhrhardtExamples
779d3ad924SChristian Ehrhardt--------
789d3ad924SChristian Ehrhardt
799d3ad924SChristian EhrhardtTo display current device status::
809d3ad924SChristian Ehrhardt
819d3ad924SChristian Ehrhardt   dpdk-devbind --status
829d3ad924SChristian Ehrhardt
83*ad709fa9SStephen HemmingerTo bind eth1 from the current driver and move to use vfio-pci::
849d3ad924SChristian Ehrhardt
85*ad709fa9SStephen Hemminger   dpdk-devbind --bind=vfio-pci eth1
869d3ad924SChristian Ehrhardt
879d3ad924SChristian EhrhardtTo unbind 0000:01:00.0 from using any driver::
889d3ad924SChristian Ehrhardt
899d3ad924SChristian Ehrhardt   dpdk-devbind -u 0000:01:00.0
909d3ad924SChristian Ehrhardt
919d3ad924SChristian EhrhardtTo bind 0000:02:00.0 and 0000:02:00.1 to the ixgbe kernel driver::
929d3ad924SChristian Ehrhardt
939d3ad924SChristian Ehrhardt   dpdk-devbind -b ixgbe 02:00.0 02:00.1
949d3ad924SChristian Ehrhardt
95*ad709fa9SStephen HemmingerTo check status of all network ports, assign one to the vfio-pci driver and check status again::
969d3ad924SChristian Ehrhardt
979d3ad924SChristian Ehrhardt   # Check the status of the available devices.
989d3ad924SChristian Ehrhardt   dpdk-devbind --status
999d3ad924SChristian Ehrhardt   Network devices using DPDK-compatible driver
1009d3ad924SChristian Ehrhardt   ============================================
1019d3ad924SChristian Ehrhardt   <none>
1029d3ad924SChristian Ehrhardt
1039d3ad924SChristian Ehrhardt   Network devices using kernel driver
1049d3ad924SChristian Ehrhardt   ===================================
1059d3ad924SChristian Ehrhardt   0000:0a:00.0 '82599ES 10-Gigabit' if=eth2 drv=ixgbe unused=
1069d3ad924SChristian Ehrhardt
1079d3ad924SChristian Ehrhardt
108*ad709fa9SStephen Hemminger   # Bind the device to vfio-pci.
109*ad709fa9SStephen Hemminger   sudo dpdk-devbind -b vfio-pci 0000:0a:00.0
1109d3ad924SChristian Ehrhardt
1119d3ad924SChristian Ehrhardt
1129d3ad924SChristian Ehrhardt   # Recheck the status of the devices.
1139d3ad924SChristian Ehrhardt   dpdk-devbind --status
1149d3ad924SChristian Ehrhardt   Network devices using DPDK-compatible driver
1159d3ad924SChristian Ehrhardt   ============================================
116*ad709fa9SStephen Hemminger   0000:0a:00.0 '82599ES 10-Gigabit' drv=vfio-pci unused=
117