From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 68281A49A for ; Wed, 21 Mar 2018 06:43:52 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2018 22:43:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,338,1517904000"; d="scan'208";a="43927031" Received: from tanjianf-mobl.ccr.corp.intel.com (HELO [10.67.64.69]) ([10.67.64.69]) by orsmga002.jf.intel.com with ESMTP; 20 Mar 2018 22:43:50 -0700 To: Gaetan Rivet , dev@dpdk.org References: <5d49fe469f56c443c8a95688db1b96f13f169652.1521587199.git.gaetan.rivet@6wind.com> From: "Tan, Jianfeng" Message-ID: Date: Wed, 21 Mar 2018 13:43:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <5d49fe469f56c443c8a95688db1b96f13f169652.1521587199.git.gaetan.rivet@6wind.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 01/10] devargs: introduce iterator 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: Wed, 21 Mar 2018 05:43:53 -0000 Hi Gaetan, On 3/21/2018 7:20 AM, Gaetan Rivet wrote: > In preparation to making devargs_list private. > > Bus drivers generally need to access rte_devargs pertaining to their > operations. This match is a common operation for bus drivers. > > Add a new accessor for the rte_devargs list. > > Signed-off-by: Gaetan Rivet > --- > lib/librte_eal/common/eal_common_devargs.c | 20 ++++++++++++++++++++ > lib/librte_eal/common/include/rte_devargs.h | 20 ++++++++++++++++++++ > lib/librte_eal/rte_eal_version.map | 1 + > 3 files changed, 41 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c > index 810b3e18f..c6c5eabcf 100644 > --- a/lib/librte_eal/common/eal_common_devargs.c > +++ b/lib/librte_eal/common/eal_common_devargs.c > @@ -207,3 +207,23 @@ rte_eal_devargs_dump(FILE *f) > devargs->name, devargs->args); > } > } > + > +/* bus-aware rte_devargs iterator. */ > +__rte_experimental > +struct rte_devargs * > +rte_eal_devargs_next(const char *busname, const struct rte_devargs *start) > +{ > + struct rte_devargs *da; > + > + if (start != NULL) > + da = TAILQ_NEXT(start, next); > + else > + da = TAILQ_FIRST(&devargs_list); > + while (da != NULL) { > + if (busname == NULL || > + (strcmp(busname, da->bus->name) == 0)) > + return da; > + da = TAILQ_NEXT(da, next); > + } > + return NULL; > +} > diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h > index 84e5e23c4..969a10449 100644 > --- a/lib/librte_eal/common/include/rte_devargs.h > +++ b/lib/librte_eal/common/include/rte_devargs.h > @@ -189,6 +189,26 @@ rte_eal_devargs_type_count(enum rte_devtype devtype); > */ > void rte_eal_devargs_dump(FILE *f); > > +/** > + * Find next rte_devargs matching the provided bus name. > + * > + * @param busname > + * Limit the iteration to devargs related to buses > + * matching this name. > + * Will return any next rte_devargs if NULL. > + * > + * @param start > + * Starting iteration point. The iteration will start at > + * the first rte_devargs if NULL. > + * > + * @return > + * Next rte_devargs entry matching the requested bus, > + * NULL if there is none. > + */ > +__rte_experimental > +struct rte_devargs * > +rte_eal_devargs_next(const char *busname, const struct rte_devargs *start); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map > index d12360235..02a040a8b 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -216,6 +216,7 @@ EXPERIMENTAL { > > rte_eal_cleanup; > rte_eal_devargs_insert; > + rte_eal_devargs_next; > rte_eal_devargs_parse; > rte_eal_devargs_remove; > rte_eal_hotplug_add; Shall we change these APIs to be thread-safe? Thanks, Jianfeng