[dpdk-stable] patch 'net/hns3: fix flushing RSS rule' has been queued to stable release 19.11.6

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Oct 28 11:43:58 CET 2020


Hi,

FYI, your patch has been queued to stable release 19.11.6

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 10/30/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Luca Boccassi

---
>From 2ca208f42094aa32f2cadb31e5d2a6a1ddf041fe Mon Sep 17 00:00:00 2001
From: Lijun Ou <oulijun at huawei.com>
Date: Tue, 22 Sep 2020 20:03:27 +0800
Subject: [PATCH] net/hns3: fix flushing RSS rule

[ upstream commit ec674cb742e5a756b9e4c7623c486220a718c885 ]

When user create a flow without RSS by calling rte_flow_create API and then
destroy it by calling rte_flow_flush API, driver should not clear RSS rule.

A reasonable handling method is that when user creates an RSS rule, the
driver should clear the created RSS rule when flushing destroy all flow
rules. Also, hw->rss_info should save the RSS config of the last success
RSS rule. When create n RSS rules, the RSS should not be disabled before
the last RSS rule destroyed.

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

Signed-off-by: Lijun Ou <oulijun at huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei at huawei.com>
---
 drivers/net/hns3/hns3_flow.c | 81 ++++++++++++++++++++++++++----------
 drivers/net/hns3/hns3_rss.h  |  1 +
 2 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 9904918110..a53d5ed2b1 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1456,7 +1456,9 @@ static int
 hns3_config_rss_filter(struct rte_eth_dev *dev,
 		       const struct hns3_rss_conf *conf, bool add)
 {
+	struct hns3_process_private *process_list = dev->process_private;
 	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;
@@ -1504,28 +1506,27 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
 
 	rss_info = &hw->rss_info;
 	if (!add) {
-		if (hns3_action_rss_same(&rss_info->conf, &rss_flow_conf)) {
-			ret = hns3_disable_rss(hw);
-			if (ret) {
-				hns3_err(hw, "RSS disable failed(%d)", ret);
-				return ret;
-			}
-
-			if (rss_flow_conf.queue_num) {
-				/*
-				 * Due the content of queue pointer have been
-				 * reset to 0, the rss_info->conf.queue should
-				 * be set NULL.
-				 */
-				rss_info->conf.queue = NULL;
-				rss_info->conf.queue_num = 0;
-			}
-
-			/* set RSS func invalid after flushed */
-			rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX;
+		if (!conf->valid)
 			return 0;
+
+		ret = hns3_disable_rss(hw);
+		if (ret) {
+			hns3_err(hw, "RSS disable failed(%d)", ret);
+			return ret;
 		}
-		return -EINVAL;
+
+		if (rss_flow_conf.queue_num) {
+			/*
+			 * Due the content of queue pointer have been reset to
+			 * 0, the rss_info->conf.queue should be set NULL
+			 */
+			rss_info->conf.queue = NULL;
+			rss_info->conf.queue_num = 0;
+		}
+
+		/* set RSS func invalid after flushed */
+		rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX;
+		return 0;
 	}
 
 	/* Get rx queues num */
@@ -1556,6 +1557,13 @@ 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, &process_list->filter_rss_list, entries)
+		rss_filter_ptr->filter_info.valid = false;
+
 rss_config_err:
 	rte_spinlock_unlock(&hw->lock);
 
@@ -1566,10 +1574,36 @@ rss_config_err:
 static int
 hns3_clear_rss_filter(struct rte_eth_dev *dev)
 {
+	struct hns3_process_private *process_list = dev->process_private;
 	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_rss_conf_ele *rss_filter_ptr;
 	struct hns3_hw *hw = &hns->hw;
+	int rss_rule_succ_cnt = 0; /* count for success of clearing RSS rules */
+	int rss_rule_fail_cnt = 0; /* count for failure of clearing RSS rules */
+	int ret = 0;
 
-	return hns3_config_rss_filter(dev, &hw->rss_info, false);
+	rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list);
+	while (rss_filter_ptr) {
+		TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr,
+			     entries);
+		ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+					     false);
+		if (ret)
+			rss_rule_fail_cnt++;
+		else
+			rss_rule_succ_cnt++;
+		rte_free(rss_filter_ptr);
+		rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list);
+	}
+
+	if (rss_rule_fail_cnt) {
+		hns3_err(hw, "fail to delete all RSS filters, success num = %d "
+			     "fail num = %d", rss_rule_succ_cnt,
+			     rss_rule_fail_cnt);
+		ret = -EIO;
+	}
+
+	return ret;
 }
 
 /* Restore the rss filter */
@@ -1720,6 +1754,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 		}
 		memcpy(&rss_filter_ptr->filter_info, rss_conf,
 			sizeof(struct hns3_rss_conf));
+		rss_filter_ptr->filter_info.valid = true;
 		TAILQ_INSERT_TAIL(&process_list->filter_rss_list,
 				  rss_filter_ptr, entries);
 
@@ -1785,7 +1820,6 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 	struct hns3_fdir_rule_ele *fdir_rule_ptr;
 	struct hns3_rss_conf_ele *rss_filter_ptr;
 	struct hns3_flow_mem *flow_node;
-	struct hns3_hw *hw = &hns->hw;
 	enum rte_filter_type filter_type;
 	struct hns3_fdir_rule fdir_rule;
 	int ret;
