2 * Huawei HiNIC PCI Express Linux driver
3 * Copyright(c) 2017 Huawei Technologies Co., Ltd
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #ifndef HINIC_HW_WQE_H
17 #define HINIC_HW_WQE_H
19 #include "hinic_common.h"
21 #define HINIC_CMDQ_CTRL_PI_SHIFT 0
22 #define HINIC_CMDQ_CTRL_CMD_SHIFT 16
23 #define HINIC_CMDQ_CTRL_MOD_SHIFT 24
24 #define HINIC_CMDQ_CTRL_ACK_TYPE_SHIFT 29
25 #define HINIC_CMDQ_CTRL_HW_BUSY_BIT_SHIFT 31
27 #define HINIC_CMDQ_CTRL_PI_MASK 0xFFFF
28 #define HINIC_CMDQ_CTRL_CMD_MASK 0xFF
29 #define HINIC_CMDQ_CTRL_MOD_MASK 0x1F
30 #define HINIC_CMDQ_CTRL_ACK_TYPE_MASK 0x3
31 #define HINIC_CMDQ_CTRL_HW_BUSY_BIT_MASK 0x1
33 #define HINIC_CMDQ_CTRL_SET(val, member) \
34 (((u32)(val) & HINIC_CMDQ_CTRL_##member##_MASK) \
35 << HINIC_CMDQ_CTRL_##member##_SHIFT)
37 #define HINIC_CMDQ_CTRL_GET(val, member) \
38 (((val) >> HINIC_CMDQ_CTRL_##member##_SHIFT) \
39 & HINIC_CMDQ_CTRL_##member##_MASK)
41 #define HINIC_CMDQ_WQE_HEADER_BUFDESC_LEN_SHIFT 0
42 #define HINIC_CMDQ_WQE_HEADER_COMPLETE_FMT_SHIFT 15
43 #define HINIC_CMDQ_WQE_HEADER_DATA_FMT_SHIFT 22
44 #define HINIC_CMDQ_WQE_HEADER_COMPLETE_REQ_SHIFT 23
45 #define HINIC_CMDQ_WQE_HEADER_COMPLETE_SECT_LEN_SHIFT 27
46 #define HINIC_CMDQ_WQE_HEADER_CTRL_LEN_SHIFT 29
47 #define HINIC_CMDQ_WQE_HEADER_TOGGLED_WRAPPED_SHIFT 31
49 #define HINIC_CMDQ_WQE_HEADER_BUFDESC_LEN_MASK 0xFF
50 #define HINIC_CMDQ_WQE_HEADER_COMPLETE_FMT_MASK 0x1
51 #define HINIC_CMDQ_WQE_HEADER_DATA_FMT_MASK 0x1
52 #define HINIC_CMDQ_WQE_HEADER_COMPLETE_REQ_MASK 0x1
53 #define HINIC_CMDQ_WQE_HEADER_COMPLETE_SECT_LEN_MASK 0x3
54 #define HINIC_CMDQ_WQE_HEADER_CTRL_LEN_MASK 0x3
55 #define HINIC_CMDQ_WQE_HEADER_TOGGLED_WRAPPED_MASK 0x1
57 #define HINIC_CMDQ_WQE_HEADER_SET(val, member) \
58 (((u32)(val) & HINIC_CMDQ_WQE_HEADER_##member##_MASK) \
59 << HINIC_CMDQ_WQE_HEADER_##member##_SHIFT)
61 #define HINIC_CMDQ_WQE_HEADER_GET(val, member) \
62 (((val) >> HINIC_CMDQ_WQE_HEADER_##member##_SHIFT) \
63 & HINIC_CMDQ_WQE_HEADER_##member##_MASK)
65 #define HINIC_SQ_CTRL_BUFDESC_SECT_LEN_SHIFT 0
66 #define HINIC_SQ_CTRL_TASKSECT_LEN_SHIFT 16
67 #define HINIC_SQ_CTRL_DATA_FORMAT_SHIFT 22
68 #define HINIC_SQ_CTRL_LEN_SHIFT 29
70 #define HINIC_SQ_CTRL_BUFDESC_SECT_LEN_MASK 0xFF
71 #define HINIC_SQ_CTRL_TASKSECT_LEN_MASK 0x1F
72 #define HINIC_SQ_CTRL_DATA_FORMAT_MASK 0x1
73 #define HINIC_SQ_CTRL_LEN_MASK 0x3
75 #define HINIC_SQ_CTRL_QUEUE_INFO_MSS_SHIFT 13
77 #define HINIC_SQ_CTRL_QUEUE_INFO_MSS_MASK 0x3FFF
79 #define HINIC_SQ_CTRL_SET(val, member) \
80 (((u32)(val) & HINIC_SQ_CTRL_##member##_MASK) \
81 << HINIC_SQ_CTRL_##member##_SHIFT)
83 #define HINIC_SQ_CTRL_GET(val, member) \
84 (((val) >> HINIC_SQ_CTRL_##member##_SHIFT) \
85 & HINIC_SQ_CTRL_##member##_MASK)
87 #define HINIC_SQ_TASK_INFO0_L2HDR_LEN_SHIFT 0
88 #define HINIC_SQ_TASK_INFO0_L4_OFFLOAD_SHIFT 8
89 #define HINIC_SQ_TASK_INFO0_INNER_L3TYPE_SHIFT 10
90 #define HINIC_SQ_TASK_INFO0_VLAN_OFFLOAD_SHIFT 12
91 #define HINIC_SQ_TASK_INFO0_PARSE_FLAG_SHIFT 13
93 #define HINIC_SQ_TASK_INFO0_TSO_FLAG_SHIFT 15
94 #define HINIC_SQ_TASK_INFO0_VLAN_TAG_SHIFT 16
96 #define HINIC_SQ_TASK_INFO0_L2HDR_LEN_MASK 0xFF
97 #define HINIC_SQ_TASK_INFO0_L4_OFFLOAD_MASK 0x3
98 #define HINIC_SQ_TASK_INFO0_INNER_L3TYPE_MASK 0x3
99 #define HINIC_SQ_TASK_INFO0_VLAN_OFFLOAD_MASK 0x1
100 #define HINIC_SQ_TASK_INFO0_PARSE_FLAG_MASK 0x1
102 #define HINIC_SQ_TASK_INFO0_TSO_FLAG_MASK 0x1
103 #define HINIC_SQ_TASK_INFO0_VLAN_TAG_MASK 0xFFFF
105 #define HINIC_SQ_TASK_INFO0_SET(val, member) \
106 (((u32)(val) & HINIC_SQ_TASK_INFO0_##member##_MASK) << \
107 HINIC_SQ_TASK_INFO0_##member##_SHIFT)
109 /* 8 bits reserved */
110 #define HINIC_SQ_TASK_INFO1_MEDIA_TYPE_SHIFT 8
111 #define HINIC_SQ_TASK_INFO1_INNER_L4_LEN_SHIFT 16
112 #define HINIC_SQ_TASK_INFO1_INNER_L3_LEN_SHIFT 24
114 /* 8 bits reserved */
115 #define HINIC_SQ_TASK_INFO1_MEDIA_TYPE_MASK 0xFF
116 #define HINIC_SQ_TASK_INFO1_INNER_L4_LEN_MASK 0xFF
117 #define HINIC_SQ_TASK_INFO1_INNER_L3_LEN_MASK 0xFF
119 #define HINIC_SQ_TASK_INFO1_SET(val, member) \
120 (((u32)(val) & HINIC_SQ_TASK_INFO1_##member##_MASK) << \
121 HINIC_SQ_TASK_INFO1_##member##_SHIFT)
123 #define HINIC_SQ_TASK_INFO2_TUNNEL_L4_LEN_SHIFT 0
124 #define HINIC_SQ_TASK_INFO2_OUTER_L3_LEN_SHIFT 12
125 #define HINIC_SQ_TASK_INFO2_TUNNEL_L4TYPE_SHIFT 19
127 #define HINIC_SQ_TASK_INFO2_OUTER_L3TYPE_SHIFT 22
128 /* 8 bits reserved */
130 #define HINIC_SQ_TASK_INFO2_TUNNEL_L4_LEN_MASK 0xFFF
131 #define HINIC_SQ_TASK_INFO2_OUTER_L3_LEN_MASK 0x7F
132 #define HINIC_SQ_TASK_INFO2_TUNNEL_L4TYPE_MASK 0x3
134 #define HINIC_SQ_TASK_INFO2_OUTER_L3TYPE_MASK 0x3
135 /* 8 bits reserved */
137 #define HINIC_SQ_TASK_INFO2_SET(val, member) \
138 (((u32)(val) & HINIC_SQ_TASK_INFO2_##member##_MASK) << \
139 HINIC_SQ_TASK_INFO2_##member##_SHIFT)
141 /* 31 bits reserved */
142 #define HINIC_SQ_TASK_INFO4_L2TYPE_SHIFT 31
144 /* 31 bits reserved */
145 #define HINIC_SQ_TASK_INFO4_L2TYPE_MASK 0x1
147 #define HINIC_SQ_TASK_INFO4_SET(val, member) \
148 (((u32)(val) & HINIC_SQ_TASK_INFO4_##member##_MASK) << \
149 HINIC_SQ_TASK_INFO4_##member##_SHIFT)
151 #define HINIC_RQ_CQE_STATUS_RXDONE_SHIFT 31
153 #define HINIC_RQ_CQE_STATUS_RXDONE_MASK 0x1
155 #define HINIC_RQ_CQE_STATUS_GET(val, member) \
156 (((val) >> HINIC_RQ_CQE_STATUS_##member##_SHIFT) & \
157 HINIC_RQ_CQE_STATUS_##member##_MASK)
159 #define HINIC_RQ_CQE_STATUS_CLEAR(val, member) \
160 ((val) & (~(HINIC_RQ_CQE_STATUS_##member##_MASK << \
161 HINIC_RQ_CQE_STATUS_##member##_SHIFT)))
163 #define HINIC_RQ_CQE_SGE_LEN_SHIFT 16
165 #define HINIC_RQ_CQE_SGE_LEN_MASK 0xFFFF
167 #define HINIC_RQ_CQE_SGE_GET(val, member) \
168 (((val) >> HINIC_RQ_CQE_SGE_##member##_SHIFT) & \
169 HINIC_RQ_CQE_SGE_##member##_MASK)
171 #define HINIC_RQ_CTRL_BUFDESC_SECT_LEN_SHIFT 0
172 #define HINIC_RQ_CTRL_COMPLETE_FORMAT_SHIFT 15
173 #define HINIC_RQ_CTRL_COMPLETE_LEN_SHIFT 27
174 #define HINIC_RQ_CTRL_LEN_SHIFT 29
176 #define HINIC_RQ_CTRL_BUFDESC_SECT_LEN_MASK 0xFF
177 #define HINIC_RQ_CTRL_COMPLETE_FORMAT_MASK 0x1
178 #define HINIC_RQ_CTRL_COMPLETE_LEN_MASK 0x3
179 #define HINIC_RQ_CTRL_LEN_MASK 0x3
181 #define HINIC_RQ_CTRL_SET(val, member) \
182 (((u32)(val) & HINIC_RQ_CTRL_##member##_MASK) << \
183 HINIC_RQ_CTRL_##member##_SHIFT)
185 #define HINIC_SQ_WQE_SIZE(nr_sges) \
186 (sizeof(struct hinic_sq_ctrl) + \
187 sizeof(struct hinic_sq_task) + \
188 (nr_sges) * sizeof(struct hinic_sq_bufdesc))
190 #define HINIC_SCMD_DATA_LEN 16
192 #define HINIC_MAX_SQ_BUFDESCS 17
194 #define HINIC_SQ_WQE_MAX_SIZE 320
195 #define HINIC_RQ_WQE_SIZE 32
197 enum hinic_l4offload_type
{
198 HINIC_L4_OFF_DISABLE
= 0,
199 HINIC_TCP_OFFLOAD_ENABLE
= 1,
200 HINIC_SCTP_OFFLOAD_ENABLE
= 2,
201 HINIC_UDP_OFFLOAD_ENABLE
= 3,
204 enum hinic_vlan_offload
{
205 HINIC_VLAN_OFF_DISABLE
= 0,
206 HINIC_VLAN_OFF_ENABLE
= 1,
209 enum hinic_pkt_parsed
{
210 HINIC_PKT_NOT_PARSED
= 0,
211 HINIC_PKT_PARSED
= 1,
214 enum hinic_outer_l3type
{
215 HINIC_OUTER_L3TYPE_UNKNOWN
= 0,
216 HINIC_OUTER_L3TYPE_IPV6
= 1,
217 HINIC_OUTER_L3TYPE_IPV4_NO_CHKSUM
= 2,
218 HINIC_OUTER_L3TYPE_IPV4_CHKSUM
= 3,
221 enum hinic_media_type
{
222 HINIC_MEDIA_UNKNOWN
= 0,
226 HINIC_L2TYPE_ETH
= 0,
229 enum hinc_tunnel_l4type
{
230 HINIC_TUNNEL_L4TYPE_UNKNOWN
= 0,
233 struct hinic_cmdq_header
{
238 struct hinic_status
{
246 struct hinic_sge_resp
{
247 struct hinic_sge sge
;
251 struct hinic_cmdq_completion
{
254 struct hinic_sge_resp sge_resp
;
259 struct hinic_scmd_bufdesc
{
262 u8 data
[HINIC_SCMD_DATA_LEN
];
265 struct hinic_lcmd_bufdesc
{
266 struct hinic_sge sge
;
272 struct hinic_cmdq_wqe_scmd
{
273 struct hinic_cmdq_header header
;
275 struct hinic_status status
;
276 struct hinic_ctrl ctrl
;
277 struct hinic_cmdq_completion completion
;
278 struct hinic_scmd_bufdesc buf_desc
;
281 struct hinic_cmdq_wqe_lcmd
{
282 struct hinic_cmdq_header header
;
283 struct hinic_status status
;
284 struct hinic_ctrl ctrl
;
285 struct hinic_cmdq_completion completion
;
286 struct hinic_lcmd_bufdesc buf_desc
;
289 struct hinic_cmdq_direct_wqe
{
290 struct hinic_cmdq_wqe_scmd wqe_scmd
;
293 struct hinic_cmdq_wqe
{
296 struct hinic_cmdq_direct_wqe direct_wqe
;
297 struct hinic_cmdq_wqe_lcmd wqe_lcmd
;
301 struct hinic_sq_ctrl
{
306 struct hinic_sq_task
{
315 struct hinic_sq_bufdesc
{
316 struct hinic_sge sge
;
320 struct hinic_sq_wqe
{
321 struct hinic_sq_ctrl ctrl
;
322 struct hinic_sq_task task
;
323 struct hinic_sq_bufdesc buf_descs
[HINIC_MAX_SQ_BUFDESCS
];
326 struct hinic_rq_cqe
{
338 struct hinic_rq_ctrl
{
342 struct hinic_rq_cqe_sect
{
343 struct hinic_sge sge
;
347 struct hinic_rq_bufdesc
{
352 struct hinic_rq_wqe
{
353 struct hinic_rq_ctrl ctrl
;
355 struct hinic_rq_cqe_sect cqe_sect
;
356 struct hinic_rq_bufdesc buf_desc
;
359 struct hinic_hw_wqe
{
362 struct hinic_cmdq_wqe cmdq_wqe
;
363 struct hinic_sq_wqe sq_wqe
;
364 struct hinic_rq_wqe rq_wqe
;