From patchwork Tue Jun 14 23:08:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihong Wang X-Patchwork-Id: 13753 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 0AC55ADF2; Wed, 15 Jun 2016 08:13:55 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 65E6EADE6 for ; Wed, 15 Jun 2016 08:13:51 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 14 Jun 2016 23:13:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,474,1459839600"; d="scan'208";a="719268290" Received: from unknown (HELO dpdk5.sh.intel.com) ([10.239.129.244]) by FMSMGA003.fm.intel.com with ESMTP; 14 Jun 2016 23:13:41 -0700 From: Zhihong Wang To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com, thomas.monjalon@6wind.com, Zhihong Wang Date: Tue, 14 Jun 2016 19:08:04 -0400 Message-Id: <1465945686-142094-4-git-send-email-zhihong.wang@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1465945686-142094-1-git-send-email-zhihong.wang@intel.com> References: <1462488421-118990-1-git-send-email-zhihong.wang@intel.com> <1465945686-142094-1-git-send-email-zhihong.wang@intel.com> Subject: [dpdk-dev] [PATCH v3 3/5] testpmd: show throughput in port stats 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds throughput numbers (in the period since last use of this command) in port statistics display for "show port stats (port_id|all)". Signed-off-by: Zhihong Wang --- app/test-pmd/config.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a85bb5f..ede7c78 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -92,6 +92,7 @@ #include #include #include +#include #include "testpmd.h" @@ -150,6 +151,11 @@ print_ethaddr(const char *name, struct ether_addr *eth_addr) void nic_stats_display(portid_t port_id) { + static uint64_t prev_pkts_rx[RTE_MAX_ETHPORTS]; + static uint64_t prev_pkts_tx[RTE_MAX_ETHPORTS]; + static uint64_t prev_cycles[RTE_MAX_ETHPORTS]; + uint64_t diff_pkts_rx, diff_pkts_tx, diff_cycles; + uint64_t mpps_rx, mpps_tx; struct rte_eth_stats stats; struct rte_port *port = &ports[port_id]; uint8_t i; @@ -209,6 +215,23 @@ nic_stats_display(portid_t port_id) } } + diff_cycles = prev_cycles[port_id]; + prev_cycles[port_id] = rte_rdtsc(); + if (diff_cycles > 0) + diff_cycles = prev_cycles[port_id] - diff_cycles; + + diff_pkts_rx = stats.ipackets - prev_pkts_rx[port_id]; + diff_pkts_tx = stats.opackets - prev_pkts_tx[port_id]; + prev_pkts_rx[port_id] = stats.ipackets; + prev_pkts_tx[port_id] = stats.opackets; + mpps_rx = diff_cycles > 0 ? + diff_pkts_rx * rte_get_tsc_hz() / diff_cycles : 0; + mpps_tx = diff_cycles > 0 ? + diff_pkts_tx * rte_get_tsc_hz() / diff_cycles : 0; + printf("\n Throughput (since last show)\n"); + printf(" Rx-pps: %12"PRIu64"\n Tx-pps: %12"PRIu64"\n", + mpps_rx, mpps_tx); + printf(" %s############################%s\n", nic_stats_border, nic_stats_border); }