From patchwork Thu Mar 9 16:25:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remy Horton X-Patchwork-Id: 21653 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id F13DBD072; Thu, 9 Mar 2017 17:26:07 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 4DD14CF62 for ; Thu, 9 Mar 2017 17:25:43 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP; 09 Mar 2017 08:25:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,136,1486454400"; d="scan'208";a="74743453" Received: from cchotard-mobl2.ger.corp.intel.com (HELO FC23.ger.corp.intel.com) ([10.252.10.254]) by fmsmga006.fm.intel.com with ESMTP; 09 Mar 2017 08:25:41 -0800 From: Remy Horton To: dev@dpdk.org Cc: Thomas Monjalon Date: Thu, 9 Mar 2017 16:25:31 +0000 Message-Id: <1489076734-31474-5-git-send-email-remy.horton@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1489076734-31474-1-git-send-email-remy.horton@intel.com> References: <1489076734-31474-1-git-send-email-remy.horton@intel.com> Subject: [dpdk-dev] [PATCH v11 4/7] app/test-pmd: add bitrate statistics calculation 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Calculate bitrate statistics using the bitrate stats library. The resulting statistics can be viewed via proc_info. Signed-off-by: Remy Horton --- app/test-pmd/testpmd.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index bfb2f8e..b31a300 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -79,6 +79,10 @@ #include #endif #include +#include +#ifdef RTE_LIBRTE_BITRATE +#include +#endif #include "testpmd.h" @@ -323,6 +327,9 @@ uint16_t nb_rx_queue_stats_mappings = 0; unsigned max_socket = 0; +/* Bitrate statistics */ +struct rte_stats_bitrates *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); @@ -922,12 +929,32 @@ 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; +#ifdef RTE_LIBRTE_BITRATE + uint64_t tics_per_1sec; + uint64_t tics_datum; + uint64_t tics_current; + uint8_t idx_port, cnt_ports; +#endif +#ifdef RTE_LIBRTE_BITRATE + cnt_ports = rte_eth_dev_count(); + tics_datum = rte_rdtsc(); + tics_per_1sec = rte_get_timer_hz(); +#endif 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]); +#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; + } +#endif } while (! fc->stopped); } @@ -2139,6 +2166,18 @@ main(int argc, char** argv) FOREACH_PORT(port_id, ports) rte_eth_promiscuous_enable(port_id); + /* Init metrics library */ + rte_metrics_init(rte_socket_id()); + + /* 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); +#endif + + #ifdef RTE_LIBRTE_CMDLINE if (interactive == 1) { if (auto_start) {