Skip to content

Commit f325d3f

Browse files
sgoutham-marvelldavem330
authored andcommitted
octeontx2-af: Verify NPA/SSO/NIX PF_FUNC mapping
While mapping a NIX LF to a NPA LF attached PF_FUNC or SSO LF attached PF_FUNC, verify if PF_FUNC is valid and if that PF_FUNC has a LF of that block attached to it or not. Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 86cea61 commit f325d3f

File tree

4 files changed

+62
-11
lines changed

4 files changed

+62
-11
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ enum nix_af_status {
405405
NIX_AF_INVAL_TXSCHQ_CFG = -412,
406406
NIX_AF_SMQ_FLUSH_FAILED = -413,
407407
NIX_AF_ERR_LF_RESET = -414,
408+
NIX_AF_INVAL_NPA_PF_FUNC = -419,
409+
NIX_AF_INVAL_SSO_PF_FUNC = -420,
408410
};
409411

410412
/* For NIX LF context alloc and init */

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,28 @@ struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc)
337337
return &rvu->pf[rvu_get_pf(pcifunc)];
338338
}
339339

340+
static bool is_pf_func_valid(struct rvu *rvu, u16 pcifunc)
341+
{
342+
int pf, vf, nvfs;
343+
u64 cfg;
344+
345+
pf = rvu_get_pf(pcifunc);
346+
if (pf >= rvu->hw->total_pfs)
347+
return false;
348+
349+
if (!(pcifunc & RVU_PFVF_FUNC_MASK))
350+
return true;
351+
352+
/* Check if VF is within number of VFs attached to this PF */
353+
vf = (pcifunc & RVU_PFVF_FUNC_MASK) - 1;
354+
cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_PFX_CFG(pf));
355+
nvfs = (cfg >> 12) & 0xFF;
356+
if (vf >= nvfs)
357+
return false;
358+
359+
return true;
360+
}
361+
340362
bool is_block_implemented(struct rvu_hwinfo *hw, int blkaddr)
341363
{
342364
struct rvu_block *block;
@@ -860,6 +882,22 @@ static u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype)
860882
return 0;
861883
}
862884

885+
bool is_pffunc_map_valid(struct rvu *rvu, u16 pcifunc, int blktype)
886+
{
887+
struct rvu_pfvf *pfvf;
888+
889+
if (!is_pf_func_valid(rvu, pcifunc))
890+
return false;
891+
892+
pfvf = rvu_get_pfvf(rvu, pcifunc);
893+
894+
/* Check if this PFFUNC has a LF of type blktype attached */
895+
if (!rvu_get_rsrc_mapcount(pfvf, blktype))
896+
return false;
897+
898+
return true;
899+
}
900+
863901
static int rvu_lookup_rsrc(struct rvu *rvu, struct rvu_block *block,
864902
int pcifunc, int slot)
865903
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ int rvu_get_pf(u16 pcifunc);
255255
struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc);
256256
void rvu_get_pf_numvfs(struct rvu *rvu, int pf, int *numvfs, int *hwvf);
257257
bool is_block_implemented(struct rvu_hwinfo *hw, int blkaddr);
258+
bool is_pffunc_map_valid(struct rvu *rvu, u16 pcifunc, int blktype);
258259
int rvu_get_lf(struct rvu *rvu, struct rvu_block *block, u16 pcifunc, u16 slot);
259260
int rvu_lf_reset(struct rvu *rvu, struct rvu_block *block, int lf);
260261
int rvu_get_blkaddr(struct rvu *rvu, int blktype, u16 pcifunc);

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,24 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
694694
if (nixlf < 0)
695695
return NIX_AF_ERR_AF_LF_INVALID;
696696

697+
/* Check if requested 'NIXLF <=> NPALF' mapping is valid */
698+
if (req->npa_func) {
699+
/* If default, use 'this' NIXLF's PFFUNC */
700+
if (req->npa_func == RVU_DEFAULT_PF_FUNC)
701+
req->npa_func = pcifunc;
702+
if (!is_pffunc_map_valid(rvu, req->npa_func, BLKTYPE_NPA))
703+
return NIX_AF_INVAL_NPA_PF_FUNC;
704+
}
705+
706+
/* Check if requested 'NIXLF <=> SSOLF' mapping is valid */
707+
if (req->sso_func) {
708+
/* If default, use 'this' NIXLF's PFFUNC */
709+
if (req->sso_func == RVU_DEFAULT_PF_FUNC)
710+
req->sso_func = pcifunc;
711+
if (!is_pffunc_map_valid(rvu, req->sso_func, BLKTYPE_SSO))
712+
return NIX_AF_INVAL_SSO_PF_FUNC;
713+
}
714+
697715
/* If RSS is being enabled, check if requested config is valid.
698716
* RSS table size should be power of two, otherwise
699717
* RSS_GRP::OFFSET + adder might go beyond that group or
@@ -798,18 +816,10 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,
798816
/* Enable LMTST for this NIX LF */
799817
rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_CFG2(nixlf), BIT_ULL(0));
800818

801-
/* Set CQE/WQE size, NPA_PF_FUNC for SQBs and also SSO_PF_FUNC
802-
* If requester has sent a 'RVU_DEFAULT_PF_FUNC' use this NIX LF's
803-
* PCIFUNC itself.
804-
*/
805-
if (req->npa_func == RVU_DEFAULT_PF_FUNC)
806-
cfg = pcifunc;
807-
else
819+
/* Set CQE/WQE size, NPA_PF_FUNC for SQBs and also SSO_PF_FUNC */
820+
if (req->npa_func)
808821
cfg = req->npa_func;
809-
810-
if (req->sso_func == RVU_DEFAULT_PF_FUNC)
811-
cfg |= (u64)pcifunc << 16;
812-
else
822+
if (req->sso_func)
813823
cfg |= (u64)req->sso_func << 16;
814824

815825
cfg |= (u64)req->xqe_sz << 33;

0 commit comments

Comments
 (0)