[02/19] net/hns3: fix RSS filter restore

Message ID 20220930072220.20753-3-liudongdong3@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Andrew Rybchenko
Headers
Series some bugfixes and clean code for hns3 - part2 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dongdong Liu Sept. 30, 2022, 7:22 a.m. UTC
  From: Huisong Li <lihuisong@huawei.com>

Currently, driver sets RSS function to 'RTE_ETH_HASH_FUNCTION_MAX'
when user flush all rules in order to judge whether driver needs
to restore RSS rules. In fact, all rules are saved in flow RSS list.
So there is no need to modify RSS function to this macro. And this
list can be used to restore. The modification of RSS function may
introduce new problem. So this patch fix it.

Fixes: eb158fc756a5 ("net/hns3: fix config when creating RSS rule after flush")
Cc: stable@dpdk.org

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

Patch

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 4952d807b8..2fb83f756a 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1587,8 +1587,6 @@  hns3_config_rss_filter(struct rte_eth_dev *dev,
 			rss_info->conf.queue_num = 0;
 		}
 
-		/* set RSS func invalid after flushed */
-		rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX;
 		return 0;
 	}
 
@@ -1659,13 +1657,23 @@  int
 hns3_restore_rss_filter(struct rte_eth_dev *dev)
 {
 	struct hns3_adapter *hns = dev->data->dev_private;
+	struct hns3_rss_conf_ele *filter;
 	struct hns3_hw *hw = &hns->hw;
+	int ret = 0;
 
-	/* When user flush all rules, it doesn't need to restore RSS rule */
-	if (hw->rss_info.conf.func == RTE_ETH_HASH_FUNCTION_MAX)
-		return 0;
+	TAILQ_FOREACH(filter, &hw->flow_rss_list, entries) {
+		if (!filter->filter_info.valid)
+			continue;
 
-	return hns3_config_rss_filter(dev, &hw->rss_info, true);
+		ret = hns3_config_rss_filter(dev, &filter->filter_info, true);
+		if (ret != 0) {
+			hns3_err(hw, "restore RSS filter failed, ret=%d", ret);
+			goto out;
+		}
+	}
+
+out:
+	return ret;
 }
 
 static int