kfd_pm4_headers.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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 reserved5:2;
  208. uint32_t doorbell_offset:21;
  209. uint32_t reserved6:3;
  210. uint32_t queue:6;
  211. } bitfields3;
  212. uint32_t ordinal3;
  213. };
  214. uint32_t mqd_addr_lo;
  215. uint32_t mqd_addr_hi;
  216. uint32_t wptr_addr_lo;
  217. uint32_t wptr_addr_hi;
  218. } mes_map_queues_ordinals[1]; /* 1..N of these ordinal groups */
  219. };
  220. #endif
  221. /*--------------------MES_QUERY_STATUS--------------------*/
  222. #ifndef PM4_MES_QUERY_STATUS_DEFINED
  223. #define PM4_MES_QUERY_STATUS_DEFINED
  224. enum query_status_interrupt_sel_enum {
  225. interrupt_sel__mes_query_status__completion_status = 0,
  226. interrupt_sel__mes_query_status__process_status = 1,
  227. interrupt_sel__mes_query_status__queue_status = 2
  228. };
  229. enum query_status_command_enum {
  230. command__mes_query_status__interrupt_only = 0,
  231. command__mes_query_status__fence_only_immediate = 1,
  232. command__mes_query_status__fence_only_after_write_ack = 2,
  233. command__mes_query_status__fence_wait_for_write_ack_send_interrupt = 3
  234. };
  235. enum query_status_engine_sel_enum {
  236. engine_sel__mes_query_status__compute = 0,
  237. engine_sel__mes_query_status__sdma0_queue = 2,
  238. engine_sel__mes_query_status__sdma1_queue = 3
  239. };
  240. struct pm4_query_status {
  241. union {
  242. union PM4_MES_TYPE_3_HEADER header; /* header */
  243. uint32_t ordinal1;
  244. };
  245. union {
  246. struct {
  247. uint32_t context_id:28;
  248. enum query_status_interrupt_sel_enum interrupt_sel:2;
  249. enum query_status_command_enum command:2;
  250. } bitfields2;
  251. uint32_t ordinal2;
  252. };
  253. union {
  254. struct {
  255. uint32_t pasid:16;
  256. uint32_t reserved1:16;
  257. } bitfields3a;
  258. struct {
  259. uint32_t reserved2:2;
  260. uint32_t doorbell_offset:21;
  261. uint32_t reserved3:3;
  262. enum query_status_engine_sel_enum engine_sel:3;
  263. uint32_t reserved4:3;
  264. } bitfields3b;
  265. uint32_t ordinal3;
  266. };
  267. uint32_t addr_lo;
  268. uint32_t addr_hi;
  269. uint32_t data_lo;
  270. uint32_t data_hi;
  271. };
  272. #endif
  273. /*--------------------MES_UNMAP_QUEUES--------------------*/
  274. #ifndef PM4_MES_UNMAP_QUEUES_DEFINED
  275. #define PM4_MES_UNMAP_QUEUES_DEFINED
  276. enum unmap_queues_action_enum {
  277. action__mes_unmap_queues__preempt_queues = 0,
  278. action__mes_unmap_queues__reset_queues = 1,
  279. action__mes_unmap_queues__disable_process_queues = 2
  280. };
  281. enum unmap_queues_queue_sel_enum {
  282. queue_sel__mes_unmap_queues__perform_request_on_specified_queues = 0,
  283. queue_sel__mes_unmap_queues__perform_request_on_pasid_queues = 1,
  284. queue_sel__mes_unmap_queues__perform_request_on_all_active_queues = 2
  285. };
  286. enum unmap_queues_engine_sel_enum {
  287. engine_sel__mes_unmap_queues__compute = 0,
  288. engine_sel__mes_unmap_queues__sdma0 = 2,
  289. engine_sel__mes_unmap_queues__sdma1 = 3
  290. };
  291. struct pm4_unmap_queues {
  292. union {
  293. union PM4_MES_TYPE_3_HEADER header; /* header */
  294. uint32_t ordinal1;
  295. };
  296. union {
  297. struct {
  298. enum unmap_queues_action_enum action:2;
  299. uint32_t reserved1:2;
  300. enum unmap_queues_queue_sel_enum queue_sel:2;
  301. uint32_t reserved2:20;
  302. enum unmap_queues_engine_sel_enum engine_sel:3;
  303. uint32_t num_queues:3;
  304. } bitfields2;
  305. uint32_t ordinal2;
  306. };
  307. union {
  308. struct {
  309. uint32_t pasid:16;
  310. uint32_t reserved3:16;
  311. } bitfields3a;
  312. struct {
  313. uint32_t reserved4:2;
  314. uint32_t doorbell_offset0:21;
  315. uint32_t reserved5:9;
  316. } bitfields3b;
  317. uint32_t ordinal3;
  318. };
  319. union {
  320. struct {
  321. uint32_t reserved6:2;
  322. uint32_t doorbell_offset1:21;
  323. uint32_t reserved7:9;
  324. } bitfields4;
  325. uint32_t ordinal4;
  326. };
  327. union {
  328. struct {
  329. uint32_t reserved8:2;
  330. uint32_t doorbell_offset2:21;
  331. uint32_t reserved9:9;
  332. } bitfields5;
  333. uint32_t ordinal5;
  334. };
  335. union {
  336. struct {
  337. uint32_t reserved10:2;
  338. uint32_t doorbell_offset3:21;
  339. uint32_t reserved11:9;
  340. } bitfields6;
  341. uint32_t ordinal6;
  342. };
  343. };
  344. #endif
  345. enum {
  346. CACHE_FLUSH_AND_INV_TS_EVENT = 0x00000014
  347. };
  348. #endif /* KFD_PM4_HEADERS_H_ */