From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kamil Rytarowski Subject: Re: [PATCH v6 1/2] tools: Add support for handling built-in kernel modules Date: Tue, 26 Jan 2016 10:31:15 +0100 Message-ID: <56A73CE3.7010801@caviumnetworks.com> References: <1449667198-27218-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2"; format=flowed Content-Transfer-Encoding: 7bit To: Return-path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0082.outbound.protection.outlook.com [65.55.169.82]) by dpdk.org (Postfix) with ESMTP id 2EE259212 for ; Tue, 26 Jan 2016 10:31:30 +0100 (CET) In-Reply-To: <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" ping? W dniu 20.01.2016 o 10:48, krytarowski@caviumnetworks.com pisze: > From: Kamil Rytarowski > > 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 > Acked-by: David Marchand > Acked-by: Yuanhan Liu > --- > 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 f02454e..1d16d9f 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 = file("/proc/modules") > - 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 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 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["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: