root/drivers/crypto/qat/qat_common/icp_qat_uclo.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   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.
   4 
   5   GPL LICENSE SUMMARY
   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.
  10 
  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.
  15 
  16   Contact Information:
  17   qat-linux@intel.com
  18 
  19   BSD LICENSE
  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
  23   are met:
  24 
  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
  30       distribution.
  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.
  34 
  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.
  46 */
  47 #ifndef __ICP_QAT_UCLO_H__
  48 #define __ICP_QAT_UCLO_H__
  49 
  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
  99 
 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)
 104 
 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)
 107 
 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
 112 };
 113 
 114 enum icp_qat_uof_regtype {
 115         ICP_NO_DEST     = 0,
 116         ICP_GPA_REL     = 1,
 117         ICP_GPA_ABS     = 2,
 118         ICP_GPB_REL     = 3,
 119         ICP_GPB_ABS     = 4,
 120         ICP_SR_REL      = 5,
 121         ICP_SR_RD_REL   = 6,
 122         ICP_SR_WR_REL   = 7,
 123         ICP_SR_ABS      = 8,
 124         ICP_SR_RD_ABS   = 9,
 125         ICP_SR_WR_ABS   = 10,
 126         ICP_DR_REL      = 19,
 127         ICP_DR_RD_REL   = 20,
 128         ICP_DR_WR_REL   = 21,
 129         ICP_DR_ABS      = 22,
 130         ICP_DR_RD_ABS   = 23,
 131         ICP_DR_WR_ABS   = 24,
 132         ICP_LMEM        = 26,
 133         ICP_LMEM0       = 27,
 134         ICP_LMEM1       = 28,
 135         ICP_NEIGH_REL   = 31,
 136 };
 137 
 138 enum icp_qat_css_fwtype {
 139         CSS_AE_FIRMWARE = 0,
 140         CSS_MMP_FIRMWARE = 1
 141 };
 142 
 143 struct icp_qat_uclo_page {
 144         struct icp_qat_uclo_encap_page *encap_page;
 145         struct icp_qat_uclo_region *region;
 146         unsigned int flags;
 147 };
 148 
 149 struct icp_qat_uclo_region {
 150         struct icp_qat_uclo_page *loaded;
 151         struct icp_qat_uclo_page *page;
 152 };
 153 
 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];
 161 };
 162 
 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];
 167 };
 168 
 169 struct icp_qat_uof_encap_obj {
 170         char *beg_uof;
 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;
 174 };
 175 
 176 struct icp_qat_uclo_encap_uwblock {
 177         unsigned int start_addr;
 178         unsigned int words_num;
 179         uint64_t micro_words;
 180 };
 181 
 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;
 190 };
 191 
 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;
 202 };
 203 
 204 struct icp_qat_uclo_init_mem_table {
 205         unsigned int entry_num;
 206         struct icp_qat_uof_initmem *init_mem;
 207 };
 208 
 209 struct icp_qat_uclo_objhdr {
 210         char *file_buff;
 211         unsigned int checksum;
 212         unsigned int size;
 213 };
 214 
 215 struct icp_qat_uof_strtable {
 216         unsigned int table_len;
 217         unsigned int reserved;
 218         uint64_t strings;
 219 };
 220 
 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];
 232         int uimage_num;
 233         int uword_in_bytes;
 234         int global_inited;
 235         unsigned int ae_num;
 236         unsigned int ustore_phy_size;
 237         void *obj_buf;
 238         uint64_t *uword_buf;
 239 };
 240 
 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;
 246 };
 247 
 248 struct icp_qat_uof_filehdr {
 249         unsigned short file_id;
 250         unsigned short reserved1;
 251         char min_ver;
 252         char maj_ver;
 253         unsigned short reserved2;
 254         unsigned short max_chunks;
 255         unsigned short num_chunks;
 256 };
 257 
 258 struct icp_qat_uof_filechunkhdr {
 259         char chunk_id[ICP_QAT_UOF_OBJID_LEN];
 260         unsigned int checksum;
 261         unsigned int offset;
 262         unsigned int size;
 263 };
 264 
 265 struct icp_qat_uof_objhdr {
 266         unsigned int ac_dev_type;
 267         unsigned short min_cpu_ver;
 268         unsigned short max_cpu_ver;
 269         short max_chunks;
 270         short num_chunks;
 271         unsigned int reserved1;
 272         unsigned int reserved2;
 273 };
 274 
 275 struct icp_qat_uof_chunkhdr {
 276         char chunk_id[ICP_QAT_UOF_OBJID_LEN];
 277         unsigned int offset;
 278         unsigned int size;
 279 };
 280 
 281 struct icp_qat_uof_memvar_attr {
 282         unsigned int offset_in_byte;
 283         unsigned int value;
 284 };
 285 
 286 struct icp_qat_uof_initmem {
 287         unsigned int sym_name;
 288         char region;
 289         char scope;
 290         unsigned short reserved1;
 291         unsigned int addr;
 292         unsigned int num_in_bytes;
 293         unsigned int val_attr_num;
 294 };
 295 
 296 struct icp_qat_uof_init_regsym {
 297         unsigned int sym_name;
 298         char init_type;
 299         char value_type;
 300         char reg_type;
 301         unsigned char ctx;
 302         unsigned int reg_addr;
 303         unsigned int value;
 304 };
 305 
 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;
 319 };
 320 
 321 struct icp_qat_uof_gtid {
 322         char tool_id[ICP_QAT_UOF_OBJID_LEN];
 323         int tool_ver;
 324         unsigned int reserved1;
 325         unsigned int reserved2;
 326 };
 327 
 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;
 336 };
 337 
 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;
 351 };
 352 
 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;
 374 };
 375 
 376 struct icp_qat_uof_objtable {
 377         unsigned int entry_num;
 378 };
 379 
 380 struct icp_qat_uof_ae_reg {
 381         unsigned int name;
 382         unsigned int vis_name;
 383         unsigned short type;
 384         unsigned short addr;
 385         unsigned short access_mode;
 386         unsigned char visible;
 387         unsigned char reserved1;
 388         unsigned short ref_count;
 389         unsigned short reserved2;
 390         unsigned int xo_id;
 391 };
 392 
 393 struct icp_qat_uof_code_area {
 394         unsigned int micro_words_num;
 395         unsigned int uword_block_tab;
 396 };
 397 
 398 struct icp_qat_uof_batch_init {
 399         unsigned int ae;
 400         unsigned int addr;
 401         unsigned int *value;
 402         unsigned int size;
 403         struct icp_qat_uof_batch_init *next;
 404 };
 405 
 406 struct icp_qat_suof_img_hdr {
 407         char          *simg_buf;
 408         unsigned long simg_len;
 409         char          *css_header;
 410         char          *css_key;
 411         char          *css_signature;
 412         char          *css_simg;
 413         unsigned long simg_size;
 414         unsigned int  ae_num;
 415         unsigned int  ae_mask;
 416         unsigned int  fw_type;
 417         unsigned long simg_name;
 418         unsigned long appmeta_data;
 419 };
 420 
 421 struct icp_qat_suof_img_tbl {
 422         unsigned int num_simgs;
 423         struct icp_qat_suof_img_hdr *simg_hdr;
 424 };
 425 
 426 struct icp_qat_suof_handle {
 427         unsigned int  file_id;
 428         unsigned int  check_sum;
 429         char          min_ver;
 430         char          maj_ver;
 431         char          fw_type;
 432         char          *suof_buf;
 433         unsigned int  suof_size;
 434         char          *sym_str;
 435         unsigned int  sym_size;
 436         struct icp_qat_suof_img_tbl img_table;
 437 };
 438 
 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;
 456 };
 457 
 458 struct icp_qat_auth_chunk {
 459         struct icp_qat_fw_auth_desc fw_auth_desc;
 460         u64 chunk_size;
 461         u64 chunk_bus_addr;
 462 };
 463 
 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;
 470         unsigned int date;
 471         unsigned int size;
 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];
 477 };
 478 
 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;
 488         char             fw_type;
 489         char             ctx_mode;
 490         char             nn_mode;
 491         char             lm0_mode;
 492         char             lm1_mode;
 493         char             scs_mode;
 494         char             lm2_mode;
 495         char             lm3_mode;
 496         char             tindex_mode;
 497         unsigned char    reserved[7];
 498         char             simg_name[256];
 499         char             appmeta_data[256];
 500 };
 501 
 502 struct icp_qat_suof_filehdr {
 503         unsigned int     file_id;
 504         unsigned int     check_sum;
 505         char             min_ver;
 506         char             maj_ver;
 507         char             fw_type;
 508         char             reserved;
 509         unsigned short   max_chunks;
 510         unsigned short   num_chunks;
 511 };
 512 
 513 struct icp_qat_suof_chunk_hdr {
 514         char chunk_id[ICP_QAT_SUOF_OBJ_ID_LEN];
 515         u64 offset;
 516         u64 size;
 517 };
 518 
 519 struct icp_qat_suof_strtable {
 520         unsigned int tab_length;
 521         unsigned int strings;
 522 };
 523 
 524 struct icp_qat_suof_objhdr {
 525         unsigned int img_length;
 526         unsigned int reserved;
 527 };
 528 #endif

/* [<][>][^][v][top][bottom][index][help] */