Commit cdd41e87 authored by Subbaraya Sundeep's avatar Subbaraya Sundeep Committed by Jakub Kicinski

octeontx2-af: Update get/set resource count functions

Since multiple blocks of same type are present in
98xx, modify functions which get resource count and
which update resource count to work with individual
block address instead of block type.
Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: default avatarSunil Goutham <sgoutham@marvell.com>
Signed-off-by: default avatarRakesh Babu <rsaladi2@marvell.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1a025560
...@@ -306,31 +306,36 @@ static void rvu_update_rsrc_map(struct rvu *rvu, struct rvu_pfvf *pfvf, ...@@ -306,31 +306,36 @@ static void rvu_update_rsrc_map(struct rvu *rvu, struct rvu_pfvf *pfvf,
block->fn_map[lf] = attach ? pcifunc : 0; block->fn_map[lf] = attach ? pcifunc : 0;
switch (block->type) { switch (block->addr) {
case BLKTYPE_NPA: case BLKADDR_NPA:
pfvf->npalf = attach ? true : false; pfvf->npalf = attach ? true : false;
num_lfs = pfvf->npalf; num_lfs = pfvf->npalf;
break; break;
case BLKTYPE_NIX: case BLKADDR_NIX0:
case BLKADDR_NIX1:
pfvf->nixlf = attach ? true : false; pfvf->nixlf = attach ? true : false;
num_lfs = pfvf->nixlf; num_lfs = pfvf->nixlf;
break; break;
case BLKTYPE_SSO: case BLKADDR_SSO:
attach ? pfvf->sso++ : pfvf->sso--; attach ? pfvf->sso++ : pfvf->sso--;
num_lfs = pfvf->sso; num_lfs = pfvf->sso;
break; break;
case BLKTYPE_SSOW: case BLKADDR_SSOW:
attach ? pfvf->ssow++ : pfvf->ssow--; attach ? pfvf->ssow++ : pfvf->ssow--;
num_lfs = pfvf->ssow; num_lfs = pfvf->ssow;
break; break;
case BLKTYPE_TIM: case BLKADDR_TIM:
attach ? pfvf->timlfs++ : pfvf->timlfs--; attach ? pfvf->timlfs++ : pfvf->timlfs--;
num_lfs = pfvf->timlfs; num_lfs = pfvf->timlfs;
break; break;
case BLKTYPE_CPT: case BLKADDR_CPT0:
attach ? pfvf->cptlfs++ : pfvf->cptlfs--; attach ? pfvf->cptlfs++ : pfvf->cptlfs--;
num_lfs = pfvf->cptlfs; num_lfs = pfvf->cptlfs;
break; break;
case BLKADDR_CPT1:
attach ? pfvf->cpt1_lfs++ : pfvf->cpt1_lfs--;
num_lfs = pfvf->cpt1_lfs;
break;
} }
reg = is_pf ? block->pf_lfcnt_reg : block->vf_lfcnt_reg; reg = is_pf ? block->pf_lfcnt_reg : block->vf_lfcnt_reg;
...@@ -1025,7 +1030,30 @@ int rvu_mbox_handler_ready(struct rvu *rvu, struct msg_req *req, ...@@ -1025,7 +1030,30 @@ int rvu_mbox_handler_ready(struct rvu *rvu, struct msg_req *req,
/* Get current count of a RVU block's LF/slots /* Get current count of a RVU block's LF/slots
* provisioned to a given RVU func. * provisioned to a given RVU func.
*/ */
static u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype) u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blkaddr)
{
switch (blkaddr) {
case BLKADDR_NPA:
return pfvf->npalf ? 1 : 0;
case BLKADDR_NIX0:
case BLKADDR_NIX1:
return pfvf->nixlf ? 1 : 0;
case BLKADDR_SSO:
return pfvf->sso;
case BLKADDR_SSOW:
return pfvf->ssow;
case BLKADDR_TIM:
return pfvf->timlfs;
case BLKADDR_CPT0:
return pfvf->cptlfs;
case BLKADDR_CPT1:
return pfvf->cpt1_lfs;
}
return 0;
}
/* Return true if LFs of block type are attached to pcifunc */
static bool is_blktype_attached(struct rvu_pfvf *pfvf, int blktype)
{ {
switch (blktype) { switch (blktype) {
case BLKTYPE_NPA: case BLKTYPE_NPA:
...@@ -1033,15 +1061,16 @@ static u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype) ...@@ -1033,15 +1061,16 @@ static u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype)
case BLKTYPE_NIX: case BLKTYPE_NIX:
return pfvf->nixlf ? 1 : 0; return pfvf->nixlf ? 1 : 0;
case BLKTYPE_SSO: case BLKTYPE_SSO:
return pfvf->sso; return !!pfvf->sso;
case BLKTYPE_SSOW: case BLKTYPE_SSOW:
return pfvf->ssow; return !!pfvf->ssow;
case BLKTYPE_TIM: case BLKTYPE_TIM:
return pfvf->timlfs; return !!pfvf->timlfs;
case BLKTYPE_CPT: case BLKTYPE_CPT:
return pfvf->cptlfs; return pfvf->cptlfs || pfvf->cpt1_lfs;
} }
return 0;
return false;
} }
bool is_pffunc_map_valid(struct rvu *rvu, u16 pcifunc, int blktype) bool is_pffunc_map_valid(struct rvu *rvu, u16 pcifunc, int blktype)
...@@ -1054,7 +1083,7 @@ bool is_pffunc_map_valid(struct rvu *rvu, u16 pcifunc, int blktype) ...@@ -1054,7 +1083,7 @@ bool is_pffunc_map_valid(struct rvu *rvu, u16 pcifunc, int blktype)
pfvf = rvu_get_pfvf(rvu, pcifunc); pfvf = rvu_get_pfvf(rvu, pcifunc);
/* Check if this PFFUNC has a LF of type blktype attached */ /* Check if this PFFUNC has a LF of type blktype attached */
if (!rvu_get_rsrc_mapcount(pfvf, blktype)) if (!is_blktype_attached(pfvf, blktype))
return false; return false;
return true; return true;
...@@ -1095,7 +1124,7 @@ static void rvu_detach_block(struct rvu *rvu, int pcifunc, int blktype) ...@@ -1095,7 +1124,7 @@ static void rvu_detach_block(struct rvu *rvu, int pcifunc, int blktype)
block = &hw->block[blkaddr]; block = &hw->block[blkaddr];
num_lfs = rvu_get_rsrc_mapcount(pfvf, block->type); num_lfs = rvu_get_rsrc_mapcount(pfvf, block->addr);
if (!num_lfs) if (!num_lfs)
return; return;
...@@ -1216,7 +1245,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu, ...@@ -1216,7 +1245,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu,
int free_lfs, mappedlfs; int free_lfs, mappedlfs;
/* Only one NPA LF can be attached */ /* Only one NPA LF can be attached */
if (req->npalf && !rvu_get_rsrc_mapcount(pfvf, BLKTYPE_NPA)) { if (req->npalf && !is_blktype_attached(pfvf, BLKTYPE_NPA)) {
block = &hw->block[BLKADDR_NPA]; block = &hw->block[BLKADDR_NPA];
free_lfs = rvu_rsrc_free_count(&block->lf); free_lfs = rvu_rsrc_free_count(&block->lf);
if (!free_lfs) if (!free_lfs)
...@@ -1229,7 +1258,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu, ...@@ -1229,7 +1258,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu,
} }
/* Only one NIX LF can be attached */ /* Only one NIX LF can be attached */
if (req->nixlf && !rvu_get_rsrc_mapcount(pfvf, BLKTYPE_NIX)) { if (req->nixlf && !is_blktype_attached(pfvf, BLKTYPE_NIX)) {
block = &hw->block[BLKADDR_NIX0]; block = &hw->block[BLKADDR_NIX0];
free_lfs = rvu_rsrc_free_count(&block->lf); free_lfs = rvu_rsrc_free_count(&block->lf);
if (!free_lfs) if (!free_lfs)
...@@ -1250,7 +1279,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu, ...@@ -1250,7 +1279,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu,
pcifunc, req->sso, block->lf.max); pcifunc, req->sso, block->lf.max);
return -EINVAL; return -EINVAL;
} }
mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->type); mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->addr);
free_lfs = rvu_rsrc_free_count(&block->lf); free_lfs = rvu_rsrc_free_count(&block->lf);
/* Check if additional resources are available */ /* Check if additional resources are available */
if (req->sso > mappedlfs && if (req->sso > mappedlfs &&
...@@ -1266,7 +1295,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu, ...@@ -1266,7 +1295,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu,
pcifunc, req->sso, block->lf.max); pcifunc, req->sso, block->lf.max);
return -EINVAL; return -EINVAL;
} }
mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->type); mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->addr);
free_lfs = rvu_rsrc_free_count(&block->lf); free_lfs = rvu_rsrc_free_count(&block->lf);
if (req->ssow > mappedlfs && if (req->ssow > mappedlfs &&
((req->ssow - mappedlfs) > free_lfs)) ((req->ssow - mappedlfs) > free_lfs))
...@@ -1281,7 +1310,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu, ...@@ -1281,7 +1310,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu,
pcifunc, req->timlfs, block->lf.max); pcifunc, req->timlfs, block->lf.max);
return -EINVAL; return -EINVAL;
} }
mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->type); mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->addr);
free_lfs = rvu_rsrc_free_count(&block->lf); free_lfs = rvu_rsrc_free_count(&block->lf);
if (req->timlfs > mappedlfs && if (req->timlfs > mappedlfs &&
((req->timlfs - mappedlfs) > free_lfs)) ((req->timlfs - mappedlfs) > free_lfs))
...@@ -1296,7 +1325,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu, ...@@ -1296,7 +1325,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu,
pcifunc, req->cptlfs, block->lf.max); pcifunc, req->cptlfs, block->lf.max);
return -EINVAL; return -EINVAL;
} }
mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->type); mappedlfs = rvu_get_rsrc_mapcount(pfvf, block->addr);
free_lfs = rvu_rsrc_free_count(&block->lf); free_lfs = rvu_rsrc_free_count(&block->lf);
if (req->cptlfs > mappedlfs && if (req->cptlfs > mappedlfs &&
((req->cptlfs - mappedlfs) > free_lfs)) ((req->cptlfs - mappedlfs) > free_lfs))
...@@ -1932,7 +1961,7 @@ static void rvu_blklf_teardown(struct rvu *rvu, u16 pcifunc, u8 blkaddr) ...@@ -1932,7 +1961,7 @@ static void rvu_blklf_teardown(struct rvu *rvu, u16 pcifunc, u8 blkaddr)
block = &rvu->hw->block[blkaddr]; block = &rvu->hw->block[blkaddr];
num_lfs = rvu_get_rsrc_mapcount(rvu_get_pfvf(rvu, pcifunc), num_lfs = rvu_get_rsrc_mapcount(rvu_get_pfvf(rvu, pcifunc),
block->type); block->addr);
if (!num_lfs) if (!num_lfs)
return; return;
for (slot = 0; slot < num_lfs; slot++) { for (slot = 0; slot < num_lfs; slot++) {
......
...@@ -137,6 +137,7 @@ struct rvu_pfvf { ...@@ -137,6 +137,7 @@ struct rvu_pfvf {
u16 ssow; u16 ssow;
u16 cptlfs; u16 cptlfs;
u16 timlfs; u16 timlfs;
u16 cpt1_lfs;
u8 cgx_lmac; u8 cgx_lmac;
/* Block LF's MSIX vector info */ /* Block LF's MSIX vector info */
...@@ -420,6 +421,7 @@ void rvu_free_rsrc(struct rsrc_bmap *rsrc, int id); ...@@ -420,6 +421,7 @@ void rvu_free_rsrc(struct rsrc_bmap *rsrc, int id);
int rvu_rsrc_free_count(struct rsrc_bmap *rsrc); int rvu_rsrc_free_count(struct rsrc_bmap *rsrc);
int rvu_alloc_rsrc_contig(struct rsrc_bmap *rsrc, int nrsrc); int rvu_alloc_rsrc_contig(struct rsrc_bmap *rsrc, int nrsrc);
bool rvu_rsrc_check_contig(struct rsrc_bmap *rsrc, int nrsrc); bool rvu_rsrc_check_contig(struct rsrc_bmap *rsrc, int nrsrc);
u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blkaddr);
int rvu_get_pf(u16 pcifunc); int rvu_get_pf(u16 pcifunc);
struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc); struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc);
void rvu_get_pf_numvfs(struct rvu *rvu, int pf, int *numvfs, int *hwvf); void rvu_get_pf_numvfs(struct rvu *rvu, int pf, int *numvfs, int *hwvf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment