This patch implements the plug and unplug function to support
attach/detach of dpni interfaces.

Signed-off-by: Hemant Agrawal <[email protected]>
---
 drivers/bus/fslmc/fslmc_bus.c | 56 +++++++++++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 49c61c9d2d..4529ec5085 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -589,17 +589,61 @@ rte_dpaa2_get_iommu_class(void)
 }
 
 static int
-fslmc_bus_plug(struct rte_device *dev __rte_unused)
+fslmc_bus_plug(struct rte_device *rte_dev)
 {
-       /* No operation is performed while plugging the device */
-       return 0;
+       int ret = 0;
+       struct rte_dpaa2_device *dev = container_of(rte_dev,
+                       struct rte_dpaa2_device, device);
+       struct rte_dpaa2_driver *drv;
+
+       TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) {
+               ret = rte_fslmc_match(drv, dev);
+               if (ret)
+                       continue;
+
+               if (!drv->probe)
+                       continue;
+
+               if (rte_dev_is_probed(&dev->device))
+                       continue;
+
+               if (dev->device.devargs &&
+                   dev->device.devargs->policy == RTE_DEV_BLOCKED) {
+                       DPAA2_BUS_DEBUG("%s Blocked, skipping",
+                                     dev->device.name);
+                       continue;
+               }
+
+               ret = drv->probe(drv, dev);
+               if (ret) {
+                       DPAA2_BUS_ERR("Unable to probe");
+               } else {
+                       dev->driver = drv;
+                       dev->device.driver = &drv->driver;
+                       DPAA2_BUS_INFO("%s Plugged",  dev->device.name);
+               }
+               break;
+       }
+
+       return ret;
 }
 
 static int
-fslmc_bus_unplug(struct rte_device *dev __rte_unused)
+fslmc_bus_unplug(struct rte_device *rte_dev)
 {
-       /* No operation is performed while unplugging the device */
-       return 0;
+       struct rte_dpaa2_device *dev = container_of(rte_dev,
+                       struct rte_dpaa2_device, device);
+       struct rte_dpaa2_driver *drv = dev->driver;
+
+       if (drv && drv->remove) {
+               drv->remove(dev);
+               dev->driver = NULL;
+               dev->device.driver = NULL;
+               DPAA2_BUS_INFO("%s Un-Plugged",  dev->device.name);
+               return 0;
+       }
+
+       return -ENODEV;
 }
 
 static void *
-- 
2.25.1

Reply via email to