Lines Matching +full:mbox +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
13 cptvf->bbuf_base = devm_kmalloc(&pdev->dev, MBOX_SIZE, GFP_KERNEL); in otx2_cpt_mbox_bbuf_init()
14 if (!cptvf->bbuf_base) in otx2_cpt_mbox_bbuf_init()
15 return -ENOMEM; in otx2_cpt_mbox_bbuf_init()
17 * Overwrite mbox mbase to point to bounce buffer, so that PF/VF in otx2_cpt_mbox_bbuf_init()
18 * prepare all mbox messages in bounce buffer instead of directly in otx2_cpt_mbox_bbuf_init()
19 * in hw mbox memory. in otx2_cpt_mbox_bbuf_init()
21 otx2_mbox = &cptvf->pfvf_mbox; in otx2_cpt_mbox_bbuf_init()
22 mdev = &otx2_mbox->dev[0]; in otx2_cpt_mbox_bbuf_init()
23 mdev->mbase = cptvf->bbuf_base; in otx2_cpt_mbox_bbuf_init()
28 static void otx2_cpt_sync_mbox_bbuf(struct otx2_mbox *mbox, int devid) in otx2_cpt_sync_mbox_bbuf() argument
31 void *hw_mbase = mbox->hwbase + (devid * MBOX_SIZE); in otx2_cpt_sync_mbox_bbuf()
32 struct otx2_mbox_dev *mdev = &mbox->dev[devid]; in otx2_cpt_sync_mbox_bbuf()
36 if (mdev->mbase == hw_mbase) in otx2_cpt_sync_mbox_bbuf()
39 hdr = hw_mbase + mbox->rx_start; in otx2_cpt_sync_mbox_bbuf()
40 msg_size = hdr->msg_size; in otx2_cpt_sync_mbox_bbuf()
42 if (msg_size > mbox->rx_size - msgs_offset) in otx2_cpt_sync_mbox_bbuf()
43 msg_size = mbox->rx_size - msgs_offset; in otx2_cpt_sync_mbox_bbuf()
45 /* Copy mbox messages from mbox memory to bounce buffer */ in otx2_cpt_sync_mbox_bbuf()
46 memcpy(mdev->mbase + mbox->rx_start, in otx2_cpt_sync_mbox_bbuf()
47 hw_mbase + mbox->rx_start, msg_size + msgs_offset); in otx2_cpt_sync_mbox_bbuf()
56 intr = otx2_cpt_read64(cptvf->reg_base, BLKADDR_RVUM, 0, in otx2_cptvf_pfvf_mbox_intr()
60 /* Schedule work queue function to process the MBOX request */ in otx2_cptvf_pfvf_mbox_intr()
61 queue_work(cptvf->pfvf_mbox_wq, &cptvf->pfvf_mbox_work); in otx2_cptvf_pfvf_mbox_intr()
63 otx2_cpt_write64(cptvf->reg_base, BLKADDR_RVUM, 0, in otx2_cptvf_pfvf_mbox_intr()
72 struct otx2_cptlfs_info *lfs = &cptvf->lfs; in process_pfvf_mbox_mbox_msg()
80 if (msg->id >= MBOX_MSG_MAX) { in process_pfvf_mbox_mbox_msg()
81 dev_err(&cptvf->pdev->dev, in process_pfvf_mbox_mbox_msg()
82 "MBOX msg with unknown ID %d\n", msg->id); in process_pfvf_mbox_mbox_msg()
85 if (msg->sig != OTX2_MBOX_RSP_SIG) { in process_pfvf_mbox_mbox_msg()
86 dev_err(&cptvf->pdev->dev, in process_pfvf_mbox_mbox_msg()
87 "MBOX msg with wrong signature %x, ID %d\n", in process_pfvf_mbox_mbox_msg()
88 msg->sig, msg->id); in process_pfvf_mbox_mbox_msg()
91 switch (msg->id) { in process_pfvf_mbox_mbox_msg()
93 cptvf->vf_id = ((msg->pcifunc >> RVU_PFVF_FUNC_SHIFT) in process_pfvf_mbox_mbox_msg()
94 & RVU_PFVF_FUNC_MASK) - 1; in process_pfvf_mbox_mbox_msg()
98 if (!msg->rc) in process_pfvf_mbox_mbox_msg()
99 lfs->are_lfs_attached = 1; in process_pfvf_mbox_mbox_msg()
103 if (!msg->rc) in process_pfvf_mbox_mbox_msg()
104 lfs->are_lfs_attached = 0; in process_pfvf_mbox_mbox_msg()
108 for (i = 0; i < rsp_msix->cptlfs; i++) in process_pfvf_mbox_mbox_msg()
109 lfs->lf[i].msix_offset = rsp_msix->cptlf_msixoff[i]; in process_pfvf_mbox_mbox_msg()
113 if (msg->rc) { in process_pfvf_mbox_mbox_msg()
114 dev_err(&cptvf->pdev->dev, in process_pfvf_mbox_mbox_msg()
116 rsp_reg->reg_offset, rsp_reg->is_write, in process_pfvf_mbox_mbox_msg()
117 msg->rc); in process_pfvf_mbox_mbox_msg()
120 if (!rsp_reg->is_write) in process_pfvf_mbox_mbox_msg()
121 *rsp_reg->ret_val = rsp_reg->val; in process_pfvf_mbox_mbox_msg()
125 cptvf->lfs.kcrypto_eng_grp_num = rsp_grp->eng_grp_num; in process_pfvf_mbox_mbox_msg()
129 cptvf->lfs.kvf_limits = rsp_limits->kvf_limits; in process_pfvf_mbox_mbox_msg()
133 memcpy(cptvf->eng_caps, eng_caps->eng_caps, in process_pfvf_mbox_mbox_msg()
134 sizeof(cptvf->eng_caps)); in process_pfvf_mbox_mbox_msg()
139 dev_err(&cptvf->pdev->dev, "Unsupported msg %d received.\n", in process_pfvf_mbox_mbox_msg()
140 msg->id); in process_pfvf_mbox_mbox_msg()
154 /* sync with mbox memory region */ in otx2_cptvf_pfvf_mbox_handler()
158 pfvf_mbox = &cptvf->pfvf_mbox; in otx2_cptvf_pfvf_mbox_handler()
160 mdev = &pfvf_mbox->dev[0]; in otx2_cptvf_pfvf_mbox_handler()
161 rsp_hdr = (struct mbox_hdr *)(mdev->mbase + pfvf_mbox->rx_start); in otx2_cptvf_pfvf_mbox_handler()
162 if (rsp_hdr->num_msgs == 0) in otx2_cptvf_pfvf_mbox_handler()
166 for (i = 0; i < rsp_hdr->num_msgs; i++) { in otx2_cptvf_pfvf_mbox_handler()
167 msg = (struct mbox_msghdr *)(mdev->mbase + pfvf_mbox->rx_start + in otx2_cptvf_pfvf_mbox_handler()
170 offset = msg->next_msgoff; in otx2_cptvf_pfvf_mbox_handler()
171 mdev->msgs_acked++; in otx2_cptvf_pfvf_mbox_handler()
178 struct otx2_mbox *mbox = &cptvf->pfvf_mbox; in otx2_cptvf_send_eng_grp_num_msg() local
179 struct pci_dev *pdev = cptvf->pdev; in otx2_cptvf_send_eng_grp_num_msg()
183 otx2_mbox_alloc_msg_rsp(mbox, 0, sizeof(*req), in otx2_cptvf_send_eng_grp_num_msg()
186 dev_err(&pdev->dev, "RVU MBOX failed to get message.\n"); in otx2_cptvf_send_eng_grp_num_msg()
187 return -EFAULT; in otx2_cptvf_send_eng_grp_num_msg()
189 req->hdr.id = MBOX_MSG_GET_ENG_GRP_NUM; in otx2_cptvf_send_eng_grp_num_msg()
190 req->hdr.sig = OTX2_MBOX_REQ_SIG; in otx2_cptvf_send_eng_grp_num_msg()
191 req->hdr.pcifunc = OTX2_CPT_RVU_PFFUNC(cptvf->vf_id, 0); in otx2_cptvf_send_eng_grp_num_msg()
192 req->eng_type = eng_type; in otx2_cptvf_send_eng_grp_num_msg()
194 return otx2_cpt_send_mbox_msg(mbox, pdev); in otx2_cptvf_send_eng_grp_num_msg()
199 struct otx2_mbox *mbox = &cptvf->pfvf_mbox; in otx2_cptvf_send_kvf_limits_msg() local
200 struct pci_dev *pdev = cptvf->pdev; in otx2_cptvf_send_kvf_limits_msg()
204 otx2_mbox_alloc_msg_rsp(mbox, 0, sizeof(*req), in otx2_cptvf_send_kvf_limits_msg()
207 dev_err(&pdev->dev, "RVU MBOX failed to get message.\n"); in otx2_cptvf_send_kvf_limits_msg()
208 return -EFAULT; in otx2_cptvf_send_kvf_limits_msg()
210 req->id = MBOX_MSG_GET_KVF_LIMITS; in otx2_cptvf_send_kvf_limits_msg()
211 req->sig = OTX2_MBOX_REQ_SIG; in otx2_cptvf_send_kvf_limits_msg()
212 req->pcifunc = OTX2_CPT_RVU_PFFUNC(cptvf->vf_id, 0); in otx2_cptvf_send_kvf_limits_msg()
214 return otx2_cpt_send_mbox_msg(mbox, pdev); in otx2_cptvf_send_kvf_limits_msg()
219 struct otx2_mbox *mbox = &cptvf->pfvf_mbox; in otx2_cptvf_send_caps_msg() local
220 struct pci_dev *pdev = cptvf->pdev; in otx2_cptvf_send_caps_msg()
224 otx2_mbox_alloc_msg_rsp(mbox, 0, sizeof(*req), in otx2_cptvf_send_caps_msg()
227 dev_err(&pdev->dev, "RVU MBOX failed to get message.\n"); in otx2_cptvf_send_caps_msg()
228 return -EFAULT; in otx2_cptvf_send_caps_msg()
230 req->id = MBOX_MSG_GET_CAPS; in otx2_cptvf_send_caps_msg()
231 req->sig = OTX2_MBOX_REQ_SIG; in otx2_cptvf_send_caps_msg()
232 req->pcifunc = OTX2_CPT_RVU_PFFUNC(cptvf->vf_id, 0); in otx2_cptvf_send_caps_msg()
234 return otx2_cpt_send_mbox_msg(mbox, pdev); in otx2_cptvf_send_caps_msg()