icp_qat_uclo.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. GPL LICENSE SUMMARY
  5. Copyright(c) 2014 Intel Corporation.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License as
  8. published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. Contact Information:
  14. qat-linux@intel.com
  15. BSD LICENSE
  16. Copyright(c) 2014 Intel Corporation.
  17. Redistribution and use in source and binary forms, with or without
  18. modification, are permitted provided that the following conditions
  19. are met:
  20. * Redistributions of source code must retain the above copyright
  21. notice, this list of conditions and the following disclaimer.
  22. * Redistributions in binary form must reproduce the above copyright
  23. notice, this list of conditions and the following disclaimer in
  24. the documentation and/or other materials provided with the
  25. distribution.
  26. * Neither the name of Intel Corporation nor the names of its
  27. contributors may be used to endorse or promote products derived
  28. from this software without specific prior written permission.
  29. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. */
  41. #ifndef __ICP_QAT_UCLO_H__
  42. #define __ICP_QAT_UCLO_H__
  43. #define ICP_QAT_AC_C_CPU_TYPE 0x00400000
  44. #define ICP_QAT_UCLO_MAX_AE 12
  45. #define ICP_QAT_UCLO_MAX_CTX 8
  46. #define ICP_QAT_UCLO_MAX_UIMAGE (ICP_QAT_UCLO_MAX_AE * ICP_QAT_UCLO_MAX_CTX)
  47. #define ICP_QAT_UCLO_MAX_USTORE 0x4000
  48. #define ICP_QAT_UCLO_MAX_XFER_REG 128
  49. #define ICP_QAT_UCLO_MAX_GPR_REG 128
  50. #define ICP_QAT_UCLO_MAX_NN_REG 128
  51. #define ICP_QAT_UCLO_MAX_LMEM_REG 1024
  52. #define ICP_QAT_UCLO_AE_ALL_CTX 0xff
  53. #define ICP_QAT_UOF_OBJID_LEN 8
  54. #define ICP_QAT_UOF_FID 0xc6c2
  55. #define ICP_QAT_UOF_MAJVER 0x4
  56. #define ICP_QAT_UOF_MINVER 0x11
  57. #define ICP_QAT_UOF_NN_MODE_NOTCARE 0xff
  58. #define ICP_QAT_UOF_OBJS "UOF_OBJS"
  59. #define ICP_QAT_UOF_STRT "UOF_STRT"
  60. #define ICP_QAT_UOF_GTID "UOF_GTID"
  61. #define ICP_QAT_UOF_IMAG "UOF_IMAG"
  62. #define ICP_QAT_UOF_IMEM "UOF_IMEM"
  63. #define ICP_QAT_UOF_MSEG "UOF_MSEG"
  64. #define ICP_QAT_UOF_LOCAL_SCOPE 1
  65. #define ICP_QAT_UOF_INIT_EXPR 0
  66. #define ICP_QAT_UOF_INIT_REG 1
  67. #define ICP_QAT_UOF_INIT_REG_CTX 2
  68. #define ICP_QAT_UOF_INIT_EXPR_ENDIAN_SWAP 3
  69. #define ICP_QAT_CTX_MODE(ae_mode) ((ae_mode) & 0xf)
  70. #define ICP_QAT_NN_MODE(ae_mode) (((ae_mode) >> 0x4) & 0xf)
  71. #define ICP_QAT_SHARED_USTORE_MODE(ae_mode) (((ae_mode) >> 0xb) & 0x1)
  72. #define RELOADABLE_CTX_SHARED_MODE(ae_mode) (((ae_mode) >> 0xc) & 0x1)
  73. #define ICP_QAT_LOC_MEM0_MODE(ae_mode) (((ae_mode) >> 0x8) & 0x1)
  74. #define ICP_QAT_LOC_MEM1_MODE(ae_mode) (((ae_mode) >> 0x9) & 0x1)
  75. enum icp_qat_uof_mem_region {
  76. ICP_QAT_UOF_SRAM_REGION = 0x0,
  77. ICP_QAT_UOF_LMEM_REGION = 0x3,
  78. ICP_QAT_UOF_UMEM_REGION = 0x5
  79. };
  80. enum icp_qat_uof_regtype {
  81. ICP_NO_DEST,
  82. ICP_GPA_REL,
  83. ICP_GPA_ABS,
  84. ICP_GPB_REL,
  85. ICP_GPB_ABS,
  86. ICP_SR_REL,
  87. ICP_SR_RD_REL,
  88. ICP_SR_WR_REL,
  89. ICP_SR_ABS,
  90. ICP_SR_RD_ABS,
  91. ICP_SR_WR_ABS,
  92. ICP_DR_REL,
  93. ICP_DR_RD_REL,
  94. ICP_DR_WR_REL,
  95. ICP_DR_ABS,
  96. ICP_DR_RD_ABS,
  97. ICP_DR_WR_ABS,
  98. ICP_LMEM,
  99. ICP_LMEM0,
  100. ICP_LMEM1,
  101. ICP_NEIGH_REL,
  102. };
  103. struct icp_qat_uclo_page {
  104. struct icp_qat_uclo_encap_page *encap_page;
  105. struct icp_qat_uclo_region *region;
  106. unsigned int flags;
  107. };
  108. struct icp_qat_uclo_region {
  109. struct icp_qat_uclo_page *loaded;
  110. struct icp_qat_uclo_page *page;
  111. };
  112. struct icp_qat_uclo_aeslice {
  113. struct icp_qat_uclo_region *region;
  114. struct icp_qat_uclo_page *page;
  115. struct icp_qat_uclo_page *cur_page[ICP_QAT_UCLO_MAX_CTX];
  116. struct icp_qat_uclo_encapme *encap_image;
  117. unsigned int ctx_mask_assigned;
  118. unsigned int new_uaddr[ICP_QAT_UCLO_MAX_CTX];
  119. };
  120. struct icp_qat_uclo_aedata {
  121. unsigned int slice_num;
  122. unsigned int eff_ustore_size;
  123. struct icp_qat_uclo_aeslice ae_slices[ICP_QAT_UCLO_MAX_CTX];
  124. };
  125. struct icp_qat_uof_encap_obj {
  126. char *beg_uof;
  127. struct icp_qat_uof_objhdr *obj_hdr;
  128. struct icp_qat_uof_chunkhdr *chunk_hdr;
  129. struct icp_qat_uof_varmem_seg *var_mem_seg;
  130. };
  131. struct icp_qat_uclo_encap_uwblock {
  132. unsigned int start_addr;
  133. unsigned int words_num;
  134. uint64_t micro_words;
  135. };
  136. struct icp_qat_uclo_encap_page {
  137. unsigned int def_page;
  138. unsigned int page_region;
  139. unsigned int beg_addr_v;
  140. unsigned int beg_addr_p;
  141. unsigned int micro_words_num;
  142. unsigned int uwblock_num;
  143. struct icp_qat_uclo_encap_uwblock *uwblock;
  144. };
  145. struct icp_qat_uclo_encapme {
  146. struct icp_qat_uof_image *img_ptr;
  147. struct icp_qat_uclo_encap_page *page;
  148. unsigned int ae_reg_num;
  149. struct icp_qat_uof_ae_reg *ae_reg;
  150. unsigned int init_regsym_num;
  151. struct icp_qat_uof_init_regsym *init_regsym;
  152. unsigned int sbreak_num;
  153. struct icp_qat_uof_sbreak *sbreak;
  154. unsigned int uwords_num;
  155. };
  156. struct icp_qat_uclo_init_mem_table {
  157. unsigned int entry_num;
  158. struct icp_qat_uof_initmem *init_mem;
  159. };
  160. struct icp_qat_uclo_objhdr {
  161. char *file_buff;
  162. unsigned int checksum;
  163. unsigned int size;
  164. };
  165. struct icp_qat_uof_strtable {
  166. unsigned int table_len;
  167. unsigned int reserved;
  168. uint64_t strings;
  169. };
  170. struct icp_qat_uclo_objhandle {
  171. unsigned int prod_type;
  172. unsigned int prod_rev;
  173. struct icp_qat_uclo_objhdr *obj_hdr;
  174. struct icp_qat_uof_encap_obj encap_uof_obj;
  175. struct icp_qat_uof_strtable str_table;
  176. struct icp_qat_uclo_encapme ae_uimage[ICP_QAT_UCLO_MAX_UIMAGE];
  177. struct icp_qat_uclo_aedata ae_data[ICP_QAT_UCLO_MAX_AE];
  178. struct icp_qat_uclo_init_mem_table init_mem_tab;
  179. struct icp_qat_uof_batch_init *lm_init_tab[ICP_QAT_UCLO_MAX_AE];
  180. struct icp_qat_uof_batch_init *umem_init_tab[ICP_QAT_UCLO_MAX_AE];
  181. int uimage_num;
  182. int uword_in_bytes;
  183. int global_inited;
  184. unsigned int ae_num;
  185. unsigned int ustore_phy_size;
  186. void *obj_buf;
  187. uint64_t *uword_buf;
  188. };
  189. struct icp_qat_uof_uword_block {
  190. unsigned int start_addr;
  191. unsigned int words_num;
  192. unsigned int uword_offset;
  193. unsigned int reserved;
  194. };
  195. struct icp_qat_uof_filehdr {
  196. unsigned short file_id;
  197. unsigned short reserved1;
  198. char min_ver;
  199. char maj_ver;
  200. unsigned short reserved2;
  201. unsigned short max_chunks;
  202. unsigned short num_chunks;
  203. };
  204. struct icp_qat_uof_filechunkhdr {
  205. char chunk_id[ICP_QAT_UOF_OBJID_LEN];
  206. unsigned int checksum;
  207. unsigned int offset;
  208. unsigned int size;
  209. };
  210. struct icp_qat_uof_objhdr {
  211. unsigned int cpu_type;
  212. unsigned short min_cpu_ver;
  213. unsigned short max_cpu_ver;
  214. short max_chunks;
  215. short num_chunks;
  216. unsigned int reserved1;
  217. unsigned int reserved2;
  218. };
  219. struct icp_qat_uof_chunkhdr {
  220. char chunk_id[ICP_QAT_UOF_OBJID_LEN];
  221. unsigned int offset;
  222. unsigned int size;
  223. };
  224. struct icp_qat_uof_memvar_attr {
  225. unsigned int offset_in_byte;
  226. unsigned int value;
  227. };
  228. struct icp_qat_uof_initmem {
  229. unsigned int sym_name;
  230. char region;
  231. char scope;
  232. unsigned short reserved1;
  233. unsigned int addr;
  234. unsigned int num_in_bytes;
  235. unsigned int val_attr_num;
  236. };
  237. struct icp_qat_uof_init_regsym {
  238. unsigned int sym_name;
  239. char init_type;
  240. char value_type;
  241. char reg_type;
  242. unsigned char ctx;
  243. unsigned int reg_addr;
  244. unsigned int value;
  245. };
  246. struct icp_qat_uof_varmem_seg {
  247. unsigned int sram_base;
  248. unsigned int sram_size;
  249. unsigned int sram_alignment;
  250. unsigned int sdram_base;
  251. unsigned int sdram_size;
  252. unsigned int sdram_alignment;
  253. unsigned int sdram1_base;
  254. unsigned int sdram1_size;
  255. unsigned int sdram1_alignment;
  256. unsigned int scratch_base;
  257. unsigned int scratch_size;
  258. unsigned int scratch_alignment;
  259. };
  260. struct icp_qat_uof_gtid {
  261. char tool_id[ICP_QAT_UOF_OBJID_LEN];
  262. int tool_ver;
  263. unsigned int reserved1;
  264. unsigned int reserved2;
  265. };
  266. struct icp_qat_uof_sbreak {
  267. unsigned int page_num;
  268. unsigned int virt_uaddr;
  269. unsigned char sbreak_type;
  270. unsigned char reg_type;
  271. unsigned short reserved1;
  272. unsigned int addr_offset;
  273. unsigned int reg_addr;
  274. };
  275. struct icp_qat_uof_code_page {
  276. unsigned int page_region;
  277. unsigned int page_num;
  278. unsigned char def_page;
  279. unsigned char reserved2;
  280. unsigned short reserved1;
  281. unsigned int beg_addr_v;
  282. unsigned int beg_addr_p;
  283. unsigned int neigh_reg_tab_offset;
  284. unsigned int uc_var_tab_offset;
  285. unsigned int imp_var_tab_offset;
  286. unsigned int imp_expr_tab_offset;
  287. unsigned int code_area_offset;
  288. };
  289. struct icp_qat_uof_image {
  290. unsigned int img_name;
  291. unsigned int ae_assigned;
  292. unsigned int ctx_assigned;
  293. unsigned int cpu_type;
  294. unsigned int entry_address;
  295. unsigned int fill_pattern[2];
  296. unsigned int reloadable_size;
  297. unsigned char sensitivity;
  298. unsigned char reserved;
  299. unsigned short ae_mode;
  300. unsigned short max_ver;
  301. unsigned short min_ver;
  302. unsigned short image_attrib;
  303. unsigned short reserved2;
  304. unsigned short page_region_num;
  305. unsigned short numpages;
  306. unsigned int reg_tab_offset;
  307. unsigned int init_reg_sym_tab;
  308. unsigned int sbreak_tab;
  309. unsigned int app_metadata;
  310. };
  311. struct icp_qat_uof_objtable {
  312. unsigned int entry_num;
  313. };
  314. struct icp_qat_uof_ae_reg {
  315. unsigned int name;
  316. unsigned int vis_name;
  317. unsigned short type;
  318. unsigned short addr;
  319. unsigned short access_mode;
  320. unsigned char visible;
  321. unsigned char reserved1;
  322. unsigned short ref_count;
  323. unsigned short reserved2;
  324. unsigned int xo_id;
  325. };
  326. struct icp_qat_uof_code_area {
  327. unsigned int micro_words_num;
  328. unsigned int uword_block_tab;
  329. };
  330. struct icp_qat_uof_batch_init {
  331. unsigned int ae;
  332. unsigned int addr;
  333. unsigned int *value;
  334. unsigned int size;
  335. struct icp_qat_uof_batch_init *next;
  336. };
  337. #endif