Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Srujana Challa and committed by
Herbert Xu
82f89f1a 92508e7f

+87 -4
+9
Documentation/crypto/device_drivers/index.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Hardware Device Driver Specific Documentation 4 + --------------------------------------------- 5 + 6 + .. toctree:: 7 + :maxdepth: 1 8 + 9 + octeontx2
+25
Documentation/crypto/device_drivers/octeontx2.rst
··· 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.
+1
Documentation/crypto/index.rst
··· 28 28 api 29 29 api-samples 30 30 descore-readme 31 + device_drivers/index
+8
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h
··· 187 187 } 188 188 189 189 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 + 190 198 int otx2_cpt_send_ready_msg(struct otx2_mbox *mbox, struct pci_dev *pdev); 191 199 int otx2_cpt_send_mbox_msg(struct otx2_mbox *mbox, struct pci_dev *pdev); 192 200
+42 -2
drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c
··· 24 24 static int otx2_cpt_dl_uc_info(struct devlink *dl, u32 id, 25 25 struct devlink_param_gset_ctx *ctx) 26 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) 34 + { 27 35 struct otx2_cpt_devlink *cpt_dl = devlink_priv(dl); 28 36 struct otx2_cptpf_dev *cptpf = cpt_dl->cptpf; 37 + struct pci_dev *pdev = cptpf->pdev; 38 + u64 reg_val = 0; 29 39 30 - otx2_cpt_print_uc_dbg_info(cptpf); 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 + } 46 + 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 + } 31 66 32 67 return 0; 33 68 } ··· 71 36 OTX2_CPT_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, 72 37 OTX2_CPT_DEVLINK_PARAM_ID_EGRP_CREATE, 73 38 OTX2_CPT_DEVLINK_PARAM_ID_EGRP_DELETE, 39 + OTX2_CPT_DEVLINK_PARAM_ID_T106_MODE, 74 40 }; 75 41 76 42 static const struct devlink_param otx2_cpt_dl_params[] = { ··· 84 48 "egrp_delete", DEVLINK_PARAM_TYPE_STRING, 85 49 BIT(DEVLINK_PARAM_CMODE_RUNTIME), 86 50 otx2_cpt_dl_uc_info, otx2_cpt_dl_egrp_delete, 51 + NULL), 52 + DEVLINK_PARAM_DRIVER(OTX2_CPT_DEVLINK_PARAM_ID_T106_MODE, 53 + "t106_mode", DEVLINK_PARAM_TYPE_U8, 54 + BIT(DEVLINK_PARAM_CMODE_RUNTIME), 55 + otx2_cpt_dl_t106_mode_get, otx2_cpt_dl_t106_mode_set, 87 56 NULL), 88 57 }; 89 58 ··· 161 120 devlink_free(dl); 162 121 return ret; 163 122 } 164 - 165 123 devlink_register(dl); 166 124 167 125 return 0;
+2 -2
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
··· 600 600 } 601 601 otx2_cpt_read_af_reg(&cptpf->afpf_mbox, pdev, CPT_AF_CTL, &reg_val, 602 602 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))) || 604 604 is_dev_cn10ka_ax(pdev)) 605 605 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)) 607 607 eng_grps->rid = CPT_UC_RID_CN10K_B; 608 608 } 609 609