1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */
2 /* Copyright(c) 2014 - 2020 Intel Corporation */
3 #ifndef __ICP_QAT_UCLO_H__
4 #define __ICP_QAT_UCLO_H__
6 #define ICP_QAT_AC_895XCC_DEV_TYPE 0x00400000
7 #define ICP_QAT_AC_C62X_DEV_TYPE 0x01000000
8 #define ICP_QAT_AC_C3XXX_DEV_TYPE 0x02000000
9 #define ICP_QAT_UCLO_MAX_AE 12
10 #define ICP_QAT_UCLO_MAX_CTX 8
11 #define ICP_QAT_UCLO_MAX_UIMAGE (ICP_QAT_UCLO_MAX_AE * ICP_QAT_UCLO_MAX_CTX)
12 #define ICP_QAT_UCLO_MAX_USTORE 0x4000
13 #define ICP_QAT_UCLO_MAX_XFER_REG 128
14 #define ICP_QAT_UCLO_MAX_GPR_REG 128
15 #define ICP_QAT_UCLO_MAX_LMEM_REG 1024
16 #define ICP_QAT_UCLO_AE_ALL_CTX 0xff
17 #define ICP_QAT_UOF_OBJID_LEN 8
18 #define ICP_QAT_UOF_FID 0xc6c2
19 #define ICP_QAT_UOF_MAJVER 0x4
20 #define ICP_QAT_UOF_MINVER 0x11
21 #define ICP_QAT_UOF_OBJS "UOF_OBJS"
22 #define ICP_QAT_UOF_STRT "UOF_STRT"
23 #define ICP_QAT_UOF_IMAG "UOF_IMAG"
24 #define ICP_QAT_UOF_IMEM "UOF_IMEM"
25 #define ICP_QAT_UOF_LOCAL_SCOPE 1
26 #define ICP_QAT_UOF_INIT_EXPR 0
27 #define ICP_QAT_UOF_INIT_REG 1
28 #define ICP_QAT_UOF_INIT_REG_CTX 2
29 #define ICP_QAT_UOF_INIT_EXPR_ENDIAN_SWAP 3
30 #define ICP_QAT_SUOF_OBJ_ID_LEN 8
31 #define ICP_QAT_SUOF_FID 0x53554f46
32 #define ICP_QAT_SUOF_MAJVER 0x0
33 #define ICP_QAT_SUOF_MINVER 0x1
34 #define ICP_QAT_SIMG_AE_INIT_SEQ_LEN (50 * sizeof(unsigned long long))
35 #define ICP_QAT_SIMG_AE_INSTS_LEN (0x4000 * sizeof(unsigned long long))
36 #define ICP_QAT_CSS_FWSK_MODULUS_LEN 256
37 #define ICP_QAT_CSS_FWSK_EXPONENT_LEN 4
38 #define ICP_QAT_CSS_FWSK_PAD_LEN 252
39 #define ICP_QAT_CSS_FWSK_PUB_LEN (ICP_QAT_CSS_FWSK_MODULUS_LEN + \
40 ICP_QAT_CSS_FWSK_EXPONENT_LEN + \
41 ICP_QAT_CSS_FWSK_PAD_LEN)
42 #define ICP_QAT_CSS_SIGNATURE_LEN 256
43 #define ICP_QAT_CSS_AE_IMG_LEN (sizeof(struct icp_qat_simg_ae_mode) + \
44 ICP_QAT_SIMG_AE_INIT_SEQ_LEN + \
45 ICP_QAT_SIMG_AE_INSTS_LEN)
46 #define ICP_QAT_CSS_AE_SIMG_LEN (sizeof(struct icp_qat_css_hdr) + \
47 ICP_QAT_CSS_FWSK_PUB_LEN + \
48 ICP_QAT_CSS_SIGNATURE_LEN + \
49 ICP_QAT_CSS_AE_IMG_LEN)
50 #define ICP_QAT_AE_IMG_OFFSET (sizeof(struct icp_qat_css_hdr) + \
51 ICP_QAT_CSS_FWSK_MODULUS_LEN + \
52 ICP_QAT_CSS_FWSK_EXPONENT_LEN + \
53 ICP_QAT_CSS_SIGNATURE_LEN)
54 #define ICP_QAT_CSS_MAX_IMAGE_LEN 0x40000
56 #define ICP_QAT_CTX_MODE(ae_mode) ((ae_mode) & 0xf)
57 #define ICP_QAT_NN_MODE(ae_mode) (((ae_mode) >> 0x4) & 0xf)
58 #define ICP_QAT_SHARED_USTORE_MODE(ae_mode) (((ae_mode) >> 0xb) & 0x1)
59 #define RELOADABLE_CTX_SHARED_MODE(ae_mode) (((ae_mode) >> 0xc) & 0x1)
61 #define ICP_QAT_LOC_MEM0_MODE(ae_mode) (((ae_mode) >> 0x8) & 0x1)
62 #define ICP_QAT_LOC_MEM1_MODE(ae_mode) (((ae_mode) >> 0x9) & 0x1)
64 enum icp_qat_uof_mem_region {
65 ICP_QAT_UOF_SRAM_REGION = 0x0,
66 ICP_QAT_UOF_LMEM_REGION = 0x3,
67 ICP_QAT_UOF_UMEM_REGION = 0x5
70 enum icp_qat_uof_regtype {
94 enum icp_qat_css_fwtype {
99 struct icp_qat_uclo_page {
100 struct icp_qat_uclo_encap_page *encap_page;
101 struct icp_qat_uclo_region *region;
105 struct icp_qat_uclo_region {
106 struct icp_qat_uclo_page *loaded;
107 struct icp_qat_uclo_page *page;
110 struct icp_qat_uclo_aeslice {
111 struct icp_qat_uclo_region *region;
112 struct icp_qat_uclo_page *page;
113 struct icp_qat_uclo_page *cur_page[ICP_QAT_UCLO_MAX_CTX];
114 struct icp_qat_uclo_encapme *encap_image;
115 unsigned int ctx_mask_assigned;
116 unsigned int new_uaddr[ICP_QAT_UCLO_MAX_CTX];
119 struct icp_qat_uclo_aedata {
120 unsigned int slice_num;
121 unsigned int eff_ustore_size;
122 struct icp_qat_uclo_aeslice ae_slices[ICP_QAT_UCLO_MAX_CTX];
125 struct icp_qat_uof_encap_obj {
127 struct icp_qat_uof_objhdr *obj_hdr;
128 struct icp_qat_uof_chunkhdr *chunk_hdr;
129 struct icp_qat_uof_varmem_seg *var_mem_seg;
132 struct icp_qat_uclo_encap_uwblock {
133 unsigned int start_addr;
134 unsigned int words_num;
138 struct icp_qat_uclo_encap_page {
139 unsigned int def_page;
140 unsigned int page_region;
141 unsigned int beg_addr_v;
142 unsigned int beg_addr_p;
143 unsigned int micro_words_num;
144 unsigned int uwblock_num;
145 struct icp_qat_uclo_encap_uwblock *uwblock;
148 struct icp_qat_uclo_encapme {
149 struct icp_qat_uof_image *img_ptr;
150 struct icp_qat_uclo_encap_page *page;
151 unsigned int ae_reg_num;
152 struct icp_qat_uof_ae_reg *ae_reg;
153 unsigned int init_regsym_num;
154 struct icp_qat_uof_init_regsym *init_regsym;
155 unsigned int sbreak_num;
156 struct icp_qat_uof_sbreak *sbreak;
157 unsigned int uwords_num;
160 struct icp_qat_uclo_init_mem_table {
161 unsigned int entry_num;
162 struct icp_qat_uof_initmem *init_mem;
165 struct icp_qat_uclo_objhdr {
167 unsigned int checksum;
171 struct icp_qat_uof_strtable {
172 unsigned int table_len;
173 unsigned int reserved;
177 struct icp_qat_uclo_objhandle {
178 unsigned int prod_type;
179 unsigned int prod_rev;
180 struct icp_qat_uclo_objhdr *obj_hdr;
181 struct icp_qat_uof_encap_obj encap_uof_obj;
182 struct icp_qat_uof_strtable str_table;
183 struct icp_qat_uclo_encapme ae_uimage[ICP_QAT_UCLO_MAX_UIMAGE];
184 struct icp_qat_uclo_aedata ae_data[ICP_QAT_UCLO_MAX_AE];
185 struct icp_qat_uclo_init_mem_table init_mem_tab;
186 struct icp_qat_uof_batch_init *lm_init_tab[ICP_QAT_UCLO_MAX_AE];
187 struct icp_qat_uof_batch_init *umem_init_tab[ICP_QAT_UCLO_MAX_AE];
192 unsigned int ustore_phy_size;
197 struct icp_qat_uof_uword_block {
198 unsigned int start_addr;
199 unsigned int words_num;
200 unsigned int uword_offset;
201 unsigned int reserved;
204 struct icp_qat_uof_filehdr {
205 unsigned short file_id;
206 unsigned short reserved1;
209 unsigned short reserved2;
210 unsigned short max_chunks;
211 unsigned short num_chunks;
214 struct icp_qat_uof_filechunkhdr {
215 char chunk_id[ICP_QAT_UOF_OBJID_LEN];
216 unsigned int checksum;
221 struct icp_qat_uof_objhdr {
222 unsigned int ac_dev_type;
223 unsigned short min_cpu_ver;
224 unsigned short max_cpu_ver;
227 unsigned int reserved1;
228 unsigned int reserved2;
231 struct icp_qat_uof_chunkhdr {
232 char chunk_id[ICP_QAT_UOF_OBJID_LEN];
237 struct icp_qat_uof_memvar_attr {
238 unsigned int offset_in_byte;
242 struct icp_qat_uof_initmem {
243 unsigned int sym_name;
246 unsigned short reserved1;
248 unsigned int num_in_bytes;
249 unsigned int val_attr_num;
252 struct icp_qat_uof_init_regsym {
253 unsigned int sym_name;
258 unsigned int reg_addr;
262 struct icp_qat_uof_varmem_seg {
263 unsigned int sram_base;
264 unsigned int sram_size;
265 unsigned int sram_alignment;
266 unsigned int sdram_base;
267 unsigned int sdram_size;
268 unsigned int sdram_alignment;
269 unsigned int sdram1_base;
270 unsigned int sdram1_size;
271 unsigned int sdram1_alignment;
272 unsigned int scratch_base;
273 unsigned int scratch_size;
274 unsigned int scratch_alignment;
277 struct icp_qat_uof_gtid {
278 char tool_id[ICP_QAT_UOF_OBJID_LEN];
280 unsigned int reserved1;
281 unsigned int reserved2;
284 struct icp_qat_uof_sbreak {
285 unsigned int page_num;
286 unsigned int virt_uaddr;
287 unsigned char sbreak_type;
288 unsigned char reg_type;
289 unsigned short reserved1;
290 unsigned int addr_offset;
291 unsigned int reg_addr;
294 struct icp_qat_uof_code_page {
295 unsigned int page_region;
296 unsigned int page_num;
297 unsigned char def_page;
298 unsigned char reserved2;
299 unsigned short reserved1;
300 unsigned int beg_addr_v;
301 unsigned int beg_addr_p;
302 unsigned int neigh_reg_tab_offset;
303 unsigned int uc_var_tab_offset;
304 unsigned int imp_var_tab_offset;
305 unsigned int imp_expr_tab_offset;
306 unsigned int code_area_offset;
309 struct icp_qat_uof_image {
310 unsigned int img_name;
311 unsigned int ae_assigned;
312 unsigned int ctx_assigned;
313 unsigned int ac_dev_type;
314 unsigned int entry_address;
315 unsigned int fill_pattern[2];
316 unsigned int reloadable_size;
317 unsigned char sensitivity;
318 unsigned char reserved;
319 unsigned short ae_mode;
320 unsigned short max_ver;
321 unsigned short min_ver;
322 unsigned short image_attrib;
323 unsigned short reserved2;
324 unsigned short page_region_num;
325 unsigned short numpages;
326 unsigned int reg_tab_offset;
327 unsigned int init_reg_sym_tab;
328 unsigned int sbreak_tab;
329 unsigned int app_metadata;
332 struct icp_qat_uof_objtable {
333 unsigned int entry_num;
336 struct icp_qat_uof_ae_reg {
338 unsigned int vis_name;
341 unsigned short access_mode;
342 unsigned char visible;
343 unsigned char reserved1;
344 unsigned short ref_count;
345 unsigned short reserved2;
349 struct icp_qat_uof_code_area {
350 unsigned int micro_words_num;
351 unsigned int uword_block_tab;
354 struct icp_qat_uof_batch_init {
359 struct icp_qat_uof_batch_init *next;
362 struct icp_qat_suof_img_hdr {
364 unsigned long simg_len;
369 unsigned long simg_size;
371 unsigned int ae_mask;
372 unsigned int fw_type;
373 unsigned long simg_name;
374 unsigned long appmeta_data;
377 struct icp_qat_suof_img_tbl {
378 unsigned int num_simgs;
379 struct icp_qat_suof_img_hdr *simg_hdr;
382 struct icp_qat_suof_handle {
383 unsigned int file_id;
384 unsigned int check_sum;
389 unsigned int suof_size;
391 unsigned int sym_size;
392 struct icp_qat_suof_img_tbl img_table;
395 struct icp_qat_fw_auth_desc {
396 unsigned int img_len;
397 unsigned int reserved;
398 unsigned int css_hdr_high;
399 unsigned int css_hdr_low;
400 unsigned int img_high;
401 unsigned int img_low;
402 unsigned int signature_high;
403 unsigned int signature_low;
404 unsigned int fwsk_pub_high;
405 unsigned int fwsk_pub_low;
406 unsigned int img_ae_mode_data_high;
407 unsigned int img_ae_mode_data_low;
408 unsigned int img_ae_init_data_high;
409 unsigned int img_ae_init_data_low;
410 unsigned int img_ae_insts_high;
411 unsigned int img_ae_insts_low;
414 struct icp_qat_auth_chunk {
415 struct icp_qat_fw_auth_desc fw_auth_desc;
420 struct icp_qat_css_hdr {
421 unsigned int module_type;
422 unsigned int header_len;
423 unsigned int header_ver;
424 unsigned int module_id;
425 unsigned int module_vendor;
428 unsigned int key_size;
429 unsigned int module_size;
430 unsigned int exponent_size;
431 unsigned int fw_type;
432 unsigned int reserved[21];
435 struct icp_qat_simg_ae_mode {
436 unsigned int file_id;
437 unsigned short maj_ver;
438 unsigned short min_ver;
439 unsigned int dev_type;
440 unsigned short devmax_ver;
441 unsigned short devmin_ver;
442 unsigned int ae_mask;
443 unsigned int ctx_enables;
453 unsigned char reserved[7];
455 char appmeta_data[256];
458 struct icp_qat_suof_filehdr {
459 unsigned int file_id;
460 unsigned int check_sum;
465 unsigned short max_chunks;
466 unsigned short num_chunks;
469 struct icp_qat_suof_chunk_hdr {
470 char chunk_id[ICP_QAT_SUOF_OBJ_ID_LEN];
475 struct icp_qat_suof_strtable {
476 unsigned int tab_length;
477 unsigned int strings;
480 struct icp_qat_suof_objhdr {
481 unsigned int img_length;
482 unsigned int reserved;