xref: /linux/drivers/accel/amdxdna/aie4_msg_priv.h (revision bba2c3615bd6cfee7456d1130f2e6b01b3f4e9ba)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2026, Advanced Micro Devices, Inc.
4  */
5 
6 #ifndef _AIE4_MSG_PRIV_H_
7 #define _AIE4_MSG_PRIV_H_
8 
9 #include <linux/sizes.h>
10 #include <linux/types.h>
11 
12 enum aie4_msg_opcode {
13 	AIE4_MSG_OP_SUSPEND                          = 0x10003,
14 	AIE4_MSG_OP_ATTACH_WORK_BUFFER               = 0x1000D,
15 
16 	AIE4_MSG_OP_CREATE_VFS                       = 0x20001,
17 	AIE4_MSG_OP_DESTROY_VFS                      = 0x20002,
18 
19 	AIE4_MSG_OP_CREATE_PARTITION                 = 0x30001,
20 	AIE4_MSG_OP_DESTROY_PARTITION                = 0x30002,
21 	AIE4_MSG_OP_CREATE_HW_CONTEXT                = 0x30003,
22 	AIE4_MSG_OP_DESTROY_HW_CONTEXT               = 0x30004,
23 	AIE4_MSG_OP_AIE_TILE_INFO                    = 0x30006,
24 };
25 
26 enum aie4_msg_status {
27 	AIE4_MSG_STATUS_SUCCESS = 0x0,
28 	AIE4_MSG_STATUS_ERROR = 0x1,
29 	AIE4_MSG_STATUS_NOTSUPP = 0x2,
30 	MAX_AIE4_MSG_STATUS_CODE = 0x4,
31 };
32 
33 struct aie4_msg_suspend_req {
34 	__u32 rsvd;
35 } __packed;
36 
37 struct aie4_msg_suspend_resp {
38 	enum aie4_msg_status status;
39 } __packed;
40 
41 struct aie4_msg_create_vfs_req {
42 	__u32 vf_cnt;
43 } __packed;
44 
45 struct aie4_msg_create_vfs_resp {
46 	enum aie4_msg_status status;
47 } __packed;
48 
49 struct aie4_msg_destroy_vfs_req {
50 	__u32 rsvd;
51 } __packed;
52 
53 struct aie4_msg_destroy_vfs_resp {
54 	enum aie4_msg_status status;
55 } __packed;
56 
57 struct aie4_msg_create_partition_req {
58 	__u32 partition_col_start;
59 	__u32 partition_col_count;
60 } __packed;
61 
62 struct aie4_msg_create_partition_resp {
63 	enum aie4_msg_status status;
64 	__u32 partition_id;
65 } __packed;
66 
67 struct aie4_msg_destroy_partition_req {
68 	__u32 partition_id;
69 } __packed;
70 
71 struct aie4_msg_destroy_partition_resp {
72 	enum aie4_msg_status status;
73 } __packed;
74 
75 struct aie4_msg_create_hw_context_req {
76 	__u32 partition_id;
77 	__u32 request_num_tiles;
78 	__u32 hsa_addr_high;
79 	__u32 hsa_addr_low;
80 #define AIE4_MSG_PASID GENMASK(19, 0)
81 #define AIE4_MSG_PASID_VLD GENMASK(31, 31)
82 	__u32 pasid;
83 	__u32 priority_band;
84 } __packed;
85 
86 struct aie4_msg_create_hw_context_resp {
87 	enum aie4_msg_status status;
88 	__u32 hw_context_id;
89 	__u32 doorbell_offset;
90 	__u32 job_complete_msix_idx;
91 } __packed;
92 
93 struct aie4_msg_destroy_hw_context_req {
94 	__u32 hw_context_id;
95 	__u32 resvd1;
96 } __packed;
97 
98 struct aie4_msg_destroy_hw_context_resp {
99 	enum aie4_msg_status status;
100 } __packed;
101 
102 struct aie4_tile_info {
103 	__u32 size;
104 	__u16 major;
105 	__u16 minor;
106 	__u16 cols;
107 	__u16 rows;
108 	__u16 core_rows;
109 	__u16 mem_rows;
110 	__u16 shim_rows;
111 	__u16 core_row_start;
112 	__u16 mem_row_start;
113 	__u16 shim_row_start;
114 	__u16 core_dma_channels;
115 	__u16 mem_dma_channels;
116 	__u16 shim_dma_channels;
117 	__u16 core_locks;
118 	__u16 mem_locks;
119 	__u16 shim_locks;
120 	__u16 core_events;
121 	__u16 mem_events;
122 	__u16 shim_events;
123 	__u16 resvd;
124 } __packed;
125 
126 struct aie4_msg_aie4_tile_info_req {
127 	__u32 resvd;
128 } __packed;
129 
130 struct aie4_msg_aie4_tile_info_resp {
131 	enum aie4_msg_status status;
132 	struct aie4_tile_info info;
133 } __packed;
134 
135 #define AIE4_WORK_BUFFER_MIN_SIZE      SZ_4M
136 
137 struct aie4_msg_attach_work_buffer_req {
138 	__u64 buff_addr;
139 	__u32 reserved;
140 	__u32 buff_size;
141 } __packed;
142 
143 struct aie4_msg_attach_work_buffer_resp {
144 	enum aie4_msg_status status;
145 } __packed;
146 
147 #endif /* _AIE4_MSG_PRIV_H_ */
148