Skip to content

Commit 873a1e3

Browse files
harman-kalradavem330
authored andcommitted
octeontx2-af: cn10k: Setting up lmtst map table
Introducing a new mailbox to support updating lmt entries and common lmt base address scheme i.e. multiple pcifuncs can share lmt region to reduce L1 cache pressure for application. Parameters passed to mailbox includes the primary pcifunc value whose lmt regions will be shared by other secondary pcifuncs. Here secondary pcifunc will be the one who is calling the mailbox. For example: By default each pcifunc has its own LMT base address: PCIFUNC1 LMT_BASE_ADDR A PCIFUNC2 LMT_BASE_ADDR B PCIFUNC3 LMT_BASE_ADDR C PCIFUNC4 LMT_BASE_ADDR D Application will choose PCIFUNC1 as base/primary pcifunc and as and when other pcifunc(secondary pcifuncs) gets probed, this mailbox will be called and LMTST table will be updated as: PCIFUNC1 LMT_BASE_ADDR A PCIFUNC2 LMT_BASE_ADDR A PCIFUNC3 LMT_BASE_ADDR A PCIFUNC4 LMT_BASE_ADDR A On FLR lmtst map table gets resetted to the default lmt base addresses for all secondary pcifuncs. Signed-off-by: Harman Kalra <hkalra@marvell.com> Signed-off-by: Geetha sowjanya <gakula@marvell.com> Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dbe69e4 commit 873a1e3

File tree

6 files changed

+159
-1
lines changed

6 files changed

+159
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ M(MSIX_OFFSET, 0x005, msix_offset, msg_req, msix_offset_rsp) \
134134
M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \
135135
M(PTP_OP, 0x007, ptp_op, ptp_req, ptp_rsp) \
136136
M(GET_HW_CAP, 0x008, get_hw_cap, msg_req, get_hw_cap_rsp) \
137+
M(LMTST_TBL_SETUP, 0x00a, lmtst_tbl_setup, lmtst_tbl_setup_req, \
138+
msg_rsp) \
137139
M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \
138140
/* CGX mbox IDs (range 0x200 - 0x3FF) */ \
139141
M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \
@@ -1278,6 +1280,11 @@ struct set_vf_perm {
12781280
u64 flags;
12791281
};
12801282

1283+
struct lmtst_tbl_setup_req {
1284+
struct mbox_msghdr hdr;
1285+
u16 base_pcifunc;
1286+
};
1287+
12811288
/* CPT mailbox error codes
12821289
* Range 901 - 1000.
12831290
*/

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,7 @@ static void __rvu_flr_handler(struct rvu *rvu, u16 pcifunc)
23332333
rvu_blklf_teardown(rvu, pcifunc, BLKADDR_SSOW);
23342334
rvu_blklf_teardown(rvu, pcifunc, BLKADDR_SSO);
23352335
rvu_blklf_teardown(rvu, pcifunc, BLKADDR_NPA);
2336+
rvu_reset_lmt_map_tbl(rvu, pcifunc);
23362337
rvu_detach_rsrcs(rvu, NULL, pcifunc);
23372338
mutex_unlock(&rvu->flr_lock);
23382339
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ struct rvu_pfvf {
243243
u8 nix_blkaddr; /* BLKADDR_NIX0/1 assigned to this PF */
244244
u8 nix_rx_intf; /* NIX0_RX/NIX1_RX interface to NPC */
245245
u8 nix_tx_intf; /* NIX0_TX/NIX1_TX interface to NPC */
246+
u64 lmt_base_addr; /* Preseving the pcifunc's lmtst base addr*/
246247
unsigned long flags;
247248
};
248249

@@ -754,6 +755,9 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot);
754755
int rvu_set_channels_base(struct rvu *rvu);
755756
void rvu_program_channels(struct rvu *rvu);
756757

758+
/* CN10K RVU - LMT*/
759+
void rvu_reset_lmt_map_tbl(struct rvu *rvu, u16 pcifunc);
760+
757761
#ifdef CONFIG_DEBUG_FS
758762
void rvu_dbg_init(struct rvu *rvu);
759763
void rvu_dbg_exit(struct rvu *rvu);

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

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,146 @@
1010
#include "cgx.h"
1111
#include "rvu_reg.h"
1212

