From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0086.outbound.protection.outlook.com [157.56.111.86]) by dpdk.org (Postfix) with ESMTP id 4005B9A92 for ; Mon, 7 Dec 2015 19:36:30 +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 BY2PR07MB1444.namprd07.prod.outlook.com (10.162.76.146) with Microsoft SMTP Server (TLS) id 15.1.331.20; Mon, 7 Dec 2015 18:36:27 +0000 From: Kamil Rytarowski To: Date: Mon, 7 Dec 2015 19:36:04 +0100 Message-ID: <1449513365-22282-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1449507460-32038-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> References: <1449507460-32038-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: AM3PR01CA036.eurprd01.prod.exchangelabs.com (10.141.191.26) To BY2PR07MB1444.namprd07.prod.outlook.com (25.162.76.146) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 2:aqESMMp01h7+ffHXVlEGM8rnz6TFcYVAHPTzxVWBGeTLZZ7IlbhOqIUrwPsmSfIk4QRzaIMH24sQBAqKynk4krjH+M0oAMs+WDilMHAzQ8Y6l+4fCzhSPosySQrUD/tttI5/klGsoYyqEAcuxFInzg==; 3:5MKShQ1GmzTgMZLPgvVCHLWwRNiYdsSijlaGOuxZSuVwJCU1vr0Ve0Hq6jgZnXB9QEKpWCK9tSUHTCSd+sQWicvJhkgeEg2pR1k7HXxKtxPHJnJoxJbiRxuaPka7dy9G; 25:0QFJLaQvmKIyLXVt4bc5gIKx7V+vNAFyrEvAwez/4ptyF2LdGEuAhfAIdOpswRgz9aVbZc3smpSPJFAXNdKN0sQIp+4wALJYJebtY5ReTVFOfxYnuaJ+D+KIBOo3UnGTFJlVXgPRMQ8ImYnwaeXQSAKwFVW3+PISS/xFm5aMZ7pIwYnt/55EVe3U+fAs/s5LM4rSh4Lp0AX5sJAyDP2eygszOeA1Vqru7RG+Q9m7DOp2fBm3+7MO6wfnEmWSQHdzUzmNXuOVkopjc6LmMvtXbQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1444; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 20:JZcNxLQ1e5eDaB4iaMgERi3cd8n+GBo5lhd7z3sbJPa2T9Gaq8X3eyLG4hLvvgmAaKguGhjOBdaIWLk+uOqyH9AhelTdU5tAl2lh4nXs1+T3Z84p8XEoR7x7zfx2A2qTv2lCE3O5dCsdZheuOATkfO3ohzQD60QlLzHaciOr24EfTO1g3G2XYd3fjDJ4+9hvsa/7pIPO7ZJ4ItpUlzysu+RRd7ZM0P7gIzcrxVtTuyRKdaqnYvpugvQfy5N78hgOZKGXVvvbvA1btKkp87e9gB9SFP8f7QNDVdXMHYGMEj7Bpj/LflpzobxypPp/4ELgQi8znzBpiCrl2hSeLqMbpYJm916baX2HCeZLx22Faq4ntm6lxZfc1i0qXMZYzwmBCqZXkdKwmWXF7dFVBJbdVWfQ+ZQILoOssQAjn69AK39RQQb/99QSDeeU40fRKm0/Mm7EbZtgYbrH7e228vdt2zhV3meh6FO5sV3d4LWbbYeyTZr97uCTnpFiVqJenVZJjTEdcDXGi88ef9TmrUljPsMLK1bcTRKChkfntqqkQaqYMaPwG0LsTbx1wTzHivoDEiiStpy1LrhJqyGOht7bsZyE4/6d+ykWeJIapGaH/pg= 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:BY2PR07MB1444; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB1444; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 4:PCfMgJowWliXgs1lM58pAxm3v/JKbTSl1hbM9VjQio5iQ0Jp4gXtJtcnxDTEmXnkOljRqpnzfxJPLYodujV+NtO71G8yUqwpgcAM5t1/yhUc1NgNf6UZrni1C0za1Vh2144s9NKCyp/xHY4k1qGyqOCY4k2Gv9FqP/moZ1I1IMcLWAZVQMJOfEBtK5JG4pzTN0yNpeR1LcLHoG5qoasL9VdHbIHE8wJ/+oa3dLINHdgI4fTg9OlQviaRBYe9sBDrTie+oAKWy5G8jqOrnhUrAzwvx4hy5Yyt1IBYbgEJ9WipN5yh5fRg13xI34SB23wo34hTHYCZ5ay/Q2vMTSvtbfZ/IzNmYqWYQuw3qLkqfvYfhtZVQsae4SWKxQsaWnWUj9NjXxcu9IBzgIiTaSxDYFXfQSu3kMk0wSde0HgMK6BHusXFkXydeRbnlQ0w/Bl+ X-Forefront-PRVS: 078310077C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(50226001)(1096002)(87976001)(86362001)(92566002)(122386002)(105586002)(586003)(42186005)(106356001)(189998001)(2351001)(229853001)(76176999)(48376002)(2950100001)(3846002)(4001430100002)(6116002)(5004730100002)(50466002)(101416001)(47776003)(19580405001)(36756003)(19580395003)(5003940100001)(97736004)(5008740100001)(107886002)(81156007)(40100003)(110136002)(5001960100002)(66066001)(50986999)(77096005)(7099028); 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:zy6joBpmPz47G/cjzxHfVcblbYgR54Dp+vGsZFg6L?= =?us-ascii?Q?syHDWi7TA9HcVygjr11qg9bRE1CMDHeNlH6lzxtQ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?us-ascii?Q?7JUf5qQzcbF5srJcBqHr1DoJ0Vq0+ovWPz/VUF3E4TKEVfAyUdtIiQBEkcCu?= =?us-ascii?Q?kCeq1ky148JhIOqURSqk8Z+8mwh7Y7qT871Ovj1vBehGdUVm7OUwUtWnBMYE?= =?us-ascii?Q?JlucIClbQ4jxtNrLqb8XjsO28NYquM7fYlkAhAjZw7IeONtRQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 5:CO1UOuDWf1M75cHSqj6tKrqn9peZhg1ApWAsF8z9osZmuoDrZ1cyx70ynB1xqNMIAYn8tIraTbDW+avepC0e61UNrPXZtGpibHx0iRT98XquviwBCQubHXM8RcuBaUQuS2i5PNFF5GPRlp/PCFrwJQ==; 24:2PlkscAPXVzbyGaf294oVtyQF2ZPq6dDRWDY+GzcPZOTo1J0R6iE4Qcfqb8I1HOlpqREtLt68tn8xVbl3xZMIliRSmOpPqRWjXWJUoifalU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2015 18:36:27.6224 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB1444 Subject: [dpdk-dev] [PATCH v3 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: Mon, 07 Dec 2015 18:36:30 -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 --- tools/dpdk_nic_bind.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py index f02454e..0318598 100755 --- a/tools/dpdk_nic_bind.py +++ b/tools/dpdk_nic_bind.py @@ -33,7 +33,7 @@ # import sys, os, getopt, subprocess -from os.path import exists, abspath, dirname, basename +from os.path import exists, abspath, dirname, basename, join # The PCI device class for ETHERNET devices @@ -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.5.0