app/testpmd: allow detaching a port not closed
authorThomas Monjalon <thomas@monjalon.net>
Fri, 19 Oct 2018 02:07:53 +0000 (04:07 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 26 Oct 2018 20:14:05 +0000 (22:14 +0200)
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>
app/test-pmd/testpmd.c

index 89fc39c..8956d8e 100644 (file)
@@ -2356,13 +2356,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;