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