From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 8AA6825A1 for ; Wed, 28 Mar 2018 14:48:44 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id l9so4740591wmh.2 for ; Wed, 28 Mar 2018 05:48:44 -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=0cZoGO25hmxp/gxtEb/288hw5sNjmPETZ+OARV8I/0I=; b=nTP+j3uh39VcZ9tqfPwfGnUajD3r2nYovENWcixQ8G+quC28pbNMzUDH57FQRz71E3 YjzgTNJzPWJXyG74wkZmyvc8Dv19sn/dW92vw1wsPYtMbAzk0OkCdTLaveTKYb/XL7YM ARceyj1Pz/cPhzxvWHyhh/69/D7JhvV7ScO/ALHVSpVzndrs059MAJIkmqY72U7qFX1z eBWo5GSpl4GWdIYsvacMWzSmciRQ8AkMGNTy5AkcOz9HPEQhlS4nQHpO0wy7dC/pbCOy xjW95LJw+oLef1xqUOyQF/fndB7YsjoyeU9KdUFN6T2nWXGAVgmeDJ3/OTz1SMYdX47c qn2g== 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=0cZoGO25hmxp/gxtEb/288hw5sNjmPETZ+OARV8I/0I=; b=uOWxg8HoZvRihzu5tgPHopefANeifIABImjSVvmZcNR/uOKvDpVnvE1S/u/BgaYiS/ 8mDLkEBOy+rWye50mBuJrYHiVr08sZJawPB3D6L4S+Xw4xB1f4IcmPQ5aM6+It2GIxpx 7m2F6uXt0kRLz7F1/i7hKwuZOClWaH5E+pSref3K7FdTkjLV0OS72l1x2Yn7ztsH1XPk lcPJWlzuqNr7tEaWSvMsqqVv8WtgMfo+MZ8qQlGfOlipX6wN0byiCDVQC+cdNYnBezxi hmQ0T7TBfgst7P3x93u8w2U3vXS4kLQ9UKu2Jp4r5YUHZ9H8K3tuTlkRP4M0R0I6TcyO 7+wA== X-Gm-Message-State: AElRT7G0PylZdeyylHWodZbgPYz31B3cWGQHpz4L1ITjDDFDlWtcUFJr JmaSd1legGxwT1qrO3395ylb+ygF X-Google-Smtp-Source: AIpwx49FSYnhnQoK5+pVFPvLhA/fK8ackJYr2QR84OJNcfLLFiVox4t8DacmJEVlb10wjzXGiAA4Jg== X-Received: by 10.28.237.6 with SMTP id l6mr2347485wmh.122.1522241323888; Wed, 28 Mar 2018 05:48:43 -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 i127sm3419028wmf.33.2018.03.28.05.48.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Mar 2018 05:48:41 -0700 (PDT) Date: Wed, 28 Mar 2018 14:48:28 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Neil Horman Cc: dev@dpdk.org, "Wiles, Keith" Message-ID: <20180328124828.7ue64rntx4dt6os3@bidouze.vm.6wind.com> References: <20180327114750.GA30585@hmswarspite.think-freely.org> <20180327124000.6n63hpng53tm3bil@bidouze.vm.6wind.com> <20180327130413.s2waw6udjfehu77t@bidouze.vm.6wind.com> <20180327202321.bapd64u6ftqyke5q@bidouze.vm.6wind.com> <20180327232641.GA16505@neilslaptop.think-freely.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180327232641.GA16505@neilslaptop.think-freely.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v3 10/20] eal/dev: implement device iteration initialization 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, 28 Mar 2018 12:48:44 -0000 On Tue, Mar 27, 2018 at 07:26:41PM -0400, Neil Horman wrote: > On Tue, Mar 27, 2018 at 10:23:21PM +0200, Gaëtan Rivet wrote: > > On Tue, Mar 27, 2018 at 03:04:13PM +0200, Gaëtan Rivet wrote: > > > On Tue, Mar 27, 2018 at 02:40:00PM +0200, Gaëtan Rivet wrote: > > > > On Tue, Mar 27, 2018 at 07:47:50AM -0400, Neil Horman wrote: > > > > > On Tue, Mar 27, 2018 at 01:18:34AM +0200, Gaetan Rivet wrote: > > > > > > Parse a device description. > > > > > > Split this description in their relevant part for each layers. > > > > > > No dynamic allocation is performed. > > > > > > > > > > > > Cc: Neil Horman > > > > > > Cc: "Wiles, Keith" > > > > > > Signed-off-by: Gaetan Rivet > > > > > > --- > > > > > > > > > > > > This version uses librte_kvargs. > > > > > > > > > > > > lib/Makefile | 1 + > > > > > > lib/librte_eal/bsdapp/eal/Makefile | 1 + > > > > > > lib/librte_eal/common/eal_common_dev.c | 147 ++++++++++++++++++++++++++++++++ > > > > > > lib/librte_eal/common/include/rte_dev.h | 23 +++++ > > > > > > lib/librte_eal/linuxapp/eal/Makefile | 1 + > > > > > > lib/librte_eal/rte_eal_version.map | 1 + > > > > > > 6 files changed, 174 insertions(+) > > > > > > > > > > > > diff --git a/lib/Makefile b/lib/Makefile > > > > > > index fc7a55a37..1b17526f7 100644 > > > > > > --- a/lib/Makefile > > > > > > +++ b/lib/Makefile > > > > > > @@ -6,6 +6,7 @@ include $(RTE_SDK)/mk/rte.vars.mk > > > > > > DIRS-y += librte_compat > > > > > > DIRS-$(CONFIG_RTE_LIBRTE_KVARGS) += librte_kvargs > > > > > > DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal > > > > > > +DEPDIRS-librte_eal := librte_kvargs > > > > > > DIRS-$(CONFIG_RTE_LIBRTE_PCI) += librte_pci > > > > > > DEPDIRS-librte_pci := librte_eal > > > > > > DIRS-$(CONFIG_RTE_LIBRTE_RING) += librte_ring > > > > > > diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile > > > > > > index 17ff1ac45..f6cea7fc2 100644 > > > > > > --- a/lib/librte_eal/bsdapp/eal/Makefile > > > > > > +++ b/lib/librte_eal/bsdapp/eal/Makefile > > > > > > @@ -18,6 +18,7 @@ CFLAGS += $(WERROR_FLAGS) -O3 > > > > > > LDLIBS += -lexecinfo > > > > > > LDLIBS += -lpthread > > > > > > LDLIBS += -lgcc_s > > > > > > +LDLIBS += -lrte_kvargs > > > > > > > > > > > > EXPORT_MAP := ../../rte_eal_version.map > > > > > > > > > > > > diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c > > > > > > index cd071442f..1f6df2351 100644 > > > > > > --- a/lib/librte_eal/common/eal_common_dev.c > > > > > > +++ b/lib/librte_eal/common/eal_common_dev.c > > > > > > @@ -10,9 +10,12 @@ > > > > > > > > > > > > #include > > > > > > #include > > > > > > +#include > > > > > > #include > > > > > > #include > > > > > > #include > > > > > > +#include > > > > > > +#include > > > > > > #include > > > > > > > > > > > > #include "eal_private.h" > > > > > > @@ -207,3 +210,147 @@ rte_eal_hotplug_remove(const char *busname, const char *devname) > > > > > > rte_eal_devargs_remove(busname, devname); > > > > > > return ret; > > > > > > } > > > > > > + > > > > > > +static size_t > > > > > > +dev_layer_count(const char *s) > > > > > > +{ > > > > > > + size_t i = s ? 1 : 0; > > > > > > + > > > > > > + while (s != NULL && s[0] != '\0') { > > > > > > + i += s[0] == '/'; > > > > > > + s++; > > > > > > + } > > > > > > + return i; > > > > > > +} > > > > > > + > > > > > So the above code really just counts the number characters in the string, > > > > > omitting the delimiter character '/', right? If thats all you want to do, you can just > > > > > use strtok and strnlen for that, cant you? > > > > > > > > Will do. > > > > > > > > > > Answered too quickly. > > > No, this function only counts the number of occurences of '/' in the > > > text. > > > > > > strtok could be used however in the main function. > > > Will see for a simpler implementation using it. > > > > > > > After a few tries, I see no benefit in using strtok. > > The original const text must still be tokenized, strtok would modify it. > > > > Duplicating would force finding the references in the original text, > > which would make the code as complex as it is now. > > > Oh, if you don't want to modify the string, then index() is what you want. see > man 3 index, or man 3 rindex > > Neil > strchr is already used when necessary, and index is removed since POSIX.1-2008. Thanks for the suggestions, it was still helpful to go over the code and see if there were possible improvements. -- Gaëtan Rivet 6WIND