Skip to content

Commit ab94003

Browse files
author
Paolo Abeni
committed
Merge branch 'octeontx2-af-apr-mapping-fixes'
Geetha sowjanya says: ==================== octeontx2-af: APR Mapping Fixes This patch series includes fixes related to APR (LMT) mapping and debugfs support. Changes include: Patch 1:Set LMT_ENA bit for APR table entries. Enables the LMT line for each PF/VF by setting the LMT_ENA bit in the APR_LMT_MAP_ENTRY_S structure. Patch-2:Fix APR entry in debugfs The APR table was previously mapped using a fixed size, which could lead to incorrect mappings when the number of PFs and VFs differed from the assumed value. This patch updates the logic to calculate the APR table size dynamically, based on values from the APR_LMT_CFG register, ensuring correct representation in debugfs. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents bd2ec34 + a6ae712 commit ab94003

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@
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
17+
#define LMT_MAX_VFS 256
18+
19+
#define LMT_MAP_ENTRY_ENA BIT_ULL(20)
20+
#define LMT_MAP_ENTRY_LINES GENMASK_ULL(18, 16)
1821

1922
/* Function to perform operations (read/write) on lmtst map table */
2023
static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val,
2124
int lmt_tbl_op)
2225
{
2326
void __iomem *lmt_map_base;
24-
u64 tbl_base;
27+
u64 tbl_base, cfg;
28+
int pfs, vfs;
2529

2630
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);
2734

28-
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);
2936
if (!lmt_map_base) {
3037
dev_err(rvu->dev, "Failed to setup lmt map table mapping!!\n");
3138
return -ENOMEM;
@@ -35,6 +42,13 @@ static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val,
3542
*val = readq(lmt_map_base + index);
3643
} else {
3744
writeq((*val), (lmt_map_base + index));
45+
46+
cfg = FIELD_PREP(LMT_MAP_ENTRY_ENA, 0x1);
47+
/* 2048 LMTLINES */
48+
cfg |= FIELD_PREP(LMT_MAP_ENTRY_LINES, 0x6);
49+
50+
writeq(cfg, (lmt_map_base + (index + 8)));
51+
3852
/* Flushing the AP interceptor cache to make APR_LMT_MAP_ENTRY_S
3953
* changes effective. Write 1 for flush and read is being used as a
4054
* barrier and sets up a data dependency. Write to 0 after a write
@@ -52,7 +66,7 @@ static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val,
5266
#define LMT_MAP_TBL_W1_OFF 8
5367
static u32 rvu_get_lmtst_tbl_index(struct rvu *rvu, u16 pcifunc)
5468
{
55-
return ((rvu_get_pf(pcifunc) * rvu->hw->total_vfs) +
69+
return ((rvu_get_pf(pcifunc) * LMT_MAX_VFS) +
5670
(pcifunc & RVU_PFVF_FUNC_MASK)) * LMT_MAPTBL_ENTRY_SIZE;
5771
}
5872

@@ -69,7 +83,7 @@ static int rvu_get_lmtaddr(struct rvu *rvu, u16 pcifunc,
6983

7084
mutex_lock(&rvu->rsrc_lock);
7185
rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_REQ, iova);
72-
pf = rvu_get_pf(pcifunc) & 0x1F;
86+
pf = rvu_get_pf(pcifunc) & RVU_PFVF_PF_MASK;
7387
val = BIT_ULL(63) | BIT_ULL(14) | BIT_ULL(13) | pf << 8 |
7488
((pcifunc & RVU_PFVF_FUNC_MASK) & 0xFF);
7589
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)