From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0064.outbound.protection.outlook.com [104.47.41.64]) by dpdk.org (Postfix) with ESMTP id 950BD68E8 for ; Fri, 28 Oct 2016 14:30:36 +0200 (CEST) Received: from DM2PR03CA0049.namprd03.prod.outlook.com (10.141.96.48) by BN3PR03MB2371.namprd03.prod.outlook.com (10.166.75.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12; Fri, 28 Oct 2016 12:30:35 +0000 Received: from BL2FFO11FD022.protection.gbl (2a01:111:f400:7c09::173) by DM2PR03CA0049.outlook.office365.com (2a01:111:e400:2428::48) 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; Fri, 28 Oct 2016 12:30:35 +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 BL2FFO11FD022.mail.protection.outlook.com (10.173.161.101) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Fri, 28 Oct 2016 12:30:34 +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 u9SCPEMG019399; Fri, 28 Oct 2016 05:30:32 -0700 From: Shreyansh Jain To: Date: Fri, 28 Oct 2016 17:56:21 +0530 Message-ID: <1477657598-826-5-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> References: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131221314347758910; (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)(356003)(68736007)(8666005)(7846002)(97736004)(2906002)(575784001)(305945005)(47776003)(81156014)(81166006)(92566002)(8676002)(105606002)(106466001)(586003)(77096005)(86362001)(8936002)(19580395003)(19580405001)(4326007)(50226002)(2950100002)(229853001)(2351001)(33646002)(5003940100001)(85426001)(48376002)(50466002)(87936001)(36756003)(6916009)(104016004)(110136003)(6666003)(626004)(5660300001)(50986999)(11100500001)(76176999)(189998001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2371; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD022; 1:2H6DRc3EfIbEzy18Xfceu7ydPzVfPZ5BtLMq0O+EpnJq5foA+oKwy7VGc1EpP9jut02O1EOhXzXG7X03juv9s7YOj47LksnfEHKnuzMC9as7VXNfopOt277HN9Jn2U/sae0OXYZ1z1xsFquDbdIJo/GbOoxmRDAn9mMBcfP8KW+IncHMJJPk5SBXVC8F5Bd/lCihm0Kms1cm6Z5wrRfq+TcEDNb5vZSmYlqkEsWA8SNj1DzgbvikX/MHIntrVpX6+I9rJ5Pe5A3WsNWGn38m7dzDF3yQKZMY56EGpoVWemtwJQweKwr4DF2lXUYTy1QjhTH/XpbDv5XG9RI2G7YkM5A957LF+4Ymhi62HqvQfHbWxFt6eUnQsPk/c8U3gGYHoXXbT39+6jek5BV66F5oHh9W8M9ZucMj959sZwKDyAUde1vHg+S6a9j/xZM4wG3l89s+9naO1l/ABYwPZf491MtdE5zZjpVCvyuid4VBUWSAE5IVJB+eMdaPj6HHv2b/buLFsXxb0AYYvS1NTP8y8eqbHHB2ZBhizo8mx75kXVMfIQMxqFSe6xDpW69xzH6KdYb51R8bbnNgKefV2w2qP3H9R5TBRBOXWvZ0ywOwxOAb6Mw6zmDvLwPtKZAWAg5te32SXNLCi9lbBbg+a18AsCIx0J1n/PEJk1mwPNaCy4kQAgJ9GkIfUMQkDVzR5OqOMGGbnoEk3SZxSMREm7duKoidYCqPDJeROoa7SkcQEm0= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 1d1f99c5-0d03-4413-13dd-08d3ff2e371d X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2371; 2:0ciPcxPW0PWWddxQhRyPboq3cDspsKRKTQ6HtKbPaHv2Nk2HQQxbh40q29LpstqxDK5w1hz0xCDfaj5pKBVRwX/OOXJdKSCgumTC1VqgU38I0MDS4gl/Dq1PeqMAxlJy40SBWM2NSjNfbPQrfF99qp+YSVQZ4Hg+UrhWXiQwFfFnbkYUd8w1Go0WMB692Tc0rRlS9zMU8HmTxATRjLLDrQ==; 3:ifKavrjdvuxWjQ4MhUjvhP8lKqZ76zRLW7lJq6cFdrCNMq+clhZWd6pxlxqn2RfE5Gsi/16S1uwqf72A4vI4PPlxyYdxVz5+P7ctr8Dv9deojxo/7ZnlEW80B0D58vNC7nGH7W7L1B0bqu8ns+v+K8an2k74KhrIBX1lSVBU72vBeOD70B/INEhHmk8zmyqwj7qqUPb6ceFPU4d6shs3ItrQLItVdh+pu6ic4spuKPIX9DdbABKon1soeE31+Ezp X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB2371; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2371; 25:hqOJBVUfiEtQgUBsNCIY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I0xakFIYTb/CwplTsr6A==; 4:BdiCQz5h/agBjxTqjZOwHVAEe1Vt4pyUUVEUIbVVT0notjtxWkOuh/SmONaV5qVcyDP/HxkXpGYHkqtnpKdtJJ7ZHwB7QbWm07NYUsik+R4Mn1H3//maKyCRnwiEx4OfLpTbNTTN/7DMYFs0ATPXexMUJJFOBUq25zUyqwAMJ73xDX6Emk+1xBOhbwJFl8P8YvBo73S3rAgGnY1Aj4ysdiPAFfMg8XBMy+66io3gSWgKfBXOunD5bylDEC5lAfSkjECyfYFj3Crfs58xrn7gAPuvxtypY0SVKu2A11wxpv/stI4RdnRJBRP19vDokX2daSQK49d913BHkMz1wtAjbV5PmMANL18+jV1OCsg0aH9026KlnXit4unk/yxpwqS8e2zcwy7Z0nGnOalkNmIScFZuwLLT2/uiihTzaQfFbDGhS4duP55AIfHQtFNEwDgjvk+cgRLvTpnlFEc/3rpZ6d8evNkDJaDwWFqpFT0j/DwuSfFXiDnbU2qFi8x95B/GzaTaiO0eTQDZGOvp6TuPJ+3SgnTIFrpJWqEg1ffWLSwPY4E/FmDYdYCpw8APg4dN 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)(13024025)(13018025)(13023025)(13017025)(13015025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BN3PR03MB2371; BCL:0; PCL:0; RULEID:(400006); SRVR:BN3PR03MB2371; X-Forefront-PRVS: 0109D382B0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2371; 23:AQGflzxpfJK2Gebzk87BSSiJTjLrQkG2+xGiHI8Kv?= =?us-ascii?Q?l/tzjtNA/fNddJnr+Rgt4MDaPY4HEn5icSs2dBBoxhbK9InolvWIxX+/Zeg4?= =?us-ascii?Q?U+DceHiLv4emoJa/rVg8vcRXbrXV5xCPuz9Jl7fy6Q8QKkaeNzjlccGdYxjE?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RY8bCsIgE3pojm27C/Somh8Kg3nIkgK?= =?us-ascii?Q?Ldj98LvxKrByNywUzW7E2GHUPk40V6yBKRfOEdVJ4hPrklS6o07rAixkB1ik?= =?us-ascii?Q?hYz9j4tZOXsKxjwY836Nt0EYPomFm3HabQWk1znSE0eIEn8Cb0vb0qimG3Vr?= =?us-ascii?Q?E+vjJIp3l6CBUqsSEivuxL9Ka7t6VEaQn0EeHlbcbbUdRrBHpmwjZ9jSw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2371; 6:Z4JRavoG2tR0zeLYcWbKsr/pddpGW8dkg68yTn0Clhao2b1ysgxEfKgqU2C7B78Ubm5hy6cWIZsucmDBwMlbjD9w6UlJgkB1cqRuAgDDJEB9rDnqbgK0QpQimgFnKgaua9LjlHJe0yA9VLDegd/7jANMtDGWql6w+x3HJv+FQPiJmXLc1azxX81LpUZ8sa1C86OJI2Ah9ZyIgKnw8ICE4+tCRMeZSwvvunMCFfI2qYJL8SHFGzh5vAusPqUhlZLLd/Ikkpxpog0BPp1dnpfJ8ngE6Pzfovfgg9h2jOU1HD+7fHodMCPRvZ+4rOMqgiK+; 5:PbF0rwh6P9zAmo2uRV98rtPRnRzuSgY4hYnpeYIg5JBn2KzqpY/tuCS+aCSX6G5IdIFOT3NA1/a1/UXC2ANY1M6SIpf+h2zxxN0c4vBeqSA7DEgj6SjL945Y/dJhbLbII1xj1Dd5YW0cxfLUCeloYtkkxlDqupyVtNpg2B462oocVFGXDua7WWBryGnKtEOC; 24:GFv38W7kyF1DTGZa1EoGM6WoDqYXglJvX18sW+xF3TViHiOG6uS1dKFN2RlDFK7s1S6l6AmkwS2jjsrTZvElNto44d480/WSZtDLEepx4nY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2371; 7:5IusKXWTzWU+2UeUkQNDTAJ+N7tdVm3oxF5O7LQ0xoaoEAW6fAMTLh9yaKThPI/OqTkIELVWyl4AFoSo4DDQm9KDSsp6oZyIv3TFMs8K7JcI9VFqGHWDyXZno+EZF94/3EwHZtEXgQGVkfz/mEQ2ZoQ+lfZ+aR5Otbm4e2vKRGF7y2jzNdGE7un4iurpjTcWdg7XP+/c/3gaaYNgf4mVDEJO5odT9FSksRuIIdNG+d3D0OXbdFrUhTsc2AnWzpCpI/gggfU7/zWdzRZ/Az0hRS4glp5jKG0nMgZ/f4SZsXEaD5bZneDwgdap0k+x6BNTQjRW+vxSg30EuGPyPoyDf/lh38HhOB23HhR6VjVQJZE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 12:30:34.5886 (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: BN3PR03MB2371 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v7 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: Fri, 28 Oct 2016 12:30:37 -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