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_AC_4XXX_A_DEV_TYPE 0x08000000
10 #define ICP_QAT_UCLO_MAX_AE 12
11 #define ICP_QAT_UCLO_MAX_CTX 8
12 #define ICP_QAT_UCLO_MAX_UIMAGE (ICP_QAT_UCLO_MAX_AE * ICP_QAT_UCLO_MAX_CTX)
13 #define ICP_QAT_UCLO_MAX_USTORE 0x4000
14 #define ICP_QAT_UCLO_MAX_XFER_REG 128
15 #define ICP_QAT_UCLO_MAX_GPR_REG 128
16 #define ICP_QAT_UCLO_MAX_LMEM_REG 1024
17 #define ICP_QAT_UCLO_MAX_LMEM_REG_2X 1280
18 #define ICP_QAT_UCLO_AE_ALL_CTX 0xff
19 #define ICP_QAT_UOF_OBJID_LEN 8
20 #define ICP_QAT_UOF_FID 0xc6c2
21 #define ICP_QAT_UOF_MAJVER 0x4
22 #define ICP_QAT_UOF_MINVER 0x11
23 #define ICP_QAT_UOF_OBJS "UOF_OBJS"
24 #define ICP_QAT_UOF_STRT "UOF_STRT"
25 #define ICP_QAT_UOF_IMAG "UOF_IMAG"
26 #define ICP_QAT_UOF_IMEM "UOF_IMEM"
27 #define ICP_QAT_UOF_LOCAL_SCOPE 1
28 #define ICP_QAT_UOF_INIT_EXPR 0
29 #define ICP_QAT_UOF_INIT_REG 1
30 #define ICP_QAT_UOF_INIT_REG_CTX 2
31 #define ICP_QAT_UOF_INIT_EXPR_ENDIAN_SWAP 3
32 #define ICP_QAT_SUOF_OBJ_ID_LEN 8
33 #define ICP_QAT_SUOF_FID 0x53554f46
34 #define ICP_QAT_SUOF_MAJVER 0x0
35 #define ICP_QAT_SUOF_MINVER 0x1
36 #define ICP_QAT_SUOF_OBJ_NAME_LEN 128
37 #define ICP_QAT_MOF_OBJ_ID_LEN 8
38 #define ICP_QAT_MOF_OBJ_CHUNKID_LEN 8
39 #define ICP_QAT_MOF_FID 0x00666f6d
40 #define ICP_QAT_MOF_MAJVER 0x0
41 #define ICP_QAT_MOF_MINVER 0x1
42 #define ICP_QAT_MOF_SYM_OBJS "SYM_OBJS"
43 #define ICP_QAT_SUOF_OBJS "SUF_OBJS"
44 #define ICP_QAT_SUOF_IMAG "SUF_IMAG"
45 #define ICP_QAT_SIMG_AE_INIT_SEQ_LEN (50 * sizeof(unsigned long long))
46 #define ICP_QAT_SIMG_AE_INSTS_LEN (0x4000 * sizeof(unsigned long long))
48 #define DSS_FWSK_MODULUS_LEN 384 /* RSA3K */
49 #define DSS_FWSK_EXPONENT_LEN 4
50 #define DSS_FWSK_PADDING_LEN 380
51 #define DSS_SIGNATURE_LEN 384 /* RSA3K */
53 #define CSS_FWSK_MODULUS_LEN 256 /* RSA2K */
54 #define CSS_FWSK_EXPONENT_LEN 4
55 #define CSS_FWSK_PADDING_LEN 252
56 #define CSS_SIGNATURE_LEN 256 /* RSA2K */
58 #define ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) ((handle)->chip_info->css_3k ? \
59 DSS_FWSK_MODULUS_LEN : \
62 #define ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle) ((handle)->chip_info->css_3k ? \
63 DSS_FWSK_EXPONENT_LEN : \
64 CSS_FWSK_EXPONENT_LEN)
66 #define ICP_QAT_CSS_FWSK_PAD_LEN(handle) ((handle)->chip_info->css_3k ? \
67 DSS_FWSK_PADDING_LEN : \
70 #define ICP_QAT_CSS_FWSK_PUB_LEN(handle) (ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) + \
71 ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle) + \
72 ICP_QAT_CSS_FWSK_PAD_LEN(handle))
74 #define ICP_QAT_CSS_SIGNATURE_LEN(handle) ((handle)->chip_info->css_3k ? \
78 #define ICP_QAT_CSS_AE_IMG_LEN (sizeof(struct icp_qat_simg_ae_mode) + \
79 ICP_QAT_SIMG_AE_INIT_SEQ_LEN + \
80 ICP_QAT_SIMG_AE_INSTS_LEN)
81 #define ICP_QAT_CSS_AE_SIMG_LEN(handle) (sizeof(struct icp_qat_css_hdr) + \
82 ICP_QAT_CSS_FWSK_PUB_LEN(handle) + \
83 ICP_QAT_CSS_SIGNATURE_LEN(handle) + \
84 ICP_QAT_CSS_AE_IMG_LEN)
85 #define ICP_QAT_AE_IMG_OFFSET(handle) (sizeof(struct icp_qat_css_hdr) + \
86 ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) + \
87 ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle) + \
88 ICP_QAT_CSS_SIGNATURE_LEN(handle))
89 #define ICP_QAT_CSS_RSA4K_MAX_IMAGE_LEN 0x40000
90 #define ICP_QAT_CSS_RSA3K_MAX_IMAGE_LEN 0x30000
92 #define ICP_QAT_CTX_MODE(ae_mode) ((ae_mode) & 0xf)
93 #define ICP_QAT_NN_MODE(ae_mode) (((ae_mode) >> 0x4) & 0xf)
94 #define ICP_QAT_SHARED_USTORE_MODE(ae_mode) (((ae_mode) >> 0xb) & 0x1)
95 #define RELOADABLE_CTX_SHARED_MODE(ae_mode) (((ae_mode) >> 0xc) & 0x1)
97 #define ICP_QAT_LOC_MEM0_MODE(ae_mode) (((ae_mode) >> 0x8) & 0x1)
98 #define ICP_QAT_LOC_MEM1_MODE(ae_mode) (((ae_mode) >> 0x9) & 0x1)
99 #define ICP_QAT_LOC_MEM2_MODE(ae_mode) (((ae_mode) >> 0x6) & 0x1)
100 #define ICP_QAT_LOC_MEM3_MODE(ae_mode) (((ae_mode) >> 0x7) & 0x1)
101 #define ICP_QAT_LOC_TINDEX_MODE(ae_mode) (((ae_mode) >> 0xe) & 0x1)
103 enum icp_qat_uof_mem_region {
104 ICP_QAT_UOF_SRAM_REGION = 0x0,
105 ICP_QAT_UOF_LMEM_REGION = 0x3,
106 ICP_QAT_UOF_UMEM_REGION = 0x5
109 enum icp_qat_uof_regtype {
135 enum icp_qat_css_fwtype {
140 struct icp_qat_uclo_page {
141 struct icp_qat_uclo_encap_page *encap_page;
142 struct icp_qat_uclo_region *region;
146 struct icp_qat_uclo_region {
147 struct icp_qat_uclo_page *loaded;
148 struct icp_qat_uclo_page *page;
151 struct icp_qat_uclo_aeslice {
152 struct icp_qat_uclo_region *region;
153 struct icp_qat_uclo_page *page;
154 struct icp_qat_uclo_page *cur_page[ICP_QAT_UCLO_MAX_CTX];
155 struct icp_qat_uclo_encapme *encap_image;
156 unsigned int ctx_mask_assigned;
157 unsigned int new_uaddr[ICP_QAT_UCLO_MAX_CTX];
160 struct icp_qat_uclo_aedata {
161 unsigned int slice_num;
162 unsigned int eff_ustore_size;
163 struct icp_qat_uclo_aeslice ae_slices[ICP_QAT_UCLO_MAX_CTX];
166 struct icp_qat_uof_encap_obj {
168 struct icp_qat_uof_objhdr *obj_hdr;
169 struct icp_qat_uof_chunkhdr *chunk_hdr;
170 struct icp_qat_uof_varmem_seg *var_mem_seg;
173 struct icp_qat_uclo_encap_uwblock {
174 unsigned int start_addr;
175 unsigned int words_num;
179 struct icp_qat_uclo_encap_page {
180 unsigned int def_page;
181 unsigned int page_region;
182 unsigned int beg_addr_v;
183 unsigned int beg_addr_p;
184 unsigned int micro_words_num;
185 unsigned int uwblock_num;
186 struct icp_qat_uclo_encap_uwblock *uwblock;
189 struct icp_qat_uclo_encapme {
190 struct icp_qat_uof_image *img_ptr;
191 struct icp_qat_uclo_encap_page *page;
192 unsigned int ae_reg_num;
193 struct icp_qat_uof_ae_reg *ae_reg;
194 unsigned int init_regsym_num;
195 struct icp_qat_uof_init_regsym *init_regsym;
196 unsigned int sbreak_num;
197 struct icp_qat_uof_sbreak *sbreak;
198 unsigned int uwords_num;
201 struct icp_qat_uclo_init_mem_table {
202 unsigned int entry_num;
203 struct icp_qat_uof_initmem *init_mem;
206 struct icp_qat_uclo_objhdr {
208 unsigned int checksum;
212 struct icp_qat_uof_strtable {
213 unsigned int table_len;
214 unsigned int reserved;
218 struct icp_qat_uclo_objhandle {
219 unsigned int prod_type;
220 unsigned int prod_rev;
221 struct icp_qat_uclo_objhdr *obj_hdr;
222 struct icp_qat_uof_encap_obj encap_uof_obj;
223 struct icp_qat_uof_strtable str_table;
224 struct icp_qat_uclo_encapme ae_uimage[ICP_QAT_UCLO_MAX_UIMAGE];
225 struct icp_qat_uclo_aedata ae_data[ICP_QAT_UCLO_MAX_AE];
226 struct icp_qat_uclo_init_mem_table init_mem_tab;
227 struct icp_qat_uof_batch_init *lm_init_tab[ICP_QAT_UCLO_MAX_AE];
228 struct icp_qat_uof_batch_init *umem_init_tab[ICP_QAT_UCLO_MAX_AE];
233 unsigned int ustore_phy_size;
238 struct icp_qat_uof_uword_block {
239 unsigned int start_addr;
240 unsigned int words_num;
241 unsigned int uword_offset;
242 unsigned int reserved;
245 struct icp_qat_uof_filehdr {
246 unsigned short file_id;
247 unsigned short reserved1;
250 unsigned short reserved2;
251 unsigned short max_chunks;
252 unsigned short num_chunks;
255 struct icp_qat_uof_filechunkhdr {
256 char chunk_id[ICP_QAT_UOF_OBJID_LEN];
257 unsigned int checksum;
262 struct icp_qat_uof_objhdr {
263 unsigned int ac_dev_type;
264 unsigned short min_cpu_ver;
265 unsigned short max_cpu_ver;
268 unsigned int reserved1;
269 unsigned int reserved2;
272 struct icp_qat_uof_chunkhdr {
273 char chunk_id[ICP_QAT_UOF_OBJID_LEN];
278 struct icp_qat_uof_memvar_attr {
279 unsigned int offset_in_byte;
283 struct icp_qat_uof_initmem {
284 unsigned int sym_name;
287 unsigned short reserved1;
289 unsigned int num_in_bytes;
290 unsigned int val_attr_num;
293 struct icp_qat_uof_init_regsym {
294 unsigned int sym_name;
299 unsigned int reg_addr;
303 struct icp_qat_uof_varmem_seg {
304 unsigned int sram_base;
305 unsigned int sram_size;
306 unsigned int sram_alignment;
307 unsigned int sdram_base;
308 unsigned int sdram_size;
309 unsigned int sdram_alignment;
310 unsigned int sdram1_base;
311 unsigned int sdram1_size;
312 unsigned int sdram1_alignment;
313 unsigned int scratch_base;
314 unsigned int scratch_size;
315 unsigned int scratch_alignment;
318 struct icp_qat_uof_gtid {
319 char tool_id[ICP_QAT_UOF_OBJID_LEN];
321 unsigned int reserved1;
322 unsigned int reserved2;
325 struct icp_qat_uof_sbreak {
326 unsigned int page_num;
327 unsigned int virt_uaddr;
328 unsigned char sbreak_type;
329 unsigned char reg_type;
330 unsigned short reserved1;
331 unsigned int addr_offset;
332 unsigned int reg_addr;
335 struct icp_qat_uof_code_page {
336 unsigned int page_region;
337 unsigned int page_num;
338 unsigned char def_page;
339 unsigned char reserved2;
340 unsigned short reserved1;
341 unsigned int beg_addr_v;
342 unsigned int beg_addr_p;
343 unsigned int neigh_reg_tab_offset;
344 unsigned int uc_var_tab_offset;
345 unsigned int imp_var_tab_offset;
346 unsigned int imp_expr_tab_offset;
347 unsigned int code_area_offset;
350 struct icp_qat_uof_image {
351 unsigned int img_name;
352 unsigned int ae_assigned;
353 unsigned int ctx_assigned;
354 unsigned int ac_dev_type;
355 unsigned int entry_address;
356 unsigned int fill_pattern[2];
357 unsigned int reloadable_size;
358 unsigned char sensitivity;
359 unsigned char reserved;
360 unsigned short ae_mode;
361 unsigned short max_ver;
362 unsigned short min_ver;
363 unsigned short image_attrib;
364 unsigned short reserved2;
365 unsigned short page_region_num;
366 unsigned short numpages;
367 unsigned int reg_tab_offset;
368 unsigned int init_reg_sym_tab;
369 unsigned int sbreak_tab;
370 unsigned int app_metadata;
373 struct icp_qat_uof_objtable {
374 unsigned int entry_num;
377 struct icp_qat_uof_ae_reg {
379 unsigned int vis_name;
382 unsigned short access_mode;
383 unsigned char visible;
384 unsigned char reserved1;
385 unsigned short ref_count;
386 unsigned short reserved2;
390 struct icp_qat_uof_code_area {
391 unsigned int micro_words_num;
392 unsigned int uword_block_tab;
395 struct icp_qat_uof_batch_init {
400 struct icp_qat_uof_batch_init *next;
403 struct icp_qat_suof_img_hdr {
405 unsigned long simg_len;
410 unsigned long simg_size;
412 unsigned int ae_mask;
413 unsigned int fw_type;
414 unsigned long simg_name;
415 unsigned long appmeta_data;
418 struct icp_qat_suof_img_tbl {
419 unsigned int num_simgs;
420 struct icp_qat_suof_img_hdr *simg_hdr;
423 struct icp_qat_suof_handle {
424 unsigned int file_id;
425 unsigned int check_sum;
430 unsigned int suof_size;
432 unsigned int sym_size;
433 struct icp_qat_suof_img_tbl img_table;
436 struct icp_qat_fw_auth_desc {
437 unsigned int img_len;
438 unsigned int ae_mask;
439 unsigned int css_hdr_high;
440 unsigned int css_hdr_low;
441 unsigned int img_high;
442 unsigned int img_low;
443 unsigned int signature_high;
444 unsigned int signature_low;
445 unsigned int fwsk_pub_high;
446 unsigned int fwsk_pub_low;
447 unsigned int img_ae_mode_data_high;
448 unsigned int img_ae_mode_data_low;
449 unsigned int img_ae_init_data_high;
450 unsigned int img_ae_init_data_low;
451 unsigned int img_ae_insts_high;
452 unsigned int img_ae_insts_low;
455 struct icp_qat_auth_chunk {
456 struct icp_qat_fw_auth_desc fw_auth_desc;
461 struct icp_qat_css_hdr {
462 unsigned int module_type;
463 unsigned int header_len;
464 unsigned int header_ver;
465 unsigned int module_id;
466 unsigned int module_vendor;
469 unsigned int key_size;
470 unsigned int module_size;
471 unsigned int exponent_size;
472 unsigned int fw_type;
473 unsigned int reserved[21];
476 struct icp_qat_simg_ae_mode {
477 unsigned int file_id;
478 unsigned short maj_ver;
479 unsigned short min_ver;
480 unsigned int dev_type;
481 unsigned short devmax_ver;
482 unsigned short devmin_ver;
483 unsigned int ae_mask;
484 unsigned int ctx_enables;
494 unsigned char reserved[7];
496 char appmeta_data[256];
499 struct icp_qat_suof_filehdr {
500 unsigned int file_id;
501 unsigned int check_sum;
506 unsigned short max_chunks;
507 unsigned short num_chunks;
510 struct icp_qat_suof_chunk_hdr {
511 char chunk_id[ICP_QAT_SUOF_OBJ_ID_LEN];
516 struct icp_qat_suof_strtable {
517 unsigned int tab_length;
518 unsigned int strings;
521 struct icp_qat_suof_objhdr {
522 unsigned int img_length;
523 unsigned int reserved;
526 struct icp_qat_mof_file_hdr {
527 unsigned int file_id;
528 unsigned int checksum;
531 unsigned short reserved;
532 unsigned short max_chunks;
533 unsigned short num_chunks;
536 struct icp_qat_mof_chunkhdr {
537 char chunk_id[ICP_QAT_MOF_OBJ_ID_LEN];
542 struct icp_qat_mof_str_table {
543 unsigned int tab_len;
544 unsigned int strings;
547 struct icp_qat_mof_obj_hdr {
548 unsigned short max_chunks;
549 unsigned short num_chunks;
550 unsigned int reserved;
553 struct icp_qat_mof_obj_chunkhdr {
554 char chunk_id[ICP_QAT_MOF_OBJ_CHUNKID_LEN];
558 unsigned int reserved;
561 struct icp_qat_mof_objhdr {
564 unsigned int obj_size;
567 struct icp_qat_mof_table {
568 unsigned int num_objs;
569 struct icp_qat_mof_objhdr *obj_hdr;
572 struct icp_qat_mof_handle {
573 unsigned int file_id;
574 unsigned int checksum;
580 unsigned int sym_size;
583 struct icp_qat_mof_table obj_table;