ethdev: remove release function for secondary process
authorThomas Monjalon <thomas@monjalon.net>
Fri, 19 Oct 2018 02:07:56 +0000 (04:07 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 26 Oct 2018 20:14:05 +0000 (22:14 +0200)
After previous changes, the function rte_eth_dev_release_port()
can be used for primary or secondary process as well.
The only difference with rte_eth_dev_release_port_secondary()
is the shared lock used in rte_eth_dev_release_port().

The function rte_eth_dev_release_port_secondary() was recently
added in 18.11 cycle.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
12 files changed:
drivers/net/af_packet/rte_eth_af_packet.c
drivers/net/bonding/rte_eth_bond_pmd.c
drivers/net/kni/rte_eth_kni.c
drivers/net/null/rte_eth_null.c
drivers/net/octeontx/octeontx_ethdev.c
drivers/net/pcap/rte_eth_pcap.c
drivers/net/tap/rte_eth_tap.c
drivers/net/vhost/rte_eth_vhost.c
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev_driver.h
lib/librte_ethdev/rte_ethdev_pci.h
lib/librte_ethdev/rte_ethdev_version.map

index 2efc177..95a98c6 100644 (file)
@@ -990,7 +990,7 @@ rte_pmd_af_packet_remove(struct rte_vdev_device *dev)
        eth_dev->data->mac_addrs = NULL;
 
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(eth_dev);
+               return rte_eth_dev_release_port(eth_dev);
 
        internals = eth_dev->data->dev_private;
        for (q = 0; q < internals->nb_queues; q++) {
index 77fb3dc..e7a4be9 100644 (file)
@@ -3267,7 +3267,7 @@ bond_remove(struct rte_vdev_device *dev)
                return -ENODEV;
 
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(eth_dev);
+               return rte_eth_dev_release_port(eth_dev);
 
        RTE_ASSERT(eth_dev->device == &dev->device);
 
index f43ee7d..a1e9970 100644 (file)
@@ -467,7 +467,7 @@ eth_kni_remove(struct rte_vdev_device *vdev)
        eth_dev->data->mac_addrs = NULL;
 
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(eth_dev);
+               return rte_eth_dev_release_port(eth_dev);
 
        eth_kni_dev_stop(eth_dev);
 
index b77283a..159c1c1 100644 (file)
@@ -679,11 +679,10 @@ rte_pmd_null_remove(struct rte_vdev_device *dev)
        if (eth_dev == NULL)
                return -1;
 
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(eth_dev);
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+               /* mac_addrs must not be freed alone because part of dev_private */
+               eth_dev->data->mac_addrs = NULL;
 
-       /* mac_addrs must not be freed alone because part of dev_private */
-       eth_dev->data->mac_addrs = NULL;
        rte_eth_dev_release_port(eth_dev);
 
        return 0;
index 7465079..0681486 100644 (file)
@@ -1129,7 +1129,7 @@ octeontx_remove(struct rte_vdev_device *dev)
                        return -ENODEV;
 
                if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
-                       rte_eth_dev_release_port_secondary(eth_dev);
+                       rte_eth_dev_release_port(eth_dev);
                        continue;
                }
 
index 1790a80..7bbe72e 100644 (file)
@@ -1228,13 +1228,13 @@ pmd_pcap_remove(struct rte_vdev_device *dev)
        if (eth_dev == NULL)
                return -1;
 
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(eth_dev);
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+               internals = eth_dev->data->dev_private;
+               if (internals != NULL && internals->phy_mac == 0)
+                       /* not dynamically allocated, must not be freed */
+                       eth_dev->data->mac_addrs = NULL;
+       }
 
-       internals = eth_dev->data->dev_private;
-       if (internals != NULL && internals->phy_mac == 0)
-               /* not dynamically allocated, must not be freed */
-               eth_dev->data->mac_addrs = NULL;
        rte_eth_dev_release_port(eth_dev);
 
        return 0;
index 4905c08..e7817e8 100644 (file)
@@ -2265,7 +2265,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
        eth_dev->data->mac_addrs = NULL;
 
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(eth_dev);
+               return rte_eth_dev_release_port(eth_dev);
 
        internals = eth_dev->data->dev_private;
        process_private = eth_dev->process_private;
index 0ad9248..b38a4b6 100644 (file)
@@ -1446,7 +1446,7 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev)
                return -ENODEV;
 
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(eth_dev);
+               return rte_eth_dev_release_port(eth_dev);
 
        eth_dev_close(eth_dev);
 
index 3bc05f4..178800a 100644 (file)
@@ -362,18 +362,6 @@ rte_eth_dev_attach_secondary(const char *name)
        return eth_dev;
 }
 
-int
-rte_eth_dev_release_port_secondary(struct rte_eth_dev *eth_dev)
-{
-       if (eth_dev == NULL)
-               return -EINVAL;
-
-       _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
-       eth_dev->state = RTE_ETH_DEV_UNUSED;
-
-       return 0;
-}
-
 int
 rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 {
@@ -3591,9 +3579,6 @@ rte_eth_dev_destroy(struct rte_eth_dev *ethdev,
                        return ret;
        }
 
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port_secondary(ethdev);
-
        return rte_eth_dev_release_port(ethdev);
 }
 
index 66274be..c2ac263 100644 (file)
@@ -74,20 +74,6 @@ struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
  */
 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
 
-/**
- * @internal
- * Release the specified ethdev port in the local process.
- * Only set ethdev state to unused, but not reset shared data since
- * it assume other processes is still using it. typically it is
- * called by a secondary process.
- *
- * @param eth_dev
- * Device to be detached.
- * @return
- *   - 0 on success, negative on error
- */
-int rte_eth_dev_release_port_secondary(struct rte_eth_dev *eth_dev);
-
 /**
  * @internal
  * Release device queues and clear its configuration to force the user
index 8ff4f6b..23257e9 100644 (file)
@@ -135,13 +135,6 @@ rte_eth_dev_pci_allocate(struct rte_pci_device *dev, size_t private_data_size)
 static inline void
 rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev)
 {
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
-               eth_dev->device = NULL;
-               eth_dev->intr_handle = NULL;
-               rte_eth_dev_release_port_secondary(eth_dev);
-               return;
-       }
-
        eth_dev->device = NULL;
        eth_dev->intr_handle = NULL;
 
index 3a4dd47..dfa122c 100644 (file)
@@ -220,13 +220,6 @@ DPDK_18.08 {
 
 } DPDK_18.05;
 
-DPDK_18.11 {
-       global:
-
-       rte_eth_dev_release_port_secondary;
-
-} DPDK_18.08;
-
 EXPERIMENTAL {
        global: