Skip to content

Commit c553531

Browse files
committed
crypto: octeontx2 - register error interrupts for inline cptlf
JIRA: https://issues.redhat.com/browse/RHEL-31478 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 434c1cb Author: Nithin Dabilpuram <ndabilpuram@marvell.com> Date: Wed Dec 13 13:00:54 2023 +0530 crypto: octeontx2 - register error interrupts for inline cptlf Register errors interrupts for inline cptlf attached to PF driver so that SMMU faults and other errors can be reported. 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 8bc57a4 commit c553531

File tree

6 files changed

+155
-55
lines changed

6 files changed

+155
-55
lines changed

drivers/crypto/marvell/octeontx2/otx2_cptlf.c

Lines changed: 64 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,26 +151,14 @@ static void cptlf_set_misc_intrs(struct otx2_cptlfs_info *lfs, u8 enable)
151151
irq_misc.u);
152152
}
153153

154-
static void cptlf_enable_intrs(struct otx2_cptlfs_info *lfs)
154+
static void cptlf_set_done_intrs(struct otx2_cptlfs_info *lfs, u8 enable)
155155
{
156+
u64 reg = enable ? OTX2_CPT_LF_DONE_INT_ENA_W1S :
157+
OTX2_CPT_LF_DONE_INT_ENA_W1C;
156158
int slot;
157159

158-
/* Enable done interrupts */
159160
for (slot = 0; slot < lfs->lfs_num; slot++)
160-
otx2_cpt_write64(lfs->reg_base, lfs->blkaddr, slot,
161-
OTX2_CPT_LF_DONE_INT_ENA_W1S, 0x1);
162-
/* Enable Misc interrupts */
163-
cptlf_set_misc_intrs(lfs, true);
164-
}
165-
166-
static void cptlf_disable_intrs(struct otx2_cptlfs_info *lfs)
167-
{
168-
int slot;
169-
170-
for (slot = 0; slot < lfs->lfs_num; slot++)
171-
otx2_cpt_write64(lfs->reg_base, lfs->blkaddr, slot,
172-
OTX2_CPT_LF_DONE_INT_ENA_W1C, 0x1);
173-
cptlf_set_misc_intrs(lfs, false);
161+
otx2_cpt_write64(lfs->reg_base, lfs->blkaddr, slot, reg, 0x1);
174162
}
175163

176164
static inline int cptlf_read_done_cnt(struct otx2_cptlf_info *lf)
@@ -257,24 +245,44 @@ static irqreturn_t cptlf_done_intr_handler(int irq, void *arg)
257245
return IRQ_HANDLED;
258246
}
259247

