[dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once

Wisam Monther wisamm at mellanox.com
Thu Oct 18 13:49:13 CEST 2018


Are we saving cycles by set it to be <= instead of < _ +1?

BRs,
Wisam Jaddo

From: Thomas Monjalon<mailto:thomas at monjalon.net>
Sent: Thursday, October 18, 2018 2:29 PM
To: Iremonger, Bernard<mailto:bernard.iremonger at intel.com>
Cc: dev at dpdk.org<mailto:dev at dpdk.org>; Yigit, Ferruh<mailto:ferruh.yigit at intel.com>; arybchenko at solarflare.com<mailto:arybchenko at solarflare.com>; Ophir Munk<mailto:ophirmu at mellanox.com>; rahul.lakkireddy at chelsio.com<mailto:rahul.lakkireddy at chelsio.com>; Wisam Monther<mailto:wisamm at mellanox.com>
Subject: Re: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once

18/10/2018 12:40, Iremonger, Bernard:
> From: Thomas Monjalon [mailto:thomas at monjalon.net]
> >
> > From: Wisam Jaddo <wisamm at mellanox.com>
> >
> > When detaching a port, the full rte_device is removed.
> > If the rte_device was hosting several ports, the testpmd list of ports must be
> > updated for multiple removals.
>
> ./devtools/check-git-log.sh -1
> Missing 'Fixes' tag:
>         app/testpmd: fix ports list after removing several at once

I think it is OK.
It is fixing a case which was not tested before.
And we don't really need to backport it.

> > Signed-off-by: Wisam Jaddo <wisamm at mellanox.com>
> > ---
> >  app/test-pmd/testpmd.c | 36 +++++++++++++++++++++++++-----------
> >  1 file changed, 25 insertions(+), 11 deletions(-)
> >
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> > 5dbbf783f..c4109417a 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -2186,6 +2186,30 @@ stop_port(portid_t pid)
> >      printf("Done\n");
> >  }
> >
> > +static void
> > +remove_unused_fwd_ports(void)
> > +{
> > +   int i;
> > +   int last_port_idx = nb_ports - 1;
> > +
> > +   for (i = 0; i < last_port_idx + 1; i++) { /* iterate in ports_ids */
>
> Why not use  " i <= last_port_index" instead of adding back 1

If Wisam agrees, I can fix it in v6.

> > +           if (rte_eth_devices[ports_ids[i]].state ==
> > RTE_ETH_DEV_UNUSED) {
> > +                   /* skip unused ports at the end */
> > +                   while (rte_eth_devices[ports_ids[last_port_idx]].state
> > +                                   == RTE_ETH_DEV_UNUSED && i <=
> > last_port_idx)
>
> WARNING:LONG_LINE: line over 80 characters
> #48: FILE: app/test-pmd/testpmd.c:2199:
> +                                       == RTE_ETH_DEV_UNUSED && i <= last_port_idx)

Will fix it.
Anyway, we should reverse the order of this check in order to avoid
accessing ports_ids[-1].

> > +                           last_port_idx--;





More information about the dev mailing list