@@ -1815,7 +1849,8 @@ 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, &hw->rss_info, false);
+		ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
+					     false);
 		if (ret)
 			return rte_flow_error_set(error, EIO,
 						  RTE_FLOW_ERROR_TYPE_HANDLE,
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 8f065af0aa..b49e399901 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -54,6 +54,7 @@ struct hns3_rss_conf {
 	struct hns3_rss_tuple_cfg rss_tuple_sets;
 	uint8_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE]; /* Shadow table */
 	uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
+	bool valid; /* check if RSS rule is valid */
 };
 
 /* Bit 8 ~Bit 15 */
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-10-28 10:35:14.226151435 +0000
+++ 0079-net-hns3-fix-flushing-RSS-rule.patch	2020-10-28 10:35:11.588831261 +0000
@@ -1,8 +1,10 @@
-From ec674cb742e5a756b9e4c7623c486220a718c885 Mon Sep 17 00:00:00 2001
+From 2ca208f42094aa32f2cadb31e5d2a6a1ddf041fe Mon Sep 17 00:00:00 2001
 From: Lijun Ou <oulijun at huawei.com>
 Date: Tue, 22 Sep 2020 20:03:27 +0800
 Subject: [PATCH] net/hns3: fix flushing RSS rule
 
+[ upstream commit ec674cb742e5a756b9e4c7623c486220a718c885 ]
+
 When user create a flow without RSS by calling rte_flow_create API and then
 destroy it by calling rte_flow_flush API, driver should not clear RSS rule.
 
@@ -13,7 +15,6 @@
 the last RSS rule destroyed.
 
 Fixes: c37ca66f2b27 ("net/hns3: support RSS")
-Cc: stable at dpdk.org
 
 Signed-off-by: Lijun Ou <oulijun at huawei.com>
 Signed-off-by: Wei Hu (Xavier) <xavier.huwei at huawei.com>
@@ -23,10 +24,10 @@
  2 files changed, 59 insertions(+), 23 deletions(-)
 
 diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
-index 5b5124c196..05cc95e3cf 100644
+index 9904918110..a53d5ed2b1 100644
 --- a/drivers/net/hns3/hns3_flow.c
 +++ b/drivers/net/hns3/hns3_flow.c
-@@ -1560,7 +1560,9 @@ static int
+@@ -1456,7 +1456,9 @@ static int
  hns3_config_rss_filter(struct rte_eth_dev *dev,
  		       const struct hns3_rss_conf *conf, bool add)
  {
@@ -36,7 +37,7 @@
  	struct hns3_hw *hw = &hns->hw;
  	struct hns3_rss_conf *rss_info;
  	uint64_t flow_types;
-@@ -1591,28 +1593,27 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
+@@ -1504,28 +1506,27 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
  
  	rss_info = &hw->rss_info;
  	if (!add) {
@@ -84,7 +85,7 @@
  	}
  
  	/* Get rx queues num */
-@@ -1643,6 +1644,13 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
+@@ -1556,6 +1557,13 @@ hns3_config_rss_filter(struct rte_eth_dev *dev,
  		goto rss_config_err;
  	}
  
@@ -98,7 +99,7 @@
  rss_config_err:
  	rte_spinlock_unlock(&hw->lock);
  
-@@ -1653,10 +1661,36 @@ rss_config_err:
+@@ -1566,10 +1574,36 @@ rss_config_err:
  static int
  hns3_clear_rss_filter(struct rte_eth_dev *dev)
  {
@@ -136,7 +137,7 @@
  }
  
  /* Restore the rss filter */
-@@ -1807,6 +1841,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
+@@ -1720,6 +1754,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
  		}
  		memcpy(&rss_filter_ptr->filter_info, rss_conf,
  			sizeof(struct hns3_rss_conf));
@@ -144,7 +145,7 @@
  		TAILQ_INSERT_TAIL(&process_list->filter_rss_list,
  				  rss_filter_ptr, entries);
  
-@@ -1872,7 +1907,6 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
+@@ -1785,7 +1820,6 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
  	struct hns3_fdir_rule_ele *fdir_rule_ptr;
  	struct hns3_rss_conf_ele *rss_filter_ptr;
  	struct hns3_flow_mem *flow_node;
@@ -152,7 +153,7 @@
  	enum rte_filter_type filter_type;
  	struct hns3_fdir_rule fdir_rule;
  	int ret;
-@@ -1902,7 +1936,8 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
+@@ -1815,7 +1849,8 @@ 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;
@@ -163,17 +164,17 @@
  			return rte_flow_error_set(error, EIO,
  						  RTE_FLOW_ERROR_TYPE_HANDLE,
 diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
-index 47d3586225..8fa1b301b8 100644
+index 8f065af0aa..b49e399901 100644
 --- a/drivers/net/hns3/hns3_rss.h
 +++ b/drivers/net/hns3/hns3_rss.h
-@@ -47,6 +47,7 @@ struct hns3_rss_conf {
+@@ -54,6 +54,7 @@ struct hns3_rss_conf {
  	struct hns3_rss_tuple_cfg rss_tuple_sets;
  	uint8_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE]; /* Shadow table */
  	uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */
 +	bool valid; /* check if RSS rule is valid */
  };
  
- #ifndef ilog2
+ /* Bit 8 ~Bit 15 */
 -- 
 2.20.1
 


More information about the stable mailing list