Skip to content

Commit bbfd989

Browse files
committed
crypto: octeontx2 - add devlink option to set t106 mode
JIRA: https://issues.redhat.com/browse/RHEL-31478 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 82f89f1 Author: Srujana Challa <schalla@marvell.com> Date: Wed Dec 13 13:00:49 2023 +0530 crypto: octeontx2 - add devlink option to set t106 mode On CN10KA B0/CN10KB, CPT scatter gather format has modified to support multi-seg in inline IPsec. Due to this CPT requires new firmware and doesn't work with CN10KA0/A1 firmware. To make HW works in backward compatibility mode or works with CN10KA0/A1 firmware, a bit(T106_MODE) is introduced in HW CSR. This patch adds devlink parameter for configuring T106_MODE. This patch also documents the devlink parameter under Documentation/crypto/device_drivers. Signed-off-by: Srujana Challa <schalla@marvell.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
1 parent 7a8ae68 commit bbfd989

File tree

6 files changed

+87
-4
lines changed

6 files changed

+87
-4
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

drivers/crypto/marvell/octeontx2/otx2_cpt_common.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ static inline void otx2_cpt_set_hw_caps(struct pci_dev *pdev,
187187
}
188188

189189

190+
static inline bool cpt_feature_sgv2(struct pci_dev *pdev)
191+
{
192+
if (!is_dev_otx2(pdev) && !is_dev_cn10ka_ax(pdev))
193+
return true;
194+
195+
return false;
196+
}
197+
190198
int otx2_cpt_send_ready_msg(struct otx2_mbox *mbox, struct pci_dev *pdev);
191199
int otx2_cpt_send_mbox_msg(struct otx2_mbox *mbox, struct pci_dev *pdev);
192200

drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,46 @@ static int otx2_cpt_dl_egrp_delete(struct devlink *dl, u32 id,
2323

2424
static int otx2_cpt_dl_uc_info(struct devlink *dl, u32 id,
2525
struct devlink_param_gset_ctx *ctx)
26+
{
27+
ctx->val.vstr[0] = '\0';
28+
29+
return 0;
30+
}
31+
32+
static int otx2_cpt_dl_t106_mode_get(struct devlink *dl, u32 id,
33+
struct devlink_param_gset_ctx *ctx)
2634
{
2735
struct otx2_cpt_devlink *cpt_dl = devlink_priv(dl);
2836
struct otx2_cptpf_dev *cptpf = cpt_dl->cptpf;
37+
struct pci_dev *pdev = cptpf->pdev;
38+
u64 reg_val = 0;
39+
40+
otx2_cpt_read_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL, &reg_val,
41+
BLKADDR_CPT0);
42+
ctx->val.vu8 = (reg_val >> 18) & 0x1;
43+
44+
return 0;
45+
}
2946

30-
otx2_cpt_print_uc_dbg_info(cptpf);
47+
static int otx2_cpt_dl_t106_mode_set(struct devlink *dl, u32 id,
48+
struct devlink_param_gset_ctx *ctx)
49+
{
50+
struct otx2_cpt_devlink *cpt_dl = devlink_priv(dl);
51+
struct otx2_cptpf_dev *cptpf = cpt_dl->cptpf;
52+
struct pci_dev *pdev = cptpf->pdev;
53+
u64 reg_val = 0;
54+
55+
if (cptpf->enabled_vfs != 0 || cptpf->eng_grps.is_grps_created)
56+
return -EPERM;
57+
58+
if (cpt_feature_sgv2(pdev)) {
59+
otx2_cpt_read_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL,
60+
&reg_val, BLKADDR_CPT0);
61+
reg_val &= ~(0x1ULL << 18);
62+
reg_val |= ((u64)ctx->val.vu8 & 0x1) << 18;
63+
return otx2_cpt_write_af_reg(&cptpf->afpf_mbox, pdev,
64+
CPT_AF_CTL, reg_val, BLKADDR_CPT0);
65+
}
3166

3267
return 0;
3368
}
@@ -36,6 +71,7 @@ enum otx2_cpt_dl_param_id {
3671
OTX2_CPT_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
3772
OTX2_CPT_DEVLINK_PARAM_ID_EGRP_CREATE,
3873
OTX2_CPT_DEVLINK_PARAM_ID_EGRP_DELETE,
74+
OTX2_CPT_DEVLINK_PARAM_ID_T106_MODE,
3975
};
4076

4177
static const struct devlink_param otx2_cpt_dl_params[] = {
@@ -49,6 +85,11 @@ static const struct devlink_param otx2_cpt_dl_params[] = {
4985
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
5086
otx2_cpt_dl_uc_info, otx2_cpt_dl_egrp_delete,
5187
NULL),
88+
DEVLINK_PARAM_DRIVER(OTX2_CPT_DEVLINK_PARAM_ID_T106_MODE,
89+
"t106_mode", DEVLINK_PARAM_TYPE_U8,
90+
BIT(DEVLINK_PARAM_CMODE_RUNTIME),
91+
otx2_cpt_dl_t106_mode_get, otx2_cpt_dl_t106_mode_set,
92+
NULL),
5293
};
5394

5495
static int otx2_cpt_dl_info_firmware_version_put(struct devlink_info_req *req,
@@ -120,7 +161,6 @@ int otx2_cpt_register_dl(struct otx2_cptpf_dev *cptpf)
120161
devlink_free(dl);
121162
return ret;
122163
}
123-
124164
devlink_register(dl);
125165

126166
return 0;

drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,10 @@ static void cptpf_get_rid(struct pci_dev *pdev, struct otx2_cptpf_dev *cptpf)
600600
}
601601
otx2_cpt_read_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL, &reg_val,
602602
BLKADDR_CPT0);
603-
if ((is_dev_cn10ka_b0(pdev) && (reg_val & BIT_ULL(18))) ||
603+
if ((cpt_feature_sgv2(pdev) && (reg_val & BIT_ULL(18))) ||
604604
is_dev_cn10ka_ax(pdev))
605605
eng_grps->rid = CPT_UC_RID_CN10K_A;
606-
else if (is_dev_cn10kb(pdev) || is_dev_cn10ka_b0(pdev))
606+
else if (cpt_feature_sgv2(pdev))
607607
eng_grps->rid = CPT_UC_RID_CN10K_B;
608608
}
609609

0 commit comments

Comments
 (0)