X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Ftestpmd.c;h=132ce81fe748edd41cd44660349995bb0b9deeda;hb=cfea1f3048d1bfda61036e6f823949fba4d692d4;hp=a7bad738126d98a6384dc2c1ea190912318b45fd;hpb=99cabef088557401c550809a0e01242b23579847;p=dpdk.git diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index a7bad73812..132ce81fe7 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -181,7 +181,7 @@ uint32_t burst_tx_retry_num = BURST_TX_RETRIES; uint16_t mbuf_data_size = DEFAULT_MBUF_DATA_SIZE; /**< Mbuf data space size. */ uint32_t param_total_num_mbufs = 0; /**< number of mbufs in all pools - if * specified on command-line. */ - +uint16_t stats_period; /**< Period to show statistics (disabled by default) */ /* * Configuration of packet segments used by the "txonly" processing engine. */ @@ -2235,6 +2235,21 @@ force_quit(void) prompt_exit(); } +static void +print_stats(void) +{ + uint8_t i; + const char clr[] = { 27, '[', '2', 'J', '\0' }; + const char top_left[] = { 27, '[', '1', ';', '1', 'H', '\0' }; + + /* Clear screen and move to top left */ + printf("%s%s", clr, top_left); + + printf("\nPort statistics ===================================="); + for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) + nic_stats_display(fwd_ports_ids[i]); +} + static void signal_handler(int signum) { @@ -2361,6 +2376,28 @@ main(int argc, char** argv) printf("No commandline core given, start packet forwarding\n"); start_packet_forwarding(tx_first); + if (stats_period != 0) { + uint64_t prev_time = 0, cur_time, diff_time = 0; + uint64_t timer_period; + + /* Convert to number of cycles */ + timer_period = stats_period * rte_get_timer_hz(); + + while (1) { + cur_time = rte_get_timer_cycles(); + diff_time += cur_time - prev_time; + + if (diff_time >= timer_period) { + print_stats(); + /* Reset the timer */ + diff_time = 0; + } + /* Sleep to avoid unnecessary checks */ + prev_time = cur_time; + sleep(1); + } + } + printf("Press enter to exit\n"); rc = read(0, &c, 1); pmd_test_exit();