From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 557381B468 for ; Tue, 23 Oct 2018 12:01:26 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2018 03:01:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,415,1534834800"; d="scan'208";a="101864663" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga001.jf.intel.com with ESMTP; 23 Oct 2018 03:01:23 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 Oct 2018 11:01:22 +0100 Received: from irsmsx107.ger.corp.intel.com ([169.254.10.56]) by irsmsx155.ger.corp.intel.com ([169.254.14.27]) with mapi id 14.03.0319.002; Tue, 23 Oct 2018 11:01:22 +0100 From: "Iremonger, Bernard" To: 'Thomas Monjalon' , "dev@dpdk.org" CC: "gaetan.rivet@6wind.com" , "ophirmu@mellanox.com" , "wisamm@mellanox.com" , "Yigit, Ferruh" , "arybchenko@solarflare.com" Thread-Topic: [PATCH v7 7/7] app/testpmd: check not detaching device twice Thread-Index: AQHUaqqGgoRGowT2F06TFSecGoYGl6Uskf7Q Date: Tue, 23 Oct 2018 10:01:21 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C260D15558@IRSMSX107.ger.corp.intel.com> References: <20181007222554.4886-1-thomas@monjalon.net> <20181023082842.7963-1-thomas@monjalon.net> <20181023082842.7963-8-thomas@monjalon.net> In-Reply-To: <20181023082842.7963-8-thomas@monjalon.net> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjViMjFjYTUtMTk0ZS00M2RlLWJmMGQtNGU4MWY4MTNhMjg5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieHZWSU9ZK204NGhkT2pWRFNXMmw5dVAzUnZSUEdrT3d6Y3U3ajh3TnlwOWltYXhFUTdlQkZzWVhudVFjXC96VkoifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v7 7/7] app/testpmd: check not detaching device twice X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2018 10:01:27 -0000 Hi Thomas, > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Tuesday, October 23, 2018 9:29 AM > To: dev@dpdk.org > Cc: gaetan.rivet@6wind.com; ophirmu@mellanox.com; > wisamm@mellanox.com; Yigit, Ferruh ; > arybchenko@solarflare.com; Iremonger, Bernard > > Subject: [PATCH v7 7/7] app/testpmd: check not detaching device twice >=20 > The command "port detach" is removing the EAL rte_device of the ethdev > port specified as parameter. >=20 > After detaching, the pointer, which maps a port to its device, is resette= d. This Typo: "resetted" should be "reset" > way, it is possible to check whether a port is still associated to a (not > removed) device. >=20 > Signed-off-by: Thomas Monjalon > --- > app/test-pmd/testpmd.c | 24 +++++++++++++++++++++--- > 1 file changed, 21 insertions(+), 3 deletions(-) >=20 > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > 14647fa19..d5998fddc 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -2353,8 +2353,17 @@ setup_attached_port(portid_t pi) void > detach_port(portid_t port_id) { > + struct rte_device *dev; > + portid_t sibling; > + > printf("Removing a device...\n"); The functionality of the detach_port() function has changed now to removing= a device, should the function name be changed to reflect the new functiona= lity. How about detach_device() instead of detach detach_port(). >=20 > + dev =3D rte_eth_devices[port_id].device; > + if (dev =3D=3D NULL) { > + printf("Device already removed\n"); > + return; > + } > + > if (ports[port_id].port_status !=3D RTE_PORT_CLOSED) { > if (ports[port_id].port_status !=3D RTE_PORT_STOPPED) { > printf("Port not stopped\n"); > @@ -2365,15 +2374,24 @@ detach_port(portid_t port_id) > port_flow_flush(port_id); > } >=20 > - if (rte_dev_remove(rte_eth_devices[port_id].device) !=3D 0) { > + if (rte_dev_remove(dev) !=3D 0) { > TESTPMD_LOG(ERR, "Failed to detach port %u\n", port_id); Should the log message be ( ERR "Failed to detach device %s\n", dev->name) = ? > return; > } >=20 > + /* reset mapping between old ports and removed device */ > + for (sibling =3D 0; sibling < RTE_MAX_ETHPORTS; sibling++) > + if (rte_eth_devices[sibling].device =3D=3D dev) { > + rte_eth_devices[sibling].device =3D NULL; > + if (ports[sibling].port_status !=3D RTE_PORT_CLOSED) { > + ports[sibling].port_status =3D > RTE_PORT_CLOSED; > + printf("Port %u is closed\n", sibling); > + } > + } > + > remove_unused_fwd_ports(); >=20 > - printf("Port %u is detached. Now total ports is %d\n", > - port_id, nb_ports); How about printf("Device %s is detached, Now total ports is %d\n" dev->name, nb_ports); =20 > + printf("Now total ports is %d\n", nb_ports); > printf("Done\n"); > return; > } > -- > 2.19.0 Regards, Bernard.