Skip to content

Commit 6450601

Browse files
SruChallaherbertx
authored andcommitted
crypto: octeontx2 - add LF framework
CPT RVU Local Functions(LFs) needs to be attached to the PF/VF to submit the instructions to CPT. This patch adds the interface to initialize and attach the LFs. It also adds interface to register the LF's interrupts. Signed-off-by: Suheil Chandran <schandran@marvell.com> Signed-off-by: Lukasz Bartosik <lbartosik@marvell.com> Signed-off-by: Srujana Challa <schalla@marvell.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 43ac0b8 commit 6450601

File tree

7 files changed

+783
-1
lines changed

7 files changed

+783
-1
lines changed

drivers/crypto/marvell/octeontx2/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
obj-$(CONFIG_CRYPTO_DEV_OCTEONTX2_CPT) += octeontx2-cpt.o
33

44
octeontx2-cpt-objs := otx2_cptpf_main.o otx2_cptpf_mbox.o \
5-
otx2_cpt_mbox_common.o otx2_cptpf_ucode.o
5+
otx2_cpt_mbox_common.o otx2_cptpf_ucode.o otx2_cptlf.o
66

77
ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af

drivers/crypto/marvell/octeontx2/otx2_cpt_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,8 @@ int otx2_cpt_read_af_reg(struct otx2_mbox *mbox, struct pci_dev *pdev,
7676
u64 reg, u64 *val);
7777
int otx2_cpt_write_af_reg(struct otx2_mbox *mbox, struct pci_dev *pdev,
7878
u64 reg, u64 val);
79+
struct otx2_cptlfs_info;
80+
int otx2_cpt_attach_rscrs_msg(struct otx2_cptlfs_info *lfs);
81+
int otx2_cpt_detach_rsrcs_msg(struct otx2_cptlfs_info *lfs);
82+
7983
#endif /* __OTX2_CPT_COMMON_H */

drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright (C) 2020 Marvell. */
33

44
#include "otx2_cpt_common.h"
5+
#include "otx2_cptlf.h"
56

67
int otx2_cpt_send_mbox_msg(struct otx2_mbox *mbox, struct pci_dev *pdev)
78
{
@@ -112,3 +113,58 @@ int otx2_cpt_write_af_reg(struct otx2_mbox *mbox, struct pci_dev *pdev,
112113

113114
return otx2_cpt_send_mbox_msg(mbox, pdev);
114115
}
116+
117+
int otx2_cpt_attach_rscrs_msg(struct otx2_cptlfs_info *lfs)
118+
{
119+
struct otx2_mbox *mbox = lfs->mbox;
120+
struct rsrc_attach *req;
121+
int ret;
122+
123+
req = (struct rsrc_attach *)
124+
otx2_mbox_alloc_msg_rsp(mbox, 0, sizeof(*req),
125+
sizeof(struct msg_rsp));
126+
if (req == NULL) {
127+
dev_err(&lfs->pdev->dev, "RVU MBOX failed to get message.\n");
128+
return -EFAULT;
129+
}
130+
131+
req->hdr.id = MBOX_MSG_ATTACH_RESOURCES;
132+
req->hdr.sig = OTX2_MBOX_REQ_SIG;
133+
req->hdr.pcifunc = 0;
134+
req->cptlfs = lfs->lfs_num;
135+
ret = otx2_cpt_send_mbox_msg(mbox, lfs->pdev);
136+
if (ret)
137+
return ret;
138+
139+
if (!lfs->are_lfs_attached)
140+
ret = -EINVAL;
141+
142+
return ret;
143+
}
144+
145+
int otx2_cpt_detach_rsrcs_msg(struct otx2_cptlfs_info *lfs)
146+
{
147+
struct otx2_mbox *mbox = lfs->mbox;
148+
struct rsrc_detach *req;
149+
int ret;
150+
151+
req = (struct rsrc_detach *)
152+
otx2_mbox_alloc_msg_rsp(mbox, 0, sizeof(*req),
153+
sizeof(struct msg_rsp));
154+
if (req == NULL) {
155+
dev_err(&lfs->pdev->dev, "RVU MBOX failed to get message.\n");
156+
return -EFAULT;
157+
}
158+
159+
req->hdr.id = MBOX_MSG_DETACH_RESOURCES;
160+
req->hdr.sig = OTX2_MBOX_REQ_SIG;
161+
req->hdr.pcifunc = 0;
162+
ret = otx2_cpt_send_mbox_msg(mbox, lfs->pdev);
163+
if (ret)
164+
return ret;
165+
166+
if (lfs->are_lfs_attached)
167+
ret = -EINVAL;
168+
169+
return ret;
170+
}

0 commit comments

Comments
 (0)