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 47 #define DSS_FWSK_MODULUS_LEN 384 /* RSA3K */ 48 #define DSS_FWSK_EXPONENT_LEN 4 49 #define DSS_FWSK_PADDING_LEN 380 50 #define DSS_SIGNATURE_LEN 384 /* RSA3K */ 51 52 #define CSS_FWSK_MODULUS_LEN 256 /* RSA2K */ 53 #define CSS_FWSK_EXPONENT_LEN 4 54 #define CSS_FWSK_PADDING_LEN 252 55 #define CSS_SIGNATURE_LEN 256 /* RSA2K */ 56 57 #define ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) ((handle)->chip_info->css_3k ? \ 58 DSS_FWSK_MODULUS_LEN : \ 59 CSS_FWSK_MODULUS_LEN) 60 61 #define ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle) ((handle)->chip_info->css_3k ? \ 62 DSS_FWSK_EXPONENT_LEN : \ 63 CSS_FWSK_EXPONENT_LEN) 64 65 #define ICP_QAT_CSS_FWSK_PAD_LEN(handle) ((handle)->chip_info->css_3k ? \ 66 DSS_FWSK_PADDING_LEN : \ 67 CSS_FWSK_PADDING_LEN) 68 69 #define ICP_QAT_CSS_FWSK_PUB_LEN(handle) (ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) + \ 70 ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle) + \ 71 ICP_QAT_CSS_FWSK_PAD_LEN(handle)) 72 73 #define ICP_QAT_CSS_SIGNATURE_LEN(handle) ((handle)->chip_info->css_3k ? \ 74 DSS_SIGNATURE_LEN : \ 75 CSS_SIGNATURE_LEN) 76 77 #define ICP_QAT_AE_IMG_OFFSET(handle) (sizeof(struct icp_qat_css_hdr) + \ 78 ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) + \ 79 ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle) + \ 80 ICP_QAT_CSS_SIGNATURE_LEN(handle)) 81 #define ICP_QAT_CSS_RSA4K_MAX_IMAGE_LEN 0x40000 82 #define ICP_QAT_CSS_RSA3K_MAX_IMAGE_LEN 0x30000 83 84 #define ICP_QAT_CTX_MODE(ae_mode) ((ae_mode) & 0xf) 85 #define ICP_QAT_NN_MODE(ae_mode) (((ae_mode) >> 0x4) & 0xf) 86 #define ICP_QAT_SHARED_USTORE_MODE(ae_mode) (((ae_mode) >> 0xb) & 0x1) 87 #define RELOADABLE_CTX_SHARED_MODE(ae_mode) (((ae_mode) >> 0xc) & 0x1) 88 89 #define ICP_QAT_LOC_MEM0_MODE(ae_mode) (((ae_mode) >> 0x8) & 0x1) 90 #define ICP_QAT_LOC_MEM1_MODE(ae_mode) (((ae_mode) >> 0x9) & 0x1) 91 #define ICP_QAT_LOC_MEM2_MODE(ae_mode) (((ae_mode) >> 0x6) & 0x1) 92 #define ICP_QAT_LOC_MEM3_MODE(ae_mode) (((ae_mode) >> 0x7) & 0x1) 93 #define ICP_QAT_LOC_TINDEX_MODE(ae_mode) (((ae_mode) >> 0xe) & 0x1) 94 95 enum icp_qat_uof_mem_region { 96 ICP_QAT_UOF_SRAM_REGION = 0x0, 97 ICP_QAT_UOF_LMEM_REGION = 0x3, 98 ICP_QAT_UOF_UMEM_REGION = 0x5 99 }; 100 101 enum icp_qat_uof_regtype { 102 ICP_NO_DEST = 0, 103 ICP_GPA_REL = 1, 104 ICP_GPA_ABS = 2, 105 ICP_GPB_REL = 3, 106 ICP_GPB_ABS = 4, 107 ICP_SR_REL = 5, 108 ICP_SR_RD_REL = 6, 109 ICP_SR_WR_REL = 7, 110 ICP_SR_ABS = 8, 111 ICP_SR_RD_ABS = 9, 112 ICP_SR_WR_ABS = 10, 113 ICP_DR_REL = 19, 114 ICP_DR_RD_REL = 20, 115 ICP_DR_WR_REL = 21, 116 ICP_DR_ABS = 22, 117 ICP_DR_RD_ABS = 23, 118 ICP_DR_WR_ABS = 24, 119 ICP_LMEM = 26, 120 ICP_LMEM0 = 27, 121 ICP_LMEM1 = 28, 122 ICP_NEIGH_REL = 31, 123 ICP_LMEM2 = 61, 124 ICP_LMEM3 = 62, 125 }; 126 127 enum icp_qat_css_fwtype { 128 CSS_AE_FIRMWARE = 0, 129 CSS_MMP_FIRMWARE = 1 130 }; 131 132 struct icp_qat_uclo_page { 133 struct icp_qat_uclo_encap_page *encap_page; 134 struct icp_qat_uclo_region *region; 135 unsigned int flags; 136 }; 137 138 struct icp_qat_uclo_region { 139 struct icp_qat_uclo_page *loaded; 140 struct icp_qat_uclo_page *page; 141 }; 142 143 struct icp_qat_uclo_aeslice { 144 struct icp_qat_uclo_region *region; 145 struct icp_qat_uclo_page *page; 146 struct icp_qat_uclo_page *cur_page[ICP_QAT_UCLO_MAX_CTX]; 147 struct icp_qat_uclo_encapme *encap_image; 148 unsigned int ctx_mask_assigned; 149 unsigned int new_uaddr[ICP_QAT_UCLO_MAX_CTX]; 150 }; 151 152 struct icp_qat_uclo_aedata { 153 unsigned int slice_num; 154 unsigned int eff_ustore_size; 155 struct icp_qat_uclo_aeslice ae_slices[ICP_QAT_UCLO_MAX_CTX]; 156 }; 157 158 struct icp_qat_uof_encap_obj { 159 char *beg_uof; 160 struct icp_qat_uof_objhdr *obj_hdr; 161 struct icp_qat_uof_chunkhdr *chunk_hdr; 162 struct icp_qat_uof_varmem_seg *var_mem_seg; 163 }; 164 165 struct icp_qat_uclo_encap_uwblock { 166 unsigned int start_addr; 167 unsigned int words_num; 168 u64 micro_words; 169 }; 170 171 struct icp_qat_uclo_encap_page { 172 unsigned int def_page; 173 unsigned int page_region; 174 unsigned int beg_addr_v; 175 unsigned int beg_addr_p; 176 unsigned int micro_words_num; 177 unsigned int uwblock_num; 178 struct icp_qat_uclo_encap_uwblock *uwblock; 179 }; 180 181 struct icp_qat_uclo_encapme { 182 struct icp_qat_uof_image *img_ptr; 183 struct icp_qat_uclo_encap_page *page; 184 unsigned int ae_reg_num; 185 struct icp_qat_uof_ae_reg *ae_reg; 186 unsigned int init_regsym_num; 187 struct icp_qat_uof_init_regsym *init_regsym; 188 unsigned int sbreak_num; 189 struct icp_qat_uof_sbreak *sbreak; 190 unsigned int uwords_num; 191 }; 192 193 struct icp_qat_uclo_init_mem_table { 194 unsigned int entry_num; 195 struct icp_qat_uof_initmem *init_mem; 196 }; 197 198 struct icp_qat_uclo_objhdr { 199 char *file_buff; 200 unsigned int checksum; 201 unsigned int size; 202 }; 203 204 struct icp_qat_uof_strtable { 205 unsigned int table_len; 206 unsigned int reserved; 207 u64 strings; 208 }; 209 210 struct icp_qat_uclo_objhandle { 211 unsigned int prod_type; 212 unsigned int prod_rev; 213 struct icp_qat_uclo_objhdr *obj_hdr; 214 struct icp_qat_uof_encap_obj encap_uof_obj; 215 struct icp_qat_uof_strtable str_table; 216 struct icp_qat_uclo_encapme ae_uimage[ICP_QAT_UCLO_MAX_UIMAGE]; 217 struct icp_qat_uclo_aedata ae_data[ICP_QAT_UCLO_MAX_AE]; 218 struct icp_qat_uclo_init_mem_table init_mem_tab; 219 struct icp_qat_uof_batch_init *lm_init_tab[ICP_QAT_UCLO_MAX_AE]; 220 struct icp_qat_uof_batch_init *umem_init_tab[ICP_QAT_UCLO_MAX_AE]; 221 int uimage_num; 222 int uword_in_bytes; 223 int global_inited; 224 unsigned int ae_num; 225 unsigned int ustore_phy_size; 226 void *obj_buf; 227 u64 *uword_buf; 228 }; 229 230 struct icp_qat_uof_uword_block { 231 unsigned int start_addr; 232 unsigned int words_num; 233 unsigned int uword_offset; 234 unsigned int reserved; 235 }; 236 237 struct icp_qat_uof_filehdr { 238 unsigned short file_id; 239 unsigned short reserved1; 240 char min_ver; 241 char maj_ver; 242 unsigned short reserved2; 243 unsigned short max_chunks; 244 unsigned short num_chunks; 245 }; 246 247 struct icp_qat_uof_filechunkhdr { 248 char chunk_id[ICP_QAT_UOF_OBJID_LEN]; 249 unsigned int checksum; 250 unsigned int offset; 251 unsigned int size; 252 }; 253 254 struct icp_qat_uof_objhdr { 255 unsigned int ac_dev_type; 256 unsigned short min_cpu_ver; 257 unsigned short max_cpu_ver; 258 short max_chunks; 259 short num_chunks; 260 unsigned int reserved1; 261 unsigned int reserved2; 262 }; 263 264 struct icp_qat_uof_chunkhdr { 265 char chunk_id[ICP_QAT_UOF_OBJID_LEN]; 266 unsigned int offset; 267 unsigned int size; 268 }; 269 270 struct icp_qat_uof_memvar_attr { 271 unsigned int offset_in_byte; 272 unsigned int value; 273 }; 274 275 struct icp_qat_uof_initmem { 276 unsigned int sym_name; 277 char region; 278 char scope; 279 unsigned short reserved1; 280 unsigned int addr; 281 unsigned int num_in_bytes; 282 unsigned int val_attr_num; 283 }; 284 285 struct icp_qat_uof_init_regsym { 286 unsigned int sym_name; 287 char init_type; 288 char value_type; 289 char reg_type; 290 unsigned char ctx; 291 unsigned int reg_addr; 292 unsigned int value; 293 }; 294 295 struct icp_qat_uof_varmem_seg { 296 unsigned int sram_base; 297 unsigned int sram_size; 298 unsigned int sram_alignment; 299 unsigned int sdram_base; 300 unsigned int sdram_size; 301 unsigned int sdram_alignment; 302 unsigned int sdram1_base; 303 unsigned int sdram1_size; 304 unsigned int sdram1_alignment; 305 unsigned int scratch_base; 306 unsigned int scratch_size; 307 unsigned int scratch_alignment; 308 }; 309 310 struct icp_qat_uof_gtid { 311 char tool_id[ICP_QAT_UOF_OBJID_LEN]; 312 int tool_ver; 313 unsigned int reserved1; 314 unsigned int reserved2; 315 }; 316 317 struct icp_qat_uof_sbreak { 318 unsigned int page_num; 319 unsigned int virt_uaddr; 320 unsigned char sbreak_type; 321 unsigned char reg_type; 322 unsigned short reserved1; 323 unsigned int addr_offset; 324 unsigned int reg_addr; 325 }; 326 327 struct icp_qat_uof_code_page { 328 unsigned int page_region; 329 unsigned int page_num; 330 unsigned char def_page; 331 unsigned char reserved2; 332 unsigned short reserved1; 333 unsigned int beg_addr_v; 334 unsigned int beg_addr_p; 335 unsigned int neigh_reg_tab_offset; 336 unsigned int uc_var_tab_offset; 337 unsigned int imp_var_tab_offset; 338 unsigned int imp_expr_tab_offset; 339 unsigned int code_area_offset; 340 }; 341 342 struct icp_qat_uof_image { 343 unsigned int img_name; 344 unsigned int ae_assigned; 345 unsigned int ctx_assigned; 346 unsigned int ac_dev_type; 347 unsigned int entry_address; 348 unsigned int fill_pattern[2]; 349 unsigned int reloadable_size; 350 unsigned char sensitivity; 351 unsigned char reserved; 352 unsigned short ae_mode; 353 unsigned short max_ver; 354 unsigned short min_ver; 355 unsigned short image_attrib; 356 unsigned short reserved2; 357 unsigned short page_region_num; 358 unsigned short numpages; 359 unsigned int reg_tab_offset; 360 unsigned int init_reg_sym_tab; 361 unsigned int sbreak_tab; 362 unsigned int app_metadata; 363 }; 364 365 struct icp_qat_uof_objtable { 366 unsigned int entry_num; 367 }; 368 369 struct icp_qat_uof_ae_reg { 370 unsigned int name; 371 unsigned int vis_name; 372 unsigned short type; 373 unsigned short addr; 374 unsigned short access_mode; 375 unsigned char visible; 376 unsigned char reserved1; 377 unsigned short ref_count; 378 unsigned short reserved2; 379 unsigned int xo_id; 380 }; 381 382 struct icp_qat_uof_code_area { 383 unsigned int micro_words_num; 384 unsigned int uword_block_tab; 385 }; 386 387 struct icp_qat_uof_batch_init { 388 unsigned int ae; 389 unsigned int addr; 390 unsigned int *value; 391 unsigned int size; 392 struct icp_qat_uof_batch_init *next; 393 }; 394 395 struct icp_qat_suof_img_hdr { 396 char *simg_buf; 397 unsigned long simg_len; 398 char *css_header; 399 char *css_simg; 400 unsigned long simg_size; 401 unsigned int ae_num; 402 unsigned int ae_mask; 403 unsigned int fw_type; 404 unsigned long simg_name; 405 unsigned long appmeta_data; 406 }; 407 408 struct icp_qat_suof_img_tbl { 409 unsigned int num_simgs; 410 struct icp_qat_suof_img_hdr *simg_hdr; 411 }; 412 413 struct icp_qat_suof_handle { 414 unsigned int file_id; 415 unsigned int check_sum; 416 char min_ver; 417 char maj_ver; 418 char fw_type; 419 char *suof_buf; 420 unsigned int suof_size; 421 char *sym_str; 422 unsigned int sym_size; 423 struct icp_qat_suof_img_tbl img_table; 424 }; 425 426 struct icp_qat_fw_auth_desc { 427 unsigned int img_len; 428 unsigned int ae_mask; 429 unsigned int css_hdr_high; 430 unsigned int css_hdr_low; 431 unsigned int img_high; 432 unsigned int img_low; 433 unsigned int signature_high; 434 unsigned int signature_low; 435 unsigned int fwsk_pub_high; 436 unsigned int fwsk_pub_low; 437 unsigned int img_ae_mode_data_high; 438 unsigned int img_ae_mode_data_low; 439 unsigned int img_ae_init_data_high; 440 unsigned int img_ae_init_data_low; 441 unsigned int img_ae_insts_high; 442 unsigned int img_ae_insts_low; 443 }; 444 445 struct icp_qat_auth_chunk { 446 struct icp_qat_fw_auth_desc fw_auth_desc; 447 u64 chunk_size; 448 u64 chunk_bus_addr; 449 }; 450 451 struct icp_qat_css_hdr { 452 unsigned int module_type; 453 unsigned int header_len; 454 unsigned int header_ver; 455 unsigned int module_id; 456 unsigned int module_vendor; 457 unsigned int date; 458 unsigned int size; 459 unsigned int key_size; 460 unsigned int module_size; 461 unsigned int exponent_size; 462 unsigned int fw_type; 463 unsigned int reserved[21]; 464 }; 465 466 struct icp_qat_simg_ae_mode { 467 unsigned int file_id; 468 unsigned short maj_ver; 469 unsigned short min_ver; 470 unsigned int dev_type; 471 unsigned short devmax_ver; 472 unsigned short devmin_ver; 473 unsigned int ae_mask; 474 unsigned int ctx_enables; 475 char fw_type; 476 char ctx_mode; 477 char nn_mode; 478 char lm0_mode; 479 char lm1_mode; 480 char scs_mode; 481 char lm2_mode; 482 char lm3_mode; 483 char tindex_mode; 484 unsigned char reserved[7]; 485 char simg_name[256]; 486 char appmeta_data[256]; 487 }; 488 489 struct icp_qat_suof_filehdr { 490 unsigned int file_id; 491 unsigned int check_sum; 492 char min_ver; 493 char maj_ver; 494 char fw_type; 495 char reserved; 496 unsigned short max_chunks; 497 unsigned short num_chunks; 498 }; 499 500 struct icp_qat_suof_chunk_hdr { 501 char chunk_id[ICP_QAT_SUOF_OBJ_ID_LEN]; 502 u64 offset; 503 u64 size; 504 }; 505 506 struct icp_qat_suof_strtable { 507 unsigned int tab_length; 508 unsigned int strings; 509 }; 510 511 struct icp_qat_suof_objhdr { 512 unsigned int img_length; 513 unsigned int reserved; 514 }; 515 516 struct icp_qat_mof_file_hdr { 517 unsigned int file_id; 518 unsigned int checksum; 519 char min_ver; 520 char maj_ver; 521 unsigned short reserved; 522 unsigned short max_chunks; 523 unsigned short num_chunks; 524 }; 525 526 struct icp_qat_mof_chunkhdr { 527 char chunk_id[ICP_QAT_MOF_OBJ_ID_LEN]; 528 u64 offset; 529 u64 size; 530 }; 531 532 struct icp_qat_mof_str_table { 533 unsigned int tab_len; 534 unsigned int strings; 535 }; 536 537 struct icp_qat_mof_obj_hdr { 538 unsigned short max_chunks; 539 unsigned short num_chunks; 540 unsigned int reserved; 541 }; 542 543 struct icp_qat_mof_obj_chunkhdr { 544 char chunk_id[ICP_QAT_MOF_OBJ_CHUNKID_LEN]; 545 u64 offset; 546 u64 size; 547 unsigned int name; 548 unsigned int reserved; 549 }; 550 551 struct icp_qat_mof_objhdr { 552 char *obj_name; 553 char *obj_buf; 554 unsigned int obj_size; 555 }; 556 557 struct icp_qat_mof_table { 558 unsigned int num_objs; 559 struct icp_qat_mof_objhdr *obj_hdr; 560 }; 561 562 struct icp_qat_mof_handle { 563 unsigned int file_id; 564 unsigned int checksum; 565 char min_ver; 566 char maj_ver; 567 char *mof_buf; 568 u32 mof_size; 569 char *sym_str; 570 unsigned int sym_size; 571 char *uobjs_hdr; 572 char *sobjs_hdr; 573 struct icp_qat_mof_table obj_table; 574 }; 575 #endif 576