Skip to contentSkip to conversation

octeontx2-af: Fix issues with NPC field hash extract

PATCH In review Suman Ghosh 3 participants 13 messages Jul 12, 2023 – Jul 14, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover octeontx2-af: Fix issues with NPC field hash extract

This patchset fixes the issues with NPC field hash extract. This feature is supported only for CN10KB variant of CN10K series of silicons.

Patch #1 Fix hash extraction mbox message

Patch #2 Fix hash extraction enable configuration

Patch #3 Fix hash configuration for both source and destination IPv6

Suman Ghosh (3):
octeontx2-af: Fix hash extraction mbox message
octeontx2-af: Fix hash extraction enable configuration
octeontx2-af: Fix hash configuration for both source and destination
IPv6

 .../net/ethernet/marvell/octeontx2/af/mbox.h  |  16 +-
 .../marvell/octeontx2/af/rvu_npc_fs.c         |  22 ++-
 .../marvell/octeontx2/af/rvu_npc_fs.h         |   4 +
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 160 ++++++++++++------
 .../marvell/octeontx2/af/rvu_npc_hash.h       |  21 ++-
 5 files changed, 150 insertions(+), 73 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 octeontx2-af: Fix hash extraction mbox message

As of today, hash extraction mbox message response supports only the secret key. This patch adds support to extract both hash mask and hash control along with the secret key. These are needed to use hash reduction of 128 bit IPv6 address to 32 bit.

Fixes a95ab93550d3 ("octeontx2-af: Use hashed field in MCAM key")
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 16 ++--
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 80 +++++++++++--------
 .../marvell/octeontx2/af/rvu_npc_hash.h       | 13 +--
 3 files changed, 67 insertions(+), 42 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +11 -5
