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,
152*00b9f0daSYevgeny Kliteynik MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE = 1 << 5,
153e126ba97SEli Cohen };
154e126ba97SEli Cohen
155e126ba97SEli Cohen enum {
156e281682bSSaeed Mahameed MLX5_SEND_WQE_DS = 16,
157e126ba97SEli Cohen MLX5_SEND_WQE_BB = 64,
158e126ba97SEli Cohen };
159e126ba97SEli Cohen
160e281682bSSaeed Mahameed #define MLX5_SEND_WQEBB_NUM_DS (MLX5_SEND_WQE_BB / MLX5_SEND_WQE_DS)
161e281682bSSaeed Mahameed
162e281682bSSaeed Mahameed enum {
163e281682bSSaeed Mahameed MLX5_SEND_WQE_MAX_WQEBBS = 16,
164e281682bSSaeed Mahameed };
165e281682bSSaeed Mahameed
166e5a3cc83SMaxim Mikityanskiy #define MLX5_SEND_WQE_MAX_SIZE (MLX5_SEND_WQE_MAX_WQEBBS * MLX5_SEND_WQE_BB)
167e5a3cc83SMaxim Mikityanskiy
168e126ba97SEli Cohen enum {
169e126ba97SEli Cohen MLX5_WQE_FMR_PERM_LOCAL_READ = 1 << 27,
170e126ba97SEli Cohen MLX5_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28,
171e126ba97SEli Cohen MLX5_WQE_FMR_PERM_REMOTE_READ = 1 << 29,
172e126ba97SEli Cohen MLX5_WQE_FMR_PERM_REMOTE_WRITE = 1 << 30,
173e126ba97SEli Cohen MLX5_WQE_FMR_PERM_ATOMIC = 1 << 31
174e126ba97SEli Cohen };
175e126ba97SEli Cohen
176e126ba97SEli Cohen enum {
177e126ba97SEli Cohen MLX5_FENCE_MODE_NONE = 0 << 5,
178e126ba97SEli Cohen MLX5_FENCE_MODE_INITIATOR_SMALL = 1 << 5,
179c9b25495SEli Cohen MLX5_FENCE_MODE_FENCE = 2 << 5,
180e126ba97SEli Cohen MLX5_FENCE_MODE_STRONG_ORDERING = 3 << 5,
181e126ba97SEli Cohen MLX5_FENCE_MODE_SMALL_AND_FENCE = 4 << 5,
182e126ba97SEli Cohen };
183e126ba97SEli Cohen
184e126ba97SEli Cohen enum {
185e126ba97SEli Cohen MLX5_RCV_DBR = 0,
186e126ba97SEli Cohen MLX5_SND_DBR = 1,
187e126ba97SEli Cohen };
188e126ba97SEli Cohen
189e6631814SSagi Grimberg enum {
190e6631814SSagi Grimberg MLX5_FLAGS_INLINE = 1<<7,
191e6631814SSagi Grimberg MLX5_FLAGS_CHECK_FREE = 1<<5,
192e6631814SSagi Grimberg };
193e6631814SSagi Grimberg
194e126ba97SEli Cohen struct mlx5_wqe_fmr_seg {
195e126ba97SEli Cohen __be32 flags;
196e126ba97SEli Cohen __be32 mem_key;
197e126ba97SEli Cohen __be64 buf_list;
198e126ba97SEli Cohen __be64 start_addr;
199e126ba97SEli Cohen __be64 reg_len;
200e126ba97SEli Cohen __be32 offset;
201e126ba97SEli Cohen __be32 page_size;
202e126ba97SEli Cohen u32 reserved[2];
203e126ba97SEli Cohen };
204e126ba97SEli Cohen
205e126ba97SEli Cohen struct mlx5_wqe_ctrl_seg {
206e126ba97SEli Cohen __be32 opmod_idx_opcode;
207e126ba97SEli Cohen __be32 qpn_ds;
2082af7e566SSaeed Mahameed
2092af7e566SSaeed Mahameed struct_group(trailer,
2102af7e566SSaeed Mahameed
211e126ba97SEli Cohen u8 signature;
212e126ba97SEli Cohen u8 rsvd[2];
213e126ba97SEli Cohen u8 fm_ce_se;
2140718edf5STariq Toukan union {
2150718edf5STariq Toukan __be32 general_id;
216e126ba97SEli Cohen __be32 imm;
2170718edf5STariq Toukan __be32 umr_mkey;
2182d1b69edSTariq Toukan __be32 tis_tir_num;
2190718edf5STariq Toukan };
2202af7e566SSaeed Mahameed
2212af7e566SSaeed Mahameed ); /* end of trailer group */
222e126ba97SEli Cohen };
223e126ba97SEli Cohen
224c1395a2aSHaggai Eran #define MLX5_WQE_CTRL_DS_MASK 0x3f
2257bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_QPN_MASK 0xffffff00
2267bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_QPN_SHIFT 8
227c1395a2aSHaggai Eran #define MLX5_WQE_DS_UNITS 16
2287bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_OPCODE_MASK 0xff
2297bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_WQE_INDEX_MASK 0x00ffff00
2307bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_WQE_INDEX_SHIFT 8
231c1395a2aSHaggai Eran
232e281682bSSaeed Mahameed enum {
233e281682bSSaeed Mahameed MLX5_ETH_WQE_L3_INNER_CSUM = 1 << 4,
234e281682bSSaeed Mahameed MLX5_ETH_WQE_L4_INNER_CSUM = 1 << 5,
235e281682bSSaeed Mahameed MLX5_ETH_WQE_L3_CSUM = 1 << 6,
236e281682bSSaeed Mahameed MLX5_ETH_WQE_L4_CSUM = 1 << 7,
237e281682bSSaeed Mahameed };
238e281682bSSaeed Mahameed
2392b31f7aeSSaeed Mahameed enum {
2404382c7b9SGal Pressman MLX5_ETH_WQE_SVLAN = 1 << 0,
2412dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_OUTER_IP_ASSOC = 1 << 26,
2422dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_OUTER_L4_ASSOC = 1 << 27,
2432dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_INNER_IP_ASSOC = 3 << 26,
2442dc8b524SRaed Salem MLX5_ETH_WQE_TRAILER_HDR_INNER_L4_ASSOC = 1 << 28,
2452dc8b524SRaed Salem MLX5_ETH_WQE_INSERT_TRAILER = 1 << 30,
2462b31f7aeSSaeed Mahameed MLX5_ETH_WQE_INSERT_VLAN = 1 << 15,
2472b31f7aeSSaeed Mahameed };
2482b31f7aeSSaeed Mahameed
249547eede0SIlan Tayari enum {
250547eede0SIlan Tayari MLX5_ETH_WQE_SWP_INNER_L3_IPV6 = 1 << 0,
251547eede0SIlan Tayari MLX5_ETH_WQE_SWP_INNER_L4_UDP = 1 << 1,
252547eede0SIlan Tayari MLX5_ETH_WQE_SWP_OUTER_L3_IPV6 = 1 << 4,
253547eede0SIlan Tayari MLX5_ETH_WQE_SWP_OUTER_L4_UDP = 1 << 5,
254547eede0SIlan Tayari };
255547eede0SIlan Tayari
2569b9d454dSHuy Nguyen enum {
2579b9d454dSHuy Nguyen MLX5_ETH_WQE_FT_META_IPSEC = BIT(0),
258e467b283SLior Nahmanson MLX5_ETH_WQE_FT_META_MACSEC = BIT(1),
2599b9d454dSHuy Nguyen };
2609b9d454dSHuy Nguyen
261e281682bSSaeed Mahameed struct mlx5_wqe_eth_seg {
262547eede0SIlan Tayari u8 swp_outer_l4_offset;
263547eede0SIlan Tayari u8 swp_outer_l3_offset;
264547eede0SIlan Tayari u8 swp_inner_l4_offset;
265547eede0SIlan Tayari u8 swp_inner_l3_offset;
266e281682bSSaeed Mahameed u8 cs_flags;
267547eede0SIlan Tayari u8 swp_flags;
268e281682bSSaeed Mahameed __be16 mss;
2699b9d454dSHuy Nguyen __be32 flow_table_metadata;
2702b31f7aeSSaeed Mahameed union {
2712b31f7aeSSaeed Mahameed struct {
2722b31f7aeSSaeed Mahameed __be16 sz;
2734d5e86a5SLeon Romanovsky union {
2742b31f7aeSSaeed Mahameed u8 start[2];
2754d5e86a5SLeon Romanovsky DECLARE_FLEX_ARRAY(u8, data);
2764d5e86a5SLeon Romanovsky };
2772b31f7aeSSaeed Mahameed } inline_hdr;
2782b31f7aeSSaeed Mahameed struct {
2792b31f7aeSSaeed Mahameed __be16 type;
2802b31f7aeSSaeed Mahameed __be16 vlan_tci;
2812b31f7aeSSaeed Mahameed } insert;
2822dc8b524SRaed Salem __be32 trailer;
2832b31f7aeSSaeed Mahameed };
284e281682bSSaeed Mahameed };
285e281682bSSaeed Mahameed
286e126ba97SEli Cohen struct mlx5_wqe_xrc_seg {
287e126ba97SEli Cohen __be32 xrc_srqn;
288e126ba97SEli Cohen u8 rsvd[12];
289e126ba97SEli Cohen };
290e126ba97SEli Cohen
291e126ba97SEli Cohen struct mlx5_wqe_masked_atomic_seg {
292e126ba97SEli Cohen __be64 swap_add;
293e126ba97SEli Cohen __be64 compare;
294e126ba97SEli Cohen __be64 swap_add_mask;
295e126ba97SEli Cohen __be64 compare_mask;
296e126ba97SEli Cohen };
297e126ba97SEli Cohen
29817d2f88fSArtemy Kovalyov struct mlx5_base_av {
29917d2f88fSArtemy Kovalyov union {
30017d2f88fSArtemy Kovalyov struct {
30117d2f88fSArtemy Kovalyov __be32 qkey;
30217d2f88fSArtemy Kovalyov __be32 reserved;
30317d2f88fSArtemy Kovalyov } qkey;
30417d2f88fSArtemy Kovalyov __be64 dc_key;
30517d2f88fSArtemy Kovalyov } key;
30617d2f88fSArtemy Kovalyov __be32 dqp_dct;
30717d2f88fSArtemy Kovalyov u8 stat_rate_sl;
30817d2f88fSArtemy Kovalyov u8 fl_mlid;
30917d2f88fSArtemy Kovalyov union {
31017d2f88fSArtemy Kovalyov __be16 rlid;
31117d2f88fSArtemy Kovalyov __be16 udp_sport;
31217d2f88fSArtemy Kovalyov };
31317d2f88fSArtemy Kovalyov };
31417d2f88fSArtemy Kovalyov
315e126ba97SEli Cohen struct mlx5_av {
316e126ba97SEli Cohen union {
317e126ba97SEli Cohen struct {
318e126ba97SEli Cohen __be32 qkey;
319e126ba97SEli Cohen __be32 reserved;
320e126ba97SEli Cohen } qkey;
321e126ba97SEli Cohen __be64 dc_key;
322e126ba97SEli Cohen } key;
323e126ba97SEli Cohen __be32 dqp_dct;
324e126ba97SEli Cohen u8 stat_rate_sl;
325e126ba97SEli Cohen u8 fl_mlid;
3262811ba51SAchiad Shochat union {
327e126ba97SEli Cohen __be16 rlid;
3282811ba51SAchiad Shochat __be16 udp_sport;
3292811ba51SAchiad Shochat };
3302811ba51SAchiad Shochat u8 reserved0[4];
3312811ba51SAchiad Shochat u8 rmac[6];
332e126ba97SEli Cohen u8 tclass;
333e126ba97SEli Cohen u8 hop_limit;
334e126ba97SEli Cohen __be32 grh_gid_fl;
335e126ba97SEli Cohen u8 rgid[16];
336e126ba97SEli Cohen };
337e126ba97SEli Cohen
33825854544SSaeed Mahameed struct mlx5_ib_ah {
33925854544SSaeed Mahameed struct ib_ah ibah;
34025854544SSaeed Mahameed struct mlx5_av av;
341cfc1a89eSMaor Gottlieb u8 xmit_port;
34225854544SSaeed Mahameed };
34325854544SSaeed Mahameed
to_mah(struct ib_ah * ibah)34425854544SSaeed Mahameed static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah)
34525854544SSaeed Mahameed {
34625854544SSaeed Mahameed return container_of(ibah, struct mlx5_ib_ah, ibah);
34725854544SSaeed Mahameed }
34825854544SSaeed Mahameed
349e126ba97SEli Cohen struct mlx5_wqe_datagram_seg {
350e126ba97SEli Cohen struct mlx5_av av;
351e126ba97SEli Cohen };
352e126ba97SEli Cohen
353e126ba97SEli Cohen struct mlx5_wqe_raddr_seg {
354e126ba97SEli Cohen __be64 raddr;
355e126ba97SEli Cohen __be32 rkey;
356e126ba97SEli Cohen u32 reserved;
357e126ba97SEli Cohen };
358e126ba97SEli Cohen
359e126ba97SEli Cohen struct mlx5_wqe_atomic_seg {
360e126ba97SEli Cohen __be64 swap_add;
361e126ba97SEli Cohen __be64 compare;
362e126ba97SEli Cohen };
363e126ba97SEli Cohen
364e126ba97SEli Cohen struct mlx5_wqe_data_seg {
365e126ba97SEli Cohen __be32 byte_count;
366e126ba97SEli Cohen __be32 lkey;
367e126ba97SEli Cohen __be64 addr;
368e126ba97SEli Cohen };
369e126ba97SEli Cohen
370e126ba97SEli Cohen struct mlx5_wqe_umr_ctrl_seg {
371e126ba97SEli Cohen u8 flags;
372e126ba97SEli Cohen u8 rsvd0[3];
37331616255SArtemy Kovalyov __be16 xlt_octowords;
37431616255SArtemy Kovalyov union {
37531616255SArtemy Kovalyov __be16 xlt_offset;
376e126ba97SEli Cohen __be16 bsf_octowords;
37731616255SArtemy Kovalyov };
378e126ba97SEli Cohen __be64 mkey_mask;
37931616255SArtemy Kovalyov __be32 xlt_offset_47_16;
38031616255SArtemy Kovalyov u8 rsvd1[28];
381e126ba97SEli Cohen };
382e126ba97SEli Cohen
383e126ba97SEli Cohen struct mlx5_seg_set_psv {
384e126ba97SEli Cohen __be32 psv_num;
385e126ba97SEli Cohen __be16 syndrome;
386e126ba97SEli Cohen __be16 status;
387e126ba97SEli Cohen __be32 transient_sig;
388e126ba97SEli Cohen __be32 ref_tag;
389e126ba97SEli Cohen };
390e126ba97SEli Cohen
391e126ba97SEli Cohen struct mlx5_seg_get_psv {
392e126ba97SEli Cohen u8 rsvd[19];
393e126ba97SEli Cohen u8 num_psv;
394e126ba97SEli Cohen __be32 l_key;
395e126ba97SEli Cohen __be64 va;
396e126ba97SEli Cohen __be32 psv_index[4];
397e126ba97SEli Cohen };
398e126ba97SEli Cohen
399e126ba97SEli Cohen struct mlx5_seg_check_psv {
400e126ba97SEli Cohen u8 rsvd0[2];
401e126ba97SEli Cohen __be16 err_coalescing_op;
402e126ba97SEli Cohen u8 rsvd1[2];
403e126ba97SEli Cohen __be16 xport_err_op;
404e126ba97SEli Cohen u8 rsvd2[2];
405e126ba97SEli Cohen __be16 xport_err_mask;
406e126ba97SEli Cohen u8 rsvd3[7];
407e126ba97SEli Cohen u8 num_psv;
408e126ba97SEli Cohen __be32 l_key;
409e126ba97SEli Cohen __be64 va;
410e126ba97SEli Cohen __be32 psv_index[4];
411e126ba97SEli Cohen };
412e126ba97SEli Cohen
413e126ba97SEli Cohen struct mlx5_rwqe_sig {
414e126ba97SEli Cohen u8 rsvd0[4];
415e126ba97SEli Cohen u8 signature;
416e126ba97SEli Cohen u8 rsvd1[11];
417e126ba97SEli Cohen };
418e126ba97SEli Cohen
419e126ba97SEli Cohen struct mlx5_wqe_signature_seg {
420e126ba97SEli Cohen u8 rsvd0[4];
421e126ba97SEli Cohen u8 signature;
422e126ba97SEli Cohen u8 rsvd1[11];
423e126ba97SEli Cohen };
424e126ba97SEli Cohen
4257bdf65d4SHaggai Eran #define MLX5_WQE_INLINE_SEG_BYTE_COUNT_MASK 0x3ff
4267bdf65d4SHaggai Eran
427e126ba97SEli Cohen struct mlx5_wqe_inline_seg {
428e126ba97SEli Cohen __be32 byte_count;
429b6ca09cbSGustavo A. R. Silva __be32 data[];
430e126ba97SEli Cohen };
431e126ba97SEli Cohen
432142537f4SSagi Grimberg enum mlx5_sig_type {
433142537f4SSagi Grimberg MLX5_DIF_CRC = 0x1,
434142537f4SSagi Grimberg MLX5_DIF_IPCS = 0x2,
435142537f4SSagi Grimberg };
436142537f4SSagi Grimberg
437142537f4SSagi Grimberg struct mlx5_bsf_inl {
438142537f4SSagi Grimberg __be16 vld_refresh;
439142537f4SSagi Grimberg __be16 dif_apptag;
440142537f4SSagi Grimberg __be32 dif_reftag;
441142537f4SSagi Grimberg u8 sig_type;
442142537f4SSagi Grimberg u8 rp_inv_seed;
443142537f4SSagi Grimberg u8 rsvd[3];
444142537f4SSagi Grimberg u8 dif_inc_ref_guard_check;
445142537f4SSagi Grimberg __be16 dif_app_bitmask_check;
446142537f4SSagi Grimberg };
447142537f4SSagi Grimberg
448e6631814SSagi Grimberg struct mlx5_bsf {
449e6631814SSagi Grimberg struct mlx5_bsf_basic {
450e6631814SSagi Grimberg u8 bsf_size_sbs;
451e6631814SSagi Grimberg u8 check_byte_mask;
452e6631814SSagi Grimberg union {
453e6631814SSagi Grimberg u8 copy_byte_mask;
454e6631814SSagi Grimberg u8 bs_selector;
455e6631814SSagi Grimberg u8 rsvd_wflags;
456e6631814SSagi Grimberg } wire;
457e6631814SSagi Grimberg union {
458e6631814SSagi Grimberg u8 bs_selector;
459e6631814SSagi Grimberg u8 rsvd_mflags;
460e6631814SSagi Grimberg } mem;
461e6631814SSagi Grimberg __be32 raw_data_size;
462e6631814SSagi Grimberg __be32 w_bfs_psv;
463e6631814SSagi Grimberg __be32 m_bfs_psv;
464e6631814SSagi Grimberg } basic;
465e6631814SSagi Grimberg struct mlx5_bsf_ext {
466e6631814SSagi Grimberg __be32 t_init_gen_pro_size;
467e6631814SSagi Grimberg __be32 rsvd_epi_size;
468e6631814SSagi Grimberg __be32 w_tfs_psv;
469e6631814SSagi Grimberg __be32 m_tfs_psv;
470e6631814SSagi Grimberg } ext;
471142537f4SSagi Grimberg struct mlx5_bsf_inl w_inl;
472142537f4SSagi Grimberg struct mlx5_bsf_inl m_inl;
473e6631814SSagi Grimberg };
474e6631814SSagi Grimberg
47531616255SArtemy Kovalyov struct mlx5_mtt {
47631616255SArtemy Kovalyov __be64 ptag;
47731616255SArtemy Kovalyov };
47831616255SArtemy Kovalyov
479e6631814SSagi Grimberg struct mlx5_klm {
480e6631814SSagi Grimberg __be32 bcount;
481e6631814SSagi Grimberg __be32 key;
482e6631814SSagi Grimberg __be64 va;
483e6631814SSagi Grimberg };
484e6631814SSagi Grimberg
4856470d2e7SMaxim Mikityanskiy struct mlx5_ksm {
4866470d2e7SMaxim Mikityanskiy __be32 reserved;
4876470d2e7SMaxim Mikityanskiy __be32 key;
4886470d2e7SMaxim Mikityanskiy __be64 va;
4896470d2e7SMaxim Mikityanskiy };
4906470d2e7SMaxim Mikityanskiy
491e6631814SSagi Grimberg struct mlx5_stride_block_entry {
492e6631814SSagi Grimberg __be16 stride;
493e6631814SSagi Grimberg __be16 bcount;
494e6631814SSagi Grimberg __be32 key;
495e6631814SSagi Grimberg __be64 va;
496e6631814SSagi Grimberg };
497e6631814SSagi Grimberg
498e6631814SSagi Grimberg struct mlx5_stride_block_ctrl_seg {
499e6631814SSagi Grimberg __be32 bcount_per_cycle;
500e6631814SSagi Grimberg __be32 op;
501e6631814SSagi Grimberg __be32 repeat_count;
502e6631814SSagi Grimberg u16 rsvd;
503e6631814SSagi Grimberg __be16 num_entries;
504e6631814SSagi Grimberg };
505e6631814SSagi Grimberg
506977c4a3eSYevgeny Kliteynik struct mlx5_wqe_flow_update_ctrl_seg {
507977c4a3eSYevgeny Kliteynik __be32 flow_idx_update;
508977c4a3eSYevgeny Kliteynik __be32 dest_handle;
509977c4a3eSYevgeny Kliteynik u8 reserved0[40];
510977c4a3eSYevgeny Kliteynik };
511977c4a3eSYevgeny Kliteynik
512977c4a3eSYevgeny Kliteynik struct mlx5_wqe_header_modify_argument_update_seg {
513977c4a3eSYevgeny Kliteynik u8 argument_list[64];
514977c4a3eSYevgeny Kliteynik };
515977c4a3eSYevgeny Kliteynik
516e126ba97SEli Cohen struct mlx5_core_qp {
5175903325aSEli Cohen struct mlx5_core_rsc_common common; /* must be first */
518e126ba97SEli Cohen void (*event) (struct mlx5_core_qp *, int);
519e126ba97SEli Cohen int qpn;
520e126ba97SEli Cohen struct mlx5_rsc_debug *dbg;
521e126ba97SEli Cohen int pid;
5224ac63ec7SYishai Hadas u16 uid;
523e126ba97SEli Cohen };
524e126ba97SEli Cohen
52557cda166SMoni Shoua struct mlx5_core_dct {
52657cda166SMoni Shoua struct mlx5_core_qp mqp;
52757cda166SMoni Shoua struct completion drained;
52857cda166SMoni Shoua };
52957cda166SMoni Shoua
530e126ba97SEli Cohen int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
531e126ba97SEli Cohen void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
53227e95603SMoni Shoua
mlx5_qp_type_str(int type)533db81a5c3SEli Cohen static inline const char *mlx5_qp_type_str(int type)
534db81a5c3SEli Cohen {
535db81a5c3SEli Cohen switch (type) {
536db81a5c3SEli Cohen case MLX5_QP_ST_RC: return "RC";
537db81a5c3SEli Cohen case MLX5_QP_ST_UC: return "C";
538db81a5c3SEli Cohen case MLX5_QP_ST_UD: return "UD";
539db81a5c3SEli Cohen case MLX5_QP_ST_XRC: return "XRC";
540db81a5c3SEli Cohen case MLX5_QP_ST_MLX: return "MLX";
541db81a5c3SEli Cohen case MLX5_QP_ST_QP0: return "QP0";
542db81a5c3SEli Cohen case MLX5_QP_ST_QP1: return "QP1";
543db81a5c3SEli Cohen case MLX5_QP_ST_RAW_ETHERTYPE: return "RAW_ETHERTYPE";
544db81a5c3SEli Cohen case MLX5_QP_ST_RAW_IPV6: return "RAW_IPV6";
545db81a5c3SEli Cohen case MLX5_QP_ST_SNIFFER: return "SNIFFER";
546db81a5c3SEli Cohen case MLX5_QP_ST_SYNC_UMR: return "SYNC_UMR";
547db81a5c3SEli Cohen case MLX5_QP_ST_PTP_1588: return "PTP_1588";
548db81a5c3SEli Cohen case MLX5_QP_ST_REG_UMR: return "REG_UMR";
549db81a5c3SEli Cohen default: return "Invalid transport type";
550db81a5c3SEli Cohen }
551db81a5c3SEli Cohen }
552db81a5c3SEli Cohen
mlx5_qp_state_str(int state)553db81a5c3SEli Cohen static inline const char *mlx5_qp_state_str(int state)
554db81a5c3SEli Cohen {
555db81a5c3SEli Cohen switch (state) {
556db81a5c3SEli Cohen case MLX5_QP_STATE_RST:
557db81a5c3SEli Cohen return "RST";
558db81a5c3SEli Cohen case MLX5_QP_STATE_INIT:
559db81a5c3SEli Cohen return "INIT";
560db81a5c3SEli Cohen case MLX5_QP_STATE_RTR:
561db81a5c3SEli Cohen return "RTR";
562db81a5c3SEli Cohen case MLX5_QP_STATE_RTS:
563db81a5c3SEli Cohen return "RTS";
564db81a5c3SEli Cohen case MLX5_QP_STATE_SQER:
565db81a5c3SEli Cohen return "SQER";
566db81a5c3SEli Cohen case MLX5_QP_STATE_SQD:
567db81a5c3SEli Cohen return "SQD";
568db81a5c3SEli Cohen case MLX5_QP_STATE_ERR:
569db81a5c3SEli Cohen return "ERR";
570db81a5c3SEli Cohen case MLX5_QP_STATE_SQ_DRAINING:
571db81a5c3SEli Cohen return "SQ_DRAINING";
572db81a5c3SEli Cohen case MLX5_QP_STATE_SUSPENDED:
573db81a5c3SEli Cohen return "SUSPENDED";
574db81a5c3SEli Cohen default: return "Invalid QP state";
575db81a5c3SEli Cohen }
576db81a5c3SEli Cohen }
577db81a5c3SEli Cohen
mlx5_get_qp_default_ts(struct mlx5_core_dev * dev)5784806f1e2SMaor Gottlieb static inline int mlx5_get_qp_default_ts(struct mlx5_core_dev *dev)
5794806f1e2SMaor Gottlieb {
5800c5275bfSOr Har-Toov u8 supported_ts_cap = mlx5_get_roce_state(dev) ?
5810c5275bfSOr Har-Toov MLX5_CAP_ROCE(dev, qp_ts_format) :
5820c5275bfSOr Har-Toov MLX5_CAP_GEN(dev, sq_ts_format);
5830c5275bfSOr Har-Toov
5840c5275bfSOr Har-Toov return supported_ts_cap ? MLX5_TIMESTAMP_FORMAT_DEFAULT :
5850c5275bfSOr Har-Toov MLX5_TIMESTAMP_FORMAT_FREE_RUNNING;
5864806f1e2SMaor Gottlieb }
5874806f1e2SMaor Gottlieb
588e126ba97SEli Cohen #endif /* MLX5_QP_H */
589