diff mbox

[dpdk-dev] pci: implement find_device bus operation

Message ID a2f90d259a1e4f1a63a27aa82e6aa8d085364914.1495636394.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Headers show

Checks

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

Commit Message

Gaëtan Rivet May 24, 2017, 3:09 p.m. UTC
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
This patch depends on:

bus: attach / detach API
http://dpdk.org/ml/archives/dev/2017-May/066330.html
http://dpdk.org/dev/patchwork/patch/24489/
---
 lib/librte_eal/common/eal_common_pci.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox

Patch

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index b749991..8428006 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -512,10 +512,24 @@  rte_pci_remove_device(struct rte_pci_device *pci_dev)
 	TAILQ_REMOVE(&rte_pci_bus.device_list, pci_dev, next);
 }
 
+static struct rte_device *
+pci_find_device(int (*match)(const struct rte_device *dev, const void *data),
+		const void *data)
+{
+	struct rte_pci_device *dev;
+
+	FOREACH_DEVICE_ON_PCIBUS(dev) {
+		if (match(&dev->device, data))
+			return &dev->device;
+	}
+	return NULL;
+}
+
 struct rte_pci_bus rte_pci_bus = {
 	.bus = {
 		.scan = rte_pci_scan,
 		.probe = rte_pci_probe,
+		.find_device = pci_find_device,
 	},
 	.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
 	.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),