mbuf: fix data room size calculation in pool init
[dpdk.git] / app / test-pmd / testpmd.c
index 61291be..10e4347 100644 (file)
@@ -57,7 +57,6 @@
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
 #include <rte_launch.h>
-#include <rte_tailq.h>
 #include <rte_eal.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
@@ -333,7 +332,7 @@ find_next_port(portid_t p, struct rte_port *ports, int size)
        if (ports == NULL)
                rte_exit(-EINVAL, "failed to find a next port id\n");
 
-       while ((ports[p].enabled == 0) && (p < size))
+       while ((p < size) && (ports[p].enabled == 0))
                p++;
        return p;
 }
@@ -444,6 +443,7 @@ testpmd_mbuf_pool_ctor(struct rte_mempool *mp,
        mbp_ctor_arg = (struct mbuf_pool_ctor_arg *) opaque_arg;
        mbp_priv = rte_mempool_get_priv(mp);
        mbp_priv->mbuf_data_room_size = mbp_ctor_arg->seg_buf_size;
+       mbp_priv->mbuf_priv_size = 0;
 }
 
 static void
@@ -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;
@@ -1326,6 +1326,9 @@ start_port(portid_t pid)
                return -1;
        }
 
+       if (port_id_is_invalid(pid, ENABLED_WARN))
+               return 0;
+
        if (init_fwd_streams() < 0) {
                printf("Fail from init_fwd_streams()\n");
                return -1;
@@ -1337,6 +1340,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 +1461,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");
@@ -1481,10 +1485,14 @@ stop_port(portid_t pid)
                dcb_test = 0;
                dcb_config = 0;
        }
+
+       if (port_id_is_invalid(pid, ENABLED_WARN))
+               return;
+
        printf("Stopping ports...\n");
 
        FOREACH_PORT(pi, ports) {
-               if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+               if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
                        continue;
 
                port = &ports[pi];
@@ -1516,10 +1524,13 @@ close_port(portid_t pid)
                return;
        }
 
+       if (port_id_is_invalid(pid, ENABLED_WARN))
+               return;
+
        printf("Closing ports...\n");
 
        FOREACH_PORT(pi, ports) {
-               if (!port_id_is_invalid(pid, DISABLED_WARN) && pid != pi)
+               if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
                        continue;
 
                port = &ports[pi];
@@ -1623,6 +1634,9 @@ pmd_test_exit(void)
 {
        portid_t pt_id;
 
+       if (test_done == 0)
+               stop_packet_forwarding();
+
        FOREACH_PORT(pt_id, ports) {
                printf("Stopping port %d...", pt_id);
                fflush(stdout);