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_release_port_private to release a port.

Signed-off-by: Qi Zhang <qi.z.zh...@intel.com>
---
 drivers/net/softnic/rte_eth_softnic.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/softnic/rte_eth_softnic.c 
b/drivers/net/softnic/rte_eth_softnic.c
index 6b3c13e5c..f3b6863ae 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -741,8 +741,7 @@ pmd_probe(struct rte_vdev_device *vdev)
        /* Parse input arguments */
        params = rte_vdev_device_args(vdev);
 
-       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);
@@ -750,6 +749,7 @@ pmd_probe(struct rte_vdev_device *vdev)
                }
                /* TODO: request info from primary to set up Rx and Tx */
                eth_dev->dev_ops = &pmd_ops;
+               eth_dev->device = &vdev->device;
                rte_eth_dev_probing_finish(eth_dev);
                return 0;
        }
@@ -803,17 +803,22 @@ pmd_remove(struct rte_vdev_device *vdev)
 {
        struct rte_eth_dev *dev = NULL;
        struct pmd_internals *p;
+       const char *name;
 
        if (!vdev)
                return -EINVAL;
 
-       PMD_LOG(INFO, "Removing device \"%s\"",
-               rte_vdev_device_name(vdev));
+       name = rte_vdev_device_name(vdev);
+       PMD_LOG(INFO, "Removing device \"%s\"", name);
 
        /* Find the ethdev entry */
-       dev = rte_eth_dev_allocated(rte_vdev_device_name(vdev));
+       dev = rte_eth_dev_allocated(name);
        if (dev == NULL)
                return -ENODEV;
+
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return rte_eth_dev_release_port_private(dev);
+
        p = dev->data->dev_private;
 
        /* Free device data structures*/
-- 
2.13.6

Reply via email to