Skip to contentSkip to conversation

bugfix for hns3 PMD

PATCH Superseded Min Hu (Connor) 2 participants 24 messages Apr 6, 2022 – May 12, 2022 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover bugfix for hns3 PMD

This patch set contains 7 bugfix for hns3 PMD.

Chengwen Feng (1):
net/hns3: fix more mbufs are freed when Tx done cleanup

Huisong Li (6):
net/hns3: fix order of clearing imissed register in PF net/hns3: fix MAC and queues HW statistics reversion net/hns3: fix pseudo-sharing between threads net/hns3: fix RSS disable
net/hns3: fix undo rollback when update RSS hash net/hns3: remove redundant RSS tuple field

 drivers/net/hns3/hns3_ethdev.c    |  20 ++--
 drivers/net/hns3/hns3_ethdev.h    |   6 ++
 drivers/net/hns3/hns3_ethdev_vf.c |  20 ++--
 drivers/net/hns3/hns3_flow.c      |  10 +-
 drivers/net/hns3/hns3_rss.c       | 124 ++++++-----------------
 drivers/net/hns3/hns3_rss.h       |   5 +-
 drivers/net/hns3/hns3_rxtx.c      |   8 +-
 drivers/net/hns3/hns3_rxtx.h      |   4 +-
 drivers/net/hns3/hns3_stats.c     | 163 ++++++++++++++++++++++--------
 drivers/net/hns3/hns3_stats.h     |   6 +-
 10 files changed, 183 insertions(+), 183 deletions(-)
Signature · 1 line
2.33.0
#1 lore raw

PATCH 1/7 net/hns3: fix order of clearing imissed register in PF

From: Huisong Li <[email protected]>

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")
---
 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(-)
drivers/net/hns3/hns3_ethdev.c +3 -10
index 24ae5ef929..ee2c5d5a1a 100644
@@ -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);
drivers/net/hns3/hns3_ethdev_vf.c +3 -10
index e06a1a41dd..4f52f22776 100644
@@ -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,
drivers/net/hns3/hns3_stats.c +24 -3
index 806720faff..e4a5dcf2f8 100644
@@ -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);
+}
drivers/net/hns3/hns3_stats.h +2 -3
index c81d351082..e89dc97632 100644
@@ -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_ */
Signature · 1 line
2.33.0
#2 lore raw

PATCH 2/7 net/hns3: fix MAC and queues HW statistics reversion

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

The MAC and queues statistics aren't 64-bit registers in hardware. If hardware statistics are not obtained for a long time, these statistics will be reversed. So PF and VF driver have to periodically obtain and save these statistics. Since the periodical task and the stats API are in different threads, we introduce a statistics lock to protect the statistics.

Fixes 8839c5e202f3 ("net/hns3: support device stats")
---
 drivers/net/hns3/hns3_ethdev.c    |   6 +-
 drivers/net/hns3/hns3_ethdev.h    |   6 ++
 drivers/net/hns3/hns3_ethdev_vf.c |   6 +-
 drivers/net/hns3/hns3_stats.c     | 136 +++++++++++++++++++++---------
 drivers/net/hns3/hns3_stats.h     |   1 +
 5 files changed, 110 insertions(+), 45 deletions(-)
drivers/net/hns3/hns3_ethdev.c +4 -2
index ee2c5d5a1a..2d47088487 100644
@@ -4362,10 +4362,12 @@ hns3_service_handler(void *param)
 	struct hns3_adapter *hns = eth_dev->data->dev_private;
 	struct hns3_hw *hw = &hns->hw;
 
-	if (!hns3_is_reset_pending(hns))
+	if (!hns3_is_reset_pending(hns)) {
 		hns3_update_linkstatus_and_event(hw, true);
-	else
+		hns3_update_hw_stats(hw);
+	} else {
 		hns3_warn(hw, "Cancel the query when reset is pending");
+	}
 
 	rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev);
 }
drivers/net/hns3/hns3_ethdev.h +6 -0
index a00f841543..6a3dbae48e 100644
@@ -503,6 +503,12 @@ struct hns3_hw {
 	uint32_t mac_stats_reg_num;
 	struct hns3_rx_missed_stats imissed_stats;
 	uint64_t oerror_stats;
+	/*
+	 * The lock is used to protect statistics update in stats APIs and
+	 * periodic task.
+	 */
+	rte_spinlock_t stats_lock;
+
 	uint32_t fw_version;
 	uint16_t pf_vf_if_version;  /* version of communication interface */
 
drivers/net/hns3/hns3_ethdev_vf.c +4 -2
index 4f52f22776..589de0ab3a 100644
@@ -1335,10 +1335,12 @@ hns3vf_service_handler(void *param)
 	 * Before querying the link status, check whether there is a reset
 	 * pending, and if so, abandon the query.
 	 */
-	if (!hns3vf_is_reset_pending(hns))
+	if (!hns3vf_is_reset_pending(hns)) {
 		hns3vf_request_link_info(hw);
-	else
+		hns3_update_hw_stats(hw);
+	} else {
 		hns3_warn(hw, "Cancel the query when reset is pending");
+	}
 
 	rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler,
 			  eth_dev);
drivers/net/hns3/hns3_stats.c +95 -41

285 lines not on this page · raw message

drivers/net/hns3/hns3_stats.h +1 -0
index e89dc97632..b5cd6188b4 100644
@@ -164,5 +164,6 @@ int hns3_stats_reset(struct rte_eth_dev *dev);
 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);
