kfd_crat.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. #ifndef KFD_CRAT_H_INCLUDED
  23. #define KFD_CRAT_H_INCLUDED
  24. #include <linux/types.h>
  25. #pragma pack(1)
  26. /*
  27. * 4CC signature values for the CRAT and CDIT ACPI tables
  28. */
  29. #define CRAT_SIGNATURE "CRAT"
  30. #define CDIT_SIGNATURE "CDIT"
  31. /*
  32. * Component Resource Association Table (CRAT)
  33. */
  34. #define CRAT_OEMID_LENGTH 6
  35. #define CRAT_OEMTABLEID_LENGTH 8
  36. #define CRAT_RESERVED_LENGTH 6
  37. #define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1)
  38. struct crat_header {
  39. uint32_t signature;
  40. uint32_t length;
  41. uint8_t revision;
  42. uint8_t checksum;
  43. uint8_t oem_id[CRAT_OEMID_LENGTH];
  44. uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];
  45. uint32_t oem_revision;
  46. uint32_t creator_id;
  47. uint32_t creator_revision;
  48. uint32_t total_entries;
  49. uint16_t num_domains;
  50. uint8_t reserved[CRAT_RESERVED_LENGTH];
  51. };
  52. /*
  53. * The header structure is immediately followed by total_entries of the
  54. * data definitions
  55. */
  56. /*
  57. * The currently defined subtype entries in the CRAT
  58. */
  59. #define CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY 0
  60. #define CRAT_SUBTYPE_MEMORY_AFFINITY 1
  61. #define CRAT_SUBTYPE_CACHE_AFFINITY 2
  62. #define CRAT_SUBTYPE_TLB_AFFINITY 3
  63. #define CRAT_SUBTYPE_CCOMPUTE_AFFINITY 4
  64. #define CRAT_SUBTYPE_IOLINK_AFFINITY 5
  65. #define CRAT_SUBTYPE_MAX 6
  66. #define CRAT_SIBLINGMAP_SIZE 32
  67. /*
  68. * ComputeUnit Affinity structure and definitions
  69. */
  70. #define CRAT_CU_FLAGS_ENABLED 0x00000001
  71. #define CRAT_CU_FLAGS_HOT_PLUGGABLE 0x00000002
  72. #define CRAT_CU_FLAGS_CPU_PRESENT 0x00000004
  73. #define CRAT_CU_FLAGS_GPU_PRESENT 0x00000008
  74. #define CRAT_CU_FLAGS_IOMMU_PRESENT 0x00000010
  75. #define CRAT_CU_FLAGS_RESERVED 0xffffffe0
  76. #define CRAT_COMPUTEUNIT_RESERVED_LENGTH 4
  77. struct crat_subtype_computeunit {
  78. uint8_t type;
  79. uint8_t length;
  80. uint16_t reserved;
  81. uint32_t flags;
  82. uint32_t proximity_domain;
  83. uint32_t processor_id_low;
  84. uint16_t num_cpu_cores;
  85. uint16_t num_simd_cores;
  86. uint16_t max_waves_simd;
  87. uint16_t io_count;
  88. uint16_t hsa_capability;
  89. uint16_t lds_size_in_kb;
  90. uint8_t wave_front_size;
  91. uint8_t num_banks;
  92. uint16_t micro_engine_id;
  93. uint8_t num_arrays;
  94. uint8_t num_cu_per_array;
  95. uint8_t num_simd_per_cu;
  96. uint8_t max_slots_scatch_cu;
  97. uint8_t reserved2[CRAT_COMPUTEUNIT_RESERVED_LENGTH];
  98. };
  99. /*
  100. * HSA Memory Affinity structure and definitions
  101. */
  102. #define CRAT_MEM_FLAGS_ENABLED 0x00000001
  103. #define CRAT_MEM_FLAGS_HOT_PLUGGABLE 0x00000002
  104. #define CRAT_MEM_FLAGS_NON_VOLATILE 0x00000004
  105. #define CRAT_MEM_FLAGS_RESERVED 0xfffffff8
  106. #define CRAT_MEMORY_RESERVED_LENGTH 8
  107. struct crat_subtype_memory {
  108. uint8_t type;
  109. uint8_t length;
  110. uint16_t reserved;
  111. uint32_t flags;
  112. uint32_t promixity_domain;
  113. uint32_t base_addr_low;
  114. uint32_t base_addr_high;
  115. uint32_t length_low;
  116. uint32_t length_high;
  117. uint32_t width;
  118. uint8_t reserved2[CRAT_MEMORY_RESERVED_LENGTH];
  119. };
  120. /*
  121. * HSA Cache Affinity structure and definitions
  122. */
  123. #define CRAT_CACHE_FLAGS_ENABLED 0x00000001
  124. #define CRAT_CACHE_FLAGS_DATA_CACHE 0x00000002
  125. #define CRAT_CACHE_FLAGS_INST_CACHE 0x00000004
  126. #define CRAT_CACHE_FLAGS_CPU_CACHE 0x00000008
  127. #define CRAT_CACHE_FLAGS_SIMD_CACHE 0x00000010
  128. #define CRAT_CACHE_FLAGS_RESERVED 0xffffffe0
  129. #define CRAT_CACHE_RESERVED_LENGTH 8
  130. struct crat_subtype_cache {
  131. uint8_t type;
  132. uint8_t length;
  133. uint16_t reserved;
  134. uint32_t flags;
  135. uint32_t processor_id_low;
  136. uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
  137. uint32_t cache_size;
  138. uint8_t cache_level;
  139. uint8_t lines_per_tag;
  140. uint16_t cache_line_size;
  141. uint8_t associativity;
  142. uint8_t cache_properties;
  143. uint16_t cache_latency;
  144. uint8_t reserved2[CRAT_CACHE_RESERVED_LENGTH];
  145. };
  146. /*
  147. * HSA TLB Affinity structure and definitions
  148. */
  149. #define CRAT_TLB_FLAGS_ENABLED 0x00000001
  150. #define CRAT_TLB_FLAGS_DATA_TLB 0x00000002
  151. #define CRAT_TLB_FLAGS_INST_TLB 0x00000004
  152. #define CRAT_TLB_FLAGS_CPU_TLB 0x00000008
  153. #define CRAT_TLB_FLAGS_SIMD_TLB 0x00000010
  154. #define CRAT_TLB_FLAGS_RESERVED 0xffffffe0
  155. #define CRAT_TLB_RESERVED_LENGTH 4
  156. struct crat_subtype_tlb {
  157. uint8_t type;
  158. uint8_t length;
  159. uint16_t reserved;
  160. uint32_t flags;
  161. uint32_t processor_id_low;
  162. uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
  163. uint32_t tlb_level;
  164. uint8_t data_tlb_associativity_2mb;
  165. uint8_t data_tlb_size_2mb;
  166. uint8_t instruction_tlb_associativity_2mb;
  167. uint8_t instruction_tlb_size_2mb;
  168. uint8_t data_tlb_associativity_4k;
  169. uint8_t data_tlb_size_4k;
  170. uint8_t instruction_tlb_associativity_4k;
  171. uint8_t instruction_tlb_size_4k;
  172. uint8_t data_tlb_associativity_1gb;
  173. uint8_t data_tlb_size_1gb;
  174. uint8_t instruction_tlb_associativity_1gb;
  175. uint8_t instruction_tlb_size_1gb;
  176. uint8_t reserved2[CRAT_TLB_RESERVED_LENGTH];
  177. };
  178. /*
  179. * HSA CCompute/APU Affinity structure and definitions
  180. */
  181. #define CRAT_CCOMPUTE_FLAGS_ENABLED 0x00000001
  182. #define CRAT_CCOMPUTE_FLAGS_RESERVED 0xfffffffe
  183. #define CRAT_CCOMPUTE_RESERVED_LENGTH 16
  184. struct crat_subtype_ccompute {
  185. uint8_t type;
  186. uint8_t length;
  187. uint16_t reserved;
  188. uint32_t flags;
  189. uint32_t processor_id_low;
  190. uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
  191. uint32_t apu_size;
  192. uint8_t reserved2[CRAT_CCOMPUTE_RESERVED_LENGTH];
  193. };
  194. /*
  195. * HSA IO Link Affinity structure and definitions
  196. */
  197. #define CRAT_IOLINK_FLAGS_ENABLED 0x00000001
  198. #define CRAT_IOLINK_FLAGS_COHERENCY 0x00000002
  199. #define CRAT_IOLINK_FLAGS_RESERVED 0xfffffffc
  200. /*
  201. * IO interface types
  202. */
  203. #define CRAT_IOLINK_TYPE_UNDEFINED 0
  204. #define CRAT_IOLINK_TYPE_HYPERTRANSPORT 1
  205. #define CRAT_IOLINK_TYPE_PCIEXPRESS 2
  206. #define CRAT_IOLINK_TYPE_OTHER 3
  207. #define CRAT_IOLINK_TYPE_MAX 255
  208. #define CRAT_IOLINK_RESERVED_LENGTH 24
  209. struct crat_subtype_iolink {
  210. uint8_t type;
  211. uint8_t length;
  212. uint16_t reserved;
  213. uint32_t flags;
  214. uint32_t proximity_domain_from;
  215. uint32_t proximity_domain_to;
  216. uint8_t io_interface_type;
  217. uint8_t version_major;
  218. uint16_t version_minor;
  219. uint32_t minimum_latency;
  220. uint32_t maximum_latency;
  221. uint32_t minimum_bandwidth_mbs;
  222. uint32_t maximum_bandwidth_mbs;
  223. uint32_t recommended_transfer_size;
  224. uint8_t reserved2[CRAT_IOLINK_RESERVED_LENGTH];
  225. };
  226. /*
  227. * HSA generic sub-type header
  228. */
  229. #define CRAT_SUBTYPE_FLAGS_ENABLED 0x00000001
  230. struct crat_subtype_generic {
  231. uint8_t type;
  232. uint8_t length;
  233. uint16_t reserved;
  234. uint32_t flags;
  235. };
  236. /*
  237. * Component Locality Distance Information Table (CDIT)
  238. */
  239. #define CDIT_OEMID_LENGTH 6
  240. #define CDIT_OEMTABLEID_LENGTH 8
  241. struct cdit_header {
  242. uint32_t signature;
  243. uint32_t length;
  244. uint8_t revision;
  245. uint8_t checksum;
  246. uint8_t oem_id[CDIT_OEMID_LENGTH];
  247. uint8_t oem_table_id[CDIT_OEMTABLEID_LENGTH];
  248. uint32_t oem_revision;
  249. uint32_t creator_id;
  250. uint32_t creator_revision;
  251. uint32_t total_entries;
  252. uint16_t num_domains;
  253. uint8_t entry[1];
  254. };
  255. #pragma pack()
  256. #endif /* KFD_CRAT_H_INCLUDED */