From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0074.outbound.protection.outlook.com [104.47.40.74]) by dpdk.org (Postfix) with ESMTP id D02A758DD for ; Fri, 16 Sep 2016 06:32:37 +0200 (CEST) Received: from BN3PR0301CA0026.namprd03.prod.outlook.com (10.160.180.164) by BN6PR03MB2433.namprd03.prod.outlook.com (10.168.223.11) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10; Fri, 16 Sep 2016 04:32:36 +0000 Received: from BN1BFFO11FD045.protection.gbl (2a01:111:f400:7c10::1:101) by BN3PR0301CA0026.outlook.office365.com (2a01:111:e400:4000::36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10 via Frontend Transport; Fri, 16 Sep 2016 04:32:36 +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 BN1BFFO11FD045.mail.protection.outlook.com (10.58.145.0) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.619.6 via Frontend Transport; Fri, 16 Sep 2016 04:32:36 +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 u8G4Trfr029256; Thu, 15 Sep 2016 21:32:33 -0700 From: Shreyansh Jain To: CC: , David Marchand , , Thomas Monjalon , Shreyansh Jain Date: Fri, 16 Sep 2016 09:59:46 +0530 Message-ID: <1474000200-16705-12-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474000200-16705-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1474000200-16705-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131184739563647871; (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)(189002)(199003)(110136003)(11100500001)(36756003)(48376002)(586003)(15650500001)(85426001)(4326007)(229853001)(92566002)(2351001)(2906002)(626004)(189998001)(104016004)(19580395003)(106466001)(105606002)(87936001)(19580405001)(50226002)(68736007)(86362001)(33646002)(5660300001)(97736004)(7846002)(50986999)(50466002)(81166006)(76176999)(8936002)(8666005)(81156014)(356003)(5003940100001)(305945005)(77096005)(2950100001)(47776003)(8676002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2433; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD045; 1:X2FI/1Abvfd86jC2sn+fx6TltDbtXmBtISR5ukgltu8U5OXZx5aPjEn1oCM+vJjWkM5LgAnrBxHxlz82nRmzJVIaPqtuciK5EpI8mX1eWEpifrNe6pB7IejHbpbIGvUbiQzvSyyRIX/+ibAMSReMGZoe5hlYDA+EBeAHcLLx5qtUrgwHtIGFLCk/2lKmMhpwReffHTU0Tc/+D7B6MBB/GROtN3TcyU/kJbTs1VoqpMzaMbQ2+2KEKbAfRVdbgJOfrt5nRsjulcHVFPElxlOrNSL/Nm7zLyrHH80O9AKcUcXWjItP48sZpjUd47zKJDi6DG0o4AQ7dujwjwNP+GDRaMA1YfCtvG+Fi0gJU4jh0sBVuMq0vaZOPBQ7iwH1EbqD8T/LfLjkbmggCQbEG3hqecRqveXxLZtM4qqbhk58bolRbUJW429ZBZOtE3/65U6EWVJY0nEplM3Z0Wx8cP1QsKxbZlQMflphwfOWspI5F990ts6j2iuxPtfbcwzF23tCM5yF8v+c9iDCdAT+L+J09QYDlzpGdYyHSSdXf1Arfd9U/6nuq4MbJvTQZJUjEQ4/VnaiEG+gajRlKXpoAKlEgppG9ANPxzs+YAkEEPujx7kmQ0FFYlDgCYEG+ryno+5EHhqPxj4PwsuNKvqsuU99cD2Qcy5twXKo9f3KDYDAXniwsl69MfLl+tHDDGELLDHBnVV3AGak7iO4N/+iJhikWMpjpYyteF1xJ+3SaQc7XwQ= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 708df6dc-07b5-42c4-b37f-08d3ddea7c1b X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2433; 2:FxLvj7JQpyd1igPMevnQvHhd4dI9V3venxHWSYDDbEyBpKIzl7Pp5aZi+3rX4Vl4IlIgproBlrBqfqOCEpm7s6scmOtfuFCNXdiTXxux4fMx5HmpLwxE3XjyEX/b20tpAtsKp+R0q4tHaBXxBFlT/gtChfahnEcLDubbGQ0gEff4WbgGaEj9E32KlPoxgMhX; 3:HDQnC65wsqW8td1PhVlVm7IehfpIjS6jrOu1Iglr4hjQITV7e6uDARg2gE7DRDsRe6mMP3ta+XIAANU+utsK9PMsdVXNP5SUPM1R4slsd9XdEn705VkcOPci1z6pd9p66ObBdCYVzpMcoYrSgpQQSpr235xxwm2Ij567jbw+xP0dGKKewNnE98k2U6JnFBEsjEpR0bJuaz03h6UcmgsGHvQC+Ah2QLb1wcStBk0yx88=; 25:GP8GNlfzEUiGEHh/AQb3+yzuM/o719hXXu7HhAJuixcnm1xVaV0SNy2wf85TeMQHr9Hv39Kb/rf31BwGqYvNg0NwIay1EhG7xC2BCT00QnxafsfjdJO2zECwj25LB7Mz1ELVkKRV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hjOP0iqjoc8ZcnurDq8JbTUyT42ZGdMh2+vAPSlyy9kDd/76CWmK52C5DKR96y3hTGekfLJ/mnEjz3YmbGHM7FEh4cog9Yw= 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)(5005006)(8121501046)(13015025)(13017025)(13023025)(13024025)(13018025)(3002001)(10201501046)(6055026); SRVR:BN6PR03MB2433; BCL:0; PCL:0; RULEID:(400006); SRVR:BN6PR03MB2433; X-Forefront-PRVS: 0067A8BA2A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2433; 23:kajMYjQ1uhq19Ks8CbtyFXRZFVME9BqM6eF2WhJQD?= =?us-ascii?Q?KQDR1N50ESbE5hG2RklkC8pv4aYgFbjBT1EVx9AtC3Wt1JBXoIxXXpVro+Ef?= =?us-ascii?Q?OfzyOp0KB9w8IX8HmdPxjl/NrjIFTX97MsPk+3ysgkbxOuAjjz0JrzUDaE7w?= =?us-ascii?Q?+QV/za7ez1ke5aGF83kikZHWQdLGh/MSd2iWAByFXj/O68JrWMcidZFD1iGn?= =?us-ascii?Q?8rJ4AllHA4jtIDTl9wASQqP2iTl2/f8KJ2+331NAvVN8Y4DWu8dG6de0XguE?= =?us-ascii?Q?SAHuJ0y64pTwo1x9b7VXh5SG334aMlL6YbJHsEPdkUKCWljBOl6C9yrqn+YF?= =?us-ascii?Q?UnwWAHytzPLJ1Qdh7J/tBBk6B3TWWY/dy1h6tRhdRgn1goMbBdeXezfu5JtT?= =?us-ascii?Q?kcGNdhp/qoLZNoDgrvGg+scFr3uyKrRZzm8/mDgzHLeK6SGy6zCDnWwYW/A0?= =?us-ascii?Q?haFAAIq/CbzyY/pvFYel3x7x0I8zA1kIUFmfgEpjOAluMqvckzlRS51JSgcM?= =?us-ascii?Q?8eoKz9A/AHW44q1Chqm0TIeK3NXIuUzq/wFofGIY8rP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eekG3m/9IYUbmh8o0/rQgoWxR3AEDJJt2GcXXuKtAqG5swBYcNRWOChYEt/ebXGlZ810f9wH4kTtk8M8=; 5:+oYmc9yKiAYgLH2aeMqK5Us1+omEjoUsVRnCYWyRHZI8tp0YCDH29O2AGSZs91cuvbcG/ap7uuK/TqKMJHJBiBqSVKZMbPBNA+p2Ed6W1bhvKuCUDC6MfKFmhzp2UXNcAZT6UIVJhHvgsArDKviWoDx6XSY3HQA0u86OXkne1SU=; 24:8f76B6gaxbe/J3kEKsNZmpyFRg5KeZX57ZCVO2E/CMS+q8tezW5xKz5ER1YQjcsgpWE/9A5FF1UOub2XCdKKYiSuWvgW3xLIvL0YJl/5E68=; 7:VFYTuhtHis0iS4WKFvAHPLWq9IgnMBO6uLJY4+gJeY0ZzCdicH4suT97LeKwhnH/WA3XP8Mx+HgJzKF69Rh/m3pFN0k+ymx5Prqn8qjKyJQ2pK2GbJ6qdQgX3vGUmmJBxbkGsBZs1HdBndkM507YBIZl/Q8M5HLPFqtfXYvHto2urADft3WUSAupDQpxbTqYtqyFASSjowdSXSsmbUhQdQUOTKxdoaidDPM9onDNHN05TRT01651EBCAlRPAI/En SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2016 04:32:36.1775 (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: BN6PR03MB2433 Subject: [dpdk-dev] [PATCH v10 11/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: Fri, 16 Sep 2016 04:32:39 -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 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 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 11eecaf..e80cab4 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