xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/amdkfd/kfd_crat.h (revision 33881f779a77dce6440bdc44610d94de75bebefe)
1 /*	$NetBSD: kfd_crat.h,v 1.2 2018/08/27 04:58:20 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2014 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KFD_CRAT_H_INCLUDED
26 #define KFD_CRAT_H_INCLUDED
27 
28 #include <linux/types.h>
29 
30 #pragma pack(1)
31 
32 /*
33  * 4CC signature values for the CRAT and CDIT ACPI tables
34  */
35 
36 #define CRAT_SIGNATURE	"CRAT"
37 #define CDIT_SIGNATURE	"CDIT"
38 
39 /*
40  * Component Resource Association Table (CRAT)
41  */
42 
43 #define CRAT_OEMID_LENGTH	6
44 #define CRAT_OEMTABLEID_LENGTH	8
45 #define CRAT_RESERVED_LENGTH	6
46 
47 #define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1)
48 
49 struct crat_header {
50 	uint32_t	signature;
51 	uint32_t	length;
52 	uint8_t		revision;
53 	uint8_t		checksum;
54 	uint8_t		oem_id[CRAT_OEMID_LENGTH];
55 	uint8_t		oem_table_id[CRAT_OEMTABLEID_LENGTH];
56 	uint32_t	oem_revision;
57 	uint32_t	creator_id;
58 	uint32_t	creator_revision;
59 	uint32_t	total_entries;
60 	uint16_t	num_domains;
61 	uint8_t		reserved[CRAT_RESERVED_LENGTH];
62 };
63 
64 /*
65  * The header structure is immediately followed by total_entries of the
66  * data definitions
67  */
68 
69 /*
70  * The currently defined subtype entries in the CRAT
71  */
72 #define CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY	0
73 #define CRAT_SUBTYPE_MEMORY_AFFINITY		1
74 #define CRAT_SUBTYPE_CACHE_AFFINITY		2
75 #define CRAT_SUBTYPE_TLB_AFFINITY		3
76 #define CRAT_SUBTYPE_CCOMPUTE_AFFINITY		4
77 #define CRAT_SUBTYPE_IOLINK_AFFINITY		5
78 #define CRAT_SUBTYPE_MAX			6
79 
80 #define CRAT_SIBLINGMAP_SIZE	32
81 
82 /*
83  * ComputeUnit Affinity structure and definitions
84  */
85 #define CRAT_CU_FLAGS_ENABLED		0x00000001
86 #define CRAT_CU_FLAGS_HOT_PLUGGABLE	0x00000002
87 #define CRAT_CU_FLAGS_CPU_PRESENT	0x00000004
88 #define CRAT_CU_FLAGS_GPU_PRESENT	0x00000008
89 #define CRAT_CU_FLAGS_IOMMU_PRESENT	0x00000010
90 #define CRAT_CU_FLAGS_RESERVED		0xffffffe0
91 
92 #define CRAT_COMPUTEUNIT_RESERVED_LENGTH 4
93 
94 struct crat_subtype_computeunit {
95 	uint8_t		type;
96 	uint8_t		length;
97 	uint16_t	reserved;
98 	uint32_t	flags;
99 	uint32_t	proximity_domain;
100 	uint32_t	processor_id_low;
101 	uint16_t	num_cpu_cores;
102 	uint16_t	num_simd_cores;
103 	uint16_t	max_waves_simd;
104 	uint16_t	io_count;
105 	uint16_t	hsa_capability;
106 	uint16_t	lds_size_in_kb;
107 	uint8_t		wave_front_size;
108 	uint8_t		num_banks;
109 	uint16_t	micro_engine_id;
110 	uint8_t		num_arrays;
111 	uint8_t		num_cu_per_array;
112 	uint8_t		num_simd_per_cu;
113 	uint8_t		max_slots_scatch_cu;
114 	uint8_t		reserved2[CRAT_COMPUTEUNIT_RESERVED_LENGTH];
115 };
116 
117 /*
118  * HSA Memory Affinity structure and definitions
119  */
120 #define CRAT_MEM_FLAGS_ENABLED		0x00000001
121 #define CRAT_MEM_FLAGS_HOT_PLUGGABLE	0x00000002
122 #define CRAT_MEM_FLAGS_NON_VOLATILE	0x00000004
123 #define CRAT_MEM_FLAGS_RESERVED		0xfffffff8
124 
125 #define CRAT_MEMORY_RESERVED_LENGTH 8
126 
127 struct crat_subtype_memory {
128 	uint8_t		type;
129 	uint8_t		length;
130 	uint16_t	reserved;
131 	uint32_t	flags;
132 	uint32_t	promixity_domain;
133 	uint32_t	base_addr_low;
134 	uint32_t	base_addr_high;
135 	uint32_t	length_low;
136 	uint32_t	length_high;
137 	uint32_t	width;
138 	uint8_t		reserved2[CRAT_MEMORY_RESERVED_LENGTH];
139 };
140 
141 /*
142  * HSA Cache Affinity structure and definitions
143  */
144 #define CRAT_CACHE_FLAGS_ENABLED	0x00000001
145 #define CRAT_CACHE_FLAGS_DATA_CACHE	0x00000002
146 #define CRAT_CACHE_FLAGS_INST_CACHE	0x00000004
147 #define CRAT_CACHE_FLAGS_CPU_CACHE	0x00000008
148 #define CRAT_CACHE_FLAGS_SIMD_CACHE	0x00000010
149 #define CRAT_CACHE_FLAGS_RESERVED	0xffffffe0
150 
151 #define CRAT_CACHE_RESERVED_LENGTH 8
152 
153 struct crat_subtype_cache {
154 	uint8_t		type;
155 	uint8_t		length;
156 	uint16_t	reserved;
157 	uint32_t	flags;
158 	uint32_t	processor_id_low;
159 	uint8_t		sibling_map[CRAT_SIBLINGMAP_SIZE];
160 	uint32_t	cache_size;
161 	uint8_t		cache_level;
162 	uint8_t		lines_per_tag;
163 	uint16_t	cache_line_size;
164 	uint8_t		associativity;
165 	uint8_t		cache_properties;
166 	uint16_t	cache_latency;
167 	uint8_t		reserved2[CRAT_CACHE_RESERVED_LENGTH];
168 };
169 
170 /*
171  * HSA TLB Affinity structure and definitions
172  */
173 #define CRAT_TLB_FLAGS_ENABLED	0x00000001
174 #define CRAT_TLB_FLAGS_DATA_TLB	0x00000002
175 #define CRAT_TLB_FLAGS_INST_TLB	0x00000004
176 #define CRAT_TLB_FLAGS_CPU_TLB	0x00000008
177 #define CRAT_TLB_FLAGS_SIMD_TLB	0x00000010
178 #define CRAT_TLB_FLAGS_RESERVED	0xffffffe0
179 
180 #define CRAT_TLB_RESERVED_LENGTH 4
181 
182 struct crat_subtype_tlb {
183 	uint8_t		type;
184 	uint8_t		length;
185 	uint16_t	reserved;
186 	uint32_t	flags;
187 	uint32_t	processor_id_low;
188 	uint8_t		sibling_map[CRAT_SIBLINGMAP_SIZE];
189 	uint32_t	tlb_level;
190 	uint8_t		data_tlb_associativity_2mb;
191 	uint8_t		data_tlb_size_2mb;
192 	uint8_t		instruction_tlb_associativity_2mb;
193 	uint8_t		instruction_tlb_size_2mb;
194 	uint8_t		data_tlb_associativity_4k;
195 	uint8_t		data_tlb_size_4k;
196 	uint8_t		instruction_tlb_associativity_4k;
197 	uint8_t		instruction_tlb_size_4k;
198 	uint8_t		data_tlb_associativity_1gb;
199 	uint8_t		data_tlb_size_1gb;
200 	uint8_t		instruction_tlb_associativity_1gb;
201 	uint8_t		instruction_tlb_size_1gb;
202 	uint8_t		reserved2[CRAT_TLB_RESERVED_LENGTH];
203 };
204 
205 /*
206  * HSA CCompute/APU Affinity structure and definitions
207  */
208 #define CRAT_CCOMPUTE_FLAGS_ENABLED	0x00000001
209 #define CRAT_CCOMPUTE_FLAGS_RESERVED	0xfffffffe
210 
211 #define CRAT_CCOMPUTE_RESERVED_LENGTH 16
212 
213 struct crat_subtype_ccompute {
214 	uint8_t		type;
215 	uint8_t		length;
216 	uint16_t	reserved;
217 	uint32_t	flags;
218 	uint32_t	processor_id_low;
219 	uint8_t		sibling_map[CRAT_SIBLINGMAP_SIZE];
220 	uint32_t	apu_size;
221 	uint8_t		reserved2[CRAT_CCOMPUTE_RESERVED_LENGTH];
222 };
223 
224 /*
225  * HSA IO Link Affinity structure and definitions
226  */
227 #define CRAT_IOLINK_FLAGS_ENABLED	0x00000001
228 #define CRAT_IOLINK_FLAGS_COHERENCY	0x00000002
229 #define CRAT_IOLINK_FLAGS_RESERVED	0xfffffffc
230 
231 /*
232  * IO interface types
233  */
234 #define CRAT_IOLINK_TYPE_UNDEFINED	0
235 #define CRAT_IOLINK_TYPE_HYPERTRANSPORT	1
236 #define CRAT_IOLINK_TYPE_PCIEXPRESS	2
237 #define CRAT_IOLINK_TYPE_OTHER		3
238 #define CRAT_IOLINK_TYPE_MAX		255
239 
240 #define CRAT_IOLINK_RESERVED_LENGTH 24
241 
242 struct crat_subtype_iolink {
243 	uint8_t		type;
244 	uint8_t		length;
245 	uint16_t	reserved;
246 	uint32_t	flags;
247 	uint32_t	proximity_domain_from;
248 	uint32_t	proximity_domain_to;
249 	uint8_t		io_interface_type;
250 	uint8_t		version_major;
251 	uint16_t	version_minor;
252 	uint32_t	minimum_latency;
253 	uint32_t	maximum_latency;
254 	uint32_t	minimum_bandwidth_mbs;
255 	uint32_t	maximum_bandwidth_mbs;
256 	uint32_t	recommended_transfer_size;
257 	uint8_t		reserved2[CRAT_IOLINK_RESERVED_LENGTH];
258 };
259 
260 /*
261  * HSA generic sub-type header
262  */
263 
264 #define CRAT_SUBTYPE_FLAGS_ENABLED 0x00000001
265 
266 struct crat_subtype_generic {
267 	uint8_t		type;
268 	uint8_t		length;
269 	uint16_t	reserved;
270 	uint32_t	flags;
271 };
272 
273 /*
274  * Component Locality Distance Information Table (CDIT)
275  */
276 #define CDIT_OEMID_LENGTH	6
277 #define CDIT_OEMTABLEID_LENGTH	8
278 
279 struct cdit_header {
280 	uint32_t	signature;
281 	uint32_t	length;
282 	uint8_t		revision;
283 	uint8_t		checksum;
284 	uint8_t		oem_id[CDIT_OEMID_LENGTH];
285 	uint8_t		oem_table_id[CDIT_OEMTABLEID_LENGTH];
286 	uint32_t	oem_revision;
287 	uint32_t	creator_id;
288 	uint32_t	creator_revision;
289 	uint32_t	total_entries;
290 	uint16_t	num_domains;
291 	uint8_t		entry[1];
292 };
293 
294 #pragma pack()
295 
296 #endif /* KFD_CRAT_H_INCLUDED */
297