octeontx2-af: Fix issues with NPC field hash extract
PATCH v2 1/1 octeontx2-af: Fix issues with NPC field hash extract
1. Allow field hash configuration for both source and destination IPv6.
2. Configure hardware parser based on hash extract feature enable flag for IPv6.
3. Fix IPv6 endianness issue while updating the source/destination IP address via ntuple rule.
4. Update hash extraction mbox message.
5. Enable hash extraction based on the MKEX profile
---
Changes since v1:
- Added changes to enable hash extraction based on MKEX profile.
.../net/ethernet/marvell/octeontx2/af/mbox.h | 16 +- .../marvell/octeontx2/af/rvu_npc_fs.c | 23 ++- .../marvell/octeontx2/af/rvu_npc_fs.h | 4 + .../marvell/octeontx2/af/rvu_npc_hash.c | 161 ++++++++++++------ .../marvell/octeontx2/af/rvu_npc_hash.h | 18 +- 5 files changed, 151 insertions(+), 71 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +11 -5
@@ -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_fs.c +16 -7
@@ -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,21 @@ 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
@@ -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 +108 -53
274 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h +12 -6
@@ -35,6 +35,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,16 +62,16 @@ 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 = { [NIX_INTF_RX ] = { [NPC_LID_LC ] = { [NPC_LT_LC_IP6 ] = { - true, - true, + false, + false, }, }, },
@@ -73,8 +79,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
From: Suman Ghosh <[email protected]>
Date: Mon, 3 Jul 2023 17:50:40 +0530
Quoted 7 lines
1. Allow field hash configuration for both source and destination IPv6.
2. Configure hardware parser based on hash extract feature enable flag for IPv6.
3. Fix IPv6 endianness issue while updating the source/destination IP address via ntuple rule.
4. Update hash extraction mbox message.
5. Enable hash extraction based on the MKEX profile
That's a lot. Can't this patch be split? For example, one commit per list item? I don't think it's atomic.
Quoted 3 lines
Fixes 56d9f5fd2246 ("octeontx2-af: Use hashed field in MCAM key")Signed-off-by Suman Ghosh <[email protected]>
[...]
Thanks,
Olek
Quoted 11 lines
Quoted 1 line
1. Allow field hash configuration for both source and destination
IPv6.
Quoted 6 lines
2. Configure hardware parser based on hash extract feature enable flag for IPv6.
3. Fix IPv6 endianness issue while updating the source/destination IP address via ntuple rule.
4. Update hash extraction mbox message.
5. Enable hash extraction based on the MKEX profileThat's a lot. Can't this patch be split? For example, one commit per list item? I don't think it's atomic.
[Suman] Okay. I will split the patches
Quoted 8 lines
Quoted 4 lines
Fixes 56d9f5fd2246 ("octeontx2-af: Use hashed field in MCAM key")Signed-off-by Suman Ghosh <[email protected]>[...]
Thanks,
Olek