Skip to content

Commit

Permalink
octeontx2-af: Fix hash extraction enable configuration
Browse files Browse the repository at this point in the history
[ Upstream commit 4e62c99 ]

As of today, hash extraction support is enabled for all the silicons.
Because of which we are facing initialization issues when the silicon
does not support hash extraction. During creation of the hardware
parsing table for IPv6 address, we need to consider if hash extraction
is enabled then extract only 32 bit, otherwise 128 bit needs to be
extracted. This patch fixes the issue and configures the hardware parser
based on the availability of the feature.

Fixes: a95ab93 ("octeontx2-af: Use hashed field in MCAM key")
Signed-off-by: Suman Ghosh <sumang@marvell.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230721061222.2632521-1-sumang@marvell.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Suman Ghosh authored and gregkh committed Aug 3, 2023
1 parent 9b0c968 commit 17e67a0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
43 changes: 42 additions & 1 deletion drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,54 @@ void npc_config_secret_key(struct rvu *rvu, int blkaddr)

void npc_program_mkex_hash(struct rvu *rvu, int blkaddr)
{
struct npc_mcam_kex_hash *mh = rvu->kpu.mkex_hash;
struct hw_cap *hwcap = &rvu->hw->cap;
u8 intf, ld, hdr_offset, byte_len;
struct rvu_hwinfo *hw = rvu->hw;
u8 intf;
u64 cfg;

/* Check if hardware supports hash extraction */
if (!hwcap->npc_hash_extract)
return;

/* Check if IPv6 source/destination address
* should be hash enabled.
* Hashing reduces 128bit SIP/DIP fields to 32bit
* so that 224 bit X2 key can be used for IPv6 based filters as well,
* which in turn results in more number of MCAM entries available for
* use.
*
* Hashing of IPV6 SIP/DIP is enabled in below scenarios
* 1. If the silicon variant supports hashing feature
* 2. If the number of bytes of IP addr being extracted is 4 bytes ie
* 32bit. The assumption here is that if user wants 8bytes of LSB of
* IP addr or full 16 bytes then his intention is not to use 32bit
* hash.
*/
for (intf = 0; intf < hw->npc_intfs; intf++) {
for (ld = 0; ld < NPC_MAX_LD; ld++) {
cfg = rvu_read64(rvu, blkaddr,
NPC_AF_INTFX_LIDX_LTX_LDX_CFG(intf,
NPC_LID_LC,
NPC_LT_LC_IP6,
ld));
hdr_offset = FIELD_GET(NPC_HDR_OFFSET, cfg);
byte_len = FIELD_GET(NPC_BYTESM, cfg);
/* Hashing of IPv6 source/destination address should be
* enabled if,
* hdr_offset == 8 (offset of source IPv6 address) or
* hdr_offset == 24 (offset of destination IPv6)
* address) and the number of byte to be
* extracted is 4. As per hardware configuration
* byte_len should be == actual byte_len - 1.
* Hence byte_len is checked against 3 but nor 4.
*/
if ((hdr_offset == 8 || hdr_offset == 24) && byte_len == 3)
mh->lid_lt_ld_hash_en[intf][NPC_LID_LC][NPC_LT_LC_IP6][ld] = true;
}
}

/* Update hash configuration if the field is hash enabled */
for (intf = 0; intf < hw->npc_intfs; intf++) {
npc_program_mkex_hash_rx(rvu, blkaddr, intf);
npc_program_mkex_hash_tx(rvu, blkaddr, intf);
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ 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,
},
},
},

[NIX_INTF_TX] = {
[NPC_LID_LC] = {
[NPC_LT_LC_IP6] = {
true,
true,
false,
false,
},
},
},
Expand Down

0 comments on commit 17e67a0

Please sign in to comment.