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