+void hns3_update_hw_stats(struct hns3_hw *hw);
 
 #endif /* _HNS3_STATS_H_ */
Signature · 1 line
2.33.0
#3 lore raw

Re: [PATCH 2/7] net/hns3: fix MAC and queues HW statistics reversion

Quoted 5 lines · Min Hu (Connor)

From: Huisong Li <[email protected]>

The MAC and queues statistics aren't 64-bit registers in hardware. If hardware statistics are not obtained for a long time, these statistics will be reversed.

I think using 'overflow' instead of 'reversed' is more clear.

As far as I can see from code, these are 32 bit values, can be good to mention in the commit log.

Quoted 9 lines

So PF and VF driver have to periodically obtain and save these statistics. Since the periodical task and the stats API are in different threads, we introduce a statistics lock to protect the statistics.

Fixes 8839c5e202f3 ("net/hns3: support device stats")

<...>

drivers/net/hns3/hns3_stats.c hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) · line 632

Quoted 9 lines
drivers/net/hns3/hns3_stats.c +1 -1
@@ -604,16 +626,15 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
  	struct hns3_tqp_stats *stats = &hw->tqp_stats;
  	struct hns3_rx_queue *rxq;
  	struct hns3_tx_queue *txq;
-	uint64_t cnt;
  	uint16_t i;
  	int ret;
 
+	rte_spinlock_lock(&hw->stats_lock);

The lock covers most of the 'stats_get()' function, but only Rx/Tx queue stats needs to be protected, you may consider reducing the scope of the lock. Same for below functions.

<...>

drivers/net/hns3/hns3_stats.c hns3_dev_xstats_reset(struct rte_eth_dev *dev) · line 1475

Quoted 13 lines
drivers/net/hns3/hns3_stats.c +2 -0
@@ -1453,6 +1464,7 @@ int
  hns3_dev_xstats_reset(struct rte_eth_dev *dev)
  {
  	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_hw *hw = &hns->hw;
  	int ret;
 
  	/* Clear tqp stats */
@@ -1460,20 +1472,22 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev)
  	if (ret)
  		return ret;
 
+	rte_spinlock_unlock(&hw->stats_lock);

I guess this should be 'rte_spinlock_lock()'

#4 lore raw

PATCH 3/7 net/hns3: fix pseudo-sharing between threads

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

Some fields in the end of 'struct hns3_rx_queue' and 'struct hns3_tx_queue' are not accessed in the I/O path. But these fields may be accessed in other threads, which may lead to the problem of pseudo-sharing of IO threads. This patch add a cacheline alignment to avoid it.

Fixes 9261fd3caf1f ("net/hns3: improve IO path data cache usage")
---
 drivers/net/hns3/hns3_rxtx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_rxtx.h +2 -2
index a000318357..62efc854e4 100644
@@ -348,7 +348,7 @@ struct hns3_rx_queue {
 	 * The following fields are not accessed in the I/O path, so they are
 	 * placed at the end.
 	 */
-	void *io_base;
+	void *io_base __rte_cache_aligned;
 	struct hns3_adapter *hns;
 	uint64_t rx_ring_phys_addr; /* RX ring DMA address */
 	const struct rte_memzone *mz;
@@ -521,7 +521,7 @@ struct hns3_tx_queue {
 	 * The following fields are not accessed in the I/O path, so they are
 	 * placed at the end.
 	 */
-	void *io_base;
+	void *io_base __rte_cache_aligned;
 	struct hns3_adapter *hns;
 	uint64_t tx_ring_phys_addr; /* TX ring DMA address */
 	const struct rte_memzone *mz;
Signature · 1 line
2.33.0
#5 lore raw

Re: [PATCH 3/7] net/hns3: fix pseudo-sharing between threads

Quoted 5 lines · Min Hu (Connor)

From: Huisong Li <[email protected]>

Some fields in the end of 'struct hns3_rx_queue' and 'struct hns3_tx_queue' are not accessed in the I/O path. But these fields may be accessed in other threads, which may lead to the problem of pseudo-sharing of IO threads.

... problem of cache pseudo-sharing ...

Quoted 7 lines

This patch add a cacheline alignment to avoid it.

Fixes 9261fd3caf1f ("net/hns3: improve IO path data cache usage")

<...>

#6 lore raw

PATCH 4/7 net/hns3: fix more mbufs are freed when Tx done cleanup

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

Currently, the hns3 PMD may free more mbufs than free_cnt parameter, this is an incorrect implementation. This patch fixes it.

Fixes 0b77e8f3d364 ("net/hns3: optimize Tx performance")
---
 drivers/net/hns3/hns3_rxtx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/hns3/hns3_rxtx.c +4 -4
index a28de06dfd..0c91e4721e 100644
@@ -4595,7 +4595,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 static int
 hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt)
 {
-	uint16_t round_free_cnt;
+	uint16_t round_cnt;
 	uint32_t idx;
 
 	if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
@@ -4604,13 +4604,13 @@ hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt)
 	if (txq->tx_rs_thresh == 0)
 		return 0;
 
-	round_free_cnt = roundup(free_cnt, txq->tx_rs_thresh);
-	for (idx = 0; idx < round_free_cnt; idx += txq->tx_rs_thresh) {
+	round_cnt = rounddown(free_cnt, txq->tx_rs_thresh);
+	for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) {
 		if (hns3_tx_free_useless_buffer(txq) != 0)
 			break;
 	}
 
-	return RTE_MIN(idx, free_cnt);
+	return idx;
 }
 
 int
