From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0052.outbound.protection.outlook.com [104.47.34.52]) by dpdk.org (Postfix) with ESMTP id 7504E6CBC for ; Tue, 20 Sep 2016 14:42:36 +0200 (CEST) Received: from BN3PR0301CA0016.namprd03.prod.outlook.com (10.160.180.154) by DM5PR03MB2441.namprd03.prod.outlook.com (10.168.233.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Tue, 20 Sep 2016 12:42:35 +0000 Received: from BL2FFO11FD040.protection.gbl (2a01:111:f400:7c09::146) by BN3PR0301CA0016.outlook.office365.com (2a01:111:e400:4000::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8 via Frontend Transport; Tue, 20 Sep 2016 12:42: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 BL2FFO11FD040.mail.protection.outlook.com (10.173.161.136) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Tue, 20 Sep 2016 12:42: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 u8KCexsc006559; Tue, 20 Sep 2016 05:42:31 -0700 From: Shreyansh Jain To: CC: , David Marchand , , Thomas Monjalon , Shreyansh Jain Date: Tue, 20 Sep 2016 18:11:22 +0530 Message-ID: <1474375296-26078-11-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474375296-26078-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1474375296-26078-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131188489545844880; (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)(50466002)(33646002)(85426001)(48376002)(11100500001)(97736004)(50986999)(76176999)(229853001)(68736007)(4326007)(189998001)(92566002)(15650500001)(305945005)(2950100001)(5003940100001)(81166006)(19580405001)(7846002)(356003)(36756003)(8676002)(8666005)(50226002)(19580395003)(81156014)(8936002)(47776003)(2351001)(104016004)(586003)(87936001)(2906002)(105606002)(5660300001)(86362001)(77096005)(110136003)(106466001)(626004)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2441; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD040; 1:iKR2IUeGgnhlU4usF6WJSEeDDErLrkHAOXBVuPPs3BbZRg1exdeS0qTvOQn6qSUw+9MskP6ZndkQjZKKknJnU+BeIEf4T4qAU1QddJ36RRz6OynvYx0u1VB9/zr8gq5rz++a85WkZcar/3wlSK4vaLZXsiBgELWcKv8+vliH04RbpKxxtc9/nrvqw1lecRlIg5Y7qdIud+rAF5YQ7xj5+dZbzUfGsHJvnNVEr93CbZsDIE1pSR+Mew+RM7eBJMedVb32HZPe2NOXzrSMuyRZy7Raoh6cbf6jSNL4HE4MMZ0Zc1WuZYj0sHX6uVttecInBDKHUibK6713nfK+JgKu/aCWrSMnwRJLtwDld7Yv9v633wTh5WLEnnilZZg5J/kBuCu7K26Cg22irdW74CMev59yHHD3NqrWVDaodjxs4fh92MkqtxZZNiQCoQuRFJqcPQTS2VxUtlS4bj70BBwWsTwSh2CM+623cEMz4rKcT7kGo65z+i+k4oIcVkSHc3rHgF+YJtS65tUuZ1hngXLTXuuPyE9umR29fGze5kwKW0vugFb89lreFURuA4zqkIM1i2rxsrNzI9zmB5iTIcxUoVWP+NnhcHEEfi/3Ojbh2p9ULYTHPCA+uRsLiNcr46cbOURdVLKewT2Hat7bqo0Mu/heZx0cpBQWOxDqNQxYy1XoLw8ftdgvtmRUccfGci/hQMelR/85Y3kk6xgagDbE5DBGtRrbyTCmEnoVfdhv0yI= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 520b9897-7bd3-4d2c-0890-08d3e1539877 X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2441; 2:PVPcHa99RYXFFZoqZg3OtFWqK6Dl4ta8a3Dxex5okhUv0N3JW3x+3ZNah8GcWyfHUKlAc3pdpeMqcMAO/N2aJKXhBma9wsiH/8X5P4GwXl5VODCByizw9Oxv0Ra0FdCd5U2HPtY/ERUOjtoVoHqLFMmlahVAEDKyYPgDow6eh9oDZezaCUf/Q+Xo5Y7P5gY1; 3:lZsto0UHorE2ePmDg9wPi571UCKgV05MsfeCvKubE8JH7f8ayoqHmAeWQJZLke0zu+tXuCIJltLYPFeF53ZcUJ1yZAgmirpBXTwN1MKKlEdZhnSMEIEbsUZmN6YrAbhZMkl2vA7X1+gXB4qYlIuZrnq/RfuMysftyeCKqNWvytQzryKCMElm9InHLlBNAwWDL2RaUkJr61qTpYdGPe87dlSbHEOjvX9ckI+AbI3i79Q=; 25:Q4SDJ82tDSYgu9WdMOXd9t17rzy06N5XqT15DuX3ZpkwuWGlU8kYFE42AzkjBVqBHXIWsklGVxs7tSJpuwT0euinURkC1n8jyROnPSOdWlpI0P0LhturPpb6eVmgu1O7VU5dkUAXv3AYyoeFw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KPN51LGbPU44wW6Aiq5PIBuaDorMRe89V4qsWtgGLZ6zPOibCbV1oNrn3K2F2kOW0E3fEpxGnG70z0A/MBPz7K8QBGAW0LFyQoRod4g= 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)(13018025)(13015025)(13024025)(13023025)(13017025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:DM5PR03MB2441; BCL:0; PCL:0; RULEID:(400006); SRVR:DM5PR03MB2441; X-Forefront-PRVS: 0071BFA85B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2441; 23:SlI07bsB5QOQu1qC2Egap6T43EcSF7GPnAvwBFxTO?= =?us-ascii?Q?SJfRPFTf6u/QnZlJa9qCOpYMu8wK2s8gIYIFBiH1OQhQQxDz5SifzJhYli18?= =?us-ascii?Q?BHpXKCmRttk8alhJu3VB1Inru8nu8CyUsduSQpJFjgoSeHQjp11T72FiydiL?= =?us-ascii?Q?iC9XHDFzjPhjMZ/DCXD5NZB4ETsgCJzp7SPHc5hOSkSNUcSktAjxyfaRMu+U?= =?us-ascii?Q?SuOkUJO9nGWIyiWfxl/xBiQ/azdjrDW+Pa9dvAkdsKfEvAozLna1EgGnJ+Zu?= =?us-ascii?Q?NbvIr1Tdzy31xcqO02yrZWa3lUZs233pfX7kfe6NcWU7Paul/qf8TIImzyGB?= =?us-ascii?Q?eayWEf4O0GCSn2rdvpI/1y0yDWkQUDevO8uYdPFy7tlTk9br0kExWDDXUDSd?= =?us-ascii?Q?5IASMzKJL9hLMSeU213czDAtqid0limw9D3GrbooimpH66p+dGTsVHYnLtpq?= =?us-ascii?Q?FX7HTFzYIoTPjyldpFi7xCt1240AwCu0CkgCHz2UM5/LR/uQVU4kbH6BneVS?= =?us-ascii?Q?rP2dmk/pDf4M5qBPwWZGw4M1Il8JXxbQxV7I+IasMYJG+uUOQ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lA2J+NAO9kY5qq2KHx6uGY//PoXu2GrZhG++cO84BjvanPXcx2Q6B8=; 5:FNXT6ERDuX6F/bTsP59NxeplQstu4bk//tb8p1rvtCJVFuZ5UwHuUvs/LBG/tbRYWSMOJfXjQ6veaiw83LBzeD1+2g3euh+JpvgdLPLPMXzWl+xuDAGr4skHd+SVnG94QMPgjIOHj8Jw6znEVaWKtP7jhT3n3nTGBVlnzL1ITLQ=; 24:2AqdLfKh4x9MQKd2vM4Lw+PF12POzL8UpeaWfdqGO7pvIBniG2vFThfsXLRTfhDw9JGCNE0wjsrffRB/ZYkS85nQhwbG9kh/3oV7AoVGkWo=; 7:SlfWNc57bTHvV7GQzg/MKQyFbBZLQnY+b8soJ7qmWfxdNKU7KAkKUowQSW1CW1hvMlQjm+av4kk7Pm8ilyY2Hl5MaNwOLMUoF09v0ZJ90RrUdfMqmRgaHsQpXEgANBuskR0Djmg1EzMaaO8uMZuf8s8vssAYjUiLNCfnz8D9I3IcTUIfSTWNlyV8vF1KjTQ36vvz6eWohoxBCT9o53IHM79munoFRiuuSr/YNyvWgf8TB0J+5WbQ3e7lZT8015mCujSewFS13qE+ARG4UMd7KOl7wSLG9RcElmSnBy72cPbUHUXSslCVNzek+iHKy49h SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2016 12:42:34.4128 (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: DM5PR03MB2441 Subject: [dpdk-dev] [PATCH v11 10/24] 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: Tue, 20 Sep 2016 12:42:37 -0000 From: David Marchand - 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 [Shreyansh: Merge crypto/pci helper patches] 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 f591711..17e4502 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -364,23 +364,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) { @@ -443,9 +426,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) @@ -500,9 +482,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 cf81898..e1f695f 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 0b9f701..0753b42 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -219,20 +219,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) { @@ -256,9 +242,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) @@ -309,9 +294,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