From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matan Azrad Subject: Re: [PATCH v4 18/20] ethdev: register ether layer as a class Date: Mon, 9 Apr 2018 07:58:08 +0000 Message-ID: References: <06ec9fd8f884c6d3cffb8a24c0d9ac71d589812d.1522358422.git.gaetan.rivet@6wind.com> <20180409074705.p4y56y43ef2fszso@bidouze.vm.6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= Return-path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50065.outbound.protection.outlook.com [40.107.5.65]) by dpdk.org (Postfix) with ESMTP id 3F6DF1B764 for ; Mon, 9 Apr 2018 09:58:09 +0200 (CEST) In-Reply-To: <20180409074705.p4y56y43ef2fszso@bidouze.vm.6wind.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Gaetan From: Ga=EBtan Rivet, Monday, April 9, 2018 10:47 AM > Hi Matan, >=20 > On Mon, Apr 09, 2018 at 07:41:58AM +0000, Matan Azrad wrote: > > Hi Gaetan > > > > From: Gaetan Rivet, Friday, March 30, 2018 12:24 AM > > > Signed-off-by: Gaetan Rivet > > > --- > > > lib/Makefile | 2 +- > > > lib/librte_ether/Makefile | 3 +- > > > lib/librte_ether/rte_class_eth.c | 73 > > > ++++++++++++++++++++++++++++++++++++++++ > > > 3 files changed, 76 insertions(+), 2 deletions(-) create mode > > > 100644 lib/librte_ether/rte_class_eth.c > > > > > > diff --git a/lib/Makefile b/lib/Makefile index 4206485d3..47513f03f > > > 100644 > > > --- a/lib/Makefile > > > +++ b/lib/Makefile > > > @@ -23,7 +23,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=3D > > > librte_cmdline DEPDIRS-librte_cmdline :=3D librte_eal > > > DIRS-$(CONFIG_RTE_LIBRTE_ETHER) +=3D librte_ether > > > DEPDIRS-librte_ether :=3D librte_net librte_eal librte_mempool > > > librte_ring -DEPDIRS-librte_ether +=3D librte_mbuf > > > +DEPDIRS-librte_ether +=3D librte_mbuf librte_kvargs > > > DIRS-$(CONFIG_RTE_LIBRTE_BBDEV) +=3D librte_bbdev DEPDIRS- > > > librte_bbdev :=3D librte_eal librte_mempool librte_mbuf > > > DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) +=3D librte_cryptodev diff --git > > > a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile index > > > 3ca5782bb..a1a0393de 100644 > > > --- a/lib/librte_ether/Makefile > > > +++ b/lib/librte_ether/Makefile > > > @@ -12,13 +12,14 @@ CFLAGS +=3D -DALLOW_EXPERIMENTAL_API > CFLAGS > > > +=3D -O3 CFLAGS +=3D $(WERROR_FLAGS) LDLIBS +=3D -lrte_net -lrte_ea= l - > > > lrte_mempool -lrte_ring -LDLIBS +=3D -lrte_mbuf > > > +LDLIBS +=3D -lrte_mbuf -lrte_kvargs > > > > > > EXPORT_MAP :=3D rte_ethdev_version.map > > > > > > LIBABIVER :=3D 8 > > > > > > SRCS-y +=3D rte_ethdev.c > > > +SRCS-y +=3D rte_class_eth.c > > > SRCS-y +=3D rte_flow.c > > > SRCS-y +=3D rte_tm.c > > > SRCS-y +=3D rte_mtr.c > > > diff --git a/lib/librte_ether/rte_class_eth.c > > > b/lib/librte_ether/rte_class_eth.c > > > new file mode 100644 > > > index 000000000..97d24781d > > > --- /dev/null > > > +++ b/lib/librte_ether/rte_class_eth.c > > > @@ -0,0 +1,73 @@ > > > +/* SPDX-License-Identifier: BSD-3-Clause > > > + * Copyright(c) 2018 Ga=EBtan Rivet > > > + */ > > > + > > > +#include > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +#include "rte_ethdev.h" > > > +#include "rte_ethdev_core.h" > > > + > > > +enum eth_params { > > > + RTE_ETH_PARAMS_MAX, > > > +}; > > > + > > > +static const char *eth_params_keys[] =3D { > > > + [RTE_ETH_PARAMS_MAX] =3D NULL, > > > +}; > > > + > > > +static int > > > +eth_dev_match(struct rte_eth_dev *edev, > > > + struct rte_kvargs *kvlist) > > > +{ > > > + (void) kvlist; > > > + (void) edev; > > > + return 0; > > > +} > > > + > > > +static void * > > > +eth_dev_iterate(const void *_start, > > > + const char *str, > > > + const struct rte_dev_iterator *it) { > > > + const struct rte_eth_dev *start =3D _start; > > > + struct rte_device *dev =3D it->device; > > > + struct rte_kvargs *kvargs =3D NULL; > > > + struct rte_eth_dev *edev =3D NULL; > > > + uint16_t p =3D 0; > > > + > > > + if (str !=3D NULL) { > > > + kvargs =3D rte_kvargs_parse(str, eth_params_keys); > > > + if (kvargs =3D=3D NULL) { > > > + RTE_LOG(ERR, EAL, "cannot parse argument list\n"); > > > + rte_errno =3D EINVAL; > > > + return NULL; > > > + } > > > + } > > > + if (start) > > > + p =3D start->data->port_id + 1; > > > + for (p =3D rte_eth_find_next(p); > > > + p < RTE_MAX_ETHPORTS; > > > + p =3D rte_eth_find_next(p + 1)) { > > > > What are about differed\owned\bonded devices? > > What is actually the use cases of this iterator? > > DPDK internal management or applications? > > >=20 > This API is public, so anyone can use it. > It should be primarily used by internal systems however. > I do not think Applications would be interested in calling the dev_iterat= e ops. >=20 > The EAL would provide a way to list interfaces from each layers. Then DPD= K > libraries (such as librte_ether) would translate this following their int= ernal > rules. librte_ether would thus for example here translate an rte_eth_dev > handle to a port_id, that an application could use. If there was a need t= o filter > by owner_id, then it would be the job of librte_ether. >=20 > The EAL cannot keep track of layers specifics, it can only provide generi= c APIs. This is exactly what I'm asking, what is the right behavior here? Now, The code is skipping DEFFERED devices but iterating over owned\bonded = devices. Looks like any USED port should be iterated... Moreover, looks like there is chance to iterate over EAL device more than 1= time for loop, Is it OK? > > > + edev =3D &rte_eth_devices[p]; > > > + if (dev !=3D edev->device) > > > + goto next_ethdev; > > > + if (eth_dev_match(edev, kvargs) =3D=3D 0) > > > + break; > > > +next_ethdev: > > > + edev =3D NULL; > > > + } > > > + rte_kvargs_free(kvargs); > > > + return edev; > > > +} > > > + > > > +struct rte_class rte_class_eth =3D { > > > + .dev_iterate =3D eth_dev_iterate, > > > +}; > > > + > > > +RTE_REGISTER_CLASS(eth, rte_class_eth); > > > -- > > > 2.11.0 > > >=20 > -- > Ga=EBtan Rivet > 6WIND