DPDK patches and discussions
 help / color / mirror / Atom feed
From: Junlong Wang <wang.junlong1@zte.com.cn>
To: stephen@networkplumber.org
Cc: dev@dpdk.org, Junlong Wang <wang.junlong1@zte.com.cn>
Subject: [PATCH v2 4/5] net/zxdh: modify RSS related issues
Date: Tue, 17 Jun 2025 10:05:02 +0800	[thread overview]
Message-ID: <20250617020503.3554511-4-wang.junlong1@zte.com.cn> (raw)
In-Reply-To: <20250617020503.3554511-1-wang.junlong1@zte.com.cn>


[-- Attachment #1.1.1: Type: text/plain, Size: 5879 bytes --]

modify rss related issues in testing process.
Modify the comments of the maintainers.

Fixes: 01acc23bab13 ("net/zxdh: optimize RSS operations")

Signed-off-by: Junlong Wang <wang.junlong1@zte.com.cn>
---
 drivers/net/zxdh/zxdh_ethdev.h     |  1 +
 drivers/net/zxdh/zxdh_ethdev_ops.c | 64 +++++++++++++++++++-----------
 drivers/net/zxdh/zxdh_msg.c        | 10 +++--
 3 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/drivers/net/zxdh/zxdh_ethdev.h b/drivers/net/zxdh/zxdh_ethdev.h
index 169af209a2..1013446876 100644
--- a/drivers/net/zxdh/zxdh_ethdev.h
+++ b/drivers/net/zxdh/zxdh_ethdev.h
@@ -54,6 +54,7 @@
 #define ZXDH_SLOT_MAX             256
 #define ZXDH_MAX_VF               256
 #define ZXDH_HASHIDX_MAX          6
+#define ZXDH_RSS_HASH_KEY_LEN     40U
 
 union zxdh_virport_num {
 	uint16_t vport;
diff --git a/drivers/net/zxdh/zxdh_ethdev_ops.c b/drivers/net/zxdh/zxdh_ethdev_ops.c
index 3eed388dac..b1361ef518 100644
--- a/drivers/net/zxdh/zxdh_ethdev_ops.c
+++ b/drivers/net/zxdh/zxdh_ethdev_ops.c
@@ -1170,7 +1170,7 @@ zxdh_rss_hf_to_hw(uint64_t hf)
 }
 
 static uint64_t
-zxdh_rss_hf_to_eth(uint32_t hw_hf)
+zxdh_rss_hf_to_eth(uint64_t hw_hf)
 {
 	uint64_t hf = 0;
 
@@ -1208,7 +1208,7 @@ zxdh_rss_hash_update(struct rte_eth_dev *dev,
 	hw_hf_new = zxdh_rss_hf_to_hw(rss_conf->rss_hf);
 	hw_hf_old = zxdh_rss_hf_to_hw(old_rss_conf->rss_hf);
 
-	if ((hw_hf_new != hw_hf_old || !!rss_conf->rss_hf))
+	if (hw_hf_new != hw_hf_old || hw->rss_enable != !!rss_conf->rss_hf)
 		need_update_hf = 1;
 
 	if (need_update_hf) {
@@ -1230,6 +1230,9 @@ zxdh_rss_hash_update(struct rte_eth_dev *dev,
 				return -EINVAL;
 			}
 		}
+		hw->rss_enable = !!rss_conf->rss_hf;
+		if (rss_conf->rss_hf == 0)
+			return 0;
 		if (hw->is_pf) {
 			ret = zxdh_get_port_attr(hw, hw->vport.vport, &port_attr);
 			port_attr.rss_hash_factor = hw_hf_new;
@@ -1257,15 +1260,16 @@ zxdh_rss_hash_update(struct rte_eth_dev *dev,
 int
 zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf)
 {
-	struct zxdh_hw *hw = (struct zxdh_hw *)dev->data->dev_private;
+	struct zxdh_hw *hw = dev->data->dev_private;
 	struct rte_eth_rss_conf *old_rss_conf = &dev->data->dev_conf.rx_adv_conf.rss_conf;
 	struct zxdh_msg_info msg = {0};
 	uint8_t zxdh_msg_reply_info[ZXDH_ST_SZ_BYTES(msg_reply_info)] = {0};
 	void *reply_body_addr = ZXDH_ADDR_OF(msg_reply_info, zxdh_msg_reply_info, reply_body);
 	void *rss_hf_msg_addr = ZXDH_ADDR_OF(msg_reply_body, reply_body_addr, rss_hf_msg);
 	struct zxdh_port_attr_table port_attr = {0};
-	uint32_t rss_hf;
-	uint32_t hw_hf;
+	uint64_t rss_hf = 0;
+	uint64_t hw_hf = 0;
+	uint8_t need_update_hf = 0;
 	int ret;
 
 	if (rss_conf == NULL) {
@@ -1273,27 +1277,40 @@ zxdh_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_con
 		return -ENOMEM;
 	}
 
-	hw_hf = zxdh_rss_hf_to_hw(old_rss_conf->rss_hf);
-	rss_conf->rss_hf = zxdh_rss_hf_to_eth(hw_hf);
+	if (hw->rss_enable == 0) {
+		rss_conf->rss_hf = 0;
+		return 0;
+	}
 
-	zxdh_msg_head_build(hw, ZXDH_RSS_HF_GET, &msg);
-	if (hw->is_pf) {
-		ret = zxdh_get_port_attr(hw, hw->vport.vport, &port_attr);
-		if (ret) {
-			PMD_DRV_LOG(ERR, "rss hash factor set failed");
-			return -EINVAL;
-		}
-		ZXDH_SET(rss_hf, rss_hf_msg_addr, rss_hf, port_attr.rss_hash_factor);
-	} else {
-		ret = zxdh_vf_send_msg_to_pf(dev, &msg, sizeof(struct zxdh_msg_info),
-				zxdh_msg_reply_info, ZXDH_ST_SZ_BYTES(msg_reply_info));
-		if (ret) {
-			PMD_DRV_LOG(ERR, "rss hash factor set failed");
-			return -EINVAL;
+	if (old_rss_conf->rss_hf == 0)
+		need_update_hf = 1;
+
+	if (!need_update_hf) {
+		hw_hf = zxdh_rss_hf_to_hw(old_rss_conf->rss_hf);
+		rss_conf->rss_hf = zxdh_rss_hf_to_eth(hw_hf);
+	}
+
+	if (need_update_hf) {
+		zxdh_msg_head_build(hw, ZXDH_RSS_HF_GET, &msg);
+		if (hw->is_pf) {
+			ret = zxdh_get_port_attr(hw, hw->vport.vport, &port_attr);
+			if (ret) {
+				PMD_DRV_LOG(ERR, "rss hash factor set failed");
+				return -EINVAL;
+			}
+			ZXDH_SET(rss_hf, rss_hf_msg_addr, rss_hf, port_attr.rss_hash_factor);
+		} else {
+			ret = zxdh_vf_send_msg_to_pf(dev, &msg, sizeof(struct zxdh_msg_info),
+					zxdh_msg_reply_info, ZXDH_ST_SZ_BYTES(msg_reply_info));
+			if (ret) {
+				PMD_DRV_LOG(ERR, "rss hash factor set failed");
+				return -EINVAL;
+			}
 		}
+		rss_hf = ZXDH_GET(rss_hf, rss_hf_msg_addr, rss_hf);
+		rss_conf->rss_hf = zxdh_rss_hf_to_eth(rss_hf);
+		old_rss_conf->rss_hf = zxdh_rss_hf_to_eth(hw_hf);
 	}
-	rss_hf = ZXDH_GET(rss_hf, rss_hf_msg_addr, rss_hf);
-	rss_conf->rss_hf = zxdh_rss_hf_to_eth(rss_hf);
 
 	return 0;
 }
@@ -1352,7 +1369,6 @@ zxdh_rss_configure(struct rte_eth_dev *dev)
 
 	if (curr_rss_enable && hw->rss_init == 0) {
 		/* config hash factor */
-		dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf = ZXDH_HF_F5_ETH;
 		hw_hf = zxdh_rss_hf_to_hw(dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
 		memset(&msg, 0, sizeof(msg));
 		if (hw->is_pf) {
diff --git a/drivers/net/zxdh/zxdh_msg.c b/drivers/net/zxdh/zxdh_msg.c
index e607ea1dab..b378a99a7e 100644
--- a/drivers/net/zxdh/zxdh_msg.c
+++ b/drivers/net/zxdh/zxdh_msg.c
@@ -1713,12 +1713,14 @@ zxdh_vf_rss_table_get(struct zxdh_hw *hw, uint16_t vport, void *cfg_data __rte_u
 	if (ret)
 		sprintf(str, "set rss reta tbl failed, code:%d", ret);
 
-	*res_len = strlen(str) + sizeof(uint8_t);
-	if (ret == 0)
+	if (ret == 0) {
+		*res_len = ZXDH_ST_SZ_BYTES(rss_reta) + sizeof(uint8_t);
 		ZXDH_SET(msg_reply_body, reply, flag, ZXDH_REPS_SUCC);
-	else
+	} else {
+		*res_len = strlen(str) + sizeof(uint8_t);
 		ZXDH_SET(msg_reply_body, reply, flag, ZXDH_REPS_FAIL);
-	memcpy(reply_data_addr, str, strlen(str) + 1);
+		memcpy(reply_data_addr, str, strlen(str) + 1);
+	}
 	return ret;
 }
 
-- 
2.27.0

[-- Attachment #1.1.2: Type: text/html , Size: 13714 bytes --]

  parent reply	other threads:[~2025-06-17  2:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-07  2:30 [PATCH v1 1/3] net/zxdh: modify some MAC config issues Junlong Wang
2025-06-07  2:30 ` [PATCH v1 2/3] net/zxdh: modify some VLAN related issues Junlong Wang
2025-06-16 16:20   ` Stephen Hemminger
2025-06-07  2:30 ` [PATCH v1 3/3] net/zxdh: modify RSS " Junlong Wang
2025-06-16 16:22   ` Stephen Hemminger
2025-06-12  0:14 ` [PATCH v1 1/3] net/zxdh: modify some MAC config issues Thomas Monjalon
2025-06-12  1:18 ` Junlong Wang
2025-06-16 16:16 ` Stephen Hemminger
2025-06-17  2:04 ` [PATCH v2 1/5] net/zxdh: fix meson.build issus in compilation Junlong Wang
2025-06-17  2:05   ` [PATCH v2 2/5] net/zxdh: modify some MAC config issues Junlong Wang
2025-06-17  2:05   ` [PATCH v2 3/5] net/zxdh: modify some VLAN related issues Junlong Wang
2025-06-17  2:05   ` Junlong Wang [this message]
2025-06-17  2:05   ` [PATCH v2 5/5] net/zxdh: add support VLAN TPID set ops Junlong Wang
2025-06-17  3:32     ` zhoumin

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=20250617020503.3554511-4-wang.junlong1@zte.com.cn \
    --to=wang.junlong1@zte.com.cn \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.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).