260-
void otx2_cptlf_unregister_interrupts(struct otx2_cptlfs_info *lfs)
248+
void otx2_cptlf_unregister_misc_interrupts(struct otx2_cptlfs_info *lfs)
261249
{
262-
int i, offs, vector;
250+
int i, irq_offs, vector;
263251

252+
irq_offs = OTX2_CPT_LF_INT_VEC_E_MISC;
264253
for (i = 0; i < lfs->lfs_num; i++) {
265-
for (offs = 0; offs < OTX2_CPT_LF_MSIX_VECTORS; offs++) {
266-
if (!lfs->lf[i].is_irq_reg[offs])
267-
continue;
254+
if (!lfs->lf[i].is_irq_reg[irq_offs])
255+
continue;
268256

269-
vector = pci_irq_vector(lfs->pdev,
270-
lfs->lf[i].msix_offset + offs);
271-
free_irq(vector, &lfs->lf[i]);
272-
lfs->lf[i].is_irq_reg[offs] = false;
273-
}
257+
vector = pci_irq_vector(lfs->pdev,
258+
lfs->lf[i].msix_offset + irq_offs);
259+
free_irq(vector, &lfs->lf[i]);
260+
lfs->lf[i].is_irq_reg[irq_offs] = false;
261+
}
262+
263+
cptlf_set_misc_intrs(lfs, false);
264+
}
265+
EXPORT_SYMBOL_NS_GPL(otx2_cptlf_unregister_misc_interrupts,
266+
CRYPTO_DEV_OCTEONTX2_CPT);
267+
268+
void otx2_cptlf_unregister_done_interrupts(struct otx2_cptlfs_info *lfs)
269+
{
270+
int i, irq_offs, vector;
271+
272+
irq_offs = OTX2_CPT_LF_INT_VEC_E_DONE;
273+
for (i = 0; i < lfs->lfs_num; i++) {
274+
if (!lfs->lf[i].is_irq_reg[irq_offs])
275+
continue;
276+
277+
vector = pci_irq_vector(lfs->pdev,
278+
lfs->lf[i].msix_offset + irq_offs);
279+
free_irq(vector, &lfs->lf[i]);
280+
lfs->lf[i].is_irq_reg[irq_offs] = false;
274281
}
275-
cptlf_disable_intrs(lfs);
282+
283+
cptlf_set_done_intrs(lfs, false);
276284
}
277-
EXPORT_SYMBOL_NS_GPL(otx2_cptlf_unregister_interrupts,
285+
EXPORT_SYMBOL_NS_GPL(otx2_cptlf_unregister_done_interrupts,
278286
CRYPTO_DEV_OCTEONTX2_CPT);
279287

280288
static int cptlf_do_register_interrrupts(struct otx2_cptlfs_info *lfs,
@@ -296,34 +304,53 @@ static int cptlf_do_register_interrrupts(struct otx2_cptlfs_info *lfs,
296304
return ret;
297305
}
298306

299-
int otx2_cptlf_register_interrupts(struct otx2_cptlfs_info *lfs)
307+
int otx2_cptlf_register_misc_interrupts(struct otx2_cptlfs_info *lfs)
300308
{
309+
bool is_cpt1 = (lfs->blkaddr == BLKADDR_CPT1);
301310
int irq_offs, ret, i;
302311

312+
irq_offs = OTX2_CPT_LF_INT_VEC_E_MISC;
303313
for (i = 0; i < lfs->lfs_num; i++) {
304-
irq_offs = OTX2_CPT_LF_INT_VEC_E_MISC;
305-
snprintf(lfs->lf[i].irq_name[irq_offs], 32, "CPTLF Misc%d", i);
314+
snprintf(lfs->lf[i].irq_name[irq_offs], 32, "CPT%dLF Misc%d",
315+
is_cpt1, i);
306316
ret = cptlf_do_register_interrrupts(lfs, i, irq_offs,
307317
cptlf_misc_intr_handler);
308318
if (ret)
309319
goto free_irq;
320+
}
321+
cptlf_set_misc_intrs(lfs, true);
322+
return 0;
310323

311-
irq_offs = OTX2_CPT_LF_INT_VEC_E_DONE;
312-
snprintf(lfs->lf[i].irq_name[irq_offs], 32, "OTX2_CPTLF Done%d",
313-
i);
324+
free_irq:
325+
otx2_cptlf_unregister_misc_interrupts(lfs);
326+
return ret;
327+
}
328+
EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_misc_interrupts,
329+
CRYPTO_DEV_OCTEONTX2_CPT);
330+
331+
int otx2_cptlf_register_done_interrupts(struct otx2_cptlfs_info *lfs)
332+
{
333+
bool is_cpt1 = (lfs->blkaddr == BLKADDR_CPT1);
334+
int irq_offs, ret, i;
335+
336+
irq_offs = OTX2_CPT_LF_INT_VEC_E_DONE;
337+
for (i = 0; i < lfs->lfs_num; i++) {
338+
snprintf(lfs->lf[i].irq_name[irq_offs], 32,
339+
"OTX2_CPT%dLF Done%d", is_cpt1, i);
314340
ret = cptlf_do_register_interrrupts(lfs, i, irq_offs,
315341
cptlf_done_intr_handler);
316342
if (ret)
317343
goto free_irq;
318344
}
319-
cptlf_enable_intrs(lfs);
345+
cptlf_set_done_intrs(lfs, true);
320346
return 0;
321347

322348
free_irq:
323-
otx2_cptlf_unregister_interrupts(lfs);
349+
otx2_cptlf_unregister_done_interrupts(lfs);
324350
return ret;
325351
}
326-
EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_interrupts, CRYPTO_DEV_OCTEONTX2_CPT);
352+
EXPORT_SYMBOL_NS_GPL(otx2_cptlf_register_done_interrupts,
353+
CRYPTO_DEV_OCTEONTX2_CPT);
327354

