]> git.droids-corp.org - dpdk.git/commitdiff
drivers/net: enable hotplug on secondary process
authorQi Zhang <qi.z.zhang@intel.com>
Tue, 16 Oct 2018 00:16:30 +0000 (08:16 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 17 Oct 2018 08:16:18 +0000 (10:16 +0200)
Attach port from secondary should ignore devargs since the private
device is not necessary to support. Also previously, detach port on
a secondary process will mess primary process and cause the same
device can't be attached back again. A secondary process should use
rte_eth_dev_release_port_secondary to release a port.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
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

index bc7daed5e2dea1df7898c1b3926e469054de6d38..376d76302edde2dbf7fd51847e8532d1354904d5 100644 (file)
@@ -926,8 +926,7 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev)
 
        PMD_LOG(INFO, "Initializing pmd_af_packet for %s", name);
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(rte_vdev_device_args(dev)) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        PMD_LOG(ERR, "Failed to probe %s", name);
@@ -987,6 +986,9 @@ rte_pmd_af_packet_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);
+
        internals = eth_dev->data->dev_private;
        for (q = 0; q < internals->nb_queues; q++) {
                rte_free(internals->rx_queue[q].rd);
index 31c83a2869d8f842ec0ad0a987bc502083740880..b731132a5728920c98668a1847aa8f4b0e51156b 100644 (file)
@@ -3152,8 +3152,7 @@ bond_probe(struct rte_vdev_device *dev)
        name = rte_vdev_device_name(dev);
        RTE_BOND_LOG(INFO, "Initializing pmd_bond for %s", name);
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(rte_vdev_device_args(dev)) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        RTE_BOND_LOG(ERR, "Failed to probe %s", name);
@@ -3268,6 +3267,9 @@ bond_remove(struct rte_vdev_device *dev)
        if (eth_dev == NULL)
                return -ENODEV;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return rte_eth_dev_release_port_secondary(eth_dev);
+
        RTE_ASSERT(eth_dev->device == &dev->device);
 
        internals = eth_dev->data->dev_private;
index 8a7015a0b9d076da42df6e1fb270ffdabc4179e2..72f3c16c1a56f87a3c6f64f1963c8b746c91c1f2 100644 (file)
@@ -410,8 +410,7 @@ eth_kni_probe(struct rte_vdev_device *vdev)
        params = rte_vdev_device_args(vdev);
        PMD_LOG(INFO, "Initializing eth_kni for %s", name);
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(params) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        PMD_LOG(ERR, "Failed to probe %s", name);
@@ -464,6 +463,9 @@ eth_kni_remove(struct rte_vdev_device *vdev)
        if (eth_dev == NULL)
                return -1;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return rte_eth_dev_release_port_secondary(eth_dev);
+
        eth_kni_dev_stop(eth_dev);
 
        internals = eth_dev->data->dev_private;
index de10b5bdf6f5163f2ab16867d634169ad255cab0..1e8237a41b6bc41dd38d94fd602ea9b651f34e86 100644 (file)
@@ -614,8 +614,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev)
        params = rte_vdev_device_args(dev);
        PMD_LOG(INFO, "Initializing pmd_null for %s", name);
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(params) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        PMD_LOG(ERR, "Failed to probe %s", name);
@@ -680,6 +679,9 @@ 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);
+
        rte_free(eth_dev->data->dev_private);
 
        rte_eth_dev_release_port(eth_dev);
index 71843c63a140c5e58438cddf234fac7c552b41cb..5431b44dc01c403e1878f98fa4565d05b0ea6475 100644 (file)
@@ -1133,6 +1133,11 @@ octeontx_remove(struct rte_vdev_device *dev)
                if (eth_dev == NULL)
                        return -ENODEV;
 
+               if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+                       rte_eth_dev_release_port_secondary(eth_dev);
+                       continue;
+               }
+
                nic = octeontx_pmd_priv(eth_dev);
                rte_event_dev_stop(nic->evdev);
                PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name);
@@ -1143,6 +1148,9 @@ octeontx_remove(struct rte_vdev_device *dev)
                rte_event_dev_close(nic->evdev);
        }
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        /* Free FC resource */
        octeontx_pko_fc_free();
 
index 51d4051166aa5124017824fc70140b62d19ec683..ede5ebb45e7bcb06010d41c27ad4b8103ea93b18 100644 (file)
@@ -1122,8 +1122,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
        start_cycles = rte_get_timer_cycles();
        hz = rte_get_timer_hz();
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(rte_vdev_device_args(dev)) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        PMD_LOG(ERR, "Failed to probe %s", name);
@@ -1229,6 +1228,9 @@ 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);
+
        internals = eth_dev->data->dev_private;
        if (internals && internals->phy_mac)
                rte_free(eth_dev->data->mac_addrs);
index ad5ae988b131db1dc4885c244c6243fef5cb9e0d..84aaf241019ac24c75b183d8609b6cd95a7fd46d 100644 (file)
@@ -1992,8 +1992,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
        name = rte_vdev_device_name(dev);
        params = rte_vdev_device_args(dev);
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(params) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        TAP_LOG(ERR, "Failed to probe %s", name);
@@ -2075,7 +2074,10 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
        /* find the ethdev entry */
        eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev));
        if (!eth_dev)
-               return 0;
+               return -ENODEV;
+
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return rte_eth_dev_release_port_secondary(eth_dev);
 
        internals = eth_dev->data->dev_private;
 
index aa60522216100a460a67b3f485360c2ccb90a892..a7604ff2323319f27b56fbe06104d4de598e5d88 100644 (file)
@@ -1344,8 +1344,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
 
        VHOST_LOG(INFO, "Initializing pmd_vhost for %s\n", name);
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY &&
-           strlen(rte_vdev_device_args(dev)) == 0) {
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                eth_dev = rte_eth_dev_attach_secondary(name);
                if (!eth_dev) {
                        VHOST_LOG(ERR, "Failed to probe %s\n", name);
@@ -1436,6 +1435,9 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev)
        if (eth_dev == NULL)
                return -ENODEV;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return rte_eth_dev_release_port_secondary(eth_dev);
+
        eth_dev_close(eth_dev);
 
        rte_free(vring_states[eth_dev->data->port_id]);