Oded Gabbay | 99b9d7b | 2019-02-16 00:39:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note |
| 2 | * |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 3 | * Copyright 2016-2020 HabanaLabs, Ltd. |
Oded Gabbay | 99b9d7b | 2019-02-16 00:39:13 +0200 | [diff] [blame] | 4 | * All Rights Reserved. |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef HABANALABS_H_ |
| 9 | #define HABANALABS_H_ |
| 10 | |
| 11 | #include <linux/types.h> |
| 12 | #include <linux/ioctl.h> |
| 13 | |
| 14 | /* |
| 15 | * Defines that are asic-specific but constitutes as ABI between kernel driver |
| 16 | * and userspace |
| 17 | */ |
Oded Gabbay | 466c782 | 2020-05-11 10:32:10 +0300 | [diff] [blame] | 18 | #define GOYA_KMD_SRAM_RESERVED_SIZE_FROM_START 0x8000 /* 32KB */ |
| 19 | #define GAUDI_DRIVER_SRAM_RESERVED_SIZE_FROM_START 0x80 /* 128 bytes */ |
Oded Gabbay | 99b9d7b | 2019-02-16 00:39:13 +0200 | [diff] [blame] | 20 | |
Ofir Bitton | 5de406c | 2020-09-10 10:56:26 +0300 | [diff] [blame] | 21 | /* |
| 22 | * 128 SOBs reserved for collective wait |
| 23 | * 16 SOBs reserved for sync stream |
| 24 | */ |
| 25 | #define GAUDI_FIRST_AVAILABLE_W_S_SYNC_OBJECT 144 |
| 26 | |
| 27 | /* |
| 28 | * 64 monitors reserved for collective wait |
| 29 | * 8 monitors reserved for sync stream |
| 30 | */ |
| 31 | #define GAUDI_FIRST_AVAILABLE_W_S_MONITOR 72 |
| 32 | |
Oded Gabbay | 9494a8d | 2019-02-16 00:39:17 +0200 | [diff] [blame] | 33 | /* |
Oded Gabbay | 466c782 | 2020-05-11 10:32:10 +0300 | [diff] [blame] | 34 | * Goya queue Numbering |
Oded Gabbay | 9494a8d | 2019-02-16 00:39:17 +0200 | [diff] [blame] | 35 | * |
Oded Gabbay | 9002729 | 2019-04-03 09:51:04 +0300 | [diff] [blame] | 36 | * The external queues (PCI DMA channels) MUST be before the internal queues |
| 37 | * and each group (PCI DMA channels and internal) must be contiguous inside |
Oded Gabbay | 9494a8d | 2019-02-16 00:39:17 +0200 | [diff] [blame] | 38 | * itself but there can be a gap between the two groups (although not |
| 39 | * recommended) |
| 40 | */ |
| 41 | |
| 42 | enum goya_queue_id { |
| 43 | GOYA_QUEUE_ID_DMA_0 = 0, |
Dotan Barak | 4fd2cb1 | 2019-08-12 10:23:33 +0300 | [diff] [blame] | 44 | GOYA_QUEUE_ID_DMA_1 = 1, |
| 45 | GOYA_QUEUE_ID_DMA_2 = 2, |
| 46 | GOYA_QUEUE_ID_DMA_3 = 3, |
| 47 | GOYA_QUEUE_ID_DMA_4 = 4, |
| 48 | GOYA_QUEUE_ID_CPU_PQ = 5, |
| 49 | GOYA_QUEUE_ID_MME = 6, /* Internal queues start here */ |
| 50 | GOYA_QUEUE_ID_TPC0 = 7, |
| 51 | GOYA_QUEUE_ID_TPC1 = 8, |
| 52 | GOYA_QUEUE_ID_TPC2 = 9, |
| 53 | GOYA_QUEUE_ID_TPC3 = 10, |
| 54 | GOYA_QUEUE_ID_TPC4 = 11, |
| 55 | GOYA_QUEUE_ID_TPC5 = 12, |
| 56 | GOYA_QUEUE_ID_TPC6 = 13, |
| 57 | GOYA_QUEUE_ID_TPC7 = 14, |
Oded Gabbay | 9494a8d | 2019-02-16 00:39:17 +0200 | [diff] [blame] | 58 | GOYA_QUEUE_ID_SIZE |
| 59 | }; |
| 60 | |
Tomer Tayar | e8960ca | 2019-07-01 13:59:45 +0000 | [diff] [blame] | 61 | /* |
Oded Gabbay | 466c782 | 2020-05-11 10:32:10 +0300 | [diff] [blame] | 62 | * Gaudi queue Numbering |
| 63 | * External queues (PCI DMA channels) are DMA_0_*, DMA_1_* and DMA_5_*. |
| 64 | * Except one CPU queue, all the rest are internal queues. |
| 65 | */ |
| 66 | |
| 67 | enum gaudi_queue_id { |
| 68 | GAUDI_QUEUE_ID_DMA_0_0 = 0, /* external */ |
| 69 | GAUDI_QUEUE_ID_DMA_0_1 = 1, /* external */ |
| 70 | GAUDI_QUEUE_ID_DMA_0_2 = 2, /* external */ |
| 71 | GAUDI_QUEUE_ID_DMA_0_3 = 3, /* external */ |
| 72 | GAUDI_QUEUE_ID_DMA_1_0 = 4, /* external */ |
| 73 | GAUDI_QUEUE_ID_DMA_1_1 = 5, /* external */ |
| 74 | GAUDI_QUEUE_ID_DMA_1_2 = 6, /* external */ |
| 75 | GAUDI_QUEUE_ID_DMA_1_3 = 7, /* external */ |
| 76 | GAUDI_QUEUE_ID_CPU_PQ = 8, /* CPU */ |
| 77 | GAUDI_QUEUE_ID_DMA_2_0 = 9, /* internal */ |
| 78 | GAUDI_QUEUE_ID_DMA_2_1 = 10, /* internal */ |
| 79 | GAUDI_QUEUE_ID_DMA_2_2 = 11, /* internal */ |
| 80 | GAUDI_QUEUE_ID_DMA_2_3 = 12, /* internal */ |
| 81 | GAUDI_QUEUE_ID_DMA_3_0 = 13, /* internal */ |
| 82 | GAUDI_QUEUE_ID_DMA_3_1 = 14, /* internal */ |
| 83 | GAUDI_QUEUE_ID_DMA_3_2 = 15, /* internal */ |
| 84 | GAUDI_QUEUE_ID_DMA_3_3 = 16, /* internal */ |
| 85 | GAUDI_QUEUE_ID_DMA_4_0 = 17, /* internal */ |
| 86 | GAUDI_QUEUE_ID_DMA_4_1 = 18, /* internal */ |
| 87 | GAUDI_QUEUE_ID_DMA_4_2 = 19, /* internal */ |
| 88 | GAUDI_QUEUE_ID_DMA_4_3 = 20, /* internal */ |
Ofir Bitton | 0940cab | 2020-08-31 08:52:56 +0300 | [diff] [blame] | 89 | GAUDI_QUEUE_ID_DMA_5_0 = 21, /* internal */ |
| 90 | GAUDI_QUEUE_ID_DMA_5_1 = 22, /* internal */ |
| 91 | GAUDI_QUEUE_ID_DMA_5_2 = 23, /* internal */ |
| 92 | GAUDI_QUEUE_ID_DMA_5_3 = 24, /* internal */ |
Oded Gabbay | 466c782 | 2020-05-11 10:32:10 +0300 | [diff] [blame] | 93 | GAUDI_QUEUE_ID_DMA_6_0 = 25, /* internal */ |
| 94 | GAUDI_QUEUE_ID_DMA_6_1 = 26, /* internal */ |
| 95 | GAUDI_QUEUE_ID_DMA_6_2 = 27, /* internal */ |
| 96 | GAUDI_QUEUE_ID_DMA_6_3 = 28, /* internal */ |
| 97 | GAUDI_QUEUE_ID_DMA_7_0 = 29, /* internal */ |
| 98 | GAUDI_QUEUE_ID_DMA_7_1 = 30, /* internal */ |
| 99 | GAUDI_QUEUE_ID_DMA_7_2 = 31, /* internal */ |
| 100 | GAUDI_QUEUE_ID_DMA_7_3 = 32, /* internal */ |
| 101 | GAUDI_QUEUE_ID_MME_0_0 = 33, /* internal */ |
| 102 | GAUDI_QUEUE_ID_MME_0_1 = 34, /* internal */ |
| 103 | GAUDI_QUEUE_ID_MME_0_2 = 35, /* internal */ |
| 104 | GAUDI_QUEUE_ID_MME_0_3 = 36, /* internal */ |
| 105 | GAUDI_QUEUE_ID_MME_1_0 = 37, /* internal */ |
| 106 | GAUDI_QUEUE_ID_MME_1_1 = 38, /* internal */ |
| 107 | GAUDI_QUEUE_ID_MME_1_2 = 39, /* internal */ |
| 108 | GAUDI_QUEUE_ID_MME_1_3 = 40, /* internal */ |
| 109 | GAUDI_QUEUE_ID_TPC_0_0 = 41, /* internal */ |
| 110 | GAUDI_QUEUE_ID_TPC_0_1 = 42, /* internal */ |
| 111 | GAUDI_QUEUE_ID_TPC_0_2 = 43, /* internal */ |
| 112 | GAUDI_QUEUE_ID_TPC_0_3 = 44, /* internal */ |
| 113 | GAUDI_QUEUE_ID_TPC_1_0 = 45, /* internal */ |
| 114 | GAUDI_QUEUE_ID_TPC_1_1 = 46, /* internal */ |
| 115 | GAUDI_QUEUE_ID_TPC_1_2 = 47, /* internal */ |
| 116 | GAUDI_QUEUE_ID_TPC_1_3 = 48, /* internal */ |
| 117 | GAUDI_QUEUE_ID_TPC_2_0 = 49, /* internal */ |
| 118 | GAUDI_QUEUE_ID_TPC_2_1 = 50, /* internal */ |
| 119 | GAUDI_QUEUE_ID_TPC_2_2 = 51, /* internal */ |
| 120 | GAUDI_QUEUE_ID_TPC_2_3 = 52, /* internal */ |
| 121 | GAUDI_QUEUE_ID_TPC_3_0 = 53, /* internal */ |
| 122 | GAUDI_QUEUE_ID_TPC_3_1 = 54, /* internal */ |
| 123 | GAUDI_QUEUE_ID_TPC_3_2 = 55, /* internal */ |
| 124 | GAUDI_QUEUE_ID_TPC_3_3 = 56, /* internal */ |
| 125 | GAUDI_QUEUE_ID_TPC_4_0 = 57, /* internal */ |
| 126 | GAUDI_QUEUE_ID_TPC_4_1 = 58, /* internal */ |
| 127 | GAUDI_QUEUE_ID_TPC_4_2 = 59, /* internal */ |
| 128 | GAUDI_QUEUE_ID_TPC_4_3 = 60, /* internal */ |
| 129 | GAUDI_QUEUE_ID_TPC_5_0 = 61, /* internal */ |
| 130 | GAUDI_QUEUE_ID_TPC_5_1 = 62, /* internal */ |
| 131 | GAUDI_QUEUE_ID_TPC_5_2 = 63, /* internal */ |
| 132 | GAUDI_QUEUE_ID_TPC_5_3 = 64, /* internal */ |
| 133 | GAUDI_QUEUE_ID_TPC_6_0 = 65, /* internal */ |
| 134 | GAUDI_QUEUE_ID_TPC_6_1 = 66, /* internal */ |
| 135 | GAUDI_QUEUE_ID_TPC_6_2 = 67, /* internal */ |
| 136 | GAUDI_QUEUE_ID_TPC_6_3 = 68, /* internal */ |
| 137 | GAUDI_QUEUE_ID_TPC_7_0 = 69, /* internal */ |
| 138 | GAUDI_QUEUE_ID_TPC_7_1 = 70, /* internal */ |
| 139 | GAUDI_QUEUE_ID_TPC_7_2 = 71, /* internal */ |
| 140 | GAUDI_QUEUE_ID_TPC_7_3 = 72, /* internal */ |
| 141 | GAUDI_QUEUE_ID_NIC_0_0 = 73, /* internal */ |
| 142 | GAUDI_QUEUE_ID_NIC_0_1 = 74, /* internal */ |
| 143 | GAUDI_QUEUE_ID_NIC_0_2 = 75, /* internal */ |
| 144 | GAUDI_QUEUE_ID_NIC_0_3 = 76, /* internal */ |
| 145 | GAUDI_QUEUE_ID_NIC_1_0 = 77, /* internal */ |
| 146 | GAUDI_QUEUE_ID_NIC_1_1 = 78, /* internal */ |
| 147 | GAUDI_QUEUE_ID_NIC_1_2 = 79, /* internal */ |
| 148 | GAUDI_QUEUE_ID_NIC_1_3 = 80, /* internal */ |
| 149 | GAUDI_QUEUE_ID_NIC_2_0 = 81, /* internal */ |
| 150 | GAUDI_QUEUE_ID_NIC_2_1 = 82, /* internal */ |
| 151 | GAUDI_QUEUE_ID_NIC_2_2 = 83, /* internal */ |
| 152 | GAUDI_QUEUE_ID_NIC_2_3 = 84, /* internal */ |
| 153 | GAUDI_QUEUE_ID_NIC_3_0 = 85, /* internal */ |
| 154 | GAUDI_QUEUE_ID_NIC_3_1 = 86, /* internal */ |
| 155 | GAUDI_QUEUE_ID_NIC_3_2 = 87, /* internal */ |
| 156 | GAUDI_QUEUE_ID_NIC_3_3 = 88, /* internal */ |
| 157 | GAUDI_QUEUE_ID_NIC_4_0 = 89, /* internal */ |
| 158 | GAUDI_QUEUE_ID_NIC_4_1 = 90, /* internal */ |
| 159 | GAUDI_QUEUE_ID_NIC_4_2 = 91, /* internal */ |
| 160 | GAUDI_QUEUE_ID_NIC_4_3 = 92, /* internal */ |
| 161 | GAUDI_QUEUE_ID_NIC_5_0 = 93, /* internal */ |
| 162 | GAUDI_QUEUE_ID_NIC_5_1 = 94, /* internal */ |
| 163 | GAUDI_QUEUE_ID_NIC_5_2 = 95, /* internal */ |
| 164 | GAUDI_QUEUE_ID_NIC_5_3 = 96, /* internal */ |
| 165 | GAUDI_QUEUE_ID_NIC_6_0 = 97, /* internal */ |
| 166 | GAUDI_QUEUE_ID_NIC_6_1 = 98, /* internal */ |
| 167 | GAUDI_QUEUE_ID_NIC_6_2 = 99, /* internal */ |
| 168 | GAUDI_QUEUE_ID_NIC_6_3 = 100, /* internal */ |
| 169 | GAUDI_QUEUE_ID_NIC_7_0 = 101, /* internal */ |
| 170 | GAUDI_QUEUE_ID_NIC_7_1 = 102, /* internal */ |
| 171 | GAUDI_QUEUE_ID_NIC_7_2 = 103, /* internal */ |
| 172 | GAUDI_QUEUE_ID_NIC_7_3 = 104, /* internal */ |
| 173 | GAUDI_QUEUE_ID_NIC_8_0 = 105, /* internal */ |
| 174 | GAUDI_QUEUE_ID_NIC_8_1 = 106, /* internal */ |
| 175 | GAUDI_QUEUE_ID_NIC_8_2 = 107, /* internal */ |
| 176 | GAUDI_QUEUE_ID_NIC_8_3 = 108, /* internal */ |
| 177 | GAUDI_QUEUE_ID_NIC_9_0 = 109, /* internal */ |
| 178 | GAUDI_QUEUE_ID_NIC_9_1 = 110, /* internal */ |
| 179 | GAUDI_QUEUE_ID_NIC_9_2 = 111, /* internal */ |
| 180 | GAUDI_QUEUE_ID_NIC_9_3 = 112, /* internal */ |
| 181 | GAUDI_QUEUE_ID_SIZE |
| 182 | }; |
| 183 | |
| 184 | /* |
Tomer Tayar | e8960ca | 2019-07-01 13:59:45 +0000 | [diff] [blame] | 185 | * Engine Numbering |
| 186 | * |
| 187 | * Used in the "busy_engines_mask" field in `struct hl_info_hw_idle' |
| 188 | */ |
| 189 | |
| 190 | enum goya_engine_id { |
| 191 | GOYA_ENGINE_ID_DMA_0 = 0, |
| 192 | GOYA_ENGINE_ID_DMA_1, |
| 193 | GOYA_ENGINE_ID_DMA_2, |
| 194 | GOYA_ENGINE_ID_DMA_3, |
| 195 | GOYA_ENGINE_ID_DMA_4, |
| 196 | GOYA_ENGINE_ID_MME_0, |
| 197 | GOYA_ENGINE_ID_TPC_0, |
| 198 | GOYA_ENGINE_ID_TPC_1, |
| 199 | GOYA_ENGINE_ID_TPC_2, |
| 200 | GOYA_ENGINE_ID_TPC_3, |
| 201 | GOYA_ENGINE_ID_TPC_4, |
| 202 | GOYA_ENGINE_ID_TPC_5, |
| 203 | GOYA_ENGINE_ID_TPC_6, |
| 204 | GOYA_ENGINE_ID_TPC_7, |
| 205 | GOYA_ENGINE_ID_SIZE |
| 206 | }; |
| 207 | |
Oded Gabbay | 466c782 | 2020-05-11 10:32:10 +0300 | [diff] [blame] | 208 | enum gaudi_engine_id { |
| 209 | GAUDI_ENGINE_ID_DMA_0 = 0, |
| 210 | GAUDI_ENGINE_ID_DMA_1, |
| 211 | GAUDI_ENGINE_ID_DMA_2, |
| 212 | GAUDI_ENGINE_ID_DMA_3, |
| 213 | GAUDI_ENGINE_ID_DMA_4, |
| 214 | GAUDI_ENGINE_ID_DMA_5, |
| 215 | GAUDI_ENGINE_ID_DMA_6, |
| 216 | GAUDI_ENGINE_ID_DMA_7, |
| 217 | GAUDI_ENGINE_ID_MME_0, |
| 218 | GAUDI_ENGINE_ID_MME_1, |
| 219 | GAUDI_ENGINE_ID_MME_2, |
| 220 | GAUDI_ENGINE_ID_MME_3, |
| 221 | GAUDI_ENGINE_ID_TPC_0, |
| 222 | GAUDI_ENGINE_ID_TPC_1, |
| 223 | GAUDI_ENGINE_ID_TPC_2, |
| 224 | GAUDI_ENGINE_ID_TPC_3, |
| 225 | GAUDI_ENGINE_ID_TPC_4, |
| 226 | GAUDI_ENGINE_ID_TPC_5, |
| 227 | GAUDI_ENGINE_ID_TPC_6, |
| 228 | GAUDI_ENGINE_ID_TPC_7, |
| 229 | GAUDI_ENGINE_ID_NIC_0, |
| 230 | GAUDI_ENGINE_ID_NIC_1, |
| 231 | GAUDI_ENGINE_ID_NIC_2, |
| 232 | GAUDI_ENGINE_ID_NIC_3, |
| 233 | GAUDI_ENGINE_ID_NIC_4, |
| 234 | GAUDI_ENGINE_ID_NIC_5, |
| 235 | GAUDI_ENGINE_ID_NIC_6, |
| 236 | GAUDI_ENGINE_ID_NIC_7, |
| 237 | GAUDI_ENGINE_ID_NIC_8, |
| 238 | GAUDI_ENGINE_ID_NIC_9, |
| 239 | GAUDI_ENGINE_ID_SIZE |
| 240 | }; |
| 241 | |
Dalit Ben Zoor | aa95708 | 2019-03-24 10:15:44 +0200 | [diff] [blame] | 242 | enum hl_device_status { |
| 243 | HL_DEVICE_STATUS_OPERATIONAL, |
| 244 | HL_DEVICE_STATUS_IN_RESET, |
Ofir Bitton | 66a7640 | 2020-10-05 14:40:10 +0300 | [diff] [blame] | 245 | HL_DEVICE_STATUS_MALFUNCTION, |
| 246 | HL_DEVICE_STATUS_NEEDS_RESET |
Dalit Ben Zoor | aa95708 | 2019-03-24 10:15:44 +0200 | [diff] [blame] | 247 | }; |
| 248 | |
Oded Gabbay | f388ec7 | 2019-07-16 08:55:04 +0300 | [diff] [blame] | 249 | /* Opcode for management ioctl |
| 250 | * |
Oded Gabbay | 75b3cb2 | 2019-08-28 17:32:04 +0300 | [diff] [blame] | 251 | * HW_IP_INFO - Receive information about different IP blocks in the |
| 252 | * device. |
| 253 | * HL_INFO_HW_EVENTS - Receive an array describing how many times each event |
| 254 | * occurred since the last hard reset. |
| 255 | * HL_INFO_DRAM_USAGE - Retrieve the dram usage inside the device and of the |
| 256 | * specific context. This is relevant only for devices |
| 257 | * where the dram is managed by the kernel driver |
| 258 | * HL_INFO_HW_IDLE - Retrieve information about the idle status of each |
| 259 | * internal engine. |
Oded Gabbay | f388ec7 | 2019-07-16 08:55:04 +0300 | [diff] [blame] | 260 | * HL_INFO_DEVICE_STATUS - Retrieve the device's status. This opcode doesn't |
| 261 | * require an open context. |
Oded Gabbay | 62c1e12 | 2019-10-10 15:48:59 +0300 | [diff] [blame] | 262 | * HL_INFO_DEVICE_UTILIZATION - Retrieve the total utilization of the device |
| 263 | * over the last period specified by the user. |
| 264 | * The period can be between 100ms to 1s, in |
| 265 | * resolution of 100ms. The return value is a |
| 266 | * percentage of the utilization rate. |
Oded Gabbay | e973076 | 2019-08-28 21:51:52 +0300 | [diff] [blame] | 267 | * HL_INFO_HW_EVENTS_AGGREGATE - Receive an array describing how many times each |
| 268 | * event occurred since the driver was loaded. |
Oded Gabbay | 62c1e12 | 2019-10-10 15:48:59 +0300 | [diff] [blame] | 269 | * HL_INFO_CLK_RATE - Retrieve the current and maximum clock rate |
| 270 | * of the device in MHz. The maximum clock rate is |
| 271 | * configurable via sysfs parameter |
Moti Haimovski | 52c01b0 | 2019-11-03 16:26:44 +0200 | [diff] [blame] | 272 | * HL_INFO_RESET_COUNT - Retrieve the counts of the soft and hard reset |
| 273 | * operations performed on the device since the last |
| 274 | * time the driver was loaded. |
Tomer Tayar | 25e7aeb | 2020-03-31 22:46:36 +0300 | [diff] [blame] | 275 | * HL_INFO_TIME_SYNC - Retrieve the device's time alongside the host's time |
| 276 | * for synchronization. |
Ofir Bitton | db491e4 | 2020-06-18 09:51:16 +0300 | [diff] [blame] | 277 | * HL_INFO_CS_COUNTERS - Retrieve command submission counters |
Ofir Bitton | 0a068ad | 2020-07-21 10:49:51 +0300 | [diff] [blame] | 278 | * HL_INFO_PCI_COUNTERS - Retrieve PCI counters |
| 279 | * HL_INFO_CLK_THROTTLE_REASON - Retrieve clock throttling reason |
Ofir Bitton | 843839b | 2020-07-19 11:08:09 +0300 | [diff] [blame] | 280 | * HL_INFO_SYNC_MANAGER - Retrieve sync manager info per dcore |
farah kassabri | 9f30649 | 2020-08-09 16:25:53 +0300 | [diff] [blame] | 281 | * HL_INFO_TOTAL_ENERGY - Retrieve total energy consumption |
Alon Mizrahi | 429f157 | 2020-12-01 18:44:11 +0200 | [diff] [blame] | 282 | * HL_INFO_PLL_FREQUENCY - Retrieve PLL frequency |
Oded Gabbay | f388ec7 | 2019-07-16 08:55:04 +0300 | [diff] [blame] | 283 | */ |
Oded Gabbay | 75b3cb2 | 2019-08-28 17:32:04 +0300 | [diff] [blame] | 284 | #define HL_INFO_HW_IP_INFO 0 |
| 285 | #define HL_INFO_HW_EVENTS 1 |
| 286 | #define HL_INFO_DRAM_USAGE 2 |
| 287 | #define HL_INFO_HW_IDLE 3 |
| 288 | #define HL_INFO_DEVICE_STATUS 4 |
| 289 | #define HL_INFO_DEVICE_UTILIZATION 6 |
Oded Gabbay | e973076 | 2019-08-28 21:51:52 +0300 | [diff] [blame] | 290 | #define HL_INFO_HW_EVENTS_AGGREGATE 7 |
Oded Gabbay | 62c1e12 | 2019-10-10 15:48:59 +0300 | [diff] [blame] | 291 | #define HL_INFO_CLK_RATE 8 |
Moti Haimovski | 52c01b0 | 2019-11-03 16:26:44 +0200 | [diff] [blame] | 292 | #define HL_INFO_RESET_COUNT 9 |
Tomer Tayar | 25e7aeb | 2020-03-31 22:46:36 +0300 | [diff] [blame] | 293 | #define HL_INFO_TIME_SYNC 10 |
Ofir Bitton | db491e4 | 2020-06-18 09:51:16 +0300 | [diff] [blame] | 294 | #define HL_INFO_CS_COUNTERS 11 |
Ofir Bitton | 0a068ad | 2020-07-21 10:49:51 +0300 | [diff] [blame] | 295 | #define HL_INFO_PCI_COUNTERS 12 |
| 296 | #define HL_INFO_CLK_THROTTLE_REASON 13 |
Ofir Bitton | 843839b | 2020-07-19 11:08:09 +0300 | [diff] [blame] | 297 | #define HL_INFO_SYNC_MANAGER 14 |
farah kassabri | 9f30649 | 2020-08-09 16:25:53 +0300 | [diff] [blame] | 298 | #define HL_INFO_TOTAL_ENERGY 15 |
Alon Mizrahi | 4147864 | 2020-11-17 14:25:14 +0200 | [diff] [blame] | 299 | #define HL_INFO_PLL_FREQUENCY 16 |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 300 | |
| 301 | #define HL_INFO_VERSION_MAX_LEN 128 |
Oded Gabbay | 91edbf2 | 2019-10-16 11:53:52 +0300 | [diff] [blame] | 302 | #define HL_INFO_CARD_NAME_MAX_LEN 16 |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 303 | |
| 304 | struct hl_info_hw_ip_info { |
| 305 | __u64 sram_base_address; |
| 306 | __u64 dram_base_address; |
| 307 | __u64 dram_size; |
| 308 | __u32 sram_size; |
| 309 | __u32 num_of_events; |
| 310 | __u32 device_id; /* PCI Device ID */ |
Omer Shpigelman | fca72fb | 2020-05-03 17:35:54 +0300 | [diff] [blame] | 311 | __u32 module_id; /* For mezzanine cards in servers (From OCP spec.) */ |
| 312 | __u32 reserved[2]; |
Oded Gabbay | 2f55342 | 2020-08-15 16:28:10 +0300 | [diff] [blame] | 313 | __u32 cpld_version; |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 314 | __u32 psoc_pci_pll_nr; |
| 315 | __u32 psoc_pci_pll_nf; |
| 316 | __u32 psoc_pci_pll_od; |
| 317 | __u32 psoc_pci_pll_div_factor; |
| 318 | __u8 tpc_enabled_mask; |
| 319 | __u8 dram_enabled; |
| 320 | __u8 pad[2]; |
Oded Gabbay | 2f55342 | 2020-08-15 16:28:10 +0300 | [diff] [blame] | 321 | __u8 cpucp_version[HL_INFO_VERSION_MAX_LEN]; |
Oded Gabbay | 91edbf2 | 2019-10-16 11:53:52 +0300 | [diff] [blame] | 322 | __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN]; |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 323 | }; |
| 324 | |
| 325 | struct hl_info_dram_usage { |
| 326 | __u64 dram_free_mem; |
| 327 | __u64 ctx_dram_mem; |
| 328 | }; |
| 329 | |
| 330 | struct hl_info_hw_idle { |
| 331 | __u32 is_idle; |
Tomer Tayar | e8960ca | 2019-07-01 13:59:45 +0000 | [diff] [blame] | 332 | /* |
| 333 | * Bitmask of busy engines. |
| 334 | * Bits definition is according to `enum <chip>_enging_id'. |
| 335 | */ |
| 336 | __u32 busy_engines_mask; |
farah kassabri | d90416c | 2020-08-12 17:20:13 +0300 | [diff] [blame] | 337 | |
| 338 | /* |
| 339 | * Extended Bitmask of busy engines. |
| 340 | * Bits definition is according to `enum <chip>_enging_id'. |
| 341 | */ |
| 342 | __u64 busy_engines_mask_ext; |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 343 | }; |
| 344 | |
Dalit Ben Zoor | aa95708 | 2019-03-24 10:15:44 +0200 | [diff] [blame] | 345 | struct hl_info_device_status { |
| 346 | __u32 status; |
| 347 | __u32 pad; |
| 348 | }; |
| 349 | |
Oded Gabbay | 75b3cb2 | 2019-08-28 17:32:04 +0300 | [diff] [blame] | 350 | struct hl_info_device_utilization { |
| 351 | __u32 utilization; |
| 352 | __u32 pad; |
| 353 | }; |
| 354 | |
Oded Gabbay | 62c1e12 | 2019-10-10 15:48:59 +0300 | [diff] [blame] | 355 | struct hl_info_clk_rate { |
| 356 | __u32 cur_clk_rate_mhz; |
| 357 | __u32 max_clk_rate_mhz; |
| 358 | }; |
| 359 | |
Moti Haimovski | 52c01b0 | 2019-11-03 16:26:44 +0200 | [diff] [blame] | 360 | struct hl_info_reset_count { |
| 361 | __u32 hard_reset_cnt; |
| 362 | __u32 soft_reset_cnt; |
| 363 | }; |
| 364 | |
Tomer Tayar | 25e7aeb | 2020-03-31 22:46:36 +0300 | [diff] [blame] | 365 | struct hl_info_time_sync { |
| 366 | __u64 device_time; |
| 367 | __u64 host_time; |
| 368 | }; |
| 369 | |
Ofir Bitton | db491e4 | 2020-06-18 09:51:16 +0300 | [diff] [blame] | 370 | /** |
Ofir Bitton | 0a068ad | 2020-07-21 10:49:51 +0300 | [diff] [blame] | 371 | * struct hl_info_pci_counters - pci counters |
| 372 | * @rx_throughput: PCI rx throughput KBps |
| 373 | * @tx_throughput: PCI tx throughput KBps |
| 374 | * @replay_cnt: PCI replay counter |
| 375 | */ |
| 376 | struct hl_info_pci_counters { |
| 377 | __u64 rx_throughput; |
| 378 | __u64 tx_throughput; |
| 379 | __u64 replay_cnt; |
| 380 | }; |
| 381 | |
| 382 | #define HL_CLK_THROTTLE_POWER 0x1 |
| 383 | #define HL_CLK_THROTTLE_THERMAL 0x2 |
| 384 | |
| 385 | /** |
| 386 | * struct hl_info_clk_throttle - clock throttling reason |
| 387 | * @clk_throttling_reason: each bit represents a clk throttling reason |
| 388 | */ |
| 389 | struct hl_info_clk_throttle { |
| 390 | __u32 clk_throttling_reason; |
| 391 | }; |
| 392 | |
| 393 | /** |
farah kassabri | 9f30649 | 2020-08-09 16:25:53 +0300 | [diff] [blame] | 394 | * struct hl_info_energy - device energy information |
| 395 | * @total_energy_consumption: total device energy consumption |
| 396 | */ |
| 397 | struct hl_info_energy { |
| 398 | __u64 total_energy_consumption; |
| 399 | }; |
| 400 | |
Alon Mizrahi | 4147864 | 2020-11-17 14:25:14 +0200 | [diff] [blame] | 401 | #define HL_PLL_NUM_OUTPUTS 4 |
| 402 | |
| 403 | struct hl_pll_frequency_info { |
| 404 | __u16 output[HL_PLL_NUM_OUTPUTS]; |
| 405 | }; |
| 406 | |
farah kassabri | 9f30649 | 2020-08-09 16:25:53 +0300 | [diff] [blame] | 407 | /** |
Ofir Bitton | 843839b | 2020-07-19 11:08:09 +0300 | [diff] [blame] | 408 | * struct hl_info_sync_manager - sync manager information |
| 409 | * @first_available_sync_object: first available sob |
| 410 | * @first_available_monitor: first available monitor |
| 411 | */ |
| 412 | struct hl_info_sync_manager { |
| 413 | __u32 first_available_sync_object; |
| 414 | __u32 first_available_monitor; |
| 415 | }; |
| 416 | |
| 417 | /** |
Ofir Bitton | db491e4 | 2020-06-18 09:51:16 +0300 | [diff] [blame] | 418 | * struct hl_info_cs_counters - command submission counters |
farah kassabri | e753643 | 2020-10-12 14:30:26 +0300 | [diff] [blame] | 419 | * @total_out_of_mem_drop_cnt: total dropped due to memory allocation issue |
| 420 | * @ctx_out_of_mem_drop_cnt: context dropped due to memory allocation issue |
| 421 | * @total_parsing_drop_cnt: total dropped due to error in packet parsing |
| 422 | * @ctx_parsing_drop_cnt: context dropped due to error in packet parsing |
| 423 | * @total_queue_full_drop_cnt: total dropped due to queue full |
| 424 | * @ctx_queue_full_drop_cnt: context dropped due to queue full |
| 425 | * @total_device_in_reset_drop_cnt: total dropped due to device in reset |
| 426 | * @ctx_device_in_reset_drop_cnt: context dropped due to device in reset |
| 427 | * @total_max_cs_in_flight_drop_cnt: total dropped due to maximum CS in-flight |
| 428 | * @ctx_max_cs_in_flight_drop_cnt: context dropped due to maximum CS in-flight |
Alon Mizrahi | a3fd283 | 2020-12-08 16:14:01 +0200 | [diff] [blame] | 429 | * @total_validation_drop_cnt: total dropped due to validation error |
| 430 | * @ctx_validation_drop_cnt: context dropped due to validation error |
Ofir Bitton | db491e4 | 2020-06-18 09:51:16 +0300 | [diff] [blame] | 431 | */ |
Ofir Bitton | db491e4 | 2020-06-18 09:51:16 +0300 | [diff] [blame] | 432 | struct hl_info_cs_counters { |
farah kassabri | e753643 | 2020-10-12 14:30:26 +0300 | [diff] [blame] | 433 | __u64 total_out_of_mem_drop_cnt; |
| 434 | __u64 ctx_out_of_mem_drop_cnt; |
| 435 | __u64 total_parsing_drop_cnt; |
| 436 | __u64 ctx_parsing_drop_cnt; |
| 437 | __u64 total_queue_full_drop_cnt; |
| 438 | __u64 ctx_queue_full_drop_cnt; |
| 439 | __u64 total_device_in_reset_drop_cnt; |
| 440 | __u64 ctx_device_in_reset_drop_cnt; |
| 441 | __u64 total_max_cs_in_flight_drop_cnt; |
| 442 | __u64 ctx_max_cs_in_flight_drop_cnt; |
Alon Mizrahi | a3fd283 | 2020-12-08 16:14:01 +0200 | [diff] [blame] | 443 | __u64 total_validation_drop_cnt; |
| 444 | __u64 ctx_validation_drop_cnt; |
Ofir Bitton | db491e4 | 2020-06-18 09:51:16 +0300 | [diff] [blame] | 445 | }; |
| 446 | |
Ofir Bitton | 843839b | 2020-07-19 11:08:09 +0300 | [diff] [blame] | 447 | enum gaudi_dcores { |
| 448 | HL_GAUDI_WS_DCORE, |
| 449 | HL_GAUDI_WN_DCORE, |
| 450 | HL_GAUDI_EN_DCORE, |
| 451 | HL_GAUDI_ES_DCORE |
| 452 | }; |
| 453 | |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 454 | struct hl_info_args { |
| 455 | /* Location of relevant struct in userspace */ |
| 456 | __u64 return_pointer; |
| 457 | /* |
| 458 | * The size of the return value. Just like "size" in "snprintf", |
| 459 | * it limits how many bytes the kernel can write |
| 460 | * |
| 461 | * For hw_events array, the size should be |
| 462 | * hl_info_hw_ip_info.num_of_events * sizeof(__u32) |
| 463 | */ |
| 464 | __u32 return_size; |
| 465 | |
| 466 | /* HL_INFO_* */ |
| 467 | __u32 op; |
| 468 | |
Oded Gabbay | 75b3cb2 | 2019-08-28 17:32:04 +0300 | [diff] [blame] | 469 | union { |
Ofir Bitton | 843839b | 2020-07-19 11:08:09 +0300 | [diff] [blame] | 470 | /* Dcore id for which the information is relevant. |
| 471 | * For Gaudi refer to 'enum gaudi_dcores' |
| 472 | */ |
| 473 | __u32 dcore_id; |
Oded Gabbay | 75b3cb2 | 2019-08-28 17:32:04 +0300 | [diff] [blame] | 474 | /* Context ID - Currently not in use */ |
| 475 | __u32 ctx_id; |
| 476 | /* Period value for utilization rate (100ms - 1000ms, in 100ms |
| 477 | * resolution. |
| 478 | */ |
| 479 | __u32 period_ms; |
Alon Mizrahi | 4147864 | 2020-11-17 14:25:14 +0200 | [diff] [blame] | 480 | /* PLL frequency retrieval */ |
| 481 | __u32 pll_index; |
Oded Gabbay | 75b3cb2 | 2019-08-28 17:32:04 +0300 | [diff] [blame] | 482 | }; |
| 483 | |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 484 | __u32 pad; |
| 485 | }; |
Oded Gabbay | 9494a8d | 2019-02-16 00:39:17 +0200 | [diff] [blame] | 486 | |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 487 | /* Opcode to create a new command buffer */ |
| 488 | #define HL_CB_OP_CREATE 0 |
| 489 | /* Opcode to destroy previously created command buffer */ |
| 490 | #define HL_CB_OP_DESTROY 1 |
Tomer Tayar | f44afb5 | 2020-09-02 13:43:32 +0300 | [diff] [blame] | 491 | /* Opcode to retrieve information about a command buffer */ |
| 492 | #define HL_CB_OP_INFO 2 |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 493 | |
Oded Gabbay | 39b4251 | 2020-04-17 12:12:13 +0300 | [diff] [blame] | 494 | /* 2MB minus 32 bytes for 2xMSG_PROT */ |
| 495 | #define HL_MAX_CB_SIZE (0x200000 - 32) |
Oded Gabbay | 5d10125 | 2019-11-10 16:08:26 +0200 | [diff] [blame] | 496 | |
Tomer Tayar | ef6a0f6 | 2020-07-09 16:17:48 +0300 | [diff] [blame] | 497 | /* Indicates whether the command buffer should be mapped to the device's MMU */ |
| 498 | #define HL_CB_FLAGS_MAP 0x1 |
| 499 | |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 500 | struct hl_cb_in { |
| 501 | /* Handle of CB or 0 if we want to create one */ |
| 502 | __u64 cb_handle; |
| 503 | /* HL_CB_OP_* */ |
| 504 | __u32 op; |
Oded Gabbay | 5d10125 | 2019-11-10 16:08:26 +0200 | [diff] [blame] | 505 | /* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that |
| 506 | * will be allocated, regardless of this parameter's value, is PAGE_SIZE |
Oded Gabbay | 541664d3 | 2019-02-28 11:55:44 +0200 | [diff] [blame] | 507 | */ |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 508 | __u32 cb_size; |
| 509 | /* Context ID - Currently not in use */ |
| 510 | __u32 ctx_id; |
Tomer Tayar | ef6a0f6 | 2020-07-09 16:17:48 +0300 | [diff] [blame] | 511 | /* HL_CB_FLAGS_* */ |
| 512 | __u32 flags; |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | struct hl_cb_out { |
Tomer Tayar | f44afb5 | 2020-09-02 13:43:32 +0300 | [diff] [blame] | 516 | union { |
| 517 | /* Handle of CB */ |
| 518 | __u64 cb_handle; |
| 519 | |
| 520 | /* Information about CB */ |
| 521 | struct { |
| 522 | /* Usage count of CB */ |
| 523 | __u32 usage_cnt; |
| 524 | __u32 pad; |
| 525 | }; |
| 526 | }; |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 527 | }; |
| 528 | |
| 529 | union hl_cb_args { |
| 530 | struct hl_cb_in in; |
| 531 | struct hl_cb_out out; |
| 532 | }; |
| 533 | |
Tal Cohen | 4bb1f2f | 2020-06-03 09:25:27 +0300 | [diff] [blame] | 534 | /* HL_CS_CHUNK_FLAGS_ values |
| 535 | * |
| 536 | * HL_CS_CHUNK_FLAGS_USER_ALLOC_CB: |
| 537 | * Indicates if the CB was allocated and mapped by userspace. |
| 538 | * User allocated CB is a command buffer allocated by the user, via malloc |
| 539 | * (or similar). After allocating the CB, the user invokes “memory ioctl” |
| 540 | * to map the user memory into a device virtual address. The user provides |
| 541 | * this address via the cb_handle field. The interface provides the |
| 542 | * ability to create a large CBs, Which aren’t limited to |
| 543 | * “HL_MAX_CB_SIZE”. Therefore, it increases the PCI-DMA queues |
| 544 | * throughput. This CB allocation method also reduces the use of Linux |
| 545 | * DMA-able memory pool. Which are limited and used by other Linux |
| 546 | * sub-systems. |
| 547 | */ |
| 548 | #define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x1 |
| 549 | |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 550 | /* |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 551 | * This structure size must always be fixed to 64-bytes for backward |
| 552 | * compatibility |
| 553 | */ |
| 554 | struct hl_cs_chunk { |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 555 | union { |
| 556 | /* For external queue, this represents a Handle of CB on the |
| 557 | * Host. |
| 558 | * For internal queue in Goya, this represents an SRAM or |
| 559 | * a DRAM address of the internal CB. In Gaudi, this might also |
| 560 | * represent a mapped host address of the CB. |
| 561 | * |
| 562 | * A mapped host address is in the device address space, after |
| 563 | * a host address was mapped by the device MMU. |
| 564 | */ |
| 565 | __u64 cb_handle; |
| 566 | |
Ofir Bitton | 5fe1c17 | 2020-09-10 10:10:55 +0300 | [diff] [blame] | 567 | /* Relevant only when HL_CS_FLAGS_WAIT or |
| 568 | * HL_CS_FLAGS_COLLECTIVE_WAIT is set. |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 569 | * This holds address of array of u64 values that contain |
| 570 | * signal CS sequence numbers. The wait described by this job |
| 571 | * will listen on all those signals (wait event per signal) |
| 572 | */ |
| 573 | __u64 signal_seq_arr; |
| 574 | }; |
| 575 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 576 | /* Index of queue to put the CB on */ |
| 577 | __u32 queue_index; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 578 | |
| 579 | union { |
| 580 | /* |
| 581 | * Size of command buffer with valid packets |
| 582 | * Can be smaller then actual CB size |
| 583 | */ |
| 584 | __u32 cb_size; |
| 585 | |
Ofir Bitton | 5fe1c17 | 2020-09-10 10:10:55 +0300 | [diff] [blame] | 586 | /* Relevant only when HL_CS_FLAGS_WAIT or |
| 587 | * HL_CS_FLAGS_COLLECTIVE_WAIT is set. |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 588 | * Number of entries in signal_seq_arr |
| 589 | */ |
| 590 | __u32 num_signal_seq_arr; |
| 591 | }; |
| 592 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 593 | /* HL_CS_CHUNK_FLAGS_* */ |
| 594 | __u32 cs_chunk_flags; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 595 | |
Ofir Bitton | 5fe1c17 | 2020-09-10 10:10:55 +0300 | [diff] [blame] | 596 | /* Relevant only when HL_CS_FLAGS_COLLECTIVE_WAIT is set. |
| 597 | * This holds the collective engine ID. The wait described by this job |
| 598 | * will sync with this engine and with all NICs before completion. |
| 599 | */ |
| 600 | __u32 collective_engine_id; |
| 601 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 602 | /* Align structure to 64 bytes */ |
Ofir Bitton | 5fe1c17 | 2020-09-10 10:10:55 +0300 | [diff] [blame] | 603 | __u32 pad[10]; |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 604 | }; |
| 605 | |
Ofir Bitton | 5fe1c17 | 2020-09-10 10:10:55 +0300 | [diff] [blame] | 606 | /* SIGNAL and WAIT/COLLECTIVE_WAIT flags are mutually exclusive */ |
Ofir Bitton | c209e74 | 2020-12-03 17:12:09 +0200 | [diff] [blame^] | 607 | #define HL_CS_FLAGS_FORCE_RESTORE 0x1 |
| 608 | #define HL_CS_FLAGS_SIGNAL 0x2 |
| 609 | #define HL_CS_FLAGS_WAIT 0x4 |
| 610 | #define HL_CS_FLAGS_COLLECTIVE_WAIT 0x8 |
| 611 | #define HL_CS_FLAGS_TIMESTAMP 0x20 |
| 612 | #define HL_CS_FLAGS_STAGED_SUBMISSION 0x40 |
| 613 | #define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x80 |
| 614 | #define HL_CS_FLAGS_STAGED_SUBMISSION_LAST 0x100 |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 615 | |
| 616 | #define HL_CS_STATUS_SUCCESS 0 |
| 617 | |
Oded Gabbay | 5d10125 | 2019-11-10 16:08:26 +0200 | [diff] [blame] | 618 | #define HL_MAX_JOBS_PER_CS 512 |
| 619 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 620 | struct hl_cs_in { |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 621 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 622 | /* this holds address of array of hl_cs_chunk for restore phase */ |
| 623 | __u64 chunks_restore; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 624 | |
| 625 | /* holds address of array of hl_cs_chunk for execution phase */ |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 626 | __u64 chunks_execute; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 627 | |
Ofir Bitton | c209e74 | 2020-12-03 17:12:09 +0200 | [diff] [blame^] | 628 | union { |
| 629 | /* this holds address of array of hl_cs_chunk for store phase - |
| 630 | * Currently not in use |
| 631 | */ |
| 632 | __u64 chunks_store; |
| 633 | |
| 634 | /* Sequence number of a staged submission CS |
| 635 | * valid only if HL_CS_FLAGS_STAGED_SUBMISSION is set |
| 636 | */ |
| 637 | __u64 seq; |
| 638 | }; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 639 | |
Oded Gabbay | 5d10125 | 2019-11-10 16:08:26 +0200 | [diff] [blame] | 640 | /* Number of chunks in restore phase array. Maximum number is |
| 641 | * HL_MAX_JOBS_PER_CS |
| 642 | */ |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 643 | __u32 num_chunks_restore; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 644 | |
Oded Gabbay | 5d10125 | 2019-11-10 16:08:26 +0200 | [diff] [blame] | 645 | /* Number of chunks in execution array. Maximum number is |
| 646 | * HL_MAX_JOBS_PER_CS |
| 647 | */ |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 648 | __u32 num_chunks_execute; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 649 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 650 | /* Number of chunks in restore phase array - Currently not in use */ |
| 651 | __u32 num_chunks_store; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 652 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 653 | /* HL_CS_FLAGS_* */ |
| 654 | __u32 cs_flags; |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 655 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 656 | /* Context ID - Currently not in use */ |
| 657 | __u32 ctx_id; |
| 658 | }; |
| 659 | |
| 660 | struct hl_cs_out { |
Oded Gabbay | e126600 | 2019-03-07 14:20:05 +0200 | [diff] [blame] | 661 | /* |
| 662 | * seq holds the sequence number of the CS to pass to wait ioctl. All |
| 663 | * values are valid except for 0 and ULLONG_MAX |
| 664 | */ |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 665 | __u64 seq; |
| 666 | /* HL_CS_STATUS_* */ |
| 667 | __u32 status; |
| 668 | __u32 pad; |
| 669 | }; |
| 670 | |
| 671 | union hl_cs_args { |
| 672 | struct hl_cs_in in; |
| 673 | struct hl_cs_out out; |
| 674 | }; |
| 675 | |
| 676 | struct hl_wait_cs_in { |
| 677 | /* Command submission sequence number */ |
| 678 | __u64 seq; |
| 679 | /* Absolute timeout to wait in microseconds */ |
| 680 | __u64 timeout_us; |
| 681 | /* Context ID - Currently not in use */ |
| 682 | __u32 ctx_id; |
| 683 | __u32 pad; |
| 684 | }; |
| 685 | |
| 686 | #define HL_WAIT_CS_STATUS_COMPLETED 0 |
| 687 | #define HL_WAIT_CS_STATUS_BUSY 1 |
| 688 | #define HL_WAIT_CS_STATUS_TIMEDOUT 2 |
| 689 | #define HL_WAIT_CS_STATUS_ABORTED 3 |
| 690 | #define HL_WAIT_CS_STATUS_INTERRUPTED 4 |
| 691 | |
Ofir Bitton | bd2f477 | 2020-11-10 17:26:22 +0200 | [diff] [blame] | 692 | #define HL_WAIT_CS_STATUS_FLAG_GONE 0x1 |
| 693 | #define HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD 0x2 |
Ofir Bitton | 9d127ad | 2020-11-10 16:30:53 +0200 | [diff] [blame] | 694 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 695 | struct hl_wait_cs_out { |
| 696 | /* HL_WAIT_CS_STATUS_* */ |
| 697 | __u32 status; |
Ofir Bitton | 9d127ad | 2020-11-10 16:30:53 +0200 | [diff] [blame] | 698 | /* HL_WAIT_CS_STATUS_FLAG* */ |
| 699 | __u32 flags; |
Ofir Bitton | bd2f477 | 2020-11-10 17:26:22 +0200 | [diff] [blame] | 700 | /* valid only if HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD is set */ |
| 701 | __s64 timestamp_nsec; |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 702 | }; |
| 703 | |
| 704 | union hl_wait_cs_args { |
| 705 | struct hl_wait_cs_in in; |
| 706 | struct hl_wait_cs_out out; |
| 707 | }; |
| 708 | |
Oded Gabbay | 3bf1c02 | 2020-06-09 16:14:55 +0300 | [diff] [blame] | 709 | /* Opcode to allocate device memory */ |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 710 | #define HL_MEM_OP_ALLOC 0 |
| 711 | /* Opcode to free previously allocated device memory */ |
| 712 | #define HL_MEM_OP_FREE 1 |
Oded Gabbay | 3bf1c02 | 2020-06-09 16:14:55 +0300 | [diff] [blame] | 713 | /* Opcode to map host and device memory */ |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 714 | #define HL_MEM_OP_MAP 2 |
Oded Gabbay | 3bf1c02 | 2020-06-09 16:14:55 +0300 | [diff] [blame] | 715 | /* Opcode to unmap previously mapped host and device memory */ |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 716 | #define HL_MEM_OP_UNMAP 3 |
| 717 | |
| 718 | /* Memory flags */ |
| 719 | #define HL_MEM_CONTIGUOUS 0x1 |
| 720 | #define HL_MEM_SHARED 0x2 |
| 721 | #define HL_MEM_USERPTR 0x4 |
| 722 | |
| 723 | struct hl_mem_in { |
| 724 | union { |
| 725 | /* HL_MEM_OP_ALLOC- allocate device memory */ |
| 726 | struct { |
| 727 | /* Size to alloc */ |
Oded Gabbay | 230afe7 | 2019-02-27 00:19:18 +0200 | [diff] [blame] | 728 | __u64 mem_size; |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 729 | } alloc; |
| 730 | |
| 731 | /* HL_MEM_OP_FREE - free device memory */ |
| 732 | struct { |
| 733 | /* Handle returned from HL_MEM_OP_ALLOC */ |
| 734 | __u64 handle; |
| 735 | } free; |
| 736 | |
| 737 | /* HL_MEM_OP_MAP - map device memory */ |
| 738 | struct { |
| 739 | /* |
| 740 | * Requested virtual address of mapped memory. |
Oded Gabbay | 4c172bb | 2019-08-30 16:59:33 +0300 | [diff] [blame] | 741 | * The driver will try to map the requested region to |
| 742 | * this hint address, as long as the address is valid |
| 743 | * and not already mapped. The user should check the |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 744 | * returned address of the IOCTL to make sure he got |
Oded Gabbay | 4c172bb | 2019-08-30 16:59:33 +0300 | [diff] [blame] | 745 | * the hint address. Passing 0 here means that the |
| 746 | * driver will choose the address itself. |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 747 | */ |
| 748 | __u64 hint_addr; |
| 749 | /* Handle returned from HL_MEM_OP_ALLOC */ |
| 750 | __u64 handle; |
| 751 | } map_device; |
| 752 | |
| 753 | /* HL_MEM_OP_MAP - map host memory */ |
| 754 | struct { |
| 755 | /* Address of allocated host memory */ |
| 756 | __u64 host_virt_addr; |
| 757 | /* |
| 758 | * Requested virtual address of mapped memory. |
Oded Gabbay | 4c172bb | 2019-08-30 16:59:33 +0300 | [diff] [blame] | 759 | * The driver will try to map the requested region to |
| 760 | * this hint address, as long as the address is valid |
| 761 | * and not already mapped. The user should check the |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 762 | * returned address of the IOCTL to make sure he got |
Oded Gabbay | 4c172bb | 2019-08-30 16:59:33 +0300 | [diff] [blame] | 763 | * the hint address. Passing 0 here means that the |
| 764 | * driver will choose the address itself. |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 765 | */ |
| 766 | __u64 hint_addr; |
| 767 | /* Size of allocated host memory */ |
Oded Gabbay | 230afe7 | 2019-02-27 00:19:18 +0200 | [diff] [blame] | 768 | __u64 mem_size; |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 769 | } map_host; |
| 770 | |
| 771 | /* HL_MEM_OP_UNMAP - unmap host memory */ |
| 772 | struct { |
| 773 | /* Virtual address returned from HL_MEM_OP_MAP */ |
| 774 | __u64 device_virt_addr; |
| 775 | } unmap; |
| 776 | }; |
| 777 | |
| 778 | /* HL_MEM_OP_* */ |
| 779 | __u32 op; |
| 780 | /* HL_MEM_* flags */ |
| 781 | __u32 flags; |
| 782 | /* Context ID - Currently not in use */ |
| 783 | __u32 ctx_id; |
| 784 | __u32 pad; |
| 785 | }; |
| 786 | |
| 787 | struct hl_mem_out { |
| 788 | union { |
| 789 | /* |
| 790 | * Used for HL_MEM_OP_MAP as the virtual address that was |
| 791 | * assigned in the device VA space. |
| 792 | * A value of 0 means the requested operation failed. |
| 793 | */ |
| 794 | __u64 device_virt_addr; |
| 795 | |
| 796 | /* |
| 797 | * Used for HL_MEM_OP_ALLOC. This is the assigned |
| 798 | * handle for the allocated memory |
| 799 | */ |
| 800 | __u64 handle; |
| 801 | }; |
| 802 | }; |
| 803 | |
| 804 | union hl_mem_args { |
| 805 | struct hl_mem_in in; |
| 806 | struct hl_mem_out out; |
| 807 | }; |
| 808 | |
Omer Shpigelman | 315bc05 | 2019-04-01 22:31:22 +0300 | [diff] [blame] | 809 | #define HL_DEBUG_MAX_AUX_VALUES 10 |
| 810 | |
| 811 | struct hl_debug_params_etr { |
| 812 | /* Address in memory to allocate buffer */ |
| 813 | __u64 buffer_address; |
| 814 | |
| 815 | /* Size of buffer to allocate */ |
| 816 | __u64 buffer_size; |
| 817 | |
| 818 | /* Sink operation mode: SW fifo, HW fifo, Circular buffer */ |
| 819 | __u32 sink_mode; |
| 820 | __u32 pad; |
| 821 | }; |
| 822 | |
| 823 | struct hl_debug_params_etf { |
| 824 | /* Address in memory to allocate buffer */ |
| 825 | __u64 buffer_address; |
| 826 | |
| 827 | /* Size of buffer to allocate */ |
| 828 | __u64 buffer_size; |
| 829 | |
| 830 | /* Sink operation mode: SW fifo, HW fifo, Circular buffer */ |
| 831 | __u32 sink_mode; |
| 832 | __u32 pad; |
| 833 | }; |
| 834 | |
| 835 | struct hl_debug_params_stm { |
| 836 | /* Two bit masks for HW event and Stimulus Port */ |
| 837 | __u64 he_mask; |
| 838 | __u64 sp_mask; |
| 839 | |
| 840 | /* Trace source ID */ |
| 841 | __u32 id; |
| 842 | |
| 843 | /* Frequency for the timestamp register */ |
| 844 | __u32 frequency; |
| 845 | }; |
| 846 | |
| 847 | struct hl_debug_params_bmon { |
Oded Gabbay | d691171 | 2019-04-21 16:20:46 +0300 | [diff] [blame] | 848 | /* Two address ranges that the user can request to filter */ |
| 849 | __u64 start_addr0; |
| 850 | __u64 addr_mask0; |
| 851 | |
| 852 | __u64 start_addr1; |
| 853 | __u64 addr_mask1; |
Omer Shpigelman | 315bc05 | 2019-04-01 22:31:22 +0300 | [diff] [blame] | 854 | |
| 855 | /* Capture window configuration */ |
| 856 | __u32 bw_win; |
| 857 | __u32 win_capture; |
| 858 | |
| 859 | /* Trace source ID */ |
| 860 | __u32 id; |
| 861 | __u32 pad; |
| 862 | }; |
| 863 | |
| 864 | struct hl_debug_params_spmu { |
| 865 | /* Event types selection */ |
| 866 | __u64 event_types[HL_DEBUG_MAX_AUX_VALUES]; |
| 867 | |
| 868 | /* Number of event types selection */ |
| 869 | __u32 event_types_num; |
| 870 | __u32 pad; |
| 871 | }; |
| 872 | |
| 873 | /* Opcode for ETR component */ |
| 874 | #define HL_DEBUG_OP_ETR 0 |
| 875 | /* Opcode for ETF component */ |
| 876 | #define HL_DEBUG_OP_ETF 1 |
| 877 | /* Opcode for STM component */ |
| 878 | #define HL_DEBUG_OP_STM 2 |
| 879 | /* Opcode for FUNNEL component */ |
| 880 | #define HL_DEBUG_OP_FUNNEL 3 |
| 881 | /* Opcode for BMON component */ |
| 882 | #define HL_DEBUG_OP_BMON 4 |
| 883 | /* Opcode for SPMU component */ |
| 884 | #define HL_DEBUG_OP_SPMU 5 |
Tomer Tayar | 413cf57 | 2019-08-27 16:14:18 +0000 | [diff] [blame] | 885 | /* Opcode for timestamp (deprecated) */ |
Omer Shpigelman | 315bc05 | 2019-04-01 22:31:22 +0300 | [diff] [blame] | 886 | #define HL_DEBUG_OP_TIMESTAMP 6 |
Oded Gabbay | 2add64e | 2019-05-04 16:30:00 +0300 | [diff] [blame] | 887 | /* Opcode for setting the device into or out of debug mode. The enable |
| 888 | * variable should be 1 for enabling debug mode and 0 for disabling it |
| 889 | */ |
| 890 | #define HL_DEBUG_OP_SET_MODE 7 |
Omer Shpigelman | 315bc05 | 2019-04-01 22:31:22 +0300 | [diff] [blame] | 891 | |
| 892 | struct hl_debug_args { |
| 893 | /* |
| 894 | * Pointer to user input structure. |
| 895 | * This field is relevant to specific opcodes. |
| 896 | */ |
| 897 | __u64 input_ptr; |
| 898 | /* Pointer to user output structure */ |
| 899 | __u64 output_ptr; |
| 900 | /* Size of user input structure */ |
| 901 | __u32 input_size; |
| 902 | /* Size of user output structure */ |
| 903 | __u32 output_size; |
| 904 | /* HL_DEBUG_OP_* */ |
| 905 | __u32 op; |
| 906 | /* |
| 907 | * Register index in the component, taken from the debug_regs_index enum |
| 908 | * in the various ASIC header files |
| 909 | */ |
| 910 | __u32 reg_idx; |
| 911 | /* Enable/disable */ |
| 912 | __u32 enable; |
| 913 | /* Context ID - Currently not in use */ |
| 914 | __u32 ctx_id; |
| 915 | }; |
| 916 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 917 | /* |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 918 | * Various information operations such as: |
| 919 | * - H/W IP information |
| 920 | * - Current dram usage |
| 921 | * |
| 922 | * The user calls this IOCTL with an opcode that describes the required |
| 923 | * information. The user should supply a pointer to a user-allocated memory |
| 924 | * chunk, which will be filled by the driver with the requested information. |
| 925 | * |
| 926 | * The user supplies the maximum amount of size to copy into the user's memory, |
| 927 | * in order to prevent data corruption in case of differences between the |
| 928 | * definitions of structures in kernel and userspace, e.g. in case of old |
| 929 | * userspace and new kernel driver |
| 930 | */ |
| 931 | #define HL_IOCTL_INFO \ |
| 932 | _IOWR('H', 0x01, struct hl_info_args) |
| 933 | |
| 934 | /* |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 935 | * Command Buffer |
| 936 | * - Request a Command Buffer |
| 937 | * - Destroy a Command Buffer |
| 938 | * |
| 939 | * The command buffers are memory blocks that reside in DMA-able address |
| 940 | * space and are physically contiguous so they can be accessed by the device |
| 941 | * directly. They are allocated using the coherent DMA API. |
| 942 | * |
| 943 | * When creating a new CB, the IOCTL returns a handle of it, and the user-space |
| 944 | * process needs to use that handle to mmap the buffer so it can access them. |
| 945 | * |
Tomer Tayar | ef6a0f6 | 2020-07-09 16:17:48 +0300 | [diff] [blame] | 946 | * In some instances, the device must access the command buffer through the |
| 947 | * device's MMU, and thus its memory should be mapped. In these cases, user can |
| 948 | * indicate the driver that such a mapping is required. |
| 949 | * The resulting device virtual address will be used internally by the driver, |
| 950 | * and won't be returned to user. |
| 951 | * |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 952 | */ |
| 953 | #define HL_IOCTL_CB \ |
| 954 | _IOWR('H', 0x02, union hl_cb_args) |
| 955 | |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 956 | /* |
| 957 | * Command Submission |
| 958 | * |
| 959 | * To submit work to the device, the user need to call this IOCTL with a set |
| 960 | * of JOBS. That set of JOBS constitutes a CS object. |
| 961 | * Each JOB will be enqueued on a specific queue, according to the user's input. |
| 962 | * There can be more then one JOB per queue. |
| 963 | * |
Oded Gabbay | 9002729 | 2019-04-03 09:51:04 +0300 | [diff] [blame] | 964 | * The CS IOCTL will receive three sets of JOBS. One set is for "restore" phase, |
| 965 | * a second set is for "execution" phase and a third set is for "store" phase. |
| 966 | * The JOBS on the "restore" phase are enqueued only after context-switch |
| 967 | * (or if its the first CS for this context). The user can also order the |
| 968 | * driver to run the "restore" phase explicitly |
| 969 | * |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 970 | * There are two types of queues - external and internal. External queues |
| 971 | * are DMA queues which transfer data from/to the Host. All other queues are |
| 972 | * internal. The driver will get completion notifications from the device only |
| 973 | * on JOBS which are enqueued in the external queues. |
| 974 | * |
Oded Gabbay | 541664d3 | 2019-02-28 11:55:44 +0200 | [diff] [blame] | 975 | * For jobs on external queues, the user needs to create command buffers |
| 976 | * through the CB ioctl and give the CB's handle to the CS ioctl. For jobs on |
| 977 | * internal queues, the user needs to prepare a "command buffer" with packets |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 978 | * on either the device SRAM/DRAM or the host, and give the device address of |
| 979 | * that buffer to the CS ioctl. |
Oded Gabbay | 541664d3 | 2019-02-28 11:55:44 +0200 | [diff] [blame] | 980 | * |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 981 | * This IOCTL is asynchronous in regard to the actual execution of the CS. This |
| 982 | * means it returns immediately after ALL the JOBS were enqueued on their |
| 983 | * relevant queues. Therefore, the user mustn't assume the CS has been completed |
| 984 | * or has even started to execute. |
| 985 | * |
Oded Gabbay | 9002729 | 2019-04-03 09:51:04 +0300 | [diff] [blame] | 986 | * Upon successful enqueue, the IOCTL returns a sequence number which the user |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 987 | * can use with the "Wait for CS" IOCTL to check whether the handle's CS |
| 988 | * external JOBS have been completed. Note that if the CS has internal JOBS |
| 989 | * which can execute AFTER the external JOBS have finished, the driver might |
| 990 | * report that the CS has finished executing BEFORE the internal JOBS have |
Omer Shpigelman | f9e5f29 | 2020-05-07 13:41:16 +0300 | [diff] [blame] | 991 | * actually finished executing. |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 992 | * |
Oded Gabbay | 9002729 | 2019-04-03 09:51:04 +0300 | [diff] [blame] | 993 | * Even though the sequence number increments per CS, the user can NOT |
| 994 | * automatically assume that if CS with sequence number N finished, then CS |
| 995 | * with sequence number N-1 also finished. The user can make this assumption if |
| 996 | * and only if CS N and CS N-1 are exactly the same (same CBs for the same |
| 997 | * queues). |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 998 | */ |
| 999 | #define HL_IOCTL_CS \ |
| 1000 | _IOWR('H', 0x03, union hl_cs_args) |
| 1001 | |
| 1002 | /* |
| 1003 | * Wait for Command Submission |
| 1004 | * |
| 1005 | * The user can call this IOCTL with a handle it received from the CS IOCTL |
| 1006 | * to wait until the handle's CS has finished executing. The user will wait |
Tomer Tayar | f435614 | 2019-10-02 13:53:52 +0000 | [diff] [blame] | 1007 | * inside the kernel until the CS has finished or until the user-requested |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 1008 | * timeout has expired. |
| 1009 | * |
Oded Gabbay | 681a22f | 2020-09-07 18:08:51 +0300 | [diff] [blame] | 1010 | * If the timeout value is 0, the driver won't sleep at all. It will check |
| 1011 | * the status of the CS and return immediately |
| 1012 | * |
Oded Gabbay | eff6f4a | 2019-02-16 00:39:21 +0200 | [diff] [blame] | 1013 | * The return value of the IOCTL is a standard Linux error code. The possible |
| 1014 | * values are: |
| 1015 | * |
| 1016 | * EINTR - Kernel waiting has been interrupted, e.g. due to OS signal |
| 1017 | * that the user process received |
| 1018 | * ETIMEDOUT - The CS has caused a timeout on the device |
| 1019 | * EIO - The CS was aborted (usually because the device was reset) |
| 1020 | * ENODEV - The device wants to do hard-reset (so user need to close FD) |
| 1021 | * |
| 1022 | * The driver also returns a custom define inside the IOCTL which can be: |
| 1023 | * |
| 1024 | * HL_WAIT_CS_STATUS_COMPLETED - The CS has been completed successfully (0) |
| 1025 | * HL_WAIT_CS_STATUS_BUSY - The CS is still executing (0) |
| 1026 | * HL_WAIT_CS_STATUS_TIMEDOUT - The CS has caused a timeout on the device |
| 1027 | * (ETIMEDOUT) |
| 1028 | * HL_WAIT_CS_STATUS_ABORTED - The CS was aborted, usually because the |
| 1029 | * device was reset (EIO) |
| 1030 | * HL_WAIT_CS_STATUS_INTERRUPTED - Waiting for the CS was interrupted (EINTR) |
| 1031 | * |
| 1032 | */ |
| 1033 | |
| 1034 | #define HL_IOCTL_WAIT_CS \ |
| 1035 | _IOWR('H', 0x04, union hl_wait_cs_args) |
| 1036 | |
Omer Shpigelman | 0feaf86 | 2019-02-16 00:39:22 +0200 | [diff] [blame] | 1037 | /* |
| 1038 | * Memory |
| 1039 | * - Map host memory to device MMU |
| 1040 | * - Unmap host memory from device MMU |
| 1041 | * |
| 1042 | * This IOCTL allows the user to map host memory to the device MMU |
| 1043 | * |
| 1044 | * For host memory, the IOCTL doesn't allocate memory. The user is supposed |
| 1045 | * to allocate the memory in user-space (malloc/new). The driver pins the |
| 1046 | * physical pages (up to the allowed limit by the OS), assigns a virtual |
| 1047 | * address in the device VA space and initializes the device MMU. |
| 1048 | * |
| 1049 | * There is an option for the user to specify the requested virtual address. |
| 1050 | * |
| 1051 | */ |
| 1052 | #define HL_IOCTL_MEMORY \ |
| 1053 | _IOWR('H', 0x05, union hl_mem_args) |
| 1054 | |
Omer Shpigelman | 315bc05 | 2019-04-01 22:31:22 +0300 | [diff] [blame] | 1055 | /* |
| 1056 | * Debug |
| 1057 | * - Enable/disable the ETR/ETF/FUNNEL/STM/BMON/SPMU debug traces |
| 1058 | * |
| 1059 | * This IOCTL allows the user to get debug traces from the chip. |
| 1060 | * |
Oded Gabbay | 2add64e | 2019-05-04 16:30:00 +0300 | [diff] [blame] | 1061 | * Before the user can send configuration requests of the various |
| 1062 | * debug/profile engines, it needs to set the device into debug mode. |
| 1063 | * This is because the debug/profile infrastructure is shared component in the |
| 1064 | * device and we can't allow multiple users to access it at the same time. |
| 1065 | * |
| 1066 | * Once a user set the device into debug mode, the driver won't allow other |
| 1067 | * users to "work" with the device, i.e. open a FD. If there are multiple users |
| 1068 | * opened on the device, the driver won't allow any user to debug the device. |
| 1069 | * |
| 1070 | * For each configuration request, the user needs to provide the register index |
| 1071 | * and essential data such as buffer address and size. |
| 1072 | * |
| 1073 | * Once the user has finished using the debug/profile engines, he should |
| 1074 | * set the device into non-debug mode, i.e. disable debug mode. |
| 1075 | * |
| 1076 | * The driver can decide to "kick out" the user if he abuses this interface. |
Omer Shpigelman | 315bc05 | 2019-04-01 22:31:22 +0300 | [diff] [blame] | 1077 | * |
| 1078 | */ |
| 1079 | #define HL_IOCTL_DEBUG \ |
| 1080 | _IOWR('H', 0x06, struct hl_debug_args) |
| 1081 | |
Oded Gabbay | d8dd7b0 | 2019-02-16 00:39:23 +0200 | [diff] [blame] | 1082 | #define HL_COMMAND_START 0x01 |
Omer Shpigelman | 315bc05 | 2019-04-01 22:31:22 +0300 | [diff] [blame] | 1083 | #define HL_COMMAND_END 0x07 |
Oded Gabbay | be5d926 | 2019-02-16 00:39:15 +0200 | [diff] [blame] | 1084 | |
Oded Gabbay | 99b9d7b | 2019-02-16 00:39:13 +0200 | [diff] [blame] | 1085 | #endif /* HABANALABS_H_ */ |