From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A6E38A04F5; Fri, 19 Jun 2020 06:09:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 843A0F04; Fri, 19 Jun 2020 06:09:06 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 92F98E07; Fri, 19 Jun 2020 06:09:04 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F17C9C0A; Thu, 18 Jun 2020 21:09:03 -0700 (PDT) Received: from phil-VirtualBox.shanghai.arm.com (phil-VirtualBox.shanghai.arm.com [10.169.108.159]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 552A03F6CF; Thu, 18 Jun 2020 21:09:01 -0700 (PDT) From: Phil Yang To: dev@dpdk.org Cc: ferruh.yigit@intel.com, maxime.coquelin@redhat.com, Honnappa.Nagarahalli@arm.com, ruifeng.wang@arm.com, nd@arm.com, stable@dpdk.org, david.marchand@redhat.com Date: Fri, 19 Jun 2020 12:08:01 +0800 Message-Id: <1592539681-3855-1-git-send-email-phil.yang@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592491803-21173-1-git-send-email-phil.yang@arm.com> References: <1592491803-21173-1-git-send-email-phil.yang@arm.com> Subject: [dpdk-dev] [PATCH v2] app/testpmd: fix CPU cycles per pkt stats on transmit modes 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" In txonly and flowgen forwarding mode, calculating CPU per packets with total received packets is not accurate. Use total transmitted packets for these cases. The error output under txonly mode: testpmd> show fwd stats all ---------------------- Forward statistics for port 0 ------------------- RX-packets: 0 RX-dropped: 0 RX-total: 0 TX-packets: 3582891927 TX-dropped: 401965824 TX-total: 3984857751 TX-bursts : 86381636 [0% of 0 pkts + 85% of 64 pkts + 15% of 32 pkts] ------------------------------------------------------------------------- ---------------------- Forward statistics for port 1 ------------------- RX-packets: 1 RX-dropped: 394351696 RX-total: 394351697 TX-packets: 3582890632 TX-dropped: 401965568 TX-total: 3984856200 TX-bursts : 86381679 [0% of 0 pkts + 85% of 64 pkts + 15% of 32 pkts] ------------------------------------------------------------------------- +++++++++++++++ Accumulated forward statistics for all ports+++++++++++++ RX-packets: 1 RX-dropped: 394351696 RX-total: 394351697 TX-packets: 7165782559 TX-dropped: 803931392 TX-total: 7969713951 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ CPU cycles/packet=54984156291.00 \ (total cycles=54984156291 / total RX packets=1) at 200 MHz Clock Signed-off-by: Phil Yang Reviewed-by: Ruifeng Wang Fixes: 53324971a14e ("app/testpmd: display/clear forwarding stats on demand") Cc: stable@dpdk.org Cc: david.marchand@redhat.com --- v2: Consolidate the output into a single printf. (Honnappa Nagarahalli) app/test-pmd/testpmd.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 4989d22..826d7dd 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1961,13 +1961,22 @@ fwd_stats_display(void) acc_stats_border, acc_stats_border); #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES #define CYC_PER_MHZ 1E6 - if (total_recv > 0) + if (total_recv > 0 || total_xmit > 0) { + uint8_t ingress; + if (strcmp(cur_fwd_eng->fwd_mode_name, "txonly") == 0 || + strcmp(cur_fwd_eng->fwd_mode_name, "flowgen") == 0) + ingress = 0; + else + ingress = 1; + printf("\n CPU cycles/packet=%.2F (total cycles=" - "%"PRIu64" / total RX packets=%"PRIu64") at %"PRIu64 - " MHz Clock\n", - (double) fwd_cycles / total_recv, - fwd_cycles, total_recv, - (uint64_t)(rte_get_tsc_hz() / CYC_PER_MHZ)); + "%"PRIu64" / total %s packets=%"PRIu64") at %" + PRIu64" MHz Clock\n", ((double) fwd_cycles / + (ingress ? total_recv : total_xmit)), + fwd_cycles, cur_fwd_eng->fwd_mode_name, + (ingress ? total_recv : total_xmit), + (uint64_t)(rte_get_tsc_hz() / CYC_PER_MHZ)); + } #endif } -- 2.7.4