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 EC483A04C0; Tue, 29 Sep 2020 01:23:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 63F2D1DA3F; Tue, 29 Sep 2020 01:16:40 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 00DA11DA0A for ; Tue, 29 Sep 2020 01:15:57 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 45AAD5C01A1; Mon, 28 Sep 2020 19:15:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:57 -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=SP6RI4ATAlmBo9fM/m1ovyPSPZE5Z kU6GknDk3dAz5FkcTo1GMoFwIk5CojuP2AA6bFTjJ7fI92eYTw1G8pCEzneY7S78 W++SnCDlAX6QjGmYE+pkpV2fgWYWCrES+aZE+DxK9lbY+w/XElGnufoIzRtEM+1F X4TSRTnxdXcjFK033Mlrdy1Uo6HRHBsZJBVNF6eJkIvi/VrU9Wrn8r0g0zhZZwFy xBqPMx0AloVzp2BUwO5eFj0Ql1MopIhaLzBXasgDweZUNb+We21rbk5C2DcsxXbi kzpRMZKS42cbEIp9p7ztUZkA3KgW/5jfS94Q/ZKmBXVhu643g9hJonSng== 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=u2xqrpuE /EPNMPjBW+TbkqP2xj4yz3PIqfqEllazc7+t8whVUfJnJBGLh4UsmQ3uJXTkFNLU VG8bffGkOoyRF7y3yj58HhJ/wT/R+mHu5oH+mmD76u3DovFxf1hRGEoKz4h3oWpY b3Vr+l9M6NM34c1elEgl6Am94C1c7c6nBKrHuCwMM+Wx14TvL6OEyMmBffbfpdf4 0vdTrpwHfXXhhRaN90n53vIK+uAPk0aFB8pvZz10lGZyjqpWrP1TUGcz6fOgo8Zn yWTF3wAKb+I7xziID10d+zeZAGfQJPWLG9EOtXStTTk30L0oSUkreC609cQFtWkj vW26yaNtI+vyfw== 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 2F6ED3064680; Mon, 28 Sep 2020 19:15:56 -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:34 +0200 Message-Id: <20200928231437.414489-27-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 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 26/29] 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