From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3B6A8A04C9; Mon, 14 Sep 2020 00:09:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E1D3D1C197; Mon, 14 Sep 2020 00:09:06 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 290BD1C196 for ; Mon, 14 Sep 2020 00:09:06 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 013474A2; Sun, 13 Sep 2020 18:09:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 13 Sep 2020 18:09:05 -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; s=fm2; bh=JxB0p6C6Zh3VU +hMaROOwX7RQTee26NX/EVd/Yiof+c=; b=QiyvkcQccvwUl39FdPLRo+NeKLNNP DDdkGpNf3wt/OaMoc3L0TcWficchdeSXVO721nU7mZp/l+facXyvv5KBdVpaE4NP KeA/0u7HeU272ZE+9T1dMZZgOE6gpjIZvWYplF66hCkbrZN8gINGykhdjZUTZ7mq w20vC0aBXdozMhUltEMAYKWt8dYUDMyb+1+QCXpoecABzQWlgrSEPFYr1xGYhqKs 4wb/E7UZiXmt+JTYgK4xddYwhIRJvqRznWIQz7uW3VrVFpIym4xW1s/sKwSGYJ1W sgoUoRhRn2uO4r7Oe0X94DeEqhmykc/h3H9F99l62Xj/heagqjRn1n9kQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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= fm3; bh=JxB0p6C6Zh3VU+hMaROOwX7RQTee26NX/EVd/Yiof+c=; b=eFeOL/J8 x98jAbrYFs/mrfaDtPq8xNPC1VCivdgaCD6hL4OXkm6zOJrB6yNU06sviFJSGvsH TCH9OeRY43UikjfY1IPJJ4fSb268AEo8W0+HBkACz4Z1jHOVJCTAJbD0mp2GSa34 br6C/UjMIyUUdrzpBVlpAbmuYVTPIaUq7nXOcbwilMnAcSgCXDu+koZr1aCAmCQD 2oBdc0nov1hL2eBawUYUGmi+OnQ222ilFUSoaPkSBPwQZ/QUqfyHeaTjLvjHea/a 33jcSdx+gNLmDljI9aPYAubWRKnpzK4QUTh1MUixsXAqw8HA0VlFMqy6L5vcjmyd 4tyGAZ7oA9pfiA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeihedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedujeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr lhhonhdrnhgvth X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A8741306467D; Sun, 13 Sep 2020 18:09:03 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Wenzhuo Lu , Beilei Xing , Bernard Iremonger Date: Mon, 14 Sep 2020 00:07:10 +0200 Message-Id: <20200913220711.3768597-20-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200913220711.3768597-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 19/20] app/testpmd: reset port status on close notification 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Since rte_eth_dev_release_port() is called on all port close operations, the event RTE_ETH_EVENT_DESTROY can be reliably used for resetting the port status on the application side. The intermediate state RTE_PORT_HANDLING is removed in close_port() because a port can also be closed by a PMD in a device remove operation. In case multiple ports are closed, calling remove_invalid_ports() only once is enough. Signed-off-by: Thomas Monjalon --- app/test-pmd/testpmd.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 7842c3b781..31dc97239b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2694,23 +2694,12 @@ close_port(portid_t pid) continue; } - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_STOPPED, RTE_PORT_HANDLING) == 0) { - printf("Port %d is now not stopped\n", pi); - continue; - } - if (port->flow_list) port_flow_flush(pi); rte_eth_dev_close(pi); - - remove_invalid_ports(); - - if (rte_atomic16_cmpset(&(port->port_status), - RTE_PORT_HANDLING, RTE_PORT_CLOSED) == 0) - printf("Port %d cannot be set to closed\n", pi); } + remove_invalid_ports(); printf("Done\n"); } @@ -2841,12 +2830,7 @@ detach_device(struct rte_device *dev) return; } RTE_ETH_FOREACH_DEV_OF(sibling, dev) { - /* reset mapping between old ports and removed device */ - rte_eth_devices[sibling].device = NULL; if (ports[sibling].port_status != RTE_PORT_CLOSED) { - /* sibling ports are forced to be closed */ - ports[sibling].port_status = RTE_PORT_CLOSED; - printf("Port %u is closed\n", sibling); } } @@ -2902,11 +2886,8 @@ detach_devargs(char *identifier) return; } - /* sibling ports are forced to be closed */ if (ports[port_id].flow_list) port_flow_flush(port_id); - ports[port_id].port_status = RTE_PORT_CLOSED; - printf("Port %u is now closed\n", port_id); } } @@ -3055,12 +3036,6 @@ check_all_ports_link_status(uint32_t port_mask) } } -/* - * This callback is for remove a port for a device. It has limitation because - * it is not for multiple port removal for a device. - * TODO: the device detach invoke will plan to be removed from user side to - * eal. And convert all PMDs to free port resources on ether device closing. - */ static void rmv_port_callback(void *arg) { @@ -3118,6 +3093,13 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, rmv_port_callback, (void *)(intptr_t)port_id)) fprintf(stderr, "Could not set up deferred device removal\n"); break; + case RTE_ETH_EVENT_DESTROY: + if (rte_atomic16_cmpset(&(ports[port_id].port_status), + RTE_PORT_STOPPED, + RTE_PORT_CLOSED) == 0) + printf("Port %d cannot be set to closed\n", port_id); + printf("Port %u is closed\n", port_id); + break; default: break; } -- 2.28.0