Skip to content

Commit 4e62c99

Browse files
sumang-mrvlPaolo Abeni
authored andcommitted
octeontx2-af: Fix hash extraction enable configuration
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>
1 parent 34192a2 commit 4e62c99

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,54 @@ void npc_config_secret_key(struct rvu *rvu, int blkaddr)
218218

219219
void npc_program_mkex_hash(struct rvu *rvu, int blkaddr)
220220
{
221+
struct npc_mcam_kex_hash *mh = rvu->kpu.mkex_hash;
221222
struct hw_cap *hwcap = &rvu->hw->cap;
223+
u8 intf, ld, hdr_offset, byte_len;
222224
struct rvu_hwinfo *hw = rvu->hw;
223-
u8 intf;
225+
u64 cfg;
224226

227+
/* Check if hardware supports hash extraction */
225228
if (!hwcap->npc_hash_extract)
226229
return;
227230

231+
/* Check if IPv6 source/destination address
232+
* should be hash enabled.
233+
* Hashing reduces 128bit SIP/DIP fields to 32bit
234+
* so that 224 bit X2 key can be used for IPv6 based filters as well,
235+
* which in turn results in more number of MCAM entries available for
236+
* use.
237+
*
238+
* Hashing of IPV6 SIP/DIP is enabled in below scenarios
239+
* 1. If the silicon variant supports hashing feature
240+
* 2. If the number of bytes of IP addr being extracted is 4 bytes ie
241+
* 32bit. The assumption here is that if user wants 8bytes of LSB of
242+
* IP addr or full 16 bytes then his intention is not to use 32bit
243+
* hash.
244+
*/
245+
for (intf = 0; intf < hw->npc_intfs; intf++) {
246+
for (ld = 0; ld < NPC_MAX_LD; ld++) {
247+
cfg = rvu_read64(rvu, blkaddr,
248+
NPC_AF_INTFX_LIDX_LTX_LDX_CFG(intf,
249+
NPC_LID_LC,
250+
NPC_LT_LC_IP6,
251+
ld));
252+
hdr_offset = FIELD_GET(NPC_HDR_OFFSET, cfg);
253+
byte_len = FIELD_GET(NPC_BYTESM, cfg);
254+
/* Hashing of IPv6 source/destination address should be
255+
* enabled if,
256+
* hdr_offset == 8 (offset of source IPv6 address) or
257+
* hdr_offset == 24 (offset of destination IPv6)
258+
* address) and the number of byte to be
259+
* extracted is 4. As per hardware configuration
260+
* byte_len should be == actual byte_len - 1.
261+
* Hence byte_len is checked against 3 but nor 4.
262+
*/
263+
if ((hdr_offset == 8 || hdr_offset == 24) && byte_len == 3)
264+
mh->lid_lt_ld_hash_en[intf][NPC_LID_LC][NPC_LT_LC_IP6][ld] = true;
265+
}
266+
}
267+
268+
/* Update hash configuration if the field is hash enabled */
228269
for (intf = 0; intf < hw->npc_intfs; intf++) {
229270
npc_program_mkex_hash_rx(rvu, blkaddr, intf);
230271
npc_program_mkex_hash_tx(rvu, blkaddr, intf);

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ static struct npc_mcam_kex_hash npc_mkex_hash_default __maybe_unused = {
7070
[NIX_INTF_RX] = {
7171
[NPC_LID_LC] = {
7272
[NPC_LT_LC_IP6] = {
73-
true,
74-
true,
73+
false,
74+
false,
7575
},
7676
},
7777
},
7878

7979
[NIX_INTF_TX] = {
8080
[NPC_LID_LC] = {
8181
[NPC_LT_LC_IP6] = {
82-
true,
83-
true,
82+
false,
83+
false,
8484
},
8585
},
8686
},

0 commit comments

Comments
 (0)