From: Remy Horton Date: Fri, 28 Apr 2017 11:00:13 +0000 (+0100) Subject: app/testpmd: add --bitrate-stats option X-Git-Tag: spdx-start~3314 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e25e6c70fb56;p=dpdk.git app/testpmd: add --bitrate-stats option Bit-rate collation should only be done by one core. This patch adds an option to select which core performs the bit-rate calculation, which is also disabled by default. Fixes: 7e4441c8efb9 ("app/testpmd: add bitrate statistics calculation") Signed-off-by: Remy Horton Acked-by: Pablo de Lara --- diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 3f4d3a2478..a0300eb66c 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -201,7 +201,9 @@ usage(char* progname) printf(" --disable-link-check: disable check on link status when " "starting/stopping ports.\n"); printf(" --no-lsc-interrupt: disable link status change interrupt.\n"); - printf(" --no-rmv-interrupt: disable device removal interrupt."); + printf(" --no-rmv-interrupt: disable device removal interrupt.\n"); + printf(" --bitrate-stats=N: set the logical core N to perform " + "bit-rate calculation.\n"); } #ifdef RTE_LIBRTE_CMDLINE @@ -535,6 +537,9 @@ launch_args_parse(int argc, char** argv) { "pkt-filter-drop-queue", 1, 0, 0 }, #ifdef RTE_LIBRTE_LATENCY_STATS { "latencystats", 1, 0, 0 }, +#endif +#ifdef RTE_LIBRTE_BITRATE + { "bitrate-stats", 1, 0, 0 }, #endif { "disable-crc-strip", 0, 0, 0 }, { "enable-lro", 0, 0, 0 }, @@ -792,6 +797,18 @@ launch_args_parse(int argc, char** argv) "invalid lcore id %d for latencystats" " must be >= 0\n", n); } +#endif +#ifdef RTE_LIBRTE_BITRATE + if (!strcmp(lgopts[opt_idx].name, "bitrate-stats")) { + n = atoi(optarg); + if (n >= 0) { + bitrate_lcore_id = (lcoreid_t) n; + bitrate_enabled = 1; + } else + rte_exit(EXIT_FAILURE, + "invalid lcore id %d for bitrate stats" + " must be >= 0\n", n); + } #endif if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip")) rx_mode.hw_strip_crc = 0; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 36a4701627..6526018517 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -355,8 +355,12 @@ uint16_t nb_rx_queue_stats_mappings = 0; unsigned max_socket = 0; +#ifdef RTE_LIBRTE_BITRATE /* Bitrate statistics */ struct rte_stats_bitrates *bitrate_data; +lcoreid_t bitrate_lcore_id; +uint8_t bitrate_enabled; +#endif /* Forward function declarations */ static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port *port); @@ -951,12 +955,18 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) for (sm_id = 0; sm_id < nb_fs; sm_id++) (*pkt_fwd)(fsm[sm_id]); #ifdef RTE_LIBRTE_BITRATE - tics_current = rte_rdtsc(); - if (tics_current - tics_datum >= tics_per_1sec) { - /* Periodic bitrate calculation */ - for (idx_port = 0; idx_port < cnt_ports; idx_port++) - rte_stats_bitrate_calc(bitrate_data, idx_port); - tics_datum = tics_current; + if (bitrate_enabled != 0 && + bitrate_lcore_id == rte_lcore_id()) { + tics_current = rte_rdtsc(); + if (tics_current - tics_datum >= tics_per_1sec) { + /* Periodic bitrate calculation */ + for (idx_port = 0; + idx_port < cnt_ports; + idx_port++) + rte_stats_bitrate_calc(bitrate_data, + idx_port); + tics_datum = tics_current; + } } #endif #ifdef RTE_LIBRTE_LATENCY_STATS @@ -2227,6 +2237,9 @@ main(int argc, char** argv) rte_panic("Empty set of forwarding logical cores - check the " "core mask supplied in the command parameters\n"); + /* Bitrate stats disabled by default */ + bitrate_enabled = 0; + argc -= diag; argv += diag; if (argc > 1) @@ -2264,10 +2277,13 @@ main(int argc, char** argv) /* Setup bitrate stats */ #ifdef RTE_LIBRTE_BITRATE - bitrate_data = rte_stats_bitrate_create(); - if (bitrate_data == NULL) - rte_exit(EXIT_FAILURE, "Could not allocate bitrate data.\n"); - rte_stats_bitrate_reg(bitrate_data); + if (bitrate_enabled != 0) { + bitrate_data = rte_stats_bitrate_create(); + if (bitrate_data == NULL) + rte_exit(EXIT_FAILURE, + "Could not allocate bitrate data.\n"); + rte_stats_bitrate_reg(bitrate_data); + } #endif diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index a9ff07e5d5..6443f7eb8c 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -380,6 +380,11 @@ extern uint8_t latencystats_enabled; extern lcoreid_t latencystats_lcore_id; #endif +#ifdef RTE_LIBRTE_BITRATE +extern lcoreid_t bitrate_lcore_id; +extern uint8_t bitrate_enabled; +#endif + extern struct rte_fdir_conf fdir_conf; /* diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index a72c7e3723..a117354931 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -466,10 +466,14 @@ The commandline options are: Disable check on link status when starting/stopping ports. -* ``--no-lsc-interrupt`` +* ``--no-lsc-interrupt`` - Disable LSC interrupts for all ports, even those supporting it. + Disable LSC interrupts for all ports, even those supporting it. -* ``--no-rmv-interrupt`` +* ``--no-rmv-interrupt`` - Disable RMV interrupts for all ports, even those supporting it. + Disable RMV interrupts for all ports, even those supporting it. + +* ``--bitrate-stats=N`` + + Set the logical core N to perform bitrate calculation.