app/testpmd: fix log with no bound device
authorMichael Qiu <michael.qiu@intel.com>
Mon, 2 Mar 2015 08:31:37 +0000 (16:31 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 9 Mar 2015 11:46:46 +0000 (12:46 +0100)
As hotplug has been enabled, start the testpmd with no nic binded
will show one error log "Please stop the ports first":

Interactive-mode selected
Please stop the ports first
Done
testpmd>

This issue is cause by the logic of check link status.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
app/test-pmd/testpmd.c

index 61291be..e556b4c 100644 (file)
@@ -1315,7 +1315,7 @@ port_is_closed(portid_t port_id)
 int
 start_port(portid_t pid)
 {
-       int diag, need_check_link_status = 0;
+       int diag, need_check_link_status = -1;
        portid_t pi;
        queueid_t qi;
        struct rte_port *port;
@@ -1337,6 +1337,7 @@ start_port(portid_t pid)
                if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
                        continue;
 
+               need_check_link_status = 0;
                port = &ports[pi];
                if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STOPPED,
                                                 RTE_PORT_HANDLING) == 0) {
@@ -1457,9 +1458,9 @@ start_port(portid_t pid)
                need_check_link_status = 1;
        }
 
-       if (need_check_link_status && !no_link_check)
+       if (need_check_link_status == 1 && !no_link_check)
                check_all_ports_link_status(RTE_PORT_ALL);
-       else
+       else if (need_check_link_status == 0)
                printf("Please stop the ports first\n");
 
        printf("Done\n");