app/testpmd: fix timeout in Rx queue flushing
[dpdk.git] / app / test-pmd / testpmd.c
index b7f28e9..e2403c3 100644 (file)
@@ -63,7 +63,6 @@
 #include <rte_lcore.h>
 #include <rte_atomic.h>
 #include <rte_branch_prediction.h>
-#include <rte_ring.h>
 #include <rte_mempool.h>
 #include <rte_malloc.h>
 #include <rte_mbuf.h>
@@ -272,9 +271,6 @@ uint32_t bypass_timeout = RTE_BYPASS_TMT_OFF;
 
 #endif
 
-/* default period is 1 second */
-static uint64_t timer_period = 1;
-
 /*
  * Ethernet device configuration.
  */
@@ -444,10 +440,13 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
                                mb_size, (unsigned) mb_mempool_cache,
                                sizeof(struct rte_pktmbuf_pool_private),
                                socket_id, 0);
+                       if (rte_mp == NULL)
+                               goto err;
 
                        if (rte_mempool_populate_anon(rte_mp) == 0) {
                                rte_mempool_free(rte_mp);
                                rte_mp = NULL;
+                               goto err;
                        }
                        rte_pktmbuf_pool_init(rte_mp, NULL);
                        rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL);
@@ -458,6 +457,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
                }
        }
 
+err:
        if (rte_mp == NULL) {
                rte_exit(EXIT_FAILURE,
                        "Creation of mbuf pool for socket %u failed: %s\n",
@@ -881,9 +881,10 @@ flush_fwd_rx_queues(void)
        uint16_t  i;
        uint8_t   j;
        uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;
+       uint64_t timer_period;
 
        /* convert to number of cycles */
-       timer_period *= rte_get_timer_hz();
+       timer_period = rte_get_timer_hz(); /* 1 second timeout */
 
        for (j = 0; j < 2; j++) {
                for (rxp = 0; rxp < cur_fwd_config.nb_fwd_ports; rxp++) {
@@ -907,7 +908,6 @@ flush_fwd_rx_queues(void)
                                        timer_tsc += diff_tsc;
                                } while ((nb_rx > 0) &&
                                        (timer_tsc < timer_period));
-                               prev_tsc = cur_tsc;
                                timer_tsc = 0;
                        }
                }