net/octeontx: release port upon close
authorThomas Monjalon <thomas@monjalon.net>
Mon, 28 Sep 2020 23:14:22 +0000 (01:14 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 17:19:14 +0000 (19:19 +0200)
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 <thomas@monjalon.net>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
drivers/net/octeontx/octeontx_ethdev.c

index 10eeeac..48ce3e1 100644 (file)
@@ -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)