[dpdk-dev,v4,03/10] eal: move virtual device probing into a bus

Message ID 1488797809-12917-4-git-send-email-jblunck@infradead.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

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

Commit Message

Jan Blunck March 6, 2017, 10:56 a.m. UTC
  This is a refactoring of the virtual device probing which moves into into
a proper bus structure.

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_dev.c  | 22 -----------------
 lib/librte_eal/common/eal_common_vdev.c | 44 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 22 deletions(-)
  

Comments

Thomas Monjalon March 13, 2017, 5:44 p.m. UTC | #1
2017-03-06 11:56, Jan Blunck:
> +static int
> +vdev_scan(void)
> +{
> +	/* for virtual devices we don't need to scan anything */
> +	return 0;
> +}

The vdev_scan could save the devargs.
The vdev args are the equivalent of PCI BDF.
  
Jan Blunck March 27, 2017, 7:46 a.m. UTC | #2
On Mon, Mar 13, 2017 at 6:44 PM, Thomas Monjalon
<thomas.monjalon@6wind.com> wrote:
> 2017-03-06 11:56, Jan Blunck:
>> +static int
>> +vdev_scan(void)
>> +{
>> +     /* for virtual devices we don't need to scan anything */
>> +     return 0;
>> +}
>
> The vdev_scan could save the devargs.
> The vdev args are the equivalent of PCI BDF.

In a later patch ("eal: make virtual bus use rte_vdev_device") the
vdev_scan() is creating the list of devices based on the devargs.
  

Patch

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 4f3b493..1ce90f6 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -79,28 +79,6 @@  void rte_eal_device_remove(struct rte_device *dev)
 int
 rte_eal_dev_init(void)
 {
-	struct rte_devargs *devargs;
-
-	/*
-	 * Note that the dev_driver_list is populated here
-	 * from calls made to rte_eal_driver_register from constructor functions
-	 * embedded into PMD modules via the RTE_PMD_REGISTER_VDEV macro
-	 */
-
-	/* call the init function for each virtual device */
-	TAILQ_FOREACH(devargs, &devargs_list, next) {
-
-		if (devargs->type != RTE_DEVTYPE_VIRTUAL)
-			continue;
-
-		if (rte_eal_vdev_init(devargs->virt.drv_name,
-					devargs->args)) {
-			RTE_LOG(ERR, EAL, "failed to initialize %s device\n",
-					devargs->virt.drv_name);
-			return -1;
-		}
-	}
-
 	return 0;
 }
 
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 7d6e54f..b1f490c 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -37,8 +37,10 @@ 
 #include <stdint.h>
 #include <sys/queue.h>
 
+#include <rte_bus.h>
 #include <rte_vdev.h>
 #include <rte_common.h>
+#include <rte_devargs.h>
 
 struct vdev_driver_list vdev_driver_list =
 	TAILQ_HEAD_INITIALIZER(vdev_driver_list);
@@ -122,3 +124,45 @@  rte_eal_vdev_uninit(const char *name)
 	RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
 	return -EINVAL;
 }
+
+static int
+vdev_scan(void)
+{
+	/* for virtual devices we don't need to scan anything */
+	return 0;
+}
+
+static int
+vdev_probe(void)
+{
+	struct rte_devargs *devargs;
+
+	/*
+	 * Note that the dev_driver_list is populated here
+	 * from calls made to rte_eal_driver_register from constructor functions
+	 * embedded into PMD modules via the RTE_PMD_REGISTER_VDEV macro
+	 */
+
+	/* call the init function for each virtual device */
+	TAILQ_FOREACH(devargs, &devargs_list, next) {
+
+		if (devargs->type != RTE_DEVTYPE_VIRTUAL)
+			continue;
+
+		if (rte_eal_vdev_init(devargs->virt.drv_name,
+				      devargs->args)) {
+			RTE_LOG(ERR, EAL, "failed to initialize %s device\n",
+				devargs->virt.drv_name);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+static struct rte_bus rte_vdev_bus = {
+	.scan = vdev_scan,
+	.probe = vdev_probe,
+};
+
+RTE_REGISTER_BUS(virtual, rte_vdev_bus);