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 edf9d7d0f2f51bdb3a362661b02d7c550df30610..458e3a6f5d78249c8d91aa2786baed82c613a13f 100644 (file)
@@ -198,5 +198,6 @@ DPDK_17.08 {
        global:
 
        rte_bus_find;
+       rte_bus_find_by_device;
 
 } DPDK_17.05;
index e04ab4ff3df6a711fb15938cb9427f39d04eb5e2..b8a9e3072fbeb32f08006e200c936683ccb94bae 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 052ac8d4cb04994a9dd88cab3ccb927a918f4b0a..f8b321559ec466e4a96889ab051919e86eb97aab 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 944416eda2b13569c4f3cea2d3bd1fe42fe76248..3c193e492781ba80cdf8a7b0dfb8bc1395c64045 100644 (file)
@@ -203,5 +203,6 @@ DPDK_17.08 {
        global:
 
        rte_bus_find;
+       rte_bus_find_by_device;
 
 } DPDK_17.05;