From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <matan@mellanox.com>
Received: from EUR03-DB5-obe.outbound.protection.outlook.com
 (mail-eopbgr40062.outbound.protection.outlook.com [40.107.4.62])
 by dpdk.org (Postfix) with ESMTP id 54B3337A0;
 Mon,  4 Sep 2017 11:25:05 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com;
 s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;
 bh=dJOXe2v5pmAr2KIHptSjqW3jkivtrfZpCgDtjFxaEKo=;
 b=m41eO8ndUlEv0jlBsFFeGQ1r6CZ6elI5m0ahL9/ecPTXENzFg1WUV2RMn9dDdhneOoHu7hR7q9wgBeE+n3dD/CbutJ2tJPD7STxbfQ3vIsfDVP4D7LALq2iXNXlwn1jYIe6UITWfWmeyTH0QFdhlTRo/s0zB2NmN+kIO1ailrJQ=
Received: from DB6PR0502MB3048.eurprd05.prod.outlook.com (10.172.250.136) by
 DB6PR0502MB2983.eurprd05.prod.outlook.com (10.172.246.145) with Microsoft
 SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Mon, 4 Sep
 2017 09:25:04 +0000
Received: from DB6PR0502MB3048.eurprd05.prod.outlook.com
 ([fe80::e938:efe9:effc:7ef8]) by DB6PR0502MB3048.eurprd05.prod.outlook.com
 ([fe80::e938:efe9:effc:7ef8%14]) with mapi id 15.20.0013.018; Mon, 4 Sep 2017
 09:25:04 +0000
From: Matan Azrad <matan@mellanox.com>
To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= <gaetan.rivet@6wind.com>
CC: Jingjing Wu <jingjing.wu@intel.com>, Thomas Monjalon
 <thomas@monjalon.net>, "dev@dpdk.org" <dev@dpdk.org>, Ori Kam
 <orika@mellanox.com>, "stable@dpdk.org" <stable@dpdk.org>
Thread-Topic: [PATCH] app/testpmd: fix forward port ids setting
Thread-Index: AQHTJVo2lKO7rAT05UWFWNtTAIOC7qKkcdPg
Date: Mon, 4 Sep 2017 09:25:04 +0000
Message-ID: <DB6PR0502MB3048708C2F230CA041D7BC36D2910@DB6PR0502MB3048.eurprd05.prod.outlook.com>
References: <1504444747-56298-1-git-send-email-matan@mellanox.com>
 <20170904084538.GB21444@bidouze.vm.6wind.com>
In-Reply-To: <20170904084538.GB21444@bidouze.vm.6wind.com>
Accept-Language: en-US, he-IL
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: spf=none (sender IP is )
 smtp.mailfrom=matan@mellanox.com; 
x-originating-ip: [193.47.165.251]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; DB6PR0502MB2983;
 6:4g2a02SyMt/sh8tV33FXsxsegMUZDxBAZKo8AB+jPsHb7LWzYY7mLfSsl+r1Pmi7/UGsTpKjVAUVm6B2uh7LeFnylTZ7ZlUHSMRUvh6x9IChTe4qfNtVelyc+DuN7pyICm0zaj0hGAyfbG7eh8jOqhMvUZuvXVdNRvJ1Mhv+hNDdNqinT04931om8Ry4OFg65v6fXIpoZQKJmhW8cdfx7U6EOlvtQ/CAt60sHViuSNvn/aACjC5iFF5n60R3hw2LjNyYfZqGw+8aX5MGfUuhzBIZzvjrv72O+OnMpZO9AcIEnErRbLgo3puYhnXGz1TiFElXF2ZVjLjbo/2eH1rmiQ==;
 5:C9AiD6tF4+p0xTNhM5WU07+if7aPYWWYlnOmBsW7oHMqXlrx2VnAvy4Vx0FE7+pWnDNDk4YIM0ZkUP43fb++Relm/lOwRJFGF1LPbzZIJ2dAmcvVoeIlzfjDNAFjfuZ726emO4VVNgXXPQGSBcib4g==;
 24:vhwYbnEK/AjSJWGpl/y/fCRgidZdLatOkX7i/mOlacfQxDVef3uC4qpmrXR00HzIJ3MExaSJJNCVO7CtylS3OT+9ZbSkEqqmvj/pUNdqAYw=;
 7:V87OpvaAmbGLkWOiFgNInQ7js1B8JZkaWf7/FHmzAob3VkZoyKMysAPmjfES46mGMupbhwL9VUJRxl5yfs8cyWpsEKWMTJzbm3Zz5BEM0wckvp2u+Vpj9cMcMgA7coThYS9EEdI0CtaTLDt2EzIkPntfPdsm+fpTAG1lk2xhiuryYrElqBxZiAzhR7Jbzf7i1QrKOzMOrQRV9itQRN2a6NTLMCOldjsoStEQqg8w2vA=
x-ms-exchange-antispam-srfa-diagnostics: SSOS;
x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr
x-ms-office365-filtering-correlation-id: 5e72083e-2e6a-4507-ba42-08d4f376d358
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0;
 RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);
 SRVR:DB6PR0502MB2983; 
x-ms-traffictypediagnostic: DB6PR0502MB2983:
x-exchange-antispam-report-test: UriScan:(228905959029699);
x-microsoft-antispam-prvs: <DB6PR0502MB298360E1D56A0146E7EB632CD2910@DB6PR0502MB2983.eurprd05.prod.outlook.com>
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0;
 RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);
 SRVR:DB6PR0502MB2983; BCL:0; PCL:0;
 RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);
 SRVR:DB6PR0502MB2983; 
