From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0071.outbound.protection.outlook.com [207.46.100.71]) by dpdk.org (Postfix) with ESMTP id 3F8B43195 for ; Tue, 8 Dec 2015 16:34:22 +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 CY1PR07MB1446.namprd07.prod.outlook.com (10.161.167.144) with Microsoft SMTP Server (TLS) id 15.1.337.19; Tue, 8 Dec 2015 15:34:19 +0000 From: Kamil Rytarowski To: Date: Tue, 8 Dec 2015 16:33:52 +0100 Message-ID: <1449588833-485-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449513365-22282-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> References: <1449513365-22282-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: AM2PR09CA0028.eurprd09.prod.outlook.com (25.161.22.166) To CY1PR07MB1446.namprd07.prod.outlook.com (25.161.167.144) X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 2:aqtPlic/++S3Kn5BOopn7T0jQkP8YZytJ0vTZi9ymAdEcQX/FBam63BEy+ThGtq0xV/OyxanD7vukMAOwMKaIsi9dCgJxhBMkTTmvUsi+7nYueWHzdGyFUJy71D2lLLfdUwbAWYSgN7BDeYiYTEipA==; 3:Yphe4UKGfOrjfyACT+o035enCEhFg4lUEHBy/1cnPOh6sYzeasHzZT9NBpxDWJp7etDwOulpKOwFv1lTwPnuaKJZX7IxvI/SSK16W71TombDxo6XwocltiPOseYcmAf0; 25:mTd3DR/1BS+aXKJTYoZr/rov+tBNyUp4r178lXHkl0/tshl1uJ94aMjYd/Xs22BezhWPWEITXxYvcSTbZ8K4DYvQo/MmGFAE4ocHT3mOjLdUU5NrcdG8l3qIu6qGKOw55y0Ijg0nElEErFyzq1S7jHRBLZRvP4msiu3wGvnRSVUEuqP/ZhP8ZEks9nNqhZcXIXvGS/XdmcZ04A/DTkRwRYztKg9ZWJ9ZCqaxohgLWMxaprEOracNVCZ1YosaKDFYmvMDlNZKF4dNDmxp85KibA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 20:zZ6k4/GjCjYIccJ/WAwbEct8GeiCfQ0ZNo3D1EfSeGVh0sKV/oKGVgWgOD15i7nVy2mbfJZZqd1zhrGNvQMnGYMOOQfAsTzaxoqhMmGMQJt/xoLDFYNMDJ1KCMF+sC6S+cjuQ386ABzFXh+Qib6y+YICt5rhP/qjUQyOUZrPj5UImB/HoTtszKqmWXN9MMRMU2wqIoZ11fDHCZsSSXdcol2W83bA29ECBk9EzOzXq8ap6k337BHpu1sHBS+ZwbVEn9Hm8E/hkwzh9wmaKNr+ZpM9yIcJNxVPJHCPZpAqSzZT+mEt+bbiOJI8BJFSIwQApCRLCtqUn4JaK/FYo8tJ/x8rdpPGuVLmyTf4EnUUwkaPXyv8VzWFFTpHQ78RGkhnkz+M2ljX/Ik6l35o2ENpgJGXbCWbV2pHngbUvdMpOp+u1LhbeXboevi3mVgDmCDgU5bD815fqmn12E6/sSWbTbGXCncs3pR3y0G1451ibMLrdHlv+ZlAgRg3IxDwO/YMW5h91BQtKkgCQ4Mx9qqhOPmzoV88n/E4kL+uwyyXjd8HOcrRcqrWDuKeS37HRLolUS3qyVcWkZ10XqrgAX4ufKb8NqJIUh2h11l0NzFOK2I= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046); SRVR:CY1PR07MB1446; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 4:oimXuyP4bVqzh0E5U3o2pHJfIZeiA0p4L+wo1tP3ZI0I48Rl+OElt/SMLnmYPVsMwNZLlmvvCRaKeEYTeDWBe+Ljh5DfGgm0Ysmf9MSuCgH1EQ9bnLrv4unDf6pIW6yPQWrnLbAhj49nj+/P1mRjNDP7x64W2j2VWGJk+d796sO/y3dKXtbEnxdZdiZlei9gzdJyVt1eHk6S7Tl8iUYO4qQQwUCKQS6qT2sYlYrk2+9nG9jYH6Z8zXSVS43trB3NsdviOB9KlStrGPhdSqmeXmXev3t6uehy7Mqw/cEg7oYlsv/Tr9YOOxe4EeqaRN++7Tg6M62bQVryObMQxcWS3u3y19Sjua4kzvTNqpnCg8agVUqcah5q2lqDQWEa6ozSsBfkHWsQqYV1qMsPTki+1lsWEOE5Agk15SnPcy9PGfz01kDz5QCjAvnO3Bx2HyQp X-Forefront-PRVS: 0784C803FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(122386002)(19580395003)(107886002)(106356001)(86362001)(5001960100002)(76176999)(50226001)(2351001)(50986999)(97736004)(105586002)(40100003)(5004730100002)(48376002)(189998001)(110136002)(229853001)(19580405001)(81156007)(92566002)(5003940100001)(77096005)(47776003)(2950100001)(87976001)(50466002)(586003)(66066001)(42186005)(3846002)(36756003)(4001430100002)(101416001)(1096002)(5008740100001)(6116002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB1446; 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; CY1PR07MB1446; 23:fWnSnShImHTg4XrQfZS+xxkL46FD2tjetN8OYv2po?= =?us-ascii?Q?UACv15cgsaNFnDVQKY1R6LRSOBEBANkMIL8jdqmY9aYA1kKqMVvx7A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Zess0GBCOI9TriB4sGTBZFRu2m83RF4nB/pn?= =?us-ascii?Q?NrOlIDLntogwzWYzzbSoAVDWED2bDKjbhlqRWZnc+WR6+KFITRjQDKdgjb5q?= =?us-ascii?Q?R9Z5Ck4hfBICk30yyUi1cllS1+Jo4AjKjc5h7NkKKYdsyvRSQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 5:XGJYo2rJURiAya9Noz1xoYuFaxA35WUUM9WKnimLjQoDGxtpSd97aZyVwuXsGjTk/ni3eatu764XREnzJcPPN8nxCzuyz05PL9IUBvmvBORksqAd7rmcto67odN/5MYQk3wBswxE8iaArltvj/kdIQ==; 24:y1uT1HOhSXy90u7WwFwuz3LCZ43JWzGtSh4UO00Z6fRnCQeY96Zq4yJ8GsV9LQlrVvj9A+uiV3ihYkM1ZIOBBr3C8UMOPMqJ2kFGYZr6qto= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2015 15:34:19.3972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB1446 Subject: [dpdk-dev] [PATCH v4 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: Tue, 08 Dec 2015 15:34:22 -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: -- 1.9.1