drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / drivers / accel / habanalabs / include / gaudi / gaudi_packets.h
blob66fc083a7c6a430ff02dd7038568e93e0aaadac5
1 /* SPDX-License-Identifier: GPL-2.0
3 * Copyright 2017-2020 HabanaLabs, Ltd.
4 * All Rights Reserved.
6 */
8 #ifndef GAUDI_PACKETS_H
9 #define GAUDI_PACKETS_H
11 #include <linux/types.h>
13 #define PACKET_HEADER_PACKET_ID_SHIFT 56
14 #define PACKET_HEADER_PACKET_ID_MASK 0x1F00000000000000ull
16 enum packet_id {
17 PACKET_WREG_32 = 0x1,
18 PACKET_WREG_BULK = 0x2,
19 PACKET_MSG_LONG = 0x3,
20 PACKET_MSG_SHORT = 0x4,
21 PACKET_CP_DMA = 0x5,
22 PACKET_REPEAT = 0x6,
23 PACKET_MSG_PROT = 0x7,
24 PACKET_FENCE = 0x8,
25 PACKET_LIN_DMA = 0x9,
26 PACKET_NOP = 0xA,
27 PACKET_STOP = 0xB,
28 PACKET_ARB_POINT = 0xC,
29 PACKET_WAIT = 0xD,
30 PACKET_LOAD_AND_EXE = 0xF,
31 MAX_PACKET_ID = (PACKET_HEADER_PACKET_ID_MASK >>
32 PACKET_HEADER_PACKET_ID_SHIFT) + 1
35 #define GAUDI_PKT_CTL_OPCODE_SHIFT 24
36 #define GAUDI_PKT_CTL_OPCODE_MASK 0x1F000000
38 #define GAUDI_PKT_CTL_EB_SHIFT 29
39 #define GAUDI_PKT_CTL_EB_MASK 0x20000000
41 #define GAUDI_PKT_CTL_RB_SHIFT 30
42 #define GAUDI_PKT_CTL_RB_MASK 0x40000000
44 #define GAUDI_PKT_CTL_MB_SHIFT 31
45 #define GAUDI_PKT_CTL_MB_MASK 0x80000000
47 /* All packets have, at least, an 8-byte header, which contains
48 * the packet type. The kernel driver uses the packet header for packet
49 * validation and to perform any necessary required preparation before
50 * sending them off to the hardware.
52 struct gaudi_packet {
53 __le64 header;
54 /* The rest of the packet data follows. Use the corresponding
55 * packet_XXX struct to deference the data, based on packet type
57 u8 contents[];
60 struct packet_nop {
61 __le32 reserved;
62 __le32 ctl;
65 struct packet_stop {
66 __le32 reserved;
67 __le32 ctl;
70 struct packet_wreg32 {
71 __le32 value;
72 __le32 ctl;
75 struct packet_wreg_bulk {
76 __le32 size64;
77 __le32 ctl;
78 __le64 values[]; /* data starts here */
81 #define GAUDI_PKT_LONG_CTL_OP_SHIFT 20
82 #define GAUDI_PKT_LONG_CTL_OP_MASK 0x00300000
84 struct packet_msg_long {
85 __le32 value;
86 __le32 ctl;
87 __le64 addr;
90 #define GAUDI_PKT_SHORT_VAL_SOB_SYNC_VAL_SHIFT 0
91 #define GAUDI_PKT_SHORT_VAL_SOB_SYNC_VAL_MASK 0x00007FFF
93 #define GAUDI_PKT_SHORT_VAL_SOB_MOD_SHIFT 31
94 #define GAUDI_PKT_SHORT_VAL_SOB_MOD_MASK 0x80000000
96 #define GAUDI_PKT_SHORT_VAL_MON_SYNC_GID_SHIFT 0
97 #define GAUDI_PKT_SHORT_VAL_MON_SYNC_GID_MASK 0x000000FF
99 #define GAUDI_PKT_SHORT_VAL_MON_MASK_SHIFT 8
100 #define GAUDI_PKT_SHORT_VAL_MON_MASK_MASK 0x0000FF00
102 #define GAUDI_PKT_SHORT_VAL_MON_MODE_SHIFT 16
103 #define GAUDI_PKT_SHORT_VAL_MON_MODE_MASK 0x00010000
105 #define GAUDI_PKT_SHORT_VAL_MON_SYNC_VAL_SHIFT 17
106 #define GAUDI_PKT_SHORT_VAL_MON_SYNC_VAL_MASK 0xFFFE0000
108 #define GAUDI_PKT_SHORT_CTL_ADDR_SHIFT 0
109 #define GAUDI_PKT_SHORT_CTL_ADDR_MASK 0x0000FFFF
111 #define GAUDI_PKT_SHORT_CTL_OP_SHIFT 20
112 #define GAUDI_PKT_SHORT_CTL_OP_MASK 0x00300000
114 #define GAUDI_PKT_SHORT_CTL_BASE_SHIFT 22
115 #define GAUDI_PKT_SHORT_CTL_BASE_MASK 0x00C00000
117 struct packet_msg_short {
118 __le32 value;
119 __le32 ctl;
122 struct packet_msg_prot {
123 __le32 value;
124 __le32 ctl;
125 __le64 addr;
128 #define GAUDI_PKT_FENCE_CFG_DEC_VAL_SHIFT 0
129 #define GAUDI_PKT_FENCE_CFG_DEC_VAL_MASK 0x0000000F
131 #define GAUDI_PKT_FENCE_CFG_TARGET_VAL_SHIFT 16
132 #define GAUDI_PKT_FENCE_CFG_TARGET_VAL_MASK 0x00FF0000
134 #define GAUDI_PKT_FENCE_CFG_ID_SHIFT 30
135 #define GAUDI_PKT_FENCE_CFG_ID_MASK 0xC0000000
137 #define GAUDI_PKT_FENCE_CTL_PRED_SHIFT 0
138 #define GAUDI_PKT_FENCE_CTL_PRED_MASK 0x0000001F
140 struct packet_fence {
141 __le32 cfg;
142 __le32 ctl;
145 #define GAUDI_PKT_LIN_DMA_CTL_WRCOMP_EN_SHIFT 0
146 #define GAUDI_PKT_LIN_DMA_CTL_WRCOMP_EN_MASK 0x00000001
148 #define GAUDI_PKT_LIN_DMA_CTL_LIN_SHIFT 3
149 #define GAUDI_PKT_LIN_DMA_CTL_LIN_MASK 0x00000008
151 #define GAUDI_PKT_LIN_DMA_CTL_MEMSET_SHIFT 4
152 #define GAUDI_PKT_LIN_DMA_CTL_MEMSET_MASK 0x00000010
154 #define GAUDI_PKT_LIN_DMA_DST_ADDR_SHIFT 0
155 #define GAUDI_PKT_LIN_DMA_DST_ADDR_MASK 0x00FFFFFFFFFFFFFFull
157 struct packet_lin_dma {
158 __le32 tsize;
159 __le32 ctl;
160 __le64 src_addr;
161 __le64 dst_addr;
164 struct packet_arb_point {
165 __le32 cfg;
166 __le32 ctl;
169 struct packet_repeat {
170 __le32 cfg;
171 __le32 ctl;
174 struct packet_wait {
175 __le32 cfg;
176 __le32 ctl;
179 #define GAUDI_PKT_LOAD_AND_EXE_CFG_DST_SHIFT 0
180 #define GAUDI_PKT_LOAD_AND_EXE_CFG_DST_MASK 0x00000001
182 struct packet_load_and_exe {
183 __le32 cfg;
184 __le32 ctl;
185 __le64 src_addr;
188 struct packet_cp_dma {
189 __le32 tsize;
190 __le32 ctl;
191 __le64 src_addr;
194 #endif /* GAUDI_PACKETS_H */