Signature · 1 line
2.33.0
#7 lore raw

PATCH 5/7 net/hns3: fix RSS disable

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

Currently, hns3 PMD disable RSS by resetting redirection table when user set rss_hf to 0 so as to all packets go to queue 0. The implementation may cause following problems:
1) the same type packet may go to different queue on the case of disableing all tuples and partial tuples. The problem is determined by hardware design.
2) affect the configuration of redirection table and user experience.

For hns3 hardware, the packets with RSS disabled are always go to the queue corresponding to first entry of the redirection table. Genernally, disable RSS should be implemented by disabling all tuples, This patch fix the implementation.

Fixes c37ca66f2b27 ("net/hns3: support RSS")
---
 drivers/net/hns3/hns3_ethdev.c    |  1 -
 drivers/net/hns3/hns3_ethdev_vf.c |  1 -
 drivers/net/hns3/hns3_flow.c      |  6 +-
 drivers/net/hns3/hns3_rss.c       | 93 ++++++-------------------------
 4 files changed, 18 insertions(+), 83 deletions(-)
drivers/net/hns3/hns3_ethdev.c +0 -1
index 2d47088487..0b565a5614 100644
@@ -2015,7 +2015,6 @@ hns3_dev_configure(struct rte_eth_dev *dev)
 			goto cfg_err;
 	}
 
-	/* When RSS is not configured, redirect the packet queue 0 */
 	if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
 		conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 		rss_conf = conf->rx_adv_conf.rss_conf;
drivers/net/hns3/hns3_ethdev_vf.c +0 -1
index 589de0ab3a..9ccce98d48 100644
@@ -492,7 +492,6 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
 		goto cfg_err;
 	}
 
-	/* When RSS is not configured, redirect the packet queue 0 */
 	if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
 		conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 		rss_conf = conf->rx_adv_conf.rss_conf;
drivers/net/hns3/hns3_flow.c +1 -5
index c5a37ee5eb..ed08e19656 100644
@@ -1446,14 +1446,10 @@ hns3_disable_rss(struct hns3_hw *hw)
 {
 	int ret;
 
-	/* Redirected the redirection table to queue 0 */
-	ret = hns3_rss_reset_indir_table(hw);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0);
 	if (ret)
 		return ret;
 
-	/* Disable RSS */
-	hw->rss_info.conf.types = 0;
-
 	return 0;
 }
 
drivers/net/hns3/hns3_rss.c +17 -76

141 lines not on this page · raw message

Signature · 1 line
2.33.0
#8 lore raw

Re: [PATCH 5/7] net/hns3: fix RSS disable

Quoted 6 lines · Min Hu (Connor)

From: Huisong Li <[email protected]>

Currently, hns3 PMD disable RSS by resetting redirection table when user set rss_hf to 0 so as to all packets go to queue 0. The implementation may cause following problems:
1) the same type packet may go to different queue on the case of disableing

typo, disabling

Quoted 6 lines

all tuples and partial tuples. The problem is determined by hardware design.
2) affect the configuration of redirection table and user experience.

For hns3 hardware, the packets with RSS disabled are always go to the queue corresponding to first entry of the redirection table. Genernally, disable

typo, generally

Quoted 3 lines

RSS should be implemented by disabling all tuples, This patch fix the implementation.

ack

Quoted 5 lines
Fixes c37ca66f2b27 ("net/hns3: support RSS")

<...>

#9 lore raw

PATCH 6/7 net/hns3: fix undo rollback when update RSS hash

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

The RSS tuple isn't restored when RSS key length is invalid or setting algo key failed. This patch fixes it.

Fixes c37ca66f2b27 ("net/hns3: support RSS")
---
 drivers/net/hns3/hns3_rss.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/net/hns3/hns3_rss.c +14 -11
index 087dc28f2d..d88227e4f0 100644
@@ -376,36 +376,39 @@ int
 hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 			 struct rte_eth_rss_conf *rss_conf)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_hw *hw = &hns->hw;
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
+	uint64_t rss_hf_bk = hw->rss_info.conf.types;
 	uint8_t key_len = rss_conf->rss_key_len;
 	uint64_t rss_hf = rss_conf->rss_hf;
 	uint8_t *key = rss_conf->rss_key;
 	int ret;
 
+	if (key && key_len != HNS3_RSS_KEY_SIZE) {
+		hns3_err(hw, "the hash key len(%u) is invalid, must be %u",
+			 key_len, HNS3_RSS_KEY_SIZE);
+		return -EINVAL;
+	}
+
 	rte_spinlock_lock(&hw->lock);
 	ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
 	if (ret)
-		goto conf_err;
+		goto set_tuple_fail;
 
 	if (key) {
-		if (key_len != HNS3_RSS_KEY_SIZE) {
-			hns3_err(hw, "The hash key len(%u) is invalid",
-				 key_len);
-			ret = -EINVAL;
-			goto conf_err;
-		}
 		ret = hns3_rss_set_algo_key(hw, key);
 		if (ret)
-			goto conf_err;
+			goto set_algo_key_fail;
 	}
 	rte_spinlock_unlock(&hw->lock);
 
 	return 0;
 
-conf_err:
+set_algo_key_fail:
+	(void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk);
+set_tuple_fail:
 	rte_spinlock_unlock(&hw->lock);
