From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0070.outbound.protection.outlook.com [104.47.37.70]) by dpdk.org (Postfix) with ESMTP id D6E8E56A9 for ; Tue, 12 Jul 2016 08:01:40 +0200 (CEST) Received: from BN3PR0301CA0066.namprd03.prod.outlook.com (10.160.152.162) by CY1PR0301MB1995.namprd03.prod.outlook.com (10.164.2.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Tue, 12 Jul 2016 06:01:38 +0000 Received: from BY2FFO11OLC004.protection.gbl (2a01:111:f400:7c0c::174) by BN3PR0301CA0066.outlook.office365.com (2a01:111:e400:401e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.539.14 via Frontend Transport; Tue, 12 Jul 2016 06:01:38 +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 BY2FFO11OLC004.mail.protection.outlook.com (10.1.15.184) with Microsoft SMTP Server (TLS) id 15.1.534.7 via Frontend Transport; Tue, 12 Jul 2016 06:01:38 +0000 Received: from Tophie.ap.freescale.net (Tophie.ap.freescale.net [10.232.14.199]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u6C60qWo006202; Mon, 11 Jul 2016 23:01:35 -0700 From: Shreyansh Jain To: CC: , , Date: Tue, 12 Jul 2016 11:31:21 +0530 Message-ID: <1468303282-2806-17-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468303282-2806-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1468303282-2806-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131127768982497723; (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)(189002)(199003)(105606002)(106466001)(356003)(4326007)(19580395003)(50226002)(189998001)(36756003)(5890100001)(19580405001)(76176999)(11100500001)(5003940100001)(47776003)(229853001)(2351001)(50986999)(586003)(85426001)(33646002)(77096005)(97736004)(305945005)(92566002)(104016004)(6806005)(86362001)(8676002)(7846002)(48376002)(81166006)(87936001)(2950100001)(2906002)(110136002)(68736007)(8936002)(81156014)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1995; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC004; 1:C9blGEAO4USMqbmmDSaXe7M5imY7Ge61jQXJMX8vX+cLuLGhNNhFuYWg94PDkL5o68c2vKnCVwD3YF6lqBqc33TF1qfYxfmBN0HjDeR1BwSH2VmWnbJir1iEzjBcam0SScL7fq2ySZk2e3fJAgH0Wk0JaeVgF2LCM51dzC6Rofgh1Q9QSK5tbJrMavU90UHu8TXxavu1R9eNlouAd9xURihhj3TZk5sK186ddwCivW+KategcAHA8jU+yIrnvMdAjw9406Rg4P3qy3iWjWRwMiaeeDmhKLacRhS4xRc/Eoejr6+z2V0suIUzGsuv+ku0fMCp+uG984lWt0yViUe2Szvpu9sW/8QMdbFF7Ng8B4qUHesSlV+HjaRMscFJnzlUwzR9ZPTL2d1xDb441OF7RtfVyx7Wuh9GtbhTddIHowRs6eHYwyl7tGISxrXK9Fe3pGOPVI/LPYWk/odSYZzzoQHUafzbuDl4YgHWZ9Y0qDgW/fX2A4OIv+6gl2ktJ6XMK6MbW/HcNjBbKvXrDewLXpyh94rFptIOjiju7YrCEn7uqdDEvOX/8vDnXdDQCm7YkEeLwhPqizL+XXe+AXefE76C7ufhL2uNd9WzY9WRJRmpS+vUZw7eK39cYqE6Ln5V MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d581f501-7dcf-4de1-29bb-08d3aa19fcdb X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1995; 2:Hs0aBir4lC7cFV7j6l8erz/bVS6c/sEHz3cPoerk3JaZJRd31IQWwsKgnvmuCA8KF1E6ftfzKR9X2Mthn+HBmXR/cXyw6ArTsZztJem1KMzuFRacN/TEcGm4nZ1mJFajHE0qr9kGCjBMRMErAkRc909SzERe2aDd8hnqNs6ZsiyBNQz9sftzRoEZm3FDhMxn; 3:fTW/1AP++nWjdV5VaPmbF+sbIbgR0lpturi5tOyyuWKlgwMllowm3M6lB0VrLEj+ywXGLinTLmoX3MzJ7Kt0rvoyZddwG831hJYju78h+1HGCKjP/Up9eeGxRi5+2++C7nU5ocT3a+cUBDlqVjtJP5D8HQGNDy4IYqIJTcr/mV+hx/UWgBPN24yyCUQnrBWELfA3XRgQugxwP4R050YDjVc0thAKyPpebKYtAaFyPtI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1995; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1995; 25:hZop5qTGpUELZ+zyWVYVuZ42GgHkHFaPYO7io00mDqnF9HH9cO9OTosHJ219rAekKGpoS3YCaAzxNIz7qidhvogmtohenYhzY1zDyphxSfpbfozbpHgIkqkwdmvtZ0uAlZMWHdVOq8cdBNWM1REk5EUksjfnj9SigHkXoisOeuN/TsnlLAW52GtCzWbhvKd8xiGGjeTZAB9p9Zf8kqt9aksWRQSGBkNQmf3haTR7uQjbtAdGZ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1M+nAy0Ij771NYqy6DbH+1gBktNm77Zz2ITa/5Ja7eT8mPtkUTdl7heFO+J267FCY/JtOYNNGTaHj+SPcbQ8NOnfEWjwcMij3B8c5L7ulUS2of61MAhjd3dRxJyzJya8j2Exr0DId6iFYTfIf4w3U1edZXDjiS4+H1Lg5iROGL0Hrwp2/IwNInXKQkHcXfzhAm8mIxa8vasVfTobHaHmDm+9o0ZEZtY8MSqqfyIOwtQMa4Z64Sy34bQO0MOVbWb50FNKlGdj4qFjcQROLBTe4J/EjKfKsrLgN5w6PdRB0gaBoR8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397)(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13018025)(13024025)(13017025)(13023025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:CY1PR0301MB1995; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1995; X-Forefront-PRVS: 0001227049 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1995; 23:yfiy5Ag+rFWVRpcttiyOzvGyPS6KI6QwwIfKR//?= =?us-ascii?Q?tOqkkZGkkl/HgZbYh5K3fcqlKgXbx7M5sysRLIikRO9M3NWG7I8Ky4NDUJtl?= =?us-ascii?Q?FBXLGwEqZopOFweC2ZCZtZqwUTPy4mpAp9Jm0wtS/KEBGCoynIY70ay9mo/f?= =?us-ascii?Q?fm+aVUnwOqsYrUMAmfugokcOL0Zw6SRKLciefIlqpAvJRW0TjaFfl+QUlvkS?= =?us-ascii?Q?MKvbDKZBOtbILiuOLTojfvb0IgdmqFj0N7xmlfi/linFSZexsm3N9Qc0dUOB?= =?us-ascii?Q?TFXHcX8P7zyua0x97APCh+oI6kgChKam1y+EDT8KQ5OfsPaGgNpK3iMFX0RQ?= =?us-ascii?Q?zsGSO6pR/eQdgvBzgMISFC0Atd+AqVpT+KBqcmH4uKChXm732VNDszTHkK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KoMSq1fH578mmIkxpmTGoRz2fnCqlzsEFpOGkIFsXOrPGRPYgpdjnVJvqzC1RR0v6IS1HFygg14uoqYTaFzi39PlL4fNYYKLUovIybuKXceBiqDQHIoWB3TJD34RMn3Tn7/k+60KSlgSZ47PEBdZlAq18+KcWdgDna6ATCks9IhyY6rIImAH+oM0uC+xNqO55quH/T9vZYlHE=; 5:+Tsm4PnsULrT0MuxKBL5ugVU27wzPVh2KHUqw0I7PH46LyOu3B4dKp1qnPbfIvN066ppQDNu0YFFMQN4P/rFUibkMv+QfHbPHvBMZQ82+D3e0OVUkWN0Rw3NtjQAIVFpqK88w2HrjvJAjpKFS91/84z7sJOwkFbCcm2rfPccm3E=; 24:Sqk5agF59bFvh96KrBWYq+Kbm0UhpcINhjKgYa82yqS8iwB/7mzGi4PSGUFvLvrPs46EMg+7TeMxKsCLAeMMBjC1FyA23O8/IlPr10yBTzQ=; 7:Lb+r5PL0RGyuZLIpS19iBtFINkFbZ9q0Kzs6QNnLK7cFIBpTtqpHztWufrVTluxUURU452PdVAqLY8dYvTlrNEDY23BCZjms5PNjQ6kqqiBhaRuaz/wMEEU5y9was7DZ0gmnE+qic56GkjF11ttHSpVkHtHSV8+wEFE8qwgTi4PRRtpaf8oT/tZgsklM6u4ft5snkcHPPRyZGc2LudgtxUEP5l6uKH0Yjfuf7hcun1xK5PDxJJXDJKldv95Nb7s1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2016 06:01:38.0469 (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: CY1PR0301MB1995 Subject: [dpdk-dev] [PATCH v6 16/17] ethdev: convert to eal hotplug 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, 12 Jul 2016 06:01:41 -0000 Remove bus logic from ethdev hotplug by using eal for this. Current api is preserved: - the last port that has been created is tracked to return it to the application when attaching, - the internal device name is reused when detaching. We can not get rid of ethdev hotplug yet since we still need some mechanism to inform applications of port creation/removal to substitute for ethdev hotplug api. dev_type field in struct rte_eth_dev and rte_eth_dev_allocate are kept as is, but this information is not needed anymore and is removed in the following commit. Signed-off-by: David Marchand Signed-off-by: Shreyansh Jain --- lib/librte_ether/rte_ethdev.c | 207 +++++++----------------------------------- 1 file changed, 33 insertions(+), 174 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index a667012..8d14fd7 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -72,6 +72,7 @@ static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data"; struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS]; static struct rte_eth_dev_data *rte_eth_dev_data; +static uint8_t eth_dev_last_created_port; static uint8_t nb_ports; /* spinlock for eth device callbacks */ @@ -216,6 +217,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type) eth_dev->data->port_id = port_id; eth_dev->attached = DEV_ATTACHED; eth_dev->dev_type = type; + eth_dev_last_created_port = port_id; nb_ports++; return eth_dev; } @@ -347,27 +349,6 @@ rte_eth_dev_count(void) return nb_ports; } -static enum rte_eth_dev_type -rte_eth_dev_get_device_type(uint8_t port_id) -{ - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, RTE_ETH_DEV_UNKNOWN); - return rte_eth_devices[port_id].dev_type; -} - -static int -rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr) -{ - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); - - if (addr == NULL) { - RTE_PMD_DEBUG_TRACE("Null pointer is specified\n"); - return -EINVAL; - } - - *addr = rte_eth_devices[port_id].pci_dev->addr; - return 0; -} - int rte_eth_dev_get_name_by_port(uint8_t port_id, char *name) { @@ -413,34 +394,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id) } static int -rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t *port_id) -{ - int i; - struct rte_pci_device *pci_dev = NULL; - - if (addr == NULL) { - RTE_PMD_DEBUG_TRACE("Null pointer is specified\n"); - return -EINVAL; - } - - *port_id = RTE_MAX_ETHPORTS; - - for (i = 0; i < RTE_MAX_ETHPORTS; i++) { - - pci_dev = rte_eth_devices[i].pci_dev; - - if (pci_dev && - !rte_eal_compare_pci_addr(&pci_dev->addr, addr)) { - - *port_id = i; - - return 0; - } - } - return -ENODEV; -} - -static int rte_eth_dev_is_detachable(uint8_t port_id) { uint32_t dev_flags; @@ -465,124 +418,45 @@ rte_eth_dev_is_detachable(uint8_t port_id) return 1; } -/* attach the new physical device, then store port_id of the device */ -static int -rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id) -{ - /* Invoke probe func of the driver can handle the new device. */ - if (rte_eal_pci_probe_one(addr)) - goto err; - - if (rte_eth_dev_get_port_by_addr(addr, port_id)) - goto err; - - return 0; -err: - return -1; -} - -/* detach the new physical device, then store pci_addr of the device */ -static int -rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_pci_addr *addr) -{ - struct rte_pci_addr freed_addr; - struct rte_pci_addr vp; - - /* get pci address by port id */ - if (rte_eth_dev_get_addr_by_port(port_id, &freed_addr)) - goto err; - - /* Zeroed pci addr means the port comes from virtual device */ - vp.domain = vp.bus = vp.devid = vp.function = 0; - if (rte_eal_compare_pci_addr(&vp, &freed_addr) == 0) - goto err; - - /* invoke devuninit func of the pci driver, - * also remove the device from pci_device_list */ - if (rte_eal_pci_detach(&freed_addr)) - goto err; - - *addr = freed_addr; - return 0; -err: - return -1; -} - -/* attach the new virtual device, then store port_id of the device */ -static int -rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id) -{ - char *name = NULL, *args = NULL; - int ret = -1; - - /* parse vdevargs, then retrieve device name and args */ - if (rte_eal_parse_devargs_str(vdevargs, &name, &args)) - goto end; - - /* walk around dev_driver_list to find the driver of the device, - * then invoke probe function of the driver. - * rte_eal_vdev_init() updates port_id allocated after - * initialization. - */ - if (rte_eal_vdev_init(name, args)) - goto end; - - if (rte_eth_dev_get_port_by_name(name, port_id)) - goto end; - - ret = 0; -end: - free(name); - free(args); - - return ret; -} - -/* detach the new virtual device, then store the name of the device */ -static int -rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname) -{ - char name[RTE_ETH_NAME_MAX_LEN]; - - /* get device name by port id */ - if (rte_eth_dev_get_name_by_port(port_id, name)) - goto err; - /* walk around dev_driver_list to find the driver of the device, - * then invoke uninit function of the driver */ - if (rte_eal_vdev_uninit(name)) - goto err; - - strncpy(vdevname, name, sizeof(name)); - return 0; -err: - return -1; -} - /* attach the new device, then store port_id of the device */ int rte_eth_dev_attach(const char *devargs, uint8_t *port_id) { - struct rte_pci_addr addr; int ret = -1; + int current = eth_dev_last_created_port; + char *name = NULL; + char *args = NULL; if ((devargs == NULL) || (port_id == NULL)) { ret = -EINVAL; goto err; } - if (eal_parse_pci_DomBDF(devargs, &addr) == 0) { - ret = rte_eth_dev_attach_pdev(&addr, port_id); - if (ret < 0) - goto err; - } else { - ret = rte_eth_dev_attach_vdev(devargs, port_id); - if (ret < 0) - goto err; + /* parse devargs, then retrieve device name and args */ + if (rte_eal_parse_devargs_str(devargs, &name, &args)) + goto err; + + ret = rte_eal_dev_attach(name, args); + if (ret < 0) + goto err; + + /* no point looking at eth_dev_last_created_port if no port exists */ + if (!nb_ports) { + ret = -1; + goto err; + } + /* if nothing happened, there is a bug here, since some driver told us + * it did attach a device, but did not create a port */ + if (current == eth_dev_last_created_port) { + ret = -1; + goto err; } + *port_id = eth_dev_last_created_port; + ret = 0; - return 0; err: - RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n"); + free(name); + free(args); return ret; } @@ -590,7 +464,6 @@ err: int rte_eth_dev_detach(uint8_t port_id, char *name) { - struct rte_pci_addr addr; int ret = -1; if (name == NULL) { @@ -598,33 +471,19 @@ rte_eth_dev_detach(uint8_t port_id, char *name) goto err; } - /* check whether the driver supports detach feature, or not */ + /* FIXME: move this to eal, once device flags are relocated there */ if (rte_eth_dev_is_detachable(port_id)) goto err; - if (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) { - ret = rte_eth_dev_get_addr_by_port(port_id, &addr); - if (ret < 0) - goto err; - - ret = rte_eth_dev_detach_pdev(port_id, &addr); - if (ret < 0) - goto err; - - snprintf(name, RTE_ETH_NAME_MAX_LEN, - "%04x:%02x:%02x.%d", - addr.domain, addr.bus, - addr.devid, addr.function); - } else { - ret = rte_eth_dev_detach_vdev(port_id, name); - if (ret < 0) - goto err; - } + snprintf(name, sizeof(rte_eth_devices[port_id].data->name), + "%s", rte_eth_devices[port_id].data->name); + ret = rte_eal_dev_detach(name); + if (ret < 0) + goto err; return 0; err: - RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n"); return ret; } -- 2.7.4