DPDK patches and discussions
 help / color / mirror / Atom feed
From: Keith Wiles <keith.wiles@intel.com>
To: dev@dpdk.org
Cc: olivier.matz@6wind.com
Subject: [dpdk-dev] [PATCH v4] eal:add tailq walk routine
Date: Thu, 27 Dec 2018 11:23:22 -0600	[thread overview]
Message-ID: <20181227172322.25264-1-keith.wiles@intel.com> (raw)
In-Reply-To: <20181216172721.91042-1-keith.wiles@intel.com>

Signed-off-by: Keith Wiles <keith.wiles@intel.com>
---
V4
  Change function to have a return value.
  to be used to stop walking or continue walking.
V3
  Fix checkpatch warnings adding a commit message.
  Must be using a different checkpatch then on my Ubuntu 18.04 system 
V2
  Fix checkpatch warnings.

 lib/librte_eal/common/eal_common_tailqs.c | 20 ++++++++++++++++++++
 lib/librte_eal/common/include/rte_tailq.h | 16 ++++++++++++++++
 lib/librte_eal/rte_eal_version.map        |  1 +
 3 files changed, 37 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_tailqs.c b/lib/librte_eal/common/eal_common_tailqs.c
index babd3b30a..99e898019 100644
--- a/lib/librte_eal/common/eal_common_tailqs.c
+++ b/lib/librte_eal/common/eal_common_tailqs.c
@@ -69,6 +69,26 @@ rte_dump_tailq(FILE *f)
 	rte_rwlock_read_unlock(&mcfg->qlock);
 }
 
+void
+rte_tailq_walk(int (*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];
+
+		if (iter(tailq, arg) < 0)
+			break;
+	}
+	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..25e99658b 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,21 @@ struct rte_tailq_elem {
  */
 void rte_dump_tailq(FILE *f);
 
+/**
+ * Walk the tailq list and call the Iterator function given.
+ *
+ * @param func
+ *   Iterator function called for each tailq list.
+ *   The rte_eal_get_configuration()->mem_config.qlock read lock is held.
+ *   If Iterator returns < 0 then break out of loop.
+ *   If Iterator returns 0 then continue looping.
+ * @param arg
+ *   pointer to user supplied argument passed to Iterator function.
+ */
+void __rte_experimental
+	rte_tailq_walk(int (*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 eb5f7b9cb..288b20b0e 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -364,4 +364,5 @@ EXPERIMENTAL {
 	rte_service_may_be_active;
 	rte_socket_count;
 	rte_socket_id_by_idx;
+	rte_tailq_walk;
 };
-- 
2.17.1

  parent reply	other threads:[~2018-12-27 17:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16 17:27 [dpdk-dev] [PATCH v2 1/3] dfs:add FUSE based filesystem for DPDK Keith Wiles
2018-12-16 17:27 ` [dpdk-dev] [PATCH v3 2/3] eal:add tailq walk routine Keith Wiles
2018-12-16 17:27 ` [dpdk-dev] [PATCH v3 3/3] ring:add ring " Keith Wiles
2018-12-27 10:02   ` Olivier Matz
2018-12-27 14:47     ` Wiles, Keith
2018-12-27 14:52       ` Wiles, Keith
2018-12-27 15:17         ` Olivier Matz
2018-12-27 15:40           ` Wiles, Keith
2018-12-27 17:24   ` [dpdk-dev] [PATCH v4] " Keith Wiles
2018-12-27 17:23 ` Keith Wiles [this message]
2018-12-27 17:41 ` [dpdk-dev] [PATCH v5] " Keith Wiles
2018-12-27 17:44 ` [dpdk-dev] [PATCH v5] eal:add tailq " Keith Wiles
2018-12-27 18:16 ` [dpdk-dev] [PATCH v6] " Keith Wiles
2018-12-27 18:17 ` [dpdk-dev] [PATCH v5] ring:add ring " Keith Wiles
2018-12-27 18:19 ` [dpdk-dev] [PATCH v6] " Keith Wiles

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181227172322.25264-1-keith.wiles@intel.com \
    --to=keith.wiles@intel.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).