diff mbox series

[v2,2/3] eal:add tailq walk routine

Message ID 20181216171904.90865-2-keith.wiles@intel.com (mailing list archive)
State Superseded, archived
Headers show
Series [v2,1/3] dfs:add FUSE based filesystem for DPDK | expand

Checks

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

Commit Message

Wiles, Keith Dec. 16, 2018, 5:19 p.m. UTC
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
---
V2
   Fix checkpatch warnings

 lib/librte_eal/common/eal_common_tailqs.c | 19 +++++++++++++++++++
 lib/librte_eal/common/include/rte_tailq.h | 13 +++++++++++++
 lib/librte_eal/rte_eal_version.map        |  1 +
 3 files changed, 33 insertions(+)
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index babd3b30a..791dcc37b 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -69,6 +69,25 @@  rte_dump_tailq(FILE *f)
 	rte_rwlock_read_unlock(&mcfg->qlock);
 }
 
+void
+rte_tailq_walk(void (*iter)(const struct rte_tailq_head *, void *), void *arg)
+{
+	struct rte_mem_config *mcfg;
+	unsigned int i = 0;
+
+	if (!iter)
+		return;
+	mcfg = rte_eal_get_configuration()->mem_config;
+
+	rte_rwlock_read_lock(&mcfg->qlock);
+	for (i = 0; i < RTE_MAX_TAILQ; i++) {
+		const struct rte_tailq_head *tailq = &mcfg->tailq_head[i];
+
+		iter(tailq, arg);
+	}
+	rte_rwlock_read_unlock(&mcfg->qlock);
+}
+
 static struct rte_tailq_head *
 rte_eal_tailq_create(const char *name)
 {
diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h
index 9b01abb2c..b9b1c6e75 100644
--- a/lib/librte_eal/common/include/rte_tailq.h
+++ b/lib/librte_eal/common/include/rte_tailq.h
@@ -18,6 +18,7 @@  extern "C" {
 #include <sys/queue.h>
 #include <stdio.h>
 #include <rte_debug.h>
+#include <rte_compat.h>
 
 /** dummy structure type used by the rte_tailq APIs */
 struct rte_tailq_entry {
@@ -85,6 +86,18 @@  struct rte_tailq_elem {
  */
 void rte_dump_tailq(FILE *f);
 
+/**
+ * Walk the tailq list and call the Iterator function given.
+ *
+ * @param func
+ *   Iterator function
+ * @param arg
+ *   pointer to user supplied argument passed to Iterator function
+ */
+void __rte_experimental
+	rte_tailq_walk(void (*iter)(const struct rte_tailq_head *, void *),
+	void *arg);
+
 /**
  * Lookup for a tail queue.
  *
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 3fe78260d..9a7abc778 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -360,4 +360,5 @@  EXPERIMENTAL {
 	rte_service_may_be_active;
 	rte_socket_count;
 	rte_socket_id_by_idx;
+	rte_tailq_walk;
 };