From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 3642F1B104 for ; Thu, 18 Oct 2018 03:45:25 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C7B18221D7; Wed, 17 Oct 2018 21:45:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 17 Oct 2018 21:45:24 -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=CedmJG0Is5j0ArDydVCMXpGhYPxwwwaNZoO+t1aFrGg=; b=qrnsFiT2C2V2 SJusF6yRH5pDIpQRh0AQzIqYXWkIrjC3vH+fSngQtmE/7Aki0K5eq7ZBTVE7xHNe R/u48tyFOwwjqSBgEI3wbbQit5DqTcUbRceJ8hvw0T6pzDbA7yu87SZSUtMvEGDH GSk7yPeH8OagVg4yB+Fp6LB0M0YWzfI= 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=CedmJG0Is5j0ArDydVCMXpGhYPxwwwaNZoO+t1aFr Gg=; b=BLoE8yHZY4alX9gRJpMxFF+XPzhnEHsuAe4LTv9AKolbxqILcO3aMvh8q Z+oMkkkpWhVeuqM1wL1KeZp0xYAmusdZl7gu9fds4DpxXsa1pmRSO6X2PCytEObV nPKn0uDVZYNMVB3IFqGd6sNQiOHgU6GFZwc7k/J1S4C5pdfswMV98izbcGCel5yg 4+a8nKldDi7rf6qfRd9+7OZ6YLkssZaBwY1+Yn3vdKYe+uM9HtCYAydUNnJXQvfQ o7RhLK7EpWj9niybrqDEj+aH0pxbRsLX2nQfquLIXoqn7Mi8AlfPmcYSIslXICM1 kpGr6HNewVrCPjNN+m/NP4Ur30WJw== X-ME-Sender: X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 12BDA102D7; Wed, 17 Oct 2018 21:45:22 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, wisamm@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com, bernard.iremonger@intel.com Date: Thu, 18 Oct 2018 03:45:26 +0200 Message-ID: <1667170.UpD0Izeecg@xps> In-Reply-To: <20181018013522.11253-8-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> <20181018013522.11253-1-thomas@monjalon.net> <20181018013522.11253-8-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v5 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: Thu, 18 Oct 2018 01:45:25 -0000 +Cc Bernard 18/10/2018 03:35, Thomas Monjalon: > The command "port detach" is removing the EAL rte_device > of the ethdev port specified as parameter. > > After detaching, the pointer, which maps a port to its device, > is resetted. This way, it is possible to check whether a port > is still associated to a (not removed) device. > > Signed-off-by: Thomas Monjalon > --- > app/test-pmd/testpmd.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index f241ce363..3093d3306 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -2340,8 +2340,17 @@ setup_attached_port(portid_t pi) > void > detach_port(portid_t port_id) > { > + struct rte_device *dev; > + portid_t sibling; > + > printf("Detaching a port...\n"); > > + dev = rte_eth_devices[port_id].device; > + if (dev == NULL) { > + printf("Device already removed\n"); > + return; > + } > + > if (ports[port_id].port_status != RTE_PORT_CLOSED) { > if (ports[port_id].port_status != RTE_PORT_STOPPED) { > printf("Port not stopped\n"); > @@ -2352,10 +2361,14 @@ detach_port(portid_t port_id) > port_flow_flush(port_id); > } > > - if (rte_dev_remove(rte_eth_devices[port_id].device) != 0) { > + if (rte_dev_remove(dev) != 0) { > TESTPMD_LOG(ERR, "Failed to detach port %u\n", port_id); > return; > } > + /* reset mapping between old ports and removed device */ > + for (sibling = 0; sibling < RTE_MAX_ETHPORTS; sibling++) > + if (rte_eth_devices[sibling].device == dev) > + rte_eth_devices[sibling].device = NULL; > > remove_unused_fwd_ports();