[05/19] net/hns3: move flow direction rule recovery position

Message ID 20220930072220.20753-6-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>

The 'hns3_restore_filter' is used to restore flow rules from
rte_flow API during the reset process. This patch moves the
recovery of flow direction rule to this function to improve
code maintainability.

Fixes: fcba820d9b9e ("net/hns3: support flow director")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 4 ----
 drivers/net/hns3/hns3_fdir.c   | 3 +++
 drivers/net/hns3/hns3_flow.c   | 7 +++++++
 3 files changed, 10 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index b0f69589d9..15d622a900 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5907,10 +5907,6 @@  hns3_restore_conf(struct hns3_adapter *hns)
 	if (ret)
 		goto err_promisc;
 
-	ret = hns3_restore_all_fdir_filter(hns);
-	if (ret)
-		goto err_promisc;
-
 	ret = hns3_restore_ptp(hns);
 	if (ret)
 		goto err_promisc;
diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 30e5e66772..48a91fb517 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -1068,6 +1068,9 @@  int hns3_restore_all_fdir_filter(struct hns3_adapter *hns)
 	bool err = false;
 	int ret;
 
+	if (hns->is_vf)
+		return 0;
+
 	/*
 	 * This API is called in the reset recovery process, the parent function
 	 * must hold hw->lock.
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 08fa6da7bb..dd61ecd2aa 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1675,6 +1675,13 @@  hns3_restore_rss_filter(struct rte_eth_dev *dev)
 int
 hns3_restore_filter(struct rte_eth_dev *dev)
 {
+	struct hns3_adapter *hns = dev->data->dev_private;
+	int ret;
+
+	ret = hns3_restore_all_fdir_filter(hns);
+	if (ret != 0)
+		return ret;
+
 	return hns3_restore_rss_filter(dev);
 }