Linux Audio

Check our new training course

Loading...
  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__
  5
  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       17
 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))
 47
 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 */
 52
 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 */
 57
 58#define ICP_QAT_CSS_FWSK_MODULUS_LEN(handle)	((handle)->chip_info->css_3k ? \
 59						DSS_FWSK_MODULUS_LEN  : \
 60						CSS_FWSK_MODULUS_LEN)
 61
 62#define ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle)	((handle)->chip_info->css_3k ? \
 63						DSS_FWSK_EXPONENT_LEN : \
 64						CSS_FWSK_EXPONENT_LEN)
 65
 66#define ICP_QAT_CSS_FWSK_PAD_LEN(handle)	((handle)->chip_info->css_3k ? \
 67						DSS_FWSK_PADDING_LEN : \
 68						CSS_FWSK_PADDING_LEN)
 69
 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))
 73
 74#define ICP_QAT_CSS_SIGNATURE_LEN(handle)	((handle)->chip_info->css_3k ? \
 75						DSS_SIGNATURE_LEN : \
 76						CSS_SIGNATURE_LEN)
 77
 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
 91
 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)
 96
 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)
102
103enum 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
107};
108
109enum icp_qat_uof_regtype {
110	ICP_NO_DEST	= 0,
111	ICP_GPA_REL	= 1,
112	ICP_GPA_ABS	= 2,
113	ICP_GPB_REL	= 3,
114	ICP_GPB_ABS	= 4,
115	ICP_SR_REL	= 5,
116	ICP_SR_RD_REL	= 6,
117	ICP_SR_WR_REL	= 7,
118	ICP_SR_ABS	= 8,
119	ICP_SR_RD_ABS	= 9,
120	ICP_SR_WR_ABS	= 10,
121	ICP_DR_REL	= 19,
122	ICP_DR_RD_REL	= 20,
123	ICP_DR_WR_REL	= 21,
124	ICP_DR_ABS	= 22,
125	ICP_DR_RD_ABS	= 23,
126	ICP_DR_WR_ABS	= 24,
127	ICP_LMEM	= 26,
128	ICP_LMEM0	= 27,
129	ICP_LMEM1	= 28,
130	ICP_NEIGH_REL	= 31,
131	ICP_LMEM2	= 61,
132	ICP_LMEM3	= 62,
133};
134
135enum icp_qat_css_fwtype {
136	CSS_AE_FIRMWARE = 0,
137	CSS_MMP_FIRMWARE = 1
138};
139
140struct icp_qat_uclo_page {
141	struct icp_qat_uclo_encap_page *encap_page;
142	struct icp_qat_uclo_region *region;
143	unsigned int flags;
144};
145
146struct icp_qat_uclo_region {
147	struct icp_qat_uclo_page *loaded;
148	struct icp_qat_uclo_page *page;
149};
150
151struct 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];
158};
159
160struct 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];
164};
165
166struct icp_qat_uof_encap_obj {
167	char *beg_uof;
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;
171};
172
173struct icp_qat_uclo_encap_uwblock {
174	unsigned int start_addr;
175	unsigned int words_num;
176	u64 micro_words;
177};
178
179struct 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;
187};
188
189struct 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;
199};
200
201struct icp_qat_uclo_init_mem_table {
202	unsigned int entry_num;
203	struct icp_qat_uof_initmem *init_mem;
204};
205
206struct icp_qat_uclo_objhdr {
207	char *file_buff;
208	unsigned int checksum;
209	unsigned int size;
210};
211
212struct icp_qat_uof_strtable {
213	unsigned int table_len;
214	unsigned int reserved;
215	u64 strings;
216};
217
218struct 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];
229	int uimage_num;
230	int uword_in_bytes;
231	int global_inited;
232	unsigned int ae_num;
233	unsigned int ustore_phy_size;
234	void *obj_buf;
235	u64 *uword_buf;
236};
237
238struct icp_qat_uof_uword_block {
239	unsigned int start_addr;
240	unsigned int words_num;
241	unsigned int uword_offset;
242	unsigned int reserved;
243};
244
245struct icp_qat_uof_filehdr {
246	unsigned short file_id;
247	unsigned short reserved1;
248	char min_ver;
249	char maj_ver;
250	unsigned short reserved2;
251	unsigned short max_chunks;
252	unsigned short num_chunks;
253};
254
255struct icp_qat_uof_filechunkhdr {
256	char chunk_id[ICP_QAT_UOF_OBJID_LEN];
257	unsigned int checksum;
258	unsigned int offset;
259	unsigned int size;
260};
261
262struct icp_qat_uof_objhdr {
263	unsigned int ac_dev_type;
264	unsigned short min_cpu_ver;
265	unsigned short max_cpu_ver;
266	short max_chunks;
267	short num_chunks;
268	unsigned int reserved1;
269	unsigned int reserved2;
270};
271
272struct icp_qat_uof_chunkhdr {
273	char chunk_id[ICP_QAT_UOF_OBJID_LEN];
274	unsigned int offset;
275	unsigned int size;
276};
277
278struct icp_qat_uof_memvar_attr {
279	unsigned int offset_in_byte;
280	unsigned int value;
281};
282
283struct icp_qat_uof_initmem {
284	unsigned int sym_name;
285	char region;
286	char scope;
287	unsigned short reserved1;
288	unsigned int addr;
289	unsigned int num_in_bytes;
290	unsigned int val_attr_num;
291};
292
293struct icp_qat_uof_init_regsym {
294	unsigned int sym_name;
295	char init_type;
296	char value_type;
297	char reg_type;
298	unsigned char ctx;
299	unsigned int reg_addr;
300	unsigned int value;
301};
302
303struct 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;
316};
317
318struct icp_qat_uof_gtid {
319	char tool_id[ICP_QAT_UOF_OBJID_LEN];
320	int tool_ver;
321	unsigned int reserved1;
322	unsigned int reserved2;
323};
324
325struct 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;
333};
334
335struct 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;
348};
349
350struct 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;
371};
372
373struct icp_qat_uof_objtable {
374	unsigned int entry_num;
375};
376
377struct icp_qat_uof_ae_reg {
378	unsigned int name;
379	unsigned int vis_name;
380	unsigned short type;
381	unsigned short addr;
382	unsigned short access_mode;
383	unsigned char visible;
384	unsigned char reserved1;
385	unsigned short ref_count;
386	unsigned short reserved2;
387	unsigned int xo_id;
388};
389
390struct icp_qat_uof_code_area {
391	unsigned int micro_words_num;
392	unsigned int uword_block_tab;
393};
394
395struct icp_qat_uof_batch_init {
396	unsigned int ae;
397	unsigned int addr;
398	unsigned int *value;
399	unsigned int size;
400	struct icp_qat_uof_batch_init *next;
401};
402
403struct icp_qat_suof_img_hdr {
404	char          *simg_buf;
405	unsigned long simg_len;
406	char          *css_header;
407	char          *css_key;
408	char          *css_signature;
409	char          *css_simg;
410	unsigned long simg_size;
411	unsigned int  ae_num;
412	unsigned int  ae_mask;
413	unsigned int  fw_type;
414	unsigned long simg_name;
415	unsigned long appmeta_data;
416};
417
418struct icp_qat_suof_img_tbl {
419	unsigned int num_simgs;
420	struct icp_qat_suof_img_hdr *simg_hdr;
421};
422
423struct icp_qat_suof_handle {
424	unsigned int  file_id;
425	unsigned int  check_sum;
426	char          min_ver;
427	char          maj_ver;
428	char          fw_type;
429	char          *suof_buf;
430	unsigned int  suof_size;
431	char          *sym_str;
432	unsigned int  sym_size;
433	struct icp_qat_suof_img_tbl img_table;
434};
435
436struct 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;
453};
454
455struct icp_qat_auth_chunk {
456	struct icp_qat_fw_auth_desc fw_auth_desc;
457	u64 chunk_size;
458	u64 chunk_bus_addr;
459};
460
461struct 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;
467	unsigned int date;
468	unsigned int size;
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];
474};
475
476struct 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;
485	char             fw_type;
486	char             ctx_mode;
487	char             nn_mode;
488	char             lm0_mode;
489	char             lm1_mode;
490	char             scs_mode;
491	char             lm2_mode;
492	char             lm3_mode;
493	char             tindex_mode;
494	unsigned char    reserved[7];
495	char             simg_name[256];
496	char             appmeta_data[256];
497};
498
499struct icp_qat_suof_filehdr {
500	unsigned int     file_id;
501	unsigned int     check_sum;
502	char             min_ver;
503	char             maj_ver;
504	char             fw_type;
505	char             reserved;
506	unsigned short   max_chunks;
507	unsigned short   num_chunks;
508};
509
510struct icp_qat_suof_chunk_hdr {
511	char chunk_id[ICP_QAT_SUOF_OBJ_ID_LEN];
512	u64 offset;
513	u64 size;
514};
515
516struct icp_qat_suof_strtable {
517	unsigned int tab_length;
518	unsigned int strings;
519};
520
521struct icp_qat_suof_objhdr {
522	unsigned int img_length;
523	unsigned int reserved;
524};
525
526struct icp_qat_mof_file_hdr {
527	unsigned int file_id;
528	unsigned int checksum;
529	char min_ver;
530	char maj_ver;
531	unsigned short reserved;
532	unsigned short max_chunks;
533	unsigned short num_chunks;
534};
535
536struct icp_qat_mof_chunkhdr {
537	char chunk_id[ICP_QAT_MOF_OBJ_ID_LEN];
538	u64 offset;
539	u64 size;
540};
541
542struct icp_qat_mof_str_table {
543	unsigned int tab_len;
544	unsigned int strings;
545};
546
547struct icp_qat_mof_obj_hdr {
548	unsigned short max_chunks;
549	unsigned short num_chunks;
550	unsigned int reserved;
551};
552
553struct icp_qat_mof_obj_chunkhdr {
554	char chunk_id[ICP_QAT_MOF_OBJ_CHUNKID_LEN];
555	u64 offset;
556	u64 size;
557	unsigned int name;
558	unsigned int reserved;
559};
560
561struct icp_qat_mof_objhdr {
562	char *obj_name;
563	char *obj_buf;
564	unsigned int obj_size;
565};
566
567struct icp_qat_mof_table {
568	unsigned int num_objs;
569	struct icp_qat_mof_objhdr *obj_hdr;
570};
571
572struct icp_qat_mof_handle {
573	unsigned int file_id;
574	unsigned int checksum;
575	char min_ver;
576	char maj_ver;
577	char *mof_buf;
578	u32 mof_size;
579	char *sym_str;
580	unsigned int sym_size;
581	char *uobjs_hdr;
582	char *sobjs_hdr;
583	struct icp_qat_mof_table obj_table;
584};
585#endif