Skip to content

Commit 8cc89ae

Browse files
nithind1988davem330
authored andcommitted
octeontx2-af: Clear NPC MCAM entries before update
Writing into NPC MCAM1 and MCAM0 registers are suppressed if they happened to form a reserved combination. Hence clear and disable MCAM entries before update. For HRM: [CAM(1)]<n>=1, [CAM(0)]<n>=1: Reserved. The reserved combination is not allowed. Hardware suppresses any write to CAM(0) or CAM(1) that would result in the reserved combination for any CAM bit. Signed-off-by: Nithin Dabilpuram <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 922584f commit 8cc89ae

File tree

1 file changed

+31
-2
lines changed
  • drivers/net/ethernet/marvell/octeontx2/af

1 file changed

+31
-2
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,31 @@ static void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
120120
}
121121
}
122122

123+
static void npc_clear_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
124+
int blkaddr, int index)
125+
{
126+
int bank = npc_get_bank(mcam, index);
127+
int actbank = bank;
128+
129+
index &= (mcam->banksize - 1);
130+
for (; bank < (actbank + mcam->banks_per_entry); bank++) {
131+
rvu_write64(rvu, blkaddr,
132+
NPC_AF_MCAMEX_BANKX_CAMX_INTF(index, bank, 1), 0);
133+
rvu_write64(rvu, blkaddr,
134+
NPC_AF_MCAMEX_BANKX_CAMX_INTF(index, bank, 0), 0);
135+
136+
rvu_write64(rvu, blkaddr,
137+
NPC_AF_MCAMEX_BANKX_CAMX_W0(index, bank, 1), 0);
138+
rvu_write64(rvu, blkaddr,
139+
NPC_AF_MCAMEX_BANKX_CAMX_W0(index, bank, 0), 0);
140+
141+
rvu_write64(rvu, blkaddr,
142+
NPC_AF_MCAMEX_BANKX_CAMX_W1(index, bank, 1), 0);
143+
rvu_write64(rvu, blkaddr,
144+
NPC_AF_MCAMEX_BANKX_CAMX_W1(index, bank, 0), 0);
145+
}
146+
}
147+
123148
static void npc_get_keyword(struct mcam_entry *entry, int idx,
124149
u64 *cam0, u64 *cam1)
125150
{
@@ -211,6 +236,12 @@ static void npc_config_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
211236
actindex = index;
212237
index &= (mcam->banksize - 1);
213238

239+
/* Disable before mcam entry update */
240+
npc_enable_mcam_entry(rvu, mcam, blkaddr, actindex, false);
241+
242+
/* Clear mcam entry to avoid writes being suppressed by NPC */
243+
npc_clear_mcam_entry(rvu, mcam, blkaddr, actindex);
244+
214245
/* CAM1 takes the comparison value and
215246
* CAM0 specifies match for a bit in key being '0' or '1' or 'dontcare'.
216247
* CAM1<n> = 0 & CAM0<n> = 1 => match if key<n> = 0
@@ -251,8 +282,6 @@ static void npc_config_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
251282
/* Enable the entry */
252283
if (enable)
253284
npc_enable_mcam_entry(rvu, mcam, blkaddr, actindex, true);
254-
else
255-
npc_enable_mcam_entry(rvu, mcam, blkaddr, actindex, false);
256285
}
257286

258287
static void npc_copy_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,

0 commit comments

Comments
 (0)