+
 	return ret;
 }
 
Signature · 1 line
2.33.0
#10 lore raw

PATCH 7/7 net/hns3: remove redundant RSS tuple field

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

The 'rss_tuple_fields' in struct struct hns3_rss_conf::rss_tuple_sets is redundant. Because the enabled RSS tuple in PMD is already managed by the 'types' in struct hns3_rss_conf::conf. This patch removes this rebundant variable.

Fixes c37ca66f2b27 ("net/hns3: support RSS")
---
 drivers/net/hns3/hns3_flow.c |  6 ++----
 drivers/net/hns3/hns3_rss.c  | 12 ++++--------
 drivers/net/hns3/hns3_rss.h  |  5 +----
 3 files changed, 7 insertions(+), 16 deletions(-)
drivers/net/hns3/hns3_flow.c +2 -4
index ed08e19656..86ebbf69b6 100644
@@ -1446,7 +1446,7 @@ hns3_disable_rss(struct hns3_hw *hw)
 {
 	int ret;
 
-	ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, 0);
 	if (ret)
 		return ret;
 
@@ -1495,7 +1495,6 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func,
 static int
 hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
 {
-	struct hns3_rss_tuple_cfg *tuple;
 	int ret;
 
 	hns3_adjust_rss_key(hw, rss_config);
@@ -1511,8 +1510,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
 
 	hw->rss_info.conf.func = rss_config->func;
 
-	tuple = &hw->rss_info.rss_tuple_sets;
-	ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_config->types);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_config->types);
 	if (ret)
 		hns3_err(hw, "Update RSS tuples by rss hf failed %d", ret);
 
drivers/net/hns3/hns3_rss.c +4 -8
index d88227e4f0..866ffd1a90 100644
@@ -310,8 +310,7 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw)
 }
 
 int
-hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
-			     struct hns3_rss_tuple_cfg *tuple, uint64_t rss_hf)
+hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf)
 {
 	struct hns3_rss_input_tuple_cmd *req;
 	struct hns3_cmd_desc desc;
@@ -356,7 +355,6 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
 		return ret;
 	}
 
-	tuple->rss_tuple_fields = rte_le_to_cpu_64(req->tuple_field);
 	/* Update supported flow types when set tuple success */
 	hw->rss_info.conf.types = rss_hf;
 
@@ -377,7 +375,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 			 struct rte_eth_rss_conf *rss_conf)
 {
 	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
 	uint64_t rss_hf_bk = hw->rss_info.conf.types;
 	uint8_t key_len = rss_conf->rss_key_len;
 	uint64_t rss_hf = rss_conf->rss_hf;
@@ -391,7 +388,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 	}
 
 	rte_spinlock_lock(&hw->lock);
-	ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_hf);
 	if (ret)
 		goto set_tuple_fail;
 
@@ -405,7 +402,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 	return 0;
 
 set_algo_key_fail:
-	(void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk);
+	(void)hns3_set_rss_tuple_by_rss_hf(hw, rss_hf_bk);
 set_tuple_fail:
 	rte_spinlock_unlock(&hw->lock);
 
@@ -697,8 +694,7 @@ hns3_config_rss(struct hns3_adapter *hns)
 	    !(rss_hf & HNS3_ETH_RSS_SUPPORT))
 		rss_hf = 0;
 
-	return hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets,
-					    rss_hf);
+	return hns3_set_rss_tuple_by_rss_hf(hw, rss_hf);
 }
 
 /*
drivers/net/hns3/hns3_rss.h +1 -4
index c4121207aa..55d5718ffc 100644
@@ -43,7 +43,6 @@ struct hns3_rss_conf {
 	struct rte_flow_action_rss conf;
 	uint8_t hash_algo; /* hash function type defined by hardware */
 	uint8_t key[HNS3_RSS_KEY_SIZE];  /* Hash key */
-	struct hns3_rss_tuple_cfg rss_tuple_sets;
 	uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
 	uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
 	bool valid; /* check if RSS rule is valid */
@@ -107,9 +106,7 @@ int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir,
 int hns3_rss_reset_indir_table(struct hns3_hw *hw);
 int hns3_config_rss(struct hns3_adapter *hns);
 void hns3_rss_uninit(struct hns3_adapter *hns);
-int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
-				 struct hns3_rss_tuple_cfg *tuple,
-				 uint64_t rss_hf);
+int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf);
 int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key);
 int hns3_restore_rss_filter(struct rte_eth_dev *dev);
 
Signature · 1 line
2.33.0
#11 lore raw

Re: [PATCH 7/7] net/hns3: remove redundant RSS tuple field

Quoted 5 lines · Min Hu (Connor)

From: Huisong Li <[email protected]>

The 'rss_tuple_fields' in struct struct hns3_rss_conf::rss_tuple_sets is redundant. Because the enabled RSS tuple in PMD is already managed by the 'types' in struct hns3_rss_conf::conf. This patch removes this rebundant

typo, redundant

Quoted 7 lines

variable.

Fixes c37ca66f2b27 ("net/hns3: support RSS")

<...>

#12 lore raw
In reply to Min Hu (Connor)

Hi, Ferruh,
what do you think of this set of patches?

Quoted 25 lines · Min Hu (Connor)

This patch set contains 7 bugfix for hns3 PMD.

Chengwen Feng (1):
net/hns3: fix more mbufs are freed when Tx done cleanup

