Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: octeontx2 - add support for AF to CPT PF uplink mbox

This patch adds support for AF -> CPT PF uplink mailbox messages
and adds a mailbox handler to submit a CPT instruction from AF as
current architecture doesn't allow AF to submit CPT instruction
directly to HW.

Signed-off-by: Srujana Challa <schalla@marvell.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Srujana Challa and committed by
Herbert Xu
5c553114 dee3590c

+98 -2
+4
drivers/crypto/marvell/octeontx2/otx2_cptpf.h
··· 40 40 struct work_struct afpf_mbox_work; 41 41 struct workqueue_struct *afpf_mbox_wq; 42 42 43 + struct otx2_mbox afpf_mbox_up; 44 + struct work_struct afpf_mbox_up_work; 45 + 43 46 /* VF <=> PF mbox */ 44 47 struct otx2_mbox vfpf_mbox; 45 48 struct workqueue_struct *vfpf_mbox_wq; ··· 64 61 65 62 irqreturn_t otx2_cptpf_afpf_mbox_intr(int irq, void *arg); 66 63 void otx2_cptpf_afpf_mbox_handler(struct work_struct *work); 64 + void otx2_cptpf_afpf_mbox_up_handler(struct work_struct *work); 67 65 irqreturn_t otx2_cptpf_vfpf_mbox_intr(int irq, void *arg); 68 66 void otx2_cptpf_vfpf_mbox_handler(struct work_struct *work); 69 67
+10
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
··· 473 473 if (err) 474 474 goto error; 475 475 476 + err = otx2_mbox_init(&cptpf->afpf_mbox_up, cptpf->afpf_mbox_base, 477 + pdev, cptpf->reg_base, MBOX_DIR_PFAF_UP, 1); 478 + if (err) 479 + goto mbox_cleanup; 480 + 476 481 INIT_WORK(&cptpf->afpf_mbox_work, otx2_cptpf_afpf_mbox_handler); 482 + INIT_WORK(&cptpf->afpf_mbox_up_work, otx2_cptpf_afpf_mbox_up_handler); 477 483 mutex_init(&cptpf->lock); 484 + 478 485 return 0; 479 486 487 + mbox_cleanup: 488 + otx2_mbox_destroy(&cptpf->afpf_mbox); 480 489 error: 481 490 destroy_workqueue(cptpf->afpf_mbox_wq); 482 491 return err; ··· 495 486 { 496 487 destroy_workqueue(cptpf->afpf_mbox_wq); 497 488 otx2_mbox_destroy(&cptpf->afpf_mbox); 489 + otx2_mbox_destroy(&cptpf->afpf_mbox_up); 498 490 } 499 491 500 492 static ssize_t kvf_limits_show(struct device *dev,
+84 -2
drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c
··· 224 224 irqreturn_t otx2_cptpf_afpf_mbox_intr(int __always_unused irq, void *arg) 225 225 { 226 226 struct otx2_cptpf_dev *cptpf = arg; 227 + struct otx2_mbox_dev *mdev; 228 + struct otx2_mbox *mbox; 229 + struct mbox_hdr *hdr; 227 230 u64 intr; 228 231 229 232 /* Read the interrupt bits */ 230 233 intr = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT); 231 234 232 235 if (intr & 0x1ULL) { 233 - /* Schedule work queue function to process the MBOX request */ 234 - queue_work(cptpf->afpf_mbox_wq, &cptpf->afpf_mbox_work); 236 + mbox = &cptpf->afpf_mbox; 237 + mdev = &mbox->dev[0]; 238 + hdr = mdev->mbase + mbox->rx_start; 239 + if (hdr->num_msgs) 240 + /* Schedule work queue function to process the MBOX request */ 241 + queue_work(cptpf->afpf_mbox_wq, &cptpf->afpf_mbox_work); 242 + 243 + mbox = &cptpf->afpf_mbox_up; 244 + mdev = &mbox->dev[0]; 245 + hdr = mdev->mbase + mbox->rx_start; 246 + if (hdr->num_msgs) 247 + /* Schedule work queue function to process the MBOX request */ 248 + queue_work(cptpf->afpf_mbox_wq, &cptpf->afpf_mbox_up_work); 235 249 /* Clear and ack the interrupt */ 236 250 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT, 237 251 0x1ULL); ··· 380 366 mdev->msgs_acked++; 381 367 } 382 368 otx2_mbox_reset(afpf_mbox, 0); 369 + } 370 + 371 + static void handle_msg_cpt_inst_lmtst(struct otx2_cptpf_dev *cptpf, 372 + struct mbox_msghdr *msg) 373 + { 374 + struct cpt_inst_lmtst_req *req = (struct cpt_inst_lmtst_req *)msg; 375 + struct otx2_cptlfs_info *lfs = &cptpf->lfs; 376 + struct msg_rsp *rsp; 377 + 378 + if (cptpf->lfs.lfs_num) 379 + lfs->ops->send_cmd((union otx2_cpt_inst_s *)req->inst, 1, 380 + &lfs->lf[0]); 381 + 382 + rsp = (struct msg_rsp *)otx2_mbox_alloc_msg(&cptpf->afpf_mbox_up, 0, 383 + sizeof(*rsp)); 384 + if (!rsp) 385 + return; 386 + 387 + rsp->hdr.id = msg->id; 388 + rsp->hdr.sig = OTX2_MBOX_RSP_SIG; 389 + rsp->hdr.pcifunc = 0; 390 + rsp->hdr.rc = 0; 391 + } 392 + 393 + static void process_afpf_mbox_up_msg(struct otx2_cptpf_dev *cptpf, 394 + struct mbox_msghdr *msg) 395 + { 396 + if (msg->id >= MBOX_MSG_MAX) { 397 + dev_err(&cptpf->pdev->dev, 398 + "MBOX msg with unknown ID %d\n", msg->id); 399 + return; 400 + } 401 + 402 + switch (msg->id) { 403 + case MBOX_MSG_CPT_INST_LMTST: 404 + handle_msg_cpt_inst_lmtst(cptpf, msg); 405 + break; 406 + default: 407 + otx2_reply_invalid_msg(&cptpf->afpf_mbox_up, 0, 0, msg->id); 408 + } 409 + } 410 + 411 + void otx2_cptpf_afpf_mbox_up_handler(struct work_struct *work) 412 + { 413 + struct otx2_cptpf_dev *cptpf; 414 + struct otx2_mbox_dev *mdev; 415 + struct mbox_hdr *rsp_hdr; 416 + struct mbox_msghdr *msg; 417 + struct otx2_mbox *mbox; 418 + int offset, i; 419 + 420 + cptpf = container_of(work, struct otx2_cptpf_dev, afpf_mbox_up_work); 421 + mbox = &cptpf->afpf_mbox_up; 422 + mdev = &mbox->dev[0]; 423 + /* Sync mbox data into memory */ 424 + smp_wmb(); 425 + 426 + rsp_hdr = (struct mbox_hdr *)(mdev->mbase + mbox->rx_start); 427 + offset = mbox->rx_start + ALIGN(sizeof(*rsp_hdr), MBOX_MSG_ALIGN); 428 + 429 + for (i = 0; i < rsp_hdr->num_msgs; i++) { 430 + msg = (struct mbox_msghdr *)(mdev->mbase + offset); 431 + 432 + process_afpf_mbox_up_msg(cptpf, msg); 433 + 434 + offset = mbox->rx_start + msg->next_msgoff; 435 + } 436 + otx2_mbox_msg_send(mbox, 0); 383 437 }