Skip to content

Commit 4a522af

Browse files
committed
crypto: octeontx2 - support setting ctx ilen for inline CPT LF
JIRA: https://issues.redhat.com/browse/RHEL-31478 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Conflicts: Minor context difference due to missing commit 8bb0be9. commit 3139ebf Author: Nithin Dabilpuram <ndabilpuram@marvell.com> Date: Wed Dec 13 13:00:55 2023 +0530 crypto: octeontx2 - support setting ctx ilen for inline CPT LF Provide an option in Inline IPsec configure mailbox to configure the CPT_AF_LFX_CTL:CTX_ILEN for inline CPT LF attached to CPT RVU PF. This is needed to set the ctx ilen to size of inbound SA for HW errata IPBUCPT-38756. Not setting this would lead to new context's not being fetched. Also set FLR_FLUSH in CPT_LF_CTX_CTL for CPT LF's as workaround for same errata. Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
1 parent c553531 commit 4a522af

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

drivers/crypto/marvell/octeontx2/otx2_cpt_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ struct otx2_cpt_rx_inline_lf_cfg {
5757
u16 opcode;
5858
u32 credit;
5959
u32 reserved;
60+
u8 ctx_ilen_valid : 1;
61+
u8 ctx_ilen : 7;
6062
};
6163

6264
/*

drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
#define OTX2_CPT_LF_Q_INST_PTR (0x110)
103103
#define OTX2_CPT_LF_Q_GRP_PTR (0x120)
104104
#define OTX2_CPT_LF_NQX(a) (0x400 | (a) << 3)
105+
#define OTX2_CPT_LF_CTX_CTL (0x500)
105106
#define OTX2_CPT_LF_CTX_FLUSH (0x510)
106107
#define OTX2_CPT_LF_CTX_ERR (0x520)
107108
#define OTX2_CPT_RVU_FUNC_BLKADDR_SHIFT 20
@@ -472,7 +473,8 @@ union otx2_cptx_af_lf_ctrl {
472473
u64 cont_err:1;
473474
u64 reserved_11_15:5;
474475
u64 nixtx_en:1;
475-
u64 reserved_17_47:31;
476+
u64 ctx_ilen:3;
477+
u64 reserved_17_47:28;
476478
u64 grp:8;
477479
u64 reserved_56_63:8;
478480
} s;

drivers/crypto/marvell/octeontx2/otx2_cptlf.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,32 @@ static int cptlf_set_grp_and_pri(struct otx2_cptlfs_info *lfs,
106106
return ret;
107107
}
108108

109+
static int cptlf_set_ctx_ilen(struct otx2_cptlfs_info *lfs, int ctx_ilen)
110+
{
111+
union otx2_cptx_af_lf_ctrl lf_ctrl;
112+
struct otx2_cptlf_info *lf;
113+
int slot, ret = 0;
114+
115+
for (slot = 0; slot < lfs->lfs_num; slot++) {
116+
lf = &lfs->lf[slot];
117+
118+
ret = otx2_cpt_read_af_reg(lfs->mbox, lfs->pdev,
119+
CPT_AF_LFX_CTL(lf->slot),
120+
&lf_ctrl.u, lfs->blkaddr);
121+
if (ret)
122+
return ret;
123+
124+
lf_ctrl.s.ctx_ilen = ctx_ilen;
125+
126+
ret = otx2_cpt_write_af_reg(lfs->mbox, lfs->pdev,
127+
CPT_AF_LFX_CTL(lf->slot),
128+
lf_ctrl.u, lfs->blkaddr);
129+
if (ret)
130+
return ret;
131+
}
132+
return ret;
133+
}
134+
109135
static void cptlf_hw_init(struct otx2_cptlfs_info *lfs)
110136
{
111137
/* Disable instruction queues */
@@ -443,6 +469,12 @@ int otx2_cptlf_init(struct otx2_cptlfs_info *lfs, u8 eng_grp_mask, int pri,
443469
if (ret)
444470
goto free_iq;
445471

472+
if (lfs->ctx_ilen_ovrd) {
473+
ret = cptlf_set_ctx_ilen(lfs, lfs->ctx_ilen);
474+
if (ret)
475+
goto free_iq;
476+
}
477+
446478
return 0;
447479

448480
free_iq:

drivers/crypto/marvell/octeontx2/otx2_cptlf.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ struct otx2_cptlfs_info {
121121
atomic_t state; /* LF's state. started/reset */
122122
int blkaddr; /* CPT blkaddr: BLKADDR_CPT0/BLKADDR_CPT1 */
123123
int global_slot; /* Global slot across the blocks */
124+
u8 ctx_ilen;
125+
u8 ctx_ilen_ovrd;
124126
};
125127

126128
static inline void otx2_cpt_free_instruction_queues(
@@ -310,6 +312,19 @@ static inline void otx2_cptlf_set_iqueue_exec(struct otx2_cptlf_info *lf,
310312
OTX2_CPT_LF_INPROG, lf_inprog.u);
311313
}
312314

315+
static inline void otx2_cptlf_set_ctx_flr_flush(struct otx2_cptlf_info *lf)
316+
{
317+
u8 blkaddr = lf->lfs->blkaddr;
318+
u64 val;
319+
320+
val = otx2_cpt_read64(lf->lfs->reg_base, blkaddr, lf->slot,
321+
OTX2_CPT_LF_CTX_CTL);
322+
val |= BIT_ULL(0);
323+
324+
otx2_cpt_write64(lf->lfs->reg_base, blkaddr, lf->slot,
325+
OTX2_CPT_LF_CTX_CTL, val);
326+
}
327+
313328
static inline void otx2_cptlf_enable_iqueue_exec(struct otx2_cptlf_info *lf)
314329
{
315330
otx2_cptlf_set_iqueue_exec(lf, true);
@@ -325,6 +340,10 @@ static inline void otx2_cptlf_enable_iqueues(struct otx2_cptlfs_info *lfs)
325340
int slot;
326341

327342
for (slot = 0; slot < lfs->lfs_num; slot++) {
343+
/* Enable flush on FLR for Errata */
344+
if (is_dev_cn10kb(lfs->pdev))
345+
otx2_cptlf_set_ctx_flr_flush(&lfs->lf[slot]);
346+
328347
otx2_cptlf_enable_iqueue_exec(&lfs->lf[slot]);
329348
otx2_cptlf_enable_iqueue_enq(&lfs->lf[slot]);
330349
}

drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,
265265
otx2_cptlf_set_dev_info(&cptpf->lfs, cptpf->pdev, cptpf->reg_base,
266266
&cptpf->afpf_mbox, BLKADDR_CPT0);
267267
cptpf->lfs.global_slot = 0;
268+
cptpf->lfs.ctx_ilen_ovrd = cfg_req->ctx_ilen_valid;
269+
cptpf->lfs.ctx_ilen = cfg_req->ctx_ilen;
270+
268271
ret = otx2_inline_cptlf_setup(cptpf, &cptpf->lfs, egrp, num_lfs);
269272
if (ret) {
270273
dev_err(&cptpf->pdev->dev, "Inline-Ipsec CPT0 LF setup failed.\n");
@@ -277,6 +280,8 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,
277280
cptpf->reg_base, &cptpf->afpf_mbox,
278281
BLKADDR_CPT1);
279282
cptpf->cpt1_lfs.global_slot = num_lfs;
283+
cptpf->cpt1_lfs.ctx_ilen_ovrd = cfg_req->ctx_ilen_valid;
284+
cptpf->cpt1_lfs.ctx_ilen = cfg_req->ctx_ilen;
280285
ret = otx2_inline_cptlf_setup(cptpf, &cptpf->cpt1_lfs, egrp,
281286
num_lfs);
282287
if (ret) {

0 commit comments

Comments
 (0)