2 This file is provided under a dual BSD/GPLv2 license. When using or
3 redistributing this file, you may do so under either license.
6 Copyright(c) 2014 Intel Corporation.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of version 2 of the GNU General Public License as
9 published by the Free Software Foundation.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
20 Copyright(c) 2014 Intel Corporation.
21 Redistribution and use in source and binary forms, with or without
22 modification, are permitted provided that the following conditions
25 * Redistributions of source code must retain the above copyright
26 notice, this list of conditions and the following disclaimer.
27 * Redistributions in binary form must reproduce the above copyright
28 notice, this list of conditions and the following disclaimer in
29 the documentation and/or other materials provided with the
31 * Neither the name of Intel Corporation nor the names of its
32 contributors may be used to endorse or promote products derived
33 from this software without specific prior written permission.
35 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 #ifndef __ICP_QAT_UCLO_H__
48 #define __ICP_QAT_UCLO_H__
50 #define ICP_QAT_AC_895XCC_DEV_TYPE 0x00400000
51 #define ICP_QAT_AC_C62X_DEV_TYPE 0x01000000
52 #define ICP_QAT_AC_C3XXX_DEV_TYPE 0x02000000
53 #define ICP_QAT_UCLO_MAX_AE 12
54 #define ICP_QAT_UCLO_MAX_CTX 8
55 #define ICP_QAT_UCLO_MAX_UIMAGE (ICP_QAT_UCLO_MAX_AE * ICP_QAT_UCLO_MAX_CTX)
56 #define ICP_QAT_UCLO_MAX_USTORE 0x4000
57 #define ICP_QAT_UCLO_MAX_XFER_REG 128
58 #define ICP_QAT_UCLO_MAX_GPR_REG 128
59 #define ICP_QAT_UCLO_MAX_LMEM_REG 1024
60 #define ICP_QAT_UCLO_AE_ALL_CTX 0xff
61 #define ICP_QAT_UOF_OBJID_LEN 8
62 #define ICP_QAT_UOF_FID 0xc6c2
63 #define ICP_QAT_UOF_MAJVER 0x4
64 #define ICP_QAT_UOF_MINVER 0x11
65 #define ICP_QAT_UOF_OBJS "UOF_OBJS"
66 #define ICP_QAT_UOF_STRT "UOF_STRT"
67 #define ICP_QAT_UOF_IMAG "UOF_IMAG"
68 #define ICP_QAT_UOF_IMEM "UOF_IMEM"
69 #define ICP_QAT_UOF_LOCAL_SCOPE 1
70 #define ICP_QAT_UOF_INIT_EXPR 0
71 #define ICP_QAT_UOF_INIT_REG 1
72 #define ICP_QAT_UOF_INIT_REG_CTX 2
73 #define ICP_QAT_UOF_INIT_EXPR_ENDIAN_SWAP 3
74 #define ICP_QAT_SUOF_OBJ_ID_LEN 8
75 #define ICP_QAT_SUOF_FID 0x53554f46
76 #define ICP_QAT_SUOF_MAJVER 0x0
77 #define ICP_QAT_SUOF_MINVER 0x1
78 #define ICP_QAT_SIMG_AE_INIT_SEQ_LEN (50 * sizeof(unsigned long long))
79 #define ICP_QAT_SIMG_AE_INSTS_LEN (0x4000 * sizeof(unsigned long long))
80 #define ICP_QAT_CSS_FWSK_MODULUS_LEN 256
81 #define ICP_QAT_CSS_FWSK_EXPONENT_LEN 4
82 #define ICP_QAT_CSS_FWSK_PAD_LEN 252
83 #define ICP_QAT_CSS_FWSK_PUB_LEN (ICP_QAT_CSS_FWSK_MODULUS_LEN + \
84 ICP_QAT_CSS_FWSK_EXPONENT_LEN + \
85 ICP_QAT_CSS_FWSK_PAD_LEN)
86 #define ICP_QAT_CSS_SIGNATURE_LEN 256
87 #define ICP_QAT_CSS_AE_IMG_LEN (sizeof(struct icp_qat_simg_ae_mode) + \
88 ICP_QAT_SIMG_AE_INIT_SEQ_LEN + \
89 ICP_QAT_SIMG_AE_INSTS_LEN)
90 #define ICP_QAT_CSS_AE_SIMG_LEN (sizeof(struct icp_qat_css_hdr) + \
91 ICP_QAT_CSS_FWSK_PUB_LEN + \
92 ICP_QAT_CSS_SIGNATURE_LEN + \
93 ICP_QAT_CSS_AE_IMG_LEN)
94 #define ICP_QAT_AE_IMG_OFFSET (sizeof(struct icp_qat_css_hdr) + \
95 ICP_QAT_CSS_FWSK_MODULUS_LEN + \
96 ICP_QAT_CSS_FWSK_EXPONENT_LEN + \
97 ICP_QAT_CSS_SIGNATURE_LEN)
98 #define ICP_QAT_CSS_MAX_IMAGE_LEN 0x40000
100 #define ICP_QAT_CTX_MODE(ae_mode) ((ae_mode) & 0xf)
101 #define ICP_QAT_NN_MODE(ae_mode) (((ae_mode) >> 0x4) & 0xf)
102 #define ICP_QAT_SHARED_USTORE_MODE(ae_mode) (((ae_mode) >> 0xb) & 0x1)
103 #define RELOADABLE_CTX_SHARED_MODE(ae_mode) (((ae_mode) >> 0xc) & 0x1)
105 #define ICP_QAT_LOC_MEM0_MODE(ae_mode) (((ae_mode) >> 0x8) & 0x1)
106 #define ICP_QAT_LOC_MEM1_MODE(ae_mode) (((ae_mode) >> 0x9) & 0x1)
108 enum icp_qat_uof_mem_region
{
109 ICP_QAT_UOF_SRAM_REGION
= 0x0,
110 ICP_QAT_UOF_LMEM_REGION
= 0x3,
111 ICP_QAT_UOF_UMEM_REGION
= 0x5
114 enum icp_qat_uof_regtype
{
138 enum icp_qat_css_fwtype
{
143 struct icp_qat_uclo_page
{
144 struct icp_qat_uclo_encap_page
*encap_page
;
145 struct icp_qat_uclo_region
*region
;
149 struct icp_qat_uclo_region
{
150 struct icp_qat_uclo_page
*loaded
;
151 struct icp_qat_uclo_page
*page
;
154 struct icp_qat_uclo_aeslice
{
155 struct icp_qat_uclo_region
*region
;
156 struct icp_qat_uclo_page
*page
;
157 struct icp_qat_uclo_page
*cur_page
[ICP_QAT_UCLO_MAX_CTX
];
158 struct icp_qat_uclo_encapme
*encap_image
;
159 unsigned int ctx_mask_assigned
;
160 unsigned int new_uaddr
[ICP_QAT_UCLO_MAX_CTX
];
163 struct icp_qat_uclo_aedata
{
164 unsigned int slice_num
;
165 unsigned int eff_ustore_size
;
166 struct icp_qat_uclo_aeslice ae_slices
[ICP_QAT_UCLO_MAX_CTX
];
169 struct icp_qat_uof_encap_obj
{
171 struct icp_qat_uof_objhdr
*obj_hdr
;
172 struct icp_qat_uof_chunkhdr
*chunk_hdr
;
173 struct icp_qat_uof_varmem_seg
*var_mem_seg
;
176 struct icp_qat_uclo_encap_uwblock
{
177 unsigned int start_addr
;
178 unsigned int words_num
;
179 uint64_t micro_words
;
182 struct icp_qat_uclo_encap_page
{
183 unsigned int def_page
;
184 unsigned int page_region
;
185 unsigned int beg_addr_v
;
186 unsigned int beg_addr_p
;
187 unsigned int micro_words_num
;
188 unsigned int uwblock_num
;
189 struct icp_qat_uclo_encap_uwblock
*uwblock
;
192 struct icp_qat_uclo_encapme
{
193 struct icp_qat_uof_image
*img_ptr
;
194 struct icp_qat_uclo_encap_page
*page
;
195 unsigned int ae_reg_num
;
196 struct icp_qat_uof_ae_reg
*ae_reg
;
197 unsigned int init_regsym_num
;
198 struct icp_qat_uof_init_regsym
*init_regsym
;
199 unsigned int sbreak_num
;
200 struct icp_qat_uof_sbreak
*sbreak
;
201 unsigned int uwords_num
;
204 struct icp_qat_uclo_init_mem_table
{
205 unsigned int entry_num
;
206 struct icp_qat_uof_initmem
*init_mem
;
209 struct icp_qat_uclo_objhdr
{
211 unsigned int checksum
;
215 struct icp_qat_uof_strtable
{
216 unsigned int table_len
;
217 unsigned int reserved
;
221 struct icp_qat_uclo_objhandle
{
222 unsigned int prod_type
;
223 unsigned int prod_rev
;
224 struct icp_qat_uclo_objhdr
*obj_hdr
;
225 struct icp_qat_uof_encap_obj encap_uof_obj
;
226 struct icp_qat_uof_strtable str_table
;
227 struct icp_qat_uclo_encapme ae_uimage
[ICP_QAT_UCLO_MAX_UIMAGE
];
228 struct icp_qat_uclo_aedata ae_data
[ICP_QAT_UCLO_MAX_AE
];
229 struct icp_qat_uclo_init_mem_table init_mem_tab
;
230 struct icp_qat_uof_batch_init
*lm_init_tab
[ICP_QAT_UCLO_MAX_AE
];
231 struct icp_qat_uof_batch_init
*umem_init_tab
[ICP_QAT_UCLO_MAX_AE
];
236 unsigned int ustore_phy_size
;
241 struct icp_qat_uof_uword_block
{
242 unsigned int start_addr
;
243 unsigned int words_num
;
244 unsigned int uword_offset
;
245 unsigned int reserved
;
248 struct icp_qat_uof_filehdr
{
249 unsigned short file_id
;
250 unsigned short reserved1
;
253 unsigned short reserved2
;
254 unsigned short max_chunks
;
255 unsigned short num_chunks
;
258 struct icp_qat_uof_filechunkhdr
{
259 char chunk_id
[ICP_QAT_UOF_OBJID_LEN
];
260 unsigned int checksum
;
265 struct icp_qat_uof_objhdr
{
266 unsigned int ac_dev_type
;
267 unsigned short min_cpu_ver
;
268 unsigned short max_cpu_ver
;
271 unsigned int reserved1
;
272 unsigned int reserved2
;
275 struct icp_qat_uof_chunkhdr
{
276 char chunk_id
[ICP_QAT_UOF_OBJID_LEN
];
281 struct icp_qat_uof_memvar_attr
{
282 unsigned int offset_in_byte
;
286 struct icp_qat_uof_initmem
{
287 unsigned int sym_name
;
290 unsigned short reserved1
;
292 unsigned int num_in_bytes
;
293 unsigned int val_attr_num
;
296 struct icp_qat_uof_init_regsym
{
297 unsigned int sym_name
;
302 unsigned int reg_addr
;
306 struct icp_qat_uof_varmem_seg
{
307 unsigned int sram_base
;
308 unsigned int sram_size
;
309 unsigned int sram_alignment
;
310 unsigned int sdram_base
;
311 unsigned int sdram_size
;
312 unsigned int sdram_alignment
;
313 unsigned int sdram1_base
;
314 unsigned int sdram1_size
;
315 unsigned int sdram1_alignment
;
316 unsigned int scratch_base
;
317 unsigned int scratch_size
;
318 unsigned int scratch_alignment
;
321 struct icp_qat_uof_gtid
{
322 char tool_id
[ICP_QAT_UOF_OBJID_LEN
];
324 unsigned int reserved1
;
325 unsigned int reserved2
;
328 struct icp_qat_uof_sbreak
{
329 unsigned int page_num
;
330 unsigned int virt_uaddr
;
331 unsigned char sbreak_type
;
332 unsigned char reg_type
;
333 unsigned short reserved1
;
334 unsigned int addr_offset
;
335 unsigned int reg_addr
;
338 struct icp_qat_uof_code_page
{
339 unsigned int page_region
;
340 unsigned int page_num
;
341 unsigned char def_page
;
342 unsigned char reserved2
;
343 unsigned short reserved1
;
344 unsigned int beg_addr_v
;
345 unsigned int beg_addr_p
;
346 unsigned int neigh_reg_tab_offset
;
347 unsigned int uc_var_tab_offset
;
348 unsigned int imp_var_tab_offset
;
349 unsigned int imp_expr_tab_offset
;
350 unsigned int code_area_offset
;
353 struct icp_qat_uof_image
{
354 unsigned int img_name
;
355 unsigned int ae_assigned
;
356 unsigned int ctx_assigned
;
357 unsigned int ac_dev_type
;
358 unsigned int entry_address
;
359 unsigned int fill_pattern
[2];
360 unsigned int reloadable_size
;
361 unsigned char sensitivity
;
362 unsigned char reserved
;
363 unsigned short ae_mode
;
364 unsigned short max_ver
;
365 unsigned short min_ver
;
366 unsigned short image_attrib
;
367 unsigned short reserved2
;
368 unsigned short page_region_num
;
369 unsigned short numpages
;
370 unsigned int reg_tab_offset
;
371 unsigned int init_reg_sym_tab
;
372 unsigned int sbreak_tab
;
373 unsigned int app_metadata
;
376 struct icp_qat_uof_objtable
{
377 unsigned int entry_num
;
380 struct icp_qat_uof_ae_reg
{
382 unsigned int vis_name
;
385 unsigned short access_mode
;
386 unsigned char visible
;
387 unsigned char reserved1
;
388 unsigned short ref_count
;
389 unsigned short reserved2
;
393 struct icp_qat_uof_code_area
{
394 unsigned int micro_words_num
;
395 unsigned int uword_block_tab
;
398 struct icp_qat_uof_batch_init
{
403 struct icp_qat_uof_batch_init
*next
;
406 struct icp_qat_suof_img_hdr
{
408 unsigned long simg_len
;
413 unsigned long simg_size
;
415 unsigned int ae_mask
;
416 unsigned int fw_type
;
417 unsigned long simg_name
;
418 unsigned long appmeta_data
;
421 struct icp_qat_suof_img_tbl
{
422 unsigned int num_simgs
;
423 struct icp_qat_suof_img_hdr
*simg_hdr
;
426 struct icp_qat_suof_handle
{
427 unsigned int file_id
;
428 unsigned int check_sum
;
433 unsigned int suof_size
;
435 unsigned int sym_size
;
436 struct icp_qat_suof_img_tbl img_table
;
439 struct icp_qat_fw_auth_desc
{
440 unsigned int img_len
;
441 unsigned int reserved
;
442 unsigned int css_hdr_high
;
443 unsigned int css_hdr_low
;
444 unsigned int img_high
;
445 unsigned int img_low
;
446 unsigned int signature_high
;
447 unsigned int signature_low
;
448 unsigned int fwsk_pub_high
;
449 unsigned int fwsk_pub_low
;
450 unsigned int img_ae_mode_data_high
;
451 unsigned int img_ae_mode_data_low
;
452 unsigned int img_ae_init_data_high
;
453 unsigned int img_ae_init_data_low
;
454 unsigned int img_ae_insts_high
;
455 unsigned int img_ae_insts_low
;
458 struct icp_qat_auth_chunk
{
459 struct icp_qat_fw_auth_desc fw_auth_desc
;
464 struct icp_qat_css_hdr
{
465 unsigned int module_type
;
466 unsigned int header_len
;
467 unsigned int header_ver
;
468 unsigned int module_id
;
469 unsigned int module_vendor
;
472 unsigned int key_size
;
473 unsigned int module_size
;
474 unsigned int exponent_size
;
475 unsigned int fw_type
;
476 unsigned int reserved
[21];
479 struct icp_qat_simg_ae_mode
{
480 unsigned int file_id
;
481 unsigned short maj_ver
;
482 unsigned short min_ver
;
483 unsigned int dev_type
;
484 unsigned short devmax_ver
;
485 unsigned short devmin_ver
;
486 unsigned int ae_mask
;
487 unsigned int ctx_enables
;
497 unsigned char reserved
[7];
499 char appmeta_data
[256];
502 struct icp_qat_suof_filehdr
{
503 unsigned int file_id
;
504 unsigned int check_sum
;
509 unsigned short max_chunks
;
510 unsigned short num_chunks
;
513 struct icp_qat_suof_chunk_hdr
{
514 char chunk_id
[ICP_QAT_SUOF_OBJ_ID_LEN
];
519 struct icp_qat_suof_strtable
{
520 unsigned int tab_length
;
521 unsigned int strings
;
524 struct icp_qat_suof_objhdr
{
525 unsigned int img_length
;
526 unsigned int reserved
;