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 - parameters for custom engine groups

Added devlink parameters to create and delete custom CPT engine groups.

Example:
devlink dev param set pci/0002:20:00.0 name egrp_create value \
"se:32;se.out" cmode runtime
devlink dev param set pci/0002:20:00.0 name egrp_delete value \
"egrp:1" cmode runtime

Signed-off-by: Srujana Challa <schalla@marvell.com>
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Srujana Challa and committed by
Herbert Xu
fed8f4d5 d9d77497

+142 -1
+1 -1
drivers/crypto/marvell/octeontx2/Makefile
··· 3 3 4 4 rvu_cptpf-objs := otx2_cptpf_main.o otx2_cptpf_mbox.o \ 5 5 otx2_cpt_mbox_common.o otx2_cptpf_ucode.o otx2_cptlf.o \ 6 - cn10k_cpt.o 6 + cn10k_cpt.o otx2_cpt_devlink.o 7 7 rvu_cptvf-objs := otx2_cptvf_main.o otx2_cptvf_mbox.o otx2_cptlf.o \ 8 8 otx2_cpt_mbox_common.o otx2_cptvf_reqmgr.o \ 9 9 otx2_cptvf_algs.o cn10k_cpt.o
+1
drivers/crypto/marvell/octeontx2/otx2_cpt_common.h
··· 10 10 #include <linux/module.h> 11 11 #include <linux/delay.h> 12 12 #include <linux/crypto.h> 13 + #include <net/devlink.h> 13 14 #include "otx2_cpt_hw_types.h" 14 15 #include "rvu.h" 15 16 #include "mbox.h"
+108
drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* Copyright (C) 2021 Marvell. */ 3 + 4 + #include "otx2_cpt_devlink.h" 5 + 6 + static int otx2_cpt_dl_egrp_create(struct devlink *dl, u32 id, 7 + struct devlink_param_gset_ctx *ctx) 8 + { 9 + struct otx2_cpt_devlink *cpt_dl = devlink_priv(dl); 10 + struct otx2_cptpf_dev *cptpf = cpt_dl->cptpf; 11 + 12 + return otx2_cpt_dl_custom_egrp_create(cptpf, ctx); 13 + } 14 + 15 + static int otx2_cpt_dl_egrp_delete(struct devlink *dl, u32 id, 16 + struct devlink_param_gset_ctx *ctx) 17 + { 18 + struct otx2_cpt_devlink *cpt_dl = devlink_priv(dl); 19 + struct otx2_cptpf_dev *cptpf = cpt_dl->cptpf; 20 + 21 + return otx2_cpt_dl_custom_egrp_delete(cptpf, ctx); 22 + } 23 + 24 + static int otx2_cpt_dl_uc_info(struct devlink *dl, u32 id, 25 + struct devlink_param_gset_ctx *ctx) 26 + { 27 + struct otx2_cpt_devlink *cpt_dl = devlink_priv(dl); 28 + struct otx2_cptpf_dev *cptpf = cpt_dl->cptpf; 29 + 30 + otx2_cpt_print_uc_dbg_info(cptpf); 31 + 32 + return 0; 33 + } 34 + 35 + enum otx2_cpt_dl_param_id { 36 + OTX2_CPT_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, 37 + OTX2_CPT_DEVLINK_PARAM_ID_EGRP_CREATE, 38 + OTX2_CPT_DEVLINK_PARAM_ID_EGRP_DELETE, 39 + }; 40 + 41 + static const struct devlink_param otx2_cpt_dl_params[] = { 42 + DEVLINK_PARAM_DRIVER(OTX2_CPT_DEVLINK_PARAM_ID_EGRP_CREATE, 43 + "egrp_create", DEVLINK_PARAM_TYPE_STRING, 44 + BIT(DEVLINK_PARAM_CMODE_RUNTIME), 45 + otx2_cpt_dl_uc_info, otx2_cpt_dl_egrp_create, 46 + NULL), 47 + DEVLINK_PARAM_DRIVER(OTX2_CPT_DEVLINK_PARAM_ID_EGRP_DELETE, 48 + "egrp_delete", DEVLINK_PARAM_TYPE_STRING, 49 + BIT(DEVLINK_PARAM_CMODE_RUNTIME), 50 + otx2_cpt_dl_uc_info, otx2_cpt_dl_egrp_delete, 51 + NULL), 52 + }; 53 + 54 + static int otx2_cpt_devlink_info_get(struct devlink *devlink, 55 + struct devlink_info_req *req, 56 + struct netlink_ext_ack *extack) 57 + { 58 + return devlink_info_driver_name_put(req, "rvu_cptpf"); 59 + } 60 + 61 + static const struct devlink_ops otx2_cpt_devlink_ops = { 62 + .info_get = otx2_cpt_devlink_info_get, 63 + }; 64 + 65 + int otx2_cpt_register_dl(struct otx2_cptpf_dev *cptpf) 66 + { 67 + struct device *dev = &cptpf->pdev->dev; 68 + struct otx2_cpt_devlink *cpt_dl; 69 + struct devlink *dl; 70 + int ret; 71 + 72 + dl = devlink_alloc(&otx2_cpt_devlink_ops, 73 + sizeof(struct otx2_cpt_devlink), dev); 74 + if (!dl) { 75 + dev_warn(dev, "devlink_alloc failed\n"); 76 + return -ENOMEM; 77 + } 78 + 79 + cpt_dl = devlink_priv(dl); 80 + cpt_dl->dl = dl; 81 + cpt_dl->cptpf = cptpf; 82 + cptpf->dl = dl; 83 + ret = devlink_params_register(dl, otx2_cpt_dl_params, 84 + ARRAY_SIZE(otx2_cpt_dl_params)); 85 + if (ret) { 86 + dev_err(dev, "devlink params register failed with error %d", 87 + ret); 88 + devlink_free(dl); 89 + return ret; 90 + } 91 + 92 + devlink_register(dl); 93 + 94 + return 0; 95 + } 96 + 97 + void otx2_cpt_unregister_dl(struct otx2_cptpf_dev *cptpf) 98 + { 99 + struct devlink *dl = cptpf->dl; 100 + 101 + if (!dl) 102 + return; 103 + 104 + devlink_unregister(dl); 105 + devlink_params_unregister(dl, otx2_cpt_dl_params, 106 + ARRAY_SIZE(otx2_cpt_dl_params)); 107 + devlink_free(dl); 108 + }
+20
drivers/crypto/marvell/octeontx2/otx2_cpt_devlink.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only 2 + * Copyright (C) 2021 Marvell. 3 + */ 4 + 5 + #ifndef __OTX2_CPT_DEVLINK_H 6 + #define __OTX2_CPT_DEVLINK_H 7 + 8 + #include "otx2_cpt_common.h" 9 + #include "otx2_cptpf.h" 10 + 11 + struct otx2_cpt_devlink { 12 + struct devlink *dl; 13 + struct otx2_cptpf_dev *cptpf; 14 + }; 15 + 16 + /* Devlink APIs */ 17 + int otx2_cpt_register_dl(struct otx2_cptpf_dev *cptpf); 18 + void otx2_cpt_unregister_dl(struct otx2_cptpf_dev *cptpf); 19 + 20 + #endif /* __OTX2_CPT_DEVLINK_H */
+3
drivers/crypto/marvell/octeontx2/otx2_cptpf.h
··· 53 53 u8 enabled_vfs; /* Number of enabled VFs */ 54 54 u8 kvf_limits; /* Kernel crypto limits */ 55 55 bool has_cpt1; 56 + 57 + /* Devlink */ 58 + struct devlink *dl; 56 59 }; 57 60 58 61 irqreturn_t otx2_cptpf_afpf_mbox_intr(int irq, void *arg);
+9
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c
··· 4 4 #include <linux/firmware.h> 5 5 #include "otx2_cpt_hw_types.h" 6 6 #include "otx2_cpt_common.h" 7 + #include "otx2_cpt_devlink.h" 7 8 #include "otx2_cptpf_ucode.h" 8 9 #include "otx2_cptpf.h" 9 10 #include "cn10k_cpt.h" ··· 767 766 err = sysfs_create_group(&dev->kobj, &cptpf_sysfs_group); 768 767 if (err) 769 768 goto cleanup_eng_grps; 769 + 770 + err = otx2_cpt_register_dl(cptpf); 771 + if (err) 772 + goto sysfs_grp_del; 773 + 770 774 return 0; 771 775 776 + sysfs_grp_del: 777 + sysfs_remove_group(&dev->kobj, &cptpf_sysfs_group); 772 778 cleanup_eng_grps: 773 779 otx2_cpt_cleanup_eng_grps(pdev, &cptpf->eng_grps); 774 780 unregister_intr: ··· 795 787 return; 796 788 797 789 cptpf_sriov_disable(pdev); 790 + otx2_cpt_unregister_dl(cptpf); 798 791 /* Delete sysfs entry created for kernel VF limits */ 799 792 sysfs_remove_group(&pdev->dev.kobj, &cptpf_sysfs_group); 800 793 /* Cleanup engine groups */