WIP FPC-III support
[linux/fpc-iii.git] / drivers / infiniband / hw / hns / hns_roce_hw_v1.h
blob46ab0a321d211346b3d74e954c84b15c1b8a5275
1 /*
2 * Copyright (c) 2016 Hisilicon Limited.
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:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
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.
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.
33 #ifndef _HNS_ROCE_HW_V1_H
34 #define _HNS_ROCE_HW_V1_H
36 #define CQ_STATE_VALID 2
38 #define HNS_ROCE_V1_MAX_PD_NUM 0x8000
39 #define HNS_ROCE_V1_MAX_CQ_NUM 0x10000
40 #define HNS_ROCE_V1_MAX_CQE_NUM 0x8000
42 #define HNS_ROCE_V1_MAX_QP_NUM 0x40000
43 #define HNS_ROCE_V1_MAX_WQE_NUM 0x4000
45 #define HNS_ROCE_V1_MAX_MTPT_NUM 0x80000
47 #define HNS_ROCE_V1_MAX_MTT_SEGS 0x100000
49 #define HNS_ROCE_V1_MAX_QP_INIT_RDMA 128
50 #define HNS_ROCE_V1_MAX_QP_DEST_RDMA 128
52 #define HNS_ROCE_V1_MAX_SQ_DESC_SZ 64
53 #define HNS_ROCE_V1_MAX_RQ_DESC_SZ 64
54 #define HNS_ROCE_V1_SG_NUM 2
55 #define HNS_ROCE_V1_INLINE_SIZE 32
57 #define HNS_ROCE_V1_UAR_NUM 256
58 #define HNS_ROCE_V1_PHY_UAR_NUM 8
60 #define HNS_ROCE_V1_GID_NUM 16
61 #define HNS_ROCE_V1_RESV_QP 8
63 #define HNS_ROCE_V1_MAX_IRQ_NUM 34
64 #define HNS_ROCE_V1_COMP_VEC_NUM 32
65 #define HNS_ROCE_V1_AEQE_VEC_NUM 1
66 #define HNS_ROCE_V1_ABNORMAL_VEC_NUM 1
68 #define HNS_ROCE_V1_COMP_EQE_NUM 0x8000
69 #define HNS_ROCE_V1_ASYNC_EQE_NUM 0x400
71 #define HNS_ROCE_V1_QPC_SIZE 256
72 #define HNS_ROCE_V1_IRRL_ENTRY_SIZE 8
73 #define HNS_ROCE_V1_CQC_ENTRY_SIZE 64
74 #define HNS_ROCE_V1_MTPT_ENTRY_SIZE 64
75 #define HNS_ROCE_V1_MTT_ENTRY_SIZE 64
77 #define HNS_ROCE_V1_CQE_SIZE 32
78 #define HNS_ROCE_V1_PAGE_SIZE_SUPPORT 0xFFFFF000
80 #define HNS_ROCE_V1_TABLE_CHUNK_SIZE (1 << 17)
82 #define HNS_ROCE_V1_EXT_RAQ_WF 8
83 #define HNS_ROCE_V1_RAQ_ENTRY 64
84 #define HNS_ROCE_V1_RAQ_DEPTH 32768
85 #define HNS_ROCE_V1_RAQ_SIZE (HNS_ROCE_V1_RAQ_ENTRY * HNS_ROCE_V1_RAQ_DEPTH)
87 #define HNS_ROCE_V1_SDB_DEPTH 0x400
88 #define HNS_ROCE_V1_ODB_DEPTH 0x400
90 #define HNS_ROCE_V1_DB_RSVD 0x80
92 #define HNS_ROCE_V1_SDB_ALEPT HNS_ROCE_V1_DB_RSVD
93 #define HNS_ROCE_V1_SDB_ALFUL (HNS_ROCE_V1_SDB_DEPTH - HNS_ROCE_V1_DB_RSVD)
94 #define HNS_ROCE_V1_ODB_ALEPT HNS_ROCE_V1_DB_RSVD
95 #define HNS_ROCE_V1_ODB_ALFUL (HNS_ROCE_V1_ODB_DEPTH - HNS_ROCE_V1_DB_RSVD)
97 #define HNS_ROCE_V1_EXT_SDB_DEPTH 0x4000
98 #define HNS_ROCE_V1_EXT_ODB_DEPTH 0x4000
99 #define HNS_ROCE_V1_EXT_SDB_ENTRY 16
100 #define HNS_ROCE_V1_EXT_ODB_ENTRY 16
101 #define HNS_ROCE_V1_EXT_SDB_SIZE \
102 (HNS_ROCE_V1_EXT_SDB_DEPTH * HNS_ROCE_V1_EXT_SDB_ENTRY)
103 #define HNS_ROCE_V1_EXT_ODB_SIZE \
104 (HNS_ROCE_V1_EXT_ODB_DEPTH * HNS_ROCE_V1_EXT_ODB_ENTRY)
106 #define HNS_ROCE_V1_EXT_SDB_ALEPT HNS_ROCE_V1_DB_RSVD
107 #define HNS_ROCE_V1_EXT_SDB_ALFUL \
108 (HNS_ROCE_V1_EXT_SDB_DEPTH - HNS_ROCE_V1_DB_RSVD)
109 #define HNS_ROCE_V1_EXT_ODB_ALEPT HNS_ROCE_V1_DB_RSVD
110 #define HNS_ROCE_V1_EXT_ODB_ALFUL \
111 (HNS_ROCE_V1_EXT_ODB_DEPTH - HNS_ROCE_V1_DB_RSVD)
113 #define HNS_ROCE_V1_FREE_MR_TIMEOUT_MSECS 50000
114 #define HNS_ROCE_V1_RECREATE_LP_QP_TIMEOUT_MSECS 10000
115 #define HNS_ROCE_V1_FREE_MR_WAIT_VALUE 5
116 #define HNS_ROCE_V1_RECREATE_LP_QP_WAIT_VALUE 20
118 #define HNS_ROCE_BT_RSV_BUF_SIZE (1 << 17)
120 #define HNS_ROCE_V1_TPTR_ENTRY_SIZE 2
121 #define HNS_ROCE_V1_TPTR_BUF_SIZE \
122 (HNS_ROCE_V1_TPTR_ENTRY_SIZE * HNS_ROCE_V1_MAX_CQ_NUM)
124 #define HNS_ROCE_ODB_POLL_MODE 0
126 #define HNS_ROCE_SDB_NORMAL_MODE 0
127 #define HNS_ROCE_SDB_EXTEND_MODE 1
129 #define HNS_ROCE_ODB_EXTEND_MODE 1
131 #define KEY_VALID 0x02
133 #define HNS_ROCE_CQE_QPN_MASK 0x3ffff
134 #define HNS_ROCE_CQE_STATUS_MASK 0x1f
135 #define HNS_ROCE_CQE_OPCODE_MASK 0xf
137 #define HNS_ROCE_CQE_SUCCESS 0x00
138 #define HNS_ROCE_CQE_SYNDROME_LOCAL_LENGTH_ERR 0x01
139 #define HNS_ROCE_CQE_SYNDROME_LOCAL_QP_OP_ERR 0x02
140 #define HNS_ROCE_CQE_SYNDROME_LOCAL_PROT_ERR 0x03
141 #define HNS_ROCE_CQE_SYNDROME_WR_FLUSH_ERR 0x04
142 #define HNS_ROCE_CQE_SYNDROME_MEM_MANAGE_OPERATE_ERR 0x05
143 #define HNS_ROCE_CQE_SYNDROME_BAD_RESP_ERR 0x06
144 #define HNS_ROCE_CQE_SYNDROME_LOCAL_ACCESS_ERR 0x07
145 #define HNS_ROCE_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR 0x08
146 #define HNS_ROCE_CQE_SYNDROME_REMOTE_ACCESS_ERR 0x09
147 #define HNS_ROCE_CQE_SYNDROME_REMOTE_OP_ERR 0x0a
148 #define HNS_ROCE_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR 0x0b
149 #define HNS_ROCE_CQE_SYNDROME_RNR_RETRY_EXC_ERR 0x0c
151 #define QP1C_CFGN_OFFSET 0x28
152 #define PHY_PORT_OFFSET 0x8
153 #define MTPT_IDX_SHIFT 16
154 #define ALL_PORT_VAL_OPEN 0x3f
155 #define POL_TIME_INTERVAL_VAL 0x80
156 #define SLEEP_TIME_INTERVAL 20
157 #define SQ_PSN_SHIFT 8
158 #define QKEY_VAL 0x80010000
159 #define SDB_INV_CNT_OFFSET 8
161 #define HNS_ROCE_CEQ_DEFAULT_INTERVAL 0x10
162 #define HNS_ROCE_CEQ_DEFAULT_BURST_NUM 0x10
164 #define HNS_ROCE_INT_MASK_DISABLE 0
165 #define HNS_ROCE_INT_MASK_ENABLE 1
167 #define CEQ_REG_OFFSET 0x18
169 #define HNS_ROCE_CEQE_CEQE_COMP_OWNER_S 0
171 #define HNS_ROCE_V1_CONS_IDX_M GENMASK(15, 0)
173 #define HNS_ROCE_CEQE_CEQE_COMP_CQN_S 16
174 #define HNS_ROCE_CEQE_CEQE_COMP_CQN_M GENMASK(31, 16)
176 #define HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S 16
177 #define HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M GENMASK(23, 16)
179 #define HNS_ROCE_AEQE_U32_4_EVENT_SUB_TYPE_S 24
180 #define HNS_ROCE_AEQE_U32_4_EVENT_SUB_TYPE_M GENMASK(30, 24)
182 #define HNS_ROCE_AEQE_U32_4_OWNER_S 31
184 #define HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S 0
185 #define HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M GENMASK(23, 0)
187 #define HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_S 25
188 #define HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_M GENMASK(27, 25)
190 #define HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S 0
191 #define HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M GENMASK(15, 0)
193 #define HNS_ROCE_AEQE_EVENT_CE_EVENT_CEQE_CEQN_S 0
194 #define HNS_ROCE_AEQE_EVENT_CE_EVENT_CEQE_CEQN_M GENMASK(4, 0)
196 struct hns_roce_cq_context {
197 __le32 cqc_byte_4;
198 __le32 cq_bt_l;
199 __le32 cqc_byte_12;
200 __le32 cur_cqe_ba0_l;
201 __le32 cqc_byte_20;
202 __le32 cqe_tptr_addr_l;
203 __le32 cur_cqe_ba1_l;
204 __le32 cqc_byte_32;
207 #define CQ_CONTEXT_CQC_BYTE_4_CQC_STATE_S 0
208 #define CQ_CONTEXT_CQC_BYTE_4_CQC_STATE_M \
209 (((1UL << 2) - 1) << CQ_CONTEXT_CQC_BYTE_4_CQC_STATE_S)
211 #define CQ_CONTEXT_CQC_BYTE_4_CQN_S 16
212 #define CQ_CONTEXT_CQC_BYTE_4_CQN_M \
213 (((1UL << 16) - 1) << CQ_CONTEXT_CQC_BYTE_4_CQN_S)
215 #define CQ_CONTEXT_CQC_BYTE_12_CQ_BT_H_S 0
216 #define CQ_CONTEXT_CQC_BYTE_12_CQ_BT_H_M \
217 (((1UL << 17) - 1) << CQ_CONTEXT_CQC_BYTE_12_CQ_BT_H_S)
219 #define CQ_CONTEXT_CQC_BYTE_12_CQ_CQE_SHIFT_S 20
220 #define CQ_CONTEXT_CQC_BYTE_12_CQ_CQE_SHIFT_M \
221 (((1UL << 4) - 1) << CQ_CONTEXT_CQC_BYTE_12_CQ_CQE_SHIFT_S)
223 #define CQ_CONTEXT_CQC_BYTE_12_CEQN_S 24
224 #define CQ_CONTEXT_CQC_BYTE_12_CEQN_M \
225 (((1UL << 5) - 1) << CQ_CONTEXT_CQC_BYTE_12_CEQN_S)
227 #define CQ_CONTEXT_CQC_BYTE_20_CUR_CQE_BA0_H_S 0
228 #define CQ_CONTEXT_CQC_BYTE_20_CUR_CQE_BA0_H_M \
229 (((1UL << 5) - 1) << CQ_CONTEXT_CQC_BYTE_20_CUR_CQE_BA0_H_S)
231 #define CQ_CONTEXT_CQC_BYTE_20_CQ_CUR_INDEX_S 16
232 #define CQ_CONTEXT_CQC_BYTE_20_CQ_CUR_INDEX_M \
233 (((1UL << 16) - 1) << CQ_CONTEXT_CQC_BYTE_20_CQ_CUR_INDEX_S)
235 #define CQ_CONTEXT_CQC_BYTE_20_CQE_TPTR_ADDR_H_S 8
236 #define CQ_CONTEXT_CQC_BYTE_20_CQE_TPTR_ADDR_H_M \
237 (((1UL << 5) - 1) << CQ_CONTEXT_CQC_BYTE_20_CQE_TPTR_ADDR_H_S)
239 #define CQ_CONTEXT_CQC_BYTE_32_CUR_CQE_BA1_H_S 0
240 #define CQ_CONTEXT_CQC_BYTE_32_CUR_CQE_BA1_H_M \
241 (((1UL << 5) - 1) << CQ_CONTEXT_CQC_BYTE_32_CUR_CQE_BA1_H_S)
243 #define CQ_CONTEXT_CQC_BYTE_32_SE_FLAG_S 9
245 #define CQ_CONTEXT_CQC_BYTE_32_CE_FLAG_S 8
246 #define CQ_CONTEXT_CQC_BYTE_32_NOTIFICATION_FLAG_S 14
247 #define CQ_CQNTEXT_CQC_BYTE_32_TYPE_OF_COMPLETION_NOTIFICATION_S 15
249 #define CQ_CONTEXT_CQC_BYTE_32_CQ_CONS_IDX_S 16
250 #define CQ_CONTEXT_CQC_BYTE_32_CQ_CONS_IDX_M \
251 (((1UL << 16) - 1) << CQ_CONTEXT_CQC_BYTE_32_CQ_CONS_IDX_S)
253 struct hns_roce_cqe {
254 __le32 cqe_byte_4;
255 union {
256 __le32 r_key;
257 __le32 immediate_data;
259 __le32 byte_cnt;
260 __le32 cqe_byte_16;
261 __le32 cqe_byte_20;
262 __le32 s_mac_l;
263 __le32 cqe_byte_28;
264 __le32 reserved;
267 #define CQE_BYTE_4_OWNER_S 7
268 #define CQE_BYTE_4_SQ_RQ_FLAG_S 14
270 #define CQE_BYTE_4_STATUS_OF_THE_OPERATION_S 8
271 #define CQE_BYTE_4_STATUS_OF_THE_OPERATION_M \
272 (((1UL << 5) - 1) << CQE_BYTE_4_STATUS_OF_THE_OPERATION_S)
274 #define CQE_BYTE_4_WQE_INDEX_S 16
275 #define CQE_BYTE_4_WQE_INDEX_M (((1UL << 14) - 1) << CQE_BYTE_4_WQE_INDEX_S)
277 #define CQE_BYTE_4_OPERATION_TYPE_S 0
278 #define CQE_BYTE_4_OPERATION_TYPE_M \
279 (((1UL << 4) - 1) << CQE_BYTE_4_OPERATION_TYPE_S)
281 #define CQE_BYTE_4_IMM_INDICATOR_S 15
283 #define CQE_BYTE_16_LOCAL_QPN_S 0
284 #define CQE_BYTE_16_LOCAL_QPN_M (((1UL << 24) - 1) << CQE_BYTE_16_LOCAL_QPN_S)
286 #define CQE_BYTE_20_PORT_NUM_S 26
287 #define CQE_BYTE_20_PORT_NUM_M (((1UL << 3) - 1) << CQE_BYTE_20_PORT_NUM_S)
289 #define CQE_BYTE_20_SL_S 24
290 #define CQE_BYTE_20_SL_M (((1UL << 2) - 1) << CQE_BYTE_20_SL_S)
292 #define CQE_BYTE_20_REMOTE_QPN_S 0
293 #define CQE_BYTE_20_REMOTE_QPN_M \
294 (((1UL << 24) - 1) << CQE_BYTE_20_REMOTE_QPN_S)
296 #define CQE_BYTE_20_GRH_PRESENT_S 29
298 #define CQE_BYTE_28_P_KEY_IDX_S 16
299 #define CQE_BYTE_28_P_KEY_IDX_M (((1UL << 16) - 1) << CQE_BYTE_28_P_KEY_IDX_S)
301 #define CQ_DB_REQ_NOT_SOL 0
302 #define CQ_DB_REQ_NOT (1 << 16)
304 struct hns_roce_v1_mpt_entry {
305 __le32 mpt_byte_4;
306 __le32 pbl_addr_l;
307 __le32 mpt_byte_12;
308 __le32 virt_addr_l;
309 __le32 virt_addr_h;
310 __le32 length;
311 __le32 mpt_byte_28;
312 __le32 pa0_l;
313 __le32 mpt_byte_36;
314 __le32 mpt_byte_40;
315 __le32 mpt_byte_44;
316 __le32 mpt_byte_48;
317 __le32 pa4_l;
318 __le32 mpt_byte_56;
319 __le32 mpt_byte_60;
320 __le32 mpt_byte_64;
323 #define MPT_BYTE_4_KEY_STATE_S 0
324 #define MPT_BYTE_4_KEY_STATE_M (((1UL << 2) - 1) << MPT_BYTE_4_KEY_STATE_S)
326 #define MPT_BYTE_4_KEY_S 8
327 #define MPT_BYTE_4_KEY_M (((1UL << 8) - 1) << MPT_BYTE_4_KEY_S)
329 #define MPT_BYTE_4_PAGE_SIZE_S 16
330 #define MPT_BYTE_4_PAGE_SIZE_M (((1UL << 2) - 1) << MPT_BYTE_4_PAGE_SIZE_S)
332 #define MPT_BYTE_4_MW_TYPE_S 20
334 #define MPT_BYTE_4_MW_BIND_ENABLE_S 21
336 #define MPT_BYTE_4_OWN_S 22
338 #define MPT_BYTE_4_MEMORY_LOCATION_TYPE_S 24
339 #define MPT_BYTE_4_MEMORY_LOCATION_TYPE_M \
340 (((1UL << 2) - 1) << MPT_BYTE_4_MEMORY_LOCATION_TYPE_S)
342 #define MPT_BYTE_4_REMOTE_ATOMIC_S 26
343 #define MPT_BYTE_4_LOCAL_WRITE_S 27
344 #define MPT_BYTE_4_REMOTE_WRITE_S 28
345 #define MPT_BYTE_4_REMOTE_READ_S 29
346 #define MPT_BYTE_4_REMOTE_INVAL_ENABLE_S 30
347 #define MPT_BYTE_4_ADDRESS_TYPE_S 31
349 #define MPT_BYTE_12_PBL_ADDR_H_S 0
350 #define MPT_BYTE_12_PBL_ADDR_H_M \
351 (((1UL << 17) - 1) << MPT_BYTE_12_PBL_ADDR_H_S)
353 #define MPT_BYTE_12_MW_BIND_COUNTER_S 17
354 #define MPT_BYTE_12_MW_BIND_COUNTER_M \
355 (((1UL << 15) - 1) << MPT_BYTE_12_MW_BIND_COUNTER_S)
357 #define MPT_BYTE_28_PD_S 0
358 #define MPT_BYTE_28_PD_M (((1UL << 16) - 1) << MPT_BYTE_28_PD_S)
360 #define MPT_BYTE_28_L_KEY_IDX_L_S 16
361 #define MPT_BYTE_28_L_KEY_IDX_L_M \
362 (((1UL << 16) - 1) << MPT_BYTE_28_L_KEY_IDX_L_S)
364 #define MPT_BYTE_36_PA0_H_S 0
365 #define MPT_BYTE_36_PA0_H_M (((1UL << 5) - 1) << MPT_BYTE_36_PA0_H_S)
367 #define MPT_BYTE_36_PA1_L_S 8
368 #define MPT_BYTE_36_PA1_L_M (((1UL << 24) - 1) << MPT_BYTE_36_PA1_L_S)
370 #define MPT_BYTE_40_PA1_H_S 0
371 #define MPT_BYTE_40_PA1_H_M (((1UL << 13) - 1) << MPT_BYTE_40_PA1_H_S)
373 #define MPT_BYTE_40_PA2_L_S 16
374 #define MPT_BYTE_40_PA2_L_M (((1UL << 16) - 1) << MPT_BYTE_40_PA2_L_S)
376 #define MPT_BYTE_44_PA2_H_S 0
377 #define MPT_BYTE_44_PA2_H_M (((1UL << 21) - 1) << MPT_BYTE_44_PA2_H_S)
379 #define MPT_BYTE_44_PA3_L_S 24
380 #define MPT_BYTE_44_PA3_L_M (((1UL << 8) - 1) << MPT_BYTE_44_PA3_L_S)
382 #define MPT_BYTE_48_PA3_H_S 0
383 #define MPT_BYTE_48_PA3_H_M (((1UL << 29) - 1) << MPT_BYTE_48_PA3_H_S)
385 #define MPT_BYTE_56_PA4_H_S 0
386 #define MPT_BYTE_56_PA4_H_M (((1UL << 5) - 1) << MPT_BYTE_56_PA4_H_S)
388 #define MPT_BYTE_56_PA5_L_S 8
389 #define MPT_BYTE_56_PA5_L_M (((1UL << 24) - 1) << MPT_BYTE_56_PA5_L_S)
391 #define MPT_BYTE_60_PA5_H_S 0
392 #define MPT_BYTE_60_PA5_H_M (((1UL << 13) - 1) << MPT_BYTE_60_PA5_H_S)
394 #define MPT_BYTE_60_PA6_L_S 16
395 #define MPT_BYTE_60_PA6_L_M (((1UL << 16) - 1) << MPT_BYTE_60_PA6_L_S)
397 #define MPT_BYTE_64_PA6_H_S 0
398 #define MPT_BYTE_64_PA6_H_M (((1UL << 21) - 1) << MPT_BYTE_64_PA6_H_S)
400 #define MPT_BYTE_64_L_KEY_IDX_H_S 24
401 #define MPT_BYTE_64_L_KEY_IDX_H_M \
402 (((1UL << 8) - 1) << MPT_BYTE_64_L_KEY_IDX_H_S)
404 struct hns_roce_wqe_ctrl_seg {
405 __le32 sgl_pa_h;
406 __le32 flag;
407 union {
408 __be32 imm_data;
409 __le32 inv_key;
411 __le32 msg_length;
414 struct hns_roce_wqe_data_seg {
415 __le64 addr;
416 __le32 lkey;
417 __le32 len;
420 struct hns_roce_wqe_raddr_seg {
421 __le32 rkey;
422 __le32 len; /* reserved */
423 __le64 raddr;
426 struct hns_roce_rq_wqe_ctrl {
427 __le32 rwqe_byte_4;
428 __le32 rocee_sgl_ba_l;
429 __le32 rwqe_byte_12;
430 __le32 reserved[5];
433 #define RQ_WQE_CTRL_RWQE_BYTE_12_RWQE_SGE_NUM_S 16
434 #define RQ_WQE_CTRL_RWQE_BYTE_12_RWQE_SGE_NUM_M \
435 (((1UL << 6) - 1) << RQ_WQE_CTRL_RWQE_BYTE_12_RWQE_SGE_NUM_S)
437 #define HNS_ROCE_QP_DESTROY_TIMEOUT_MSECS 10000
439 #define GID_LEN 16
441 struct hns_roce_ud_send_wqe {
442 __le32 dmac_h;
443 __le32 u32_8;
444 __le32 immediate_data;
446 __le32 u32_16;
447 union {
448 unsigned char dgid[GID_LEN];
449 struct {
450 __le32 u32_20;
451 __le32 u32_24;
452 __le32 u32_28;
453 __le32 u32_32;
457 __le32 u32_36;
458 __le32 u32_40;
460 __le32 va0_l;
461 __le32 va0_h;
462 __le32 l_key0;
464 __le32 va1_l;
465 __le32 va1_h;
466 __le32 l_key1;
469 #define UD_SEND_WQE_U32_4_DMAC_0_S 0
470 #define UD_SEND_WQE_U32_4_DMAC_0_M \
471 (((1UL << 8) - 1) << UD_SEND_WQE_U32_4_DMAC_0_S)
473 #define UD_SEND_WQE_U32_4_DMAC_1_S 8
474 #define UD_SEND_WQE_U32_4_DMAC_1_M \
475 (((1UL << 8) - 1) << UD_SEND_WQE_U32_4_DMAC_1_S)
477 #define UD_SEND_WQE_U32_4_DMAC_2_S 16
478 #define UD_SEND_WQE_U32_4_DMAC_2_M \
479 (((1UL << 8) - 1) << UD_SEND_WQE_U32_4_DMAC_2_S)
481 #define UD_SEND_WQE_U32_4_DMAC_3_S 24
482 #define UD_SEND_WQE_U32_4_DMAC_3_M \
483 (((1UL << 8) - 1) << UD_SEND_WQE_U32_4_DMAC_3_S)
485 #define UD_SEND_WQE_U32_8_DMAC_4_S 0
486 #define UD_SEND_WQE_U32_8_DMAC_4_M \
487 (((1UL << 8) - 1) << UD_SEND_WQE_U32_8_DMAC_4_S)
489 #define UD_SEND_WQE_U32_8_DMAC_5_S 8
490 #define UD_SEND_WQE_U32_8_DMAC_5_M \
491 (((1UL << 8) - 1) << UD_SEND_WQE_U32_8_DMAC_5_S)
493 #define UD_SEND_WQE_U32_8_LOOPBACK_INDICATOR_S 22
495 #define UD_SEND_WQE_U32_8_OPERATION_TYPE_S 16
496 #define UD_SEND_WQE_U32_8_OPERATION_TYPE_M \
497 (((1UL << 4) - 1) << UD_SEND_WQE_U32_8_OPERATION_TYPE_S)
499 #define UD_SEND_WQE_U32_8_NUMBER_OF_DATA_SEG_S 24
500 #define UD_SEND_WQE_U32_8_NUMBER_OF_DATA_SEG_M \
501 (((1UL << 6) - 1) << UD_SEND_WQE_U32_8_NUMBER_OF_DATA_SEG_S)
503 #define UD_SEND_WQE_U32_8_SEND_GL_ROUTING_HDR_FLAG_S 31
505 #define UD_SEND_WQE_U32_16_DEST_QP_S 0
506 #define UD_SEND_WQE_U32_16_DEST_QP_M \
507 (((1UL << 24) - 1) << UD_SEND_WQE_U32_16_DEST_QP_S)
509 #define UD_SEND_WQE_U32_16_MAX_STATIC_RATE_S 24
510 #define UD_SEND_WQE_U32_16_MAX_STATIC_RATE_M \
511 (((1UL << 8) - 1) << UD_SEND_WQE_U32_16_MAX_STATIC_RATE_S)
513 #define UD_SEND_WQE_U32_36_FLOW_LABEL_S 0
514 #define UD_SEND_WQE_U32_36_FLOW_LABEL_M \
515 (((1UL << 20) - 1) << UD_SEND_WQE_U32_36_FLOW_LABEL_S)
517 #define UD_SEND_WQE_U32_36_PRIORITY_S 20
518 #define UD_SEND_WQE_U32_36_PRIORITY_M \
519 (((1UL << 4) - 1) << UD_SEND_WQE_U32_36_PRIORITY_S)
521 #define UD_SEND_WQE_U32_36_SGID_INDEX_S 24
522 #define UD_SEND_WQE_U32_36_SGID_INDEX_M \
523 (((1UL << 8) - 1) << UD_SEND_WQE_U32_36_SGID_INDEX_S)
525 #define UD_SEND_WQE_U32_40_HOP_LIMIT_S 0
526 #define UD_SEND_WQE_U32_40_HOP_LIMIT_M \
527 (((1UL << 8) - 1) << UD_SEND_WQE_U32_40_HOP_LIMIT_S)
529 #define UD_SEND_WQE_U32_40_TRAFFIC_CLASS_S 8
530 #define UD_SEND_WQE_U32_40_TRAFFIC_CLASS_M \
531 (((1UL << 8) - 1) << UD_SEND_WQE_U32_40_TRAFFIC_CLASS_S)
533 struct hns_roce_sqp_context {
534 __le32 qp1c_bytes_4;
535 __le32 sq_rq_bt_l;
536 __le32 qp1c_bytes_12;
537 __le32 qp1c_bytes_16;
538 __le32 qp1c_bytes_20;
539 __le32 cur_rq_wqe_ba_l;
540 __le32 qp1c_bytes_28;
541 __le32 qp1c_bytes_32;
542 __le32 cur_sq_wqe_ba_l;
543 __le32 qp1c_bytes_40;
546 #define QP1C_BYTES_4_QP_STATE_S 0
547 #define QP1C_BYTES_4_QP_STATE_M \
548 (((1UL << 3) - 1) << QP1C_BYTES_4_QP_STATE_S)
550 #define QP1C_BYTES_4_SQ_WQE_SHIFT_S 8
551 #define QP1C_BYTES_4_SQ_WQE_SHIFT_M \
552 (((1UL << 4) - 1) << QP1C_BYTES_4_SQ_WQE_SHIFT_S)
554 #define QP1C_BYTES_4_RQ_WQE_SHIFT_S 12
555 #define QP1C_BYTES_4_RQ_WQE_SHIFT_M \
556 (((1UL << 4) - 1) << QP1C_BYTES_4_RQ_WQE_SHIFT_S)
558 #define QP1C_BYTES_4_PD_S 16
559 #define QP1C_BYTES_4_PD_M (((1UL << 16) - 1) << QP1C_BYTES_4_PD_S)
561 #define QP1C_BYTES_12_SQ_RQ_BT_H_S 0
562 #define QP1C_BYTES_12_SQ_RQ_BT_H_M \
563 (((1UL << 17) - 1) << QP1C_BYTES_12_SQ_RQ_BT_H_S)
565 #define QP1C_BYTES_16_RQ_HEAD_S 0
566 #define QP1C_BYTES_16_RQ_HEAD_M (((1UL << 15) - 1) << QP1C_BYTES_16_RQ_HEAD_S)
568 #define QP1C_BYTES_16_PORT_NUM_S 16
569 #define QP1C_BYTES_16_PORT_NUM_M \
570 (((1UL << 3) - 1) << QP1C_BYTES_16_PORT_NUM_S)
572 #define QP1C_BYTES_16_SIGNALING_TYPE_S 27
573 #define QP1C_BYTES_16_LOCAL_ENABLE_E2E_CREDIT_S 28
574 #define QP1C_BYTES_16_RQ_BA_FLG_S 29
575 #define QP1C_BYTES_16_SQ_BA_FLG_S 30
576 #define QP1C_BYTES_16_QP1_ERR_S 31
578 #define QP1C_BYTES_20_SQ_HEAD_S 0
579 #define QP1C_BYTES_20_SQ_HEAD_M (((1UL << 15) - 1) << QP1C_BYTES_20_SQ_HEAD_S)
581 #define QP1C_BYTES_20_PKEY_IDX_S 16
582 #define QP1C_BYTES_20_PKEY_IDX_M \
583 (((1UL << 16) - 1) << QP1C_BYTES_20_PKEY_IDX_S)
585 #define QP1C_BYTES_28_CUR_RQ_WQE_BA_H_S 0
586 #define QP1C_BYTES_28_CUR_RQ_WQE_BA_H_M \
587 (((1UL << 5) - 1) << QP1C_BYTES_28_CUR_RQ_WQE_BA_H_S)
589 #define QP1C_BYTES_28_RQ_CUR_IDX_S 16
590 #define QP1C_BYTES_28_RQ_CUR_IDX_M \
591 (((1UL << 15) - 1) << QP1C_BYTES_28_RQ_CUR_IDX_S)
593 #define QP1C_BYTES_32_TX_CQ_NUM_S 0
594 #define QP1C_BYTES_32_TX_CQ_NUM_M \
595 (((1UL << 16) - 1) << QP1C_BYTES_32_TX_CQ_NUM_S)
597 #define QP1C_BYTES_32_RX_CQ_NUM_S 16
598 #define QP1C_BYTES_32_RX_CQ_NUM_M \
599 (((1UL << 16) - 1) << QP1C_BYTES_32_RX_CQ_NUM_S)
601 #define QP1C_BYTES_40_CUR_SQ_WQE_BA_H_S 0
602 #define QP1C_BYTES_40_CUR_SQ_WQE_BA_H_M \
603 (((1UL << 5) - 1) << QP1C_BYTES_40_CUR_SQ_WQE_BA_H_S)
605 #define QP1C_BYTES_40_SQ_CUR_IDX_S 16
606 #define QP1C_BYTES_40_SQ_CUR_IDX_M \
607 (((1UL << 15) - 1) << QP1C_BYTES_40_SQ_CUR_IDX_S)
609 #define HNS_ROCE_WQE_INLINE (1UL<<31)
610 #define HNS_ROCE_WQE_SE (1UL<<30)
612 #define HNS_ROCE_WQE_SGE_NUM_BIT 24
613 #define HNS_ROCE_WQE_IMM (1UL<<23)
614 #define HNS_ROCE_WQE_FENCE (1UL<<21)
615 #define HNS_ROCE_WQE_CQ_NOTIFY (1UL<<20)
617 #define HNS_ROCE_WQE_OPCODE_SEND (0<<16)
618 #define HNS_ROCE_WQE_OPCODE_RDMA_READ (1<<16)
619 #define HNS_ROCE_WQE_OPCODE_RDMA_WRITE (2<<16)
620 #define HNS_ROCE_WQE_OPCODE_LOCAL_INV (4<<16)
621 #define HNS_ROCE_WQE_OPCODE_UD_SEND (7<<16)
622 #define HNS_ROCE_WQE_OPCODE_MASK (15<<16)
624 struct hns_roce_qp_context {
625 __le32 qpc_bytes_4;
626 __le32 qpc_bytes_8;
627 __le32 qpc_bytes_12;
628 __le32 qpc_bytes_16;
629 __le32 sq_rq_bt_l;
630 __le32 qpc_bytes_24;
631 __le32 irrl_ba_l;
632 __le32 qpc_bytes_32;
633 __le32 qpc_bytes_36;
634 __le32 dmac_l;
635 __le32 qpc_bytes_44;
636 __le32 qpc_bytes_48;
637 u8 dgid[16];
638 __le32 qpc_bytes_68;
639 __le32 cur_rq_wqe_ba_l;
640 __le32 qpc_bytes_76;
641 __le32 rx_rnr_time;
642 __le32 qpc_bytes_84;
643 __le32 qpc_bytes_88;
644 union {
645 __le32 rx_sge_len;
646 __le32 dma_length;
648 union {
649 __le32 rx_sge_num;
650 __le32 rx_send_pktn;
651 __le32 r_key;
653 __le32 va_l;
654 __le32 va_h;
655 __le32 qpc_bytes_108;
656 __le32 qpc_bytes_112;
657 __le32 rx_cur_sq_wqe_ba_l;
658 __le32 qpc_bytes_120;
659 __le32 qpc_bytes_124;
660 __le32 qpc_bytes_128;
661 __le32 qpc_bytes_132;
662 __le32 qpc_bytes_136;
663 __le32 qpc_bytes_140;
664 __le32 qpc_bytes_144;
665 __le32 qpc_bytes_148;
666 union {
667 __le32 rnr_retry;
668 __le32 ack_time;
670 __le32 qpc_bytes_156;
671 __le32 pkt_use_len;
672 __le32 qpc_bytes_164;
673 __le32 qpc_bytes_168;
674 union {
675 __le32 sge_use_len;
676 __le32 pa_use_len;
678 __le32 qpc_bytes_176;
679 __le32 qpc_bytes_180;
680 __le32 tx_cur_sq_wqe_ba_l;
681 __le32 qpc_bytes_188;
682 __le32 rvd21;
685 #define QP_CONTEXT_QPC_BYTES_4_TRANSPORT_SERVICE_TYPE_S 0
686 #define QP_CONTEXT_QPC_BYTES_4_TRANSPORT_SERVICE_TYPE_M \
687 (((1UL << 3) - 1) << QP_CONTEXT_QPC_BYTES_4_TRANSPORT_SERVICE_TYPE_S)
689 #define QP_CONTEXT_QPC_BYTE_4_ENABLE_FPMR_S 3
690 #define QP_CONTEXT_QPC_BYTE_4_RDMA_READ_ENABLE_S 4
691 #define QP_CONTEXT_QPC_BYTE_4_RDMA_WRITE_ENABLE_S 5
692 #define QP_CONTEXT_QPC_BYTE_4_ATOMIC_OPERATION_ENABLE_S 6
693 #define QP_CONTEXT_QPC_BYTE_4_RDMAR_USE_S 7
695 #define QP_CONTEXT_QPC_BYTES_4_SQ_WQE_SHIFT_S 8
696 #define QP_CONTEXT_QPC_BYTES_4_SQ_WQE_SHIFT_M \
697 (((1UL << 4) - 1) << QP_CONTEXT_QPC_BYTES_4_SQ_WQE_SHIFT_S)
699 #define QP_CONTEXT_QPC_BYTES_4_RQ_WQE_SHIFT_S 12
700 #define QP_CONTEXT_QPC_BYTES_4_RQ_WQE_SHIFT_M \
701 (((1UL << 4) - 1) << QP_CONTEXT_QPC_BYTES_4_RQ_WQE_SHIFT_S)
703 #define QP_CONTEXT_QPC_BYTES_4_PD_S 16
704 #define QP_CONTEXT_QPC_BYTES_4_PD_M \
705 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_4_PD_S)
707 #define QP_CONTEXT_QPC_BYTES_8_TX_COMPLETION_S 0
708 #define QP_CONTEXT_QPC_BYTES_8_TX_COMPLETION_M \
709 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_8_TX_COMPLETION_S)
711 #define QP_CONTEXT_QPC_BYTES_8_RX_COMPLETION_S 16
712 #define QP_CONTEXT_QPC_BYTES_8_RX_COMPLETION_M \
713 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_8_RX_COMPLETION_S)
715 #define QP_CONTEXT_QPC_BYTES_12_SRQ_NUMBER_S 0
716 #define QP_CONTEXT_QPC_BYTES_12_SRQ_NUMBER_M \
717 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_12_SRQ_NUMBER_S)
719 #define QP_CONTEXT_QPC_BYTES_12_P_KEY_INDEX_S 16
720 #define QP_CONTEXT_QPC_BYTES_12_P_KEY_INDEX_M \
721 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_12_P_KEY_INDEX_S)
723 #define QP_CONTEXT_QPC_BYTES_16_QP_NUM_S 0
724 #define QP_CONTEXT_QPC_BYTES_16_QP_NUM_M \
725 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_16_QP_NUM_S)
727 #define QP_CONTEXT_QPC_BYTES_24_SQ_RQ_BT_H_S 0
728 #define QP_CONTEXT_QPC_BYTES_24_SQ_RQ_BT_H_M \
729 (((1UL << 17) - 1) << QP_CONTEXT_QPC_BYTES_24_SQ_RQ_BT_H_S)
731 #define QP_CONTEXT_QPC_BYTES_24_MINIMUM_RNR_NAK_TIMER_S 18
732 #define QP_CONTEXT_QPC_BYTES_24_MINIMUM_RNR_NAK_TIMER_M \
733 (((1UL << 5) - 1) << QP_CONTEXT_QPC_BYTES_24_MINIMUM_RNR_NAK_TIMER_S)
735 #define QP_CONTEXT_QPC_BYTE_24_REMOTE_ENABLE_E2E_CREDITS_S 23
737 #define QP_CONTEXT_QPC_BYTES_32_IRRL_BA_H_S 0
738 #define QP_CONTEXT_QPC_BYTES_32_IRRL_BA_H_M \
739 (((1UL << 17) - 1) << QP_CONTEXT_QPC_BYTES_32_IRRL_BA_H_S)
741 #define QP_CONTEXT_QPC_BYTES_32_MIG_STATE_S 18
742 #define QP_CONTEXT_QPC_BYTES_32_MIG_STATE_M \
743 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_32_MIG_STATE_S)
745 #define QP_CONTEXT_QPC_BYTE_32_LOCAL_ENABLE_E2E_CREDITS_S 20
746 #define QP_CONTEXT_QPC_BYTE_32_SIGNALING_TYPE_S 21
747 #define QP_CONTEXT_QPC_BYTE_32_LOOPBACK_INDICATOR_S 22
748 #define QP_CONTEXT_QPC_BYTE_32_GLOBAL_HEADER_S 23
750 #define QP_CONTEXT_QPC_BYTES_32_RESPONDER_RESOURCES_S 24
751 #define QP_CONTEXT_QPC_BYTES_32_RESPONDER_RESOURCES_M \
752 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_32_RESPONDER_RESOURCES_S)
754 #define QP_CONTEXT_QPC_BYTES_36_DEST_QP_S 0
755 #define QP_CONTEXT_QPC_BYTES_36_DEST_QP_M \
756 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_36_DEST_QP_S)
758 #define QP_CONTEXT_QPC_BYTES_36_SGID_INDEX_S 24
759 #define QP_CONTEXT_QPC_BYTES_36_SGID_INDEX_M \
760 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_36_SGID_INDEX_S)
762 #define QP_CONTEXT_QPC_BYTES_44_DMAC_H_S 0
763 #define QP_CONTEXT_QPC_BYTES_44_DMAC_H_M \
764 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_44_DMAC_H_S)
766 #define QP_CONTEXT_QPC_BYTES_44_MAXIMUM_STATIC_RATE_S 16
767 #define QP_CONTEXT_QPC_BYTES_44_MAXIMUM_STATIC_RATE_M \
768 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_44_MAXIMUM_STATIC_RATE_S)
770 #define QP_CONTEXT_QPC_BYTES_44_HOPLMT_S 24
771 #define QP_CONTEXT_QPC_BYTES_44_HOPLMT_M \
772 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_44_HOPLMT_S)
774 #define QP_CONTEXT_QPC_BYTES_48_FLOWLABEL_S 0
775 #define QP_CONTEXT_QPC_BYTES_48_FLOWLABEL_M \
776 (((1UL << 20) - 1) << QP_CONTEXT_QPC_BYTES_48_FLOWLABEL_S)
778 #define QP_CONTEXT_QPC_BYTES_48_TCLASS_S 20
779 #define QP_CONTEXT_QPC_BYTES_48_TCLASS_M \
780 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_48_TCLASS_S)
782 #define QP_CONTEXT_QPC_BYTES_48_MTU_S 28
783 #define QP_CONTEXT_QPC_BYTES_48_MTU_M \
784 (((1UL << 4) - 1) << QP_CONTEXT_QPC_BYTES_48_MTU_S)
786 #define QP_CONTEXT_QPC_BYTES_68_RQ_HEAD_S 0
787 #define QP_CONTEXT_QPC_BYTES_68_RQ_HEAD_M \
788 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_68_RQ_HEAD_S)
790 #define QP_CONTEXT_QPC_BYTES_68_RQ_CUR_INDEX_S 16
791 #define QP_CONTEXT_QPC_BYTES_68_RQ_CUR_INDEX_M \
792 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_68_RQ_CUR_INDEX_S)
794 #define QP_CONTEXT_QPC_BYTES_76_CUR_RQ_WQE_BA_H_S 0
795 #define QP_CONTEXT_QPC_BYTES_76_CUR_RQ_WQE_BA_H_M \
796 (((1UL << 5) - 1) << QP_CONTEXT_QPC_BYTES_76_CUR_RQ_WQE_BA_H_S)
798 #define QP_CONTEXT_QPC_BYTES_76_RX_REQ_MSN_S 8
799 #define QP_CONTEXT_QPC_BYTES_76_RX_REQ_MSN_M \
800 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_76_RX_REQ_MSN_S)
802 #define QP_CONTEXT_QPC_BYTES_84_LAST_ACK_PSN_S 0
803 #define QP_CONTEXT_QPC_BYTES_84_LAST_ACK_PSN_M \
804 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_84_LAST_ACK_PSN_S)
806 #define QP_CONTEXT_QPC_BYTES_84_TRRL_HEAD_S 24
807 #define QP_CONTEXT_QPC_BYTES_84_TRRL_HEAD_M \
808 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_84_TRRL_HEAD_S)
810 #define QP_CONTEXT_QPC_BYTES_88_RX_REQ_EPSN_S 0
811 #define QP_CONTEXT_QPC_BYTES_88_RX_REQ_EPSN_M \
812 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_88_RX_REQ_EPSN_S)
814 #define QP_CONTEXT_QPC_BYTES_88_RX_REQ_PSN_ERR_FLAG_S 24
815 #define QP_CONTEXT_QPC_BYTES_88_RX_LAST_OPCODE_FLG_S 25
817 #define QP_CONTEXT_QPC_BYTES_88_RQ_REQ_LAST_OPERATION_TYPE_S 26
818 #define QP_CONTEXT_QPC_BYTES_88_RQ_REQ_LAST_OPERATION_TYPE_M \
819 (((1UL << 2) - 1) << \
820 QP_CONTEXT_QPC_BYTES_88_RQ_REQ_LAST_OPERATION_TYPE_S)
822 #define QP_CONTEXT_QPC_BYTES_88_RQ_REQ_RDMA_WR_FLAG_S 29
823 #define QP_CONTEXT_QPC_BYTES_88_RQ_REQ_RDMA_WR_FLAG_M \
824 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_88_RQ_REQ_RDMA_WR_FLAG_S)
826 #define QP_CONTEXT_QPC_BYTES_108_TRRL_SDB_PSN_S 0
827 #define QP_CONTEXT_QPC_BYTES_108_TRRL_SDB_PSN_M \
828 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_108_TRRL_SDB_PSN_S)
830 #define QP_CONTEXT_QPC_BYTES_108_TRRL_SDB_PSN_FLG_S 24
831 #define QP_CONTEXT_QPC_BYTES_108_TRRL_TDB_PSN_FLG_S 25
833 #define QP_CONTEXT_QPC_BYTES_112_TRRL_TDB_PSN_S 0
834 #define QP_CONTEXT_QPC_BYTES_112_TRRL_TDB_PSN_M \
835 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_112_TRRL_TDB_PSN_S)
837 #define QP_CONTEXT_QPC_BYTES_112_TRRL_TAIL_S 24
838 #define QP_CONTEXT_QPC_BYTES_112_TRRL_TAIL_M \
839 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_112_TRRL_TAIL_S)
841 #define QP_CONTEXT_QPC_BYTES_120_RX_CUR_SQ_WQE_BA_H_S 0
842 #define QP_CONTEXT_QPC_BYTES_120_RX_CUR_SQ_WQE_BA_H_M \
843 (((1UL << 5) - 1) << QP_CONTEXT_QPC_BYTES_120_RX_CUR_SQ_WQE_BA_H_S)
845 #define QP_CONTEXT_QPC_BYTES_124_RX_ACK_MSN_S 0
846 #define QP_CONTEXT_QPC_BYTES_124_RX_ACK_MSN_M \
847 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_124_RX_ACK_MSN_S)
849 #define QP_CONTEXT_QPC_BYTES_124_IRRL_MSG_IDX_S 16
850 #define QP_CONTEXT_QPC_BYTES_124_IRRL_MSG_IDX_M \
851 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_124_IRRL_MSG_IDX_S)
853 #define QP_CONTEXT_QPC_BYTES_128_RX_ACK_EPSN_S 0
854 #define QP_CONTEXT_QPC_BYTES_128_RX_ACK_EPSN_M \
855 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_128_RX_ACK_EPSN_S)
857 #define QP_CONTEXT_QPC_BYTES_128_RX_ACK_PSN_ERR_FLG_S 24
859 #define QP_CONTEXT_QPC_BYTES_128_ACK_LAST_OPERATION_TYPE_S 25
860 #define QP_CONTEXT_QPC_BYTES_128_ACK_LAST_OPERATION_TYPE_M \
861 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_128_ACK_LAST_OPERATION_TYPE_S)
863 #define QP_CONTEXT_QPC_BYTES_128_IRRL_PSN_VLD_FLG_S 27
865 #define QP_CONTEXT_QPC_BYTES_132_IRRL_PSN_S 0
866 #define QP_CONTEXT_QPC_BYTES_132_IRRL_PSN_M \
867 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_132_IRRL_PSN_S)
869 #define QP_CONTEXT_QPC_BYTES_132_IRRL_TAIL_S 24
870 #define QP_CONTEXT_QPC_BYTES_132_IRRL_TAIL_M \
871 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_132_IRRL_TAIL_S)
873 #define QP_CONTEXT_QPC_BYTES_136_RETRY_MSG_PSN_S 0
874 #define QP_CONTEXT_QPC_BYTES_136_RETRY_MSG_PSN_M \
875 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_136_RETRY_MSG_PSN_S)
877 #define QP_CONTEXT_QPC_BYTES_136_RETRY_MSG_FPKT_PSN_L_S 24
878 #define QP_CONTEXT_QPC_BYTES_136_RETRY_MSG_FPKT_PSN_L_M \
879 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_136_RETRY_MSG_FPKT_PSN_L_S)
881 #define QP_CONTEXT_QPC_BYTES_140_RETRY_MSG_FPKT_PSN_H_S 0
882 #define QP_CONTEXT_QPC_BYTES_140_RETRY_MSG_FPKT_PSN_H_M \
883 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_140_RETRY_MSG_FPKT_PSN_H_S)
885 #define QP_CONTEXT_QPC_BYTES_140_RETRY_MSG_MSN_S 16
886 #define QP_CONTEXT_QPC_BYTES_140_RETRY_MSG_MSN_M \
887 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_140_RETRY_MSG_MSN_S)
889 #define QP_CONTEXT_QPC_BYTES_140_RNR_RETRY_FLG_S 31
891 #define QP_CONTEXT_QPC_BYTES_144_QP_STATE_S 0
892 #define QP_CONTEXT_QPC_BYTES_144_QP_STATE_M \
893 (((1UL << 3) - 1) << QP_CONTEXT_QPC_BYTES_144_QP_STATE_S)
895 #define QP_CONTEXT_QPC_BYTES_148_CHECK_FLAG_S 0
896 #define QP_CONTEXT_QPC_BYTES_148_CHECK_FLAG_M \
897 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_148_CHECK_FLAG_S)
899 #define QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_S 2
900 #define QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_M \
901 (((1UL << 3) - 1) << QP_CONTEXT_QPC_BYTES_148_RETRY_COUNT_S)
903 #define QP_CONTEXT_QPC_BYTES_148_RNR_RETRY_COUNT_S 5
904 #define QP_CONTEXT_QPC_BYTES_148_RNR_RETRY_COUNT_M \
905 (((1UL << 3) - 1) << QP_CONTEXT_QPC_BYTES_148_RNR_RETRY_COUNT_S)
907 #define QP_CONTEXT_QPC_BYTES_148_LSN_S 8
908 #define QP_CONTEXT_QPC_BYTES_148_LSN_M \
909 (((1UL << 16) - 1) << QP_CONTEXT_QPC_BYTES_148_LSN_S)
911 #define QP_CONTEXT_QPC_BYTES_156_RETRY_COUNT_INIT_S 0
912 #define QP_CONTEXT_QPC_BYTES_156_RETRY_COUNT_INIT_M \
913 (((1UL << 3) - 1) << QP_CONTEXT_QPC_BYTES_156_RETRY_COUNT_INIT_S)
915 #define QP_CONTEXT_QPC_BYTES_156_ACK_TIMEOUT_S 3
916 #define QP_CONTEXT_QPC_BYTES_156_ACK_TIMEOUT_M \
917 (((1UL << 5) - 1) << QP_CONTEXT_QPC_BYTES_156_ACK_TIMEOUT_S)
919 #define QP_CONTEXT_QPC_BYTES_156_RNR_RETRY_COUNT_INIT_S 8
920 #define QP_CONTEXT_QPC_BYTES_156_RNR_RETRY_COUNT_INIT_M \
921 (((1UL << 3) - 1) << QP_CONTEXT_QPC_BYTES_156_RNR_RETRY_COUNT_INIT_S)
923 #define QP_CONTEXT_QPC_BYTES_156_PORT_NUM_S 11
924 #define QP_CONTEXT_QPC_BYTES_156_PORT_NUM_M \
925 (((1UL << 3) - 1) << QP_CONTEXT_QPC_BYTES_156_PORT_NUM_S)
927 #define QP_CONTEXT_QPC_BYTES_156_SL_S 14
928 #define QP_CONTEXT_QPC_BYTES_156_SL_M \
929 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_156_SL_S)
931 #define QP_CONTEXT_QPC_BYTES_156_INITIATOR_DEPTH_S 16
932 #define QP_CONTEXT_QPC_BYTES_156_INITIATOR_DEPTH_M \
933 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_156_INITIATOR_DEPTH_S)
935 #define QP_CONTEXT_QPC_BYTES_156_ACK_REQ_IND_S 24
936 #define QP_CONTEXT_QPC_BYTES_156_ACK_REQ_IND_M \
937 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_156_ACK_REQ_IND_S)
939 #define QP_CONTEXT_QPC_BYTES_164_SQ_PSN_S 0
940 #define QP_CONTEXT_QPC_BYTES_164_SQ_PSN_M \
941 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_164_SQ_PSN_S)
943 #define QP_CONTEXT_QPC_BYTES_164_IRRL_HEAD_S 24
944 #define QP_CONTEXT_QPC_BYTES_164_IRRL_HEAD_M \
945 (((1UL << 8) - 1) << QP_CONTEXT_QPC_BYTES_164_IRRL_HEAD_S)
947 #define QP_CONTEXT_QPC_BYTES_168_RETRY_SQ_PSN_S 0
948 #define QP_CONTEXT_QPC_BYTES_168_RETRY_SQ_PSN_M \
949 (((1UL << 24) - 1) << QP_CONTEXT_QPC_BYTES_168_RETRY_SQ_PSN_S)
951 #define QP_CONTEXT_QPC_BYTES_168_SGE_USE_FLA_S 24
952 #define QP_CONTEXT_QPC_BYTES_168_SGE_USE_FLA_M \
953 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_168_SGE_USE_FLA_S)
955 #define QP_CONTEXT_QPC_BYTES_168_DB_TYPE_S 26
956 #define QP_CONTEXT_QPC_BYTES_168_DB_TYPE_M \
957 (((1UL << 2) - 1) << QP_CONTEXT_QPC_BYTES_168_DB_TYPE_S)
959 #define QP_CONTEXT_QPC_BYTES_168_MSG_LP_IND_S 28
960 #define QP_CONTEXT_QPC_BYTES_168_CSDB_LP_IND_S 29
961 #define QP_CONTEXT_QPC_BYTES_168_QP_ERR_FLG_S 30
963 #define QP_CONTEXT_QPC_BYTES_176_DB_CUR_INDEX_S 0
964 #define QP_CONTEXT_QPC_BYTES_176_DB_CUR_INDEX_M \
965 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_176_DB_CUR_INDEX_S)
967 #define QP_CONTEXT_QPC_BYTES_176_RETRY_DB_CUR_INDEX_S 16
968 #define QP_CONTEXT_QPC_BYTES_176_RETRY_DB_CUR_INDEX_M \
969 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_176_RETRY_DB_CUR_INDEX_S)
971 #define QP_CONTEXT_QPC_BYTES_180_SQ_HEAD_S 0
972 #define QP_CONTEXT_QPC_BYTES_180_SQ_HEAD_M \
973 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_180_SQ_HEAD_S)
975 #define QP_CONTEXT_QPC_BYTES_180_SQ_CUR_INDEX_S 16
976 #define QP_CONTEXT_QPC_BYTES_180_SQ_CUR_INDEX_M \
977 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_180_SQ_CUR_INDEX_S)
979 #define QP_CONTEXT_QPC_BYTES_188_TX_CUR_SQ_WQE_BA_H_S 0
980 #define QP_CONTEXT_QPC_BYTES_188_TX_CUR_SQ_WQE_BA_H_M \
981 (((1UL << 5) - 1) << QP_CONTEXT_QPC_BYTES_188_TX_CUR_SQ_WQE_BA_H_S)
983 #define QP_CONTEXT_QPC_BYTES_188_PKT_RETRY_FLG_S 8
985 #define QP_CONTEXT_QPC_BYTES_188_TX_RETRY_CUR_INDEX_S 16
986 #define QP_CONTEXT_QPC_BYTES_188_TX_RETRY_CUR_INDEX_M \
987 (((1UL << 15) - 1) << QP_CONTEXT_QPC_BYTES_188_TX_RETRY_CUR_INDEX_S)
989 #define STATUS_MASK 0xff
990 #define GO_BIT_TIMEOUT_MSECS 10000
991 #define HCR_STATUS_OFFSET 0x18
992 #define HCR_GO_BIT 15
994 struct hns_roce_rq_db {
995 __le32 u32_4;
996 __le32 u32_8;
999 #define RQ_DOORBELL_U32_4_RQ_HEAD_S 0
1000 #define RQ_DOORBELL_U32_4_RQ_HEAD_M \
1001 (((1UL << 15) - 1) << RQ_DOORBELL_U32_4_RQ_HEAD_S)
1003 #define RQ_DOORBELL_U32_8_QPN_S 0
1004 #define RQ_DOORBELL_U32_8_QPN_M (((1UL << 24) - 1) << RQ_DOORBELL_U32_8_QPN_S)
1006 #define RQ_DOORBELL_U32_8_CMD_S 28
1007 #define RQ_DOORBELL_U32_8_CMD_M (((1UL << 3) - 1) << RQ_DOORBELL_U32_8_CMD_S)
1009 #define RQ_DOORBELL_U32_8_HW_SYNC_S 31
1011 struct hns_roce_sq_db {
1012 __le32 u32_4;
1013 __le32 u32_8;
1016 #define SQ_DOORBELL_U32_4_SQ_HEAD_S 0
1017 #define SQ_DOORBELL_U32_4_SQ_HEAD_M \
1018 (((1UL << 15) - 1) << SQ_DOORBELL_U32_4_SQ_HEAD_S)
1020 #define SQ_DOORBELL_U32_4_SL_S 16
1021 #define SQ_DOORBELL_U32_4_SL_M \
1022 (((1UL << 2) - 1) << SQ_DOORBELL_U32_4_SL_S)
1024 #define SQ_DOORBELL_U32_4_PORT_S 18
1025 #define SQ_DOORBELL_U32_4_PORT_M (((1UL << 3) - 1) << SQ_DOORBELL_U32_4_PORT_S)
1027 #define SQ_DOORBELL_U32_8_QPN_S 0
1028 #define SQ_DOORBELL_U32_8_QPN_M (((1UL << 24) - 1) << SQ_DOORBELL_U32_8_QPN_S)
1030 #define SQ_DOORBELL_HW_SYNC_S 31
1032 struct hns_roce_ext_db {
1033 int esdb_dep;
1034 int eodb_dep;
1035 struct hns_roce_buf_list *sdb_buf_list;
1036 struct hns_roce_buf_list *odb_buf_list;
1039 struct hns_roce_db_table {
1040 int sdb_ext_mod;
1041 int odb_ext_mod;
1042 struct hns_roce_ext_db *ext_db;
1045 struct hns_roce_bt_table {
1046 struct hns_roce_buf_list qpc_buf;
1047 struct hns_roce_buf_list mtpt_buf;
1048 struct hns_roce_buf_list cqc_buf;
1051 struct hns_roce_tptr_table {
1052 struct hns_roce_buf_list tptr_buf;
1055 struct hns_roce_qp_work {
1056 struct work_struct work;
1057 struct ib_device *ib_dev;
1058 struct hns_roce_qp *qp;
1059 u32 db_wait_stage;
1060 u32 sdb_issue_ptr;
1061 u32 sdb_inv_cnt;
1062 u32 sche_cnt;
1065 struct hns_roce_mr_free_work {
1066 struct work_struct work;
1067 struct ib_device *ib_dev;
1068 struct completion *comp;
1069 int comp_flag;
1070 void *mr;
1073 struct hns_roce_recreate_lp_qp_work {
1074 struct work_struct work;
1075 struct ib_device *ib_dev;
1076 struct completion *comp;
1077 int comp_flag;
1080 struct hns_roce_free_mr {
1081 struct workqueue_struct *free_mr_wq;
1082 struct hns_roce_qp *mr_free_qp[HNS_ROCE_V1_RESV_QP];
1083 struct hns_roce_cq *mr_free_cq;
1084 struct hns_roce_pd *mr_free_pd;
1087 struct hns_roce_v1_priv {
1088 struct hns_roce_db_table db_table;
1089 struct hns_roce_raq_table raq_table;
1090 struct hns_roce_bt_table bt_table;
1091 struct hns_roce_tptr_table tptr_table;
1092 struct hns_roce_free_mr free_mr;
1095 int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset);
1096 int hns_roce_v1_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
1097 int hns_roce_v1_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata);
1099 #endif