DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH] tools: Add support for handling built-in kernel modules
Date: Mon, 7 Dec 2015 15:50:19 +0100	[thread overview]
Message-ID: <1449499819-31510-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> (raw)

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.

Signed-off-by: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
---
 tools/dpdk_nic_bind.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
index 8523f82..2ddc14a 100755
--- a/tools/dpdk_nic_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -33,7 +33,7 @@
 #
 
 import sys, os, getopt, subprocess
-from os.path import exists, abspath, dirname, basename
+from os.path import exists, abspath, dirname, basename, join
 
 
 # The PCI device class for ETHERNET devices
@@ -173,6 +173,26 @@ def check_modules():
             elif line.replace("_", "-").startswith(mod["Name"]):
                 mod["Found"] = True
 
+    try:
+        # Get list of syfs modules, some of them might be builtin and merge with mods
+        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 mod["Found"] == False and (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:
         if b_flag in dpdk_drivers:
-- 
2.5.0

                 reply	other threads:[~2015-12-07 14:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449499819-31510-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com \
    --to=kamil.rytarowski@caviumnetworks.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).