From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v2 2/4] ethdev: add siblings iterators Date: Mon, 01 Apr 2019 03:59:45 +0200 Message-ID: <2318869.vaV4MP09YM@xps> References: <20181130002716.27325-1-thomas@monjalon.net> <20190227100724.tjkxtuis5yfwvvrd@bidouze.vm.6wind.com> <5809024.HDbGbE6FtF@xps> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: dev@dpdk.org, Ferruh Yigit , Andrew Rybchenko To: =?ISO-8859-1?Q?Ga=EBtan?= Rivet Return-path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 266DF10A3 for ; Mon, 1 Apr 2019 03:59:48 +0200 (CEST) In-Reply-To: <5809024.HDbGbE6FtF@xps> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 27/02/2019 11:51, Thomas Monjalon: > 27/02/2019 11:07, Ga=EBtan Rivet: > > On Wed, Feb 20, 2019 at 11:10:49PM +0100, Thomas Monjalon wrote: > > > +uint16_t __rte_experimental > > > +rte_eth_find_next_of(uint16_t port_id, const struct rte_device *pare= nt) > > > +{ > > > + while (port_id < RTE_MAX_ETHPORTS && > > > + rte_eth_devices[port_id].state =3D=3D RTE_ETH_DEV_UNUSED && > > > + rte_eth_devices[port_id].device !=3D parent) > > > + port_id++; > >=20 > > Why not call rte_eth_find_next directly from this function, and > > add your specific test on top of it? > >=20 > > Something like: > >=20 > > while (port_id < RTE_MAX_ETHPORTS && > > rte_eth_devices[port_id].device !=3D parent) > > port_id =3D rte_eth_find_next(port_id + 1); > >=20 > > this way you won't have to rewrite the test on the device state. Having= the > > logic expressed in several places would make reworking the device state= s more > > complicated than necessary if it were to happen (just as you did when s= witching > > the test from !(ATTACHED || REMOVED) to (UNUSED). >=20 > About the intent, you are right. > About the solution, it seems buggy. We can try to find another way > of coding this loop by using rte_eth_find_next() > and adding the parent condition. Your proposal is correct if adding a first call before the loop: port_id =3D rte_eth_find_next(port_id);