SHA256
1
0
forked from pool/dpdk
dpdk/0030-tools-support-binding-to-built-in-kernel-modules.patch
Nirmoy Das d761fec5f6 Accepting request 399089 from home:ndas:branches:network
- Applied all the fixes recommended by upstream for 
  v2.2 stable release(bsc#981996).
	[+0008-app-testpmd-handle-SIGINT-and-SIGTERM.patch,
	+0009-bonding-copy-entire-config-structure-in-mode-4.patch,
	+0010-bonding-fix-active-slaves-with-no-primary.patch,
	+0011-bonding-do-not-ignore-multicast-in-mode-4.patch,
	+0012-bonding-do-not-activate-slave-twice.patch,
	+0013-bonding-fix-crash-when-no-slave-device.patch,
	+0014-bonding-fix-detach-of-bonded-device.patch,
	+0015-bonding-fix-detach-of-slave-devices.patch,
	+0016-eal-linux-support-built-in-kernel-modules.patch,
	+0017-examples-l3fwd-handle-SIGINT-and-SIGTERM.patch,
	+0018-fm10k-fix-VLAN-flag-in-scattered-Rx.patch,
	+0019-i40e-base-fix-driver-load-failure.patch,
	+0020-i40e-base-fix-missing-check-for-stopped-admin-queue.patch,
	+0021-i40e-fix-inverted-check-for-no-refcount.patch,
	+0022-i40e-fix-overflow.patch,
	+0023-i40e-fix-VLAN-filtering.patch,
	+0024-mempool-fix-leak-when-creation-fails.patch,
	+0025-pcap-fix-captured-frame-length.patch,
	+0026-port-fix-crash-for-ethdev-writer-nodrop.patch,
	+0027-port-fix-crash-for-ring-writer-nodrop.patch,
	+0028-tools-fix-unbinding-failure-handling.patch,
	+0029-tools-support-Python-3-in-bind-script.patch,
	+0030-tools-support-binding-to-built-in-kernel-modules.patch,
	+0031-vhost-fix-leak-of-fds-and-mmaps.patch,
	+0032-virtio-fix-crash-in-statistics-functions.patch,
	+0033-virtio-fix-descriptors-pointing-to-the-same-buffer.patch,
	+0034-virtio-fix-restart.patch]

OBS-URL: https://build.opensuse.org/request/show/399089
OBS-URL: https://build.opensuse.org/package/show/network/dpdk?expand=0&rev=3
2016-05-31 11:30:42 +00:00

70 lines
2.5 KiB
Diff

From bb9f408550d13af6c1da104b0d9d9b9837f69bde Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
Date: Thu, 28 Jan 2016 14:13:53 +0100
Subject: [PATCH] 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>
---
tools/dpdk_nic_bind.py | 30 ++++++++++++++++++++----------
1 file 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:
--
2.6.2