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_MAX_IMAGE_LEN 0x40000
91 #define ICP_QAT_CTX_MODE(ae_mode) ((ae_mode) & 0xf)
92 #define ICP_QAT_NN_MODE(ae_mode) (((ae_mode) >> 0x4) & 0xf)
93 #define ICP_QAT_SHARED_USTORE_MODE(ae_mode) (((ae_mode) >> 0xb) & 0x1)
94 #define RELOADABLE_CTX_SHARED_MODE(ae_mode) (((ae_mode) >> 0xc) & 0x1)
96 #define ICP_QAT_LOC_MEM0_MODE(ae_mode) (((ae_mode) >> 0x8) & 0x1)
97 #define ICP_QAT_LOC_MEM1_MODE(ae_mode) (((ae_mode) >> 0x9) & 0x1)
98 #define ICP_QAT_LOC_MEM2_MODE(ae_mode) (((ae_mode) >> 0x6) & 0x1)
99 #define ICP_QAT_LOC_MEM3_MODE(ae_mode) (((ae_mode) >> 0x7) & 0x1)
100 #define ICP_QAT_LOC_TINDEX_MODE(ae_mode) (((ae_mode) >> 0xe) & 0x1)
102 enum icp_qat_uof_mem_region
{
103 ICP_QAT_UOF_SRAM_REGION
= 0x0,
104 ICP_QAT_UOF_LMEM_REGION
= 0x3,
105 ICP_QAT_UOF_UMEM_REGION
= 0x5
108 enum icp_qat_uof_regtype
{
134 enum icp_qat_css_fwtype
{
139 struct icp_qat_uclo_page
{
140 struct icp_qat_uclo_encap_page
*encap_page
;
141 struct icp_qat_uclo_region
*region
;
145 struct icp_qat_uclo_region
{
146 struct icp_qat_uclo_page
*loaded
;
147 struct icp_qat_uclo_page
*page
;
150 struct icp_qat_uclo_aeslice
{
151 struct icp_qat_uclo_region
*region
;
152 struct icp_qat_uclo_page
*page
;
153 struct icp_qat_uclo_page
*cur_page
[ICP_QAT_UCLO_MAX_CTX
];
154 struct icp_qat_uclo_encapme
*encap_image
;
155 unsigned int ctx_mask_assigned
;
156 unsigned int new_uaddr
[ICP_QAT_UCLO_MAX_CTX
];
159 struct icp_qat_uclo_aedata
{
160 unsigned int slice_num
;
161 unsigned int eff_ustore_size
;
162 struct icp_qat_uclo_aeslice ae_slices
[ICP_QAT_UCLO_MAX_CTX
];
165 struct icp_qat_uof_encap_obj
{
167 struct icp_qat_uof_objhdr
*obj_hdr
;
168 struct icp_qat_uof_chunkhdr
*chunk_hdr
;
169 struct icp_qat_uof_varmem_seg
*var_mem_seg
;
172 struct icp_qat_uclo_encap_uwblock
{
173 unsigned int start_addr
;
174 unsigned int words_num
;
178 struct icp_qat_uclo_encap_page
{
179 unsigned int def_page
;
180 unsigned int page_region
;
181 unsigned int beg_addr_v
;
182 unsigned int beg_addr_p
;
183 unsigned int micro_words_num
;
184 unsigned int uwblock_num
;
185 struct icp_qat_uclo_encap_uwblock
*uwblock
;
188 struct icp_qat_uclo_encapme
{
189 struct icp_qat_uof_image
*img_ptr
;
190 struct icp_qat_uclo_encap_page
*page
;
191 unsigned int ae_reg_num
;
192 struct icp_qat_uof_ae_reg
*ae_reg
;
193 unsigned int init_regsym_num
;
194 struct icp_qat_uof_init_regsym
*init_regsym
;
195 unsigned int sbreak_num
;
196 struct icp_qat_uof_sbreak
*sbreak
;
197 unsigned int uwords_num
;
200 struct icp_qat_uclo_init_mem_table
{
201 unsigned int entry_num
;
202 struct icp_qat_uof_initmem
*init_mem
;
205 struct icp_qat_uclo_objhdr
{
207 unsigned int checksum
;
211 struct icp_qat_uof_strtable
{
212 unsigned int table_len
;
213 unsigned int reserved
;
217 struct icp_qat_uclo_objhandle
{
218 unsigned int prod_type
;
219 unsigned int prod_rev
;
220 struct icp_qat_uclo_objhdr
*obj_hdr
;
221 struct icp_qat_uof_encap_obj encap_uof_obj
;
222 struct icp_qat_uof_strtable str_table
;
223 struct icp_qat_uclo_encapme ae_uimage
[ICP_QAT_UCLO_MAX_UIMAGE
];
224 struct icp_qat_uclo_aedata ae_data
[ICP_QAT_UCLO_MAX_AE
];
225 struct icp_qat_uclo_init_mem_table init_mem_tab
;
226 struct icp_qat_uof_batch_init
*lm_init_tab
[ICP_QAT_UCLO_MAX_AE
];
227 struct icp_qat_uof_batch_init
*umem_init_tab
[ICP_QAT_UCLO_MAX_AE
];
232 unsigned int ustore_phy_size
;
237 struct icp_qat_uof_uword_block
{
238 unsigned int start_addr
;
239 unsigned int words_num
;
240 unsigned int uword_offset
;
241 unsigned int reserved
;
244 struct icp_qat_uof_filehdr
{
245 unsigned short file_id
;
246 unsigned short reserved1
;
249 unsigned short reserved2
;
250 unsigned short max_chunks
;
251 unsigned short num_chunks
;
254 struct icp_qat_uof_filechunkhdr
{
255 char chunk_id
[ICP_QAT_UOF_OBJID_LEN
];
256 unsigned int checksum
;
261 struct icp_qat_uof_objhdr
{
262 unsigned int ac_dev_type
;
263 unsigned short min_cpu_ver
;
264 unsigned short max_cpu_ver
;
267 unsigned int reserved1
;
268 unsigned int reserved2
;
271 struct icp_qat_uof_chunkhdr
{
272 char chunk_id
[ICP_QAT_UOF_OBJID_LEN
];
277 struct icp_qat_uof_memvar_attr
{
278 unsigned int offset_in_byte
;
282 struct icp_qat_uof_initmem
{
283 unsigned int sym_name
;
286 unsigned short reserved1
;
288 unsigned int num_in_bytes
;
289 unsigned int val_attr_num
;
292 struct icp_qat_uof_init_regsym
{
293 unsigned int sym_name
;
298 unsigned int reg_addr
;
302 struct icp_qat_uof_varmem_seg
{
303 unsigned int sram_base
;
304 unsigned int sram_size
;
305 unsigned int sram_alignment
;
306 unsigned int sdram_base
;
307 unsigned int sdram_size
;
308 unsigned int sdram_alignment
;
309 unsigned int sdram1_base
;
310 unsigned int sdram1_size
;
311 unsigned int sdram1_alignment
;
312 unsigned int scratch_base
;
313 unsigned int scratch_size
;
314 unsigned int scratch_alignment
;
317 struct icp_qat_uof_gtid
{
318 char tool_id
[ICP_QAT_UOF_OBJID_LEN
];
320 unsigned int reserved1
;
321 unsigned int reserved2
;
324 struct icp_qat_uof_sbreak
{
325 unsigned int page_num
;
326 unsigned int virt_uaddr
;
327 unsigned char sbreak_type
;
328 unsigned char reg_type
;
329 unsigned short reserved1
;
330 unsigned int addr_offset
;
331 unsigned int reg_addr
;
334 struct icp_qat_uof_code_page
{
335 unsigned int page_region
;
336 unsigned int page_num
;
337 unsigned char def_page
;
338 unsigned char reserved2
;
339 unsigned short reserved1
;
340 unsigned int beg_addr_v
;
341 unsigned int beg_addr_p
;
342 unsigned int neigh_reg_tab_offset
;
343 unsigned int uc_var_tab_offset
;
344 unsigned int imp_var_tab_offset
;
345 unsigned int imp_expr_tab_offset
;
346 unsigned int code_area_offset
;
349 struct icp_qat_uof_image
{
350 unsigned int img_name
;
351 unsigned int ae_assigned
;
352 unsigned int ctx_assigned
;
353 unsigned int ac_dev_type
;
354 unsigned int entry_address
;
355 unsigned int fill_pattern
[2];
356 unsigned int reloadable_size
;
357 unsigned char sensitivity
;
358 unsigned char reserved
;
359 unsigned short ae_mode
;
360 unsigned short max_ver
;
361 unsigned short min_ver
;
362 unsigned short image_attrib
;
363 unsigned short reserved2
;
364 unsigned short page_region_num
;
365 unsigned short numpages
;
366 unsigned int reg_tab_offset
;
367 unsigned int init_reg_sym_tab
;
368 unsigned int sbreak_tab
;
369 unsigned int app_metadata
;
372 struct icp_qat_uof_objtable
{
373 unsigned int entry_num
;
376 struct icp_qat_uof_ae_reg
{
378 unsigned int vis_name
;
381 unsigned short access_mode
;
382 unsigned char visible
;
383 unsigned char reserved1
;
384 unsigned short ref_count
;
385 unsigned short reserved2
;
389 struct icp_qat_uof_code_area
{
390 unsigned int micro_words_num
;
391 unsigned int uword_block_tab
;
394 struct icp_qat_uof_batch_init
{
399 struct icp_qat_uof_batch_init
*next
;
402 struct icp_qat_suof_img_hdr
{
404 unsigned long simg_len
;
409 unsigned long simg_size
;
411 unsigned int ae_mask
;
412 unsigned int fw_type
;
413 unsigned long simg_name
;
414 unsigned long appmeta_data
;
417 struct icp_qat_suof_img_tbl
{
418 unsigned int num_simgs
;
419 struct icp_qat_suof_img_hdr
*simg_hdr
;
422 struct icp_qat_suof_handle
{
423 unsigned int file_id
;
424 unsigned int check_sum
;
429 unsigned int suof_size
;
431 unsigned int sym_size
;
432 struct icp_qat_suof_img_tbl img_table
;
435 struct icp_qat_fw_auth_desc
{
436 unsigned int img_len
;
437 unsigned int ae_mask
;
438 unsigned int css_hdr_high
;
439 unsigned int css_hdr_low
;
440 unsigned int img_high
;
441 unsigned int img_low
;
442 unsigned int signature_high
;
443 unsigned int signature_low
;
444 unsigned int fwsk_pub_high
;
445 unsigned int fwsk_pub_low
;
446 unsigned int img_ae_mode_data_high
;
447 unsigned int img_ae_mode_data_low
;
448 unsigned int img_ae_init_data_high
;
449 unsigned int img_ae_init_data_low
;
450 unsigned int img_ae_insts_high
;
451 unsigned int img_ae_insts_low
;
454 struct icp_qat_auth_chunk
{
455 struct icp_qat_fw_auth_desc fw_auth_desc
;
460 struct icp_qat_css_hdr
{
461 unsigned int module_type
;
462 unsigned int header_len
;
463 unsigned int header_ver
;
464 unsigned int module_id
;
465 unsigned int module_vendor
;
468 unsigned int key_size
;
469 unsigned int module_size
;
470 unsigned int exponent_size
;
471 unsigned int fw_type
;
472 unsigned int reserved
[21];
475 struct icp_qat_simg_ae_mode
{
476 unsigned int file_id
;
477 unsigned short maj_ver
;
478 unsigned short min_ver
;
479 unsigned int dev_type
;
480 unsigned short devmax_ver
;
481 unsigned short devmin_ver
;
482 unsigned int ae_mask
;
483 unsigned int ctx_enables
;
493 unsigned char reserved
[7];
495 char appmeta_data
[256];
498 struct icp_qat_suof_filehdr
{
499 unsigned int file_id
;
500 unsigned int check_sum
;
505 unsigned short max_chunks
;
506 unsigned short num_chunks
;
509 struct icp_qat_suof_chunk_hdr
{
510 char chunk_id
[ICP_QAT_SUOF_OBJ_ID_LEN
];
515 struct icp_qat_suof_strtable
{
516 unsigned int tab_length
;
517 unsigned int strings
;
520 struct icp_qat_suof_objhdr
{
521 unsigned int img_length
;
522 unsigned int reserved
;
525 struct icp_qat_mof_file_hdr
{
526 unsigned int file_id
;
527 unsigned int checksum
;
530 unsigned short reserved
;
531 unsigned short max_chunks
;
532 unsigned short num_chunks
;
535 struct icp_qat_mof_chunkhdr
{
536 char chunk_id
[ICP_QAT_MOF_OBJ_ID_LEN
];
541 struct icp_qat_mof_str_table
{
542 unsigned int tab_len
;
543 unsigned int strings
;
546 struct icp_qat_mof_obj_hdr
{
547 unsigned short max_chunks
;
548 unsigned short num_chunks
;
549 unsigned int reserved
;
552 struct icp_qat_mof_obj_chunkhdr
{
553 char chunk_id
[ICP_QAT_MOF_OBJ_CHUNKID_LEN
];
557 unsigned int reserved
;
560 struct icp_qat_mof_objhdr
{
563 unsigned int obj_size
;
566 struct icp_qat_mof_table
{
567 unsigned int num_objs
;
568 struct icp_qat_mof_objhdr
*obj_hdr
;
571 struct icp_qat_mof_handle
{
572 unsigned int file_id
;
573 unsigned int checksum
;
579 unsigned int sym_size
;
582 struct icp_qat_mof_table obj_table
;