patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Wenjun Wu <wenjun1.wu@intel.com>
To: dev@dpdk.org, qi.z.zhang@intel.com, jingjing.wu@intel.com,
	beilei.xing@intel.com, stable@dpdk.org
Cc: Wenjun Wu <wenjun1.wu@intel.com>
Subject: [PATCH 20.11] net/iavf: fix default RSS configuration
Date: Mon, 17 Jan 2022 14:31:50 +0800	[thread overview]
Message-ID: <20220117063150.259609-1-wenjun1.wu@intel.com> (raw)

All the RSS rules should be cleared before creating default
RSS rules for VF, otherwise duplicated rules will cause error.

Fixes: 5ea614254332("net/iavf: fix VF reset for RSS")
Cc: stable@dpdk.org

Signed-off-by: Wenjun Wu <wenjun1.wu@intel.com>
---
This is a DPDK 20.11 only patch, since the deployment has been implemented
after code refactoring in DPDK 21.02.
---
 drivers/net/iavf/iavf.h        |  2 ++
 drivers/net/iavf/iavf_ethdev.c | 26 ++++++++++++++++++++++++++
 drivers/net/iavf/iavf_hash.c   |  8 +-------
 drivers/net/iavf/iavf_vchnl.c  | 23 +++++++++++++++++++++++
 4 files changed, 52 insertions(+), 7 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index e06b35a283..301789be98 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -322,6 +322,8 @@ int iavf_fdir_check(struct iavf_adapter *adapter,
 		struct iavf_fdir_conf *filter);
 int iavf_add_del_rss_cfg(struct iavf_adapter *adapter,
 			 struct virtchnl_rss_cfg *rss_cfg, bool add);
+int iavf_set_hena(struct iavf_adapter *adapter, uint64_t hena);
+int iavf_hash_default_set(struct iavf_adapter *ad, bool add);
 int iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,
 			struct rte_ether_addr *mc_addrs,
 			uint32_t mc_addrs_num, bool add);
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 168e4fef02..374cc720bf 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -295,6 +295,12 @@ iavf_init_rss(struct iavf_adapter *adapter)
 	if (ret)
 		return ret;
 
+	ret = iavf_hash_default_set(adapter, true);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "fail to set default RSS");
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -1954,6 +1960,24 @@ iavf_dev_filter_ctrl(struct rte_eth_dev *dev,
 	return ret;
 }
 
+static void
+iavf_default_rss_disable(struct iavf_adapter *adapter)
+{
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	int ret = 0;
+
+	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
+		/* Set hena = 0 to ask PF to cleanup all existing RSS. */
+		ret = iavf_set_hena(adapter, 0);
+		if (ret)
+			/* It is a workaround, temporarily allow error to be
+			 * returned due to possible lack of PF handling for
+			 * hena = 0.
+			 */
+			PMD_INIT_LOG(WARNING, "fail to disable default RSS,"
+				    "lack PF support");
+	}
+}
 
 static int
 iavf_dev_init(struct rte_eth_dev *eth_dev)
@@ -2041,6 +2065,8 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 		return ret;
 	}
 
+	iavf_default_rss_disable(adapter);
+
 	return 0;
 }
 
diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c
index eb7fd3f66f..53a5ef6cd1 100644
--- a/drivers/net/iavf/iavf_hash.c
+++ b/drivers/net/iavf/iavf_hash.c
@@ -458,7 +458,7 @@ static struct iavf_flow_parser iavf_hash_parser = {
 	.stage = IAVF_FLOW_STAGE_RSS,
 };
 
-static int
+int
 iavf_hash_default_set(struct iavf_adapter *ad, bool add)
 {
 	struct virtchnl_rss_cfg *rss_cfg;
@@ -510,12 +510,6 @@ iavf_hash_init(struct iavf_adapter *ad)
 		return ret;
 	}
 
-	ret = iavf_hash_default_set(ad, true);
-	if (ret) {
-		PMD_DRV_LOG(ERR, "fail to set default RSS");
-		iavf_unregister_parser(parser, ad);
-	}
-
 	return ret;
 }
 
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 1460330572..08bba56e18 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -1490,3 +1490,26 @@ iavf_get_max_rss_queue_region(struct iavf_adapter *adapter)
 
 	return 0;
 }
+
+int
+iavf_set_hena(struct iavf_adapter *adapter, uint64_t hena)
+{
+	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+	struct virtchnl_rss_hena vrh;
+	struct iavf_cmd_info args;
+	int err;
+
+	vrh.hena = hena;
+	args.ops = VIRTCHNL_OP_SET_RSS_HENA;
+	args.in_args = (u8 *)&vrh;
+	args.in_args_size = sizeof(vrh);
+	args.out_buffer = vf->aq_resp;
+	args.out_size = IAVF_AQ_BUF_SZ;
+
+	err = iavf_execute_vf_cmd(adapter, &args);
+	if (err)
+		PMD_DRV_LOG(ERR,
+			    "Failed to execute command of OP_SET_RSS_HENA");
+
+	return err;
+}
-- 
2.25.1


                 reply	other threads:[~2022-01-17  6:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117063150.259609-1-wenjun1.wu@intel.com \
    --to=wenjun1.wu@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).