kfd_topology.h revision 1.1 1 /* $NetBSD: kfd_topology.h,v 1.1 2018/08/27 01:34:46 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_TOPOLOGY_H__
26 #define __KFD_TOPOLOGY_H__
27
28 #include <linux/types.h>
29 #include <linux/list.h>
30 #include "kfd_priv.h"
31
32 #define KFD_TOPOLOGY_PUBLIC_NAME_SIZE 128
33
34 #define HSA_CAP_HOT_PLUGGABLE 0x00000001
35 #define HSA_CAP_ATS_PRESENT 0x00000002
36 #define HSA_CAP_SHARED_WITH_GRAPHICS 0x00000004
37 #define HSA_CAP_QUEUE_SIZE_POW2 0x00000008
38 #define HSA_CAP_QUEUE_SIZE_32BIT 0x00000010
39 #define HSA_CAP_QUEUE_IDLE_EVENT 0x00000020
40 #define HSA_CAP_VA_LIMIT 0x00000040
41 #define HSA_CAP_WATCH_POINTS_SUPPORTED 0x00000080
42 #define HSA_CAP_WATCH_POINTS_TOTALBITS_MASK 0x00000f00
43 #define HSA_CAP_WATCH_POINTS_TOTALBITS_SHIFT 8
44 #define HSA_CAP_RESERVED 0xfffff000
45 #define HSA_CAP_DOORBELL_PACKET_TYPE 0x00001000
46
47 struct kfd_node_properties {
48 uint32_t cpu_cores_count;
49 uint32_t simd_count;
50 uint32_t mem_banks_count;
51 uint32_t caches_count;
52 uint32_t io_links_count;
53 uint32_t cpu_core_id_base;
54 uint32_t simd_id_base;
55 uint32_t capability;
56 uint32_t max_waves_per_simd;
57 uint32_t lds_size_in_kb;
58 uint32_t gds_size_in_kb;
59 uint32_t wave_front_size;
60 uint32_t array_count;
61 uint32_t simd_arrays_per_engine;
62 uint32_t cu_per_simd_array;
63 uint32_t simd_per_cu;
64 uint32_t max_slots_scratch_cu;
65 uint32_t engine_id;
66 uint32_t vendor_id;
67 uint32_t device_id;
68 uint32_t location_id;
69 uint32_t max_engine_clk_fcompute;
70 uint32_t max_engine_clk_ccompute;
71 uint16_t marketing_name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE];
72 };
73
74 #define HSA_MEM_HEAP_TYPE_SYSTEM 0
75 #define HSA_MEM_HEAP_TYPE_FB_PUBLIC 1
76 #define HSA_MEM_HEAP_TYPE_FB_PRIVATE 2
77 #define HSA_MEM_HEAP_TYPE_GPU_GDS 3
78 #define HSA_MEM_HEAP_TYPE_GPU_LDS 4
79 #define HSA_MEM_HEAP_TYPE_GPU_SCRATCH 5
80
81 #define HSA_MEM_FLAGS_HOT_PLUGGABLE 0x00000001
82 #define HSA_MEM_FLAGS_NON_VOLATILE 0x00000002
83 #define HSA_MEM_FLAGS_RESERVED 0xfffffffc
84
85 struct kfd_mem_properties {
86 struct list_head list;
87 uint32_t heap_type;
88 uint64_t size_in_bytes;
89 uint32_t flags;
90 uint32_t width;
91 uint32_t mem_clk_max;
92 struct kobject *kobj;
93 struct attribute attr;
94 };
95
96 #define KFD_TOPOLOGY_CPU_SIBLINGS 256
97
98 #define HSA_CACHE_TYPE_DATA 0x00000001
99 #define HSA_CACHE_TYPE_INSTRUCTION 0x00000002
100 #define HSA_CACHE_TYPE_CPU 0x00000004
101 #define HSA_CACHE_TYPE_HSACU 0x00000008
102 #define HSA_CACHE_TYPE_RESERVED 0xfffffff0
103
104 struct kfd_cache_properties {
105 struct list_head list;
106 uint32_t processor_id_low;
107 uint32_t cache_level;
108 uint32_t cache_size;
109 uint32_t cacheline_size;
110 uint32_t cachelines_per_tag;
111 uint32_t cache_assoc;
112 uint32_t cache_latency;
113 uint32_t cache_type;
114 uint8_t sibling_map[KFD_TOPOLOGY_CPU_SIBLINGS];
115 struct kobject *kobj;
116 struct attribute attr;
117 };
118
119 struct kfd_iolink_properties {
120 struct list_head list;
121 uint32_t iolink_type;
122 uint32_t ver_maj;
123 uint32_t ver_min;
124 uint32_t node_from;
125 uint32_t node_to;
126 uint32_t weight;
127 uint32_t min_latency;
128 uint32_t max_latency;
129 uint32_t min_bandwidth;
130 uint32_t max_bandwidth;
131 uint32_t rec_transfer_size;
132 uint32_t flags;
133 struct kobject *kobj;
134 struct attribute attr;
135 };
136
137 struct kfd_topology_device {
138 struct list_head list;
139 uint32_t gpu_id;
140 struct kfd_node_properties node_props;
141 uint32_t mem_bank_count;
142 struct list_head mem_props;
143 uint32_t cache_count;
144 struct list_head cache_props;
145 uint32_t io_link_count;
146 struct list_head io_link_props;
147 struct kfd_dev *gpu;
148 struct kobject *kobj_node;
149 struct kobject *kobj_mem;
150 struct kobject *kobj_cache;
151 struct kobject *kobj_iolink;
152 struct attribute attr_gpuid;
153 struct attribute attr_name;
154 struct attribute attr_props;
155 };
156
157 struct kfd_system_properties {
158 uint32_t num_devices; /* Number of H-NUMA nodes */
159 uint32_t generation_count;
160 uint64_t platform_oem;
161 uint64_t platform_id;
162 uint64_t platform_rev;
163 struct kobject *kobj_topology;
164 struct kobject *kobj_nodes;
165 struct attribute attr_genid;
166 struct attribute attr_props;
167 };
168
169
170
171 #endif /* __KFD_TOPOLOGY_H__ */
172