[dpdk-dev,v4,2/4] net/i40e: add statistics protect for vf clear xstats

Message ID 1505975545-16393-2-git-send-email-wei.zhao1@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Zhao1, Wei Sept. 21, 2017, 6:32 a.m. UTC
  The diff_pkts_rx and diff_pkts_tx statistic data
will be wrong  when the first time after clear
xstats command if there is no protect.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
 app/test-pmd/config.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index ca83eef..e8e311c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -203,8 +203,10 @@  nic_stats_display(portid_t port_id)
 	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];
+	diff_pkts_rx = (stats.ipackets > prev_pkts_rx[port_id]) ?
+		(stats.ipackets - prev_pkts_rx[port_id]) : 0;
+	diff_pkts_tx = (stats.opackets > prev_pkts_tx[port_id]) ?
+		(stats.opackets - prev_pkts_tx[port_id]) : 0;
 	prev_pkts_rx[port_id] = stats.ipackets;
 	prev_pkts_tx[port_id] = stats.opackets;
 	mpps_rx = diff_cycles > 0 ?