0001
0002
0003
0004
0005 #ifndef __OTX2_CPTPF_UCODE_H
0006 #define __OTX2_CPTPF_UCODE_H
0007
0008 #include <linux/pci.h>
0009 #include <linux/types.h>
0010 #include <linux/module.h>
0011 #include "otx2_cpt_hw_types.h"
0012 #include "otx2_cpt_common.h"
0013
0014
0015
0016
0017
0018 #define OTX2_CPT_MAX_ETYPES_PER_GRP 2
0019
0020
0021 #define OTX2_CPT_UCODE_SIGN_LEN 256
0022
0023
0024 #define OTX2_CPT_UCODE_VER_STR_SZ 44
0025
0026
0027 #define OTX2_CPT_MAX_ENGINES 144
0028
0029 #define OTX2_CPT_ENGS_BITMASK_LEN BITS_TO_LONGS(OTX2_CPT_MAX_ENGINES)
0030
0031 #define OTX2_CPT_UCODE_SZ (64 * 1024)
0032
0033
0034 enum otx2_cpt_ucode_type {
0035 OTX2_CPT_AE_UC_TYPE = 1,
0036 OTX2_CPT_SE_UC_TYPE1 = 20,
0037 OTX2_CPT_SE_UC_TYPE2 = 21,
0038 OTX2_CPT_SE_UC_TYPE3 = 22,
0039
0040
0041
0042 OTX2_CPT_IE_UC_TYPE1 = 30,
0043 OTX2_CPT_IE_UC_TYPE2 = 31,
0044 OTX2_CPT_IE_UC_TYPE3 = 32,
0045
0046
0047
0048 };
0049
0050 struct otx2_cpt_bitmap {
0051 unsigned long bits[OTX2_CPT_ENGS_BITMASK_LEN];
0052 int size;
0053 };
0054
0055 struct otx2_cpt_engines {
0056 int type;
0057 int count;
0058 };
0059
0060
0061 struct otx2_cpt_ucode_ver_num {
0062 u8 nn;
0063 u8 xx;
0064 u8 yy;
0065 u8 zz;
0066 };
0067
0068 struct otx2_cpt_ucode_hdr {
0069 struct otx2_cpt_ucode_ver_num ver_num;
0070 u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ];
0071 __be32 code_length;
0072 u32 padding[3];
0073 };
0074
0075 struct otx2_cpt_ucode {
0076 u8 ver_str[OTX2_CPT_UCODE_VER_STR_SZ];
0077
0078
0079
0080 struct otx2_cpt_ucode_ver_num ver_num;
0081 char filename[OTX2_CPT_NAME_LENGTH];
0082 dma_addr_t dma;
0083 void *va;
0084 u32 size;
0085 int type;
0086 };
0087
0088 struct otx2_cpt_uc_info_t {
0089 struct list_head list;
0090 struct otx2_cpt_ucode ucode;
0091 const struct firmware *fw;
0092 };
0093
0094
0095 struct otx2_cpt_engs_available {
0096 int max_se_cnt;
0097 int max_ie_cnt;
0098 int max_ae_cnt;
0099 int se_cnt;
0100 int ie_cnt;
0101 int ae_cnt;
0102 };
0103
0104
0105 struct otx2_cpt_engs_rsvd {
0106 int type;
0107 int count;
0108 int offset;
0109 unsigned long *bmap;
0110 struct otx2_cpt_ucode *ucode;
0111 };
0112
0113 struct otx2_cpt_mirror_info {
0114 int is_ena;
0115
0116
0117
0118 int idx;
0119
0120
0121
0122
0123 int ref_count;
0124
0125
0126
0127
0128 };
0129
0130 struct otx2_cpt_eng_grp_info {
0131 struct otx2_cpt_eng_grps *g;
0132
0133 struct otx2_cpt_engs_rsvd engs[OTX2_CPT_MAX_ETYPES_PER_GRP];
0134
0135 struct otx2_cpt_ucode ucode[OTX2_CPT_MAX_ETYPES_PER_GRP];
0136
0137 struct otx2_cpt_mirror_info mirror;
0138 int idx;
0139 bool is_enabled;
0140
0141
0142
0143 };
0144
0145 struct otx2_cpt_eng_grps {
0146 struct mutex lock;
0147 struct otx2_cpt_eng_grp_info grp[OTX2_CPT_MAX_ENGINE_GROUPS];
0148 struct otx2_cpt_engs_available avail;
0149 void *obj;
0150 int engs_num;
0151 u8 eng_ref_cnt[OTX2_CPT_MAX_ENGINES];
0152 bool is_grps_created;
0153 };
0154 struct otx2_cptpf_dev;
0155 int otx2_cpt_init_eng_grps(struct pci_dev *pdev,
0156 struct otx2_cpt_eng_grps *eng_grps);
0157 void otx2_cpt_cleanup_eng_grps(struct pci_dev *pdev,
0158 struct otx2_cpt_eng_grps *eng_grps);
0159 int otx2_cpt_create_eng_grps(struct otx2_cptpf_dev *cptpf,
0160 struct otx2_cpt_eng_grps *eng_grps);
0161 int otx2_cpt_disable_all_cores(struct otx2_cptpf_dev *cptpf);
0162 int otx2_cpt_get_eng_grp(struct otx2_cpt_eng_grps *eng_grps, int eng_type);
0163 int otx2_cpt_discover_eng_capabilities(struct otx2_cptpf_dev *cptpf);
0164 int otx2_cpt_dl_custom_egrp_create(struct otx2_cptpf_dev *cptpf,
0165 struct devlink_param_gset_ctx *ctx);
0166 int otx2_cpt_dl_custom_egrp_delete(struct otx2_cptpf_dev *cptpf,
0167 struct devlink_param_gset_ctx *ctx);
0168 void otx2_cpt_print_uc_dbg_info(struct otx2_cptpf_dev *cptpf);
0169 struct otx2_cpt_engs_rsvd *find_engines_by_type(
0170 struct otx2_cpt_eng_grp_info *eng_grp,
0171 int eng_type);
0172 #endif