vdev: refactor probe/remove
authorJan Blunck <jblunck@infradead.org>
Tue, 11 Apr 2017 15:44:08 +0000 (17:44 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 14 Apr 2017 13:23:29 +0000 (15:23 +0200)
This is a preparation for the introduction of the struct rte_vdev_device.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
lib/librte_eal/common/eal_common_vdev.c

index a94c4c6..c255073 100644 (file)
@@ -66,14 +66,11 @@ rte_eal_vdrv_unregister(struct rte_vdev_driver *driver)
        TAILQ_REMOVE(&vdev_driver_list, driver, next);
 }
 
-int
-rte_eal_vdev_init(const char *name, const char *args)
+static int
+vdev_probe_all_drivers(const char *name, const char *args)
 {
        struct rte_vdev_driver *driver;
 
-       if (name == NULL)
-               return -EINVAL;
-
        TAILQ_FOREACH(driver, &vdev_driver_list, next) {
                /*
                 * search a driver prefix in virtual device name.
@@ -94,18 +91,29 @@ rte_eal_vdev_init(const char *name, const char *args)
                        return driver->probe(name, args);
        }
 
-       RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
-       return -EINVAL;
+       return 1;
 }
 
 int
-rte_eal_vdev_uninit(const char *name)
+rte_eal_vdev_init(const char *name, const char *args)
 {
-       struct rte_vdev_driver *driver;
+       int ret;
 
        if (name == NULL)
                return -EINVAL;
 
+       ret = vdev_probe_all_drivers(name, args);
+       if (ret  > 0)
+               RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+
+       return ret;
+}
+
+static int
+vdev_remove_driver(const char *name)
+{
+       struct rte_vdev_driver *driver;
+
        TAILQ_FOREACH(driver, &vdev_driver_list, next) {
                /*
                 * search a driver prefix in virtual device name.
@@ -126,8 +134,22 @@ rte_eal_vdev_uninit(const char *name)
                        return driver->remove(name);
        }
 
-       RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
-       return -EINVAL;
+       return 1;
+}
+
+int
+rte_eal_vdev_uninit(const char *name)
+{
+       int ret;
+
+       if (name == NULL)
+               return -EINVAL;
+
+       ret = vdev_remove_driver(name);
+       if (ret > 0)
+               RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
+
+       return ret;
 }
 
 static int