[v3] app/testpmd: fix CPU cycles per pkt stats on transmit modes

Message ID 1592816682-6414-1-git-send-email-phil.yang@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v3] app/testpmd: fix CPU cycles per pkt stats on transmit modes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Phil Yang June 22, 2020, 9:04 a.m. UTC
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 <phil.yang@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Fixes: 53324971a14e ("app/testpmd: display/clear forwarding stats on demand")
Cc: stable@dpdk.org
Cc: david.marchand@redhat.com
---
v3:
replace ingress flag with total_pkts. (Honnappa Nagarahalli)

v2:
Consolidate the output into a single printf. (Honnappa Nagarahalli)

 app/test-pmd/testpmd.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
  

Comments

Ferruh Yigit July 10, 2020, 5:14 p.m. UTC | #1
On 6/22/2020 10:04 AM, Phil Yang wrote:
> 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
> 
> Fixes: 53324971a14e ("app/testpmd: display/clear forwarding stats on demand")
> Cc: stable@dpdk.org
>
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 4989d22..be47a7d 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1961,13 +1961,21 @@  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) {
+		uint64_t total_pkts = 0;
+		if (strcmp(cur_fwd_eng->fwd_mode_name, "txonly") == 0 ||
+		    strcmp(cur_fwd_eng->fwd_mode_name, "flowgen") == 0)
+			total_pkts = total_xmit;
+		else
+			total_pkts = total_recv;
+
 		printf("\n  CPU cycles/packet=%.2F (total cycles="
-		       "%"PRIu64" / total RX packets=%"PRIu64") at %"PRIu64
+		       "%"PRIu64" / total %s packets=%"PRIu64") at %"PRIu64
 		       " MHz Clock\n",
-		       (double) fwd_cycles / total_recv,
-		       fwd_cycles, total_recv,
+		       (double) fwd_cycles / total_pkts,
+		       fwd_cycles, cur_fwd_eng->fwd_mode_name, total_pkts,
 		       (uint64_t)(rte_get_tsc_hz() / CYC_PER_MHZ));
+	}
 #endif
 }