patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 21.11 0/4] net/hns3: backporting some bugfix
@ 2022-11-02  2:32 Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 1/4] net/hns3: extract functions to create RSS and FDIR flow rule Huisong Li
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Huisong Li @ 2022-11-02  2:32 UTC (permalink / raw)
  To: stable, ktraynor; +Cc: liudongdong3, huangdaode, lihuisong

Backporting some hns3 bugfix.
The patch2/4 and patch4/4 depand on patch1/4 and patch3/4, respectively.

Huisong Li (4):
  net/hns3: extract functions to create RSS and FDIR flow rule
  net/hns3: fix RSS rule restore
  net/hns3: fix lock protection of RSS flow rule
  net/hns3: fix restore filter function input

 drivers/net/hns3/hns3_ethdev.c    |   3 +-
 drivers/net/hns3/hns3_ethdev_vf.c |   3 +-
 drivers/net/hns3/hns3_flow.c      | 236 +++++++++++++++++-------------
 drivers/net/hns3/hns3_flow.h      |   2 +-
 4 files changed, 136 insertions(+), 108 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 21.11 1/4] net/hns3: extract functions to create RSS and FDIR flow rule
  2022-11-02  2:32 [PATCH 21.11 0/4] net/hns3: backporting some bugfix Huisong Li