Huisong Li (6):
net/hns3: fix order of clearing imissed register in PF net/hns3: fix MAC and queues HW statistics reversion net/hns3: fix pseudo-sharing between threads net/hns3: fix RSS disable
net/hns3: fix undo rollback when update RSS hash net/hns3: remove redundant RSS tuple field

  drivers/net/hns3/hns3_ethdev.c    |  20 ++--
  drivers/net/hns3/hns3_ethdev.h    |   6 ++
  drivers/net/hns3/hns3_ethdev_vf.c |  20 ++--
  drivers/net/hns3/hns3_flow.c      |  10 +-
  drivers/net/hns3/hns3_rss.c       | 124 ++++++-----------------
  drivers/net/hns3/hns3_rss.h       |   5 +-
  drivers/net/hns3/hns3_rxtx.c      |   8 +-
  drivers/net/hns3/hns3_rxtx.h      |   4 +-
  drivers/net/hns3/hns3_stats.c     | 163 ++++++++++++++++++++++--------
  drivers/net/hns3/hns3_stats.h     |   6 +-
  10 files changed, 183 insertions(+), 183 deletions(-)
#13 lore raw
In reply to Min Hu (Connor)
Quoted 5 lines · Min Hu (Connor)

This patch set contains 7 bugfix for hns3 PMD.

Chengwen Feng (1):
net/hns3: fix more mbufs are freed when Tx done cleanup

Quoted 8 lines

Huisong Li (6):
net/hns3: fix order of clearing imissed register in PF net/hns3: fix MAC and queues HW statistics reversion net/hns3: fix pseudo-sharing between threads net/hns3: fix RSS disable
net/hns3: fix undo rollback when update RSS hash net/hns3: remove redundant RSS tuple field

Hi Connor,

I need to resolve some conflicts while merging this set, I assume it is based on another patch, can you please document it in cover letter next time.

Also I can see CI had same issue, to enable CI to check the patch, each set should be send on top of latest next-net, so the CI can apply them. There is a defined 'Depends-on:' keyword [1] for commit log, but as far as I know CI not implemented it yet.

[1]
https://doc.dpdk.org/guides/contributing/patches.html#patch-dependencies

#14 lore raw

v2 cover bugfix for hns3 PMD

In reply to Min Hu (Connor)

This patch set contains 7 bugfix for hns3 PMD.

Chengwen Feng (1):
net/hns3: fix more mbufs are freed when Tx done cleanup

Huisong Li (6):
net/hns3: fix order of clearing imissed register in PF net/hns3: fix MAC and queues HW statistics overflow net/hns3: fix pseudo-sharing between threads net/hns3: fix RSS disable
net/hns3: fix undo rollback when update RSS hash net/hns3: remove redundant RSS tuple field

 drivers/net/hns3/hns3_ethdev.c    |  20 ++--
 drivers/net/hns3/hns3_ethdev.h    |   6 ++
 drivers/net/hns3/hns3_ethdev_vf.c |  19 ++--
 drivers/net/hns3/hns3_flow.c      |  10 +-
 drivers/net/hns3/hns3_rss.c       | 123 ++++++---------------
 drivers/net/hns3/hns3_rss.h       |   5 +-
 drivers/net/hns3/hns3_rxtx.c      |   8 +-
 drivers/net/hns3/hns3_rxtx.h      |   4 +-
 drivers/net/hns3/hns3_stats.c     | 171 ++++++++++++++++++++++--------
 drivers/net/hns3/hns3_stats.h     |   6 +-
 10 files changed, 188 insertions(+), 184 deletions(-)

---
v2:
* fix some comments about usage of spin lock and typo.

Signature · 1 line
2.33.0
#15 lore raw

PATCH v2 1/7 net/hns3: fix order of clearing imissed register in PF

From: Huisong Li <[email protected]>

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")
---
 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(-)
drivers/net/hns3/hns3_ethdev.c +3 -10
index 4e089e682f..5aed7046d8 100644
@@ -4622,13 +4622,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,
@@ -4654,7 +4647,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;
 
@@ -4700,7 +4693,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);
@@ -4734,7 +4727,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);
drivers/net/hns3/hns3_ethdev_vf.c +3 -10
index 9091706fe5..9e9fdc4144 100644
@@ -1510,17 +1510,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);
@@ -1548,7 +1541,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);
@@ -1579,7 +1572,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,
drivers/net/hns3/hns3_stats.c +24 -3
index 806720faff..e4a5dcf2f8 100644
@@ -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);
+}
drivers/net/hns3/hns3_stats.h +2 -3
index c81d351082..e89dc97632 100644
@@ -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_ */
Signature · 1 line
2.33.0
#16 lore raw

PATCH v2 2/7 net/hns3: fix MAC and queues HW statistics overflow

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

The MAC and queues statistics are 32-bit registers in hardware. If hardware statistics are not obtained for a long time, these statistics will be overflow. So PF and VF driver have to periodically obtain and save these statistics. Since the periodical task and the stats API are in different threads, we introduce a statistics lock to protect the statistics.

Fixes 8839c5e202f3 ("net/hns3: support device stats")
---
 drivers/net/hns3/hns3_ethdev.c    |   6 +-
 drivers/net/hns3/hns3_ethdev.h    |   6 ++
 drivers/net/hns3/hns3_ethdev_vf.c |   6 +-
 drivers/net/hns3/hns3_stats.c     | 144 +++++++++++++++++++++---------
 drivers/net/hns3/hns3_stats.h     |   1 +
 5 files changed, 116 insertions(+), 47 deletions(-)
