blob: ed2ba7c6d98d8b3b6848abb771e2a46faf334adc [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
Christopher Ferris8177cdf2020-08-03 11:53:55 -070024#define GAUDI_DRIVER_SRAM_RESERVED_SIZE_FROM_START 0x80
Christopher Ferris05667cd2021-02-16 16:01:34 -080025#define GAUDI_FIRST_AVAILABLE_W_S_SYNC_OBJECT 144
26#define GAUDI_FIRST_AVAILABLE_W_S_MONITOR 72
Christopher Ferris24f97eb2019-05-20 12:58:13 -070027enum goya_queue_id {
28 GOYA_QUEUE_ID_DMA_0 = 0,
Christopher Ferris9584fa42019-12-09 15:36:13 -080029 GOYA_QUEUE_ID_DMA_1 = 1,
30 GOYA_QUEUE_ID_DMA_2 = 2,
31 GOYA_QUEUE_ID_DMA_3 = 3,
32 GOYA_QUEUE_ID_DMA_4 = 4,
33 GOYA_QUEUE_ID_CPU_PQ = 5,
34 GOYA_QUEUE_ID_MME = 6,
35 GOYA_QUEUE_ID_TPC0 = 7,
36 GOYA_QUEUE_ID_TPC1 = 8,
37 GOYA_QUEUE_ID_TPC2 = 9,
38 GOYA_QUEUE_ID_TPC3 = 10,
39 GOYA_QUEUE_ID_TPC4 = 11,
40 GOYA_QUEUE_ID_TPC5 = 12,
41 GOYA_QUEUE_ID_TPC6 = 13,
42 GOYA_QUEUE_ID_TPC7 = 14,
Christopher Ferris24f97eb2019-05-20 12:58:13 -070043 GOYA_QUEUE_ID_SIZE
44};
Christopher Ferris8177cdf2020-08-03 11:53:55 -070045enum gaudi_queue_id {
46 GAUDI_QUEUE_ID_DMA_0_0 = 0,
47 GAUDI_QUEUE_ID_DMA_0_1 = 1,
48 GAUDI_QUEUE_ID_DMA_0_2 = 2,
49 GAUDI_QUEUE_ID_DMA_0_3 = 3,
50 GAUDI_QUEUE_ID_DMA_1_0 = 4,
51 GAUDI_QUEUE_ID_DMA_1_1 = 5,
52 GAUDI_QUEUE_ID_DMA_1_2 = 6,
53 GAUDI_QUEUE_ID_DMA_1_3 = 7,
54 GAUDI_QUEUE_ID_CPU_PQ = 8,
55 GAUDI_QUEUE_ID_DMA_2_0 = 9,
56 GAUDI_QUEUE_ID_DMA_2_1 = 10,
57 GAUDI_QUEUE_ID_DMA_2_2 = 11,
58 GAUDI_QUEUE_ID_DMA_2_3 = 12,
59 GAUDI_QUEUE_ID_DMA_3_0 = 13,
60 GAUDI_QUEUE_ID_DMA_3_1 = 14,
61 GAUDI_QUEUE_ID_DMA_3_2 = 15,
62 GAUDI_QUEUE_ID_DMA_3_3 = 16,
63 GAUDI_QUEUE_ID_DMA_4_0 = 17,
64 GAUDI_QUEUE_ID_DMA_4_1 = 18,
65 GAUDI_QUEUE_ID_DMA_4_2 = 19,
66 GAUDI_QUEUE_ID_DMA_4_3 = 20,
67 GAUDI_QUEUE_ID_DMA_5_0 = 21,
68 GAUDI_QUEUE_ID_DMA_5_1 = 22,
69 GAUDI_QUEUE_ID_DMA_5_2 = 23,
70 GAUDI_QUEUE_ID_DMA_5_3 = 24,
71 GAUDI_QUEUE_ID_DMA_6_0 = 25,
72 GAUDI_QUEUE_ID_DMA_6_1 = 26,
73 GAUDI_QUEUE_ID_DMA_6_2 = 27,
74 GAUDI_QUEUE_ID_DMA_6_3 = 28,
75 GAUDI_QUEUE_ID_DMA_7_0 = 29,
76 GAUDI_QUEUE_ID_DMA_7_1 = 30,
77 GAUDI_QUEUE_ID_DMA_7_2 = 31,
78 GAUDI_QUEUE_ID_DMA_7_3 = 32,
79 GAUDI_QUEUE_ID_MME_0_0 = 33,
80 GAUDI_QUEUE_ID_MME_0_1 = 34,
81 GAUDI_QUEUE_ID_MME_0_2 = 35,
82 GAUDI_QUEUE_ID_MME_0_3 = 36,
83 GAUDI_QUEUE_ID_MME_1_0 = 37,
84 GAUDI_QUEUE_ID_MME_1_1 = 38,
85 GAUDI_QUEUE_ID_MME_1_2 = 39,
86 GAUDI_QUEUE_ID_MME_1_3 = 40,
87 GAUDI_QUEUE_ID_TPC_0_0 = 41,
88 GAUDI_QUEUE_ID_TPC_0_1 = 42,
89 GAUDI_QUEUE_ID_TPC_0_2 = 43,
90 GAUDI_QUEUE_ID_TPC_0_3 = 44,
91 GAUDI_QUEUE_ID_TPC_1_0 = 45,
92 GAUDI_QUEUE_ID_TPC_1_1 = 46,
93 GAUDI_QUEUE_ID_TPC_1_2 = 47,
94 GAUDI_QUEUE_ID_TPC_1_3 = 48,
95 GAUDI_QUEUE_ID_TPC_2_0 = 49,
96 GAUDI_QUEUE_ID_TPC_2_1 = 50,
97 GAUDI_QUEUE_ID_TPC_2_2 = 51,
98 GAUDI_QUEUE_ID_TPC_2_3 = 52,
99 GAUDI_QUEUE_ID_TPC_3_0 = 53,
100 GAUDI_QUEUE_ID_TPC_3_1 = 54,
101 GAUDI_QUEUE_ID_TPC_3_2 = 55,
102 GAUDI_QUEUE_ID_TPC_3_3 = 56,
103 GAUDI_QUEUE_ID_TPC_4_0 = 57,
104 GAUDI_QUEUE_ID_TPC_4_1 = 58,
105 GAUDI_QUEUE_ID_TPC_4_2 = 59,
106 GAUDI_QUEUE_ID_TPC_4_3 = 60,
107 GAUDI_QUEUE_ID_TPC_5_0 = 61,
108 GAUDI_QUEUE_ID_TPC_5_1 = 62,
109 GAUDI_QUEUE_ID_TPC_5_2 = 63,
110 GAUDI_QUEUE_ID_TPC_5_3 = 64,
111 GAUDI_QUEUE_ID_TPC_6_0 = 65,
112 GAUDI_QUEUE_ID_TPC_6_1 = 66,
113 GAUDI_QUEUE_ID_TPC_6_2 = 67,
114 GAUDI_QUEUE_ID_TPC_6_3 = 68,
115 GAUDI_QUEUE_ID_TPC_7_0 = 69,
116 GAUDI_QUEUE_ID_TPC_7_1 = 70,
117 GAUDI_QUEUE_ID_TPC_7_2 = 71,
118 GAUDI_QUEUE_ID_TPC_7_3 = 72,
119 GAUDI_QUEUE_ID_NIC_0_0 = 73,
120 GAUDI_QUEUE_ID_NIC_0_1 = 74,
121 GAUDI_QUEUE_ID_NIC_0_2 = 75,
122 GAUDI_QUEUE_ID_NIC_0_3 = 76,
123 GAUDI_QUEUE_ID_NIC_1_0 = 77,
124 GAUDI_QUEUE_ID_NIC_1_1 = 78,
125 GAUDI_QUEUE_ID_NIC_1_2 = 79,
126 GAUDI_QUEUE_ID_NIC_1_3 = 80,
127 GAUDI_QUEUE_ID_NIC_2_0 = 81,
128 GAUDI_QUEUE_ID_NIC_2_1 = 82,
129 GAUDI_QUEUE_ID_NIC_2_2 = 83,
130 GAUDI_QUEUE_ID_NIC_2_3 = 84,
131 GAUDI_QUEUE_ID_NIC_3_0 = 85,
132 GAUDI_QUEUE_ID_NIC_3_1 = 86,
133 GAUDI_QUEUE_ID_NIC_3_2 = 87,
134 GAUDI_QUEUE_ID_NIC_3_3 = 88,
135 GAUDI_QUEUE_ID_NIC_4_0 = 89,
136 GAUDI_QUEUE_ID_NIC_4_1 = 90,
137 GAUDI_QUEUE_ID_NIC_4_2 = 91,
138 GAUDI_QUEUE_ID_NIC_4_3 = 92,
139 GAUDI_QUEUE_ID_NIC_5_0 = 93,
140 GAUDI_QUEUE_ID_NIC_5_1 = 94,
141 GAUDI_QUEUE_ID_NIC_5_2 = 95,
142 GAUDI_QUEUE_ID_NIC_5_3 = 96,
143 GAUDI_QUEUE_ID_NIC_6_0 = 97,
144 GAUDI_QUEUE_ID_NIC_6_1 = 98,
145 GAUDI_QUEUE_ID_NIC_6_2 = 99,
146 GAUDI_QUEUE_ID_NIC_6_3 = 100,
147 GAUDI_QUEUE_ID_NIC_7_0 = 101,
148 GAUDI_QUEUE_ID_NIC_7_1 = 102,
149 GAUDI_QUEUE_ID_NIC_7_2 = 103,
150 GAUDI_QUEUE_ID_NIC_7_3 = 104,
151 GAUDI_QUEUE_ID_NIC_8_0 = 105,
152 GAUDI_QUEUE_ID_NIC_8_1 = 106,
153 GAUDI_QUEUE_ID_NIC_8_2 = 107,
154 GAUDI_QUEUE_ID_NIC_8_3 = 108,
155 GAUDI_QUEUE_ID_NIC_9_0 = 109,
156 GAUDI_QUEUE_ID_NIC_9_1 = 110,
157 GAUDI_QUEUE_ID_NIC_9_2 = 111,
158 GAUDI_QUEUE_ID_NIC_9_3 = 112,
159 GAUDI_QUEUE_ID_SIZE
160};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700161enum goya_engine_id {
162 GOYA_ENGINE_ID_DMA_0 = 0,
163 GOYA_ENGINE_ID_DMA_1,
164 GOYA_ENGINE_ID_DMA_2,
165 GOYA_ENGINE_ID_DMA_3,
166 GOYA_ENGINE_ID_DMA_4,
167 GOYA_ENGINE_ID_MME_0,
168 GOYA_ENGINE_ID_TPC_0,
169 GOYA_ENGINE_ID_TPC_1,
170 GOYA_ENGINE_ID_TPC_2,
171 GOYA_ENGINE_ID_TPC_3,
172 GOYA_ENGINE_ID_TPC_4,
173 GOYA_ENGINE_ID_TPC_5,
174 GOYA_ENGINE_ID_TPC_6,
175 GOYA_ENGINE_ID_TPC_7,
176 GOYA_ENGINE_ID_SIZE
177};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700178enum gaudi_engine_id {
179 GAUDI_ENGINE_ID_DMA_0 = 0,
180 GAUDI_ENGINE_ID_DMA_1,
181 GAUDI_ENGINE_ID_DMA_2,
182 GAUDI_ENGINE_ID_DMA_3,
183 GAUDI_ENGINE_ID_DMA_4,
184 GAUDI_ENGINE_ID_DMA_5,
185 GAUDI_ENGINE_ID_DMA_6,
186 GAUDI_ENGINE_ID_DMA_7,
187 GAUDI_ENGINE_ID_MME_0,
188 GAUDI_ENGINE_ID_MME_1,
189 GAUDI_ENGINE_ID_MME_2,
190 GAUDI_ENGINE_ID_MME_3,
191 GAUDI_ENGINE_ID_TPC_0,
192 GAUDI_ENGINE_ID_TPC_1,
193 GAUDI_ENGINE_ID_TPC_2,
194 GAUDI_ENGINE_ID_TPC_3,
195 GAUDI_ENGINE_ID_TPC_4,
196 GAUDI_ENGINE_ID_TPC_5,
197 GAUDI_ENGINE_ID_TPC_6,
198 GAUDI_ENGINE_ID_TPC_7,
199 GAUDI_ENGINE_ID_NIC_0,
200 GAUDI_ENGINE_ID_NIC_1,
201 GAUDI_ENGINE_ID_NIC_2,
202 GAUDI_ENGINE_ID_NIC_3,
203 GAUDI_ENGINE_ID_NIC_4,
204 GAUDI_ENGINE_ID_NIC_5,
205 GAUDI_ENGINE_ID_NIC_6,
206 GAUDI_ENGINE_ID_NIC_7,
207 GAUDI_ENGINE_ID_NIC_8,
208 GAUDI_ENGINE_ID_NIC_9,
209 GAUDI_ENGINE_ID_SIZE
210};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000211enum hl_goya_pll_index {
212 HL_GOYA_CPU_PLL = 0,
213 HL_GOYA_IC_PLL,
214 HL_GOYA_MC_PLL,
215 HL_GOYA_MME_PLL,
216 HL_GOYA_PCI_PLL,
217 HL_GOYA_EMMC_PLL,
218 HL_GOYA_TPC_PLL,
219 HL_GOYA_PLL_MAX
220};
221enum hl_gaudi_pll_index {
222 HL_GAUDI_CPU_PLL = 0,
223 HL_GAUDI_PCI_PLL,
224 HL_GAUDI_SRAM_PLL,
225 HL_GAUDI_HBM_PLL,
226 HL_GAUDI_NIC_PLL,
227 HL_GAUDI_DMA_PLL,
228 HL_GAUDI_MESH_PLL,
229 HL_GAUDI_MME_PLL,
230 HL_GAUDI_TPC_PLL,
231 HL_GAUDI_IF_PLL,
232 HL_GAUDI_PLL_MAX
233};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700234enum hl_device_status {
235 HL_DEVICE_STATUS_OPERATIONAL,
236 HL_DEVICE_STATUS_IN_RESET,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800237 HL_DEVICE_STATUS_MALFUNCTION,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700238 HL_DEVICE_STATUS_NEEDS_RESET,
239 HL_DEVICE_STATUS_IN_DEVICE_CREATION,
240 HL_DEVICE_STATUS_LAST = HL_DEVICE_STATUS_IN_DEVICE_CREATION
241};
242enum hl_server_type {
243 HL_SERVER_TYPE_UNKNOWN = 0,
244 HL_SERVER_GAUDI_HLS1 = 1,
245 HL_SERVER_GAUDI_HLS1H = 2,
246 HL_SERVER_GAUDI_TYPE1 = 3,
247 HL_SERVER_GAUDI_TYPE2 = 4
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700248};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700249#define HL_INFO_HW_IP_INFO 0
250#define HL_INFO_HW_EVENTS 1
251#define HL_INFO_DRAM_USAGE 2
252#define HL_INFO_HW_IDLE 3
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700253#define HL_INFO_DEVICE_STATUS 4
Christopher Ferris9584fa42019-12-09 15:36:13 -0800254#define HL_INFO_DEVICE_UTILIZATION 6
255#define HL_INFO_HW_EVENTS_AGGREGATE 7
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800256#define HL_INFO_CLK_RATE 8
257#define HL_INFO_RESET_COUNT 9
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700258#define HL_INFO_TIME_SYNC 10
Christopher Ferris25c18d42020-10-14 17:42:58 -0700259#define HL_INFO_CS_COUNTERS 11
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800260#define HL_INFO_PCI_COUNTERS 12
261#define HL_INFO_CLK_THROTTLE_REASON 13
262#define HL_INFO_SYNC_MANAGER 14
263#define HL_INFO_TOTAL_ENERGY 15
Christopher Ferris05667cd2021-02-16 16:01:34 -0800264#define HL_INFO_PLL_FREQUENCY 16
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000265#define HL_INFO_POWER 17
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000266#define HL_INFO_OPEN_STATS 18
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700267#define HL_INFO_VERSION_MAX_LEN 128
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800268#define HL_INFO_CARD_NAME_MAX_LEN 16
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700269struct hl_info_hw_ip_info {
270 __u64 sram_base_address;
271 __u64 dram_base_address;
272 __u64 dram_size;
273 __u32 sram_size;
274 __u32 num_of_events;
275 __u32 device_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700276 __u32 module_id;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700277 __u32 reserved;
278 __u16 first_available_interrupt_id;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700279 __u16 server_type;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800280 __u32 cpld_version;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700281 __u32 psoc_pci_pll_nr;
282 __u32 psoc_pci_pll_nf;
283 __u32 psoc_pci_pll_od;
284 __u32 psoc_pci_pll_div_factor;
285 __u8 tpc_enabled_mask;
286 __u8 dram_enabled;
287 __u8 pad[2];
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800288 __u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800289 __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700290 __u64 reserved2;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700291 __u64 dram_page_size;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700292};
293struct hl_info_dram_usage {
294 __u64 dram_free_mem;
295 __u64 ctx_dram_mem;
296};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700297#define HL_BUSY_ENGINES_MASK_EXT_SIZE 2
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700298struct hl_info_hw_idle {
299 __u32 is_idle;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700300 __u32 busy_engines_mask;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700301 __u64 busy_engines_mask_ext[HL_BUSY_ENGINES_MASK_EXT_SIZE];
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700302};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700303struct hl_info_device_status {
304 __u32 status;
305 __u32 pad;
306};
Christopher Ferris9584fa42019-12-09 15:36:13 -0800307struct hl_info_device_utilization {
308 __u32 utilization;
309 __u32 pad;
310};
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800311struct hl_info_clk_rate {
312 __u32 cur_clk_rate_mhz;
313 __u32 max_clk_rate_mhz;
314};
315struct hl_info_reset_count {
316 __u32 hard_reset_cnt;
317 __u32 soft_reset_cnt;
318};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700319struct hl_info_time_sync {
320 __u64 device_time;
321 __u64 host_time;
322};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800323struct hl_info_pci_counters {
324 __u64 rx_throughput;
325 __u64 tx_throughput;
326 __u64 replay_cnt;
327};
328#define HL_CLK_THROTTLE_POWER 0x1
329#define HL_CLK_THROTTLE_THERMAL 0x2
330struct hl_info_clk_throttle {
331 __u32 clk_throttling_reason;
332};
333struct hl_info_energy {
334 __u64 total_energy_consumption;
335};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800336#define HL_PLL_NUM_OUTPUTS 4
337struct hl_pll_frequency_info {
338 __u16 output[HL_PLL_NUM_OUTPUTS];
339};
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000340struct hl_open_stats_info {
341 __u64 open_counter;
342 __u64 last_open_period_ms;
343};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000344struct hl_power_info {
345 __u64 power;
346};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800347struct hl_info_sync_manager {
348 __u32 first_available_sync_object;
349 __u32 first_available_monitor;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700350 __u32 first_available_cq;
351 __u32 reserved;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800352};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700353struct hl_info_cs_counters {
Christopher Ferris05667cd2021-02-16 16:01:34 -0800354 __u64 total_out_of_mem_drop_cnt;
355 __u64 ctx_out_of_mem_drop_cnt;
356 __u64 total_parsing_drop_cnt;
357 __u64 ctx_parsing_drop_cnt;
358 __u64 total_queue_full_drop_cnt;
359 __u64 ctx_queue_full_drop_cnt;
360 __u64 total_device_in_reset_drop_cnt;
361 __u64 ctx_device_in_reset_drop_cnt;
362 __u64 total_max_cs_in_flight_drop_cnt;
363 __u64 ctx_max_cs_in_flight_drop_cnt;
364 __u64 total_validation_drop_cnt;
365 __u64 ctx_validation_drop_cnt;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700366};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800367enum gaudi_dcores {
368 HL_GAUDI_WS_DCORE,
369 HL_GAUDI_WN_DCORE,
370 HL_GAUDI_EN_DCORE,
371 HL_GAUDI_ES_DCORE
372};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700373struct hl_info_args {
374 __u64 return_pointer;
375 __u32 return_size;
376 __u32 op;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800377 union {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800378 __u32 dcore_id;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800379 __u32 ctx_id;
380 __u32 period_ms;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800381 __u32 pll_index;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800382 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700383 __u32 pad;
384};
385#define HL_CB_OP_CREATE 0
386#define HL_CB_OP_DESTROY 1
Christopher Ferris05667cd2021-02-16 16:01:34 -0800387#define HL_CB_OP_INFO 2
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700388#define HL_MAX_CB_SIZE (0x200000 - 32)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800389#define HL_CB_FLAGS_MAP 0x1
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700390struct hl_cb_in {
391 __u64 cb_handle;
392 __u32 op;
393 __u32 cb_size;
394 __u32 ctx_id;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800395 __u32 flags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700396};
397struct hl_cb_out {
Christopher Ferris05667cd2021-02-16 16:01:34 -0800398 union {
399 __u64 cb_handle;
400 struct {
401 __u32 usage_cnt;
402 __u32 pad;
403 };
404 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700405};
406union hl_cb_args {
407 struct hl_cb_in in;
408 struct hl_cb_out out;
409};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800410#define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x1
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700411struct hl_cs_chunk {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700412 union {
413 __u64 cb_handle;
414 __u64 signal_seq_arr;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700415 __u64 encaps_signal_seq;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700416 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700417 __u32 queue_index;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700418 union {
419 __u32 cb_size;
420 __u32 num_signal_seq_arr;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700421 __u32 encaps_signal_offset;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700422 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700423 __u32 cs_chunk_flags;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800424 __u32 collective_engine_id;
425 __u32 pad[10];
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700426};
427#define HL_CS_FLAGS_FORCE_RESTORE 0x1
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700428#define HL_CS_FLAGS_SIGNAL 0x2
429#define HL_CS_FLAGS_WAIT 0x4
Christopher Ferris05667cd2021-02-16 16:01:34 -0800430#define HL_CS_FLAGS_COLLECTIVE_WAIT 0x8
431#define HL_CS_FLAGS_TIMESTAMP 0x20
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700432#define HL_CS_FLAGS_STAGED_SUBMISSION 0x40
433#define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x80
434#define HL_CS_FLAGS_STAGED_SUBMISSION_LAST 0x100
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000435#define HL_CS_FLAGS_CUSTOM_TIMEOUT 0x200
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000436#define HL_CS_FLAGS_SKIP_RESET_ON_TIMEOUT 0x400
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700437#define HL_CS_FLAGS_ENCAP_SIGNALS 0x800
438#define HL_CS_FLAGS_RESERVE_SIGNALS_ONLY 0x1000
439#define HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY 0x2000
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700440#define HL_CS_STATUS_SUCCESS 0
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800441#define HL_MAX_JOBS_PER_CS 512
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700442struct hl_cs_in {
443 __u64 chunks_restore;
444 __u64 chunks_execute;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700445 union {
446 __u64 seq;
447 __u32 encaps_sig_handle_id;
448 struct {
449 __u32 encaps_signals_count;
450 __u32 encaps_signals_q_idx;
451 };
452 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700453 __u32 num_chunks_restore;
454 __u32 num_chunks_execute;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000455 __u32 timeout;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700456 __u32 cs_flags;
457 __u32 ctx_id;
458};
459struct hl_cs_out {
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700460 union {
461 __u64 seq;
462 struct {
463 __u32 handle_id;
464 __u32 count;
465 };
466 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700467 __u32 status;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700468 __u32 sob_base_addr_offset;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700469};
470union hl_cs_args {
471 struct hl_cs_in in;
472 struct hl_cs_out out;
473};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000474#define HL_WAIT_CS_FLAGS_INTERRUPT 0x2
475#define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700476#define HL_WAIT_CS_FLAGS_MULTI_CS 0x4
477#define HL_WAIT_MULTI_CS_LIST_MAX_LEN 32
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700478struct hl_wait_cs_in {
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000479 union {
480 struct {
481 __u64 seq;
482 __u64 timeout_us;
483 };
484 struct {
485 __u64 addr;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800486 __u64 target;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000487 };
488 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700489 __u32 ctx_id;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000490 __u32 flags;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700491 __u8 seq_arr_len;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800492 __u8 pad[3];
493 __u32 interrupt_timeout_us;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700494};
495#define HL_WAIT_CS_STATUS_COMPLETED 0
496#define HL_WAIT_CS_STATUS_BUSY 1
497#define HL_WAIT_CS_STATUS_TIMEDOUT 2
498#define HL_WAIT_CS_STATUS_ABORTED 3
Christopher Ferris05667cd2021-02-16 16:01:34 -0800499#define HL_WAIT_CS_STATUS_FLAG_GONE 0x1
500#define HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD 0x2
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700501struct hl_wait_cs_out {
502 __u32 status;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800503 __u32 flags;
504 __s64 timestamp_nsec;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700505 __u32 cs_completion_map;
506 __u32 pad;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700507};
508union hl_wait_cs_args {
509 struct hl_wait_cs_in in;
510 struct hl_wait_cs_out out;
511};
512#define HL_MEM_OP_ALLOC 0
513#define HL_MEM_OP_FREE 1
514#define HL_MEM_OP_MAP 2
515#define HL_MEM_OP_UNMAP 3
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700516#define HL_MEM_OP_MAP_BLOCK 4
Christopher Ferrisa4792612022-01-10 13:51:15 -0800517#define HL_MEM_OP_EXPORT_DMABUF_FD 5
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700518#define HL_MEM_CONTIGUOUS 0x1
519#define HL_MEM_SHARED 0x2
520#define HL_MEM_USERPTR 0x4
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700521#define HL_MEM_FORCE_HINT 0x8
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700522struct hl_mem_in {
523 union {
524 struct {
525 __u64 mem_size;
526 } alloc;
527 struct {
528 __u64 handle;
529 } free;
530 struct {
531 __u64 hint_addr;
532 __u64 handle;
533 } map_device;
534 struct {
535 __u64 host_virt_addr;
536 __u64 hint_addr;
537 __u64 mem_size;
538 } map_host;
539 struct {
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700540 __u64 block_addr;
541 } map_block;
542 struct {
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700543 __u64 device_virt_addr;
544 } unmap;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800545 struct {
546 __u64 handle;
547 __u64 mem_size;
548 } export_dmabuf_fd;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700549 };
550 __u32 op;
551 __u32 flags;
552 __u32 ctx_id;
553 __u32 pad;
554};
555struct hl_mem_out {
556 union {
557 __u64 device_virt_addr;
558 __u64 handle;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700559 struct {
560 __u64 block_handle;
561 __u32 block_size;
562 __u32 pad;
563 };
Christopher Ferrisa4792612022-01-10 13:51:15 -0800564 __s32 fd;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700565 };
566};
567union hl_mem_args {
568 struct hl_mem_in in;
569 struct hl_mem_out out;
570};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700571#define HL_DEBUG_MAX_AUX_VALUES 10
572struct hl_debug_params_etr {
573 __u64 buffer_address;
574 __u64 buffer_size;
575 __u32 sink_mode;
576 __u32 pad;
577};
578struct hl_debug_params_etf {
579 __u64 buffer_address;
580 __u64 buffer_size;
581 __u32 sink_mode;
582 __u32 pad;
583};
584struct hl_debug_params_stm {
585 __u64 he_mask;
586 __u64 sp_mask;
587 __u32 id;
588 __u32 frequency;
589};
590struct hl_debug_params_bmon {
591 __u64 start_addr0;
592 __u64 addr_mask0;
593 __u64 start_addr1;
594 __u64 addr_mask1;
595 __u32 bw_win;
596 __u32 win_capture;
597 __u32 id;
598 __u32 pad;
599};
600struct hl_debug_params_spmu {
601 __u64 event_types[HL_DEBUG_MAX_AUX_VALUES];
602 __u32 event_types_num;
603 __u32 pad;
604};
605#define HL_DEBUG_OP_ETR 0
606#define HL_DEBUG_OP_ETF 1
607#define HL_DEBUG_OP_STM 2
608#define HL_DEBUG_OP_FUNNEL 3
609#define HL_DEBUG_OP_BMON 4
610#define HL_DEBUG_OP_SPMU 5
611#define HL_DEBUG_OP_TIMESTAMP 6
612#define HL_DEBUG_OP_SET_MODE 7
613struct hl_debug_args {
614 __u64 input_ptr;
615 __u64 output_ptr;
616 __u32 input_size;
617 __u32 output_size;
618 __u32 op;
619 __u32 reg_idx;
620 __u32 enable;
621 __u32 ctx_id;
622};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700623#define HL_IOCTL_INFO _IOWR('H', 0x01, struct hl_info_args)
624#define HL_IOCTL_CB _IOWR('H', 0x02, union hl_cb_args)
625#define HL_IOCTL_CS _IOWR('H', 0x03, union hl_cs_args)
626#define HL_IOCTL_WAIT_CS _IOWR('H', 0x04, union hl_wait_cs_args)
627#define HL_IOCTL_MEMORY _IOWR('H', 0x05, union hl_mem_args)
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700628#define HL_IOCTL_DEBUG _IOWR('H', 0x06, struct hl_debug_args)
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700629#define HL_COMMAND_START 0x01
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700630#define HL_COMMAND_END 0x07
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700631#endif