Add Marvell CN10KB/CN10KA B0 support
Subsystems (4)
Srujana Challa
maintainercover Add Marvell CN10KB/CN10KA B0 support
Marvell OcteonTX2's next gen platform CN10KB/CN10KA B0 introduced changes in CPT SG input format(SGv2) to make it compatibile with NIX SG input format to support inline IPsec in SG mode.
This patchset modifies the CPT driver code to support SGv2 format for CN10KB/CN10KA B0. And also adds code to configure newly introduced HW registers.
This patchset also implements SW workaround for couple of HW erratas.
Nithin Dabilpuram (2):
crypto/octeontx2: register error interrupts for inline cptlf
crypto: octeontx2: support setting ctx ilen for inline CPT LF
Srujana Challa (8):
crypto: octeontx2: remove CPT block reset
crypto: octeontx2: add SGv2 support for CN10KB or CN10KA B0
crypto: octeontx2: add devlink option to set max_rxc_icb_cnt
crypto: octeontx2: add devlink option to set t106 mode
crypto: octeontx2: remove errata workaround for CN10KB or CN10KA B0
chip.
crypto: octeontx2: add LF reset on queue disable
octeontx2-af: update CPT inbound inline IPsec mailbox
crypto: octeontx2: add ctx_val workaround
drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 87 +++++- drivers/crypto/marvell/octeontx2/cn10k_cpt.h | 25 ++ .../marvell/octeontx2/otx2_cpt_common.h | 68 +++- .../marvell/octeontx2/otx2_cpt_devlink.c | 89 +++++- .../marvell/octeontx2/otx2_cpt_hw_types.h | 9 +- .../marvell/octeontx2/otx2_cpt_mbox_common.c | 26 ++ .../marvell/octeontx2/otx2_cpt_reqmgr.h | 293 ++++++++++++++++++ drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 131 +++++--- drivers/crypto/marvell/octeontx2/otx2_cptlf.h | 102 ++++-- drivers/crypto/marvell/octeontx2/otx2_cptpf.h | 4 + .../marvell/octeontx2/otx2_cptpf_main.c | 76 ++--- .../marvell/octeontx2/otx2_cptpf_mbox.c | 81 ++++- .../marvell/octeontx2/otx2_cptpf_ucode.c | 49 +-- .../marvell/octeontx2/otx2_cptpf_ucode.h | 3 +- drivers/crypto/marvell/octeontx2/otx2_cptvf.h | 2 + .../marvell/octeontx2/otx2_cptvf_algs.c | 31 ++ .../marvell/octeontx2/otx2_cptvf_algs.h | 5 + .../marvell/octeontx2/otx2_cptvf_main.c | 25 +- .../marvell/octeontx2/otx2_cptvf_mbox.c | 27 ++ .../marvell/octeontx2/otx2_cptvf_reqmgr.c | 162 +--------- .../ethernet/marvell/octeontx2/af/rvu_cpt.c | 14 + .../ethernet/marvell/octeontx2/af/rvu_reg.h | 1 + 22 files changed, 1005 insertions(+), 305 deletions(-)
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 1/10 crypto: octeontx2: remove CPT block reset
CPT block reset in CPT PF erase all the CPT configuration which is done in AF driver init. So, remove CPT block reset from CPT PF as it is also being done in AF init and not required in PF.
--- .../marvell/octeontx2/otx2_cptpf_main.c | 43 ------------------- 1 file changed, 43 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c +0 -43
@@ -587,45 +587,6 @@ static int cpt_is_pf_usable(struct otx2_cptpf_dev *cptpf)return 0 ; } -static int cptx_device_reset (struct otx2_cptpf_dev *cptpf,int blkaddr) -{ -int timeout =10 , ret; -u64 reg =0 ; - - ret =otx2_cpt_write_af_reg (&cptpf->afpf_mbox, cptpf->pdev, -CPT_AF_BLK_RST ,0x1 , blkaddr); -if (ret) -return ret; - -do { - ret =otx2_cpt_read_af_reg (&cptpf->afpf_mbox, cptpf->pdev, -CPT_AF_BLK_RST , ®, blkaddr); -if (ret) -return ret; - -if (!((reg >>63 ) &0x1 )) -break ; - -usleep_range (10000 ,20000 ); -if (timeout-- <0 ) -return -EBUSY ; - }while (1 ); - -return ret; -} - -static int cptpf_device_reset (struct otx2_cptpf_dev *cptpf) -{ -int ret =0 ; - -if (cptpf->has_cpt1) { - ret =cptx_device_reset (cptpf,BLKADDR_CPT1 ); -if (ret) -return ret; - } -return cptx_device_reset (cptpf,BLKADDR_CPT0 ); -} -static void cptpf_check_block_implemented (struct otx2_cptpf_dev *cptpf) {u64 cfg;
@@ -643,10 +604,6 @@ static int cptpf_device_init(struct otx2_cptpf_dev *cptpf)/* check if 'implemented' bit is set for block BLKADDR_CPT1 */ cptpf_check_block_implemented (cptpf); -/* Reset the CPT PF device */ - ret =cptpf_device_reset (cptpf); -if (ret) -return ret;/* Get number of SE, IE and AE engines */ ret = otx2_cpt_read_af_reg(&cptpf->afpf_mbox, cptpf->pdev,
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 2/10 crypto: octeontx2: add SGv2 support for CN10KB or CN10KA B0
In reply to Srujana ChallaScatter Gather input format for CPT has changed on CN10KB/CN10KA B0 HW to make it comapatible 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.
--- drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 19 +- drivers/crypto/marvell/octeontx2/cn10k_cpt.h | 1 + .../marvell/octeontx2/otx2_cpt_common.h | 41 ++- .../marvell/octeontx2/otx2_cpt_hw_types.h | 3 + .../marvell/octeontx2/otx2_cpt_reqmgr.h | 291 ++++++++++++++++++ drivers/crypto/marvell/octeontx2/otx2_cptlf.h | 2 + .../marvell/octeontx2/otx2_cptpf_main.c | 26 +- .../marvell/octeontx2/otx2_cptpf_mbox.c | 2 +- .../marvell/octeontx2/otx2_cptpf_ucode.c | 33 +- .../marvell/octeontx2/otx2_cptpf_ucode.h | 3 +- drivers/crypto/marvell/octeontx2/otx2_cptvf.h | 2 + .../marvell/octeontx2/otx2_cptvf_main.c | 13 + .../marvell/octeontx2/otx2_cptvf_mbox.c | 25 ++ .../marvell/octeontx2/otx2_cptvf_reqmgr.c | 160 +--------- 14 files changed, 444 insertions(+), 177 deletions(-)
drivers/crypto/marvell/octeontx2/cn10k_cpt.c +15 -4
@@ -14,12 +14,14 @@ static struct cpt_hw_ops otx2_hw_ops = { .send_cmd = otx2_cpt_send_cmd, .cpt_get_compcode = otx2_cpt_get_compcode, .cpt_get_uc_compcode = otx2_cpt_get_uc_compcode, + .cpt_sg_info_create = otx2_sg_info_create, };static struct cpt_hw_ops cn10k_hw_ops = { .send_cmd = cn10k_cpt_send_cmd, .cpt_get_compcode = cn10k_cpt_get_compcode, .cpt_get_uc_compcode = cn10k_cpt_get_uc_compcode, + .cpt_sg_info_create = otx2_sg_info_create, }; 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)struct pci_dev *pdev = cptvf->pdev;resource_size_t offset, size; -if (!test_bit (CN10K_LMTST , &cptvf->cap_flag)) { - cptvf->lfs.ops = &otx2_hw_ops; +if (!test_bit (CN10K_LMTST , &cptvf->cap_flag))return 0 ; - } - cptvf->lfs.ops = &cn10k_hw_ops; offset =pci_resource_start (pdev,PCI_MBOX_BAR_NUM ); size =pci_resource_len (pdev,PCI_MBOX_BAR_NUM );/* Map VF LMILINE region */
@@ -96,3 +95,15 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf)return 0 ; }EXPORT_SYMBOL_NS_GPL (cn10k_cptvf_lmtst_init,CRYPTO_DEV_OCTEONTX2_CPT ); + +int cptvf_hw_ops_get (struct otx2_cptvf_dev *cptvf) +{ +if (!test_bit (CN10K_LMTST , &cptvf->cap_flag)) { + cptvf->lfs.ops = &otx2_hw_ops; +return 0 ; + } + cptvf->lfs.ops = &cn10k_hw_ops; + +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cptvf_hw_ops_get,CRYPTO_DEV_OCTEONTX2_CPT );
drivers/crypto/marvell/octeontx2/cn10k_cpt.h +1 -0
@@ -30,5 +30,6 @@ static inline u8 otx2_cpt_get_uc_compcode(union otx2_cpt_res_s *result)int cn10k_cptpf_lmtst_init (struct otx2_cptpf_dev *cptpf);int cn10k_cptvf_lmtst_init (struct otx2_cptvf_dev *cptvf); +int cptvf_hw_ops_get (struct otx2_cptvf_dev *cptvf);#endif /* __CN10K_CPTLF_H */
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h +39 -2
59 lines not on this page · raw message
drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h +3 -0
@@ -13,6 +13,9 @@#define CN10K_CPT_PCI_PF_DEVICE_ID 0xA0F2#define CN10K_CPT_PCI_VF_DEVICE_ID 0xA0F3 +#define CPT_PCI_SUBSYS_DEVID_CN10K_A 0xB900 +#define CPT_PCI_SUBSYS_DEVID_CN10K_B 0xBD00 +/* Mailbox interrupts offset */ #define OTX2_CPT_PF_MBOX_INT 6#define OTX2_CPT_PF_INT_VEC_E_MBOXX (x, a) ((x) + (a))
drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h +291 -0
309 lines not on this page · raw message
drivers/crypto/marvell/octeontx2/otx2_cptlf.h +2 -0
@@ -99,6 +99,8 @@ struct cpt_hw_ops { struct otx2_cptlf_info *lf);u8 (*cpt_get_compcode)(union otx2_cpt_res_s *result);u8 (*cpt_get_uc_compcode)(union otx2_cpt_res_s *result); +struct otx2_cpt_inst_info * (*cpt_sg_info_create)(struct pci_dev *pdev, +struct otx2_cpt_req_info *req,gfp_t gfp); };struct otx2_cptlfs_info {
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c +25 -1
@@ -14,6 +14,8 @@#define OTX2_CPT_DRV_STRING "Marvell RVU CPT Physical Function Driver"#define CPT_UC_RID_CN9K_B0 1 +#define CPT_UC_RID_CN10K_A 4 +#define CPT_UC_RID_CN10K_B 5static void cptpf_enable_vfpf_mbox_intr (struct otx2_cptpf_dev *cptpf,int num_vfs)
@@ -587,6 +589,26 @@ static int cpt_is_pf_usable(struct otx2_cptpf_dev *cptpf)return 0 ; } +static int cptpf_get_rid (struct pci_dev *pdev,struct otx2_cptpf_dev *cptpf) +{ +struct otx2_cpt_eng_grps *eng_grps = &cptpf->eng_grps; +u64 reg_val =0x0 ; + +if (is_dev_otx2 (pdev)) { + eng_grps->rid = pdev->revision; +return 0 ; + } +otx2_cpt_read_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_CTL , ®_val, +BLKADDR_CPT0 ); +if ((is_dev_cn10ka_b0 (pdev) && (reg_val &BIT_ULL (18 ))) || +is_dev_cn10ka_ax (pdev)) + eng_grps->rid =CPT_UC_RID_CN10K_A ; +else if (is_dev_cn10kb (pdev) ||is_dev_cn10ka_b0 (pdev)) + eng_grps->rid =CPT_UC_RID_CN10K_B ; + +return 0 ; +} +static void cptpf_check_block_implemented (struct otx2_cptpf_dev *cptpf) {u64 cfg;
@@ -657,7 +679,9 @@ static int cptpf_sriov_enable(struct pci_dev *pdev, int num_vfs) ret =cptpf_register_vfpf_intr (cptpf, num_vfs);if (ret) goto destroy_flr; - + ret =cptpf_get_rid (pdev, cptpf); +if (ret) + goto disable_intr;/* Get CPT HW capabilities using LOAD_FVC operation. */ ret =otx2_cpt_discover_eng_capabilities (cptpf);if (ret)
drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c +1 -1
@@ -78,7 +78,7 @@ static int handle_msg_get_caps(struct otx2_cptpf_dev *cptpf, rsp->hdr.sig =OTX2_MBOX_RSP_SIG ; rsp->hdr.pcifunc = req->pcifunc; rsp->cpt_pf_drv_version =OTX2_CPT_PF_DRV_VERSION ; - rsp->cpt_revision = cptpf->pdev->revision; + rsp->cpt_revision = cptpf->eng_grps.rid;memcpy (&rsp->eng_caps, &cptpf->eng_caps,sizeof (rsp->eng_caps));return 0 ;
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +18 -15
@@ -117,12 +117,10 @@ static char *get_ucode_type_str(int ucode_type)static int get_ucode_type (struct device *dev,struct otx2_cpt_ucode_hdr *ucode_hdr, -int *ucode_type) +int *ucode_type,u16 rid) { -struct otx2_cptpf_dev *cptpf =dev_get_drvdata (dev);char ver_str_prefix[OTX2_CPT_UCODE_VER_STR_SZ ];char tmp_ver_str[OTX2_CPT_UCODE_VER_STR_SZ ]; -struct pci_dev *pdev = cptpf->pdev;int i, val =0 ;u8 nn;
@@ -130,7 +128,7 @@ static int get_ucode_type(struct device *dev,for (i =0 ; i <strlen (tmp_ver_str); i++) tmp_ver_str[i] =tolower (tmp_ver_str[i]); -sprintf (ver_str_prefix,"ocpt-%02d" , pdev->revision); +sprintf (ver_str_prefix,"ocpt-%02d" , rid);if (!strnstr (tmp_ver_str, ver_str_prefix,OTX2_CPT_UCODE_VER_STR_SZ ))return -EINVAL ;
@@ -359,7 +357,7 @@ static int cpt_attach_and_enable_cores(struct otx2_cpt_eng_grp_info *eng_grp, }static int load_fw (struct device *dev,struct fw_info_t *fw_info, -char *filename) +char *filename,u16 rid) {struct otx2_cpt_ucode_hdr *ucode_hdr;struct otx2_cpt_uc_info_t *uc_info;
@@ -375,7 +373,7 @@ static int load_fw(struct device *dev, struct fw_info_t *fw_info, goto free_uc_info; ucode_hdr = (struct otx2_cpt_ucode_hdr *)uc_info->fw->data; - ret =get_ucode_type (dev, ucode_hdr, &ucode_type); + ret =get_ucode_type (dev, ucode_hdr, &ucode_type, rid);if (ret) goto release_fw;
@@ -389,6 +387,7 @@ static int load_fw(struct device *dev, struct fw_info_t *fw_info,set_ucode_filename (&uc_info->ucode, filename);memcpy (uc_info->ucode.ver_str, ucode_hdr->ver_str,OTX2_CPT_UCODE_VER_STR_SZ ); + uc_info->ucode.ver_str[OTX2_CPT_UCODE_VER_STR_SZ ] =0 ; uc_info->ucode.ver_num = ucode_hdr->ver_num; uc_info->ucode.type = ucode_type; uc_info->ucode.size = ucode_size;
@@ -448,7 +447,8 @@ static void print_uc_info(struct fw_info_t *fw_info) } } -static int cpt_ucode_load_fw (struct pci_dev *pdev,struct fw_info_t *fw_info) +static int cpt_ucode_load_fw (struct pci_dev *pdev,struct fw_info_t *fw_info, +u16 rid) {char filename[OTX2_CPT_NAME_LENGTH ];char eng_type[8 ] = {0 };
@@ -462,9 +462,9 @@ static int cpt_ucode_load_fw(struct pci_dev *pdev, struct fw_info_t *fw_info) eng_type[i] =tolower (eng_type[i]);snprintf (filename,sizeof (filename),"mrvl/cpt%02d/%s.out" , - pdev->revision, eng_type); + rid, eng_type);/* Request firmware for each engine type */ - ret =load_fw (&pdev->dev, fw_info, filename); + ret =load_fw (&pdev->dev, fw_info, filename, rid);if (ret) goto release_fw; }
@@ -1155,7 +1155,7 @@ int otx2_cpt_create_eng_grps(struct otx2_cptpf_dev *cptpf,if (eng_grps->is_grps_created) goto unlock; - ret =cpt_ucode_load_fw (pdev, &fw_info); + ret =cpt_ucode_load_fw (pdev, &fw_info, eng_grps->rid);if (ret) goto unlock;
@@ -1230,14 +1230,16 @@ int otx2_cpt_create_eng_grps(struct otx2_cptpf_dev *cptpf,*/ rnm_to_cpt_errata_fixup (&pdev->dev); +otx2_cpt_read_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_CTL , ®_val, +BLKADDR_CPT0 );/* * Configure engine group mask to allow context prefetching * for the groups and enable random number request, to enable * CPT to request random numbers from RNM. */ + reg_val |=OTX2_CPT_ALL_ENG_GRPS_MASK <<3 |BIT_ULL (16 );otx2_cpt_write_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_CTL , -OTX2_CPT_ALL_ENG_GRPS_MASK <<3 |BIT_ULL (16 ), -BLKADDR_CPT0 ); + reg_val,BLKADDR_CPT0 );/* * Set interval to periodically flush dirty data for the next * CTX cache entry. Set the interval count to maximum supported
@@ -1412,7 +1414,7 @@ static int create_eng_caps_discovery_grps(struct pci_dev *pdev,int ret;mutex_lock (&eng_grps->lock); - ret =cpt_ucode_load_fw (pdev, &fw_info); + ret =cpt_ucode_load_fw (pdev, &fw_info, eng_grps->rid);if (ret) {mutex_unlock (&eng_grps->lock);return ret;
@@ -1686,13 +1688,14 @@ int otx2_cpt_dl_custom_egrp_create(struct otx2_cptpf_dev *cptpf, goto err_unlock; }INIT_LIST_HEAD (&fw_info.ucodes); - ret =load_fw (dev, &fw_info, ucode_filename[0 ]); + + ret =load_fw (dev, &fw_info, ucode_filename[0 ], eng_grps->rid);if (ret) {dev_err (dev,"Unable to load firmware %s\n" , ucode_filename[0 ]); goto err_unlock; }if (ucode_idx >1 ) { - ret =load_fw (dev, &fw_info, ucode_filename[1 ]); + ret =load_fw (dev, &fw_info, ucode_filename[1 ], eng_grps->rid);if (ret) {dev_err (dev,"Unable to load firmware %s\n" , ucode_filename[1 ]);
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.h +2 -1
@@ -73,7 +73,7 @@ struct otx2_cpt_ucode_hdr { };struct otx2_cpt_ucode { -u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ ];/* +u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ +1 ];/* * ucode version in readable * format */
@@ -150,6 +150,7 @@ struct otx2_cpt_eng_grps {int engs_num;/* total number of engines supported */ u8 eng_ref_cnt[OTX2_CPT_MAX_ENGINES ];/* engines reference count */ bool is_grps_created;/* Is the engine groups are already created */ +u16 rid; };struct otx2_cptpf_dev ; int otx2_cpt_init_eng_grps(struct pci_dev *pdev,
drivers/crypto/marvell/octeontx2/otx2_cptvf.h +2 -0
@@ -22,6 +22,7 @@ struct otx2_cptvf_dev {int blkaddr;void *bbuf_base;unsigned long cap_flag; +u64 eng_caps[OTX2_CPT_MAX_ENG_TYPES ]; };irqreturn_t otx2_cptvf_pfvf_mbox_intr (int irq,void *arg);
@@ -29,5 +30,6 @@ void otx2_cptvf_pfvf_mbox_handler(struct work_struct *work);int otx2_cptvf_send_eng_grp_num_msg (struct otx2_cptvf_dev *cptvf,int eng_type);int otx2_cptvf_send_kvf_limits_msg (struct otx2_cptvf_dev *cptvf);int otx2_cpt_mbox_bbuf_init (struct otx2_cptvf_dev *cptvf,struct pci_dev *pdev); +int otx2_cptvf_send_caps_msg (struct otx2_cptvf_dev *cptvf);#endif /* __OTX2_CPTVF_H */
drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c +13 -0
@@ -380,6 +380,19 @@ static int otx2_cptvf_probe(struct pci_dev *pdev, goto destroy_pfvf_mbox; cptvf->blkaddr =BLKADDR_CPT0 ; + + ret =cptvf_hw_ops_get (cptvf); +if (ret) + goto unregister_interrupts; + + ret =otx2_cptvf_send_caps_msg (cptvf); +if (ret) { +dev_err (&pdev->dev,"Couldn't get CPT engine capabilities.\n" ); + goto unregister_interrupts; + } +if (cptvf->eng_caps[OTX2_CPT_SE_TYPES ] &BIT_ULL (35 )) + cptvf->lfs.ops->cpt_sg_info_create = cn10k_sgv2_info_create; +/* Initialize CPT LFs */ ret =cptvf_lf_init (cptvf);if (ret)
drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c +25 -0
@@ -72,6 +72,7 @@ static void process_pfvf_mbox_mbox_msg(struct otx2_cptvf_dev *cptvf,struct otx2_cptlfs_info *lfs = &cptvf->lfs;struct otx2_cpt_kvf_limits_rsp *rsp_limits;struct otx2_cpt_egrp_num_rsp *rsp_grp; +struct otx2_cpt_caps_rsp *eng_caps;struct cpt_rd_wr_reg_msg *rsp_reg;struct msix_offset_rsp *rsp_msix;int i;
@@ -127,6 +128,10 @@ static void process_pfvf_mbox_mbox_msg(struct otx2_cptvf_dev *cptvf, rsp_limits = (struct otx2_cpt_kvf_limits_rsp *) msg; cptvf->lfs.kvf_limits = rsp_limits->kvf_limits;break ; +case MBOX_MSG_GET_CAPS : + eng_caps = (struct otx2_cpt_caps_rsp *) msg; +memcpy (cptvf->eng_caps, eng_caps->eng_caps,sizeof (cptvf->eng_caps)); +break ;default :dev_err (&cptvf->pdev->dev,"Unsupported msg %d received.\n" , msg->id);
@@ -205,3 +210,23 @@ int otx2_cptvf_send_kvf_limits_msg(struct otx2_cptvf_dev *cptvf)return otx2_cpt_send_mbox_msg (mbox, pdev); } + +int otx2_cptvf_send_caps_msg (struct otx2_cptvf_dev *cptvf) +{ +struct otx2_mbox *mbox = &cptvf->pfvf_mbox; +struct pci_dev *pdev = cptvf->pdev; +struct mbox_msghdr *req; + + req = (struct mbox_msghdr *) +otx2_mbox_alloc_msg_rsp (mbox,0 ,sizeof (*req), +sizeof (struct otx2_cpt_caps_rsp )); +if (req ==NULL ) { +dev_err (&pdev->dev,"RVU MBOX failed to get message.\n" ); +return -EFAULT ; + } + req->id =MBOX_MSG_GET_CAPS ; + req->sig =OTX2_MBOX_REQ_SIG ; + req->pcifunc =OTX2_CPT_RVU_PFFUNC (cptvf->vf_id,0 ); + +return otx2_cpt_send_mbox_msg (mbox, pdev); +}
drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c +7 -153
198 lines not on this page · raw message
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 3/10 crypto: octeontx2: add devlink option to set max_rxc_icb_cnt
In reply to Srujana ChallaOn CN10KA B0/CN10KB HW, maximum icb entries that RX can use, can be configured through HW CSR. This patch adds option to set max icb entries through devlink parameter and also sets max_rxc_icb_cnt to 0xc0 as default to match inline inbound peak performance compared to other chip versions.
--- .../marvell/octeontx2/otx2_cpt_common.h | 8 ++++ .../marvell/octeontx2/otx2_cpt_devlink.c | 44 +++++++++++++++++++ .../ethernet/marvell/octeontx2/af/rvu_cpt.c | 14 ++++++ .../ethernet/marvell/octeontx2/af/rvu_reg.h | 1 + 4 files changed, 67 insertions(+)
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h +8 -0
@@ -192,6 +192,14 @@ static inline void otx2_cpt_set_hw_caps(struct pci_dev *pdev, } } +static inline bool cpt_feature_rxc_icb_cnt (struct pci_dev *pdev) +{ +if (!is_dev_otx2 (pdev) && !is_dev_cn10ka_ax (pdev)) +return true; + +return false; +} +int otx2_cpt_send_ready_msg (struct otx2_mbox *mbox,struct pci_dev *pdev);int otx2_cpt_send_mbox_msg (struct otx2_mbox *mbox,struct pci_dev *pdev);
drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c +44 -0
60 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c +14 -0
@@ -673,6 +673,7 @@ static bool is_valid_offset(struct rvu *rvu, struct cpt_rd_wr_reg_msg *req)case CPT_AF_BLK_RST :case CPT_AF_CONSTANTS1 :case CPT_AF_CTX_FLUSH_TIMER : +case CPT_AF_RXC_CFG1 :return true; }
@@ -1213,8 +1214,21 @@ int rvu_cpt_ctx_flush(struct rvu *rvu, u16 pcifunc)int rvu_cpt_init (struct rvu *rvu) { +u64 reg_val; +/* Retrieve CPT PF number */ rvu->cpt_pf_num =get_cpt_pf_num (rvu); +if (is_block_implemented (rvu->hw,BLKADDR_CPT0 ) && + (!is_rvu_otx2 (rvu) && !is_cn10ka_a0 (rvu) && !is_cn10ka_a1 (rvu))) { +/* Set CPT_AF_RXC_CFG1:max_rxc_icb_cnt to 0xc0 to not effect +* inline inbound peak performance +*/ + reg_val =rvu_read64 (rvu,BLKADDR_CPT0 ,CPT_AF_RXC_CFG1 ); + reg_val &= ~(0x1FFULL <<32 ); + reg_val |=0xC0ULL <<32 ; +rvu_write64 (rvu,BLKADDR_CPT0 ,CPT_AF_RXC_CFG1 , reg_val); + } +spin_lock_init (&rvu->cpt_intr_lock);return 0 ;
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +1 -0
@@ -532,6 +532,7 @@#define CPT_AF_CTX_PSH_PC (0x49450ull)#define CPT_AF_CTX_PSH_LATENCY_PC (0x49458ull)#define CPT_AF_CTX_CAM_DATA (a) (0x49800ull | (u64)(a) << 3) +#define CPT_AF_RXC_CFG1 (0x50000ull)#define CPT_AF_RXC_TIME (0x50010ull)#define CPT_AF_RXC_TIME_CFG (0x50018ull)#define CPT_AF_RXC_DFRG (0x50020ull)
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerRe: [PATCH 03/10] crypto: octeontx2: add devlink option to set max_rxc_icb_cnt
Quoted 5 lines · On Mon, 16 Oct 2023 12:19:27 +0530 Srujana Challa wrote:
On CN10KA B0/CN10KB HW, maximum icb entries that RX can use, can be configured through HW CSR. This patch adds option to set max icb entries through devlink parameter and also sets
max_rxc_icb_cntto0xc0as default to match inline inbound peak performance compared to other chip versions.
If it's a resource it should be configured via devlink-resource.
Every piece of devlink config must be documented under Documentation/
When you repost please CC netdev.
kernel test robot
build botRe: [PATCH 03/10] crypto: octeontx2: add devlink option to set max_rxc_icb_cnt
In reply to Srujana Challakernel test robot noticed the following build errors:
Hi Srujana,
kernel test robot noticed the following build errors:
[auto build test ERROR on herbert-cryptodev-2.6/master]
[also build test ERROR on herbert-crypto-2.6/master linus/master v6.6-rc6 next-20231020] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Srujana-Challa/crypto-octeontx2-remove-CPT-block-reset/20231017-141612 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/20231016064934.1913964-4-schalla%40marvell.com patch subject: [PATCH 03/10] crypto: octeontx2: add devlink option to set max_rxc_icb_cnt config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20231021/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231021/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c: In function 'rvu_cpt_init':
>> drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c:1222:36: error: implicit declaration of function 'is_cn10ka_a0'; did you mean 'is_cnf10ka_a0'? [-Werror=implicit-function-declaration]
1222 | (!is_rvu_otx2(rvu) && !is_cn10ka_a0(rvu) && !is_cn10ka_a1(rvu))) {
| ^~~~~~~~~~~~
| is_cnf10ka_a0
>> drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c:1222:58: error: implicit declaration of function 'is_cn10ka_a1'; did you mean 'is_cnf10ka_a0'? [-Werror=implicit-function-declaration]
1222 | (!is_rvu_otx2(rvu) && !is_cn10ka_a0(rvu) && !is_cn10ka_a1(rvu))) {
| ^~~~~~~~~~~~
| is_cnf10ka_a0cc1: some warnings being treated as errors
vim +1222 drivers/net/ethernet/marvell/octeontx2/af/rvu_cpt.c
1214
1215 int rvu_cpt_init(struct rvu *rvu)
1216 {
1217 u64 reg_val;
1218
1219 /* Retrieve CPT PF number */
1220 rvu->cpt_pf_num = get_cpt_pf_num(rvu);
1221 if (is_block_implemented(rvu->hw, BLKADDR_CPT0) &&
> 1222 (!is_rvu_otx2(rvu) && !is_cn10ka_a0(rvu) && !is_cn10ka_a1(rvu))) {Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Srujana Challa
maintainerPATCH 4/10 crypto: octeontx2: add devlink option to set t106 mode
In reply to Srujana ChallaOn 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.
--- .../marvell/octeontx2/otx2_cpt_common.h | 8 +++ .../marvell/octeontx2/otx2_cpt_devlink.c | 51 +++++++++++++++++-- .../marvell/octeontx2/otx2_cptpf_main.c | 4 +- 3 files changed, 56 insertions(+), 7 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h +8 -0
@@ -200,6 +200,14 @@ static inline bool cpt_feature_rxc_icb_cnt(struct pci_dev *pdev)return false; } +static inline bool cpt_feature_sgv2 (struct pci_dev *pdev) +{ +if (!is_dev_otx2 (pdev) && !is_dev_cn10ka_ax (pdev)) +return true; + +return false; +} +int otx2_cpt_send_ready_msg (struct otx2_mbox *mbox,struct pci_dev *pdev);int otx2_cpt_send_mbox_msg (struct otx2_mbox *mbox,struct pci_dev *pdev);
drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c +46 -5
80 lines not on this page · raw message
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c +2 -2
@@ -600,10 +600,10 @@ static int cptpf_get_rid(struct pci_dev *pdev, struct otx2_cptpf_dev *cptpf) }otx2_cpt_read_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_CTL , ®_val,BLKADDR_CPT0 ); -if ((is_dev_cn10ka_b0 (pdev) && (reg_val &BIT_ULL (18 ))) || +if ((cpt_feature_sgv2 (pdev) && (reg_val &BIT_ULL (18 ))) ||is_dev_cn10ka_ax (pdev)) eng_grps->rid =CPT_UC_RID_CN10K_A ; -else if (is_dev_cn10kb (pdev) ||is_dev_cn10ka_b0 (pdev)) +else if (cpt_feature_sgv2 (pdev)) eng_grps->rid =CPT_UC_RID_CN10K_B ;return 0 ;
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH 04/10] crypto: octeontx2: add devlink option to set t106 mode
kernel test robot noticed the following build errors:
Hi Srujana,
kernel test robot noticed the following build errors:
[auto build test ERROR on herbert-cryptodev-2.6/master]
[also build test ERROR on herbert-crypto-2.6/master linus/master v6.6-rc6 next-20231020] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Srujana-Challa/crypto-octeontx2-remove-CPT-block-reset/20231017-141612 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/20231016064934.1913964-5-schalla%40marvell.com patch subject: [PATCH 04/10] crypto: octeontx2: add devlink option to set t106 mode config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20231021/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231021/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c: In function 'otx2_cpt_register_dl':
>> drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c:208:9: error: implicit declaration of function 'devlink_params_publish'; did you mean 'devlink_params_register'? [-Werror=implicit-function-declaration]
208 | devlink_params_publish(dl);
| ^~~~~~~~~~~~~~~~~~~~~~
| devlink_params_registercc1: some warnings being treated as errors
vim +208 drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c
181
182 int otx2_cpt_register_dl(struct otx2_cptpf_dev *cptpf)
183 {
184 struct device *dev = &cptpf->pdev->dev;
185 struct otx2_cpt_devlink *cpt_dl;
186 struct devlink *dl;
187 int ret;
188
189 dl = devlink_alloc(&otx2_cpt_devlink_ops,
190 sizeof(struct otx2_cpt_devlink), dev);
191 if (!dl) {
192 dev_warn(dev, "devlink_alloc failed\n");
193 return -ENOMEM;
194 }
195
196 cpt_dl = devlink_priv(dl);
197 cpt_dl->dl = dl;
198 cpt_dl->cptpf = cptpf;
199 cptpf->dl = dl;
200 ret = devlink_params_register(dl, otx2_cpt_dl_params,
201 ARRAY_SIZE(otx2_cpt_dl_params));
202 if (ret) {
203 dev_err(dev, "devlink params register failed with error %d",
204 ret);
205 devlink_free(dl);
206 return ret;
207 }
> 208 devlink_params_publish(dl);
209 devlink_register(dl);
210
211 return 0;
212 }
213
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Srujana Challa
maintainerPATCH 5/10 crypto: octeontx2: remove errata workaround for CN10KB or CN10KA B0 chip.
In reply to Srujana ChallaAdds code to not execute CPT errata "when CPT_AF_DIAG[FLT_DIS] = 0 and a CPT engine access to LLC/DRAM encounters a fault/poison, a rare case may result in unpredictable data being delivered to a CPT engine" workaround on CN10KA B0/CN10KB HW as it is fixed on these chips.
--- drivers/crypto/marvell/octeontx2/otx2_cpt_common.h | 8 ++++++++ drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h +8 -0
@@ -208,6 +208,14 @@ static inline bool cpt_feature_sgv2(struct pci_dev *pdev)return false; } +static inline bool cpt_is_errata_38550_exists (struct pci_dev *pdev) +{ +if (is_dev_otx2 (pdev) ||is_dev_cn10ka_ax (pdev)) +return true; + +return false; +} +int otx2_cpt_send_ready_msg (struct otx2_mbox *mbox,struct pci_dev *pdev);int otx2_cpt_send_mbox_msg (struct otx2_mbox *mbox,struct pci_dev *pdev);
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +6 -4
@@ -1254,10 +1254,12 @@ int otx2_cpt_create_eng_grps(struct otx2_cptpf_dev *cptpf,* encounters a fault/poison, a rare case may result in * unpredictable data being delivered to a CPT engine. */ -otx2_cpt_read_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_DIAG , ®_val, -BLKADDR_CPT0 ); -otx2_cpt_write_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_DIAG , - reg_val |BIT_ULL (24 ),BLKADDR_CPT0 ); +if (cpt_is_errata_38550_exists (pdev)) { +otx2_cpt_read_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_DIAG , ®_val, +BLKADDR_CPT0 ); +otx2_cpt_write_af_reg (&cptpf->afpf_mbox, pdev,CPT_AF_DIAG , + reg_val |BIT_ULL (24 ),BLKADDR_CPT0 ); + }mutex_unlock (&eng_grps->lock);return 0 ;
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 6/10 crypto: octeontx2: add LF reset on queue disable
In reply to Srujana ChallaCPT LF must be reset and follow CPT LF disable sequence suggested by HW team, when driver exits.
This patch adds code for the same.
--- .../marvell/octeontx2/otx2_cpt_common.h | 1 + .../marvell/octeontx2/otx2_cpt_mbox_common.c | 26 +++++++ drivers/crypto/marvell/octeontx2/otx2_cptlf.h | 77 ++++++++++++------- .../marvell/octeontx2/otx2_cptpf_mbox.c | 9 ++- .../marvell/octeontx2/otx2_cptvf_mbox.c | 2 + 5 files changed, 86 insertions(+), 29 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h +1 -0
@@ -232,5 +232,6 @@ int otx2_cpt_attach_rscrs_msg(struct otx2_cptlfs_info *lfs);int otx2_cpt_detach_rsrcs_msg (struct otx2_cptlfs_info *lfs);int otx2_cpt_msix_offset_msg (struct otx2_cptlfs_info *lfs);int otx2_cpt_sync_mbox_msg (struct otx2_mbox *mbox); +int otx2_cpt_lf_reset_msg (struct otx2_cptlfs_info *lfs,int slot);#endif /* __OTX2_CPT_COMMON_H */
drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.c +26 -0
@@ -229,3 +229,29 @@ int otx2_cpt_sync_mbox_msg(struct otx2_mbox *mbox)return otx2_mbox_check_rsp_msgs (mbox,0 ); }EXPORT_SYMBOL_NS_GPL (otx2_cpt_sync_mbox_msg,CRYPTO_DEV_OCTEONTX2_CPT ); + +int otx2_cpt_lf_reset_msg (struct otx2_cptlfs_info *lfs,int slot) +{ +struct otx2_mbox *mbox = lfs->mbox; +struct pci_dev *pdev = lfs->pdev; +struct cpt_lf_rst_req *req; +int ret; + + req = (struct cpt_lf_rst_req *)otx2_mbox_alloc_msg_rsp (mbox,0 ,sizeof (*req), +sizeof (struct msg_rsp )); +if (req ==NULL ) { +dev_err (&pdev->dev,"RVU MBOX failed to get message.\n" ); +return -EFAULT ; + } + + req->hdr.id =MBOX_MSG_CPT_LF_RESET ; + req->hdr.sig =OTX2_MBOX_REQ_SIG ; + req->hdr.pcifunc =0 ; + req->slot = slot; + ret =otx2_cpt_send_mbox_msg (mbox, pdev); +if (ret) +return ret; + +return ret; +} +EXPORT_SYMBOL_NS_GPL (otx2_cpt_lf_reset_msg,CRYPTO_DEV_OCTEONTX2_CPT );
drivers/crypto/marvell/octeontx2/otx2_cptlf.h +51 -26
111 lines not on this page · raw message
drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c +6 -3
@@ -201,8 +201,8 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf, struct mbox_msghdr *req) {struct otx2_cpt_rx_inline_lf_cfg *cfg_req; +int num_lfs =1 , ret;u8 egrp; -int ret; cfg_req = (struct otx2_cpt_rx_inline_lf_cfg *)req;if (cptpf->lfs.lfs_num) {
@@ -223,8 +223,9 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,otx2_cptlf_set_dev_info (&cptpf->lfs, cptpf->pdev, cptpf->reg_base, &cptpf->afpf_mbox,BLKADDR_CPT0 ); + cptpf->lfs.global_slot =0 ; ret =otx2_cptlf_init (&cptpf->lfs,1 << egrp,OTX2_CPT_QUEUE_HI_PRIO , -1 ); + num_lfs);if (ret) {dev_err (&cptpf->pdev->dev,"LF configuration failed for RX inline ipsec.\n" );
@@ -236,8 +237,9 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,otx2_cptlf_set_dev_info (&cptpf->cpt1_lfs, cptpf->pdev, cptpf->reg_base, &cptpf->afpf_mbox,BLKADDR_CPT1 ); + cptpf->cpt1_lfs.global_slot = num_lfs; ret =otx2_cptlf_init (&cptpf->cpt1_lfs,1 << egrp, -OTX2_CPT_QUEUE_HI_PRIO ,1 ); +OTX2_CPT_QUEUE_HI_PRIO , num_lfs);if (ret) {dev_err (&cptpf->pdev->dev,"LF configuration failed for RX inline ipsec.\n" );
@@ -449,6 +451,7 @@ static void process_afpf_mbox_msg(struct otx2_cptpf_dev *cptpf,break ;case MBOX_MSG_CPT_INLINE_IPSEC_CFG :case MBOX_MSG_NIX_INLINE_IPSEC_CFG : +case MBOX_MSG_CPT_LF_RESET :break ;default :
drivers/crypto/marvell/octeontx2/otx2_cptvf_mbox.c +2 -0
@@ -132,6 +132,8 @@ static void process_pfvf_mbox_mbox_msg(struct otx2_cptvf_dev *cptvf, eng_caps = (struct otx2_cpt_caps_rsp *) msg;memcpy (cptvf->eng_caps, eng_caps->eng_caps,sizeof (cptvf->eng_caps));break ; +case MBOX_MSG_CPT_LF_RESET : +break ;default :dev_err (&cptvf->pdev->dev,"Unsupported msg %d received.\n" , msg->id);
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 7/10 octeontx2-af: update CPT inbound inline IPsec mailbox
In reply to Srujana ChallaUpdates CPT inbound inline IPsec configure mailbox to take CPT credit threshold and bpid, which are introduced in CN10KB.
--- drivers/crypto/marvell/octeontx2/otx2_cpt_common.h | 2 ++ drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c | 2 ++ drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h +2 -0
@@ -56,6 +56,8 @@ struct otx2_cpt_rx_inline_lf_cfg {u16 param2;u16 opcode;u32 credit; +u32 credit_th; +u16 bpid;u32 reserved; };
drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c +2 -0
@@ -171,6 +171,8 @@ static int rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf, u8 egrp, nix_req->hdr.id =MBOX_MSG_NIX_INLINE_IPSEC_CFG ; nix_req->hdr.sig =OTX2_MBOX_REQ_SIG ; nix_req->enable =1 ; + nix_req->credit_th = req->credit_th; + nix_req->bpid = req->bpid;if (!req->credit || req->credit >OTX2_CPT_INST_QLEN_MSGS ) nix_req->cpt_credit =OTX2_CPT_INST_QLEN_MSGS -1 ;else
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +5 -1
@@ -16,7 +16,11 @@#define LOADFVC_MAJOR_OP 0x01#define LOADFVC_MINOR_OP 0x08 -#define CTX_FLUSH_TIMER_CNT 0xFFFFFF +/* +* Interval to flush dirty data for next CTX entry. The interval is measured +* in increments of 10ns(interval time = CTX_FLUSH_TIMER_COUNT * 10ns). +*/ +#define CTX_FLUSH_TIMER_CNT 0x2FAF0struct fw_info_t {struct list_head ucodes;
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 8/10 crypto: octeontx2: add ctx_val workaround
In reply to Srujana ChallaHW has a errata that CPT HW may hit an issue, while processing CPT instructions with CTX_VAL set and CTX_VAL not set. So, this patch adds the code to always set the CTX_VAL as a workaround.
--- drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 68 +++++++++++++++++++ drivers/crypto/marvell/octeontx2/cn10k_cpt.h | 24 +++++++ .../marvell/octeontx2/otx2_cpt_hw_types.h | 2 + .../marvell/octeontx2/otx2_cpt_reqmgr.h | 2 + .../marvell/octeontx2/otx2_cptvf_algs.c | 31 +++++++++ .../marvell/octeontx2/otx2_cptvf_algs.h | 5 ++ .../marvell/octeontx2/otx2_cptvf_reqmgr.c | 2 +- 7 files changed, 133 insertions(+), 1 deletion(-)
drivers/crypto/marvell/octeontx2/cn10k_cpt.c +68 -0
@@ -96,6 +96,74 @@ int cn10k_cptvf_lmtst_init(struct otx2_cptvf_dev *cptvf) }EXPORT_SYMBOL_NS_GPL (cn10k_cptvf_lmtst_init,CRYPTO_DEV_OCTEONTX2_CPT ); +void cn10k_cpt_hw_ctx_clear (struct pci_dev *pdev,struct cn10k_cpt_errata_ctx *er_ctx) +{ +u64 cptr_dma; + +if (!is_dev_cn10ka_ax (pdev)) +return ; + + cptr_dma = er_ctx->cptr_dma & ~(BIT_ULL (60 )); +cn10k_cpt_ctx_flush (pdev, cptr_dma, true); +dma_unmap_single (&pdev->dev, cptr_dma,CN10K_CPT_HW_CTX_SIZE , +DMA_BIDIRECTIONAL ); +kfree (er_ctx->hw_ctx); +} +EXPORT_SYMBOL_NS_GPL (cn10k_cpt_hw_ctx_clear,CRYPTO_DEV_OCTEONTX2_CPT ); + +void cn10k_cpt_hw_ctx_set (union cn10k_cpt_hw_ctx *hctx,u16 ctx_sz) +{ + hctx->w0.aop_valid =1 ; + hctx->w0.ctx_hdr_sz =0 ; + hctx->w0.ctx_sz = ctx_sz; + hctx->w0.ctx_push_sz =1 ; +} +EXPORT_SYMBOL_NS_GPL (cn10k_cpt_hw_ctx_set,CRYPTO_DEV_OCTEONTX2_CPT ); + +int cn10k_cpt_hw_ctx_init (struct pci_dev *pdev,struct cn10k_cpt_errata_ctx *er_ctx) +{ +union cn10k_cpt_hw_ctx *hctx; +u64 cptr_dma; + + er_ctx->cptr_dma =0 ; + er_ctx->hw_ctx =NULL ; + +if (!is_dev_cn10ka_ax (pdev)) +return 0 ; + + hctx =kmalloc (CN10K_CPT_HW_CTX_SIZE ,GFP_KERNEL ); +if (unlikely (!hctx)) +return -ENOMEM ; + cptr_dma =dma_map_single (&pdev->dev, hctx,CN10K_CPT_HW_CTX_SIZE , +DMA_BIDIRECTIONAL ); + +cn10k_cpt_hw_ctx_set (hctx,1 ); + er_ctx->hw_ctx = hctx; + er_ctx->cptr_dma = cptr_dma |BIT_ULL (60 ); + +return 0 ; +} +EXPORT_SYMBOL_NS_GPL (cn10k_cpt_hw_ctx_init,CRYPTO_DEV_OCTEONTX2_CPT ); + +void cn10k_cpt_ctx_flush (struct pci_dev *pdev,u64 cptr,bool inval) +{ +struct otx2_cptvf_dev *cptvf =pci_get_drvdata (pdev); +struct otx2_cptlfs_info *lfs = &cptvf->lfs; +u64 reg; + + reg = (uintptr_t )cptr >>7 ; +if (inval) + reg = reg |BIT_ULL (46 ); + +otx2_cpt_write64 (lfs->reg_base, lfs->blkaddr, lfs->lf[0 ].slot, +OTX2_CPT_LF_CTX_FLUSH , reg); +/* Make sure that the FLUSH operation is complete */ +wmb (); +otx2_cpt_read64 (lfs->reg_base, lfs->blkaddr, lfs->lf[0 ].slot, +OTX2_CPT_LF_CTX_ERR ); +} +EXPORT_SYMBOL_NS_GPL (cn10k_cpt_ctx_flush,CRYPTO_DEV_OCTEONTX2_CPT ); +int cptvf_hw_ops_get (struct otx2_cptvf_dev *cptvf) {if (!test_bit (CN10K_LMTST , &cptvf->cap_flag)) {
drivers/crypto/marvell/octeontx2/cn10k_cpt.h +24 -0
@@ -8,6 +8,26 @@#include "otx2_cptpf.h" #include "otx2_cptvf.h" +#define CN10K_CPT_HW_CTX_SIZE 256 + +union cn10k_cpt_hw_ctx { +u64 u; +struct { +u64 reserved_0_47:48 ; +u64 ctx_push_sz:7 ; +u64 reserved_55:1 ; +u64 ctx_hdr_sz:2 ; +u64 aop_valid:1 ; +u64 reserved_59:1 ; +u64 ctx_sz:4 ; + } w0; +}; + +struct cn10k_cpt_errata_ctx { +union cn10k_cpt_hw_ctx *hw_ctx; +u64 cptr_dma; +}; +static inline u8 cn10k_cpt_get_compcode (union otx2_cpt_res_s *result) {return ((struct cn10k_cpt_res_s *)result)->compcode;
@@ -30,6 +50,10 @@ static inline u8 otx2_cpt_get_uc_compcode(union otx2_cpt_res_s *result)int cn10k_cptpf_lmtst_init (struct otx2_cptpf_dev *cptpf);int cn10k_cptvf_lmtst_init (struct otx2_cptvf_dev *cptvf); +void cn10k_cpt_ctx_flush (struct pci_dev *pdev,u64 cptr,bool inval); +int cn10k_cpt_hw_ctx_init (struct pci_dev *pdev,struct cn10k_cpt_errata_ctx *er_ctx); +void cn10k_cpt_hw_ctx_clear (struct pci_dev *pdev,struct cn10k_cpt_errata_ctx *er_ctx); +void cn10k_cpt_hw_ctx_set (union cn10k_cpt_hw_ctx *hctx,u16 ctx_sz);int cptvf_hw_ops_get (struct otx2_cptvf_dev *cptvf);#endif /* __CN10K_CPTLF_H */
drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h +2 -0
@@ -102,6 +102,8 @@#define OTX2_CPT_LF_Q_INST_PTR (0x110)#define OTX2_CPT_LF_Q_GRP_PTR (0x120)#define OTX2_CPT_LF_NQX (a) (0x400 | (a) << 3) +#define OTX2_CPT_LF_CTX_FLUSH (0x510) +#define OTX2_CPT_LF_CTX_ERR (0x520)#define OTX2_CPT_RVU_FUNC_BLKADDR_SHIFT 20/* LMT LF registers */ #define OTX2_CPT_LMT_LFBASE BIT_ULL(OTX2_CPT_RVU_FUNC_BLKADDR_SHIFT)
drivers/crypto/marvell/octeontx2/otx2_cpt_reqmgr.h +2 -0
@@ -40,6 +40,8 @@ struct otx2_cptvf_request {u32 param2;u16 dlen;union otx2_cpt_opcode opcode; +dma_addr_t cptr_dma; +void *cptr; };/*
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c +31 -0
@@ -17,6 +17,7 @@#include "otx2_cptvf.h" #include "otx2_cptvf_algs.h" #include "otx2_cpt_reqmgr.h" +#include "cn10k_cpt.h" /* Size of salt in AES GCM mode */ #define AES_GCM_SALT_SIZE 4
@@ -384,6 +385,9 @@ static inline int cpt_enc_dec(struct skcipher_request *req, u32 enc) req_info->is_trunc_hmac = false; req_info->ctrl.s.grp =otx2_cpt_get_kcrypto_eng_grp_num (pdev); + req_info->req.cptr = ctx->er_ctx.hw_ctx; + req_info->req.cptr_dma = ctx->er_ctx.cptr_dma; +/* * We perform an asynchronous send and once * the request is completed the driver would
@@ -530,6 +534,8 @@ static int otx2_cpt_enc_dec_init(struct crypto_skcipher *stfm)struct otx2_cpt_enc_ctx *ctx =crypto_skcipher_ctx (stfm);struct crypto_tfm *tfm =crypto_skcipher_tfm (stfm);struct crypto_alg *alg = tfm->__crt_alg; +struct pci_dev *pdev; +int ret, cpu_num;memset (ctx,0 ,sizeof (*ctx));/*
@@ -541,6 +547,15 @@ static int otx2_cpt_enc_dec_init(struct crypto_skcipher *stfm) stfm,sizeof (struct otx2_cpt_req_ctx ) + sizeof(struct skcipher_request)); + ret =get_se_device (&pdev, &cpu_num); +if (ret) +return ret; + + ctx->pdev = pdev; + ret =cn10k_cpt_hw_ctx_init (pdev, &ctx->er_ctx); +if (ret) +return ret; +return cpt_skcipher_fallback_init (ctx, alg); }
@@ -552,6 +567,7 @@ static void otx2_cpt_skcipher_exit(struct crypto_skcipher *tfm)crypto_free_skcipher (ctx->fbk_cipher); ctx->fbk_cipher =NULL ; } +cn10k_cpt_hw_ctx_clear (ctx->pdev, &ctx->er_ctx); } static int cpt_aead_fallback_init(struct otx2_cpt_aead_ctx *ctx,
@@ -576,6 +592,8 @@ static int cpt_aead_init(struct crypto_aead *atfm, u8 cipher_type, u8 mac_type)struct otx2_cpt_aead_ctx *ctx =crypto_aead_ctx_dma (atfm);struct crypto_tfm *tfm =crypto_aead_tfm (atfm);struct crypto_alg *alg = tfm->__crt_alg; +struct pci_dev *pdev; +int ret, cpu_num; ctx->cipher_type = cipher_type; ctx->mac_type = mac_type;
@@ -632,6 +650,15 @@ static int cpt_aead_init(struct crypto_aead *atfm, u8 cipher_type, u8 mac_type) }crypto_aead_set_reqsize_dma (atfm,sizeof (struct otx2_cpt_req_ctx )); + ret =get_se_device (&pdev, &cpu_num); +if (ret) +return ret; + + ctx->pdev = pdev; + ret =cn10k_cpt_hw_ctx_init (pdev, &ctx->er_ctx); +if (ret) +return ret; +return cpt_aead_fallback_init (ctx, alg); }
@@ -694,6 +721,7 @@ static void otx2_cpt_aead_exit(struct crypto_aead *tfm)crypto_free_aead (ctx->fbk_cipher); ctx->fbk_cipher =NULL ; } +cn10k_cpt_hw_ctx_clear (ctx->pdev, &ctx->er_ctx); } static int otx2_cpt_aead_gcm_set_authsize(struct crypto_aead *tfm,
@@ -1299,6 +1327,9 @@ static int cpt_aead_enc_dec(struct aead_request *req, u8 reg_type, u8 enc) req_info->is_enc = enc; req_info->is_trunc_hmac = false; + req_info->req.cptr = ctx->er_ctx.hw_ctx; + req_info->req.cptr_dma = ctx->er_ctx.cptr_dma; +switch (reg_type) {case OTX2_CPT_AEAD_ENC_DEC_REQ : status =create_aead_input_list (req, enc);
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.h +5 -0
@@ -9,6 +9,7 @@#include <crypto/skcipher.h> #include <crypto/aead.h> #include "otx2_cpt_common.h" +#include "cn10k_cpt.h" #define OTX2_CPT_MAX_ENC_KEY_SIZE 32#define OTX2_CPT_MAX_HASH_KEY_SIZE 64
@@ -123,6 +124,8 @@ struct otx2_cpt_enc_ctx {u8 key_type;u8 enc_align_len;struct crypto_skcipher *fbk_cipher; +struct pci_dev *pdev; +struct cn10k_cpt_errata_ctx er_ctx; };union otx2_cpt_offset_ctrl {
@@ -161,6 +164,8 @@ struct otx2_cpt_aead_ctx {struct crypto_shash *hashalg;struct otx2_cpt_sdesc *sdesc;struct crypto_aead *fbk_cipher; +struct cn10k_cpt_errata_ctx er_ctx; +struct pci_dev *pdev;u8 *ipad;u8 *opad;u32 enc_key_len;
drivers/crypto/marvell/octeontx2/otx2_cptvf_reqmgr.c +1 -1
@@ -159,7 +159,7 @@ static int process_request(struct pci_dev *pdev, struct otx2_cpt_req_info *req,cpu_to_be64s (&iq_cmd.cmd.u); iq_cmd.dptr = info->dptr_baddr | info->gthr_sz <<60 ; iq_cmd.rptr = info->rptr_baddr | info->sctr_sz <<60 ; - iq_cmd.cptr.u =0 ; + iq_cmd.cptr.s.cptr = cpt_req->cptr_dma; iq_cmd.cptr.s.grp = ctrl->s.grp;/* Fill in the CPT_INST_S type command for HW interpretation */
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 9/10 crypto/octeontx2: register error interrupts for inline cptlf
In reply to Srujana ChallaFrom: Nithin Dabilpuram <[email protected]>
Register errors interrupts for inline cptlf attached to PF driver so that SMMU faults and other errors can be reported.
--- drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 98 ++++++++++++------- drivers/crypto/marvell/octeontx2/otx2_cptlf.h | 6 +- drivers/crypto/marvell/octeontx2/otx2_cptpf.h | 4 + .../marvell/octeontx2/otx2_cptpf_main.c | 17 +++- .../marvell/octeontx2/otx2_cptpf_mbox.c | 67 +++++++++++-- .../marvell/octeontx2/otx2_cptvf_main.c | 12 ++- 6 files changed, 149 insertions(+), 55 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cptlf.c +61 -37
@@ -151,26 +151,13 @@ static void cptlf_set_misc_intrs(struct otx2_cptlfs_info *lfs, u8 enable) irq_misc.u); } -static void cptlf_enable_intrs (struct otx2_cptlfs_info *lfs) +static void cptlf_set_done_intrs (struct otx2_cptlfs_info *lfs,u8 enable) { +u64 reg = enable ?OTX2_CPT_LF_DONE_INT_ENA_W1S :OTX2_CPT_LF_DONE_INT_ENA_W1C ;int slot; -/* Enable done interrupts */ for (slot =0 ; slot < lfs->lfs_num; slot++) -otx2_cpt_write64 (lfs->reg_base, lfs->blkaddr, slot, -OTX2_CPT_LF_DONE_INT_ENA_W1S ,0x1 ); -/* Enable Misc interrupts */ -cptlf_set_misc_intrs (lfs, true); -} - -static void cptlf_disable_intrs (struct otx2_cptlfs_info *lfs) -{ -int slot; - -for (slot =0 ; slot < lfs->lfs_num; slot++) -otx2_cpt_write64 (lfs->reg_base, lfs->blkaddr, slot, -OTX2_CPT_LF_DONE_INT_ENA_W1C ,0x1 ); -cptlf_set_misc_intrs (lfs, false); +otx2_cpt_write64 (lfs->reg_base, lfs->blkaddr, slot, reg,0x1 ); }static inline int cptlf_read_done_cnt (struct otx2_cptlf_info *lf)
@@ -257,24 +244,44 @@ static irqreturn_t cptlf_done_intr_handler(int irq, void *arg)return IRQ_HANDLED ; } -void otx2_cptlf_unregister_interrupts (struct otx2_cptlfs_info *lfs) +void otx2_cptlf_unregister_misc_interrupts (struct otx2_cptlfs_info *lfs) { -int i, offs, vector; +int i, irq_offs, vector; + irq_offs =OTX2_CPT_LF_INT_VEC_E_MISC ;for (i =0 ; i < lfs->lfs_num; i++) { -for (offs =0 ; offs <OTX2_CPT_LF_MSIX_VECTORS ; offs++) { -if (!lfs->lf[i].is_irq_reg[offs]) -continue ; +if (!lfs->lf[i].is_irq_reg[irq_offs]) +continue ; - vector =pci_irq_vector (lfs->pdev, - lfs->lf[i].msix_offset + offs); -free_irq (vector, &lfs->lf[i]); - lfs->lf[i].is_irq_reg[offs] = false; - } + vector =pci_irq_vector (lfs->pdev, + lfs->lf[i].msix_offset + irq_offs); +free_irq (vector, &lfs->lf[i]); + lfs->lf[i].is_irq_reg[irq_offs] = false; + } + +cptlf_set_misc_intrs (lfs, false); +} +EXPORT_SYMBOL_NS_GPL (otx2_cptlf_unregister_misc_interrupts, +CRYPTO_DEV_OCTEONTX2_CPT ); + +void otx2_cptlf_unregister_done_interrupts (struct otx2_cptlfs_info *lfs) +{ +int i, irq_offs, vector; + + irq_offs =OTX2_CPT_LF_INT_VEC_E_DONE ; +for (i =0 ; i < lfs->lfs_num; i++) { +if (!lfs->lf[i].is_irq_reg[irq_offs]) +continue ; + + vector =pci_irq_vector (lfs->pdev, + lfs->lf[i].msix_offset + irq_offs); +free_irq (vector, &lfs->lf[i]); + lfs->lf[i].is_irq_reg[irq_offs] = false; } -cptlf_disable_intrs (lfs); + +cptlf_set_done_intrs (lfs, false); } -EXPORT_SYMBOL_NS_GPL (otx2_cptlf_unregister_interrupts, +EXPORT_SYMBOL_NS_GPL (otx2_cptlf_unregister_done_interrupts,CRYPTO_DEV_OCTEONTX2_CPT ); static int cptlf_do_register_interrrupts(struct otx2_cptlfs_info *lfs,
@@ -296,34 +303,51 @@ static int cptlf_do_register_interrrupts(struct otx2_cptlfs_info *lfs,return ret; } -int otx2_cptlf_register_interrupts (struct otx2_cptlfs_info *lfs) +int otx2_cptlf_register_misc_interrupts (struct otx2_cptlfs_info *lfs) { +bool is_cpt1 = (lfs->blkaddr ==BLKADDR_CPT1 );int irq_offs, ret, i; + irq_offs =OTX2_CPT_LF_INT_VEC_E_MISC ;for (i =0 ; i < lfs->lfs_num; i++) { - irq_offs =OTX2_CPT_LF_INT_VEC_E_MISC ; -snprintf (lfs->lf[i].irq_name[irq_offs],32 ,"CPTLF Misc%d" , i); +snprintf (lfs->lf[i].irq_name[irq_offs],32 ,"CPT%dLF Misc%d" , + is_cpt1, i); ret =cptlf_do_register_interrrupts (lfs, i, irq_offs, cptlf_misc_intr_handler);if (ret) goto free_irq; + } +cptlf_set_misc_intrs (lfs, true); +return 0 ; - irq_offs =OTX2_CPT_LF_INT_VEC_E_DONE ; -snprintf (lfs->lf[i].irq_name[irq_offs],32 ,"OTX2_CPTLF Done%d" , - i); +free_irq: +otx2_cptlf_unregister_misc_interrupts (lfs); +return ret; +} +EXPORT_SYMBOL_NS_GPL (otx2_cptlf_register_misc_interrupts,CRYPTO_DEV_OCTEONTX2_CPT ); + +int otx2_cptlf_register_done_interrupts (struct otx2_cptlfs_info *lfs) +{ +bool is_cpt1 = (lfs->blkaddr ==BLKADDR_CPT1 ); +int irq_offs, ret, i; + + irq_offs =OTX2_CPT_LF_INT_VEC_E_DONE ; +for (i =0 ; i < lfs->lfs_num; i++) { +snprintf (lfs->lf[i].irq_name[irq_offs],32 , +"OTX2_CPT%dLF Done%d" , is_cpt1, i); ret =cptlf_do_register_interrrupts (lfs, i, irq_offs, cptlf_done_intr_handler);if (ret) goto free_irq; } -cptlf_enable_intrs (lfs); +cptlf_set_done_intrs (lfs, true);return 0 ; free_irq: -otx2_cptlf_unregister_interrupts (lfs); +otx2_cptlf_unregister_done_interrupts (lfs);return ret; } -EXPORT_SYMBOL_NS_GPL (otx2_cptlf_register_interrupts,CRYPTO_DEV_OCTEONTX2_CPT ); +EXPORT_SYMBOL_NS_GPL (otx2_cptlf_register_done_interrupts,CRYPTO_DEV_OCTEONTX2_CPT );void otx2_cptlf_free_irqs_affinity (struct otx2_cptlfs_info *lfs) {
drivers/crypto/marvell/octeontx2/otx2_cptlf.h +4 -2
@@ -409,8 +409,10 @@ static inline void otx2_cptlf_set_dev_info(struct otx2_cptlfs_info *lfs,int otx2_cptlf_init (struct otx2_cptlfs_info *lfs,u8 eng_grp_msk,int pri,int lfs_num);void otx2_cptlf_shutdown (struct otx2_cptlfs_info *lfs); -int otx2_cptlf_register_interrupts (struct otx2_cptlfs_info *lfs); -void otx2_cptlf_unregister_interrupts (struct otx2_cptlfs_info *lfs); +int otx2_cptlf_register_misc_interrupts (struct otx2_cptlfs_info *lfs); +int otx2_cptlf_register_done_interrupts (struct otx2_cptlfs_info *lfs); +void otx2_cptlf_unregister_misc_interrupts (struct otx2_cptlfs_info *lfs); +void otx2_cptlf_unregister_done_interrupts (struct otx2_cptlfs_info *lfs);void otx2_cptlf_free_irqs_affinity (struct otx2_cptlfs_info *lfs);int otx2_cptlf_set_irqs_affinity (struct otx2_cptlfs_info *lfs);
drivers/crypto/marvell/octeontx2/otx2_cptpf.h +4 -0
@@ -71,4 +71,8 @@ void otx2_cptpf_afpf_mbox_up_handler(struct work_struct *work);irqreturn_t otx2_cptpf_vfpf_mbox_intr (int irq,void *arg);void otx2_cptpf_vfpf_mbox_handler (struct work_struct *work); +int otx2_inline_cptlf_setup (struct otx2_cptpf_dev *cptpf, +struct otx2_cptlfs_info *lfs,u8 egrp,int num_lfs); +void otx2_inline_cptlf_cleanup (struct otx2_cptlfs_info *lfs); +#endif /* __OTX2_CPTPF_H */
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c +14 -3
@@ -725,7 +725,7 @@ static int otx2_cptpf_probe(struct pci_dev *pdev, {struct device *dev = &pdev->dev;struct otx2_cptpf_dev *cptpf; -int err; +int err, num_vec; cptpf =devm_kzalloc (dev,sizeof (*cptpf),GFP_KERNEL );if (!cptpf)
@@ -760,8 +760,11 @@ static int otx2_cptpf_probe(struct pci_dev *pdev,if (err) goto clear_drvdata; - err =pci_alloc_irq_vectors (pdev,RVU_PF_INT_VEC_CNT , -RVU_PF_INT_VEC_CNT ,PCI_IRQ_MSIX ); + num_vec =pci_msix_vec_count (cptpf->pdev); +if (num_vec <=0 ) + goto clear_drvdata; + + err =pci_alloc_irq_vectors (pdev, num_vec, num_vec,PCI_IRQ_MSIX );if (err <0 ) {dev_err (dev,"Request for %d msix vectors failed\n" ,RVU_PF_INT_VEC_CNT );
@@ -825,6 +828,14 @@ static void otx2_cptpf_remove(struct pci_dev *pdev)cptpf_sriov_disable (pdev);otx2_cpt_unregister_dl (cptpf); + +/* Cleanup Inline CPT LF's if attached */ +if (cptpf->lfs.lfs_num) +otx2_inline_cptlf_cleanup (&cptpf->lfs); + +if (cptpf->cpt1_lfs.lfs_num) +otx2_inline_cptlf_cleanup (&cptpf->cpt1_lfs); +/* Delete sysfs entry created for kernel VF limits */ sysfs_remove_group (&pdev->dev.kobj, &cptpf_sysfs_group);/* Cleanup engine groups */
drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c +57 -10
106 lines not on this page · raw message
drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c +9 -3
@@ -246,7 +246,8 @@ static void cptvf_lf_shutdown(struct otx2_cptlfs_info *lfs)/* Unregister crypto algorithms */ otx2_cpt_crypto_exit (lfs->pdev,THIS_MODULE );/* Unregister LFs interrupts */ -otx2_cptlf_unregister_interrupts (lfs); +otx2_cptlf_unregister_misc_interrupts (lfs); +otx2_cptlf_unregister_done_interrupts (lfs);/* Cleanup LFs software side */ lf_sw_cleanup (lfs);/* Send request to detach LFs */
@@ -298,7 +299,11 @@ static int cptvf_lf_init(struct otx2_cptvf_dev *cptvf) goto cleanup_lf;/* Register LFs interrupts */ - ret =otx2_cptlf_register_interrupts (lfs); + ret =otx2_cptlf_register_misc_interrupts (lfs); +if (ret) + goto cleanup_lf_sw; + + ret =otx2_cptlf_register_done_interrupts (lfs);if (ret) goto cleanup_lf_sw;
@@ -319,7 +324,8 @@ static int cptvf_lf_init(struct otx2_cptvf_dev *cptvf) disable_irqs:otx2_cptlf_free_irqs_affinity (lfs); unregister_intr: -otx2_cptlf_unregister_interrupts (lfs); +otx2_cptlf_unregister_misc_interrupts (lfs); +otx2_cptlf_unregister_done_interrupts (lfs); cleanup_lf_sw:lf_sw_cleanup (lfs); cleanup_lf:
Signature · 1 line
2.25.1
Srujana Challa
maintainerPATCH 10/10 crypto: octeontx2: support setting ctx ilen for inline CPT LF
In reply to Srujana ChallaFrom: Nithin Dabilpuram <[email protected]>
Provide an option in Inline IPsec configure mailbox to configure the CPT_AF_LFX_CTL:CTX_ILEN for inline CPT LF attached to CPT RVU PF. This is needed to set the ctx ilen to size of inbound SA for HW errata IPBUCPT-38756. Not setting this would lead to new context's not being fetched.
Also set FLR_FLUSH in CPT_LF_CTX_CTL for CPT LF's as workaround for same errata.
--- .../marvell/octeontx2/otx2_cpt_common.h | 2 ++ .../marvell/octeontx2/otx2_cpt_hw_types.h | 4 ++- drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 33 +++++++++++++++++++ drivers/crypto/marvell/octeontx2/otx2_cptlf.h | 17 ++++++++++ .../marvell/octeontx2/otx2_cptpf_mbox.c | 5 +++ 5 files changed, 60 insertions(+), 1 deletion(-)
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h +2 -0
@@ -59,6 +59,8 @@ struct otx2_cpt_rx_inline_lf_cfg {u32 credit_th;u16 bpid;u32 reserved; + u8 ctx_ilen_valid : 1; + u8 ctx_ilen : 7; };/*
drivers/crypto/marvell/octeontx2/otx2_cpt_hw_types.h +3 -1
@@ -102,6 +102,7 @@#define OTX2_CPT_LF_Q_INST_PTR (0x110)#define OTX2_CPT_LF_Q_GRP_PTR (0x120)#define OTX2_CPT_LF_NQX (a) (0x400 | (a) << 3) +#define OTX2_CPT_LF_CTX_CTL (0x500)#define OTX2_CPT_LF_CTX_FLUSH (0x510)#define OTX2_CPT_LF_CTX_ERR (0x520)#define OTX2_CPT_RVU_FUNC_BLKADDR_SHIFT 20
@@ -472,7 +473,8 @@ union otx2_cptx_af_lf_ctrl { u64 cont_err:1; u64 reserved_11_15:5; u64 nixtx_en:1; - u64 reserved_17_47:31; + u64 ctx_ilen:3; + u64 reserved_17_47:28; u64 grp:8; u64 reserved_56_63:8; } s;
drivers/crypto/marvell/octeontx2/otx2_cptlf.c +33 -0
@@ -106,6 +106,33 @@ static int cptlf_set_grp_and_pri(struct otx2_cptlfs_info *lfs,return ret; } +static int cptlf_set_ctx_ilen (struct otx2_cptlfs_info *lfs,int ctx_ilen) +{ +union otx2_cptx_af_lf_ctrl lf_ctrl; +struct otx2_cptlf_info *lf; +int slot, ret =0 ; + +for (slot =0 ; slot < lfs->lfs_num; slot++) { + lf = &lfs->lf[slot]; + + ret =otx2_cpt_read_af_reg (lfs->mbox, lfs->pdev, +CPT_AF_LFX_CTL (lf->slot), + &lf_ctrl.u, lfs->blkaddr); +if (ret) +return ret; + + lf_ctrl.s.ctx_ilen = ctx_ilen; + + ret =otx2_cpt_write_af_reg (lfs->mbox, lfs->pdev, +CPT_AF_LFX_CTL (lf->slot), + lf_ctrl.u, lfs->blkaddr); +if (ret) +return ret; + + } +return ret; +} +static void cptlf_hw_init (struct otx2_cptlfs_info *lfs) {/* Disable instruction queues */
@@ -440,6 +467,12 @@ int otx2_cptlf_init(struct otx2_cptlfs_info *lfs, u8 eng_grp_mask, int pri,if (ret) goto free_iq; +if (lfs->ctx_ilen_ovrd) { + ret =cptlf_set_ctx_ilen (lfs, lfs->ctx_ilen); +if (ret) + goto free_iq; + } +return 0 ; free_iq:
drivers/crypto/marvell/octeontx2/otx2_cptlf.h +17 -0
@@ -120,6 +120,8 @@ struct otx2_cptlfs_info {atomic_t state;/* LF's state. started/reset */ int blkaddr;/* CPT blkaddr: BLKADDR_CPT0/BLKADDR_CPT1 */ int global_slot;/* Global slot across the blocks */ +u8 ctx_ilen; +u8 ctx_ilen_ovrd; }; static inline void otx2_cpt_free_instruction_queues(
@@ -309,6 +311,17 @@ static inline void otx2_cptlf_set_iqueue_exec(struct otx2_cptlf_info *lf, OTX2_CPT_LF_INPROG, lf_inprog.u); } +static inline void otx2_cptlf_set_ctx_flr_flush (struct otx2_cptlf_info *lf) +{ +u8 blkaddr = lf->lfs->blkaddr; +u64 val; + + val =otx2_cpt_read64 (lf->lfs->reg_base, blkaddr, lf->slot,OTX2_CPT_LF_CTX_CTL ); + val |=BIT_ULL (0 ); + +otx2_cpt_write64 (lf->lfs->reg_base, blkaddr, lf->slot,OTX2_CPT_LF_CTX_CTL , val); +} +static inline void otx2_cptlf_enable_iqueue_exec (struct otx2_cptlf_info *lf) {otx2_cptlf_set_iqueue_exec (lf, true);
@@ -324,6 +337,10 @@ static inline void otx2_cptlf_enable_iqueues(struct otx2_cptlfs_info *lfs)int slot;for (slot =0 ; slot < lfs->lfs_num; slot++) { +/* Enable flush on FLR for Errata */ +if (is_dev_cn10kb (lfs->pdev)) +otx2_cptlf_set_ctx_flr_flush (&lfs->lf[slot]); +otx2_cptlf_enable_iqueue_exec (&lfs->lf[slot]);otx2_cptlf_enable_iqueue_enq (&lfs->lf[slot]); }
drivers/crypto/marvell/octeontx2/otx2_cptpf_mbox.c +5 -0
@@ -267,6 +267,9 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf,otx2_cptlf_set_dev_info (&cptpf->lfs, cptpf->pdev, cptpf->reg_base, &cptpf->afpf_mbox,BLKADDR_CPT0 ); cptpf->lfs.global_slot =0 ; + cptpf->lfs.ctx_ilen_ovrd = cfg_req->ctx_ilen_valid; + cptpf->lfs.ctx_ilen = cfg_req->ctx_ilen; + ret =otx2_inline_cptlf_setup (cptpf, &cptpf->lfs, egrp, num_lfs);if (ret) {dev_err (&cptpf->pdev->dev,"Inline CPT0 LF setup failed.\n" );
@@ -279,6 +282,8 @@ static int handle_msg_rx_inline_ipsec_lf_cfg(struct otx2_cptpf_dev *cptpf, cptpf->reg_base, &cptpf->afpf_mbox, BLKADDR_CPT1); cptpf->cpt1_lfs.global_slot = num_lfs; + cptpf->cpt1_lfs.ctx_ilen_ovrd = cfg_req->ctx_ilen_valid; + cptpf->cpt1_lfs.ctx_ilen = cfg_req->ctx_ilen; ret =otx2_inline_cptlf_setup (cptpf, &cptpf->cpt1_lfs, egrp, num_lfs);if (ret) {dev_err (&cptpf->pdev->dev,"Inline CPT1 LF setup failed.\n" );
Signature · 1 line
2.25.1