net/hns3: fix stats flip overflow
authorChengchang Tang <tangchengchang@huawei.com>
Wed, 3 Feb 2021 12:23:52 +0000 (20:23 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 4 Feb 2021 17:19:37 +0000 (18:19 +0100)
commitc27e64ee3e9b4ae6c763a4f00f72927e80e2e5f2
tree7977763c8fa68b7b96a39e10899a1bd233dfecc0
parente9550856f8c65b6e15f8f59810560bc6d240a1f8
net/hns3: fix stats flip overflow

Currently, statistics may overflow in some scenarios.

For example, if HW statistics are reset by stats reset operation,
but there are still a lot of residual packets exist in the HW
queues and these packets are error packets, flip may occurred
because the ipacket is obtained by subtracting the number of
software error packets from the number of HW received packets.

This patch verifies the calculation and returns 0 when overflow
may occur.

Fixes: 8839c5e202f3 ("net/hns3: support device stats")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
drivers/net/hns3/hns3_stats.c