Skip to content

Commit 462e99a

Browse files
committed
Merge branch 'support-for-octeontx2-98xx-cpt-block'
Srujana Challa says: ==================== Support for OcteonTX2 98xx CPT block. OcteonTX2 series of silicons have multiple variants, the 98xx variant has two crypto (CPT) blocks to double the crypto performance. This patchset adds support for new CPT block(CPT1). ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents e0183b9 + c57c58f commit 462e99a

File tree

6 files changed

+178
-60
lines changed

6 files changed

+178
-60
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,13 +1073,15 @@ struct cpt_rd_wr_reg_msg {
10731073
u64 *ret_val;
10741074
u64 val;
10751075
u8 is_write;
1076+
int blkaddr;
10761077
};
10771078

10781079
struct cpt_lf_alloc_req_msg {
10791080
struct mbox_msghdr hdr;
10801081
u16 nix_pf_func;
10811082
u16 sso_pf_func;
10821083
u16 eng_grpmsk;
1084+
int blkaddr;
10831085
};
10841086

10851087
#endif /* MBOX_H */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,9 @@ static void rvu_blklf_teardown(struct rvu *rvu, u16 pcifunc, u8 blkaddr)
21502150
rvu_nix_lf_teardown(rvu, pcifunc, block->addr, lf);
21512151
else if (block->addr == BLKADDR_NPA)
21522152
rvu_npa_lf_teardown(rvu, pcifunc, lf);
2153+
else if ((block->addr == BLKADDR_CPT0) ||
2154+
(block->addr == BLKADDR_CPT1))
2155+
rvu_cpt_lf_teardown(rvu, pcifunc, lf, slot);
21532156

21542157
err = rvu_lf_reset(rvu, block, lf);
21552158
if (err) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#define NAME_SIZE 32
3535
#define MAX_NIX_BLKS 2
36+
#define MAX_CPT_BLKS 2
3637

3738
/* PF_FUNC */
3839
#define RVU_PFVF_PF_SHIFT 10
@@ -47,6 +48,11 @@ struct dump_ctx {
4748
bool all;
4849
};
4950

51+
struct cpt_ctx {
52+
int blkaddr;
53+
struct rvu *rvu;
54+
};
55+
5056
struct rvu_debugfs {
5157
struct dentry *root;
5258
struct dentry *cgx_root;
@@ -61,6 +67,7 @@ struct rvu_debugfs {
6167
struct dump_ctx nix_cq_ctx;
6268
struct dump_ctx nix_rq_ctx;
6369
struct dump_ctx nix_sq_ctx;
70+
struct cpt_ctx cpt_ctx[MAX_CPT_BLKS];
6471
int npa_qsize_id;
6572
int nix_qsize_id;
6673
};
@@ -601,6 +608,8 @@ void npc_enable_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
601608
void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,
602609
int blkaddr, u16 src, struct mcam_entry *entry,
603610
u8 *intf, u8 *ena);
611+
/* CPT APIs */
612+
int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot);
604613

605614
#ifdef CONFIG_DEBUG_FS
606615
void rvu_dbg_init(struct rvu *rvu);

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

