From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once Date: Thu, 18 Oct 2018 13:29:10 +0200 Message-ID: <4896325.UA0OBGhyO2@xps> References: <20180907233929.21950-1-thomas@monjalon.net> <20181018012402.1240-2-thomas@monjalon.net> <8CEF83825BEC744B83065625E567D7C260D12CD2@IRSMSX107.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, "Yigit, Ferruh" , "arybchenko@solarflare.com" , "ophirmu@mellanox.com" , "rahul.lakkireddy@chelsio.com" , Wisam Jaddo To: "Iremonger, Bernard" Return-path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 74E795B36 for ; Thu, 18 Oct 2018 13:29:07 +0200 (CEST) In-Reply-To: <8CEF83825BEC744B83065625E567D7C260D12CD2@IRSMSX107.ger.corp.intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 18/10/2018 12:40, Iremonger, Bernard: > From: Thomas Monjalon [mailto:thomas@monjalon.net] > > > > From: Wisam Jaddo > > > > 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 > > --- > > 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--;