Skip to content

Commit 92508e7

Browse files
SruChallaherbertx
authored andcommitted
crypto: octeontx2 - add SGv2 support for CN10KB or CN10KA B0
Scatter Gather input format for CPT has changed on CN10KB/CN10KA B0 HW to make it compatible with NIX Scatter Gather format to support SG mode for inline IPsec. This patch modifies the code to make the driver works for the same. This patch also enables CPT firmware load for these chips. Signed-off-by: Srujana Challa <schalla@marvell.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 711b2e2 commit 92508e7

File tree

14 files changed

+436
-175
lines changed

14 files changed

+436
-175
lines changed

drivers/crypto/marvell/octeontx2/cn10k_cpt.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ static struct cpt_hw_ops otx2_hw_ops = {
1414
.send_cmd = otx2_cpt_send_cmd,
1515
.cpt_get_compcode = otx2_cpt_get_compcode,
1616
.cpt_get_uc_compcode = otx2_cpt_get_uc_compcode,
17+
.cpt_sg_info_create = otx2_sg_info_create,
1718
};
1819

1920
static struct cpt_hw_ops cn10k_hw_ops = {
2021
.send_cmd = cn10k_cpt_send_cmd,
2122
.cpt_get_compcode = cn10k_cpt_get_compcode,
2223
.cpt_get_uc_compcode = cn10k_cpt_get_uc_compcode,
24+
.cpt_sg_info_create = otx2_sg_info_create,
2325
};
2426

2527
static void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 insts_num,
@@ -78,12 +80,9 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)
7880
struct pci_dev *pdev = cptvf->pdev;
7981
resource_size_t offset, size;
8082

81-
if (!test_bit(CN10K_LMTST, &cptvf->cap_flag)) {
82-
cptvf->lfs.ops = &otx2_hw_ops;
83+
if (!test_bit(CN10K_LMTST, &cptvf->cap_flag))
8384
return 0;
84-
}
8585

86-
cptvf->lfs.ops = &cn10k_hw_ops;
8786
offset = pci_resource_start(pdev, PCI_MBOX_BAR_NUM);
8887
size = pci_resource_len(pdev, PCI_MBOX_BAR_NUM);
8988
/* Map VF LMILINE region */
@@ -96,3 +95,12 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)
9695
return 0;
9796
}
9897
EXPORT_SYMBOL_NS_GPL(cn10k_cptvf_lmtst_init, CRYPTO_DEV_OCTEONTX2_CPT);
98+
99+
void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf)
100+
{
101+
if (test_bit(CN10K_LMTST, &cptvf->cap_flag))
102+
cptvf->lfs.ops = &cn10k_hw_ops;
103+
else
104+
cptvf->lfs.ops = &otx2_hw_ops;
105+
}
106+
EXPORT_SYMBOL_NS_GPL(cptvf_hw_ops_get, CRYPTO_DEV_OCTEONTX2_CPT);

drivers/crypto/marvell/octeontx2/cn10k_cpt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ static inline u8 otx2_cpt_get_uc_compcode(union otx2_cpt_res_s *result)
3030

3131
int cn10k_cptpf_lmtst_init(struct otx2_cptpf_dev *cptpf);
3232
int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf);
33+
void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf);
3334

3435
#endif /* __CN10K_CPTLF_H */

drivers/crypto/marvell/octeontx2/otx2_cpt_common.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ union otx2_cpt_eng_caps {
102102
u64 kasumi:1;
103103
u64 des:1;
104104
u64 crc:1;
105-
u64 reserved_14_63:50;
105+
u64 mmul:1;
106+
u64 reserved_15_33:19;
107+
u64 pdcp_chain:1;
108+
u64 reserved_35_63:29;
106109
};
107110
};
108111

@@ -145,6 +148,35 @@ static inline bool is_dev_otx2(struct pci_dev *pdev)
145148
return false;
146149
}
147150

151+
static inline bool is_dev_cn10ka(struct pci_dev *pdev)
152+
{
153+
return pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_A;
154+
}
155+
156+
static inline bool is_dev_cn10ka_ax(struct pci_dev *pdev)
157+
{
158+
if (pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_A &&
159+
((pdev->revision & 0xFF) == 4 || (pdev->revision & 0xFF) == 0x50 ||
160+
(pdev->revision & 0xff) == 0x51))
161+
return true;
162+
163+
return false;
164+
}
165+
166+
static inline bool is_dev_cn10kb(struct pci_dev *pdev)
167+
{
168+
return pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_B;
169+
}
170+
171+
static inline bool is_dev_cn10ka_b0(struct pci_dev *pdev)
172+
{
173+
if (pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_A &&
174+
(pdev->revision & 0xFF) == 0x54)
175+
return true;
176+
177+
return false;
178+
}
179+
148180
static inline void otx2_cpt_set_hw_caps(struct pci_dev *pdev,
149181
unsigned long *cap_flag)
150182
{

drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#define CN10K_CPT_PCI_PF_DEVICE_ID 0xA0F2
1414
#define CN10K_CPT_PCI_VF_DEVICE_ID 0xA0F3
1515

16+
#define CPT_PCI_SUBSYS_DEVID_CN10K_A 0xB900
17+
#define CPT_PCI_SUBSYS_DEVID_CN10K_B 0xBD00
18+
1619
/* Mailbox interrupts offset */
1720
#define OTX2_CPT_PF_MBOX_INT 6
1821
#define OTX2_CPT_PF_INT_VEC_E_MBOXX(x, a) ((x) + (a))

0 commit comments

Comments
 (0)