Skip to content

Commit 812103e

Browse files
rkannoth1kuba-moo
authored andcommitted
octeontx2-af: Exact match scan from kex profile
CN10KB silicon supports exact match table. Scanning KEX profile should check for exact match feature is enabled and then set profile masks properly. These kex profile masks are required to configure NPC MCAM drop rules. If there is a miss in exact match table, these drop rules will drop those packets. Signed-off-by: Ratheesh Kannoth <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b747923 commit 812103e

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ enum key_fields {
208208
NPC_ERRLEV,
209209
NPC_ERRCODE,
210210
NPC_LXMB,
211+
NPC_EXACT_RESULT,
211212
NPC_LA,
212213
NPC_LB,
213214
NPC_LC,

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@ static bool npc_check_field(struct rvu *rvu, int blkaddr, enum key_fields type,
229229
return true;
230230
}
231231

232+
static void npc_scan_exact_result(struct npc_mcam *mcam, u8 bit_number,
233+
u8 key_nibble, u8 intf)
234+
{
235+
u8 offset = (key_nibble * 4) % 64; /* offset within key word */
236+
u8 kwi = (key_nibble * 4) / 64; /* which word in key */
237+
u8 nr_bits = 4; /* bits in a nibble */
238+
u8 type;
239+
240+
switch (bit_number) {
241+
case 40 ... 43:
242+
type = NPC_EXACT_RESULT;
243+
break;
244+
245+
default:
246+
return;
247+
}
248+
npc_set_kw_masks(mcam, type, nr_bits, kwi, offset, intf);
249+
}
250+
232251
static void npc_scan_parse_result(struct npc_mcam *mcam, u8 bit_number,
233252
u8 key_nibble, u8 intf)
234253
{
@@ -511,21 +530,33 @@ static int npc_scan_kex(struct rvu *rvu, int blkaddr, u8 intf)
511530
{
512531
struct npc_mcam *mcam = &rvu->hw->mcam;
513532
u8 lid, lt, ld, bitnr;
533+
u64 cfg, masked_cfg;
514534
u8 key_nibble = 0;
515-
u64 cfg;
516535

517536
/* Scan and note how parse result is going to be in key.
518537
* A bit set in PARSE_NIBBLE_ENA corresponds to a nibble from
519538
* parse result in the key. The enabled nibbles from parse result
520539
* will be concatenated in key.
521540
*/
522541
cfg = rvu_read64(rvu, blkaddr, NPC_AF_INTFX_KEX_CFG(intf));
523-
cfg &= NPC_PARSE_NIBBLE;
524-
for_each_set_bit(bitnr, (unsigned long *)&cfg, 31) {
542+
masked_cfg = cfg & NPC_PARSE_NIBBLE;
543+
for_each_set_bit(bitnr, (unsigned long *)&masked_cfg, 31) {
525544
npc_scan_parse_result(mcam, bitnr, key_nibble, intf);
526545
key_nibble++;
527546
}
528547

548+
/* Ignore exact match bits for mcam entries except the first rule
549+
* which is drop on hit. This first rule is configured explitcitly by
550+
* exact match code.
551+
*/
552+
masked_cfg = cfg & NPC_EXACT_NIBBLE;
553+
bitnr = NPC_EXACT_NIBBLE_START;
554+
for_each_set_bit_from(bitnr, (unsigned long *)&masked_cfg,
555+
NPC_EXACT_NIBBLE_START) {
556+
npc_scan_exact_result(mcam, bitnr, key_nibble, intf);
557+
key_nibble++;
558+
}
559+
529560
/* Scan and note how layer data is going to be in key */
530561
for (lid = 0; lid < NPC_MAX_LID; lid++) {
531562
for (lt = 0; lt < NPC_MAX_LT; lt++) {

0 commit comments

Comments
 (0)