[v8,15/19] net/softnic: enable port detach on secondary process
diff mbox series

Message ID 20180702054450.29269-16-qi.z.zhang@intel.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • enable hotplug on multi-process
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Zhang, Qi Z July 2, 2018, 5:44 a.m. UTC
Previously, detach port on secondary process will mess primary
process and cause same device can't be attached again, by take
advantage of rte_eth_release_port_private, we can support this
with minor change.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/softnic/rte_eth_softnic.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c
index 6b3c13e5c..a45a7b0dd 100644
--- a/drivers/net/softnic/rte_eth_softnic.c
+++ b/drivers/net/softnic/rte_eth_softnic.c
@@ -750,6 +750,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 +804,29 @@  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) {
+		/* detach device on local pprocess only */
+		if (strlen(rte_vdev_device_args(vdev)) == 0)
+			return rte_eth_dev_release_port_private(dev);
+		/**
+		 * else this is a private device for current process
+		 * so continue with normal detach scenario
+		 */
+	}
+
 	p = dev->data->dev_private;
 
 	/* Free device data structures*/