From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 63804475E for ; Fri, 28 Oct 2016 03:04:37 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP; 27 Oct 2016 18:04:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,406,1473145200"; d="scan'208";a="24653969" Received: from rhorton-mobl.ger.corp.intel.com (HELO VM.sh.intel.com) ([10.239.204.237]) by orsmga005.jf.intel.com with ESMTP; 27 Oct 2016 18:04:36 -0700 From: Remy Horton To: dev@dpdk.org Date: Fri, 28 Oct 2016 09:04:31 +0800 Message-Id: <1477616671-9547-4-git-send-email-remy.horton@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1477616671-9547-1-git-send-email-remy.horton@intel.com> References: <1477616671-9547-1-git-send-email-remy.horton@intel.com> Subject: [dpdk-dev] [RFC PATCH v2 3/3] app/test-pmd: add support for bitrate statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 01:04:38 -0000 Signed-off-by: Remy Horton --- app/test-pmd/testpmd.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index e2403c3..940dc3b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -78,6 +78,8 @@ #ifdef RTE_LIBRTE_PDUMP #include #endif +#include +#include #include "testpmd.h" @@ -322,6 +324,9 @@ uint16_t nb_rx_queue_stats_mappings = 0; unsigned max_socket = 0; +/* Bitrate statistics */ +struct rte_stats_bitrates_s *bitrate_data; + /* Forward function declarations */ static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port *port); static void check_all_ports_link_status(uint32_t port_mask); @@ -921,12 +926,26 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) struct fwd_stream **fsm; streamid_t nb_fs; streamid_t sm_id; - + uint64_t tics_per_1sec; + uint64_t tics_datum; + uint64_t tics_current; + uint8_t idx_port, cnt_ports; + + cnt_ports = rte_eth_dev_count(); + tics_datum = rte_rdtsc(); + tics_per_1sec = rte_get_timer_hz(); fsm = &fwd_streams[fc->stream_idx]; nb_fs = fc->stream_nb; do { for (sm_id = 0; sm_id < nb_fs; sm_id++) (*pkt_fwd)(fsm[sm_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; + } } while (! fc->stopped); } @@ -2119,6 +2138,15 @@ main(int argc, char** argv) FOREACH_PORT(port_id, ports) rte_eth_promiscuous_enable(port_id); + /* Setup bitrate stats */ + 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); + int id_const = rte_metrics_reg_metric("constant"); + rte_metrics_update_metric(55, id_const, 0xdeadbeef); + + #ifdef RTE_LIBRTE_CMDLINE if (interactive == 1) { if (auto_start) { -- 2.5.5