@ 2022-11-02  2:32 ` Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 2/4] net/hns3: fix RSS rule restore Huisong Li
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Huisong Li @ 2022-11-02  2:32 UTC (permalink / raw)
  To: stable, ktraynor; +Cc: liudongdong3, huangdaode, lihuisong

[ upstream commit c48499171f5df62a71697dce517b9fa22bc30985 ]

Extract two functions to create the RSS and FDIR flow rule for clearer
code logic.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_flow.c | 173 +++++++++++++++++++++--------------
 1 file changed, 106 insertions(+), 67 deletions(-)

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index b55cbb89e3..1bb04167f3 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1717,6 +1717,105 @@ hns3_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	return hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error);
 }
 
+static int
+hns3_flow_create_rss_rule(struct rte_eth_dev *dev,
+			  const struct rte_flow_action *act,
+			  struct rte_flow *flow)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_rss_conf_ele *rss_filter_ptr;
+	const struct hns3_rss_conf *rss_conf;
+	int ret;
+
+	rss_filter_ptr = rte_zmalloc("hns3 rss filter",
+				     sizeof(struct hns3_rss_conf_ele), 0);
+	if (rss_filter_ptr == NULL) {
+		hns3_err(hw, "failed to allocate hns3_rss_filter memory");
+		return -ENOMEM;
+	}
+
+	/*
+	 * After all the preceding tasks are successfully configured, configure
+	 * rules to the hardware to simplify the rollback of rules in the
+	 * hardware.
+	 */
+	rss_conf = (const struct hns3_rss_conf *)act->conf;
+	ret = hns3_flow_parse_rss(dev, rss_conf, true);
+	if (ret != 0) {
+		rte_free(rss_filter_ptr);
+		return ret;
+	}
+
+	hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf);
+	rss_filter_ptr->filter_info.valid = true;
+	TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries);
+	flow->rule = rss_filter_ptr;
+	flow->filter_type = RTE_ETH_FILTER_HASH;
+
+	return 0;
+}
+
+static int
+hns3_flow_create_fdir_rule(struct rte_eth_dev *dev,
+			   const struct rte_flow_item pattern[],
+			   const struct rte_flow_action actions[],
+			   struct rte_flow_error *error,
+			   struct rte_flow *flow)
+{
+	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+	struct hns3_fdir_rule_ele *fdir_rule_ptr;
+	struct hns3_fdir_rule fdir_rule;
+	int ret;
+
+	memset(&fdir_rule, 0, sizeof(struct hns3_fdir_rule));
+	ret = hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error);
+	if (ret != 0)
+		return ret;
+
+	if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) {
+		ret = hns3_counter_new(dev, 0,
+				       fdir_rule.act_cnt.id, error);
+		if (ret != 0)
+			return ret;
+
+		flow->counter_id = fdir_rule.act_cnt.id;
+	}
+
+	fdir_rule_ptr = rte_zmalloc("hns3 fdir rule",
+				    sizeof(struct hns3_fdir_rule_ele), 0);
+	if (fdir_rule_ptr == NULL) {
+		hns3_err(hw, "failed to allocate fdir_rule memory.");
+		ret = -ENOMEM;
+		goto err_malloc;
+	}
+
+	/*
+	 * After all the preceding tasks are successfully configured, configure
+	 * rules to the hardware to simplify the rollback of rules in the
+	 * hardware.
+	 */
+	ret = hns3_fdir_filter_program(hns, &fdir_rule, false);
+	if (ret != 0)
+		goto err_fdir_filter;
+
+	memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule,
+		sizeof(struct hns3_fdir_rule));
+	TAILQ_INSERT_TAIL(&hw->flow_fdir_list, fdir_rule_ptr, entries);
+	flow->rule = fdir_rule_ptr;
+	flow->filter_type = RTE_ETH_FILTER_FDIR;
+
+	return 0;
+
+err_fdir_filter:
+	rte_free(fdir_rule_ptr);
+err_malloc:
+	if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER)
+		hns3_counter_release(dev, fdir_rule.act_cnt.id);
+
+	return ret;
+}
+
 /*
  * Create or destroy a flow rule.
  * Theorically one rule can match more than one filters.
@@ -1731,13 +1830,9 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 {
 	struct hns3_adapter *hns = dev->data->dev_private;
 	struct hns3_hw *hw = &hns->hw;
-	const struct hns3_rss_conf *rss_conf;
-	struct hns3_fdir_rule_ele *fdir_rule_ptr;
-	struct hns3_rss_conf_ele *rss_filter_ptr;
 	struct hns3_flow_mem *flow_node;
 	const struct rte_flow_action *act;
 	struct rte_flow *flow;
-	struct hns3_fdir_rule fdir_rule;
 	int ret;
 
 	ret = hns3_flow_validate(dev, attr, pattern, actions, error);
@@ -1763,76 +1858,20 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	TAILQ_INSERT_TAIL(&hw->flow_list, flow_node, entries);
 
 	act = hns3_find_rss_general_action(pattern, actions);
-	if (act) {
-		rss_conf = act->conf;
-
-		ret = hns3_flow_parse_rss(dev, rss_conf, true);
-		if (ret)
-			goto err;
-
-		rss_filter_ptr = rte_zmalloc("hns3 rss filter",
-					     sizeof(struct hns3_rss_conf_ele),
-					     0);
-		if (rss_filter_ptr == NULL) {
-			hns3_err(hw,
-				    "Failed to allocate hns3_rss_filter memory");
-			ret = -ENOMEM;
-			goto err;
-		}
-		hns3_rss_conf_copy(&rss_filter_ptr->filter_info,
-				   &rss_conf->conf);
-		rss_filter_ptr->filter_info.valid = true;
-		TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries);
-
-		flow->rule = rss_filter_ptr;
-		flow->filter_type = RTE_ETH_FILTER_HASH;
-		return flow;
-	}
-
-	memset(&fdir_rule, 0, sizeof(struct hns3_fdir_rule));
-	ret = hns3_parse_fdir_filter(dev, pattern, actions, &fdir_rule, error);
-	if (ret)
-		goto out;
-
-	if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) {
-		ret = hns3_counter_new(dev, 0, fdir_rule.act_cnt.id, error);
-		if (ret)
-			goto out;
-
-		flow->counter_id = fdir_rule.act_cnt.id;
-	}
-
-	fdir_rule_ptr = rte_zmalloc("hns3 fdir rule",
-				    sizeof(struct hns3_fdir_rule_ele),
-				    0);
-	if (fdir_rule_ptr == NULL) {
-		hns3_err(hw, "failed to allocate fdir_rule memory.");
-		ret = -ENOMEM;
-		goto err_fdir;
-	}
-
-	ret = hns3_fdir_filter_program(hns, &fdir_rule, false);
-	if (!ret) {
-		memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule,
-			sizeof(struct hns3_fdir_rule));
-		TAILQ_INSERT_TAIL(&hw->flow_fdir_list, fdir_rule_ptr, entries);
-		flow->rule = fdir_rule_ptr;
-		flow->filter_type = RTE_ETH_FILTER_FDIR;
-
+	if (act)
+		ret = hns3_flow_create_rss_rule(dev, act, flow);
+	else
+		ret = hns3_flow_create_fdir_rule(dev, pattern, actions,
+						 error, flow);
+	if (ret == 0)
 		return flow;
-	}
 
-	rte_free(fdir_rule_ptr);
-err_fdir:
-	if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER)
-		hns3_counter_release(dev, fdir_rule.act_cnt.id);
-err:
 	rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 			   "Failed to create flow");
-out:
 	TAILQ_REMOVE(&hw->flow_list, flow_node, entries);
 	rte_free(flow_node);
 	rte_free(flow);
+
 	return NULL;
 }
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 21.11 2/4] net/hns3: fix RSS rule restore
  2022-11-02  2:32 [PATCH 21.11 0/4] net/hns3: backporting some bugfix Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 1/4] net/hns3: extract functions to create RSS and FDIR flow rule Huisong Li
@ 2022-11-02  2:32 ` Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 3/4] net/hns3: fix lock protection of RSS flow rule Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 4/4] net/hns3: fix restore filter function input Huisong Li
  3 siblings, 0 replies; 5+ messages in thread
