18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
38c2ecf20Sopenharmony_ci * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
48c2ecf20Sopenharmony_ci * Copyright (c) 2005, 2006, 2007 Cisco Systems.  All rights reserved.
58c2ecf20Sopenharmony_ci * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
68c2ecf20Sopenharmony_ci * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
98c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
108c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
118c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
128c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
158c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
168c2ecf20Sopenharmony_ci *     conditions are met:
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
198c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
208c2ecf20Sopenharmony_ci *        disclaimer.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
238c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
248c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
258c2ecf20Sopenharmony_ci *        provided with the distribution.
268c2ecf20Sopenharmony_ci *
278c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
288c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
298c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
308c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
318c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
328c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
338c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
348c2ecf20Sopenharmony_ci * SOFTWARE.
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#ifndef MLX4_H
388c2ecf20Sopenharmony_ci#define MLX4_H
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#include <linux/mutex.h>
418c2ecf20Sopenharmony_ci#include <linux/radix-tree.h>
428c2ecf20Sopenharmony_ci#include <linux/rbtree.h>
438c2ecf20Sopenharmony_ci#include <linux/timer.h>
448c2ecf20Sopenharmony_ci#include <linux/semaphore.h>
458c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
468c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
478c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
488c2ecf20Sopenharmony_ci#include <net/devlink.h>
498c2ecf20Sopenharmony_ci#include <linux/rwsem.h>
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#include <linux/mlx4/device.h>
528c2ecf20Sopenharmony_ci#include <linux/mlx4/driver.h>
538c2ecf20Sopenharmony_ci#include <linux/mlx4/doorbell.h>
548c2ecf20Sopenharmony_ci#include <linux/mlx4/cmd.h>
558c2ecf20Sopenharmony_ci#include "fw_qos.h"
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define DRV_NAME	"mlx4_core"
588c2ecf20Sopenharmony_ci#define DRV_VERSION	"4.0-0"
598c2ecf20Sopenharmony_ci#define DRV_NAME_FOR_FW		"Linux," DRV_NAME "," DRV_VERSION
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define MLX4_FS_UDP_UC_EN		(1 << 1)
628c2ecf20Sopenharmony_ci#define MLX4_FS_TCP_UC_EN		(1 << 2)
638c2ecf20Sopenharmony_ci#define MLX4_FS_NUM_OF_L2_ADDR		8
648c2ecf20Sopenharmony_ci#define MLX4_FS_MGM_LOG_ENTRY_SIZE	7
658c2ecf20Sopenharmony_ci#define MLX4_FS_NUM_MCG			(1 << 17)
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define INIT_HCA_TPT_MW_ENABLE          (1 << 7)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define MLX4_QUERY_IF_STAT_RESET	BIT(31)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cienum {
728c2ecf20Sopenharmony_ci	MLX4_HCR_BASE		= 0x80680,
738c2ecf20Sopenharmony_ci	MLX4_HCR_SIZE		= 0x0001c,
748c2ecf20Sopenharmony_ci	MLX4_CLR_INT_SIZE	= 0x00008,
758c2ecf20Sopenharmony_ci	MLX4_SLAVE_COMM_BASE	= 0x0,
768c2ecf20Sopenharmony_ci	MLX4_COMM_PAGESIZE	= 0x1000,
778c2ecf20Sopenharmony_ci	MLX4_CLOCK_SIZE		= 0x00008,
788c2ecf20Sopenharmony_ci	MLX4_COMM_CHAN_CAPS	= 0x8,
798c2ecf20Sopenharmony_ci	MLX4_COMM_CHAN_FLAGS	= 0xc
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cienum {
838c2ecf20Sopenharmony_ci	MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE = 10,
848c2ecf20Sopenharmony_ci	MLX4_MIN_MGM_LOG_ENTRY_SIZE = 7,
858c2ecf20Sopenharmony_ci	MLX4_MAX_MGM_LOG_ENTRY_SIZE = 12,
868c2ecf20Sopenharmony_ci	MLX4_MAX_QP_PER_MGM = 4 * ((1 << MLX4_MAX_MGM_LOG_ENTRY_SIZE) / 16 - 2),
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cienum {
908c2ecf20Sopenharmony_ci	MLX4_NUM_PDS		= 1 << 15
918c2ecf20Sopenharmony_ci};
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cienum {
948c2ecf20Sopenharmony_ci	MLX4_CMPT_TYPE_QP	= 0,
958c2ecf20Sopenharmony_ci	MLX4_CMPT_TYPE_SRQ	= 1,
968c2ecf20Sopenharmony_ci	MLX4_CMPT_TYPE_CQ	= 2,
978c2ecf20Sopenharmony_ci	MLX4_CMPT_TYPE_EQ	= 3,
988c2ecf20Sopenharmony_ci	MLX4_CMPT_NUM_TYPE
998c2ecf20Sopenharmony_ci};
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cienum {
1028c2ecf20Sopenharmony_ci	MLX4_CMPT_SHIFT		= 24,
1038c2ecf20Sopenharmony_ci	MLX4_NUM_CMPTS		= MLX4_CMPT_NUM_TYPE << MLX4_CMPT_SHIFT
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cienum mlx4_mpt_state {
1078c2ecf20Sopenharmony_ci	MLX4_MPT_DISABLED = 0,
1088c2ecf20Sopenharmony_ci	MLX4_MPT_EN_HW,
1098c2ecf20Sopenharmony_ci	MLX4_MPT_EN_SW
1108c2ecf20Sopenharmony_ci};
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#define MLX4_COMM_TIME		10000
1138c2ecf20Sopenharmony_ci#define MLX4_COMM_OFFLINE_TIME_OUT 30000
1148c2ecf20Sopenharmony_ci#define MLX4_COMM_CMD_NA_OP    0x0
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_cienum {
1188c2ecf20Sopenharmony_ci	MLX4_COMM_CMD_RESET,
1198c2ecf20Sopenharmony_ci	MLX4_COMM_CMD_VHCR0,
1208c2ecf20Sopenharmony_ci	MLX4_COMM_CMD_VHCR1,
1218c2ecf20Sopenharmony_ci	MLX4_COMM_CMD_VHCR2,
1228c2ecf20Sopenharmony_ci	MLX4_COMM_CMD_VHCR_EN,
1238c2ecf20Sopenharmony_ci	MLX4_COMM_CMD_VHCR_POST,
1248c2ecf20Sopenharmony_ci	MLX4_COMM_CMD_FLR = 254
1258c2ecf20Sopenharmony_ci};
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_cienum {
1288c2ecf20Sopenharmony_ci	MLX4_VF_SMI_DISABLED,
1298c2ecf20Sopenharmony_ci	MLX4_VF_SMI_ENABLED
1308c2ecf20Sopenharmony_ci};
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/*The flag indicates that the slave should delay the RESET cmd*/
1338c2ecf20Sopenharmony_ci#define MLX4_DELAY_RESET_SLAVE 0xbbbbbbb
1348c2ecf20Sopenharmony_ci/*indicates how many retries will be done if we are in the middle of FLR*/
1358c2ecf20Sopenharmony_ci#define NUM_OF_RESET_RETRIES	10
1368c2ecf20Sopenharmony_ci#define SLEEP_TIME_IN_RESET	(2 * 1000)
1378c2ecf20Sopenharmony_cienum mlx4_resource {
1388c2ecf20Sopenharmony_ci	RES_QP,
1398c2ecf20Sopenharmony_ci	RES_CQ,
1408c2ecf20Sopenharmony_ci	RES_SRQ,
1418c2ecf20Sopenharmony_ci	RES_XRCD,
1428c2ecf20Sopenharmony_ci	RES_MPT,
1438c2ecf20Sopenharmony_ci	RES_MTT,
1448c2ecf20Sopenharmony_ci	RES_MAC,
1458c2ecf20Sopenharmony_ci	RES_VLAN,
1468c2ecf20Sopenharmony_ci	RES_NPORT_ID,
1478c2ecf20Sopenharmony_ci	RES_COUNTER,
1488c2ecf20Sopenharmony_ci	RES_FS_RULE,
1498c2ecf20Sopenharmony_ci	RES_EQ,
1508c2ecf20Sopenharmony_ci	MLX4_NUM_OF_RESOURCE_TYPE
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cienum mlx4_alloc_mode {
1548c2ecf20Sopenharmony_ci	RES_OP_RESERVE,
1558c2ecf20Sopenharmony_ci	RES_OP_RESERVE_AND_MAP,
1568c2ecf20Sopenharmony_ci	RES_OP_MAP_ICM,
1578c2ecf20Sopenharmony_ci};
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_cienum mlx4_res_tracker_free_type {
1608c2ecf20Sopenharmony_ci	RES_TR_FREE_ALL,
1618c2ecf20Sopenharmony_ci	RES_TR_FREE_SLAVES_ONLY,
1628c2ecf20Sopenharmony_ci	RES_TR_FREE_STRUCTS_ONLY,
1638c2ecf20Sopenharmony_ci};
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci/*
1668c2ecf20Sopenharmony_ci *Virtual HCR structures.
1678c2ecf20Sopenharmony_ci * mlx4_vhcr is the sw representation, in machine endianness
1688c2ecf20Sopenharmony_ci *
1698c2ecf20Sopenharmony_ci * mlx4_vhcr_cmd is the formalized structure, the one that is passed
1708c2ecf20Sopenharmony_ci * to FW to go through communication channel.
1718c2ecf20Sopenharmony_ci * It is big endian, and has the same structure as the physical HCR
1728c2ecf20Sopenharmony_ci * used by command interface
1738c2ecf20Sopenharmony_ci */
1748c2ecf20Sopenharmony_cistruct mlx4_vhcr {
1758c2ecf20Sopenharmony_ci	u64	in_param;
1768c2ecf20Sopenharmony_ci	u64	out_param;
1778c2ecf20Sopenharmony_ci	u32	in_modifier;
1788c2ecf20Sopenharmony_ci	u32	errno;
1798c2ecf20Sopenharmony_ci	u16	op;
1808c2ecf20Sopenharmony_ci	u16	token;
1818c2ecf20Sopenharmony_ci	u8	op_modifier;
1828c2ecf20Sopenharmony_ci	u8	e_bit;
1838c2ecf20Sopenharmony_ci};
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_cistruct mlx4_vhcr_cmd {
1868c2ecf20Sopenharmony_ci	__be64 in_param;
1878c2ecf20Sopenharmony_ci	__be32 in_modifier;
1888c2ecf20Sopenharmony_ci	u32 reserved1;
1898c2ecf20Sopenharmony_ci	__be64 out_param;
1908c2ecf20Sopenharmony_ci	__be16 token;
1918c2ecf20Sopenharmony_ci	u16 reserved;
1928c2ecf20Sopenharmony_ci	u8 status;
1938c2ecf20Sopenharmony_ci	u8 flags;
1948c2ecf20Sopenharmony_ci	__be16 opcode;
1958c2ecf20Sopenharmony_ci};
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_cistruct mlx4_cmd_info {
1988c2ecf20Sopenharmony_ci	u16 opcode;
1998c2ecf20Sopenharmony_ci	bool has_inbox;
2008c2ecf20Sopenharmony_ci	bool has_outbox;
2018c2ecf20Sopenharmony_ci	bool out_is_imm;
2028c2ecf20Sopenharmony_ci	bool encode_slave_id;
2038c2ecf20Sopenharmony_ci	int (*verify)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
2048c2ecf20Sopenharmony_ci		      struct mlx4_cmd_mailbox *inbox);
2058c2ecf20Sopenharmony_ci	int (*wrapper)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
2068c2ecf20Sopenharmony_ci		       struct mlx4_cmd_mailbox *inbox,
2078c2ecf20Sopenharmony_ci		       struct mlx4_cmd_mailbox *outbox,
2088c2ecf20Sopenharmony_ci		       struct mlx4_cmd_info *cmd);
2098c2ecf20Sopenharmony_ci};
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci#ifdef CONFIG_MLX4_DEBUG
2128c2ecf20Sopenharmony_ciextern int mlx4_debug_level;
2138c2ecf20Sopenharmony_ci#else /* CONFIG_MLX4_DEBUG */
2148c2ecf20Sopenharmony_ci#define mlx4_debug_level	(0)
2158c2ecf20Sopenharmony_ci#endif /* CONFIG_MLX4_DEBUG */
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci#define mlx4_dbg(mdev, format, ...)					\
2188c2ecf20Sopenharmony_cido {									\
2198c2ecf20Sopenharmony_ci	if (mlx4_debug_level)						\
2208c2ecf20Sopenharmony_ci		dev_printk(KERN_DEBUG,					\
2218c2ecf20Sopenharmony_ci			   &(mdev)->persist->pdev->dev, format,		\
2228c2ecf20Sopenharmony_ci			   ##__VA_ARGS__);				\
2238c2ecf20Sopenharmony_ci} while (0)
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci#define mlx4_err(mdev, format, ...)					\
2268c2ecf20Sopenharmony_ci	dev_err(&(mdev)->persist->pdev->dev, format, ##__VA_ARGS__)
2278c2ecf20Sopenharmony_ci#define mlx4_info(mdev, format, ...)					\
2288c2ecf20Sopenharmony_ci	dev_info(&(mdev)->persist->pdev->dev, format, ##__VA_ARGS__)
2298c2ecf20Sopenharmony_ci#define mlx4_warn(mdev, format, ...)					\
2308c2ecf20Sopenharmony_ci	dev_warn(&(mdev)->persist->pdev->dev, format, ##__VA_ARGS__)
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ciextern int log_mtts_per_seg;
2338c2ecf20Sopenharmony_ciextern int mlx4_internal_err_reset;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci#define MLX4_MAX_NUM_SLAVES	(min(MLX4_MAX_NUM_PF + MLX4_MAX_NUM_VF, \
2368c2ecf20Sopenharmony_ci				     MLX4_MFUNC_MAX))
2378c2ecf20Sopenharmony_ci#define ALL_SLAVES 0xff
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_cistruct mlx4_bitmap {
2408c2ecf20Sopenharmony_ci	u32			last;
2418c2ecf20Sopenharmony_ci	u32			top;
2428c2ecf20Sopenharmony_ci	u32			max;
2438c2ecf20Sopenharmony_ci	u32                     reserved_top;
2448c2ecf20Sopenharmony_ci	u32			mask;
2458c2ecf20Sopenharmony_ci	u32			avail;
2468c2ecf20Sopenharmony_ci	u32			effective_len;
2478c2ecf20Sopenharmony_ci	spinlock_t		lock;
2488c2ecf20Sopenharmony_ci	unsigned long	       *table;
2498c2ecf20Sopenharmony_ci};
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistruct mlx4_buddy {
2528c2ecf20Sopenharmony_ci	unsigned long	      **bits;
2538c2ecf20Sopenharmony_ci	unsigned int	       *num_free;
2548c2ecf20Sopenharmony_ci	u32			max_order;
2558c2ecf20Sopenharmony_ci	spinlock_t		lock;
2568c2ecf20Sopenharmony_ci};
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistruct mlx4_icm;
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_cistruct mlx4_icm_table {
2618c2ecf20Sopenharmony_ci	u64			virt;
2628c2ecf20Sopenharmony_ci	int			num_icm;
2638c2ecf20Sopenharmony_ci	u32			num_obj;
2648c2ecf20Sopenharmony_ci	int			obj_size;
2658c2ecf20Sopenharmony_ci	int			lowmem;
2668c2ecf20Sopenharmony_ci	int			coherent;
2678c2ecf20Sopenharmony_ci	struct mutex		mutex;
2688c2ecf20Sopenharmony_ci	struct mlx4_icm	      **icm;
2698c2ecf20Sopenharmony_ci};
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#define MLX4_MPT_FLAG_SW_OWNS	    (0xfUL << 28)
2728c2ecf20Sopenharmony_ci#define MLX4_MPT_FLAG_FREE	    (0x3UL << 28)
2738c2ecf20Sopenharmony_ci#define MLX4_MPT_FLAG_MIO	    (1 << 17)
2748c2ecf20Sopenharmony_ci#define MLX4_MPT_FLAG_BIND_ENABLE   (1 << 15)
2758c2ecf20Sopenharmony_ci#define MLX4_MPT_FLAG_PHYSICAL	    (1 <<  9)
2768c2ecf20Sopenharmony_ci#define MLX4_MPT_FLAG_REGION	    (1 <<  8)
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci#define MLX4_MPT_PD_MASK	    (0x1FFFFUL)
2798c2ecf20Sopenharmony_ci#define MLX4_MPT_PD_VF_MASK	    (0xFE0000UL)
2808c2ecf20Sopenharmony_ci#define MLX4_MPT_PD_FLAG_FAST_REG   (1 << 27)
2818c2ecf20Sopenharmony_ci#define MLX4_MPT_PD_FLAG_RAE	    (1 << 28)
2828c2ecf20Sopenharmony_ci#define MLX4_MPT_PD_FLAG_EN_INV	    (3 << 24)
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci#define MLX4_MPT_QP_FLAG_BOUND_QP   (1 << 7)
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci#define MLX4_MPT_STATUS_SW		0xF0
2878c2ecf20Sopenharmony_ci#define MLX4_MPT_STATUS_HW		0x00
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci#define MLX4_CQE_SIZE_MASK_STRIDE	0x3
2908c2ecf20Sopenharmony_ci#define MLX4_EQE_SIZE_MASK_STRIDE	0x30
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci#define MLX4_EQ_ASYNC			0
2938c2ecf20Sopenharmony_ci#define MLX4_EQ_TO_CQ_VECTOR(vector)	((vector) - \
2948c2ecf20Sopenharmony_ci					 !!((int)(vector) >= MLX4_EQ_ASYNC))
2958c2ecf20Sopenharmony_ci#define MLX4_CQ_TO_EQ_VECTOR(vector)	((vector) + \
2968c2ecf20Sopenharmony_ci					 !!((int)(vector) >= MLX4_EQ_ASYNC))
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci/*
2998c2ecf20Sopenharmony_ci * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
3008c2ecf20Sopenharmony_ci */
3018c2ecf20Sopenharmony_cistruct mlx4_mpt_entry {
3028c2ecf20Sopenharmony_ci	__be32 flags;
3038c2ecf20Sopenharmony_ci	__be32 qpn;
3048c2ecf20Sopenharmony_ci	__be32 key;
3058c2ecf20Sopenharmony_ci	__be32 pd_flags;
3068c2ecf20Sopenharmony_ci	__be64 start;
3078c2ecf20Sopenharmony_ci	__be64 length;
3088c2ecf20Sopenharmony_ci	__be32 lkey;
3098c2ecf20Sopenharmony_ci	__be32 win_cnt;
3108c2ecf20Sopenharmony_ci	u8	reserved1[3];
3118c2ecf20Sopenharmony_ci	u8	mtt_rep;
3128c2ecf20Sopenharmony_ci	__be64 mtt_addr;
3138c2ecf20Sopenharmony_ci	__be32 mtt_sz;
3148c2ecf20Sopenharmony_ci	__be32 entity_size;
3158c2ecf20Sopenharmony_ci	__be32 first_byte_offset;
3168c2ecf20Sopenharmony_ci} __packed;
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci/*
3198c2ecf20Sopenharmony_ci * Must be packed because start is 64 bits but only aligned to 32 bits.
3208c2ecf20Sopenharmony_ci */
3218c2ecf20Sopenharmony_cistruct mlx4_eq_context {
3228c2ecf20Sopenharmony_ci	__be32			flags;
3238c2ecf20Sopenharmony_ci	u16			reserved1[3];
3248c2ecf20Sopenharmony_ci	__be16			page_offset;
3258c2ecf20Sopenharmony_ci	u8			log_eq_size;
3268c2ecf20Sopenharmony_ci	u8			reserved2[4];
3278c2ecf20Sopenharmony_ci	u8			eq_period;
3288c2ecf20Sopenharmony_ci	u8			reserved3;
3298c2ecf20Sopenharmony_ci	u8			eq_max_count;
3308c2ecf20Sopenharmony_ci	u8			reserved4[3];
3318c2ecf20Sopenharmony_ci	u8			intr;
3328c2ecf20Sopenharmony_ci	u8			log_page_size;
3338c2ecf20Sopenharmony_ci	u8			reserved5[2];
3348c2ecf20Sopenharmony_ci	u8			mtt_base_addr_h;
3358c2ecf20Sopenharmony_ci	__be32			mtt_base_addr_l;
3368c2ecf20Sopenharmony_ci	u32			reserved6[2];
3378c2ecf20Sopenharmony_ci	__be32			consumer_index;
3388c2ecf20Sopenharmony_ci	__be32			producer_index;
3398c2ecf20Sopenharmony_ci	u32			reserved7[4];
3408c2ecf20Sopenharmony_ci};
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_cistruct mlx4_cq_context {
3438c2ecf20Sopenharmony_ci	__be32			flags;
3448c2ecf20Sopenharmony_ci	u16			reserved1[3];
3458c2ecf20Sopenharmony_ci	__be16			page_offset;
3468c2ecf20Sopenharmony_ci	__be32			logsize_usrpage;
3478c2ecf20Sopenharmony_ci	__be16			cq_period;
3488c2ecf20Sopenharmony_ci	__be16			cq_max_count;
3498c2ecf20Sopenharmony_ci	u8			reserved2[3];
3508c2ecf20Sopenharmony_ci	u8			comp_eqn;
3518c2ecf20Sopenharmony_ci	u8			log_page_size;
3528c2ecf20Sopenharmony_ci	u8			reserved3[2];
3538c2ecf20Sopenharmony_ci	u8			mtt_base_addr_h;
3548c2ecf20Sopenharmony_ci	__be32			mtt_base_addr_l;
3558c2ecf20Sopenharmony_ci	__be32			last_notified_index;
3568c2ecf20Sopenharmony_ci	__be32			solicit_producer_index;
3578c2ecf20Sopenharmony_ci	__be32			consumer_index;
3588c2ecf20Sopenharmony_ci	__be32			producer_index;
3598c2ecf20Sopenharmony_ci	u32			reserved4[2];
3608c2ecf20Sopenharmony_ci	__be64			db_rec_addr;
3618c2ecf20Sopenharmony_ci};
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_cistruct mlx4_srq_context {
3648c2ecf20Sopenharmony_ci	__be32			state_logsize_srqn;
3658c2ecf20Sopenharmony_ci	u8			logstride;
3668c2ecf20Sopenharmony_ci	u8			reserved1;
3678c2ecf20Sopenharmony_ci	__be16			xrcd;
3688c2ecf20Sopenharmony_ci	__be32			pg_offset_cqn;
3698c2ecf20Sopenharmony_ci	u32			reserved2;
3708c2ecf20Sopenharmony_ci	u8			log_page_size;
3718c2ecf20Sopenharmony_ci	u8			reserved3[2];
3728c2ecf20Sopenharmony_ci	u8			mtt_base_addr_h;
3738c2ecf20Sopenharmony_ci	__be32			mtt_base_addr_l;
3748c2ecf20Sopenharmony_ci	__be32			pd;
3758c2ecf20Sopenharmony_ci	__be16			limit_watermark;
3768c2ecf20Sopenharmony_ci	__be16			wqe_cnt;
3778c2ecf20Sopenharmony_ci	u16			reserved4;
3788c2ecf20Sopenharmony_ci	__be16			wqe_counter;
3798c2ecf20Sopenharmony_ci	u32			reserved5;
3808c2ecf20Sopenharmony_ci	__be64			db_rec_addr;
3818c2ecf20Sopenharmony_ci};
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_cistruct mlx4_eq_tasklet {
3848c2ecf20Sopenharmony_ci	struct list_head list;
3858c2ecf20Sopenharmony_ci	struct list_head process_list;
3868c2ecf20Sopenharmony_ci	struct tasklet_struct task;
3878c2ecf20Sopenharmony_ci	/* lock on completion tasklet list */
3888c2ecf20Sopenharmony_ci	spinlock_t lock;
3898c2ecf20Sopenharmony_ci};
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_cistruct mlx4_eq {
3928c2ecf20Sopenharmony_ci	struct mlx4_dev	       *dev;
3938c2ecf20Sopenharmony_ci	void __iomem	       *doorbell;
3948c2ecf20Sopenharmony_ci	int			eqn;
3958c2ecf20Sopenharmony_ci	u32			cons_index;
3968c2ecf20Sopenharmony_ci	u16			irq;
3978c2ecf20Sopenharmony_ci	u16			have_irq;
3988c2ecf20Sopenharmony_ci	int			nent;
3998c2ecf20Sopenharmony_ci	struct mlx4_buf_list   *page_list;
4008c2ecf20Sopenharmony_ci	struct mlx4_mtt		mtt;
4018c2ecf20Sopenharmony_ci	struct mlx4_eq_tasklet	tasklet_ctx;
4028c2ecf20Sopenharmony_ci	struct mlx4_active_ports actv_ports;
4038c2ecf20Sopenharmony_ci	u32			ref_count;
4048c2ecf20Sopenharmony_ci	cpumask_var_t		affinity_mask;
4058c2ecf20Sopenharmony_ci};
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_cistruct mlx4_slave_eqe {
4088c2ecf20Sopenharmony_ci	u8 type;
4098c2ecf20Sopenharmony_ci	u8 port;
4108c2ecf20Sopenharmony_ci	u32 param;
4118c2ecf20Sopenharmony_ci};
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_cistruct mlx4_slave_event_eq_info {
4148c2ecf20Sopenharmony_ci	int eqn;
4158c2ecf20Sopenharmony_ci	u16 token;
4168c2ecf20Sopenharmony_ci};
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_cistruct mlx4_profile {
4198c2ecf20Sopenharmony_ci	int			num_qp;
4208c2ecf20Sopenharmony_ci	int			rdmarc_per_qp;
4218c2ecf20Sopenharmony_ci	int			num_srq;
4228c2ecf20Sopenharmony_ci	int			num_cq;
4238c2ecf20Sopenharmony_ci	int			num_mcg;
4248c2ecf20Sopenharmony_ci	int			num_mpt;
4258c2ecf20Sopenharmony_ci	unsigned		num_mtt;
4268c2ecf20Sopenharmony_ci};
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_cistruct mlx4_fw {
4298c2ecf20Sopenharmony_ci	u64			clr_int_base;
4308c2ecf20Sopenharmony_ci	u64			catas_offset;
4318c2ecf20Sopenharmony_ci	u64			comm_base;
4328c2ecf20Sopenharmony_ci	u64			clock_offset;
4338c2ecf20Sopenharmony_ci	struct mlx4_icm	       *fw_icm;
4348c2ecf20Sopenharmony_ci	struct mlx4_icm	       *aux_icm;
4358c2ecf20Sopenharmony_ci	u32			catas_size;
4368c2ecf20Sopenharmony_ci	u16			fw_pages;
4378c2ecf20Sopenharmony_ci	u8			clr_int_bar;
4388c2ecf20Sopenharmony_ci	u8			catas_bar;
4398c2ecf20Sopenharmony_ci	u8			comm_bar;
4408c2ecf20Sopenharmony_ci	u8			clock_bar;
4418c2ecf20Sopenharmony_ci};
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistruct mlx4_comm {
4448c2ecf20Sopenharmony_ci	u32			slave_write;
4458c2ecf20Sopenharmony_ci	u32			slave_read;
4468c2ecf20Sopenharmony_ci};
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cienum {
4498c2ecf20Sopenharmony_ci	MLX4_MCAST_CONFIG       = 0,
4508c2ecf20Sopenharmony_ci	MLX4_MCAST_DISABLE      = 1,
4518c2ecf20Sopenharmony_ci	MLX4_MCAST_ENABLE       = 2,
4528c2ecf20Sopenharmony_ci};
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci#define VLAN_FLTR_SIZE	128
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_cistruct mlx4_vlan_fltr {
4578c2ecf20Sopenharmony_ci	__be32 entry[VLAN_FLTR_SIZE];
4588c2ecf20Sopenharmony_ci};
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_cistruct mlx4_mcast_entry {
4618c2ecf20Sopenharmony_ci	struct list_head list;
4628c2ecf20Sopenharmony_ci	u64 addr;
4638c2ecf20Sopenharmony_ci};
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_cistruct mlx4_promisc_qp {
4668c2ecf20Sopenharmony_ci	struct list_head list;
4678c2ecf20Sopenharmony_ci	u32 qpn;
4688c2ecf20Sopenharmony_ci};
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_cistruct mlx4_steer_index {
4718c2ecf20Sopenharmony_ci	struct list_head list;
4728c2ecf20Sopenharmony_ci	unsigned int index;
4738c2ecf20Sopenharmony_ci	struct list_head duplicates;
4748c2ecf20Sopenharmony_ci};
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci#define MLX4_EVENT_TYPES_NUM 64
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_cistruct mlx4_slave_state {
4798c2ecf20Sopenharmony_ci	u8 comm_toggle;
4808c2ecf20Sopenharmony_ci	u8 last_cmd;
4818c2ecf20Sopenharmony_ci	u8 init_port_mask;
4828c2ecf20Sopenharmony_ci	bool active;
4838c2ecf20Sopenharmony_ci	bool old_vlan_api;
4848c2ecf20Sopenharmony_ci	bool vst_qinq_supported;
4858c2ecf20Sopenharmony_ci	u8 function;
4868c2ecf20Sopenharmony_ci	dma_addr_t vhcr_dma;
4878c2ecf20Sopenharmony_ci	u16 user_mtu[MLX4_MAX_PORTS + 1];
4888c2ecf20Sopenharmony_ci	u16 mtu[MLX4_MAX_PORTS + 1];
4898c2ecf20Sopenharmony_ci	__be32 ib_cap_mask[MLX4_MAX_PORTS + 1];
4908c2ecf20Sopenharmony_ci	struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES];
4918c2ecf20Sopenharmony_ci	struct list_head mcast_filters[MLX4_MAX_PORTS + 1];
4928c2ecf20Sopenharmony_ci	struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1];
4938c2ecf20Sopenharmony_ci	/* event type to eq number lookup */
4948c2ecf20Sopenharmony_ci	struct mlx4_slave_event_eq_info event_eq[MLX4_EVENT_TYPES_NUM];
4958c2ecf20Sopenharmony_ci	u16 eq_pi;
4968c2ecf20Sopenharmony_ci	u16 eq_ci;
4978c2ecf20Sopenharmony_ci	spinlock_t lock;
4988c2ecf20Sopenharmony_ci	/*initialized via the kzalloc*/
4998c2ecf20Sopenharmony_ci	u8 is_slave_going_down;
5008c2ecf20Sopenharmony_ci	u32 cookie;
5018c2ecf20Sopenharmony_ci	enum slave_port_state port_state[MLX4_MAX_PORTS + 1];
5028c2ecf20Sopenharmony_ci};
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci#define MLX4_VGT 4095
5058c2ecf20Sopenharmony_ci#define NO_INDX  (-1)
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_cistruct mlx4_vport_state {
5088c2ecf20Sopenharmony_ci	u64 mac;
5098c2ecf20Sopenharmony_ci	u16 default_vlan;
5108c2ecf20Sopenharmony_ci	u8  default_qos;
5118c2ecf20Sopenharmony_ci	__be16 vlan_proto;
5128c2ecf20Sopenharmony_ci	u32 tx_rate;
5138c2ecf20Sopenharmony_ci	bool spoofchk;
5148c2ecf20Sopenharmony_ci	u32 link_state;
5158c2ecf20Sopenharmony_ci	u8 qos_vport;
5168c2ecf20Sopenharmony_ci	__be64 guid;
5178c2ecf20Sopenharmony_ci};
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_cistruct mlx4_vf_admin_state {
5208c2ecf20Sopenharmony_ci	struct mlx4_vport_state vport[MLX4_MAX_PORTS + 1];
5218c2ecf20Sopenharmony_ci	u8 enable_smi[MLX4_MAX_PORTS + 1];
5228c2ecf20Sopenharmony_ci};
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_cistruct mlx4_vport_oper_state {
5258c2ecf20Sopenharmony_ci	struct mlx4_vport_state state;
5268c2ecf20Sopenharmony_ci	int mac_idx;
5278c2ecf20Sopenharmony_ci	int vlan_idx;
5288c2ecf20Sopenharmony_ci};
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_cistruct mlx4_vf_oper_state {
5318c2ecf20Sopenharmony_ci	struct mlx4_vport_oper_state vport[MLX4_MAX_PORTS + 1];
5328c2ecf20Sopenharmony_ci	u8 smi_enabled[MLX4_MAX_PORTS + 1];
5338c2ecf20Sopenharmony_ci};
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_cistruct slave_list {
5368c2ecf20Sopenharmony_ci	struct mutex mutex;
5378c2ecf20Sopenharmony_ci	struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE];
5388c2ecf20Sopenharmony_ci};
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_cistruct resource_allocator {
5418c2ecf20Sopenharmony_ci	spinlock_t alloc_lock; /* protect quotas */
5428c2ecf20Sopenharmony_ci	union {
5438c2ecf20Sopenharmony_ci		unsigned int res_reserved;
5448c2ecf20Sopenharmony_ci		unsigned int res_port_rsvd[MLX4_MAX_PORTS];
5458c2ecf20Sopenharmony_ci	};
5468c2ecf20Sopenharmony_ci	union {
5478c2ecf20Sopenharmony_ci		int res_free;
5488c2ecf20Sopenharmony_ci		int res_port_free[MLX4_MAX_PORTS];
5498c2ecf20Sopenharmony_ci	};
5508c2ecf20Sopenharmony_ci	int *quota;
5518c2ecf20Sopenharmony_ci	int *allocated;
5528c2ecf20Sopenharmony_ci	int *guaranteed;
5538c2ecf20Sopenharmony_ci};
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_cistruct mlx4_resource_tracker {
5568c2ecf20Sopenharmony_ci	spinlock_t lock;
5578c2ecf20Sopenharmony_ci	/* tree for each resources */
5588c2ecf20Sopenharmony_ci	struct rb_root res_tree[MLX4_NUM_OF_RESOURCE_TYPE];
5598c2ecf20Sopenharmony_ci	/* num_of_slave's lists, one per slave */
5608c2ecf20Sopenharmony_ci	struct slave_list *slave_list;
5618c2ecf20Sopenharmony_ci	struct resource_allocator res_alloc[MLX4_NUM_OF_RESOURCE_TYPE];
5628c2ecf20Sopenharmony_ci};
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ci#define SLAVE_EVENT_EQ_SIZE	128
5658c2ecf20Sopenharmony_cistruct mlx4_slave_event_eq {
5668c2ecf20Sopenharmony_ci	u32 eqn;
5678c2ecf20Sopenharmony_ci	u32 cons;
5688c2ecf20Sopenharmony_ci	u32 prod;
5698c2ecf20Sopenharmony_ci	spinlock_t event_lock;
5708c2ecf20Sopenharmony_ci	struct mlx4_eqe event_eqe[SLAVE_EVENT_EQ_SIZE];
5718c2ecf20Sopenharmony_ci};
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_cistruct mlx4_qos_manager {
5748c2ecf20Sopenharmony_ci	int num_of_qos_vfs;
5758c2ecf20Sopenharmony_ci	DECLARE_BITMAP(priority_bm, MLX4_NUM_UP);
5768c2ecf20Sopenharmony_ci};
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_cistruct mlx4_master_qp0_state {
5798c2ecf20Sopenharmony_ci	int proxy_qp0_active;
5808c2ecf20Sopenharmony_ci	int qp0_active;
5818c2ecf20Sopenharmony_ci	int port_active;
5828c2ecf20Sopenharmony_ci};
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_cistruct mlx4_mfunc_master_ctx {
5858c2ecf20Sopenharmony_ci	struct mlx4_slave_state *slave_state;
5868c2ecf20Sopenharmony_ci	struct mlx4_vf_admin_state *vf_admin;
5878c2ecf20Sopenharmony_ci	struct mlx4_vf_oper_state *vf_oper;
5888c2ecf20Sopenharmony_ci	struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1];
5898c2ecf20Sopenharmony_ci	int			init_port_ref[MLX4_MAX_PORTS + 1];
5908c2ecf20Sopenharmony_ci	u16			max_mtu[MLX4_MAX_PORTS + 1];
5918c2ecf20Sopenharmony_ci	u16			max_user_mtu[MLX4_MAX_PORTS + 1];
5928c2ecf20Sopenharmony_ci	u8			pptx;
5938c2ecf20Sopenharmony_ci	u8			pprx;
5948c2ecf20Sopenharmony_ci	int			disable_mcast_ref[MLX4_MAX_PORTS + 1];
5958c2ecf20Sopenharmony_ci	struct mlx4_resource_tracker res_tracker;
5968c2ecf20Sopenharmony_ci	struct workqueue_struct *comm_wq;
5978c2ecf20Sopenharmony_ci	struct work_struct	comm_work;
5988c2ecf20Sopenharmony_ci	struct work_struct	slave_event_work;
5998c2ecf20Sopenharmony_ci	struct work_struct	slave_flr_event_work;
6008c2ecf20Sopenharmony_ci	spinlock_t		slave_state_lock;
6018c2ecf20Sopenharmony_ci	__be32			comm_arm_bit_vector[4];
6028c2ecf20Sopenharmony_ci	struct mlx4_eqe		cmd_eqe;
6038c2ecf20Sopenharmony_ci	struct mlx4_slave_event_eq slave_eq;
6048c2ecf20Sopenharmony_ci	struct mutex		gen_eqe_mutex[MLX4_MFUNC_MAX];
6058c2ecf20Sopenharmony_ci	struct mlx4_qos_manager qos_ctl[MLX4_MAX_PORTS + 1];
6068c2ecf20Sopenharmony_ci};
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_cistruct mlx4_mfunc {
6098c2ecf20Sopenharmony_ci	struct mlx4_comm __iomem       *comm;
6108c2ecf20Sopenharmony_ci	struct mlx4_vhcr_cmd	       *vhcr;
6118c2ecf20Sopenharmony_ci	dma_addr_t			vhcr_dma;
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci	struct mlx4_mfunc_master_ctx	master;
6148c2ecf20Sopenharmony_ci};
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci#define MGM_QPN_MASK       0x00FFFFFF
6178c2ecf20Sopenharmony_ci#define MGM_BLCK_LB_BIT    30
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_cistruct mlx4_mgm {
6208c2ecf20Sopenharmony_ci	__be32			next_gid_index;
6218c2ecf20Sopenharmony_ci	__be32			members_count;
6228c2ecf20Sopenharmony_ci	u32			reserved[2];
6238c2ecf20Sopenharmony_ci	u8			gid[16];
6248c2ecf20Sopenharmony_ci	__be32			qp[MLX4_MAX_QP_PER_MGM];
6258c2ecf20Sopenharmony_ci};
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_cistruct mlx4_cmd {
6288c2ecf20Sopenharmony_ci	struct dma_pool	       *pool;
6298c2ecf20Sopenharmony_ci	void __iomem	       *hcr;
6308c2ecf20Sopenharmony_ci	struct mutex		slave_cmd_mutex;
6318c2ecf20Sopenharmony_ci	struct semaphore	poll_sem;
6328c2ecf20Sopenharmony_ci	struct semaphore	event_sem;
6338c2ecf20Sopenharmony_ci	struct rw_semaphore	switch_sem;
6348c2ecf20Sopenharmony_ci	int			max_cmds;
6358c2ecf20Sopenharmony_ci	spinlock_t		context_lock;
6368c2ecf20Sopenharmony_ci	int			free_head;
6378c2ecf20Sopenharmony_ci	struct mlx4_cmd_context *context;
6388c2ecf20Sopenharmony_ci	u16			token_mask;
6398c2ecf20Sopenharmony_ci	u8			use_events;
6408c2ecf20Sopenharmony_ci	u8			toggle;
6418c2ecf20Sopenharmony_ci	u8			comm_toggle;
6428c2ecf20Sopenharmony_ci	u8			initialized;
6438c2ecf20Sopenharmony_ci};
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_cienum {
6468c2ecf20Sopenharmony_ci	MLX4_VF_IMMED_VLAN_FLAG_VLAN = 1 << 0,
6478c2ecf20Sopenharmony_ci	MLX4_VF_IMMED_VLAN_FLAG_QOS = 1 << 1,
6488c2ecf20Sopenharmony_ci	MLX4_VF_IMMED_VLAN_FLAG_LINK_DISABLE = 1 << 2,
6498c2ecf20Sopenharmony_ci};
6508c2ecf20Sopenharmony_cistruct mlx4_vf_immed_vlan_work {
6518c2ecf20Sopenharmony_ci	struct work_struct	work;
6528c2ecf20Sopenharmony_ci	struct mlx4_priv	*priv;
6538c2ecf20Sopenharmony_ci	int			flags;
6548c2ecf20Sopenharmony_ci	int			slave;
6558c2ecf20Sopenharmony_ci	int			vlan_ix;
6568c2ecf20Sopenharmony_ci	int			orig_vlan_ix;
6578c2ecf20Sopenharmony_ci	u8			port;
6588c2ecf20Sopenharmony_ci	u8			qos;
6598c2ecf20Sopenharmony_ci	u8                      qos_vport;
6608c2ecf20Sopenharmony_ci	u16			vlan_id;
6618c2ecf20Sopenharmony_ci	u16			orig_vlan_id;
6628c2ecf20Sopenharmony_ci	__be16			vlan_proto;
6638c2ecf20Sopenharmony_ci};
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_cistruct mlx4_uar_table {
6678c2ecf20Sopenharmony_ci	struct mlx4_bitmap	bitmap;
6688c2ecf20Sopenharmony_ci};
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_cistruct mlx4_mr_table {
6718c2ecf20Sopenharmony_ci	struct mlx4_bitmap	mpt_bitmap;
6728c2ecf20Sopenharmony_ci	struct mlx4_buddy	mtt_buddy;
6738c2ecf20Sopenharmony_ci	u64			mtt_base;
6748c2ecf20Sopenharmony_ci	u64			mpt_base;
6758c2ecf20Sopenharmony_ci	struct mlx4_icm_table	mtt_table;
6768c2ecf20Sopenharmony_ci	struct mlx4_icm_table	dmpt_table;
6778c2ecf20Sopenharmony_ci};
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_cistruct mlx4_cq_table {
6808c2ecf20Sopenharmony_ci	struct mlx4_bitmap	bitmap;
6818c2ecf20Sopenharmony_ci	spinlock_t		lock;
6828c2ecf20Sopenharmony_ci	struct radix_tree_root	tree;
6838c2ecf20Sopenharmony_ci	struct mlx4_icm_table	table;
6848c2ecf20Sopenharmony_ci	struct mlx4_icm_table	cmpt_table;
6858c2ecf20Sopenharmony_ci};
6868c2ecf20Sopenharmony_ci
6878c2ecf20Sopenharmony_cistruct mlx4_eq_table {
6888c2ecf20Sopenharmony_ci	struct mlx4_bitmap	bitmap;
6898c2ecf20Sopenharmony_ci	char		       *irq_names;
6908c2ecf20Sopenharmony_ci	void __iomem	       *clr_int;
6918c2ecf20Sopenharmony_ci	void __iomem	      **uar_map;
6928c2ecf20Sopenharmony_ci	u32			clr_mask;
6938c2ecf20Sopenharmony_ci	struct mlx4_eq	       *eq;
6948c2ecf20Sopenharmony_ci	struct mlx4_icm_table	table;
6958c2ecf20Sopenharmony_ci	struct mlx4_icm_table	cmpt_table;
6968c2ecf20Sopenharmony_ci	int			have_irq;
6978c2ecf20Sopenharmony_ci	u8			inta_pin;
6988c2ecf20Sopenharmony_ci};
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_cistruct mlx4_srq_table {
7018c2ecf20Sopenharmony_ci	struct mlx4_bitmap	bitmap;
7028c2ecf20Sopenharmony_ci	spinlock_t		lock;
7038c2ecf20Sopenharmony_ci	struct radix_tree_root	tree;
7048c2ecf20Sopenharmony_ci	struct mlx4_icm_table	table;
7058c2ecf20Sopenharmony_ci	struct mlx4_icm_table	cmpt_table;
7068c2ecf20Sopenharmony_ci};
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_cienum mlx4_qp_table_zones {
7098c2ecf20Sopenharmony_ci	MLX4_QP_TABLE_ZONE_GENERAL,
7108c2ecf20Sopenharmony_ci	MLX4_QP_TABLE_ZONE_RSS,
7118c2ecf20Sopenharmony_ci	MLX4_QP_TABLE_ZONE_RAW_ETH,
7128c2ecf20Sopenharmony_ci	MLX4_QP_TABLE_ZONE_NUM
7138c2ecf20Sopenharmony_ci};
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_cistruct mlx4_qp_table {
7168c2ecf20Sopenharmony_ci	struct mlx4_bitmap	*bitmap_gen;
7178c2ecf20Sopenharmony_ci	struct mlx4_zone_allocator *zones;
7188c2ecf20Sopenharmony_ci	u32			zones_uids[MLX4_QP_TABLE_ZONE_NUM];
7198c2ecf20Sopenharmony_ci	u32			rdmarc_base;
7208c2ecf20Sopenharmony_ci	int			rdmarc_shift;
7218c2ecf20Sopenharmony_ci	spinlock_t		lock;
7228c2ecf20Sopenharmony_ci	struct mlx4_icm_table	qp_table;
7238c2ecf20Sopenharmony_ci	struct mlx4_icm_table	auxc_table;
7248c2ecf20Sopenharmony_ci	struct mlx4_icm_table	altc_table;
7258c2ecf20Sopenharmony_ci	struct mlx4_icm_table	rdmarc_table;
7268c2ecf20Sopenharmony_ci	struct mlx4_icm_table	cmpt_table;
7278c2ecf20Sopenharmony_ci};
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_cistruct mlx4_mcg_table {
7308c2ecf20Sopenharmony_ci	struct mutex		mutex;
7318c2ecf20Sopenharmony_ci	struct mlx4_bitmap	bitmap;
7328c2ecf20Sopenharmony_ci	struct mlx4_icm_table	table;
7338c2ecf20Sopenharmony_ci};
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_cistruct mlx4_catas_err {
7368c2ecf20Sopenharmony_ci	u32 __iomem	       *map;
7378c2ecf20Sopenharmony_ci	struct timer_list	timer;
7388c2ecf20Sopenharmony_ci	struct list_head	list;
7398c2ecf20Sopenharmony_ci};
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci#define MLX4_MAX_MAC_NUM	128
7428c2ecf20Sopenharmony_ci#define MLX4_MAC_TABLE_SIZE	(MLX4_MAX_MAC_NUM << 3)
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_cistruct mlx4_mac_table {
7458c2ecf20Sopenharmony_ci	__be64			entries[MLX4_MAX_MAC_NUM];
7468c2ecf20Sopenharmony_ci	int			refs[MLX4_MAX_MAC_NUM];
7478c2ecf20Sopenharmony_ci	bool			is_dup[MLX4_MAX_MAC_NUM];
7488c2ecf20Sopenharmony_ci	struct mutex		mutex;
7498c2ecf20Sopenharmony_ci	int			total;
7508c2ecf20Sopenharmony_ci	int			max;
7518c2ecf20Sopenharmony_ci};
7528c2ecf20Sopenharmony_ci
7538c2ecf20Sopenharmony_ci#define MLX4_ROCE_GID_ENTRY_SIZE	16
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_cistruct mlx4_roce_gid_entry {
7568c2ecf20Sopenharmony_ci	u8 raw[MLX4_ROCE_GID_ENTRY_SIZE];
7578c2ecf20Sopenharmony_ci};
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_cistruct mlx4_roce_gid_table {
7608c2ecf20Sopenharmony_ci	struct mlx4_roce_gid_entry	roce_gids[MLX4_ROCE_MAX_GIDS];
7618c2ecf20Sopenharmony_ci	struct mutex			mutex;
7628c2ecf20Sopenharmony_ci};
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ci#define MLX4_MAX_VLAN_NUM	128
7658c2ecf20Sopenharmony_ci#define MLX4_VLAN_TABLE_SIZE	(MLX4_MAX_VLAN_NUM << 2)
7668c2ecf20Sopenharmony_ci
7678c2ecf20Sopenharmony_cistruct mlx4_vlan_table {
7688c2ecf20Sopenharmony_ci	__be32			entries[MLX4_MAX_VLAN_NUM];
7698c2ecf20Sopenharmony_ci	int			refs[MLX4_MAX_VLAN_NUM];
7708c2ecf20Sopenharmony_ci	int			is_dup[MLX4_MAX_VLAN_NUM];
7718c2ecf20Sopenharmony_ci	struct mutex		mutex;
7728c2ecf20Sopenharmony_ci	int			total;
7738c2ecf20Sopenharmony_ci	int			max;
7748c2ecf20Sopenharmony_ci};
7758c2ecf20Sopenharmony_ci
7768c2ecf20Sopenharmony_ci#define SET_PORT_GEN_ALL_VALID	(MLX4_FLAG_V_MTU_MASK	| \
7778c2ecf20Sopenharmony_ci				 MLX4_FLAG_V_PPRX_MASK	| \
7788c2ecf20Sopenharmony_ci				 MLX4_FLAG_V_PPTX_MASK)
7798c2ecf20Sopenharmony_ci#define SET_PORT_PROMISC_SHIFT		31
7808c2ecf20Sopenharmony_ci#define SET_PORT_MC_PROMISC_SHIFT	30
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_cienum {
7838c2ecf20Sopenharmony_ci	MCAST_DIRECT_ONLY	= 0,
7848c2ecf20Sopenharmony_ci	MCAST_DIRECT		= 1,
7858c2ecf20Sopenharmony_ci	MCAST_DEFAULT		= 2
7868c2ecf20Sopenharmony_ci};
7878c2ecf20Sopenharmony_ci
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_cistruct mlx4_set_port_general_context {
7908c2ecf20Sopenharmony_ci	u16 reserved1;
7918c2ecf20Sopenharmony_ci	u8 flags2;
7928c2ecf20Sopenharmony_ci	u8 flags;
7938c2ecf20Sopenharmony_ci	union {
7948c2ecf20Sopenharmony_ci		u8 ignore_fcs;
7958c2ecf20Sopenharmony_ci		u8 roce_mode;
7968c2ecf20Sopenharmony_ci	};
7978c2ecf20Sopenharmony_ci	u8 reserved2;
7988c2ecf20Sopenharmony_ci	__be16 mtu;
7998c2ecf20Sopenharmony_ci	u8 pptx;
8008c2ecf20Sopenharmony_ci	u8 pfctx;
8018c2ecf20Sopenharmony_ci	u16 reserved3;
8028c2ecf20Sopenharmony_ci	u8 pprx;
8038c2ecf20Sopenharmony_ci	u8 pfcrx;
8048c2ecf20Sopenharmony_ci	u16 reserved4;
8058c2ecf20Sopenharmony_ci	u32 reserved5;
8068c2ecf20Sopenharmony_ci	u8 phv_en;
8078c2ecf20Sopenharmony_ci	u8 reserved6[5];
8088c2ecf20Sopenharmony_ci	__be16 user_mtu;
8098c2ecf20Sopenharmony_ci	u16 reserved7;
8108c2ecf20Sopenharmony_ci	u8 user_mac[6];
8118c2ecf20Sopenharmony_ci};
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_cistruct mlx4_set_port_rqp_calc_context {
8148c2ecf20Sopenharmony_ci	__be32 base_qpn;
8158c2ecf20Sopenharmony_ci	u8 rererved;
8168c2ecf20Sopenharmony_ci	u8 n_mac;
8178c2ecf20Sopenharmony_ci	u8 n_vlan;
8188c2ecf20Sopenharmony_ci	u8 n_prio;
8198c2ecf20Sopenharmony_ci	u8 reserved2[3];
8208c2ecf20Sopenharmony_ci	u8 mac_miss;
8218c2ecf20Sopenharmony_ci	u8 intra_no_vlan;
8228c2ecf20Sopenharmony_ci	u8 no_vlan;
8238c2ecf20Sopenharmony_ci	u8 intra_vlan_miss;
8248c2ecf20Sopenharmony_ci	u8 vlan_miss;
8258c2ecf20Sopenharmony_ci	u8 reserved3[3];
8268c2ecf20Sopenharmony_ci	u8 no_vlan_prio;
8278c2ecf20Sopenharmony_ci	__be32 promisc;
8288c2ecf20Sopenharmony_ci	__be32 mcast;
8298c2ecf20Sopenharmony_ci};
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_cistruct mlx4_port_info {
8328c2ecf20Sopenharmony_ci	struct mlx4_dev	       *dev;
8338c2ecf20Sopenharmony_ci	int			port;
8348c2ecf20Sopenharmony_ci	char			dev_name[16];
8358c2ecf20Sopenharmony_ci	struct device_attribute port_attr;
8368c2ecf20Sopenharmony_ci	enum mlx4_port_type	tmp_type;
8378c2ecf20Sopenharmony_ci	char			dev_mtu_name[16];
8388c2ecf20Sopenharmony_ci	struct device_attribute port_mtu_attr;
8398c2ecf20Sopenharmony_ci	struct mlx4_mac_table	mac_table;
8408c2ecf20Sopenharmony_ci	struct mlx4_vlan_table	vlan_table;
8418c2ecf20Sopenharmony_ci	struct mlx4_roce_gid_table gid_table;
8428c2ecf20Sopenharmony_ci	int			base_qpn;
8438c2ecf20Sopenharmony_ci	struct cpu_rmap		*rmap;
8448c2ecf20Sopenharmony_ci	struct devlink_port	devlink_port;
8458c2ecf20Sopenharmony_ci};
8468c2ecf20Sopenharmony_ci
8478c2ecf20Sopenharmony_cistruct mlx4_sense {
8488c2ecf20Sopenharmony_ci	struct mlx4_dev		*dev;
8498c2ecf20Sopenharmony_ci	u8			do_sense_port[MLX4_MAX_PORTS + 1];
8508c2ecf20Sopenharmony_ci	u8			sense_allowed[MLX4_MAX_PORTS + 1];
8518c2ecf20Sopenharmony_ci	struct delayed_work	sense_poll;
8528c2ecf20Sopenharmony_ci};
8538c2ecf20Sopenharmony_ci
8548c2ecf20Sopenharmony_cistruct mlx4_msix_ctl {
8558c2ecf20Sopenharmony_ci	DECLARE_BITMAP(pool_bm, MAX_MSIX);
8568c2ecf20Sopenharmony_ci	struct mutex	pool_lock;
8578c2ecf20Sopenharmony_ci};
8588c2ecf20Sopenharmony_ci
8598c2ecf20Sopenharmony_cistruct mlx4_steer {
8608c2ecf20Sopenharmony_ci	struct list_head promisc_qps[MLX4_NUM_STEERS];
8618c2ecf20Sopenharmony_ci	struct list_head steer_entries[MLX4_NUM_STEERS];
8628c2ecf20Sopenharmony_ci};
8638c2ecf20Sopenharmony_ci
8648c2ecf20Sopenharmony_cienum {
8658c2ecf20Sopenharmony_ci	MLX4_PCI_DEV_IS_VF		= 1 << 0,
8668c2ecf20Sopenharmony_ci	MLX4_PCI_DEV_FORCE_SENSE_PORT	= 1 << 1,
8678c2ecf20Sopenharmony_ci};
8688c2ecf20Sopenharmony_ci
8698c2ecf20Sopenharmony_cienum {
8708c2ecf20Sopenharmony_ci	MLX4_NO_RR	= 0,
8718c2ecf20Sopenharmony_ci	MLX4_USE_RR	= 1,
8728c2ecf20Sopenharmony_ci};
8738c2ecf20Sopenharmony_ci
8748c2ecf20Sopenharmony_cistruct mlx4_priv {
8758c2ecf20Sopenharmony_ci	struct mlx4_dev		dev;
8768c2ecf20Sopenharmony_ci
8778c2ecf20Sopenharmony_ci	struct list_head	dev_list;
8788c2ecf20Sopenharmony_ci	struct list_head	ctx_list;
8798c2ecf20Sopenharmony_ci	spinlock_t		ctx_lock;
8808c2ecf20Sopenharmony_ci
8818c2ecf20Sopenharmony_ci	int			pci_dev_data;
8828c2ecf20Sopenharmony_ci	int                     removed;
8838c2ecf20Sopenharmony_ci
8848c2ecf20Sopenharmony_ci	struct list_head        pgdir_list;
8858c2ecf20Sopenharmony_ci	struct mutex            pgdir_mutex;
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_ci	struct mlx4_fw		fw;
8888c2ecf20Sopenharmony_ci	struct mlx4_cmd		cmd;
8898c2ecf20Sopenharmony_ci	struct mlx4_mfunc	mfunc;
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci	struct mlx4_bitmap	pd_bitmap;
8928c2ecf20Sopenharmony_ci	struct mlx4_bitmap	xrcd_bitmap;
8938c2ecf20Sopenharmony_ci	struct mlx4_uar_table	uar_table;
8948c2ecf20Sopenharmony_ci	struct mlx4_mr_table	mr_table;
8958c2ecf20Sopenharmony_ci	struct mlx4_cq_table	cq_table;
8968c2ecf20Sopenharmony_ci	struct mlx4_eq_table	eq_table;
8978c2ecf20Sopenharmony_ci	struct mlx4_srq_table	srq_table;
8988c2ecf20Sopenharmony_ci	struct mlx4_qp_table	qp_table;
8998c2ecf20Sopenharmony_ci	struct mlx4_mcg_table	mcg_table;
9008c2ecf20Sopenharmony_ci	struct mlx4_bitmap	counters_bitmap;
9018c2ecf20Sopenharmony_ci	int			def_counter[MLX4_MAX_PORTS];
9028c2ecf20Sopenharmony_ci
9038c2ecf20Sopenharmony_ci	struct mlx4_catas_err	catas_err;
9048c2ecf20Sopenharmony_ci
9058c2ecf20Sopenharmony_ci	void __iomem	       *clr_base;
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_ci	struct mlx4_uar		driver_uar;
9088c2ecf20Sopenharmony_ci	void __iomem	       *kar;
9098c2ecf20Sopenharmony_ci	struct mlx4_port_info	port[MLX4_MAX_PORTS + 1];
9108c2ecf20Sopenharmony_ci	struct mlx4_sense       sense;
9118c2ecf20Sopenharmony_ci	struct mutex		port_mutex;
9128c2ecf20Sopenharmony_ci	struct mlx4_msix_ctl	msix_ctl;
9138c2ecf20Sopenharmony_ci	struct mlx4_steer	*steer;
9148c2ecf20Sopenharmony_ci	struct list_head	bf_list;
9158c2ecf20Sopenharmony_ci	struct mutex		bf_mutex;
9168c2ecf20Sopenharmony_ci	struct io_mapping	*bf_mapping;
9178c2ecf20Sopenharmony_ci	void __iomem            *clock_mapping;
9188c2ecf20Sopenharmony_ci	int			reserved_mtts;
9198c2ecf20Sopenharmony_ci	int			fs_hash_mode;
9208c2ecf20Sopenharmony_ci	u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
9218c2ecf20Sopenharmony_ci	struct mlx4_port_map	v2p; /* cached port mapping configuration */
9228c2ecf20Sopenharmony_ci	struct mutex		bond_mutex; /* for bond mode */
9238c2ecf20Sopenharmony_ci	__be64			slave_node_guids[MLX4_MFUNC_MAX];
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_ci	atomic_t		opreq_count;
9268c2ecf20Sopenharmony_ci	struct work_struct	opreq_task;
9278c2ecf20Sopenharmony_ci};
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_cistatic inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
9308c2ecf20Sopenharmony_ci{
9318c2ecf20Sopenharmony_ci	return container_of(dev, struct mlx4_priv, dev);
9328c2ecf20Sopenharmony_ci}
9338c2ecf20Sopenharmony_ci
9348c2ecf20Sopenharmony_ci#define MLX4_SENSE_RANGE	(HZ * 3)
9358c2ecf20Sopenharmony_ci
9368c2ecf20Sopenharmony_ciextern struct workqueue_struct *mlx4_wq;
9378c2ecf20Sopenharmony_ci
9388c2ecf20Sopenharmony_ciu32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap);
9398c2ecf20Sopenharmony_civoid mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj, int use_rr);
9408c2ecf20Sopenharmony_ciu32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt,
9418c2ecf20Sopenharmony_ci			    int align, u32 skip_mask);
9428c2ecf20Sopenharmony_civoid mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt,
9438c2ecf20Sopenharmony_ci			    int use_rr);
9448c2ecf20Sopenharmony_ciu32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap);
9458c2ecf20Sopenharmony_ciint mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
9468c2ecf20Sopenharmony_ci		     u32 reserved_bot, u32 resetrved_top);
9478c2ecf20Sopenharmony_civoid mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap);
9488c2ecf20Sopenharmony_ci
9498c2ecf20Sopenharmony_ciint mlx4_reset(struct mlx4_dev *dev);
9508c2ecf20Sopenharmony_ci
9518c2ecf20Sopenharmony_ciint mlx4_alloc_eq_table(struct mlx4_dev *dev);
9528c2ecf20Sopenharmony_civoid mlx4_free_eq_table(struct mlx4_dev *dev);
9538c2ecf20Sopenharmony_ci
9548c2ecf20Sopenharmony_ciint mlx4_init_pd_table(struct mlx4_dev *dev);
9558c2ecf20Sopenharmony_ciint mlx4_init_xrcd_table(struct mlx4_dev *dev);
9568c2ecf20Sopenharmony_ciint mlx4_init_uar_table(struct mlx4_dev *dev);
9578c2ecf20Sopenharmony_ciint mlx4_init_mr_table(struct mlx4_dev *dev);
9588c2ecf20Sopenharmony_ciint mlx4_init_eq_table(struct mlx4_dev *dev);
9598c2ecf20Sopenharmony_ciint mlx4_init_cq_table(struct mlx4_dev *dev);
9608c2ecf20Sopenharmony_ciint mlx4_init_qp_table(struct mlx4_dev *dev);
9618c2ecf20Sopenharmony_ciint mlx4_init_srq_table(struct mlx4_dev *dev);
9628c2ecf20Sopenharmony_ciint mlx4_init_mcg_table(struct mlx4_dev *dev);
9638c2ecf20Sopenharmony_ci
9648c2ecf20Sopenharmony_civoid mlx4_cleanup_pd_table(struct mlx4_dev *dev);
9658c2ecf20Sopenharmony_civoid mlx4_cleanup_xrcd_table(struct mlx4_dev *dev);
9668c2ecf20Sopenharmony_civoid mlx4_cleanup_uar_table(struct mlx4_dev *dev);
9678c2ecf20Sopenharmony_civoid mlx4_cleanup_mr_table(struct mlx4_dev *dev);
9688c2ecf20Sopenharmony_civoid mlx4_cleanup_eq_table(struct mlx4_dev *dev);
9698c2ecf20Sopenharmony_civoid mlx4_cleanup_cq_table(struct mlx4_dev *dev);
9708c2ecf20Sopenharmony_civoid mlx4_cleanup_qp_table(struct mlx4_dev *dev);
9718c2ecf20Sopenharmony_civoid mlx4_cleanup_srq_table(struct mlx4_dev *dev);
9728c2ecf20Sopenharmony_civoid mlx4_cleanup_mcg_table(struct mlx4_dev *dev);
9738c2ecf20Sopenharmony_ciint __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn);
9748c2ecf20Sopenharmony_civoid __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn);
9758c2ecf20Sopenharmony_ciint __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn);
9768c2ecf20Sopenharmony_civoid __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn);
9778c2ecf20Sopenharmony_ciint __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn);
9788c2ecf20Sopenharmony_civoid __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn);
9798c2ecf20Sopenharmony_ciint __mlx4_mpt_reserve(struct mlx4_dev *dev);
9808c2ecf20Sopenharmony_civoid __mlx4_mpt_release(struct mlx4_dev *dev, u32 index);
9818c2ecf20Sopenharmony_ciint __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index);
9828c2ecf20Sopenharmony_civoid __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index);
9838c2ecf20Sopenharmony_ciu32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order);
9848c2ecf20Sopenharmony_civoid __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order);
9858c2ecf20Sopenharmony_ci
9868c2ecf20Sopenharmony_ciint mlx4_WRITE_MTT_wrapper(struct mlx4_dev *dev, int slave,
9878c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
9888c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
9898c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
9908c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
9918c2ecf20Sopenharmony_ciint mlx4_SYNC_TPT_wrapper(struct mlx4_dev *dev, int slave,
9928c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
9938c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
9948c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
9958c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
9968c2ecf20Sopenharmony_ciint mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave,
9978c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
9988c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
9998c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
10008c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
10018c2ecf20Sopenharmony_ciint mlx4_HW2SW_MPT_wrapper(struct mlx4_dev *dev, int slave,
10028c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
10038c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
10048c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
10058c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
10068c2ecf20Sopenharmony_ciint mlx4_QUERY_MPT_wrapper(struct mlx4_dev *dev, int slave,
10078c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
10088c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
10098c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
10108c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
10118c2ecf20Sopenharmony_ciint mlx4_SW2HW_EQ_wrapper(struct mlx4_dev *dev, int slave,
10128c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
10138c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
10148c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
10158c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
10168c2ecf20Sopenharmony_ciint mlx4_CONFIG_DEV_wrapper(struct mlx4_dev *dev, int slave,
10178c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
10188c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
10198c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
10208c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
10218c2ecf20Sopenharmony_ciint mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave,
10228c2ecf20Sopenharmony_ci		     struct mlx4_vhcr *vhcr,
10238c2ecf20Sopenharmony_ci		     struct mlx4_cmd_mailbox *inbox,
10248c2ecf20Sopenharmony_ci		     struct mlx4_cmd_mailbox *outbox,
10258c2ecf20Sopenharmony_ci		     struct mlx4_cmd_info *cmd);
10268c2ecf20Sopenharmony_ciint __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
10278c2ecf20Sopenharmony_ci			    int *base, u8 flags);
10288c2ecf20Sopenharmony_civoid __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
10298c2ecf20Sopenharmony_ciint __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
10308c2ecf20Sopenharmony_civoid __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
10318c2ecf20Sopenharmony_ciint __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
10328c2ecf20Sopenharmony_ci		     int start_index, int npages, u64 *page_list);
10338c2ecf20Sopenharmony_ciint __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx);
10348c2ecf20Sopenharmony_civoid __mlx4_counter_free(struct mlx4_dev *dev, u32 idx);
10358c2ecf20Sopenharmony_ciint mlx4_calc_vf_counters(struct mlx4_dev *dev, int slave, int port,
10368c2ecf20Sopenharmony_ci			  struct mlx4_counter *data);
10378c2ecf20Sopenharmony_ciint __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
10388c2ecf20Sopenharmony_civoid __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
10398c2ecf20Sopenharmony_ci
10408c2ecf20Sopenharmony_civoid mlx4_start_catas_poll(struct mlx4_dev *dev);
10418c2ecf20Sopenharmony_civoid mlx4_stop_catas_poll(struct mlx4_dev *dev);
10428c2ecf20Sopenharmony_ciint mlx4_catas_init(struct mlx4_dev *dev);
10438c2ecf20Sopenharmony_civoid mlx4_catas_end(struct mlx4_dev *dev);
10448c2ecf20Sopenharmony_ciint mlx4_crdump_init(struct mlx4_dev *dev);
10458c2ecf20Sopenharmony_civoid mlx4_crdump_end(struct mlx4_dev *dev);
10468c2ecf20Sopenharmony_ciint mlx4_restart_one(struct pci_dev *pdev);
10478c2ecf20Sopenharmony_ciint mlx4_register_device(struct mlx4_dev *dev);
10488c2ecf20Sopenharmony_civoid mlx4_unregister_device(struct mlx4_dev *dev);
10498c2ecf20Sopenharmony_civoid mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,
10508c2ecf20Sopenharmony_ci			 unsigned long param);
10518c2ecf20Sopenharmony_ci
10528c2ecf20Sopenharmony_cistruct mlx4_dev_cap;
10538c2ecf20Sopenharmony_cistruct mlx4_init_hca_param;
10548c2ecf20Sopenharmony_ci
10558c2ecf20Sopenharmony_ciu64 mlx4_make_profile(struct mlx4_dev *dev,
10568c2ecf20Sopenharmony_ci		      struct mlx4_profile *request,
10578c2ecf20Sopenharmony_ci		      struct mlx4_dev_cap *dev_cap,
10588c2ecf20Sopenharmony_ci		      struct mlx4_init_hca_param *init_hca);
10598c2ecf20Sopenharmony_civoid mlx4_master_comm_channel(struct work_struct *work);
10608c2ecf20Sopenharmony_civoid mlx4_gen_slave_eqe(struct work_struct *work);
10618c2ecf20Sopenharmony_civoid mlx4_master_handle_slave_flr(struct work_struct *work);
10628c2ecf20Sopenharmony_ci
10638c2ecf20Sopenharmony_ciint mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave,
10648c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
10658c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
10668c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
10678c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
10688c2ecf20Sopenharmony_ciint mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave,
10698c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
10708c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
10718c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
10728c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
10738c2ecf20Sopenharmony_ciint mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
10748c2ecf20Sopenharmony_ci			struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
10758c2ecf20Sopenharmony_ci			struct mlx4_cmd_mailbox *outbox,
10768c2ecf20Sopenharmony_ci			struct mlx4_cmd_info *cmd);
10778c2ecf20Sopenharmony_ciint mlx4_COMM_INT_wrapper(struct mlx4_dev *dev, int slave,
10788c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
10798c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
10808c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
10818c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
10828c2ecf20Sopenharmony_ciint mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave,
10838c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
10848c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
10858c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
10868c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
10878c2ecf20Sopenharmony_ciint mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave,
10888c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
10898c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
10908c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
10918c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
10928c2ecf20Sopenharmony_ciint mlx4_SW2HW_CQ_wrapper(struct mlx4_dev *dev, int slave,
10938c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
10948c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
10958c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
10968c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
10978c2ecf20Sopenharmony_ciint mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave,
10988c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
10998c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
11008c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
11018c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
11028c2ecf20Sopenharmony_ciint mlx4_QUERY_CQ_wrapper(struct mlx4_dev *dev, int slave,
11038c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
11048c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
11058c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
11068c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
11078c2ecf20Sopenharmony_ciint mlx4_MODIFY_CQ_wrapper(struct mlx4_dev *dev, int slave,
11088c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
11098c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
11108c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
11118c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
11128c2ecf20Sopenharmony_ciint mlx4_SW2HW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
11138c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
11148c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
11158c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
11168c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
11178c2ecf20Sopenharmony_ciint mlx4_HW2SW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
11188c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
11198c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
11208c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
11218c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
11228c2ecf20Sopenharmony_ciint mlx4_QUERY_SRQ_wrapper(struct mlx4_dev *dev, int slave,
11238c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
11248c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
11258c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
11268c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
11278c2ecf20Sopenharmony_ciint mlx4_ARM_SRQ_wrapper(struct mlx4_dev *dev, int slave,
11288c2ecf20Sopenharmony_ci			 struct mlx4_vhcr *vhcr,
11298c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *inbox,
11308c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *outbox,
11318c2ecf20Sopenharmony_ci			 struct mlx4_cmd_info *cmd);
11328c2ecf20Sopenharmony_ciint mlx4_GEN_QP_wrapper(struct mlx4_dev *dev, int slave,
11338c2ecf20Sopenharmony_ci			struct mlx4_vhcr *vhcr,
11348c2ecf20Sopenharmony_ci			struct mlx4_cmd_mailbox *inbox,
11358c2ecf20Sopenharmony_ci			struct mlx4_cmd_mailbox *outbox,
11368c2ecf20Sopenharmony_ci			struct mlx4_cmd_info *cmd);
11378c2ecf20Sopenharmony_ciint mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
11388c2ecf20Sopenharmony_ci			     struct mlx4_vhcr *vhcr,
11398c2ecf20Sopenharmony_ci			     struct mlx4_cmd_mailbox *inbox,
11408c2ecf20Sopenharmony_ci			     struct mlx4_cmd_mailbox *outbox,
11418c2ecf20Sopenharmony_ci			     struct mlx4_cmd_info *cmd);
11428c2ecf20Sopenharmony_ciint mlx4_INIT2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
11438c2ecf20Sopenharmony_ci			      struct mlx4_vhcr *vhcr,
11448c2ecf20Sopenharmony_ci			      struct mlx4_cmd_mailbox *inbox,
11458c2ecf20Sopenharmony_ci			      struct mlx4_cmd_mailbox *outbox,
11468c2ecf20Sopenharmony_ci			      struct mlx4_cmd_info *cmd);
11478c2ecf20Sopenharmony_ciint mlx4_INIT2RTR_QP_wrapper(struct mlx4_dev *dev, int slave,
11488c2ecf20Sopenharmony_ci			     struct mlx4_vhcr *vhcr,
11498c2ecf20Sopenharmony_ci			     struct mlx4_cmd_mailbox *inbox,
11508c2ecf20Sopenharmony_ci			     struct mlx4_cmd_mailbox *outbox,
11518c2ecf20Sopenharmony_ci			     struct mlx4_cmd_info *cmd);
11528c2ecf20Sopenharmony_ciint mlx4_RTR2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
11538c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
11548c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
11558c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
11568c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
11578c2ecf20Sopenharmony_ciint mlx4_RTS2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
11588c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
11598c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
11608c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
11618c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
11628c2ecf20Sopenharmony_ciint mlx4_SQERR2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
11638c2ecf20Sopenharmony_ci			      struct mlx4_vhcr *vhcr,
11648c2ecf20Sopenharmony_ci			      struct mlx4_cmd_mailbox *inbox,
11658c2ecf20Sopenharmony_ci			      struct mlx4_cmd_mailbox *outbox,
11668c2ecf20Sopenharmony_ci			      struct mlx4_cmd_info *cmd);
11678c2ecf20Sopenharmony_ciint mlx4_2ERR_QP_wrapper(struct mlx4_dev *dev, int slave,
11688c2ecf20Sopenharmony_ci			 struct mlx4_vhcr *vhcr,
11698c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *inbox,
11708c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *outbox,
11718c2ecf20Sopenharmony_ci			 struct mlx4_cmd_info *cmd);
11728c2ecf20Sopenharmony_ciint mlx4_RTS2SQD_QP_wrapper(struct mlx4_dev *dev, int slave,
11738c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
11748c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
11758c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
11768c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
11778c2ecf20Sopenharmony_ciint mlx4_SQD2SQD_QP_wrapper(struct mlx4_dev *dev, int slave,
11788c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
11798c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
11808c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
11818c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
11828c2ecf20Sopenharmony_ciint mlx4_SQD2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
11838c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
11848c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
11858c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
11868c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
11878c2ecf20Sopenharmony_ciint mlx4_2RST_QP_wrapper(struct mlx4_dev *dev, int slave,
11888c2ecf20Sopenharmony_ci			 struct mlx4_vhcr *vhcr,
11898c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *inbox,
11908c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *outbox,
11918c2ecf20Sopenharmony_ci			 struct mlx4_cmd_info *cmd);
11928c2ecf20Sopenharmony_ciint mlx4_QUERY_QP_wrapper(struct mlx4_dev *dev, int slave,
11938c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
11948c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
11958c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
11968c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
11978c2ecf20Sopenharmony_ci
11988c2ecf20Sopenharmony_ciint mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe);
11998c2ecf20Sopenharmony_ci
12008c2ecf20Sopenharmony_cienum {
12018c2ecf20Sopenharmony_ci	MLX4_CMD_CLEANUP_STRUCT = 1UL << 0,
12028c2ecf20Sopenharmony_ci	MLX4_CMD_CLEANUP_POOL	= 1UL << 1,
12038c2ecf20Sopenharmony_ci	MLX4_CMD_CLEANUP_HCR	= 1UL << 2,
12048c2ecf20Sopenharmony_ci	MLX4_CMD_CLEANUP_VHCR	= 1UL << 3,
12058c2ecf20Sopenharmony_ci	MLX4_CMD_CLEANUP_ALL	= (MLX4_CMD_CLEANUP_VHCR << 1) - 1
12068c2ecf20Sopenharmony_ci};
12078c2ecf20Sopenharmony_ci
12088c2ecf20Sopenharmony_ciint mlx4_cmd_init(struct mlx4_dev *dev);
12098c2ecf20Sopenharmony_civoid mlx4_cmd_cleanup(struct mlx4_dev *dev, int cleanup_mask);
12108c2ecf20Sopenharmony_ciint mlx4_multi_func_init(struct mlx4_dev *dev);
12118c2ecf20Sopenharmony_ciint mlx4_ARM_COMM_CHANNEL(struct mlx4_dev *dev);
12128c2ecf20Sopenharmony_civoid mlx4_multi_func_cleanup(struct mlx4_dev *dev);
12138c2ecf20Sopenharmony_civoid mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param);
12148c2ecf20Sopenharmony_ciint mlx4_cmd_use_events(struct mlx4_dev *dev);
12158c2ecf20Sopenharmony_civoid mlx4_cmd_use_polling(struct mlx4_dev *dev);
12168c2ecf20Sopenharmony_ci
12178c2ecf20Sopenharmony_ciint mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
12188c2ecf20Sopenharmony_ci		  u16 op, unsigned long timeout);
12198c2ecf20Sopenharmony_ci
12208c2ecf20Sopenharmony_civoid mlx4_cq_tasklet_cb(struct tasklet_struct *t);
12218c2ecf20Sopenharmony_civoid mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn);
12228c2ecf20Sopenharmony_civoid mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type);
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_civoid mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type);
12258c2ecf20Sopenharmony_ci
12268c2ecf20Sopenharmony_civoid mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type);
12278c2ecf20Sopenharmony_ci
12288c2ecf20Sopenharmony_civoid mlx4_enter_error_state(struct mlx4_dev_persistent *persist);
12298c2ecf20Sopenharmony_ciint mlx4_comm_internal_err(u32 slave_read);
12308c2ecf20Sopenharmony_ci
12318c2ecf20Sopenharmony_ciint mlx4_crdump_collect(struct mlx4_dev *dev);
12328c2ecf20Sopenharmony_ci
12338c2ecf20Sopenharmony_ciint mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
12348c2ecf20Sopenharmony_ci		    enum mlx4_port_type *type);
12358c2ecf20Sopenharmony_civoid mlx4_do_sense_ports(struct mlx4_dev *dev,
12368c2ecf20Sopenharmony_ci			 enum mlx4_port_type *stype,
12378c2ecf20Sopenharmony_ci			 enum mlx4_port_type *defaults);
12388c2ecf20Sopenharmony_civoid mlx4_start_sense(struct mlx4_dev *dev);
12398c2ecf20Sopenharmony_civoid mlx4_stop_sense(struct mlx4_dev *dev);
12408c2ecf20Sopenharmony_civoid mlx4_sense_init(struct mlx4_dev *dev);
12418c2ecf20Sopenharmony_ciint mlx4_check_port_params(struct mlx4_dev *dev,
12428c2ecf20Sopenharmony_ci			   enum mlx4_port_type *port_type);
12438c2ecf20Sopenharmony_ciint mlx4_change_port_types(struct mlx4_dev *dev,
12448c2ecf20Sopenharmony_ci			   enum mlx4_port_type *port_types);
12458c2ecf20Sopenharmony_ci
12468c2ecf20Sopenharmony_civoid mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
12478c2ecf20Sopenharmony_civoid mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
12488c2ecf20Sopenharmony_civoid mlx4_init_roce_gid_table(struct mlx4_dev *dev,
12498c2ecf20Sopenharmony_ci			      struct mlx4_roce_gid_table *table);
12508c2ecf20Sopenharmony_civoid __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan);
12518c2ecf20Sopenharmony_ciint __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
12528c2ecf20Sopenharmony_ciint mlx4_bond_vlan_table(struct mlx4_dev *dev);
12538c2ecf20Sopenharmony_ciint mlx4_unbond_vlan_table(struct mlx4_dev *dev);
12548c2ecf20Sopenharmony_ciint mlx4_bond_mac_table(struct mlx4_dev *dev);
12558c2ecf20Sopenharmony_ciint mlx4_unbond_mac_table(struct mlx4_dev *dev);
12568c2ecf20Sopenharmony_ci
12578c2ecf20Sopenharmony_ciint mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz);
12588c2ecf20Sopenharmony_ci/* resource tracker functions*/
12598c2ecf20Sopenharmony_ciint mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
12608c2ecf20Sopenharmony_ci				    enum mlx4_resource resource_type,
12618c2ecf20Sopenharmony_ci				    u64 resource_id, int *slave);
12628c2ecf20Sopenharmony_civoid mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave_id);
12638c2ecf20Sopenharmony_civoid mlx4_reset_roce_gids(struct mlx4_dev *dev, int slave);
12648c2ecf20Sopenharmony_ciint mlx4_init_resource_tracker(struct mlx4_dev *dev);
12658c2ecf20Sopenharmony_ci
12668c2ecf20Sopenharmony_civoid mlx4_free_resource_tracker(struct mlx4_dev *dev,
12678c2ecf20Sopenharmony_ci				enum mlx4_res_tracker_free_type type);
12688c2ecf20Sopenharmony_ci
12698c2ecf20Sopenharmony_ciint mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave,
12708c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
12718c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
12728c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
12738c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
12748c2ecf20Sopenharmony_ciint mlx4_SET_PORT_wrapper(struct mlx4_dev *dev, int slave,
12758c2ecf20Sopenharmony_ci			  struct mlx4_vhcr *vhcr,
12768c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *inbox,
12778c2ecf20Sopenharmony_ci			  struct mlx4_cmd_mailbox *outbox,
12788c2ecf20Sopenharmony_ci			  struct mlx4_cmd_info *cmd);
12798c2ecf20Sopenharmony_ciint mlx4_INIT_PORT_wrapper(struct mlx4_dev *dev, int slave,
12808c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
12818c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
12828c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
12838c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
12848c2ecf20Sopenharmony_ciint mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave,
12858c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
12868c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
12878c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
12888c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
12898c2ecf20Sopenharmony_ciint mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,
12908c2ecf20Sopenharmony_ci			       struct mlx4_vhcr *vhcr,
12918c2ecf20Sopenharmony_ci			       struct mlx4_cmd_mailbox *inbox,
12928c2ecf20Sopenharmony_ci			       struct mlx4_cmd_mailbox *outbox,
12938c2ecf20Sopenharmony_ci			       struct mlx4_cmd_info *cmd);
12948c2ecf20Sopenharmony_ciint mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
12958c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
12968c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
12978c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
12988c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
12998c2ecf20Sopenharmony_ciint mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
13008c2ecf20Sopenharmony_ci
13018c2ecf20Sopenharmony_ciint mlx4_get_slave_pkey_gid_tbl_len(struct mlx4_dev *dev, u8 port,
13028c2ecf20Sopenharmony_ci				    int *gid_tbl_len, int *pkey_tbl_len);
13038c2ecf20Sopenharmony_ci
13048c2ecf20Sopenharmony_ciint mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
13058c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
13068c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
13078c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
13088c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
13098c2ecf20Sopenharmony_ci
13108c2ecf20Sopenharmony_ciint mlx4_UPDATE_QP_wrapper(struct mlx4_dev *dev, int slave,
13118c2ecf20Sopenharmony_ci			   struct mlx4_vhcr *vhcr,
13128c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *inbox,
13138c2ecf20Sopenharmony_ci			   struct mlx4_cmd_mailbox *outbox,
13148c2ecf20Sopenharmony_ci			   struct mlx4_cmd_info *cmd);
13158c2ecf20Sopenharmony_ci
13168c2ecf20Sopenharmony_ciint mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave,
13178c2ecf20Sopenharmony_ci			 struct mlx4_vhcr *vhcr,
13188c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *inbox,
13198c2ecf20Sopenharmony_ci			 struct mlx4_cmd_mailbox *outbox,
13208c2ecf20Sopenharmony_ci			 struct mlx4_cmd_info *cmd);
13218c2ecf20Sopenharmony_ciint mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
13228c2ecf20Sopenharmony_ci			  enum mlx4_protocol prot, enum mlx4_steer_type steer);
13238c2ecf20Sopenharmony_ciint mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
13248c2ecf20Sopenharmony_ci			  int block_mcast_loopback, enum mlx4_protocol prot,
13258c2ecf20Sopenharmony_ci			  enum mlx4_steer_type steer);
13268c2ecf20Sopenharmony_ciint mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp,
13278c2ecf20Sopenharmony_ci			      u8 gid[16], u8 port,
13288c2ecf20Sopenharmony_ci			      int block_mcast_loopback,
13298c2ecf20Sopenharmony_ci			      enum mlx4_protocol prot, u64 *reg_id);
13308c2ecf20Sopenharmony_ciint mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave,
13318c2ecf20Sopenharmony_ci				struct mlx4_vhcr *vhcr,
13328c2ecf20Sopenharmony_ci				struct mlx4_cmd_mailbox *inbox,
13338c2ecf20Sopenharmony_ci				struct mlx4_cmd_mailbox *outbox,
13348c2ecf20Sopenharmony_ci				struct mlx4_cmd_info *cmd);
13358c2ecf20Sopenharmony_ciint mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave,
13368c2ecf20Sopenharmony_ci			       struct mlx4_vhcr *vhcr,
13378c2ecf20Sopenharmony_ci			       struct mlx4_cmd_mailbox *inbox,
13388c2ecf20Sopenharmony_ci			       struct mlx4_cmd_mailbox *outbox,
13398c2ecf20Sopenharmony_ci			       struct mlx4_cmd_info *cmd);
13408c2ecf20Sopenharmony_ciint mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function,
13418c2ecf20Sopenharmony_ci				     int port, void *buf);
13428c2ecf20Sopenharmony_ciint mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
13438c2ecf20Sopenharmony_ci				   struct mlx4_vhcr *vhcr,
13448c2ecf20Sopenharmony_ci				   struct mlx4_cmd_mailbox *inbox,
13458c2ecf20Sopenharmony_ci				   struct mlx4_cmd_mailbox *outbox,
13468c2ecf20Sopenharmony_ci				struct mlx4_cmd_info *cmd);
13478c2ecf20Sopenharmony_ciint mlx4_PKEY_TABLE_wrapper(struct mlx4_dev *dev, int slave,
13488c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
13498c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
13508c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
13518c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
13528c2ecf20Sopenharmony_ciint mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave,
13538c2ecf20Sopenharmony_ci			       struct mlx4_vhcr *vhcr,
13548c2ecf20Sopenharmony_ci			       struct mlx4_cmd_mailbox *inbox,
13558c2ecf20Sopenharmony_ci			       struct mlx4_cmd_mailbox *outbox,
13568c2ecf20Sopenharmony_ci			       struct mlx4_cmd_info *cmd);
13578c2ecf20Sopenharmony_ciint mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
13588c2ecf20Sopenharmony_ci					 struct mlx4_vhcr *vhcr,
13598c2ecf20Sopenharmony_ci					 struct mlx4_cmd_mailbox *inbox,
13608c2ecf20Sopenharmony_ci					 struct mlx4_cmd_mailbox *outbox,
13618c2ecf20Sopenharmony_ci					 struct mlx4_cmd_info *cmd);
13628c2ecf20Sopenharmony_ciint mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
13638c2ecf20Sopenharmony_ci					 struct mlx4_vhcr *vhcr,
13648c2ecf20Sopenharmony_ci					 struct mlx4_cmd_mailbox *inbox,
13658c2ecf20Sopenharmony_ci					 struct mlx4_cmd_mailbox *outbox,
13668c2ecf20Sopenharmony_ci					 struct mlx4_cmd_info *cmd);
13678c2ecf20Sopenharmony_ciint mlx4_ACCESS_REG_wrapper(struct mlx4_dev *dev, int slave,
13688c2ecf20Sopenharmony_ci			    struct mlx4_vhcr *vhcr,
13698c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *inbox,
13708c2ecf20Sopenharmony_ci			    struct mlx4_cmd_mailbox *outbox,
13718c2ecf20Sopenharmony_ci			    struct mlx4_cmd_info *cmd);
13728c2ecf20Sopenharmony_ci
13738c2ecf20Sopenharmony_ciint mlx4_get_mgm_entry_size(struct mlx4_dev *dev);
13748c2ecf20Sopenharmony_ciint mlx4_get_qp_per_mgm(struct mlx4_dev *dev);
13758c2ecf20Sopenharmony_ci
13768c2ecf20Sopenharmony_cistatic inline void set_param_l(u64 *arg, u32 val)
13778c2ecf20Sopenharmony_ci{
13788c2ecf20Sopenharmony_ci	*arg = (*arg & 0xffffffff00000000ULL) | (u64) val;
13798c2ecf20Sopenharmony_ci}
13808c2ecf20Sopenharmony_ci
13818c2ecf20Sopenharmony_cistatic inline void set_param_h(u64 *arg, u32 val)
13828c2ecf20Sopenharmony_ci{
13838c2ecf20Sopenharmony_ci	*arg = (*arg & 0xffffffff) | ((u64) val << 32);
13848c2ecf20Sopenharmony_ci}
13858c2ecf20Sopenharmony_ci
13868c2ecf20Sopenharmony_cistatic inline u32 get_param_l(u64 *arg)
13878c2ecf20Sopenharmony_ci{
13888c2ecf20Sopenharmony_ci	return (u32) (*arg & 0xffffffff);
13898c2ecf20Sopenharmony_ci}
13908c2ecf20Sopenharmony_ci
13918c2ecf20Sopenharmony_cistatic inline u32 get_param_h(u64 *arg)
13928c2ecf20Sopenharmony_ci{
13938c2ecf20Sopenharmony_ci	return (u32)(*arg >> 32);
13948c2ecf20Sopenharmony_ci}
13958c2ecf20Sopenharmony_ci
13968c2ecf20Sopenharmony_cistatic inline spinlock_t *mlx4_tlock(struct mlx4_dev *dev)
13978c2ecf20Sopenharmony_ci{
13988c2ecf20Sopenharmony_ci	return &mlx4_priv(dev)->mfunc.master.res_tracker.lock;
13998c2ecf20Sopenharmony_ci}
14008c2ecf20Sopenharmony_ci
14018c2ecf20Sopenharmony_ci#define NOT_MASKED_PD_BITS 17
14028c2ecf20Sopenharmony_ci
14038c2ecf20Sopenharmony_civoid mlx4_vf_immed_vlan_work_handler(struct work_struct *_work);
14048c2ecf20Sopenharmony_ci
14058c2ecf20Sopenharmony_civoid mlx4_init_quotas(struct mlx4_dev *dev);
14068c2ecf20Sopenharmony_ci
14078c2ecf20Sopenharmony_ci/* for VFs, replace zero MACs with randomly-generated MACs at driver start */
14088c2ecf20Sopenharmony_civoid mlx4_replace_zero_macs(struct mlx4_dev *dev);
14098c2ecf20Sopenharmony_ciint mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave, int port);
14108c2ecf20Sopenharmony_ci/* Returns the VF index of slave */
14118c2ecf20Sopenharmony_ciint mlx4_get_vf_indx(struct mlx4_dev *dev, int slave);
14128c2ecf20Sopenharmony_ciint mlx4_config_mad_demux(struct mlx4_dev *dev);
14138c2ecf20Sopenharmony_ciint mlx4_do_bond(struct mlx4_dev *dev, bool enable);
14148c2ecf20Sopenharmony_ciint mlx4_bond_fs_rules(struct mlx4_dev *dev);
14158c2ecf20Sopenharmony_ciint mlx4_unbond_fs_rules(struct mlx4_dev *dev);
14168c2ecf20Sopenharmony_ci
14178c2ecf20Sopenharmony_cienum mlx4_zone_flags {
14188c2ecf20Sopenharmony_ci	MLX4_ZONE_ALLOW_ALLOC_FROM_LOWER_PRIO	= 1UL << 0,
14198c2ecf20Sopenharmony_ci	MLX4_ZONE_ALLOW_ALLOC_FROM_EQ_PRIO	= 1UL << 1,
14208c2ecf20Sopenharmony_ci	MLX4_ZONE_FALLBACK_TO_HIGHER_PRIO	= 1UL << 2,
14218c2ecf20Sopenharmony_ci	MLX4_ZONE_USE_RR			= 1UL << 3,
14228c2ecf20Sopenharmony_ci};
14238c2ecf20Sopenharmony_ci
14248c2ecf20Sopenharmony_cienum mlx4_zone_alloc_flags {
14258c2ecf20Sopenharmony_ci	/* No two objects could overlap between zones. UID
14268c2ecf20Sopenharmony_ci	 * could be left unused. If this flag is given and
14278c2ecf20Sopenharmony_ci	 * two overlapped zones are used, an object will be free'd
14288c2ecf20Sopenharmony_ci	 * from the smallest possible matching zone.
14298c2ecf20Sopenharmony_ci	 */
14308c2ecf20Sopenharmony_ci	MLX4_ZONE_ALLOC_FLAGS_NO_OVERLAP	= 1UL << 0,
14318c2ecf20Sopenharmony_ci};
14328c2ecf20Sopenharmony_ci
14338c2ecf20Sopenharmony_cistruct mlx4_zone_allocator;
14348c2ecf20Sopenharmony_ci
14358c2ecf20Sopenharmony_ci/* Create a new zone allocator */
14368c2ecf20Sopenharmony_cistruct mlx4_zone_allocator *mlx4_zone_allocator_create(enum mlx4_zone_alloc_flags flags);
14378c2ecf20Sopenharmony_ci
14388c2ecf20Sopenharmony_ci/* Attach a mlx4_bitmap <bitmap> of priority <priority> to the zone allocator
14398c2ecf20Sopenharmony_ci * <zone_alloc>. Allocating an object from this zone adds an offset <offset>.
14408c2ecf20Sopenharmony_ci * Similarly, when searching for an object to free, this offset it taken into
14418c2ecf20Sopenharmony_ci * account. The use_rr mlx4_ib parameter for allocating objects from this <bitmap>
14428c2ecf20Sopenharmony_ci * is given through the MLX4_ZONE_USE_RR flag in <flags>.
14438c2ecf20Sopenharmony_ci * When an allocation fails, <zone_alloc> tries to allocate from other zones
14448c2ecf20Sopenharmony_ci * according to the policy set by <flags>. <puid> is the unique identifier
14458c2ecf20Sopenharmony_ci * received to this zone.
14468c2ecf20Sopenharmony_ci */
14478c2ecf20Sopenharmony_ciint mlx4_zone_add_one(struct mlx4_zone_allocator *zone_alloc,
14488c2ecf20Sopenharmony_ci		      struct mlx4_bitmap *bitmap,
14498c2ecf20Sopenharmony_ci		      u32 flags,
14508c2ecf20Sopenharmony_ci		      int priority,
14518c2ecf20Sopenharmony_ci		      int offset,
14528c2ecf20Sopenharmony_ci		      u32 *puid);
14538c2ecf20Sopenharmony_ci
14548c2ecf20Sopenharmony_ci/* Remove bitmap indicated by <uid> from <zone_alloc> */
14558c2ecf20Sopenharmony_ciint mlx4_zone_remove_one(struct mlx4_zone_allocator *zone_alloc, u32 uid);
14568c2ecf20Sopenharmony_ci
14578c2ecf20Sopenharmony_ci/* Delete the zone allocator <zone_alloc. This function doesn't destroy
14588c2ecf20Sopenharmony_ci * the attached bitmaps.
14598c2ecf20Sopenharmony_ci */
14608c2ecf20Sopenharmony_civoid mlx4_zone_allocator_destroy(struct mlx4_zone_allocator *zone_alloc);
14618c2ecf20Sopenharmony_ci
14628c2ecf20Sopenharmony_ci/* Allocate <count> objects with align <align> and skip_mask <skip_mask>
14638c2ecf20Sopenharmony_ci * from the mlx4_bitmap whose uid is <uid>. The bitmap which we actually
14648c2ecf20Sopenharmony_ci * allocated from is returned in <puid>. If the allocation fails, a negative
14658c2ecf20Sopenharmony_ci * number is returned. Otherwise, the offset of the first object is returned.
14668c2ecf20Sopenharmony_ci */
14678c2ecf20Sopenharmony_ciu32 mlx4_zone_alloc_entries(struct mlx4_zone_allocator *zones, u32 uid, int count,
14688c2ecf20Sopenharmony_ci			    int align, u32 skip_mask, u32 *puid);
14698c2ecf20Sopenharmony_ci
14708c2ecf20Sopenharmony_ci/* Free <count> objects, start from <obj> of the uid <uid> from zone_allocator
14718c2ecf20Sopenharmony_ci * <zones>.
14728c2ecf20Sopenharmony_ci */
14738c2ecf20Sopenharmony_ciu32 mlx4_zone_free_entries(struct mlx4_zone_allocator *zones,
14748c2ecf20Sopenharmony_ci			   u32 uid, u32 obj, u32 count);
14758c2ecf20Sopenharmony_ci
14768c2ecf20Sopenharmony_ci/* If <zones> was allocated with MLX4_ZONE_ALLOC_FLAGS_NO_OVERLAP, instead of
14778c2ecf20Sopenharmony_ci * specifying the uid when freeing an object, zone allocator could figure it by
14788c2ecf20Sopenharmony_ci * itself. Other parameters are similar to mlx4_zone_free.
14798c2ecf20Sopenharmony_ci */
14808c2ecf20Sopenharmony_ciu32 mlx4_zone_free_entries_unique(struct mlx4_zone_allocator *zones, u32 obj, u32 count);
14818c2ecf20Sopenharmony_ci
14828c2ecf20Sopenharmony_ci/* Returns a pointer to mlx4_bitmap that was attached to <zones> with <uid> */
14838c2ecf20Sopenharmony_cistruct mlx4_bitmap *mlx4_zone_get_bitmap(struct mlx4_zone_allocator *zones, u32 uid);
14848c2ecf20Sopenharmony_ci
14858c2ecf20Sopenharmony_ci#endif /* MLX4_H */
1486