bus: add helper to find which bus holds a device
authorJan Blunck <jblunck@infradead.org>
Fri, 30 Jun 2017 18:19:35 +0000 (20:19 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 3 Jul 2017 23:08:28 +0000 (01:08 +0200)
Signed-off-by: Jan Blunck <jblunck@infradead.org>
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
lib/librte_eal/bsdapp/eal/rte_eal_version.map
lib/librte_eal/common/eal_common_bus.c
lib/librte_eal/common/include/rte_bus.h
lib/librte_eal/linuxapp/eal/rte_eal_version.map

index edf9d7d..458e3a6 100644 (file)
@@ -198,5 +198,6 @@ DPDK_17.08 {
        global:
 
        rte_bus_find;
+       rte_bus_find_by_device;
 
 } DPDK_17.05;
index e04ab4f..b8a9e30 100644 (file)
@@ -165,3 +165,26 @@ rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
        }
        return bus;
 }
+
+static int
+cmp_rte_device(const struct rte_device *dev1, const void *_dev2)
+{
+       const struct rte_device *dev2 = _dev2;
+
+       return dev1 != dev2;
+}
+
+static int
+bus_find_device(const struct rte_bus *bus, const void *_dev)
+{
+       struct rte_device *dev;
+
+       dev = bus->find_device(NULL, cmp_rte_device, _dev);
+       return dev == NULL;
+}
+
+struct rte_bus *
+rte_bus_find_by_device(const struct rte_device *dev)
+{
+       return rte_bus_find(NULL, bus_find_device, (const void *)dev);
+}
index 052ac8d..f8b3215 100644 (file)
@@ -209,6 +209,11 @@ typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data);
 struct rte_bus *rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
                             const void *data);
 
+/**
+ * Find the registered bus for a particular device.
+ */
+struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev);
+
 /**
  * Helper for Bus registration.
  * The constructor has higher priority than PMD constructors.
index 944416e..3c193e4 100644 (file)
@@ -203,5 +203,6 @@ DPDK_17.08 {
        global:
 
        rte_bus_find;
+       rte_bus_find_by_device;
 
 } DPDK_17.05;