From: Thomas Monjalon Date: Mon, 28 Sep 2020 23:14:09 +0000 (+0200) Subject: ethdev: reset device and interrupt pointers on release X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2c65898b4813baba7aadce57b68212d5af82a2fd;p=dpdk.git ethdev: reset device and interrupt pointers on release 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 Reviewed-by: Ferruh Yigit Reviewed-by: Andrew Rybchenko Acked-by: Stephen Hemminger --- diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index d472ae5643..e13415e95b 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -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; } diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index 3ad50d7cfe..2f4772f9ca 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -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 */ diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index 30c888cd96..a17c53577c 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -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; diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index dfe5c1b488..d12d74dd8c 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -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); diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h index 9c483468ba..bf715896ae 100644 --- a/lib/librte_ethdev/rte_ethdev_pci.h +++ b/lib/librte_ethdev/rte_ethdev_pci.h @@ -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; }