328355
void otx2_cptlf_free_irqs_affinity(struct otx2_cptlfs_info *lfs)
329356
{

drivers/crypto/marvell/octeontx2/otx2_cptlf.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,10 @@ static inline void otx2_cptlf_set_dev_info(struct otx2_cptlfs_info *lfs,
410410
int otx2_cptlf_init(struct otx2_cptlfs_info *lfs, u8 eng_grp_msk, int pri,
411411
int lfs_num);
412412
void otx2_cptlf_shutdown(struct otx2_cptlfs_info *lfs);
413-
int otx2_cptlf_register_interrupts(struct otx2_cptlfs_info *lfs);
414-
void otx2_cptlf_unregister_interrupts(struct otx2_cptlfs_info *lfs);
413+
int otx2_cptlf_register_misc_interrupts(struct otx2_cptlfs_info *lfs);
414+
int otx2_cptlf_register_done_interrupts(struct otx2_cptlfs_info *lfs);
415+
void otx2_cptlf_unregister_misc_interrupts(struct otx2_cptlfs_info *lfs);
416+
void otx2_cptlf_unregister_done_interrupts(struct otx2_cptlfs_info *lfs);
415417
void otx2_cptlf_free_irqs_affinity(struct otx2_cptlfs_info *lfs);
416418
int otx2_cptlf_set_irqs_affinity(struct otx2_cptlfs_info *lfs);
417419

drivers/crypto/marvell/octeontx2/otx2_cptpf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ void otx2_cptpf_afpf_mbox_up_handler(struct work_struct *work);
7171
irqreturn_t otx2_cptpf_vfpf_mbox_intr(int irq, void *arg);
7272
void otx2_cptpf_vfpf_mbox_handler(struct work_struct *work);
7373

74+
int otx2_inline_cptlf_setup(struct otx2_cptpf_dev *cptpf,
75+
struct otx2_cptlfs_info *lfs, u8 egrp, int num_lfs);
76+
void otx2_inline_cptlf_cleanup(struct otx2_cptlfs_info *lfs);
77+
7478
#endif /* __OTX2_CPTPF_H */

drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ static int otx2_cptpf_probe(struct pci_dev *pdev,
722722
{
723723
struct device *dev = &pdev->dev;
724724
struct otx2_cptpf_dev *cptpf;
725-
int err;
725+
int err, num_vec;
726726

727727
cptpf = devm_kzalloc(dev, sizeof(*cptpf), GFP_KERNEL);
728728
if (!cptpf)
@@ -757,8 +757,13 @@ static int otx2_cptpf_probe(struct pci_dev *pdev,
757757
if (err)
758758
goto clear_drvdata;
759759

760-
err = pci_alloc_irq_vectors(pdev, RVU_PF_INT_VEC_CNT,
761-
RVU_PF_INT_VEC_CNT, PCI_IRQ_MSIX);
760+
num_vec = pci_msix_vec_count(cptpf->pdev);
761+
if (num_vec <= 0) {
762+
err = -EINVAL;
763+
goto clear_drvdata;
764+
}
765+
766+
err = pci_alloc_irq_vectors(pdev, num_vec, num_vec, PCI_IRQ_MSIX);
762767
if (err < 0) {
763768
dev_err(dev, "Request for %d msix vectors failed\n",
764769
RVU_PF_INT_VEC_CNT);
@@ -823,6 +828,14 @@ static void otx2_cptpf_remove(struct pci_dev *pdev)
823828

824829
cptpf_sriov_disable(pdev);
825830
otx2_cpt_unregister_dl(cptpf);
831+
832+
/* Cleanup Inline CPT LF's if attached */
833+
if (cptpf->lfs.lfs_num)
834+
otx2_inline_cptlf_cleanup(&cptpf->lfs);
835+
836+
if (cptpf->cpt1_lfs.lfs_num)
837+
otx2_inline_cptlf_cleanup(&cptpf->cpt1_lfs);
838+
826839
/* Delete sysfs entry created for kernel VF limits */
827840
sysfs_remove_group(&pdev->dev.kobj, &cptpf_sysfs_group);
828841
/* Cleanup engine groups */

drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,47 @@ static int rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf, u8 egrp,
197197
return send_inline_ipsec_inbound_msg(cptpf, req->sso_pf_func, 0);
198198
}
199199

200+
int
201+
otx2_inline_cptlf_setup(struct otx2_cptpf_dev *cptpf,
202+
struct otx2_cptlfs_info *lfs, u8 egrp, int num_lfs)
203+
{
204+
int ret;
205+
206+
ret = otx2_cptlf_init(lfs, 1 << egrp, OTX2_CPT_QUEUE_HI_PRIO, 1);
207+
if (ret) {
208+
dev_err(&cptpf->pdev->dev,
209+
"LF configuration failed for RX inline ipsec.\n");
210+
return ret;
211+
}
212+
213+
/* Get msix offsets for attached LFs */
214+
ret = otx2_cpt_msix_offset_msg(lfs);
215+
if (ret)
216+
goto cleanup_lf;
217+
218+
/* Register for CPT LF Misc interrupts */
219+
ret = otx2_cptlf_register_misc_interrupts(lfs);
220+
if (ret)
221+
goto free_irq;
222+
223+
return 0;
224+
free_irq:
225+
otx2_cptlf_unregister_misc_interrupts(lfs);
226+
cleanup_lf:
227+
otx2_cptlf_shutdown(lfs);
228+
return ret;
229+
}
230+
231+
void
232+
otx2_inline_cptlf_cleanup(struct otx2_cptlfs_info *lfs)
233+
{
234+
/* Unregister misc interrupt */
235+
otx2_cptlf_unregister_misc_interrupts(lfs);
236+
237+
/* Cleanup LFs */
238+
otx2_cptlf_shutdown(lfs);
239+
}
240+
200241
static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,
201242
struct mbox_msghdr *req)
202243
{
@@ -224,11 +265,9 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,
224265
otx2_cptlf_set_dev_info(&cptpf->lfs, cptpf->pdev, cptpf->reg_base,
225266
&cptpf->afpf_mbox, BLKADDR_CPT0);
226267
cptpf->lfs.global_slot = 0;
227-
ret = otx2_cptlf_init(&cptpf->lfs, 1 << egrp, OTX2_CPT_QUEUE_HI_PRIO,
228-
num_lfs);
268+
ret = otx2_inline_cptlf_setup(cptpf, &cptpf->lfs, egrp, num_lfs);
229269
if (ret) {
230-
dev_err(&cptpf->pdev->dev,
231-
"LF configuration failed for RX inline ipsec.\n");
270+
dev_err(&cptpf->pdev->dev, "Inline-Ipsec CPT0 LF setup failed.\n");
232271
return ret;
233272
}
234273

@@ -238,11 +277,10 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,
238277
cptpf->reg_base, &cptpf->afpf_mbox,
239278
BLKADDR_CPT1);
240279
cptpf->cpt1_lfs.global_slot = num_lfs;
241-
ret = otx2_cptlf_init(&cptpf->cpt1_lfs, 1 << egrp,
242-
OTX2_CPT_QUEUE_HI_PRIO, num_lfs);
280+
ret = otx2_inline_cptlf_setup(cptpf, &cptpf->cpt1_lfs, egrp,
281+
num_lfs);
243282
if (ret) {
244-
dev_err(&cptpf->pdev->dev,
245-
"LF configuration failed for RX inline ipsec.\n");
283+
dev_err(&cptpf->pdev->dev, "Inline CPT1 LF setup failed.\n");
246284
goto lf_cleanup;
247285
}
248286
cptpf->rsrc_req_blkaddr = 0;
@@ -255,9 +293,9 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,
255293
return 0;
256294

257295
lf1_cleanup:
258-
otx2_cptlf_shutdown(&cptpf->cpt1_lfs);
296+
otx2_inline_cptlf_cleanup(&cptpf->cpt1_lfs);
259297
lf_cleanup:
260-
otx2_cptlf_shutdown(&cptpf->lfs);
298+
otx2_inline_cptlf_cleanup(&cptpf->lfs);
261299
return ret;
262300
}
263301

@@ -412,6 +450,8 @@ static void process_afpf_mbox_msg(struct otx2_cptpf_dev *cptpf,
412450
struct otx2_cptlfs_info *lfs = &cptpf->lfs;
413451
struct device *dev = &cptpf->pdev->dev;
414452
struct cpt_rd_wr_reg_msg *rsp_rd_wr;
453+
struct msix_offset_rsp *rsp_msix;
454+
int i;
415455

416456
if (msg->id >= MBOX_MSG_MAX) {
417457
dev_err(dev, "MBOX msg with unknown ID %d\n", msg->id);
@@ -430,6 +470,14 @@ static void process_afpf_mbox_msg(struct otx2_cptpf_dev *cptpf,
430470
cptpf->pf_id = (msg->pcifunc >> RVU_PFVF_PF_SHIFT) &
431471
RVU_PFVF_PF_MASK;
432472
break;
473+
case MBOX_MSG_MSIX_OFFSET:
474+
rsp_msix = (struct msix_offset_rsp *) msg;
475+
for (i = 0; i < rsp_msix->cptlfs; i++)
476+
lfs->lf[i].msix_offset = rsp_msix->cptlf_msixoff[i];
477+
478+
for (i = 0; i < rsp_msix->cpt1_lfs; i++)
479+
lfs->lf[i].msix_offset = rsp_msix->cpt1_lf_msixoff[i];
480+
break;
433481
case MBOX_MSG_CPT_RD_WR_REGISTER:
434482
rsp_rd_wr = (struct cpt_rd_wr_reg_msg *)msg;
435483
if (msg->rc) {

drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ static void cptvf_lf_shutdown(struct otx2_cptlfs_info *lfs)
246246
/* Unregister crypto algorithms */
247247
otx2_cpt_crypto_exit(lfs->pdev, THIS_MODULE);
248248
/* Unregister LFs interrupts */
249-
otx2_cptlf_unregister_interrupts(lfs);
249+
otx2_cptlf_unregister_misc_interrupts(lfs);
250+
otx2_cptlf_unregister_done_interrupts(lfs);
250251
/* Cleanup LFs software side */
251252
lf_sw_cleanup(lfs);
252253
/* Free instruction queues */
@@ -300,7 +301,11 @@ static int cptvf_lf_init(struct otx2_cptvf_dev *cptvf)
300301
goto cleanup_lf;
301302

302303
/* Register LFs interrupts */
303-
ret = otx2_cptlf_register_interrupts(lfs);
304+
ret = otx2_cptlf_register_misc_interrupts(lfs);
305+
if (ret)
306+
goto cleanup_lf_sw;
307+
308+
ret = otx2_cptlf_register_done_interrupts(lfs);
304309
if (ret)
305310
goto cleanup_lf_sw;
306311

@@ -321,7 +326,8 @@ static int cptvf_lf_init(struct otx2_cptvf_dev *cptvf)
321326
disable_irqs:
322327
otx2_cptlf_free_irqs_affinity(lfs);
323328
unregister_intr:
324-
otx2_cptlf_unregister_interrupts(lfs);
329+
otx2_cptlf_unregister_misc_interrupts(lfs);
330+
otx2_cptlf_unregister_done_interrupts(lfs);
325331
cleanup_lf_sw:
326332
lf_sw_cleanup(lfs);
327333
cleanup_lf:

0 commit comments

Comments
 (0)