[RESEND,12/13] net/hns3: fix uncleared hardware MAC statistics

Message ID 20220905085939.22236-13-liudongdong3@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Andrew Rybchenko
Headers
Series some bugfixes and clean code for hns3 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dongdong Liu Sept. 5, 2022, 8:59 a.m. UTC
  From: Huisong Li <lihuisong@huawei.com>

In the situation that the driver hns3 exits abnormally during packets
sending and receiving, the hardware statistics are not cleared when the
driver hns3 is reloaded. It need to be cleared during driver hns3
initialization that hardware MAC statistics.

Fixes: 8839c5e202f3 ("net/hns3: support device stats")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_stats.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index 2ec7a9635e..bad65fcbed 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -1528,6 +1528,7 @@  hns3_tqp_stats_clear(struct hns3_hw *hw)
 int
 hns3_stats_init(struct hns3_hw *hw)
 {
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
 	int ret;
 
 	rte_spinlock_init(&hw->stats_lock);
@@ -1538,6 +1539,9 @@  hns3_stats_init(struct hns3_hw *hw)
 		return ret;
 	}
 
+	if (!hns->is_vf)
+		hns3_mac_stats_reset(hw);
+
 	return hns3_tqp_stats_init(hw);
 }