From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0084.outbound.protection.outlook.com [104.47.38.84]) by dpdk.org (Postfix) with ESMTP id 6EB0D475D for ; Mon, 24 Oct 2016 13:59:20 +0200 (CEST) Received: from DM2PR03CA0024.namprd03.prod.outlook.com (10.141.96.23) by CY1PR03MB2380.namprd03.prod.outlook.com (10.167.8.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Mon, 24 Oct 2016 11:59:18 +0000 Received: from BL2FFO11FD009.protection.gbl (2a01:111:f400:7c09::158) by DM2PR03CA0024.outlook.office365.com (2a01:111:e400:2428::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12 via Frontend Transport; Mon, 24 Oct 2016 11:59:18 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD009.mail.protection.outlook.com (10.173.161.15) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.669.7 via Frontend Transport; Mon, 24 Oct 2016 11:59:18 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u9OBwEMO008267; Mon, 24 Oct 2016 04:59:15 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain Date: Mon, 24 Oct 2016 17:29:23 +0530 Message-ID: <1477310380-17944-5-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> References: <1476539108-13170-1-git-send-email-shreyansh.jain@nxp.com> <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131217839583930253; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(19580405001)(2906002)(4326007)(33646002)(81156014)(8676002)(81166006)(586003)(305945005)(189998001)(7846002)(104016004)(6916009)(76176999)(2950100002)(8666005)(356003)(19580395003)(36756003)(50986999)(97736004)(110136003)(92566002)(105606002)(50226002)(106466001)(8936002)(86362001)(575784001)(48376002)(87936001)(229853001)(2351001)(85426001)(6666003)(77096005)(47776003)(626004)(5003940100001)(11100500001)(68736007)(50466002)(5660300001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2380; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD009; 1:huV7oy0EOsPCcQUmFqLfht9N8Y6loEoiDLQreKpp9yoRqHaXH/Wetq/pRx71kB83dJGkaPuiGBC+2KA8Wtzo8a1gZoZOi9hMEtX3h9ZXVqPAYwIainkQmC0uOlTPHX1dokvlKQqQI2W7S2z9ZlPxjHyhphvezmkSxdlUbWFVumCl7p1YTZF6rvzjPqtkEbkjHtQl1QnwPihTgp9J1dD3O0fxLJ7rjmE/yVh98gzDyG945aPbLIg4UN7p6ILFnxuD5Xc/WEGwx9L+18yj3u/C2aSaMYlQKIwuYEtWQYBDKLJyHeZHHtmT5S8jJItbFNYsBOmabapSW2m3eJ1lTSD+6osB5f0oeDxzVeZPFv6waUytf7e2YA5IJW3iUDSD8obxHGFKXbpy8ki7zLuDdrdOgRQ/lpxjE7VighFeGfWP1TbE/TriI9U6AwyQ4N+QuWxc+ipnwPKw6nVBths7sdWvvYw+igqQ0i/kbBMEpWUI6otmajH12u3KgeuecFEJW+wxHSYUqCdTr0o95rdRLkRREodbXoi+wqBn13gmWYwuFaCJt6mBNWhHR55UA1ezth9ofbSB2oeCsIAX48JYBx8MyjZeiDUT7s9XGGbwxyDJAApWG97YJ89eUGaWIYMvHnefh0NuMNOd+JhHj0DgZ7g44sVhKLug0s+3ZWHAX6gL6o3WlHj/a07BpvmKlC7aSbHMyNmjttM3yKfSvUAWXr762YQDU/9V3f+3PCSHNgCNfso= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: b361c93e-8f33-475b-278d-08d3fc052f0f X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2380; 2:oEzBtO+BwVVrB6q4DmbwWnw5omxoy32/1rDLVLOUNJfpKJVKXANmOzqZRnqzNNsdSDYBY3Rd+O0TsULKe5JBeuvr6KOaCx5BEvtPlxD0tJmKx09/9bkE7TMDUo6RR7poI8K6Q5GARTzSkSFDI/16Ug8CJRr8js2BFcZdP4kjwZza5XdhL2Ybxcj3DbsH06N1+ATyMyN1bRe8xdNk9eayoQ==; 3:nHus8ziFrU7nhOcYXrd/IlGvSHXmXVHVhOgo4LCu6+g/3SqESySJEPL9yWHHGNYpYLYPkkszId7C5j7G8H5/5hlZia4cmljNNBGVfpIflo7D1L9710yu3/bKhbnNzUyWFHkRPji/lqlDvhNXg3UUEdLdNG0yz2t9I1HQ/JZdby7HL4UYyGhDdlcIgE3Ua2r2ZmDBeT+Ih9W3ZzAfLqcEYKXtvJt1MqQG2tvAvZa+YHeQ1zUEd8x0eEaVL06dhcwn; 25:sUiwT4mDYSD/jRvgTR/i+tGhR7dzWpSH0gmihI68wX79gnJ/5XPTlfOksjel1cFJ8Bkj8LJB8lbzV2HOH70D6YNA1z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WIEvgF3yyD7tQVv7kbFybmF955hkvYZflQemViiInZn8ESbX+DYuiZwHpAgmXXz5ykpQZY34nnXJnUnArKoxrOcbvEFq3CuSe1l7xkR/+nVFj8AfJFJuvP/GuQ8KFgp5BzmT9VbWjOzxJAmB9uZbD5lrog8sZzIkQvAi8LIztytrVpWEhK1iyU2E2clhHMkE2/dgfNopugG0sJSJ7j36Kr2cFM0Yfu5aum52aoZUsJURKlnp7CD9/HLpZlT1ZpFQmyAmn9FwJJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13023025)(13015025)(13017025)(13018025)(13024025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:CY1PR03MB2380; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB2380; X-Forefront-PRVS: 0105DAA385 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2380; 23:OKF/5EU/MkbX3kelKCCLZIebs8yaQz2cyU8IXOlEY?= =?us-ascii?Q?tfCy9r+rIAHpxCzFr6z73iTiVsgZBJNja8x1KpgpjZftUReq2GrHfGmv3oJR?= =?us-ascii?Q?qr7avIW4X08Cg2IOaM5krzNG6HT7WpSsECgG7WbzOpp10xUEv4AKrcux9tDt?= =?us-ascii?Q?6mN71wfJ6QTJu5ByTZOPb8ohWTG7C34ttdSLz9n2CmbAHfil88UEZuI+jCB7?= =?us-ascii?Q?LiJuiPZXayI9l+Cr/YBtlPDbmLDJTAu9pDL7TcyplR0qAoMgz5JnbXXqEstY?= =?us-ascii?Q?BanzkytnwvtuhMEFBIILf6UhgSTIx05FVrmlhfLTClpP7eQZCndhjEyA/mTN?= =?us-ascii?Q?XQD6ofZWRt5OmgChvWbEqE/Vh+JMKewMWZOBUzcagNOMqsJyBAgNRBqpNk0L?= =?us-ascii?Q?gVVLTmodiwWZaeehbD63dcVO188HZUsP9Pw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YVK6+TsyP3Gls2s5YDBfWyfDpskffvAuKgd5WcurcFjiWz/rf6b9kmo2SFhn6wXlkueED6FneohVLn1wo0OTUn066QZ9oGgi7N3SDetfPJU4Ht1DA0IUjQey3tj3Ahi8KMEtu5Pbq507paq7G6sCnjFfRResvyf8I+So54tLhCHQPDOQCfHlp+s/LZllHfPvWjZaa8uWtfBsRNWmN7VPUhjpoLB81tvU7K64fWvVZZ9plHEIUExZ8I+exLnXVSb5i5TKXzCx38zKhwFTWjhtD/Sff7fRU5X8d; 5:0v7OCWbG880GnUed7G4jpCnZ/VYk4ZDYsxeP/VBG8R89iAyBA/Nw1NPp8AqZE3vNXL7KdnkDenxPYRPEtL90wLBMu2beSlPa/RYGu5UF6Fy/gpZ9DrPta4HbUfVr7hKsrH9sK/stqOyNEMxR+SYgqY7LonafWWPdwvIVB7Qa/55UCn3rZLB4oLkM5hxiT/Gl; 24:JbbjAFbMYDlk3A+W79WwlDQIWNhYRhmo2pN47HjDrSAvwuVtejOrwtjAOBwuwCj87MthqyGVMsgPfebmrHArtCutmrV5w3W4M6IbPBo3WLk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2380; 7:SyjaIfQCVOAa6dqAr2FYV7zg6JYOcYiDt74cM1ZNoWPkNPr1YQxCk/RbUzWjny3fY7vEkk7F7nVlHThHKH7CbqNiXSaoAOcr1hHEhv1njZJf0J3zcFxHT/yQwCSlBfMr8cEqcmvt9KLsAho5BwdkaTzv4owC0axJZrc4eW65PPZKD7i7JArfjsGJYUdLEzfwRALTdFakdQmplbrrK7sUmoKdrwVxI40PI3vRhlpkmX3bigEzFfapF25jJMghOIZpEnFXWZFl9QBC+S+aVrXgpArzeMitqXYPPmxMendU0S0qTxhMYgHXJmiJOHx5m79e0ggupbTAoe10OBzmCHRzBd+gIeSPZ01d2KlnTS3P4+k= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2016 11:59:18.2214 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB2380 Subject: [dpdk-dev] [PATCH v5 04/21] eal/linux: generalize PCI kernel driver extraction to EAL 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, 24 Oct 2016 11:59:21 -0000 From: Jan Viktorin Generalize the PCI-specific pci_get_kernel_driver_by_path. The function is general enough, we have just moved it to eal.c, changed the prefix to rte_eal and provided it privately to other parts of EAL. Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++++ lib/librte_eal/common/eal_private.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 29 +++++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 31 +------------------------------ 4 files changed, 51 insertions(+), 30 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 5271fc2..9b93da3 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -640,3 +640,10 @@ rte_eal_unbind_kernel_driver(const char *devpath __rte_unused, { return -ENOTSUP; } + +int +rte_eal_get_kernel_driver_by_path(const char *filename __rte_unused, + char *dri_name __rte_unused) +{ + return -ENOTSUP; +} diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index b0c208a..c8c2131 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -269,6 +269,20 @@ int rte_eal_check_module(const char *module_name); int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid); /** + * Extract the kernel driver name from the absolute path to the driver. + * + * @param filename path to the driver ("/driver") + * @path dri_name target buffer where to place the driver name + * (should be at least PATH_MAX long) + * + * @return + * -1 on failure + * 0 when successful + * 1 when there is no such driver + */ +int rte_eal_get_kernel_driver_by_path(const char *filename, char *dri_name); + +/** * Get cpu core_id. * * This function is private to the EAL. diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 5f6676d..00af21c 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -969,3 +969,32 @@ error: fclose(f); return -1; } + +int +rte_eal_get_kernel_driver_by_path(const char *filename, char *dri_name) +{ + int count; + char path[PATH_MAX]; + char *name; + + if (!filename || !dri_name) + return -1; + + count = readlink(filename, path, PATH_MAX); + if (count >= PATH_MAX) + return -1; + + /* For device does not have a driver */ + if (count < 0) + return 1; + + path[count] = '\0'; + + name = strrchr(path, '/'); + if (name) { + strncpy(dri_name, name + 1, strlen(name + 1) + 1); + return 0; + } + + return -1; +} diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index a03553f..e1cf9e8 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -78,35 +78,6 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev) return rte_eal_unbind_kernel_driver(devpath, devid); } -static int -pci_get_kernel_driver_by_path(const char *filename, char *dri_name) -{ - int count; - char path[PATH_MAX]; - char *name; - - if (!filename || !dri_name) - return -1; - - count = readlink(filename, path, PATH_MAX); - if (count >= PATH_MAX) - return -1; - - /* For device does not have a driver */ - if (count < 0) - return 1; - - path[count] = '\0'; - - name = strrchr(path, '/'); - if (name) { - strncpy(dri_name, name + 1, strlen(name + 1) + 1); - return 0; - } - - return -1; -} - /* Map pci device */ int rte_eal_pci_map_device(struct rte_pci_device *dev) @@ -354,7 +325,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, /* parse driver */ snprintf(filename, sizeof(filename), "%s/driver", dirname); - ret = pci_get_kernel_driver_by_path(filename, driver); + ret = rte_eal_get_kernel_driver_by_path(filename, driver); if (ret < 0) { RTE_LOG(ERR, EAL, "Fail to get kernel driver\n"); free(dev); -- 2.7.4