[PATCH 20.11 3/3] net/hns3: fix clearing hardware MAC statistics
Huisong Li
lihuisong at huawei.com
Sat Nov 12 08:57:50 CET 2022
[ upstream commit b38bd88bebc5b123431b1d13f4bd06b9d468077a ]
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")
Signed-off-by: Huisong Li <lihuisong at huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3 at huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 6 +++---
drivers/net/hns3/hns3_ethdev_vf.c | 6 +++---
drivers/net/hns3/hns3_stats.c | 21 +++++++++++++++++++--
drivers/net/hns3/hns3_stats.h | 4 ++--
4 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 9eaa6f3fa0..07b77d8b99 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4810,7 +4810,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
goto err_get_config;
}
- ret = hns3_tqp_stats_init(hw);
+ ret = hns3_stats_init(hw);
if (ret)
goto err_get_config;
@@ -4844,7 +4844,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
(void)hns3_firmware_compat_config(hw, false);
hns3_uninit_umv_space(hw);
err_init_hw:
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
err_get_config:
hns3_pf_disable_irq0(hw);
rte_intr_disable(&pci_dev->intr_handle);
@@ -4878,7 +4878,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev)
hns3_fdir_filter_uninit(hns);
(void)hns3_firmware_compat_config(hw, false);
hns3_uninit_umv_space(hw);
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
hns3_pf_disable_irq0(hw);
rte_intr_disable(&pci_dev->intr_handle);
hns3_intr_unregister(&pci_dev->intr_handle, hns3_interrupt_handler,
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 61e6b9a867..f5bf5d1a29 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1815,7 +1815,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)
goto err_get_config;
}
- ret = hns3_tqp_stats_init(hw);
+ ret = hns3_stats_init(hw);
if (ret)
goto err_get_config;
@@ -1846,7 +1846,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)
return 0;
err_set_tc_queue:
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
err_get_config:
hns3vf_disable_irq0(hw);
@@ -1877,7 +1877,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev)
(void)hns3vf_set_alive(hw, false);
(void)hns3vf_set_promisc_mode(hw, false, false, false);
hns3_flow_uninit(eth_dev);
- hns3_tqp_stats_uninit(hw);
+ hns3_stats_uninit(hw);
hns3vf_disable_irq0(hw);
rte_intr_disable(&pci_dev->intr_handle);
hns3_intr_unregister(&pci_dev->intr_handle, hns3vf_interrupt_handler,
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index 6de3767c0b..16cca25862 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -1094,7 +1094,7 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev)
return 0;
}
-int
+static int
hns3_tqp_stats_init(struct hns3_hw *hw)
{
struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
@@ -1118,7 +1118,7 @@ hns3_tqp_stats_init(struct hns3_hw *hw)
return 0;
}
-void
+static void
hns3_tqp_stats_uninit(struct hns3_hw *hw)
{
struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
@@ -1139,3 +1139,20 @@ hns3_tqp_stats_clear(struct hns3_hw *hw)
memset(stats->rcb_rx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num);
memset(stats->rcb_tx_ring_pktnum, 0, sizeof(uint64_t) * hw->tqps_num);
}
+
+int
+hns3_stats_init(struct hns3_hw *hw)
+{
+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+
+ if (!hns->is_vf)
+ hns3_mac_stats_reset(hw);
+
+ return hns3_tqp_stats_init(hw);
+}
+
+void
+hns3_stats_uninit(struct hns3_hw *hw)
+{
+ hns3_tqp_stats_uninit(hw);
+}
\ No newline at end of file
diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h
index 9876e7d0cc..141d0a4cf6 100644
--- a/drivers/net/hns3/hns3_stats.h
+++ b/drivers/net/hns3/hns3_stats.h
@@ -150,8 +150,8 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
uint32_t size);
int hns3_stats_reset(struct rte_eth_dev *eth_dev);
void hns3_error_int_stats_add(struct hns3_adapter *hns, const char *err);
-int hns3_tqp_stats_init(struct hns3_hw *hw);
-void hns3_tqp_stats_uninit(struct hns3_hw *hw);
+int hns3_stats_init(struct hns3_hw *hw);
+void hns3_stats_uninit(struct hns3_hw *hw);
int hns3_query_mac_stats_reg_num(struct hns3_hw *hw);
#endif /* _HNS3_STATS_H_ */
--
2.33.0
More information about the stable
mailing list