From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0088.outbound.protection.outlook.com [104.47.42.88]) by dpdk.org (Postfix) with ESMTP id 075415587 for ; Thu, 1 Sep 2016 06:42:29 +0200 (CEST) Received: from BLUPR0301CA0036.namprd03.prod.outlook.com (10.162.113.174) by MWHPR03MB2445.namprd03.prod.outlook.com (10.169.200.139) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.13; Thu, 1 Sep 2016 04:42:27 +0000 Received: from BL2FFO11OLC014.protection.gbl (2a01:111:f400:7c09::115) by BLUPR0301CA0036.outlook.office365.com (2a01:111:e400:5259::46) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9 via Frontend Transport; Thu, 1 Sep 2016 04:42:27 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11OLC014.mail.protection.outlook.com (10.173.160.144) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Thu, 1 Sep 2016 04:42:26 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u814g8R3029498; Wed, 31 Aug 2016 21:42:24 -0700 From: Shreyansh Jain To: , CC: , Shreyansh Jain Date: Thu, 1 Sep 2016 10:11:55 +0530 Message-ID: <1472704915-13112-6-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472704915-13112-1-git-send-email-shreyansh.jain@nxp.com> References: <1472704915-13112-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131171785468379645; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(105606002)(50466002)(4326007)(92566002)(626004)(2906002)(189998001)(50226002)(575784001)(86362001)(81156014)(81166006)(8676002)(47776003)(8936002)(68736007)(87936001)(7846002)(8666005)(356003)(106466001)(48376002)(305945005)(19580395003)(19580405001)(586003)(5003940100001)(5660300001)(85426001)(33646002)(77096005)(36756003)(5001770100001)(104016004)(97736004)(50986999)(69596002)(11100500001)(2950100001)(229853001)(76176999)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2445; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC014; 1:grvACwXLqPMpTJmti2kROEIb2ROzDC6k+pLH88vazlBEr/v3+Sents7ii2VnBiz5HuTcZ3nkc1LRZnaMFnxYcnMqKHsG53sV2lyHmJSbDLG8xsd5PMPOxCKpizcV5NMsSHQx2IkxqZqEm/UQ7kHz0O9QOayYHeG7m1U/lX6iWK7kIQNQjw98GHEjTz7CKCCP08jOJnlGlSfLMoxvCm1BW6CCmAisBlT7T0zTw2Qn92WPGZilLJYUp/glscVPm8Ry/Dv2XZvtIbks1yjVZHrIpdFRPVGYg/gP4zCz61tStAiU9be5xCZeuihNGNSwgkfDNmnJTNWZ9+DZB9rXMGCYibF6MBY58vN4n1nYOdiPa8GHBYmQ7RHzkPR6CknnXpqF2jZsTjNSE+IH9HBqzvNHbU08+ArHu9nY8axiqGSxKticNd/o+n1MEDb3GE+Bjx2wqeJyWPff/WguqOl9GOSSq6EQDKHhmZTcpD1PNyQYsoLxnwV7DnMoLje/FossxQvNawi5UQB8565j6O81cqMAbbTnPMzI53XIBu2uELuTb+nZ1Uc7dG6PV0LQraxYPDiUgY5LAmk4IvUAwcMOyfG51N/Ot4aamhDzjg1m2qOR4jerkAGRGYmOKZ8ieXBMR4udgOmRp/iMiQSbvmkM0HpBwUFrgS+56ypJz+0zHvNrHbtIYa6Kpqw9k+7LWZ3K1LkamhhyboHOhwmBVneUL0Jkpuknynyjo8qJx6sMpGcLqKA= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 05bd695e-1fc5-405e-20a0-08d3d2225fda X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2445; 2:VLeSxJYARwkMb4Fsph8ynFlCnsVjSIPGFUMNneMhudraGXjpn34kYFm4piBKxWFkuIYHfDo+r/ZrWqf2p4hK0yh2FFU06Q1dYmPbX9LVFDWlasDYRGtTinJdTzcnSpcUSCwGUgAZpsFhEUixRVub8xHCRgswHoVmNds3oYS2cgeA9Xeg3ro5ApqhpcxNWjSA; 3:i2mbCUNIenQvWK8x2DTVuU7ocDxBRCWCNFjFuqDo+zVCSw/qIfTq7zp39oViSkJryyA000vfp9mG/LjAxGRG9nBChMT43yF0cSpgY8/00BZvtn+M/J2xigGO4ES6foFJrY+HV022SgBXYawLBOFb7sReREszga3UYNExpceF7tofdvVne6FrnzOU18bMFyF2WpwPkTyYRLw90CvMut2Vzv7vAWcB2fvuyOwLCjznM3k=; 25:52wE6Lz9cxaGJqQ8NkhPzVf8Lyk+hWa4bBXn61WaUYL36DmCDAo94d4EYOLiNS3sFanEsRssIP+U4xAIrKMH1p96ZdAu7HQmkeyL65nHpjK59DHqPPnJJ1h2q3jgR3Fs9ikB62ZQCbjInsbF/UO6geozACnubFy74tkLvsTlQk4B+ltLrhXsDQjljB2AW7j45svgHs+S+QiFVNyTX+lOO5Sdj7MEDU7NS8vtfQOtyXL2SKfbbz5/+nQM8C0G74k0OOubcINI8tzqhxMXxSpZskq2/R/mSh36aTZwX4/WBkgt2TJ1oYLjMi2YNGFlyNqB+P2zx+IKOk20YRvvlUuu2j1fQr8+bj3VnnrlOSv5h07d+nGVemxqSDwto48LnvK652qLFvrW1GkVdG5G/l3GPXdfZBLS+heIkoRz4heV0no= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:MWHPR03MB2445; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2445; 31:X+aDHj2Z13HPkces2W/SfUvrN4gkC3F8g26jGURt1j9mK91RjZzo7SwZACGbsA0tIO/P9+awWZeDirjhwLC4xGvo6J+83PaWtH/MkUkOflHy93NY/UCVO6ObeWX0aT6453OfBQQ1EjUpuOVR7HwNUR95jLZFnxVLr69kADaDZPG54HGJRTC4TI6LgWdOTKYyhxVhF19vhKrWEIqY75Rh6+o41WIhEqQuDiarMSciJLs=; 4:2YK8shQKZ9cvsE16JKn+Yg5gJRvOWzyEilxHYxtuwhquCdTEFuZy6NS9O16eDz86IyzEidAoqFpw3C8qJtjkNF9JZX/sbzKDlwwT03J85j6S5C43DtKRUJH1w73EYn7Qiv+kVpW9f1B0vUeOoO58WF1PikozrW+1UVebmnIJppbvADEStDkYn/M05EFGvW06Z6VRgOw/PoLqJulVZmGVDSagHkHTU5rfb3zpzXsQRTpVJvT/kSDk24S7SalEUmB2bWf14gZ5qfRtt8GWK4+fWTl6zd/sa0RLkKoS3kmqGnduOz9Cjk2QbotVYZO+gyX3JW2xN1DM52lUCFczRVyw20HUffOEAZ40RCYDyve3Elq1fO4EFqBgmUTmI9fXCO36D+d1rjU2y53+KiSNunatDyAXNHir+4cn5aVqEK44cZPSDfBF62/XpRBdoCM7eC1OW+0br9iN8aEvqFKg4CONVI8MLu82sx9FCrXTBwde8RbxRdvpozTFJ6fK8eeEDX7d4BlPyI1mp3YuCeYVuvSOLo5uCY5i5qgAO2DNP62OEuA= 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)(8121501046)(5005006)(13015025)(13017025)(13024025)(13023025)(13018025)(10201501046)(3002001)(6055026); SRVR:MWHPR03MB2445; BCL:0; PCL:0; RULEID:(400006); SRVR:MWHPR03MB2445; X-Forefront-PRVS: 0052308DC6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2445; 23:2oTZSCoT6BrmkyacX5wqG083reT8dXmgmD1zXJDa7?= =?us-ascii?Q?2buDHP0TXgtv3Cw2re44TY6W9I31yuQv7HyYSgHQdWoo8KzGgryWGx3FPPMJ?= =?us-ascii?Q?8YWqOTSE+ROVUJ/Mmnsf6LUM/bNO6fhGPtJZXGpXQ9AigaIWIzlxKBaoSiaU?= =?us-ascii?Q?UGvYrWWFQp04hnXznuVlK1jcte1OATgbJtH7p2DfAo2I7MCFFnTquyZrq70a?= =?us-ascii?Q?CgcXZZP9lsMYd+WEQP72Kukz2KKZLIgGHRzS2E+8rMekUiX73zoeCIMKl0DW?= =?us-ascii?Q?edBb7iMmshgq58HsQu7dfkJXiCE4jgUmwPn9iwI4uuejqiNHO3azyU/CvSdA?= =?us-ascii?Q?ysG4O70fw2BUzgsxyh4mRURWlhsX75Qj+TPLOR3iqJurrH0fL1E832cHvDMh?= =?us-ascii?Q?NfYVMOmvEEq1yULB/0Xhzhyc05FmgzHGCWoebM/y40MCGgGz25xhb16jImu0?= =?us-ascii?Q?jwAvUWBrV8PZe2FtHnm/4LUsAGc1GGs6Pz8wdp6vZxk1Fk3FSEE9oqnLdcUy?= =?us-ascii?Q?9GpiDm9X5zQkkV8TwNioYweOCMqjDxLhDab/AWWd/6FjP9igR85/gWMB53dr?= =?us-ascii?Q?n6+/vPi/uC6S3dnWOBBzQqZcsV9TlGqAGqj4KTu8lmDu4lDIlG+wmnsPoU6n?= =?us-ascii?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RrgXFbzezQC2hN8FvApbSXTSIBNzPFN0fLZTWbbCIZoI8izJzj+kw83TQbq9dLNOvD/H0brHYHJRR+0wIaTBlTxXS6DKPa0oWzVaMT4grvwXcvZqlBFDzN9K6Na6otaI1315R+Ykzbr0=; 24:MIaHQCRjG2KgjtLIth3jFga8AoTdb+cwwvNGf51XntNZsJhM2B/Y4uV3+fZR9g/Rc5V7KgFZgUE3bu7uBXsm9HPDzrGIwtYYYs/7G4RF11g=; 7:M/kyoynrVE5eWGVIFtWN4PbhZvVfvGdCmvv0b7PxPXsKilnK7H//MK4B7qu+FvBp1nH6l6SmPNeCim4CKcnolELoF38WmHEprcsVnUc2M8Nec0BsD0lPgt/GZ0gJz01fTL0tYyPxxVNICigFVM1ZyIiIz+EIxLHJjcwCBOshRmJV4gTJQIlV+7Hr7ry8Wtk578W+GVZEoDrt7u9TVNwBBiW6Op2ll7h3jpq55+nWuKm4ksPxLz8jmwmlEnzx01YX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2016 04:42:26.5727 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2445 Subject: [dpdk-dev] [PATCH 5/5] eal/linux: extract function rte_eal_get_kernel_driver_by_path 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, 01 Sep 2016 04:42:29 -0000 From: Jan Viktorin 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/common/eal_private.h | 14 ++++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 29 +++++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 31 +------------------------------ 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 0740c0c..5ea30a2 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -271,6 +271,20 @@ int rte_eal_check_module(const char *module_name); int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid); /** + * Extrat 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 8711d9a..9a4c498 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -973,3 +973,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 4792d05..f923e42 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