# The PCI base class for all devices
network_class = {'Class': '02', 'Vendor': None, 'Device': None,
'SVendor': None, 'SDevice': None}
+acceleration_class = {'Class': '12', 'Vendor': None, 'Device': None,
+ 'SVendor': None, 'SDevice': None}
ifpga_class = {'Class': '12', 'Vendor': '8086', 'Device': '0b30',
'SVendor': None, 'SDevice': None}
encryption_class = {'Class': '10', 'Vendor': None, 'Device': None,
'SVendor': None, 'SDevice': None}
octeontx2_npa = {'Class': '08', 'Vendor': '177d', 'Device': 'a0fb,a0fc',
'SVendor': None, 'SDevice': None}
+octeontx2_dma = {'Class': '08', 'Vendor': '177d', 'Device': 'a081',
+ '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}
intel_ioat_skx = {'Class': '08', 'Vendor': '8086', 'Device': '2021',
'SVendor': None, 'SDevice': None}
+intel_ntb_skx = {'Class': '06', 'Vendor': '8086', 'Device': '201c',
+ 'SVendor': None, 'SDevice': None}
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]
mempool_devices = [cavium_fpa, octeontx2_npa]
compress_devices = [cavium_zip]
-misc_devices = [intel_ioat_bdw, intel_ioat_skx]
+misc_devices = [intel_ioat_bdw, intel_ioat_skx, intel_ntb_skx, octeontx2_dma]
# global dict ethernet devices present. Dictionary indexed by PCI address.
# Each device within this is itself a dictionary of device properties
devices = {}
# list of supported DPDK drivers
dpdk_drivers = ["igb_uio", "vfio-pci", "uio_pci_generic"]
+# list of currently loaded kernel modules
+loaded_modules = None
# command-line arg flags
b_flag = None
--status-dev:
Print the status of given device group. Supported device groups are:
- "net", "crypto", "event", "mempool" and "compress"
+ "net", "baseband", "crypto", "event", "mempool" and "compress"
-b driver, --bind=driver:
Select the driver to use or \"none\" to unbind the device
return subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=stderr).communicate()[0]
+# check if a specific kernel module is loaded
+def module_is_loaded(module):
+ global loaded_modules
+
+ if loaded_modules:
+ return module in loaded_modules
+
+ # Get list of sysfs modules (both built-in and dynamically loaded)
+ sysfs_path = '/sys/module/'
+
+ # Get the list of directories in sysfs_path
+ sysfs_mods = [m for m in os.listdir(sysfs_path)
+ if os.path.isdir(os.path.join(sysfs_path, m))]
+
+ # special case for vfio_pci (module is named vfio-pci,
+ # but its .ko is named vfio_pci)
+ sysfs_mods = [a if a != 'vfio_pci' else 'vfio-pci' for a in sysfs_mods]
+
+ loaded_modules = sysfs_mods
+
+ return module in sysfs_mods
+
def check_modules():
'''Checks that igb_uio is loaded'''
mods = [{"Name": driver, "Found": False} for driver in dpdk_drivers]
# first check if module is loaded
- try:
- # Get list of sysfs modules (both built-in and dynamically loaded)
- sysfs_path = '/sys/module/'
-
- # Get the list of directories in sysfs_path
- sysfs_mods = [os.path.join(sysfs_path, o) for o
- in os.listdir(sysfs_path)
- if os.path.isdir(os.path.join(sysfs_path, o))]
-
- # Extract the last element of '/sys/module/abc' in the array
- sysfs_mods = [a.split('/')[-1] for a in sysfs_mods]
-
- # special case for vfio_pci (module is named vfio-pci,
- # but its .ko is named vfio_pci)
- sysfs_mods = [a if a != 'vfio_pci' else 'vfio-pci' for a in sysfs_mods]
-
- for mod in mods:
- if mod["Name"] in sysfs_mods:
- mod["Found"] = True
- except:
- pass
+ for mod in mods:
+ if module_is_loaded(mod["Name"]):
+ mod["Found"] = True
# check if we have at least one loaded module
if True not in [mod["Found"] for mod in mods] and b_flag is not None:
- if b_flag in dpdk_drivers:
- print("Error - no supported modules(DPDK driver) are loaded")
- sys.exit(1)
- else:
- print("Warning - no supported modules(DPDK driver) are loaded")
+ print("Warning: no supported DPDK kernel modules are loaded")
# change DPDK driver list to only contain drivers that are loaded
dpdk_drivers = [mod["Name"] for mod in mods if mod["Found"]]
if dev_name in devices[d]["Interface"].split(","):
return devices[d]["Slot"]
# if nothing else matches - error
- print("Unknown device: %s. "
- "Please specify device in \"bus:slot.func\" format" % dev_name)
- sys.exit(1)
+ raise ValueError("Unknown device: %s. "
+ "Please specify device in \"bus:slot.func\" format" % dev_name)
def unbind_one(dev_id, force):
unbind_one(devices[d]["Slot"], force)
return
- dev_list = map(dev_id_from_dev_name, dev_list)
+ try:
+ dev_list = map(dev_id_from_dev_name, dev_list)
+ except ValueError as ex:
+ print(ex)
+ sys.exit(1)
+
for d in dev_list:
unbind_one(d, force)
"""Bind method, takes a list of device locations"""
global devices
- dev_list = map(dev_id_from_dev_name, dev_list)
+ # a common user error is to forget to specify the driver the devices need to
+ # be bound to. check if the driver is a valid device, and if it is, show
+ # a meaningful error.
+ try:
+ dev_id_from_dev_name(driver)
+ # if we've made it this far, this means that the "driver" was a valid
+ # device string, so it's probably not a valid driver name.
+ sys.exit("Error: Driver '%s' does not look like a valid driver. " \
+ "Did you forget to specify the driver to bind devices to?" % driver)
+ except ValueError:
+ # driver generated error - it's not a valid device ID, so all is well
+ pass
+
+ # check if we're attempting to bind to a driver that isn't loaded
+ if not module_is_loaded(driver):
+ sys.exit("Error: Driver '%s' is not loaded." % driver)
+
+ try:
+ dev_list = map(dev_id_from_dev_name, dev_list)
+ except ValueError as ex:
+ sys.exit(ex)
for d in dev_list:
bind_one(d, driver, force)
if status_dev == "net" or status_dev == "all":
show_device_status(network_devices, "Network")
+ if status_dev == "baseband" or status_dev == "all":
+ show_device_status(baseband_devices, "Baseband")
+
if status_dev == "crypto" or status_dev == "all":
show_device_status(crypto_devices, "Crypto")
clear_data()
# refresh if we have changed anything
get_device_details(network_devices)
+ get_device_details(baseband_devices)
get_device_details(crypto_devices)
get_device_details(eventdev_devices)
get_device_details(mempool_devices)
check_modules()
clear_data()
get_device_details(network_devices)
+ get_device_details(baseband_devices)
get_device_details(crypto_devices)
get_device_details(eventdev_devices)
get_device_details(mempool_devices)