x-forefront-prvs: 0420213CCD
x-forefront-antispam-report: SFV:NSPM;
 SFS:(10009020)(6009001)(39860400002)(51444003)(377454003)(24454002)(189002)(53754006)(76104003)(13464003)(199003)(53936002)(6506006)(66066001)(6246003)(86362001)(25786009)(74316002)(3660700001)(9686003)(14454004)(101416001)(106356001)(105586002)(68736007)(6436002)(55016002)(2906002)(54906002)(99286003)(6916009)(2950100002)(3280700002)(189998001)(33656002)(54356999)(6116002)(4326008)(102836003)(53546010)(50986999)(76176999)(3846002)(229853002)(7696004)(81156014)(81166006)(97736004)(8936002)(7736002)(305945005)(5660300001)(8676002)(478600001)(5890100001)(5250100002)(110136004)(2900100001);
 DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0502MB2983;
 H:DB6PR0502MB3048.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords;
 MX:1; A:1; LANG:en; 
received-spf: None (protection.outlook.com: mellanox.com does not designate
 permitted sender hosts)
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: Mellanox.com
X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Sep 2017 09:25:04.1705 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0502MB2983
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: fix forward port ids setting
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Sep 2017 09:25:06 -0000

Hi

> -----Original Message-----
> From: Ga=EBtan Rivet [mailto:gaetan.rivet@6wind.com]
> Sent: Monday, September 4, 2017 11:46 AM
> To: Matan Azrad <matan@mellanox.com>
> Cc: Jingjing Wu <jingjing.wu@intel.com>; Thomas Monjalon
> <thomas@monjalon.net>; dev@dpdk.org; Ori Kam <orika@mellanox.com>;
> stable@dpdk.org
> Subject: Re: [PATCH] app/testpmd: fix forward port ids setting
>=20
> Hi Matan,
>=20
> On Sun, Sep 03, 2017 at 04:19:07PM +0300, Matan Azrad wrote:
> > The corrupted code didn't check the port availability when it was
> > trying to set the forward port IDs array.
> > However, when it was counting the number of ports, the availability
> > was checked by RTE_ETH_FOREACH_DEV iterator.
> >
> > Hence, even when ETH devices ports were not in ATTACHED state, the
> > testpmd tried to forward traffic by them and got segmentation fault at
> > queue access time.
> >
> > For example:
> > When EAL command line parameters include two devices, the first is
> > failsafe with two sub devices and the second is any device, testpmd
> > gets two devices by the iterator and sets for forwarding both, the
> > failsafe device and the failsafe first sub device (instead of the
> > second sub device).
> > After the first failsafe sub device state was changed to DEFERRED,
> > testpmd tries to forward traffic through the deferred device because
> > it didn't check the port availability in setting time.
> >
> > The fix uses the RTE_ETH_FOREACH_DEV iterator for the forward port IDs
> > default setting.
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Matan Azrad <matan@mellanox.com>
> > ---
> >  app/test-pmd/testpmd.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > Hi All
> > I would like to bring up a discussion to complete this bug fix.
> >
> > When user wants to set the list of forwarding ports by "set portlist"
> > (testpmd command line), the testpmd application checks the
> > availability of the ports by rte_eth_dev_is_valid_port API.
> > By this way, it gets the DEFERRED port as valid port and will try to
> > recieve\send packets via this port.
> >
> > This scenario will cause the same error as this patch fixes.
> >
> > Should testpmd allow user to run traffic by DEFERRED port directly?
> >
> > If any application wants to check a port availability for device usage
> > (conf\rxtx), Which API should be used?
> >
> > According to the patch cb894d99eceb ("ethdev: add deferred
> > intermediate device state"), DEFERRED ports should be invisible to
> > application, So maybe the rte_eth_dev_is_valid_port API should be
> > internal and a new ethdev API should be created for applications.
> >
> > What do you think?
> >
>=20
> I think that regardless of the semantic of the DEFERRED state or any othe=
r
> port handling, the correct assumption is to consider any port iterated ov=
er by
> RTE_ETH_FOREACH_DEV to be the exact set of devices that are supposed to
> be usable. In the event of an API evolution regarding port states, this m=
acro
> should remain correct.
>=20
> So I think your fix is correct, and that the implication of
> RTE_ETH_FOREACH_DEV avoiding DEFERRED devices is correct.
>=20

This patch fixes the default forward ports setting (actually when user don'=
t use --portmask param or "set portlist"),
But it don't fix the port validation which PMD does for "set portlist" comm=
and.
So, the discussion is how to fix this port validation.
In current code, testpmd uses  rte_eth_dev_is_valid_port which return the D=
EFERRED device too for forwarding.
Should it use the RTE_ETH_FOREACH_DEV  iterator for one port validation?=20
Don't you think we need new API for one port?

> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> > 7d40139..f9bdbf8 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -463,9 +463,10 @@ static void
> >  set_default_fwd_ports_config(void)
> >  {
> >  	portid_t pt_id;
> > +	int i =3D 0;
> >
> > -	for (pt_id =3D 0; pt_id < nb_ports; pt_id++)
> > -		fwd_ports_ids[pt_id] =3D pt_id;
> > +	RTE_ETH_FOREACH_DEV(pt_id)
> > +		fwd_ports_ids[i++] =3D pt_id;
> >
> >  	nb_cfg_ports =3D nb_ports;
> >  	nb_fwd_ports =3D nb_ports;
> > --
> > 2.7.4
> >
>=20
> --
> Ga=EBtan Rivet
> 6WIND