drivers/net/hns3/hns3_ethdev.c +4 -2
index 5aed7046d8..1d9b19d83e 100644
@@ -4364,10 +4364,12 @@ hns3_service_handler(void *param)
 	struct hns3_adapter *hns = eth_dev->data->dev_private;
 	struct hns3_hw *hw = &hns->hw;
 
-	if (!hns3_is_reset_pending(hns))
+	if (!hns3_is_reset_pending(hns)) {
 		hns3_update_linkstatus_and_event(hw, true);
-	else
+		hns3_update_hw_stats(hw);
+	} else {
 		hns3_warn(hw, "Cancel the query when reset is pending");
+	}
 
 	rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev);
 }
drivers/net/hns3/hns3_ethdev.h +6 -0
index 9a0fa09b57..56f2cdd2cd 100644
@@ -503,6 +503,12 @@ struct hns3_hw {
 	uint32_t mac_stats_reg_num;
 	struct hns3_rx_missed_stats imissed_stats;
 	uint64_t oerror_stats;
+	/*
+	 * The lock is used to protect statistics update in stats APIs and
+	 * periodic task.
+	 */
+	rte_spinlock_t stats_lock;
+
 	uint32_t fw_version;
 	uint16_t pf_vf_if_version;  /* version of communication interface */
 
drivers/net/hns3/hns3_ethdev_vf.c +4 -2
index 9e9fdc4144..f641e0dc36 100644
@@ -1337,10 +1337,12 @@ hns3vf_service_handler(void *param)
 	 * Before querying the link status, check whether there is a reset
 	 * pending, and if so, abandon the query.
 	 */
-	if (!hns3vf_is_reset_pending(hns))
+	if (!hns3vf_is_reset_pending(hns)) {
 		hns3vf_request_link_info(hw);
-	else
+		hns3_update_hw_stats(hw);
+	} else {
 		hns3_warn(hw, "Cancel the query when reset is pending");
+	}
 
 	rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler,
 			  eth_dev);
drivers/net/hns3/hns3_stats.c +101 -43

312 lines not on this page · raw message

drivers/net/hns3/hns3_stats.h +1 -0
index e89dc97632..b5cd6188b4 100644
@@ -164,5 +164,6 @@ int hns3_stats_reset(struct rte_eth_dev *dev);
 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);
+void hns3_update_hw_stats(struct hns3_hw *hw);
 
 #endif /* _HNS3_STATS_H_ */
Signature · 1 line
2.33.0
#17 lore raw

PATCH v2 3/7 net/hns3: fix pseudo-sharing between threads

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

Some fields in the end of 'struct hns3_rx_queue' and 'struct hns3_tx_queue' are not accessed in the I/O path. But these fields may be accessed in other threads, which may lead to the problem of cache pseudo-sharing of IO threads. This patch add a cacheline alignment to avoid it.

Fixes 9261fd3caf1f ("net/hns3: improve IO path data cache usage")
---
 drivers/net/hns3/hns3_rxtx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hns3/hns3_rxtx.h +2 -2
index a000318357..62efc854e4 100644
@@ -348,7 +348,7 @@ struct hns3_rx_queue {
 	 * The following fields are not accessed in the I/O path, so they are
 	 * placed at the end.
 	 */
-	void *io_base;
+	void *io_base __rte_cache_aligned;
 	struct hns3_adapter *hns;
 	uint64_t rx_ring_phys_addr; /* RX ring DMA address */
 	const struct rte_memzone *mz;
@@ -521,7 +521,7 @@ struct hns3_tx_queue {
 	 * The following fields are not accessed in the I/O path, so they are
 	 * placed at the end.
 	 */
-	void *io_base;
+	void *io_base __rte_cache_aligned;
 	struct hns3_adapter *hns;
 	uint64_t tx_ring_phys_addr; /* TX ring DMA address */
 	const struct rte_memzone *mz;
Signature · 1 line
2.33.0
#18 lore raw

PATCH v2 4/7 net/hns3: fix more mbufs are freed when Tx done cleanup

In reply to Min Hu (Connor)

From: Chengwen Feng <[email protected]>

Currently, the hns3 PMD may free more mbufs than free_cnt parameter, this is an incorrect implementation. This patch fixes it.

Fixes 0b77e8f3d364 ("net/hns3: optimize Tx performance")
---
 drivers/net/hns3/hns3_rxtx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/hns3/hns3_rxtx.c +4 -4
index a28de06dfd..0c91e4721e 100644
@@ -4595,7 +4595,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 static int
 hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt)
 {
-	uint16_t round_free_cnt;
+	uint16_t round_cnt;
 	uint32_t idx;
 
 	if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
@@ -4604,13 +4604,13 @@ hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt)
 	if (txq->tx_rs_thresh == 0)
 		return 0;
 
-	round_free_cnt = roundup(free_cnt, txq->tx_rs_thresh);
-	for (idx = 0; idx < round_free_cnt; idx += txq->tx_rs_thresh) {
+	round_cnt = rounddown(free_cnt, txq->tx_rs_thresh);
+	for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) {
 		if (hns3_tx_free_useless_buffer(txq) != 0)
 			break;
 	}
 
-	return RTE_MIN(idx, free_cnt);
+	return idx;
 }
 
 int
Signature · 1 line
2.33.0
#19 lore raw

PATCH v2 5/7 net/hns3: fix RSS disable

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