From: Huisong Li @ 2022-11-02  2:32 UTC (permalink / raw)
  To: stable, ktraynor; +Cc: liudongdong3, huangdaode, lihuisong

[ upstream commit 0d81da25597a51519c1a085417fdfe2071183599 ]

The 'hns3_restore_rss_filter' function is used to restore RSS rule.
But this function calls the 'hns3_config_rss_filter' which sets the
last to invalid in flow RSS list. This causes the flow RSS list has
no valid rule.

Fixes: ec674cb742e5 ("net/hns3: fix flushing RSS rule")

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

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 1bb04167f3..25af8d3976 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1492,7 +1492,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
 		       const struct hns3_rss_conf *conf, bool add)
 {
 	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_rss_conf_ele *rss_filter_ptr;
 	struct hns3_hw *hw = &hns->hw;
 	struct hns3_rss_conf *rss_info;
 	uint64_t flow_types;
@@ -1569,13 +1568,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
 		goto rss_config_err;
 	}
 
-	/*
-	 * When create a new RSS rule, the old rule will be overlaid and set
-	 * invalid.
-	 */
-	TAILQ_FOREACH(rss_filter_ptr, &hw->flow_rss_list, entries)
-		rss_filter_ptr->filter_info.valid = false;
-
 rss_config_err:
 	rte_spinlock_unlock(&hw->lock);
 
@@ -1724,6 +1716,7 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev,
 {
 	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct hns3_rss_conf_ele *rss_filter_ptr;
+	struct hns3_rss_conf_ele *filter_ptr;
 	const struct hns3_rss_conf *rss_conf;
 	int ret;
 
@@ -1748,6 +1741,14 @@ hns3_flow_create_rss_rule(struct rte_eth_dev *dev,
 
 	hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf);
 	rss_filter_ptr->filter_info.valid = true;
+
+	/*
+	 * When create a new RSS rule, the old rule will be overlaid and set
+	 * invalid.
+	 */
+	TAILQ_FOREACH(filter_ptr, &hw->flow_rss_list, entries)
+		filter_ptr->filter_info.valid = false;
+
 	TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries);
 	flow->rule = rss_filter_ptr;
 	flow->filter_type = RTE_ETH_FILTER_HASH;
-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 21.11 3/4] net/hns3: fix lock protection of RSS flow rule
  2022-11-02  2:32 [PATCH 21.11 0/4] net/hns3: backporting some bugfix Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 1/4] net/hns3: extract functions to create RSS and FDIR flow rule Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 2/4] net/hns3: fix RSS rule restore Huisong Li
@ 2022-11-02  2:32 ` Huisong Li
  2022-11-02  2:32 ` [PATCH 21.11 4/4] net/hns3: fix restore filter function input Huisong Li
  3 siblings, 0 replies; 5+ messages in thread
From: Huisong Li @ 2022-11-02  2:32 UTC (permalink / raw)
  To: stable, ktraynor; +Cc: liudongdong3, huangdaode, lihuisong

[ upstream commit a35799625e6849151f7d7bae312e300f8d5c2675 ]

RSS flow rules are saved in RSS filter linked list. The linked
list is modified by rte_flow API and is used to restore RSS rules
during reset process. So this patch uses 'hw->flows_lock' to protect
the configuration and recovery of RSS rule.

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

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

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 25af8d3976..213537965e 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1549,27 +1549,20 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
 		hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated",
 			  rss_flow_conf.queue_num);
 	hns3_info(hw, "Max of contiguous %u PF queues are configured", num);