13+
/* RVU LMTST */
14+
#define LMT_TBL_OP_READ 0
15+
#define LMT_TBL_OP_WRITE 1
16+
#define LMT_MAP_TABLE_SIZE (128 * 1024)
17+
#define LMT_MAPTBL_ENTRY_SIZE 16
18+
19+
/* Function to perform operations (read/write) on lmtst map table */
20+
static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val,
21+
int lmt_tbl_op)
22+
{
23+
void __iomem *lmt_map_base;
24+
u64 tbl_base;
25+
26+
tbl_base = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_MAP_BASE);
27+
28+
lmt_map_base = ioremap_wc(tbl_base, LMT_MAP_TABLE_SIZE);
29+
if (!lmt_map_base) {
30+
dev_err(rvu->dev, "Failed to setup lmt map table mapping!!\n");
31+
return -ENOMEM;
32+
}
33+
34+
if (lmt_tbl_op == LMT_TBL_OP_READ) {
35+
*val = readq(lmt_map_base + index);
36+
} else {
37+
writeq((*val), (lmt_map_base + index));
38+
/* Flushing the AP interceptor cache to make APR_LMT_MAP_ENTRY_S
39+
* changes effective. Write 1 for flush and read is being used as a
40+
* barrier and sets up a data dependency. Write to 0 after a write
41+
* to 1 to complete the flush.
42+
*/
43+
rvu_write64(rvu, BLKADDR_APR, APR_AF_LMT_CTL, BIT_ULL(0));
44+
rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_CTL);
45+
rvu_write64(rvu, BLKADDR_APR, APR_AF_LMT_CTL, 0x00);
46+
}
47+
48+
iounmap(lmt_map_base);
49+
return 0;
50+
}
51+
52+
static u32 rvu_get_lmtst_tbl_index(struct rvu *rvu, u16 pcifunc)
53+
{
54+
return ((rvu_get_pf(pcifunc) * rvu->hw->total_vfs) +
55+
(pcifunc & RVU_PFVF_FUNC_MASK)) * LMT_MAPTBL_ENTRY_SIZE;
56+
}
57+
58+
int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu,
59+
struct lmtst_tbl_setup_req *req,
60+
struct msg_rsp *rsp)
61+
{
62+
struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, req->hdr.pcifunc);
63+
u32 pri_tbl_idx, sec_tbl_idx;
64+
int err = 0;
65+
u64 val;
66+
67+
/* Reconfiguring lmtst map table in lmt region shared mode i.e. make
68+
* multiple PF_FUNCs to share an LMTLINE region, so primary/base
69+
* pcifunc (which is passed as an argument to mailbox) is the one
70+
* whose lmt base address will be shared among other secondary
71+
* pcifunc (will be the one who is calling this mailbox).
72+
*/
73+
if (req->base_pcifunc) {
74+
/* Calculating the LMT table index equivalent to primary
75+
* pcifunc.
76+
*/
77+
pri_tbl_idx = rvu_get_lmtst_tbl_index(rvu, req->base_pcifunc);
78+
79+
/* Truncating secondary pcifunc to calculate the LMT table index
80+
* equivalent to secondary pcifunc.
81+
*/
82+
sec_tbl_idx = rvu_get_lmtst_tbl_index(rvu, req->hdr.pcifunc);
83+
/* Read the base lmt addr of the secondary pcifunc */
84+
err = lmtst_map_table_ops(rvu, sec_tbl_idx, &val,
85+
LMT_TBL_OP_READ);
86+
if (err) {
87+
dev_err(rvu->dev,
88+
"Failed to read LMT map table: index 0x%x err %d\n",
89+
sec_tbl_idx, err);
90+
goto error;
91+
}
92+
93+
/* Storing the seondary's lmt base address as this needs to be
94+
* reverted in FLR. Also making sure this default value doesn't
95+
* get overwritten on multiple calls to this mailbox.
96+
*/
97+
if (!pfvf->lmt_base_addr)
98+
pfvf->lmt_base_addr = val;
99+
100+
/* Read the base lmt addr of the primary pcifunc */
101+
err = lmtst_map_table_ops(rvu, pri_tbl_idx, &val,
102+
LMT_TBL_OP_READ);
103+
if (err) {
104+
dev_err(rvu->dev,
105+
"Failed to read LMT map table: index 0x%x err %d\n",
106+
pri_tbl_idx, err);
107+
goto error;
108+
}
109+
110+
/* Update the base lmt addr of secondary with primary's base
111+
* lmt addr.
112+
*/
113+
err = lmtst_map_table_ops(rvu, sec_tbl_idx, &val,
114+
LMT_TBL_OP_WRITE);
115+
if (err) {
116+
dev_err(rvu->dev,
117+
"Failed to update LMT map table: index 0x%x err %d\n",
118+
sec_tbl_idx, err);
119+
goto error;
120+
}
121+
}
122+
123+
error:
124+
return err;
125+
}
126+
127+
/* Resetting the lmtst map table to original base addresses */
128+
void rvu_reset_lmt_map_tbl(struct rvu *rvu, u16 pcifunc)
129+
{
130+
struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc);
131+
u32 tbl_idx;
132+
int err;
133+
134+
if (is_rvu_otx2(rvu))
135+
return;
136+
137+
if (pfvf->lmt_base_addr) {
138+
/* This corresponds to lmt map table index */
139+
tbl_idx = rvu_get_lmtst_tbl_index(rvu, pcifunc);
140+
/* Reverting back original lmt base addr for respective
141+
* pcifunc.
142+
*/
143+
err = lmtst_map_table_ops(rvu, tbl_idx, &pfvf->lmt_base_addr,
144+
LMT_TBL_OP_WRITE);
145+
if (err)
146+
dev_err(rvu->dev,
147+
"Failed to update LMT map table: index 0x%x err %d\n",
148+
tbl_idx, err);
149+
pfvf->lmt_base_addr = 0;
150+
}
151+
}
152+
13153
int rvu_set_channels_base(struct rvu *rvu)
14154
{
15155
struct rvu_hwinfo *hw = rvu->hw;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,4 +692,9 @@
692692
#define LBK_LINK_CFG_ID_MASK GENMASK_ULL(11, 6)
693693
#define LBK_LINK_CFG_BASE_MASK GENMASK_ULL(5, 0)
694694

695+
/* APR */
696+
#define APR_AF_LMT_CFG (0x000ull)
697+
#define APR_AF_LMT_MAP_BASE (0x008ull)
698+
#define APR_AF_LMT_CTL (0x010ull)
699+
695700
#endif /* RVU_REG_H */

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ enum rvu_block_addr_e {
3535
BLKADDR_NDC_NPA0 = 0xeULL,
3636
BLKADDR_NDC_NIX1_RX = 0x10ULL,
3737
BLKADDR_NDC_NIX1_TX = 0x11ULL,
38-
BLK_COUNT = 0x12ULL,
38+
BLKADDR_APR = 0x16ULL,
39+
BLK_COUNT = 0x17ULL,
3940
};
4041

4142
/* RVU Block Type Enumeration */

0 commit comments

Comments
 (0)