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_SCCC_BT_NUM 64 40 #define HNS_ROCE_VF_SRQC_BT_NUM 64 41 #define HNS_ROCE_VF_CQC_BT_NUM 64 42 #define HNS_ROCE_VF_MPT_BT_NUM 64 43 #define HNS_ROCE_VF_EQC_NUM 64 44 #define HNS_ROCE_VF_SMAC_NUM 32 45 #define HNS_ROCE_VF_SGID_NUM 32 46 #define HNS_ROCE_VF_SL_NUM 8 47 #define HNS_ROCE_VF_GMV_BT_NUM 256 48 49 #define HNS_ROCE_V2_MAX_QP_NUM 0x100000 50 #define HNS_ROCE_V2_MAX_QPC_TIMER_NUM 0x200 51 #define HNS_ROCE_V2_MAX_WQE_NUM 0x8000 52 #define HNS_ROCE_V2_MAX_SRQ 0x100000 53 #define HNS_ROCE_V2_MAX_SRQ_WR 0x8000 54 #define HNS_ROCE_V2_MAX_SRQ_SGE 64 55 #define HNS_ROCE_V2_MAX_CQ_NUM 0x100000 56 #define HNS_ROCE_V2_MAX_CQC_TIMER_NUM 0x100 57 #define HNS_ROCE_V2_MAX_SRQ_NUM 0x100000 58 #define HNS_ROCE_V2_MAX_CQE_NUM 0x400000 59 #define HNS_ROCE_V2_MAX_SRQWQE_NUM 0x8000 60 #define HNS_ROCE_V2_MAX_RQ_SGE_NUM 64 61 #define HNS_ROCE_V2_MAX_SQ_SGE_NUM 64 62 #define HNS_ROCE_V2_MAX_EXTEND_SGE_NUM 0x200000 63 #define HNS_ROCE_V2_MAX_SQ_INLINE 0x20 64 #define HNS_ROCE_V2_MAX_RC_INL_INN_SZ 32 65 #define HNS_ROCE_V2_UAR_NUM 256 66 #define HNS_ROCE_V2_PHY_UAR_NUM 1 67 #define HNS_ROCE_V2_MAX_IRQ_NUM 65 68 #define HNS_ROCE_V2_COMP_VEC_NUM 63 69 #define HNS_ROCE_V2_AEQE_VEC_NUM 1 70 #define HNS_ROCE_V2_ABNORMAL_VEC_NUM 1 71 #define HNS_ROCE_V2_MAX_MTPT_NUM 0x100000 72 #define HNS_ROCE_V2_MAX_MTT_SEGS 0x1000000 73 #define HNS_ROCE_V2_MAX_CQE_SEGS 0x1000000 74 #define HNS_ROCE_V2_MAX_SRQWQE_SEGS 0x1000000 75 #define HNS_ROCE_V2_MAX_IDX_SEGS 0x1000000 76 #define HNS_ROCE_V2_MAX_PD_NUM 0x1000000 77 #define HNS_ROCE_V2_MAX_QP_INIT_RDMA 128 78 #define HNS_ROCE_V2_MAX_QP_DEST_RDMA 128 79 #define HNS_ROCE_V2_MAX_SQ_DESC_SZ 64 80 #define HNS_ROCE_V2_MAX_RQ_DESC_SZ 16 81 #define HNS_ROCE_V2_MAX_SRQ_DESC_SZ 64 82 #define HNS_ROCE_V2_IRRL_ENTRY_SZ 64 83 #define HNS_ROCE_V2_TRRL_ENTRY_SZ 48 84 #define HNS_ROCE_V2_EXT_ATOMIC_TRRL_ENTRY_SZ 100 85 #define HNS_ROCE_V2_CQC_ENTRY_SZ 64 86 #define HNS_ROCE_V2_SRQC_ENTRY_SZ 64 87 #define HNS_ROCE_V2_MTPT_ENTRY_SZ 64 88 #define HNS_ROCE_V2_MTT_ENTRY_SZ 64 89 #define HNS_ROCE_V2_IDX_ENTRY_SZ 4 90 91 #define HNS_ROCE_V2_SCCC_SZ 32 92 #define HNS_ROCE_V3_SCCC_SZ 64 93 #define HNS_ROCE_V3_GMV_ENTRY_SZ 32 94 95 #define HNS_ROCE_V2_QPC_TIMER_ENTRY_SZ PAGE_SIZE 96 #define HNS_ROCE_V2_CQC_TIMER_ENTRY_SZ PAGE_SIZE 97 #define HNS_ROCE_V2_PAGE_SIZE_SUPPORTED 0xFFFFF000 98 #define HNS_ROCE_V2_MAX_INNER_MTPT_NUM 2 99 #define HNS_ROCE_INVALID_LKEY 0x0 100 #define HNS_ROCE_INVALID_SGE_LENGTH 0x80000000 101 #define HNS_ROCE_CMQ_TX_TIMEOUT 30000 102 #define HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE 2 103 #define HNS_ROCE_V2_RSV_QPS 8 104 105 #define HNS_ROCE_V2_HW_RST_TIMEOUT 1000 106 #define HNS_ROCE_V2_HW_RST_UNINT_DELAY 100 107 108 #define HNS_ROCE_V2_HW_RST_COMPLETION_WAIT 20 109 110 #define HNS_ROCE_CONTEXT_HOP_NUM 1 111 #define HNS_ROCE_SCCC_HOP_NUM 1 112 #define HNS_ROCE_MTT_HOP_NUM 1 113 #define HNS_ROCE_CQE_HOP_NUM 1 114 #define HNS_ROCE_SRQWQE_HOP_NUM 1 115 #define HNS_ROCE_PBL_HOP_NUM 2 116 #define HNS_ROCE_EQE_HOP_NUM 2 117 #define HNS_ROCE_IDX_HOP_NUM 1 118 #define HNS_ROCE_SQWQE_HOP_NUM 2 119 #define HNS_ROCE_EXT_SGE_HOP_NUM 1 120 #define HNS_ROCE_RQWQE_HOP_NUM 2 121 122 #define HNS_ROCE_BA_PG_SZ_SUPPORTED_256K 6 123 #define HNS_ROCE_BA_PG_SZ_SUPPORTED_16K 2 124 #define HNS_ROCE_V2_GID_INDEX_NUM 256 125 126 #define HNS_ROCE_V2_TABLE_CHUNK_SIZE (1 << 18) 127 128 #define HNS_ROCE_CMD_FLAG_IN_VALID_SHIFT 0 129 #define HNS_ROCE_CMD_FLAG_OUT_VALID_SHIFT 1 130 #define HNS_ROCE_CMD_FLAG_NEXT_SHIFT 2 131 #define HNS_ROCE_CMD_FLAG_WR_OR_RD_SHIFT 3 132 #define HNS_ROCE_CMD_FLAG_NO_INTR_SHIFT 4 133 #define HNS_ROCE_CMD_FLAG_ERR_INTR_SHIFT 5 134 135 #define HNS_ROCE_CMD_FLAG_IN BIT(HNS_ROCE_CMD_FLAG_IN_VALID_SHIFT) 136 #define HNS_ROCE_CMD_FLAG_OUT BIT(HNS_ROCE_CMD_FLAG_OUT_VALID_SHIFT) 137 #define HNS_ROCE_CMD_FLAG_NEXT BIT(HNS_ROCE_CMD_FLAG_NEXT_SHIFT) 138 #define HNS_ROCE_CMD_FLAG_WR BIT(HNS_ROCE_CMD_FLAG_WR_OR_RD_SHIFT) 139 #define HNS_ROCE_CMD_FLAG_NO_INTR BIT(HNS_ROCE_CMD_FLAG_NO_INTR_SHIFT) 140 #define HNS_ROCE_CMD_FLAG_ERR_INTR BIT(HNS_ROCE_CMD_FLAG_ERR_INTR_SHIFT) 141 142 #define HNS_ROCE_CMQ_DESC_NUM_S 3 143 144 #define HNS_ROCE_CMQ_SCC_CLR_DONE_CNT 5 145 146 #define check_whether_last_step(hop_num, step_idx) \ 147 ((step_idx == 0 && hop_num == HNS_ROCE_HOP_NUM_0) || \ 148 (step_idx == 1 && hop_num == 1) || \ 149 (step_idx == 2 && hop_num == 2)) 150 #define HNS_ICL_SWITCH_CMD_ROCEE_SEL_SHIFT 0 151 #define HNS_ICL_SWITCH_CMD_ROCEE_SEL BIT(HNS_ICL_SWITCH_CMD_ROCEE_SEL_SHIFT) 152 153 #define CMD_CSQ_DESC_NUM 1024 154 #define CMD_CRQ_DESC_NUM 1024 155 156 enum { 157 NO_ARMED = 0x0, 158 REG_NXT_CEQE = 0x2, 159 REG_NXT_SE_CEQE = 0x3 160 }; 161 162 #define V2_CQ_DB_REQ_NOT_SOL 0 163 #define V2_CQ_DB_REQ_NOT 1 164 165 #define V2_CQ_STATE_VALID 1 166 #define V2_QKEY_VAL 0x80010000 167 168 #define GID_LEN_V2 16 169 170 #define HNS_ROCE_V2_CQE_QPN_MASK 0xfffff 171 172 enum { 173 HNS_ROCE_V2_WQE_OP_SEND = 0x0, 174 HNS_ROCE_V2_WQE_OP_SEND_WITH_INV = 0x1, 175 HNS_ROCE_V2_WQE_OP_SEND_WITH_IMM = 0x2, 176 HNS_ROCE_V2_WQE_OP_RDMA_WRITE = 0x3, 177 HNS_ROCE_V2_WQE_OP_RDMA_WRITE_WITH_IMM = 0x4, 178 HNS_ROCE_V2_WQE_OP_RDMA_READ = 0x5, 179 HNS_ROCE_V2_WQE_OP_ATOM_CMP_AND_SWAP = 0x6, 180 HNS_ROCE_V2_WQE_OP_ATOM_FETCH_AND_ADD = 0x7, 181 HNS_ROCE_V2_WQE_OP_ATOM_MSK_CMP_AND_SWAP = 0x8, 182 HNS_ROCE_V2_WQE_OP_ATOM_MSK_FETCH_AND_ADD = 0x9, 183 HNS_ROCE_V2_WQE_OP_FAST_REG_PMR = 0xa, 184 HNS_ROCE_V2_WQE_OP_LOCAL_INV = 0xb, 185 HNS_ROCE_V2_WQE_OP_BIND_MW = 0xc, 186 HNS_ROCE_V2_WQE_OP_MASK = 0x1f, 187 }; 188 189 enum { 190 /* rq operations */ 191 HNS_ROCE_V2_OPCODE_RDMA_WRITE_IMM = 0x0, 192 HNS_ROCE_V2_OPCODE_SEND = 0x1, 193 HNS_ROCE_V2_OPCODE_SEND_WITH_IMM = 0x2, 194 HNS_ROCE_V2_OPCODE_SEND_WITH_INV = 0x3, 195 }; 196 197 enum { 198 HNS_ROCE_V2_SQ_DB = 0x0, 199 HNS_ROCE_V2_RQ_DB = 0x1, 200 HNS_ROCE_V2_SRQ_DB = 0x2, 201 HNS_ROCE_V2_CQ_DB_PTR = 0x3, 202 HNS_ROCE_V2_CQ_DB_NTR = 0x4, 203 }; 204 205 enum { 206 HNS_ROCE_CQE_V2_SUCCESS = 0x00, 207 HNS_ROCE_CQE_V2_LOCAL_LENGTH_ERR = 0x01, 208 HNS_ROCE_CQE_V2_LOCAL_QP_OP_ERR = 0x02, 209 HNS_ROCE_CQE_V2_LOCAL_PROT_ERR = 0x04, 210 HNS_ROCE_CQE_V2_WR_FLUSH_ERR = 0x05, 211 HNS_ROCE_CQE_V2_MW_BIND_ERR = 0x06, 212 HNS_ROCE_CQE_V2_BAD_RESP_ERR = 0x10, 213 HNS_ROCE_CQE_V2_LOCAL_ACCESS_ERR = 0x11, 214 HNS_ROCE_CQE_V2_REMOTE_INVAL_REQ_ERR = 0x12, 215 HNS_ROCE_CQE_V2_REMOTE_ACCESS_ERR = 0x13, 216 HNS_ROCE_CQE_V2_REMOTE_OP_ERR = 0x14, 217 HNS_ROCE_CQE_V2_TRANSPORT_RETRY_EXC_ERR = 0x15, 218 HNS_ROCE_CQE_V2_RNR_RETRY_EXC_ERR = 0x16, 219 HNS_ROCE_CQE_V2_REMOTE_ABORT_ERR = 0x22, 220 HNS_ROCE_CQE_V2_GENERAL_ERR = 0x23, 221 222 HNS_ROCE_V2_CQE_STATUS_MASK = 0xff, 223 }; 224 225 /* CMQ command */ 226 enum hns_roce_opcode_type { 227 HNS_QUERY_FW_VER = 0x0001, 228 HNS_ROCE_OPC_QUERY_HW_VER = 0x8000, 229 HNS_ROCE_OPC_CFG_GLOBAL_PARAM = 0x8001, 230 HNS_ROCE_OPC_ALLOC_PF_RES = 0x8004, 231 HNS_ROCE_OPC_QUERY_PF_RES = 0x8400, 232 HNS_ROCE_OPC_ALLOC_VF_RES = 0x8401, 233 HNS_ROCE_OPC_CFG_EXT_LLM = 0x8403, 234 HNS_ROCE_OPC_CFG_TMOUT_LLM = 0x8404, 235 HNS_ROCE_OPC_QUERY_PF_TIMER_RES = 0x8406, 236 HNS_ROCE_OPC_QUERY_PF_CAPS_NUM = 0x8408, 237 HNS_ROCE_OPC_CFG_ENTRY_SIZE = 0x8409, 238 HNS_ROCE_OPC_CFG_SGID_TB = 0x8500, 239 HNS_ROCE_OPC_CFG_SMAC_TB = 0x8501, 240 HNS_ROCE_OPC_POST_MB = 0x8504, 241 HNS_ROCE_OPC_QUERY_MB_ST = 0x8505, 242 HNS_ROCE_OPC_CFG_BT_ATTR = 0x8506, 243 HNS_ROCE_OPC_FUNC_CLEAR = 0x8508, 244 HNS_ROCE_OPC_CLR_SCCC = 0x8509, 245 HNS_ROCE_OPC_QUERY_SCCC = 0x850a, 246 HNS_ROCE_OPC_RESET_SCCC = 0x850b, 247 HNS_ROCE_OPC_CFG_GMV_TBL = 0x850f, 248 HNS_ROCE_OPC_CFG_GMV_BT = 0x8510, 249 HNS_SWITCH_PARAMETER_CFG = 0x1033, 250 }; 251 252 enum { 253 TYPE_CRQ, 254 TYPE_CSQ, 255 }; 256 257 enum hns_roce_cmd_return_status { 258 CMD_EXEC_SUCCESS = 0, 259 CMD_NO_AUTH = 1, 260 CMD_NOT_EXEC = 2, 261 CMD_QUEUE_FULL = 3, 262 }; 263 264 enum hns_roce_sgid_type { 265 GID_TYPE_FLAG_ROCE_V1 = 0, 266 GID_TYPE_FLAG_ROCE_V2_IPV4, 267 GID_TYPE_FLAG_ROCE_V2_IPV6, 268 }; 269 270 struct hns_roce_v2_cq_context { 271 __le32 byte_4_pg_ceqn; 272 __le32 byte_8_cqn; 273 __le32 cqe_cur_blk_addr; 274 __le32 byte_16_hop_addr; 275 __le32 cqe_nxt_blk_addr; 276 __le32 byte_24_pgsz_addr; 277 __le32 byte_28_cq_pi; 278 __le32 byte_32_cq_ci; 279 __le32 cqe_ba; 280 __le32 byte_40_cqe_ba; 281 __le32 byte_44_db_record; 282 __le32 db_record_addr; 283 __le32 byte_52_cqe_cnt; 284 __le32 byte_56_cqe_period_maxcnt; 285 __le32 cqe_report_timer; 286 __le32 byte_64_se_cqe_idx; 287 }; 288 289 #define HNS_ROCE_V2_CQ_DEFAULT_BURST_NUM 0x0 290 #define HNS_ROCE_V2_CQ_DEFAULT_INTERVAL 0x0 291 292 #define V2_CQC_BYTE_4_CQ_ST_S 0 293 #define V2_CQC_BYTE_4_CQ_ST_M GENMASK(1, 0) 294 295 #define V2_CQC_BYTE_4_POLL_S 2 296 297 #define V2_CQC_BYTE_4_SE_S 3 298 299 #define V2_CQC_BYTE_4_OVER_IGNORE_S 4 300 301 #define V2_CQC_BYTE_4_COALESCE_S 5 302 303 #define V2_CQC_BYTE_4_ARM_ST_S 6 304 #define V2_CQC_BYTE_4_ARM_ST_M GENMASK(7, 6) 305 306 #define V2_CQC_BYTE_4_SHIFT_S 8 307 #define V2_CQC_BYTE_4_SHIFT_M GENMASK(12, 8) 308 309 #define V2_CQC_BYTE_4_CMD_SN_S 13 310 #define V2_CQC_BYTE_4_CMD_SN_M GENMASK(14, 13) 311 312 #define V2_CQC_BYTE_4_CEQN_S 15 313 #define V2_CQC_BYTE_4_CEQN_M GENMASK(23, 15) 314 315 #define V2_CQC_BYTE_4_PAGE_OFFSET_S 24 316 #define V2_CQC_BYTE_4_PAGE_OFFSET_M GENMASK(31, 24) 317 318 #define V2_CQC_BYTE_8_CQN_S 0 319 #define V2_CQC_BYTE_8_CQN_M GENMASK(23, 0) 320 321 #define V2_CQC_BYTE_8_CQE_SIZE_S 27 322 #define V2_CQC_BYTE_8_CQE_SIZE_M GENMASK(28, 27) 323 324 #define V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_S 0 325 #define V2_CQC_BYTE_16_CQE_CUR_BLK_ADDR_M GENMASK(19, 0) 326 327 #define V2_CQC_BYTE_16_CQE_HOP_NUM_S 30 328 #define V2_CQC_BYTE_16_CQE_HOP_NUM_M GENMASK(31, 30) 329 330 #define V2_CQC_BYTE_24_CQE_NXT_BLK_ADDR_S 0 331 #define V2_CQC_BYTE_24_CQE_NXT_BLK_ADDR_M GENMASK(19, 0) 332 333 #define V2_CQC_BYTE_24_CQE_BA_PG_SZ_S 24 334 #define V2_CQC_BYTE_24_CQE_BA_PG_SZ_M GENMASK(27, 24) 335 336 #define V2_CQC_BYTE_24_CQE_BUF_PG_SZ_S 28 337 #define V2_CQC_BYTE_24_CQE_BUF_PG_SZ_M GENMASK(31, 28) 338 339 #define V2_CQC_BYTE_28_CQ_PRODUCER_IDX_S 0 340 #define V2_CQC_BYTE_28_CQ_PRODUCER_IDX_M GENMASK(23, 0) 341 342 #define V2_CQC_BYTE_32_CQ_CONSUMER_IDX_S 0 343 #define V2_CQC_BYTE_32_CQ_CONSUMER_IDX_M GENMASK(23, 0) 344 345 #define V2_CQC_BYTE_40_CQE_BA_S 0 346 #define V2_CQC_BYTE_40_CQE_BA_M GENMASK(28, 0) 347 348 #define V2_CQC_BYTE_44_DB_RECORD_EN_S 0 349 350 #define V2_CQC_BYTE_44_DB_RECORD_ADDR_S 1 351 #define V2_CQC_BYTE_44_DB_RECORD_ADDR_M GENMASK(31, 1) 352 353 #define V2_CQC_BYTE_52_CQE_CNT_S 0 354 #define V2_CQC_BYTE_52_CQE_CNT_M GENMASK(23, 0) 355 356 #define V2_CQC_BYTE_56_CQ_MAX_CNT_S 0 357 #define V2_CQC_BYTE_56_CQ_MAX_CNT_M GENMASK(15, 0) 358 359 #define V2_CQC_BYTE_56_CQ_PERIOD_S 16 360 #define V2_CQC_BYTE_56_CQ_PERIOD_M GENMASK(31, 16) 361 362 #define V2_CQC_BYTE_64_SE_CQE_IDX_S 0 363 #define V2_CQC_BYTE_64_SE_CQE_IDX_M GENMASK(23, 0) 364 365 #define CQC_FIELD_LOC(h, l) FIELD_LOC(struct hns_roce_v2_cq_context, h, l) 366 367 #define CQC_STASH CQC_FIELD_LOC(63, 63) 368 369 struct hns_roce_srq_context { 370 __le32 byte_4_srqn_srqst; 371 __le32 byte_8_limit_wl; 372 __le32 byte_12_xrcd; 373 __le32 byte_16_pi_ci; 374 __le32 wqe_bt_ba; 375 __le32 byte_24_wqe_bt_ba; 376 __le32 byte_28_rqws_pd; 377 __le32 idx_bt_ba; 378 __le32 rsv_idx_bt_ba; 379 __le32 idx_cur_blk_addr; 380 __le32 byte_44_idxbufpgsz_addr; 381 __le32 idx_nxt_blk_addr; 382 __le32 rsv_idxnxtblkaddr; 383 __le32 byte_56_xrc_cqn; 384 __le32 db_record_addr_record_en; 385 __le32 db_record_addr; 386 }; 387 388 #define SRQC_FIELD_LOC(h, l) FIELD_LOC(struct hns_roce_srq_context, h, l) 389 390 #define SRQC_SRQ_ST SRQC_FIELD_LOC(1, 0) 391 #define SRQC_WQE_HOP_NUM SRQC_FIELD_LOC(3, 2) 392 #define SRQC_SHIFT SRQC_FIELD_LOC(7, 4) 393 #define SRQC_SRQN SRQC_FIELD_LOC(31, 8) 394 #define SRQC_LIMIT_WL SRQC_FIELD_LOC(47, 32) 395 #define SRQC_RSV0 SRQC_FIELD_LOC(63, 48) 396 #define SRQC_XRCD SRQC_FIELD_LOC(87, 64) 397 #define SRQC_RSV1 SRQC_FIELD_LOC(95, 88) 398 #define SRQC_PRODUCER_IDX SRQC_FIELD_LOC(111, 96) 399 #define SRQC_CONSUMER_IDX SRQC_FIELD_LOC(127, 112) 400 #define SRQC_WQE_BT_BA_L SRQC_FIELD_LOC(159, 128) 401 #define SRQC_WQE_BT_BA_H SRQC_FIELD_LOC(188, 160) 402 #define SRQC_RSV2 SRQC_FIELD_LOC(191, 189) 403 #define SRQC_PD SRQC_FIELD_LOC(215, 192) 404 #define SRQC_RQWS SRQC_FIELD_LOC(219, 216) 405 #define SRQC_RSV3 SRQC_FIELD_LOC(223, 220) 406 #define SRQC_IDX_BT_BA_L SRQC_FIELD_LOC(255, 224) 407 #define SRQC_IDX_BT_BA_H SRQC_FIELD_LOC(284, 256) 408 #define SRQC_RSV4 SRQC_FIELD_LOC(287, 285) 409 #define SRQC_IDX_CUR_BLK_ADDR_L SRQC_FIELD_LOC(319, 288) 410 #define SRQC_IDX_CUR_BLK_ADDR_H SRQC_FIELD_LOC(339, 320) 411 #define SRQC_RSV5 SRQC_FIELD_LOC(341, 340) 412 #define SRQC_IDX_HOP_NUM SRQC_FIELD_LOC(343, 342) 413 #define SRQC_IDX_BA_PG_SZ SRQC_FIELD_LOC(347, 344) 414 #define SRQC_IDX_BUF_PG_SZ SRQC_FIELD_LOC(351, 348) 415 #define SRQC_IDX_NXT_BLK_ADDR_L SRQC_FIELD_LOC(383, 352) 416 #define SRQC_IDX_NXT_BLK_ADDR_H SRQC_FIELD_LOC(403, 384) 417 #define SRQC_RSV6 SRQC_FIELD_LOC(415, 404) 418 #define SRQC_XRC_CQN SRQC_FIELD_LOC(439, 416) 419 #define SRQC_WQE_BA_PG_SZ SRQC_FIELD_LOC(443, 440) 420 #define SRQC_WQE_BUF_PG_SZ SRQC_FIELD_LOC(447, 444) 421 #define SRQC_DB_RECORD_EN SRQC_FIELD_LOC(448, 448) 422 #define SRQC_DB_RECORD_ADDR_L SRQC_FIELD_LOC(479, 449) 423 #define SRQC_DB_RECORD_ADDR_H SRQC_FIELD_LOC(511, 480) 424 425 #define SRQC_BYTE_4_SRQ_ST_S 0 426 #define SRQC_BYTE_4_SRQ_ST_M GENMASK(1, 0) 427 428 #define SRQC_BYTE_4_SRQ_WQE_HOP_NUM_S 2 429 #define SRQC_BYTE_4_SRQ_WQE_HOP_NUM_M GENMASK(3, 2) 430 431 #define SRQC_BYTE_4_SRQ_SHIFT_S 4 432 #define SRQC_BYTE_4_SRQ_SHIFT_M GENMASK(7, 4) 433 434 #define SRQC_BYTE_4_SRQN_S 8 435 #define SRQC_BYTE_4_SRQN_M GENMASK(31, 8) 436 437 #define SRQC_BYTE_8_SRQ_LIMIT_WL_S 0 438 #define SRQC_BYTE_8_SRQ_LIMIT_WL_M GENMASK(15, 0) 439 440 #define SRQC_BYTE_12_SRQ_XRCD_S 0 441 #define SRQC_BYTE_12_SRQ_XRCD_M GENMASK(23, 0) 442 443 #define SRQC_BYTE_16_SRQ_PRODUCER_IDX_S 0 444 #define SRQC_BYTE_16_SRQ_PRODUCER_IDX_M GENMASK(15, 0) 445 446 #define SRQC_BYTE_16_SRQ_CONSUMER_IDX_S 0 447 #define SRQC_BYTE_16_SRQ_CONSUMER_IDX_M GENMASK(31, 16) 448 449 #define SRQC_BYTE_24_SRQ_WQE_BT_BA_S 0 450 #define SRQC_BYTE_24_SRQ_WQE_BT_BA_M GENMASK(28, 0) 451 452 #define SRQC_BYTE_28_PD_S 0 453 #define SRQC_BYTE_28_PD_M GENMASK(23, 0) 454 455 #define SRQC_BYTE_28_RQWS_S 24 456 #define SRQC_BYTE_28_RQWS_M GENMASK(27, 24) 457 458 #define SRQC_BYTE_36_SRQ_IDX_BT_BA_S 0 459 #define SRQC_BYTE_36_SRQ_IDX_BT_BA_M GENMASK(28, 0) 460 461 #define SRQC_BYTE_44_SRQ_IDX_CUR_BLK_ADDR_S 0 462 #define SRQC_BYTE_44_SRQ_IDX_CUR_BLK_ADDR_M GENMASK(19, 0) 463 464 #define SRQC_BYTE_44_SRQ_IDX_HOP_NUM_S 22 465 #define SRQC_BYTE_44_SRQ_IDX_HOP_NUM_M GENMASK(23, 22) 466 467 #define SRQC_BYTE_44_SRQ_IDX_BA_PG_SZ_S 24 468 #define SRQC_BYTE_44_SRQ_IDX_BA_PG_SZ_M GENMASK(27, 24) 469 470 #define SRQC_BYTE_44_SRQ_IDX_BUF_PG_SZ_S 28 471 #define SRQC_BYTE_44_SRQ_IDX_BUF_PG_SZ_M GENMASK(31, 28) 472 473 #define SRQC_BYTE_52_SRQ_IDX_NXT_BLK_ADDR_S 0 474 #define SRQC_BYTE_52_SRQ_IDX_NXT_BLK_ADDR_M GENMASK(19, 0) 475 476 #define SRQC_BYTE_56_SRQ_XRC_CQN_S 0 477 #define SRQC_BYTE_56_SRQ_XRC_CQN_M GENMASK(23, 0) 478 479 #define SRQC_BYTE_56_SRQ_WQE_BA_PG_SZ_S 24 480 #define SRQC_BYTE_56_SRQ_WQE_BA_PG_SZ_M GENMASK(27, 24) 481 482 #define SRQC_BYTE_56_SRQ_WQE_BUF_PG_SZ_S 28 483 #define SRQC_BYTE_56_SRQ_WQE_BUF_PG_SZ_M GENMASK(31, 28) 484 485 #define SRQC_BYTE_60_SRQ_RECORD_EN_S 0 486 487 #define SRQC_BYTE_60_SRQ_DB_RECORD_ADDR_S 1 488 #define SRQC_BYTE_60_SRQ_DB_RECORD_ADDR_M GENMASK(31, 1) 489 490 enum { 491 V2_MPT_ST_VALID = 0x1, 492 V2_MPT_ST_FREE = 0x2, 493 }; 494 495 enum hns_roce_v2_qp_state { 496 HNS_ROCE_QP_ST_RST, 497 HNS_ROCE_QP_ST_INIT, 498 HNS_ROCE_QP_ST_RTR, 499 HNS_ROCE_QP_ST_RTS, 500 HNS_ROCE_QP_ST_SQD, 501 HNS_ROCE_QP_ST_SQER, 502 HNS_ROCE_QP_ST_ERR, 503 HNS_ROCE_QP_ST_SQ_DRAINING, 504 HNS_ROCE_QP_NUM_ST 505 }; 506 507 struct hns_roce_v2_qp_context_ex { 508 __le32 data[64]; 509 }; 510 struct hns_roce_v2_qp_context { 511 __le32 byte_4_sqpn_tst; 512 __le32 wqe_sge_ba; 513 __le32 byte_12_sq_hop; 514 __le32 byte_16_buf_ba_pg_sz; 515 __le32 byte_20_smac_sgid_idx; 516 __le32 byte_24_mtu_tc; 517 __le32 byte_28_at_fl; 518 u8 dgid[GID_LEN_V2]; 519 __le32 dmac; 520 __le32 byte_52_udpspn_dmac; 521 __le32 byte_56_dqpn_err; 522 __le32 byte_60_qpst_tempid; 523 __le32 qkey_xrcd; 524 __le32 byte_68_rq_db; 525 __le32 rq_db_record_addr; 526 __le32 byte_76_srqn_op_en; 527 __le32 byte_80_rnr_rx_cqn; 528 __le32 byte_84_rq_ci_pi; 529 __le32 rq_cur_blk_addr; 530 __le32 byte_92_srq_info; 531 __le32 byte_96_rx_reqmsn; 532 __le32 rq_nxt_blk_addr; 533 __le32 byte_104_rq_sge; 534 __le32 byte_108_rx_reqepsn; 535 __le32 rq_rnr_timer; 536 __le32 rx_msg_len; 537 __le32 rx_rkey_pkt_info; 538 __le64 rx_va; 539 __le32 byte_132_trrl; 540 __le32 trrl_ba; 541 __le32 byte_140_raq; 542 __le32 byte_144_raq; 543 __le32 byte_148_raq; 544 __le32 byte_152_raq; 545 __le32 byte_156_raq; 546 __le32 byte_160_sq_ci_pi; 547 __le32 sq_cur_blk_addr; 548 __le32 byte_168_irrl_idx; 549 __le32 byte_172_sq_psn; 550 __le32 byte_176_msg_pktn; 551 __le32 sq_cur_sge_blk_addr; 552 __le32 byte_184_irrl_idx; 553 __le32 cur_sge_offset; 554 __le32 byte_192_ext_sge; 555 __le32 byte_196_sq_psn; 556 __le32 byte_200_sq_max; 557 __le32 irrl_ba; 558 __le32 byte_208_irrl; 559 __le32 byte_212_lsn; 560 __le32 sq_timer; 561 __le32 byte_220_retry_psn_msn; 562 __le32 byte_224_retry_msg; 563 __le32 rx_sq_cur_blk_addr; 564 __le32 byte_232_irrl_sge; 565 __le32 irrl_cur_sge_offset; 566 __le32 byte_240_irrl_tail; 567 __le32 byte_244_rnr_rxack; 568 __le32 byte_248_ack_psn; 569 __le32 byte_252_err_txcqn; 570 __le32 byte_256_sqflush_rqcqe; 571 572 struct hns_roce_v2_qp_context_ex ext; 573 }; 574 575 #define V2_QPC_BYTE_4_TST_S 0 576 #define V2_QPC_BYTE_4_TST_M GENMASK(2, 0) 577 578 #define V2_QPC_BYTE_4_SGE_SHIFT_S 3 579 #define V2_QPC_BYTE_4_SGE_SHIFT_M GENMASK(7, 3) 580 581 #define V2_QPC_BYTE_4_SQPN_S 8 582 #define V2_QPC_BYTE_4_SQPN_M GENMASK(31, 8) 583 584 #define V2_QPC_BYTE_12_WQE_SGE_BA_S 0 585 #define V2_QPC_BYTE_12_WQE_SGE_BA_M GENMASK(28, 0) 586 587 #define V2_QPC_BYTE_12_SQ_HOP_NUM_S 29 588 #define V2_QPC_BYTE_12_SQ_HOP_NUM_M GENMASK(30, 29) 589 590 #define V2_QPC_BYTE_12_RSVD_LKEY_EN_S 31 591 592 #define V2_QPC_BYTE_16_WQE_SGE_BA_PG_SZ_S 0 593 #define V2_QPC_BYTE_16_WQE_SGE_BA_PG_SZ_M GENMASK(3, 0) 594 595 #define V2_QPC_BYTE_16_WQE_SGE_BUF_PG_SZ_S 4 596 #define V2_QPC_BYTE_16_WQE_SGE_BUF_PG_SZ_M GENMASK(7, 4) 597 598 #define V2_QPC_BYTE_16_PD_S 8 599 #define V2_QPC_BYTE_16_PD_M GENMASK(31, 8) 600 601 #define V2_QPC_BYTE_20_RQ_HOP_NUM_S 0 602 #define V2_QPC_BYTE_20_RQ_HOP_NUM_M GENMASK(1, 0) 603 604 #define V2_QPC_BYTE_20_SGE_HOP_NUM_S 2 605 #define V2_QPC_BYTE_20_SGE_HOP_NUM_M GENMASK(3, 2) 606 607 #define V2_QPC_BYTE_20_RQWS_S 4 608 #define V2_QPC_BYTE_20_RQWS_M GENMASK(7, 4) 609 610 #define V2_QPC_BYTE_20_SQ_SHIFT_S 8 611 #define V2_QPC_BYTE_20_SQ_SHIFT_M GENMASK(11, 8) 612 613 #define V2_QPC_BYTE_20_RQ_SHIFT_S 12 614 #define V2_QPC_BYTE_20_RQ_SHIFT_M GENMASK(15, 12) 615 616 #define V2_QPC_BYTE_20_SGID_IDX_S 16 617 #define V2_QPC_BYTE_20_SGID_IDX_M GENMASK(23, 16) 618 619 #define V2_QPC_BYTE_20_SMAC_IDX_S 24 620 #define V2_QPC_BYTE_20_SMAC_IDX_M GENMASK(31, 24) 621 622 #define V2_QPC_BYTE_24_HOP_LIMIT_S 0 623 #define V2_QPC_BYTE_24_HOP_LIMIT_M GENMASK(7, 0) 624 625 #define V2_QPC_BYTE_24_TC_S 8 626 #define V2_QPC_BYTE_24_TC_M GENMASK(15, 8) 627 628 #define V2_QPC_BYTE_24_VLAN_ID_S 16 629 #define V2_QPC_BYTE_24_VLAN_ID_M GENMASK(27, 16) 630 631 #define V2_QPC_BYTE_24_MTU_S 28 632 #define V2_QPC_BYTE_24_MTU_M GENMASK(31, 28) 633 634 #define V2_QPC_BYTE_28_FL_S 0 635 #define V2_QPC_BYTE_28_FL_M GENMASK(19, 0) 636 637 #define V2_QPC_BYTE_28_SL_S 20 638 #define V2_QPC_BYTE_28_SL_M GENMASK(23, 20) 639 640 #define V2_QPC_BYTE_28_CNP_TX_FLAG_S 24 641 642 #define V2_QPC_BYTE_28_CE_FLAG_S 25 643 644 #define V2_QPC_BYTE_28_LBI_S 26 645 646 #define V2_QPC_BYTE_28_AT_S 27 647 #define V2_QPC_BYTE_28_AT_M GENMASK(31, 27) 648 649 #define V2_QPC_BYTE_52_DMAC_S 0 650 #define V2_QPC_BYTE_52_DMAC_M GENMASK(15, 0) 651 652 #define V2_QPC_BYTE_52_UDPSPN_S 16 653 #define V2_QPC_BYTE_52_UDPSPN_M GENMASK(31, 16) 654 655 #define V2_QPC_BYTE_56_DQPN_S 0 656 #define V2_QPC_BYTE_56_DQPN_M GENMASK(23, 0) 657 658 #define V2_QPC_BYTE_56_SQ_TX_ERR_S 24 659 #define V2_QPC_BYTE_56_SQ_RX_ERR_S 25 660 #define V2_QPC_BYTE_56_RQ_TX_ERR_S 26 661 #define V2_QPC_BYTE_56_RQ_RX_ERR_S 27 662 663 #define V2_QPC_BYTE_56_LP_PKTN_INI_S 28 664 #define V2_QPC_BYTE_56_LP_PKTN_INI_M GENMASK(31, 28) 665 666 #define V2_QPC_BYTE_60_TEMPID_S 0 667 #define V2_QPC_BYTE_60_TEMPID_M GENMASK(7, 0) 668 669 #define V2_QPC_BYTE_60_SCC_TOKEN_S 8 670 #define V2_QPC_BYTE_60_SCC_TOKEN_M GENMASK(26, 8) 671 672 #define V2_QPC_BYTE_60_SQ_DB_DOING_S 27 673 674 #define V2_QPC_BYTE_60_RQ_DB_DOING_S 28 675 676 #define V2_QPC_BYTE_60_QP_ST_S 29 677 #define V2_QPC_BYTE_60_QP_ST_M GENMASK(31, 29) 678 679 #define V2_QPC_BYTE_68_RQ_RECORD_EN_S 0 680 681 #define V2_QPC_BYTE_68_RQ_DB_RECORD_ADDR_S 1 682 #define V2_QPC_BYTE_68_RQ_DB_RECORD_ADDR_M GENMASK(31, 1) 683 684 #define V2_QPC_BYTE_76_SRQN_S 0 685 #define V2_QPC_BYTE_76_SRQN_M GENMASK(23, 0) 686 687 #define V2_QPC_BYTE_76_SRQ_EN_S 24 688 689 #define V2_QPC_BYTE_76_RRE_S 25 690 691 #define V2_QPC_BYTE_76_RWE_S 26 692 693 #define V2_QPC_BYTE_76_ATE_S 27 694 695 #define V2_QPC_BYTE_76_RQIE_S 28 696 #define V2_QPC_BYTE_76_EXT_ATE_S 29 697 #define V2_QPC_BYTE_76_RQ_VLAN_EN_S 30 698 #define V2_QPC_BYTE_80_RX_CQN_S 0 699 #define V2_QPC_BYTE_80_RX_CQN_M GENMASK(23, 0) 700 701 #define V2_QPC_BYTE_80_MIN_RNR_TIME_S 27 702 #define V2_QPC_BYTE_80_MIN_RNR_TIME_M GENMASK(31, 27) 703 704 #define V2_QPC_BYTE_84_RQ_PRODUCER_IDX_S 0 705 #define V2_QPC_BYTE_84_RQ_PRODUCER_IDX_M GENMASK(15, 0) 706 707 #define V2_QPC_BYTE_84_RQ_CONSUMER_IDX_S 16 708 #define V2_QPC_BYTE_84_RQ_CONSUMER_IDX_M GENMASK(31, 16) 709 710 #define V2_QPC_BYTE_92_RQ_CUR_BLK_ADDR_S 0 711 #define V2_QPC_BYTE_92_RQ_CUR_BLK_ADDR_M GENMASK(19, 0) 712 713 #define V2_QPC_BYTE_92_SRQ_INFO_S 20 714 #define V2_QPC_BYTE_92_SRQ_INFO_M GENMASK(31, 20) 715 716 #define V2_QPC_BYTE_96_RX_REQ_MSN_S 0 717 #define V2_QPC_BYTE_96_RX_REQ_MSN_M GENMASK(23, 0) 718 719 #define V2_QPC_BYTE_104_RQ_NXT_BLK_ADDR_S 0 720 #define V2_QPC_BYTE_104_RQ_NXT_BLK_ADDR_M GENMASK(19, 0) 721 722 #define V2_QPC_BYTE_104_RQ_CUR_WQE_SGE_NUM_S 24 723 #define V2_QPC_BYTE_104_RQ_CUR_WQE_SGE_NUM_M GENMASK(31, 24) 724 725 #define V2_QPC_BYTE_108_INV_CREDIT_S 0 726 727 #define V2_QPC_BYTE_108_RX_REQ_PSN_ERR_S 3 728 729 #define V2_QPC_BYTE_108_RX_REQ_LAST_OPTYPE_S 4 730 #define V2_QPC_BYTE_108_RX_REQ_LAST_OPTYPE_M GENMASK(6, 4) 731 732 #define V2_QPC_BYTE_108_RX_REQ_RNR_S 7 733 734 #define V2_QPC_BYTE_108_RX_REQ_EPSN_S 8 735 #define V2_QPC_BYTE_108_RX_REQ_EPSN_M GENMASK(31, 8) 736 737 #define V2_QPC_BYTE_132_TRRL_HEAD_MAX_S 0 738 #define V2_QPC_BYTE_132_TRRL_HEAD_MAX_M GENMASK(7, 0) 739 740 #define V2_QPC_BYTE_132_TRRL_TAIL_MAX_S 8 741 #define V2_QPC_BYTE_132_TRRL_TAIL_MAX_M GENMASK(15, 8) 742 743 #define V2_QPC_BYTE_132_TRRL_BA_S 16 744 #define V2_QPC_BYTE_132_TRRL_BA_M GENMASK(31, 16) 745 746 #define V2_QPC_BYTE_140_TRRL_BA_S 0 747 #define V2_QPC_BYTE_140_TRRL_BA_M GENMASK(11, 0) 748 749 #define V2_QPC_BYTE_140_RR_MAX_S 12 750 #define V2_QPC_BYTE_140_RR_MAX_M GENMASK(14, 12) 751 752 #define V2_QPC_BYTE_140_RQ_RTY_WAIT_DO_S 15 753 754 #define V2_QPC_BYTE_140_RAQ_TRRL_HEAD_S 16 755 #define V2_QPC_BYTE_140_RAQ_TRRL_HEAD_M GENMASK(23, 16) 756 757 #define V2_QPC_BYTE_140_RAQ_TRRL_TAIL_S 24 758 #define V2_QPC_BYTE_140_RAQ_TRRL_TAIL_M GENMASK(31, 24) 759 760 #define V2_QPC_BYTE_144_RAQ_RTY_INI_PSN_S 0 761 #define V2_QPC_BYTE_144_RAQ_RTY_INI_PSN_M GENMASK(23, 0) 762 763 #define V2_QPC_BYTE_144_RAQ_CREDIT_S 25 764 #define V2_QPC_BYTE_144_RAQ_CREDIT_M GENMASK(29, 25) 765 766 #define V2_QPC_BYTE_144_RESP_RTY_FLG_S 31 767 768 #define V2_QPC_BYTE_148_RQ_MSN_S 0 769 #define V2_QPC_BYTE_148_RQ_MSN_M GENMASK(23, 0) 770 771 #define V2_QPC_BYTE_148_RAQ_SYNDROME_S 24 772 #define V2_QPC_BYTE_148_RAQ_SYNDROME_M GENMASK(31, 24) 773 774 #define V2_QPC_BYTE_152_RAQ_PSN_S 0 775 #define V2_QPC_BYTE_152_RAQ_PSN_M GENMASK(23, 0) 776 777 #define V2_QPC_BYTE_152_RAQ_TRRL_RTY_HEAD_S 24 778 #define V2_QPC_BYTE_152_RAQ_TRRL_RTY_HEAD_M GENMASK(31, 24) 779 780 #define V2_QPC_BYTE_156_RAQ_USE_PKTN_S 0 781 #define V2_QPC_BYTE_156_RAQ_USE_PKTN_M GENMASK(23, 0) 782 783 #define V2_QPC_BYTE_160_SQ_PRODUCER_IDX_S 0 784 #define V2_QPC_BYTE_160_SQ_PRODUCER_IDX_M GENMASK(15, 0) 785 786 #define V2_QPC_BYTE_160_SQ_CONSUMER_IDX_S 16 787 #define V2_QPC_BYTE_160_SQ_CONSUMER_IDX_M GENMASK(31, 16) 788 789 #define V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_S 0 790 #define V2_QPC_BYTE_168_SQ_CUR_BLK_ADDR_M GENMASK(19, 0) 791 792 #define V2_QPC_BYTE_168_MSG_RTY_LP_FLG_S 20 793 794 #define V2_QPC_BYTE_168_SQ_INVLD_FLG_S 21 795 796 #define V2_QPC_BYTE_168_LP_SGEN_INI_S 22 797 #define V2_QPC_BYTE_168_LP_SGEN_INI_M GENMASK(23, 22) 798 799 #define V2_QPC_BYTE_168_SQ_VLAN_EN_S 24 800 #define V2_QPC_BYTE_168_POLL_DB_WAIT_DO_S 25 801 #define V2_QPC_BYTE_168_SCC_TOKEN_FORBID_SQ_DEQ_S 26 802 #define V2_QPC_BYTE_168_WAIT_ACK_TIMEOUT_S 27 803 #define V2_QPC_BYTE_168_IRRL_IDX_LSB_S 28 804 #define V2_QPC_BYTE_168_IRRL_IDX_LSB_M GENMASK(31, 28) 805 806 #define V2_QPC_BYTE_172_ACK_REQ_FREQ_S 0 807 #define V2_QPC_BYTE_172_ACK_REQ_FREQ_M GENMASK(5, 0) 808 809 #define V2_QPC_BYTE_172_MSG_RNR_FLG_S 6 810 811 #define V2_QPC_BYTE_172_FRE_S 7 812 813 #define V2_QPC_BYTE_172_SQ_CUR_PSN_S 8 814 #define V2_QPC_BYTE_172_SQ_CUR_PSN_M GENMASK(31, 8) 815 816 #define V2_QPC_BYTE_176_MSG_USE_PKTN_S 0 817 #define V2_QPC_BYTE_176_MSG_USE_PKTN_M GENMASK(23, 0) 818 819 #define V2_QPC_BYTE_176_IRRL_HEAD_PRE_S 24 820 #define V2_QPC_BYTE_176_IRRL_HEAD_PRE_M GENMASK(31, 24) 821 822 #define V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_S 0 823 #define V2_QPC_BYTE_184_SQ_CUR_SGE_BLK_ADDR_M GENMASK(19, 0) 824 825 #define V2_QPC_BYTE_184_IRRL_IDX_MSB_S 20 826 #define V2_QPC_BYTE_184_IRRL_IDX_MSB_M GENMASK(31, 20) 827 828 #define V2_QPC_BYTE_192_CUR_SGE_IDX_S 0 829 #define V2_QPC_BYTE_192_CUR_SGE_IDX_M GENMASK(23, 0) 830 831 #define V2_QPC_BYTE_192_EXT_SGE_NUM_LEFT_S 24 832 #define V2_QPC_BYTE_192_EXT_SGE_NUM_LEFT_M GENMASK(31, 24) 833 834 #define V2_QPC_BYTE_196_IRRL_HEAD_S 0 835 #define V2_QPC_BYTE_196_IRRL_HEAD_M GENMASK(7, 0) 836 837 #define V2_QPC_BYTE_196_SQ_MAX_PSN_S 8 838 #define V2_QPC_BYTE_196_SQ_MAX_PSN_M GENMASK(31, 8) 839 840 #define V2_QPC_BYTE_200_SQ_MAX_IDX_S 0 841 #define V2_QPC_BYTE_200_SQ_MAX_IDX_M GENMASK(15, 0) 842 843 #define V2_QPC_BYTE_200_LCL_OPERATED_CNT_S 16 844 #define V2_QPC_BYTE_200_LCL_OPERATED_CNT_M GENMASK(31, 16) 845 846 #define V2_QPC_BYTE_208_IRRL_BA_S 0 847 #define V2_QPC_BYTE_208_IRRL_BA_M GENMASK(25, 0) 848 849 #define V2_QPC_BYTE_208_PKT_RNR_FLG_S 26 850 851 #define V2_QPC_BYTE_208_PKT_RTY_FLG_S 27 852 853 #define V2_QPC_BYTE_208_RMT_E2E_S 28 854 855 #define V2_QPC_BYTE_208_SR_MAX_S 29 856 #define V2_QPC_BYTE_208_SR_MAX_M GENMASK(31, 29) 857 858 #define V2_QPC_BYTE_212_LSN_S 0 859 #define V2_QPC_BYTE_212_LSN_M GENMASK(23, 0) 860 861 #define V2_QPC_BYTE_212_RETRY_NUM_INIT_S 24 862 #define V2_QPC_BYTE_212_RETRY_NUM_INIT_M GENMASK(26, 24) 863 864 #define V2_QPC_BYTE_212_CHECK_FLG_S 27 865 #define V2_QPC_BYTE_212_CHECK_FLG_M GENMASK(28, 27) 866 867 #define V2_QPC_BYTE_212_RETRY_CNT_S 29 868 #define V2_QPC_BYTE_212_RETRY_CNT_M GENMASK(31, 29) 869 870 #define V2_QPC_BYTE_220_RETRY_MSG_MSN_S 0 871 #define V2_QPC_BYTE_220_RETRY_MSG_MSN_M GENMASK(15, 0) 872 873 #define V2_QPC_BYTE_220_RETRY_MSG_PSN_S 16 874 #define V2_QPC_BYTE_220_RETRY_MSG_PSN_M GENMASK(31, 16) 875 876 #define V2_QPC_BYTE_224_RETRY_MSG_PSN_S 0 877 #define V2_QPC_BYTE_224_RETRY_MSG_PSN_M GENMASK(7, 0) 878 879 #define V2_QPC_BYTE_224_RETRY_MSG_FPKT_PSN_S 8 880 #define V2_QPC_BYTE_224_RETRY_MSG_FPKT_PSN_M GENMASK(31, 8) 881 882 #define V2_QPC_BYTE_232_RX_SQ_CUR_BLK_ADDR_S 0 883 #define V2_QPC_BYTE_232_RX_SQ_CUR_BLK_ADDR_M GENMASK(19, 0) 884 885 #define V2_QPC_BYTE_232_IRRL_SGE_IDX_S 20 886 #define V2_QPC_BYTE_232_IRRL_SGE_IDX_M GENMASK(28, 20) 887 888 #define V2_QPC_BYTE_232_SO_LP_VLD_S 29 889 #define V2_QPC_BYTE_232_FENCE_LP_VLD_S 30 890 #define V2_QPC_BYTE_232_IRRL_LP_VLD_S 31 891 892 #define V2_QPC_BYTE_240_IRRL_TAIL_REAL_S 0 893 #define V2_QPC_BYTE_240_IRRL_TAIL_REAL_M GENMASK(7, 0) 894 895 #define V2_QPC_BYTE_240_IRRL_TAIL_RD_S 8 896 #define V2_QPC_BYTE_240_IRRL_TAIL_RD_M GENMASK(15, 8) 897 898 #define V2_QPC_BYTE_240_RX_ACK_MSN_S 16 899 #define V2_QPC_BYTE_240_RX_ACK_MSN_M GENMASK(31, 16) 900 901 #define V2_QPC_BYTE_244_RX_ACK_EPSN_S 0 902 #define V2_QPC_BYTE_244_RX_ACK_EPSN_M GENMASK(23, 0) 903 904 #define V2_QPC_BYTE_244_RNR_NUM_INIT_S 24 905 #define V2_QPC_BYTE_244_RNR_NUM_INIT_M GENMASK(26, 24) 906 907 #define V2_QPC_BYTE_244_RNR_CNT_S 27 908 #define V2_QPC_BYTE_244_RNR_CNT_M GENMASK(29, 27) 909 910 #define V2_QPC_BYTE_244_LCL_OP_FLG_S 30 911 #define V2_QPC_BYTE_244_IRRL_RD_FLG_S 31 912 913 #define V2_QPC_BYTE_248_IRRL_PSN_S 0 914 #define V2_QPC_BYTE_248_IRRL_PSN_M GENMASK(23, 0) 915 916 #define V2_QPC_BYTE_248_ACK_PSN_ERR_S 24 917 918 #define V2_QPC_BYTE_248_ACK_LAST_OPTYPE_S 25 919 #define V2_QPC_BYTE_248_ACK_LAST_OPTYPE_M GENMASK(26, 25) 920 921 #define V2_QPC_BYTE_248_IRRL_PSN_VLD_S 27 922 923 #define V2_QPC_BYTE_248_RNR_RETRY_FLAG_S 28 924 925 #define V2_QPC_BYTE_248_CQ_ERR_IND_S 31 926 927 #define V2_QPC_BYTE_252_TX_CQN_S 0 928 #define V2_QPC_BYTE_252_TX_CQN_M GENMASK(23, 0) 929 930 #define V2_QPC_BYTE_252_SIG_TYPE_S 24 931 932 #define V2_QPC_BYTE_252_ERR_TYPE_S 25 933 #define V2_QPC_BYTE_252_ERR_TYPE_M GENMASK(31, 25) 934 935 #define V2_QPC_BYTE_256_RQ_CQE_IDX_S 0 936 #define V2_QPC_BYTE_256_RQ_CQE_IDX_M GENMASK(15, 0) 937 938 #define V2_QPC_BYTE_256_SQ_FLUSH_IDX_S 16 939 #define V2_QPC_BYTE_256_SQ_FLUSH_IDX_M GENMASK(31, 16) 940 941 #define QPCEX_FIELD_LOC(h, l) FIELD_LOC(struct hns_roce_v2_qp_context_ex, h, l) 942 943 #define QPCEX_STASH QPCEX_FIELD_LOC(82, 82) 944 945 #define V2_QP_RWE_S 1 /* rdma write enable */ 946 #define V2_QP_RRE_S 2 /* rdma read enable */ 947 #define V2_QP_ATE_S 3 /* rdma atomic enable */ 948 949 struct hns_roce_v2_cqe { 950 __le32 byte_4; 951 union { 952 __le32 rkey; 953 __le32 immtdata; 954 }; 955 __le32 byte_12; 956 __le32 byte_16; 957 __le32 byte_cnt; 958 u8 smac[4]; 959 __le32 byte_28; 960 __le32 byte_32; 961 __le32 rsv[8]; 962 }; 963 964 #define V2_CQE_BYTE_4_OPCODE_S 0 965 #define V2_CQE_BYTE_4_OPCODE_M GENMASK(4, 0) 966 967 #define V2_CQE_BYTE_4_RQ_INLINE_S 5 968 969 #define V2_CQE_BYTE_4_S_R_S 6 970 971 #define V2_CQE_BYTE_4_OWNER_S 7 972 973 #define V2_CQE_BYTE_4_STATUS_S 8 974 #define V2_CQE_BYTE_4_STATUS_M GENMASK(15, 8) 975 976 #define V2_CQE_BYTE_4_WQE_INDX_S 16 977 #define V2_CQE_BYTE_4_WQE_INDX_M GENMASK(31, 16) 978 979 #define V2_CQE_BYTE_12_XRC_SRQN_S 0 980 #define V2_CQE_BYTE_12_XRC_SRQN_M GENMASK(23, 0) 981 982 #define V2_CQE_BYTE_16_LCL_QPN_S 0 983 #define V2_CQE_BYTE_16_LCL_QPN_M GENMASK(23, 0) 984 985 #define V2_CQE_BYTE_16_SUB_STATUS_S 24 986 #define V2_CQE_BYTE_16_SUB_STATUS_M GENMASK(31, 24) 987 988 #define V2_CQE_BYTE_28_SMAC_4_S 0 989 #define V2_CQE_BYTE_28_SMAC_4_M GENMASK(7, 0) 990 991 #define V2_CQE_BYTE_28_SMAC_5_S 8 992 #define V2_CQE_BYTE_28_SMAC_5_M GENMASK(15, 8) 993 994 #define V2_CQE_BYTE_28_PORT_TYPE_S 16 995 #define V2_CQE_BYTE_28_PORT_TYPE_M GENMASK(17, 16) 996 997 #define V2_CQE_BYTE_28_VID_S 18 998 #define V2_CQE_BYTE_28_VID_M GENMASK(29, 18) 999 1000 #define V2_CQE_BYTE_28_VID_VLD_S 30 1001 1002 #define V2_CQE_BYTE_32_RMT_QPN_S 0 1003 #define V2_CQE_BYTE_32_RMT_QPN_M GENMASK(23, 0) 1004 1005 #define V2_CQE_BYTE_32_SL_S 24 1006 #define V2_CQE_BYTE_32_SL_M GENMASK(26, 24) 1007 1008 #define V2_CQE_BYTE_32_PORTN_S 27 1009 #define V2_CQE_BYTE_32_PORTN_M GENMASK(29, 27) 1010 1011 #define V2_CQE_BYTE_32_GRH_S 30 1012 1013 #define V2_CQE_BYTE_32_LPK_S 31 1014 1015 struct hns_roce_v2_mpt_entry { 1016 __le32 byte_4_pd_hop_st; 1017 __le32 byte_8_mw_cnt_en; 1018 __le32 byte_12_mw_pa; 1019 __le32 bound_lkey; 1020 __le32 len_l; 1021 __le32 len_h; 1022 __le32 lkey; 1023 __le32 va_l; 1024 __le32 va_h; 1025 __le32 pbl_size; 1026 __le32 pbl_ba_l; 1027 __le32 byte_48_mode_ba; 1028 __le32 pa0_l; 1029 __le32 byte_56_pa0_h; 1030 __le32 pa1_l; 1031 __le32 byte_64_buf_pa1; 1032 }; 1033 1034 #define MPT_FIELD_LOC(h, l) FIELD_LOC(struct hns_roce_v2_mpt_entry, h, l) 1035 1036 #define MPT_ST MPT_FIELD_LOC(1, 0) 1037 #define MPT_PBL_HOP_NUM MPT_FIELD_LOC(3, 2) 1038 #define MPT_PBL_BA_PG_SZ MPT_FIELD_LOC(7, 4) 1039 #define MPT_PD MPT_FIELD_LOC(31, 8) 1040 #define MPT_RA_EN MPT_FIELD_LOC(32, 32) 1041 #define MPT_R_INV_EN MPT_FIELD_LOC(33, 33) 1042 #define MPT_L_INV_EN MPT_FIELD_LOC(34, 34) 1043 #define MPT_BIND_EN MPT_FIELD_LOC(35, 35) 1044 #define MPT_ATOMIC_EN MPT_FIELD_LOC(36, 36) 1045 #define MPT_RR_EN MPT_FIELD_LOC(37, 37) 1046 #define MPT_RW_EN MPT_FIELD_LOC(38, 38) 1047 #define MPT_LW_EN MPT_FIELD_LOC(39, 39) 1048 #define MPT_MW_CNT MPT_FIELD_LOC(63, 40) 1049 #define MPT_FRE MPT_FIELD_LOC(64, 64) 1050 #define MPT_PA MPT_FIELD_LOC(65, 65) 1051 #define MPT_ZBVA MPT_FIELD_LOC(66, 66) 1052 #define MPT_SHARE MPT_FIELD_LOC(67, 67) 1053 #define MPT_MR_MW MPT_FIELD_LOC(68, 68) 1054 #define MPT_BPD MPT_FIELD_LOC(69, 69) 1055 #define MPT_BQP MPT_FIELD_LOC(70, 70) 1056 #define MPT_INNER_PA_VLD MPT_FIELD_LOC(71, 71) 1057 #define MPT_MW_BIND_QPN MPT_FIELD_LOC(95, 72) 1058 #define MPT_BOUND_LKEY MPT_FIELD_LOC(127, 96) 1059 #define MPT_LEN MPT_FIELD_LOC(191, 128) 1060 #define MPT_LKEY MPT_FIELD_LOC(223, 192) 1061 #define MPT_VA MPT_FIELD_LOC(287, 224) 1062 #define MPT_PBL_SIZE MPT_FIELD_LOC(319, 288) 1063 #define MPT_PBL_BA MPT_FIELD_LOC(380, 320) 1064 #define MPT_BLK_MODE MPT_FIELD_LOC(381, 381) 1065 #define MPT_RSV0 MPT_FIELD_LOC(383, 382) 1066 #define MPT_PA0 MPT_FIELD_LOC(441, 384) 1067 #define MPT_BOUND_VA MPT_FIELD_LOC(447, 442) 1068 #define MPT_PA1 MPT_FIELD_LOC(505, 448) 1069 #define MPT_PERSIST_EN MPT_FIELD_LOC(506, 506) 1070 #define MPT_RSV2 MPT_FIELD_LOC(507, 507) 1071 #define MPT_PBL_BUF_PG_SZ MPT_FIELD_LOC(511, 508) 1072 1073 #define V2_MPT_BYTE_4_MPT_ST_S 0 1074 #define V2_MPT_BYTE_4_MPT_ST_M GENMASK(1, 0) 1075 1076 #define V2_MPT_BYTE_4_PBL_HOP_NUM_S 2 1077 #define V2_MPT_BYTE_4_PBL_HOP_NUM_M GENMASK(3, 2) 1078 1079 #define V2_MPT_BYTE_4_PBL_BA_PG_SZ_S 4 1080 #define V2_MPT_BYTE_4_PBL_BA_PG_SZ_M GENMASK(7, 4) 1081 1082 #define V2_MPT_BYTE_4_PD_S 8 1083 #define V2_MPT_BYTE_4_PD_M GENMASK(31, 8) 1084 1085 #define V2_MPT_BYTE_8_RA_EN_S 0 1086 1087 #define V2_MPT_BYTE_8_R_INV_EN_S 1 1088 1089 #define V2_MPT_BYTE_8_L_INV_EN_S 2 1090 1091 #define V2_MPT_BYTE_8_BIND_EN_S 3 1092 1093 #define V2_MPT_BYTE_8_ATOMIC_EN_S 4 1094 1095 #define V2_MPT_BYTE_8_RR_EN_S 5 1096 1097 #define V2_MPT_BYTE_8_RW_EN_S 6 1098 1099 #define V2_MPT_BYTE_8_LW_EN_S 7 1100 1101 #define V2_MPT_BYTE_8_MW_CNT_S 8 1102 #define V2_MPT_BYTE_8_MW_CNT_M GENMASK(31, 8) 1103 1104 #define V2_MPT_BYTE_12_FRE_S 0 1105 1106 #define V2_MPT_BYTE_12_PA_S 1 1107 1108 #define V2_MPT_BYTE_12_MR_MW_S 4 1109 1110 #define V2_MPT_BYTE_12_BPD_S 5 1111 1112 #define V2_MPT_BYTE_12_BQP_S 6 1113 1114 #define V2_MPT_BYTE_12_INNER_PA_VLD_S 7 1115 1116 #define V2_MPT_BYTE_12_MW_BIND_QPN_S 8 1117 #define V2_MPT_BYTE_12_MW_BIND_QPN_M GENMASK(31, 8) 1118 1119 #define V2_MPT_BYTE_48_PBL_BA_H_S 0 1120 #define V2_MPT_BYTE_48_PBL_BA_H_M GENMASK(28, 0) 1121 1122 #define V2_MPT_BYTE_48_BLK_MODE_S 29 1123 1124 #define V2_MPT_BYTE_56_PA0_H_S 0 1125 #define V2_MPT_BYTE_56_PA0_H_M GENMASK(25, 0) 1126 1127 #define V2_MPT_BYTE_64_PA1_H_S 0 1128 #define V2_MPT_BYTE_64_PA1_H_M GENMASK(25, 0) 1129 1130 #define V2_MPT_BYTE_64_PBL_BUF_PG_SZ_S 28 1131 #define V2_MPT_BYTE_64_PBL_BUF_PG_SZ_M GENMASK(31, 28) 1132 1133 #define V2_DB_BYTE_4_TAG_S 0 1134 #define V2_DB_BYTE_4_TAG_M GENMASK(23, 0) 1135 1136 #define V2_DB_BYTE_4_CMD_S 24 1137 #define V2_DB_BYTE_4_CMD_M GENMASK(27, 24) 1138 1139 #define V2_DB_FLAG_S 31 1140 1141 #define V2_DB_PARAMETER_IDX_S 0 1142 #define V2_DB_PARAMETER_IDX_M GENMASK(15, 0) 1143 1144 #define V2_DB_PARAMETER_SL_S 16 1145 #define V2_DB_PARAMETER_SL_M GENMASK(18, 16) 1146 1147 #define V2_CQ_DB_BYTE_4_TAG_S 0 1148 #define V2_CQ_DB_BYTE_4_TAG_M GENMASK(23, 0) 1149 1150 #define V2_CQ_DB_BYTE_4_CMD_S 24 1151 #define V2_CQ_DB_BYTE_4_CMD_M GENMASK(27, 24) 1152 1153 #define V2_CQ_DB_PARAMETER_CONS_IDX_S 0 1154 #define V2_CQ_DB_PARAMETER_CONS_IDX_M GENMASK(23, 0) 1155 1156 #define V2_CQ_DB_PARAMETER_CMD_SN_S 25 1157 #define V2_CQ_DB_PARAMETER_CMD_SN_M GENMASK(26, 25) 1158 1159 #define V2_CQ_DB_PARAMETER_NOTIFY_S 24 1160 1161 struct hns_roce_v2_ud_send_wqe { 1162 __le32 byte_4; 1163 __le32 msg_len; 1164 __le32 immtdata; 1165 __le32 byte_16; 1166 __le32 byte_20; 1167 __le32 byte_24; 1168 __le32 qkey; 1169 __le32 byte_32; 1170 __le32 byte_36; 1171 __le32 byte_40; 1172 u8 dmac[ETH_ALEN]; 1173 u8 sgid_index; 1174 u8 smac_index; 1175 u8 dgid[GID_LEN_V2]; 1176 }; 1177 1178 #define V2_UD_SEND_WQE_BYTE_4_OPCODE_S 0 1179 #define V2_UD_SEND_WQE_BYTE_4_OPCODE_M GENMASK(4, 0) 1180 1181 #define V2_UD_SEND_WQE_BYTE_4_OWNER_S 7 1182 1183 #define V2_UD_SEND_WQE_BYTE_4_CQE_S 8 1184 1185 #define V2_UD_SEND_WQE_BYTE_4_SE_S 11 1186 1187 #define V2_UD_SEND_WQE_BYTE_16_PD_S 0 1188 #define V2_UD_SEND_WQE_BYTE_16_PD_M GENMASK(23, 0) 1189 1190 #define V2_UD_SEND_WQE_BYTE_16_SGE_NUM_S 24 1191 #define V2_UD_SEND_WQE_BYTE_16_SGE_NUM_M GENMASK(31, 24) 1192 1193 #define V2_UD_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_S 0 1194 #define V2_UD_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_M GENMASK(23, 0) 1195 1196 #define V2_UD_SEND_WQE_BYTE_24_UDPSPN_S 16 1197 #define V2_UD_SEND_WQE_BYTE_24_UDPSPN_M GENMASK(31, 16) 1198 1199 #define V2_UD_SEND_WQE_BYTE_32_DQPN_S 0 1200 #define V2_UD_SEND_WQE_BYTE_32_DQPN_M GENMASK(23, 0) 1201 1202 #define V2_UD_SEND_WQE_BYTE_36_VLAN_S 0 1203 #define V2_UD_SEND_WQE_BYTE_36_VLAN_M GENMASK(15, 0) 1204 1205 #define V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_S 16 1206 #define V2_UD_SEND_WQE_BYTE_36_HOPLIMIT_M GENMASK(23, 16) 1207 1208 #define V2_UD_SEND_WQE_BYTE_36_TCLASS_S 24 1209 #define V2_UD_SEND_WQE_BYTE_36_TCLASS_M GENMASK(31, 24) 1210 1211 #define V2_UD_SEND_WQE_BYTE_40_FLOW_LABEL_S 0 1212 #define V2_UD_SEND_WQE_BYTE_40_FLOW_LABEL_M GENMASK(19, 0) 1213 1214 #define V2_UD_SEND_WQE_BYTE_40_SL_S 20 1215 #define V2_UD_SEND_WQE_BYTE_40_SL_M GENMASK(23, 20) 1216 1217 #define V2_UD_SEND_WQE_BYTE_40_UD_VLAN_EN_S 30 1218 1219 #define V2_UD_SEND_WQE_BYTE_40_LBI_S 31 1220 1221 struct hns_roce_v2_rc_send_wqe { 1222 __le32 byte_4; 1223 __le32 msg_len; 1224 union { 1225 __le32 inv_key; 1226 __le32 immtdata; 1227 }; 1228 __le32 byte_16; 1229 __le32 byte_20; 1230 __le32 rkey; 1231 __le64 va; 1232 }; 1233 1234 #define V2_RC_SEND_WQE_BYTE_4_OPCODE_S 0 1235 #define V2_RC_SEND_WQE_BYTE_4_OPCODE_M GENMASK(4, 0) 1236 1237 #define V2_RC_SEND_WQE_BYTE_4_DB_SL_L_S 5 1238 #define V2_RC_SEND_WQE_BYTE_4_DB_SL_L_M GENMASK(6, 5) 1239 1240 #define V2_RC_SEND_WQE_BYTE_4_DB_SL_H_S 13 1241 #define V2_RC_SEND_WQE_BYTE_4_DB_SL_H_M GENMASK(14, 13) 1242 1243 #define V2_RC_SEND_WQE_BYTE_4_WQE_INDEX_S 15 1244 #define V2_RC_SEND_WQE_BYTE_4_WQE_INDEX_M GENMASK(30, 15) 1245 1246 #define V2_RC_SEND_WQE_BYTE_4_OWNER_S 7 1247 1248 #define V2_RC_SEND_WQE_BYTE_4_CQE_S 8 1249 1250 #define V2_RC_SEND_WQE_BYTE_4_FENCE_S 9 1251 1252 #define V2_RC_SEND_WQE_BYTE_4_SO_S 10 1253 1254 #define V2_RC_SEND_WQE_BYTE_4_SE_S 11 1255 1256 #define V2_RC_SEND_WQE_BYTE_4_INLINE_S 12 1257 1258 #define V2_RC_FRMR_WQE_BYTE_40_BIND_EN_S 10 1259 1260 #define V2_RC_FRMR_WQE_BYTE_40_ATOMIC_S 11 1261 1262 #define V2_RC_FRMR_WQE_BYTE_40_RR_S 12 1263 1264 #define V2_RC_FRMR_WQE_BYTE_40_RW_S 13 1265 1266 #define V2_RC_FRMR_WQE_BYTE_40_LW_S 14 1267 1268 #define V2_RC_SEND_WQE_BYTE_4_FLAG_S 31 1269 1270 #define V2_RC_SEND_WQE_BYTE_16_XRC_SRQN_S 0 1271 #define V2_RC_SEND_WQE_BYTE_16_XRC_SRQN_M GENMASK(23, 0) 1272 1273 #define V2_RC_SEND_WQE_BYTE_16_SGE_NUM_S 24 1274 #define V2_RC_SEND_WQE_BYTE_16_SGE_NUM_M GENMASK(31, 24) 1275 1276 #define V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_S 0 1277 #define V2_RC_SEND_WQE_BYTE_20_MSG_START_SGE_IDX_M GENMASK(23, 0) 1278 1279 #define V2_RC_SEND_WQE_BYTE_20_INL_TYPE_S 31 1280 1281 struct hns_roce_wqe_frmr_seg { 1282 __le32 pbl_size; 1283 __le32 byte_40; 1284 }; 1285 1286 #define V2_RC_FRMR_WQE_BYTE_40_PBL_BUF_PG_SZ_S 4 1287 #define V2_RC_FRMR_WQE_BYTE_40_PBL_BUF_PG_SZ_M GENMASK(7, 4) 1288 1289 #define V2_RC_FRMR_WQE_BYTE_40_BLK_MODE_S 8 1290 1291 struct hns_roce_v2_wqe_data_seg { 1292 __le32 len; 1293 __le32 lkey; 1294 __le64 addr; 1295 }; 1296 1297 struct hns_roce_v2_db { 1298 __le32 byte_4; 1299 __le32 parameter; 1300 }; 1301 1302 struct hns_roce_query_version { 1303 __le16 rocee_vendor_id; 1304 __le16 rocee_hw_version; 1305 __le32 rsv[5]; 1306 }; 1307 1308 struct hns_roce_query_fw_info { 1309 __le32 fw_ver; 1310 __le32 rsv[5]; 1311 }; 1312 1313 struct hns_roce_func_clear { 1314 __le32 rst_funcid_en; 1315 __le32 func_done; 1316 __le32 rsv[4]; 1317 }; 1318 1319 #define FUNC_CLEAR_RST_FUN_DONE_S 0 1320 /* Each physical function manages up to 248 virtual functions, it takes up to 1321 * 100ms for each function to execute clear. If an abnormal reset occurs, it is 1322 * executed twice at most, so it takes up to 249 * 2 * 100ms. 1323 */ 1324 #define HNS_ROCE_V2_FUNC_CLEAR_TIMEOUT_MSECS (249 * 2 * 100) 1325 #define HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_INTERVAL 40 1326 #define HNS_ROCE_V2_READ_FUNC_CLEAR_FLAG_FAIL_WAIT 20 1327 1328 struct hns_roce_cfg_llm_a { 1329 __le32 base_addr_l; 1330 __le32 base_addr_h; 1331 __le32 depth_pgsz_init_en; 1332 __le32 head_ba_l; 1333 __le32 head_ba_h_nxtptr; 1334 __le32 head_ptr; 1335 }; 1336 1337 #define CFG_LLM_QUE_DEPTH_S 0 1338 #define CFG_LLM_QUE_DEPTH_M GENMASK(12, 0) 1339 1340 #define CFG_LLM_QUE_PGSZ_S 16 1341 #define CFG_LLM_QUE_PGSZ_M GENMASK(19, 16) 1342 1343 #define CFG_LLM_INIT_EN_S 20 1344 #define CFG_LLM_INIT_EN_M GENMASK(20, 20) 1345 1346 #define CFG_LLM_HEAD_PTR_S 0 1347 #define CFG_LLM_HEAD_PTR_M GENMASK(11, 0) 1348 1349 struct hns_roce_cfg_llm_b { 1350 __le32 tail_ba_l; 1351 __le32 tail_ba_h; 1352 __le32 tail_ptr; 1353 __le32 rsv[3]; 1354 }; 1355 1356 #define CFG_LLM_TAIL_BA_H_S 0 1357 #define CFG_LLM_TAIL_BA_H_M GENMASK(19, 0) 1358 1359 #define CFG_LLM_TAIL_PTR_S 0 1360 #define CFG_LLM_TAIL_PTR_M GENMASK(11, 0) 1361 1362 struct hns_roce_cfg_global_param { 1363 __le32 time_cfg_udp_port; 1364 __le32 rsv[5]; 1365 }; 1366 1367 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_TIME_1US_CFG_S 0 1368 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_TIME_1US_CFG_M GENMASK(9, 0) 1369 1370 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_UDP_PORT_S 16 1371 #define CFG_GLOBAL_PARAM_DATA_0_ROCEE_UDP_PORT_M GENMASK(31, 16) 1372 1373 struct hns_roce_pf_res_a { 1374 __le32 rsv; 1375 __le32 qpc_bt_idx_num; 1376 __le32 srqc_bt_idx_num; 1377 __le32 cqc_bt_idx_num; 1378 __le32 mpt_bt_idx_num; 1379 __le32 eqc_bt_idx_num; 1380 }; 1381 1382 #define PF_RES_DATA_1_PF_QPC_BT_IDX_S 0 1383 #define PF_RES_DATA_1_PF_QPC_BT_IDX_M GENMASK(10, 0) 1384 1385 #define PF_RES_DATA_1_PF_QPC_BT_NUM_S 16 1386 #define PF_RES_DATA_1_PF_QPC_BT_NUM_M GENMASK(27, 16) 1387 1388 #define PF_RES_DATA_2_PF_SRQC_BT_IDX_S 0 1389 #define PF_RES_DATA_2_PF_SRQC_BT_IDX_M GENMASK(8, 0) 1390 1391 #define PF_RES_DATA_2_PF_SRQC_BT_NUM_S 16 1392 #define PF_RES_DATA_2_PF_SRQC_BT_NUM_M GENMASK(25, 16) 1393 1394 #define PF_RES_DATA_3_PF_CQC_BT_IDX_S 0 1395 #define PF_RES_DATA_3_PF_CQC_BT_IDX_M GENMASK(8, 0) 1396 1397 #define PF_RES_DATA_3_PF_CQC_BT_NUM_S 16 1398 #define PF_RES_DATA_3_PF_CQC_BT_NUM_M GENMASK(25, 16) 1399 1400 #define PF_RES_DATA_4_PF_MPT_BT_IDX_S 0 1401 #define PF_RES_DATA_4_PF_MPT_BT_IDX_M GENMASK(8, 0) 1402 1403 #define PF_RES_DATA_4_PF_MPT_BT_NUM_S 16 1404 #define PF_RES_DATA_4_PF_MPT_BT_NUM_M GENMASK(25, 16) 1405 1406 #define PF_RES_DATA_5_PF_EQC_BT_IDX_S 0 1407 #define PF_RES_DATA_5_PF_EQC_BT_IDX_M GENMASK(8, 0) 1408 1409 #define PF_RES_DATA_5_PF_EQC_BT_NUM_S 16 1410 #define PF_RES_DATA_5_PF_EQC_BT_NUM_M GENMASK(25, 16) 1411 1412 struct hns_roce_pf_res_b { 1413 __le32 rsv0; 1414 __le32 smac_idx_num; 1415 __le32 sgid_idx_num; 1416 __le32 qid_idx_sl_num; 1417 __le32 sccc_bt_idx_num; 1418 __le32 gmv_idx_num; 1419 }; 1420 1421 #define PF_RES_DATA_1_PF_SMAC_IDX_S 0 1422 #define PF_RES_DATA_1_PF_SMAC_IDX_M GENMASK(7, 0) 1423 1424 #define PF_RES_DATA_1_PF_SMAC_NUM_S 8 1425 #define PF_RES_DATA_1_PF_SMAC_NUM_M GENMASK(16, 8) 1426 1427 #define PF_RES_DATA_2_PF_SGID_IDX_S 0 1428 #define PF_RES_DATA_2_PF_SGID_IDX_M GENMASK(7, 0) 1429 1430 #define PF_RES_DATA_2_PF_SGID_NUM_S 8 1431 #define PF_RES_DATA_2_PF_SGID_NUM_M GENMASK(16, 8) 1432 1433 #define PF_RES_DATA_3_PF_QID_IDX_S 0 1434 #define PF_RES_DATA_3_PF_QID_IDX_M GENMASK(9, 0) 1435 1436 #define PF_RES_DATA_3_PF_SL_NUM_S 16 1437 #define PF_RES_DATA_3_PF_SL_NUM_M GENMASK(26, 16) 1438 1439 #define PF_RES_DATA_4_PF_SCCC_BT_IDX_S 0 1440 #define PF_RES_DATA_4_PF_SCCC_BT_IDX_M GENMASK(8, 0) 1441 1442 #define PF_RES_DATA_4_PF_SCCC_BT_NUM_S 9 1443 #define PF_RES_DATA_4_PF_SCCC_BT_NUM_M GENMASK(17, 9) 1444 1445 #define PF_RES_DATA_5_PF_GMV_BT_IDX_S 0 1446 #define PF_RES_DATA_5_PF_GMV_BT_IDX_M GENMASK(7, 0) 1447 1448 #define PF_RES_DATA_5_PF_GMV_BT_NUM_S 8 1449 #define PF_RES_DATA_5_PF_GMV_BT_NUM_M GENMASK(16, 8) 1450 1451 struct hns_roce_pf_timer_res_a { 1452 __le32 rsv0; 1453 __le32 qpc_timer_bt_idx_num; 1454 __le32 cqc_timer_bt_idx_num; 1455 __le32 rsv[3]; 1456 }; 1457 1458 #define PF_RES_DATA_1_PF_QPC_TIMER_BT_IDX_S 0 1459 #define PF_RES_DATA_1_PF_QPC_TIMER_BT_IDX_M GENMASK(11, 0) 1460 1461 #define PF_RES_DATA_1_PF_QPC_TIMER_BT_NUM_S 16 1462 #define PF_RES_DATA_1_PF_QPC_TIMER_BT_NUM_M GENMASK(28, 16) 1463 1464 #define PF_RES_DATA_2_PF_CQC_TIMER_BT_IDX_S 0 1465 #define PF_RES_DATA_2_PF_CQC_TIMER_BT_IDX_M GENMASK(10, 0) 1466 1467 #define PF_RES_DATA_2_PF_CQC_TIMER_BT_NUM_S 16 1468 #define PF_RES_DATA_2_PF_CQC_TIMER_BT_NUM_M GENMASK(27, 16) 1469 1470 struct hns_roce_vf_res_a { 1471 __le32 vf_id; 1472 __le32 vf_qpc_bt_idx_num; 1473 __le32 vf_srqc_bt_idx_num; 1474 __le32 vf_cqc_bt_idx_num; 1475 __le32 vf_mpt_bt_idx_num; 1476 __le32 vf_eqc_bt_idx_num; 1477 }; 1478 1479 #define VF_RES_A_DATA_1_VF_QPC_BT_IDX_S 0 1480 #define VF_RES_A_DATA_1_VF_QPC_BT_IDX_M GENMASK(10, 0) 1481 1482 #define VF_RES_A_DATA_1_VF_QPC_BT_NUM_S 16 1483 #define VF_RES_A_DATA_1_VF_QPC_BT_NUM_M GENMASK(27, 16) 1484 1485 #define VF_RES_A_DATA_2_VF_SRQC_BT_IDX_S 0 1486 #define VF_RES_A_DATA_2_VF_SRQC_BT_IDX_M GENMASK(8, 0) 1487 1488 #define VF_RES_A_DATA_2_VF_SRQC_BT_NUM_S 16 1489 #define VF_RES_A_DATA_2_VF_SRQC_BT_NUM_M GENMASK(25, 16) 1490 1491 #define VF_RES_A_DATA_3_VF_CQC_BT_IDX_S 0 1492 #define VF_RES_A_DATA_3_VF_CQC_BT_IDX_M GENMASK(8, 0) 1493 1494 #define VF_RES_A_DATA_3_VF_CQC_BT_NUM_S 16 1495 #define VF_RES_A_DATA_3_VF_CQC_BT_NUM_M GENMASK(25, 16) 1496 1497 #define VF_RES_A_DATA_4_VF_MPT_BT_IDX_S 0 1498 #define VF_RES_A_DATA_4_VF_MPT_BT_IDX_M GENMASK(8, 0) 1499 1500 #define VF_RES_A_DATA_4_VF_MPT_BT_NUM_S 16 1501 #define VF_RES_A_DATA_4_VF_MPT_BT_NUM_M GENMASK(25, 16) 1502 1503 #define VF_RES_A_DATA_5_VF_EQC_IDX_S 0 1504 #define VF_RES_A_DATA_5_VF_EQC_IDX_M GENMASK(8, 0) 1505 1506 #define VF_RES_A_DATA_5_VF_EQC_NUM_S 16 1507 #define VF_RES_A_DATA_5_VF_EQC_NUM_M GENMASK(25, 16) 1508 1509 struct hns_roce_vf_res_b { 1510 __le32 rsv0; 1511 __le32 vf_smac_idx_num; 1512 __le32 vf_sgid_idx_num; 1513 __le32 vf_qid_idx_sl_num; 1514 __le32 vf_sccc_idx_num; 1515 __le32 vf_gmv_idx_num; 1516 }; 1517 1518 #define VF_RES_B_DATA_0_VF_ID_S 0 1519 #define VF_RES_B_DATA_0_VF_ID_M GENMASK(7, 0) 1520 1521 #define VF_RES_B_DATA_1_VF_SMAC_IDX_S 0 1522 #define VF_RES_B_DATA_1_VF_SMAC_IDX_M GENMASK(7, 0) 1523 1524 #define VF_RES_B_DATA_1_VF_SMAC_NUM_S 8 1525 #define VF_RES_B_DATA_1_VF_SMAC_NUM_M GENMASK(16, 8) 1526 1527 #define VF_RES_B_DATA_2_VF_SGID_IDX_S 0 1528 #define VF_RES_B_DATA_2_VF_SGID_IDX_M GENMASK(7, 0) 1529 1530 #define VF_RES_B_DATA_2_VF_SGID_NUM_S 8 1531 #define VF_RES_B_DATA_2_VF_SGID_NUM_M GENMASK(16, 8) 1532 1533 #define VF_RES_B_DATA_3_VF_QID_IDX_S 0 1534 #define VF_RES_B_DATA_3_VF_QID_IDX_M GENMASK(9, 0) 1535 1536 #define VF_RES_B_DATA_3_VF_SL_NUM_S 16 1537 #define VF_RES_B_DATA_3_VF_SL_NUM_M GENMASK(19, 16) 1538 1539 #define VF_RES_B_DATA_4_VF_SCCC_BT_IDX_S 0 1540 #define VF_RES_B_DATA_4_VF_SCCC_BT_IDX_M GENMASK(8, 0) 1541 1542 #define VF_RES_B_DATA_4_VF_SCCC_BT_NUM_S 9 1543 #define VF_RES_B_DATA_4_VF_SCCC_BT_NUM_M GENMASK(17, 9) 1544 1545 #define VF_RES_B_DATA_5_VF_GMV_BT_IDX_S 0 1546 #define VF_RES_B_DATA_5_VF_GMV_BT_IDX_M GENMASK(7, 0) 1547 1548 #define VF_RES_B_DATA_5_VF_GMV_BT_NUM_S 16 1549 #define VF_RES_B_DATA_5_VF_GMV_BT_NUM_M GENMASK(24, 16) 1550 1551 struct hns_roce_vf_switch { 1552 __le32 rocee_sel; 1553 __le32 fun_id; 1554 __le32 cfg; 1555 __le32 resv1; 1556 __le32 resv2; 1557 __le32 resv3; 1558 }; 1559 1560 #define VF_SWITCH_DATA_FUN_ID_VF_ID_S 3 1561 #define VF_SWITCH_DATA_FUN_ID_VF_ID_M GENMASK(10, 3) 1562 1563 #define VF_SWITCH_DATA_CFG_ALW_LPBK_S 1 1564 #define VF_SWITCH_DATA_CFG_ALW_LCL_LPBK_S 2 1565 #define VF_SWITCH_DATA_CFG_ALW_DST_OVRD_S 3 1566 1567 struct hns_roce_post_mbox { 1568 __le32 in_param_l; 1569 __le32 in_param_h; 1570 __le32 out_param_l; 1571 __le32 out_param_h; 1572 __le32 cmd_tag; 1573 __le32 token_event_en; 1574 }; 1575 1576 struct hns_roce_mbox_status { 1577 __le32 mb_status_hw_run; 1578 __le32 rsv[5]; 1579 }; 1580 1581 struct hns_roce_cfg_bt_attr { 1582 __le32 vf_qpc_cfg; 1583 __le32 vf_srqc_cfg; 1584 __le32 vf_cqc_cfg; 1585 __le32 vf_mpt_cfg; 1586 __le32 vf_sccc_cfg; 1587 __le32 rsv; 1588 }; 1589 1590 #define CFG_BT_ATTR_DATA_0_VF_QPC_BA_PGSZ_S 0 1591 #define CFG_BT_ATTR_DATA_0_VF_QPC_BA_PGSZ_M GENMASK(3, 0) 1592 1593 #define CFG_BT_ATTR_DATA_0_VF_QPC_BUF_PGSZ_S 4 1594 #define CFG_BT_ATTR_DATA_0_VF_QPC_BUF_PGSZ_M GENMASK(7, 4) 1595 1596 #define CFG_BT_ATTR_DATA_0_VF_QPC_HOPNUM_S 8 1597 #define CFG_BT_ATTR_DATA_0_VF_QPC_HOPNUM_M GENMASK(9, 8) 1598 1599 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BA_PGSZ_S 0 1600 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BA_PGSZ_M GENMASK(3, 0) 1601 1602 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BUF_PGSZ_S 4 1603 #define CFG_BT_ATTR_DATA_1_VF_SRQC_BUF_PGSZ_M GENMASK(7, 4) 1604 1605 #define CFG_BT_ATTR_DATA_1_VF_SRQC_HOPNUM_S 8 1606 #define CFG_BT_ATTR_DATA_1_VF_SRQC_HOPNUM_M GENMASK(9, 8) 1607 1608 #define CFG_BT_ATTR_DATA_2_VF_CQC_BA_PGSZ_S 0 1609 #define CFG_BT_ATTR_DATA_2_VF_CQC_BA_PGSZ_M GENMASK(3, 0) 1610 1611 #define CFG_BT_ATTR_DATA_2_VF_CQC_BUF_PGSZ_S 4 1612 #define CFG_BT_ATTR_DATA_2_VF_CQC_BUF_PGSZ_M GENMASK(7, 4) 1613 1614 #define CFG_BT_ATTR_DATA_2_VF_CQC_HOPNUM_S 8 1615 #define CFG_BT_ATTR_DATA_2_VF_CQC_HOPNUM_M GENMASK(9, 8) 1616 1617 #define CFG_BT_ATTR_DATA_3_VF_MPT_BA_PGSZ_S 0 1618 #define CFG_BT_ATTR_DATA_3_VF_MPT_BA_PGSZ_M GENMASK(3, 0) 1619 1620 #define CFG_BT_ATTR_DATA_3_VF_MPT_BUF_PGSZ_S 4 1621 #define CFG_BT_ATTR_DATA_3_VF_MPT_BUF_PGSZ_M GENMASK(7, 4) 1622 1623 #define CFG_BT_ATTR_DATA_3_VF_MPT_HOPNUM_S 8 1624 #define CFG_BT_ATTR_DATA_3_VF_MPT_HOPNUM_M GENMASK(9, 8) 1625 1626 #define CFG_BT_ATTR_DATA_4_VF_SCCC_BA_PGSZ_S 0 1627 #define CFG_BT_ATTR_DATA_4_VF_SCCC_BA_PGSZ_M GENMASK(3, 0) 1628 1629 #define CFG_BT_ATTR_DATA_4_VF_SCCC_BUF_PGSZ_S 4 1630 #define CFG_BT_ATTR_DATA_4_VF_SCCC_BUF_PGSZ_M GENMASK(7, 4) 1631 1632 #define CFG_BT_ATTR_DATA_4_VF_SCCC_HOPNUM_S 8 1633 #define CFG_BT_ATTR_DATA_4_VF_SCCC_HOPNUM_M GENMASK(9, 8) 1634 1635 struct hns_roce_cfg_sgid_tb { 1636 __le32 table_idx_rsv; 1637 __le32 vf_sgid_l; 1638 __le32 vf_sgid_ml; 1639 __le32 vf_sgid_mh; 1640 __le32 vf_sgid_h; 1641 __le32 vf_sgid_type_rsv; 1642 }; 1643 1644 enum { 1645 HNS_ROCE_CFG_QPC_SIZE = BIT(0), 1646 HNS_ROCE_CFG_SCCC_SIZE = BIT(1), 1647 }; 1648 1649 struct hns_roce_cfg_entry_size { 1650 __le32 type; 1651 __le32 rsv[4]; 1652 __le32 size; 1653 }; 1654 1655 #define CFG_SGID_TB_TABLE_IDX_S 0 1656 #define CFG_SGID_TB_TABLE_IDX_M GENMASK(7, 0) 1657 1658 #define CFG_SGID_TB_VF_SGID_TYPE_S 0 1659 #define CFG_SGID_TB_VF_SGID_TYPE_M GENMASK(1, 0) 1660 1661 struct hns_roce_cfg_smac_tb { 1662 __le32 tb_idx_rsv; 1663 __le32 vf_smac_l; 1664 __le32 vf_smac_h_rsv; 1665 __le32 rsv[3]; 1666 }; 1667 #define CFG_SMAC_TB_IDX_S 0 1668 #define CFG_SMAC_TB_IDX_M GENMASK(7, 0) 1669 1670 #define CFG_SMAC_TB_VF_SMAC_H_S 0 1671 #define CFG_SMAC_TB_VF_SMAC_H_M GENMASK(15, 0) 1672 1673 struct hns_roce_cfg_gmv_bt { 1674 __le32 gmv_ba_l; 1675 __le32 gmv_ba_h; 1676 __le32 gmv_bt_idx; 1677 __le32 rsv[3]; 1678 }; 1679 1680 #define CFG_GMV_BA_H_S 0 1681 #define CFG_GMV_BA_H_M GENMASK(19, 0) 1682 1683 struct hns_roce_cfg_gmv_tb_a { 1684 __le32 vf_sgid_l; 1685 __le32 vf_sgid_ml; 1686 __le32 vf_sgid_mh; 1687 __le32 vf_sgid_h; 1688 __le32 vf_sgid_type_vlan; 1689 __le32 resv; 1690 }; 1691 1692 #define CFG_GMV_TB_SGID_IDX_S 0 1693 #define CFG_GMV_TB_SGID_IDX_M GENMASK(7, 0) 1694 1695 #define CFG_GMV_TB_VF_SGID_TYPE_S 0 1696 #define CFG_GMV_TB_VF_SGID_TYPE_M GENMASK(1, 0) 1697 1698 #define CFG_GMV_TB_VF_VLAN_EN_S 2 1699 1700 #define CFG_GMV_TB_VF_VLAN_ID_S 16 1701 #define CFG_GMV_TB_VF_VLAN_ID_M GENMASK(27, 16) 1702 1703 struct hns_roce_cfg_gmv_tb_b { 1704 __le32 vf_smac_l; 1705 __le32 vf_smac_h; 1706 __le32 table_idx_rsv; 1707 __le32 resv[3]; 1708 }; 1709 1710 #define CFG_GMV_TB_SMAC_H_S 0 1711 #define CFG_GMV_TB_SMAC_H_M GENMASK(15, 0) 1712 1713 #define HNS_ROCE_QUERY_PF_CAPS_CMD_NUM 5 1714 struct hns_roce_query_pf_caps_a { 1715 u8 number_ports; 1716 u8 local_ca_ack_delay; 1717 __le16 max_sq_sg; 1718 __le16 max_sq_inline; 1719 __le16 max_rq_sg; 1720 __le32 max_extend_sg; 1721 __le16 num_qpc_timer; 1722 __le16 num_cqc_timer; 1723 __le16 max_srq_sges; 1724 u8 num_aeq_vectors; 1725 u8 num_other_vectors; 1726 u8 max_sq_desc_sz; 1727 u8 max_rq_desc_sz; 1728 u8 max_srq_desc_sz; 1729 u8 cqe_sz; 1730 }; 1731 1732 struct hns_roce_query_pf_caps_b { 1733 u8 mtpt_entry_sz; 1734 u8 irrl_entry_sz; 1735 u8 trrl_entry_sz; 1736 u8 cqc_entry_sz; 1737 u8 srqc_entry_sz; 1738 u8 idx_entry_sz; 1739 u8 sccc_sz; 1740 u8 max_mtu; 1741 __le16 qpc_sz; 1742 __le16 qpc_timer_entry_sz; 1743 __le16 cqc_timer_entry_sz; 1744 u8 min_cqes; 1745 u8 min_wqes; 1746 __le32 page_size_cap; 1747 u8 pkey_table_len; 1748 u8 phy_num_uars; 1749 u8 ctx_hop_num; 1750 u8 pbl_hop_num; 1751 }; 1752 1753 struct hns_roce_query_pf_caps_c { 1754 __le32 cap_flags_num_pds; 1755 __le32 max_gid_num_cqs; 1756 __le32 cq_depth; 1757 __le32 num_mrws; 1758 __le32 ord_num_qps; 1759 __le16 sq_depth; 1760 __le16 rq_depth; 1761 }; 1762 1763 #define V2_QUERY_PF_CAPS_C_NUM_PDS_S 0 1764 #define V2_QUERY_PF_CAPS_C_NUM_PDS_M GENMASK(19, 0) 1765 1766 #define V2_QUERY_PF_CAPS_C_CAP_FLAGS_S 20 1767 #define V2_QUERY_PF_CAPS_C_CAP_FLAGS_M GENMASK(31, 20) 1768 1769 #define V2_QUERY_PF_CAPS_C_NUM_CQS_S 0 1770 #define V2_QUERY_PF_CAPS_C_NUM_CQS_M GENMASK(19, 0) 1771 1772 #define V2_QUERY_PF_CAPS_C_MAX_GID_S 20 1773 #define V2_QUERY_PF_CAPS_C_MAX_GID_M GENMASK(28, 20) 1774 1775 #define V2_QUERY_PF_CAPS_C_CQ_DEPTH_S 0 1776 #define V2_QUERY_PF_CAPS_C_CQ_DEPTH_M GENMASK(22, 0) 1777 1778 #define V2_QUERY_PF_CAPS_C_NUM_MRWS_S 0 1779 #define V2_QUERY_PF_CAPS_C_NUM_MRWS_M GENMASK(19, 0) 1780 1781 #define V2_QUERY_PF_CAPS_C_NUM_QPS_S 0 1782 #define V2_QUERY_PF_CAPS_C_NUM_QPS_M GENMASK(19, 0) 1783 1784 #define V2_QUERY_PF_CAPS_C_MAX_ORD_S 20 1785 #define V2_QUERY_PF_CAPS_C_MAX_ORD_M GENMASK(27, 20) 1786 1787 struct hns_roce_query_pf_caps_d { 1788 __le32 wq_hop_num_max_srqs; 1789 __le16 srq_depth; 1790 __le16 cap_flags_ex; 1791 __le32 num_ceqs_ceq_depth; 1792 __le32 arm_st_aeq_depth; 1793 __le32 num_uars_rsv_pds; 1794 __le32 rsv_uars_rsv_qps; 1795 }; 1796 #define V2_QUERY_PF_CAPS_D_NUM_SRQS_S 0 1797 #define V2_QUERY_PF_CAPS_D_NUM_SRQS_M GENMASK(19, 0) 1798 1799 #define V2_QUERY_PF_CAPS_D_RQWQE_HOP_NUM_S 20 1800 #define V2_QUERY_PF_CAPS_D_RQWQE_HOP_NUM_M GENMASK(21, 20) 1801 1802 #define V2_QUERY_PF_CAPS_D_EX_SGE_HOP_NUM_S 22 1803 #define V2_QUERY_PF_CAPS_D_EX_SGE_HOP_NUM_M GENMASK(23, 22) 1804 1805 #define V2_QUERY_PF_CAPS_D_SQWQE_HOP_NUM_S 24 1806 #define V2_QUERY_PF_CAPS_D_SQWQE_HOP_NUM_M GENMASK(25, 24) 1807 1808 1809 #define V2_QUERY_PF_CAPS_D_CEQ_DEPTH_S 0 1810 #define V2_QUERY_PF_CAPS_D_CEQ_DEPTH_M GENMASK(21, 0) 1811 1812 #define V2_QUERY_PF_CAPS_D_NUM_CEQS_S 22 1813 #define V2_QUERY_PF_CAPS_D_NUM_CEQS_M GENMASK(31, 22) 1814 1815 #define V2_QUERY_PF_CAPS_D_AEQ_DEPTH_S 0 1816 #define V2_QUERY_PF_CAPS_D_AEQ_DEPTH_M GENMASK(21, 0) 1817 1818 #define V2_QUERY_PF_CAPS_D_AEQ_ARM_ST_S 22 1819 #define V2_QUERY_PF_CAPS_D_AEQ_ARM_ST_M GENMASK(23, 22) 1820 1821 #define V2_QUERY_PF_CAPS_D_CEQ_ARM_ST_S 24 1822 #define V2_QUERY_PF_CAPS_D_CEQ_ARM_ST_M GENMASK(25, 24) 1823 1824 #define V2_QUERY_PF_CAPS_D_RSV_PDS_S 0 1825 #define V2_QUERY_PF_CAPS_D_RSV_PDS_M GENMASK(19, 0) 1826 1827 #define V2_QUERY_PF_CAPS_D_NUM_UARS_S 20 1828 #define V2_QUERY_PF_CAPS_D_NUM_UARS_M GENMASK(27, 20) 1829 1830 #define V2_QUERY_PF_CAPS_D_RSV_QPS_S 0 1831 #define V2_QUERY_PF_CAPS_D_RSV_QPS_M GENMASK(19, 0) 1832 1833 #define V2_QUERY_PF_CAPS_D_RSV_UARS_S 20 1834 #define V2_QUERY_PF_CAPS_D_RSV_UARS_M GENMASK(27, 20) 1835 1836 struct hns_roce_query_pf_caps_e { 1837 __le32 chunk_size_shift_rsv_mrws; 1838 __le32 rsv_cqs; 1839 __le32 rsv_srqs; 1840 __le32 rsv_lkey; 1841 __le16 ceq_max_cnt; 1842 __le16 ceq_period; 1843 __le16 aeq_max_cnt; 1844 __le16 aeq_period; 1845 }; 1846 1847 #define V2_QUERY_PF_CAPS_E_RSV_MRWS_S 0 1848 #define V2_QUERY_PF_CAPS_E_RSV_MRWS_M GENMASK(19, 0) 1849 1850 #define V2_QUERY_PF_CAPS_E_CHUNK_SIZE_SHIFT_S 20 1851 #define V2_QUERY_PF_CAPS_E_CHUNK_SIZE_SHIFT_M GENMASK(31, 20) 1852 1853 #define V2_QUERY_PF_CAPS_E_RSV_CQS_S 0 1854 #define V2_QUERY_PF_CAPS_E_RSV_CQS_M GENMASK(19, 0) 1855 1856 #define V2_QUERY_PF_CAPS_E_RSV_SRQS_S 0 1857 #define V2_QUERY_PF_CAPS_E_RSV_SRQS_M GENMASK(19, 0) 1858 1859 #define V2_QUERY_PF_CAPS_E_RSV_LKEYS_S 0 1860 #define V2_QUERY_PF_CAPS_E_RSV_LKEYS_M GENMASK(19, 0) 1861 1862 struct hns_roce_cmq_desc { 1863 __le16 opcode; 1864 __le16 flag; 1865 __le16 retval; 1866 __le16 rsv; 1867 __le32 data[6]; 1868 }; 1869 1870 #define HNS_ROCE_V2_GO_BIT_TIMEOUT_MSECS 10000 1871 1872 #define HNS_ROCE_HW_RUN_BIT_SHIFT 31 1873 #define HNS_ROCE_HW_MB_STATUS_MASK 0xFF 1874 1875 struct hns_roce_v2_cmq_ring { 1876 dma_addr_t desc_dma_addr; 1877 struct hns_roce_cmq_desc *desc; 1878 u32 head; 1879 u16 buf_size; 1880 u16 desc_num; 1881 u8 flag; 1882 spinlock_t lock; /* command queue lock */ 1883 }; 1884 1885 struct hns_roce_v2_cmq { 1886 struct hns_roce_v2_cmq_ring csq; 1887 struct hns_roce_v2_cmq_ring crq; 1888 u16 tx_timeout; 1889 }; 1890 1891 enum hns_roce_link_table_type { 1892 TSQ_LINK_TABLE, 1893 TPQ_LINK_TABLE, 1894 }; 1895 1896 struct hns_roce_link_table { 1897 struct hns_roce_buf_list table; 1898 struct hns_roce_buf_list *pg_list; 1899 u32 npages; 1900 u32 pg_sz; 1901 }; 1902 1903 struct hns_roce_link_table_entry { 1904 u32 blk_ba0; 1905 u32 blk_ba1_nxt_ptr; 1906 }; 1907 #define HNS_ROCE_LINK_TABLE_BA1_S 0 1908 #define HNS_ROCE_LINK_TABLE_BA1_M GENMASK(19, 0) 1909 1910 #define HNS_ROCE_LINK_TABLE_NXT_PTR_S 20 1911 #define HNS_ROCE_LINK_TABLE_NXT_PTR_M GENMASK(31, 20) 1912 1913 struct hns_roce_v2_priv { 1914 struct hnae3_handle *handle; 1915 struct hns_roce_v2_cmq cmq; 1916 struct hns_roce_link_table tsq; 1917 struct hns_roce_link_table tpq; 1918 }; 1919 1920 struct hns_roce_eq_context { 1921 __le32 byte_4; 1922 __le32 byte_8; 1923 __le32 byte_12; 1924 __le32 eqe_report_timer; 1925 __le32 eqe_ba0; 1926 __le32 eqe_ba1; 1927 __le32 byte_28; 1928 __le32 byte_32; 1929 __le32 byte_36; 1930 __le32 byte_40; 1931 __le32 byte_44; 1932 __le32 rsv[5]; 1933 }; 1934 1935 #define HNS_ROCE_AEQ_DEFAULT_BURST_NUM 0x0 1936 #define HNS_ROCE_AEQ_DEFAULT_INTERVAL 0x0 1937 #define HNS_ROCE_CEQ_DEFAULT_BURST_NUM 0x0 1938 #define HNS_ROCE_CEQ_DEFAULT_INTERVAL 0x0 1939 1940 #define HNS_ROCE_V2_EQ_STATE_INVALID 0 1941 #define HNS_ROCE_V2_EQ_STATE_VALID 1 1942 #define HNS_ROCE_V2_EQ_STATE_OVERFLOW 2 1943 #define HNS_ROCE_V2_EQ_STATE_FAILURE 3 1944 1945 #define HNS_ROCE_V2_EQ_OVER_IGNORE_0 0 1946 #define HNS_ROCE_V2_EQ_OVER_IGNORE_1 1 1947 1948 #define HNS_ROCE_V2_EQ_COALESCE_0 0 1949 #define HNS_ROCE_V2_EQ_COALESCE_1 1 1950 1951 #define HNS_ROCE_V2_EQ_FIRED 0 1952 #define HNS_ROCE_V2_EQ_ARMED 1 1953 #define HNS_ROCE_V2_EQ_ALWAYS_ARMED 3 1954 1955 #define HNS_ROCE_EQ_INIT_EQE_CNT 0 1956 #define HNS_ROCE_EQ_INIT_PROD_IDX 0 1957 #define HNS_ROCE_EQ_INIT_REPORT_TIMER 0 1958 #define HNS_ROCE_EQ_INIT_MSI_IDX 0 1959 #define HNS_ROCE_EQ_INIT_CONS_IDX 0 1960 #define HNS_ROCE_EQ_INIT_NXT_EQE_BA 0 1961 1962 #define HNS_ROCE_V2_CEQ_CEQE_OWNER_S 31 1963 #define HNS_ROCE_V2_AEQ_AEQE_OWNER_S 31 1964 1965 #define HNS_ROCE_V2_COMP_EQE_NUM 0x1000 1966 #define HNS_ROCE_V2_ASYNC_EQE_NUM 0x1000 1967 1968 #define HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S 0 1969 #define HNS_ROCE_V2_VF_INT_ST_BUS_ERR_S 1 1970 #define HNS_ROCE_V2_VF_INT_ST_OTHER_ERR_S 2 1971 1972 #define HNS_ROCE_EQ_DB_CMD_AEQ 0x0 1973 #define HNS_ROCE_EQ_DB_CMD_AEQ_ARMED 0x1 1974 #define HNS_ROCE_EQ_DB_CMD_CEQ 0x2 1975 #define HNS_ROCE_EQ_DB_CMD_CEQ_ARMED 0x3 1976 1977 #define EQ_ENABLE 1 1978 #define EQ_DISABLE 0 1979 1980 #define EQ_REG_OFFSET 0x4 1981 1982 #define HNS_ROCE_INT_NAME_LEN 32 1983 #define HNS_ROCE_V2_EQN_M GENMASK(23, 0) 1984 1985 #define HNS_ROCE_V2_CONS_IDX_M GENMASK(23, 0) 1986 1987 #define HNS_ROCE_V2_VF_ABN_INT_EN_S 0 1988 #define HNS_ROCE_V2_VF_ABN_INT_EN_M GENMASK(0, 0) 1989 #define HNS_ROCE_V2_VF_ABN_INT_ST_M GENMASK(2, 0) 1990 #define HNS_ROCE_V2_VF_ABN_INT_CFG_M GENMASK(2, 0) 1991 #define HNS_ROCE_V2_VF_EVENT_INT_EN_M GENMASK(0, 0) 1992 1993 /* WORD0 */ 1994 #define HNS_ROCE_EQC_EQ_ST_S 0 1995 #define HNS_ROCE_EQC_EQ_ST_M GENMASK(1, 0) 1996 1997 #define HNS_ROCE_EQC_HOP_NUM_S 2 1998 #define HNS_ROCE_EQC_HOP_NUM_M GENMASK(3, 2) 1999 2000 #define HNS_ROCE_EQC_OVER_IGNORE_S 4 2001 #define HNS_ROCE_EQC_OVER_IGNORE_M GENMASK(4, 4) 2002 2003 #define HNS_ROCE_EQC_COALESCE_S 5 2004 #define HNS_ROCE_EQC_COALESCE_M GENMASK(5, 5) 2005 2006 #define HNS_ROCE_EQC_ARM_ST_S 6 2007 #define HNS_ROCE_EQC_ARM_ST_M GENMASK(7, 6) 2008 2009 #define HNS_ROCE_EQC_EQN_S 8 2010 #define HNS_ROCE_EQC_EQN_M GENMASK(15, 8) 2011 2012 #define HNS_ROCE_EQC_EQE_CNT_S 16 2013 #define HNS_ROCE_EQC_EQE_CNT_M GENMASK(31, 16) 2014 2015 /* WORD1 */ 2016 #define HNS_ROCE_EQC_BA_PG_SZ_S 0 2017 #define HNS_ROCE_EQC_BA_PG_SZ_M GENMASK(3, 0) 2018 2019 #define HNS_ROCE_EQC_BUF_PG_SZ_S 4 2020 #define HNS_ROCE_EQC_BUF_PG_SZ_M GENMASK(7, 4) 2021 2022 #define HNS_ROCE_EQC_PROD_INDX_S 8 2023 #define HNS_ROCE_EQC_PROD_INDX_M GENMASK(31, 8) 2024 2025 /* WORD2 */ 2026 #define HNS_ROCE_EQC_MAX_CNT_S 0 2027 #define HNS_ROCE_EQC_MAX_CNT_M GENMASK(15, 0) 2028 2029 #define HNS_ROCE_EQC_PERIOD_S 16 2030 #define HNS_ROCE_EQC_PERIOD_M GENMASK(31, 16) 2031 2032 /* WORD3 */ 2033 #define HNS_ROCE_EQC_REPORT_TIMER_S 0 2034 #define HNS_ROCE_EQC_REPORT_TIMER_M GENMASK(31, 0) 2035 2036 /* WORD4 */ 2037 #define HNS_ROCE_EQC_EQE_BA_L_S 0 2038 #define HNS_ROCE_EQC_EQE_BA_L_M GENMASK(31, 0) 2039 2040 /* WORD5 */ 2041 #define HNS_ROCE_EQC_EQE_BA_H_S 0 2042 #define HNS_ROCE_EQC_EQE_BA_H_M GENMASK(28, 0) 2043 2044 /* WORD6 */ 2045 #define HNS_ROCE_EQC_SHIFT_S 0 2046 #define HNS_ROCE_EQC_SHIFT_M GENMASK(7, 0) 2047 2048 #define HNS_ROCE_EQC_MSI_INDX_S 8 2049 #define HNS_ROCE_EQC_MSI_INDX_M GENMASK(15, 8) 2050 2051 #define HNS_ROCE_EQC_CUR_EQE_BA_L_S 16 2052 #define HNS_ROCE_EQC_CUR_EQE_BA_L_M GENMASK(31, 16) 2053 2054 /* WORD7 */ 2055 #define HNS_ROCE_EQC_CUR_EQE_BA_M_S 0 2056 #define HNS_ROCE_EQC_CUR_EQE_BA_M_M GENMASK(31, 0) 2057 2058 /* WORD8 */ 2059 #define HNS_ROCE_EQC_CUR_EQE_BA_H_S 0 2060 #define HNS_ROCE_EQC_CUR_EQE_BA_H_M GENMASK(3, 0) 2061 2062 #define HNS_ROCE_EQC_CONS_INDX_S 8 2063 #define HNS_ROCE_EQC_CONS_INDX_M GENMASK(31, 8) 2064 2065 /* WORD9 */ 2066 #define HNS_ROCE_EQC_NXT_EQE_BA_L_S 0 2067 #define HNS_ROCE_EQC_NXT_EQE_BA_L_M GENMASK(31, 0) 2068 2069 /* WORD10 */ 2070 #define HNS_ROCE_EQC_NXT_EQE_BA_H_S 0 2071 #define HNS_ROCE_EQC_NXT_EQE_BA_H_M GENMASK(19, 0) 2072 2073 #define HNS_ROCE_EQC_EQE_SIZE_S 20 2074 #define HNS_ROCE_EQC_EQE_SIZE_M GENMASK(21, 20) 2075 2076 #define HNS_ROCE_V2_CEQE_COMP_CQN_S 0 2077 #define HNS_ROCE_V2_CEQE_COMP_CQN_M GENMASK(23, 0) 2078 2079 #define HNS_ROCE_V2_AEQE_EVENT_TYPE_S 0 2080 #define HNS_ROCE_V2_AEQE_EVENT_TYPE_M GENMASK(7, 0) 2081 2082 #define HNS_ROCE_V2_AEQE_SUB_TYPE_S 8 2083 #define HNS_ROCE_V2_AEQE_SUB_TYPE_M GENMASK(15, 8) 2084 2085 #define HNS_ROCE_V2_EQ_DB_CMD_S 16 2086 #define HNS_ROCE_V2_EQ_DB_CMD_M GENMASK(17, 16) 2087 2088 #define HNS_ROCE_V2_EQ_DB_TAG_S 0 2089 #define HNS_ROCE_V2_EQ_DB_TAG_M GENMASK(7, 0) 2090 2091 #define HNS_ROCE_V2_EQ_DB_PARA_S 0 2092 #define HNS_ROCE_V2_EQ_DB_PARA_M GENMASK(23, 0) 2093 2094 #define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_S 0 2095 #define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_M GENMASK(23, 0) 2096 2097 #define MAX_SERVICE_LEVEL 0x7 2098 2099 struct hns_roce_wqe_atomic_seg { 2100 __le64 fetchadd_swap_data; 2101 __le64 cmp_data; 2102 }; 2103 2104 struct hns_roce_sccc_clr { 2105 __le32 qpn; 2106 __le32 rsv[5]; 2107 }; 2108 2109 struct hns_roce_sccc_clr_done { 2110 __le32 clr_done; 2111 __le32 rsv[5]; 2112 }; 2113 2114 int hns_roce_v2_query_cqc_info(struct hns_roce_dev *hr_dev, u32 cqn, 2115 int *buffer); 2116 2117 static inline void hns_roce_write64(struct hns_roce_dev *hr_dev, __le32 val[2], 2118 void __iomem *dest) 2119 { 2120 struct hns_roce_v2_priv *priv = hr_dev->priv; 2121 struct hnae3_handle *handle = priv->handle; 2122 const struct hnae3_ae_ops *ops = handle->ae_algo->ops; 2123 2124 if (!hr_dev->dis_db && !ops->get_hw_reset_stat(handle)) 2125 hns_roce_write64_k(val, dest); 2126 } 2127 2128 #endif 2129