From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0071.outbound.protection.outlook.com [104.47.41.71]) by dpdk.org (Postfix) with ESMTP id 40C8C8E96 for ; Wed, 7 Sep 2016 16:10:00 +0200 (CEST) Received: from DM5PR03CA0003.namprd03.prod.outlook.com (10.175.104.13) by CY1PR0301MB2010.namprd03.prod.outlook.com (10.164.2.16) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Wed, 7 Sep 2016 14:09:58 +0000 Received: from BN1BFFO11FD009.protection.gbl (2a01:111:f400:7c10::1:122) by DM5PR03CA0003.outlook.office365.com (2603:10b6:3:118::13) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9 via Frontend Transport; Wed, 7 Sep 2016 14:09:59 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=fail action=none header.from=nxp.com; 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 BN1BFFO11FD009.mail.protection.outlook.com (10.58.144.72) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Wed, 7 Sep 2016 14:09:58 +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 u87E8BCt013556; Wed, 7 Sep 2016 07:09:56 -0700 From: Shreyansh Jain To: CC: , Shreyansh Jain , "David Marchand" Date: Wed, 7 Sep 2016 19:38:02 +0530 Message-ID: <1473257297-7221-11-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473257297-7221-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1473257297-7221-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131177309987641746; (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)(199003)(189002)(5660300001)(2950100001)(92566002)(8676002)(47776003)(81156014)(86362001)(81166006)(626004)(189998001)(77096005)(106466001)(8666005)(105606002)(356003)(76176999)(229853001)(2351001)(7846002)(50986999)(2906002)(19580395003)(4326007)(36756003)(50466002)(97736004)(15650500001)(48376002)(19580405001)(110136002)(104016004)(586003)(5003940100001)(33646002)(87936001)(305945005)(8936002)(50226002)(85426001)(68736007)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB2010; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD009; 1:9+AFyRiZ+rAv25EEuk8SlLrn+zr8/8ZWxoYEYgiysX6oiOqLNsj/fpapddqQTCeZlPxZH1pA2WvxV0w8gayKF8hcsKQSXyMhDocvBRCg841PDdiG2sa77e0Ky8QcgUYUJPYVhitbctaJKXLYEbSCH7jHm9F0+RrQrB2nJ+OWhBNZoS6gD0ZoO5o3v4XPel3CxEun//nzZePuynJ/+pzWe7t6JFiZoquDP4DvCe3gyUL9pZ81q4utz3QlRL3zA3Fw3EAqPuz4RARMHpfVwPNjSnrgBopZ1tmIie8/TrZlxJqjslXrgiU9qUExjPbjTPN7DG57my65HxenS2IWvFoG2dU1fj3eo+/NPfmPPr2RQJslK63iirziAFSwGiMkqX4a/TqHezlblhhKIYylQjKXYbUOa/SAcZGaVTm25341GsdUBrV15FX8m+0qDF8qhTtZF2E9QQ6JZQCmQkieec2z7b8G4KK3+eNm1bAoqIaD+kfBTgWddNO0+PVeTaFPP8A/KZ493usx2lSZRfdSOMTU3qG052mGE2V+sbph7xl5krQ+EX76qG4adFuuJtFUCi+bIx9x1cPxg9uG8eqnDXLAgcWIs2Il2Kw0VnInJN9eAegQqyIGBgDvRI6nPR7xcvIh MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 1d143bb0-d7e5-4671-3831-08d3d728a6dc X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2010; 2:7432j7N/C9ZZXmNxGHNk48rxbugN4z0VyLddTXFuMP4JPf9efC4dhqMbNkl087sLKlYU/lspJxHAmSCYieYXrcv+CNj8hRuZdZmFc79GC/emMLSSyuuLjLe+IvbiG2AmqadR7LwSPF5Ht+zfNbQAJTLZ32nVlo//lb+yReRozdodGxycwYR/BJ5Z8g36a/Ks; 3:LEM2AmbcdvoGyX60ikR8J2QNfyJgoSFuDWFX3MhZkaqc8Ptzn79NBvn8t4ngyRP/mNFZNkp4TWFBzlE8vMHE0F4PdWXNO9S63pKbUm4oLuA/p0lCqvtjMuRwd410thzRcRmXHeipa7NhskNgHhLHPXg/pGWnMrEeBZDZz0sf2rZBr/ER0EtKBCYJAMdnczRSLTvo77qtJO9iMQc+okPbUVx3SPsi2XKpoZROmDf22to=; 25:FAOSAnFZWx9V2pINatOk3/x8VHxHs+87Thykx60gTsQxH7C8hy52drke3Xj+RkWk8T5GGZldXAX9qI+rXLMh5jLi0/6kz5U5nOiSTgvHxXkzGjOuDdDEhK5PAJmkBEX2hwBAflvEjC4Z2+VBXl//K/QABLUarxRboOE+DqbIm2ea7ka/J68pwElETE/rcPJGzk45SEA+EpajSMb+bQ8PI9vTQwUL2m7aC3WiK3iFyKREsr3kUJ+n/m7zW8JCyfnbypdtod8Kjk5QeOPUQv4PoI0YPGBFe6O6PDs1fh63ax6f2UzktK/er5md39/bsM8afIqmSg9iaPJSgXili5hPYEVJnuofVceeH5iptUpJFuuAJJiutmXdNcD5R/PmbVkZ/GoonlGQwUdo+VU9KkecDJlAGxUcvtUf2M5rCYP29fQ= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB2010; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2010; 31:vVVs+rUXUEENKF/LNAm3h3rWl1YOJljK1fckdgCMUTzi7NSjaIQDrBk/Sqqb/pacQi5c1+lCHyX65jHJvn0VpKKhU+oOqDL5CnWUOP3rHC+u/jM1WmOhQSrURr/KngbmHJOt4U/EBWvA66RrwfHbuZb6NHwTin7vcHKWK1+9BNnUKNgJK40szfmq3kp2ERmOwFukR97W3ONlrINNAGrbQobktY2GtzGD+ZlELIiLhrA=; 4:8x0gX3enfd9xDId4xQEMPPWU5zP/09R9cc4gmhDteQwtlFYuMdDNl7U2VlUuGMoqCenK5lVOLPxT4M7ZtYR+Jr7xuGfDO3M9vj5BjD6AfRfs0vzFynfoAK6oFwBOq8E2LgNQAMEZvSNKyc+v2h9HLzgYqGbPVlwkHfsTcKJ5ARbOTuDvFn5yhJwff8rB35EO9qzrh1p2fmcjsisUJPP8YrF8ug/IXAxSvYpKAKUfm4Ev4FUlIiuCB+Vc+bInZ/PAeCh5TDLJiuJWRSW9DtokHez08uqQecK0IRNOwLnHcoVQb5z8RriXLAx/G60QOAHoAHAnWs47WBlXc45NGLiwL3iNxJB9+0f9CXAlx7l+olV/rw5Wa9afn8TkMpriIDy9zKsTnPCA8/L4XmmIPPdd7C0jmI5EwWGbUeFogV1Kw86QkYIiXQHquShbdAVNOje1GJokQvQuWQ8yGTD7mueN2utc9sWc/wAbuOgiEPrG2BG5+o6Q0Rs6eCV3Zim5GRiaTq97vIpy0eqp4Xv4wrk+A7sZN7tm9Ssnu478apLlwy4= 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)(13024025)(13023025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB2010; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB2010; X-Forefront-PRVS: 0058ABBBC7 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB2010; 23:sZoy/rmOkafLul+TGKTfwobIkxVwy29XVM6/I0X?= =?us-ascii?Q?vaw2taMvmWbonNfa4GkCedntC2xeqY7SgefE61LwBkscbb/MXKwPM0mecAOh?= =?us-ascii?Q?9HWDz/rU/v/clNKTqAZyCdG3sxI8hkaUJogN4oEMIuwiwalR4GpY9YgvrawQ?= =?us-ascii?Q?nUAQahS5dTC/hRCPXq0mpIEbhghV920jmGjVj1R6nx1kzomGiS4A3YKDFErz?= =?us-ascii?Q?ClJFrN2ToVga+hYdcyjXgmWhkivxDFKxkHBH9pFZ0hcb/Yc2R3r3htXQUinn?= =?us-ascii?Q?NgQuM2NDjXRNjyQBt0JC+POh+I2yZylhtcp8DVvXuU48MVZKFBPkkJHQqmz7?= =?us-ascii?Q?ABVM6haWEJfTUT+NviRJqO8RI8PctdVF/B34vB2lgEJy8OeQxD8WPHd5iq96?= =?us-ascii?Q?qkvroq0lOBTOxgseZcYJEsez/2XzPP+PbFDPqB6mHH7jja/rRQBidVqrfK1+?= =?us-ascii?Q?coT+BelWu4fPVcwHNg/zewmbj0s7qRBhGKE5Gd4IbBedcJlM8kzBvorg+38E?= =?us-ascii?Q?sNRVGeZIuwIhpYC7F8s1K4Mzx+rdddnHb6cN8LJnxkWDmV2vrSGwxERU0Yb6?= =?us-ascii?Q?CF6ze++omalNx6ZzNqht3fEeC4+hACGUDGER87wJn5EYeKXLXVp/7a6alcwi?= =?us-ascii?Q?zjLZMBv9X1QToSFjTpnrCN5LDk7Ps12SRng3/xXQXhb1MDpZsqdyPTIeNceK?= =?us-ascii?Q?ecrNnYpIR6r2pu/dtuablB0ye4BXNYJL8S9qsPABUZJ0LYPoLGf6+WLkMOCD?= =?us-ascii?Q?3WsZJgUPg/eD23dH0EadcEciqc8OGdsvlpAjPpYqJOj3oOhYK4PPZmOWrrYH?= =?us-ascii?Q?c3dYY9B3ojguhG1YR9QLRufX4z1wYHPgC+ohXRddo0zHu8LntfE+k2Osh3gF?= =?us-ascii?Q?99vwTXhcDBElw2U+KoPDsLDhIQQBBjsOE7PnVlA4Wes/s3zECZEXJCf7PMl4?= =?us-ascii?Q?aj0g/f+c4WBhUmvNRHoOlDQgB4j2mJsLAVnWg+Boy2L1m1mlnLqlUCZ7mihz?= =?us-ascii?Q?1vW1Vb6kK0uXTv0hDufWeEQnsP2eeGreulA6K9W6alzG86h/JOXJ0VxrpYvr?= =?us-ascii?Q?oSa6ktfX+UFYjjUOXffjAWX5LOaM52iU7LDUFWomqFCJCzKT30onG9eY/+44?= =?us-ascii?Q?KHkuhjx3ZL9uk11UIUgWuyS2f9Gx3uXPAnC+5B5D+aVGqNnwhrbjqTyEdmRO?= =?us-ascii?Q?iRe9aToB4R7B4vAs=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB2010; 6:raHmu/bdeK80NmXpf6qUlpGDTzrkYHo2D5A/vSCd4DFE5tsrw9Q2rdGsMRrTRdlzNYrNlNZfE4ENmPS+gS3N37cC/TL2jj3Bcc2SBY3zO2D+ISFGuSkBg8eRwbBnzAXMBLcmO0JigvyheBclzRkqR5GI66t/6SUkIGTIyI02It+SFD19r24kEtYcBHM4/K3pA3W8opn0tae3cFVSjiSSac1nkRR23hMPYQ1/mg4r8iJL+TWYQp57dGXwOVdjlQPgtX/okNP7zwTnB4KN7pk7CjGIdh2JSMZRz4JWAZuslHA=; 5:SfQzwy31LG+BpVy+MxvjEU3U3d/L5z0J21vmWtTCwfJANigqvtIPfLM9WpOfc4hS3BFlI+qTWJTOv4EOTrn81GjZdPGSeLX43/iqIkBOp79utNbrPbw4CpZ/sKjvlAY4MvYE8iYcit3AxGA+r2X+GoPn5PBIvfYpSlofqc/l2gU=; 24:/9r96v9GZYgAzHJ//jIZXn6WaAUcgNipRHybmRz8BQdQhV3xgN2yVGxSdQ6+t9ZbuYbtUNUdPpTjCh3DKLHl9xFTA7ovpK72YatHXnmUMjA=; 7:XTp6oa4S5GcAnpids0Q/iDAu6W4V3wnBgv0xqpVG3u1j81TspEA0KhLVnbkDbcoLSvqHqo5gZKdPPL4SzqcvpTrzlVuDBnHIMRk2IVxtNJDfVwKzp8onodKlum0LBKnFmrSW36ziakwGU2zIYK8aKW1EkHLZXwh5srVPq2oVAOjbvVOjhxP+ZcIihDJ/5V6GVs8wNfdinx6IR7Pct6eVyP+nWRPyCvkRRG9cF7OI7dRRnFlAXsPN6OX8pdPRwq7n SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2016 14:09:58.4833 (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: CY1PR0301MB2010 Subject: [dpdk-dev] [PATCH v9 10/25] eal/pci: Helpers for device name parsing/update 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: Wed, 07 Sep 2016 14:10:00 -0000 - Move rte_eth_dev_create_unique_device_name() from ether/rte_ethdev.c to common/include/rte_pci.h as rte_eal_pci_device_name(). Being a common method, can be used across crypto/net PCI PMDs. - Remove crypto specific routine and fallback to common name function. - Introduce a eal private Update function for PCI device naming. Signed-off-by: David Marchand Signed-off-by: Shreyansh Jain --- lib/librte_cryptodev/rte_cryptodev.c | 27 +++--------------- lib/librte_eal/bsdapp/eal/eal_pci.c | 49 +++++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 13 +++++++++ lib/librte_eal/common/include/rte_pci.h | 24 ++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 13 +++++++++ lib/librte_ether/rte_ethdev.c | 24 +++------------- 6 files changed, 107 insertions(+), 43 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 2a3b649..c81e366 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -365,23 +365,6 @@ rte_cryptodev_pmd_allocate(const char *name, int socket_id) return cryptodev; } -static inline int -rte_cryptodev_create_unique_device_name(char *name, size_t size, - struct rte_pci_device *pci_dev) -{ - int ret; - - if ((name == NULL) || (pci_dev == NULL)) - return -EINVAL; - - ret = snprintf(name, size, "%d:%d.%d", - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function); - if (ret < 0) - return ret; - return 0; -} - int rte_cryptodev_pmd_release_device(struct rte_cryptodev *cryptodev) { @@ -444,9 +427,8 @@ rte_cryptodev_pci_probe(struct rte_pci_driver *pci_drv, if (cryptodrv == NULL) return -ENODEV; - /* Create unique Crypto device name using PCI address */ - rte_cryptodev_create_unique_device_name(cryptodev_name, - sizeof(cryptodev_name), pci_dev); + rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name, + sizeof(cryptodev_name)); cryptodev = rte_cryptodev_pmd_allocate(cryptodev_name, rte_socket_id()); if (cryptodev == NULL) @@ -501,9 +483,8 @@ rte_cryptodev_pci_remove(struct rte_pci_device *pci_dev) if (pci_dev == NULL) return -EINVAL; - /* Create unique device name using PCI address */ - rte_cryptodev_create_unique_device_name(cryptodev_name, - sizeof(cryptodev_name), pci_dev); + rte_eal_pci_device_name(&pci_dev->addr, cryptodev_name, + sizeof(cryptodev_name)); cryptodev = rte_cryptodev_pmd_get_named_dev(cryptodev_name); if (cryptodev == NULL) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index a73cbb0..1d91c78 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -406,6 +406,55 @@ error: return -1; } +int +pci_update_device(const struct rte_pci_addr *addr) +{ + int fd; + struct pci_conf matches[2]; + struct pci_match_conf match = { + .pc_sel = { + .pc_domain = addr->domain, + .pc_bus = addr->bus, + .pc_dev = addr->devid, + .pc_func = addr->function, + }, + }; + struct pci_conf_io conf_io = { + .pat_buf_len = 0, + .num_patterns = 1, + .patterns = &match, + .match_buf_len = sizeof(matches), + .matches = &matches[0], + }; + + fd = open("/dev/pci", O_RDONLY); + if (fd < 0) { + RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__); + goto error; + } + + if (ioctl(fd, PCIOCGETCONF, &conf_io) < 0) { + RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n", + __func__, strerror(errno)); + goto error; + } + + if (conf_io.num_matches != 1) + goto error; + + if (pci_scan_one(fd, &matches[0]) < 0) + goto error; + + close(fd); + + return 0; + +error: + if (fd >= 0) + close(fd); + return -1; +} + /* Read PCI config space. */ int rte_eal_pci_read_config(const struct rte_pci_device *dev, void *buf, size_t len, off_t offset) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index ca1aec6..431d6c2 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -130,6 +130,19 @@ struct rte_pci_driver; struct rte_pci_device; /** + * Update a pci device object by asking the kernel for the latest information. + * + * This function is private to EAL. + * + * @param addr + * The PCI Bus-Device-Function address to look for + * @return + * - 0 on success. + * - negative on error. + */ +int pci_update_device(const struct rte_pci_addr *addr); + +/** * Unbind kernel driver for this device * * This function is private to EAL. diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index cf673e4..4ca68a2 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -82,6 +82,7 @@ extern "C" { #include #include +#include #include TAILQ_HEAD(pci_device_list, rte_pci_device); /**< PCI devices in D-linked Q. */ @@ -95,6 +96,7 @@ const char *pci_get_sysfs_path(void); /** Formatting string for PCI device identifier: Ex: 0000:00:01.0 */ #define PCI_PRI_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 +#define PCI_PRI_STR_SIZE sizeof("XXXX:XX:XX.X") /** Short formatting string, without domain, for PCI device: Ex: 00:01.0 */ #define PCI_SHORT_PRI_FMT "%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8 @@ -308,6 +310,28 @@ eal_parse_pci_DomBDF(const char *input, struct rte_pci_addr *dev_addr) } #undef GET_PCIADDR_FIELD +/** + * Utility function to write a pci device name, this device name can later be + * used to retrieve the corresponding rte_pci_addr using eal_parse_pci_* + * BDF helpers. + * + * @param addr + * The PCI Bus-Device-Function address + * @param output + * The output buffer string + * @param size + * The output buffer size + */ +static inline void +rte_eal_pci_device_name(const struct rte_pci_addr *addr, + char *output, size_t size) +{ + RTE_VERIFY(size >= PCI_PRI_STR_SIZE); + RTE_VERIFY(snprintf(output, size, PCI_PRI_FMT, + addr->domain, addr->bus, + addr->devid, addr->function) >= 0); +} + /* Compare two PCI device addresses. */ /** * Utility function to compare two PCI device addresses. diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index f0215ee..62da4d4 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -417,6 +417,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, return 0; } +int +pci_update_device(const struct rte_pci_addr *addr) +{ + char filename[PATH_MAX]; + + snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT, + pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, + addr->function); + + return pci_scan_one(filename, addr->domain, addr->bus, addr->devid, + addr->function); +} + /* * split up a pci address into its constituent parts. */ diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 3bccf20..a1bb043 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -220,20 +220,6 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type) return eth_dev; } -static int -rte_eth_dev_create_unique_device_name(char *name, size_t size, - struct rte_pci_device *pci_dev) -{ - int ret; - - ret = snprintf(name, size, "%d:%d.%d", - pci_dev->addr.bus, pci_dev->addr.devid, - pci_dev->addr.function); - if (ret < 0) - return ret; - return 0; -} - int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) { @@ -257,9 +243,8 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, eth_drv = (struct eth_driver *)pci_drv; - /* Create unique Ethernet device name using PCI address */ - rte_eth_dev_create_unique_device_name(ethdev_name, - sizeof(ethdev_name), pci_dev); + rte_eal_pci_device_name(&pci_dev->addr, ethdev_name, + sizeof(ethdev_name)); eth_dev = rte_eth_dev_allocate(ethdev_name, RTE_ETH_DEV_PCI); if (eth_dev == NULL) @@ -310,9 +295,8 @@ rte_eth_dev_pci_remove(struct rte_pci_device *pci_dev) if (pci_dev == NULL) return -EINVAL; - /* Create unique Ethernet device name using PCI address */ - rte_eth_dev_create_unique_device_name(ethdev_name, - sizeof(ethdev_name), pci_dev); + rte_eal_pci_device_name(&pci_dev->addr, ethdev_name, + sizeof(ethdev_name)); eth_dev = rte_eth_dev_allocated(ethdev_name); if (eth_dev == NULL) -- 2.7.4