18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
58c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
68c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
78c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
88c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
118c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
128c2ecf20Sopenharmony_ci *     conditions are met:
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
158c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
168c2ecf20Sopenharmony_ci *        disclaimer.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
198c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
208c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
218c2ecf20Sopenharmony_ci *        provided with the distribution.
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
248c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
258c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
268c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
278c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
288c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
298c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
308c2ecf20Sopenharmony_ci * SOFTWARE.
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#ifndef MLX5_QP_H
348c2ecf20Sopenharmony_ci#define MLX5_QP_H
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#include <linux/mlx5/device.h>
378c2ecf20Sopenharmony_ci#include <linux/mlx5/driver.h>
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define MLX5_INVALID_LKEY	0x100
408c2ecf20Sopenharmony_ci/* UMR (3 WQE_BB's) + SIG (3 WQE_BB's) + PSV (mem) + PSV (wire) */
418c2ecf20Sopenharmony_ci#define MLX5_SIG_WQE_SIZE	(MLX5_SEND_WQE_BB * 8)
428c2ecf20Sopenharmony_ci#define MLX5_DIF_SIZE		8
438c2ecf20Sopenharmony_ci#define MLX5_STRIDE_BLOCK_OP	0x400
448c2ecf20Sopenharmony_ci#define MLX5_CPY_GRD_MASK	0xc0
458c2ecf20Sopenharmony_ci#define MLX5_CPY_APP_MASK	0x30
468c2ecf20Sopenharmony_ci#define MLX5_CPY_REF_MASK	0x0f
478c2ecf20Sopenharmony_ci#define MLX5_BSF_INC_REFTAG	(1 << 6)
488c2ecf20Sopenharmony_ci#define MLX5_BSF_INL_VALID	(1 << 15)
498c2ecf20Sopenharmony_ci#define MLX5_BSF_REFRESH_DIF	(1 << 14)
508c2ecf20Sopenharmony_ci#define MLX5_BSF_REPEAT_BLOCK	(1 << 7)
518c2ecf20Sopenharmony_ci#define MLX5_BSF_APPTAG_ESCAPE	0x1
528c2ecf20Sopenharmony_ci#define MLX5_BSF_APPREF_ESCAPE	0x2
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cienum mlx5_qp_optpar {
558c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_ALT_ADDR_PATH		= 1 << 0,
568c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_RRE			= 1 << 1,
578c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_RAE			= 1 << 2,
588c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_RWE			= 1 << 3,
598c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_PKEY_INDEX		= 1 << 4,
608c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_Q_KEY			= 1 << 5,
618c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_RNR_TIMEOUT		= 1 << 6,
628c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH	= 1 << 7,
638c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_SRA_MAX			= 1 << 8,
648c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_RRA_MAX			= 1 << 9,
658c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_PM_STATE			= 1 << 10,
668c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_RETRY_COUNT		= 1 << 12,
678c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_RNR_RETRY		= 1 << 13,
688c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_ACK_TIMEOUT		= 1 << 14,
698c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_LAG_TX_AFF		= 1 << 15,
708c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_PRI_PORT			= 1 << 16,
718c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_SRQN			= 1 << 18,
728c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_CQN_RCV			= 1 << 19,
738c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_DC_HS			= 1 << 20,
748c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_DC_KEY			= 1 << 21,
758c2ecf20Sopenharmony_ci	MLX5_QP_OPTPAR_COUNTER_SET_ID		= 1 << 25,
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cienum mlx5_qp_state {
798c2ecf20Sopenharmony_ci	MLX5_QP_STATE_RST			= 0,
808c2ecf20Sopenharmony_ci	MLX5_QP_STATE_INIT			= 1,
818c2ecf20Sopenharmony_ci	MLX5_QP_STATE_RTR			= 2,
828c2ecf20Sopenharmony_ci	MLX5_QP_STATE_RTS			= 3,
838c2ecf20Sopenharmony_ci	MLX5_QP_STATE_SQER			= 4,
848c2ecf20Sopenharmony_ci	MLX5_QP_STATE_SQD			= 5,
858c2ecf20Sopenharmony_ci	MLX5_QP_STATE_ERR			= 6,
868c2ecf20Sopenharmony_ci	MLX5_QP_STATE_SQ_DRAINING		= 7,
878c2ecf20Sopenharmony_ci	MLX5_QP_STATE_SUSPENDED			= 9,
888c2ecf20Sopenharmony_ci	MLX5_QP_NUM_STATE,
898c2ecf20Sopenharmony_ci	MLX5_QP_STATE,
908c2ecf20Sopenharmony_ci	MLX5_QP_STATE_BAD,
918c2ecf20Sopenharmony_ci};
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cienum {
948c2ecf20Sopenharmony_ci	MLX5_SQ_STATE_NA	= MLX5_SQC_STATE_ERR + 1,
958c2ecf20Sopenharmony_ci	MLX5_SQ_NUM_STATE	= MLX5_SQ_STATE_NA + 1,
968c2ecf20Sopenharmony_ci	MLX5_RQ_STATE_NA	= MLX5_RQC_STATE_ERR + 1,
978c2ecf20Sopenharmony_ci	MLX5_RQ_NUM_STATE	= MLX5_RQ_STATE_NA + 1,
988c2ecf20Sopenharmony_ci};
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cienum {
1018c2ecf20Sopenharmony_ci	MLX5_QP_ST_RC				= 0x0,
1028c2ecf20Sopenharmony_ci	MLX5_QP_ST_UC				= 0x1,
1038c2ecf20Sopenharmony_ci	MLX5_QP_ST_UD				= 0x2,
1048c2ecf20Sopenharmony_ci	MLX5_QP_ST_XRC				= 0x3,
1058c2ecf20Sopenharmony_ci	MLX5_QP_ST_MLX				= 0x4,
1068c2ecf20Sopenharmony_ci	MLX5_QP_ST_DCI				= 0x5,
1078c2ecf20Sopenharmony_ci	MLX5_QP_ST_DCT				= 0x6,
1088c2ecf20Sopenharmony_ci	MLX5_QP_ST_QP0				= 0x7,
1098c2ecf20Sopenharmony_ci	MLX5_QP_ST_QP1				= 0x8,
1108c2ecf20Sopenharmony_ci	MLX5_QP_ST_RAW_ETHERTYPE		= 0x9,
1118c2ecf20Sopenharmony_ci	MLX5_QP_ST_RAW_IPV6			= 0xa,
1128c2ecf20Sopenharmony_ci	MLX5_QP_ST_SNIFFER			= 0xb,
1138c2ecf20Sopenharmony_ci	MLX5_QP_ST_SYNC_UMR			= 0xe,
1148c2ecf20Sopenharmony_ci	MLX5_QP_ST_PTP_1588			= 0xd,
1158c2ecf20Sopenharmony_ci	MLX5_QP_ST_REG_UMR			= 0xc,
1168c2ecf20Sopenharmony_ci	MLX5_QP_ST_MAX
1178c2ecf20Sopenharmony_ci};
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_cienum {
1208c2ecf20Sopenharmony_ci	MLX5_QP_PM_MIGRATED			= 0x3,
1218c2ecf20Sopenharmony_ci	MLX5_QP_PM_ARMED			= 0x0,
1228c2ecf20Sopenharmony_ci	MLX5_QP_PM_REARM			= 0x1
1238c2ecf20Sopenharmony_ci};
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_cienum {
1268c2ecf20Sopenharmony_ci	MLX5_NON_ZERO_RQ	= 0x0,
1278c2ecf20Sopenharmony_ci	MLX5_SRQ_RQ		= 0x1,
1288c2ecf20Sopenharmony_ci	MLX5_CRQ_RQ		= 0x2,
1298c2ecf20Sopenharmony_ci	MLX5_ZERO_LEN_RQ	= 0x3
1308c2ecf20Sopenharmony_ci};
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/* TODO REM */
1338c2ecf20Sopenharmony_cienum {
1348c2ecf20Sopenharmony_ci	/* params1 */
1358c2ecf20Sopenharmony_ci	MLX5_QP_BIT_SRE				= 1 << 15,
1368c2ecf20Sopenharmony_ci	MLX5_QP_BIT_SWE				= 1 << 14,
1378c2ecf20Sopenharmony_ci	MLX5_QP_BIT_SAE				= 1 << 13,
1388c2ecf20Sopenharmony_ci	/* params2 */
1398c2ecf20Sopenharmony_ci	MLX5_QP_BIT_RRE				= 1 << 15,
1408c2ecf20Sopenharmony_ci	MLX5_QP_BIT_RWE				= 1 << 14,
1418c2ecf20Sopenharmony_ci	MLX5_QP_BIT_RAE				= 1 << 13,
1428c2ecf20Sopenharmony_ci	MLX5_QP_BIT_RIC				= 1 <<	4,
1438c2ecf20Sopenharmony_ci	MLX5_QP_BIT_CC_SLAVE_RECV		= 1 <<  2,
1448c2ecf20Sopenharmony_ci	MLX5_QP_BIT_CC_SLAVE_SEND		= 1 <<  1,
1458c2ecf20Sopenharmony_ci	MLX5_QP_BIT_CC_MASTER			= 1 <<  0
1468c2ecf20Sopenharmony_ci};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cienum {
1498c2ecf20Sopenharmony_ci	MLX5_WQE_CTRL_CQ_UPDATE		= 2 << 2,
1508c2ecf20Sopenharmony_ci	MLX5_WQE_CTRL_CQ_UPDATE_AND_EQE	= 3 << 2,
1518c2ecf20Sopenharmony_ci	MLX5_WQE_CTRL_SOLICITED		= 1 << 1,
1528c2ecf20Sopenharmony_ci};
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_cienum {
1558c2ecf20Sopenharmony_ci	MLX5_SEND_WQE_DS	= 16,
1568c2ecf20Sopenharmony_ci	MLX5_SEND_WQE_BB	= 64,
1578c2ecf20Sopenharmony_ci};
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define MLX5_SEND_WQEBB_NUM_DS	(MLX5_SEND_WQE_BB / MLX5_SEND_WQE_DS)
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cienum {
1628c2ecf20Sopenharmony_ci	MLX5_SEND_WQE_MAX_WQEBBS	= 16,
1638c2ecf20Sopenharmony_ci};
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_cienum {
1668c2ecf20Sopenharmony_ci	MLX5_WQE_FMR_PERM_LOCAL_READ	= 1 << 27,
1678c2ecf20Sopenharmony_ci	MLX5_WQE_FMR_PERM_LOCAL_WRITE	= 1 << 28,
1688c2ecf20Sopenharmony_ci	MLX5_WQE_FMR_PERM_REMOTE_READ	= 1 << 29,
1698c2ecf20Sopenharmony_ci	MLX5_WQE_FMR_PERM_REMOTE_WRITE	= 1 << 30,
1708c2ecf20Sopenharmony_ci	MLX5_WQE_FMR_PERM_ATOMIC	= 1 << 31
1718c2ecf20Sopenharmony_ci};
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_cienum {
1748c2ecf20Sopenharmony_ci	MLX5_FENCE_MODE_NONE			= 0 << 5,
1758c2ecf20Sopenharmony_ci	MLX5_FENCE_MODE_INITIATOR_SMALL		= 1 << 5,
1768c2ecf20Sopenharmony_ci	MLX5_FENCE_MODE_FENCE			= 2 << 5,
1778c2ecf20Sopenharmony_ci	MLX5_FENCE_MODE_STRONG_ORDERING		= 3 << 5,
1788c2ecf20Sopenharmony_ci	MLX5_FENCE_MODE_SMALL_AND_FENCE		= 4 << 5,
1798c2ecf20Sopenharmony_ci};
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_cienum {
1828c2ecf20Sopenharmony_ci	MLX5_RCV_DBR	= 0,
1838c2ecf20Sopenharmony_ci	MLX5_SND_DBR	= 1,
1848c2ecf20Sopenharmony_ci};
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_cienum {
1878c2ecf20Sopenharmony_ci	MLX5_FLAGS_INLINE	= 1<<7,
1888c2ecf20Sopenharmony_ci	MLX5_FLAGS_CHECK_FREE   = 1<<5,
1898c2ecf20Sopenharmony_ci};
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_cistruct mlx5_wqe_fmr_seg {
1928c2ecf20Sopenharmony_ci	__be32			flags;
1938c2ecf20Sopenharmony_ci	__be32			mem_key;
1948c2ecf20Sopenharmony_ci	__be64			buf_list;
1958c2ecf20Sopenharmony_ci	__be64			start_addr;
1968c2ecf20Sopenharmony_ci	__be64			reg_len;
1978c2ecf20Sopenharmony_ci	__be32			offset;
1988c2ecf20Sopenharmony_ci	__be32			page_size;
1998c2ecf20Sopenharmony_ci	u32			reserved[2];
2008c2ecf20Sopenharmony_ci};
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_cistruct mlx5_wqe_ctrl_seg {
2038c2ecf20Sopenharmony_ci	__be32			opmod_idx_opcode;
2048c2ecf20Sopenharmony_ci	__be32			qpn_ds;
2058c2ecf20Sopenharmony_ci	u8			signature;
2068c2ecf20Sopenharmony_ci	u8			rsvd[2];
2078c2ecf20Sopenharmony_ci	u8			fm_ce_se;
2088c2ecf20Sopenharmony_ci	union {
2098c2ecf20Sopenharmony_ci		__be32		general_id;
2108c2ecf20Sopenharmony_ci		__be32		imm;
2118c2ecf20Sopenharmony_ci		__be32		umr_mkey;
2128c2ecf20Sopenharmony_ci		__be32		tis_tir_num;
2138c2ecf20Sopenharmony_ci	};
2148c2ecf20Sopenharmony_ci};
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci#define MLX5_WQE_CTRL_DS_MASK 0x3f
2178c2ecf20Sopenharmony_ci#define MLX5_WQE_CTRL_QPN_MASK 0xffffff00
2188c2ecf20Sopenharmony_ci#define MLX5_WQE_CTRL_QPN_SHIFT 8
2198c2ecf20Sopenharmony_ci#define MLX5_WQE_DS_UNITS 16
2208c2ecf20Sopenharmony_ci#define MLX5_WQE_CTRL_OPCODE_MASK 0xff
2218c2ecf20Sopenharmony_ci#define MLX5_WQE_CTRL_WQE_INDEX_MASK 0x00ffff00
2228c2ecf20Sopenharmony_ci#define MLX5_WQE_CTRL_WQE_INDEX_SHIFT 8
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_cienum {
2258c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_L3_INNER_CSUM      = 1 << 4,
2268c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_L4_INNER_CSUM      = 1 << 5,
2278c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_L3_CSUM            = 1 << 6,
2288c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_L4_CSUM            = 1 << 7,
2298c2ecf20Sopenharmony_ci};
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_cienum {
2328c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_SVLAN              = 1 << 0,
2338c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_TRAILER_HDR_OUTER_IP_ASSOC = 1 << 26,
2348c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_TRAILER_HDR_OUTER_L4_ASSOC = 1 << 27,
2358c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_TRAILER_HDR_INNER_IP_ASSOC = 3 << 26,
2368c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_TRAILER_HDR_INNER_L4_ASSOC = 1 << 28,
2378c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_INSERT_TRAILER     = 1 << 30,
2388c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_INSERT_VLAN        = 1 << 15,
2398c2ecf20Sopenharmony_ci};
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_cienum {
2428c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_SWP_INNER_L3_IPV6  = 1 << 0,
2438c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_SWP_INNER_L4_UDP   = 1 << 1,
2448c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_SWP_OUTER_L3_IPV6  = 1 << 4,
2458c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_SWP_OUTER_L4_UDP   = 1 << 5,
2468c2ecf20Sopenharmony_ci};
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cienum {
2498c2ecf20Sopenharmony_ci	MLX5_ETH_WQE_FT_META_IPSEC = BIT(0),
2508c2ecf20Sopenharmony_ci};
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_cistruct mlx5_wqe_eth_seg {
2538c2ecf20Sopenharmony_ci	u8              swp_outer_l4_offset;
2548c2ecf20Sopenharmony_ci	u8              swp_outer_l3_offset;
2558c2ecf20Sopenharmony_ci	u8              swp_inner_l4_offset;
2568c2ecf20Sopenharmony_ci	u8              swp_inner_l3_offset;
2578c2ecf20Sopenharmony_ci	u8              cs_flags;
2588c2ecf20Sopenharmony_ci	u8              swp_flags;
2598c2ecf20Sopenharmony_ci	__be16          mss;
2608c2ecf20Sopenharmony_ci	__be32          flow_table_metadata;
2618c2ecf20Sopenharmony_ci	union {
2628c2ecf20Sopenharmony_ci		struct {
2638c2ecf20Sopenharmony_ci			__be16 sz;
2648c2ecf20Sopenharmony_ci			u8     start[2];
2658c2ecf20Sopenharmony_ci		} inline_hdr;
2668c2ecf20Sopenharmony_ci		struct {
2678c2ecf20Sopenharmony_ci			__be16 type;
2688c2ecf20Sopenharmony_ci			__be16 vlan_tci;
2698c2ecf20Sopenharmony_ci		} insert;
2708c2ecf20Sopenharmony_ci		__be32 trailer;
2718c2ecf20Sopenharmony_ci	};
2728c2ecf20Sopenharmony_ci};
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistruct mlx5_wqe_xrc_seg {
2758c2ecf20Sopenharmony_ci	__be32			xrc_srqn;
2768c2ecf20Sopenharmony_ci	u8			rsvd[12];
2778c2ecf20Sopenharmony_ci};
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_cistruct mlx5_wqe_masked_atomic_seg {
2808c2ecf20Sopenharmony_ci	__be64			swap_add;
2818c2ecf20Sopenharmony_ci	__be64			compare;
2828c2ecf20Sopenharmony_ci	__be64			swap_add_mask;
2838c2ecf20Sopenharmony_ci	__be64			compare_mask;
2848c2ecf20Sopenharmony_ci};
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_cistruct mlx5_base_av {
2878c2ecf20Sopenharmony_ci	union {
2888c2ecf20Sopenharmony_ci		struct {
2898c2ecf20Sopenharmony_ci			__be32	qkey;
2908c2ecf20Sopenharmony_ci			__be32	reserved;
2918c2ecf20Sopenharmony_ci		} qkey;
2928c2ecf20Sopenharmony_ci		__be64	dc_key;
2938c2ecf20Sopenharmony_ci	} key;
2948c2ecf20Sopenharmony_ci	__be32	dqp_dct;
2958c2ecf20Sopenharmony_ci	u8	stat_rate_sl;
2968c2ecf20Sopenharmony_ci	u8	fl_mlid;
2978c2ecf20Sopenharmony_ci	union {
2988c2ecf20Sopenharmony_ci		__be16	rlid;
2998c2ecf20Sopenharmony_ci		__be16  udp_sport;
3008c2ecf20Sopenharmony_ci	};
3018c2ecf20Sopenharmony_ci};
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_cistruct mlx5_av {
3048c2ecf20Sopenharmony_ci	union {
3058c2ecf20Sopenharmony_ci		struct {
3068c2ecf20Sopenharmony_ci			__be32	qkey;
3078c2ecf20Sopenharmony_ci			__be32	reserved;
3088c2ecf20Sopenharmony_ci		} qkey;
3098c2ecf20Sopenharmony_ci		__be64	dc_key;
3108c2ecf20Sopenharmony_ci	} key;
3118c2ecf20Sopenharmony_ci	__be32	dqp_dct;
3128c2ecf20Sopenharmony_ci	u8	stat_rate_sl;
3138c2ecf20Sopenharmony_ci	u8	fl_mlid;
3148c2ecf20Sopenharmony_ci	union {
3158c2ecf20Sopenharmony_ci		__be16	rlid;
3168c2ecf20Sopenharmony_ci		__be16  udp_sport;
3178c2ecf20Sopenharmony_ci	};
3188c2ecf20Sopenharmony_ci	u8	reserved0[4];
3198c2ecf20Sopenharmony_ci	u8	rmac[6];
3208c2ecf20Sopenharmony_ci	u8	tclass;
3218c2ecf20Sopenharmony_ci	u8	hop_limit;
3228c2ecf20Sopenharmony_ci	__be32	grh_gid_fl;
3238c2ecf20Sopenharmony_ci	u8	rgid[16];
3248c2ecf20Sopenharmony_ci};
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistruct mlx5_ib_ah {
3278c2ecf20Sopenharmony_ci	struct ib_ah		ibah;
3288c2ecf20Sopenharmony_ci	struct mlx5_av		av;
3298c2ecf20Sopenharmony_ci	u8			xmit_port;
3308c2ecf20Sopenharmony_ci};
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistatic inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah)
3338c2ecf20Sopenharmony_ci{
3348c2ecf20Sopenharmony_ci	return container_of(ibah, struct mlx5_ib_ah, ibah);
3358c2ecf20Sopenharmony_ci}
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_cistruct mlx5_wqe_datagram_seg {
3388c2ecf20Sopenharmony_ci	struct mlx5_av	av;
3398c2ecf20Sopenharmony_ci};
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_cistruct mlx5_wqe_raddr_seg {
3428c2ecf20Sopenharmony_ci	__be64			raddr;
3438c2ecf20Sopenharmony_ci	__be32			rkey;
3448c2ecf20Sopenharmony_ci	u32			reserved;
3458c2ecf20Sopenharmony_ci};
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_cistruct mlx5_wqe_atomic_seg {
3488c2ecf20Sopenharmony_ci	__be64			swap_add;
3498c2ecf20Sopenharmony_ci	__be64			compare;
3508c2ecf20Sopenharmony_ci};
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_cistruct mlx5_wqe_data_seg {
3538c2ecf20Sopenharmony_ci	__be32			byte_count;
3548c2ecf20Sopenharmony_ci	__be32			lkey;
3558c2ecf20Sopenharmony_ci	__be64			addr;
3568c2ecf20Sopenharmony_ci};
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_cistruct mlx5_wqe_umr_ctrl_seg {
3598c2ecf20Sopenharmony_ci	u8		flags;
3608c2ecf20Sopenharmony_ci	u8		rsvd0[3];
3618c2ecf20Sopenharmony_ci	__be16		xlt_octowords;
3628c2ecf20Sopenharmony_ci	union {
3638c2ecf20Sopenharmony_ci		__be16	xlt_offset;
3648c2ecf20Sopenharmony_ci		__be16	bsf_octowords;
3658c2ecf20Sopenharmony_ci	};
3668c2ecf20Sopenharmony_ci	__be64		mkey_mask;
3678c2ecf20Sopenharmony_ci	__be32		xlt_offset_47_16;
3688c2ecf20Sopenharmony_ci	u8		rsvd1[28];
3698c2ecf20Sopenharmony_ci};
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cistruct mlx5_seg_set_psv {
3728c2ecf20Sopenharmony_ci	__be32		psv_num;
3738c2ecf20Sopenharmony_ci	__be16		syndrome;
3748c2ecf20Sopenharmony_ci	__be16		status;
3758c2ecf20Sopenharmony_ci	__be32		transient_sig;
3768c2ecf20Sopenharmony_ci	__be32		ref_tag;
3778c2ecf20Sopenharmony_ci};
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_cistruct mlx5_seg_get_psv {
3808c2ecf20Sopenharmony_ci	u8		rsvd[19];
3818c2ecf20Sopenharmony_ci	u8		num_psv;
3828c2ecf20Sopenharmony_ci	__be32		l_key;
3838c2ecf20Sopenharmony_ci	__be64		va;
3848c2ecf20Sopenharmony_ci	__be32		psv_index[4];
3858c2ecf20Sopenharmony_ci};
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_cistruct mlx5_seg_check_psv {
3888c2ecf20Sopenharmony_ci	u8		rsvd0[2];
3898c2ecf20Sopenharmony_ci	__be16		err_coalescing_op;
3908c2ecf20Sopenharmony_ci	u8		rsvd1[2];
3918c2ecf20Sopenharmony_ci	__be16		xport_err_op;
3928c2ecf20Sopenharmony_ci	u8		rsvd2[2];
3938c2ecf20Sopenharmony_ci	__be16		xport_err_mask;
3948c2ecf20Sopenharmony_ci	u8		rsvd3[7];
3958c2ecf20Sopenharmony_ci	u8		num_psv;
3968c2ecf20Sopenharmony_ci	__be32		l_key;
3978c2ecf20Sopenharmony_ci	__be64		va;
3988c2ecf20Sopenharmony_ci	__be32		psv_index[4];
3998c2ecf20Sopenharmony_ci};
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_cistruct mlx5_rwqe_sig {
4028c2ecf20Sopenharmony_ci	u8	rsvd0[4];
4038c2ecf20Sopenharmony_ci	u8	signature;
4048c2ecf20Sopenharmony_ci	u8	rsvd1[11];
4058c2ecf20Sopenharmony_ci};
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_cistruct mlx5_wqe_signature_seg {
4088c2ecf20Sopenharmony_ci	u8	rsvd0[4];
4098c2ecf20Sopenharmony_ci	u8	signature;
4108c2ecf20Sopenharmony_ci	u8	rsvd1[11];
4118c2ecf20Sopenharmony_ci};
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci#define MLX5_WQE_INLINE_SEG_BYTE_COUNT_MASK 0x3ff
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_cistruct mlx5_wqe_inline_seg {
4168c2ecf20Sopenharmony_ci	__be32	byte_count;
4178c2ecf20Sopenharmony_ci	__be32	data[];
4188c2ecf20Sopenharmony_ci};
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_cienum mlx5_sig_type {
4218c2ecf20Sopenharmony_ci	MLX5_DIF_CRC = 0x1,
4228c2ecf20Sopenharmony_ci	MLX5_DIF_IPCS = 0x2,
4238c2ecf20Sopenharmony_ci};
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_cistruct mlx5_bsf_inl {
4268c2ecf20Sopenharmony_ci	__be16		vld_refresh;
4278c2ecf20Sopenharmony_ci	__be16		dif_apptag;
4288c2ecf20Sopenharmony_ci	__be32		dif_reftag;
4298c2ecf20Sopenharmony_ci	u8		sig_type;
4308c2ecf20Sopenharmony_ci	u8		rp_inv_seed;
4318c2ecf20Sopenharmony_ci	u8		rsvd[3];
4328c2ecf20Sopenharmony_ci	u8		dif_inc_ref_guard_check;
4338c2ecf20Sopenharmony_ci	__be16		dif_app_bitmask_check;
4348c2ecf20Sopenharmony_ci};
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_cistruct mlx5_bsf {
4378c2ecf20Sopenharmony_ci	struct mlx5_bsf_basic {
4388c2ecf20Sopenharmony_ci		u8		bsf_size_sbs;
4398c2ecf20Sopenharmony_ci		u8		check_byte_mask;
4408c2ecf20Sopenharmony_ci		union {
4418c2ecf20Sopenharmony_ci			u8	copy_byte_mask;
4428c2ecf20Sopenharmony_ci			u8	bs_selector;
4438c2ecf20Sopenharmony_ci			u8	rsvd_wflags;
4448c2ecf20Sopenharmony_ci		} wire;
4458c2ecf20Sopenharmony_ci		union {
4468c2ecf20Sopenharmony_ci			u8	bs_selector;
4478c2ecf20Sopenharmony_ci			u8	rsvd_mflags;
4488c2ecf20Sopenharmony_ci		} mem;
4498c2ecf20Sopenharmony_ci		__be32		raw_data_size;
4508c2ecf20Sopenharmony_ci		__be32		w_bfs_psv;
4518c2ecf20Sopenharmony_ci		__be32		m_bfs_psv;
4528c2ecf20Sopenharmony_ci	} basic;
4538c2ecf20Sopenharmony_ci	struct mlx5_bsf_ext {
4548c2ecf20Sopenharmony_ci		__be32		t_init_gen_pro_size;
4558c2ecf20Sopenharmony_ci		__be32		rsvd_epi_size;
4568c2ecf20Sopenharmony_ci		__be32		w_tfs_psv;
4578c2ecf20Sopenharmony_ci		__be32		m_tfs_psv;
4588c2ecf20Sopenharmony_ci	} ext;
4598c2ecf20Sopenharmony_ci	struct mlx5_bsf_inl	w_inl;
4608c2ecf20Sopenharmony_ci	struct mlx5_bsf_inl	m_inl;
4618c2ecf20Sopenharmony_ci};
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_cistruct mlx5_mtt {
4648c2ecf20Sopenharmony_ci	__be64		ptag;
4658c2ecf20Sopenharmony_ci};
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_cistruct mlx5_klm {
4688c2ecf20Sopenharmony_ci	__be32		bcount;
4698c2ecf20Sopenharmony_ci	__be32		key;
4708c2ecf20Sopenharmony_ci	__be64		va;
4718c2ecf20Sopenharmony_ci};
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_cistruct mlx5_stride_block_entry {
4748c2ecf20Sopenharmony_ci	__be16		stride;
4758c2ecf20Sopenharmony_ci	__be16		bcount;
4768c2ecf20Sopenharmony_ci	__be32		key;
4778c2ecf20Sopenharmony_ci	__be64		va;
4788c2ecf20Sopenharmony_ci};
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_cistruct mlx5_stride_block_ctrl_seg {
4818c2ecf20Sopenharmony_ci	__be32		bcount_per_cycle;
4828c2ecf20Sopenharmony_ci	__be32		op;
4838c2ecf20Sopenharmony_ci	__be32		repeat_count;
4848c2ecf20Sopenharmony_ci	u16		rsvd;
4858c2ecf20Sopenharmony_ci	__be16		num_entries;
4868c2ecf20Sopenharmony_ci};
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_cistruct mlx5_core_qp {
4898c2ecf20Sopenharmony_ci	struct mlx5_core_rsc_common	common; /* must be first */
4908c2ecf20Sopenharmony_ci	void (*event)		(struct mlx5_core_qp *, int);
4918c2ecf20Sopenharmony_ci	int			qpn;
4928c2ecf20Sopenharmony_ci	struct mlx5_rsc_debug	*dbg;
4938c2ecf20Sopenharmony_ci	int			pid;
4948c2ecf20Sopenharmony_ci	u16			uid;
4958c2ecf20Sopenharmony_ci};
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_cistruct mlx5_core_dct {
4988c2ecf20Sopenharmony_ci	struct mlx5_core_qp	mqp;
4998c2ecf20Sopenharmony_ci	struct completion	drained;
5008c2ecf20Sopenharmony_ci};
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ciint mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
5038c2ecf20Sopenharmony_civoid mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_cistatic inline const char *mlx5_qp_type_str(int type)
5068c2ecf20Sopenharmony_ci{
5078c2ecf20Sopenharmony_ci	switch (type) {
5088c2ecf20Sopenharmony_ci	case MLX5_QP_ST_RC: return "RC";
5098c2ecf20Sopenharmony_ci	case MLX5_QP_ST_UC: return "C";
5108c2ecf20Sopenharmony_ci	case MLX5_QP_ST_UD: return "UD";
5118c2ecf20Sopenharmony_ci	case MLX5_QP_ST_XRC: return "XRC";
5128c2ecf20Sopenharmony_ci	case MLX5_QP_ST_MLX: return "MLX";
5138c2ecf20Sopenharmony_ci	case MLX5_QP_ST_QP0: return "QP0";
5148c2ecf20Sopenharmony_ci	case MLX5_QP_ST_QP1: return "QP1";
5158c2ecf20Sopenharmony_ci	case MLX5_QP_ST_RAW_ETHERTYPE: return "RAW_ETHERTYPE";
5168c2ecf20Sopenharmony_ci	case MLX5_QP_ST_RAW_IPV6: return "RAW_IPV6";
5178c2ecf20Sopenharmony_ci	case MLX5_QP_ST_SNIFFER: return "SNIFFER";
5188c2ecf20Sopenharmony_ci	case MLX5_QP_ST_SYNC_UMR: return "SYNC_UMR";
5198c2ecf20Sopenharmony_ci	case MLX5_QP_ST_PTP_1588: return "PTP_1588";
5208c2ecf20Sopenharmony_ci	case MLX5_QP_ST_REG_UMR: return "REG_UMR";
5218c2ecf20Sopenharmony_ci	default: return "Invalid transport type";
5228c2ecf20Sopenharmony_ci	}
5238c2ecf20Sopenharmony_ci}
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_cistatic inline const char *mlx5_qp_state_str(int state)
5268c2ecf20Sopenharmony_ci{
5278c2ecf20Sopenharmony_ci	switch (state) {
5288c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_RST:
5298c2ecf20Sopenharmony_ci	return "RST";
5308c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_INIT:
5318c2ecf20Sopenharmony_ci	return "INIT";
5328c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_RTR:
5338c2ecf20Sopenharmony_ci	return "RTR";
5348c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_RTS:
5358c2ecf20Sopenharmony_ci	return "RTS";
5368c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_SQER:
5378c2ecf20Sopenharmony_ci	return "SQER";
5388c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_SQD:
5398c2ecf20Sopenharmony_ci	return "SQD";
5408c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_ERR:
5418c2ecf20Sopenharmony_ci	return "ERR";
5428c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_SQ_DRAINING:
5438c2ecf20Sopenharmony_ci	return "SQ_DRAINING";
5448c2ecf20Sopenharmony_ci	case MLX5_QP_STATE_SUSPENDED:
5458c2ecf20Sopenharmony_ci	return "SUSPENDED";
5468c2ecf20Sopenharmony_ci	default: return "Invalid QP state";
5478c2ecf20Sopenharmony_ci	}
5488c2ecf20Sopenharmony_ci}
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ci#endif /* MLX5_QP_H */
551