[v2,3/3] ring:add ring walk routine
Checks
Commit Message
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
---
V2
Fix checkpatch warnings.
lib/librte_ring/rte_ring.c | 20 ++++++++++++++++++++
lib/librte_ring/rte_ring.h | 14 ++++++++++++++
lib/librte_ring/rte_ring_version.map | 7 +++++++
3 files changed, 41 insertions(+)
@@ -280,3 +280,23 @@ rte_ring_lookup(const char *name)
return r;
}
+
+void
+rte_ring_walk(void (*func)(struct rte_ring *r, void *arg), void *arg)
+{
+ const struct rte_tailq_entry *te;
+ struct rte_ring_list *ring_list;
+
+ if (!func)
+ return;
+
+ ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
+
+ rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
+
+ TAILQ_FOREACH(te, ring_list, next) {
+ func((struct rte_ring *) te->data, arg);
+ }
+
+ rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);
+}
@@ -769,6 +769,20 @@ rte_ring_get_capacity(const struct rte_ring *r)
*/
void rte_ring_list_dump(FILE *f);
+/**
+ * Walk the list of ring entries and call the function provided
+ *
+ * @param func
+ * The function to call for each ring entry using the following prototype
+ * void (*func)(struct rte_ring *r, void *arg)
+ * @param arg
+ * argument for the call to function
+ * @return
+ * None.
+ */
+void __rte_experimental
+rte_ring_walk(void (*func)(struct rte_ring *r, void *arg), void *arg);
+
/**
* Search a ring from its name
*
@@ -17,3 +17,10 @@ DPDK_2.2 {
rte_ring_free;
} DPDK_2.0;
+
+EXPERIMENTAL {
+ global:
+
+ rte_ring_walk;
+};
+