From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0056.outbound.protection.outlook.com [207.46.100.56]) by dpdk.org (Postfix) with ESMTP id C7C8BC3B2 for ; Thu, 28 Jan 2016 14:14:26 +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 BY2PR07MB1443.namprd07.prod.outlook.com (10.162.76.145) with Microsoft SMTP Server (TLS) id 15.1.390.13; Thu, 28 Jan 2016 13:14:23 +0000 From: To: Date: Thu, 28 Jan 2016 14:13:53 +0100 Message-ID: <1453986834-31128-1-git-send-email-krytarowski@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> References: <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [213.17.239.108] X-ClientProxiedBy: VI1PR08CA0028.eurprd08.prod.outlook.com (25.164.95.38) To BY2PR07MB1443.namprd07.prod.outlook.com (25.162.76.145) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 2:zvY5yuFbhjN6Wa3SnNpdcrd9e6fqWmGQd2n8ExmRRhv3ZDtWp74r4BMH/eKPNSip/4oEFjGZdwl1waNmR/eWdTcvh0aXmSPX4mTKVhqljokRVDEN3VER3UTBEe2p9Z9rB21YJe5GURLE9aiQXBjmKQ==; 3:SIw35hhXz11Za9mTqjfONo8vdtqR0kG5vXYUQfyTWj07J4f5tHEDwQ2lqUNstWBBUG2aSU7UAIPp5xJ6ceFPRr3rjii05WjQGs7qkfzmlYh/W5D8Zo/w5hw2EsdBKon4; 25:b6m+k+jwz0SZDAfg0b91lp4xZQ2yorF6LxL5vZ4bE4Fta7L8zTC69phRmVKo8sRGhSGdCYeL4MLFNt2eaQwZdOrRHsmeG1Lg2XgHu5cI+M6bH5igQF28/daguyq+lUYz452e2F8Vqky74hsc0H2PpjoyjDm8JzG8ofwpOMpZfuCwhZCgrSfECbLwyKigBT6XE7yenRs5kk+CU8XKJggoh7seAEcFNrswzvukWiVI9irXx7h0GV037tmeide7jT0M X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1443; X-MS-Office365-Filtering-Correlation-Id: f8ea5b18-d14a-4ffc-8056-08d327e4f186 X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 20:zzccLfr71lTkB1IHh9eRWqZDztac1urIqL8Tlit6u6hBaoWXlN0N5LU3j4JBPnTSPg0wfLF8jQuxZcZ6qnrz7UI93Nlt2/bh8x8YkaY+mLDpjbGQ0SypWUeoubyPluRuLWvVdp2zT+Lx90gSFgWD0sqoE3AbJXYl687SxQ0H0te3L/Dwh3s6mZ9NdnhN70jWsZvLi+3Yj9LvqADQsJC+2Qo/2fhL8q3PFirKYXE1aLijE+q/6QQ0W6yh/SWZZnSJYT/syzLBDzCkvg0lIjcbkoiv0yXVt+noKnOxdK9DbINFsU4L82lwScImIwDM+nrD5yUP14kymLwzUcHUPZvwRaHW0F0+/jDWGIgBwFt41K5bCIjCNf/udtAiSEyIMuZNSC7Pj3hvXuSPNWh8fhYgdHe/RHqyKQEzs7n/9AkWcFbvlTugvwdRODAHE5+3/IKwsYuCee4HWNReDl5bv9Da72oaJYxdNGlOB6QuaxjH3t2pynnVLofoD0SwcvNcQE/F7DZ/5UUP2AOnaMCcQ1QsJDqHL7aH5VfkCvGw4OGky2Q0KhCM83Ck64uebHbiWMKUf2fLjYPiXWKgT18C4ylaumZ9WXhisEjzk5tWFHORnMc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BY2PR07MB1443; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB1443; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 4:hVRvH5T0pELczd0qVaAwwHotXdnTPIEBhg34LBTST8ePoZC0399LyPhGy0P+WWvULz0q17l96pSGumh8adxuY3mTGYZ3XuR2sRnggrNBXKdXGj0jpdIgfKKmDHEOv0SSoDxaD7v+xRStXJ3P8frlzpVS/Z/yJ8+1OGJn18VMly6DgP3ywgpw1mAv3/KAHd0Lmg4YvyBbCEBm3zxI2TVDG6hFu1n8YSKDao33qLeQZRPCAUuVZRaVoHGxbBwF+fUbAYopdL6LAXg0U3lCevVhD12AvfWIfXsZHcyjcHFNoBlI0m1j3/DxgfaqTAYUR0Ct39qf8jV21otWBeBjz2TE9EX9uINlvXPh7COxne2V2uTFNatDNCjwKG7mZ7ImP8BM X-Forefront-PRVS: 083526BF8A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(50226001)(5008740100001)(101416001)(33646002)(122386002)(36756003)(3470700001)(3846002)(6116002)(40100003)(1096002)(92566002)(586003)(48376002)(4326007)(2876002)(2906002)(42186005)(76176999)(50986999)(110136002)(107886002)(19580395003)(19580405001)(4001430100002)(97736004)(2351001)(47776003)(81156007)(87976001)(50466002)(5001960100002)(106356001)(2950100001)(229853001)(189998001)(86152002)(105586002)(66066001)(5003940100001)(77096005)(5004730100002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB1443; H:cavium1.semihalf.local; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BY2PR07MB1443; 23:eVaC4fyDwbpuQzqe+FBAXer7QLXrZGVbWOhRP4f70?= =?us-ascii?Q?/BKDEyBkTJy/UIuRO2tdH46Vw3hFGO/yvGdmn+H+J7Y0DY/Q3SFheDYMOy8J?= =?us-ascii?Q?FIG18hE4asWW14VqUCGDZ22rEJ5Z/hHlk7hcGNvin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adIUmDEhM2fdS6IROycttcxY38lqc3nbFyszayOc+?= =?us-ascii?Q?DU0LvXoXbaSL6f3GqsVqg8wCmq6MxfIIpt70o8koHTZ39+hW8g04URk9CCHX?= =?us-ascii?Q?HDK6v0idm2UAc3iJM1RJesx3s5ub86mXHPfhOfnx1ULj95aOdfuxr/uXpvAT?= =?us-ascii?Q?CH6SKt5bi/c3UQ=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 5:9s4xrbBUTo71TRq5YtHT4mzAkEkgeemrJANHw1L3I7PL6BNeltYxoUKu8QpmsV14Gn7p9nKSXW5J3Cu/1p+bOmJI0Y3SBCSZPU3tg/4VemI9Xc6yKoK0oh5d8LwXfP+w/h7mNbm1eN8ZB1cD/oz3yA==; 24:sN48inX6dqXxqcph2IoqU1FBUwv28OXe3XfuI+gMF1Cg7e2Mx2NqP11Q6juchIIgx9TLRTt59TecTDxSgG2dab9SKKKYU5AzZFNpEFoFMGU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2016 13:14:23.1604 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB1443 Subject: [dpdk-dev] [PATCH v7 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: Thu, 28 Jan 2016 13:14:27 -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 --- 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..85cb6f1 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 sysfs modules (both built-in and dynamically loaded) + 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["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