From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 97F752C16 for ; Wed, 26 Apr 2017 15:03:07 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2017 06:03:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,254,1488873600"; d="scan'208";a="94389095" Received: from rhorton-mobl1.ger.corp.intel.com (HELO FC23.ir.intel.com) ([163.33.230.216]) by fmsmga006.fm.intel.com with ESMTP; 26 Apr 2017 06:02:55 -0700 From: Remy Horton To: dev@dpdk.org Cc: Jingjing Wu Date: Wed, 26 Apr 2017 14:02:54 +0100 Message-Id: <1493211774-28249-1-git-send-email-remy.horton@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH v1] app/testpmd: add bitrate stats option X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Apr 2017 13:03:08 -0000 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 --- app/test-pmd/parameters.c | 15 +++++++++++++++ app/test-pmd/testpmd.c | 36 ++++++++++++++++++++++++++---------- app/test-pmd/testpmd.h | 5 +++++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 3f4d3a2..a6140b5 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -536,6 +536,9 @@ launch_args_parse(int argc, char** argv) #ifdef RTE_LIBRTE_LATENCY_STATS { "latencystats", 1, 0, 0 }, #endif +#ifdef RTE_LIBRTE_BITRATE + { "bitratestats", 1, 0, 0 }, +#endif { "disable-crc-strip", 0, 0, 0 }, { "enable-lro", 0, 0, 0 }, { "enable-rx-cksum", 0, 0, 0 }, @@ -793,6 +796,18 @@ launch_args_parse(int argc, char** argv) " must be >= 0\n", n); } #endif +#ifdef RTE_LIBRTE_BITRATE + if (!strcmp(lgopts[opt_idx].name, "bitratestats")) { + 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 bitratestats" + " must be >= 0\n", n); + } +#endif if (!strcmp(lgopts[opt_idx].name, "disable-crc-strip")) rx_mode.hw_strip_crc = 0; if (!strcmp(lgopts[opt_idx].name, "enable-lro")) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 3a57348..cfd5382 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); @@ -962,12 +966,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 @@ -2238,6 +2248,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) @@ -2275,10 +2288,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 a9ff07e..6443f7e 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; /* -- 2.5.5