1e126ba97SEli Cohen /* 2302bdf68SSaeed Mahameed * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved. 3e126ba97SEli Cohen * 4e126ba97SEli Cohen * This software is available to you under a choice of one of two 5e126ba97SEli Cohen * licenses. You may choose to be licensed under the terms of the GNU 6e126ba97SEli Cohen * General Public License (GPL) Version 2, available from the file 7e126ba97SEli Cohen * COPYING in the main directory of this source tree, or the 8e126ba97SEli Cohen * OpenIB.org BSD license below: 9e126ba97SEli Cohen * 10e126ba97SEli Cohen * Redistribution and use in source and binary forms, with or 11e126ba97SEli Cohen * without modification, are permitted provided that the following 12e126ba97SEli Cohen * conditions are met: 13e126ba97SEli Cohen * 14e126ba97SEli Cohen * - Redistributions of source code must retain the above 15e126ba97SEli Cohen * copyright notice, this list of conditions and the following 16e126ba97SEli Cohen * disclaimer. 17e126ba97SEli Cohen * 18e126ba97SEli Cohen * - Redistributions in binary form must reproduce the above 19e126ba97SEli Cohen * copyright notice, this list of conditions and the following 20e126ba97SEli Cohen * disclaimer in the documentation and/or other materials 21e126ba97SEli Cohen * provided with the distribution. 22e126ba97SEli Cohen * 23e126ba97SEli Cohen * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24e126ba97SEli Cohen * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25e126ba97SEli Cohen * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26e126ba97SEli Cohen * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27e126ba97SEli Cohen * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28e126ba97SEli Cohen * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29e126ba97SEli Cohen * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30e126ba97SEli Cohen * SOFTWARE. 31e126ba97SEli Cohen */ 32e126ba97SEli Cohen 33e126ba97SEli Cohen #ifndef MLX5_QP_H 34e126ba97SEli Cohen #define MLX5_QP_H 35e126ba97SEli Cohen 36e126ba97SEli Cohen #include <linux/mlx5/device.h> 37e126ba97SEli Cohen #include <linux/mlx5/driver.h> 38e126ba97SEli Cohen 39a419bfb7SOr Har-Toov #define MLX5_TERMINATE_SCATTER_LIST_LKEY cpu_to_be32(0x100) 4038ca87c6SMax Gurtovoy /* UMR (3 WQE_BB's) + SIG (3 WQE_BB's) + PSV (mem) + PSV (wire) */ 4138ca87c6SMax Gurtovoy #define MLX5_SIG_WQE_SIZE (MLX5_SEND_WQE_BB * 8) 42e6631814SSagi Grimberg #define MLX5_DIF_SIZE 8 43e6631814SSagi Grimberg #define MLX5_STRIDE_BLOCK_OP 0x400 44fd22f78cSSagi Grimberg #define MLX5_CPY_GRD_MASK 0xc0 45fd22f78cSSagi Grimberg #define MLX5_CPY_APP_MASK 0x30 46fd22f78cSSagi Grimberg #define MLX5_CPY_REF_MASK 0x0f 47142537f4SSagi Grimberg #define MLX5_BSF_INC_REFTAG (1 << 6) 48142537f4SSagi Grimberg #define MLX5_BSF_INL_VALID (1 << 15) 49142537f4SSagi Grimberg #define MLX5_BSF_REFRESH_DIF (1 << 14) 50142537f4SSagi Grimberg #define MLX5_BSF_REPEAT_BLOCK (1 << 7) 51142537f4SSagi Grimberg #define MLX5_BSF_APPTAG_ESCAPE 0x1 52142537f4SSagi Grimberg #define MLX5_BSF_APPREF_ESCAPE 0x2 53e126ba97SEli Cohen 54e126ba97SEli Cohen enum mlx5_qp_optpar { 55e126ba97SEli Cohen MLX5_QP_OPTPAR_ALT_ADDR_PATH = 1 << 0, 56e126ba97SEli Cohen MLX5_QP_OPTPAR_RRE = 1 << 1, 57e126ba97SEli Cohen MLX5_QP_OPTPAR_RAE = 1 << 2, 58e126ba97SEli Cohen MLX5_QP_OPTPAR_RWE = 1 << 3, 59e126ba97SEli Cohen MLX5_QP_OPTPAR_PKEY_INDEX = 1 << 4, 60e126ba97SEli Cohen MLX5_QP_OPTPAR_Q_KEY = 1 << 5, 61e126ba97SEli Cohen MLX5_QP_OPTPAR_RNR_TIMEOUT = 1 << 6, 62e126ba97SEli Cohen MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH = 1 << 7, 63e126ba97SEli Cohen MLX5_QP_OPTPAR_SRA_MAX = 1 << 8, 64e126ba97SEli Cohen MLX5_QP_OPTPAR_RRA_MAX = 1 << 9, 65e126ba97SEli Cohen MLX5_QP_OPTPAR_PM_STATE = 1 << 10, 66e126ba97SEli Cohen MLX5_QP_OPTPAR_RETRY_COUNT = 1 << 12, 67e126ba97SEli Cohen MLX5_QP_OPTPAR_RNR_RETRY = 1 << 13, 68e126ba97SEli Cohen MLX5_QP_OPTPAR_ACK_TIMEOUT = 1 << 14, 69cfc1a89eSMaor Gottlieb MLX5_QP_OPTPAR_LAG_TX_AFF = 1 << 15, 70e126ba97SEli Cohen MLX5_QP_OPTPAR_PRI_PORT = 1 << 16, 71e126ba97SEli Cohen MLX5_QP_OPTPAR_SRQN = 1 << 18, 72e126ba97SEli Cohen MLX5_QP_OPTPAR_CQN_RCV = 1 << 19, 73e126ba97SEli Cohen MLX5_QP_OPTPAR_DC_HS = 1 << 20, 74e126ba97SEli Cohen MLX5_QP_OPTPAR_DC_KEY = 1 << 21, 75d14133ddSMark Zhang MLX5_QP_OPTPAR_COUNTER_SET_ID = 1 << 25, 76e126ba97SEli Cohen }; 77e126ba97SEli Cohen 78e126ba97SEli Cohen enum mlx5_qp_state { 79e126ba97SEli Cohen MLX5_QP_STATE_RST = 0, 80e126ba97SEli Cohen MLX5_QP_STATE_INIT = 1, 81e126ba97SEli Cohen MLX5_QP_STATE_RTR = 2, 82e126ba97SEli Cohen MLX5_QP_STATE_RTS = 3, 83e126ba97SEli Cohen MLX5_QP_STATE_SQER = 4, 84e126ba97SEli Cohen MLX5_QP_STATE_SQD = 5, 85e126ba97SEli Cohen MLX5_QP_STATE_ERR = 6, 86e126ba97SEli Cohen MLX5_QP_STATE_SQ_DRAINING = 7, 87e126ba97SEli Cohen MLX5_QP_STATE_SUSPENDED = 9, 886d2f89dfSmajd@mellanox.com MLX5_QP_NUM_STATE, 896d2f89dfSmajd@mellanox.com MLX5_QP_STATE, 906d2f89dfSmajd@mellanox.com MLX5_QP_STATE_BAD, 916d2f89dfSmajd@mellanox.com }; 926d2f89dfSmajd@mellanox.com 936d2f89dfSmajd@mellanox.com enum { 946d2f89dfSmajd@mellanox.com MLX5_SQ_STATE_NA = MLX5_SQC_STATE_ERR + 1, 956d2f89dfSmajd@mellanox.com MLX5_SQ_NUM_STATE = MLX5_SQ_STATE_NA + 1, 966d2f89dfSmajd@mellanox.com MLX5_RQ_STATE_NA = MLX5_RQC_STATE_ERR + 1, 976d2f89dfSmajd@mellanox.com MLX5_RQ_NUM_STATE = MLX5_RQ_STATE_NA + 1, 98e126ba97SEli Cohen }; 99e126ba97SEli Cohen 100e126ba97SEli Cohen enum { 101e126ba97SEli Cohen MLX5_QP_ST_RC = 0x0, 102e126ba97SEli Cohen MLX5_QP_ST_UC = 0x1, 103e126ba97SEli Cohen MLX5_QP_ST_UD = 0x2, 104e126ba97SEli Cohen MLX5_QP_ST_XRC = 0x3, 105e126ba97SEli Cohen MLX5_QP_ST_MLX = 0x4, 106e126ba97SEli Cohen MLX5_QP_ST_DCI = 0x5, 107e126ba97SEli Cohen MLX5_QP_ST_DCT = 0x6, 108e126ba97SEli Cohen MLX5_QP_ST_QP0 = 0x7, 109e126ba97SEli Cohen MLX5_QP_ST_QP1 = 0x8, 110e126ba97SEli Cohen MLX5_QP_ST_RAW_ETHERTYPE = 0x9, 111e126ba97SEli Cohen MLX5_QP_ST_RAW_IPV6 = 0xa, 112e126ba97SEli Cohen MLX5_QP_ST_SNIFFER = 0xb, 113e126ba97SEli Cohen MLX5_QP_ST_SYNC_UMR = 0xe, 114e126ba97SEli Cohen MLX5_QP_ST_PTP_1588 = 0xd, 115e126ba97SEli Cohen MLX5_QP_ST_REG_UMR = 0xc, 116e126ba97SEli Cohen MLX5_QP_ST_MAX 117e126ba97SEli Cohen }; 118e126ba97SEli Cohen 119e126ba97SEli Cohen enum { 120e126ba97SEli Cohen MLX5_QP_PM_MIGRATED = 0x3, 121e126ba97SEli Cohen MLX5_QP_PM_ARMED = 0x0, 122e126ba97SEli Cohen MLX5_QP_PM_REARM = 0x1 123e126ba97SEli Cohen }; 124e126ba97SEli Cohen 125e126ba97SEli Cohen enum { 12609a7d9ecSSaeed Mahameed MLX5_NON_ZERO_RQ = 0x0, 12709a7d9ecSSaeed Mahameed MLX5_SRQ_RQ = 0x1, 12809a7d9ecSSaeed Mahameed MLX5_CRQ_RQ = 0x2, 12909a7d9ecSSaeed Mahameed MLX5_ZERO_LEN_RQ = 0x3 130e126ba97SEli Cohen }; 131e126ba97SEli Cohen 13209a7d9ecSSaeed Mahameed /* TODO REM */ 133e126ba97SEli Cohen enum { 134e126ba97SEli Cohen /* params1 */ 135e126ba97SEli Cohen MLX5_QP_BIT_SRE = 1 << 15, 136e126ba97SEli Cohen MLX5_QP_BIT_SWE = 1 << 14, 137e126ba97SEli Cohen MLX5_QP_BIT_SAE = 1 << 13, 138e126ba97SEli Cohen /* params2 */ 139e126ba97SEli Cohen MLX5_QP_BIT_RRE = 1 << 15, 140e126ba97SEli Cohen MLX5_QP_BIT_RWE = 1 << 14, 141e126ba97SEli Cohen MLX5_QP_BIT_RAE = 1 << 13, 142e126ba97SEli Cohen MLX5_QP_BIT_RIC = 1 << 4, 143051f2630SLeon Romanovsky MLX5_QP_BIT_CC_SLAVE_RECV = 1 << 2, 144051f2630SLeon Romanovsky MLX5_QP_BIT_CC_SLAVE_SEND = 1 << 1, 145051f2630SLeon Romanovsky MLX5_QP_BIT_CC_MASTER = 1 << 0 146e126ba97SEli Cohen }; 147e126ba97SEli Cohen 148e126ba97SEli Cohen enum { 149e126ba97SEli Cohen MLX5_WQE_CTRL_CQ_UPDATE = 2 << 2, 150e281682bSSaeed Mahameed MLX5_WQE_CTRL_CQ_UPDATE_AND_EQE = 3 << 2, 151e126ba97SEli Cohen MLX5_WQE_CTRL_SOLICITED = 1 << 1, 152e126ba97SEli Cohen }; 153e126ba97SEli Cohen 154e126ba97SEli Cohen enum { 155e281682bSSaeed Mahameed MLX5_SEND_WQE_DS = 16, 156e126ba97SEli Cohen MLX5_SEND_WQE_BB = 64, 157e126ba97SEli Cohen }; 158e126ba97SEli Cohen 159e281682bSSaeed Mahameed #define MLX5_SEND_WQEBB_NUM_DS (MLX5_SEND_WQE_BB / MLX5_SEND_WQE_DS) 160e281682bSSaeed Mahameed 161e281682bSSaeed Mahameed enum { 162e281682bSSaeed Mahameed MLX5_SEND_WQE_MAX_WQEBBS = 16, 163e281682bSSaeed Mahameed }; 164e281682bSSaeed Mahameed 165e5a3cc83SMaxim Mikityanskiy #define MLX5_SEND_WQE_MAX_SIZE (MLX5_SEND_WQE_MAX_WQEBBS * MLX5_SEND_WQE_BB) 166e5a3cc83SMaxim Mikityanskiy 167e126ba97SEli Cohen enum { 168e126ba97SEli Cohen MLX5_WQE_FMR_PERM_LOCAL_READ = 1 << 27, 169e126ba97SEli Cohen MLX5_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28, 170e126ba97SEli Cohen MLX5_WQE_FMR_PERM_REMOTE_READ = 1 << 29, 171e126ba97SEli Cohen MLX5_WQE_FMR_PERM_REMOTE_WRITE = 1 << 30, 172e126ba97SEli Cohen MLX5_WQE_FMR_PERM_ATOMIC = 1 << 31 173e126ba97SEli Cohen }; 174e126ba97SEli Cohen 175e126ba97SEli Cohen enum { 176e126ba97SEli Cohen MLX5_FENCE_MODE_NONE = 0 << 5, 177e126ba97SEli Cohen MLX5_FENCE_MODE_INITIATOR_SMALL = 1 << 5, 178c9b25495SEli Cohen MLX5_FENCE_MODE_FENCE = 2 << 5, 179e126ba97SEli Cohen MLX5_FENCE_MODE_STRONG_ORDERING = 3 << 5, 180e126ba97SEli Cohen MLX5_FENCE_MODE_SMALL_AND_FENCE = 4 << 5, 181e126ba97SEli Cohen }; 182e126ba97SEli Cohen 183e126ba97SEli Cohen enum { 184e126ba97SEli Cohen MLX5_RCV_DBR = 0, 185e126ba97SEli Cohen MLX5_SND_DBR = 1, 186e126ba97SEli Cohen }; 187e126ba97SEli Cohen 188e6631814SSagi Grimberg enum { 189e6631814SSagi Grimberg MLX5_FLAGS_INLINE = 1<<7, 190e6631814SSagi Grimberg MLX5_FLAGS_CHECK_FREE = 1<<5, 191e6631814SSagi Grimberg }; 192e6631814SSagi Grimberg 193e126ba97SEli Cohen struct mlx5_wqe_fmr_seg { 194e126ba97SEli Cohen __be32 flags; 195e126ba97SEli Cohen __be32 mem_key; 196e126ba97SEli Cohen __be64 buf_list; 197e126ba97SEli Cohen __be64 start_addr; 198e126ba97SEli Cohen __be64 reg_len; 199e126ba97SEli Cohen __be32 offset; 200e126ba97SEli Cohen __be32 page_size; 201e126ba97SEli Cohen u32 reserved[2]; 202e126ba97SEli Cohen }; 203e126ba97SEli Cohen 204e126ba97SEli Cohen struct mlx5_wqe_ctrl_seg { 205e126ba97SEli Cohen __be32 opmod_idx_opcode; 206e126ba97SEli Cohen __be32 qpn_ds; 2072af7e566SSaeed Mahameed 2082af7e566SSaeed Mahameed struct_group(trailer, 2092af7e566SSaeed Mahameed 210e126ba97SEli Cohen u8 signature; 211e126ba97SEli Cohen u8 rsvd[2]; 212e126ba97SEli Cohen u8 fm_ce_se; 2130718edf5STariq Toukan union { 2140718edf5STariq Toukan __be32 general_id; 215e126ba97SEli Cohen __be32 imm; 2160718edf5STariq Toukan __be32 umr_mkey; 2172d1b69edSTariq Toukan __be32 tis_tir_num; 2180718edf5STariq Toukan }; 2192af7e566SSaeed Mahameed 2202af7e566SSaeed Mahameed ); /* end of trailer group */ 221e126ba97SEli Cohen }; 222e126ba97SEli Cohen 223c1395a2aSHaggai Eran #define MLX5_WQE_CTRL_DS_MASK 0x3f 2247bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_QPN_MASK 0xffffff00 2257bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_QPN_SHIFT 8 226c1395a2aSHaggai Eran #define MLX5_WQE_DS_UNITS 16 2277bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_OPCODE_MASK 0xff 2287bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_WQE_INDEX_MASK 0x00ffff00 2297bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_WQE_INDEX_SHIFT 8 230c1395a2aSHaggai Eran 231e281682bSSaeed Mahameed enum { 232e281682bSSaeed Mahameed MLX5_ETH_WQE_L3_INNER_CSUM = 1 << 4, 233e281682bSSaeed Mahameed MLX5_ETH_WQE_L4_INNER_CSUM = 1 << 5, 234e281682bSSaeed Mahameed MLX5_ETH_WQE_L3_CSUM = 1 << 6, 235e281682bSSaeed Mahameed MLX5_ETH_WQE_L4_CSUM = 1 << 7, 236e281682bSSaeed Mahameed }; 237e281682bSSaeed Mahameed 2382b31f7aeSSaeed Mahameed enum { 2394382c7b9SGal Pressman MLX5_ETH_WQE_SVLAN = 1 << 0, 2402dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_OUTER_IP_ASSOC = 1 << 26, 2412dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_OUTER_L4_ASSOC = 1 << 27, 2422dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_INNER_IP_ASSOC = 3 << 26, 2432dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_INNER_L4_ASSOC = 1 << 28, 2442dc8b524SRaed Salem MLX5_ETH_WQE_INSERT_TRAILER = 1 << 30, 2452b31f7aeSSaeed Mahameed MLX5_ETH_WQE_INSERT_VLAN = 1 << 15, 2462b31f7aeSSaeed Mahameed }; 2472b31f7aeSSaeed Mahameed 248547eede0SIlan Tayari enum { 249547eede0SIlan Tayari MLX5_ETH_WQE_SWP_INNER_L3_IPV6 = 1 << 0, 250547eede0SIlan Tayari MLX5_ETH_WQE_SWP_INNER_L4_UDP = 1 << 1, 251547eede0SIlan Tayari MLX5_ETH_WQE_SWP_OUTER_L3_IPV6 = 1 << 4, 252547eede0SIlan Tayari MLX5_ETH_WQE_SWP_OUTER_L4_UDP = 1 << 5, 253547eede0SIlan Tayari }; 254547eede0SIlan Tayari 2559b9d454dSHuy Nguyen enum { 2569b9d454dSHuy Nguyen MLX5_ETH_WQE_FT_META_IPSEC = BIT(0), 257e467b283SLior Nahmanson MLX5_ETH_WQE_FT_META_MACSEC = BIT(1), 2589b9d454dSHuy Nguyen }; 2599b9d454dSHuy Nguyen 260e281682bSSaeed Mahameed struct mlx5_wqe_eth_seg { 261547eede0SIlan Tayari u8 swp_outer_l4_offset; 262547eede0SIlan Tayari u8 swp_outer_l3_offset; 263547eede0SIlan Tayari u8 swp_inner_l4_offset; 264547eede0SIlan Tayari u8 swp_inner_l3_offset; 265e281682bSSaeed Mahameed u8 cs_flags; 266547eede0SIlan Tayari u8 swp_flags; 267e281682bSSaeed Mahameed __be16 mss; 2689b9d454dSHuy Nguyen __be32 flow_table_metadata; 2692b31f7aeSSaeed Mahameed union { 2702b31f7aeSSaeed Mahameed struct { 2712b31f7aeSSaeed Mahameed __be16 sz; 2722b31f7aeSSaeed Mahameed u8 start[2]; 2732b31f7aeSSaeed Mahameed } inline_hdr; 2742b31f7aeSSaeed Mahameed struct { 2752b31f7aeSSaeed Mahameed __be16 type; 2762b31f7aeSSaeed Mahameed __be16 vlan_tci; 2772b31f7aeSSaeed Mahameed } insert; 2782dc8b524SRaed Salem __be32 trailer; 2792b31f7aeSSaeed Mahameed }; 280e281682bSSaeed Mahameed }; 281e281682bSSaeed Mahameed 282e126ba97SEli Cohen struct mlx5_wqe_xrc_seg { 283e126ba97SEli Cohen __be32 xrc_srqn; 284e126ba97SEli Cohen u8 rsvd[12]; 285e126ba97SEli Cohen }; 286e126ba97SEli Cohen 287e126ba97SEli Cohen struct mlx5_wqe_masked_atomic_seg { 288e126ba97SEli Cohen __be64 swap_add; 289e126ba97SEli Cohen __be64 compare; 290e126ba97SEli Cohen __be64 swap_add_mask; 291e126ba97SEli Cohen __be64 compare_mask; 292e126ba97SEli Cohen }; 293e126ba97SEli Cohen 29417d2f88fSArtemy Kovalyov struct mlx5_base_av { 29517d2f88fSArtemy Kovalyov union { 29617d2f88fSArtemy Kovalyov struct { 29717d2f88fSArtemy Kovalyov __be32 qkey; 29817d2f88fSArtemy Kovalyov __be32 reserved; 29917d2f88fSArtemy Kovalyov } qkey; 30017d2f88fSArtemy Kovalyov __be64 dc_key; 30117d2f88fSArtemy Kovalyov } key; 30217d2f88fSArtemy Kovalyov __be32 dqp_dct; 30317d2f88fSArtemy Kovalyov u8 stat_rate_sl; 30417d2f88fSArtemy Kovalyov u8 fl_mlid; 30517d2f88fSArtemy Kovalyov union { 30617d2f88fSArtemy Kovalyov __be16 rlid; 30717d2f88fSArtemy Kovalyov __be16 udp_sport; 30817d2f88fSArtemy Kovalyov }; 30917d2f88fSArtemy Kovalyov }; 31017d2f88fSArtemy Kovalyov 311e126ba97SEli Cohen struct mlx5_av { 312e126ba97SEli Cohen union { 313e126ba97SEli Cohen struct { 314e126ba97SEli Cohen __be32 qkey; 315e126ba97SEli Cohen __be32 reserved; 316e126ba97SEli Cohen } qkey; 317e126ba97SEli Cohen __be64 dc_key; 318e126ba97SEli Cohen } key; 319e126ba97SEli Cohen __be32 dqp_dct; 320e126ba97SEli Cohen u8 stat_rate_sl; 321e126ba97SEli Cohen u8 fl_mlid; 3222811ba51SAchiad Shochat union { 323e126ba97SEli Cohen __be16 rlid; 3242811ba51SAchiad Shochat __be16 udp_sport; 3252811ba51SAchiad Shochat }; 3262811ba51SAchiad Shochat u8 reserved0[4]; 3272811ba51SAchiad Shochat u8 rmac[6]; 328e126ba97SEli Cohen u8 tclass; 329e126ba97SEli Cohen u8 hop_limit; 330e126ba97SEli Cohen __be32 grh_gid_fl; 331e126ba97SEli Cohen u8 rgid[16]; 332e126ba97SEli Cohen }; 333e126ba97SEli Cohen 33425854544SSaeed Mahameed struct mlx5_ib_ah { 33525854544SSaeed Mahameed struct ib_ah ibah; 33625854544SSaeed Mahameed struct mlx5_av av; 337cfc1a89eSMaor Gottlieb u8 xmit_port; 33825854544SSaeed Mahameed }; 33925854544SSaeed Mahameed 34025854544SSaeed Mahameed static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah) 34125854544SSaeed Mahameed { 34225854544SSaeed Mahameed return container_of(ibah, struct mlx5_ib_ah, ibah); 34325854544SSaeed Mahameed } 34425854544SSaeed Mahameed 345e126ba97SEli Cohen struct mlx5_wqe_datagram_seg { 346e126ba97SEli Cohen struct mlx5_av av; 347e126ba97SEli Cohen }; 348e126ba97SEli Cohen 349e126ba97SEli Cohen struct mlx5_wqe_raddr_seg { 350e126ba97SEli Cohen __be64 raddr; 351e126ba97SEli Cohen __be32 rkey; 352e126ba97SEli Cohen u32 reserved; 353e126ba97SEli Cohen }; 354e126ba97SEli Cohen 355e126ba97SEli Cohen struct mlx5_wqe_atomic_seg { 356e126ba97SEli Cohen __be64 swap_add; 357e126ba97SEli Cohen __be64 compare; 358e126ba97SEli Cohen }; 359e126ba97SEli Cohen 360e126ba97SEli Cohen struct mlx5_wqe_data_seg { 361e126ba97SEli Cohen __be32 byte_count; 362e126ba97SEli Cohen __be32 lkey; 363e126ba97SEli Cohen __be64 addr; 364e126ba97SEli Cohen }; 365e126ba97SEli Cohen 366e126ba97SEli Cohen struct mlx5_wqe_umr_ctrl_seg { 367e126ba97SEli Cohen u8 flags; 368e126ba97SEli Cohen u8 rsvd0[3]; 36931616255SArtemy Kovalyov __be16 xlt_octowords; 37031616255SArtemy Kovalyov union { 37131616255SArtemy Kovalyov __be16 xlt_offset; 372e126ba97SEli Cohen __be16 bsf_octowords; 37331616255SArtemy Kovalyov }; 374e126ba97SEli Cohen __be64 mkey_mask; 37531616255SArtemy Kovalyov __be32 xlt_offset_47_16; 37631616255SArtemy Kovalyov u8 rsvd1[28]; 377e126ba97SEli Cohen }; 378e126ba97SEli Cohen 379e126ba97SEli Cohen struct mlx5_seg_set_psv { 380e126ba97SEli Cohen __be32 psv_num; 381e126ba97SEli Cohen __be16 syndrome; 382e126ba97SEli Cohen __be16 status; 383e126ba97SEli Cohen __be32 transient_sig; 384e126ba97SEli Cohen __be32 ref_tag; 385e126ba97SEli Cohen }; 386e126ba97SEli Cohen 387e126ba97SEli Cohen struct mlx5_seg_get_psv { 388e126ba97SEli Cohen u8 rsvd[19]; 389e126ba97SEli Cohen u8 num_psv; 390e126ba97SEli Cohen __be32 l_key; 391e126ba97SEli Cohen __be64 va; 392e126ba97SEli Cohen __be32 psv_index[4]; 393e126ba97SEli Cohen }; 394e126ba97SEli Cohen 395e126ba97SEli Cohen struct mlx5_seg_check_psv { 396e126ba97SEli Cohen u8 rsvd0[2]; 397e126ba97SEli Cohen __be16 err_coalescing_op; 398e126ba97SEli Cohen u8 rsvd1[2]; 399e126ba97SEli Cohen __be16 xport_err_op; 400e126ba97SEli Cohen u8 rsvd2[2]; 401e126ba97SEli Cohen __be16 xport_err_mask; 402e126ba97SEli Cohen u8 rsvd3[7]; 403e126ba97SEli Cohen u8 num_psv; 404e126ba97SEli Cohen __be32 l_key; 405e126ba97SEli Cohen __be64 va; 406e126ba97SEli Cohen __be32 psv_index[4]; 407e126ba97SEli Cohen }; 408e126ba97SEli Cohen 409e126ba97SEli Cohen struct mlx5_rwqe_sig { 410e126ba97SEli Cohen u8 rsvd0[4]; 411e126ba97SEli Cohen u8 signature; 412e126ba97SEli Cohen u8 rsvd1[11]; 413e126ba97SEli Cohen }; 414e126ba97SEli Cohen 415e126ba97SEli Cohen struct mlx5_wqe_signature_seg { 416e126ba97SEli Cohen u8 rsvd0[4]; 417e126ba97SEli Cohen u8 signature; 418e126ba97SEli Cohen u8 rsvd1[11]; 419e126ba97SEli Cohen }; 420e126ba97SEli Cohen 4217bdf65d4SHaggai Eran #define MLX5_WQE_INLINE_SEG_BYTE_COUNT_MASK 0x3ff 4227bdf65d4SHaggai Eran 423e126ba97SEli Cohen struct mlx5_wqe_inline_seg { 424e126ba97SEli Cohen __be32 byte_count; 425b6ca09cbSGustavo A. R. Silva __be32 data[]; 426e126ba97SEli Cohen }; 427e126ba97SEli Cohen 428142537f4SSagi Grimberg enum mlx5_sig_type { 429142537f4SSagi Grimberg MLX5_DIF_CRC = 0x1, 430142537f4SSagi Grimberg MLX5_DIF_IPCS = 0x2, 431142537f4SSagi Grimberg }; 432142537f4SSagi Grimberg 433142537f4SSagi Grimberg struct mlx5_bsf_inl { 434142537f4SSagi Grimberg __be16 vld_refresh; 435142537f4SSagi Grimberg __be16 dif_apptag; 436142537f4SSagi Grimberg __be32 dif_reftag; 437142537f4SSagi Grimberg u8 sig_type; 438142537f4SSagi Grimberg u8 rp_inv_seed; 439142537f4SSagi Grimberg u8 rsvd[3]; 440142537f4SSagi Grimberg u8 dif_inc_ref_guard_check; 441142537f4SSagi Grimberg __be16 dif_app_bitmask_check; 442142537f4SSagi Grimberg }; 443142537f4SSagi Grimberg 444e6631814SSagi Grimberg struct mlx5_bsf { 445e6631814SSagi Grimberg struct mlx5_bsf_basic { 446e6631814SSagi Grimberg u8 bsf_size_sbs; 447e6631814SSagi Grimberg u8 check_byte_mask; 448e6631814SSagi Grimberg union { 449e6631814SSagi Grimberg u8 copy_byte_mask; 450e6631814SSagi Grimberg u8 bs_selector; 451e6631814SSagi Grimberg u8 rsvd_wflags; 452e6631814SSagi Grimberg } wire; 453e6631814SSagi Grimberg union { 454e6631814SSagi Grimberg u8 bs_selector; 455e6631814SSagi Grimberg u8 rsvd_mflags; 456e6631814SSagi Grimberg } mem; 457e6631814SSagi Grimberg __be32 raw_data_size; 458e6631814SSagi Grimberg __be32 w_bfs_psv; 459e6631814SSagi Grimberg __be32 m_bfs_psv; 460e6631814SSagi Grimberg } basic; 461e6631814SSagi Grimberg struct mlx5_bsf_ext { 462e6631814SSagi Grimberg __be32 t_init_gen_pro_size; 463e6631814SSagi Grimberg __be32 rsvd_epi_size; 464e6631814SSagi Grimberg __be32 w_tfs_psv; 465e6631814SSagi Grimberg __be32 m_tfs_psv; 466e6631814SSagi Grimberg } ext; 467142537f4SSagi Grimberg struct mlx5_bsf_inl w_inl; 468142537f4SSagi Grimberg struct mlx5_bsf_inl m_inl; 469e6631814SSagi Grimberg }; 470e6631814SSagi Grimberg 47131616255SArtemy Kovalyov struct mlx5_mtt { 47231616255SArtemy Kovalyov __be64 ptag; 47331616255SArtemy Kovalyov }; 47431616255SArtemy Kovalyov 475e6631814SSagi Grimberg struct mlx5_klm { 476e6631814SSagi Grimberg __be32 bcount; 477e6631814SSagi Grimberg __be32 key; 478e6631814SSagi Grimberg __be64 va; 479e6631814SSagi Grimberg }; 480e6631814SSagi Grimberg 4816470d2e7SMaxim Mikityanskiy struct mlx5_ksm { 4826470d2e7SMaxim Mikityanskiy __be32 reserved; 4836470d2e7SMaxim Mikityanskiy __be32 key; 4846470d2e7SMaxim Mikityanskiy __be64 va; 4856470d2e7SMaxim Mikityanskiy }; 4866470d2e7SMaxim Mikityanskiy 487e6631814SSagi Grimberg struct mlx5_stride_block_entry { 488e6631814SSagi Grimberg __be16 stride; 489e6631814SSagi Grimberg __be16 bcount; 490e6631814SSagi Grimberg __be32 key; 491e6631814SSagi Grimberg __be64 va; 492e6631814SSagi Grimberg }; 493e6631814SSagi Grimberg 494e6631814SSagi Grimberg struct mlx5_stride_block_ctrl_seg { 495e6631814SSagi Grimberg __be32 bcount_per_cycle; 496e6631814SSagi Grimberg __be32 op; 497e6631814SSagi Grimberg __be32 repeat_count; 498e6631814SSagi Grimberg u16 rsvd; 499e6631814SSagi Grimberg __be16 num_entries; 500e6631814SSagi Grimberg }; 501e6631814SSagi Grimberg 502*977c4a3eSYevgeny Kliteynik struct mlx5_wqe_flow_update_ctrl_seg { 503*977c4a3eSYevgeny Kliteynik __be32 flow_idx_update; 504*977c4a3eSYevgeny Kliteynik __be32 dest_handle; 505*977c4a3eSYevgeny Kliteynik u8 reserved0[40]; 506*977c4a3eSYevgeny Kliteynik }; 507*977c4a3eSYevgeny Kliteynik 508*977c4a3eSYevgeny Kliteynik struct mlx5_wqe_header_modify_argument_update_seg { 509*977c4a3eSYevgeny Kliteynik u8 argument_list[64]; 510*977c4a3eSYevgeny Kliteynik }; 511*977c4a3eSYevgeny Kliteynik 512e126ba97SEli Cohen struct mlx5_core_qp { 5135903325aSEli Cohen struct mlx5_core_rsc_common common; /* must be first */ 514e126ba97SEli Cohen void (*event) (struct mlx5_core_qp *, int); 515e126ba97SEli Cohen int qpn; 516e126ba97SEli Cohen struct mlx5_rsc_debug *dbg; 517e126ba97SEli Cohen int pid; 5184ac63ec7SYishai Hadas u16 uid; 519e126ba97SEli Cohen }; 520e126ba97SEli Cohen 52157cda166SMoni Shoua struct mlx5_core_dct { 52257cda166SMoni Shoua struct mlx5_core_qp mqp; 52357cda166SMoni Shoua struct completion drained; 52457cda166SMoni Shoua }; 52557cda166SMoni Shoua 526e126ba97SEli Cohen int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); 527e126ba97SEli Cohen void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp); 52827e95603SMoni Shoua 529db81a5c3SEli Cohen static inline const char *mlx5_qp_type_str(int type) 530db81a5c3SEli Cohen { 531db81a5c3SEli Cohen switch (type) { 532db81a5c3SEli Cohen case MLX5_QP_ST_RC: return "RC"; 533db81a5c3SEli Cohen case MLX5_QP_ST_UC: return "C"; 534db81a5c3SEli Cohen case MLX5_QP_ST_UD: return "UD"; 535db81a5c3SEli Cohen case MLX5_QP_ST_XRC: return "XRC"; 536db81a5c3SEli Cohen case MLX5_QP_ST_MLX: return "MLX"; 537db81a5c3SEli Cohen case MLX5_QP_ST_QP0: return "QP0"; 538db81a5c3SEli Cohen case MLX5_QP_ST_QP1: return "QP1"; 539db81a5c3SEli Cohen case MLX5_QP_ST_RAW_ETHERTYPE: return "RAW_ETHERTYPE"; 540db81a5c3SEli Cohen case MLX5_QP_ST_RAW_IPV6: return "RAW_IPV6"; 541db81a5c3SEli Cohen case MLX5_QP_ST_SNIFFER: return "SNIFFER"; 542db81a5c3SEli Cohen case MLX5_QP_ST_SYNC_UMR: return "SYNC_UMR"; 543db81a5c3SEli Cohen case MLX5_QP_ST_PTP_1588: return "PTP_1588"; 544db81a5c3SEli Cohen case MLX5_QP_ST_REG_UMR: return "REG_UMR"; 545db81a5c3SEli Cohen default: return "Invalid transport type"; 546db81a5c3SEli Cohen } 547db81a5c3SEli Cohen } 548db81a5c3SEli Cohen 549db81a5c3SEli Cohen static inline const char *mlx5_qp_state_str(int state) 550db81a5c3SEli Cohen { 551db81a5c3SEli Cohen switch (state) { 552db81a5c3SEli Cohen case MLX5_QP_STATE_RST: 553db81a5c3SEli Cohen return "RST"; 554db81a5c3SEli Cohen case MLX5_QP_STATE_INIT: 555db81a5c3SEli Cohen return "INIT"; 556db81a5c3SEli Cohen case MLX5_QP_STATE_RTR: 557db81a5c3SEli Cohen return "RTR"; 558db81a5c3SEli Cohen case MLX5_QP_STATE_RTS: 559db81a5c3SEli Cohen return "RTS"; 560db81a5c3SEli Cohen case MLX5_QP_STATE_SQER: 561db81a5c3SEli Cohen return "SQER"; 562db81a5c3SEli Cohen case MLX5_QP_STATE_SQD: 563db81a5c3SEli Cohen return "SQD"; 564db81a5c3SEli Cohen case MLX5_QP_STATE_ERR: 565db81a5c3SEli Cohen return "ERR"; 566db81a5c3SEli Cohen case MLX5_QP_STATE_SQ_DRAINING: 567db81a5c3SEli Cohen return "SQ_DRAINING"; 568db81a5c3SEli Cohen case MLX5_QP_STATE_SUSPENDED: 569db81a5c3SEli Cohen return "SUSPENDED"; 570db81a5c3SEli Cohen default: return "Invalid QP state"; 571db81a5c3SEli Cohen } 572db81a5c3SEli Cohen } 573db81a5c3SEli Cohen 5744806f1e2SMaor Gottlieb static inline int mlx5_get_qp_default_ts(struct mlx5_core_dev *dev) 5754806f1e2SMaor Gottlieb { 5764806f1e2SMaor Gottlieb return !MLX5_CAP_ROCE(dev, qp_ts_format) ? 5779a1ac95aSAharon Landau MLX5_TIMESTAMP_FORMAT_FREE_RUNNING : 5789a1ac95aSAharon Landau MLX5_TIMESTAMP_FORMAT_DEFAULT; 5794806f1e2SMaor Gottlieb } 5804806f1e2SMaor Gottlieb 581e126ba97SEli Cohen #endif /* MLX5_QP_H */ 582