From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0090.outbound.protection.outlook.com [65.55.169.90]) by dpdk.org (Postfix) with ESMTP id AC9675A71 for ; Wed, 20 Jan 2016 10:49:00 +0100 (CET) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Kamil.Rytarowski@caviumnetworks.com; Received: from cavium1.semihalf.local (213.17.239.108) by BY2PR07MB1444.namprd07.prod.outlook.com (10.162.76.146) with Microsoft SMTP Server (TLS) id 15.1.390.13; Wed, 20 Jan 2016 09:48:57 +0000 From: To: Date: Wed, 20 Jan 2016 10:48:36 +0100 Message-ID: <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449667198-27218-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> References: <1449667198-27218-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [213.17.239.108] X-ClientProxiedBy: AM3PR05CA017.eurprd05.prod.outlook.com (10.141.192.27) To BY2PR07MB1444.namprd07.prod.outlook.com (25.162.76.146) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 2:FDkUmVd78TlA00M4uX7YmPVuEqlhe71wAyQLphc+ZXHQqquC51EAPiDWO+/zV3SezHBfIefUfP3LrN3IHBSPstqsD6dT6OFOpxG7rOcllVrmvv13bf7tGpFXB0JTRPuBvaoxHV8DUuSSVCFzFhedxw==; 3:lO5lxQzo6XPXjKTOqIgaPuk7hJjyNmWtMhvpNZjPdjN3+LuWwWVX+s/w9lor8xVoW4AKJO5aQMehF5GEZUhuic7Zw7vSc4yBvlcPGvRCDRdnN+n+NfxnESW2YTgfJYPz; 25:h1l77MZ3ZDWiPrv7R6QtbqkxxZCL8HKDoZAL8YoyqsJejr/RBRevAGrQvr7/BuQUbzohpHS7vlHrhZObl185LcSPq1MnMQEioyefo2R5bKUFe7UE2L2sBVIRF8XMbSoEjVubLJ0OYTJYSDDR+mo2zxz7TwdnPuayndvtcfqEg2go119WX53O9XvlWxOp3Xov5W+jHCHAmOs/jR1bXYUfM9/sCk/5bUYTWUFWCm3cnlN9EWkdga5v4CXg500GsEVP X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1444; X-MS-Office365-Filtering-Correlation-Id: db536741-f1ff-4453-c3d9-08d3217eeb43 X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 20:8EaMnUD/EkNAxUCQuH87ZXjJf+U+Es+prr92tiaKIJ35BxS0BMDA4EsH6KRreDEF9BdZMhHa1MWnOyTRoqxKPoWWv8ixUeHQePB/iiWZUFlaqhC/gm4Hqd0O2qqe4TO6RbzPyOtrxfwM0hmr+PkQ3dkNwqtzcE4eqkBThaJE9PZ/kxQhHo93U2JHrUXT5d47D1ORaL+bwApBXqQKYr/LCGGGhJeSpW/5R9LNxhaMkDt8ITrH1bVzh/it2YHxbQ3nobjKqqPYl6x8fGFWnSzWKFrx1NDjcytGdxXCjaOOPNoulAv51yeB6UTvW7reU/C5eR49/g+cgYQ8up37hayuoST7DHUuX//S69EPKp6nV1S5F6FjVWjjQlq70hxVl6GdIeY+Wt2W0+4HCdAtN9sf6KNkuf5Ap2riFvedz0T7DeRQQeYPCVIx3Ax/WfT9x/2wT+YQ0FoN6hJI4l11dZNM9009FsG5hYYZEpBBw9emo2XOV5HfUlzlERuBZ4HCzc6Ll7MluOCg0cueAt65uOnrJRmIxVWxeDoMwEIluIwsLYeTUtdWMe091WbjVJhHC4qrANW8BNjMDDSnVn0YGVQC0SD3PA7iIhopPqMpxxxLMJ8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(123027)(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001); SRVR:BY2PR07MB1444; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB1444; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 4:twOQPJ84Sihfe+TKt9tC4f5h+2iVpLkZjWC8b0NZkaHy4VtmpABiKhuDrFCx6PnTmhdwy2eqBJwawZx4zPUh2cBVnzUGURwj6ZC4jKqQ8pohvyRHxroCYIgEUUO24RLW9Mmh90R9eQCU87dBlqnaXF7aRDOnuJHSusngad04DlYhwFZ0fb0kaUlynd/d8uPE1dK/4XtaLzMe02otJLUOKZ/uchUkapivwZVgfLgTmZIN2In7gduhsdRdENQ8sf0V9p85qz1GiE8g9xxS0+JJQQ515YnfxTe5eJfqQ3PmGnFfGCKfiOjucNO67dMcpNkVsLakliK5A3+XFZ3ZSzdOhgvC8M+/BZTtLJPRU/sGo7WLfWI82f/tiDkbdrSDCG2DAkEdxh+rHn+tzNJCldWUNw== X-Forefront-PRVS: 0827D7ACB9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(1096002)(229853001)(2351001)(19580395003)(19580405001)(4326007)(2950100001)(2906002)(92566002)(33646002)(6116002)(3846002)(586003)(106356001)(105586002)(50986999)(42186005)(87976001)(76176999)(36756003)(97736004)(189998001)(5008740100001)(107886002)(5001960100002)(122386002)(47776003)(81156007)(66066001)(110136002)(5004730100002)(40100003)(77096005)(2876002)(5003940100001)(86152002)(50226001)(101416001)(48376002)(50466002)(4001430100002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB1444; 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; BY2PR07MB1444; 23:E0TUR6M1zpSbdFVi05cTiCmEtSu77KPlTGufUYIhc?= =?us-ascii?Q?7lx6DqIQnz9M28P7Fmoy2Lrm5Ik+tEyhKpO/4GmFktOmq4AODYGFOpVGMy7W?= =?us-ascii?Q?ba21q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P/WIRRm90+zbmhJgbWRmfBy?= =?us-ascii?Q?vMRGf8JqB9bFwbJfBKd52bGAR7A4/lCzQFazzKjGeGDKZ8HI+jvlH/xgh684?= =?us-ascii?Q?Xt+H4I/xNAnlOMjFWTmtERjyGDzUyFAY06xM6ODpz0zCebDdIECd6JoIabvw?= =?us-ascii?Q?CQARgOJCQLl0q+vy+CIhZYoNwFt4wZb?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 5:RhNGi51qHB6J+ndi6mQpKgWKVS5VjafGQp15I+utJ0vVCWECHcDvWFDj1CJCYo9HbbzErLobWLMPZZIemoOOwBBSoGfNW6xqvUViMb841PoXnrWPaNmfOGznWgunIoQNJtmLMt7O0JpxYiCB0+5Apg==; 24:aj/Vyka9fgVKsYRfYSme9/hASqFof5p1QEtZPTskAzbrT7PdizKCyWKVo7x4dyPMuY7DDtjwzg33ell8JNUehaaSJfWGkG8L0ImtAFCIk4Y= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2016 09:48:57.4179 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB1444 Subject: [dpdk-dev] [PATCH v6 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, 20 Jan 2016 09:49:01 -0000 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: -- 1.9.1