1
2
3
4
5
6
7
8
9
10
11#ifndef __OTX_CPTPF_UCODE_H
12#define __OTX_CPTPF_UCODE_H
13
14#include <linux/pci.h>
15#include <linux/types.h>
16#include <linux/module.h>
17#include "otx_cpt_hw_types.h"
18
19
20#define OTX_CPT_UCODE_NAME_LENGTH 64
21
22
23
24
25#define OTX_CPT_MAX_ETYPES_PER_GRP 1
26
27
28#define OTX_CPT_UCODE_TAR_FILE_NAME "cpt8x-mc.tar"
29
30
31#define OTX_CPT_UCODE_ALIGNMENT 128
32
33
34#define OTX_CPT_UCODE_SIGN_LEN 256
35
36
37#define OTX_CPT_UCODE_VER_STR_SZ 44
38
39
40#define OTX_CPT_MAX_ENGINES 64
41
42#define OTX_CPT_ENGS_BITMASK_LEN (OTX_CPT_MAX_ENGINES/(BITS_PER_BYTE * \
43 sizeof(unsigned long)))
44
45
46enum otx_cpt_ucode_type {
47 OTX_CPT_AE_UC_TYPE = 1,
48 OTX_CPT_SE_UC_TYPE1 = 20,
49 OTX_CPT_SE_UC_TYPE2 = 21,
50 OTX_CPT_SE_UC_TYPE3 = 22,
51
52
53
54};
55
56struct otx_cpt_bitmap {
57 unsigned long bits[OTX_CPT_ENGS_BITMASK_LEN];
58 int size;
59};
60
61struct otx_cpt_engines {
62 int type;
63 int count;
64};
65
66
67struct otx_cpt_ucode_ver_num {
68 u8 nn;
69 u8 xx;
70 u8 yy;
71 u8 zz;
72};
73
74struct otx_cpt_ucode_hdr {
75 struct otx_cpt_ucode_ver_num ver_num;
76 u8 ver_str[OTX_CPT_UCODE_VER_STR_SZ];
77 __be32 code_length;
78 u32 padding[3];
79};
80
81struct otx_cpt_ucode {
82 u8 ver_str[OTX_CPT_UCODE_VER_STR_SZ];
83
84
85 struct otx_cpt_ucode_ver_num ver_num;
86 char filename[OTX_CPT_UCODE_NAME_LENGTH];
87 dma_addr_t dma;
88 dma_addr_t align_dma;
89 void *va;
90 void *align_va;
91 u32 size;
92 int type;
93};
94
95struct tar_ucode_info_t {
96 struct list_head list;
97 struct otx_cpt_ucode ucode;
98 const u8 *ucode_ptr;
99};
100
101
102struct otx_cpt_engs_available {
103 int max_se_cnt;
104 int max_ae_cnt;
105 int se_cnt;
106 int ae_cnt;
107};
108
109
110struct otx_cpt_engs_rsvd {
111 int type;
112 int count;
113 int offset;
114 unsigned long *bmap;
115 struct otx_cpt_ucode *ucode;
116};
117
118struct otx_cpt_mirror_info {
119 int is_ena;
120
121
122
123 int idx;
124
125
126
127
128 int ref_count;
129
130
131
132
133};
134
135struct otx_cpt_eng_grp_info {
136 struct otx_cpt_eng_grps *g;
137 struct device_attribute info_attr;
138
139 struct otx_cpt_engs_rsvd engs[OTX_CPT_MAX_ETYPES_PER_GRP];
140
141 struct otx_cpt_ucode ucode[OTX_CPT_MAX_ETYPES_PER_GRP];
142
143 char sysfs_info_name[OTX_CPT_UCODE_NAME_LENGTH];
144
145 struct otx_cpt_mirror_info mirror;
146 int idx;
147 bool is_enabled;
148
149
150
151};
152
153struct otx_cpt_eng_grps {
154 struct otx_cpt_eng_grp_info grp[OTX_CPT_MAX_ENGINE_GROUPS];
155 struct device_attribute ucode_load_attr;
156 struct otx_cpt_engs_available avail;
157 struct mutex lock;
158 void *obj;
159 int engs_num;
160 int eng_types_supported;
161 u8 eng_ref_cnt[OTX_CPT_MAX_ENGINES];
162 bool is_ucode_load_created;
163 bool is_first_try;
164 bool is_rdonly;
165};
166
167int otx_cpt_init_eng_grps(struct pci_dev *pdev,
168 struct otx_cpt_eng_grps *eng_grps, int pf_type);
169void otx_cpt_cleanup_eng_grps(struct pci_dev *pdev,
170 struct otx_cpt_eng_grps *eng_grps);
171int otx_cpt_try_create_default_eng_grps(struct pci_dev *pdev,
172 struct otx_cpt_eng_grps *eng_grps,
173 int pf_type);
174void otx_cpt_set_eng_grps_is_rdonly(struct otx_cpt_eng_grps *eng_grps,
175 bool is_rdonly);
176int otx_cpt_uc_supports_eng_type(struct otx_cpt_ucode *ucode, int eng_type);
177int otx_cpt_eng_grp_has_eng_type(struct otx_cpt_eng_grp_info *eng_grp,
178 int eng_type);
179
180#endif
181