ethdev: reset device and interrupt pointers on release
authorThomas Monjalon <thomas@monjalon.net>
Mon, 28 Sep 2020 23:14:09 +0000 (01:14 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 17:19:13 +0000 (19:19 +0200)
The pointers .device and .intr_handle were already reset by the helper
rte_eth_dev_pci_generic_remove().
It is now made part of rte_eth_dev_release_port().

It makes rte_eth_dev_pci_release() meaningless,
so it is replaced with a call to rte_eth_dev_release_port().

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
drivers/net/ark/ark_ethdev.c
drivers/net/octeontx2/otx2_ethdev.c
drivers/net/szedata2/rte_eth_szedata2.c
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev_pci.h

index d472ae5..e13415e 100644 (file)
@@ -105,7 +105,7 @@ eth_ark_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 
        ret = eth_ark_dev_init(eth_dev);
        if (ret)
-               rte_eth_dev_pci_release(eth_dev);
+               rte_eth_dev_release_port(eth_dev);
 
        return ret;
 }
index 3ad50d7..2f4772f 100644 (file)
@@ -2698,7 +2698,7 @@ nix_remove(struct rte_pci_device *pci_dev)
                if (rc)
                        return rc;
 
-               rte_eth_dev_pci_release(eth_dev);
+               rte_eth_dev_release_port(eth_dev);
        }
 
        /* Nothing to be done for secondary processes */
index 30c888c..a17c535 100644 (file)
@@ -1802,7 +1802,7 @@ szedata2_eth_dev_release_interval(struct rte_eth_dev **eth_devs,
 
        for (i = from; i < to; i++) {
                rte_szedata2_eth_dev_uninit(eth_devs[i]);
-               rte_eth_dev_pci_release(eth_devs[i]);
+               rte_eth_dev_release_port(eth_devs[i]);
        }
 }
 
@@ -1853,7 +1853,7 @@ static int szedata2_eth_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
                if (ret != 0) {
                        PMD_INIT_LOG(ERR, "Failed to init eth_dev for port %u",
                                        i);
-                       rte_eth_dev_pci_release(eth_devs[i]);
+                       rte_eth_dev_release_port(eth_devs[i]);
                        szedata2_eth_dev_release_interval(eth_devs, 0, i);
                        rte_free(list_entry);
                        return ret;
@@ -1922,7 +1922,7 @@ static int szedata2_eth_pci_remove(struct rte_pci_device *pci_dev)
                        retval = retval ? retval : ret;
                }
 
-               rte_eth_dev_pci_release(eth_dev);
+               rte_eth_dev_release_port(eth_dev);
        }
 
        return retval;
index dfe5c1b..d12d74d 100644 (file)
@@ -555,6 +555,8 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
        rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
        eth_dev->state = RTE_ETH_DEV_UNUSED;
+       eth_dev->device = NULL;
+       eth_dev->intr_handle = NULL;
 
        if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
                rte_free(eth_dev->data->rx_queues);
index 9c48346..bf71589 100644 (file)
@@ -107,16 +107,6 @@ rte_eth_dev_pci_allocate(struct rte_pci_device *dev, size_t private_data_size)
        return eth_dev;
 }
 
-static inline void
-rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev)
-{
-       eth_dev->device = NULL;
-       eth_dev->intr_handle = NULL;
-
-       /* free ether device */
-       rte_eth_dev_release_port(eth_dev);
-}
-
 typedef int (*eth_dev_pci_callback_t)(struct rte_eth_dev *eth_dev);
 
 /**
@@ -138,7 +128,7 @@ rte_eth_dev_pci_generic_probe(struct rte_pci_device *pci_dev,
        RTE_FUNC_PTR_OR_ERR_RET(*dev_init, -EINVAL);
        ret = dev_init(eth_dev);
        if (ret)
-               rte_eth_dev_pci_release(eth_dev);
+               rte_eth_dev_release_port(eth_dev);
        else
                rte_eth_dev_probing_finish(eth_dev);
 
@@ -167,7 +157,7 @@ rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev,
                        return ret;
        }
 
-       rte_eth_dev_pci_release(eth_dev);
+       rte_eth_dev_release_port(eth_dev);
        return 0;
 }