From patchwork Thu Dec 27 18:16:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wiles, Keith" X-Patchwork-Id: 49322 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1031A5B16; Thu, 27 Dec 2018 19:16:43 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 1E9095B16 for ; Thu, 27 Dec 2018 19:16:40 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Dec 2018 10:16:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,406,1539673200"; d="scan'208";a="103748162" Received: from kwyoon-mobl.amr.corp.intel.com ([10.251.151.199]) by orsmga006.jf.intel.com with ESMTP; 27 Dec 2018 10:16:39 -0800 From: Keith Wiles To: dev@dpdk.org Cc: olivier.matz@6wind.com Date: Thu, 27 Dec 2018 12:16:37 -0600 Message-Id: <20181227181637.26581-1-keith.wiles@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181216172721.91042-1-keith.wiles@intel.com> References: <20181216172721.91042-1-keith.wiles@intel.com> Subject: [dpdk-dev] [PATCH v6] eal:add tailq 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add the tailq walk routine for debugging and other uses. This routine will hold the read lock while walking the list. Signed-off-by: Keith Wiles --- V6 Remove warning V5 Fixup checkpatch warnings. 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 #include #include +#include /** 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; };