blob: 2d18d7ebf2019ed35a7b260ce245173e25b6e55b [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 Ferris10a76e62022-06-08 13:31:52 -070027#define TS_MAX_ELEMENTS_NUM (1 << 20)
Christopher Ferris24f97eb2019-05-20 12:58:13 -070028enum goya_queue_id {
29 GOYA_QUEUE_ID_DMA_0 = 0,
Christopher Ferris9584fa42019-12-09 15:36:13 -080030 GOYA_QUEUE_ID_DMA_1 = 1,
31 GOYA_QUEUE_ID_DMA_2 = 2,
32 GOYA_QUEUE_ID_DMA_3 = 3,
33 GOYA_QUEUE_ID_DMA_4 = 4,
34 GOYA_QUEUE_ID_CPU_PQ = 5,
35 GOYA_QUEUE_ID_MME = 6,
36 GOYA_QUEUE_ID_TPC0 = 7,
37 GOYA_QUEUE_ID_TPC1 = 8,
38 GOYA_QUEUE_ID_TPC2 = 9,
39 GOYA_QUEUE_ID_TPC3 = 10,
40 GOYA_QUEUE_ID_TPC4 = 11,
41 GOYA_QUEUE_ID_TPC5 = 12,
42 GOYA_QUEUE_ID_TPC6 = 13,
43 GOYA_QUEUE_ID_TPC7 = 14,
Christopher Ferris24f97eb2019-05-20 12:58:13 -070044 GOYA_QUEUE_ID_SIZE
45};
Christopher Ferris8177cdf2020-08-03 11:53:55 -070046enum gaudi_queue_id {
47 GAUDI_QUEUE_ID_DMA_0_0 = 0,
48 GAUDI_QUEUE_ID_DMA_0_1 = 1,
49 GAUDI_QUEUE_ID_DMA_0_2 = 2,
50 GAUDI_QUEUE_ID_DMA_0_3 = 3,
51 GAUDI_QUEUE_ID_DMA_1_0 = 4,
52 GAUDI_QUEUE_ID_DMA_1_1 = 5,
53 GAUDI_QUEUE_ID_DMA_1_2 = 6,
54 GAUDI_QUEUE_ID_DMA_1_3 = 7,
55 GAUDI_QUEUE_ID_CPU_PQ = 8,
56 GAUDI_QUEUE_ID_DMA_2_0 = 9,
57 GAUDI_QUEUE_ID_DMA_2_1 = 10,
58 GAUDI_QUEUE_ID_DMA_2_2 = 11,
59 GAUDI_QUEUE_ID_DMA_2_3 = 12,
60 GAUDI_QUEUE_ID_DMA_3_0 = 13,
61 GAUDI_QUEUE_ID_DMA_3_1 = 14,
62 GAUDI_QUEUE_ID_DMA_3_2 = 15,
63 GAUDI_QUEUE_ID_DMA_3_3 = 16,
64 GAUDI_QUEUE_ID_DMA_4_0 = 17,
65 GAUDI_QUEUE_ID_DMA_4_1 = 18,
66 GAUDI_QUEUE_ID_DMA_4_2 = 19,
67 GAUDI_QUEUE_ID_DMA_4_3 = 20,
68 GAUDI_QUEUE_ID_DMA_5_0 = 21,
69 GAUDI_QUEUE_ID_DMA_5_1 = 22,
70 GAUDI_QUEUE_ID_DMA_5_2 = 23,
71 GAUDI_QUEUE_ID_DMA_5_3 = 24,
72 GAUDI_QUEUE_ID_DMA_6_0 = 25,
73 GAUDI_QUEUE_ID_DMA_6_1 = 26,
74 GAUDI_QUEUE_ID_DM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DI_QUEUE_ID_NIC_5_3 = 96,
144 GAUDI_QUEUE_ID_NIC_6_0 = 97,
145 GAUDI_QUEUE_ID_NIC_6_1 = 98,
146 GAUDI_QUEUE_ID_NIC_6_2 = 99,
147 GAUDI_QUEUE_ID_NIC_6_3 = 100,
148 GAUDI_QUEUE_ID_NIC_7_0 = 101,
149 GAUDI_QUEUE_ID_NIC_7_1 = 102,
150 GAUDI_QUEUE_ID_NIC_7_2 = 103,
151 GAUDI_QUEUE_ID_NIC_7_3 = 104,
152 GAUDI_QUEUE_ID_NIC_8_0 = 105,
153 GAUDI_QUEUE_ID_NIC_8_1 = 106,
154 GAUDI_QUEUE_ID_NIC_8_2 = 107,
155 GAUDI_QUEUE_ID_NIC_8_3 = 108,
156 GAUDI_QUEUE_ID_NIC_9_0 = 109,
157 GAUDI_QUEUE_ID_NIC_9_1 = 110,
158 GAUDI_QUEUE_ID_NIC_9_2 = 111,
159 GAUDI_QUEUE_ID_NIC_9_3 = 112,
160 GAUDI_QUEUE_ID_SIZE
161};
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700162enum goya_engine_id {
163 GOYA_ENGINE_ID_DMA_0 = 0,
164 GOYA_ENGINE_ID_DMA_1,
165 GOYA_ENGINE_ID_DMA_2,
166 GOYA_ENGINE_ID_DMA_3,
167 GOYA_ENGINE_ID_DMA_4,
168 GOYA_ENGINE_ID_MME_0,
169 GOYA_ENGINE_ID_TPC_0,
170 GOYA_ENGINE_ID_TPC_1,
171 GOYA_ENGINE_ID_TPC_2,
172 GOYA_ENGINE_ID_TPC_3,
173 GOYA_ENGINE_ID_TPC_4,
174 GOYA_ENGINE_ID_TPC_5,
175 GOYA_ENGINE_ID_TPC_6,
176 GOYA_ENGINE_ID_TPC_7,
177 GOYA_ENGINE_ID_SIZE
178};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700179enum gaudi_engine_id {
180 GAUDI_ENGINE_ID_DMA_0 = 0,
181 GAUDI_ENGINE_ID_DMA_1,
182 GAUDI_ENGINE_ID_DMA_2,
183 GAUDI_ENGINE_ID_DMA_3,
184 GAUDI_ENGINE_ID_DMA_4,
185 GAUDI_ENGINE_ID_DMA_5,
186 GAUDI_ENGINE_ID_DMA_6,
187 GAUDI_ENGINE_ID_DMA_7,
188 GAUDI_ENGINE_ID_MME_0,
189 GAUDI_ENGINE_ID_MME_1,
190 GAUDI_ENGINE_ID_MME_2,
191 GAUDI_ENGINE_ID_MME_3,
192 GAUDI_ENGINE_ID_TPC_0,
193 GAUDI_ENGINE_ID_TPC_1,
194 GAUDI_ENGINE_ID_TPC_2,
195 GAUDI_ENGINE_ID_TPC_3,
196 GAUDI_ENGINE_ID_TPC_4,
197 GAUDI_ENGINE_ID_TPC_5,
198 GAUDI_ENGINE_ID_TPC_6,
199 GAUDI_ENGINE_ID_TPC_7,
200 GAUDI_ENGINE_ID_NIC_0,
201 GAUDI_ENGINE_ID_NIC_1,
202 GAUDI_ENGINE_ID_NIC_2,
203 GAUDI_ENGINE_ID_NIC_3,
204 GAUDI_ENGINE_ID_NIC_4,
205 GAUDI_ENGINE_ID_NIC_5,
206 GAUDI_ENGINE_ID_NIC_6,
207 GAUDI_ENGINE_ID_NIC_7,
208 GAUDI_ENGINE_ID_NIC_8,
209 GAUDI_ENGINE_ID_NIC_9,
210 GAUDI_ENGINE_ID_SIZE
211};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000212enum hl_goya_pll_index {
213 HL_GOYA_CPU_PLL = 0,
214 HL_GOYA_IC_PLL,
215 HL_GOYA_MC_PLL,
216 HL_GOYA_MME_PLL,
217 HL_GOYA_PCI_PLL,
218 HL_GOYA_EMMC_PLL,
219 HL_GOYA_TPC_PLL,
220 HL_GOYA_PLL_MAX
221};
222enum hl_gaudi_pll_index {
223 HL_GAUDI_CPU_PLL = 0,
224 HL_GAUDI_PCI_PLL,
225 HL_GAUDI_SRAM_PLL,
226 HL_GAUDI_HBM_PLL,
227 HL_GAUDI_NIC_PLL,
228 HL_GAUDI_DMA_PLL,
229 HL_GAUDI_MESH_PLL,
230 HL_GAUDI_MME_PLL,
231 HL_GAUDI_TPC_PLL,
232 HL_GAUDI_IF_PLL,
233 HL_GAUDI_PLL_MAX
234};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700235enum hl_device_status {
236 HL_DEVICE_STATUS_OPERATIONAL,
237 HL_DEVICE_STATUS_IN_RESET,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800238 HL_DEVICE_STATUS_MALFUNCTION,
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700239 HL_DEVICE_STATUS_NEEDS_RESET,
240 HL_DEVICE_STATUS_IN_DEVICE_CREATION,
241 HL_DEVICE_STATUS_LAST = HL_DEVICE_STATUS_IN_DEVICE_CREATION
242};
243enum hl_server_type {
244 HL_SERVER_TYPE_UNKNOWN = 0,
245 HL_SERVER_GAUDI_HLS1 = 1,
246 HL_SERVER_GAUDI_HLS1H = 2,
247 HL_SERVER_GAUDI_TYPE1 = 3,
248 HL_SERVER_GAUDI_TYPE2 = 4
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700249};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700250#define HL_INFO_HW_IP_INFO 0
251#define HL_INFO_HW_EVENTS 1
252#define HL_INFO_DRAM_USAGE 2
253#define HL_INFO_HW_IDLE 3
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700254#define HL_INFO_DEVICE_STATUS 4
Christopher Ferris9584fa42019-12-09 15:36:13 -0800255#define HL_INFO_DEVICE_UTILIZATION 6
256#define HL_INFO_HW_EVENTS_AGGREGATE 7
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800257#define HL_INFO_CLK_RATE 8
258#define HL_INFO_RESET_COUNT 9
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700259#define HL_INFO_TIME_SYNC 10
Christopher Ferris25c18d42020-10-14 17:42:58 -0700260#define HL_INFO_CS_COUNTERS 11
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800261#define HL_INFO_PCI_COUNTERS 12
262#define HL_INFO_CLK_THROTTLE_REASON 13
263#define HL_INFO_SYNC_MANAGER 14
264#define HL_INFO_TOTAL_ENERGY 15
Christopher Ferris05667cd2021-02-16 16:01:34 -0800265#define HL_INFO_PLL_FREQUENCY 16
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000266#define HL_INFO_POWER 17
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000267#define HL_INFO_OPEN_STATS 18
Christopher Ferris1ed55342022-03-22 16:06:25 -0700268#define HL_INFO_DRAM_REPLACED_ROWS 21
269#define HL_INFO_DRAM_PENDING_ROWS 22
270#define HL_INFO_LAST_ERR_OPEN_DEV_TIME 23
271#define HL_INFO_CS_TIMEOUT_EVENT 24
272#define HL_INFO_RAZWI_EVENT 25
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700273#define HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES 26
274#define HL_INFO_REGISTER_EVENTFD 28
275#define HL_INFO_UNREGISTER_EVENTFD 29
276#define HL_INFO_GET_EVENTS 30
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700277#define HL_INFO_VERSION_MAX_LEN 128
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800278#define HL_INFO_CARD_NAME_MAX_LEN 16
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700279struct hl_info_hw_ip_info {
280 __u64 sram_base_address;
281 __u64 dram_base_address;
282 __u64 dram_size;
283 __u32 sram_size;
284 __u32 num_of_events;
285 __u32 device_id;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700286 __u32 module_id;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700287 __u32 reserved;
288 __u16 first_available_interrupt_id;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700289 __u16 server_type;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800290 __u32 cpld_version;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700291 __u32 psoc_pci_pll_nr;
292 __u32 psoc_pci_pll_nf;
293 __u32 psoc_pci_pll_od;
294 __u32 psoc_pci_pll_div_factor;
295 __u8 tpc_enabled_mask;
296 __u8 dram_enabled;
297 __u8 pad[2];
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800298 __u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800299 __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700300 __u64 reserved2;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700301 __u64 dram_page_size;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700302 __u32 reserved3;
303 __u16 number_of_user_interrupts;
304 __u16 pad2;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700305 __u64 reserved4;
306 __u64 device_mem_alloc_default_page_size;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700307};
308struct hl_info_dram_usage {
309 __u64 dram_free_mem;
310 __u64 ctx_dram_mem;
311};
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700312#define HL_BUSY_ENGINES_MASK_EXT_SIZE 2
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700313struct hl_info_hw_idle {
314 __u32 is_idle;
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700315 __u32 busy_engines_mask;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700316 __u64 busy_engines_mask_ext[HL_BUSY_ENGINES_MASK_EXT_SIZE];
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700317};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700318struct hl_info_device_status {
319 __u32 status;
320 __u32 pad;
321};
Christopher Ferris9584fa42019-12-09 15:36:13 -0800322struct hl_info_device_utilization {
323 __u32 utilization;
324 __u32 pad;
325};
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800326struct hl_info_clk_rate {
327 __u32 cur_clk_rate_mhz;
328 __u32 max_clk_rate_mhz;
329};
330struct hl_info_reset_count {
331 __u32 hard_reset_cnt;
332 __u32 soft_reset_cnt;
333};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700334struct hl_info_time_sync {
335 __u64 device_time;
336 __u64 host_time;
337};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800338struct hl_info_pci_counters {
339 __u64 rx_throughput;
340 __u64 tx_throughput;
341 __u64 replay_cnt;
342};
Christopher Ferris1ed55342022-03-22 16:06:25 -0700343enum hl_clk_throttling_type {
344 HL_CLK_THROTTLE_TYPE_POWER,
345 HL_CLK_THROTTLE_TYPE_THERMAL,
346 HL_CLK_THROTTLE_TYPE_MAX
347};
348#define HL_CLK_THROTTLE_POWER (1 << HL_CLK_THROTTLE_TYPE_POWER)
349#define HL_CLK_THROTTLE_THERMAL (1 << HL_CLK_THROTTLE_TYPE_THERMAL)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800350struct hl_info_clk_throttle {
351 __u32 clk_throttling_reason;
Christopher Ferris1ed55342022-03-22 16:06:25 -0700352 __u32 pad;
353 __u64 clk_throttling_timestamp_us[HL_CLK_THROTTLE_TYPE_MAX];
354 __u64 clk_throttling_duration_ns[HL_CLK_THROTTLE_TYPE_MAX];
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800355};
356struct hl_info_energy {
357 __u64 total_energy_consumption;
358};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800359#define HL_PLL_NUM_OUTPUTS 4
360struct hl_pll_frequency_info {
361 __u16 output[HL_PLL_NUM_OUTPUTS];
362};
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000363struct hl_open_stats_info {
364 __u64 open_counter;
365 __u64 last_open_period_ms;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700366 __u8 is_compute_ctx_active;
367 __u8 compute_ctx_in_release;
368 __u8 pad[6];
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000369};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000370struct hl_power_info {
371 __u64 power;
372};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800373struct hl_info_sync_manager {
374 __u32 first_available_sync_object;
375 __u32 first_available_monitor;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700376 __u32 first_available_cq;
377 __u32 reserved;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800378};
Christopher Ferris25c18d42020-10-14 17:42:58 -0700379struct hl_info_cs_counters {
Christopher Ferris05667cd2021-02-16 16:01:34 -0800380 __u64 total_out_of_mem_drop_cnt;
381 __u64 ctx_out_of_mem_drop_cnt;
382 __u64 total_parsing_drop_cnt;
383 __u64 ctx_parsing_drop_cnt;
384 __u64 total_queue_full_drop_cnt;
385 __u64 ctx_queue_full_drop_cnt;
386 __u64 total_device_in_reset_drop_cnt;
387 __u64 ctx_device_in_reset_drop_cnt;
388 __u64 total_max_cs_in_flight_drop_cnt;
389 __u64 ctx_max_cs_in_flight_drop_cnt;
390 __u64 total_validation_drop_cnt;
391 __u64 ctx_validation_drop_cnt;
Christopher Ferris25c18d42020-10-14 17:42:58 -0700392};
Christopher Ferris1ed55342022-03-22 16:06:25 -0700393struct hl_info_last_err_open_dev_time {
394 __s64 timestamp;
395};
396struct hl_info_cs_timeout_event {
397 __s64 timestamp;
398 __u64 seq;
399};
400#define HL_RAZWI_PAGE_FAULT 0
401#define HL_RAZWI_MMU_ACCESS_ERROR 1
402struct hl_info_razwi_event {
403 __s64 timestamp;
404 __u64 addr;
405 __u16 engine_id_1;
406 __u16 engine_id_2;
407 __u8 no_engine_id;
408 __u8 error_type;
409 __u8 pad[2];
410};
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700411struct hl_info_dev_memalloc_page_sizes {
412 __u64 page_order_bitmask;
413};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800414enum gaudi_dcores {
415 HL_GAUDI_WS_DCORE,
416 HL_GAUDI_WN_DCORE,
417 HL_GAUDI_EN_DCORE,
418 HL_GAUDI_ES_DCORE
419};
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700420struct hl_info_args {
421 __u64 return_pointer;
422 __u32 return_size;
423 __u32 op;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800424 union {
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800425 __u32 dcore_id;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800426 __u32 ctx_id;
427 __u32 period_ms;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800428 __u32 pll_index;
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700429 __u32 eventfd;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800430 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700431 __u32 pad;
432};
433#define HL_CB_OP_CREATE 0
434#define HL_CB_OP_DESTROY 1
Christopher Ferris05667cd2021-02-16 16:01:34 -0800435#define HL_CB_OP_INFO 2
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700436#define HL_MAX_CB_SIZE (0x200000 - 32)
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800437#define HL_CB_FLAGS_MAP 0x1
Christopher Ferris1ed55342022-03-22 16:06:25 -0700438#define HL_CB_FLAGS_GET_DEVICE_VA 0x2
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700439struct hl_cb_in {
440 __u64 cb_handle;
441 __u32 op;
442 __u32 cb_size;
443 __u32 ctx_id;
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800444 __u32 flags;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700445};
446struct hl_cb_out {
Christopher Ferris05667cd2021-02-16 16:01:34 -0800447 union {
448 __u64 cb_handle;
Christopher Ferris1ed55342022-03-22 16:06:25 -0700449 union {
450 struct {
451 __u32 usage_cnt;
452 __u32 pad;
453 };
454 __u64 device_va;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800455 };
456 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700457};
458union hl_cb_args {
459 struct hl_cb_in in;
460 struct hl_cb_out out;
461};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800462#define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x1
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700463struct hl_cs_chunk {
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700464 union {
465 __u64 cb_handle;
466 __u64 signal_seq_arr;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700467 __u64 encaps_signal_seq;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700468 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700469 __u32 queue_index;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700470 union {
471 __u32 cb_size;
472 __u32 num_signal_seq_arr;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700473 __u32 encaps_signal_offset;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700474 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700475 __u32 cs_chunk_flags;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800476 __u32 collective_engine_id;
477 __u32 pad[10];
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700478};
479#define HL_CS_FLAGS_FORCE_RESTORE 0x1
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700480#define HL_CS_FLAGS_SIGNAL 0x2
481#define HL_CS_FLAGS_WAIT 0x4
Christopher Ferris05667cd2021-02-16 16:01:34 -0800482#define HL_CS_FLAGS_COLLECTIVE_WAIT 0x8
483#define HL_CS_FLAGS_TIMESTAMP 0x20
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700484#define HL_CS_FLAGS_STAGED_SUBMISSION 0x40
485#define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x80
486#define HL_CS_FLAGS_STAGED_SUBMISSION_LAST 0x100
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000487#define HL_CS_FLAGS_CUSTOM_TIMEOUT 0x200
Christopher Ferris3a39c0b2021-09-02 00:03:38 +0000488#define HL_CS_FLAGS_SKIP_RESET_ON_TIMEOUT 0x400
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700489#define HL_CS_FLAGS_ENCAP_SIGNALS 0x800
490#define HL_CS_FLAGS_RESERVE_SIGNALS_ONLY 0x1000
491#define HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY 0x2000
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700492#define HL_CS_STATUS_SUCCESS 0
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800493#define HL_MAX_JOBS_PER_CS 512
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700494struct hl_cs_in {
495 __u64 chunks_restore;
496 __u64 chunks_execute;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700497 union {
498 __u64 seq;
499 __u32 encaps_sig_handle_id;
500 struct {
501 __u32 encaps_signals_count;
502 __u32 encaps_signals_q_idx;
503 };
504 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700505 __u32 num_chunks_restore;
506 __u32 num_chunks_execute;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000507 __u32 timeout;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700508 __u32 cs_flags;
509 __u32 ctx_id;
510};
511struct hl_cs_out {
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700512 union {
513 __u64 seq;
514 struct {
515 __u32 handle_id;
516 __u32 count;
517 };
518 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700519 __u32 status;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700520 __u32 sob_base_addr_offset;
Christopher Ferris1ed55342022-03-22 16:06:25 -0700521 __u16 sob_count_before_submission;
522 __u16 pad[3];
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700523};
524union hl_cs_args {
525 struct hl_cs_in in;
526 struct hl_cs_out out;
527};
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000528#define HL_WAIT_CS_FLAGS_INTERRUPT 0x2
529#define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700530#define HL_WAIT_CS_FLAGS_MULTI_CS 0x4
Christopher Ferris1ed55342022-03-22 16:06:25 -0700531#define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x10
Christopher Ferris10a76e62022-06-08 13:31:52 -0700532#define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x20
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700533#define HL_WAIT_MULTI_CS_LIST_MAX_LEN 32
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700534struct hl_wait_cs_in {
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000535 union {
536 struct {
537 __u64 seq;
538 __u64 timeout_us;
539 };
540 struct {
Christopher Ferris1ed55342022-03-22 16:06:25 -0700541 union {
542 __u64 addr;
543 __u64 cq_counters_handle;
544 };
Christopher Ferrisa4792612022-01-10 13:51:15 -0800545 __u64 target;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000546 };
547 };
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700548 __u32 ctx_id;
Christopher Ferrisfcc3b4f2021-07-01 01:30:21 +0000549 __u32 flags;
Christopher Ferris1ed55342022-03-22 16:06:25 -0700550 union {
551 struct {
552 __u8 seq_arr_len;
553 __u8 pad[7];
554 };
555 __u64 interrupt_timeout_us;
556 };
557 __u64 cq_counters_offset;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700558 __u64 timestamp_handle;
559 __u64 timestamp_offset;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700560};
561#define HL_WAIT_CS_STATUS_COMPLETED 0
562#define HL_WAIT_CS_STATUS_BUSY 1
563#define HL_WAIT_CS_STATUS_TIMEDOUT 2
564#define HL_WAIT_CS_STATUS_ABORTED 3
Christopher Ferris05667cd2021-02-16 16:01:34 -0800565#define HL_WAIT_CS_STATUS_FLAG_GONE 0x1
566#define HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD 0x2
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700567struct hl_wait_cs_out {
568 __u32 status;
Christopher Ferris05667cd2021-02-16 16:01:34 -0800569 __u32 flags;
570 __s64 timestamp_nsec;
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700571 __u32 cs_completion_map;
572 __u32 pad;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700573};
574union hl_wait_cs_args {
575 struct hl_wait_cs_in in;
576 struct hl_wait_cs_out out;
577};
578#define HL_MEM_OP_ALLOC 0
579#define HL_MEM_OP_FREE 1
580#define HL_MEM_OP_MAP 2
581#define HL_MEM_OP_UNMAP 3
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700582#define HL_MEM_OP_MAP_BLOCK 4
Christopher Ferrisa4792612022-01-10 13:51:15 -0800583#define HL_MEM_OP_EXPORT_DMABUF_FD 5
Christopher Ferris10a76e62022-06-08 13:31:52 -0700584#define HL_MEM_OP_TS_ALLOC 6
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700585#define HL_MEM_CONTIGUOUS 0x1
586#define HL_MEM_SHARED 0x2
587#define HL_MEM_USERPTR 0x4
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700588#define HL_MEM_FORCE_HINT 0x8
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700589#define HL_MEM_PREFETCH 0x40
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700590struct hl_mem_in {
591 union {
592 struct {
593 __u64 mem_size;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700594 __u64 page_size;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700595 } alloc;
596 struct {
597 __u64 handle;
598 } free;
599 struct {
600 __u64 hint_addr;
601 __u64 handle;
602 } map_device;
603 struct {
604 __u64 host_virt_addr;
605 __u64 hint_addr;
606 __u64 mem_size;
607 } map_host;
608 struct {
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700609 __u64 block_addr;
610 } map_block;
611 struct {
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700612 __u64 device_virt_addr;
613 } unmap;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800614 struct {
615 __u64 handle;
616 __u64 mem_size;
617 } export_dmabuf_fd;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700618 };
619 __u32 op;
620 __u32 flags;
621 __u32 ctx_id;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700622 __u32 num_of_elements;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700623};
624struct hl_mem_out {
625 union {
626 __u64 device_virt_addr;
627 __u64 handle;
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700628 struct {
629 __u64 block_handle;
630 __u32 block_size;
631 __u32 pad;
632 };
Christopher Ferrisa4792612022-01-10 13:51:15 -0800633 __s32 fd;
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700634 };
635};
636union hl_mem_args {
637 struct hl_mem_in in;
638 struct hl_mem_out out;
639};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700640#define HL_DEBUG_MAX_AUX_VALUES 10
641struct hl_debug_params_etr {
642 __u64 buffer_address;
643 __u64 buffer_size;
644 __u32 sink_mode;
645 __u32 pad;
646};
647struct hl_debug_params_etf {
648 __u64 buffer_address;
649 __u64 buffer_size;
650 __u32 sink_mode;
651 __u32 pad;
652};
653struct hl_debug_params_stm {
654 __u64 he_mask;
655 __u64 sp_mask;
656 __u32 id;
657 __u32 frequency;
658};
659struct hl_debug_params_bmon {
660 __u64 start_addr0;
661 __u64 addr_mask0;
662 __u64 start_addr1;
663 __u64 addr_mask1;
664 __u32 bw_win;
665 __u32 win_capture;
666 __u32 id;
667 __u32 pad;
668};
669struct hl_debug_params_spmu {
670 __u64 event_types[HL_DEBUG_MAX_AUX_VALUES];
671 __u32 event_types_num;
672 __u32 pad;
673};
674#define HL_DEBUG_OP_ETR 0
675#define HL_DEBUG_OP_ETF 1
676#define HL_DEBUG_OP_STM 2
677#define HL_DEBUG_OP_FUNNEL 3
678#define HL_DEBUG_OP_BMON 4
679#define HL_DEBUG_OP_SPMU 5
680#define HL_DEBUG_OP_TIMESTAMP 6
681#define HL_DEBUG_OP_SET_MODE 7
682struct hl_debug_args {
683 __u64 input_ptr;
684 __u64 output_ptr;
685 __u32 input_size;
686 __u32 output_size;
687 __u32 op;
688 __u32 reg_idx;
689 __u32 enable;
690 __u32 ctx_id;
691};
Christopher Ferris80ae69d2022-08-02 16:32:21 -0700692#define HL_NOTIFIER_EVENT_TPC_ASSERT (1 << 0)
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700693#define HL_IOCTL_INFO _IOWR('H', 0x01, struct hl_info_args)
694#define HL_IOCTL_CB _IOWR('H', 0x02, union hl_cb_args)
695#define HL_IOCTL_CS _IOWR('H', 0x03, union hl_cs_args)
696#define HL_IOCTL_WAIT_CS _IOWR('H', 0x04, union hl_wait_cs_args)
697#define HL_IOCTL_MEMORY _IOWR('H', 0x05, union hl_mem_args)
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700698#define HL_IOCTL_DEBUG _IOWR('H', 0x06, struct hl_debug_args)
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700699#define HL_COMMAND_START 0x01
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700700#define HL_COMMAND_END 0x07
Christopher Ferris24f97eb2019-05-20 12:58:13 -0700701#endif