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_TOPOLOGY_H__
24 #define __KFD_TOPOLOGY_H__
25 
26 #include <linux/types.h>
27 #include <linux/list.h>
28 #include <linux/kfd_sysfs.h>
29 #include "kfd_crat.h"
30 
31 #define KFD_TOPOLOGY_PUBLIC_NAME_SIZE 32
32 
33 struct kfd_node_properties {
34 	uint64_t hive_id;
35 	uint32_t cpu_cores_count;
36 	uint32_t simd_count;
37 	uint32_t mem_banks_count;
38 	uint32_t caches_count;
39 	uint32_t io_links_count;
40 	uint32_t cpu_core_id_base;
41 	uint32_t simd_id_base;
42 	uint32_t capability;
43 	uint32_t max_waves_per_simd;
44 	uint32_t lds_size_in_kb;
45 	uint32_t gds_size_in_kb;
46 	uint32_t num_gws;
47 	uint32_t wave_front_size;
48 	uint32_t array_count;
49 	uint32_t simd_arrays_per_engine;
50 	uint32_t cu_per_simd_array;
51 	uint32_t simd_per_cu;
52 	uint32_t max_slots_scratch_cu;
53 	uint32_t engine_id;
54 	uint32_t gfx_target_version;
55 	uint32_t vendor_id;
56 	uint32_t device_id;
57 	uint32_t location_id;
58 	uint32_t domain;
59 	uint32_t max_engine_clk_fcompute;
60 	uint32_t max_engine_clk_ccompute;
61 	int32_t  drm_render_minor;
62 	uint32_t num_sdma_engines;
63 	uint32_t num_sdma_xgmi_engines;
64 	uint32_t num_sdma_queues_per_engine;
65 	uint32_t num_cp_queues;
66 	char name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE];
67 };
68 
69 struct kfd_mem_properties {
70 	struct list_head	list;
71 	uint32_t		heap_type;
72 	uint64_t		size_in_bytes;
73 	uint32_t		flags;
74 	uint32_t		width;
75 	uint32_t		mem_clk_max;
76 	struct kfd_dev		*gpu;
77 	struct kobject		*kobj;
78 	struct attribute	attr;
79 };
80 
81 struct kfd_cache_properties {
82 	struct list_head	list;
83 	uint32_t		processor_id_low;
84 	uint32_t		cache_level;
85 	uint32_t		cache_size;
86 	uint32_t		cacheline_size;
87 	uint32_t		cachelines_per_tag;
88 	uint32_t		cache_assoc;
89 	uint32_t		cache_latency;
90 	uint32_t		cache_type;
91 	uint8_t			sibling_map[CRAT_SIBLINGMAP_SIZE];
92 	struct kfd_dev		*gpu;
93 	struct kobject		*kobj;
94 	struct attribute	attr;
95 };
96 
97 struct kfd_iolink_properties {
98 	struct list_head	list;
99 	uint32_t		iolink_type;
100 	uint32_t		ver_maj;
101 	uint32_t		ver_min;
102 	uint32_t		node_from;
103 	uint32_t		node_to;
104 	uint32_t		weight;
105 	uint32_t		min_latency;
106 	uint32_t		max_latency;
107 	uint32_t		min_bandwidth;
108 	uint32_t		max_bandwidth;
109 	uint32_t		rec_transfer_size;
110 	uint32_t		flags;
111 	struct kfd_dev		*gpu;
112 	struct kobject		*kobj;
113 	struct attribute	attr;
114 };
115 
116 struct kfd_perf_properties {
117 	struct list_head	list;
118 	char			block_name[16];
119 	uint32_t		max_concurrent;
120 	struct attribute_group	*attr_group;
121 };
122 
123 struct kfd_topology_device {
124 	struct list_head		list;
125 	uint32_t			gpu_id;
126 	uint32_t			proximity_domain;
127 	struct kfd_node_properties	node_props;
128 	struct list_head		mem_props;
129 	uint32_t			cache_count;
130 	struct list_head		cache_props;
131 	uint32_t			io_link_count;
132 	struct list_head		io_link_props;
133 	struct list_head		perf_props;
134 	struct kfd_dev			*gpu;
135 	struct kobject			*kobj_node;
136 	struct kobject			*kobj_mem;
137 	struct kobject			*kobj_cache;
138 	struct kobject			*kobj_iolink;
139 	struct kobject			*kobj_perf;
140 	struct attribute		attr_gpuid;
141 	struct attribute		attr_name;
142 	struct attribute		attr_props;
143 	uint8_t				oem_id[CRAT_OEMID_LENGTH];
144 	uint8_t				oem_table_id[CRAT_OEMTABLEID_LENGTH];
145 	uint32_t			oem_revision;
146 };
147 
148 struct kfd_system_properties {
149 	uint32_t		num_devices;     /* Number of H-NUMA nodes */
150 	uint32_t		generation_count;
151 	uint64_t		platform_oem;
152 	uint64_t		platform_id;
153 	uint64_t		platform_rev;
154 	struct kobject		*kobj_topology;
155 	struct kobject		*kobj_nodes;
156 	struct attribute	attr_genid;
157 	struct attribute	attr_props;
158 };
159 
160 struct kfd_topology_device *kfd_create_topology_device(
161 		struct list_head *device_list);
162 void kfd_release_topology_device_list(struct list_head *device_list);
163 
164 #endif /* __KFD_TOPOLOGY_H__ */
165