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 DCE7CA04C0; Mon, 28 Sep 2020 01:50:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DF07A1D655; Mon, 28 Sep 2020 01:44:52 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 890201D663 for ; Mon, 28 Sep 2020 01:44:09 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 3C7035C00DA; Sun, 27 Sep 2020 19:44:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 27 Sep 2020 19:44:09 -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=+NBaySl1Hz2Dl /LZP6u1xOsTfZ7iPEZ0SiC6804pC+M=; b=nIFDMXK52GVAFUaBS5xeVyS3Aks5n hoGiwCBcKprpHa5sf3KDLRdkL83mAKb/POC6+2ewQY/Zz1jdJsK6CQoXNdSd45ga E+NHSOyZzYwjyRI8tXSqjoyVCs5mrnMlNj1E1UJLZ53FsPUKBW5BDh9mAlqEc8zA IiPd7ijs4h/Jhq2lewNv64EabkaBAIK6ta1PDtEqXhCWgwIom1SU223tAFm9OuWR vbHsOsmHCdKMzvRN0KFAT0KXaSYahfe04MsFhKsHc1z4zptqVGH2eR4h/sWbNN1j luamupR6Ql9gGytNPDCLOcCNqOGbQXIukl+MoMz6gVfChT0MrpY5vES8Q== 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=+NBaySl1Hz2Dl/LZP6u1xOsTfZ7iPEZ0SiC6804pC+M=; b=iEoNk4S8 vRvuTqoBkiHfygNmR3FgKO1tiiMtO+khAJcvUdlA+zEwRiWe/3LYP2gWrDCCVS18 p+G+J+/knC+6LFp1RBDcFTj/rsRqM/w99tWeWOGOyDcde21dSChAbkhbkQMoKeUs nJ1K9kmPfB01bsOVXEusF3r81KxNSgcpLNSHvWpVY+OeLHhBJsH5rUUb87upruy7 E3IdFvRw6lyBTwnE1gUwQ0cj+tPJcEUNNUsBNojb06eUvrlL96RF9zCa6oxcvGM+ 0KeczJQ59yOghb2MokizLffDFS0T0U769CoxV8H+qbcXFky/txHSv516KwQlLoby oDHFuo+Kj4EL5w== 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 337DF328005E; Sun, 27 Sep 2020 19:44:08 -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:46 +0200 Message-Id: <20200927234249.3198780-23-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 22/25] app/testpmd: align behaviour of multi-port detach 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" A port can be closed in multiple situations: - close command calling close_port() -> rte_eth_dev_close() - exit calling close_port() -> rte_eth_dev_close() - hotplug calling close_port() -> rte_eth_dev_close() - hotplug calling detach_device() -> rte_dev_remove() - port detach command, detach_device() -> rte_dev_remove() - device detach command, detach_devargs() -> rte_eal_hotplug_remove() The flow rules are flushed before each close. It was already done in close_port(), detach_devargs() and detach_port_device() which calls detach_device(), but not in detach_device(). As a consequence, it was missing for siblings of port detach command and unplugged device. The check before calling port_flow_flush() is moved inside the function. The state of the port to close is checked to be stopped. As above, this check was missing in detach_device(), impacting the cases of a multi-port device unplugged or detached with the port detach command. Signed-off-by: Thomas Monjalon --- app/test-pmd/config.c | 7 +++++-- app/test-pmd/testpmd.c | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 2d9a456467..4691ae1f7b 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1590,9 +1590,12 @@ int port_flow_flush(portid_t port_id) { struct rte_flow_error error; - struct rte_port *port; + struct rte_port *port = &ports[port_id]; int ret = 0; + if (port->flow_list == NULL) + return ret; + /* Poisoning to make sure PMDs update it in case of error. */ memset(&error, 0x44, sizeof(error)); if (rte_flow_flush(port_id, &error)) { @@ -1601,7 +1604,7 @@ port_flow_flush(portid_t port_id) port_id == (portid_t)RTE_PORT_ALL) return ret; } - port = &ports[port_id]; + while (port->flow_list) { struct port_flow *pf = port->flow_list->next; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 1e10d2e2e4..ccba71c076 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2695,8 +2695,7 @@ close_port(portid_t pid) continue; } - if (port->flow_list) - port_flow_flush(pi); + port_flow_flush(pi); rte_eth_dev_close(pi); } @@ -2826,15 +2825,20 @@ detach_device(struct rte_device *dev) printf("Removing a device...\n"); - if (rte_dev_remove(dev) < 0) { - TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->name); - return; - } RTE_ETH_FOREACH_DEV_OF(sibling, dev) { if (ports[sibling].port_status != RTE_PORT_CLOSED) { + if (ports[sibling].port_status != RTE_PORT_STOPPED) { + printf("Port %u not stopped\n", sibling); + return; + } + port_flow_flush(sibling); } } + if (rte_dev_remove(dev) < 0) { + TESTPMD_LOG(ERR, "Failed to detach device %s\n", dev->name); + return; + } remove_invalid_ports(); printf("Device is detached\n"); @@ -2855,8 +2859,6 @@ detach_port_device(portid_t port_id) return; } printf("Port was not closed\n"); - if (ports[port_id].flow_list) - port_flow_flush(port_id); } detach_device(rte_eth_devices[port_id].device); @@ -2886,9 +2888,7 @@ detach_devargs(char *identifier) rte_eth_iterator_cleanup(&iterator); return; } - - if (ports[port_id].flow_list) - port_flow_flush(port_id); + port_flow_flush(port_id); } } -- 2.28.0