From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 72096A0566 for ; Sat, 12 Nov 2022 08:57:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3A7E410EC; Sat, 12 Nov 2022 08:57:28 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 6C7C04003F for ; Sat, 12 Nov 2022 08:57:27 +0100 (CET) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N8Sb75TDFzmVhl for ; Sat, 12 Nov 2022 15:57:07 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 15:57:24 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 15:57:24 +0800 From: Huisong Li To: , CC: , , , Subject: [PATCH 20.11 3/3] net/hns3: fix clearing hardware MAC statistics Date: Sat, 12 Nov 2022 15:57:50 +0800 Message-ID: <20221112075750.55623-4-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20221112075750.55623-1-lihuisong@huawei.com> References: <20221112075750.55623-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ 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 Signed-off-by: Dongdong Liu --- 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