From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0081.outbound.protection.outlook.com [104.47.40.81]) by dpdk.org (Postfix) with ESMTP id 5B17A5591 for ; Tue, 27 Sep 2016 16:12:35 +0200 (CEST) Received: from BN6PR03CA0008.namprd03.prod.outlook.com (10.168.230.146) by BN3PR03MB2226.namprd03.prod.outlook.com (10.166.74.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Tue, 27 Sep 2016 14:12:33 +0000 Received: from BN1BFFO11FD001.protection.gbl (2a01:111:f400:7c10::1:142) by BN6PR03CA0008.outlook.office365.com (2603:10b6:404:23::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5 via Frontend Transport; Tue, 27 Sep 2016 14:12:34 +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 BN1BFFO11FD001.mail.protection.outlook.com (10.58.144.64) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Tue, 27 Sep 2016 14:12:33 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u8REBqch027766; Tue, 27 Sep 2016 07:12:31 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain Date: Tue, 27 Sep 2016 19:42:31 +0530 Message-ID: <1474985551-14219-5-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474985551-14219-1-git-send-email-shreyansh.jain@nxp.com> References: <1472704915-13112-1-git-send-email-shreyansh.jain@nxp.com> <1474985551-14219-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131194591538787649; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(356003)(8936002)(6916009)(50226002)(2906002)(4326007)(305945005)(2950100002)(7846002)(19580395003)(19580405001)(5003940100001)(8666005)(86362001)(575784001)(110136003)(626004)(586003)(85426001)(87936001)(5660300001)(189998001)(69596002)(92566002)(105606002)(106466001)(2351001)(229853001)(77096005)(76176999)(97736004)(47776003)(50986999)(36756003)(68736007)(48376002)(50466002)(104016004)(81166006)(81156014)(8676002)(33646002)(7059030)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2226; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD001; 1:vZJv620dVT5bXVcQ0RMp7Vj7h5bEY4jpBdviyihVu9ME5olxHLUxXsC1XabRL6Ab90G/uZ3XBhFMO4cDsNShGLMFavE3GXhfzDpVLiE94MyBz9kZ7n45NkxWYFiLpZEFummGfS8wBMt4REeC0SuyCMQjLZmpNBraHhE594+NTfC+qozt7pikXQD18nSMrMQN/5Do55cG9H6QiXcYCIHiuf4g0N8HLFYFIrOOJkIL4wffXjo9C+5NBXYLFbPwhYZALLMpjlFDkmRqUD5d3R1Hky7a4nIYLYcwBjSmA7bfKtL3MZ9vVtdWpSaR32x0OIpA96mrLl5hTAG1/r00/uVD2bVzm10zG9IGBH5+XpJ3gkzHVLIg6iKRQ9toum8ctzmTubB/FatcBbzYb3IXbGXxxUnEWPM7l0bVNWJZ4SN7Bp/Hdmwj1cv56rocgy4ctEUk1VEv0EieCYs0Q01BmXP1BRfPvmbAkgF/0qYG9Sz6Vmz9KsPLHhGhecjX0DQbw9BBFuMjD1dv+q2kFA8w7WngZgNFETvVT8aoAAcItsMCBfyf/XYHGwTnZUY7C3yREYcReOOApRx+8VVyBV8QRrwXwQjR3dGccky7+/CsR/sL+Mao/9cMzIeB0MrG7ZdhVR3uoWx8g+g5Y2YzQ3mr26shbzjvUQTxeyfJ0M506VH7hHrpNi6dT0zAVsn48eWhTjDaJ2223ZVstEm2b+bLCYzRA4kLqsQcH2HCJ96NxmC52/o= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 88f67609-e6f7-4d2c-d3e0-08d3e6e05393 X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2226; 2:bCS2iCsCO0ufDUZ+ttRtbgBOxGZGT/5B6jpYHjhU+904ira9eK4QhxXENZsjH6aYCd4vf985FySszb5wxsm9UY4yEFJoVpVWj5qshYQT+mVbaRLoNQ1vgyu1c/yv39bozwupdBq7LF+AVJfv02hErKgKoGVxAczSXX/lINFRO2OzQpwp1jw+E+s62aRhttuf; 3:wX57Rsdg5V2ICSP0U/7aUajjCabjsqjQdzA35yq5PCTec7rA+dP8WMi0zopP0vvCskDzEvoCfI//8rRIpF3K67diYFLA0Ry9UNHWOegGZ0zFfmOCzuRHhQkw5B2AfqN08ycIgTmb8QVJduuBtre/NS+Wa/6TFRLkOX75XLtQz7r5r0ly3S/E0JUCWRA72KCmIK+WPQ8kBHgN50bHrTOT6+ADz3opEPAnWb8YumyxUtk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB2226; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2226; 25:+hHw3Mo4dey1xjm7lbfy6OnDlWOAFYKHe5rYoFIp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VGsSOGRxF9p0KIkjnl7jp1wlLLbPGx7nOu42Qu9h4nA4SS2gPIhByGSAYu8QUzyO3o9FHpoh7AMJq3S27i0Ex0l/36LdVHmgnXSzCZ2xvym8cAffNZ4yQ93eWlqVr+bKASBr9VNPLWQuu6Q8/zc0dhXUrqRELS4br8779igZ0RejJaui7/AvQM5q7k0KIXalzG1GTvM9SymZOOlnm6Sp4xoOME9ZCuTyMdE6rIAjbUz+IjhSHIf16Ga/lqrWzClEWa2L+zCAQ2C6rv+bT76wZquTPr4WeyY0QDAGp5IGMP7egD7ChiObbDfNtFMZuvC0pFIS1j2iUJv/3HCLIaw5luvSIZirL+/s7YE0cEMNWXPEHFd0M0sMmAB+enNCZYqIfG3hgv0jPBUPVC6kjLvlgimdte0EIFTqWTFTmEVtLmb4h8ffXrSbSjuQr5ZBg590ToB6t+mORAf7yksshU1gLfCgdcuDR5iE= 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)(13015025)(13023025)(13024025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:BN3PR03MB2226; BCL:0; PCL:0; RULEID:(400006); SRVR:BN3PR03MB2226; X-Forefront-PRVS: 007814487B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2226; 23:e6kV8mvx5BF6gWluwD9NzAT7gypjwW4ykrT9L2Obf?= =?us-ascii?Q?CT0zF9RTDO8Mz9iRxXLaLg2y8BSKnV9vzBs0EaOlkgO12L/ClT3/C1Px3wyA?= =?us-ascii?Q?cOUP9SUFCjx/socS4EEb/wFzgYBReTr3MqlH3UO4FfICBueypSo7lT0srE7W?= =?us-ascii?Q?JPIPX51jqZOeVRCBzpGp8MPI/YYB+C8kZxfZaDjp8dS+dr7rNca5LP6Mb674?= =?us-ascii?Q?VwULUrB9Sv14ZGDGofsKgKGU4sE0saVmxHDm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shF75lFVxwypS0H4uL6nhMcA+qhN9D45yIh8kJv9oSYgwYSoCpwfLoV2AyTbEQ04teL65vbrZt9u5LztwqLjN31l9Iul+hak/84n7HSCXYGkRbT9k34kxwm8fhqmvxTS3s SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2016 14:12:33.5667 (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: BN3PR03MB2226 Subject: [dpdk-dev] [PATCH v1 4/4] 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: Tue, 27 Sep 2016 14:12:36 -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/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 a9c974b..956afda 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -959,3 +959,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