[dpdk-dev,v4,2/4] net/i40e: add statistics protect for vf clear xstats
Checks
Commit Message
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(-)
@@ -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 ?