[v6,2/6] app/testpmd: allow detaching a port not closed

Message ID 20181019020757.27698-3-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev port freeing |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Oct. 19, 2018, 2:07 a.m. UTC
  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.

in order to avoid a crash, it is checked that the port must be stopped
before detaching (as for closing).

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 app/test-pmd/testpmd.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Comments

Iremonger, Bernard Oct. 19, 2018, 2:32 p.m. UTC | #1
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Friday, October 19, 2018 3:08 AM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>; arybchenko@solarflare.com
> Cc: dev@dpdk.org; ophirmu@mellanox.com; Iremonger, Bernard
> <bernard.iremonger@intel.com>; rahul.lakkireddy@chelsio.com
> Subject: [PATCH v6 2/6] app/testpmd: allow detaching a port not closed
> 
> 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.
> 
> in order to avoid a crash, it is checked that the port must be stopped before
> detaching (as for closing).
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 2c0b4a021..d5a8a14af 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2344,13 +2344,15 @@  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_STOPPED) {
+			printf("Port not stopped\n");
+			return;
+		}
+		printf("Port was 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;