kfd_pm4_headers.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. /*
  2. * Copyright 2014 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #ifndef KFD_PM4_HEADERS_H_
  24. #define KFD_PM4_HEADERS_H_
  25. #ifndef PM4_MES_HEADER_DEFINED
  26. #define PM4_MES_HEADER_DEFINED
  27. union PM4_MES_TYPE_3_HEADER {
  28. struct {
  29. uint32_t reserved1:8; /* < reserved */
  30. uint32_t opcode:8; /* < IT opcode */
  31. uint32_t count:14; /* < number of DWORDs - 1
  32. * in the information body.
  33. */
  34. uint32_t type:2; /* < packet identifier.
  35. * It should be 3 for type 3 packets
  36. */
  37. };
  38. uint32_t u32all;
  39. };
  40. #endif /* PM4_MES_HEADER_DEFINED */
  41. /* --------------------MES_SET_RESOURCES-------------------- */
  42. #ifndef PM4_MES_SET_RESOURCES_DEFINED
  43. #define PM4_MES_SET_RESOURCES_DEFINED
  44. enum set_resources_queue_type_enum {
  45. queue_type__mes_set_resources__kernel_interface_queue_kiq = 0,
  46. queue_type__mes_set_resources__hsa_interface_queue_hiq = 1,
  47. queue_type__mes_set_resources__hsa_debug_interface_queue = 4
  48. };
  49. struct pm4_set_resources {
  50. union {
  51. union PM4_MES_TYPE_3_HEADER header; /* header */
  52. uint32_t ordinal1;
  53. };
  54. union {
  55. struct {
  56. uint32_t vmid_mask:16;
  57. uint32_t unmap_latency:8;
  58. uint32_t reserved1:5;
  59. enum set_resources_queue_type_enum queue_type:3;
  60. } bitfields2;
  61. uint32_t ordinal2;
  62. };
  63. uint32_t queue_mask_lo;
  64. uint32_t queue_mask_hi;
  65. uint32_t gws_mask_lo;
  66. uint32_t gws_mask_hi;
  67. union {
  68. struct {
  69. uint32_t oac_mask:16;
  70. uint32_t reserved2:16;
  71. } bitfields7;
  72. uint32_t ordinal7;
  73. };
  74. union {
  75. struct {
  76. uint32_t gds_heap_base:6;
  77. uint32_t reserved3:5;
  78. uint32_t gds_heap_size:6;
  79. uint32_t reserved4:15;
  80. } bitfields8;
  81. uint32_t ordinal8;
  82. };
  83. };
  84. #endif
  85. /*--------------------MES_RUN_LIST-------------------- */
  86. #ifndef PM4_MES_RUN_LIST_DEFINED
  87. #define PM4_MES_RUN_LIST_DEFINED
  88. struct pm4_runlist {
  89. union {
  90. union PM4_MES_TYPE_3_HEADER header; /* header */
  91. uint32_t ordinal1;
  92. };
  93. union {
  94. struct {
  95. uint32_t reserved1:2;
  96. uint32_t ib_base_lo:30;
  97. } bitfields2;
  98. uint32_t ordinal2;
  99. };
  100. union {
  101. struct {
  102. uint32_t ib_base_hi:16;
  103. uint32_t reserved2:16;
  104. } bitfields3;
  105. uint32_t ordinal3;
  106. };
  107. union {
  108. struct {
  109. uint32_t ib_size:20;
  110. uint32_t chain:1;
  111. uint32_t offload_polling:1;
  112. uint32_t reserved3:1;
  113. uint32_t valid:1;
  114. uint32_t reserved4:8;
  115. } bitfields4;
  116. uint32_t ordinal4;
  117. };
  118. };
  119. #endif
  120. /*--------------------MES_MAP_PROCESS-------------------- */
  121. #ifndef PM4_MES_MAP_PROCESS_DEFINED
  122. #define PM4_MES_MAP_PROCESS_DEFINED
  123. struct pm4_map_process {
  124. union {
  125. union PM4_MES_TYPE_3_HEADER header; /* header */
  126. uint32_t ordinal1;
  127. };
  128. union {
  129. struct {
  130. uint32_t pasid:16;
  131. uint32_t reserved1:8;
  132. uint32_t diq_enable:1;
  133. uint32_t process_quantum:7;
  134. } bitfields2;
  135. uint32_t ordinal2;
  136. };
  137. union {
  138. struct {
  139. uint32_t page_table_base:28;
  140. uint32_t reserved3:4;
  141. } bitfields3;
  142. uint32_t ordinal3;
  143. };
  144. uint32_t sh_mem_bases;
  145. uint32_t sh_mem_ape1_base;
  146. uint32_t sh_mem_ape1_limit;
  147. uint32_t sh_mem_config;
  148. uint32_t gds_addr_lo;
  149. uint32_t gds_addr_hi;
  150. union {
  151. struct {
  152. uint32_t num_gws:6;
  153. uint32_t reserved4:2;
  154. uint32_t num_oac:4;
  155. uint32_t reserved5:4;
  156. uint32_t gds_size:6;
  157. uint32_t num_queues:10;
  158. } bitfields10;
  159. uint32_t ordinal10;
  160. };
  161. };
  162. #endif
  163. /*--------------------MES_MAP_QUEUES--------------------*/
  164. #ifndef PM4_MES_MAP_QUEUES_DEFINED
  165. #define PM4_MES_MAP_QUEUES_DEFINED
  166. enum map_queues_queue_sel_enum {
  167. queue_sel__mes_map_queues__map_to_specified_queue_slots = 0,
  168. queue_sel__mes_map_queues__map_to_hws_determined_queue_slots = 1,
  169. queue_sel__mes_map_queues__enable_process_queues = 2
  170. };
  171. enum map_queues_vidmem_enum {
  172. vidmem__mes_map_queues__uses_no_video_memory = 0,
  173. vidmem__mes_map_queues__uses_video_memory = 1
  174. };
  175. enum map_queues_alloc_format_enum {
  176. alloc_format__mes_map_queues__one_per_pipe = 0,
  177. alloc_format__mes_map_queues__all_on_one_pipe = 1
  178. };
  179. enum map_queues_engine_sel_enum {
  180. engine_sel__mes_map_queues__compute = 0,
  181. engine_sel__mes_map_queues__sdma0 = 2,
  182. engine_sel__mes_map_queues__sdma1 = 3
  183. };
  184. struct pm4_map_queues {
  185. union {
  186. union PM4_MES_TYPE_3_HEADER header; /* header */
  187. uint32_t ordinal1;
  188. };
  189. union {
  190. struct {
  191. uint32_t reserved1:4;
  192. enum map_queues_queue_sel_enum queue_sel:2;
  193. uint32_t reserved2:2;
  194. uint32_t vmid:4;
  195. uint32_t reserved3:4;
  196. enum map_queues_vidmem_enum vidmem:2;
  197. uint32_t reserved4:6;
  198. enum map_queues_alloc_format_enum alloc_format:2;
  199. enum map_queues_engine_sel_enum engine_sel:3;
  200. uint32_t num_queues:3;
  201. } bitfields2;
  202. uint32_t ordinal2;
  203. };
  204. struct {
  205. union {
  206. struct {
  207. uint32_t is_static:1;
  208. uint32_t reserved5:1;
  209. uint32_t doorbell_offset:21;
  210. uint32_t reserved6:3;
  211. uint32_t queue:6;
  212. } bitfields3;
  213. uint32_t ordinal3;
  214. };
  215. uint32_t mqd_addr_lo;
  216. uint32_t mqd_addr_hi;
  217. uint32_t wptr_addr_lo;
  218. uint32_t wptr_addr_hi;
  219. } mes_map_queues_ordinals[1]; /* 1..N of these ordinal groups */
  220. };
  221. #endif
  222. /*--------------------MES_QUERY_STATUS--------------------*/
  223. #ifndef PM4_MES_QUERY_STATUS_DEFINED
  224. #define PM4_MES_QUERY_STATUS_DEFINED
  225. enum query_status_interrupt_sel_enum {
  226. interrupt_sel__mes_query_status__completion_status = 0,
  227. interrupt_sel__mes_query_status__process_status = 1,
  228. interrupt_sel__mes_query_status__queue_status = 2
  229. };
  230. enum query_status_command_enum {
  231. command__mes_query_status__interrupt_only = 0,
  232. command__mes_query_status__fence_only_immediate = 1,
  233. command__mes_query_status__fence_only_after_write_ack = 2,
  234. command__mes_query_status__fence_wait_for_write_ack_send_interrupt = 3
  235. };
  236. enum query_status_engine_sel_enum {
  237. engine_sel__mes_query_status__compute = 0,
  238. engine_sel__mes_query_status__sdma0_queue = 2,
  239. engine_sel__mes_query_status__sdma1_queue = 3
  240. };
  241. struct pm4_query_status {
  242. union {
  243. union PM4_MES_TYPE_3_HEADER header; /* header */
  244. uint32_t ordinal1;
  245. };
  246. union {
  247. struct {
  248. uint32_t context_id:28;
  249. enum query_status_interrupt_sel_enum interrupt_sel:2;
  250. enum query_status_command_enum command:2;
  251. } bitfields2;
  252. uint32_t ordinal2;
  253. };
  254. union {
  255. struct {
  256. uint32_t pasid:16;
  257. uint32_t reserved1:16;
  258. } bitfields3a;
  259. struct {
  260. uint32_t reserved2:2;
  261. uint32_t doorbell_offset:21;
  262. uint32_t reserved3:3;
  263. enum query_status_engine_sel_enum engine_sel:3;
  264. uint32_t reserved4:3;
  265. } bitfields3b;
  266. uint32_t ordinal3;
  267. };
  268. uint32_t addr_lo;
  269. uint32_t addr_hi;
  270. uint32_t data_lo;
  271. uint32_t data_hi;
  272. };
  273. #endif
  274. /*--------------------MES_UNMAP_QUEUES--------------------*/
  275. #ifndef PM4_MES_UNMAP_QUEUES_DEFINED
  276. #define PM4_MES_UNMAP_QUEUES_DEFINED
  277. enum unmap_queues_action_enum {
  278. action__mes_unmap_queues__preempt_queues = 0,
  279. action__mes_unmap_queues__reset_queues = 1,
  280. action__mes_unmap_queues__disable_process_queues = 2
  281. };
  282. enum unmap_queues_queue_sel_enum {
  283. queue_sel__mes_unmap_queues__perform_request_on_specified_queues = 0,
  284. queue_sel__mes_unmap_queues__perform_request_on_pasid_queues = 1,
  285. queue_sel__mes_unmap_queues__perform_request_on_all_active_queues = 2,
  286. queue_sel__mes_unmap_queues__perform_request_on_dynamic_queues_only = 3
  287. };
  288. enum unmap_queues_engine_sel_enum {
  289. engine_sel__mes_unmap_queues__compute = 0,
  290. engine_sel__mes_unmap_queues__sdma0 = 2,
  291. engine_sel__mes_unmap_queues__sdma1 = 3
  292. };
  293. struct pm4_unmap_queues {
  294. union {
  295. union PM4_MES_TYPE_3_HEADER header; /* header */
  296. uint32_t ordinal1;
  297. };
  298. union {
  299. struct {
  300. enum unmap_queues_action_enum action:2;
  301. uint32_t reserved1:2;
  302. enum unmap_queues_queue_sel_enum queue_sel:2;
  303. uint32_t reserved2:20;
  304. enum unmap_queues_engine_sel_enum engine_sel:3;
  305. uint32_t num_queues:3;
  306. } bitfields2;
  307. uint32_t ordinal2;
  308. };
  309. union {
  310. struct {
  311. uint32_t pasid:16;
  312. uint32_t reserved3:16;
  313. } bitfields3a;
  314. struct {
  315. uint32_t reserved4:2;
  316. uint32_t doorbell_offset0:21;
  317. uint32_t reserved5:9;
  318. } bitfields3b;
  319. uint32_t ordinal3;
  320. };
  321. union {
  322. struct {
  323. uint32_t reserved6:2;
  324. uint32_t doorbell_offset1:21;
  325. uint32_t reserved7:9;
  326. } bitfields4;
  327. uint32_t ordinal4;
  328. };
  329. union {
  330. struct {
  331. uint32_t reserved8:2;
  332. uint32_t doorbell_offset2:21;
  333. uint32_t reserved9:9;
  334. } bitfields5;
  335. uint32_t ordinal5;
  336. };
  337. union {
  338. struct {
  339. uint32_t reserved10:2;
  340. uint32_t doorbell_offset3:21;
  341. uint32_t reserved11:9;
  342. } bitfields6;
  343. uint32_t ordinal6;
  344. };
  345. };
  346. #endif
  347. enum {
  348. CACHE_FLUSH_AND_INV_TS_EVENT = 0x00000014
  349. };
  350. #endif /* KFD_PM4_HEADERS_H_ */