Currently, hns3 PMD disable RSS by resetting redirection table when user set rss_hf to 0 so as to all packets go to queue 0. The implementation may cause following problems:
1) the same type packet may go to different queue on the case of disabling all tuples and partial tuples. The problem is determined by hardware design.
2) affect the configuration of redirection table and user experience.

For hns3 hardware, the packets with RSS disabled are always go to the queue corresponding to first entry of the redirection table. Generally, disable RSS should be implemented by disabling all tuples, This patch fix the implementation.

Fixes c37ca66f2b27 ("net/hns3: support RSS")
---
 drivers/net/hns3/hns3_ethdev.c |  1 -
 drivers/net/hns3/hns3_flow.c   |  6 +--
 drivers/net/hns3/hns3_rss.c    | 93 +++++++---------------------------
 3 files changed, 18 insertions(+), 82 deletions(-)
drivers/net/hns3/hns3_ethdev.c +0 -1
index 1d9b19d83e..4d5a595aab 100644
@@ -2015,7 +2015,6 @@ hns3_dev_configure(struct rte_eth_dev *dev)
 			goto cfg_err;
 	}
 
-	/* When RSS is not configured, redirect the packet queue 0 */
 	if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) {
 		conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
 		rss_conf = conf->rx_adv_conf.rss_conf;
drivers/net/hns3/hns3_flow.c +1 -5
index aba07aaa6f..feabac9f41 100644
@@ -1446,13 +1446,9 @@ hns3_disable_rss(struct hns3_hw *hw)
 {
 	int ret;
 
-	/* Redirected the redirection table to queue 0 */
-	ret = hns3_rss_reset_indir_table(hw);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0);
 	if (ret)
 		return ret;
-
-	/* Disable RSS */
-	hw->rss_info.conf.types = 0;
 	hw->rss_dis_flag = true;
 
 	return 0;
drivers/net/hns3/hns3_rss.c +17 -76

141 lines not on this page · raw message

Signature · 1 line
2.33.0
#20 lore raw

PATCH v2 6/7 net/hns3: fix undo rollback when update RSS hash

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

The RSS tuple isn't restored when RSS key length is invalid or setting algo key failed. This patch fixes it.

Fixes c37ca66f2b27 ("net/hns3: support RSS")
---
 drivers/net/hns3/hns3_rss.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/net/hns3/hns3_rss.c +13 -11
index 1c703952b9..4b2c24ace4 100644
@@ -376,9 +376,9 @@ int
 hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 			 struct rte_eth_rss_conf *rss_conf)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_hw *hw = &hns->hw;
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
+	uint64_t rss_hf_bk = hw->rss_info.conf.types;
 	uint8_t key_len = rss_conf->rss_key_len;
 	uint64_t rss_hf = rss_conf->rss_hf;
 	uint8_t *key = rss_conf->rss_key;
@@ -387,27 +387,29 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 	if (hw->rss_dis_flag)
 		return -EINVAL;
 
+	if (key && key_len != HNS3_RSS_KEY_SIZE) {
+		hns3_err(hw, "the hash key len(%u) is invalid, must be %u",
+			 key_len, HNS3_RSS_KEY_SIZE);
+		return -EINVAL;
+	}
+
 	rte_spinlock_lock(&hw->lock);
 	ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
 	if (ret)
-		goto conf_err;
+		goto set_tuple_fail;
 
 	if (key) {
-		if (key_len != HNS3_RSS_KEY_SIZE) {
-			hns3_err(hw, "The hash key len(%u) is invalid",
-				 key_len);
-			ret = -EINVAL;
-			goto conf_err;
-		}
 		ret = hns3_rss_set_algo_key(hw, key);
 		if (ret)
-			goto conf_err;
+			goto set_algo_key_fail;
 	}
 	rte_spinlock_unlock(&hw->lock);
 
 	return 0;
 
-conf_err:
+set_algo_key_fail:
+	(void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk);
+set_tuple_fail:
 	rte_spinlock_unlock(&hw->lock);
 	return ret;
 }
Signature · 1 line
2.33.0
#21 lore raw

PATCH v2 7/7 net/hns3: remove redundant RSS tuple field

In reply to Min Hu (Connor)

From: Huisong Li <[email protected]>

The 'rss_tuple_fields' in struct struct hns3_rss_conf::rss_tuple_sets is redundant. Because the enabled RSS tuple in PMD is already managed by the 'types' in struct hns3_rss_conf::conf. This patch removes this redundant variable.

Fixes c37ca66f2b27 ("net/hns3: support RSS")
---
 drivers/net/hns3/hns3_flow.c |  6 ++----
 drivers/net/hns3/hns3_rss.c  | 12 ++++--------
 drivers/net/hns3/hns3_rss.h  |  5 +----
 3 files changed, 7 insertions(+), 16 deletions(-)
drivers/net/hns3/hns3_flow.c +2 -4
index feabac9f41..317f91fc71 100644
@@ -1446,7 +1446,7 @@ hns3_disable_rss(struct hns3_hw *hw)
 {
 	int ret;
 
-	ret = hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets, 0);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, 0);
 	if (ret)
 		return ret;
 	hw->rss_dis_flag = true;