Lines changed: 114 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ int rvu_mbox_handler_cpt_lf_alloc(struct rvu *rvu,
6565
int num_lfs, slot;
6666
u64 val;
6767

68+
blkaddr = req->blkaddr ? req->blkaddr : BLKADDR_CPT0;
69+
if (blkaddr != BLKADDR_CPT0 && blkaddr != BLKADDR_CPT1)
70+
return -ENODEV;
71+
6872
if (req->eng_grpmsk == 0x0)
6973
return CPT_AF_ERR_GRP_INVALID;
7074

71-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
72-
if (blkaddr < 0)
73-
return blkaddr;
74-
7575
block = &rvu->hw->block[blkaddr];
7676
num_lfs = rvu_get_rsrc_mapcount(rvu_get_pfvf(rvu, pcifunc),
7777
block->addr);
@@ -114,23 +114,17 @@ int rvu_mbox_handler_cpt_lf_alloc(struct rvu *rvu,
114114
return 0;
115115
}
116116

117-
int rvu_mbox_handler_cpt_lf_free(struct rvu *rvu, struct msg_req *req,
118-
struct msg_rsp *rsp)
117+
static int cpt_lf_free(struct rvu *rvu, struct msg_req *req, int blkaddr)
119118
{
120119
u16 pcifunc = req->hdr.pcifunc;
120+
int num_lfs, cptlf, slot;
121121
struct rvu_block *block;
122-
int cptlf, blkaddr;
123-
int num_lfs, slot;
124-
125-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
126-
if (blkaddr < 0)
127-
return blkaddr;
128122

129123
block = &rvu->hw->block[blkaddr];
130124
num_lfs = rvu_get_rsrc_mapcount(rvu_get_pfvf(rvu, pcifunc),
131125
block->addr);
132126
if (!num_lfs)
133-
return CPT_AF_ERR_LF_INVALID;
127+
return 0;
134128

135129
for (slot = 0; slot < num_lfs; slot++) {
136130
cptlf = rvu_get_lf(rvu, block, pcifunc, slot);
@@ -146,6 +140,21 @@ int rvu_mbox_handler_cpt_lf_free(struct rvu *rvu, struct msg_req *req,
146140
return 0;
147141
}
148142

143+
int rvu_mbox_handler_cpt_lf_free(struct rvu *rvu, struct msg_req *req,
144+
struct msg_rsp *rsp)
145+
{
146+
int ret;
147+
148+
ret = cpt_lf_free(rvu, req, BLKADDR_CPT0);
149+
if (ret)
150+
return ret;
151+
152+
if (is_block_implemented(rvu->hw, BLKADDR_CPT1))
153+
ret = cpt_lf_free(rvu, req, BLKADDR_CPT1);
154+
155+
return ret;
156+
}
157+
149158
static bool is_valid_offset(struct rvu *rvu, struct cpt_rd_wr_reg_msg *req)
150159
{
151160
u64 offset = req->reg_offset;
@@ -208,9 +217,9 @@ int rvu_mbox_handler_cpt_rd_wr_register(struct rvu *rvu,
208217
{
209218
int blkaddr;
210219

211-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
212-
if (blkaddr < 0)
213-
return blkaddr;
220+
blkaddr = req->blkaddr ? req->blkaddr : BLKADDR_CPT0;
221+
if (blkaddr != BLKADDR_CPT0 && blkaddr != BLKADDR_CPT1)
222+
return -ENODEV;
214223

215224
/* This message is accepted only if sent from CPT PF/VF */
216225
if (!is_cpt_pf(rvu, req->hdr.pcifunc) &&
@@ -231,3 +240,92 @@ int rvu_mbox_handler_cpt_rd_wr_register(struct rvu *rvu,
231240

232241
return 0;
233242
}
243+
244+
#define INPROG_INFLIGHT(reg) ((reg) & 0x1FF)
245+
#define INPROG_GRB_PARTIAL(reg) ((reg) & BIT_ULL(31))
246+
#define INPROG_GRB(reg) (((reg) >> 32) & 0xFF)
247+
#define INPROG_GWB(reg) (((reg) >> 40) & 0xFF)
248+
249+
static void cpt_lf_disable_iqueue(struct rvu *rvu, int blkaddr, int slot)
250+
{
251+
int i = 0, hard_lp_ctr = 100000;
252+
u64 inprog, grp_ptr;
253+
u16 nq_ptr, dq_ptr;
254+
255+
/* Disable instructions enqueuing */
256+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_ALIASX(slot, CPT_LF_CTL), 0x0);
257+
258+
/* Disable executions in the LF's queue */
259+
inprog = rvu_read64(rvu, blkaddr,
260+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
261+
inprog &= ~BIT_ULL(16);
262+
rvu_write64(rvu, blkaddr,
263+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG), inprog);
264+
265+
/* Wait for CPT queue to become execution-quiescent */
266+
do {
267+
inprog = rvu_read64(rvu, blkaddr,
268+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
269+
if (INPROG_GRB_PARTIAL(inprog)) {
270+
i = 0;
271+
hard_lp_ctr--;
272+
} else {
273+
i++;
274+
}
275+
276+
grp_ptr = rvu_read64(rvu, blkaddr,
277+
CPT_AF_BAR2_ALIASX(slot,
278+
CPT_LF_Q_GRP_PTR));
279+
nq_ptr = (grp_ptr >> 32) & 0x7FFF;
280+
dq_ptr = grp_ptr & 0x7FFF;
281+
282+
} while (hard_lp_ctr && (i < 10) && (nq_ptr != dq_ptr));
283+
284+
if (hard_lp_ctr == 0)
285+
dev_warn(rvu->dev, "CPT FLR hits hard loop counter\n");
286+
287+
i = 0;
288+
hard_lp_ctr = 100000;
289+
do {
290+
inprog = rvu_read64(rvu, blkaddr,
291+
CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
292+
293+
if ((INPROG_INFLIGHT(inprog) == 0) &&
294+
(INPROG_GWB(inprog) < 40) &&
295+
((INPROG_GRB(inprog) == 0) ||
296+
(INPROG_GRB((inprog)) == 40))) {
297+
i++;
298+
} else {
299+
i = 0;
300+
hard_lp_ctr--;
301+
}
302+
} while (hard_lp_ctr && (i < 10));
303+
304+
if (hard_lp_ctr == 0)
305+
dev_warn(rvu->dev, "CPT FLR hits hard loop counter\n");
306+
}
307+
308+
int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot)
309+
{
310+
int blkaddr;
311+
u64 reg;
312+
313+
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, pcifunc);
314+
if (blkaddr != BLKADDR_CPT0 && blkaddr != BLKADDR_CPT1)
315+
return -EINVAL;
316+
317+
/* Enable BAR2 ALIAS for this pcifunc. */
318+
reg = BIT_ULL(16) | pcifunc;
319+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_SEL, reg);
320+
321+
cpt_lf_disable_iqueue(rvu, blkaddr, slot);
322+
323+
/* Set group drop to help clear out hardware */
324+
reg = rvu_read64(rvu, blkaddr, CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG));
325+
reg |= BIT_ULL(17);
326+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_ALIASX(slot, CPT_LF_INPROG), reg);
327+
328+
rvu_write64(rvu, blkaddr, CPT_AF_BAR2_SEL, 0);
329+
330+
return 0;
331+
}

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

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,20 +1904,16 @@ static void rvu_dbg_npc_init(struct rvu *rvu)
19041904
&rvu_dbg_npc_rx_miss_act_fops);
19051905
}
19061906

1907-
/* CPT debugfs APIs */
19081907
static int cpt_eng_sts_display(struct seq_file *filp, u8 eng_type)
19091908
{
1910-
struct rvu *rvu = filp->private;
1909+
struct cpt_ctx *ctx = filp->private;
19111910
u64 busy_sts = 0, free_sts = 0;
19121911
u32 e_min = 0, e_max = 0, e, i;
19131912
u16 max_ses, max_ies, max_aes;
1914-
int blkaddr;
1913+
struct rvu *rvu = ctx->rvu;
1914+
int blkaddr = ctx->blkaddr;
19151915
u64 reg;
19161916

1917-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
1918-
if (blkaddr < 0)
1919-
return -ENODEV;
1920-
19211917
reg = rvu_read64(rvu, blkaddr, CPT_AF_CONSTANTS1);
19221918
max_ses = reg & 0xffff;
19231919
max_ies = (reg >> 16) & 0xffff;
@@ -1977,16 +1973,13 @@ RVU_DEBUG_SEQ_FOPS(cpt_ie_sts, cpt_ie_sts_display, NULL);
19771973

19781974
static int rvu_dbg_cpt_engines_info_display(struct seq_file *filp, void *unused)
19791975
{
1980-
struct rvu *rvu = filp->private;
1976+
struct cpt_ctx *ctx = filp->private;
19811977
u16 max_ses, max_ies, max_aes;
1978+
struct rvu *rvu = ctx->rvu;
1979+
int blkaddr = ctx->blkaddr;
19821980
u32 e_max, e;
1983-
int blkaddr;
19841981
u64 reg;
19851982

1986-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
1987-
if (blkaddr < 0)
1988-
return -ENODEV;
1989-
19901983
reg = rvu_read64(rvu, blkaddr, CPT_AF_CONSTANTS1);
19911984
max_ses = reg & 0xffff;
19921985
max_ies = (reg >> 16) & 0xffff;
@@ -2014,17 +2007,15 @@ RVU_DEBUG_SEQ_FOPS(cpt_engines_info, cpt_engines_info_display, NULL);
20142007

20152008
static int rvu_dbg_cpt_lfs_info_display(struct seq_file *filp, void *unused)
20162009
{
2017-
struct rvu *rvu = filp->private;
2018-
struct rvu_hwinfo *hw = rvu->hw;
2010+
struct cpt_ctx *ctx = filp->private;
2011+
int blkaddr = ctx->blkaddr;
2012+
struct rvu *rvu = ctx->rvu;
20192013
struct rvu_block *block;
2020-
int blkaddr;
2014+
struct rvu_hwinfo *hw;
20212015
u64 reg;
20222016
u32 lf;
20232017

2024-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
2025-
if (blkaddr < 0)
2026-
return -ENODEV;
2027-
2018+
hw = rvu->hw;
20282019
block = &hw->block[blkaddr];
20292020
if (!block->lf.bmap)
20302021
return -ENODEV;
@@ -2049,13 +2040,10 @@ RVU_DEBUG_SEQ_FOPS(cpt_lfs_info, cpt_lfs_info_display, NULL);
20492040

20502041
static int rvu_dbg_cpt_err_info_display(struct seq_file *filp, void *unused)
20512042
{
2052-
struct rvu *rvu = filp->private;
2043+
struct cpt_ctx *ctx = filp->private;
2044+
struct rvu *rvu = ctx->rvu;
2045+
int blkaddr = ctx->blkaddr;
20532046
u64 reg0, reg1;
2054-
int blkaddr;
2055-
2056-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
2057-
if (blkaddr < 0)
2058-
return -ENODEV;
20592047

20602048
reg0 = rvu_read64(rvu, blkaddr, CPT_AF_FLTX_INT(0));
20612049
reg1 = rvu_read64(rvu, blkaddr, CPT_AF_FLTX_INT(1));
@@ -2079,15 +2067,11 @@ RVU_DEBUG_SEQ_FOPS(cpt_err_info, cpt_err_info_display, NULL);
20792067

20802068
static int rvu_dbg_cpt_pc_display(struct seq_file *filp, void *unused)
20812069
{
2082-
struct rvu *rvu;
2083-
int blkaddr;
2070+
struct cpt_ctx *ctx = filp->private;
2071+
struct rvu *rvu = ctx->rvu;
2072+
int blkaddr = ctx->blkaddr;
20842073
u64 reg;
20852074

2086-
rvu = filp->private;
2087-
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
2088-
if (blkaddr < 0)
2089-
return -ENODEV;
2090-
20912075
reg = rvu_read64(rvu, blkaddr, CPT_AF_INST_REQ_PC);
20922076
seq_printf(filp, "CPT instruction requests %llu\n", reg);
20932077
reg = rvu_read64(rvu, blkaddr, CPT_AF_INST_LATENCY_PC);
@@ -2108,26 +2092,39 @@ static int rvu_dbg_cpt_pc_display(struct seq_file *filp, void *unused)
21082092

21092093
RVU_DEBUG_SEQ_FOPS(cpt_pc, cpt_pc_display, NULL);
21102094

2111-
static void rvu_dbg_cpt_init(struct rvu *rvu)
2095+
static void rvu_dbg_cpt_init(struct rvu *rvu, int blkaddr)
21122096
{
2113-
if (!is_block_implemented(rvu->hw, BLKADDR_CPT0))
2097+
struct cpt_ctx *ctx;
2098+
2099+
if (!is_block_implemented(rvu->hw, blkaddr))
21142100
return;
21152101

2116-
rvu->rvu_dbg.cpt = debugfs_create_dir("cpt", rvu->rvu_dbg.root);
2102+
if (blkaddr == BLKADDR_CPT0) {
2103+
rvu->rvu_dbg.cpt = debugfs_create_dir("cpt", rvu->rvu_dbg.root);
2104+
ctx = &rvu->rvu_dbg.cpt_ctx[0];
2105+
ctx->blkaddr = BLKADDR_CPT0;
2106+
ctx->rvu = rvu;
2107+
} else {
2108+
rvu->rvu_dbg.cpt = debugfs_create_dir("cpt1",
2109+
rvu->rvu_dbg.root);
2110+
ctx = &rvu->rvu_dbg.cpt_ctx[1];
2111+
ctx->blkaddr = BLKADDR_CPT1;
2112+
ctx->rvu = rvu;
2113+
}
21172114

2118-
debugfs_create_file("cpt_pc", 0600, rvu->rvu_dbg.cpt, rvu,
2115+
debugfs_create_file("cpt_pc", 0600, rvu->rvu_dbg.cpt, ctx,
21192116
&rvu_dbg_cpt_pc_fops);
2120-
debugfs_create_file("cpt_ae_sts", 0600, rvu->rvu_dbg.cpt, rvu,
2117+
debugfs_create_file("cpt_ae_sts", 0600, rvu->rvu_dbg.cpt, ctx,
21212118
&rvu_dbg_cpt_ae_sts_fops);
2122-
debugfs_create_file("cpt_se_sts", 0600, rvu->rvu_dbg.cpt, rvu,
2119+
debugfs_create_file("cpt_se_sts", 0600, rvu->rvu_dbg.cpt, ctx,
21232120
&rvu_dbg_cpt_se_sts_fops);
2124-
debugfs_create_file("cpt_ie_sts", 0600, rvu->rvu_dbg.cpt, rvu,
2121+
debugfs_create_file("cpt_ie_sts", 0600, rvu->rvu_dbg.cpt, ctx,
21252122
&rvu_dbg_cpt_ie_sts_fops);
2126-
debugfs_create_file("cpt_engines_info", 0600, rvu->rvu_dbg.cpt, rvu,
2123+
debugfs_create_file("cpt_engines_info", 0600, rvu->rvu_dbg.cpt, ctx,
21272124
&rvu_dbg_cpt_engines_info_fops);
2128-
debugfs_create_file("cpt_lfs_info", 0600, rvu->rvu_dbg.cpt, rvu,
2125+
debugfs_create_file("cpt_lfs_info", 0600, rvu->rvu_dbg.cpt, ctx,
21292126
&rvu_dbg_cpt_lfs_info_fops);
2130-
debugfs_create_file("cpt_err_info", 0600, rvu->rvu_dbg.cpt, rvu,
2127+
debugfs_create_file("cpt_err_info", 0600, rvu->rvu_dbg.cpt, ctx,
21312128
&rvu_dbg_cpt_err_info_fops);
21322129
}
21332130

@@ -2146,7 +2143,8 @@ void rvu_dbg_init(struct rvu *rvu)
21462143
rvu_dbg_nix_init(rvu, BLKADDR_NIX1);
21472144
rvu_dbg_cgx_init(rvu);
21482145
rvu_dbg_npc_init(rvu);
2149-
rvu_dbg_cpt_init(rvu);
2146+
rvu_dbg_cpt_init(rvu, BLKADDR_CPT0);
2147+
rvu_dbg_cpt_init(rvu, BLKADDR_CPT1);
21502148
}
21512149

21522150
void rvu_dbg_exit(struct rvu *rvu)

0 commit comments

Comments
 (0)