From patchwork Mon Sep 28 23:14:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 79091 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4FDD7A04C0; Tue, 29 Sep 2020 01:22:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 079821DA2A; Tue, 29 Sep 2020 01:16:38 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id B4D651DA00 for ; Tue, 29 Sep 2020 01:15:56 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 5D7B85C01B1; Mon, 28 Sep 2020 19:15:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:55 -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=GWotvqqOeHwgb6Gv9NYmo3qay7epi INMZhm7HSWuwCaSdOPOTOO1csk+2/E5uh+IyuYQ54J5ju4GgLzEkgsgwISzCjpEL fgcKh8IdH+lYyEpnVTyfi4wj0txUzJEvPtWN2/TRkBSE1L+XIy0OYcWgqw/4B0fi HE+R5u4QF7bnQFoILHV8qPsK2DzsqYM8icoKwDu5Z2+TN4i4G+sZkPyd8qD5W2EE An1//q4p+EddAbNMN4hhF6uJlAZ5sjQun1PuyLlo92JGF+SVZwr0DRbuwAZ6npE5 dMwb+OmTI9aAB6rpV81zuZFiGBZZh+2BU9jxNJaVKq9YwTb9Sk/u6Vyng== 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=FM6u1pMZ tsgtTEO8nmdm9d2FonZETlSau8TkcdMGilmiuqvnOTzIGAcnoXpiDxVP+4u949vL DO/0CTaGEWvCAaw+obCdV1ERTatHqcnj+75qyQXN9i0J51myuAlypr44EqpaYdq2 g0t1zxgVAqHTUno9JTvOuFeY7mUSvN52n1qkRhCVa/ICcTPOeYbJ/9L5YXB39+WD qrhHgrQHsdkWt1lcFjUo2zIGTrm3nP4etG83AzL+EfoawQy5pxt0BmEXOqw5HVzo uqU7pmLjdRABti8iR0zP28z1YL85BxIyWK9dQrWdy7gqjt51mtWlpyTfzK6+ZPJ/ vA5S3IfvsOBPsA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepvdehnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl 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 5455E3064674; Mon, 28 Sep 2020 19:15:54 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Wenzhuo Lu , Beilei Xing , Bernard Iremonger Date: Tue, 29 Sep 2020 01:14:33 +0200 Message-Id: <20200928231437.414489-26-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928231437.414489-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> <20200928231437.414489-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 25/29] 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 Reviewed-by: Ferruh Yigit --- 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; }