cryptodev: extend data-unit length field
[dpdk.git] / usertools / dpdk-devbind.py
index b0aba2c..5f0e817 100755 (executable)
@@ -7,9 +7,10 @@ import sys
 import os
 import subprocess
 import argparse
+import platform
 
 from glob import glob
-from os.path import exists, abspath, dirname, basename
+from os.path import exists, basename
 from os.path import join as path_join
 
 # The PCI base class for all devices
@@ -44,7 +45,15 @@ octeontx2_dma = {'Class': '08', 'Vendor': '177d', 'Device': 'a081',
                  'SVendor': None, 'SDevice': None}
 octeontx2_ree = {'Class': '08', 'Vendor': '177d', 'Device': 'a0f4',
                  'SVendor': None, 'SDevice': None}
+cnxk_bphy = {'Class': '08', 'Vendor': '177d', 'Device': 'a089',
+             'SVendor': None, 'SDevice': None}
+cnxk_bphy_cgx = {'Class': '08', 'Vendor': '177d', 'Device': 'a059,a060',
+                 'SVendor': None, 'SDevice': None}
+cnxk_inl_dev = {'Class': '08', 'Vendor': '177d', 'Device': 'a0f0,a0f1',
+                'SVendor': None, 'SDevice': None}
 
+intel_dlb = {'Class': '0b', 'Vendor': '8086', 'Device': '270b,2710,2714',
+             'SVendor': None, 'SDevice': None}
 intel_ioat_bdw = {'Class': '08', 'Vendor': '8086',
                   'Device': '6f20,6f21,6f22,6f23,6f24,6f25,6f26,6f27,6f2e,6f2f',
                   'SVendor': None, 'SDevice': None}
@@ -62,13 +71,13 @@ intel_ntb_icx = {'Class': '06', 'Vendor': '8086', 'Device': '347e',
 network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class]
 baseband_devices = [acceleration_class]
 crypto_devices = [encryption_class, intel_processor_class]
-eventdev_devices = [cavium_sso, cavium_tim, octeontx2_sso]
+eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso]
 mempool_devices = [cavium_fpa, octeontx2_npa]
 compress_devices = [cavium_zip]
 regex_devices = [octeontx2_ree]
-misc_devices = [intel_ioat_bdw, intel_ioat_skx, intel_ioat_icx, intel_idxd_spr,
-                intel_ntb_skx, intel_ntb_icx,
-                octeontx2_dma]
+misc_devices = [cnxk_bphy, cnxk_bphy_cgx, cnxk_inl_dev, intel_ioat_bdw,
+               intel_ioat_skx, intel_ioat_icx, intel_idxd_spr, intel_ntb_skx,
+               intel_ntb_icx, octeontx2_dma]
 
 # global dict ethernet devices present. Dictionary indexed by PCI address.
 # Each device within this is itself a dictionary of device properties
@@ -107,7 +116,17 @@ def module_is_loaded(module):
 
     loaded_modules = sysfs_mods
 
-    return module in sysfs_mods
+    # add built-in modules as loaded
+    release = platform.uname().release
+    filename = os.path.join("/lib/modules/", release, "modules.builtin")
+    if os.path.exists(filename):
+        try:
+            with open(filename) as f:
+                loaded_modules += [os.path.splitext(os.path.basename(mod))[0] for mod in f]
+        except IOError:
+            print("Warning: cannot read list of built-in kernel modules")
+
+    return module in loaded_modules
 
 
 def check_modules():
@@ -341,7 +360,7 @@ def bind_one(dev_id, driver, force):
     # of unbinding those devices
     if driver in dpdk_drivers:
         filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
-        if os.path.exists(filename):
+        if exists(filename):
             try:
                 f = open(filename, "w")
             except:
@@ -404,7 +423,7 @@ def bind_one(dev_id, driver, force):
     # Before unbinding it, overwrite driver_override with empty string so that
     # the device can be bound to any other driver
     filename = "/sys/bus/pci/devices/%s/driver_override" % dev_id
-    if os.path.exists(filename):
+    if exists(filename):
         try:
             f = open(filename, "w")
         except:
@@ -472,7 +491,7 @@ def bind_all(dev_list, driver, force=False):
     # that are not bound to any other driver could be bound even if no one has
     # asked them to. hence, we check the list of drivers again, and see if
     # some of the previously-unbound devices were erroneously bound.
-    if not os.path.exists("/sys/bus/pci/devices/%s/driver_override" % d):
+    if not exists("/sys/bus/pci/devices/%s/driver_override" % d):
         for d in devices.keys():
             # skip devices that were already bound or that we know should be bound
             if "Driver_str" in devices[d] or d in dev_list:
@@ -557,28 +576,28 @@ def show_status():
     Displays to the user what devices are bound to the igb_uio driver, the
     kernel driver or to no driver'''
 
-    if status_dev == "net" or status_dev == "all":
+    if status_dev in ["net", "all"]:
         show_device_status(network_devices, "Network", if_field=True)
 
-    if status_dev == "baseband" or status_dev == "all":
+    if status_dev in ["baseband", "all"]:
         show_device_status(baseband_devices, "Baseband")
 
-    if status_dev == "crypto" or status_dev == "all":
+    if status_dev in ["crypto", "all"]:
         show_device_status(crypto_devices, "Crypto")
 
-    if status_dev == "event" or status_dev == "all":
+    if status_dev in ["event", "all"]:
         show_device_status(eventdev_devices, "Eventdev")
 
-    if status_dev == "mempool" or status_dev == "all":
+    if status_dev in ["mempool", "all"]:
         show_device_status(mempool_devices, "Mempool")
 
-    if status_dev == "compress" or status_dev == "all":
+    if status_dev in ["compress", "all"]:
         show_device_status(compress_devices, "Compress")
 
-    if status_dev == "misc" or status_dev == "all":
+    if status_dev in ["misc", "all"]:
         show_device_status(misc_devices, "Misc (rawdev)")
 
-    if status_dev == "regex" or status_dev == "all":
+    if status_dev in ["regex", "all"]:
         show_device_status(regex_devices, "Regex")
 
 
@@ -634,7 +653,8 @@ To bind 0000:02:00.0 and 0000:02:00.1 to the ixgbe kernel driver
     parser.add_argument(
         '--status-dev',
         help="Print the status of given device group.",
-        choices=['net', 'baseband', 'crypto', 'event', 'mempool', 'compress'])
+        choices=['baseband', 'compress', 'crypto', 'event',
+                'mempool', 'misc', 'net', 'regex'])
     bind_group = parser.add_mutually_exclusive_group()
     bind_group.add_argument(
         '-b',
@@ -703,7 +723,7 @@ def do_arg_actions():
     global force_flag
     global args
 
-    if b_flag == "none" or b_flag == "None":
+    if b_flag in ["none", "None"]:
         unbind_all(args, force_flag)
     elif b_flag is not None:
         bind_all(args, b_flag, force_flag)