xref: /openbmc/linux/drivers/infiniband/hw/hns/hns_roce_hw_v2.h (revision 9c6d26df1fae6ad4718d51c48e6517913304ed27)
1 /*
2  * Copyright (c) 2016-2017 Hisilicon Limited.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef _HNS_ROCE_HW_V2_H
34 #define _HNS_ROCE_HW_V2_H
35 
36 #include <linux/bitops.h>
37 
38 #define HNS_ROCE_VF_QPC_BT_NUM			256
39 #define HNS_ROCE_VF_SRQC_BT_NUM			64
40 #define HNS_ROCE_VF_CQC_BT_NUM			64
41 #define HNS_ROCE_VF_MPT_BT_NUM			64
42 #define HNS_ROCE_VF_EQC_NUM			64
43 #define HNS_ROCE_VF_SMAC_NUM			32
44 #define HNS_ROCE_VF_SGID_NUM			32
45 #define HNS_ROCE_VF_SL_NUM			8
46 
47 #define HNS_ROCE_V2_MAX_QP_NUM			0x2000
48 #define HNS_ROCE_V2_MAX_WQE_NUM			0x8000
49 #define HNS_ROCE_V2_MAX_CQ_NUM			0x8000
50 #define HNS_ROCE_V2_MAX_CQE_NUM			0x10000
51 #define HNS_ROCE_V2_MAX_RQ_SGE_NUM		0x100
52 #define HNS_ROCE_V2_MAX_SQ_SGE_NUM		0xff
53 #define HNS_ROCE_V2_MAX_SQ_INLINE		0x20
54 #define HNS_ROCE_V2_UAR_NUM			256
55 #define HNS_ROCE_V2_PHY_UAR_NUM			1
56 #define HNS_ROCE_V2_MAX_IRQ_NUM			65
57 #define HNS_ROCE_V2_COMP_VEC_NUM		63
58 #define HNS_ROCE_V2_AEQE_VEC_NUM		1
59 #define HNS_ROCE_V2_ABNORMAL_VEC_NUM		1
60 #define HNS_ROCE_V2_MAX_MTPT_NUM		0x8000
61 #define HNS_ROCE_V2_MAX_MTT_SEGS		0x1000000
62 #define HNS_ROCE_V2_MAX_CQE_SEGS		0x1000000
63 #define HNS_ROCE_V2_MAX_PD_NUM			0x1000000
64 #define HNS_ROCE_V2_MAX_QP_INIT_RDMA		128
65 #define HNS_ROCE_V2_MAX_QP_DEST_RDMA		128
66 #define HNS_ROCE_V2_MAX_SQ_DESC_SZ		64
67 #define HNS_ROCE_V2_MAX_RQ_DESC_SZ		16
68 #define HNS_ROCE_V2_MAX_SRQ_DESC_SZ		64
69 #define HNS_ROCE_V2_QPC_ENTRY_SZ		256
70 #define HNS_ROCE_V2_IRRL_ENTRY_SZ		64
71 #define HNS_ROCE_V2_TRRL_ENTRY_SZ		48
72 #define HNS_ROCE_V2_CQC_ENTRY_SZ		64
73 #define HNS_ROCE_V2_MTPT_ENTRY_SZ		64
74 #define HNS_ROCE_V2_MTT_ENTRY_SZ		64
75 #define HNS_ROCE_V2_CQE_ENTRY_SIZE		32
76 #define HNS_ROCE_V2_PAGE_SIZE_SUPPORTED		0xFFFFF000
77 #define HNS_ROCE_V2_MAX_INNER_MTPT_NUM		2
78 #define HNS_ROCE_INVALID_LKEY			0x100
79 #define HNS_ROCE_CMQ_TX_TIMEOUT			200
80 
81 #define HNS_ROCE_CONTEXT_HOP_NUM		1
82 #define HNS_ROCE_MTT_HOP_NUM			1
83 #define HNS_ROCE_CQE_HOP_NUM			1
84 #define HNS_ROCE_PBL_HOP_NUM			2
85 #define HNS_ROCE_EQE_HOP_NUM			2
86 
87 #define HNS_ROCE_V2_GID_INDEX_NUM		256
88 
89 #define HNS_ROCE_V2_TABLE_CHUNK_SIZE		(1 << 18)
90 
91 #define HNS_ROCE_CMD_FLAG_IN_VALID_SHIFT	0
92 #define HNS_ROCE_CMD_FLAG_OUT_VALID_SHIFT	1
93 #define HNS_ROCE_CMD_FLAG_NEXT_SHIFT		2
94 #define HNS_ROCE_CMD_FLAG_WR_OR_RD_SHIFT	3
95 #define HNS_ROCE_CMD_FLAG_NO_INTR_SHIFT		4
96 #define HNS_ROCE_CMD_FLAG_ERR_INTR_SHIFT	5
97 
98 #define HNS_ROCE_CMD_FLAG_IN		BIT(HNS_ROCE_CMD_FLAG_IN_VALID_SHIFT)
99 #define HNS_ROCE_CMD_FLAG_OUT		BIT(HNS_ROCE_CMD_FLAG_OUT_VALID_SHIFT)
100 #define HNS_ROCE_CMD_FLAG_NEXT		BIT(HNS_ROCE_CMD_FLAG_NEXT_SHIFT)
101 #define HNS_ROCE_CMD_FLAG_WR		BIT(HNS_ROCE_CMD_FLAG_WR_OR_RD_SHIFT)
102 #define HNS_ROCE_CMD_FLAG_NO_INTR	BIT(HNS_ROCE_CMD_FLAG_NO_INTR_SHIFT)
103 #define HNS_ROCE_CMD_FLAG_ERR_INTR	BIT(HNS_ROCE_CMD_FLAG_ERR_INTR_SHIFT)
104 
105 #define HNS_ROCE_CMQ_DESC_NUM_S		3
106 #define HNS_ROCE_CMQ_EN_B		16
107 #define HNS_ROCE_CMQ_ENABLE		BIT(HNS_ROCE_CMQ_EN_B)
108 
109 #define check_whether_last_step(hop_num, step_idx) \
110 	((step_idx == 0 && hop_num == HNS_ROCE_HOP_NUM_0) || \
111 	(step_idx == 1 && hop_num == 1) || \
112 	(step_idx == 2 && hop_num == 2))
113 
114 enum {
115 	NO_ARMED = 0x0,
116 	REG_NXT_CEQE = 0x2,
117 	REG_NXT_SE_CEQE = 0x3
118 };
119 
120 #define V2_CQ_DB_REQ_NOT_SOL			0
121 #define V2_CQ_DB_REQ_NOT			1
122 
123 #define V2_CQ_STATE_VALID			1
124 #define V2_QKEY_VAL				0x80010000
125 
126 #define	GID_LEN_V2				16
127 
128 #define HNS_ROCE_V2_CQE_QPN_MASK		0x3ffff
129 
130 enum {
131 	HNS_ROCE_V2_WQE_OP_SEND				= 0x0,
132 	HNS_ROCE_V2_WQE_OP_SEND_WITH_INV		= 0x1,
133 	HNS_ROCE_V2_WQE_OP_SEND_WITH_IMM		= 0x2,
134 	HNS_ROCE_V2_WQE_OP_RDMA_WRITE			= 0x3,
135 	HNS_ROCE_V2_WQE_OP_RDMA_WRITE_WITH_IMM		= 0x4,
136 	HNS_ROCE_V2_WQE_OP_RDMA_READ			= 0x5,
137 	HNS_ROCE_V2_WQE_OP_ATOM_CMP_AND_SWAP		= 0x6,
138 	HNS_ROCE_V2_WQE_OP_ATOM_FETCH_AND_ADD		= 0x7,
139 	HNS_ROCE_V2_WQE_OP_ATOM_MSK_CMP_AND_SWAP	= 0x8,
140 	HNS_ROCE_V2_WQE_OP_ATOM_MSK_FETCH_AND_ADD	= 0x9,
141 	HNS_ROCE_V2_WQE_OP_FAST_REG_PMR			= 0xa,
142 	HNS_ROCE_V2_WQE_OP_LOCAL_INV			= 0xb,
143 	HNS_ROCE_V2_WQE_OP_BIND_MW_TYPE			= 0xc,
144 	HNS_ROCE_V2_WQE_OP_MASK				= 0x1f,
145 };
146 
147 enum {
148 	HNS_ROCE_SQ_OPCODE_SEND = 0x0,
149 	HNS_ROCE_SQ_OPCODE_SEND_WITH_INV = 0x1,
150 	HNS_ROCE_SQ_OPCODE_SEND_WITH_IMM = 0x2,
151 	HNS_ROCE_SQ_OPCODE_RDMA_WRITE = 0x3,
152 	HNS_ROCE_SQ_OPCODE_RDMA_WRITE_WITH_IMM = 0x4,
153 	HNS_ROCE_SQ_OPCODE_RDMA_READ = 0x5,
154 	HNS_ROCE_SQ_OPCODE_ATOMIC_COMP_AND_SWAP = 0x6,
155 	HNS_ROCE_SQ_OPCODE_ATOMIC_FETCH_AND_ADD = 0x7,
156 	HNS_ROCE_SQ_OPCODE_ATOMIC_MASK_COMP_AND_SWAP = 0x8,
157 	HNS_ROCE_SQ_OPCODE_ATOMIC_MASK_FETCH_AND_ADD = 0x9,
158 	HNS_ROCE_SQ_OPCODE_FAST_REG_WR = 0xa,
159 	HNS_ROCE_SQ_OPCODE_LOCAL_INV = 0xb,
160 	HNS_ROCE_SQ_OPCODE_BIND_MW = 0xc,
161 };
162 
163 enum {
164 	/* rq operations */
165 	HNS_ROCE_V2_OPCODE_RDMA_WRITE_IMM = 0x0,
166 	HNS_ROCE_V2_OPCODE_SEND = 0x1,
167 	HNS_ROCE_V2_OPCODE_SEND_WITH_IMM = 0x2,
168 	HNS_ROCE_V2_OPCODE_SEND_WITH_INV = 0x3,
169 };
170 
171 enum {
172 	HNS_ROCE_V2_SQ_DB	= 0x0,
173 	HNS_ROCE_V2_RQ_DB	= 0x1,
174 	HNS_ROCE_V2_SRQ_DB	= 0x2,
175 	HNS_ROCE_V2_CQ_DB_PTR	= 0x3,
176 	HNS_ROCE_V2_CQ_DB_NTR	= 0x4,
177 };
178 
179 enum {
180 	HNS_ROCE_CQE_V2_SUCCESS				= 0x00,
181 	HNS_ROCE_CQE_V2_LOCAL_LENGTH_ERR		= 0x01,
182 	HNS_ROCE_CQE_V2_LOCAL_QP_OP_ERR			= 0x02,
183 	HNS_ROCE_CQE_V2_LOCAL_PROT_ERR			= 0x04,
184 	HNS_ROCE_CQE_V2_WR_FLUSH_ERR			= 0x05,
185 	HNS_ROCE_CQE_V2_MW_BIND_ERR			= 0x06,
186 	HNS_ROCE_CQE_V2_BAD_RESP_ERR			= 0x10,
187 	HNS_ROCE_CQE_V2_LOCAL_ACCESS_ERR		= 0x11,
188 	HNS_ROCE_CQE_V2_REMOTE_INVAL_REQ_ERR		= 0x12,
189 	HNS_ROCE_CQE_V2_REMOTE_ACCESS_ERR		= 0x13,
190 	HNS_ROCE_CQE_V2_REMOTE_OP_ERR			= 0x14,
191 	HNS_ROCE_CQE_V2_TRANSPORT_RETRY_EXC_ERR		= 0x15,
192 	HNS_ROCE_CQE_V2_RNR_RETRY_EXC_ERR		= 0x16,
193 	HNS_ROCE_CQE_V2_REMOTE_ABORT_ERR		= 0x22,
194 
195 	HNS_ROCE_V2_CQE_STATUS_MASK			= 0xff,
196 };
197 
198 /* CMQ command */
199 enum hns_roce_opcode_type {
200 	HNS_ROCE_OPC_QUERY_HW_VER			= 0x8000,
201 	HNS_ROCE_OPC_CFG_GLOBAL_PARAM			= 0x8001,
202 	HNS_ROCE_OPC_ALLOC_PF_RES			= 0x8004,
203 	HNS_ROCE_OPC_QUERY_PF_RES			= 0x8400,
204 	HNS_ROCE_OPC_ALLOC_VF_RES			= 0x8401,
205 	HNS_ROCE_OPC_CFG_BT_ATTR			= 0x8506,
206 };
207 
208 enum {
209 	TYPE_CRQ,
210 	TYPE_CSQ,
211 };
212 
213 enum hns_roce_cmd_return_status {
214 	CMD_EXEC_SUCCESS	= 0,
215 	CMD_NO_AUTH		= 1,
216 	CMD_NOT_EXEC		= 2,
217 	CMD_QUEUE_FULL		= 3,
218 };
219 
220 enum hns_roce_sgid_type {
221 	GID_TYPE_FLAG_ROCE_V1 = 0,
222 	GID_TYPE_FLAG_ROCE_V2_IPV4,
223 	GID_TYPE_FLAG_ROCE_V2_IPV6,
224 };
225 
226 struct hns_roce_v2_cq_context {
227 	__le32	byte_4_pg_ceqn;
228 	__le32	byte_8_cqn;
229 	__le32	cqe_cur_blk_addr;
230 	__le32	byte_16_hop_addr;
231 	__le32	cqe_nxt_blk_addr;
232 	__le32	byte_24_pgsz_addr;
233 	__le32	byte_28_cq_pi;
234 	__le32	byte_32_cq_ci;
235 	__le32	cqe_ba;
236 	__le32	byte_40_cqe_ba;
237 	__le32	byte_44_db_record;
238 	__le32	db_record_addr;
239 	__le32	byte_52_cqe_cnt;
240 	__le32	byte_56_cqe_period_maxcnt;
241 	__le32	cqe_report_timer;
242 	__le32	byte_64_se_cqe_idx;
243 };
244 #define HNS_ROCE_V2_CQ_DEFAULT_BURST_NUM 0x0
245 #define HNS_ROCE_V2_CQ_DEFAULT_INTERVAL	0x0
246 
247 #define	V2_CQC_BYTE_4_CQ_ST_S 0
248 #define V2_CQC_BYTE_4_CQ_ST_M GENMASK(1, 0)
249 
250 #define	V2_CQC_BYTE_4_POLL_S 2
251 
252 #define	V2_CQC_BYTE_4_SE_S 3
253 
254 #define	V2_CQC_BYTE_4_OVER_IGNORE_S 4
255 
256 #define	V2_CQC_BYTE_4_COALESCE_S 5
257 
258 #define	V2_CQC_BYTE_4_ARM_ST_S 6
259 #define V2_CQC_BYTE_4_ARM_ST_M GENMASK(7, 6)
260 
261 #define	V2_CQC_BYTE_4_SHIFT_S 8
262 #define V2_CQC_BYTE_4_SHIFT_M GENMASK(12, 8)
263 
264 #define	V2_CQC_BYTE_4_CMD_SN_S 13
265 #define V2_CQC_BYTE_4_CMD_SN_M GENMASK(14, 13)
266 
267 #define	V2_CQC_BYTE_4_CEQN_S 15
268 #define V2_CQC_BYTE_4_CEQN_M GENMASK(23, 15)
269 
270 #define	V2_CQC_BYTE_4_PAGE_OFFSET_S 24
271 #define V2_CQC_BYTE_4_PAGE_OFFSET_M GENMASK(31, 24)
272 
273 #define	V2_CQC_BYTE_8_CQN_S 0
274 #define V2_CQC_BYTE_8_CQN_M GENMASK(23, 0)
275 
276 #define	V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_S 0
277 #define V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_M GENMASK(19, 0)
278 
279 #define	V2_CQC_BYTE_16_CQE_HOP_NUM_S 30
280 #define V2_CQC_BYTE_16_CQE_HOP_NUM_M GENMASK(31, 30)
281 
282 #define	V2_CQC_BYTE_24_CQE_NXT_BLK_ADDR_S 0
283 #define V2_CQC_BYTE_24_CQE_NXT_BLK_ADDR_M GENMASK(19, 0)
284 
285 #define	V2_CQC_BYTE_24_CQE_BA_PG_SZ_S 24
286 #define V2_CQC_BYTE_24_CQE_BA_PG_SZ_M GENMASK(27, 24)
287 
288 #define	V2_CQC_BYTE_24_CQE_BUF_PG_SZ_S 28
289 #define V2_CQC_BYTE_24_CQE_BUF_PG_SZ_M GENMASK(31, 28)
290 
291 #define	V2_CQC_BYTE_28_CQ_PRODUCER_IDX_S 0
292 #define V2_CQC_BYTE_28_CQ_PRODUCER_IDX_M GENMASK(23, 0)
293 
294 #define	V2_CQC_BYTE_32_CQ_CONSUMER_IDX_S 0
295 #define V2_CQC_BYTE_32_CQ_CONSUMER_IDX_M GENMASK(23, 0)
296 
297 #define	V2_CQC_BYTE_40_CQE_BA_S 0
298 #define V2_CQC_BYTE_40_CQE_BA_M GENMASK(28, 0)
299 
300 #define	V2_CQC_BYTE_44_DB_RECORD_EN_S 0
301 
302 #define	V2_CQC_BYTE_44_DB_RECORD_ADDR_S 1
303 #define	V2_CQC_BYTE_44_DB_RECORD_ADDR_M GENMASK(31, 1)
304 
305 #define	V2_CQC_BYTE_52_CQE_CNT_S 0
306 #define	V2_CQC_BYTE_52_CQE_CNT_M GENMASK(23, 0)
307 
308 #define	V2_CQC_BYTE_56_CQ_MAX_CNT_S 0
309 #define V2_CQC_BYTE_56_CQ_MAX_CNT_M GENMASK(15, 0)
310 
311 #define	V2_CQC_BYTE_56_CQ_PERIOD_S 16
312 #define V2_CQC_BYTE_56_CQ_PERIOD_M GENMASK(31, 16)
313 
314 #define	V2_CQC_BYTE_64_SE_CQE_IDX_S 0
315 #define	V2_CQC_BYTE_64_SE_CQE_IDX_M GENMASK(23, 0)
316 
317 enum{
318 	V2_MPT_ST_VALID = 0x1,
319 };
320 
321 enum hns_roce_v2_qp_state {
322 	HNS_ROCE_QP_ST_RST,
323 	HNS_ROCE_QP_ST_INIT,
324 	HNS_ROCE_QP_ST_RTR,
325 	HNS_ROCE_QP_ST_RTS,
326 	HNS_ROCE_QP_ST_SQER,
327 	HNS_ROCE_QP_ST_SQD,
328 	HNS_ROCE_QP_ST_ERR,
329 	HNS_ROCE_QP_ST_SQ_DRAINING,
330 	HNS_ROCE_QP_NUM_ST
331 };
332 
333 struct hns_roce_v2_qp_context {
334 	__le32	byte_4_sqpn_tst;
335 	__le32	wqe_sge_ba;
336 	__le32	byte_12_sq_hop;
337 	__le32	byte_16_buf_ba_pg_sz;
338 	__le32	byte_20_smac_sgid_idx;
339 	__le32	byte_24_mtu_tc;
340 	__le32	byte_28_at_fl;
341 	u8	dgid[GID_LEN_V2];
342 	__le32	dmac;
343 	__le32	byte_52_udpspn_dmac;
344 	__le32	byte_56_dqpn_err;
345 	__le32	byte_60_qpst_mapid;
346 	__le32	qkey_xrcd;
347 	__le32	byte_68_rq_db;
348 	__le32	rq_db_record_addr;
349 	__le32	byte_76_srqn_op_en;
350 	__le32	byte_80_rnr_rx_cqn;
351 	__le32	byte_84_rq_ci_pi;
352 	__le32	rq_cur_blk_addr;
353 	__le32	byte_92_srq_info;
354 	__le32	byte_96_rx_reqmsn;
355 	__le32	rq_nxt_blk_addr;
356 	__le32	byte_104_rq_sge;
357 	__le32	byte_108_rx_reqepsn;
358 	__le32	rq_rnr_timer;
359 	__le32	rx_msg_len;
360 	__le32	rx_rkey_pkt_info;
361 	__le64	rx_va;
362 	__le32	byte_132_trrl;
363 	__le32	trrl_ba;
364 	__le32	byte_140_raq;
365 	__le32	byte_144_raq;
366 	__le32	byte_148_raq;
367 	__le32	byte_152_raq;
368 	__le32	byte_156_raq;
369 	__le32	byte_160_sq_ci_pi;
370 	__le32	sq_cur_blk_addr;
371 	__le32	byte_168_irrl_idx;
372 	__le32	byte_172_sq_psn;
373 	__le32	byte_176_msg_pktn;
374 	__le32	sq_cur_sge_blk_addr;
375 	__le32	byte_184_irrl_idx;
376 	__le32	cur_sge_offset;
377 	__le32	byte_192_ext_sge;
378 	__le32	byte_196_sq_psn;
379 	__le32	byte_200_sq_max;
380 	__le32	irrl_ba;
381 	__le32	byte_208_irrl;
382 	__le32	byte_212_lsn;
383 	__le32	sq_timer;
384 	__le32	byte_220_retry_psn_msn;
385 	__le32	byte_224_retry_msg;
386 	__le32	rx_sq_cur_blk_addr;
387 	__le32	byte_232_irrl_sge;
388 	__le32	irrl_cur_sge_offset;
389 	__le32	byte_240_irrl_tail;
390 	__le32	byte_244_rnr_rxack;
391 	__le32	byte_248_ack_psn;
392 	__le32	byte_252_err_txcqn;
393 	__le32	byte_256_sqflush_rqcqe;
394 };
395 
396 #define	V2_QPC_BYTE_4_TST_S 0
397 #define V2_QPC_BYTE_4_TST_M GENMASK(2, 0)
398 
399 #define	V2_QPC_BYTE_4_SGE_SHIFT_S 3
400 #define V2_QPC_BYTE_4_SGE_SHIFT_M GENMASK(7, 3)
401 
402 #define	V2_QPC_BYTE_4_SQPN_S 8
403 #define V2_QPC_BYTE_4_SQPN_M  GENMASK(31, 8)
404 
405 #define	V2_QPC_BYTE_12_WQE_SGE_BA_S 0
406 #define V2_QPC_BYTE_12_WQE_SGE_BA_M GENMASK(28, 0)
407 
408 #define	V2_QPC_BYTE_12_SQ_HOP_NUM_S 29
409 #define V2_QPC_BYTE_12_SQ_HOP_NUM_M GENMASK(30, 29)
410 
411 #define V2_QPC_BYTE_12_RSVD_LKEY_EN_S 31
412 
413 #define	V2_QPC_BYTE_16_WQE_SGE_BA_PG_SZ_S 0
414 #define V2_QPC_BYTE_16_WQE_SGE_BA_PG_SZ_M GENMASK(3, 0)
415 
416 #define	V2_QPC_BYTE_16_WQE_SGE_BUF_PG_SZ_S 4
417 #define V2_QPC_BYTE_16_WQE_SGE_BUF_PG_SZ_M GENMASK(7, 4)
418 
419 #define	V2_QPC_BYTE_16_PD_S 8
420 #define V2_QPC_BYTE_16_PD_M GENMASK(31, 8)
421 
422 #define	V2_QPC_BYTE_20_RQ_HOP_NUM_S 0
423 #define V2_QPC_BYTE_20_RQ_HOP_NUM_M GENMASK(1, 0)
424 
425 #define	V2_QPC_BYTE_20_SGE_HOP_NUM_S 2
426 #define V2_QPC_BYTE_20_SGE_HOP_NUM_M GENMASK(3, 2)
427 
428 #define	V2_QPC_BYTE_20_RQWS_S 4
429 #define V2_QPC_BYTE_20_RQWS_M GENMASK(7, 4)
430 
431 #define	V2_QPC_BYTE_20_SQ_SHIFT_S 8
432 #define V2_QPC_BYTE_20_SQ_SHIFT_M GENMASK(11, 8)
433 
434 #define	V2_QPC_BYTE_20_RQ_SHIFT_S 12
435 #define V2_QPC_BYTE_20_RQ_SHIFT_M GENMASK(15, 12)
436 
437 #define	V2_QPC_BYTE_20_SGID_IDX_S 16
438 #define V2_QPC_BYTE_20_SGID_IDX_M GENMASK(23, 16)
439 
440 #define	V2_QPC_BYTE_20_SMAC_IDX_S 24
441 #define V2_QPC_BYTE_20_SMAC_IDX_M GENMASK(31, 24)
442 
443 #define	V2_QPC_BYTE_24_HOP_LIMIT_S 0
444 #define V2_QPC_BYTE_24_HOP_LIMIT_M GENMASK(7, 0)
445 
446 #define	V2_QPC_BYTE_24_TC_S 8
447 #define V2_QPC_BYTE_24_TC_M GENMASK(15, 8)
448 
449 #define	V2_QPC_BYTE_24_VLAN_IDX_S 16
450 #define V2_QPC_BYTE_24_VLAN_IDX_M GENMASK(27, 16)
451 
452 #define	V2_QPC_BYTE_24_MTU_S 28
453 #define V2_QPC_BYTE_24_MTU_M GENMASK(31, 28)
454 
455 #define	V2_QPC_BYTE_28_FL_S 0
456 #define V2_QPC_BYTE_28_FL_M GENMASK(19, 0)
457 
458 #define	V2_QPC_BYTE_28_SL_S 20
459 #define V2_QPC_BYTE_28_SL_M GENMASK(23, 20)
460 
461 #define V2_QPC_BYTE_28_CNP_TX_FLAG_S 24
462 
463 #define V2_QPC_BYTE_28_CE_FLAG_S 25
464 
465 #define V2_QPC_BYTE_28_LBI_S 26
466 
467 #define	V2_QPC_BYTE_28_AT_S 27
468 #define V2_QPC_BYTE_28_AT_M GENMASK(31, 27)
469 
470 #define	V2_QPC_BYTE_52_DMAC_S 0
471 #define V2_QPC_BYTE_52_DMAC_M GENMASK(15, 0)
472 
473 #define V2_QPC_BYTE_52_UDPSPN_S 16
474 #define V2_QPC_BYTE_52_UDPSPN_M GENMASK(31, 16)
475 
476 #define	V2_QPC_BYTE_56_DQPN_S 0
477 #define V2_QPC_BYTE_56_DQPN_M GENMASK(23, 0)
478 
479 #define	V2_QPC_BYTE_56_SQ_TX_ERR_S 24
480 #define	V2_QPC_BYTE_56_SQ_RX_ERR_S 25
481 #define	V2_QPC_BYTE_56_RQ_TX_ERR_S 26
482 #define	V2_QPC_BYTE_56_RQ_RX_ERR_S 27
483 
484 #define	V2_QPC_BYTE_56_LP_PKTN_INI_S 28
485 #define V2_QPC_BYTE_56_LP_PKTN_INI_M GENMASK(31, 28)
486 
487 #define	V2_QPC_BYTE_60_MAPID_S 0
488 #define V2_QPC_BYTE_60_MAPID_M GENMASK(12, 0)
489 
490 #define	V2_QPC_BYTE_60_INNER_MAP_IND_S 13
491 
492 #define	V2_QPC_BYTE_60_SQ_MAP_IND_S 14
493 
494 #define	V2_QPC_BYTE_60_RQ_MAP_IND_S 15
495 
496 #define	V2_QPC_BYTE_60_TEMPID_S 16
497 #define V2_QPC_BYTE_60_TEMPID_M  GENMASK(22, 16)
498 
499 #define	V2_QPC_BYTE_60_EXT_MAP_IND_S 23
500 
501 #define	V2_QPC_BYTE_60_RTY_NUM_INI_BAK_S 24
502 #define V2_QPC_BYTE_60_RTY_NUM_INI_BAK_M GENMASK(26, 24)
503 
504 #define V2_QPC_BYTE_60_SQ_RLS_IND_S 27
505 
506 #define	V2_QPC_BYTE_60_SQ_EXT_IND_S 28
507 
508 #define	V2_QPC_BYTE_60_QP_ST_S 29
509 #define V2_QPC_BYTE_60_QP_ST_M GENMASK(31, 29)
510 
511 #define	V2_QPC_BYTE_68_RQ_RECORD_EN_S 0
512 
513 #define	V2_QPC_BYTE_68_RQ_DB_RECORD_ADDR_S 1
514 #define V2_QPC_BYTE_68_RQ_DB_RECORD_ADDR_M GENMASK(31, 1)
515 
516 #define	V2_QPC_BYTE_76_SRQN_S 0
517 #define V2_QPC_BYTE_76_SRQN_M GENMASK(23, 0)
518 
519 #define	V2_QPC_BYTE_76_SRQ_EN_S 24
520 
521 #define	V2_QPC_BYTE_76_RRE_S 25
522 
523 #define	V2_QPC_BYTE_76_RWE_S 26
524 
525 #define	V2_QPC_BYTE_76_ATE_S 27
526 
527 #define	V2_QPC_BYTE_76_RQIE_S 28
528 
529 #define	V2_QPC_BYTE_80_RX_CQN_S 0
530 #define V2_QPC_BYTE_80_RX_CQN_M GENMASK(23, 0)
531 
532 #define	V2_QPC_BYTE_80_MIN_RNR_TIME_S 27
533 #define V2_QPC_BYTE_80_MIN_RNR_TIME_M GENMASK(31, 27)
534 
535 #define	V2_QPC_BYTE_84_RQ_PRODUCER_IDX_S 0
536 #define V2_QPC_BYTE_84_RQ_PRODUCER_IDX_M GENMASK(15, 0)
537 
538 #define	V2_QPC_BYTE_84_RQ_CONSUMER_IDX_S 16
539 #define V2_QPC_BYTE_84_RQ_CONSUMER_IDX_M GENMASK(31, 16)
540 
541 #define	V2_QPC_BYTE_92_RQ_CUR_BLK_ADDR_S 0
542 #define V2_QPC_BYTE_92_RQ_CUR_BLK_ADDR_M GENMASK(19, 0)
543 
544 #define	V2_QPC_BYTE_92_SRQ_INFO_S 20
545 #define V2_QPC_BYTE_92_SRQ_INFO_M GENMASK(31, 20)
546 
547 #define	V2_QPC_BYTE_96_RX_REQ_MSN_S 0
548 #define V2_QPC_BYTE_96_RX_REQ_MSN_M GENMASK(23, 0)
549 
550 #define	V2_QPC_BYTE_104_RQ_NXT_BLK_ADDR_S 0
551 #define V2_QPC_BYTE_104_RQ_NXT_BLK_ADDR_M GENMASK(19, 0)
552 
553 #define	V2_QPC_BYTE_104_RQ_CUR_WQE_SGE_NUM_S 24
554 #define V2_QPC_BYTE_104_RQ_CUR_WQE_SGE_NUM_M GENMASK(31, 24)
555 
556 #define V2_QPC_BYTE_108_INV_CREDIT_S 0
557 
558 #define V2_QPC_BYTE_108_RX_REQ_PSN_ERR_S 3
559 
560 #define	V2_QPC_BYTE_108_RX_REQ_LAST_OPTYPE_S 4
561 #define V2_QPC_BYTE_108_RX_REQ_LAST_OPTYPE_M GENMASK(6, 4)
562 
563 #define V2_QPC_BYTE_108_RX_REQ_RNR_S 7
564 
565 #define	V2_QPC_BYTE_108_RX_REQ_EPSN_S 8
566 #define V2_QPC_BYTE_108_RX_REQ_EPSN_M GENMASK(31, 8)
567 
568 #define	V2_QPC_BYTE_132_TRRL_HEAD_MAX_S 0
569 #define V2_QPC_BYTE_132_TRRL_HEAD_MAX_M GENMASK(7, 0)
570 
571 #define	V2_QPC_BYTE_132_TRRL_TAIL_MAX_S 8
572 #define V2_QPC_BYTE_132_TRRL_TAIL_MAX_M GENMASK(15, 8)
573 
574 #define	V2_QPC_BYTE_132_TRRL_BA_S 16
575 #define V2_QPC_BYTE_132_TRRL_BA_M GENMASK(31, 16)
576 
577 #define	V2_QPC_BYTE_140_TRRL_BA_S 0
578 #define V2_QPC_BYTE_140_TRRL_BA_M GENMASK(11, 0)
579 
580 #define	V2_QPC_BYTE_140_RR_MAX_S 12
581 #define V2_QPC_BYTE_140_RR_MAX_M GENMASK(14, 12)
582 
583 #define	V2_QPC_BYTE_140_RSVD_RAQ_MAP_S 15
584 
585 #define	V2_QPC_BYTE_140_RAQ_TRRL_HEAD_S 16
586 #define V2_QPC_BYTE_140_RAQ_TRRL_HEAD_M GENMASK(23, 16)
587 
588 #define	V2_QPC_BYTE_140_RAQ_TRRL_TAIL_S 24
589 #define V2_QPC_BYTE_140_RAQ_TRRL_TAIL_M GENMASK(31, 24)
590 
591 #define	V2_QPC_BYTE_144_RAQ_RTY_INI_PSN_S 0
592 #define V2_QPC_BYTE_144_RAQ_RTY_INI_PSN_M GENMASK(23, 0)
593 
594 #define V2_QPC_BYTE_144_RAQ_RTY_INI_IND_S 24
595 
596 #define V2_QPC_BYTE_144_RAQ_CREDIT_S 25
597 #define V2_QPC_BYTE_144_RAQ_CREDIT_M GENMASK(29, 25)
598 
599 #define V2_QPC_BYTE_144_RESP_RTY_FLG_S 31
600 
601 #define	V2_QPC_BYTE_148_RQ_MSN_S 0
602 #define V2_QPC_BYTE_148_RQ_MSN_M GENMASK(23, 0)
603 
604 #define	V2_QPC_BYTE_148_RAQ_SYNDROME_S 24
605 #define V2_QPC_BYTE_148_RAQ_SYNDROME_M GENMASK(31, 24)
606 
607 #define	V2_QPC_BYTE_152_RAQ_PSN_S 8
608 #define V2_QPC_BYTE_152_RAQ_PSN_M GENMASK(31, 8)
609 
610 #define	V2_QPC_BYTE_152_RAQ_TRRL_RTY_HEAD_S 24
611 #define V2_QPC_BYTE_152_RAQ_TRRL_RTY_HEAD_M GENMASK(31, 24)
612 
613 #define	V2_QPC_BYTE_156_RAQ_USE_PKTN_S 0
614 #define V2_QPC_BYTE_156_RAQ_USE_PKTN_M GENMASK(23, 0)
615 
616 #define	V2_QPC_BYTE_160_SQ_PRODUCER_IDX_S 0
617 #define V2_QPC_BYTE_160_SQ_PRODUCER_IDX_M GENMASK(15, 0)
618 
619 #define	V2_QPC_BYTE_160_SQ_CONSUMER_IDX_S 16
620 #define V2_QPC_BYTE_160_SQ_CONSUMER_IDX_M GENMASK(31, 16)
621 
622 #define	V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_S 0
623 #define V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_M GENMASK(19, 0)
624 
625 #define V2_QPC_BYTE_168_MSG_RTY_LP_FLG_S 20
626 
627 #define V2_QPC_BYTE_168_SQ_INVLD_FLG_S 21
628 
629 #define	V2_QPC_BYTE_168_LP_SGEN_INI_S 22
630 #define V2_QPC_BYTE_168_LP_SGEN_INI_M GENMASK(23, 22)
631 
632 #define	V2_QPC_BYTE_168_SQ_SHIFT_BAK_S 24
633 #define V2_QPC_BYTE_168_SQ_SHIFT_BAK_M GENMASK(27, 24)
634 
635 #define	V2_QPC_BYTE_168_IRRL_IDX_LSB_S 28
636 #define V2_QPC_BYTE_168_IRRL_IDX_LSB_M GENMASK(31, 28)
637 
638 #define	V2_QPC_BYTE_172_ACK_REQ_FREQ_S 0
639 #define V2_QPC_BYTE_172_ACK_REQ_FREQ_M GENMASK(5, 0)
640 
641 #define V2_QPC_BYTE_172_MSG_RNR_FLG_S 6
642 
643 #define V2_QPC_BYTE_172_FRE_S 7
644 
645 #define	V2_QPC_BYTE_172_SQ_CUR_PSN_S 8
646 #define V2_QPC_BYTE_172_SQ_CUR_PSN_M GENMASK(31, 8)
647 
648 #define	V2_QPC_BYTE_176_MSG_USE_PKTN_S 0
649 #define V2_QPC_BYTE_176_MSG_USE_PKTN_M GENMASK(23, 0)
650 
651 #define	V2_QPC_BYTE_176_IRRL_HEAD_PRE_S 24
652 #define V2_QPC_BYTE_176_IRRL_HEAD_PRE_M GENMASK(31, 24)
653 
654 #define	V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_S 0
655 #define V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_M GENMASK(19, 0)
656 
657 #define	V2_QPC_BYTE_184_IRRL_IDX_MSB_S 20
658 #define V2_QPC_BYTE_184_IRRL_IDX_MSB_M GENMASK(31, 20)
659 
660 #define	V2_QPC_BYTE_192_CUR_SGE_IDX_S 0
661 #define V2_QPC_BYTE_192_CUR_SGE_IDX_M GENMASK(23, 0)
662 
663 #define	V2_QPC_BYTE_192_EXT_SGE_NUM_LEFT_S 24
664 #define V2_QPC_BYTE_192_EXT_SGE_NUM_LEFT_M GENMASK(31, 24)
665 
666 #define	V2_QPC_BYTE_196_IRRL_HEAD_S 0
667 #define V2_QPC_BYTE_196_IRRL_HEAD_M GENMASK(7, 0)
668 
669 #define	V2_QPC_BYTE_196_SQ_MAX_PSN_S 8
670 #define V2_QPC_BYTE_196_SQ_MAX_PSN_M GENMASK(31, 8)
671 
672 #define	V2_QPC_BYTE_200_SQ_MAX_IDX_S 0
673 #define V2_QPC_BYTE_200_SQ_MAX_IDX_M GENMASK(15, 0)
674 
675 #define	V2_QPC_BYTE_200_LCL_OPERATED_CNT_S 16
676 #define V2_QPC_BYTE_200_LCL_OPERATED_CNT_M GENMASK(31, 16)
677 
678 #define	V2_QPC_BYTE_208_IRRL_BA_S 0
679 #define V2_QPC_BYTE_208_IRRL_BA_M GENMASK(25, 0)
680 
681 #define V2_QPC_BYTE_208_PKT_RNR_FLG_S 26
682 
683 #define V2_QPC_BYTE_208_PKT_RTY_FLG_S 27
684 
685 #define V2_QPC_BYTE_208_RMT_E2E_S 28
686 
687 #define	V2_QPC_BYTE_208_SR_MAX_S 29
688 #define V2_QPC_BYTE_208_SR_MAX_M GENMASK(31, 29)
689 
690 #define	V2_QPC_BYTE_212_LSN_S 0
691 #define V2_QPC_BYTE_212_LSN_M GENMASK(23, 0)
692 
693 #define	V2_QPC_BYTE_212_RETRY_NUM_INIT_S 24
694 #define V2_QPC_BYTE_212_RETRY_NUM_INIT_M GENMASK(26, 24)
695 
696 #define	V2_QPC_BYTE_212_CHECK_FLG_S 27
697 #define V2_QPC_BYTE_212_CHECK_FLG_M GENMASK(28, 27)
698 
699 #define	V2_QPC_BYTE_212_RETRY_CNT_S 29
700 #define V2_QPC_BYTE_212_RETRY_CNT_M GENMASK(31, 29)
701 
702 #define	V2_QPC_BYTE_220_RETRY_MSG_MSN_S 0
703 #define V2_QPC_BYTE_220_RETRY_MSG_MSN_M GENMASK(15, 0)
704 
705 #define	V2_QPC_BYTE_220_RETRY_MSG_PSN_S 16
706 #define V2_QPC_BYTE_220_RETRY_MSG_PSN_M GENMASK(31, 16)
707 
708 #define	V2_QPC_BYTE_224_RETRY_MSG_PSN_S 0
709 #define V2_QPC_BYTE_224_RETRY_MSG_PSN_M GENMASK(7, 0)
710 
711 #define	V2_QPC_BYTE_224_RETRY_MSG_FPKT_PSN_S 8
712 #define V2_QPC_BYTE_224_RETRY_MSG_FPKT_PSN_M GENMASK(31, 8)
713 
714 #define	V2_QPC_BYTE_232_RX_SQ_CUR_BLK_ADDR_S 0
715 #define V2_QPC_BYTE_232_RX_SQ_CUR_BLK_ADDR_M GENMASK(19, 0)
716 
717 #define	V2_QPC_BYTE_232_IRRL_SGE_IDX_S 20
718 #define V2_QPC_BYTE_232_IRRL_SGE_IDX_M GENMASK(28, 20)
719 
720 #define	V2_QPC_BYTE_240_IRRL_TAIL_REAL_S 0
721 #define V2_QPC_BYTE_240_IRRL_TAIL_REAL_M GENMASK(7, 0)
722 
723 #define	V2_QPC_BYTE_240_IRRL_TAIL_RD_S 8
724 #define V2_QPC_BYTE_240_IRRL_TAIL_RD_M GENMASK(15, 8)
725 
726 #define	V2_QPC_BYTE_240_RX_ACK_MSN_S 16
727 #define V2_QPC_BYTE_240_RX_ACK_MSN_M GENMASK(31, 16)
728 
729 #define	V2_QPC_BYTE_244_RX_ACK_EPSN_S 0
730 #define V2_QPC_BYTE_244_RX_ACK_EPSN_M GENMASK(23, 0)
731 
732 #define	V2_QPC_BYTE_244_RNR_NUM_INIT_S 24
733 #define V2_QPC_BYTE_244_RNR_NUM_INIT_M GENMASK(26, 24)
734 
735 #define	V2_QPC_BYTE_244_RNR_CNT_S 27
736 #define V2_QPC_BYTE_244_RNR_CNT_M GENMASK(29, 27)
737 
738 #define	V2_QPC_BYTE_248_IRRL_PSN_S 0
739 #define V2_QPC_BYTE_248_IRRL_PSN_M GENMASK(23, 0)
740 
741 #define V2_QPC_BYTE_248_ACK_PSN_ERR_S 24
742 
743 #define	V2_QPC_BYTE_248_ACK_LAST_OPTYPE_S 25
744 #define V2_QPC_BYTE_248_ACK_LAST_OPTYPE_M GENMASK(26, 25)
745 
746 #define V2_QPC_BYTE_248_IRRL_PSN_VLD_S 27
747 
748 #define V2_QPC_BYTE_248_RNR_RETRY_FLAG_S 28
749 
750 #define V2_QPC_BYTE_248_CQ_ERR_IND_S 31
751 
752 #define	V2_QPC_BYTE_252_TX_CQN_S 0
753 #define V2_QPC_BYTE_252_TX_CQN_M GENMASK(23, 0)
754 
755 #define	V2_QPC_BYTE_252_SIG_TYPE_S 24
756 
757 #define	V2_QPC_BYTE_252_ERR_TYPE_S 25
758 #define V2_QPC_BYTE_252_ERR_TYPE_M GENMASK(31, 25)
759 
760 #define	V2_QPC_BYTE_256_RQ_CQE_IDX_S 0
761 #define V2_QPC_BYTE_256_RQ_CQE_IDX_M GENMASK(15, 0)
762 
763 #define	V2_QPC_BYTE_256_SQ_FLUSH_IDX_S 16
764 #define V2_QPC_BYTE_256_SQ_FLUSH_IDX_M GENMASK(31, 16)
765 
766 struct hns_roce_v2_cqe {
767 	__le32	byte_4;
768 	union {
769 		__le32 rkey;
770 		__be32 immtdata;
771 	};
772 	__le32	byte_12;
773 	__le32	byte_16;
774 	__le32	byte_cnt;
775 	u8	smac[4];
776 	__le32	byte_28;
777 	__le32	byte_32;
778 };
779 
780 #define	V2_CQE_BYTE_4_OPCODE_S 0
781 #define V2_CQE_BYTE_4_OPCODE_M GENMASK(4, 0)
782 
783 #define	V2_CQE_BYTE_4_RQ_INLINE_S 5
784 
785 #define	V2_CQE_BYTE_4_S_R_S 6
786 
787 #define	V2_CQE_BYTE_4_OWNER_S 7
788 
789 #define	V2_CQE_BYTE_4_STATUS_S 8
790 #define V2_CQE_BYTE_4_STATUS_M GENMASK(15, 8)
791 
792 #define	V2_CQE_BYTE_4_WQE_INDX_S 16
793 #define V2_CQE_BYTE_4_WQE_INDX_M GENMASK(31, 16)
794 
795 #define	V2_CQE_BYTE_12_XRC_SRQN_S 0
796 #define V2_CQE_BYTE_12_XRC_SRQN_M GENMASK(23, 0)
797 
798 #define	V2_CQE_BYTE_16_LCL_QPN_S 0
799 #define V2_CQE_BYTE_16_LCL_QPN_M GENMASK(23, 0)
800 
801 #define	V2_CQE_BYTE_16_SUB_STATUS_S 24
802 #define V2_CQE_BYTE_16_SUB_STATUS_M GENMASK(31, 24)
803 
804 #define	V2_CQE_BYTE_28_SMAC_4_S 0
805 #define V2_CQE_BYTE_28_SMAC_4_M	GENMASK(7, 0)
806 
807 #define	V2_CQE_BYTE_28_SMAC_5_S 8
808 #define V2_CQE_BYTE_28_SMAC_5_M	GENMASK(15, 8)
809 
810 #define	V2_CQE_BYTE_28_PORT_TYPE_S 16
811 #define V2_CQE_BYTE_28_PORT_TYPE_M GENMASK(17, 16)
812 
813 #define	V2_CQE_BYTE_32_RMT_QPN_S 0
814 #define V2_CQE_BYTE_32_RMT_QPN_M GENMASK(23, 0)
815 
816 #define	V2_CQE_BYTE_32_SL_S 24
817 #define V2_CQE_BYTE_32_SL_M GENMASK(26, 24)
818 
819 #define	V2_CQE_BYTE_32_PORTN_S 27
820 #define V2_CQE_BYTE_32_PORTN_M GENMASK(29, 27)
821 
822 #define	V2_CQE_BYTE_32_GRH_S 30
823 
824 #define	V2_CQE_BYTE_32_LPK_S 31
825 
826 struct hns_roce_v2_mpt_entry {
827 	__le32	byte_4_pd_hop_st;
828 	__le32	byte_8_mw_cnt_en;
829 	__le32	byte_12_mw_pa;
830 	__le32	bound_lkey;
831 	__le32	len_l;
832 	__le32	len_h;
833 	__le32	lkey;
834 	__le32	va_l;
835 	__le32	va_h;
836 	__le32	pbl_size;
837 	__le32	pbl_ba_l;
838 	__le32	byte_48_mode_ba;
839 	__le32	pa0_l;
840 	__le32	byte_56_pa0_h;
841 	__le32	pa1_l;
842 	__le32	byte_64_buf_pa1;
843 };
844 
845 #define V2_MPT_BYTE_4_MPT_ST_S 0
846 #define V2_MPT_BYTE_4_MPT_ST_M GENMASK(1, 0)
847 
848 #define V2_MPT_BYTE_4_PBL_HOP_NUM_S 2
849 #define V2_MPT_BYTE_4_PBL_HOP_NUM_M GENMASK(3, 2)
850 
851 #define V2_MPT_BYTE_4_PBL_BA_PG_SZ_S 4
852 #define V2_MPT_BYTE_4_PBL_BA_PG_SZ_M GENMASK(7, 4)
853 
854 #define V2_MPT_BYTE_4_PD_S 8
855 #define V2_MPT_BYTE_4_PD_M GENMASK(31, 8)
856 
857 #define V2_MPT_BYTE_8_RA_EN_S 0
858 
859 #define V2_MPT_BYTE_8_R_INV_EN_S 1
860 
861 #define V2_MPT_BYTE_8_L_INV_EN_S 2
862 
863 #define V2_MPT_BYTE_8_BIND_EN_S 3
864 
865 #define V2_MPT_BYTE_8_ATOMIC_EN_S 4
866 
867 #define V2_MPT_BYTE_8_RR_EN_S 5
868 
869 #define V2_MPT_BYTE_8_RW_EN_S 6
870 
871 #define V2_MPT_BYTE_8_LW_EN_S 7
872 
873 #define V2_MPT_BYTE_12_PA_S 1
874 
875 #define V2_MPT_BYTE_12_INNER_PA_VLD_S 7
876 
877 #define V2_MPT_BYTE_12_MW_BIND_QPN_S 8
878 #define V2_MPT_BYTE_12_MW_BIND_QPN_M GENMASK(31, 8)
879 
880 #define V2_MPT_BYTE_48_PBL_BA_H_S 0
881 #define V2_MPT_BYTE_48_PBL_BA_H_M GENMASK(28, 0)
882 
883 #define V2_MPT_BYTE_48_BLK_MODE_S 29
884 
885 #define V2_MPT_BYTE_56_PA0_H_S 0
886 #define V2_MPT_BYTE_56_PA0_H_M GENMASK(25, 0)
887 
888 #define V2_MPT_BYTE_64_PA1_H_S 0
889 #define V2_MPT_BYTE_64_PA1_H_M GENMASK(25, 0)
890 
891 #define V2_MPT_BYTE_64_PBL_BUF_PG_SZ_S 28
892 #define V2_MPT_BYTE_64_PBL_BUF_PG_SZ_M GENMASK(31, 28)
893 
894 #define	V2_DB_BYTE_4_TAG_S 0
895 #define V2_DB_BYTE_4_TAG_M GENMASK(23, 0)
896 
897 #define	V2_DB_BYTE_4_CMD_S 24
898 #define V2_DB_BYTE_4_CMD_M GENMASK(27, 24)
899 
900 #define V2_DB_PARAMETER_CONS_IDX_S 0
901 #define V2_DB_PARAMETER_CONS_IDX_M GENMASK(15, 0)
902 
903 #define V2_DB_PARAMETER_SL_S 16
904 #define V2_DB_PARAMETER_SL_M GENMASK(18, 16)
905 
906 struct hns_roce_v2_cq_db {
907 	__le32	byte_4;
908 	__le32	parameter;
909 };
910 
911 #define	V2_CQ_DB_BYTE_4_TAG_S 0
912 #define V2_CQ_DB_BYTE_4_TAG_M GENMASK(23, 0)
913 
914 #define	V2_CQ_DB_BYTE_4_CMD_S 24
915 #define V2_CQ_DB_BYTE_4_CMD_M GENMASK(27, 24)
916 
917 #define V2_CQ_DB_PARAMETER_CONS_IDX_S 0
918 #define V2_CQ_DB_PARAMETER_CONS_IDX_M GENMASK(23, 0)
919 
920 #define V2_CQ_DB_PARAMETER_CMD_SN_S 25
921 #define V2_CQ_DB_PARAMETER_CMD_SN_M GENMASK(26, 25)
922 
923 #define V2_CQ_DB_PARAMETER_NOTIFY_S 24
924 
925 struct hns_roce_v2_ud_send_wqe {
926 	__le32	byte_4;
927 	__le32	msg_len;
928 	__be32	immtdata;
929 	__le32	byte_16;
930 	__le32	byte_20;
931 	__le32	byte_24;
932 	__le32	qkey;
933 	__le32	byte_32;
934 	__le32	byte_36;
935 	__le32	byte_40;
936 	__le32	dmac;
937 	__le32	byte_48;
938 	u8	dgid[GID_LEN_V2];
939 
940 };
941 #define	V2_UD_SEND_WQE_BYTE_4_OPCODE_S 0
942 #define V2_UD_SEND_WQE_BYTE_4_OPCODE_M GENMASK(4, 0)
943 
944 #define	V2_UD_SEND_WQE_BYTE_4_OWNER_S 7
945 
946 #define	V2_UD_SEND_WQE_BYTE_4_CQE_S 8
947 
948 #define	V2_UD_SEND_WQE_BYTE_4_SE_S 11
949 
950 #define	V2_UD_SEND_WQE_BYTE_16_PD_S 0
951 #define V2_UD_SEND_WQE_BYTE_16_PD_M GENMASK(23, 0)
952 
953 #define	V2_UD_SEND_WQE_BYTE_16_SGE_NUM_S 24
954 #define V2_UD_SEND_WQE_BYTE_16_SGE_NUM_M GENMASK(31, 24)
955 
956 #define	V2_UD_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_S 0
957 #define V2_UD_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_M GENMASK(23, 0)
958 
959 #define	V2_UD_SEND_WQE_BYTE_24_UDPSPN_S 16
960 #define V2_UD_SEND_WQE_BYTE_24_UDPSPN_M GENMASK(31, 16)
961 
962 #define	V2_UD_SEND_WQE_BYTE_32_DQPN_S 0
963 #define V2_UD_SEND_WQE_BYTE_32_DQPN_M GENMASK(23, 0)
964 
965 #define	V2_UD_SEND_WQE_BYTE_36_VLAN_S 0
966 #define V2_UD_SEND_WQE_BYTE_36_VLAN_M GENMASK(15, 0)
967 
968 #define	V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_S 16
969 #define V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_M GENMASK(23, 16)
970 
971 #define	V2_UD_SEND_WQE_BYTE_36_TCLASS_S 24
972 #define V2_UD_SEND_WQE_BYTE_36_TCLASS_M GENMASK(31, 24)
973 
974 #define	V2_UD_SEND_WQE_BYTE_40_FLOW_LABEL_S 0
975 #define V2_UD_SEND_WQE_BYTE_40_FLOW_LABEL_M GENMASK(19, 0)
976 
977 #define	V2_UD_SEND_WQE_BYTE_40_SL_S 20
978 #define V2_UD_SEND_WQE_BYTE_40_SL_M GENMASK(23, 20)
979 
980 #define	V2_UD_SEND_WQE_BYTE_40_PORTN_S 24
981 #define V2_UD_SEND_WQE_BYTE_40_PORTN_M GENMASK(26, 24)
982 
983 #define	V2_UD_SEND_WQE_BYTE_40_LBI_S 31
984 
985 #define	V2_UD_SEND_WQE_DMAC_0_S 0
986 #define V2_UD_SEND_WQE_DMAC_0_M GENMASK(7, 0)
987 
988 #define	V2_UD_SEND_WQE_DMAC_1_S 8
989 #define V2_UD_SEND_WQE_DMAC_1_M GENMASK(15, 8)
990 
991 #define	V2_UD_SEND_WQE_DMAC_2_S 16
992 #define V2_UD_SEND_WQE_DMAC_2_M GENMASK(23, 16)
993 
994 #define	V2_UD_SEND_WQE_DMAC_3_S 24
995 #define V2_UD_SEND_WQE_DMAC_3_M GENMASK(31, 24)
996 
997 #define	V2_UD_SEND_WQE_BYTE_48_DMAC_4_S 0
998 #define V2_UD_SEND_WQE_BYTE_48_DMAC_4_M GENMASK(7, 0)
999 
1000 #define	V2_UD_SEND_WQE_BYTE_48_DMAC_5_S 8
1001 #define V2_UD_SEND_WQE_BYTE_48_DMAC_5_M GENMASK(15, 8)
1002 
1003 #define	V2_UD_SEND_WQE_BYTE_48_SGID_INDX_S 16
1004 #define V2_UD_SEND_WQE_BYTE_48_SGID_INDX_M GENMASK(23, 16)
1005 
1006 #define	V2_UD_SEND_WQE_BYTE_48_SMAC_INDX_S 24
1007 #define V2_UD_SEND_WQE_BYTE_48_SMAC_INDX_M GENMASK(31, 24)
1008 
1009 struct hns_roce_v2_rc_send_wqe {
1010 	__le32		byte_4;
1011 	__le32		msg_len;
1012 	union {
1013 		__le32  inv_key;
1014 		__be32  immtdata;
1015 	};
1016 	__le32		byte_16;
1017 	__le32		byte_20;
1018 	__le32		rkey;
1019 	__le64		va;
1020 };
1021 
1022 #define	V2_RC_SEND_WQE_BYTE_4_OPCODE_S 0
1023 #define V2_RC_SEND_WQE_BYTE_4_OPCODE_M GENMASK(4, 0)
1024 
1025 #define V2_RC_SEND_WQE_BYTE_4_OWNER_S 7
1026 
1027 #define V2_RC_SEND_WQE_BYTE_4_CQE_S 8
1028 
1029 #define V2_RC_SEND_WQE_BYTE_4_FENCE_S 9
1030 
1031 #define V2_RC_SEND_WQE_BYTE_4_SO_S 10
1032 
1033 #define V2_RC_SEND_WQE_BYTE_4_SE_S 11
1034 
1035 #define V2_RC_SEND_WQE_BYTE_4_INLINE_S 12
1036 
1037 #define	V2_RC_SEND_WQE_BYTE_16_XRC_SRQN_S 0
1038 #define V2_RC_SEND_WQE_BYTE_16_XRC_SRQN_M GENMASK(23, 0)
1039 
1040 #define	V2_RC_SEND_WQE_BYTE_16_SGE_NUM_S 24
1041 #define V2_RC_SEND_WQE_BYTE_16_SGE_NUM_M GENMASK(31, 24)
1042 
1043 #define V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_S 0
1044 #define V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_M GENMASK(23, 0)
1045 
1046 struct hns_roce_v2_wqe_data_seg {
1047 	__le32    len;
1048 	__le32    lkey;
1049 	__le64    addr;
1050 };
1051 
1052 struct hns_roce_v2_db {
1053 	__le32	byte_4;
1054 	__le32	parameter;
1055 };
1056 
1057 struct hns_roce_query_version {
1058 	__le16 rocee_vendor_id;
1059 	__le16 rocee_hw_version;
1060 	__le32 rsv[5];
1061 };
1062 
1063 struct hns_roce_cfg_global_param {
1064 	__le32 time_cfg_udp_port;
1065 	__le32 rsv[5];
1066 };
1067 
1068 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_TIME_1US_CFG_S 0
1069 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_TIME_1US_CFG_M GENMASK(9, 0)
1070 
1071 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_UDP_PORT_S 16
1072 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_UDP_PORT_M GENMASK(31, 16)
1073 
1074 struct hns_roce_pf_res {
1075 	__le32	rsv;
1076 	__le32	qpc_bt_idx_num;
1077 	__le32	srqc_bt_idx_num;
1078 	__le32	cqc_bt_idx_num;
1079 	__le32	mpt_bt_idx_num;
1080 	__le32	eqc_bt_idx_num;
1081 };
1082 
1083 #define PF_RES_DATA_1_PF_QPC_BT_IDX_S 0
1084 #define PF_RES_DATA_1_PF_QPC_BT_IDX_M GENMASK(10, 0)
1085 
1086 #define PF_RES_DATA_1_PF_QPC_BT_NUM_S 16
1087 #define PF_RES_DATA_1_PF_QPC_BT_NUM_M GENMASK(27, 16)
1088 
1089 #define PF_RES_DATA_2_PF_SRQC_BT_IDX_S 0
1090 #define PF_RES_DATA_2_PF_SRQC_BT_IDX_M GENMASK(8, 0)
1091 
1092 #define PF_RES_DATA_2_PF_SRQC_BT_NUM_S 16
1093 #define PF_RES_DATA_2_PF_SRQC_BT_NUM_M GENMASK(25, 16)
1094 
1095 #define PF_RES_DATA_3_PF_CQC_BT_IDX_S 0
1096 #define PF_RES_DATA_3_PF_CQC_BT_IDX_M GENMASK(8, 0)
1097 
1098 #define PF_RES_DATA_3_PF_CQC_BT_NUM_S 16
1099 #define PF_RES_DATA_3_PF_CQC_BT_NUM_M GENMASK(25, 16)
1100 
1101 #define PF_RES_DATA_4_PF_MPT_BT_IDX_S 0
1102 #define PF_RES_DATA_4_PF_MPT_BT_IDX_M GENMASK(8, 0)
1103 
1104 #define PF_RES_DATA_4_PF_MPT_BT_NUM_S 16
1105 #define PF_RES_DATA_4_PF_MPT_BT_NUM_M GENMASK(25, 16)
1106 
1107 #define PF_RES_DATA_5_PF_EQC_BT_IDX_S 0
1108 #define PF_RES_DATA_5_PF_EQC_BT_IDX_M GENMASK(8, 0)
1109 
1110 #define PF_RES_DATA_5_PF_EQC_BT_NUM_S 16
1111 #define PF_RES_DATA_5_PF_EQC_BT_NUM_M GENMASK(25, 16)
1112 
1113 struct hns_roce_vf_res_a {
1114 	__le32 vf_id;
1115 	__le32 vf_qpc_bt_idx_num;
1116 	__le32 vf_srqc_bt_idx_num;
1117 	__le32 vf_cqc_bt_idx_num;
1118 	__le32 vf_mpt_bt_idx_num;
1119 	__le32 vf_eqc_bt_idx_num;
1120 };
1121 
1122 #define VF_RES_A_DATA_1_VF_QPC_BT_IDX_S 0
1123 #define VF_RES_A_DATA_1_VF_QPC_BT_IDX_M GENMASK(10, 0)
1124 
1125 #define VF_RES_A_DATA_1_VF_QPC_BT_NUM_S 16
1126 #define VF_RES_A_DATA_1_VF_QPC_BT_NUM_M GENMASK(27, 16)
1127 
1128 #define VF_RES_A_DATA_2_VF_SRQC_BT_IDX_S 0
1129 #define VF_RES_A_DATA_2_VF_SRQC_BT_IDX_M GENMASK(8, 0)
1130 
1131 #define VF_RES_A_DATA_2_VF_SRQC_BT_NUM_S 16
1132 #define VF_RES_A_DATA_2_VF_SRQC_BT_NUM_M GENMASK(25, 16)
1133 
1134 #define VF_RES_A_DATA_3_VF_CQC_BT_IDX_S 0
1135 #define VF_RES_A_DATA_3_VF_CQC_BT_IDX_M GENMASK(8, 0)
1136 
1137 #define VF_RES_A_DATA_3_VF_CQC_BT_NUM_S 16
1138 #define VF_RES_A_DATA_3_VF_CQC_BT_NUM_M GENMASK(25, 16)
1139 
1140 #define VF_RES_A_DATA_4_VF_MPT_BT_IDX_S 0
1141 #define VF_RES_A_DATA_4_VF_MPT_BT_IDX_M GENMASK(8, 0)
1142 
1143 #define VF_RES_A_DATA_4_VF_MPT_BT_NUM_S 16
1144 #define VF_RES_A_DATA_4_VF_MPT_BT_NUM_M GENMASK(25, 16)
1145 
1146 #define VF_RES_A_DATA_5_VF_EQC_IDX_S 0
1147 #define VF_RES_A_DATA_5_VF_EQC_IDX_M GENMASK(8, 0)
1148 
1149 #define VF_RES_A_DATA_5_VF_EQC_NUM_S 16
1150 #define VF_RES_A_DATA_5_VF_EQC_NUM_M GENMASK(25, 16)
1151 
1152 struct hns_roce_vf_res_b {
1153 	__le32 rsv0;
1154 	__le32 vf_smac_idx_num;
1155 	__le32 vf_sgid_idx_num;
1156 	__le32 vf_qid_idx_sl_num;
1157 	__le32 rsv[2];
1158 };
1159 
1160 #define VF_RES_B_DATA_0_VF_ID_S 0
1161 #define VF_RES_B_DATA_0_VF_ID_M GENMASK(7, 0)
1162 
1163 #define VF_RES_B_DATA_1_VF_SMAC_IDX_S 0
1164 #define VF_RES_B_DATA_1_VF_SMAC_IDX_M GENMASK(7, 0)
1165 
1166 #define VF_RES_B_DATA_1_VF_SMAC_NUM_S 8
1167 #define VF_RES_B_DATA_1_VF_SMAC_NUM_M GENMASK(16, 8)
1168 
1169 #define VF_RES_B_DATA_2_VF_SGID_IDX_S 0
1170 #define VF_RES_B_DATA_2_VF_SGID_IDX_M GENMASK(7, 0)
1171 
1172 #define VF_RES_B_DATA_2_VF_SGID_NUM_S 8
1173 #define VF_RES_B_DATA_2_VF_SGID_NUM_M GENMASK(16, 8)
1174 
1175 #define VF_RES_B_DATA_3_VF_QID_IDX_S 0
1176 #define VF_RES_B_DATA_3_VF_QID_IDX_M GENMASK(9, 0)
1177 
1178 #define VF_RES_B_DATA_3_VF_SL_NUM_S 16
1179 #define VF_RES_B_DATA_3_VF_SL_NUM_M GENMASK(19, 16)
1180 
1181 /* Reg field definition */
1182 #define ROCEE_VF_SMAC_CFG1_VF_SMAC_H_S 0
1183 #define ROCEE_VF_SMAC_CFG1_VF_SMAC_H_M GENMASK(15, 0)
1184 
1185 #define ROCEE_VF_SGID_CFG4_SGID_TYPE_S 0
1186 #define ROCEE_VF_SGID_CFG4_SGID_TYPE_M GENMASK(1, 0)
1187 
1188 struct hns_roce_cfg_bt_attr {
1189 	__le32 vf_qpc_cfg;
1190 	__le32 vf_srqc_cfg;
1191 	__le32 vf_cqc_cfg;
1192 	__le32 vf_mpt_cfg;
1193 	__le32 rsv[2];
1194 };
1195 
1196 #define CFG_BT_ATTR_DATA_0_VF_QPC_BA_PGSZ_S 0
1197 #define CFG_BT_ATTR_DATA_0_VF_QPC_BA_PGSZ_M GENMASK(3, 0)
1198 
1199 #define CFG_BT_ATTR_DATA_0_VF_QPC_BUF_PGSZ_S 4
1200 #define CFG_BT_ATTR_DATA_0_VF_QPC_BUF_PGSZ_M GENMASK(7, 4)
1201 
1202 #define CFG_BT_ATTR_DATA_0_VF_QPC_HOPNUM_S 8
1203 #define CFG_BT_ATTR_DATA_0_VF_QPC_HOPNUM_M GENMASK(9, 8)
1204 
1205 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BA_PGSZ_S 0
1206 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BA_PGSZ_M GENMASK(3, 0)
1207 
1208 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BUF_PGSZ_S 4
1209 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BUF_PGSZ_M GENMASK(7, 4)
1210 
1211 #define CFG_BT_ATTR_DATA_1_VF_SRQC_HOPNUM_S 8
1212 #define CFG_BT_ATTR_DATA_1_VF_SRQC_HOPNUM_M GENMASK(9, 8)
1213 
1214 #define CFG_BT_ATTR_DATA_2_VF_CQC_BA_PGSZ_S 0
1215 #define CFG_BT_ATTR_DATA_2_VF_CQC_BA_PGSZ_M GENMASK(3, 0)
1216 
1217 #define CFG_BT_ATTR_DATA_2_VF_CQC_BUF_PGSZ_S 4
1218 #define CFG_BT_ATTR_DATA_2_VF_CQC_BUF_PGSZ_M GENMASK(7, 4)
1219 
1220 #define CFG_BT_ATTR_DATA_2_VF_CQC_HOPNUM_S 8
1221 #define CFG_BT_ATTR_DATA_2_VF_CQC_HOPNUM_M GENMASK(9, 8)
1222 
1223 #define CFG_BT_ATTR_DATA_3_VF_MPT_BA_PGSZ_S 0
1224 #define CFG_BT_ATTR_DATA_3_VF_MPT_BA_PGSZ_M GENMASK(3, 0)
1225 
1226 #define CFG_BT_ATTR_DATA_3_VF_MPT_BUF_PGSZ_S 4
1227 #define CFG_BT_ATTR_DATA_3_VF_MPT_BUF_PGSZ_M GENMASK(7, 4)
1228 
1229 #define CFG_BT_ATTR_DATA_3_VF_MPT_HOPNUM_S 8
1230 #define CFG_BT_ATTR_DATA_3_VF_MPT_HOPNUM_M GENMASK(9, 8)
1231 
1232 struct hns_roce_cmq_desc {
1233 	__le16 opcode;
1234 	__le16 flag;
1235 	__le16 retval;
1236 	__le16 rsv;
1237 	__le32 data[6];
1238 };
1239 
1240 #define HNS_ROCE_V2_GO_BIT_TIMEOUT_MSECS	10000
1241 
1242 #define HNS_ROCE_HW_RUN_BIT_SHIFT	31
1243 #define HNS_ROCE_HW_MB_STATUS_MASK	0xFF
1244 
1245 #define HNS_ROCE_VF_MB4_TAG_MASK	0xFFFFFF00
1246 #define HNS_ROCE_VF_MB4_TAG_SHIFT	8
1247 
1248 #define HNS_ROCE_VF_MB4_CMD_MASK	0xFF
1249 #define HNS_ROCE_VF_MB4_CMD_SHIFT	0
1250 
1251 #define HNS_ROCE_VF_MB5_EVENT_MASK	0x10000
1252 #define HNS_ROCE_VF_MB5_EVENT_SHIFT	16
1253 
1254 #define HNS_ROCE_VF_MB5_TOKEN_MASK	0xFFFF
1255 #define HNS_ROCE_VF_MB5_TOKEN_SHIFT	0
1256 
1257 struct hns_roce_v2_cmq_ring {
1258 	dma_addr_t desc_dma_addr;
1259 	struct hns_roce_cmq_desc *desc;
1260 	u32 head;
1261 	u32 tail;
1262 
1263 	u16 buf_size;
1264 	u16 desc_num;
1265 	int next_to_use;
1266 	int next_to_clean;
1267 	u8 flag;
1268 	spinlock_t lock; /* command queue lock */
1269 };
1270 
1271 struct hns_roce_v2_cmq {
1272 	struct hns_roce_v2_cmq_ring csq;
1273 	struct hns_roce_v2_cmq_ring crq;
1274 	u16 tx_timeout;
1275 	u16 last_status;
1276 };
1277 
1278 struct hns_roce_v2_priv {
1279 	struct hns_roce_v2_cmq cmq;
1280 };
1281 
1282 struct hns_roce_eq_context {
1283 	__le32	byte_4;
1284 	__le32	byte_8;
1285 	__le32	byte_12;
1286 	__le32	eqe_report_timer;
1287 	__le32	eqe_ba0;
1288 	__le32	eqe_ba1;
1289 	__le32	byte_28;
1290 	__le32	byte_32;
1291 	__le32	byte_36;
1292 	__le32	nxt_eqe_ba0;
1293 	__le32	nxt_eqe_ba1;
1294 	__le32	rsv[5];
1295 };
1296 
1297 #define HNS_ROCE_AEQ_DEFAULT_BURST_NUM	0x0
1298 #define HNS_ROCE_AEQ_DEFAULT_INTERVAL	0x0
1299 #define HNS_ROCE_CEQ_DEFAULT_BURST_NUM	0x0
1300 #define HNS_ROCE_CEQ_DEFAULT_INTERVAL	0x0
1301 
1302 #define HNS_ROCE_V2_EQ_STATE_INVALID		0
1303 #define HNS_ROCE_V2_EQ_STATE_VALID		1
1304 #define HNS_ROCE_V2_EQ_STATE_OVERFLOW		2
1305 #define HNS_ROCE_V2_EQ_STATE_FAILURE		3
1306 
1307 #define HNS_ROCE_V2_EQ_OVER_IGNORE_0		0
1308 #define HNS_ROCE_V2_EQ_OVER_IGNORE_1		1
1309 
1310 #define HNS_ROCE_V2_EQ_COALESCE_0		0
1311 #define HNS_ROCE_V2_EQ_COALESCE_1		1
1312 
1313 #define HNS_ROCE_V2_EQ_FIRED			0
1314 #define HNS_ROCE_V2_EQ_ARMED			1
1315 #define HNS_ROCE_V2_EQ_ALWAYS_ARMED		3
1316 
1317 #define HNS_ROCE_EQ_INIT_EQE_CNT		0
1318 #define HNS_ROCE_EQ_INIT_PROD_IDX		0
1319 #define HNS_ROCE_EQ_INIT_REPORT_TIMER		0
1320 #define HNS_ROCE_EQ_INIT_MSI_IDX		0
1321 #define HNS_ROCE_EQ_INIT_CONS_IDX		0
1322 #define HNS_ROCE_EQ_INIT_NXT_EQE_BA		0
1323 
1324 #define HNS_ROCE_V2_CEQ_CEQE_OWNER_S		31
1325 #define HNS_ROCE_V2_AEQ_AEQE_OWNER_S		31
1326 
1327 #define HNS_ROCE_V2_COMP_EQE_NUM		0x1000
1328 #define HNS_ROCE_V2_ASYNC_EQE_NUM		0x1000
1329 
1330 #define HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S	0
1331 #define HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S		1
1332 #define HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S	2
1333 
1334 #define HNS_ROCE_EQ_DB_CMD_AEQ			0x0
1335 #define HNS_ROCE_EQ_DB_CMD_AEQ_ARMED		0x1
1336 #define HNS_ROCE_EQ_DB_CMD_CEQ			0x2
1337 #define HNS_ROCE_EQ_DB_CMD_CEQ_ARMED		0x3
1338 
1339 #define EQ_ENABLE				1
1340 #define EQ_DISABLE				0
1341 
1342 #define EQ_REG_OFFSET				0x4
1343 
1344 #define HNS_ROCE_INT_NAME_LEN			32
1345 #define HNS_ROCE_V2_EQN_M GENMASK(23, 0)
1346 
1347 #define HNS_ROCE_V2_CONS_IDX_M GENMASK(23, 0)
1348 
1349 #define HNS_ROCE_V2_VF_ABN_INT_EN_S 0
1350 #define HNS_ROCE_V2_VF_ABN_INT_EN_M GENMASK(0, 0)
1351 #define HNS_ROCE_V2_VF_ABN_INT_ST_M GENMASK(2, 0)
1352 #define HNS_ROCE_V2_VF_ABN_INT_CFG_M GENMASK(2, 0)
1353 #define HNS_ROCE_V2_VF_EVENT_INT_EN_M GENMASK(0, 0)
1354 
1355 /* WORD0 */
1356 #define HNS_ROCE_EQC_EQ_ST_S 0
1357 #define HNS_ROCE_EQC_EQ_ST_M GENMASK(1, 0)
1358 
1359 #define HNS_ROCE_EQC_HOP_NUM_S 2
1360 #define HNS_ROCE_EQC_HOP_NUM_M GENMASK(3, 2)
1361 
1362 #define HNS_ROCE_EQC_OVER_IGNORE_S 4
1363 #define HNS_ROCE_EQC_OVER_IGNORE_M GENMASK(4, 4)
1364 
1365 #define HNS_ROCE_EQC_COALESCE_S 5
1366 #define HNS_ROCE_EQC_COALESCE_M GENMASK(5, 5)
1367 
1368 #define HNS_ROCE_EQC_ARM_ST_S 6
1369 #define HNS_ROCE_EQC_ARM_ST_M GENMASK(7, 6)
1370 
1371 #define HNS_ROCE_EQC_EQN_S 8
1372 #define HNS_ROCE_EQC_EQN_M GENMASK(15, 8)
1373 
1374 #define HNS_ROCE_EQC_EQE_CNT_S 16
1375 #define HNS_ROCE_EQC_EQE_CNT_M GENMASK(31, 16)
1376 
1377 /* WORD1 */
1378 #define HNS_ROCE_EQC_BA_PG_SZ_S 0
1379 #define HNS_ROCE_EQC_BA_PG_SZ_M GENMASK(3, 0)
1380 
1381 #define HNS_ROCE_EQC_BUF_PG_SZ_S 4
1382 #define HNS_ROCE_EQC_BUF_PG_SZ_M GENMASK(7, 4)
1383 
1384 #define HNS_ROCE_EQC_PROD_INDX_S 8
1385 #define HNS_ROCE_EQC_PROD_INDX_M GENMASK(31, 8)
1386 
1387 /* WORD2 */
1388 #define HNS_ROCE_EQC_MAX_CNT_S 0
1389 #define HNS_ROCE_EQC_MAX_CNT_M GENMASK(15, 0)
1390 
1391 #define HNS_ROCE_EQC_PERIOD_S 16
1392 #define HNS_ROCE_EQC_PERIOD_M GENMASK(31, 16)
1393 
1394 /* WORD3 */
1395 #define HNS_ROCE_EQC_REPORT_TIMER_S 0
1396 #define HNS_ROCE_EQC_REPORT_TIMER_M GENMASK(31, 0)
1397 
1398 /* WORD4 */
1399 #define HNS_ROCE_EQC_EQE_BA_L_S 0
1400 #define HNS_ROCE_EQC_EQE_BA_L_M GENMASK(31, 0)
1401 
1402 /* WORD5 */
1403 #define HNS_ROCE_EQC_EQE_BA_H_S 0
1404 #define HNS_ROCE_EQC_EQE_BA_H_M GENMASK(28, 0)
1405 
1406 /* WORD6 */
1407 #define HNS_ROCE_EQC_SHIFT_S 0
1408 #define HNS_ROCE_EQC_SHIFT_M GENMASK(7, 0)
1409 
1410 #define HNS_ROCE_EQC_MSI_INDX_S 8
1411 #define HNS_ROCE_EQC_MSI_INDX_M GENMASK(15, 8)
1412 
1413 #define HNS_ROCE_EQC_CUR_EQE_BA_L_S 16
1414 #define HNS_ROCE_EQC_CUR_EQE_BA_L_M GENMASK(31, 16)
1415 
1416 /* WORD7 */
1417 #define HNS_ROCE_EQC_CUR_EQE_BA_M_S 0
1418 #define HNS_ROCE_EQC_CUR_EQE_BA_M_M GENMASK(31, 0)
1419 
1420 /* WORD8 */
1421 #define HNS_ROCE_EQC_CUR_EQE_BA_H_S 0
1422 #define HNS_ROCE_EQC_CUR_EQE_BA_H_M GENMASK(3, 0)
1423 
1424 #define HNS_ROCE_EQC_CONS_INDX_S 8
1425 #define HNS_ROCE_EQC_CONS_INDX_M GENMASK(31, 8)
1426 
1427 /* WORD9 */
1428 #define HNS_ROCE_EQC_NXT_EQE_BA_L_S 0
1429 #define HNS_ROCE_EQC_NXT_EQE_BA_L_M GENMASK(31, 0)
1430 
1431 /* WORD10 */
1432 #define HNS_ROCE_EQC_NXT_EQE_BA_H_S 0
1433 #define HNS_ROCE_EQC_NXT_EQE_BA_H_M GENMASK(19, 0)
1434 
1435 #define HNS_ROCE_V2_CEQE_COMP_CQN_S 0
1436 #define HNS_ROCE_V2_CEQE_COMP_CQN_M GENMASK(23, 0)
1437 
1438 #define HNS_ROCE_V2_AEQE_EVENT_TYPE_S 0
1439 #define HNS_ROCE_V2_AEQE_EVENT_TYPE_M GENMASK(7, 0)
1440 
1441 #define HNS_ROCE_V2_AEQE_SUB_TYPE_S 8
1442 #define HNS_ROCE_V2_AEQE_SUB_TYPE_M GENMASK(15, 8)
1443 
1444 #define HNS_ROCE_V2_EQ_DB_CMD_S	16
1445 #define HNS_ROCE_V2_EQ_DB_CMD_M	GENMASK(17, 16)
1446 
1447 #define HNS_ROCE_V2_EQ_DB_TAG_S	0
1448 #define HNS_ROCE_V2_EQ_DB_TAG_M	GENMASK(7, 0)
1449 
1450 #define HNS_ROCE_V2_EQ_DB_PARA_S 0
1451 #define HNS_ROCE_V2_EQ_DB_PARA_M GENMASK(23, 0)
1452 
1453 #define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_S 0
1454 #define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_M GENMASK(23, 0)
1455 
1456 #endif
1457