[PATCH 21.11] common/cnxk: fix RSS key configuration

psatheesh at marvell.com psatheesh at marvell.com
Fri Nov 29 11:43:11 CET 2024


From: Kiran Kumar K <kirankumark at marvell.com>

[ upstream commit 56fa6f92e9e32cbc5c99af89da611a9f33bbe254 ]

Limit the configuring RSS key with rte_flow operations as
it is a global resource. Key can be update only with ethdev dev
operations using rte_eth_dev_rss_hash_update().

Fixes: 51dc6a80f843 ("common/cnxk: support RSS action in NPC rule")

Signed-off-by: Kiran Kumar K <kirankumark at marvell.com>
Signed-off-by: Satheesh Paul <psatheesh at marvell.com>
Reviewed-by: Jerin Jacob <jerinj at marvell.com>
---
 drivers/common/cnxk/roc_npc.c      | 33 +++++++++++++++++++++++-------
 drivers/common/cnxk/roc_platform.h |  3 ++-
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index 9422a42457..5183d3016e 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -716,9 +716,35 @@ npc_rss_action_configure(struct roc_npc *roc_npc,
 	uint8_t key[ROC_NIX_RSS_KEY_LEN];
 	const uint8_t *key_ptr;
 	uint8_t flowkey_algx;
+	uint32_t key_len;
 	uint16_t *reta;
 	int rc;
 
+	roc_nix_rss_key_get(roc_nix, key);
+	if (rss->key == NULL) {
+		key_ptr = key;
+	} else {
+		key_len = rss->key_len;
+		if (key_len > ROC_NIX_RSS_KEY_LEN)
+			key_len = ROC_NIX_RSS_KEY_LEN;
+
+		for (i = 0; i < key_len; i++) {
+			if (key[i] != rss->key[i]) {
+				plt_err("RSS key config not supported");
+				plt_err("New Key:");
+				for (i = 0; i < key_len; i++)
+					plt_dump_no_nl("0x%.2x ", rss->key[i]);
+				plt_dump_no_nl("\n");
+				plt_err("Configured Key:");
+				for (i = 0; i < ROC_NIX_RSS_KEY_LEN; i++)
+					plt_dump_no_nl("0x%.2x ", key[i]);
+				plt_dump_no_nl("\n");
+				return -ENOTSUP;
+			}
+		}
+		key_ptr = rss->key;
+	}
+
 	rc = npc_rss_free_grp_get(npc, &rss_grp_idx);
 	/* RSS group :0 is not usable for flow rss action */
 	if (rc < 0 || rss_grp_idx == 0)
@@ -733,13 +759,6 @@ npc_rss_action_configure(struct roc_npc *roc_npc,
 
 	*rss_grp = rss_grp_idx;
 
-	if (rss->key == NULL) {
-		roc_nix_rss_key_default_fill(roc_nix, key);
-		key_ptr = key;
-	} else {
-		key_ptr = rss->key;
-	}
-
 	roc_nix_rss_key_set(roc_nix, key_ptr);
 
 	/* If queue count passed in the rss action is less than
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index 61d4781209..c79c5fda4b 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -203,7 +203,8 @@ extern int cnxk_logtype_tm;
 #define plt_info(fmt, args...) RTE_LOG(INFO, PMD, fmt "\n", ##args)
 #define plt_warn(fmt, args...) RTE_LOG(WARNING, PMD, fmt "\n", ##args)
 #define plt_print(fmt, args...) RTE_LOG(INFO, PMD, fmt "\n", ##args)
-#define plt_dump(fmt, ...)      fprintf(stderr, fmt "\n", ##__VA_ARGS__)
+#define plt_dump(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
+#define plt_dump_no_nl(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
 
 /**
  * Log debug message if given subsystem logging is enabled.
-- 
2.39.2



More information about the stable mailing list