-
-	rte_spinlock_lock(&hw->lock);
 	if (num) {
 		ret = hns3_update_indir_table(dev, &rss_flow_conf, num);
 		if (ret)
-			goto rss_config_err;
+			return ret;
 	}
 
 	/* Set hash algorithm and flow types by the user's config */
 	ret = hns3_hw_rss_hash_set(hw, &rss_flow_conf);
 	if (ret)
-		goto rss_config_err;
+		return ret;
 
 	ret = hns3_rss_conf_copy(rss_info, &rss_flow_conf);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "RSS config init fail(%d)", ret);
-		goto rss_config_err;
-	}
-
-rss_config_err:
-	rte_spinlock_unlock(&hw->lock);
 
 	return ret;
 }
@@ -1615,6 +1608,7 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
 	struct hns3_hw *hw = &hns->hw;
 	int ret = 0;
 
+	pthread_mutex_lock(&hw->flows_lock);
 	TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) {
 		if (!filter->filter_info.valid)
 			continue;
@@ -1627,6 +1621,8 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
 	}
 
 out:
+	pthread_mutex_unlock(&hw->flows_lock);
+
 	return ret;
 }
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 21.11 4/4] net/hns3: fix restore filter function input
  2022-11-02  2:32 [PATCH 21.11 0/4] net/hns3: backporting some bugfix Huisong Li
                   ` (2 preceding siblings ...)
  2022-11-02  2:32 ` [PATCH 21.11 3/4] net/hns3: fix lock protection of RSS flow rule Huisong Li
