From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: [PATCH v3 1/4] app/testpmd: allow detaching a port not closed Date: Wed, 17 Oct 2018 03:54:47 +0200 Message-ID: <20181017015450.15783-2-thomas@monjalon.net> References: <20180907233929.21950-1-thomas@monjalon.net> <20181017015450.15783-1-thomas@monjalon.net> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: dev@dpdk.org, ophirmu@mellanox.com To: ferruh.yigit@intel.com, arybchenko@solarflare.com Return-path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 21E185A6A for ; Wed, 17 Oct 2018 03:54:51 +0200 (CEST) In-Reply-To: <20181017015450.15783-1-thomas@monjalon.net> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The testpmd application aim is for testing; so order of operations should not be enforced. There was a test to forbid detaching before closing a port. However, it may interesting to test what happens in such case. It is possible for a PMD to automatically close the port when detaching. Signed-off-by: Thomas Monjalon --- app/test-pmd/testpmd.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 5dbbf783f..f5dee1d71 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1938,18 +1938,6 @@ port_is_started(portid_t port_id) return 1; } -static int -port_is_closed(portid_t port_id) -{ - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return 0; - - if (ports[port_id].port_status != RTE_PORT_CLOSED) - return 0; - - return 1; -} - int start_port(portid_t pid) { @@ -2319,14 +2307,12 @@ detach_port(portid_t port_id) printf("Detaching a port...\n"); - if (!port_is_closed(port_id)) { - printf("Please close port first\n"); - return; + if (ports[port_id].port_status != RTE_PORT_CLOSED) { + printf("Port not closed\n"); + if (ports[port_id].flow_list) + port_flow_flush(port_id); } - if (ports[port_id].flow_list) - port_flow_flush(port_id); - if (rte_eth_dev_detach(port_id, name)) { TESTPMD_LOG(ERR, "Failed to detach port %u\n", port_id); return; -- 2.19.0