xref: /freebsd/sys/dev/mlx4/device.h (revision 2cebcdc7b6e227ae8cff90386f49a54d31e43a76)
197549c34SHans Petter Selasky /*
297549c34SHans Petter Selasky  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.
397549c34SHans Petter Selasky  *
497549c34SHans Petter Selasky  * This software is available to you under a choice of one of two
597549c34SHans Petter Selasky  * licenses.  You may choose to be licensed under the terms of the GNU
697549c34SHans Petter Selasky  * General Public License (GPL) Version 2, available from the file
797549c34SHans Petter Selasky  * COPYING in the main directory of this source tree, or the
897549c34SHans Petter Selasky  * OpenIB.org BSD license below:
997549c34SHans Petter Selasky  *
1097549c34SHans Petter Selasky  *     Redistribution and use in source and binary forms, with or
1197549c34SHans Petter Selasky  *     without modification, are permitted provided that the following
1297549c34SHans Petter Selasky  *     conditions are met:
1397549c34SHans Petter Selasky  *
1497549c34SHans Petter Selasky  *	- Redistributions of source code must retain the above
1597549c34SHans Petter Selasky  *	  copyright notice, this list of conditions and the following
1697549c34SHans Petter Selasky  *	  disclaimer.
1797549c34SHans Petter Selasky  *
1897549c34SHans Petter Selasky  *	- Redistributions in binary form must reproduce the above
1997549c34SHans Petter Selasky  *	  copyright notice, this list of conditions and the following
2097549c34SHans Petter Selasky  *	  disclaimer in the documentation and/or other materials
2197549c34SHans Petter Selasky  *	  provided with the distribution.
2297549c34SHans Petter Selasky  *
2397549c34SHans Petter Selasky  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2497549c34SHans Petter Selasky  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2597549c34SHans Petter Selasky  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2697549c34SHans Petter Selasky  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2797549c34SHans Petter Selasky  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2897549c34SHans Petter Selasky  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2997549c34SHans Petter Selasky  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3097549c34SHans Petter Selasky  * SOFTWARE.
3197549c34SHans Petter Selasky  */
3297549c34SHans Petter Selasky 
3397549c34SHans Petter Selasky #ifndef MLX4_DEVICE_H
3497549c34SHans Petter Selasky #define MLX4_DEVICE_H
3597549c34SHans Petter Selasky 
3697549c34SHans Petter Selasky #include <linux/pci.h>
3797549c34SHans Petter Selasky #include <linux/completion.h>
3897549c34SHans Petter Selasky #include <linux/radix-tree.h>
3997549c34SHans Petter Selasky #include <linux/types.h>
4097549c34SHans Petter Selasky #include <linux/bitops.h>
4197549c34SHans Petter Selasky #include <linux/workqueue.h>
4297549c34SHans Petter Selasky #include <asm/atomic.h>
4397549c34SHans Petter Selasky 
4497549c34SHans Petter Selasky #include <linux/clocksource.h>
4597549c34SHans Petter Selasky 
4697549c34SHans Petter Selasky #define MAX_MSIX_P_PORT		17
4797549c34SHans Petter Selasky #define MAX_MSIX		64
4897549c34SHans Petter Selasky #define MSIX_LEGACY_SZ		4
4997549c34SHans Petter Selasky #define MIN_MSIX_P_PORT		5
5097549c34SHans Petter Selasky 
5197549c34SHans Petter Selasky #define MLX4_ROCE_MAX_GIDS	128
5297549c34SHans Petter Selasky #define MLX4_ROCE_PF_GIDS	16
5397549c34SHans Petter Selasky 
5497549c34SHans Petter Selasky #define MLX4_NUM_UP			8
5597549c34SHans Petter Selasky #define MLX4_NUM_TC			8
5697549c34SHans Petter Selasky #define MLX4_MAX_100M_UNITS_VAL		255	/*
5797549c34SHans Petter Selasky 						 * work around: can't set values
5897549c34SHans Petter Selasky 						 * greater then this value when
5997549c34SHans Petter Selasky 						 * using 100 Mbps units.
6097549c34SHans Petter Selasky 						 */
6197549c34SHans Petter Selasky #define MLX4_RATELIMIT_100M_UNITS	3	/* 100 Mbps */
6297549c34SHans Petter Selasky #define MLX4_RATELIMIT_1G_UNITS		4	/* 1 Gbps */
6397549c34SHans Petter Selasky #define MLX4_RATELIMIT_DEFAULT		0x00ff
6497549c34SHans Petter Selasky 
6597549c34SHans Petter Selasky #define CORE_CLOCK_MASK 0xffffffffffffULL
6697549c34SHans Petter Selasky 
6797549c34SHans Petter Selasky enum {
6897549c34SHans Petter Selasky 	MLX4_FLAG_MSI_X		= 1 << 0,
6997549c34SHans Petter Selasky 	MLX4_FLAG_OLD_PORT_CMDS	= 1 << 1,
7097549c34SHans Petter Selasky 	MLX4_FLAG_MASTER	= 1 << 2,
7197549c34SHans Petter Selasky 	MLX4_FLAG_SLAVE		= 1 << 3,
7297549c34SHans Petter Selasky 	MLX4_FLAG_SRIOV		= 1 << 4,
7397549c34SHans Petter Selasky 	MLX4_FLAG_DEV_NUM_STR	= 1 << 5,
7497549c34SHans Petter Selasky 	MLX4_FLAG_OLD_REG_MAC   = 1 << 6,
7597549c34SHans Petter Selasky };
7697549c34SHans Petter Selasky 
7797549c34SHans Petter Selasky enum {
7897549c34SHans Petter Selasky 	MLX4_PORT_CAP_IS_SM	= 1 << 1,
7997549c34SHans Petter Selasky 	MLX4_PORT_CAP_DEV_MGMT_SUP = 1 << 19,
8097549c34SHans Petter Selasky };
8197549c34SHans Petter Selasky 
8297549c34SHans Petter Selasky enum {
8397549c34SHans Petter Selasky 	MLX4_MAX_PORTS		= 2,
8497549c34SHans Petter Selasky 	MLX4_MAX_PORT_PKEYS	= 128
8597549c34SHans Petter Selasky };
8697549c34SHans Petter Selasky 
8797549c34SHans Petter Selasky /* base qkey for use in sriov tunnel-qp/proxy-qp communication.
8897549c34SHans Petter Selasky  * These qkeys must not be allowed for general use. This is a 64k range,
8997549c34SHans Petter Selasky  * and to test for violation, we use the mask (protect against future chg).
9097549c34SHans Petter Selasky  */
9197549c34SHans Petter Selasky #define MLX4_RESERVED_QKEY_BASE  (0xFFFF0000)
9297549c34SHans Petter Selasky #define MLX4_RESERVED_QKEY_MASK  (0xFFFF0000)
9397549c34SHans Petter Selasky 
9497549c34SHans Petter Selasky enum {
9597549c34SHans Petter Selasky 	MLX4_BOARD_ID_LEN = 64,
9697549c34SHans Petter Selasky 	MLX4_VSD_LEN = 208
9797549c34SHans Petter Selasky };
9897549c34SHans Petter Selasky 
9997549c34SHans Petter Selasky enum {
10097549c34SHans Petter Selasky 	MLX4_MAX_NUM_PF		= 16,
10197549c34SHans Petter Selasky 	MLX4_MAX_NUM_VF		= 64,
10297549c34SHans Petter Selasky 	MLX4_MFUNC_MAX		= 80,
10397549c34SHans Petter Selasky 	MLX4_MAX_EQ_NUM		= 1024,
10497549c34SHans Petter Selasky 	MLX4_MFUNC_EQ_NUM	= 4,
10597549c34SHans Petter Selasky 	MLX4_MFUNC_MAX_EQES     = 8,
10697549c34SHans Petter Selasky 	MLX4_MFUNC_EQE_MASK     = (MLX4_MFUNC_MAX_EQES - 1)
10797549c34SHans Petter Selasky };
10897549c34SHans Petter Selasky 
10997549c34SHans Petter Selasky /* Driver supports 3 different device methods to manage traffic steering:
11097549c34SHans Petter Selasky  *	-device managed - High level API for ib and eth flow steering. FW is
11197549c34SHans Petter Selasky  *			  managing flow steering tables.
11297549c34SHans Petter Selasky  *	- B0 steering mode - Common low level API for ib and (if supported) eth.
11397549c34SHans Petter Selasky  *	- A0 steering mode - Limited low level API for eth. In case of IB,
11497549c34SHans Petter Selasky  *			     B0 mode is in use.
11597549c34SHans Petter Selasky  */
11697549c34SHans Petter Selasky enum {
11797549c34SHans Petter Selasky 	MLX4_STEERING_MODE_A0,
11897549c34SHans Petter Selasky 	MLX4_STEERING_MODE_B0,
11997549c34SHans Petter Selasky 	MLX4_STEERING_MODE_DEVICE_MANAGED
12097549c34SHans Petter Selasky };
12197549c34SHans Petter Selasky 
12297549c34SHans Petter Selasky static inline const char *mlx4_steering_mode_str(int steering_mode)
12397549c34SHans Petter Selasky {
12497549c34SHans Petter Selasky 	switch (steering_mode) {
12597549c34SHans Petter Selasky 	case MLX4_STEERING_MODE_A0:
12697549c34SHans Petter Selasky 		return "A0 steering";
12797549c34SHans Petter Selasky 
12897549c34SHans Petter Selasky 	case MLX4_STEERING_MODE_B0:
12997549c34SHans Petter Selasky 		return "B0 steering";
13097549c34SHans Petter Selasky 
13197549c34SHans Petter Selasky 	case MLX4_STEERING_MODE_DEVICE_MANAGED:
13297549c34SHans Petter Selasky 		return "Device managed flow steering";
13397549c34SHans Petter Selasky 
13497549c34SHans Petter Selasky 	default:
13597549c34SHans Petter Selasky 		return "Unrecognize steering mode";
13697549c34SHans Petter Selasky 	}
13797549c34SHans Petter Selasky }
13897549c34SHans Petter Selasky 
13997549c34SHans Petter Selasky enum {
14097549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_RC		= 1LL <<  0,
14197549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_UC		= 1LL <<  1,
14297549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_UD		= 1LL <<  2,
14397549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_XRC		= 1LL <<  3,
14497549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_SRQ		= 1LL <<  6,
14597549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_IPOIB_CSUM	= 1LL <<  7,
14697549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR	= 1LL <<  8,
14797549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR	= 1LL <<  9,
14897549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_DPDP		= 1LL << 12,
14997549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_BLH		= 1LL << 15,
15097549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_MEM_WINDOW	= 1LL << 16,
15197549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_APM		= 1LL << 17,
15297549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_ATOMIC	= 1LL << 18,
15397549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_RAW_MCAST	= 1LL << 19,
15497549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_UD_AV_PORT	= 1LL << 20,
15597549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_UD_MCAST	= 1LL << 21,
15697549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_IBOE		= 1LL << 30,
15797549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_UC_LOOPBACK	= 1LL << 32,
15897549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_FCS_KEEP	= 1LL << 34,
15997549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_WOL_PORT1	= 1LL << 37,
16097549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_WOL_PORT2	= 1LL << 38,
16197549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_UDP_RSS	= 1LL << 40,
16297549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_VEP_UC_STEER	= 1LL << 41,
16397549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_VEP_MC_STEER	= 1LL << 42,
16497549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_CROSS_CHANNEL	= 1LL << 44,
16597549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_COUNTERS	= 1LL << 48,
16697549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_COUNTERS_EXT	= 1LL << 49,
16797549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_SET_PORT_ETH_SCHED = 1LL << 53,
16897549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_SENSE_SUPPORT	= 1LL << 55,
16997549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_FAST_DROP	= 1LL << 57,
17097549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59,
17197549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_64B_EQE	= 1LL << 61,
17297549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG_64B_CQE	= 1LL << 62
17397549c34SHans Petter Selasky };
17497549c34SHans Petter Selasky 
17597549c34SHans Petter Selasky enum {
17697549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_RSS			= 1LL <<  0,
17797549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_RSS_TOP		= 1LL <<  1,
17897549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_RSS_XOR		= 1LL <<  2,
17997549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_FS_EN		= 1LL <<  3,
18097549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_FSM			= 1LL <<  4,
18197549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_VLAN_CONTROL		= 1LL <<  5,
18297549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_UPDATE_QP		= 1LL <<  6,
18397549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_LB_SRC_CHK		= 1LL <<  7,
18497549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_DMFS_IPOIB		= 1LL <<  8,
18597549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_ETS_CFG		= 1LL <<  9,
18697549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP	= 1LL <<  10,
18797549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN		= 1LL <<  11,
18897549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 12,
18997549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_TS			= 1LL <<  13,
19097549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW	   = 1LL <<  14,
19197549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_REASSIGN_MAC_EN	= 1LL <<  15,
19297549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS	= 1LL <<  16,
19397549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_FS_EN_NCSI		= 1LL <<  17,
19497549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_80_VFS		= 1LL <<  18,
19597549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_DMFS_TAG_MODE	= 1LL <<  19,
19697549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_ROCEV2		= 1LL <<  20,
19797549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL	= 1LL <<  21,
19897549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_CQE_STRIDE		= 1LL <<  22,
19997549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_EQE_STRIDE		= 1LL <<  23,
20097549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB = 1LL << 24,
20197549c34SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_RX_CSUM_MODE		= 1LL <<  25,
202*2cebcdc7SHans Petter Selasky 	MLX4_DEV_CAP_FLAG2_SYS_EQS		= 1LL <<  26,
20397549c34SHans Petter Selasky };
20497549c34SHans Petter Selasky 
20597549c34SHans Petter Selasky /* bit enums for an 8-bit flags field indicating special use
20697549c34SHans Petter Selasky  * QPs which require special handling in qp_reserve_range.
20797549c34SHans Petter Selasky  * Currently, this only includes QPs used by the ETH interface,
20897549c34SHans Petter Selasky  * where we expect to use blueflame.  These QPs must not have
20997549c34SHans Petter Selasky  * bits 6 and 7 set in their qp number.
21097549c34SHans Petter Selasky  *
21197549c34SHans Petter Selasky  * This enum may use only bits 0..7.
21297549c34SHans Petter Selasky  */
21397549c34SHans Petter Selasky enum {
21497549c34SHans Petter Selasky 	MLX4_RESERVE_BF_QP	= 1 << 7,
21597549c34SHans Petter Selasky };
21697549c34SHans Petter Selasky 
21797549c34SHans Petter Selasky enum {
21897549c34SHans Petter Selasky 	MLX4_DEV_CAP_CQ_FLAG_IO			= 1 <<  0
21997549c34SHans Petter Selasky };
22097549c34SHans Petter Selasky 
22197549c34SHans Petter Selasky enum {
22297549c34SHans Petter Selasky 	MLX4_DEV_CAP_64B_EQE_ENABLED	= 1LL << 0,
22397549c34SHans Petter Selasky 	MLX4_DEV_CAP_64B_CQE_ENABLED	= 1LL << 1
22497549c34SHans Petter Selasky };
22597549c34SHans Petter Selasky 
22697549c34SHans Petter Selasky enum {
22797549c34SHans Petter Selasky 	MLX4_USER_DEV_CAP_64B_CQE	= 1L << 0
22897549c34SHans Petter Selasky };
22997549c34SHans Petter Selasky 
23097549c34SHans Petter Selasky enum {
23197549c34SHans Petter Selasky 	MLX4_FUNC_CAP_64B_EQE_CQE	= 1L << 0
23297549c34SHans Petter Selasky };
23397549c34SHans Petter Selasky 
23497549c34SHans Petter Selasky 
23597549c34SHans Petter Selasky #define MLX4_ATTR_EXTENDED_PORT_INFO	cpu_to_be16(0xff90)
23697549c34SHans Petter Selasky 
23797549c34SHans Petter Selasky enum {
23897549c34SHans Petter Selasky 	MLX4_BMME_FLAG_WIN_TYPE_2B	= 1 << 1,
23997549c34SHans Petter Selasky 	MLX4_BMME_FLAG_LOCAL_INV	= 1 <<  6,
24097549c34SHans Petter Selasky 	MLX4_BMME_FLAG_REMOTE_INV	= 1 <<  7,
24197549c34SHans Petter Selasky 	MLX4_BMME_FLAG_TYPE_2_WIN	= 1 <<  9,
24297549c34SHans Petter Selasky 	MLX4_BMME_FLAG_RESERVED_LKEY	= 1 << 10,
24397549c34SHans Petter Selasky 	MLX4_BMME_FLAG_FAST_REG_WR	= 1 << 11,
24497549c34SHans Petter Selasky };
24597549c34SHans Petter Selasky 
24697549c34SHans Petter Selasky enum mlx4_event {
24797549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_COMP		   = 0x00,
24897549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_PATH_MIG	   = 0x01,
24997549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_COMM_EST	   = 0x02,
25097549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_SQ_DRAINED	   = 0x03,
25197549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_SRQ_QP_LAST_WQE	   = 0x13,
25297549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_SRQ_LIMIT	   = 0x14,
25397549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_CQ_ERROR	   = 0x04,
25497549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_WQ_CATAS_ERROR	   = 0x05,
25597549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_EEC_CATAS_ERROR	   = 0x06,
25697549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_PATH_MIG_FAILED	   = 0x07,
25797549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10,
25897549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_WQ_ACCESS_ERROR	   = 0x11,
25997549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_SRQ_CATAS_ERROR	   = 0x12,
26097549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_LOCAL_CATAS_ERROR  = 0x08,
26197549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_PORT_CHANGE	   = 0x09,
26297549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_EQ_OVERFLOW	   = 0x0f,
26397549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_ECC_DETECT	   = 0x0e,
26497549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_CMD		   = 0x0a,
26597549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_VEP_UPDATE	   = 0x19,
26697549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_COMM_CHANNEL	   = 0x18,
26797549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_OP_REQUIRED	   = 0x1a,
26897549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_FATAL_WARNING	   = 0x1b,
26997549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_FLR_EVENT	   = 0x1c,
27097549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT = 0x1d,
27197549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_RECOVERABLE_ERROR_EVENT  = 0x3e,
27297549c34SHans Petter Selasky 	MLX4_EVENT_TYPE_NONE		   = 0xff,
27397549c34SHans Petter Selasky };
27497549c34SHans Petter Selasky 
27597549c34SHans Petter Selasky enum {
27697549c34SHans Petter Selasky 	MLX4_PORT_CHANGE_SUBTYPE_DOWN	= 1,
27797549c34SHans Petter Selasky 	MLX4_PORT_CHANGE_SUBTYPE_ACTIVE	= 4
27897549c34SHans Petter Selasky };
27997549c34SHans Petter Selasky 
28097549c34SHans Petter Selasky enum {
28197549c34SHans Petter Selasky 	MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_BAD_CABLE		= 1,
28297549c34SHans Petter Selasky 	MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_UNSUPPORTED_CABLE	= 2,
28397549c34SHans Petter Selasky };
28497549c34SHans Petter Selasky 
28597549c34SHans Petter Selasky enum {
28697549c34SHans Petter Selasky 	MLX4_FATAL_WARNING_SUBTYPE_WARMING = 0,
28797549c34SHans Petter Selasky };
28897549c34SHans Petter Selasky 
28997549c34SHans Petter Selasky enum slave_port_state {
29097549c34SHans Petter Selasky 	SLAVE_PORT_DOWN = 0,
29197549c34SHans Petter Selasky 	SLAVE_PENDING_UP,
29297549c34SHans Petter Selasky 	SLAVE_PORT_UP,
29397549c34SHans Petter Selasky };
29497549c34SHans Petter Selasky 
29597549c34SHans Petter Selasky enum slave_port_gen_event {
29697549c34SHans Petter Selasky 	SLAVE_PORT_GEN_EVENT_DOWN = 0,
29797549c34SHans Petter Selasky 	SLAVE_PORT_GEN_EVENT_UP,
29897549c34SHans Petter Selasky 	SLAVE_PORT_GEN_EVENT_NONE,
29997549c34SHans Petter Selasky };
30097549c34SHans Petter Selasky 
30197549c34SHans Petter Selasky enum slave_port_state_event {
30297549c34SHans Petter Selasky 	MLX4_PORT_STATE_DEV_EVENT_PORT_DOWN,
30397549c34SHans Petter Selasky 	MLX4_PORT_STATE_DEV_EVENT_PORT_UP,
30497549c34SHans Petter Selasky 	MLX4_PORT_STATE_IB_PORT_STATE_EVENT_GID_VALID,
30597549c34SHans Petter Selasky 	MLX4_PORT_STATE_IB_EVENT_GID_INVALID,
30697549c34SHans Petter Selasky };
30797549c34SHans Petter Selasky 
30897549c34SHans Petter Selasky enum {
30997549c34SHans Petter Selasky 	MLX4_PERM_LOCAL_READ	= 1 << 10,
31097549c34SHans Petter Selasky 	MLX4_PERM_LOCAL_WRITE	= 1 << 11,
31197549c34SHans Petter Selasky 	MLX4_PERM_REMOTE_READ	= 1 << 12,
31297549c34SHans Petter Selasky 	MLX4_PERM_REMOTE_WRITE	= 1 << 13,
31397549c34SHans Petter Selasky 	MLX4_PERM_ATOMIC	= 1 << 14,
31497549c34SHans Petter Selasky 	MLX4_PERM_BIND_MW	= 1 << 15,
31597549c34SHans Petter Selasky };
31697549c34SHans Petter Selasky 
31797549c34SHans Petter Selasky enum {
31897549c34SHans Petter Selasky 	MLX4_OPCODE_NOP			= 0x00,
31997549c34SHans Petter Selasky 	MLX4_OPCODE_SEND_INVAL		= 0x01,
32097549c34SHans Petter Selasky 	MLX4_OPCODE_RDMA_WRITE		= 0x08,
32197549c34SHans Petter Selasky 	MLX4_OPCODE_RDMA_WRITE_IMM	= 0x09,
32297549c34SHans Petter Selasky 	MLX4_OPCODE_SEND		= 0x0a,
32397549c34SHans Petter Selasky 	MLX4_OPCODE_SEND_IMM		= 0x0b,
32497549c34SHans Petter Selasky 	MLX4_OPCODE_LSO			= 0x0e,
32597549c34SHans Petter Selasky 	MLX4_OPCODE_RDMA_READ		= 0x10,
32697549c34SHans Petter Selasky 	MLX4_OPCODE_ATOMIC_CS		= 0x11,
32797549c34SHans Petter Selasky 	MLX4_OPCODE_ATOMIC_FA		= 0x12,
32897549c34SHans Petter Selasky 	MLX4_OPCODE_MASKED_ATOMIC_CS	= 0x14,
32997549c34SHans Petter Selasky 	MLX4_OPCODE_MASKED_ATOMIC_FA	= 0x15,
33097549c34SHans Petter Selasky 	MLX4_OPCODE_BIND_MW		= 0x18,
33197549c34SHans Petter Selasky 	MLX4_OPCODE_FMR			= 0x19,
33297549c34SHans Petter Selasky 	MLX4_OPCODE_LOCAL_INVAL		= 0x1b,
33397549c34SHans Petter Selasky 	MLX4_OPCODE_CONFIG_CMD		= 0x1f,
33497549c34SHans Petter Selasky 
33597549c34SHans Petter Selasky 	MLX4_RECV_OPCODE_RDMA_WRITE_IMM	= 0x00,
33697549c34SHans Petter Selasky 	MLX4_RECV_OPCODE_SEND		= 0x01,
33797549c34SHans Petter Selasky 	MLX4_RECV_OPCODE_SEND_IMM	= 0x02,
33897549c34SHans Petter Selasky 	MLX4_RECV_OPCODE_SEND_INVAL	= 0x03,
33997549c34SHans Petter Selasky 
34097549c34SHans Petter Selasky 	MLX4_CQE_OPCODE_ERROR		= 0x1e,
34197549c34SHans Petter Selasky 	MLX4_CQE_OPCODE_RESIZE		= 0x16,
34297549c34SHans Petter Selasky };
34397549c34SHans Petter Selasky 
34497549c34SHans Petter Selasky enum {
34597549c34SHans Petter Selasky 	MLX4_STAT_RATE_OFFSET	= 5
34697549c34SHans Petter Selasky };
34797549c34SHans Petter Selasky 
34897549c34SHans Petter Selasky enum mlx4_protocol {
34997549c34SHans Petter Selasky 	MLX4_PROT_IB_IPV6 = 0,
35097549c34SHans Petter Selasky 	MLX4_PROT_ETH,
35197549c34SHans Petter Selasky 	MLX4_PROT_IB_IPV4,
35297549c34SHans Petter Selasky 	MLX4_PROT_FCOE
35397549c34SHans Petter Selasky };
35497549c34SHans Petter Selasky 
35597549c34SHans Petter Selasky enum {
35697549c34SHans Petter Selasky 	MLX4_MTT_FLAG_PRESENT		= 1
35797549c34SHans Petter Selasky };
35897549c34SHans Petter Selasky 
35997549c34SHans Petter Selasky enum {
36097549c34SHans Petter Selasky 	MLX4_MAX_MTT_SHIFT		= 31
36197549c34SHans Petter Selasky };
36297549c34SHans Petter Selasky 
36397549c34SHans Petter Selasky enum mlx4_qp_region {
36497549c34SHans Petter Selasky 	MLX4_QP_REGION_FW = 0,
36597549c34SHans Petter Selasky 	MLX4_QP_REGION_ETH_ADDR,
36697549c34SHans Petter Selasky 	MLX4_QP_REGION_FC_ADDR,
36797549c34SHans Petter Selasky 	MLX4_QP_REGION_FC_EXCH,
36897549c34SHans Petter Selasky 	MLX4_NUM_QP_REGION
36997549c34SHans Petter Selasky };
37097549c34SHans Petter Selasky 
37197549c34SHans Petter Selasky enum mlx4_port_type {
37297549c34SHans Petter Selasky 	MLX4_PORT_TYPE_NONE	= 0,
37397549c34SHans Petter Selasky 	MLX4_PORT_TYPE_IB	= 1,
37497549c34SHans Petter Selasky 	MLX4_PORT_TYPE_ETH	= 2,
37597549c34SHans Petter Selasky 	MLX4_PORT_TYPE_AUTO	= 3,
37697549c34SHans Petter Selasky 	MLX4_PORT_TYPE_NA	= 4
37797549c34SHans Petter Selasky };
37897549c34SHans Petter Selasky 
37997549c34SHans Petter Selasky enum mlx4_special_vlan_idx {
38097549c34SHans Petter Selasky 	MLX4_NO_VLAN_IDX        = 0,
38197549c34SHans Petter Selasky 	MLX4_VLAN_MISS_IDX,
38297549c34SHans Petter Selasky 	MLX4_VLAN_REGULAR
38397549c34SHans Petter Selasky };
38497549c34SHans Petter Selasky 
38597549c34SHans Petter Selasky enum mlx4_steer_type {
38697549c34SHans Petter Selasky 	MLX4_MC_STEER = 0,
38797549c34SHans Petter Selasky 	MLX4_UC_STEER,
38897549c34SHans Petter Selasky 	MLX4_NUM_STEERS
38997549c34SHans Petter Selasky };
39097549c34SHans Petter Selasky 
39197549c34SHans Petter Selasky enum {
39297549c34SHans Petter Selasky 	MLX4_NUM_FEXCH          = 64 * 1024,
39397549c34SHans Petter Selasky };
39497549c34SHans Petter Selasky 
39597549c34SHans Petter Selasky enum {
39697549c34SHans Petter Selasky 	MLX4_MAX_FAST_REG_PAGES = 511,
39797549c34SHans Petter Selasky };
39897549c34SHans Petter Selasky 
39997549c34SHans Petter Selasky enum {
40097549c34SHans Petter Selasky 	MLX4_DEV_PMC_SUBTYPE_GUID_INFO	 = 0x14,
40197549c34SHans Petter Selasky 	MLX4_DEV_PMC_SUBTYPE_PORT_INFO	 = 0x15,
40297549c34SHans Petter Selasky 	MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE	 = 0x16,
40397549c34SHans Petter Selasky };
40497549c34SHans Petter Selasky 
40597549c34SHans Petter Selasky /* Port mgmt change event handling */
40697549c34SHans Petter Selasky enum {
40797549c34SHans Petter Selasky 	MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK	= 1 << 0,
40897549c34SHans Petter Selasky 	MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK		= 1 << 1,
40997549c34SHans Petter Selasky 	MLX4_EQ_PORT_INFO_LID_CHANGE_MASK		= 1 << 2,
41097549c34SHans Petter Selasky 	MLX4_EQ_PORT_INFO_CLIENT_REREG_MASK		= 1 << 3,
41197549c34SHans Petter Selasky 	MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK	= 1 << 4,
41297549c34SHans Petter Selasky };
41397549c34SHans Petter Selasky 
41497549c34SHans Petter Selasky #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
41597549c34SHans Petter Selasky 			     MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK)
41697549c34SHans Petter Selasky 
41797549c34SHans Petter Selasky enum mlx4_module_id {
41897549c34SHans Petter Selasky 	MLX4_MODULE_ID_SFP		= 0x3,
41997549c34SHans Petter Selasky 	MLX4_MODULE_ID_QSFP		= 0xC,
42097549c34SHans Petter Selasky 	MLX4_MODULE_ID_QSFP_PLUS	= 0xD,
42197549c34SHans Petter Selasky 	MLX4_MODULE_ID_QSFP28		= 0x11,
42297549c34SHans Petter Selasky };
42397549c34SHans Petter Selasky 
42497549c34SHans Petter Selasky static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
42597549c34SHans Petter Selasky {
42697549c34SHans Petter Selasky 	return (major << 32) | (minor << 16) | subminor;
42797549c34SHans Petter Selasky }
42897549c34SHans Petter Selasky 
42997549c34SHans Petter Selasky struct mlx4_phys_caps {
43097549c34SHans Petter Selasky 	u32			gid_phys_table_len[MLX4_MAX_PORTS + 1];
43197549c34SHans Petter Selasky 	u32			pkey_phys_table_len[MLX4_MAX_PORTS + 1];
43297549c34SHans Petter Selasky 	u32			num_phys_eqs;
43397549c34SHans Petter Selasky 	u32			base_sqpn;
43497549c34SHans Petter Selasky 	u32			base_proxy_sqpn;
43597549c34SHans Petter Selasky 	u32			base_tunnel_sqpn;
43697549c34SHans Petter Selasky };
43797549c34SHans Petter Selasky 
43897549c34SHans Petter Selasky struct mlx4_caps {
43997549c34SHans Petter Selasky 	u64			fw_ver;
44097549c34SHans Petter Selasky 	u32			function;
44197549c34SHans Petter Selasky 	int			num_ports;
44297549c34SHans Petter Selasky 	int			vl_cap[MLX4_MAX_PORTS + 1];
44397549c34SHans Petter Selasky 	int			ib_mtu_cap[MLX4_MAX_PORTS + 1];
44497549c34SHans Petter Selasky 	__be32			ib_port_def_cap[MLX4_MAX_PORTS + 1];
44597549c34SHans Petter Selasky 	u64			def_mac[MLX4_MAX_PORTS + 1];
44697549c34SHans Petter Selasky 	int			eth_mtu_cap[MLX4_MAX_PORTS + 1];
44797549c34SHans Petter Selasky 	int			gid_table_len[MLX4_MAX_PORTS + 1];
44897549c34SHans Petter Selasky 	int			pkey_table_len[MLX4_MAX_PORTS + 1];
44997549c34SHans Petter Selasky 	int			trans_type[MLX4_MAX_PORTS + 1];
45097549c34SHans Petter Selasky 	int			vendor_oui[MLX4_MAX_PORTS + 1];
45197549c34SHans Petter Selasky 	int			wavelength[MLX4_MAX_PORTS + 1];
45297549c34SHans Petter Selasky 	u64			trans_code[MLX4_MAX_PORTS + 1];
45397549c34SHans Petter Selasky 	int			local_ca_ack_delay;
45497549c34SHans Petter Selasky 	int			num_uars;
45597549c34SHans Petter Selasky 	u32			uar_page_size;
45697549c34SHans Petter Selasky 	int			bf_reg_size;
45797549c34SHans Petter Selasky 	int			bf_regs_per_page;
45897549c34SHans Petter Selasky 	int			max_sq_sg;
45997549c34SHans Petter Selasky 	int			max_rq_sg;
46097549c34SHans Petter Selasky 	int			num_qps;
46197549c34SHans Petter Selasky 	int			max_wqes;
46297549c34SHans Petter Selasky 	int			max_sq_desc_sz;
46397549c34SHans Petter Selasky 	int			max_rq_desc_sz;
46497549c34SHans Petter Selasky 	int			max_qp_init_rdma;
46597549c34SHans Petter Selasky 	int			max_qp_dest_rdma;
46697549c34SHans Petter Selasky 	u32			*qp0_proxy;
46797549c34SHans Petter Selasky 	u32			*qp1_proxy;
46897549c34SHans Petter Selasky 	u32			*qp0_tunnel;
46997549c34SHans Petter Selasky 	u32			*qp1_tunnel;
47097549c34SHans Petter Selasky 	int			num_srqs;
47197549c34SHans Petter Selasky 	int			max_srq_wqes;
47297549c34SHans Petter Selasky 	int			max_srq_sge;
47397549c34SHans Petter Selasky 	int			reserved_srqs;
47497549c34SHans Petter Selasky 	int			num_cqs;
47597549c34SHans Petter Selasky 	int			max_cqes;
47697549c34SHans Petter Selasky 	int			reserved_cqs;
477*2cebcdc7SHans Petter Selasky 	int			num_sys_eqs;
47897549c34SHans Petter Selasky 	int			num_eqs;
47997549c34SHans Petter Selasky 	int			reserved_eqs;
48097549c34SHans Petter Selasky 	int			num_comp_vectors;
48197549c34SHans Petter Selasky 	int			comp_pool;
48297549c34SHans Petter Selasky 	int			num_mpts;
48397549c34SHans Petter Selasky 	int			max_fmr_maps;
48497549c34SHans Petter Selasky 	u64			num_mtts;
48597549c34SHans Petter Selasky 	int			fmr_reserved_mtts;
48697549c34SHans Petter Selasky 	int			reserved_mtts;
48797549c34SHans Petter Selasky 	int			reserved_mrws;
48897549c34SHans Petter Selasky 	int			reserved_uars;
48997549c34SHans Petter Selasky 	int			num_mgms;
49097549c34SHans Petter Selasky 	int			num_amgms;
49197549c34SHans Petter Selasky 	int			reserved_mcgs;
49297549c34SHans Petter Selasky 	int			num_qp_per_mgm;
49397549c34SHans Petter Selasky 	int			steering_mode;
49497549c34SHans Petter Selasky 	int			num_pds;
49597549c34SHans Petter Selasky 	int			reserved_pds;
49697549c34SHans Petter Selasky 	int			max_xrcds;
49797549c34SHans Petter Selasky 	int			reserved_xrcds;
49897549c34SHans Petter Selasky 	int			mtt_entry_sz;
49997549c34SHans Petter Selasky 	u32			max_msg_sz;
50097549c34SHans Petter Selasky 	u32			page_size_cap;
50197549c34SHans Petter Selasky 	u64			flags;
50297549c34SHans Petter Selasky 	u64			flags2;
50397549c34SHans Petter Selasky 	u32			bmme_flags;
50497549c34SHans Petter Selasky 	u32			reserved_lkey;
50597549c34SHans Petter Selasky 	u16			stat_rate_support;
50697549c34SHans Petter Selasky 	u8			cq_timestamp;
50797549c34SHans Petter Selasky 	u8			port_width_cap[MLX4_MAX_PORTS + 1];
50897549c34SHans Petter Selasky 	int			max_gso_sz;
50997549c34SHans Petter Selasky 	int			max_rss_tbl_sz;
51097549c34SHans Petter Selasky 	int                     reserved_qps_cnt[MLX4_NUM_QP_REGION];
51197549c34SHans Petter Selasky 	int			reserved_qps;
51297549c34SHans Petter Selasky 	int                     reserved_qps_base[MLX4_NUM_QP_REGION];
51397549c34SHans Petter Selasky 	int                     log_num_macs;
51497549c34SHans Petter Selasky 	int                     log_num_vlans;
51597549c34SHans Petter Selasky 	enum mlx4_port_type	port_type[MLX4_MAX_PORTS + 1];
51697549c34SHans Petter Selasky 	u8			supported_type[MLX4_MAX_PORTS + 1];
51797549c34SHans Petter Selasky 	u8                      suggested_type[MLX4_MAX_PORTS + 1];
51897549c34SHans Petter Selasky 	u8                      default_sense[MLX4_MAX_PORTS + 1];
51997549c34SHans Petter Selasky 	u32			port_mask[MLX4_MAX_PORTS + 1];
52097549c34SHans Petter Selasky 	enum mlx4_port_type	possible_type[MLX4_MAX_PORTS + 1];
52197549c34SHans Petter Selasky 	u32			max_counters;
52297549c34SHans Petter Selasky 	u8			port_ib_mtu[MLX4_MAX_PORTS + 1];
52397549c34SHans Petter Selasky 	u16			sqp_demux;
52497549c34SHans Petter Selasky 	u32			sync_qp;
52597549c34SHans Petter Selasky 	u32			cq_flags;
52697549c34SHans Petter Selasky 	u32			eqe_size;
52797549c34SHans Petter Selasky 	u32			cqe_size;
52897549c34SHans Petter Selasky 	u8			eqe_factor;
52997549c34SHans Petter Selasky 	u32			userspace_caps; /* userspace must be aware to */
53097549c34SHans Petter Selasky 	u32			function_caps;  /* functions must be aware to */
53197549c34SHans Petter Selasky 	u8			fast_drop;
53297549c34SHans Petter Selasky 	u16			hca_core_clock;
53397549c34SHans Petter Selasky 	u32			max_basic_counters;
53497549c34SHans Petter Selasky 	u32			max_extended_counters;
53597549c34SHans Petter Selasky 	u8			def_counter_index[MLX4_MAX_PORTS + 1];
53697549c34SHans Petter Selasky };
53797549c34SHans Petter Selasky 
53897549c34SHans Petter Selasky struct mlx4_buf_list {
53997549c34SHans Petter Selasky 	void		       *buf;
54097549c34SHans Petter Selasky 	dma_addr_t		map;
54197549c34SHans Petter Selasky };
54297549c34SHans Petter Selasky 
54397549c34SHans Petter Selasky struct mlx4_buf {
54497549c34SHans Petter Selasky 	struct mlx4_buf_list	direct;
54597549c34SHans Petter Selasky 	struct mlx4_buf_list   *page_list;
54697549c34SHans Petter Selasky 	int			nbufs;
54797549c34SHans Petter Selasky 	int			npages;
54897549c34SHans Petter Selasky 	int			page_shift;
54997549c34SHans Petter Selasky };
55097549c34SHans Petter Selasky 
55197549c34SHans Petter Selasky struct mlx4_mtt {
55297549c34SHans Petter Selasky 	u32			offset;
55397549c34SHans Petter Selasky 	int			order;
55497549c34SHans Petter Selasky 	int			page_shift;
55597549c34SHans Petter Selasky };
55697549c34SHans Petter Selasky 
55797549c34SHans Petter Selasky enum {
55897549c34SHans Petter Selasky 	MLX4_DB_PER_PAGE = PAGE_SIZE / 4
55997549c34SHans Petter Selasky };
56097549c34SHans Petter Selasky 
56197549c34SHans Petter Selasky struct mlx4_db_pgdir {
56297549c34SHans Petter Selasky 	struct list_head	list;
56397549c34SHans Petter Selasky 	DECLARE_BITMAP(order0, MLX4_DB_PER_PAGE);
56497549c34SHans Petter Selasky 	DECLARE_BITMAP(order1, MLX4_DB_PER_PAGE / 2);
56597549c34SHans Petter Selasky 	unsigned long	       *bits[2];
56697549c34SHans Petter Selasky 	__be32		       *db_page;
56797549c34SHans Petter Selasky 	dma_addr_t		db_dma;
56897549c34SHans Petter Selasky };
56997549c34SHans Petter Selasky 
57097549c34SHans Petter Selasky struct mlx4_ib_user_db_page;
57197549c34SHans Petter Selasky 
57297549c34SHans Petter Selasky struct mlx4_db {
57397549c34SHans Petter Selasky 	__be32			*db;
57497549c34SHans Petter Selasky 	union {
57597549c34SHans Petter Selasky 		struct mlx4_db_pgdir		*pgdir;
57697549c34SHans Petter Selasky 		struct mlx4_ib_user_db_page	*user_page;
57797549c34SHans Petter Selasky 	}			u;
57897549c34SHans Petter Selasky 	dma_addr_t		dma;
57997549c34SHans Petter Selasky 	int			index;
58097549c34SHans Petter Selasky 	int			order;
58197549c34SHans Petter Selasky };
58297549c34SHans Petter Selasky 
58397549c34SHans Petter Selasky struct mlx4_hwq_resources {
58497549c34SHans Petter Selasky 	struct mlx4_db		db;
58597549c34SHans Petter Selasky 	struct mlx4_mtt		mtt;
58697549c34SHans Petter Selasky 	struct mlx4_buf		buf;
58797549c34SHans Petter Selasky };
58897549c34SHans Petter Selasky 
58997549c34SHans Petter Selasky struct mlx4_mr {
59097549c34SHans Petter Selasky 	struct mlx4_mtt		mtt;
59197549c34SHans Petter Selasky 	u64			iova;
59297549c34SHans Petter Selasky 	u64			size;
59397549c34SHans Petter Selasky 	u32			key;
59497549c34SHans Petter Selasky 	u32			pd;
59597549c34SHans Petter Selasky 	u32			access;
59697549c34SHans Petter Selasky 	int			enabled;
59797549c34SHans Petter Selasky };
59897549c34SHans Petter Selasky 
59997549c34SHans Petter Selasky enum mlx4_mw_type {
60097549c34SHans Petter Selasky 	MLX4_MW_TYPE_1 = 1,
60197549c34SHans Petter Selasky 	MLX4_MW_TYPE_2 = 2,
60297549c34SHans Petter Selasky };
60397549c34SHans Petter Selasky 
60497549c34SHans Petter Selasky struct mlx4_mw {
60597549c34SHans Petter Selasky 	u32			key;
60697549c34SHans Petter Selasky 	u32			pd;
60797549c34SHans Petter Selasky 	enum mlx4_mw_type	type;
60897549c34SHans Petter Selasky 	int			enabled;
60997549c34SHans Petter Selasky };
61097549c34SHans Petter Selasky 
61197549c34SHans Petter Selasky struct mlx4_fmr {
61297549c34SHans Petter Selasky 	struct mlx4_mr		mr;
61397549c34SHans Petter Selasky 	struct mlx4_mpt_entry  *mpt;
61497549c34SHans Petter Selasky 	__be64		       *mtts;
61597549c34SHans Petter Selasky 	dma_addr_t		dma_handle;
61697549c34SHans Petter Selasky 	int			max_pages;
61797549c34SHans Petter Selasky 	int			max_maps;
61897549c34SHans Petter Selasky 	int			maps;
61997549c34SHans Petter Selasky 	u8			page_shift;
62097549c34SHans Petter Selasky };
62197549c34SHans Petter Selasky 
62297549c34SHans Petter Selasky struct mlx4_uar {
62397549c34SHans Petter Selasky 	unsigned long		pfn;
62497549c34SHans Petter Selasky 	int			index;
62597549c34SHans Petter Selasky 	struct list_head	bf_list;
62697549c34SHans Petter Selasky 	unsigned		free_bf_bmap;
62797549c34SHans Petter Selasky 	void __iomem	       *map;
62897549c34SHans Petter Selasky 	void __iomem	       *bf_map;
62997549c34SHans Petter Selasky };
63097549c34SHans Petter Selasky 
63197549c34SHans Petter Selasky struct mlx4_bf {
63297549c34SHans Petter Selasky 	unsigned long		offset;
63397549c34SHans Petter Selasky 	int			buf_size;
63497549c34SHans Petter Selasky 	struct mlx4_uar	       *uar;
63597549c34SHans Petter Selasky 	void __iomem	       *reg;
63697549c34SHans Petter Selasky };
63797549c34SHans Petter Selasky 
63897549c34SHans Petter Selasky struct mlx4_cq {
63997549c34SHans Petter Selasky 	void (*comp)		(struct mlx4_cq *);
64097549c34SHans Petter Selasky 	void (*event)		(struct mlx4_cq *, enum mlx4_event);
64197549c34SHans Petter Selasky 
64297549c34SHans Petter Selasky 	struct mlx4_uar	       *uar;
64397549c34SHans Petter Selasky 
64497549c34SHans Petter Selasky 	u32			cons_index;
64597549c34SHans Petter Selasky 
64697549c34SHans Petter Selasky 	__be32		       *set_ci_db;
64797549c34SHans Petter Selasky 	__be32		       *arm_db;
64897549c34SHans Petter Selasky 	int			arm_sn;
64997549c34SHans Petter Selasky 
65097549c34SHans Petter Selasky 	int			cqn;
65197549c34SHans Petter Selasky 	unsigned		vector;
65297549c34SHans Petter Selasky 
65397549c34SHans Petter Selasky 	atomic_t		refcount;
65497549c34SHans Petter Selasky 	struct completion	free;
65597549c34SHans Petter Selasky 	int			eqn;
65697549c34SHans Petter Selasky 	u16			irq;
65797549c34SHans Petter Selasky };
65897549c34SHans Petter Selasky 
65997549c34SHans Petter Selasky struct mlx4_qp {
66097549c34SHans Petter Selasky 	void (*event)		(struct mlx4_qp *, enum mlx4_event);
66197549c34SHans Petter Selasky 
66297549c34SHans Petter Selasky 	int			qpn;
66397549c34SHans Petter Selasky 
66497549c34SHans Petter Selasky 	atomic_t		refcount;
66597549c34SHans Petter Selasky 	struct completion	free;
66697549c34SHans Petter Selasky };
66797549c34SHans Petter Selasky 
66897549c34SHans Petter Selasky struct mlx4_srq {
66997549c34SHans Petter Selasky 	void (*event)		(struct mlx4_srq *, enum mlx4_event);
67097549c34SHans Petter Selasky 
67197549c34SHans Petter Selasky 	int			srqn;
67297549c34SHans Petter Selasky 	int			max;
67397549c34SHans Petter Selasky 	int			max_gs;
67497549c34SHans Petter Selasky 	int			wqe_shift;
67597549c34SHans Petter Selasky 
67697549c34SHans Petter Selasky 	atomic_t		refcount;
67797549c34SHans Petter Selasky 	struct completion	free;
67897549c34SHans Petter Selasky };
67997549c34SHans Petter Selasky 
68097549c34SHans Petter Selasky struct mlx4_av {
68197549c34SHans Petter Selasky 	__be32			port_pd;
68297549c34SHans Petter Selasky 	u8			reserved1;
68397549c34SHans Petter Selasky 	u8			g_slid;
68497549c34SHans Petter Selasky 	__be16			dlid;
68597549c34SHans Petter Selasky 	u8			reserved2;
68697549c34SHans Petter Selasky 	u8			gid_index;
68797549c34SHans Petter Selasky 	u8			stat_rate;
68897549c34SHans Petter Selasky 	u8			hop_limit;
68997549c34SHans Petter Selasky 	__be32			sl_tclass_flowlabel;
69097549c34SHans Petter Selasky 	u8			dgid[16];
69197549c34SHans Petter Selasky };
69297549c34SHans Petter Selasky 
69397549c34SHans Petter Selasky struct mlx4_eth_av {
69497549c34SHans Petter Selasky 	__be32		port_pd;
69597549c34SHans Petter Selasky 	u8		reserved1;
69697549c34SHans Petter Selasky 	u8		smac_idx;
69797549c34SHans Petter Selasky 	u16		reserved2;
69897549c34SHans Petter Selasky 	u8		reserved3;
69997549c34SHans Petter Selasky 	u8		gid_index;
70097549c34SHans Petter Selasky 	u8		stat_rate;
70197549c34SHans Petter Selasky 	u8		hop_limit;
70297549c34SHans Petter Selasky 	__be32		sl_tclass_flowlabel;
70397549c34SHans Petter Selasky 	u8		dgid[16];
70497549c34SHans Petter Selasky 	u8		s_mac[6];
70597549c34SHans Petter Selasky 	u8	reserved4[2];
70697549c34SHans Petter Selasky 	__be16		vlan;
70797549c34SHans Petter Selasky 	u8		mac[6];
70897549c34SHans Petter Selasky };
70997549c34SHans Petter Selasky 
71097549c34SHans Petter Selasky union mlx4_ext_av {
71197549c34SHans Petter Selasky 	struct mlx4_av		ib;
71297549c34SHans Petter Selasky 	struct mlx4_eth_av	eth;
71397549c34SHans Petter Selasky };
71497549c34SHans Petter Selasky 
71597549c34SHans Petter Selasky struct mlx4_if_stat_control {
71697549c34SHans Petter Selasky 	u8 reserved1[3];
71797549c34SHans Petter Selasky 	/* Extended counters enabled */
71897549c34SHans Petter Selasky 	u8 cnt_mode;
71997549c34SHans Petter Selasky 	/* Number of interfaces */
72097549c34SHans Petter Selasky 	__be32 num_of_if;
72197549c34SHans Petter Selasky 	__be32 reserved[2];
72297549c34SHans Petter Selasky };
72397549c34SHans Petter Selasky 
72497549c34SHans Petter Selasky struct mlx4_if_stat_basic {
72597549c34SHans Petter Selasky 	struct mlx4_if_stat_control control;
72697549c34SHans Petter Selasky 	struct {
72797549c34SHans Petter Selasky 		__be64 IfRxFrames;
72897549c34SHans Petter Selasky 		__be64 IfRxOctets;
72997549c34SHans Petter Selasky 		__be64 IfTxFrames;
73097549c34SHans Petter Selasky 		__be64 IfTxOctets;
73197549c34SHans Petter Selasky 	} counters[];
73297549c34SHans Petter Selasky };
73397549c34SHans Petter Selasky #define MLX4_IF_STAT_BSC_SZ(ports)(sizeof(struct mlx4_if_stat_extended) +\
73497549c34SHans Petter Selasky 				   sizeof(((struct mlx4_if_stat_extended *)0)->\
73597549c34SHans Petter Selasky 				   counters[0]) * ports)
73697549c34SHans Petter Selasky 
73797549c34SHans Petter Selasky struct mlx4_if_stat_extended {
73897549c34SHans Petter Selasky 	struct mlx4_if_stat_control control;
73997549c34SHans Petter Selasky 	struct {
74097549c34SHans Petter Selasky 		__be64 IfRxUnicastFrames;
74197549c34SHans Petter Selasky 		__be64 IfRxUnicastOctets;
74297549c34SHans Petter Selasky 		__be64 IfRxMulticastFrames;
74397549c34SHans Petter Selasky 		__be64 IfRxMulticastOctets;
74497549c34SHans Petter Selasky 		__be64 IfRxBroadcastFrames;
74597549c34SHans Petter Selasky 		__be64 IfRxBroadcastOctets;
74697549c34SHans Petter Selasky 		__be64 IfRxNoBufferFrames;
74797549c34SHans Petter Selasky 		__be64 IfRxNoBufferOctets;
74897549c34SHans Petter Selasky 		__be64 IfRxErrorFrames;
74997549c34SHans Petter Selasky 		__be64 IfRxErrorOctets;
75097549c34SHans Petter Selasky 		__be32 reserved[39];
75197549c34SHans Petter Selasky 		__be64 IfTxUnicastFrames;
75297549c34SHans Petter Selasky 		__be64 IfTxUnicastOctets;
75397549c34SHans Petter Selasky 		__be64 IfTxMulticastFrames;
75497549c34SHans Petter Selasky 		__be64 IfTxMulticastOctets;
75597549c34SHans Petter Selasky 		__be64 IfTxBroadcastFrames;
75697549c34SHans Petter Selasky 		__be64 IfTxBroadcastOctets;
75797549c34SHans Petter Selasky 		__be64 IfTxDroppedFrames;
75897549c34SHans Petter Selasky 		__be64 IfTxDroppedOctets;
75997549c34SHans Petter Selasky 		__be64 IfTxRequestedFramesSent;
76097549c34SHans Petter Selasky 		__be64 IfTxGeneratedFramesSent;
76197549c34SHans Petter Selasky 		__be64 IfTxTsoOctets;
76297549c34SHans Petter Selasky 	} __packed counters[];
76397549c34SHans Petter Selasky };
76497549c34SHans Petter Selasky #define MLX4_IF_STAT_EXT_SZ(ports)   (sizeof(struct mlx4_if_stat_extended) +\
76597549c34SHans Petter Selasky 				      sizeof(((struct mlx4_if_stat_extended *)\
76697549c34SHans Petter Selasky 				      0)->counters[0]) * ports)
76797549c34SHans Petter Selasky 
76897549c34SHans Petter Selasky union mlx4_counter {
76997549c34SHans Petter Selasky 	struct mlx4_if_stat_control	control;
77097549c34SHans Petter Selasky 	struct mlx4_if_stat_basic	basic;
77197549c34SHans Petter Selasky 	struct mlx4_if_stat_extended	ext;
77297549c34SHans Petter Selasky };
77397549c34SHans Petter Selasky #define MLX4_IF_STAT_SZ(ports)		MLX4_IF_STAT_EXT_SZ(ports)
77497549c34SHans Petter Selasky 
77597549c34SHans Petter Selasky struct mlx4_quotas {
77697549c34SHans Petter Selasky 	int qp;
77797549c34SHans Petter Selasky 	int cq;
77897549c34SHans Petter Selasky 	int srq;
77997549c34SHans Petter Selasky 	int mpt;
78097549c34SHans Petter Selasky 	int mtt;
78197549c34SHans Petter Selasky 	int counter;
78297549c34SHans Petter Selasky 	int xrcd;
78397549c34SHans Petter Selasky };
78497549c34SHans Petter Selasky 
78597549c34SHans Petter Selasky struct mlx4_dev {
78697549c34SHans Petter Selasky 	struct pci_dev	       *pdev;
78797549c34SHans Petter Selasky 	unsigned long		flags;
78897549c34SHans Petter Selasky 	unsigned long		num_slaves;
78997549c34SHans Petter Selasky 	struct mlx4_caps	caps;
79097549c34SHans Petter Selasky 	struct mlx4_phys_caps	phys_caps;
79197549c34SHans Petter Selasky 	struct mlx4_quotas	quotas;
79297549c34SHans Petter Selasky 	struct radix_tree_root	qp_table_tree;
79397549c34SHans Petter Selasky 	u8			rev_id;
79497549c34SHans Petter Selasky 	char			board_id[MLX4_BOARD_ID_LEN];
79597549c34SHans Petter Selasky 	u16			vsd_vendor_id;
79697549c34SHans Petter Selasky 	char			vsd[MLX4_VSD_LEN];
79797549c34SHans Petter Selasky 	int			num_vfs;
79897549c34SHans Petter Selasky 	int			numa_node;
79997549c34SHans Petter Selasky 	int			oper_log_mgm_entry_size;
80097549c34SHans Petter Selasky 	u64			regid_promisc_array[MLX4_MAX_PORTS + 1];
80197549c34SHans Petter Selasky 	u64			regid_allmulti_array[MLX4_MAX_PORTS + 1];
80297549c34SHans Petter Selasky };
80397549c34SHans Petter Selasky 
80497549c34SHans Petter Selasky struct mlx4_clock_params {
80597549c34SHans Petter Selasky 	u64 offset;
80697549c34SHans Petter Selasky 	u8 bar;
80797549c34SHans Petter Selasky 	u8 size;
80897549c34SHans Petter Selasky };
80997549c34SHans Petter Selasky 
81097549c34SHans Petter Selasky struct mlx4_eqe {
81197549c34SHans Petter Selasky 	u8			reserved1;
81297549c34SHans Petter Selasky 	u8			type;
81397549c34SHans Petter Selasky 	u8			reserved2;
81497549c34SHans Petter Selasky 	u8			subtype;
81597549c34SHans Petter Selasky 	union {
81697549c34SHans Petter Selasky 		u32		raw[6];
81797549c34SHans Petter Selasky 		struct {
81897549c34SHans Petter Selasky 			__be32	cqn;
81997549c34SHans Petter Selasky 		} __packed comp;
82097549c34SHans Petter Selasky 		struct {
82197549c34SHans Petter Selasky 			u16	reserved1;
82297549c34SHans Petter Selasky 			__be16	token;
82397549c34SHans Petter Selasky 			u32	reserved2;
82497549c34SHans Petter Selasky 			u8	reserved3[3];
82597549c34SHans Petter Selasky 			u8	status;
82697549c34SHans Petter Selasky 			__be64	out_param;
82797549c34SHans Petter Selasky 		} __packed cmd;
82897549c34SHans Petter Selasky 		struct {
82997549c34SHans Petter Selasky 			__be32	qpn;
83097549c34SHans Petter Selasky 		} __packed qp;
83197549c34SHans Petter Selasky 		struct {
83297549c34SHans Petter Selasky 			__be32	srqn;
83397549c34SHans Petter Selasky 		} __packed srq;
83497549c34SHans Petter Selasky 		struct {
83597549c34SHans Petter Selasky 			__be32	cqn;
83697549c34SHans Petter Selasky 			u32	reserved1;
83797549c34SHans Petter Selasky 			u8	reserved2[3];
83897549c34SHans Petter Selasky 			u8	syndrome;
83997549c34SHans Petter Selasky 		} __packed cq_err;
84097549c34SHans Petter Selasky 		struct {
84197549c34SHans Petter Selasky 			u32	reserved1[2];
84297549c34SHans Petter Selasky 			__be32	port;
84397549c34SHans Petter Selasky 		} __packed port_change;
84497549c34SHans Petter Selasky 		struct {
84597549c34SHans Petter Selasky 			#define COMM_CHANNEL_BIT_ARRAY_SIZE	4
84697549c34SHans Petter Selasky 			u32 reserved;
84797549c34SHans Petter Selasky 			u32 bit_vec[COMM_CHANNEL_BIT_ARRAY_SIZE];
84897549c34SHans Petter Selasky 		} __packed comm_channel_arm;
84997549c34SHans Petter Selasky 		struct {
85097549c34SHans Petter Selasky 			u8	port;
85197549c34SHans Petter Selasky 			u8	reserved[3];
85297549c34SHans Petter Selasky 			__be64	mac;
85397549c34SHans Petter Selasky 		} __packed mac_update;
85497549c34SHans Petter Selasky 		struct {
85597549c34SHans Petter Selasky 			__be32	slave_id;
85697549c34SHans Petter Selasky 		} __packed flr_event;
85797549c34SHans Petter Selasky 		struct {
85897549c34SHans Petter Selasky 			__be16  current_temperature;
85997549c34SHans Petter Selasky 			__be16  warning_threshold;
86097549c34SHans Petter Selasky 		} __packed warming;
86197549c34SHans Petter Selasky 		struct {
86297549c34SHans Petter Selasky 			u8 reserved[3];
86397549c34SHans Petter Selasky 			u8 port;
86497549c34SHans Petter Selasky 			union {
86597549c34SHans Petter Selasky 				struct {
86697549c34SHans Petter Selasky 					__be16 mstr_sm_lid;
86797549c34SHans Petter Selasky 					__be16 port_lid;
86897549c34SHans Petter Selasky 					__be32 changed_attr;
86997549c34SHans Petter Selasky 					u8 reserved[3];
87097549c34SHans Petter Selasky 					u8 mstr_sm_sl;
87197549c34SHans Petter Selasky 					__be64 gid_prefix;
87297549c34SHans Petter Selasky 				} __packed port_info;
87397549c34SHans Petter Selasky 				struct {
87497549c34SHans Petter Selasky 					__be32 block_ptr;
87597549c34SHans Petter Selasky 					__be32 tbl_entries_mask;
87697549c34SHans Petter Selasky 				} __packed tbl_change_info;
87797549c34SHans Petter Selasky 			} params;
87897549c34SHans Petter Selasky 		} __packed port_mgmt_change;
87997549c34SHans Petter Selasky 		struct {
88097549c34SHans Petter Selasky 			u8 reserved[3];
88197549c34SHans Petter Selasky 			u8 port;
88297549c34SHans Petter Selasky 			u32 reserved1[5];
88397549c34SHans Petter Selasky 		} __packed bad_cable;
88497549c34SHans Petter Selasky 	}			event;
88597549c34SHans Petter Selasky 	u8			slave_id;
88697549c34SHans Petter Selasky 	u8			reserved3[2];
88797549c34SHans Petter Selasky 	u8			owner;
88897549c34SHans Petter Selasky } __packed;
88997549c34SHans Petter Selasky 
89097549c34SHans Petter Selasky struct mlx4_init_port_param {
89197549c34SHans Petter Selasky 	int			set_guid0;
89297549c34SHans Petter Selasky 	int			set_node_guid;
89397549c34SHans Petter Selasky 	int			set_si_guid;
89497549c34SHans Petter Selasky 	u16			mtu;
89597549c34SHans Petter Selasky 	int			port_width_cap;
89697549c34SHans Petter Selasky 	u16			vl_cap;
89797549c34SHans Petter Selasky 	u16			max_gid;
89897549c34SHans Petter Selasky 	u16			max_pkey;
89997549c34SHans Petter Selasky 	u64			guid0;
90097549c34SHans Petter Selasky 	u64			node_guid;
90197549c34SHans Petter Selasky 	u64			si_guid;
90297549c34SHans Petter Selasky };
90397549c34SHans Petter Selasky 
90497549c34SHans Petter Selasky #define MAD_IFC_DATA_SZ 192
90597549c34SHans Petter Selasky /* MAD IFC Mailbox */
90697549c34SHans Petter Selasky struct mlx4_mad_ifc {
90797549c34SHans Petter Selasky 	u8      base_version;
90897549c34SHans Petter Selasky 	u8      mgmt_class;
90997549c34SHans Petter Selasky 	u8      class_version;
91097549c34SHans Petter Selasky 	u8      method;
91197549c34SHans Petter Selasky 	__be16  status;
91297549c34SHans Petter Selasky 	__be16  class_specific;
91397549c34SHans Petter Selasky 	__be64  tid;
91497549c34SHans Petter Selasky 	__be16  attr_id;
91597549c34SHans Petter Selasky 	__be16  resv;
91697549c34SHans Petter Selasky 	__be32  attr_mod;
91797549c34SHans Petter Selasky 	__be64  mkey;
91897549c34SHans Petter Selasky 	__be16  dr_slid;
91997549c34SHans Petter Selasky 	__be16  dr_dlid;
92097549c34SHans Petter Selasky 	u8      reserved[28];
92197549c34SHans Petter Selasky 	u8      data[MAD_IFC_DATA_SZ];
92297549c34SHans Petter Selasky } __packed;
92397549c34SHans Petter Selasky 
92497549c34SHans Petter Selasky #define mlx4_foreach_port(port, dev, type)				\
92597549c34SHans Petter Selasky 	for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++)	\
92697549c34SHans Petter Selasky 		if ((type) == (dev)->caps.port_mask[(port)])
92797549c34SHans Petter Selasky 
92897549c34SHans Petter Selasky #define mlx4_foreach_non_ib_transport_port(port, dev)                     \
92997549c34SHans Petter Selasky 	for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++)	  \
93097549c34SHans Petter Selasky 		if (((dev)->caps.port_mask[port] != MLX4_PORT_TYPE_IB))
93197549c34SHans Petter Selasky 
93297549c34SHans Petter Selasky #define mlx4_foreach_ib_transport_port(port, dev)                         \
93397549c34SHans Petter Selasky 	for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++)	  \
93497549c34SHans Petter Selasky 		if (((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_IB) || \
93597549c34SHans Petter Selasky 			((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
93697549c34SHans Petter Selasky 
93797549c34SHans Petter Selasky #define MLX4_INVALID_SLAVE_ID	0xFF
93897549c34SHans Petter Selasky 
93997549c34SHans Petter Selasky #define MLX4_SINK_COUNTER_INDEX 0xff
94097549c34SHans Petter Selasky 
94197549c34SHans Petter Selasky void handle_port_mgmt_change_event(struct work_struct *work);
94297549c34SHans Petter Selasky 
94397549c34SHans Petter Selasky static inline int mlx4_master_func_num(struct mlx4_dev *dev)
94497549c34SHans Petter Selasky {
94597549c34SHans Petter Selasky 	return dev->caps.function;
94697549c34SHans Petter Selasky }
94797549c34SHans Petter Selasky 
94897549c34SHans Petter Selasky static inline int mlx4_is_master(struct mlx4_dev *dev)
94997549c34SHans Petter Selasky {
95097549c34SHans Petter Selasky 	return dev->flags & MLX4_FLAG_MASTER;
95197549c34SHans Petter Selasky }
95297549c34SHans Petter Selasky 
95397549c34SHans Petter Selasky static inline int mlx4_num_reserved_sqps(struct mlx4_dev *dev)
95497549c34SHans Petter Selasky {
95597549c34SHans Petter Selasky 	return dev->phys_caps.base_sqpn + 8 +
95697549c34SHans Petter Selasky 		16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev);
95797549c34SHans Petter Selasky }
95897549c34SHans Petter Selasky 
95997549c34SHans Petter Selasky static inline int mlx4_is_qp_reserved(struct mlx4_dev *dev, u32 qpn)
96097549c34SHans Petter Selasky {
96197549c34SHans Petter Selasky 	return (qpn < dev->phys_caps.base_sqpn + 8 +
96297549c34SHans Petter Selasky 		16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev));
96397549c34SHans Petter Selasky }
96497549c34SHans Petter Selasky 
96597549c34SHans Petter Selasky static inline int mlx4_is_guest_proxy(struct mlx4_dev *dev, int slave, u32 qpn)
96697549c34SHans Petter Selasky {
96797549c34SHans Petter Selasky 	int guest_proxy_base = dev->phys_caps.base_proxy_sqpn + slave * 8;
96897549c34SHans Petter Selasky 
96997549c34SHans Petter Selasky 	if (qpn >= guest_proxy_base && qpn < guest_proxy_base + 8)
97097549c34SHans Petter Selasky 		return 1;
97197549c34SHans Petter Selasky 
97297549c34SHans Petter Selasky 	return 0;
97397549c34SHans Petter Selasky }
97497549c34SHans Petter Selasky 
97597549c34SHans Petter Selasky static inline int mlx4_is_mfunc(struct mlx4_dev *dev)
97697549c34SHans Petter Selasky {
97797549c34SHans Petter Selasky 	return dev->flags & (MLX4_FLAG_SLAVE | MLX4_FLAG_MASTER);
97897549c34SHans Petter Selasky }
97997549c34SHans Petter Selasky 
98097549c34SHans Petter Selasky static inline int mlx4_is_slave(struct mlx4_dev *dev)
98197549c34SHans Petter Selasky {
98297549c34SHans Petter Selasky 	return dev->flags & MLX4_FLAG_SLAVE;
98397549c34SHans Petter Selasky }
98497549c34SHans Petter Selasky 
98597549c34SHans Petter Selasky int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
98697549c34SHans Petter Selasky 		   struct mlx4_buf *buf);
98797549c34SHans Petter Selasky void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf);
98897549c34SHans Petter Selasky static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset)
98997549c34SHans Petter Selasky {
99097549c34SHans Petter Selasky 	if (BITS_PER_LONG == 64 || buf->nbufs == 1)
99197549c34SHans Petter Selasky 		return (u8 *)buf->direct.buf + offset;
99297549c34SHans Petter Selasky 	else
99397549c34SHans Petter Selasky 		return (u8 *)buf->page_list[offset >> PAGE_SHIFT].buf +
99497549c34SHans Petter Selasky 			(offset & (PAGE_SIZE - 1));
99597549c34SHans Petter Selasky }
99697549c34SHans Petter Selasky 
99797549c34SHans Petter Selasky int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn);
99897549c34SHans Petter Selasky void mlx4_pd_free(struct mlx4_dev *dev, u32 pdn);
99997549c34SHans Petter Selasky int mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
100097549c34SHans Petter Selasky void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
100197549c34SHans Petter Selasky 
100297549c34SHans Petter Selasky int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar);
100397549c34SHans Petter Selasky void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar);
100497549c34SHans Petter Selasky int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, int node);
100597549c34SHans Petter Selasky void mlx4_bf_free(struct mlx4_dev *dev, struct mlx4_bf *bf);
100697549c34SHans Petter Selasky 
100797549c34SHans Petter Selasky int mlx4_mtt_init(struct mlx4_dev *dev, int npages, int page_shift,
100897549c34SHans Petter Selasky 		  struct mlx4_mtt *mtt);
100997549c34SHans Petter Selasky void mlx4_mtt_cleanup(struct mlx4_dev *dev, struct mlx4_mtt *mtt);
101097549c34SHans Petter Selasky u64 mlx4_mtt_addr(struct mlx4_dev *dev, struct mlx4_mtt *mtt);
101197549c34SHans Petter Selasky 
101297549c34SHans Petter Selasky int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access,
101397549c34SHans Petter Selasky 		  int npages, int page_shift, struct mlx4_mr *mr);
101497549c34SHans Petter Selasky int mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr);
101597549c34SHans Petter Selasky int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr);
101697549c34SHans Petter Selasky int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, enum mlx4_mw_type type,
101797549c34SHans Petter Selasky 		  struct mlx4_mw *mw);
101897549c34SHans Petter Selasky void mlx4_mw_free(struct mlx4_dev *dev, struct mlx4_mw *mw);
101997549c34SHans Petter Selasky int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw);
102097549c34SHans Petter Selasky int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
102197549c34SHans Petter Selasky 		   int start_index, int npages, u64 *page_list);
102297549c34SHans Petter Selasky int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
102397549c34SHans Petter Selasky 		       struct mlx4_buf *buf);
102497549c34SHans Petter Selasky 
102597549c34SHans Petter Selasky int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order);
102697549c34SHans Petter Selasky void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db);
102797549c34SHans Petter Selasky 
102897549c34SHans Petter Selasky int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres,
102997549c34SHans Petter Selasky 		       int size, int max_direct);
103097549c34SHans Petter Selasky void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres,
103197549c34SHans Petter Selasky 		       int size);
103297549c34SHans Petter Selasky 
103397549c34SHans Petter Selasky int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
103497549c34SHans Petter Selasky 		  struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq,
103597549c34SHans Petter Selasky 		  unsigned vector, int collapsed, int timestamp_en);
103697549c34SHans Petter Selasky void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq);
103797549c34SHans Petter Selasky 
103897549c34SHans Petter Selasky int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
103997549c34SHans Petter Selasky 			  int *base, u8 flags);
104097549c34SHans Petter Selasky void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
104197549c34SHans Petter Selasky 
104297549c34SHans Petter Selasky int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp);
104397549c34SHans Petter Selasky void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp);
104497549c34SHans Petter Selasky 
104597549c34SHans Petter Selasky int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn,
104697549c34SHans Petter Selasky 		   struct mlx4_mtt *mtt, u64 db_rec, struct mlx4_srq *srq);
104797549c34SHans Petter Selasky void mlx4_srq_free(struct mlx4_dev *dev, struct mlx4_srq *srq);
104897549c34SHans Petter Selasky int mlx4_srq_arm(struct mlx4_dev *dev, struct mlx4_srq *srq, int limit_watermark);
104997549c34SHans Petter Selasky int mlx4_srq_query(struct mlx4_dev *dev, struct mlx4_srq *srq, int *limit_watermark);
105097549c34SHans Petter Selasky 
105197549c34SHans Petter Selasky int mlx4_INIT_PORT(struct mlx4_dev *dev, int port);
105297549c34SHans Petter Selasky int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
105397549c34SHans Petter Selasky 
105497549c34SHans Petter Selasky int mlx4_unicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
105597549c34SHans Petter Selasky 			int block_mcast_loopback, enum mlx4_protocol prot);
105697549c34SHans Petter Selasky int mlx4_unicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
105797549c34SHans Petter Selasky 			enum mlx4_protocol prot);
105897549c34SHans Petter Selasky int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
105997549c34SHans Petter Selasky 			  u8 port, int block_mcast_loopback,
106097549c34SHans Petter Selasky 			  enum mlx4_protocol protocol, u64 *reg_id);
106197549c34SHans Petter Selasky int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
106297549c34SHans Petter Selasky 			  enum mlx4_protocol protocol, u64 reg_id);
106397549c34SHans Petter Selasky 
106497549c34SHans Petter Selasky enum {
106597549c34SHans Petter Selasky 	MLX4_DOMAIN_UVERBS	= 0x1000,
106697549c34SHans Petter Selasky 	MLX4_DOMAIN_ETHTOOL     = 0x2000,
106797549c34SHans Petter Selasky 	MLX4_DOMAIN_RFS         = 0x3000,
106897549c34SHans Petter Selasky 	MLX4_DOMAIN_NIC    = 0x5000,
106997549c34SHans Petter Selasky };
107097549c34SHans Petter Selasky 
107197549c34SHans Petter Selasky enum mlx4_net_trans_rule_id {
107297549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_ID_ETH = 0,
107397549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_ID_IB,
107497549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_ID_IPV6,
107597549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_ID_IPV4,
107697549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_ID_TCP,
107797549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_ID_UDP,
107897549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_NUM, /* should be last */
107997549c34SHans Petter Selasky 	MLX4_NET_TRANS_RULE_DUMMY = -1,	/* force enum to be signed */
108097549c34SHans Petter Selasky };
108197549c34SHans Petter Selasky 
108297549c34SHans Petter Selasky extern const u16 __sw_id_hw[];
108397549c34SHans Petter Selasky 
108497549c34SHans Petter Selasky static inline int map_hw_to_sw_id(u16 header_id)
108597549c34SHans Petter Selasky {
108697549c34SHans Petter Selasky 
108797549c34SHans Petter Selasky 	int i;
108897549c34SHans Petter Selasky 	for (i = 0; i < MLX4_NET_TRANS_RULE_NUM; i++) {
108997549c34SHans Petter Selasky 		if (header_id == __sw_id_hw[i])
109097549c34SHans Petter Selasky 			return i;
109197549c34SHans Petter Selasky 	}
109297549c34SHans Petter Selasky 	return -EINVAL;
109397549c34SHans Petter Selasky }
109497549c34SHans Petter Selasky 
109597549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode {
109697549c34SHans Petter Selasky 	MLX4_FS_REGULAR		= 1,
109797549c34SHans Petter Selasky 	MLX4_FS_ALL_DEFAULT,
109897549c34SHans Petter Selasky 	MLX4_FS_MC_DEFAULT,
109997549c34SHans Petter Selasky 	MLX4_FS_UC_SNIFFER,
110097549c34SHans Petter Selasky 	MLX4_FS_MC_SNIFFER,
110197549c34SHans Petter Selasky 	MLX4_FS_MODE_NUM, /* should be last */
110297549c34SHans Petter Selasky 	MLX4_FS_MODE_DUMMY = -1,	/* force enum to be signed */
110397549c34SHans Petter Selasky };
110497549c34SHans Petter Selasky 
110597549c34SHans Petter Selasky struct mlx4_spec_eth {
110697549c34SHans Petter Selasky 	u8	dst_mac[6];
110797549c34SHans Petter Selasky 	u8	dst_mac_msk[6];
110897549c34SHans Petter Selasky 	u8	src_mac[6];
110997549c34SHans Petter Selasky 	u8	src_mac_msk[6];
111097549c34SHans Petter Selasky 	u8	ether_type_enable;
111197549c34SHans Petter Selasky 	__be16	ether_type;
111297549c34SHans Petter Selasky 	__be16	vlan_id_msk;
111397549c34SHans Petter Selasky 	__be16	vlan_id;
111497549c34SHans Petter Selasky };
111597549c34SHans Petter Selasky 
111697549c34SHans Petter Selasky struct mlx4_spec_tcp_udp {
111797549c34SHans Petter Selasky 	__be16 dst_port;
111897549c34SHans Petter Selasky 	__be16 dst_port_msk;
111997549c34SHans Petter Selasky 	__be16 src_port;
112097549c34SHans Petter Selasky 	__be16 src_port_msk;
112197549c34SHans Petter Selasky };
112297549c34SHans Petter Selasky 
112397549c34SHans Petter Selasky struct mlx4_spec_ipv4 {
112497549c34SHans Petter Selasky 	__be32 dst_ip;
112597549c34SHans Petter Selasky 	__be32 dst_ip_msk;
112697549c34SHans Petter Selasky 	__be32 src_ip;
112797549c34SHans Petter Selasky 	__be32 src_ip_msk;
112897549c34SHans Petter Selasky };
112997549c34SHans Petter Selasky 
113097549c34SHans Petter Selasky struct mlx4_spec_ib {
113197549c34SHans Petter Selasky 	__be32 l3_qpn;
113297549c34SHans Petter Selasky 	__be32 qpn_msk;
113397549c34SHans Petter Selasky 	u8 dst_gid[16];
113497549c34SHans Petter Selasky 	u8 dst_gid_msk[16];
113597549c34SHans Petter Selasky };
113697549c34SHans Petter Selasky 
113797549c34SHans Petter Selasky struct mlx4_spec_list {
113897549c34SHans Petter Selasky 	struct	list_head list;
113997549c34SHans Petter Selasky 	enum	mlx4_net_trans_rule_id id;
114097549c34SHans Petter Selasky 	union {
114197549c34SHans Petter Selasky 		struct mlx4_spec_eth eth;
114297549c34SHans Petter Selasky 		struct mlx4_spec_ib ib;
114397549c34SHans Petter Selasky 		struct mlx4_spec_ipv4 ipv4;
114497549c34SHans Petter Selasky 		struct mlx4_spec_tcp_udp tcp_udp;
114597549c34SHans Petter Selasky 	};
114697549c34SHans Petter Selasky };
114797549c34SHans Petter Selasky 
114897549c34SHans Petter Selasky enum mlx4_net_trans_hw_rule_queue {
114997549c34SHans Petter Selasky 	MLX4_NET_TRANS_Q_FIFO,
115097549c34SHans Petter Selasky 	MLX4_NET_TRANS_Q_LIFO,
115197549c34SHans Petter Selasky };
115297549c34SHans Petter Selasky 
115397549c34SHans Petter Selasky struct mlx4_net_trans_rule {
115497549c34SHans Petter Selasky 	struct	list_head list;
115597549c34SHans Petter Selasky 	enum	mlx4_net_trans_hw_rule_queue queue_mode;
115697549c34SHans Petter Selasky 	bool	exclusive;
115797549c34SHans Petter Selasky 	bool	allow_loopback;
115897549c34SHans Petter Selasky 	enum	mlx4_net_trans_promisc_mode promisc_mode;
115997549c34SHans Petter Selasky 	u8	port;
116097549c34SHans Petter Selasky 	u16	priority;
116197549c34SHans Petter Selasky 	u32	qpn;
116297549c34SHans Petter Selasky };
116397549c34SHans Petter Selasky 
116497549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ctrl {
116597549c34SHans Petter Selasky 	__be16 prio;
116697549c34SHans Petter Selasky 	u8 type;
116797549c34SHans Petter Selasky 	u8 flags;
116897549c34SHans Petter Selasky 	u8 rsvd1;
116997549c34SHans Petter Selasky 	u8 funcid;
117097549c34SHans Petter Selasky 	u8 vep;
117197549c34SHans Petter Selasky 	u8 port;
117297549c34SHans Petter Selasky 	__be32 qpn;
117397549c34SHans Petter Selasky 	__be32 rsvd2;
117497549c34SHans Petter Selasky };
117597549c34SHans Petter Selasky 
117697549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ib {
117797549c34SHans Petter Selasky 	u8 size;
117897549c34SHans Petter Selasky 	u8 rsvd1;
117997549c34SHans Petter Selasky 	__be16 id;
118097549c34SHans Petter Selasky 	u32 rsvd2;
118197549c34SHans Petter Selasky 	__be32 l3_qpn;
118297549c34SHans Petter Selasky 	__be32 qpn_mask;
118397549c34SHans Petter Selasky 	u8 dst_gid[16];
118497549c34SHans Petter Selasky 	u8 dst_gid_msk[16];
118597549c34SHans Petter Selasky } __packed;
118697549c34SHans Petter Selasky 
118797549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_eth {
118897549c34SHans Petter Selasky 	u8	size;
118997549c34SHans Petter Selasky 	u8	rsvd;
119097549c34SHans Petter Selasky 	__be16	id;
119197549c34SHans Petter Selasky 	u8	rsvd1[6];
119297549c34SHans Petter Selasky 	u8	dst_mac[6];
119397549c34SHans Petter Selasky 	u16	rsvd2;
119497549c34SHans Petter Selasky 	u8	dst_mac_msk[6];
119597549c34SHans Petter Selasky 	u16	rsvd3;
119697549c34SHans Petter Selasky 	u8	src_mac[6];
119797549c34SHans Petter Selasky 	u16	rsvd4;
119897549c34SHans Petter Selasky 	u8	src_mac_msk[6];
119997549c34SHans Petter Selasky 	u8      rsvd5;
120097549c34SHans Petter Selasky 	u8      ether_type_enable;
120197549c34SHans Petter Selasky 	__be16  ether_type;
120297549c34SHans Petter Selasky 	__be16  vlan_tag_msk;
120397549c34SHans Petter Selasky 	__be16  vlan_tag;
120497549c34SHans Petter Selasky } __packed;
120597549c34SHans Petter Selasky 
120697549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_tcp_udp {
120797549c34SHans Petter Selasky 	u8	size;
120897549c34SHans Petter Selasky 	u8	rsvd;
120997549c34SHans Petter Selasky 	__be16	id;
121097549c34SHans Petter Selasky 	__be16	rsvd1[3];
121197549c34SHans Petter Selasky 	__be16	dst_port;
121297549c34SHans Petter Selasky 	__be16	rsvd2;
121397549c34SHans Petter Selasky 	__be16	dst_port_msk;
121497549c34SHans Petter Selasky 	__be16	rsvd3;
121597549c34SHans Petter Selasky 	__be16	src_port;
121697549c34SHans Petter Selasky 	__be16	rsvd4;
121797549c34SHans Petter Selasky 	__be16	src_port_msk;
121897549c34SHans Petter Selasky } __packed;
121997549c34SHans Petter Selasky 
122097549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ipv4 {
122197549c34SHans Petter Selasky 	u8	size;
122297549c34SHans Petter Selasky 	u8	rsvd;
122397549c34SHans Petter Selasky 	__be16	id;
122497549c34SHans Petter Selasky 	__be32	rsvd1;
122597549c34SHans Petter Selasky 	__be32	dst_ip;
122697549c34SHans Petter Selasky 	__be32	dst_ip_msk;
122797549c34SHans Petter Selasky 	__be32	src_ip;
122897549c34SHans Petter Selasky 	__be32	src_ip_msk;
122997549c34SHans Petter Selasky } __packed;
123097549c34SHans Petter Selasky 
123197549c34SHans Petter Selasky struct _rule_hw {
123297549c34SHans Petter Selasky 	union {
123397549c34SHans Petter Selasky 		struct {
123497549c34SHans Petter Selasky 			u8 size;
123597549c34SHans Petter Selasky 			u8 rsvd;
123697549c34SHans Petter Selasky 			__be16 id;
123797549c34SHans Petter Selasky 		};
123897549c34SHans Petter Selasky 		struct mlx4_net_trans_rule_hw_eth eth;
123997549c34SHans Petter Selasky 		struct mlx4_net_trans_rule_hw_ib ib;
124097549c34SHans Petter Selasky 		struct mlx4_net_trans_rule_hw_ipv4 ipv4;
124197549c34SHans Petter Selasky 		struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp;
124297549c34SHans Petter Selasky 	};
124397549c34SHans Petter Selasky };
124497549c34SHans Petter Selasky 
124597549c34SHans Petter Selasky int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, u32 qpn,
124697549c34SHans Petter Selasky 				enum mlx4_net_trans_promisc_mode mode);
124797549c34SHans Petter Selasky int mlx4_flow_steer_promisc_remove(struct mlx4_dev *dev, u8 port,
124897549c34SHans Petter Selasky 				   enum mlx4_net_trans_promisc_mode mode);
124997549c34SHans Petter Selasky int mlx4_multicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
125097549c34SHans Petter Selasky int mlx4_multicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
125197549c34SHans Petter Selasky int mlx4_unicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
125297549c34SHans Petter Selasky int mlx4_unicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
125397549c34SHans Petter Selasky 
125497549c34SHans Petter Selasky int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
125597549c34SHans Petter Selasky void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
125697549c34SHans Petter Selasky int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port);
125797549c34SHans Petter Selasky int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac);
125897549c34SHans Petter Selasky void mlx4_set_stats_bitmap(struct mlx4_dev *dev, unsigned long *stats_bitmap);
125997549c34SHans Petter Selasky int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
126097549c34SHans Petter Selasky 			  u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
126197549c34SHans Petter Selasky int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
126297549c34SHans Petter Selasky 			   u8 promisc);
126397549c34SHans Petter Selasky int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc);
126497549c34SHans Petter Selasky int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw,
126597549c34SHans Petter Selasky 		u8 *pg, u16 *ratelimit);
126697549c34SHans Petter Selasky int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
126797549c34SHans Petter Selasky int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
126897549c34SHans Petter Selasky void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan);
126997549c34SHans Petter Selasky 
127097549c34SHans Petter Selasky int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list,
127197549c34SHans Petter Selasky 		      int npages, u64 iova, u32 *lkey, u32 *rkey);
127297549c34SHans Petter Selasky int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
127397549c34SHans Petter Selasky 		   int max_maps, u8 page_shift, struct mlx4_fmr *fmr);
127497549c34SHans Petter Selasky int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr);
127597549c34SHans Petter Selasky void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr,
127697549c34SHans Petter Selasky 		    u32 *lkey, u32 *rkey);
127797549c34SHans Petter Selasky int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr);
127897549c34SHans Petter Selasky int mlx4_SYNC_TPT(struct mlx4_dev *dev);
127997549c34SHans Petter Selasky int mlx4_query_diag_counters(struct mlx4_dev *mlx4_dev, int array_length,
128097549c34SHans Petter Selasky 			     u8 op_modifier, u32 in_offset[],
128197549c34SHans Petter Selasky 			     u32 counter_out[]);
128297549c34SHans Petter Selasky 
128397549c34SHans Petter Selasky int mlx4_test_interrupts(struct mlx4_dev *dev);
128497549c34SHans Petter Selasky int mlx4_assign_eq(struct mlx4_dev *dev, char* name, int * vector);
128597549c34SHans Petter Selasky void mlx4_release_eq(struct mlx4_dev *dev, int vec);
128697549c34SHans Petter Selasky 
128797549c34SHans Petter Selasky int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port);
128897549c34SHans Petter Selasky int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port);
128997549c34SHans Petter Selasky 
129097549c34SHans Petter Selasky int mlx4_counter_alloc(struct mlx4_dev *dev, u8 port, u32 *idx);
129197549c34SHans Petter Selasky void mlx4_counter_free(struct mlx4_dev *dev, u8 port, u32 idx);
129297549c34SHans Petter Selasky 
129397549c34SHans Petter Selasky int mlx4_flow_attach(struct mlx4_dev *dev,
129497549c34SHans Petter Selasky 		     struct mlx4_net_trans_rule *rule, u64 *reg_id);
129597549c34SHans Petter Selasky int mlx4_flow_detach(struct mlx4_dev *dev, u64 reg_id);
129697549c34SHans Petter Selasky int map_sw_to_hw_steering_mode(struct mlx4_dev *dev,
129797549c34SHans Petter Selasky 			       enum mlx4_net_trans_promisc_mode flow_type);
129897549c34SHans Petter Selasky int map_sw_to_hw_steering_id(struct mlx4_dev *dev,
129997549c34SHans Petter Selasky 			     enum mlx4_net_trans_rule_id id);
130097549c34SHans Petter Selasky int hw_rule_sz(struct mlx4_dev *dev, enum mlx4_net_trans_rule_id id);
130197549c34SHans Petter Selasky 
130297549c34SHans Petter Selasky void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port,
130397549c34SHans Petter Selasky 			  int i, int val);
130497549c34SHans Petter Selasky 
130597549c34SHans Petter Selasky int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey);
130697549c34SHans Petter Selasky 
130797549c34SHans Petter Selasky int mlx4_is_slave_active(struct mlx4_dev *dev, int slave);
130897549c34SHans Petter Selasky int mlx4_gen_pkey_eqe(struct mlx4_dev *dev, int slave, u8 port);
130997549c34SHans Petter Selasky int mlx4_gen_guid_change_eqe(struct mlx4_dev *dev, int slave, u8 port);
131097549c34SHans Petter Selasky int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr, u16 lid, u8 sl);
131197549c34SHans Petter Selasky int mlx4_gen_port_state_change_eqe(struct mlx4_dev *dev, int slave, u8 port, u8 port_subtype_change);
131297549c34SHans Petter Selasky enum slave_port_state mlx4_get_slave_port_state(struct mlx4_dev *dev, int slave, u8 port);
131397549c34SHans Petter Selasky int set_and_calc_slave_port_state(struct mlx4_dev *dev, int slave, u8 port, int event, enum slave_port_gen_event *gen_event);
131497549c34SHans Petter Selasky 
131597549c34SHans Petter Selasky void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid);
131697549c34SHans Petter Selasky __be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave);
131797549c34SHans Petter Selasky int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid, int *slave_id);
131897549c34SHans Petter Selasky int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev, int port, int slave_id, u8 *gid);
131997549c34SHans Petter Selasky 
132097549c34SHans Petter Selasky int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn, u32 max_range_qpn);
132197549c34SHans Petter Selasky 
132297549c34SHans Petter Selasky int mlx4_read_clock(struct mlx4_dev *dev);
132397549c34SHans Petter Selasky int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
132497549c34SHans Petter Selasky 				   struct mlx4_clock_params *params);
132597549c34SHans Petter Selasky 
132697549c34SHans Petter Selasky int mlx4_get_module_info(struct mlx4_dev *dev, u8 port,
132797549c34SHans Petter Selasky 			u16 offset, u16 size, u8 *data);
132897549c34SHans Petter Selasky 
132997549c34SHans Petter Selasky #endif /* MLX4_DEVICE_H */
1330