1 /* SPDX-License-Identifier: GPL-2.0
3 * Copyright 2020 HabanaLabs, Ltd.
8 #ifndef GAUDI2_PACKETS_H
9 #define GAUDI2_PACKETS_H
11 #include <linux/types.h>
13 #define PACKET_HEADER_PACKET_ID_SHIFT 56
14 #define PACKET_HEADER_PACKET_ID_MASK 0x1F00000000000000ull
18 PACKET_WREG_BULK
= 0x2,
19 PACKET_MSG_LONG
= 0x3,
20 PACKET_MSG_SHORT
= 0x4,
23 PACKET_MSG_PROT
= 0x7,
28 PACKET_ARB_POINT
= 0xC,
31 PACKET_LOAD_AND_EXE
= 0xF,
32 PACKET_WRITE_ARC_STREAM
= 0x10,
33 PACKET_LAST_READ_FROM_ARC
= 0x11,
34 PACKET_WREG_64_SHORT
= 0x12,
35 PACKET_WREG_64_LONG
= 0x13,
36 MAX_PACKET_ID
= (PACKET_HEADER_PACKET_ID_MASK
>>
37 PACKET_HEADER_PACKET_ID_SHIFT
) + 1
40 #define GAUDI2_PKT_CTL_OPCODE_SHIFT 24
41 #define GAUDI2_PKT_CTL_OPCODE_MASK 0x1F000000
43 #define GAUDI2_PKT_CTL_EB_SHIFT 29
44 #define GAUDI2_PKT_CTL_EB_MASK 0x20000000
46 #define GAUDI2_PKT_CTL_RB_SHIFT 30
47 #define GAUDI2_PKT_CTL_RB_MASK 0x40000000
49 #define GAUDI2_PKT_CTL_MB_SHIFT 31
50 #define GAUDI2_PKT_CTL_MB_MASK 0x80000000
52 /* All packets have, at least, an 8-byte header, which contains
53 * the packet type. The kernel driver uses the packet header for packet
54 * validation and to perform any necessary required preparation before
55 * sending them off to the hardware.
57 struct gaudi2_packet
{
59 /* The rest of the packet data follows. Use the corresponding
60 * packet_XXX struct to deference the data, based on packet type
75 struct packet_wreg32
{
80 struct packet_wreg_bulk
{
83 __le64 values
[]; /* data starts here */
86 struct packet_msg_long
{
92 #define GAUDI2_PKT_SHORT_VAL_SOB_SYNC_VAL_SHIFT 0
93 #define GAUDI2_PKT_SHORT_VAL_SOB_SYNC_VAL_MASK 0x00007FFF
95 #define GAUDI2_PKT_SHORT_VAL_SOB_MOD_SHIFT 31
96 #define GAUDI2_PKT_SHORT_VAL_SOB_MOD_MASK 0x80000000
98 #define GAUDI2_PKT_SHORT_VAL_MON_SYNC_GID_SHIFT 0
99 #define GAUDI2_PKT_SHORT_VAL_MON_SYNC_GID_MASK 0x000000FF
101 #define GAUDI2_PKT_SHORT_VAL_MON_MASK_SHIFT 8
102 #define GAUDI2_PKT_SHORT_VAL_MON_MASK_MASK 0x0000FF00
104 #define GAUDI2_PKT_SHORT_VAL_MON_MODE_SHIFT 16
105 #define GAUDI2_PKT_SHORT_VAL_MON_MODE_MASK 0x00010000
107 #define GAUDI2_PKT_SHORT_VAL_MON_SYNC_VAL_SHIFT 17
108 #define GAUDI2_PKT_SHORT_VAL_MON_SYNC_VAL_MASK 0xFFFE0000
110 #define GAUDI2_PKT_SHORT_CTL_ADDR_SHIFT 0
111 #define GAUDI2_PKT_SHORT_CTL_ADDR_MASK 0x0000FFFF
113 #define GAUDI2_PKT_SHORT_CTL_BASE_SHIFT 22
114 #define GAUDI2_PKT_SHORT_CTL_BASE_MASK 0x00C00000
116 struct packet_msg_short
{
121 struct packet_msg_prot
{
127 #define GAUDI2_PKT_FENCE_CFG_DEC_VAL_SHIFT 0
128 #define GAUDI2_PKT_FENCE_CFG_DEC_VAL_MASK 0x0000000F
130 #define GAUDI2_PKT_FENCE_CFG_TARGET_VAL_SHIFT 16
131 #define GAUDI2_PKT_FENCE_CFG_TARGET_VAL_MASK 0x00FF0000
133 #define GAUDI2_PKT_FENCE_CFG_ID_SHIFT 30
134 #define GAUDI2_PKT_FENCE_CFG_ID_MASK 0xC0000000
136 #define GAUDI2_PKT_FENCE_CTL_PRED_SHIFT 0
137 #define GAUDI2_PKT_FENCE_CTL_PRED_MASK 0x0000001F
139 struct packet_fence
{
144 #define GAUDI2_PKT_LIN_DMA_CTL_WRCOMP_SHIFT 0
145 #define GAUDI2_PKT_LIN_DMA_CTL_WRCOMP_MASK 0x00000001
147 #define GAUDI2_PKT_LIN_DMA_CTL_ENDIAN_SHIFT 1
148 #define GAUDI2_PKT_LIN_DMA_CTL_ENDIAN_MASK 0x00000006
150 #define GAUDI2_PKT_LIN_DMA_CTL_MEMSET_SHIFT 4
151 #define GAUDI2_PKT_LIN_DMA_CTL_MEMSET_MASK 0x00000010
153 #define GAUDI2_PKT_LIN_DMA_CTL_CONTEXT_ID_SHIFT 8
154 #define GAUDI2_PKT_LIN_DMA_CTL_CONTEXT_ID_MASK 0x00FFFF00
156 struct packet_lin_dma
{
163 struct packet_arb_point
{
168 struct packet_repeat
{
178 struct packet_cb_list
{
185 struct packet_load_and_exe
{
191 struct packet_cp_dma
{
197 #endif /* GAUDI2_PACKETS_H */