From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0071.outbound.protection.outlook.com [65.55.169.71]) by dpdk.org (Postfix) with ESMTP id A33B0568B for ; Wed, 9 Dec 2015 14:20:23 +0100 (CET) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Kamil.Rytarowski@caviumnetworks.com; Received: from cavium1.semihalf.local (80.82.22.190) by CY1PR07MB1448.namprd07.prod.outlook.com (10.161.167.146) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 9 Dec 2015 13:20:21 +0000 From: Kamil Rytarowski To: Date: Wed, 9 Dec 2015 14:19:57 +0100 Message-ID: <1449667198-27218-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1449588833-485-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> References: <1449588833-485-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [80.82.22.190] X-ClientProxiedBy: VI1PR02CA0021.eurprd02.prod.outlook.com (25.162.7.159) To CY1PR07MB1448.namprd07.prod.outlook.com (25.161.167.146) X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 2:E8lzMPYrWup8ly/BlzOmftqSYlC+ADg0A913GRLaFxXj3KZMxHFtMQgZV5Kkz1eKUms1fx3wCCekNIalEvsBR71TG3VJRNI5D24e2H649cVSKgOXarvd9yvVnACgaF4bC8fPJ1/Dp1AUPpz+tAx5sA==; 3:HjQjWLnQgT8hChZSztQj0TENcbcUSgZaZJbVESSQfXH0q0/sggng/78pxC+CkEIikLkY7z6S98bdj7ZTnCETxxeojGcCdFW78ZkWrzfn8MgeFSACaRw6snr93UzkMcR4; 25://N+NlG7IGRQmosUZrvE+QljjxbGvTtgQhxIJ8w96fXj5aE4p3XKZKf/Ed+G74HqbgamHSy3VWONcpXCPYzAjezR37LzdHNBib8hJ8TWsO3QTGBEBrCZOOiMV+7ns65RQCApDyLNSB3XikL0VA3JvEUjtiXcnwvFZa/Da39+gKwkkX0nHQWB77c90jM6SCEmV1mgYuur+l7BEjPJgwWY36zDzqw5az+kdceq73wX49EzfGEJ76oF+Dpxd8a4yJxeplMdOwDKY7kkNMRUuZOWCg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB1448; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 20:C7mAMiAyZWQqpI6UHeIMxAtKZvMyBcGVjk4+AKhYASDP4utHcvBFzxpY28EghdcOLasIey1aLcmSswBf2Gdfvmr5f8GGzU1A35HCXj3HV9gPvqRmIvtO0oiDpFra6CFi9g6/91ClFci+CtbK0YQycVfrJyXPDIMuhW1FO2SY5gNMwx091zkW/eOpZJxN7BpSNNq2ax1qaDWbsac2skqJ8ERQWZ0Q6vCM6u1lZV5caXzHYT5NRL8wSK+XvX9vCPkMBi386oX/lzdc8hzB/+t1z1bompw8K7qt8tenFs/+5mDlG1GUAel6Ae0fYzb8tVXR+I5RVKzM3Y5L9ai1gnAFFhFDT+s9FIgZX2I9a3wwUOak0j+OyffsCCEg3dz2W5t38agxOKcpnPU41vwzlvlBCHPvMbh9tQ+nF8LtJvdmJkkTj7WGmj6VCgOKt9igjjVTpMUbMJKnWDS7Jzu6e911RJA8++8C2WPiSZjDgSW4wzhRUJ7a66epUru2lQPMJpKCpsVhlWkfE72tvIwVwUS9CKgYejAz10inHgmwsipTfNHTKqOcVU13+klNtaV7AROggizH9dIcAJHYtzC8cp1a/he9gtFmJhXCt4yiKKbwy+E= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:CY1PR07MB1448; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB1448; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 4:Azjsa9EbGI3zfwFHtUR/7egK1o+Of002SEzJd/6uENN2bPrPygirMGhT1uNQS2M1n72V+WK0ZibrRZHPaFlHk4wtRuLUQlmDRhWnjHx+bYodEgDUyLmCs11n7lyExXDnU8pU3n4ytZCM0a1diXVRmUAr2yIUmBqf+23Sr5Qzk4OhRjQgtQ5Ya9opGlLIOZBF1wpEUPotnyEjSRGBYHW/QOJAHkMo38VQaN6xDr2jaq7ySCjZWsBtK6goLJliJ15x0jTVdhmAJjCXilIxshV7kfmbk9s8mU1u0f3CtvWb3UXXgLbXdibB6WgS7YKDvrYwQPpEe2DqNhAoVUsoPhbYlyRUG5PFwtMt6dUxZmq3UdE9dRW/kLWXy4RJ6XfwvhCK6jsE6tVjGanspqPF4dteTVUUkNoVn8kG/r4//R8QmaKDPk9T0b9Ou6uVLEKCBBea X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(105586002)(92566002)(42186005)(586003)(19580395003)(106356001)(3846002)(19580405001)(5008740100001)(50226001)(1096002)(5004730100002)(122386002)(229853001)(66066001)(110136002)(36756003)(5001960100002)(6116002)(76176999)(50986999)(47776003)(189998001)(101416001)(77096005)(2950100001)(97736004)(81156007)(2351001)(86362001)(5003940100001)(50466002)(87976001)(40100003)(48376002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB1448; H:cavium1.semihalf.local; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB1448; 23:9+14mEwsPgUFMUiMs6GoDsqlRibYMhyXKTLmWlY9s?= =?us-ascii?Q?oY6XcQ3Kv319s/wCBt2TAtjBKD3k/Td82oX15k9EUvxamtfnTyHtx+hKrAjh?= =?us-ascii?Q?q3tAX48/oD6Eulwe0125hiHxLB27l4O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q?XLRXQPN3Sae6PIK5FXRMVq/oFSk5FAxuHM7wsDBefQEcQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 5:D2y+yMGe6z4M1z6LePWvZU7JhtxCmNLN3fCB63fw0dDMYTrC4UxUv0Zt+Jk82jGRZD3uv014yNIQyNXf7IlCZhi7a3KcDWQjCRDJpTrI4PN2zYEo2We7qidUhPsEY3PZ0SxSe2hzujJrzq4G37oytA==; 24:aB9qYSTgEcq/mcGUweEN4QPsqAeDp/WyEh/ajI7QzQNDh0VnN+cKPBERPAaAKHm/M/lFZv450mOel3T1jdDHi05MPeRsgR6Tb7irF6toS4o= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 13:20:21.0807 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB1448 Subject: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Dec 2015 13:20:24 -0000 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 Signed-off-by: David Marchand --- tools/dpdk_nic_bind.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py index f02454e..e161062 100755 --- a/tools/dpdk_nic_bind.py +++ b/tools/dpdk_nic_bind.py @@ -156,22 +156,29 @@ 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: -- 2.6.3