From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0074.outbound.protection.outlook.com [65.55.169.74]) by dpdk.org (Postfix) with ESMTP id 5D2E9C548 for ; Wed, 22 Jun 2016 11:06:54 +0200 (CEST) Received: from DM2PR03CA0024.namprd03.prod.outlook.com (10.141.96.23) by CY1PR0301MB1626.namprd03.prod.outlook.com (10.162.166.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12; Wed, 22 Jun 2016 09:06:53 +0000 Received: from BN1BFFO11FD012.protection.gbl (2a01:111:f400:7c10::1:111) by DM2PR03CA0024.outlook.office365.com (2a01:111:e400:2428::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12 via Frontend Transport; Wed, 22 Jun 2016 09:06:54 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD012.mail.protection.outlook.com (10.58.144.75) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Wed, 22 Jun 2016 09:06:52 +0000 Received: from Tophie.ap.freescale.net (Tophie.ap.freescale.net [10.232.14.199]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u5M9663p022009; Wed, 22 Jun 2016 02:06:50 -0700 From: Shreyansh Jain To: CC: , Date: Wed, 22 Jun 2016 14:36:35 +0530 Message-ID: <1466586396-22618-17-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466586396-22618-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1466586396-22618-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131110600128570130; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(356003)(7846002)(4326007)(48376002)(2906002)(85426001)(97736004)(189998001)(69596002)(19580405001)(19580395003)(76176999)(50986999)(586003)(50466002)(33646002)(106466001)(36756003)(2351001)(229853001)(87936001)(5003940100001)(77096005)(110136002)(2950100001)(8676002)(81156014)(68736007)(86362001)(5890100001)(50226002)(81166006)(8936002)(92566002)(47776003)(6806005)(105606002)(104016004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1626; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD012; 1:WYlcgicJAySJfGA/2k1QgbzCNNalhOl3/hEAFAGvMcBVwuq+aASAraj6H4jAY45dbbbgMNB7Q/F3BGZxGrHM4qm0Ur1qQ6BYR4Hh7zTzTzDCcpdJqKDyjwESvHY39mQAF3cIpPyHMifTR7xewEI4FyrBSA2T9SVwVUq1mn9P6mXV8OZ9wpYpODZLVDYitIxg5ZJOK/+bI8yJfYAOAHxxs6tCcbS1+FL9T0ZuWcmCrsGXZaVS8JbTL4awcjyWoc1i0kyfog9keRH7lhTOLg6VdrvuW5BrNp8TV+x2Qv8c1yjg2wgc7Da6A7D1bDBscCUzekeHfyXik7IR3VugxyvDpnFYiZwnXbngUPpH8JN+GxfF+2mUVhnufnDhy8TF2T9Ffu37XY5MhJbuih+huOKTsVjlIcfibkCQmJBQvZTyoQ4XS2ElJ0MYX/5WsIaNS87/PJVojKP2G2CtqePFbkyrIgJLKt5G8xd663CcwLpIrKei4rottIDYHOY+/XEWKKqckD294hujXM2aV1sIz/o3CNg/5GFHoFnj3dnrSimK8G63Eqecpl7C06FUIHQWXUOnZ/ya3mynKC92+nEfG4DKSQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: fa014449-b109-4862-41b1-08d39a7c8d68 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1626; 2:qv+CG6AEWYXn9YA1F99/b6mIhHwUZrWLEo18P/UMvJBqo2Z9k6XObTLkeKXluHvzdhzexjT0xHO/4Sp69tFVn8QFvWc9wWCVC9pZZVcCJzht/n0pzy3U7gWkrvRisaNQhN7ubwkF5UnKoEkgLubcJ1n4KPmkQF3xwpaRJqhy0YY96SwEqdVYEco3k8j38i3/; 3:oWgSHBLAY7/8/Gu+7O8Skwgqyx8ybM4/KRcVDX9w+jNVZsBb7GBTOwaEFNH/vUY5KQsNWEVZdhrSmww+slwRSS6unLN9aXOkZWFsQjufj7DpqOUgh0Apip9DPIQJ3O8sIdqEeEMXZGkw+lLN0xRy9S1pCRf9z2F3vwvFTkeFtk9XSqW0/Zn9GYPKOF8I6DDET73olUNrD+Ehbk2TagWjV8KbUYYcUCVh/WaoDmS5aks= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1626; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1626; 25:yXaPQKibyxvdZdZVLl3qHciUGgDHUE9Jz2KfmxTdblLHqX8fGEQYRIj1fZdQjAGE8IFkjRFTdiwWgf60bwEUpmI6ACR/BFh9W4OKp1EEQRVnYjfC9iaBNV6e5NOEsBqmFAYyIaHF00k8cV+1EUFgviHtjImhsyjf+/kkC6xTiqPVAEklbpdMjIiLctQkgHpf/jHoGLiwut1Y6L9p6EvtuvFirVCOU22xin3s34CuK91X1qdSn0w6hTURQAUKr9/Uw3seIFOGjTCYXS30wkdqYvD1tGF/0QIIAR4KCgdTLRHOzO+c/ONHd0CbMfFRBtHodsBpYR6LVCnfIdmBpItJhtiMqo+LEpWfBihNXYbrhfOSAbiyLS4S5QJrD9T0+wiw8mqhEeYrFbOFxXGGmtCCZejONL4ZsjDYnl54nq6eWC9O1UqNhGRAm7fzVMFWChNSEsursXzQVT5Z0rRvhaWl/p1YVdm5fDPGIjPkhS5NFTE6e7tqlwKEnlDiYHsf0PxlfLHdUb0q7j/pE1QXwo5FQy//PAT7orEaiDlqc2ujDbQfsiN7apyRiFfGWAvUYk2K9z5wERgbBpmfUP7G6ZbGZJQuCtUrqQkjOxQ4txxcRK0HEIJ6pN/oKJUEm2dvt7f2p9KkUscTTKHvALbySjmXc5k5WCyqcc304bnANPaPOKIW6YRCZ35vCJalMf1bbMfN5ffbhRZ6O9iZoYTLODLk8iU+kUD267IbY7+Rek+YPVF9qNIaREGRJWlhgI473l2TatS0h+fbys7RU1q+GfGB6Q== 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)(13018025)(13017025)(13024025)(13023025)(13015025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB1626; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1626; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1626; 4:wfNMAFxuk6xEMtxPKzNY4MffNTTtQQvUnUVutoLNExKt3RdVLO6y3IFr/mf/DaCqxm7X/N6VFsjAeBN1CzpyJO4jZOnRIk2r5xsJ68Qlvf8uJy0ky5wwhhLSWVDjEI4j+Ww+7/w6xVJtkeg+Hwkv3CRlChgGSi4InExQvwAXAkKVUG4tRvgFdOu++giIp9Is/cnXxltK4fR/b0S80GoTqD/hMwvwQxr3Iktu+CJTEFhBy0rE41c9ivEJGGgs0O+fOsu5Wjbs42ki5Ulc1iHHmqWZFbgOF0lJMkqSrCozTwQVAXtb+yl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7GveqWol8jmXEqlNRx+ENp1gIn6tM1jNZUchDp63sqhaGmp0j0J9vxwAW9CBD57aKspW17Rv5iytQj6uShFysz54hCtSjaeRhp5TWdckpoiRq+fA2YbP38rmFRKaIfoY0TY=; 24:YR6JR90+1Jq+KmygDI5AmjXKFn0g8Ab0cbc0ezJk6spfkg/+wBRn6nbR9j05HQsCmdp2pR8sw7d2/3Z4jNfhOSz3Xvtb7cZBC0Iq0dfDVeE=; 7:BXb+alHlSaayxzfXpK03d1/gRI5R2uQUMIUzpuS1EhM+QBGSJeaodgjK9mnmcqV09X4bBNGz3y80BD8pQGP3AYFeZsIwYyuXAivoh/SUJpW6rUse7sVluyTCfar+qC5kcxCIBqSJ1Ed2wOC03NZrGYJ5RStBsQtv8a4+iyFySLjEjK2dQZlFF6ZAd54gT9ED5kG4ZEfbs5vVLwnrVhRtSi40eQYh4eOjtN8qv5Onh8X01GjGuwqAUcBJPBQyMvUESFM7BrCHbgfbi0mcncx1vw== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2016 09:06:52.6074 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1626 Subject: [dpdk-dev] [PATCH v5 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: Wed, 22 Jun 2016 09:06:54 -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 6f2b169..10e81e1 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