[dpdk-dev] [PATCH v2] ethdev: complete closing of port
Thomas Monjalon
thomas at monjalon.net
Wed Oct 10 00:17:32 CEST 2018
After closing a port, it cannot be restarted.
So there is no reason to not free all associated resources.
The last step was done with rte_eth_dev_detach() which is deprecated.
Instead of blindly removing the associated rte_device, the driver should
check if no more port (ethdev, cryptodev, etc) is open for the device.
The last ethdev freeing (dev_private and final release), which were done
by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close().
If the driver is trying to free the port again, the function
rte_eth_dev_release_port() will abort with -ENODEV error.
Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
lib/librte_ethdev/rte_ethdev.c | 6 ++++++
lib/librte_ethdev/rte_ethdev.h | 3 +--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index ed83e5954..3062dc711 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -506,6 +506,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
{
if (eth_dev == NULL)
return -EINVAL;
+ if (eth_dev->state == RTE_ETH_DEV_UNUSED)
+ return -ENODEV;
rte_eth_dev_shared_data_prepare();
@@ -1441,6 +1443,10 @@ rte_eth_dev_close(uint16_t port_id)
dev->data->nb_tx_queues = 0;
rte_free(dev->data->tx_queues);
dev->data->tx_queues = NULL;
+
+ rte_free(dev->data->dev_private);
+
+ rte_eth_dev_release_port(dev);
}
int
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index a8942ff88..378c01afa 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -1846,8 +1846,7 @@ int rte_eth_dev_set_link_down(uint16_t port_id);
/**
* Close a stopped Ethernet device. The device cannot be restarted!
- * The function frees all resources except for needed by the
- * closed state.
+ * The function frees all port resources.
*
* @param port_id
* The port identifier of the Ethernet device.
--
2.19.0
More information about the dev
mailing list