From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id 03865187 for ; Tue, 24 Apr 2018 01:54:20 +0200 (CEST) Received: by mail-pf0-f193.google.com with SMTP id f189so1533243pfa.7 for ; Mon, 23 Apr 2018 16:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OVgpV9OL64gvO6Jn12C12ignHyC/98E9EvMKtocQXu0=; b=HmEkT96eQBYBigoN1fuObCWtYKtsMJSZb9scxm/jf1LppYoNGCUzcQI8jOEOjgDVv9 gT8o9hTCkgoLyv+RB+LLZr4AVX14ue+YlV9ObRPIf0Fr3SzoTguLagUrFJ798i16Wbte Kwa21ZoPpgqmH4woC5lmjt05vX8l3fi2OF1bWhP8ekxG7XHcIrF8YT9pw5pVcCpok3/P jP+XZkl4zlxuxVtOKE7hS885bE4NExfpLcX8m1GsaiKpKFLQUdK/O60dVE4d5cJsOzuw ZHmM+VdLWT3HUS2WzTGxBo0GcCLsiqE67qwge9Z1zAWlVZoqScEVPnQJS6qryK/QeHvS wf+w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=OVgpV9OL64gvO6Jn12C12ignHyC/98E9EvMKtocQXu0=; b=hm6j0mPwYHigRvnUd2c3kR21qcBaqROf1FTBNTY46S2pGiEsz3iTPGirCKabJqzrj1 IvKnICvDjMRIzQCiDi/2xEio+IKzCcRV7B6WscuRQoSjLrI+niEUJG7QDmyiUvnImQPC 9GgAcwqTrbSlas/D84un75A4/1CJEbFCE01T3whgGKDn1J8hIS5Z0TsD3zYdJcomZiU7 fOun1/x3MzTaHO2N9SLWmHEI+83P3PBKmkAEYHXCr8j+jagKIdnrW6qr2pz33NxKh6so idLCK7rMdFMx7R7HfEJn+tPISrWVx1K0QtiWO7hlNl+o2qCwxaviGsS0x4YFfUEE9tA4 1lQw== X-Gm-Message-State: ALQs6tCPEKStxuPLAmMAf4w1jyT0gDYhO7tElaeHZk1Z7DARbM56OWuS CyOWLEjLybcZfk+Di+vapikDq4HMb7c= X-Google-Smtp-Source: AIpwx499AP24/OUm0yryceOJ7/vwzCXUrE3pySLqfB8VxX3Hg+re7+7gEf2ncAylnQbBaL809tYM+Q== X-Received: by 2002:a17:902:a50f:: with SMTP id s15-v6mr23234705plq.175.1524527660163; Mon, 23 Apr 2018 16:54:20 -0700 (PDT) Received: from xeon-e3 (204-195-71-95.wavecable.com. [204.195.71.95]) by smtp.gmail.com with ESMTPSA id q9sm25665761pgs.5.2018.04.23.16.54.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Apr 2018 16:54:20 -0700 (PDT) Date: Mon, 23 Apr 2018 16:54:17 -0700 From: Stephen Hemminger To: Gaetan Rivet Cc: dev@dpdk.org Message-ID: <20180423165417.554d0ee0@xeon-e3> In-Reply-To: <4ae5a6e418b19a458aefee0621af9cc7baf76aab.1524522515.git.gaetan.rivet@6wind.com> References: <4ae5a6e418b19a458aefee0621af9cc7baf76aab.1524522515.git.gaetan.rivet@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 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: Mon, 23 Apr 2018 23:54:21 -0000 On Tue, 24 Apr 2018 00:41:01 +0200 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; > +} Can this be made to return a const pointer? It seems unsymmetrical to get the next value as a non-const pointer when passed a const based on last value.