Home | History | Annotate | Line # | Download | only in amdkfd
      1  1.1  riastrad /*	$NetBSD: kfd_topology.h,v 1.3 2021/12/18 23:44:59 riastradh Exp $	*/
      2  1.1  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright 2014 Advanced Micro Devices, Inc.
      5  1.1  riastrad  *
      6  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      7  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      8  1.1  riastrad  * to deal in the Software without restriction, including without limitation
      9  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     11  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     12  1.1  riastrad  *
     13  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     14  1.1  riastrad  * all copies or substantial portions of the Software.
     15  1.1  riastrad  *
     16  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  1.1  riastrad  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     23  1.1  riastrad  */
     24  1.1  riastrad 
     25  1.1  riastrad #ifndef __KFD_TOPOLOGY_H__
     26  1.1  riastrad #define __KFD_TOPOLOGY_H__
     27  1.1  riastrad 
     28  1.1  riastrad #include <linux/types.h>
     29  1.1  riastrad #include <linux/list.h>
     30  1.3  riastrad #include "kfd_crat.h"
     31  1.1  riastrad 
     32  1.3  riastrad #define KFD_TOPOLOGY_PUBLIC_NAME_SIZE 32
     33  1.1  riastrad 
     34  1.1  riastrad #define HSA_CAP_HOT_PLUGGABLE			0x00000001
     35  1.1  riastrad #define HSA_CAP_ATS_PRESENT			0x00000002
     36  1.1  riastrad #define HSA_CAP_SHARED_WITH_GRAPHICS		0x00000004
     37  1.1  riastrad #define HSA_CAP_QUEUE_SIZE_POW2			0x00000008
     38  1.1  riastrad #define HSA_CAP_QUEUE_SIZE_32BIT		0x00000010
     39  1.1  riastrad #define HSA_CAP_QUEUE_IDLE_EVENT		0x00000020
     40  1.1  riastrad #define HSA_CAP_VA_LIMIT			0x00000040
     41  1.1  riastrad #define HSA_CAP_WATCH_POINTS_SUPPORTED		0x00000080
     42  1.1  riastrad #define HSA_CAP_WATCH_POINTS_TOTALBITS_MASK	0x00000f00
     43  1.1  riastrad #define HSA_CAP_WATCH_POINTS_TOTALBITS_SHIFT	8
     44  1.3  riastrad #define HSA_CAP_DOORBELL_TYPE_TOTALBITS_MASK	0x00003000
     45  1.3  riastrad #define HSA_CAP_DOORBELL_TYPE_TOTALBITS_SHIFT	12
     46  1.3  riastrad #define HSA_CAP_RESERVED			0xffffc000
     47  1.3  riastrad 
     48  1.3  riastrad #define HSA_CAP_DOORBELL_TYPE_PRE_1_0		0x0
     49  1.3  riastrad #define HSA_CAP_DOORBELL_TYPE_1_0		0x1
     50  1.3  riastrad #define HSA_CAP_DOORBELL_TYPE_2_0		0x2
     51  1.3  riastrad #define HSA_CAP_AQL_QUEUE_DOUBLE_MAP		0x00004000
     52  1.3  riastrad 
     53  1.3  riastrad #define HSA_CAP_SRAM_EDCSUPPORTED		0x00080000
     54  1.3  riastrad #define HSA_CAP_MEM_EDCSUPPORTED		0x00100000
     55  1.3  riastrad #define HSA_CAP_RASEVENTNOTIFY			0x00200000
     56  1.1  riastrad 
     57  1.1  riastrad struct kfd_node_properties {
     58  1.3  riastrad 	uint64_t hive_id;
     59  1.1  riastrad 	uint32_t cpu_cores_count;
     60  1.1  riastrad 	uint32_t simd_count;
     61  1.1  riastrad 	uint32_t mem_banks_count;
     62  1.1  riastrad 	uint32_t caches_count;
     63  1.1  riastrad 	uint32_t io_links_count;
     64  1.1  riastrad 	uint32_t cpu_core_id_base;
     65  1.1  riastrad 	uint32_t simd_id_base;
     66  1.1  riastrad 	uint32_t capability;
     67  1.1  riastrad 	uint32_t max_waves_per_simd;
     68  1.1  riastrad 	uint32_t lds_size_in_kb;
     69  1.1  riastrad 	uint32_t gds_size_in_kb;
     70  1.3  riastrad 	uint32_t num_gws;
     71  1.1  riastrad 	uint32_t wave_front_size;
     72  1.1  riastrad 	uint32_t array_count;
     73  1.1  riastrad 	uint32_t simd_arrays_per_engine;
     74  1.1  riastrad 	uint32_t cu_per_simd_array;
     75  1.1  riastrad 	uint32_t simd_per_cu;
     76  1.1  riastrad 	uint32_t max_slots_scratch_cu;
     77  1.1  riastrad 	uint32_t engine_id;
     78  1.1  riastrad 	uint32_t vendor_id;
     79  1.1  riastrad 	uint32_t device_id;
     80  1.1  riastrad 	uint32_t location_id;
     81  1.1  riastrad 	uint32_t max_engine_clk_fcompute;
     82  1.1  riastrad 	uint32_t max_engine_clk_ccompute;
     83  1.3  riastrad 	int32_t  drm_render_minor;
     84  1.3  riastrad 	uint32_t num_sdma_engines;
     85  1.3  riastrad 	uint32_t num_sdma_xgmi_engines;
     86  1.3  riastrad 	uint32_t num_sdma_queues_per_engine;
     87  1.3  riastrad 	uint32_t num_cp_queues;
     88  1.3  riastrad 	char name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE];
     89  1.1  riastrad };
     90  1.1  riastrad 
     91  1.1  riastrad #define HSA_MEM_HEAP_TYPE_SYSTEM	0
     92  1.1  riastrad #define HSA_MEM_HEAP_TYPE_FB_PUBLIC	1
     93  1.1  riastrad #define HSA_MEM_HEAP_TYPE_FB_PRIVATE	2
     94  1.1  riastrad #define HSA_MEM_HEAP_TYPE_GPU_GDS	3
     95  1.1  riastrad #define HSA_MEM_HEAP_TYPE_GPU_LDS	4
     96  1.1  riastrad #define HSA_MEM_HEAP_TYPE_GPU_SCRATCH	5
     97  1.1  riastrad 
     98  1.1  riastrad #define HSA_MEM_FLAGS_HOT_PLUGGABLE	0x00000001
     99  1.1  riastrad #define HSA_MEM_FLAGS_NON_VOLATILE	0x00000002
    100  1.1  riastrad #define HSA_MEM_FLAGS_RESERVED		0xfffffffc
    101  1.1  riastrad 
    102  1.1  riastrad struct kfd_mem_properties {
    103  1.1  riastrad 	struct list_head	list;
    104  1.1  riastrad 	uint32_t		heap_type;
    105  1.1  riastrad 	uint64_t		size_in_bytes;
    106  1.1  riastrad 	uint32_t		flags;
    107  1.1  riastrad 	uint32_t		width;
    108  1.1  riastrad 	uint32_t		mem_clk_max;
    109  1.3  riastrad 	struct kfd_dev		*gpu;
    110  1.1  riastrad 	struct kobject		*kobj;
    111  1.1  riastrad 	struct attribute	attr;
    112  1.1  riastrad };
    113  1.1  riastrad 
    114  1.1  riastrad #define HSA_CACHE_TYPE_DATA		0x00000001
    115  1.1  riastrad #define HSA_CACHE_TYPE_INSTRUCTION	0x00000002
    116  1.1  riastrad #define HSA_CACHE_TYPE_CPU		0x00000004
    117  1.1  riastrad #define HSA_CACHE_TYPE_HSACU		0x00000008
    118  1.1  riastrad #define HSA_CACHE_TYPE_RESERVED		0xfffffff0
    119  1.1  riastrad 
    120  1.1  riastrad struct kfd_cache_properties {
    121  1.1  riastrad 	struct list_head	list;
    122  1.1  riastrad 	uint32_t		processor_id_low;
    123  1.1  riastrad 	uint32_t		cache_level;
    124  1.1  riastrad 	uint32_t		cache_size;
    125  1.1  riastrad 	uint32_t		cacheline_size;
    126  1.1  riastrad 	uint32_t		cachelines_per_tag;
    127  1.1  riastrad 	uint32_t		cache_assoc;
    128  1.1  riastrad 	uint32_t		cache_latency;
    129  1.1  riastrad 	uint32_t		cache_type;
    130  1.3  riastrad 	uint8_t			sibling_map[CRAT_SIBLINGMAP_SIZE];
    131  1.3  riastrad 	struct kfd_dev		*gpu;
    132  1.1  riastrad 	struct kobject		*kobj;
    133  1.1  riastrad 	struct attribute	attr;
    134  1.1  riastrad };
    135  1.1  riastrad 
    136  1.1  riastrad struct kfd_iolink_properties {
    137  1.1  riastrad 	struct list_head	list;
    138  1.1  riastrad 	uint32_t		iolink_type;
    139  1.1  riastrad 	uint32_t		ver_maj;
    140  1.1  riastrad 	uint32_t		ver_min;
    141  1.1  riastrad 	uint32_t		node_from;
    142  1.1  riastrad 	uint32_t		node_to;
    143  1.1  riastrad 	uint32_t		weight;
    144  1.1  riastrad 	uint32_t		min_latency;
    145  1.1  riastrad 	uint32_t		max_latency;
    146  1.1  riastrad 	uint32_t		min_bandwidth;
    147  1.1  riastrad 	uint32_t		max_bandwidth;
    148  1.1  riastrad 	uint32_t		rec_transfer_size;
    149  1.1  riastrad 	uint32_t		flags;
    150  1.3  riastrad 	struct kfd_dev		*gpu;
    151  1.1  riastrad 	struct kobject		*kobj;
    152  1.1  riastrad 	struct attribute	attr;
    153  1.1  riastrad };
    154  1.1  riastrad 
    155  1.3  riastrad struct kfd_perf_properties {
    156  1.3  riastrad 	struct list_head	list;
    157  1.3  riastrad 	char			block_name[16];
    158  1.3  riastrad 	uint32_t		max_concurrent;
    159  1.3  riastrad 	struct attribute_group	*attr_group;
    160  1.3  riastrad };
    161  1.3  riastrad 
    162  1.1  riastrad struct kfd_topology_device {
    163  1.1  riastrad 	struct list_head		list;
    164  1.1  riastrad 	uint32_t			gpu_id;
    165  1.3  riastrad 	uint32_t			proximity_domain;
    166  1.1  riastrad 	struct kfd_node_properties	node_props;
    167  1.1  riastrad 	struct list_head		mem_props;
    168  1.1  riastrad 	uint32_t			cache_count;
    169  1.1  riastrad 	struct list_head		cache_props;
    170  1.1  riastrad 	uint32_t			io_link_count;
    171  1.1  riastrad 	struct list_head		io_link_props;
    172  1.3  riastrad 	struct list_head		perf_props;
    173  1.1  riastrad 	struct kfd_dev			*gpu;
    174  1.1  riastrad 	struct kobject			*kobj_node;
    175  1.1  riastrad 	struct kobject			*kobj_mem;
    176  1.1  riastrad 	struct kobject			*kobj_cache;
    177  1.1  riastrad 	struct kobject			*kobj_iolink;
    178  1.3  riastrad 	struct kobject			*kobj_perf;
    179  1.1  riastrad 	struct attribute		attr_gpuid;
    180  1.1  riastrad 	struct attribute		attr_name;
    181  1.1  riastrad 	struct attribute		attr_props;
    182  1.3  riastrad 	uint8_t				oem_id[CRAT_OEMID_LENGTH];
    183  1.3  riastrad 	uint8_t				oem_table_id[CRAT_OEMTABLEID_LENGTH];
    184  1.3  riastrad 	uint32_t			oem_revision;
    185  1.1  riastrad };
    186  1.1  riastrad 
    187  1.1  riastrad struct kfd_system_properties {
    188  1.1  riastrad 	uint32_t		num_devices;     /* Number of H-NUMA nodes */
    189  1.1  riastrad 	uint32_t		generation_count;
    190  1.1  riastrad 	uint64_t		platform_oem;
    191  1.1  riastrad 	uint64_t		platform_id;
    192  1.1  riastrad 	uint64_t		platform_rev;
    193  1.1  riastrad 	struct kobject		*kobj_topology;
    194  1.1  riastrad 	struct kobject		*kobj_nodes;
    195  1.1  riastrad 	struct attribute	attr_genid;
    196  1.1  riastrad 	struct attribute	attr_props;
    197  1.1  riastrad };
    198  1.1  riastrad 
    199  1.3  riastrad struct kfd_topology_device *kfd_create_topology_device(
    200  1.3  riastrad 		struct list_head *device_list);
    201  1.3  riastrad void kfd_release_topology_device_list(struct list_head *device_list);
    202  1.1  riastrad 
    203  1.1  riastrad #endif /* __KFD_TOPOLOGY_H__ */
    204