Skip to content

Commit a6ae712

Browse files
Geetha sowjanyaPaolo Abeni
authored andcommitted
octeontx2-af: Fix APR entry mapping based on APR_LMT_CFG
The current implementation maps the APR table using a fixed size, which can lead to incorrect mapping when the number of PFs and VFs varies. This patch corrects the mapping by calculating the APR table size dynamically based on the values configured in the APR_LMT_CFG register, ensuring accurate representation of APR entries in debugfs. Fixes: 0daa55d ("octeontx2-af: cn10k: debugfs for dumping LMTST map table"). Signed-off-by: Geetha sowjanya <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 0eefa27 commit a6ae712

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
/* RVU LMTST */
1414
#define LMT_TBL_OP_READ 0
1515
#define LMT_TBL_OP_WRITE 1
16-
#define LMT_MAP_TABLE_SIZE (128 * 1024)
1716
#define LMT_MAPTBL_ENTRY_SIZE 16
1817
#define LMT_MAX_VFS 256
1918

@@ -26,10 +25,14 @@ static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val,
2625
{
2726
void __iomem *lmt_map_base;
2827
u64 tbl_base, cfg;
28+
int pfs, vfs;
2929

3030
tbl_base = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_MAP_BASE);
31+
cfg = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_CFG);
32+
vfs = 1 << (cfg & 0xF);
33+
pfs = 1 << ((cfg >> 4) & 0x7);
3134

32-
lmt_map_base = ioremap_wc(tbl_base, LMT_MAP_TABLE_SIZE);
35+
lmt_map_base = ioremap_wc(tbl_base, pfs * vfs * LMT_MAPTBL_ENTRY_SIZE);
3336
if (!lmt_map_base) {
3437
dev_err(rvu->dev, "Failed to setup lmt map table mapping!!\n");
3538
return -ENOMEM;
@@ -80,7 +83,7 @@ static int rvu_get_lmtaddr(struct rvu *rvu, u16 pcifunc,
8083

8184
mutex_lock(&rvu->rsrc_lock);
8285
rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_REQ, iova);
83-
pf = rvu_get_pf(pcifunc) & 0x1F;
86+
pf = rvu_get_pf(pcifunc) & RVU_PFVF_PF_MASK;
8487
val = BIT_ULL(63) | BIT_ULL(14) | BIT_ULL(13) | pf << 8 |
8588
((pcifunc & RVU_PFVF_FUNC_MASK) & 0xFF);
8689
rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_TXN_REQ, val);

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
553553
u64 lmt_addr, val, tbl_base;
554554
int pf, vf, num_vfs, hw_vfs;
555555
void __iomem *lmt_map_base;
556+
int apr_pfs, apr_vfs;
556557
int buf_size = 10240;
557558
size_t off = 0;
558559
int index = 0;
@@ -568,8 +569,12 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
568569
return -ENOMEM;
569570

570571
tbl_base = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_MAP_BASE);
572+
val = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_CFG);
573+
apr_vfs = 1 << (val & 0xF);
574+
apr_pfs = 1 << ((val >> 4) & 0x7);
571575

572-
lmt_map_base = ioremap_wc(tbl_base, 128 * 1024);
576+
lmt_map_base = ioremap_wc(tbl_base, apr_pfs * apr_vfs *
577+
LMT_MAPTBL_ENTRY_SIZE);
573578
if (!lmt_map_base) {
574579
dev_err(rvu->dev, "Failed to setup lmt map table mapping!!\n");
575580
kfree(buf);
@@ -591,7 +596,7 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
591596
off += scnprintf(&buf[off], buf_size - 1 - off, "PF%d \t\t\t",
592597
pf);
593598

594-
index = pf * rvu->hw->total_vfs * LMT_MAPTBL_ENTRY_SIZE;
599+
index = pf * apr_vfs * LMT_MAPTBL_ENTRY_SIZE;
595600
off += scnprintf(&buf[off], buf_size - 1 - off, " 0x%llx\t\t",
596601
(tbl_base + index));
597602
lmt_addr = readq(lmt_map_base + index);
@@ -604,7 +609,7 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
604609
/* Reading num of VFs per PF */
605610
rvu_get_pf_numvfs(rvu, pf, &num_vfs, &hw_vfs);
606611
for (vf = 0; vf < num_vfs; vf++) {
607-
index = (pf * rvu->hw->total_vfs * 16) +
612+
index = (pf * apr_vfs * LMT_MAPTBL_ENTRY_SIZE) +
608613
((vf + 1) * LMT_MAPTBL_ENTRY_SIZE);
609614
off += scnprintf(&buf[off], buf_size - 1 - off,
610615
"PF%d:VF%d \t\t", pf, vf);

0 commit comments

Comments
 (0)