Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/accel/amdxdna/aie2_msg_priv.h
50951 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
/*
3
* Copyright (C) 2022-2024, Advanced Micro Devices, Inc.
4
*/
5
6
#ifndef _AIE2_MSG_PRIV_H_
7
#define _AIE2_MSG_PRIV_H_
8
9
enum aie2_msg_opcode {
10
MSG_OP_CREATE_CONTEXT = 0x2,
11
MSG_OP_DESTROY_CONTEXT = 0x3,
12
MSG_OP_GET_TELEMETRY = 0x4,
13
MSG_OP_SYNC_BO = 0x7,
14
MSG_OP_EXECUTE_BUFFER_CF = 0xC,
15
MSG_OP_QUERY_COL_STATUS = 0xD,
16
MSG_OP_QUERY_AIE_TILE_INFO = 0xE,
17
MSG_OP_QUERY_AIE_VERSION = 0xF,
18
MSG_OP_EXEC_DPU = 0x10,
19
MSG_OP_CONFIG_CU = 0x11,
20
MSG_OP_CHAIN_EXEC_BUFFER_CF = 0x12,
21
MSG_OP_CHAIN_EXEC_DPU = 0x13,
22
MSG_OP_CONFIG_DEBUG_BO = 0x14,
23
MSG_OP_CHAIN_EXEC_NPU = 0x18,
24
MSG_OP_MAX_XRT_OPCODE,
25
MSG_OP_SUSPEND = 0x101,
26
MSG_OP_RESUME = 0x102,
27
MSG_OP_ASSIGN_MGMT_PASID = 0x103,
28
MSG_OP_INVOKE_SELF_TEST = 0x104,
29
MSG_OP_MAP_HOST_BUFFER = 0x106,
30
MSG_OP_GET_FIRMWARE_VERSION = 0x108,
31
MSG_OP_SET_RUNTIME_CONFIG = 0x10A,
32
MSG_OP_GET_RUNTIME_CONFIG = 0x10B,
33
MSG_OP_REGISTER_ASYNC_EVENT_MSG = 0x10C,
34
MSG_OP_MAX_DRV_OPCODE,
35
MSG_OP_GET_PROTOCOL_VERSION = 0x301,
36
MSG_OP_MAX_OPCODE
37
};
38
39
enum aie2_msg_status {
40
AIE2_STATUS_SUCCESS = 0x0,
41
/* AIE Error codes */
42
AIE2_STATUS_AIE_SATURATION_ERROR = 0x1000001,
43
AIE2_STATUS_AIE_FP_ERROR = 0x1000002,
44
AIE2_STATUS_AIE_STREAM_ERROR = 0x1000003,
45
AIE2_STATUS_AIE_ACCESS_ERROR = 0x1000004,
46
AIE2_STATUS_AIE_BUS_ERROR = 0x1000005,
47
AIE2_STATUS_AIE_INSTRUCTION_ERROR = 0x1000006,
48
AIE2_STATUS_AIE_ECC_ERROR = 0x1000007,
49
AIE2_STATUS_AIE_LOCK_ERROR = 0x1000008,
50
AIE2_STATUS_AIE_DMA_ERROR = 0x1000009,
51
AIE2_STATUS_AIE_MEM_PARITY_ERROR = 0x100000a,
52
AIE2_STATUS_AIE_PWR_CFG_ERROR = 0x100000b,
53
AIE2_STATUS_AIE_BACKTRACK_ERROR = 0x100000c,
54
AIE2_STATUS_MAX_AIE_STATUS_CODE,
55
/* MGMT ERT Error codes */
56
AIE2_STATUS_MGMT_ERT_SELF_TEST_FAILURE = 0x2000001,
57
AIE2_STATUS_MGMT_ERT_HASH_MISMATCH,
58
AIE2_STATUS_MGMT_ERT_NOAVAIL,
59
AIE2_STATUS_MGMT_ERT_INVALID_PARAM,
60
AIE2_STATUS_MGMT_ERT_ENTER_SUSPEND_FAILURE,
61
AIE2_STATUS_MGMT_ERT_BUSY,
62
AIE2_STATUS_MGMT_ERT_APPLICATION_ACTIVE,
63
MAX_MGMT_ERT_STATUS_CODE,
64
/* APP ERT Error codes */
65
AIE2_STATUS_APP_ERT_FIRST_ERROR = 0x3000001,
66
AIE2_STATUS_APP_INVALID_INSTR,
67
AIE2_STATUS_APP_LOAD_PDI_FAIL,
68
MAX_APP_ERT_STATUS_CODE,
69
/* NPU RTOS Error Codes */
70
AIE2_STATUS_INVALID_INPUT_BUFFER = 0x4000001,
71
AIE2_STATUS_INVALID_COMMAND,
72
AIE2_STATUS_INVALID_PARAM,
73
AIE2_STATUS_INVALID_OPERATION = 0x4000006,
74
AIE2_STATUS_ASYNC_EVENT_MSGS_FULL,
75
AIE2_STATUS_MAX_RTOS_STATUS_CODE,
76
MAX_AIE2_STATUS_CODE
77
};
78
79
struct assign_mgmt_pasid_req {
80
__u16 pasid;
81
__u16 reserved;
82
} __packed;
83
84
struct assign_mgmt_pasid_resp {
85
enum aie2_msg_status status;
86
} __packed;
87
88
struct map_host_buffer_req {
89
__u32 context_id;
90
__u64 buf_addr;
91
__u64 buf_size;
92
} __packed;
93
94
struct map_host_buffer_resp {
95
enum aie2_msg_status status;
96
} __packed;
97
98
#define MAX_CQ_PAIRS 2
99
struct cq_info {
100
__u32 head_addr;
101
__u32 tail_addr;
102
__u32 buf_addr;
103
__u32 buf_size;
104
};
105
106
struct cq_pair {
107
struct cq_info x2i_q;
108
struct cq_info i2x_q;
109
};
110
111
#define PRIORITY_REALTIME 1
112
#define PRIORITY_HIGH 2
113
#define PRIORITY_NORMAL 3
114
#define PRIORITY_LOW 4
115
116
struct create_ctx_req {
117
__u32 aie_type;
118
__u8 start_col;
119
__u8 num_col;
120
__u8 num_unused_col;
121
__u8 reserved;
122
__u8 num_cq_pairs_requested;
123
__u8 reserved1;
124
__u16 pasid;
125
__u32 pad[2];
126
__u32 sec_comm_target_type;
127
__u32 context_priority;
128
} __packed;
129
130
struct create_ctx_resp {
131
enum aie2_msg_status status;
132
__u32 context_id;
133
__u16 msix_id;
134
__u8 num_cq_pairs_allocated;
135
__u8 reserved;
136
struct cq_pair cq_pair[MAX_CQ_PAIRS];
137
} __packed;
138
139
struct destroy_ctx_req {
140
__u32 context_id;
141
} __packed;
142
143
struct destroy_ctx_resp {
144
enum aie2_msg_status status;
145
} __packed;
146
147
enum telemetry_type {
148
TELEMETRY_TYPE_DISABLED,
149
TELEMETRY_TYPE_HEALTH,
150
TELEMETRY_TYPE_ERROR_INFO,
151
TELEMETRY_TYPE_PROFILING,
152
TELEMETRY_TYPE_DEBUG,
153
MAX_TELEMETRY_TYPE
154
};
155
156
struct get_telemetry_req {
157
enum telemetry_type type;
158
__u64 buf_addr;
159
__u32 buf_size;
160
} __packed;
161
162
struct get_telemetry_resp {
163
__u32 major;
164
__u32 minor;
165
__u32 size;
166
enum aie2_msg_status status;
167
} __packed;
168
169
struct execute_buffer_req {
170
__u32 cu_idx;
171
__u32 payload[19];
172
} __packed;
173
174
struct exec_dpu_req {
175
__u64 inst_buf_addr;
176
__u32 inst_size;
177
__u32 inst_prop_cnt;
178
__u32 cu_idx;
179
__u32 payload[35];
180
} __packed;
181
182
enum exec_npu_type {
183
EXEC_NPU_TYPE_NON_ELF = 0x1,
184
EXEC_NPU_TYPE_PARTIAL_ELF = 0x2,
185
EXEC_NPU_TYPE_PREEMPT = 0x3,
186
EXEC_NPU_TYPE_ELF = 0x4,
187
};
188
189
union exec_req {
190
struct execute_buffer_req ebuf;
191
struct exec_dpu_req dpu_req;
192
};
193
194
struct execute_buffer_resp {
195
enum aie2_msg_status status;
196
} __packed;
197
198
struct aie_tile_info {
199
__u32 size;
200
__u16 major;
201
__u16 minor;
202
__u16 cols;
203
__u16 rows;
204
__u16 core_rows;
205
__u16 mem_rows;
206
__u16 shim_rows;
207
__u16 core_row_start;
208
__u16 mem_row_start;
209
__u16 shim_row_start;
210
__u16 core_dma_channels;
211
__u16 mem_dma_channels;
212
__u16 shim_dma_channels;
213
__u16 core_locks;
214
__u16 mem_locks;
215
__u16 shim_locks;
216
__u16 core_events;
217
__u16 mem_events;
218
__u16 shim_events;
219
__u16 reserved;
220
};
221
222
struct aie_tile_info_req {
223
__u32 reserved;
224
} __packed;
225
226
struct aie_tile_info_resp {
227
enum aie2_msg_status status;
228
struct aie_tile_info info;
229
} __packed;
230
231
struct aie_version_info_req {
232
__u32 reserved;
233
} __packed;
234
235
struct aie_version_info_resp {
236
enum aie2_msg_status status;
237
__u16 major;
238
__u16 minor;
239
} __packed;
240
241
struct aie_column_info_req {
242
__u64 dump_buff_addr;
243
__u32 dump_buff_size;
244
__u32 num_cols;
245
__u32 aie_bitmap;
246
} __packed;
247
248
struct aie_column_info_resp {
249
enum aie2_msg_status status;
250
__u32 size;
251
} __packed;
252
253
struct suspend_req {
254
__u32 place_holder;
255
} __packed;
256
257
struct suspend_resp {
258
enum aie2_msg_status status;
259
} __packed;
260
261
struct resume_req {
262
__u32 place_holder;
263
} __packed;
264
265
struct resume_resp {
266
enum aie2_msg_status status;
267
} __packed;
268
269
struct check_header_hash_req {
270
__u64 hash_high;
271
__u64 hash_low;
272
} __packed;
273
274
struct check_header_hash_resp {
275
enum aie2_msg_status status;
276
} __packed;
277
278
struct query_error_req {
279
__u64 buf_addr;
280
__u32 buf_size;
281
__u32 next_row;
282
__u32 next_column;
283
__u32 next_module;
284
} __packed;
285
286
struct query_error_resp {
287
enum aie2_msg_status status;
288
__u32 num_err;
289
__u32 has_next_err;
290
__u32 next_row;
291
__u32 next_column;
292
__u32 next_module;
293
} __packed;
294
295
struct protocol_version_req {
296
__u32 reserved;
297
} __packed;
298
299
struct protocol_version_resp {
300
enum aie2_msg_status status;
301
__u32 major;
302
__u32 minor;
303
} __packed;
304
305
struct firmware_version_req {
306
__u32 reserved;
307
} __packed;
308
309
struct firmware_version_resp {
310
enum aie2_msg_status status;
311
__u32 major;
312
__u32 minor;
313
__u32 sub;
314
__u32 build;
315
} __packed;
316
317
#define MAX_NUM_CUS 32
318
#define AIE2_MSG_CFG_CU_PDI_ADDR GENMASK(16, 0)
319
#define AIE2_MSG_CFG_CU_FUNC GENMASK(24, 17)
320
struct config_cu_req {
321
__u32 num_cus;
322
__u32 cfgs[MAX_NUM_CUS];
323
} __packed;
324
325
struct config_cu_resp {
326
enum aie2_msg_status status;
327
} __packed;
328
329
struct set_runtime_cfg_req {
330
__u32 type;
331
__u64 value;
332
} __packed;
333
334
struct set_runtime_cfg_resp {
335
enum aie2_msg_status status;
336
} __packed;
337
338
struct get_runtime_cfg_req {
339
__u32 type;
340
} __packed;
341
342
struct get_runtime_cfg_resp {
343
enum aie2_msg_status status;
344
__u64 value;
345
} __packed;
346
347
enum async_event_type {
348
ASYNC_EVENT_TYPE_AIE_ERROR,
349
ASYNC_EVENT_TYPE_EXCEPTION,
350
MAX_ASYNC_EVENT_TYPE
351
};
352
353
#define ASYNC_BUF_SIZE SZ_8K
354
struct async_event_msg_req {
355
__u64 buf_addr;
356
__u32 buf_size;
357
} __packed;
358
359
struct async_event_msg_resp {
360
enum aie2_msg_status status;
361
enum async_event_type type;
362
} __packed;
363
364
#define MAX_CHAIN_CMDBUF_SIZE SZ_4K
365
366
struct cmd_chain_slot_execbuf_cf {
367
__u32 cu_idx;
368
__u32 arg_cnt;
369
__u32 args[] __counted_by(arg_cnt);
370
};
371
372
struct cmd_chain_slot_dpu {
373
__u64 inst_buf_addr;
374
__u32 inst_size;
375
__u32 inst_prop_cnt;
376
__u32 cu_idx;
377
__u32 arg_cnt;
378
#define MAX_DPU_ARGS_SIZE (34 * sizeof(__u32))
379
__u32 args[] __counted_by(arg_cnt);
380
};
381
382
#define MAX_NPU_ARGS_SIZE (26 * sizeof(__u32))
383
#define AIE2_EXEC_BUFFER_KERNEL_OP_TXN 3
384
struct cmd_chain_slot_npu {
385
enum exec_npu_type type;
386
u64 inst_buf_addr;
387
u64 save_buf_addr;
388
u64 restore_buf_addr;
389
u32 inst_size;
390
u32 save_size;
391
u32 restore_size;
392
u32 inst_prop_cnt;
393
u32 cu_idx;
394
u32 arg_cnt;
395
u32 args[] __counted_by(arg_cnt);
396
} __packed;
397
398
struct cmd_chain_req {
399
__u64 buf_addr;
400
__u32 buf_size;
401
__u32 count;
402
} __packed;
403
404
struct cmd_chain_npu_req {
405
u32 flags;
406
u32 reserved;
407
u64 buf_addr;
408
u32 buf_size;
409
u32 count;
410
} __packed;
411
412
union exec_chain_req {
413
struct cmd_chain_npu_req npu_req;
414
struct cmd_chain_req req;
415
};
416
417
struct cmd_chain_resp {
418
enum aie2_msg_status status;
419
__u32 fail_cmd_idx;
420
enum aie2_msg_status fail_cmd_status;
421
} __packed;
422
423
#define AIE2_MSG_SYNC_BO_SRC_TYPE GENMASK(3, 0)
424
#define AIE2_MSG_SYNC_BO_DST_TYPE GENMASK(7, 4)
425
struct sync_bo_req {
426
__u64 src_addr;
427
__u64 dst_addr;
428
__u32 size;
429
#define SYNC_BO_DEV_MEM 0
430
#define SYNC_BO_HOST_MEM 2
431
__u32 type;
432
} __packed;
433
434
struct sync_bo_resp {
435
enum aie2_msg_status status;
436
} __packed;
437
438
#define DEBUG_BO_UNREGISTER 0
439
#define DEBUG_BO_REGISTER 1
440
struct config_debug_bo_req {
441
__u64 offset;
442
__u64 size;
443
/*
444
* config operations.
445
* DEBUG_BO_REGISTER: Register debug buffer
446
* DEBUG_BO_UNREGISTER: Unregister debug buffer
447
*/
448
__u32 config;
449
} __packed;
450
451
struct config_debug_bo_resp {
452
enum aie2_msg_status status;
453
} __packed;
454
#endif /* _AIE2_MSG_PRIV_H_ */
455
456