index 5727d67e0259..f43f162e8a99 100644
@@ -245,9 +245,9 @@ M(NPC_MCAM_READ_BASE_RULE, 0x6011, npc_read_base_steer_rule,            \
 M(NPC_MCAM_GET_STATS, 0x6012, npc_mcam_entry_stats,                     \
 				   npc_mcam_get_stats_req,              \
 				   npc_mcam_get_stats_rsp)              \
-M(NPC_GET_SECRET_KEY, 0x6013, npc_get_secret_key,                     \
-				   npc_get_secret_key_req,              \
-				   npc_get_secret_key_rsp)              \
+M(NPC_GET_FIELD_HASH_INFO, 0x6013, npc_get_field_hash_info,             \
+				   npc_get_field_hash_info_req,              \
+				   npc_get_field_hash_info_rsp)              \
 M(NPC_GET_FIELD_STATUS, 0x6014, npc_get_field_status,                     \
 				   npc_get_field_status_req,              \
 				   npc_get_field_status_rsp)              \
@@ -1524,14 +1524,20 @@ struct npc_mcam_get_stats_rsp {
 	u8 stat_ena; /* enabled */
 };
 
-struct npc_get_secret_key_req {
+struct npc_get_field_hash_info_req {
 	struct mbox_msghdr hdr;
 	u8 intf;
 };
 
-struct npc_get_secret_key_rsp {
+struct npc_get_field_hash_info_rsp {
 	struct mbox_msghdr hdr;
 	u64 secret_key[3];
+#define NPC_MAX_HASH 2
+#define NPC_MAX_HASH_MASK 2
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_MASK(0..1) */
+	u64 hash_mask[NPC_MAX_INTF][NPC_MAX_HASH][NPC_MAX_HASH_MASK];
+	/* NPC_AF_INTF(0..1)_HASH(0..1)_RESULT_CTRL */
+	u64 hash_ctrl[NPC_MAX_INTF][NPC_MAX_HASH];
 };
 
 enum ptp_op {
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +48 -32

151 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h +8 -5
index 3efeb09c58de..bbc7a0e95e48 100644
@@ -12,9 +12,6 @@
 #define RVU_NPC_HASH_SECRET_KEY1 0xa9d5af4c9fbc87b4
 #define RVU_NPC_HASH_SECRET_KEY2 0x5954c9e7
 
-#define NPC_MAX_HASH 2
-#define NPC_MAX_HASH_MASK 2
-
 #define KEX_LD_CFG_USE_HASH(use_hash, bytesm1, hdr_ofs, ena, flags_ena, key_ofs) \
 			    ((use_hash) << 20 | ((bytesm1) << 16) | ((hdr_ofs) << 8) | \
 			     ((ena) << 7) | ((flags_ena) << 6) | ((key_ofs) & 0x3F))
@@ -35,6 +32,12 @@
 	rvu_write64(rvu, blkaddr,	\
 		    NPC_AF_INTFX_HASHX_RESULT_CTRL(intf, ld), cfg)
 
+#define GET_KEX_LD_HASH_CTRL(intf, ld)  \
+	rvu_read64(rvu, blkaddr, NPC_AF_INTFX_HASHX_RESULT_CTRL(intf, ld))
+
+#define GET_KEX_LD_HASH_MASK(intf, ld, mask_idx)	\
+	rvu_read64(rvu, blkaddr, NPC_AF_INTFX_HASHX_MASKX(intf, ld, mask_idx))
+
 struct npc_mcam_kex_hash {
 	/* NPC_AF_INTF(0..1)_LID(0..7)_LT(0..15)_LD(0..1)_CFG */
 	bool lid_lt_ld_hash_en[NPC_MAX_INTF][NPC_MAX_LID][NPC_MAX_LT][NPC_MAX_LD];
@@ -56,8 +59,8 @@ void npc_update_field_hash(struct rvu *rvu, u8 intf,
 			   struct flow_msg *omask);
 void npc_config_secret_key(struct rvu *rvu, int blkaddr);
 void npc_program_mkex_hash(struct rvu *rvu, int blkaddr);
-u32 npc_field_hash_calc(u64 *ldata, struct npc_mcam_kex_hash *mkex_hash,
-			u64 *secret_key, u8 intf, u8 hash_idx);
+u32 npc_field_hash_calc(u64 *ldata, struct npc_get_field_hash_info_rsp rsp,
+			u8 intf, u8 hash_idx);
 
 static struct npc_mcam_kex_hash npc_mkex_hash_default __maybe_unused = {
 	.lid_lt_ld_hash_en = {
Signature · 1 line
2.25.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [net PATCH 1/3] octeontx2-af: Fix hash extraction mbox message

Quoted 5 lines · Suman Ghosh

As of today, hash extraction mbox message response supports only the secret key. This patch adds support to extract both hash mask and hash control along with the secret key. These are needed to use hash reduction of 128 bit IPv6 address to 32 bit.

Quoted 8 lines
Fixes a95ab93550d3 ("octeontx2-af: Use hashed field in MCAM key")
---
 .../net/ethernet/marvell/octeontx2/af/mbox.h  | 16 ++--
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 80 +++++++++++--------
 .../marvell/octeontx2/af/rvu_npc_hash.h       | 13 +--
 3 files changed, 67 insertions(+), 42 deletions(-)

Thanks,

maintainer
#3 lore raw

Re: [net PATCH 1/3] octeontx2-af: Fix hash extraction mbox message

In reply to Suman Ghosh
Quoted 4 lines · On Wed, 12 Jul 2023 16:46:02 +0530 Suman Ghosh wrote:

As of today, hash extraction mbox message response supports only the secret key. This patch adds support to extract both hash mask and hash control along with the secret key. These are needed to use hash reduction of 128 bit IPv6 address to 32 bit.

What are hash mask and hash control?

Why is this a fix and not a new feature / extension?

#4 lore raw

RE: [EXT] Re: [net PATCH 1/3] octeontx2-af: Fix hash extraction mbox message

Quoted 9 lines · On Wed, 12 Jul 2023 16:46:02 +0530 Suman Ghosh wrote:
Quoted 4 lines

As of today, hash extraction mbox message response supports only the secret key. This patch adds support to extract both hash mask and hash control along with the secret key. These are needed to use hash reduction of 128 bit IPv6 address to 32 bit.

What are hash mask and hash control?

Why is this a fix and not a new feature / extension?

[Suman] Update the messages in v2

#5 lore raw

PATCH 2/3 octeontx2-af: Fix hash extraction enable configuration

In reply to Suman Ghosh

As of today, hash extraction was enabled by default for the default MKEX profile. This patch fixes that and enable the support based on customer specific MKEX profile.

Fixes a95ab93550d3 ("octeontx2-af: Use hashed field in MCAM key")
---
 .../marvell/octeontx2/af/rvu_npc_fs.c         | 22 +++++++---
 .../marvell/octeontx2/af/rvu_npc_fs.h         |  4 ++
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 43 ++++++++++++++++++-
 .../marvell/octeontx2/af/rvu_npc_hash.h       |  8 ++--
 4 files changed, 65 insertions(+), 12 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +15 -7
index 006beb5cf98d..acb6f34b3cae 100644
@@ -13,11 +13,6 @@
 #include "rvu_npc_fs.h"
 #include "rvu_npc_hash.h"
 
-#define NPC_BYTESM		GENMASK_ULL(19, 16)
-#define NPC_HDR_OFFSET		GENMASK_ULL(15, 8)
-#define NPC_KEY_OFFSET		GENMASK_ULL(5, 0)
-#define NPC_LDATA_EN		BIT_ULL(7)
-
 static const char * const npc_flow_names[] = {
 	[NPC_DMAC]	= "dmac",
 	[NPC_SMAC]	= "smac",
@@ -442,6 +437,7 @@ static void npc_handle_multi_layer_fields(struct rvu *rvu, int blkaddr, u8 intf)
 static void npc_scan_ldata(struct rvu *rvu, int blkaddr, u8 lid,
 			   u8 lt, u64 cfg, u8 intf)
 {
+	struct npc_mcam_kex_hash *mkex_hash = rvu->kpu.mkex_hash;
 	struct npc_mcam *mcam = &rvu->hw->mcam;
 	u8 hdr, key, nr_bytes, bit_offset;
 	u8 la_ltype, la_start;
@@ -490,8 +486,20 @@ do {									       \
 	NPC_SCAN_HDR(NPC_SIP_IPV4, NPC_LID_LC, NPC_LT_LC_IP, 12, 4);
 	NPC_SCAN_HDR(NPC_DIP_IPV4, NPC_LID_LC, NPC_LT_LC_IP, 16, 4);
 	NPC_SCAN_HDR(NPC_IPFRAG_IPV6, NPC_LID_LC, NPC_LT_LC_IP6_EXT, 6, 1);
-	NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 16);
-	NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 16);
+	if (rvu->hw->cap.npc_hash_extract) {
+		if (mkex_hash->lid_lt_ld_hash_en[intf][lid][lt][0])
+			NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 4);
+		else
+			NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 16);
+
+		if (mkex_hash->lid_lt_ld_hash_en[intf][lid][lt][1])
+			NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 4);
+		else
+			NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 16);
+	} else {
+		NPC_SCAN_HDR(NPC_SIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 8, 16);
+		NPC_SCAN_HDR(NPC_DIP_IPV6, NPC_LID_LC, NPC_LT_LC_IP6, 24, 16);
+	}
 	NPC_SCAN_HDR(NPC_SPORT_UDP, NPC_LID_LD, NPC_LT_LD_UDP, 0, 2);
 	NPC_SCAN_HDR(NPC_DPORT_UDP, NPC_LID_LD, NPC_LT_LD_UDP, 2, 2);
 	NPC_SCAN_HDR(NPC_SPORT_TCP, NPC_LID_LD, NPC_LT_LD_TCP, 0, 2);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.h +4 -0
index bdd65ce56a32..3f5c9042d10e 100644
@@ -9,6 +9,10 @@
 #define __RVU_NPC_FS_H
 
 #define IPV6_WORDS	4
+#define NPC_BYTESM	GENMASK_ULL(19, 16)
+#define NPC_HDR_OFFSET	GENMASK_ULL(15, 8)
+#define NPC_KEY_OFFSET	GENMASK_ULL(5, 0)
+#define NPC_LDATA_EN	BIT_ULL(7)
 
 void npc_update_entry(struct rvu *rvu, enum key_fields type,
 		      struct mcam_entry *entry, u64 val_lo,
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +42 -1

55 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h +4 -4
index bbc7a0e95e48..52d4234897c6 100644
@@ -67,8 +67,8 @@ static struct npc_mcam_kex_hash npc_mkex_hash_default __maybe_unused = {
 	[NIX_INTF_RX] = {
 		[NPC_LID_LC] = {
 			[NPC_LT_LC_IP6] = {
-				true,
-				true,
+				false,
+				false,
 			},
 		},
 	},
@@ -76,8 +76,8 @@ static struct npc_mcam_kex_hash npc_mkex_hash_default __maybe_unused = {
 	[NIX_INTF_TX] = {
 		[NPC_LID_LC] = {
 			[NPC_LT_LC_IP6] = {
-				true,
-				true,
+				false,
+				false,
 			},
 		},
 	},
Signature · 1 line
2.25.1
Reviewed-by on v1 2/3
#6 lore raw

Re: [net PATCH 2/3] octeontx2-af: Fix hash extraction enable configuration

Quoted 4 lines · Suman Ghosh

As of today, hash extraction was enabled by default for the default MKEX profile. This patch fixes that and enable the support based on customer specific MKEX profile.

Quoted 9 lines
Fixes a95ab93550d3 ("octeontx2-af: Use hashed field in MCAM key")
---
 .../marvell/octeontx2/af/rvu_npc_fs.c         | 22 +++++++---
 .../marvell/octeontx2/af/rvu_npc_fs.h         |  4 ++
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 43 ++++++++++++++++++-
 .../marvell/octeontx2/af/rvu_npc_hash.h       |  8 ++--
 4 files changed, 65 insertions(+), 12 deletions(-)

Thanks,

maintainer
#7 lore raw

Re: [net PATCH 2/3] octeontx2-af: Fix hash extraction enable configuration

In reply to Suman Ghosh
Quoted 3 lines · On Wed, 12 Jul 2023 16:46:03 +0530 Suman Ghosh wrote:

As of today, hash extraction was enabled by default for the default MKEX profile. This patch fixes that and enable the support based on customer specific MKEX profile.

I'm not sure what this means, can the commit message be readable for people who don't know your HW, please?

#8 lore raw

RE: [EXT] Re: [net PATCH 2/3] octeontx2-af: Fix hash extraction enable configuration

Quoted 7 lines · On Wed, 12 Jul 2023 16:46:03 +0530 Suman Ghosh wrote:
Quoted 3 lines

As of today, hash extraction was enabled by default for the default MKEX profile. This patch fixes that and enable the support based on customer specific MKEX profile.

I'm not sure what this means, can the commit message be readable for people who don't know your HW, please?

[Suman] Update the messages in v2

#9 lore raw

PATCH 3/3 octeontx2-af: Fix hash configuration for both source and destination IPv6

In reply to Suman Ghosh

As of today, hash reduction was supported only for source IPv6 address. This patch fixes that and adds supports for both source and destination IPv6 address.

Fixes a95ab93550d3 ("octeontx2-af: Use hashed field in MCAM key")
---
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 37 +++++++++----------
 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c +18 -19
index 76553e0c216f..e7b71f2f3ad3 100644
@@ -100,20 +100,20 @@ u32 npc_field_hash_calc(u64 *ldata, struct npc_get_field_hash_info_rsp rsp,
 	return field_hash;
 }
 
-static u64 npc_update_use_hash(int lt, int ld)
+static u64 npc_update_use_hash(struct rvu *rvu, int blkaddr,
+			       u8 intf, int lid, int lt, int ld)
 {
-	u64 cfg = 0;
-
-	switch (lt) {
-	case NPC_LT_LC_IP6:
-		/* Update use_hash(bit-20) and bytesm1 (bit-16:19)
-		 * in KEX_LD_CFG
-		 */
-		cfg = KEX_LD_CFG_USE_HASH(0x1, 0x03,
-					  ld ? 0x8 : 0x18,
-					  0x1, 0x0, 0x10);
-		break;
-	}
+	u8 hdr, key;
+	u64 cfg;
+
+	cfg = rvu_read64(rvu, blkaddr, NPC_AF_INTFX_LIDX_LTX_LDX_CFG(intf, lid, lt, ld));
+	hdr = FIELD_GET(NPC_HDR_OFFSET, cfg);
+	key = FIELD_GET(NPC_KEY_OFFSET, cfg);
+
+	/* Update use_hash(bit-20) to 'true' and
+	 * bytesm1(bit-16:19) to '0x3' in KEX_LD_CFG
+	 */
+	cfg = KEX_LD_CFG_USE_HASH(0x1, 0x03, hdr, 0x1, 0x0, key);
 
 	return cfg;
 }
@@ -132,12 +132,12 @@ static void npc_program_mkex_hash_rx(struct rvu *rvu, int blkaddr,
 		for (lt = 0; lt < NPC_MAX_LT; lt++) {
 			for (ld = 0; ld < NPC_MAX_LD; ld++) {
 				if (mkex_hash->lid_lt_ld_hash_en[intf][lid][lt][ld]) {
-					u64 cfg = npc_update_use_hash(lt, ld);
+					u64 cfg;
 
-					hash_cnt++;
 					if (hash_cnt == NPC_MAX_HASH)
 						return;
 
+					cfg = npc_update_use_hash(rvu, blkaddr, intf, lid, lt, ld);
 					/* Set updated KEX configuration */
 					SET_KEX_LD(intf, lid, lt, ld, cfg);
 					/* Set HASH configuration */
@@ -149,6 +149,7 @@ static void npc_program_mkex_hash_rx(struct rvu *rvu, int blkaddr,
 							     mkex_hash->hash_mask[intf][ld][1]);
 					SET_KEX_LD_HASH_CTRL(intf, ld,
 							     mkex_hash->hash_ctrl[intf][ld]);
+					hash_cnt++;
 				}
 			}
 		}
@@ -169,12 +170,12 @@ static void npc_program_mkex_hash_tx(struct rvu *rvu, int blkaddr,
 		for (lt = 0; lt < NPC_MAX_LT; lt++) {
 			for (ld = 0; ld < NPC_MAX_LD; ld++)
 				if (mkex_hash->lid_lt_ld_hash_en[intf][lid][lt][ld]) {
-					u64 cfg = npc_update_use_hash(lt, ld);
+					u64 cfg;
 
-					hash_cnt++;
 					if (hash_cnt == NPC_MAX_HASH)
 						return;
 
+					cfg = npc_update_use_hash(rvu, blkaddr, intf, lid, lt, ld);
 					/* Set updated KEX configuration */
 					SET_KEX_LD(intf, lid, lt, ld, cfg);
 					/* Set HASH configuration */
@@ -187,8 +188,6 @@ static void npc_program_mkex_hash_tx(struct rvu *rvu, int blkaddr,
 					SET_KEX_LD_HASH_CTRL(intf, ld,
 							     mkex_hash->hash_ctrl[intf][ld]);
 					hash_cnt++;
-					if (hash_cnt == NPC_MAX_HASH)
-						return;
 				}
 		}
 	}
Signature · 1 line
2.25.1
Reviewed-by on v1 3/3
#10 lore raw

Re: [net PATCH 3/3] octeontx2-af: Fix hash configuration for both source and destination IPv6

Quoted 10 lines · Suman Ghosh

As of today, hash reduction was supported only for source IPv6 address. This patch fixes that and adds supports for both source and destination IPv6 address.

Fixes a95ab93550d3 ("octeontx2-af: Use hashed field in MCAM key")
---
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 37 +++++++++----------
 1 file changed, 18 insertions(+), 19 deletions(-)

Thanks,

maintainer
#11 lore raw
In reply to Suman Ghosh
Quoted 2 lines · On Wed, 12 Jul 2023 16:46:01 +0530 Suman Ghosh wrote:

This patchset fixes the issues with NPC field hash extract. This feature is supported only for CN10KB variant of CN10K series of silicons.

All patches look like features / extension.

Please describe in the cover letter how user of upstream Linux kernel can take advantage of those features.

Signature · 1 line
pw-bot: cr
#12 lore raw
Quoted 8 lines
Quoted 2 lines

This patchset fixes the issues with NPC field hash extract. This feature is supported only for CN10KB variant of CN10K series of

silicons.

All patches look like features / extension.

Please describe in the cover letter how user of upstream Linux kernel can take advantage of those features.

[Suman] Update the messages in v2

Quoted 2 lines

--
pw-bot: cr