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 D181BA04C0; Mon, 28 Sep 2020 01:49:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 528241D680; Mon, 28 Sep 2020 01:44:16 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 9E0D11D5FC for ; Mon, 28 Sep 2020 01:44:07 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 510435C00DA; Sun, 27 Sep 2020 19:44:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 27 Sep 2020 19:44:07 -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=xLcmA6IrBJ4aA gPlUHO6QjcvHNKCHGJUj8cV+TEmr7k=; b=buzky9vSwp1DtMrVUGILyGEFXyOvY vRFzQhf4qGqSpGzid091HXoGRYnQlGDfHhQcS4q5WFZsa7m13dnbrNarKYFu1O9S ybYXUmma46iP60nEO0653P13hqlaVffg/zVQ/2P6w9RsN8eubiPB1wbyiKsjrFUH o4oP81cmJDGPfTViCYCEopzA8ac7+/TX1lMDn4LZgnrpiBzCfzBK1v2B4/CcblZ0 EJKuS9K12/xBodxtZ05FBpQ43GWcLchEeRWjg9B0rwBUP6HEeWfleO1NTDvA5sh0 jrR21R9JtGtZE8fgQc6tkdi0E2nfimhb4Dah+G8+jJXjZfHhDFixyiNZw== 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=xLcmA6IrBJ4aAgPlUHO6QjcvHNKCHGJUj8cV+TEmr7k=; b=Dc2RvIWG fbc3e0zoHaU+68+u4YT6Tc7v7dfSHH8HkXBFHh/3J4I/6sc/JLIhNHxjtuNoZSiY tYSgcOqBvhjyaB4oGbqJxFhGvS1W6WLHlSzwkPAUHmgdHta8p8tCtvgT+dY86Pcp LlgZMlGNL82VhOAglEBY+J8wINb7IBTHd5RQxyBNCtc5qHeouKvc7ZZ8oNrNZ+Ok btL9F5/JGdLnWaiRxZ+T/DuiSdR9VSSY5Pw3yBENK5pq4nrlAaYT67rvwxb8VUlw ntRToN32rRsb5MPU/6qEmmbG6031pzbkeCUim8UPO5RGNFZI4RKDUxqgb6nMuP7F h1rxsbHznjMgyg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdehgddvhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepvddunecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght 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 653FC328005A; Sun, 27 Sep 2020 19:44:06 -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, 28 Sep 2020 01:42:45 +0200 Message-Id: <20200927234249.3198780-22-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927234249.3198780-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> <20200927234249.3198780-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 21/25] 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 | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe6450cc0d..1e10d2e2e4 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2695,23 +2695,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"); } @@ -2842,12 +2831,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); } } @@ -2903,11 +2887,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); } } @@ -3052,12 +3033,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) { @@ -3115,6 +3090,10 @@ 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: + ports[port_id].port_status = RTE_PORT_CLOSED; + printf("Port %u is closed\n", port_id); + break; default: break; } -- 2.28.0