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