blob: ffc8c9faf75167d3c6e7f69ee09555e83b5d555a [file] [log] [blame]
Christopher Ferris24f97eb2019-05-20 12:58:13 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef HABANALABS_H_
20#define HABANALABS_H_
21#include <linux/types.h>
22#include <linux/ioctl.h>
23#define GOYA_KMD_SRAM_RESERVED_SIZE_FROM_START 0x8000
24enum goya_queue_id {
25 GOYA_QUEUE_ID_DMA_0 = 0,
Christopher Ferris9584fa42019-12-09 15:36:13 -080026 GOYA_QUEUE_ID_DMA_1 = 1,
27 GOYA_QUEUE_ID_DMA_2 = 2,
28 GOYA_QUEUE_ID_DMA_3 = 3,
29 GOYA_QUEUE_ID_DMA_4 = 4,
30 GOYA_QUEUE_ID_CPU_PQ = 5,
31 GOYA_QUEUE_ID_MME = 6,
32 GOYA_QUEUE_ID_TPC0 = 7,
33 GOYA_QUEUE_ID_TPC1 = 8,
34 GOYA_QUEUE_ID_TPC2 = 9,
35 GOYA_QUEUE_ID_TPC3 = 10,
36 GOYA_QUEUE_ID_TPC4 = 11,
37 GOYA_QUEUE_ID_TPC5 = 12,
38 GOYA_QUEUE_ID_TPC6 = 13,
39 GOYA_QUEUE_ID_TPC7 = 14,
Christopher Ferris24f97eb2019-05-20 12:58:13 -070040 GOYA_QUEUE_ID_SIZE
41};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -070042enum goya_engine_id {
43 GOYA_ENGINE_ID_DMA_0 = 0,
44 GOYA_ENGINE_ID_DMA_1,
45 GOYA_ENGINE_ID_DMA_2,
46 GOYA_ENGINE_ID_DMA_3,
47 GOYA_ENGINE_ID_DMA_4,
48 GOYA_ENGINE_ID_MME_0,
49 GOYA_ENGINE_ID_TPC_0,
50 GOYA_ENGINE_ID_TPC_1,
51 GOYA_ENGINE_ID_TPC_2,
52 GOYA_ENGINE_ID_TPC_3,
53 GOYA_ENGINE_ID_TPC_4,
54 GOYA_ENGINE_ID_TPC_5,
55 GOYA_ENGINE_ID_TPC_6,
56 GOYA_ENGINE_ID_TPC_7,
57 GOYA_ENGINE_ID_SIZE
58};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -070059enum hl_device_status {
60 HL_DEVICE_STATUS_OPERATIONAL,
61 HL_DEVICE_STATUS_IN_RESET,
62 HL_DEVICE_STATUS_MALFUNCTION
63};
Christopher Ferris24f97eb2019-05-20 12:58:13 -070064#define HL_INFO_HW_IP_INFO 0
65#define HL_INFO_HW_EVENTS 1
66#define HL_INFO_DRAM_USAGE 2
67#define HL_INFO_HW_IDLE 3
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -070068#define HL_INFO_DEVICE_STATUS 4
Christopher Ferris9584fa42019-12-09 15:36:13 -080069#define HL_INFO_DEVICE_UTILIZATION 6
70#define HL_INFO_HW_EVENTS_AGGREGATE 7
Christopher Ferris24f97eb2019-05-20 12:58:13 -070071#define HL_INFO_VERSION_MAX_LEN 128
72struct hl_info_hw_ip_info {
73 __u64 sram_base_address;
74 __u64 dram_base_address;
75 __u64 dram_size;
76 __u32 sram_size;
77 __u32 num_of_events;
78 __u32 device_id;
79 __u32 reserved[3];
80 __u32 armcp_cpld_version;
81 __u32 psoc_pci_pll_nr;
82 __u32 psoc_pci_pll_nf;
83 __u32 psoc_pci_pll_od;
84 __u32 psoc_pci_pll_div_factor;
85 __u8 tpc_enabled_mask;
86 __u8 dram_enabled;
87 __u8 pad[2];
88 __u8 armcp_version[HL_INFO_VERSION_MAX_LEN];
89};
90struct hl_info_dram_usage {
91 __u64 dram_free_mem;
92 __u64 ctx_dram_mem;
93};
94struct hl_info_hw_idle {
95 __u32 is_idle;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -070096 __u32 busy_engines_mask;
Christopher Ferris24f97eb2019-05-20 12:58:13 -070097};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -070098struct hl_info_device_status {
99 __u32 status;
100 __u32 pad;
101};
Christopher Ferris9584fa42019-12-09 15:36:13 -0800102struct hl_info_device_utilization {
103 __u32 utilization;
104 __u32 pad;
105};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700106struct hl_info_args {
107 __u64 return_pointer;
108 __u32 return_size;
109 __u32 op;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800110 union {
111 __u32 ctx_id;
112 __u32 period_ms;
113 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700114 __u32 pad;
115};
116#define HL_CB_OP_CREATE 0
117#define HL_CB_OP_DESTROY 1
118struct hl_cb_in {
119 __u64 cb_handle;
120 __u32 op;
121 __u32 cb_size;
122 __u32 ctx_id;
123 __u32 pad;
124};
125struct hl_cb_out {
126 __u64 cb_handle;
127};
128union hl_cb_args {
129 struct hl_cb_in in;
130 struct hl_cb_out out;
131};
132struct hl_cs_chunk {
133 __u64 cb_handle;
134 __u32 queue_index;
135 __u32 cb_size;
136 __u32 cs_chunk_flags;
137 __u32 pad[11];
138};
139#define HL_CS_FLAGS_FORCE_RESTORE 0x1
140#define HL_CS_STATUS_SUCCESS 0
141struct hl_cs_in {
142 __u64 chunks_restore;
143 __u64 chunks_execute;
144 __u64 chunks_store;
145 __u32 num_chunks_restore;
146 __u32 num_chunks_execute;
147 __u32 num_chunks_store;
148 __u32 cs_flags;
149 __u32 ctx_id;
150};
151struct hl_cs_out {
152 __u64 seq;
153 __u32 status;
154 __u32 pad;
155};
156union hl_cs_args {
157 struct hl_cs_in in;
158 struct hl_cs_out out;
159};
160struct hl_wait_cs_in {
161 __u64 seq;
162 __u64 timeout_us;
163 __u32 ctx_id;
164 __u32 pad;
165};
166#define HL_WAIT_CS_STATUS_COMPLETED 0
167#define HL_WAIT_CS_STATUS_BUSY 1
168#define HL_WAIT_CS_STATUS_TIMEDOUT 2
169#define HL_WAIT_CS_STATUS_ABORTED 3
170#define HL_WAIT_CS_STATUS_INTERRUPTED 4
171struct hl_wait_cs_out {
172 __u32 status;
173 __u32 pad;
174};
175union hl_wait_cs_args {
176 struct hl_wait_cs_in in;
177 struct hl_wait_cs_out out;
178};
179#define HL_MEM_OP_ALLOC 0
180#define HL_MEM_OP_FREE 1
181#define HL_MEM_OP_MAP 2
182#define HL_MEM_OP_UNMAP 3
183#define HL_MEM_CONTIGUOUS 0x1
184#define HL_MEM_SHARED 0x2
185#define HL_MEM_USERPTR 0x4
186struct hl_mem_in {
187 union {
188 struct {
189 __u64 mem_size;
190 } alloc;
191 struct {
192 __u64 handle;
193 } free;
194 struct {
195 __u64 hint_addr;
196 __u64 handle;
197 } map_device;
198 struct {
199 __u64 host_virt_addr;
200 __u64 hint_addr;
201 __u64 mem_size;
202 } map_host;
203 struct {
204 __u64 device_virt_addr;
205 } unmap;
206 };
207 __u32 op;
208 __u32 flags;
209 __u32 ctx_id;
210 __u32 pad;
211};
212struct hl_mem_out {
213 union {
214 __u64 device_virt_addr;
215 __u64 handle;
216 };
217};
218union hl_mem_args {
219 struct hl_mem_in in;
220 struct hl_mem_out out;
221};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700222#define HL_DEBUG_MAX_AUX_VALUES 10
223struct hl_debug_params_etr {
224 __u64 buffer_address;
225 __u64 buffer_size;
226 __u32 sink_mode;
227 __u32 pad;
228};
229struct hl_debug_params_etf {
230 __u64 buffer_address;
231 __u64 buffer_size;
232 __u32 sink_mode;
233 __u32 pad;
234};
235struct hl_debug_params_stm {
236 __u64 he_mask;
237 __u64 sp_mask;
238 __u32 id;
239 __u32 frequency;
240};
241struct hl_debug_params_bmon {
242 __u64 start_addr0;
243 __u64 addr_mask0;
244 __u64 start_addr1;
245 __u64 addr_mask1;
246 __u32 bw_win;
247 __u32 win_capture;
248 __u32 id;
249 __u32 pad;
250};
251struct hl_debug_params_spmu {
252 __u64 event_types[HL_DEBUG_MAX_AUX_VALUES];
253 __u32 event_types_num;
254 __u32 pad;
255};
256#define HL_DEBUG_OP_ETR 0
257#define HL_DEBUG_OP_ETF 1
258#define HL_DEBUG_OP_STM 2
259#define HL_DEBUG_OP_FUNNEL 3
260#define HL_DEBUG_OP_BMON 4
261#define HL_DEBUG_OP_SPMU 5
262#define HL_DEBUG_OP_TIMESTAMP 6
263#define HL_DEBUG_OP_SET_MODE 7
264struct hl_debug_args {
265 __u64 input_ptr;
266 __u64 output_ptr;
267 __u32 input_size;
268 __u32 output_size;
269 __u32 op;
270 __u32 reg_idx;
271 __u32 enable;
272 __u32 ctx_id;
273};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700274#define HL_IOCTL_INFO _IOWR('H', 0x01, struct hl_info_args)
275#define HL_IOCTL_CB _IOWR('H', 0x02, union hl_cb_args)
276#define HL_IOCTL_CS _IOWR('H', 0x03, union hl_cs_args)
277#define HL_IOCTL_WAIT_CS _IOWR('H', 0x04, union hl_wait_cs_args)
278#define HL_IOCTL_MEMORY _IOWR('H', 0x05, union hl_mem_args)
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700279#define HL_IOCTL_DEBUG _IOWR('H', 0x06, struct hl_debug_args)
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700280#define HL_COMMAND_START 0x01
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700281#define HL_COMMAND_END 0x07
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700282#endif