summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKamil Rytarowski <kamil.rytarowski@caviumnetworks.com>2016-01-28 14:13:53 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-02-09 16:03:46 +0100
commitbb9f408550d13af6c1da104b0d9d9b9837f69bde (patch)
treea9c32095246f473c90bea2606e9d7cebba4538af /tools
parent16c1814c802c205f6d3c32e3d3d10de9f87e7f22 (diff)
downloaddpdk-bb9f408550d13af6c1da104b0d9d9b9837f69bde.zip
dpdk-bb9f408550d13af6c1da104b0d9d9b9837f69bde.tar.gz
dpdk-bb9f408550d13af6c1da104b0d9d9b9837f69bde.tar.xz
tools: support binding to built-in kernel modules
Currently dpdk_nic_bind.py detects Linux kernel modules via reading /proc/modules. Built-in ones aren't listed there and therefore they are not being found by the script. Add support for checking built-in modules with parsing the sysfs files. This commit obsoletes the /proc/modules parsing approach. Signed-off-by: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/dpdk_nic_bind.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
index dfefdae..14c5311 100755
--- a/tools/dpdk_nic_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -156,22 +156,32 @@ def check_modules():
'''Checks that igb_uio is loaded'''
global dpdk_drivers
- fd = open("/proc/modules", 'r')
- loaded_mods = fd.readlines()
- fd.close()
-
# list of supported modules
mods = [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]
# first check if module is loaded
- for line in loaded_mods:
+ 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 = map(lambda a:
+ a if a != 'vfio_pci' else 'vfio-pci', sysfs_mods)
+
for mod in mods:
- if line.startswith(mod["Name"]):
- mod["Found"] = True
- # special case for vfio_pci (module is named vfio-pci,
- # but its .ko is named vfio_pci)
- elif line.replace("_", "-").startswith(mod["Name"]):
+ if mod["Name"] in sysfs_mods:
mod["Found"] = True
+ except:
+ pass
# 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: