Skip to content

Commit 0e2dad3

Browse files
committed
Merge: crypto: octeontx2: Update to upstream v6.8
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4171 JIRA: https://issues.redhat.com/browse/RHEL-31478 Depends: !3910 Conflicts: Few commits (25085ba, d887dec, 8bb0be9) were left out as they depended on other changes that have not been backported. Includes also commit b7e4152 as it is required by cac482f and it seems to be separate from the rest of the merge. Signed-off-by: Štěpán Horáček <[email protected]> Approved-by: Vladis Dronov <[email protected]> Approved-by: Kamal Heib <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: Rado Vrbovsky <[email protected]>
2 parents 3df2bf2 + ebf8893 commit 0e2dad3

26 files changed

+1399
-342
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Hardware Device Driver Specific Documentation
4+
---------------------------------------------
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
9+
octeontx2
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=========================
4+
octeontx2 devlink support
5+
=========================
6+
7+
This document describes the devlink features implemented by the ``octeontx2 CPT``
8+
device drivers.
9+
10+
Parameters
11+
==========
12+
13+
The ``octeontx2`` driver implements the following driver-specific parameters.
14+
15+
.. list-table:: Driver-specific parameters implemented
16+
:widths: 5 5 5 85
17+
18+
* - Name
19+
- Type
20+
- Mode
21+
- Description
22+
* - ``t106_mode``
23+
- u8
24+
- runtime
25+
- Used to configure CN10KA B0/CN10KB CPT to work as CN10KA A0/A1.

Documentation/crypto/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ for cryptographic use cases, as well as programming examples.
2828
api
2929
api-samples
3030
descore-readme
31+
device_drivers/index
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
obj-$(CONFIG_CRYPTO_DEV_OCTEONTX2_CPT) += rvu_cptpf.o rvu_cptvf.o
2+
obj-$(CONFIG_CRYPTO_DEV_OCTEONTX2_CPT) += rvu_cptcommon.o rvu_cptpf.o rvu_cptvf.o
33

4+
rvu_cptcommon-objs := cn10k_cpt.o otx2_cptlf.o otx2_cpt_mbox_common.o
45
rvu_cptpf-objs := otx2_cptpf_main.o otx2_cptpf_mbox.o \
5-
otx2_cpt_mbox_common.o otx2_cptpf_ucode.o otx2_cptlf.o \
6-
cn10k_cpt.o otx2_cpt_devlink.o
7-
rvu_cptvf-objs := otx2_cptvf_main.o otx2_cptvf_mbox.o otx2_cptlf.o \
8-
otx2_cpt_mbox_common.o otx2_cptvf_reqmgr.o \
9-
otx2_cptvf_algs.o cn10k_cpt.o
6+
otx2_cptpf_ucode.o otx2_cpt_devlink.o
7+
rvu_cptvf-objs := otx2_cptvf_main.o otx2_cptvf_mbox.o \
8+
otx2_cptvf_reqmgr.o otx2_cptvf_algs.o
109

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

drivers/crypto/marvell/octeontx2/cn10k_cpt.c

Lines changed: 93 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,25 @@
77
#include "otx2_cptlf.h"
88
#include "cn10k_cpt.h"
99

10+
static void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 insts_num,
11+
struct otx2_cptlf_info *lf);
12+
1013
static struct cpt_hw_ops otx2_hw_ops = {
1114
.send_cmd = otx2_cpt_send_cmd,
1215
.cpt_get_compcode = otx2_cpt_get_compcode,
1316
.cpt_get_uc_compcode = otx2_cpt_get_uc_compcode,
17+
.cpt_sg_info_create = otx2_sg_info_create,
1418
};
1519

1620
static struct cpt_hw_ops cn10k_hw_ops = {
1721
.send_cmd = cn10k_cpt_send_cmd,
1822
.cpt_get_compcode = cn10k_cpt_get_compcode,
1923
.cpt_get_uc_compcode = cn10k_cpt_get_uc_compcode,
24+
.cpt_sg_info_create = otx2_sg_info_create,
2025
};
2126

22-
void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 insts_num,
23-
struct otx2_cptlf_info *lf)
27+
static void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 insts_num,
28+
struct otx2_cptlf_info *lf)
2429
{
2530
void __iomem *lmtline = lf->lmtline;
2631
u64 val = (lf->slot & 0x7FF);
@@ -68,18 +73,16 @@ int cn10k_cptpf_lmtst_init(struct otx2_cptpf_dev *cptpf)
6873

6974
return 0;
7075
}
76+
EXPORT_SYMBOL_NS_GPL(cn10k_cptpf_lmtst_init, CRYPTO_DEV_OCTEONTX2_CPT);
7177

7278
int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)
7379
{
7480
struct pci_dev *pdev = cptvf->pdev;
7581
resource_size_t offset, size;
7682

77-
if (!test_bit(CN10K_LMTST, &cptvf->cap_flag)) {
78-
cptvf->lfs.ops = &otx2_hw_ops;
83+
if (!test_bit(CN10K_LMTST, &cptvf->cap_flag))
7984
return 0;
80-
}
8185

82-
cptvf->lfs.ops = &cn10k_hw_ops;
8386
offset = pci_resource_start(pdev, PCI_MBOX_BAR_NUM);
8487
size = pci_resource_len(pdev, PCI_MBOX_BAR_NUM);
8588
/* Map VF LMILINE region */
@@ -91,3 +94,87 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)
9194

9295
return 0;
9396
}
97+
EXPORT_SYMBOL_NS_GPL(cn10k_cptvf_lmtst_init, CRYPTO_DEV_OCTEONTX2_CPT);
98+
99+
void cn10k_cpt_hw_ctx_clear(struct pci_dev *pdev,
100+
struct cn10k_cpt_errata_ctx *er_ctx)
101+
{
102+
u64 cptr_dma;
103+
104+
if (!is_dev_cn10ka_ax(pdev))
105+
return;
106+
107+
cptr_dma = er_ctx->cptr_dma & ~(BIT_ULL(60));
108+
cn10k_cpt_ctx_flush(pdev, cptr_dma, true);
109+
dma_unmap_single(&pdev->dev, cptr_dma, CN10K_CPT_HW_CTX_SIZE,
110+
DMA_BIDIRECTIONAL);
111+
kfree(er_ctx->hw_ctx);
112+
}
113+
EXPORT_SYMBOL_NS_GPL(cn10k_cpt_hw_ctx_clear, CRYPTO_DEV_OCTEONTX2_CPT);
114+
115+
void cn10k_cpt_hw_ctx_set(union cn10k_cpt_hw_ctx *hctx, u16 ctx_sz)
116+
{
117+
hctx->w0.aop_valid = 1;
118+
hctx->w0.ctx_hdr_sz = 0;
119+
hctx->w0.ctx_sz = ctx_sz;
120+
hctx->w0.ctx_push_sz = 1;
121+
}
122+
EXPORT_SYMBOL_NS_GPL(cn10k_cpt_hw_ctx_set, CRYPTO_DEV_OCTEONTX2_CPT);
123+
124+
int cn10k_cpt_hw_ctx_init(struct pci_dev *pdev,
125+
struct cn10k_cpt_errata_ctx *er_ctx)
126+
{
127+
union cn10k_cpt_hw_ctx *hctx;
128+
u64 cptr_dma;
129+
130+
er_ctx->cptr_dma = 0;
131+
er_ctx->hw_ctx = NULL;
132+
133+
if (!is_dev_cn10ka_ax(pdev))
134+
return 0;
135+
136+
hctx = kmalloc(CN10K_CPT_HW_CTX_SIZE, GFP_KERNEL);
137+
if (unlikely(!hctx))
138+
return -ENOMEM;
139+
cptr_dma = dma_map_single(&pdev->dev, hctx, CN10K_CPT_HW_CTX_SIZE,
140+
DMA_BIDIRECTIONAL);
141+
if (dma_mapping_error(&pdev->dev, cptr_dma)) {
142+
kfree(hctx);
143+
return -ENOMEM;
144+
}
145+
146+
cn10k_cpt_hw_ctx_set(hctx, 1);
147+
er_ctx->hw_ctx = hctx;
148+
er_ctx->cptr_dma = cptr_dma | BIT_ULL(60);
149+
150+
return 0;
151+
}
152+
EXPORT_SYMBOL_NS_GPL(cn10k_cpt_hw_ctx_init, CRYPTO_DEV_OCTEONTX2_CPT);
153+
154+
void cn10k_cpt_ctx_flush(struct pci_dev *pdev, u64 cptr, bool inval)
155+
{
156+
struct otx2_cptvf_dev *cptvf = pci_get_drvdata(pdev);
157+
struct otx2_cptlfs_info *lfs = &cptvf->lfs;
158+
u64 reg;
159+
160+
reg = (uintptr_t)cptr >> 7;
161+
if (inval)
162+
reg = reg | BIT_ULL(46);
163+
164+
otx2_cpt_write64(lfs->reg_base, lfs->blkaddr, lfs->lf[0].slot,
165+
OTX2_CPT_LF_CTX_FLUSH, reg);
166+
/* Make sure that the FLUSH operation is complete */
167+
wmb();
168+
otx2_cpt_read64(lfs->reg_base, lfs->blkaddr, lfs->lf[0].slot,
169+
OTX2_CPT_LF_CTX_ERR);
170+
}
171+
EXPORT_SYMBOL_NS_GPL(cn10k_cpt_ctx_flush, CRYPTO_DEV_OCTEONTX2_CPT);
172+
173+
void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf)
174+
{
175+
if (test_bit(CN10K_LMTST, &cptvf->cap_flag))
176+
cptvf->lfs.ops = &cn10k_hw_ops;
177+
else
178+
cptvf->lfs.ops = &otx2_hw_ops;
179+
}
180+
EXPORT_SYMBOL_NS_GPL(cptvf_hw_ops_get, CRYPTO_DEV_OCTEONTX2_CPT);

drivers/crypto/marvell/octeontx2/cn10k_cpt.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@
88
#include "otx2_cptpf.h"
99
#include "otx2_cptvf.h"
1010

11+
#define CN10K_CPT_HW_CTX_SIZE 256
12+
13+
union cn10k_cpt_hw_ctx {
14+
u64 u;
15+
struct {
16+
u64 reserved_0_47:48;
17+
u64 ctx_push_sz:7;
18+
u64 reserved_55:1;
19+
u64 ctx_hdr_sz:2;
20+
u64 aop_valid:1;
21+
u64 reserved_59:1;
22+
u64 ctx_sz:4;
23+
} w0;
24+
};
25+
26+
struct cn10k_cpt_errata_ctx {
27+
union cn10k_cpt_hw_ctx *hw_ctx;
28+
u64 cptr_dma;
29+
};
30+
1131
static inline u8 cn10k_cpt_get_compcode(union otx2_cpt_res_s *result)
1232
{
1333
return ((struct cn10k_cpt_res_s *)result)->compcode;
@@ -28,9 +48,14 @@ static inline u8 otx2_cpt_get_uc_compcode(union otx2_cpt_res_s *result)
2848
return ((struct cn9k_cpt_res_s *)result)->uc_compcode;
2949
}
3050

31-
void cn10k_cpt_send_cmd(union otx2_cpt_inst_s *cptinst, u32 insts_num,
32-
struct otx2_cptlf_info *lf);
3351
int cn10k_cptpf_lmtst_init(struct otx2_cptpf_dev *cptpf);
3452
int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf);
53+
void cn10k_cpt_ctx_flush(struct pci_dev *pdev, u64 cptr, bool inval);
54+
int cn10k_cpt_hw_ctx_init(struct pci_dev *pdev,
55+
struct cn10k_cpt_errata_ctx *er_ctx);
56+
void cn10k_cpt_hw_ctx_clear(struct pci_dev *pdev,
57+
struct cn10k_cpt_errata_ctx *er_ctx);
58+
void cn10k_cpt_hw_ctx_set(union cn10k_cpt_hw_ctx *hctx, u16 ctx_sz);
59+
void cptvf_hw_ops_get(struct otx2_cptvf_dev *cptvf);
3560

3661
#endif /* __CN10K_CPTLF_H */

drivers/crypto/marvell/octeontx2/otx2_cpt_common.h

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,27 @@ enum otx2_cpt_eng_type {
4040
};
4141

4242
/* Take mbox id from end of CPT mbox range in AF (range 0xA00 - 0xBFF) */
43+
#define MBOX_MSG_RX_INLINE_IPSEC_LF_CFG 0xBFE
4344
#define MBOX_MSG_GET_ENG_GRP_NUM 0xBFF
4445
#define MBOX_MSG_GET_CAPS 0xBFD
4546
#define MBOX_MSG_GET_KVF_LIMITS 0xBFC
4647

48+
/*
49+
* Message request to config cpt lf for inline inbound ipsec.
50+
* This message is only used between CPT PF <-> CPT VF
51+
*/
52+
struct otx2_cpt_rx_inline_lf_cfg {
53+
struct mbox_msghdr hdr;
54+
u16 sso_pf_func;
55+
u16 param1;
56+
u16 param2;
57+
u16 opcode;
58+
u32 credit;
59+
u32 reserved;
60+
u8 ctx_ilen_valid : 1;
61+
u8 ctx_ilen : 7;
62+
};
63+
4764
/*
4865
* Message request and response to get engine group number
4966
* which has attached a given type of engines (SE, AE, IE)
@@ -87,7 +104,10 @@ union otx2_cpt_eng_caps {
87104
u64 kasumi:1;
88105
u64 des:1;
89106
u64 crc:1;
90-
u64 reserved_14_63:50;
107+
u64 mmul:1;
108+
u64 reserved_15_33:19;
109+
u64 pdcp_chain:1;
110+
u64 reserved_35_63:29;
91111
};
92112
};
93113

@@ -130,6 +150,35 @@ static inline bool is_dev_otx2(struct pci_dev *pdev)
130150
return false;
131151
}
132152

153+
static inline bool is_dev_cn10ka(struct pci_dev *pdev)
154+
{
155+
return pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_A;
156+
}
157+
158+
static inline bool is_dev_cn10ka_ax(struct pci_dev *pdev)
159+
{
160+
if (pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_A &&
161+
((pdev->revision & 0xFF) == 4 || (pdev->revision & 0xFF) == 0x50 ||
162+
(pdev->revision & 0xff) == 0x51))
163+
return true;
164+
165+
return false;
166+
}
167+
168+
static inline bool is_dev_cn10kb(struct pci_dev *pdev)
169+
{
170+
return pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_B;
171+
}
172+
173+
static inline bool is_dev_cn10ka_b0(struct pci_dev *pdev)
174+
{
175+
if (pdev->subsystem_device == CPT_PCI_SUBSYS_DEVID_CN10K_A &&
176+
(pdev->revision & 0xFF) == 0x54)
177+
return true;
178+
179+
return false;
180+
}
181+
133182
static inline void otx2_cpt_set_hw_caps(struct pci_dev *pdev,
134183
unsigned long *cap_flag)
135184
{
@@ -139,14 +188,27 @@ static inline void otx2_cpt_set_hw_caps(struct pci_dev *pdev,
139188
}
140189
}
141190

191+
static inline bool cpt_is_errata_38550_exists(struct pci_dev *pdev)
192+
{
193+
if (is_dev_otx2(pdev) || is_dev_cn10ka_ax(pdev))
194+
return true;
195+
196+
return false;
197+
}
198+
199+
static inline bool cpt_feature_sgv2(struct pci_dev *pdev)
200+
{
201+
if (!is_dev_otx2(pdev) && !is_dev_cn10ka_ax(pdev))
202+
return true;
203+
204+
return false;
205+
}
142206

143207
int otx2_cpt_send_ready_msg(struct otx2_mbox *mbox, struct pci_dev *pdev);
144208
int otx2_cpt_send_mbox_msg(struct otx2_mbox *mbox, struct pci_dev *pdev);
145209

146210
int otx2_cpt_send_af_reg_requests(struct otx2_mbox *mbox,
147211
struct pci_dev *pdev);
148-
int otx2_cpt_add_read_af_reg(struct otx2_mbox *mbox, struct pci_dev *pdev,
149-
u64 reg, u64 *val, int blkaddr);
150212
int otx2_cpt_add_write_af_reg(struct otx2_mbox *mbox, struct pci_dev *pdev,
151213
u64 reg, u64 val, int blkaddr);
152214
int otx2_cpt_read_af_reg(struct otx2_mbox *mbox, struct pci_dev *pdev,
@@ -158,5 +220,6 @@ int otx2_cpt_attach_rscrs_msg(struct otx2_cptlfs_info *lfs);
158220
int otx2_cpt_detach_rsrcs_msg(struct otx2_cptlfs_info *lfs);
159221
int otx2_cpt_msix_offset_msg(struct otx2_cptlfs_info *lfs);
160222
int otx2_cpt_sync_mbox_msg(struct otx2_mbox *mbox);
223+
int otx2_cpt_lf_reset_msg(struct otx2_cptlfs_info *lfs, int slot);
161224

162225
#endif /* __OTX2_CPT_COMMON_H */

0 commit comments

Comments
 (0)