From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id D5D992C24 for ; Tue, 12 Mar 2019 10:31:37 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2019 02:31:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,470,1544515200"; d="scan'208";a="326513920" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga006.fm.intel.com with ESMTP; 12 Mar 2019 02:31:35 -0700 Received: from irsmsx110.ger.corp.intel.com ([169.254.15.102]) by IRSMSX101.ger.corp.intel.com ([169.254.1.230]) with mapi id 14.03.0415.000; Tue, 12 Mar 2019 09:31:34 +0000 From: "Pattan, Reshma" To: Yongseok Koh CC: "stable@dpdk.org" , "Zhang, Pan1" Thread-Topic: [dpdk-stable] [ PATCH 17.11 1/2] ethdev: clear ethdev data upon detach Thread-Index: AQHU0sR/0nSgoFipYk2NBUyLxSui1aYHwnCQ Date: Tue, 12 Mar 2019 09:31:33 +0000 Message-ID: <3AEA2BF9852C6F48A459DA490692831F2A429CBA@irsmsx110.ger.corp.intel.com> References: <20190301115323.32420-1-reshma.pattan@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmI1NTE0MzktZGExYS00NGNkLTgzOTAtYjM2YmQ1NTQ3OTgzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSlF5bHExZTh3a2NlUXRsTnl2NDJlUkJVMUY0aWZjcHZSTDRaSTBNeFRhcnE5NkZJdzB6cFQwa1JlNnAzWk5wbSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [ PATCH 17.11 1/2] ethdev: clear ethdev data upon detach X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 09:31:38 -0000 Hi, > -----Original Message----- > From: Yongseok Koh [mailto:yskoh@mellanox.com] > Sent: Monday, March 4, 2019 7:57 PM > To: Pattan, Reshma > Cc: stable@dpdk.org > Subject: Re: [dpdk-stable] [ PATCH 17.11 1/2] ethdev: clear ethdev data u= pon > detach >=20 >=20 > > On Mar 1, 2019, at 3:53 AM, Reshma Pattan > wrote: > > > > When port is detached its relevant rte_eth_dev_data[port_id] has to be > > zeroed, otherwise the next port creations could get wrong port_id. > > > > Fixes: 92d94d3744 ("ethdev: attach or detach port") > > Signed-off-by: Reshma Pattan > > --- > > lib/librte_ether/rte_ethdev.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/lib/librte_ether/rte_ethdev.c > > b/lib/librte_ether/rte_ethdev.c index 096b35faf..7ba9bc564 100644 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -443,6 +443,7 @@ rte_eth_dev_detach(uint16_t port_id, char *name) > > goto err; > > > > rte_eth_devices[port_id].state =3D RTE_ETH_DEV_UNUSED; > > + memset(&rte_eth_dev_data[port_id], 0, sizeof(struct > > +rte_eth_dev_data)); >=20 > Hi, >=20 > I believe such code is good to have. Before I merge it, I have a question= . > I wonder what the problem of the current code is. > If the state turns into RTE_ETH_DEV_UNUSED, then will the eth_dev be re- > initialized next time anyway? >=20 >=20 Yes to reuse the UNUSED port next time , its relevant rte_eth_dev_data[] al= so has to be 0 (which is missing in current code), because attach operation= not only checks for UNUSED but also for its relevant data to be 0. If state UNUSED, but data still not 0, the attach operation will assume por= t is under use, so it will assign the next new available port id which is = wrong. So we are now fixing this by zeroing dev data upon detach operation. Thanks, Reshma