DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <thomas@monjalon.net>
Subject: [PATCH 1/7] net/hns3: fix order of clearing imissed register in PF
Date: Wed, 6 Apr 2022 17:22:34 +0800	[thread overview]
Message-ID: <20220406092240.52900-2-humin29@huawei.com> (raw)
In-Reply-To: <20220406092240.52900-1-humin29@huawei.com>

From: Huisong Li <lihuisong@huawei.com>

Clearing imissed registers in PF hardware depends on the 'drop_stats_mode'
in struct hns3_hw. The variable is initialized after the
"hns3_get_configuration". But, in current code, the clearing operation runs
before the function. So this patch fixes this order. In addition, this
patch extracts a public function to initialize and uninitialize statistics
to improve the maintainability of these codes.

Fixes: 3e9f3042d7c8 ("net/hns3: add imissed packet stats")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    | 13 +++----------
 drivers/net/hns3/hns3_ethdev_vf.c | 13 +++----------
 drivers/net/hns3/hns3_stats.c     | 27 ++++++++++++++++++++++++---
 drivers/net/hns3/hns3_stats.h     |  5 ++---
 4 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 24ae5ef929..ee2c5d5a1a 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4620,13 +4620,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
 		goto err_cmd_init;
 	}
 
-	/* Hardware statistics of imissed registers cleared. */
-	ret = hns3_update_imissed_stats(hw, true);
-	if (ret) {
-		hns3_err(hw, "clear imissed stats failed, ret = %d", ret);
-		goto err_cmd_init;
-	}
-
 	hns3_config_all_msix_error(hw, true);
 
 	ret = rte_intr_callback_register(pci_dev->intr_handle,
@@ -4652,7 +4645,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;
 
@@ -4698,7 +4691,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
 err_fdir:
 	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);
@@ -4732,7 +4725,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev)
 	hns3_flow_uninit(eth_dev);
 	hns3_fdir_filter_uninit(hns);
 	hns3_uninit_umv_space(hw);
-	hns3_tqp_stats_uninit(hw);
+	hns3_stats_uninit(hw);
 	hns3_config_mac_tnl_int(hw, false);
 	hns3_pf_disable_irq0(hw);
 	rte_intr_disable(pci_dev->intr_handle);
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index e06a1a41dd..4f52f22776 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1508,17 +1508,10 @@ 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;
 
-	/* Hardware statistics of imissed registers cleared. */
-	ret = hns3_update_imissed_stats(hw, true);
-	if (ret) {
-		hns3_err(hw, "clear imissed stats failed, ret = %d", ret);
-		goto err_set_tc_queue;
-	}
-
 	ret = hns3_queue_to_tc_mapping(hw, hw->tqps_num, hw->tqps_num);
 	if (ret) {
 		PMD_INIT_LOG(ERR, "failed to set tc info, ret = %d.", ret);
@@ -1546,7 +1539,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);
@@ -1577,7 +1570,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 806720faff..e4a5dcf2f8 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -540,7 +540,7 @@ hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw)
 	return 0;
 }
 
-int
+static int
 hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear)
 {
 	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
@@ -1476,7 +1476,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;
@@ -1500,7 +1500,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;
@@ -1521,3 +1521,24 @@ 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)
+{
+	int ret;
+
+	/* Hardware statistics of imissed registers cleared. */
+	ret = hns3_update_imissed_stats(hw, true);
+	if (ret) {
+		hns3_err(hw, "clear imissed stats failed, ret = %d", ret);
+		return ret;
+	}
+
+	return hns3_tqp_stats_init(hw);
+}
+
+void
+hns3_stats_uninit(struct hns3_hw *hw)
+{
+	hns3_tqp_stats_uninit(hw);
+}
diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h
index c81d351082..e89dc97632 100644
--- a/drivers/net/hns3/hns3_stats.h
+++ b/drivers/net/hns3/hns3_stats.h
@@ -161,9 +161,8 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 				    struct rte_eth_xstat_name *xstats_names,
 				    uint32_t size);
 int hns3_stats_reset(struct rte_eth_dev *dev);
-int hns3_tqp_stats_init(struct hns3_hw *hw);
-void hns3_tqp_stats_uninit(struct hns3_hw *hw);
-int hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear);
+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


  reply	other threads:[~2022-04-06  9:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  9:22 [PATCH 0/7] bugfix for hns3 PMD Min Hu (Connor)
2022-04-06  9:22 ` Min Hu (Connor) [this message]
2022-04-06  9:22 ` [PATCH 2/7] net/hns3: fix MAC and queues HW statistics reversion Min Hu (Connor)
2022-05-03 19:05   ` Ferruh Yigit
2022-04-06  9:22 ` [PATCH 3/7] net/hns3: fix pseudo-sharing between threads Min Hu (Connor)
2022-05-03 19:05   ` Ferruh Yigit
2022-04-06  9:22 ` [PATCH 4/7] net/hns3: fix more mbufs are freed when Tx done cleanup Min Hu (Connor)
2022-04-06  9:22 ` [PATCH 5/7] net/hns3: fix RSS disable Min Hu (Connor)
2022-05-03 19:05   ` Ferruh Yigit
2022-04-06  9:22 ` [PATCH 6/7] net/hns3: fix undo rollback when update RSS hash Min Hu (Connor)
2022-04-06  9:22 ` [PATCH 7/7] net/hns3: remove redundant RSS tuple field Min Hu (Connor)
2022-05-03 19:06   ` Ferruh Yigit
2022-04-25  7:03 ` [PATCH 0/7] bugfix for hns3 PMD Min Hu (Connor)
2022-05-03 19:07 ` Ferruh Yigit
2022-05-05 12:27 ` [PATCH v2 " Min Hu (Connor)
2022-05-05 12:27   ` [PATCH v2 1/7] net/hns3: fix order of clearing imissed register in PF Min Hu (Connor)
2022-05-05 12:27   ` [PATCH v2 2/7] net/hns3: fix MAC and queues HW statistics overflow Min Hu (Connor)
2022-05-05 12:27   ` [PATCH v2 3/7] net/hns3: fix pseudo-sharing between threads Min Hu (Connor)
2022-05-05 12:27   ` [PATCH v2 4/7] net/hns3: fix more mbufs are freed when Tx done cleanup Min Hu (Connor)
2022-05-05 12:27   ` [PATCH v2 5/7] net/hns3: fix RSS disable Min Hu (Connor)
2022-05-05 12:27   ` [PATCH v2 6/7] net/hns3: fix undo rollback when update RSS hash Min Hu (Connor)
2022-05-05 12:27   ` [PATCH v2 7/7] net/hns3: remove redundant RSS tuple field Min Hu (Connor)
2022-05-12  9:51   ` [PATCH v2 0/7] bugfix for hns3 PMD Ferruh Yigit
2022-05-05 12:29 ` [PATCH " Min Hu (Connor)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220406092240.52900-2-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).