[dpdk-dev,6/9] vdev: implement find_device bus operation

Message ID 7edb13ac85b3efa9082a39057a9d455ea7c30616.1495637723.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

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

Commit Message

Gaëtan Rivet May 24, 2017, 3:04 p.m. UTC
  From: Jan Blunck <jblunck@infradead.org>

Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
 lib/librte_eal/common/eal_common_vdev.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
  

Patch

diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 0037a64..5fc516f 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -338,9 +338,24 @@  vdev_probe(void)
 	return 0;
 }
 
+static struct rte_device *
+vdev_find_device(int (*match)(const struct rte_device *dev, const void *data),
+	const void *data)
+{
+	struct rte_vdev_device *dev;
+
+	TAILQ_FOREACH(dev, &vdev_device_list, next) {
+		if (match(&dev->device, data))
+			return &dev->device;
+	}
+
+	return NULL;
+}
+
 static struct rte_bus rte_vdev_bus = {
 	.scan = vdev_scan,
 	.probe = vdev_probe,
+	.find_device = vdev_find_device,
 };
 
 RTE_INIT(rte_vdev_bus_register);