@@ -1496,7 +1496,6 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func,
 static int
 hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
 {
-	struct hns3_rss_tuple_cfg *tuple;
 	int ret;
 
 	hns3_adjust_rss_key(hw, rss_config);
@@ -1512,8 +1511,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
 
 	hw->rss_info.conf.func = rss_config->func;
 
-	tuple = &hw->rss_info.rss_tuple_sets;
-	ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_config->types);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_config->types);
 	if (ret)
 		hns3_err(hw, "Update RSS tuples by rss hf failed %d", ret);
 
drivers/net/hns3/hns3_rss.c +4 -8
index 4b2c24ace4..e149c16bfe 100644
@@ -310,8 +310,7 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw)
 }
 
 int
-hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
-			     struct hns3_rss_tuple_cfg *tuple, uint64_t rss_hf)
+hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf)
 {
 	struct hns3_rss_input_tuple_cmd *req;
 	struct hns3_cmd_desc desc;
@@ -356,7 +355,6 @@ hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
 		return ret;
 	}
 
-	tuple->rss_tuple_fields = rte_le_to_cpu_64(req->tuple_field);
 	/* Update supported flow types when set tuple success */
 	hw->rss_info.conf.types = rss_hf;
 
@@ -377,7 +375,6 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 			 struct rte_eth_rss_conf *rss_conf)
 {
 	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
 	uint64_t rss_hf_bk = hw->rss_info.conf.types;
 	uint8_t key_len = rss_conf->rss_key_len;
 	uint64_t rss_hf = rss_conf->rss_hf;
@@ -394,7 +391,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 	}
 
 	rte_spinlock_lock(&hw->lock);
-	ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
+	ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_hf);
 	if (ret)
 		goto set_tuple_fail;
 
@@ -408,7 +405,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
 	return 0;
 
 set_algo_key_fail:
-	(void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk);
+	(void)hns3_set_rss_tuple_by_rss_hf(hw, rss_hf_bk);
 set_tuple_fail:
 	rte_spinlock_unlock(&hw->lock);
 	return ret;
@@ -699,8 +696,7 @@ hns3_config_rss(struct hns3_adapter *hns)
 	    !(rss_hf & HNS3_ETH_RSS_SUPPORT))
 		rss_hf = 0;
 
-	return hns3_set_rss_tuple_by_rss_hf(hw, &hw->rss_info.rss_tuple_sets,
-					    rss_hf);
+	return hns3_set_rss_tuple_by_rss_hf(hw, rss_hf);
 }
 
 /*
drivers/net/hns3/hns3_rss.h +1 -4
index c4121207aa..55d5718ffc 100644
@@ -43,7 +43,6 @@ struct hns3_rss_conf {
 	struct rte_flow_action_rss conf;
 	uint8_t hash_algo; /* hash function type defined by hardware */
 	uint8_t key[HNS3_RSS_KEY_SIZE];  /* Hash key */
-	struct hns3_rss_tuple_cfg rss_tuple_sets;
 	uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
 	uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
 	bool valid; /* check if RSS rule is valid */
@@ -107,9 +106,7 @@ int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir,
 int hns3_rss_reset_indir_table(struct hns3_hw *hw);
 int hns3_config_rss(struct hns3_adapter *hns);
 void hns3_rss_uninit(struct hns3_adapter *hns);
-int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
-				 struct hns3_rss_tuple_cfg *tuple,
-				 uint64_t rss_hf);
+int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, uint64_t rss_hf);
 int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key);
 int hns3_restore_rss_filter(struct rte_eth_dev *dev);
 
Signature · 1 line
2.33.0
#22 lore raw
In reply to Min Hu (Connor)
Quoted 5 lines · Min Hu (Connor)

This patch set contains 7 bugfix for hns3 PMD.

Chengwen Feng (1):
net/hns3: fix more mbufs are freed when Tx done cleanup

Quoted 8 lines

Huisong Li (6):
net/hns3: fix order of clearing imissed register in PF net/hns3: fix MAC and queues HW statistics overflow net/hns3: fix pseudo-sharing between threads net/hns3: fix RSS disable
net/hns3: fix undo rollback when update RSS hash net/hns3: remove redundant RSS tuple field

Series applied to dpdk-next-net/main, thanks.

#23 lore raw
In reply to Min Hu (Connor)

Hi, Ferruh,
v2 has been sent, thanks.

Quoted 25 lines · Min Hu (Connor)

This patch set contains 7 bugfix for hns3 PMD.

Chengwen Feng (1):
net/hns3: fix more mbufs are freed when Tx done cleanup

Huisong Li (6):
net/hns3: fix order of clearing imissed register in PF net/hns3: fix MAC and queues HW statistics reversion net/hns3: fix pseudo-sharing between threads net/hns3: fix RSS disable
net/hns3: fix undo rollback when update RSS hash net/hns3: remove redundant RSS tuple field

  drivers/net/hns3/hns3_ethdev.c    |  20 ++--
  drivers/net/hns3/hns3_ethdev.h    |   6 ++
  drivers/net/hns3/hns3_ethdev_vf.c |  20 ++--
  drivers/net/hns3/hns3_flow.c      |  10 +-
  drivers/net/hns3/hns3_rss.c       | 124 ++++++-----------------
  drivers/net/hns3/hns3_rss.h       |   5 +-
  drivers/net/hns3/hns3_rxtx.c      |   8 +-
  drivers/net/hns3/hns3_rxtx.h      |   4 +-
  drivers/net/hns3/hns3_stats.c     | 163 ++++++++++++++++++++++--------
  drivers/net/hns3/hns3_stats.h     |   6 +-
  10 files changed, 183 insertions(+), 183 deletions(-)