From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0067.outbound.protection.outlook.com [104.47.41.67]) by dpdk.org (Postfix) with ESMTP id 3C14E68EE for ; Thu, 27 Oct 2016 17:17:33 +0200 (CEST) Received: from BN6PR03CA0011.namprd03.prod.outlook.com (10.168.230.149) by CY1PR0301MB1628.namprd03.prod.outlook.com (10.162.166.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Thu, 27 Oct 2016 15:17:32 +0000 Received: from BN1BFFO11FD042.protection.gbl (2a01:111:f400:7c10::1:113) by BN6PR03CA0011.outlook.office365.com (2603:10b6:404:23::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.16 via Frontend Transport; Thu, 27 Oct 2016 15:17:31 +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 BN1BFFO11FD042.mail.protection.outlook.com (10.58.144.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Thu, 27 Oct 2016 15:17:31 +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 u9RFGIfY027183; Thu, 27 Oct 2016 08:17:29 -0700 From: Shreyansh Jain To: Date: Thu, 27 Oct 2016 20:47:30 +0530 Message-ID: <1477581467-12588-5-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> References: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com> <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131220550516933407; (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)(1109001)(1110001)(339900001)(189002)(199003)(33646002)(36756003)(8936002)(2950100002)(626004)(19580405001)(19580395003)(11100500001)(5003940100001)(586003)(50226002)(92566002)(6916009)(110136003)(68736007)(2351001)(229853001)(2906002)(105606002)(7846002)(87936001)(85426001)(106466001)(305945005)(47776003)(50466002)(77096005)(81156014)(81166006)(189998001)(48376002)(76176999)(356003)(50986999)(104016004)(8676002)(6666003)(86362001)(575784001)(8666005)(4326007)(5660300001)(97736004)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1628; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD042; 1:lWxIhHKJphfcsKUFvcelpfLaUdHR4wsZarqu8esvJE0/14Qh6nU8JWxBMDR7YRBG0oy0MY6Hcb+28RlazYamlhT/WAUy2yXJAG+eEn1XpYKFsMjrLpIgkxRzpq/EogT3najZ3hYeREsoyx9P1/lpFMqNDcB5mdE8bhV8GydL0sA1Ma/e5dQs0f+gkYEImU/A1tEA7WzL9mFOg99ga+YeYf9bCpEE9x7quZlvBuimTUOb+nhy1yfT3nFWqeG2s3Y89jFVt302GZLTdf8spM8ipIxxJNlJ4kYoyCPp3QwoWaPo2v3mpfhxJSHr7Uca563tmUNHatq3vMzdpkZuu9NDMuRbGOrpGJTtuLDPzc+IokJa7aYSkb8KFqTBGm9TtnCzImrji5X5HnHKKhD68kKD0+rWl8qNCGsDYIQRArSeF566h+1OmQMJWs3Cq3lGzkdf9q1V9Hu89qVC/06/U6EnX0zlFCQxBaYIOQE2unkmno0+CXAJvsOk94xP81W9tcUL7l/vQYJGkHDQEFAiUrlMi/2W4mMM7On4H49+DowwQaNFy5eS2oH+tM/oe+nZaF1GHLgho0g6sGIFlaHJas6B2xBi8bGsOf0z8LpJ0463mK3IuzLSa0ZppoSowYGXMtTTT425Ps6fAZtMYY+gpeKxY1tW7bnPhFJy9+jnIwdzPXY89918KGrDoVgGzGtJbGTZOgFQcRKi72MoTWbSJZ57vJ9XB4IjnSskDRFMvdkOzXA= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 7cab0a24-fd7d-4749-a1bd-08d3fe7c5f3f X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 2:lJd7+6CvbFW9viAA4iC3bMx+ZizwPj0RNZiXI8QYVvpKW2cO312PepVHpWp2T4eNBVXIdv/qyzCftmG3iq1Hp/qwT1eSrYhH6HdEO+evGUNaUbYuD/psGfYXlIeeJlEdzcXd8PP4ViasEY8VUMAOPecvKUkVDs6aNcsgowDvNc13FTTA/xVKl2G+STiGI9scDt/a7a6g+ED0bcFVW3lEzQ==; 3:iyv4TPSa/8Odf8XOSvoH6BqQW5T4f3rE3QlLZIc0ypzgvZDGL0EbvpDJL+wjUyZrqyNb/oaqEyytH6d/SF3F7xNYdq8qq0Robz+IponEfJ/NIqjULe5vTQTeZcB5W2QgM95Z1THIsbkr0WnUD27GL5qcbmLSEcVSTF4Ebuu04+mIB8UvuD9Q1FMV6GQ/6pCem820hA95Gip1/WGk1zXM8S/UGyt0D1m65SAjUV0xptGo1xvkE89PfnPvd5oulTLW; 25:tpoDAxBNEiWE/X4LqtyNicWPez/4/uSlmqntyOwTEn72zZOTc+9K+VlR8iBvrHVd9duX15oQfQuk0HIpU++23qjwEhp/cCUR6rGXkHcAVJ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yGnzPhxFsV2/EsfWDOnQZntS0fYdB1/8Pb/5nu5Nyh69bRdXO2UqceAIZ6cljiE0LGroPtJ2rn5zShDFt/izTYQh5fZJSIrqmdEcnbO/0V9ukXBFPvYEWJ78x/gOSBn3TTOohMiRXrVMWbdBJ26rn99I7uWnnybc2imnis1lnbGQBSxB7O4DhrZ+zkAPPAL0GyLn+dVRCr8Y3nRNcT/BK14R27sFIEsJrDWi5FtnTQEIT4d4/rPJtPmxCxqE0xs 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)(13017025)(13018025)(13024025)(13023025)(13015025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB1628; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1628; X-Forefront-PRVS: 0108A997B2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1628; 23:0iGJHbLj4QaIFPOc4utkjzOHW+j0feIW2Y8kcp7?= =?us-ascii?Q?4W81lGgDk9XSpofGhLpj7cJhtJx1Gmer2CrAZB/CdtwfZwYPhoKDHRSv9CtL?= =?us-ascii?Q?yls0NSc3O2cYBQ8eyBor9TgnsrmUFHXVV024M0Fu8v/qgOwER9Wy966cFy3U?= =?us-ascii?Q?alK5d6KhsgOjJqdOgobjAdxYTupUo+zdb5Ev3DDA4gUoe8AdboiPsQcrt05b?= =?us-ascii?Q?O1JKjxXVUdbYR0DYCi0nuBkbdHrZIU4ZxjhiCYMRvH+aes8LKGKwLKlFeypz?= =?us-ascii?Q?kh6RN4dmeyBjpv0Yeft2IO8CihgzjziopGcBPh5/AYGrE8OvpKeD1UGgeEdY?= =?us-ascii?Q?xWmlDaWvyEyZ+qTHbQg6IWJcfKpmGuyDq/hUhlyBlYQ3b3CZqSnDoq3LL5Nf?= =?us-ascii?Q?48JMpNIcZQQdAPMwU1F5e126yf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YSourbuvuMyC2KTGZqx6L3p1ajPDdizdbH5b7cbrakScCGPmOXkFGUeE5VE57qSA16KeKsAPc29hkwd++NwU51H50Mx3Bk4jiyDU2cThlrvlb1U1ZbqdDARIkOAuhrMt1MAxayorromZfrprpg+mEOqVHb+x8smDBkQGBrhoGDoSSmnzBIuBgS4djnIdlOLDzF6+HOU1qkvACWTZhIGZFlet0UvoqfGsJKeqgbefDFk5Q8NNird1hWogisNFi0sQd3ZryOUZiaTRp4XeVxC5BP4gqTpONyTTtuU2DUK16Hm+LnVVK4Cm; 5:YlkTz5zesp+1JxbLrMjpHMsKPLonseOqapK0yJcb1NfkW4YlvI1ldMI4+gKziho+IE+Xo0nzxSe8Y6JXnMrfQR52Dj+LgAPv2ynLvb2qzvsfRgXGH07bGmaw/tDeickOwEAloyveCQoK6cE+OVXokq2YWTHc04PdPcSEV2be+uBz0KAyoRgsTL9g4W8O84OZ; 24:KNT7fFBuOfVsKxrlOURQJvldy71xMwafTiPrWNzxWj99Vt/pgjAGjOpvBpidFjyEcHwy8hgK89bSzJH+Cjx+hHb5vd4pvnx2tD2Qpks33NI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 7:8D5BNWJdk4RMR/7t37eITFZyZvEZQj1eCgDIQsGADD0x6Y+e1KTfNImXkjNxP7ZdhOIhUjUGnL9w+xsHUiDD3clXvIAkjILlQCXC5GL3lRESAl63/8+hvkIu2G69QnV+x5AT8EXjswDqtsG9PaVRYjt26hVeR5cUvxftOB7d0WPHDOR6xqnT0JAyNXKUCcCdkodmEcEKTLxP2WcxYTgG1R8nySQlu+hH2k3Yw0TlVHyusSfs9sLZPlw3OP7GkGt86oSxPriUP94A1MbYYMDEIzNXXq/Mi+Z1uzLUmUjkcLXMclUsddt7w8PbT4QfvJwKArMQLhnsMLzU/iNR2ibTpUcVo6oDWdTtGIUdwdyVscc= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2016 15:17:31.4905 (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: CY1PR0301MB1628 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v6 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: Thu, 27 Oct 2016 15:17:33 -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