18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2006, 2007 Cisco Systems.  All rights reserved.
38c2ecf20Sopenharmony_ci * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
68c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
78c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
88c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
98c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
128c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
138c2ecf20Sopenharmony_ci *     conditions are met:
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
168c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
178c2ecf20Sopenharmony_ci *        disclaimer.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
208c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
218c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
228c2ecf20Sopenharmony_ci *        provided with the distribution.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
258c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
268c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
278c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
288c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
298c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
308c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
318c2ecf20Sopenharmony_ci * SOFTWARE.
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#ifndef MLX4_IB_H
358c2ecf20Sopenharmony_ci#define MLX4_IB_H
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#include <linux/compiler.h>
388c2ecf20Sopenharmony_ci#include <linux/list.h>
398c2ecf20Sopenharmony_ci#include <linux/mutex.h>
408c2ecf20Sopenharmony_ci#include <linux/idr.h>
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#include <rdma/ib_verbs.h>
438c2ecf20Sopenharmony_ci#include <rdma/ib_umem.h>
448c2ecf20Sopenharmony_ci#include <rdma/ib_mad.h>
458c2ecf20Sopenharmony_ci#include <rdma/ib_sa.h>
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#include <linux/mlx4/device.h>
488c2ecf20Sopenharmony_ci#include <linux/mlx4/doorbell.h>
498c2ecf20Sopenharmony_ci#include <linux/mlx4/qp.h>
508c2ecf20Sopenharmony_ci#include <linux/mlx4/cq.h>
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define MLX4_IB_DRV_NAME	"mlx4_ib"
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#ifdef pr_fmt
558c2ecf20Sopenharmony_ci#undef pr_fmt
568c2ecf20Sopenharmony_ci#endif
578c2ecf20Sopenharmony_ci#define pr_fmt(fmt)	"<" MLX4_IB_DRV_NAME "> %s: " fmt, __func__
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define mlx4_ib_warn(ibdev, format, arg...) \
608c2ecf20Sopenharmony_ci	dev_warn((ibdev)->dev.parent, MLX4_IB_DRV_NAME ": " format, ## arg)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cienum {
638c2ecf20Sopenharmony_ci	MLX4_IB_SQ_MIN_WQE_SHIFT = 6,
648c2ecf20Sopenharmony_ci	MLX4_IB_MAX_HEADROOM	 = 2048
658c2ecf20Sopenharmony_ci};
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define MLX4_IB_SQ_HEADROOM(shift)	((MLX4_IB_MAX_HEADROOM >> (shift)) + 1)
688c2ecf20Sopenharmony_ci#define MLX4_IB_SQ_MAX_SPARE		(MLX4_IB_SQ_HEADROOM(MLX4_IB_SQ_MIN_WQE_SHIFT))
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/*module param to indicate if SM assigns the alias_GUID*/
718c2ecf20Sopenharmony_ciextern int mlx4_ib_sm_guid_assign;
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define MLX4_IB_UC_STEER_QPN_ALIGN 1
748c2ecf20Sopenharmony_ci#define MLX4_IB_UC_MAX_NUM_QPS     256
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cienum hw_bar_type {
778c2ecf20Sopenharmony_ci	HW_BAR_BF,
788c2ecf20Sopenharmony_ci	HW_BAR_DB,
798c2ecf20Sopenharmony_ci	HW_BAR_CLOCK,
808c2ecf20Sopenharmony_ci	HW_BAR_COUNT
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistruct mlx4_ib_ucontext {
848c2ecf20Sopenharmony_ci	struct ib_ucontext	ibucontext;
858c2ecf20Sopenharmony_ci	struct mlx4_uar		uar;
868c2ecf20Sopenharmony_ci	struct list_head	db_page_list;
878c2ecf20Sopenharmony_ci	struct mutex		db_page_mutex;
888c2ecf20Sopenharmony_ci	struct list_head	wqn_ranges_list;
898c2ecf20Sopenharmony_ci	struct mutex		wqn_ranges_mutex; /* protect wqn_ranges_list */
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistruct mlx4_ib_pd {
938c2ecf20Sopenharmony_ci	struct ib_pd		ibpd;
948c2ecf20Sopenharmony_ci	u32			pdn;
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cistruct mlx4_ib_xrcd {
988c2ecf20Sopenharmony_ci	struct ib_xrcd		ibxrcd;
998c2ecf20Sopenharmony_ci	u32			xrcdn;
1008c2ecf20Sopenharmony_ci	struct ib_pd	       *pd;
1018c2ecf20Sopenharmony_ci	struct ib_cq	       *cq;
1028c2ecf20Sopenharmony_ci};
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistruct mlx4_ib_cq_buf {
1058c2ecf20Sopenharmony_ci	struct mlx4_buf		buf;
1068c2ecf20Sopenharmony_ci	struct mlx4_mtt		mtt;
1078c2ecf20Sopenharmony_ci	int			entry_size;
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cistruct mlx4_ib_cq_resize {
1118c2ecf20Sopenharmony_ci	struct mlx4_ib_cq_buf	buf;
1128c2ecf20Sopenharmony_ci	int			cqe;
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistruct mlx4_ib_cq {
1168c2ecf20Sopenharmony_ci	struct ib_cq		ibcq;
1178c2ecf20Sopenharmony_ci	struct mlx4_cq		mcq;
1188c2ecf20Sopenharmony_ci	struct mlx4_ib_cq_buf	buf;
1198c2ecf20Sopenharmony_ci	struct mlx4_ib_cq_resize *resize_buf;
1208c2ecf20Sopenharmony_ci	struct mlx4_db		db;
1218c2ecf20Sopenharmony_ci	spinlock_t		lock;
1228c2ecf20Sopenharmony_ci	struct mutex		resize_mutex;
1238c2ecf20Sopenharmony_ci	struct ib_umem	       *umem;
1248c2ecf20Sopenharmony_ci	struct ib_umem	       *resize_umem;
1258c2ecf20Sopenharmony_ci	int			create_flags;
1268c2ecf20Sopenharmony_ci	/* List of qps that it serves.*/
1278c2ecf20Sopenharmony_ci	struct list_head		send_qp_list;
1288c2ecf20Sopenharmony_ci	struct list_head		recv_qp_list;
1298c2ecf20Sopenharmony_ci};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#define MLX4_MR_PAGES_ALIGN 0x40
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistruct mlx4_ib_mr {
1348c2ecf20Sopenharmony_ci	struct ib_mr		ibmr;
1358c2ecf20Sopenharmony_ci	__be64			*pages;
1368c2ecf20Sopenharmony_ci	dma_addr_t		page_map;
1378c2ecf20Sopenharmony_ci	u32			npages;
1388c2ecf20Sopenharmony_ci	u32			max_pages;
1398c2ecf20Sopenharmony_ci	struct mlx4_mr		mmr;
1408c2ecf20Sopenharmony_ci	struct ib_umem	       *umem;
1418c2ecf20Sopenharmony_ci	size_t			page_map_size;
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistruct mlx4_ib_mw {
1458c2ecf20Sopenharmony_ci	struct ib_mw		ibmw;
1468c2ecf20Sopenharmony_ci	struct mlx4_mw		mmw;
1478c2ecf20Sopenharmony_ci};
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci#define MAX_REGS_PER_FLOW 2
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_cistruct mlx4_flow_reg_id {
1528c2ecf20Sopenharmony_ci	u64 id;
1538c2ecf20Sopenharmony_ci	u64 mirror;
1548c2ecf20Sopenharmony_ci};
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistruct mlx4_ib_flow {
1578c2ecf20Sopenharmony_ci	struct ib_flow ibflow;
1588c2ecf20Sopenharmony_ci	/* translating DMFS verbs sniffer rule to FW API requires two reg IDs */
1598c2ecf20Sopenharmony_ci	struct mlx4_flow_reg_id reg_id[MAX_REGS_PER_FLOW];
1608c2ecf20Sopenharmony_ci};
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistruct mlx4_ib_wq {
1638c2ecf20Sopenharmony_ci	u64		       *wrid;
1648c2ecf20Sopenharmony_ci	spinlock_t		lock;
1658c2ecf20Sopenharmony_ci	int			wqe_cnt;
1668c2ecf20Sopenharmony_ci	int			max_post;
1678c2ecf20Sopenharmony_ci	int			max_gs;
1688c2ecf20Sopenharmony_ci	int			offset;
1698c2ecf20Sopenharmony_ci	int			wqe_shift;
1708c2ecf20Sopenharmony_ci	unsigned		head;
1718c2ecf20Sopenharmony_ci	unsigned		tail;
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cienum {
1758c2ecf20Sopenharmony_ci	MLX4_IB_QP_CREATE_ROCE_V2_GSI = IB_QP_CREATE_RESERVED_START
1768c2ecf20Sopenharmony_ci};
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_cienum mlx4_ib_qp_flags {
1798c2ecf20Sopenharmony_ci	MLX4_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO,
1808c2ecf20Sopenharmony_ci	MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK,
1818c2ecf20Sopenharmony_ci	MLX4_IB_QP_NETIF = IB_QP_CREATE_NETIF_QP,
1828c2ecf20Sopenharmony_ci	MLX4_IB_QP_SCATTER_FCS = IB_QP_CREATE_SCATTER_FCS,
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	/* Mellanox specific flags start from IB_QP_CREATE_RESERVED_START */
1858c2ecf20Sopenharmony_ci	MLX4_IB_ROCE_V2_GSI_QP = MLX4_IB_QP_CREATE_ROCE_V2_GSI,
1868c2ecf20Sopenharmony_ci	MLX4_IB_SRIOV_TUNNEL_QP = 1 << 30,
1878c2ecf20Sopenharmony_ci	MLX4_IB_SRIOV_SQP = 1 << 31,
1888c2ecf20Sopenharmony_ci};
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_cistruct mlx4_ib_gid_entry {
1918c2ecf20Sopenharmony_ci	struct list_head	list;
1928c2ecf20Sopenharmony_ci	union ib_gid		gid;
1938c2ecf20Sopenharmony_ci	int			added;
1948c2ecf20Sopenharmony_ci	u8			port;
1958c2ecf20Sopenharmony_ci};
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_cienum mlx4_ib_qp_type {
1988c2ecf20Sopenharmony_ci	/*
1998c2ecf20Sopenharmony_ci	 * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
2008c2ecf20Sopenharmony_ci	 * here (and in that order) since the MAD layer uses them as
2018c2ecf20Sopenharmony_ci	 * indices into a 2-entry table.
2028c2ecf20Sopenharmony_ci	 */
2038c2ecf20Sopenharmony_ci	MLX4_IB_QPT_SMI = IB_QPT_SMI,
2048c2ecf20Sopenharmony_ci	MLX4_IB_QPT_GSI = IB_QPT_GSI,
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci	MLX4_IB_QPT_RC = IB_QPT_RC,
2078c2ecf20Sopenharmony_ci	MLX4_IB_QPT_UC = IB_QPT_UC,
2088c2ecf20Sopenharmony_ci	MLX4_IB_QPT_UD = IB_QPT_UD,
2098c2ecf20Sopenharmony_ci	MLX4_IB_QPT_RAW_IPV6 = IB_QPT_RAW_IPV6,
2108c2ecf20Sopenharmony_ci	MLX4_IB_QPT_RAW_ETHERTYPE = IB_QPT_RAW_ETHERTYPE,
2118c2ecf20Sopenharmony_ci	MLX4_IB_QPT_RAW_PACKET = IB_QPT_RAW_PACKET,
2128c2ecf20Sopenharmony_ci	MLX4_IB_QPT_XRC_INI = IB_QPT_XRC_INI,
2138c2ecf20Sopenharmony_ci	MLX4_IB_QPT_XRC_TGT = IB_QPT_XRC_TGT,
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	MLX4_IB_QPT_PROXY_SMI_OWNER	= 1 << 16,
2168c2ecf20Sopenharmony_ci	MLX4_IB_QPT_PROXY_SMI		= 1 << 17,
2178c2ecf20Sopenharmony_ci	MLX4_IB_QPT_PROXY_GSI		= 1 << 18,
2188c2ecf20Sopenharmony_ci	MLX4_IB_QPT_TUN_SMI_OWNER	= 1 << 19,
2198c2ecf20Sopenharmony_ci	MLX4_IB_QPT_TUN_SMI		= 1 << 20,
2208c2ecf20Sopenharmony_ci	MLX4_IB_QPT_TUN_GSI		= 1 << 21,
2218c2ecf20Sopenharmony_ci};
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci#define MLX4_IB_QPT_ANY_SRIOV	(MLX4_IB_QPT_PROXY_SMI_OWNER | \
2248c2ecf20Sopenharmony_ci	MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER | \
2258c2ecf20Sopenharmony_ci	MLX4_IB_QPT_TUN_SMI | MLX4_IB_QPT_TUN_GSI)
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cienum mlx4_ib_mad_ifc_flags {
2288c2ecf20Sopenharmony_ci	MLX4_MAD_IFC_IGNORE_MKEY	= 1,
2298c2ecf20Sopenharmony_ci	MLX4_MAD_IFC_IGNORE_BKEY	= 2,
2308c2ecf20Sopenharmony_ci	MLX4_MAD_IFC_IGNORE_KEYS	= (MLX4_MAD_IFC_IGNORE_MKEY |
2318c2ecf20Sopenharmony_ci					   MLX4_MAD_IFC_IGNORE_BKEY),
2328c2ecf20Sopenharmony_ci	MLX4_MAD_IFC_NET_VIEW		= 4,
2338c2ecf20Sopenharmony_ci};
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cienum {
2368c2ecf20Sopenharmony_ci	MLX4_NUM_TUNNEL_BUFS		= 512,
2378c2ecf20Sopenharmony_ci	MLX4_NUM_WIRE_BUFS		= 2048,
2388c2ecf20Sopenharmony_ci};
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_cistruct mlx4_ib_tunnel_header {
2418c2ecf20Sopenharmony_ci	struct mlx4_av av;
2428c2ecf20Sopenharmony_ci	__be32 remote_qpn;
2438c2ecf20Sopenharmony_ci	__be32 qkey;
2448c2ecf20Sopenharmony_ci	__be16 vlan;
2458c2ecf20Sopenharmony_ci	u8 mac[6];
2468c2ecf20Sopenharmony_ci	__be16 pkey_index;
2478c2ecf20Sopenharmony_ci	u8 reserved[6];
2488c2ecf20Sopenharmony_ci};
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_cistruct mlx4_ib_buf {
2518c2ecf20Sopenharmony_ci	void *addr;
2528c2ecf20Sopenharmony_ci	dma_addr_t map;
2538c2ecf20Sopenharmony_ci};
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_cistruct mlx4_rcv_tunnel_hdr {
2568c2ecf20Sopenharmony_ci	__be32 flags_src_qp; /* flags[6:5] is defined for VLANs:
2578c2ecf20Sopenharmony_ci			      * 0x0 - no vlan was in the packet
2588c2ecf20Sopenharmony_ci			      * 0x01 - C-VLAN was in the packet */
2598c2ecf20Sopenharmony_ci	u8 g_ml_path; /* gid bit stands for ipv6/4 header in RoCE */
2608c2ecf20Sopenharmony_ci	u8 reserved;
2618c2ecf20Sopenharmony_ci	__be16 pkey_index;
2628c2ecf20Sopenharmony_ci	__be16 sl_vid;
2638c2ecf20Sopenharmony_ci	__be16 slid_mac_47_32;
2648c2ecf20Sopenharmony_ci	__be32 mac_31_0;
2658c2ecf20Sopenharmony_ci};
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_cistruct mlx4_ib_proxy_sqp_hdr {
2688c2ecf20Sopenharmony_ci	struct ib_grh grh;
2698c2ecf20Sopenharmony_ci	struct mlx4_rcv_tunnel_hdr tun;
2708c2ecf20Sopenharmony_ci}  __packed;
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistruct mlx4_roce_smac_vlan_info {
2738c2ecf20Sopenharmony_ci	u64 smac;
2748c2ecf20Sopenharmony_ci	int smac_index;
2758c2ecf20Sopenharmony_ci	int smac_port;
2768c2ecf20Sopenharmony_ci	u64 candidate_smac;
2778c2ecf20Sopenharmony_ci	int candidate_smac_index;
2788c2ecf20Sopenharmony_ci	int candidate_smac_port;
2798c2ecf20Sopenharmony_ci	u16 vid;
2808c2ecf20Sopenharmony_ci	int vlan_index;
2818c2ecf20Sopenharmony_ci	int vlan_port;
2828c2ecf20Sopenharmony_ci	u16 candidate_vid;
2838c2ecf20Sopenharmony_ci	int candidate_vlan_index;
2848c2ecf20Sopenharmony_ci	int candidate_vlan_port;
2858c2ecf20Sopenharmony_ci	int update_vid;
2868c2ecf20Sopenharmony_ci};
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_cistruct mlx4_wqn_range {
2898c2ecf20Sopenharmony_ci	int			base_wqn;
2908c2ecf20Sopenharmony_ci	int			size;
2918c2ecf20Sopenharmony_ci	int			refcount;
2928c2ecf20Sopenharmony_ci	bool			dirty;
2938c2ecf20Sopenharmony_ci	struct list_head	list;
2948c2ecf20Sopenharmony_ci};
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_cistruct mlx4_ib_rss {
2978c2ecf20Sopenharmony_ci	unsigned int		base_qpn_tbl_sz;
2988c2ecf20Sopenharmony_ci	u8			flags;
2998c2ecf20Sopenharmony_ci	u8			rss_key[MLX4_EN_RSS_KEY_SIZE];
3008c2ecf20Sopenharmony_ci};
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_cienum {
3038c2ecf20Sopenharmony_ci	/*
3048c2ecf20Sopenharmony_ci	 * Largest possible UD header: send with GRH and immediate
3058c2ecf20Sopenharmony_ci	 * data plus 18 bytes for an Ethernet header with VLAN/802.1Q
3068c2ecf20Sopenharmony_ci	 * tag.  (LRH would only use 8 bytes, so Ethernet is the
3078c2ecf20Sopenharmony_ci	 * biggest case)
3088c2ecf20Sopenharmony_ci	 */
3098c2ecf20Sopenharmony_ci	MLX4_IB_UD_HEADER_SIZE		= 82,
3108c2ecf20Sopenharmony_ci	MLX4_IB_LSO_HEADER_SPARE	= 128,
3118c2ecf20Sopenharmony_ci};
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_cistruct mlx4_ib_sqp {
3148c2ecf20Sopenharmony_ci	int pkey_index;
3158c2ecf20Sopenharmony_ci	u32 qkey;
3168c2ecf20Sopenharmony_ci	u32 send_psn;
3178c2ecf20Sopenharmony_ci	struct ib_ud_header ud_header;
3188c2ecf20Sopenharmony_ci	u8 header_buf[MLX4_IB_UD_HEADER_SIZE];
3198c2ecf20Sopenharmony_ci	struct ib_qp *roce_v2_gsi;
3208c2ecf20Sopenharmony_ci};
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_cistruct mlx4_ib_qp {
3238c2ecf20Sopenharmony_ci	union {
3248c2ecf20Sopenharmony_ci		struct ib_qp	ibqp;
3258c2ecf20Sopenharmony_ci		struct ib_wq	ibwq;
3268c2ecf20Sopenharmony_ci	};
3278c2ecf20Sopenharmony_ci	struct mlx4_qp		mqp;
3288c2ecf20Sopenharmony_ci	struct mlx4_buf		buf;
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci	struct mlx4_db		db;
3318c2ecf20Sopenharmony_ci	struct mlx4_ib_wq	rq;
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	u32			doorbell_qpn;
3348c2ecf20Sopenharmony_ci	__be32			sq_signal_bits;
3358c2ecf20Sopenharmony_ci	unsigned		sq_next_wqe;
3368c2ecf20Sopenharmony_ci	int			sq_spare_wqes;
3378c2ecf20Sopenharmony_ci	struct mlx4_ib_wq	sq;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci	enum mlx4_ib_qp_type	mlx4_ib_qp_type;
3408c2ecf20Sopenharmony_ci	struct ib_umem	       *umem;
3418c2ecf20Sopenharmony_ci	struct mlx4_mtt		mtt;
3428c2ecf20Sopenharmony_ci	int			buf_size;
3438c2ecf20Sopenharmony_ci	struct mutex		mutex;
3448c2ecf20Sopenharmony_ci	u16			xrcdn;
3458c2ecf20Sopenharmony_ci	u32			flags;
3468c2ecf20Sopenharmony_ci	u8			port;
3478c2ecf20Sopenharmony_ci	u8			alt_port;
3488c2ecf20Sopenharmony_ci	u8			atomic_rd_en;
3498c2ecf20Sopenharmony_ci	u8			resp_depth;
3508c2ecf20Sopenharmony_ci	u8			sq_no_prefetch;
3518c2ecf20Sopenharmony_ci	u8			state;
3528c2ecf20Sopenharmony_ci	int			mlx_type;
3538c2ecf20Sopenharmony_ci	u32			inl_recv_sz;
3548c2ecf20Sopenharmony_ci	struct list_head	gid_list;
3558c2ecf20Sopenharmony_ci	struct list_head	steering_rules;
3568c2ecf20Sopenharmony_ci	struct mlx4_ib_buf	*sqp_proxy_rcv;
3578c2ecf20Sopenharmony_ci	struct mlx4_roce_smac_vlan_info pri;
3588c2ecf20Sopenharmony_ci	struct mlx4_roce_smac_vlan_info alt;
3598c2ecf20Sopenharmony_ci	u64			reg_id;
3608c2ecf20Sopenharmony_ci	struct list_head	qps_list;
3618c2ecf20Sopenharmony_ci	struct list_head	cq_recv_list;
3628c2ecf20Sopenharmony_ci	struct list_head	cq_send_list;
3638c2ecf20Sopenharmony_ci	struct counter_index	*counter_index;
3648c2ecf20Sopenharmony_ci	struct mlx4_wqn_range	*wqn_range;
3658c2ecf20Sopenharmony_ci	/* Number of RSS QP parents that uses this WQ */
3668c2ecf20Sopenharmony_ci	u32			rss_usecnt;
3678c2ecf20Sopenharmony_ci	union {
3688c2ecf20Sopenharmony_ci		struct mlx4_ib_rss *rss_ctx;
3698c2ecf20Sopenharmony_ci		struct mlx4_ib_sqp *sqp;
3708c2ecf20Sopenharmony_ci	};
3718c2ecf20Sopenharmony_ci};
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_cistruct mlx4_ib_srq {
3748c2ecf20Sopenharmony_ci	struct ib_srq		ibsrq;
3758c2ecf20Sopenharmony_ci	struct mlx4_srq		msrq;
3768c2ecf20Sopenharmony_ci	struct mlx4_buf		buf;
3778c2ecf20Sopenharmony_ci	struct mlx4_db		db;
3788c2ecf20Sopenharmony_ci	u64		       *wrid;
3798c2ecf20Sopenharmony_ci	spinlock_t		lock;
3808c2ecf20Sopenharmony_ci	int			head;
3818c2ecf20Sopenharmony_ci	int			tail;
3828c2ecf20Sopenharmony_ci	u16			wqe_ctr;
3838c2ecf20Sopenharmony_ci	struct ib_umem	       *umem;
3848c2ecf20Sopenharmony_ci	struct mlx4_mtt		mtt;
3858c2ecf20Sopenharmony_ci	struct mutex		mutex;
3868c2ecf20Sopenharmony_ci};
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_cistruct mlx4_ib_ah {
3898c2ecf20Sopenharmony_ci	struct ib_ah		ibah;
3908c2ecf20Sopenharmony_ci	union mlx4_ext_av       av;
3918c2ecf20Sopenharmony_ci};
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_cistruct mlx4_ib_rwq_ind_table {
3948c2ecf20Sopenharmony_ci	struct ib_rwq_ind_table ib_rwq_ind_tbl;
3958c2ecf20Sopenharmony_ci};
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci/****************************************/
3988c2ecf20Sopenharmony_ci/* alias guid support */
3998c2ecf20Sopenharmony_ci/****************************************/
4008c2ecf20Sopenharmony_ci#define NUM_PORT_ALIAS_GUID		2
4018c2ecf20Sopenharmony_ci#define NUM_ALIAS_GUID_IN_REC		8
4028c2ecf20Sopenharmony_ci#define NUM_ALIAS_GUID_REC_IN_PORT	16
4038c2ecf20Sopenharmony_ci#define GUID_REC_SIZE			8
4048c2ecf20Sopenharmony_ci#define NUM_ALIAS_GUID_PER_PORT		128
4058c2ecf20Sopenharmony_ci#define MLX4_NOT_SET_GUID		(0x00LL)
4068c2ecf20Sopenharmony_ci#define MLX4_GUID_FOR_DELETE_VAL	(~(0x00LL))
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_cienum mlx4_guid_alias_rec_status {
4098c2ecf20Sopenharmony_ci	MLX4_GUID_INFO_STATUS_IDLE,
4108c2ecf20Sopenharmony_ci	MLX4_GUID_INFO_STATUS_SET,
4118c2ecf20Sopenharmony_ci};
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci#define GUID_STATE_NEED_PORT_INIT 0x01
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_cienum mlx4_guid_alias_rec_method {
4168c2ecf20Sopenharmony_ci	MLX4_GUID_INFO_RECORD_SET	= IB_MGMT_METHOD_SET,
4178c2ecf20Sopenharmony_ci	MLX4_GUID_INFO_RECORD_DELETE	= IB_SA_METHOD_DELETE,
4188c2ecf20Sopenharmony_ci};
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_cistruct mlx4_sriov_alias_guid_info_rec_det {
4218c2ecf20Sopenharmony_ci	u8 all_recs[GUID_REC_SIZE * NUM_ALIAS_GUID_IN_REC];
4228c2ecf20Sopenharmony_ci	ib_sa_comp_mask guid_indexes; /*indicates what from the 8 records are valid*/
4238c2ecf20Sopenharmony_ci	enum mlx4_guid_alias_rec_status status; /*indicates the administraively status of the record.*/
4248c2ecf20Sopenharmony_ci	unsigned int guids_retry_schedule[NUM_ALIAS_GUID_IN_REC];
4258c2ecf20Sopenharmony_ci	u64 time_to_run;
4268c2ecf20Sopenharmony_ci};
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_cistruct mlx4_sriov_alias_guid_port_rec_det {
4298c2ecf20Sopenharmony_ci	struct mlx4_sriov_alias_guid_info_rec_det all_rec_per_port[NUM_ALIAS_GUID_REC_IN_PORT];
4308c2ecf20Sopenharmony_ci	struct workqueue_struct *wq;
4318c2ecf20Sopenharmony_ci	struct delayed_work alias_guid_work;
4328c2ecf20Sopenharmony_ci	u8 port;
4338c2ecf20Sopenharmony_ci	u32 state_flags;
4348c2ecf20Sopenharmony_ci	struct mlx4_sriov_alias_guid *parent;
4358c2ecf20Sopenharmony_ci	struct list_head cb_list;
4368c2ecf20Sopenharmony_ci};
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistruct mlx4_sriov_alias_guid {
4398c2ecf20Sopenharmony_ci	struct mlx4_sriov_alias_guid_port_rec_det ports_guid[MLX4_MAX_PORTS];
4408c2ecf20Sopenharmony_ci	spinlock_t ag_work_lock;
4418c2ecf20Sopenharmony_ci	struct ib_sa_client *sa_client;
4428c2ecf20Sopenharmony_ci};
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_cistruct mlx4_ib_demux_work {
4458c2ecf20Sopenharmony_ci	struct work_struct	work;
4468c2ecf20Sopenharmony_ci	struct mlx4_ib_dev     *dev;
4478c2ecf20Sopenharmony_ci	int			slave;
4488c2ecf20Sopenharmony_ci	int			do_init;
4498c2ecf20Sopenharmony_ci	u8			port;
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci};
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_cistruct mlx4_ib_tun_tx_buf {
4548c2ecf20Sopenharmony_ci	struct mlx4_ib_buf buf;
4558c2ecf20Sopenharmony_ci	struct ib_ah *ah;
4568c2ecf20Sopenharmony_ci};
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_cistruct mlx4_ib_demux_pv_qp {
4598c2ecf20Sopenharmony_ci	struct ib_qp *qp;
4608c2ecf20Sopenharmony_ci	enum ib_qp_type proxy_qpt;
4618c2ecf20Sopenharmony_ci	struct mlx4_ib_buf *ring;
4628c2ecf20Sopenharmony_ci	struct mlx4_ib_tun_tx_buf *tx_ring;
4638c2ecf20Sopenharmony_ci	spinlock_t tx_lock;
4648c2ecf20Sopenharmony_ci	unsigned tx_ix_head;
4658c2ecf20Sopenharmony_ci	unsigned tx_ix_tail;
4668c2ecf20Sopenharmony_ci};
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_cienum mlx4_ib_demux_pv_state {
4698c2ecf20Sopenharmony_ci	DEMUX_PV_STATE_DOWN,
4708c2ecf20Sopenharmony_ci	DEMUX_PV_STATE_STARTING,
4718c2ecf20Sopenharmony_ci	DEMUX_PV_STATE_ACTIVE,
4728c2ecf20Sopenharmony_ci	DEMUX_PV_STATE_DOWNING,
4738c2ecf20Sopenharmony_ci};
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_cistruct mlx4_ib_demux_pv_ctx {
4768c2ecf20Sopenharmony_ci	int port;
4778c2ecf20Sopenharmony_ci	int slave;
4788c2ecf20Sopenharmony_ci	enum mlx4_ib_demux_pv_state state;
4798c2ecf20Sopenharmony_ci	int has_smi;
4808c2ecf20Sopenharmony_ci	struct ib_device *ib_dev;
4818c2ecf20Sopenharmony_ci	struct ib_cq *cq;
4828c2ecf20Sopenharmony_ci	struct ib_pd *pd;
4838c2ecf20Sopenharmony_ci	struct work_struct work;
4848c2ecf20Sopenharmony_ci	struct workqueue_struct *wq;
4858c2ecf20Sopenharmony_ci	struct workqueue_struct *wi_wq;
4868c2ecf20Sopenharmony_ci	struct mlx4_ib_demux_pv_qp qp[2];
4878c2ecf20Sopenharmony_ci};
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_cistruct mlx4_ib_demux_ctx {
4908c2ecf20Sopenharmony_ci	struct ib_device *ib_dev;
4918c2ecf20Sopenharmony_ci	int port;
4928c2ecf20Sopenharmony_ci	struct workqueue_struct *wq;
4938c2ecf20Sopenharmony_ci	struct workqueue_struct *wi_wq;
4948c2ecf20Sopenharmony_ci	struct workqueue_struct *ud_wq;
4958c2ecf20Sopenharmony_ci	spinlock_t ud_lock;
4968c2ecf20Sopenharmony_ci	atomic64_t subnet_prefix;
4978c2ecf20Sopenharmony_ci	__be64 guid_cache[128];
4988c2ecf20Sopenharmony_ci	struct mlx4_ib_dev *dev;
4998c2ecf20Sopenharmony_ci	/* the following lock protects both mcg_table and mcg_mgid0_list */
5008c2ecf20Sopenharmony_ci	struct mutex		mcg_table_lock;
5018c2ecf20Sopenharmony_ci	struct rb_root		mcg_table;
5028c2ecf20Sopenharmony_ci	struct list_head	mcg_mgid0_list;
5038c2ecf20Sopenharmony_ci	struct workqueue_struct	*mcg_wq;
5048c2ecf20Sopenharmony_ci	struct mlx4_ib_demux_pv_ctx **tun;
5058c2ecf20Sopenharmony_ci	atomic_t tid;
5068c2ecf20Sopenharmony_ci	int    flushing; /* flushing the work queue */
5078c2ecf20Sopenharmony_ci};
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_cistruct mlx4_ib_sriov {
5108c2ecf20Sopenharmony_ci	struct mlx4_ib_demux_ctx demux[MLX4_MAX_PORTS];
5118c2ecf20Sopenharmony_ci	struct mlx4_ib_demux_pv_ctx *sqps[MLX4_MAX_PORTS];
5128c2ecf20Sopenharmony_ci	/* when using this spinlock you should use "irq" because
5138c2ecf20Sopenharmony_ci	 * it may be called from interrupt context.*/
5148c2ecf20Sopenharmony_ci	spinlock_t going_down_lock;
5158c2ecf20Sopenharmony_ci	int is_going_down;
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci	struct mlx4_sriov_alias_guid alias_guid;
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	/* CM paravirtualization fields */
5208c2ecf20Sopenharmony_ci	struct xarray pv_id_table;
5218c2ecf20Sopenharmony_ci	u32 pv_id_next;
5228c2ecf20Sopenharmony_ci	spinlock_t id_map_lock;
5238c2ecf20Sopenharmony_ci	struct rb_root sl_id_map;
5248c2ecf20Sopenharmony_ci	struct list_head cm_list;
5258c2ecf20Sopenharmony_ci	struct xarray xa_rej_tmout;
5268c2ecf20Sopenharmony_ci};
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_cistruct gid_cache_context {
5298c2ecf20Sopenharmony_ci	int real_index;
5308c2ecf20Sopenharmony_ci	int refcount;
5318c2ecf20Sopenharmony_ci};
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_cistruct gid_entry {
5348c2ecf20Sopenharmony_ci	union ib_gid	gid;
5358c2ecf20Sopenharmony_ci	enum ib_gid_type gid_type;
5368c2ecf20Sopenharmony_ci	struct gid_cache_context *ctx;
5378c2ecf20Sopenharmony_ci	u16 vlan_id;
5388c2ecf20Sopenharmony_ci};
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_cistruct mlx4_port_gid_table {
5418c2ecf20Sopenharmony_ci	struct gid_entry gids[MLX4_MAX_PORT_GIDS];
5428c2ecf20Sopenharmony_ci};
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_cistruct mlx4_ib_iboe {
5458c2ecf20Sopenharmony_ci	spinlock_t		lock;
5468c2ecf20Sopenharmony_ci	struct net_device      *netdevs[MLX4_MAX_PORTS];
5478c2ecf20Sopenharmony_ci	atomic64_t		mac[MLX4_MAX_PORTS];
5488c2ecf20Sopenharmony_ci	struct notifier_block 	nb;
5498c2ecf20Sopenharmony_ci	struct mlx4_port_gid_table gids[MLX4_MAX_PORTS];
5508c2ecf20Sopenharmony_ci	enum ib_port_state	last_port_state[MLX4_MAX_PORTS];
5518c2ecf20Sopenharmony_ci};
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_cistruct pkey_mgt {
5548c2ecf20Sopenharmony_ci	u8			virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
5558c2ecf20Sopenharmony_ci	u16			phys_pkey_cache[MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
5568c2ecf20Sopenharmony_ci	struct list_head	pkey_port_list[MLX4_MFUNC_MAX];
5578c2ecf20Sopenharmony_ci	struct kobject	       *device_parent[MLX4_MFUNC_MAX];
5588c2ecf20Sopenharmony_ci};
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_cistruct mlx4_ib_iov_sysfs_attr {
5618c2ecf20Sopenharmony_ci	void *ctx;
5628c2ecf20Sopenharmony_ci	struct kobject *kobj;
5638c2ecf20Sopenharmony_ci	unsigned long data;
5648c2ecf20Sopenharmony_ci	u32 entry_num;
5658c2ecf20Sopenharmony_ci	char name[15];
5668c2ecf20Sopenharmony_ci	struct device_attribute dentry;
5678c2ecf20Sopenharmony_ci	struct device *dev;
5688c2ecf20Sopenharmony_ci};
5698c2ecf20Sopenharmony_ci
5708c2ecf20Sopenharmony_cistruct mlx4_ib_iov_sysfs_attr_ar {
5718c2ecf20Sopenharmony_ci	struct mlx4_ib_iov_sysfs_attr dentries[3 * NUM_ALIAS_GUID_PER_PORT + 1];
5728c2ecf20Sopenharmony_ci};
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_cistruct mlx4_ib_iov_port {
5758c2ecf20Sopenharmony_ci	char name[100];
5768c2ecf20Sopenharmony_ci	u8 num;
5778c2ecf20Sopenharmony_ci	struct mlx4_ib_dev *dev;
5788c2ecf20Sopenharmony_ci	struct list_head list;
5798c2ecf20Sopenharmony_ci	struct mlx4_ib_iov_sysfs_attr_ar *dentr_ar;
5808c2ecf20Sopenharmony_ci	struct ib_port_attr attr;
5818c2ecf20Sopenharmony_ci	struct kobject	*cur_port;
5828c2ecf20Sopenharmony_ci	struct kobject	*admin_alias_parent;
5838c2ecf20Sopenharmony_ci	struct kobject	*gids_parent;
5848c2ecf20Sopenharmony_ci	struct kobject	*pkeys_parent;
5858c2ecf20Sopenharmony_ci	struct kobject	*mcgs_parent;
5868c2ecf20Sopenharmony_ci	struct mlx4_ib_iov_sysfs_attr mcg_dentry;
5878c2ecf20Sopenharmony_ci};
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_cistruct counter_index {
5908c2ecf20Sopenharmony_ci	struct  list_head       list;
5918c2ecf20Sopenharmony_ci	u32		index;
5928c2ecf20Sopenharmony_ci	u8		allocated;
5938c2ecf20Sopenharmony_ci};
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_cistruct mlx4_ib_counters {
5968c2ecf20Sopenharmony_ci	struct list_head        counters_list;
5978c2ecf20Sopenharmony_ci	struct mutex            mutex; /* mutex for accessing counters list */
5988c2ecf20Sopenharmony_ci	u32			default_counter;
5998c2ecf20Sopenharmony_ci};
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci#define MLX4_DIAG_COUNTERS_TYPES 2
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_cistruct mlx4_ib_diag_counters {
6048c2ecf20Sopenharmony_ci	const char **name;
6058c2ecf20Sopenharmony_ci	u32 *offset;
6068c2ecf20Sopenharmony_ci	u32 num_counters;
6078c2ecf20Sopenharmony_ci};
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_cistruct mlx4_ib_dev {
6108c2ecf20Sopenharmony_ci	struct ib_device	ib_dev;
6118c2ecf20Sopenharmony_ci	struct mlx4_dev	       *dev;
6128c2ecf20Sopenharmony_ci	int			num_ports;
6138c2ecf20Sopenharmony_ci	void __iomem	       *uar_map;
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci	struct mlx4_uar		priv_uar;
6168c2ecf20Sopenharmony_ci	u32			priv_pdn;
6178c2ecf20Sopenharmony_ci	MLX4_DECLARE_DOORBELL_LOCK(uar_lock);
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci	struct ib_mad_agent    *send_agent[MLX4_MAX_PORTS][2];
6208c2ecf20Sopenharmony_ci	struct ib_ah	       *sm_ah[MLX4_MAX_PORTS];
6218c2ecf20Sopenharmony_ci	spinlock_t		sm_lock;
6228c2ecf20Sopenharmony_ci	atomic64_t		sl2vl[MLX4_MAX_PORTS];
6238c2ecf20Sopenharmony_ci	struct mlx4_ib_sriov	sriov;
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_ci	struct mutex		cap_mask_mutex;
6268c2ecf20Sopenharmony_ci	bool			ib_active;
6278c2ecf20Sopenharmony_ci	struct mlx4_ib_iboe	iboe;
6288c2ecf20Sopenharmony_ci	struct mlx4_ib_counters counters_table[MLX4_MAX_PORTS];
6298c2ecf20Sopenharmony_ci	int		       *eq_table;
6308c2ecf20Sopenharmony_ci	struct kobject	       *iov_parent;
6318c2ecf20Sopenharmony_ci	struct kobject	       *ports_parent;
6328c2ecf20Sopenharmony_ci	struct kobject	       *dev_ports_parent[MLX4_MFUNC_MAX];
6338c2ecf20Sopenharmony_ci	struct mlx4_ib_iov_port	iov_ports[MLX4_MAX_PORTS];
6348c2ecf20Sopenharmony_ci	struct pkey_mgt		pkeys;
6358c2ecf20Sopenharmony_ci	unsigned long *ib_uc_qpns_bitmap;
6368c2ecf20Sopenharmony_ci	int steer_qpn_count;
6378c2ecf20Sopenharmony_ci	int steer_qpn_base;
6388c2ecf20Sopenharmony_ci	int steering_support;
6398c2ecf20Sopenharmony_ci	struct mlx4_ib_qp      *qp1_proxy[MLX4_MAX_PORTS];
6408c2ecf20Sopenharmony_ci	/* lock when destroying qp1_proxy and getting netdev events */
6418c2ecf20Sopenharmony_ci	struct mutex		qp1_proxy_lock[MLX4_MAX_PORTS];
6428c2ecf20Sopenharmony_ci	u8			bond_next_port;
6438c2ecf20Sopenharmony_ci	/* protect resources needed as part of reset flow */
6448c2ecf20Sopenharmony_ci	spinlock_t		reset_flow_resource_lock;
6458c2ecf20Sopenharmony_ci	struct list_head		qp_list;
6468c2ecf20Sopenharmony_ci	struct mlx4_ib_diag_counters diag_counters[MLX4_DIAG_COUNTERS_TYPES];
6478c2ecf20Sopenharmony_ci};
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_cistruct ib_event_work {
6508c2ecf20Sopenharmony_ci	struct work_struct	work;
6518c2ecf20Sopenharmony_ci	struct mlx4_ib_dev	*ib_dev;
6528c2ecf20Sopenharmony_ci	struct mlx4_eqe		ib_eqe;
6538c2ecf20Sopenharmony_ci	int			port;
6548c2ecf20Sopenharmony_ci};
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_cistruct mlx4_ib_qp_tunnel_init_attr {
6578c2ecf20Sopenharmony_ci	struct ib_qp_init_attr init_attr;
6588c2ecf20Sopenharmony_ci	int slave;
6598c2ecf20Sopenharmony_ci	enum ib_qp_type proxy_qp_type;
6608c2ecf20Sopenharmony_ci	u8 port;
6618c2ecf20Sopenharmony_ci};
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_cistruct mlx4_uverbs_ex_query_device {
6648c2ecf20Sopenharmony_ci	__u32 comp_mask;
6658c2ecf20Sopenharmony_ci	__u32 reserved;
6668c2ecf20Sopenharmony_ci};
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_dev *to_mdev(struct ib_device *ibdev)
6698c2ecf20Sopenharmony_ci{
6708c2ecf20Sopenharmony_ci	return container_of(ibdev, struct mlx4_ib_dev, ib_dev);
6718c2ecf20Sopenharmony_ci}
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
6748c2ecf20Sopenharmony_ci{
6758c2ecf20Sopenharmony_ci	return container_of(ibucontext, struct mlx4_ib_ucontext, ibucontext);
6768c2ecf20Sopenharmony_ci}
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_pd *to_mpd(struct ib_pd *ibpd)
6798c2ecf20Sopenharmony_ci{
6808c2ecf20Sopenharmony_ci	return container_of(ibpd, struct mlx4_ib_pd, ibpd);
6818c2ecf20Sopenharmony_ci}
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_xrcd *to_mxrcd(struct ib_xrcd *ibxrcd)
6848c2ecf20Sopenharmony_ci{
6858c2ecf20Sopenharmony_ci	return container_of(ibxrcd, struct mlx4_ib_xrcd, ibxrcd);
6868c2ecf20Sopenharmony_ci}
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_cq *to_mcq(struct ib_cq *ibcq)
6898c2ecf20Sopenharmony_ci{
6908c2ecf20Sopenharmony_ci	return container_of(ibcq, struct mlx4_ib_cq, ibcq);
6918c2ecf20Sopenharmony_ci}
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_cq *to_mibcq(struct mlx4_cq *mcq)
6948c2ecf20Sopenharmony_ci{
6958c2ecf20Sopenharmony_ci	return container_of(mcq, struct mlx4_ib_cq, mcq);
6968c2ecf20Sopenharmony_ci}
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_mr *to_mmr(struct ib_mr *ibmr)
6998c2ecf20Sopenharmony_ci{
7008c2ecf20Sopenharmony_ci	return container_of(ibmr, struct mlx4_ib_mr, ibmr);
7018c2ecf20Sopenharmony_ci}
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_mw *to_mmw(struct ib_mw *ibmw)
7048c2ecf20Sopenharmony_ci{
7058c2ecf20Sopenharmony_ci	return container_of(ibmw, struct mlx4_ib_mw, ibmw);
7068c2ecf20Sopenharmony_ci}
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_flow *to_mflow(struct ib_flow *ibflow)
7098c2ecf20Sopenharmony_ci{
7108c2ecf20Sopenharmony_ci	return container_of(ibflow, struct mlx4_ib_flow, ibflow);
7118c2ecf20Sopenharmony_ci}
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_qp *to_mqp(struct ib_qp *ibqp)
7148c2ecf20Sopenharmony_ci{
7158c2ecf20Sopenharmony_ci	return container_of(ibqp, struct mlx4_ib_qp, ibqp);
7168c2ecf20Sopenharmony_ci}
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_qp *to_mibqp(struct mlx4_qp *mqp)
7198c2ecf20Sopenharmony_ci{
7208c2ecf20Sopenharmony_ci	return container_of(mqp, struct mlx4_ib_qp, mqp);
7218c2ecf20Sopenharmony_ci}
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_srq *to_msrq(struct ib_srq *ibsrq)
7248c2ecf20Sopenharmony_ci{
7258c2ecf20Sopenharmony_ci	return container_of(ibsrq, struct mlx4_ib_srq, ibsrq);
7268c2ecf20Sopenharmony_ci}
7278c2ecf20Sopenharmony_ci
7288c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_srq *to_mibsrq(struct mlx4_srq *msrq)
7298c2ecf20Sopenharmony_ci{
7308c2ecf20Sopenharmony_ci	return container_of(msrq, struct mlx4_ib_srq, msrq);
7318c2ecf20Sopenharmony_ci}
7328c2ecf20Sopenharmony_ci
7338c2ecf20Sopenharmony_cistatic inline struct mlx4_ib_ah *to_mah(struct ib_ah *ibah)
7348c2ecf20Sopenharmony_ci{
7358c2ecf20Sopenharmony_ci	return container_of(ibah, struct mlx4_ib_ah, ibah);
7368c2ecf20Sopenharmony_ci}
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_cistatic inline u8 mlx4_ib_bond_next_port(struct mlx4_ib_dev *dev)
7398c2ecf20Sopenharmony_ci{
7408c2ecf20Sopenharmony_ci	dev->bond_next_port = (dev->bond_next_port + 1) % dev->num_ports;
7418c2ecf20Sopenharmony_ci
7428c2ecf20Sopenharmony_ci	return dev->bond_next_port + 1;
7438c2ecf20Sopenharmony_ci}
7448c2ecf20Sopenharmony_ci
7458c2ecf20Sopenharmony_ciint mlx4_ib_init_sriov(struct mlx4_ib_dev *dev);
7468c2ecf20Sopenharmony_civoid mlx4_ib_close_sriov(struct mlx4_ib_dev *dev);
7478c2ecf20Sopenharmony_ci
7488c2ecf20Sopenharmony_ciint mlx4_ib_db_map_user(struct ib_udata *udata, unsigned long virt,
7498c2ecf20Sopenharmony_ci			struct mlx4_db *db);
7508c2ecf20Sopenharmony_civoid mlx4_ib_db_unmap_user(struct mlx4_ib_ucontext *context, struct mlx4_db *db);
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_cistruct ib_mr *mlx4_ib_get_dma_mr(struct ib_pd *pd, int acc);
7538c2ecf20Sopenharmony_ciint mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt,
7548c2ecf20Sopenharmony_ci			   struct ib_umem *umem);
7558c2ecf20Sopenharmony_cistruct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
7568c2ecf20Sopenharmony_ci				  u64 virt_addr, int access_flags,
7578c2ecf20Sopenharmony_ci				  struct ib_udata *udata);
7588c2ecf20Sopenharmony_ciint mlx4_ib_dereg_mr(struct ib_mr *mr, struct ib_udata *udata);
7598c2ecf20Sopenharmony_ciint mlx4_ib_alloc_mw(struct ib_mw *mw, struct ib_udata *udata);
7608c2ecf20Sopenharmony_ciint mlx4_ib_dealloc_mw(struct ib_mw *mw);
7618c2ecf20Sopenharmony_cistruct ib_mr *mlx4_ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
7628c2ecf20Sopenharmony_ci			       u32 max_num_sg);
7638c2ecf20Sopenharmony_ciint mlx4_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
7648c2ecf20Sopenharmony_ci		      unsigned int *sg_offset);
7658c2ecf20Sopenharmony_ciint mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
7668c2ecf20Sopenharmony_ciint mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
7678c2ecf20Sopenharmony_ciint mlx4_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
7688c2ecf20Sopenharmony_ci		      struct ib_udata *udata);
7698c2ecf20Sopenharmony_ciint mlx4_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
7708c2ecf20Sopenharmony_ciint mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
7718c2ecf20Sopenharmony_ciint mlx4_ib_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
7728c2ecf20Sopenharmony_civoid __mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq);
7738c2ecf20Sopenharmony_civoid mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq);
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ciint mlx4_ib_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr,
7768c2ecf20Sopenharmony_ci		      struct ib_udata *udata);
7778c2ecf20Sopenharmony_ciint mlx4_ib_create_ah_slave(struct ib_ah *ah, struct rdma_ah_attr *ah_attr,
7788c2ecf20Sopenharmony_ci			    int slave_sgid_index, u8 *s_mac, u16 vlan_tag);
7798c2ecf20Sopenharmony_ciint mlx4_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);
7808c2ecf20Sopenharmony_cistatic inline int mlx4_ib_destroy_ah(struct ib_ah *ah, u32 flags)
7818c2ecf20Sopenharmony_ci{
7828c2ecf20Sopenharmony_ci	return 0;
7838c2ecf20Sopenharmony_ci}
7848c2ecf20Sopenharmony_ci
7858c2ecf20Sopenharmony_ciint mlx4_ib_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *init_attr,
7868c2ecf20Sopenharmony_ci		       struct ib_udata *udata);
7878c2ecf20Sopenharmony_ciint mlx4_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
7888c2ecf20Sopenharmony_ci		       enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
7898c2ecf20Sopenharmony_ciint mlx4_ib_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
7908c2ecf20Sopenharmony_ciint mlx4_ib_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
7918c2ecf20Sopenharmony_civoid mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index);
7928c2ecf20Sopenharmony_ciint mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
7938c2ecf20Sopenharmony_ci			  const struct ib_recv_wr **bad_wr);
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_cistruct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
7968c2ecf20Sopenharmony_ci				struct ib_qp_init_attr *init_attr,
7978c2ecf20Sopenharmony_ci				struct ib_udata *udata);
7988c2ecf20Sopenharmony_ciint mlx4_ib_destroy_qp(struct ib_qp *qp, struct ib_udata *udata);
7998c2ecf20Sopenharmony_civoid mlx4_ib_drain_sq(struct ib_qp *qp);
8008c2ecf20Sopenharmony_civoid mlx4_ib_drain_rq(struct ib_qp *qp);
8018c2ecf20Sopenharmony_ciint mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
8028c2ecf20Sopenharmony_ci		      int attr_mask, struct ib_udata *udata);
8038c2ecf20Sopenharmony_ciint mlx4_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
8048c2ecf20Sopenharmony_ci		     struct ib_qp_init_attr *qp_init_attr);
8058c2ecf20Sopenharmony_ciint mlx4_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
8068c2ecf20Sopenharmony_ci		      const struct ib_send_wr **bad_wr);
8078c2ecf20Sopenharmony_ciint mlx4_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
8088c2ecf20Sopenharmony_ci		      const struct ib_recv_wr **bad_wr);
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ciint mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
8118c2ecf20Sopenharmony_ci		 int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
8128c2ecf20Sopenharmony_ci		 const void *in_mad, void *response_mad);
8138c2ecf20Sopenharmony_ciint mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
8148c2ecf20Sopenharmony_ci			const struct ib_wc *in_wc, const struct ib_grh *in_grh,
8158c2ecf20Sopenharmony_ci			const struct ib_mad *in, struct ib_mad *out,
8168c2ecf20Sopenharmony_ci			size_t *out_mad_size, u16 *out_mad_pkey_index);
8178c2ecf20Sopenharmony_ciint mlx4_ib_mad_init(struct mlx4_ib_dev *dev);
8188c2ecf20Sopenharmony_civoid mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev);
8198c2ecf20Sopenharmony_ci
8208c2ecf20Sopenharmony_ciint __mlx4_ib_query_port(struct ib_device *ibdev, u8 port,
8218c2ecf20Sopenharmony_ci			 struct ib_port_attr *props, int netw_view);
8228c2ecf20Sopenharmony_ciint __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
8238c2ecf20Sopenharmony_ci			 u16 *pkey, int netw_view);
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ciint __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
8268c2ecf20Sopenharmony_ci			union ib_gid *gid, int netw_view);
8278c2ecf20Sopenharmony_ci
8288c2ecf20Sopenharmony_cistatic inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
8298c2ecf20Sopenharmony_ci{
8308c2ecf20Sopenharmony_ci	u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
8318c2ecf20Sopenharmony_ci
8328c2ecf20Sopenharmony_ci	if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
8338c2ecf20Sopenharmony_ci		return true;
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_ci	return !!(ah->av.ib.g_slid & 0x80);
8368c2ecf20Sopenharmony_ci}
8378c2ecf20Sopenharmony_ci
8388c2ecf20Sopenharmony_ciint mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx);
8398c2ecf20Sopenharmony_civoid mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy_wq);
8408c2ecf20Sopenharmony_civoid clean_vf_mcast(struct mlx4_ib_demux_ctx *ctx, int slave);
8418c2ecf20Sopenharmony_ciint mlx4_ib_mcg_init(void);
8428c2ecf20Sopenharmony_civoid mlx4_ib_mcg_destroy(void);
8438c2ecf20Sopenharmony_ci
8448c2ecf20Sopenharmony_ciint mlx4_ib_find_real_gid(struct ib_device *ibdev, u8 port, __be64 guid);
8458c2ecf20Sopenharmony_ci
8468c2ecf20Sopenharmony_ciint mlx4_ib_mcg_multiplex_handler(struct ib_device *ibdev, int port, int slave,
8478c2ecf20Sopenharmony_ci				  struct ib_sa_mad *sa_mad);
8488c2ecf20Sopenharmony_ciint mlx4_ib_mcg_demux_handler(struct ib_device *ibdev, int port, int slave,
8498c2ecf20Sopenharmony_ci			      struct ib_sa_mad *mad);
8508c2ecf20Sopenharmony_ci
8518c2ecf20Sopenharmony_ciint mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
8528c2ecf20Sopenharmony_ci		   union ib_gid *gid);
8538c2ecf20Sopenharmony_ci
8548c2ecf20Sopenharmony_civoid mlx4_ib_dispatch_event(struct mlx4_ib_dev *dev, u8 port_num,
8558c2ecf20Sopenharmony_ci			    enum ib_event_type type);
8568c2ecf20Sopenharmony_ci
8578c2ecf20Sopenharmony_civoid mlx4_ib_tunnels_update_work(struct work_struct *work);
8588c2ecf20Sopenharmony_ci
8598c2ecf20Sopenharmony_ciint mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
8608c2ecf20Sopenharmony_ci			  enum ib_qp_type qpt, struct ib_wc *wc,
8618c2ecf20Sopenharmony_ci			  struct ib_grh *grh, struct ib_mad *mad);
8628c2ecf20Sopenharmony_ci
8638c2ecf20Sopenharmony_ciint mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
8648c2ecf20Sopenharmony_ci			 enum ib_qp_type dest_qpt, u16 pkey_index, u32 remote_qpn,
8658c2ecf20Sopenharmony_ci			 u32 qkey, struct rdma_ah_attr *attr, u8 *s_mac,
8668c2ecf20Sopenharmony_ci			 u16 vlan_id, struct ib_mad *mad);
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_ci__be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx);
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_ciint mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave,
8718c2ecf20Sopenharmony_ci		struct ib_mad *mad);
8728c2ecf20Sopenharmony_ci
8738c2ecf20Sopenharmony_ciint mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id,
8748c2ecf20Sopenharmony_ci		struct ib_mad *mad);
8758c2ecf20Sopenharmony_ci
8768c2ecf20Sopenharmony_civoid mlx4_ib_cm_paravirt_init(struct mlx4_ib_dev *dev);
8778c2ecf20Sopenharmony_civoid mlx4_ib_cm_paravirt_clean(struct mlx4_ib_dev *dev, int slave_id);
8788c2ecf20Sopenharmony_ci
8798c2ecf20Sopenharmony_ci/* alias guid support */
8808c2ecf20Sopenharmony_civoid mlx4_ib_init_alias_guid_work(struct mlx4_ib_dev *dev, int port);
8818c2ecf20Sopenharmony_ciint mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev);
8828c2ecf20Sopenharmony_civoid mlx4_ib_destroy_alias_guid_service(struct mlx4_ib_dev *dev);
8838c2ecf20Sopenharmony_civoid mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port);
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_civoid mlx4_ib_notify_slaves_on_guid_change(struct mlx4_ib_dev *dev,
8868c2ecf20Sopenharmony_ci					  int block_num,
8878c2ecf20Sopenharmony_ci					  u8 port_num, u8 *p_data);
8888c2ecf20Sopenharmony_ci
8898c2ecf20Sopenharmony_civoid mlx4_ib_update_cache_on_guid_change(struct mlx4_ib_dev *dev,
8908c2ecf20Sopenharmony_ci					 int block_num, u8 port_num,
8918c2ecf20Sopenharmony_ci					 u8 *p_data);
8928c2ecf20Sopenharmony_ci
8938c2ecf20Sopenharmony_ciint add_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num,
8948c2ecf20Sopenharmony_ci			    struct attribute *attr);
8958c2ecf20Sopenharmony_civoid del_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num,
8968c2ecf20Sopenharmony_ci			     struct attribute *attr);
8978c2ecf20Sopenharmony_ciib_sa_comp_mask mlx4_ib_get_aguid_comp_mask_from_ix(int index);
8988c2ecf20Sopenharmony_civoid mlx4_ib_slave_alias_guid_event(struct mlx4_ib_dev *dev, int slave,
8998c2ecf20Sopenharmony_ci				    int port, int slave_init);
9008c2ecf20Sopenharmony_ci
9018c2ecf20Sopenharmony_ciint mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *device) ;
9028c2ecf20Sopenharmony_ci
9038c2ecf20Sopenharmony_civoid mlx4_ib_device_unregister_sysfs(struct mlx4_ib_dev *device);
9048c2ecf20Sopenharmony_ci
9058c2ecf20Sopenharmony_ci__be64 mlx4_ib_gen_node_guid(void);
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_ciint mlx4_ib_steer_qp_alloc(struct mlx4_ib_dev *dev, int count, int *qpn);
9088c2ecf20Sopenharmony_civoid mlx4_ib_steer_qp_free(struct mlx4_ib_dev *dev, u32 qpn, int count);
9098c2ecf20Sopenharmony_ciint mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
9108c2ecf20Sopenharmony_ci			 int is_attach);
9118c2ecf20Sopenharmony_ciint mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
9128c2ecf20Sopenharmony_ci			  u64 start, u64 length, u64 virt_addr,
9138c2ecf20Sopenharmony_ci			  int mr_access_flags, struct ib_pd *pd,
9148c2ecf20Sopenharmony_ci			  struct ib_udata *udata);
9158c2ecf20Sopenharmony_ciint mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
9168c2ecf20Sopenharmony_ci				    const struct ib_gid_attr *attr);
9178c2ecf20Sopenharmony_ci
9188c2ecf20Sopenharmony_civoid mlx4_sched_ib_sl2vl_update_work(struct mlx4_ib_dev *ibdev,
9198c2ecf20Sopenharmony_ci				     int port);
9208c2ecf20Sopenharmony_ci
9218c2ecf20Sopenharmony_civoid mlx4_ib_sl2vl_update(struct mlx4_ib_dev *mdev, int port);
9228c2ecf20Sopenharmony_ci
9238c2ecf20Sopenharmony_cistruct ib_wq *mlx4_ib_create_wq(struct ib_pd *pd,
9248c2ecf20Sopenharmony_ci				struct ib_wq_init_attr *init_attr,
9258c2ecf20Sopenharmony_ci				struct ib_udata *udata);
9268c2ecf20Sopenharmony_ciint mlx4_ib_destroy_wq(struct ib_wq *wq, struct ib_udata *udata);
9278c2ecf20Sopenharmony_ciint mlx4_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
9288c2ecf20Sopenharmony_ci		      u32 wq_attr_mask, struct ib_udata *udata);
9298c2ecf20Sopenharmony_ci
9308c2ecf20Sopenharmony_ciint mlx4_ib_create_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl,
9318c2ecf20Sopenharmony_ci				 struct ib_rwq_ind_table_init_attr *init_attr,
9328c2ecf20Sopenharmony_ci				 struct ib_udata *udata);
9338c2ecf20Sopenharmony_cistatic inline int
9348c2ecf20Sopenharmony_cimlx4_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table)
9358c2ecf20Sopenharmony_ci{
9368c2ecf20Sopenharmony_ci	return 0;
9378c2ecf20Sopenharmony_ci}
9388c2ecf20Sopenharmony_ciint mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem, u64 start_va,
9398c2ecf20Sopenharmony_ci				       int *num_of_mtts);
9408c2ecf20Sopenharmony_ci
9418c2ecf20Sopenharmony_ci#endif /* MLX4_IB_H */
942