From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id E26301B7F2 for ; Sun, 16 Dec 2018 18:19:11 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Dec 2018 09:19:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,361,1539673200"; d="scan'208";a="128334504" Received: from voquocvi-mobl.ccr.corp.intel.com ([10.255.79.207]) by fmsmga004.fm.intel.com with ESMTP; 16 Dec 2018 09:19:08 -0800 From: Keith Wiles To: dev@dpdk.org Date: Sun, 16 Dec 2018 11:19:04 -0600 Message-Id: <20181216171904.90865-3-keith.wiles@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181216171904.90865-1-keith.wiles@intel.com> References: <20181216171904.90865-1-keith.wiles@intel.com> Subject: [dpdk-dev] [PATCH v2 3/3] ring:add ring walk routine X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Dec 2018 17:19:12 -0000 Signed-off-by: Keith Wiles --- 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(+) diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c index d215acecc..fb5819e4b 100644 --- a/lib/librte_ring/rte_ring.c +++ b/lib/librte_ring/rte_ring.c @@ -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); +} diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index af5444a9f..b9391a655 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -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 * diff --git a/lib/librte_ring/rte_ring_version.map b/lib/librte_ring/rte_ring_version.map index d935efd0d..17c05c1b2 100644 --- a/lib/librte_ring/rte_ring_version.map +++ b/lib/librte_ring/rte_ring_version.map @@ -17,3 +17,10 @@ DPDK_2.2 { rte_ring_free; } DPDK_2.0; + +EXPERIMENTAL { + global: + + rte_ring_walk; +}; + -- 2.17.1