usertools: enhance device bind script module detection

Message ID 20190921181626.13034-1-pbhagavatula@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series usertools: enhance device bind script module detection |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/intel-Performance success Performance Testing PASS
ci/mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Pavan Nikhilesh Bhagavatula Sept. 21, 2019, 6:16 p.m. UTC
  From: Pavan Nikhilesh <pbhagavatula@marvell.com>

Some kernel modules have '-' in their name when populated in
'/sys/bus/pci/drivers/' where as the kernel always populates
'/sys/modules/' with '_'.
Replace '-' in module name with '_' to avoid script complaining
that module not loaded.

Signed-off-by: Phanendra Vukkisala <pvukkisala@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 usertools/dpdk-devbind.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Oct. 27, 2019, 8:20 p.m. UTC | #1
21/09/2019 20:16, pbhagavatula@marvell.com:
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> 
> Some kernel modules have '-' in their name when populated in
> '/sys/bus/pci/drivers/' where as the kernel always populates
> '/sys/modules/' with '_'.
> Replace '-' in module name with '_' to avoid script complaining
> that module not loaded.

Sorry it does not look obvious to me.
Please, could you describe what is wrong and what is the real cause?
  

Patch

diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py
index 7b5cbc12c..b1d149876 100755
--- a/usertools/dpdk-devbind.py
+++ b/usertools/dpdk-devbind.py
@@ -153,6 +153,9 @@  def check_output(args, stderr=None):
 def module_is_loaded(module):
     global loaded_modules
 
+    if module == 'vfio_pci':
+        module = 'vfio-pci'
+
     if loaded_modules:
         return module in loaded_modules
 
@@ -520,7 +523,7 @@  def bind_all(dev_list, driver, force=False):
         pass
 
     # check if we're attempting to bind to a driver that isn't loaded
-    if not module_is_loaded(driver):
+    if not module_is_loaded(driver.replace('-','_')):
         sys.exit("Error: Driver '%s' is not loaded." % driver)
 
     try: