Skip to content

Commit c57c58f

Browse files
SruChallakuba-moo
authored andcommitted
octeontx2-af: Handle CPT function level reset
When FLR is initiated for a VF (PCI function level reset), the parent PF gets a interrupt. PF then sends a message to admin function (AF), which then cleans up all resources attached to that VF. This patch adds support to handle CPT FLR. Signed-off-by: Narayana Prasad Raju Atherya <[email protected]> Signed-off-by: Suheil Chandran <[email protected]> Signed-off-by: Sunil Kovvuri Goutham <[email protected]> Signed-off-by: Srujana Challa <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b0f60fa commit c57c58f

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,9 @@ static void rvu_blklf_teardown(struct rvu *rvu, u16 pcifunc, u8 blkaddr)
21502150
rvu_nix_lf_teardown(rvu, pcifunc, block->addr, lf);
21512151
else if (block->addr == BLKADDR_NPA)
21522152
rvu_npa_lf_teardown(rvu, pcifunc, lf);
2153+
else if ((block->addr == BLKADDR_CPT0) ||
2154+
(block->addr == BLKADDR_CPT1))
2155+
rvu_cpt_lf_teardown(rvu, pcifunc, lf, slot);
21532156

21542157
err = rvu_lf_reset(rvu, block, lf);
21552158
if (err) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
608608
void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
609609
int blkaddr, u16 src, struct mcam_entry *entry,
610610
u8 *intf, u8 *ena);
611+
/* CPT APIs */
612+
int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot);
611613

612614
#ifdef CONFIG_DEBUG_FS
613615
void rvu_dbg_init(struct rvu *rvu);

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

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,92 @@ int rvu_mbox_handler_cpt_rd_wr_register(struct rvu *rvu,
240240

241241
return 0;
242242
}
243+
244+
#define INPROG_INFLIGHT(reg) ((reg) & 0x1FF)
245+
#define INPROG_GRB_PARTIAL(reg) ((reg) & BIT_ULL(31))
246+
#define INPROG_GRB(reg) (((reg) >> 32) & 0xFF)
247+
#define INPROG_GWB(reg) (((reg) >> 40) & 0xFF)
248+
249+
static void cpt_lf_disable_iqueue(struct rvu *rvu, int blkaddr, int slot)
250+
{
251+
int i = 0, hard_lp_ctr = 100000;
252+
u64 inprog, grp_ptr;
253+
u16 nq_ptr, dq_ptr;
254+
255+
/* Disable instructions enqueuing */
256+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_ALIASX(slot, CPT_LF_CTL), 0x0);
257+
258+
/* Disable executions in the LF's queue */
259+
inprog = rvu_read64(rvu, blkaddr,
260+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
261+
inprog &= ~BIT_ULL(16);
262+
rvu_write64(rvu, blkaddr,
263+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG), inprog);
264+
265+
/* Wait for CPT queue to become execution-quiescent */
266+
do {
267+
inprog = rvu_read64(rvu, blkaddr,
268+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
269+
if (INPROG_GRB_PARTIAL(inprog)) {
270+
i = 0;
271+
hard_lp_ctr--;
272+
} else {
273+
i++;
274+
}
275+
276+
grp_ptr = rvu_read64(rvu, blkaddr,
277+
CPT_AF_BAR2_ALIASX(slot,
278+
CPT_LF_Q_GRP_PTR));
279+
nq_ptr = (grp_ptr >> 32) & 0x7FFF;
280+
dq_ptr = grp_ptr & 0x7FFF;
281+
282+
} while (hard_lp_ctr && (i < 10) && (nq_ptr != dq_ptr));
283+
284+
if (hard_lp_ctr == 0)
285+
dev_warn(rvu->dev, "CPT FLR hits hard loop counter\n");
286+
287+
i = 0;
288+
hard_lp_ctr = 100000;
289+
do {
290+
inprog = rvu_read64(rvu, blkaddr,
291+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
292+
293+
if ((INPROG_INFLIGHT(inprog) == 0) &&
294+
(INPROG_GWB(inprog) < 40) &&
295+
((INPROG_GRB(inprog) == 0) ||
296+
(INPROG_GRB((inprog)) == 40))) {
297+
i++;
298+
} else {
299+
i = 0;
300+
hard_lp_ctr--;
301+
}
302+
} while (hard_lp_ctr && (i < 10));
303+
304+
if (hard_lp_ctr == 0)
305+
dev_warn(rvu->dev, "CPT FLR hits hard loop counter\n");
306+
}
307+
308+
int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot)
309+
{
310+
int blkaddr;
311+
u64 reg;
312+
313+
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, pcifunc);
314+
if (blkaddr != BLKADDR_CPT0 && blkaddr != BLKADDR_CPT1)
315+
return -EINVAL;
316+
317+
/* Enable BAR2 ALIAS for this pcifunc. */
318+
reg = BIT_ULL(16) | pcifunc;
319+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_SEL, reg);
320+
321+
cpt_lf_disable_iqueue(rvu, blkaddr, slot);
322+
323+
/* Set group drop to help clear out hardware */
324+
reg = rvu_read64(rvu, blkaddr, CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
325+
reg |= BIT_ULL(17);
326+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG), reg);
327+
328+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_SEL, 0);
329+
330+
return 0;
331+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,17 @@
484484
#define CPT_AF_RAS_INT_ENA_W1S (0x47030)
485485
#define CPT_AF_RAS_INT_ENA_W1C (0x47038)
486486

487+
#define AF_BAR2_ALIASX(a, b) (0x9100000ull | (a) << 12 | (b))
488+
#define CPT_AF_BAR2_SEL 0x9000000
489+
#define CPT_AF_BAR2_ALIASX(a, b) AF_BAR2_ALIASX(a, b)
490+
487491
#define CPT_AF_LF_CTL2_SHIFT 3
488492
#define CPT_AF_LF_SSO_PF_FUNC_SHIFT 32
489493

494+
#define CPT_LF_CTL 0x10
495+
#define CPT_LF_INPROG 0x40
496+
#define CPT_LF_Q_GRP_PTR 0x120
497+
490498
#define NPC_AF_BLK_RST (0x00040)
491499

492500
/* NPC */

0 commit comments

Comments
 (0)