@ 2022-11-02  2:32 ` Huisong Li
  3 siblings, 0 replies; 5+ messages in thread
From: Huisong Li @ 2022-11-02  2:32 UTC (permalink / raw)
  To: stable, ktraynor; +Cc: liudongdong3, huangdaode, lihuisong

[ upstream commit 1042ed401f3d19efb499ef832eb3c48f77dac13f ]

This 'hns3_restore_filter' is an internal interface of driver.
Currently, it uses 'struct rte_eth_dev *dev' as input parameter,
This is inconvenient for the function to call in driver because
caller has to obtain its device address by global variable
'rte_eth_devices[]'. Fix the input of this function.

Fixes: 920be799dbc3 ("net/hns3: fix RSS indirection table configuration")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c    |  3 +--
 drivers/net/hns3/hns3_ethdev_vf.c |  3 +--
 drivers/net/hns3/hns3_flow.c      | 30 ++++++++++++------------------
 drivers/net/hns3/hns3_flow.h      |  2 +-
 4 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 9cc1759a4a..9bf6e73ae7 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5035,7 +5035,6 @@ static int
 hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
 {
 	struct hns3_hw *hw = &hns->hw;
-	struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
 	bool link_en;
 	int ret;
 
@@ -5072,7 +5071,7 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
 	if (ret)
 		goto err_set_link_speed;
 
-	return hns3_restore_filter(dev);
+	return hns3_restore_filter(hns);
 
 err_set_link_speed:
 	(void)hns3_cfg_mac_mode(hw, false);
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 8292a4fab4..063633e5ed 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1777,7 +1777,6 @@ static int
 hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
 {
 	struct hns3_hw *hw = &hns->hw;
-	struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
 	uint16_t nb_rx_q = hw->data->nb_rx_queues;
 	uint16_t nb_tx_q = hw->data->nb_tx_queues;
 	int ret;
@@ -1792,7 +1791,7 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
 	if (ret)
 		hns3_err(hw, "failed to init queues, ret = %d.", ret);
 
-	return hns3_restore_filter(dev);
+	return hns3_restore_filter(hns);
 }
 
 static int
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 213537965e..a9256569e3 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1461,11 +1461,9 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config)
 }
 
 static int
-hns3_update_indir_table(struct rte_eth_dev *dev,
+hns3_update_indir_table(struct hns3_hw *hw,
 			const struct rte_flow_action_rss *conf, uint16_t num)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_hw *hw = &hns->hw;
 	uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE_MAX];
 	uint16_t j;
 	uint32_t i;
@@ -1488,11 +1486,9 @@ hns3_update_indir_table(struct rte_eth_dev *dev,
 }
 
 static int
-hns3_config_rss_filter(struct rte_eth_dev *dev,
+hns3_config_rss_filter(struct hns3_hw *hw,
 		       const struct hns3_rss_conf *conf, bool add)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
-	struct hns3_hw *hw = &hns->hw;
 	struct hns3_rss_conf *rss_info;
 	uint64_t flow_types;
 	uint16_t num;
@@ -1544,13 +1540,13 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
 	}
 
 	/* Set rx queues to use */
-	num = RTE_MIN(dev->data->nb_rx_queues, rss_flow_conf.queue_num);
+	num = RTE_MIN(hw->data->nb_rx_queues, rss_flow_conf.queue_num);
 	if (rss_flow_conf.queue_num > num)
 		hns3_warn(hw, "Config queue numbers %u are beyond the scope of truncated",
 			  rss_flow_conf.queue_num);
 	hns3_info(hw, "Max of contiguous %u PF queues are configured", num);
 	if (num) {
-		ret = hns3_update_indir_table(dev, &rss_flow_conf, num);
+		ret = hns3_update_indir_table(hw, &rss_flow_conf, num);
 		if (ret)
 			return ret;
 	}
@@ -1580,7 +1576,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
 	rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list);
 	while (rss_filter_ptr) {
 		TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries);
-		ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+		ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info,
 					     false);
 		if (ret)
 			rss_rule_fail_cnt++;
@@ -1601,11 +1597,9 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
 }
 
 static int
-hns3_restore_rss_filter(struct rte_eth_dev *dev)
+hns3_restore_rss_filter(struct hns3_hw *hw)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
 	struct hns3_rss_conf_ele *filter;
-	struct hns3_hw *hw = &hns->hw;
 	int ret = 0;
 
 	pthread_mutex_lock(&hw->flows_lock);
@@ -1613,7 +1607,7 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
 		if (!filter->filter_info.valid)
 			continue;
 
-		ret = hns3_config_rss_filter(dev, &filter->filter_info, true);
+		ret = hns3_config_rss_filter(hw, &filter->filter_info, true);
 		if (ret != 0) {
 			hns3_err(hw, "restore RSS filter failed, ret=%d", ret);
 			goto out;
@@ -1627,16 +1621,16 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev)
 }
 
 int
-hns3_restore_filter(struct rte_eth_dev *dev)
+hns3_restore_filter(struct hns3_adapter *hns)
 {
-	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_hw *hw = &hns->hw;
 	int ret;
 
 	ret = hns3_restore_all_fdir_filter(hns);
 	if (ret != 0)
 		return ret;
 
-	return hns3_restore_rss_filter(dev);
+	return hns3_restore_rss_filter(hw);
 }
 
 static int
@@ -1653,7 +1647,7 @@ hns3_flow_parse_rss(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
-	return hns3_config_rss_filter(dev, conf, add);
+	return hns3_config_rss_filter(hw, conf, add);
 }
 
 static int
@@ -1912,7 +1906,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 		break;
 	case RTE_ETH_FILTER_HASH:
 		rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule;
-		ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+		ret = hns3_config_rss_filter(hw, &rss_filter_ptr->filter_info,
 					     false);
 		if (ret)
 			return rte_flow_error_set(error, EIO,
diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h
index a3fcafa7bb..e90d2211e4 100644
--- a/drivers/net/hns3/hns3_flow.h
+++ b/drivers/net/hns3/hns3_flow.h
@@ -40,6 +40,6 @@ int hns3_dev_flow_ops_get(struct rte_eth_dev *dev,
 			  const struct rte_flow_ops **ops);
 void hns3_flow_init(struct rte_eth_dev *dev);
 void hns3_flow_uninit(struct rte_eth_dev *dev);
-int hns3_restore_filter(struct rte_eth_dev *dev);
+int hns3_restore_filter(struct hns3_adapter *hns);
 
 #endif /* _HNS3_FLOW_H_ */
-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-02  2:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02  2:32 [PATCH 21.11 0/4] net/hns3: backporting some bugfix Huisong Li
2022-11-02  2:32 ` [PATCH 21.11 1/4] net/hns3: extract functions to create RSS and FDIR flow rule Huisong Li
2022-11-02  2:32 ` [PATCH 21.11 2/4] net/hns3: fix RSS rule restore Huisong Li
2022-11-02  2:32 ` [PATCH 21.11 3/4] net/hns3: fix lock protection of RSS flow rule Huisong Li
2022-11-02  2:32 ` [PATCH 21.11 4/4] net/hns3: fix restore filter function input Huisong Li

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).