app/testpmd: fix packet throughput after stats reset
Testpmd calculates packet throughput by getting a diff of previous stats value and current one. If a stats clear called after previous sample taken, the diff will be negative and throughput calculation will be wrong. If current stats value is smaller than previous one, set throughput to zero. Fixes: 0e106980301d ("app/testpmd: show throughput in port stats") Cc: stable@dpdk.org Signed-off-by: Wei Zhao <wei.zhao1@intel.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
This commit is contained in:
parent
8210e9e0d8
commit
69986a823d
@ -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 ?
|
||||
|
Loading…
x
Reference in New Issue
Block a user