From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 3ECB15F6E for ; Wed, 21 Mar 2018 09:50:26 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id h2so4315377wre.12 for ; Wed, 21 Mar 2018 01:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=UDAobkxGdodjbHHq4b8X8ugdWvu3XOonA07ZXbznq6M=; b=xsNL0i8mx4jCmMGyYs7hVy4pqaWzaDQHLvd5UAs1FATmLx90fFL9kfl/krES2A/Msq dqcuFCusnCXDn5qs2013JuiRZD6iSB78T1X3izdW/sA+kyl/xNc4r99w/iXqMlym53HK /Ut9HO4SYrkYjTsMhKHv4XKdtwhRLhp0uSn3QoNNTRxuOCjkmvM+cDZ6crLRupF4RtP/ RigRqwZrymJ3aMSckttNgWTsrItGL2lXrU17+0l+k6QUIzUEgqBEZLTqCBw7zovqfni3 IFyCFc76LFRgGo+4U2So4zS1OhHKCh/TVPNohFBRXPFrGOvjH+adBz7c5O8c/f5vX8Zt I99g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=UDAobkxGdodjbHHq4b8X8ugdWvu3XOonA07ZXbznq6M=; b=HPg1jnQgIJunFPCTpyo8Qk+q7jj6Dd5N8WvrySB1i+vqpb9gBaq80268Dq91cQJm2/ FJsu8HgliFfyQlcckwzp3a0c38n8nbeBs0kFa8QzQhaU18LxY4rwsb8kkMmSdiVyDCrt L2GR35/UWCekZMLq1TDEIgE0yvcsC0uD2TF+oBcFhppW7cAFRlOG9OEa22SXV5LEKWgu Mh1YMuIB0P3cIW6mBN6v0gFkIfoUSjjk4AsXS9cfetNw4WPJx3eqVDBUR02m8Ws2Wkc/ 3m32me5DMWT5WNVB1ESmc/PQHGJ6AE28PwYaE1oNMuiOMOkvyUE+g0o2NVDRQnP6oY9g R3Yg== X-Gm-Message-State: AElRT7GvOvI+/uQhgtoUfzJURpZLhYcQcI4BuFlYyrCgatdIZbVxXtCy gxSDLMPd8yOv5IDGATSFBtXKkwlI X-Google-Smtp-Source: AG47ELs1UFRTm8cR6P6BZhT/NAR9Uey4q9P8BHVjF4A8Fy1N5QGTdYUWBn9OdN2F1xpwsycJ/d5LBQ== X-Received: by 10.223.164.140 with SMTP id g12mr12615741wrb.270.1521622225726; Wed, 21 Mar 2018 01:50:25 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id t6sm3100944wre.50.2018.03.21.01.50.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 01:50:24 -0700 (PDT) Date: Wed, 21 Mar 2018 09:50:10 +0100 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: "Tan, Jianfeng" Cc: dev@dpdk.org Message-ID: <20180321085010.issi4uagba7yqoyi@bidouze.vm.6wind.com> References: <5d49fe469f56c443c8a95688db1b96f13f169652.1521587199.git.gaetan.rivet@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) 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 08:50:26 -0000 Hello Jianfeng, On Wed, Mar 21, 2018 at 01:43:49PM +0800, Tan, Jianfeng wrote: > 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? It was not planned, but I think you raise an interesting point. At the moment, most devargs operations are happening when a single thread is started (eal init). However, hotplug means having insertion and deletion possibly happening in additional threads. This API exists and could help making these operations thread-safe. So this is low-priority I think for now (unless shown otherwise), but definitely something to look into. -- Gaëtan Rivet 6WIND