From 90629946812d40529d216c85b49631985ac904d2 Mon Sep 17 00:00:00 2001 From: Thomas Monjalon Date: Tue, 29 Sep 2020 01:14:22 +0200 Subject: [PATCH] net/octeontx: release port upon close The flag RTE_ETH_DEV_CLOSE_REMOVE is set so all port resources can be freed by rte_eth_dev_close(). The callback ".dev_close(port)" is called also from the ".remove(device)" operation. Signed-off-by: Thomas Monjalon Acked-by: Stephen Hemminger --- drivers/net/octeontx/octeontx_ethdev.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index 10eeeac642..48ce3e1621 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -509,10 +509,6 @@ octeontx_dev_close(struct rte_eth_dev *dev) rte_free(txq); } - /* Free MAC address table */ - rte_free(dev->data->mac_addrs); - dev->data->mac_addrs = NULL; - octeontx_port_close(nic); dev->tx_pkt_burst = NULL; @@ -1378,6 +1374,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, data->promiscuous = 0; data->all_multicast = 0; data->scattered_rx = 0; + data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; /* Get maximum number of supported MAC entries */ max_entries = octeontx_bgx_port_mac_entries_get(nic->port_id); @@ -1465,10 +1462,9 @@ octeontx_remove(struct rte_vdev_device *dev) for (i = 0; i < OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT; i++) { sprintf(octtx_name, "eth_octeontx_%d", i); - /* reserve an ethdev entry */ eth_dev = rte_eth_dev_allocated(octtx_name); if (eth_dev == NULL) - return -ENODEV; + continue; /* port already released */ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { rte_eth_dev_release_port(eth_dev); @@ -1478,9 +1474,8 @@ octeontx_remove(struct rte_vdev_device *dev) nic = octeontx_pmd_priv(eth_dev); rte_event_dev_stop(nic->evdev); PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name); - + octeontx_dev_close(eth_dev); rte_eth_dev_release_port(eth_dev); - rte_event_dev_close(nic->evdev); } if (rte_eal_process_type() != RTE_PROC_PRIMARY) -- 2.20.1