From: Gaetan Rivet Date: Tue, 24 Oct 2017 10:35:37 +0000 (+0200) Subject: ethdev: do not rely on detachable flag in detach X-Git-Tag: spdx-start~1094 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=02f01267deea8313c4fa78a5187bdd78f73d043e;p=dpdk.git ethdev: do not rely on detachable flag in detach This flag is deprecated and should not be used to check for the device ability to be detached. The rte_dev library call will fail with the relevant error code if detaching this port is not possible. Signed-off-by: Gaetan Rivet Acked-by: Thomas Monjalon --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 17ebb94d15..f8e6765864 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -363,21 +363,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id) return -ENODEV; } -static int -rte_eth_dev_is_detachable(uint16_t port_id) -{ - uint32_t dev_flags; - - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); - - dev_flags = rte_eth_devices[port_id].data->dev_flags; - if ((dev_flags & RTE_ETH_DEV_DETACHABLE) && - (!(dev_flags & RTE_ETH_DEV_BONDED_SLAVE))) - return 0; - else - return 1; -} - /* attach the new device, then store port_id of the device */ int rte_eth_dev_attach(const char *devargs, uint16_t *port_id) @@ -428,16 +413,23 @@ err: int rte_eth_dev_detach(uint16_t port_id, char *name) { + uint32_t dev_flags; int ret = -1; + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); + if (name == NULL) { ret = -EINVAL; goto err; } - /* FIXME: move this to eal, once device flags are relocated there */ - if (rte_eth_dev_is_detachable(port_id)) + dev_flags = rte_eth_devices[port_id].data->dev_flags; + if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) { + RTE_LOG(ERR, EAL, "Port %" PRIu16 " is bonded, cannot detach\n", + port_id); + ret = -ENOTSUP; goto err; + } snprintf(name, sizeof(rte_eth_devices[port_id].data->name), "%s", rte_eth_devices[port_id].data->name);