From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas@monjalon.net>
Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com
 [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 74E795B36
 for <dev@dpdk.org>; Thu, 18 Oct 2018 13:29:07 +0200 (CEST)
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id 1B6BF2264F;
 Thu, 18 Oct 2018 07:29:07 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute1.internal (MEProxy); Thu, 18 Oct 2018 07:29:07 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding:content-type; s=mesmtp;
 bh=Ox+LxjFLVZxBjPXDI0SzRHIC1ln+qsu5kFfYEl9H1EA=; b=nzguO01YUVRa
 WHo+kx8f64WB/BXuTyRgXjv7jKEoCG+icT9ALbmTJ4J/vZm2OAtzPKDOXSncvyVz
 dCcDIvy0s0E+wIYOZl5aNxWww+mZT80cTjTC7gbx/vl5LqZeMNuOnxbce0XnM5u7
 bJJlZalKcIn3isejChi5w+HxZEelWsU=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:content-type
 :date:from:in-reply-to:message-id:mime-version:references
 :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
 :x-sasl-enc; s=fm1; bh=Ox+LxjFLVZxBjPXDI0SzRHIC1ln+qsu5kFfYEl9H1
 EA=; b=Bb5/mYZ0PZJoNlX/qKZFhaPP13ZeXdKpnohBwA+sRAGhz64Ak913ofLU1
 QOfD8jWXd8ZvhH1EhaSAZgB1bgXz4viLYonRqAZvQMi4YSW7JKbwx/+yuvMyq1yl
 UBKEO7+bo+dE60V6Q9OFDOaHcZn3B2fg2hdY+c2oYnRLsDvECHBMsZumZ0vmEKDZ
 4Mh46q+RN4AtX4Cseq3iCk5VyZ3o56wRODM0/tjraJWnZs6r/B4V8Z0TmkrDX6Qa
 eRVqzNyCRkAPRR4iSqSFNkKx8tUA3M6OW1mnDXQp+KKmUdSVpFcibZRGETYgiA4E
 MwTKrOiEpMpC3wbFNR92AUrq4ErJQ==
X-ME-Sender: <xms:gm7IW8xoJwyZkUBCoCcfOPyMFmHkRTZwjgLvqi08pXnKyrgaFNWzRA>
X-ME-Proxy: <xmx:gm7IW3FfDhBZj5XeYTdFXEOcJelxLwPlIE205qRtfctvX2XClzWDww>
 <xmx:gm7IW0gfU-7pMDLuq8Aq1BApbb0O831gV1EFFPrBptkCBV3xe_RdKg>
 <xmx:gm7IW69KuZWhkofvKQCeA26ULd67tCl_hX5pa4NzSVcGnVzqe0OB7w>
 <xmx:gm7IWzqEGL6Hhzswh-mE2j7s3cAelwStMgGwLrn0Ft0tJYn_ccvKzA>
 <xmx:gm7IWx9UTMZDNlJnI6POlDLxO9iIn1p58m5awWbh0vaBZaQbhuIqXQ>
 <xmx:g27IW3D2AvWmln6DRd_0hGj40Lzam_HpCsE8wwDSNoGReQPypMCiog>
Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id B83DCE4412;
 Thu, 18 Oct 2018 07:29:05 -0400 (EDT)
From: Thomas Monjalon <thomas@monjalon.net>
To: "Iremonger, Bernard" <bernard.iremonger@intel.com>
Cc: dev@dpdk.org, "Yigit, Ferruh" <ferruh.yigit@intel.com>,
 "arybchenko@solarflare.com" <arybchenko@solarflare.com>,
 "ophirmu@mellanox.com" <ophirmu@mellanox.com>,
 "rahul.lakkireddy@chelsio.com" <rahul.lakkireddy@chelsio.com>,
 Wisam Jaddo <wisamm@mellanox.com>
Date: Thu, 18 Oct 2018 13:29:10 +0200
Message-ID: <4896325.UA0OBGhyO2@xps>
In-Reply-To: <8CEF83825BEC744B83065625E567D7C260D12CD2@IRSMSX107.ger.corp.intel.com>
References: <20180907233929.21950-1-thomas@monjalon.net>
 <20181018012402.1240-2-thomas@monjalon.net>
 <8CEF83825BEC744B83065625E567D7C260D12CD2@IRSMSX107.ger.corp.intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Subject: Re: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after
	removing several at once
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 18 Oct 2018 11:29:07 -0000

18/10/2018 12:40, Iremonger, Bernard:
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> > 
> > From: Wisam Jaddo <wisamm@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@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--;