[dpdk-dev] [PATCH 1/9] bus: add bus iterator to find a particular bus
Gaetan Rivet
gaetan.rivet at 6wind.com
Wed May 24 17:04:53 CEST 2017
From: Jan Blunck <jblunck at infradead.org>
Signed-off-by: Jan Blunck <jblunck at infradead.org>
---
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 +
lib/librte_eal/common/eal_common_bus.c | 14 ++++++++++++++
lib/librte_eal/common/include/rte_bus.h | 20 ++++++++++++++++++++
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 +
4 files changed, 36 insertions(+)
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 2e48a73..ed09ab2 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -162,6 +162,7 @@ DPDK_17.02 {
DPDK_17.05 {
global:
+ rte_bus_find;
rte_cpu_is_supported;
rte_log_dump;
rte_log_register;
diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 8f9baf8..5e33129 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -145,3 +145,17 @@ rte_bus_dump(FILE *f)
}
}
}
+
+struct rte_bus *
+rte_bus_find(int (*match)(const struct rte_bus *bus, const void *data),
+ const void *data)
+{
+ struct rte_bus *bus = NULL;
+
+ TAILQ_FOREACH(bus, &rte_bus_list, next) {
+ if (match(bus, data))
+ break;
+ }
+
+ return bus;
+}
diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
index 7c36969..66856bb 100644
--- a/lib/librte_eal/common/include/rte_bus.h
+++ b/lib/librte_eal/common/include/rte_bus.h
@@ -141,6 +141,26 @@ int rte_bus_probe(void);
void rte_bus_dump(FILE *f);
/**
+ * Bus iterator to find a particular bus.
+ *
+ * The callback function should return 0 if the bus doesn't match and non-zero
+ * if it does. If the callback returns non-zero this function will stop
+ * iterating over any more buses.
+ *
+ * @param match
+ * Callback function to check bus
+ *
+ * @param data
+ * Data to pass to match callback
+ *
+ * @return
+ * A pointer to a rte_bus structure or NULL in case no bus matches
+ */
+struct rte_bus *rte_bus_find(
+ int (*match)(const struct rte_bus *bus, const void *data),
+ const void *data);
+
+/**
* Helper for Bus registration.
* The constructor has higher priority than PMD constructors.
*/
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 670bab3..6efa517 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -166,6 +166,7 @@ DPDK_17.02 {
DPDK_17.05 {
global:
+ rte_bus_find;
rte_cpu_is_supported;
rte_intr_free_epoll_fd;
rte_log_dump;
--
2.1.4
More information about the dev
mailing list