0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef __OTX_CPTPF_UCODE_H
0012 #define __OTX_CPTPF_UCODE_H
0013
0014 #include <linux/pci.h>
0015 #include <linux/types.h>
0016 #include <linux/module.h>
0017 #include "otx_cpt_hw_types.h"
0018
0019
0020 #define OTX_CPT_UCODE_NAME_LENGTH 64
0021
0022
0023
0024
0025 #define OTX_CPT_MAX_ETYPES_PER_GRP 1
0026
0027
0028 #define OTX_CPT_UCODE_TAR_FILE_NAME "cpt8x-mc.tar"
0029
0030
0031 #define OTX_CPT_UCODE_ALIGNMENT 128
0032
0033
0034 #define OTX_CPT_UCODE_SIGN_LEN 256
0035
0036
0037 #define OTX_CPT_UCODE_VER_STR_SZ 44
0038
0039
0040 #define OTX_CPT_MAX_ENGINES 64
0041
0042 #define OTX_CPT_ENGS_BITMASK_LEN (OTX_CPT_MAX_ENGINES/(BITS_PER_BYTE * \
0043 sizeof(unsigned long)))
0044
0045
0046 enum otx_cpt_ucode_type {
0047 OTX_CPT_AE_UC_TYPE = 1,
0048 OTX_CPT_SE_UC_TYPE1 = 20,
0049 OTX_CPT_SE_UC_TYPE2 = 21,
0050 OTX_CPT_SE_UC_TYPE3 = 22,
0051
0052
0053
0054 };
0055
0056 struct otx_cpt_bitmap {
0057 unsigned long bits[OTX_CPT_ENGS_BITMASK_LEN];
0058 int size;
0059 };
0060
0061 struct otx_cpt_engines {
0062 int type;
0063 int count;
0064 };
0065
0066
0067 struct otx_cpt_ucode_ver_num {
0068 u8 nn;
0069 u8 xx;
0070 u8 yy;
0071 u8 zz;
0072 };
0073
0074 struct otx_cpt_ucode_hdr {
0075 struct otx_cpt_ucode_ver_num ver_num;
0076 u8 ver_str[OTX_CPT_UCODE_VER_STR_SZ];
0077 __be32 code_length;
0078 u32 padding[3];
0079 };
0080
0081 struct otx_cpt_ucode {
0082 u8 ver_str[OTX_CPT_UCODE_VER_STR_SZ];
0083
0084
0085 struct otx_cpt_ucode_ver_num ver_num;
0086 char filename[OTX_CPT_UCODE_NAME_LENGTH];
0087 dma_addr_t dma;
0088 dma_addr_t align_dma;
0089 void *va;
0090 void *align_va;
0091 u32 size;
0092 int type;
0093 };
0094
0095 struct tar_ucode_info_t {
0096 struct list_head list;
0097 struct otx_cpt_ucode ucode;
0098 const u8 *ucode_ptr;
0099 };
0100
0101
0102 struct otx_cpt_engs_available {
0103 int max_se_cnt;
0104 int max_ae_cnt;
0105 int se_cnt;
0106 int ae_cnt;
0107 };
0108
0109
0110 struct otx_cpt_engs_rsvd {
0111 int type;
0112 int count;
0113 int offset;
0114 unsigned long *bmap;
0115 struct otx_cpt_ucode *ucode;
0116 };
0117
0118 struct otx_cpt_mirror_info {
0119 int is_ena;
0120
0121
0122
0123 int idx;
0124
0125
0126
0127
0128 int ref_count;
0129
0130
0131
0132
0133 };
0134
0135 struct otx_cpt_eng_grp_info {
0136 struct otx_cpt_eng_grps *g;
0137 struct device_attribute info_attr;
0138
0139 struct otx_cpt_engs_rsvd engs[OTX_CPT_MAX_ETYPES_PER_GRP];
0140
0141 struct otx_cpt_ucode ucode[OTX_CPT_MAX_ETYPES_PER_GRP];
0142
0143 char sysfs_info_name[OTX_CPT_UCODE_NAME_LENGTH];
0144
0145 struct otx_cpt_mirror_info mirror;
0146 int idx;
0147 bool is_enabled;
0148
0149
0150
0151 };
0152
0153 struct otx_cpt_eng_grps {
0154 struct otx_cpt_eng_grp_info grp[OTX_CPT_MAX_ENGINE_GROUPS];
0155 struct device_attribute ucode_load_attr;
0156 struct otx_cpt_engs_available avail;
0157 struct mutex lock;
0158 void *obj;
0159 int engs_num;
0160 int eng_types_supported;
0161 u8 eng_ref_cnt[OTX_CPT_MAX_ENGINES];
0162 bool is_ucode_load_created;
0163 bool is_first_try;
0164 bool is_rdonly;
0165 };
0166
0167 int otx_cpt_init_eng_grps(struct pci_dev *pdev,
0168 struct otx_cpt_eng_grps *eng_grps, int pf_type);
0169 void otx_cpt_cleanup_eng_grps(struct pci_dev *pdev,
0170 struct otx_cpt_eng_grps *eng_grps);
0171 int otx_cpt_try_create_default_eng_grps(struct pci_dev *pdev,
0172 struct otx_cpt_eng_grps *eng_grps,
0173 int pf_type);
0174 void otx_cpt_set_eng_grps_is_rdonly(struct otx_cpt_eng_grps *eng_grps,
0175 bool is_rdonly);
0176 int otx_cpt_uc_supports_eng_type(struct otx_cpt_ucode *ucode, int eng_type);
0177 int otx_cpt_eng_grp_has_eng_type(struct otx_cpt_eng_grp_info *eng_grp,
0178 int eng_type);
0179
0180 #endif