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>
42c3191c2eSHans Petter Selasky #include <linux/if_ether.h>
43c3191c2eSHans Petter Selasky #include <linux/mutex.h>
44c3191c2eSHans Petter Selasky
4597549c34SHans Petter Selasky #include <asm/atomic.h>
4697549c34SHans Petter Selasky
4797549c34SHans Petter Selasky #include <linux/clocksource.h>
4897549c34SHans Petter Selasky
49c3191c2eSHans Petter Selasky #define DEFAULT_UAR_PAGE_SHIFT 12
50c3191c2eSHans Petter Selasky
5197549c34SHans Petter Selasky #define MAX_MSIX_P_PORT 17
5297549c34SHans Petter Selasky #define MAX_MSIX 64
5397549c34SHans Petter Selasky #define MIN_MSIX_P_PORT 5
54c3191c2eSHans Petter Selasky #define MLX4_IS_LEGACY_EQ_MODE(dev_cap) ((dev_cap).num_comp_vectors < \
55c3191c2eSHans Petter Selasky (dev_cap).num_ports * MIN_MSIX_P_PORT)
5697549c34SHans Petter Selasky
5797549c34SHans Petter Selasky #define MLX4_MAX_100M_UNITS_VAL 255 /*
5897549c34SHans Petter Selasky * work around: can't set values
5997549c34SHans Petter Selasky * greater then this value when
6097549c34SHans Petter Selasky * using 100 Mbps units.
6197549c34SHans Petter Selasky */
6297549c34SHans Petter Selasky #define MLX4_RATELIMIT_100M_UNITS 3 /* 100 Mbps */
6397549c34SHans Petter Selasky #define MLX4_RATELIMIT_1G_UNITS 4 /* 1 Gbps */
6497549c34SHans Petter Selasky #define MLX4_RATELIMIT_DEFAULT 0x00ff
6597549c34SHans Petter Selasky
66c3191c2eSHans Petter Selasky #define MLX4_ROCE_MAX_GIDS 128
67c3191c2eSHans Petter Selasky #define MLX4_ROCE_PF_GIDS 16
68c3191c2eSHans Petter Selasky
6997549c34SHans Petter Selasky #define CORE_CLOCK_MASK 0xffffffffffffULL
7097549c34SHans Petter Selasky
7197549c34SHans Petter Selasky enum {
7297549c34SHans Petter Selasky MLX4_FLAG_MSI_X = 1 << 0,
7397549c34SHans Petter Selasky MLX4_FLAG_OLD_PORT_CMDS = 1 << 1,
7497549c34SHans Petter Selasky MLX4_FLAG_MASTER = 1 << 2,
7597549c34SHans Petter Selasky MLX4_FLAG_SLAVE = 1 << 3,
7697549c34SHans Petter Selasky MLX4_FLAG_SRIOV = 1 << 4,
7797549c34SHans Petter Selasky MLX4_FLAG_OLD_REG_MAC = 1 << 6,
78c3191c2eSHans Petter Selasky MLX4_FLAG_BONDED = 1 << 7,
79c3191c2eSHans Petter Selasky MLX4_FLAG_SECURE_HOST = 1 << 8,
8097549c34SHans Petter Selasky };
8197549c34SHans Petter Selasky
8297549c34SHans Petter Selasky enum {
8397549c34SHans Petter Selasky MLX4_PORT_CAP_IS_SM = 1 << 1,
8497549c34SHans Petter Selasky MLX4_PORT_CAP_DEV_MGMT_SUP = 1 << 19,
8597549c34SHans Petter Selasky };
8697549c34SHans Petter Selasky
8797549c34SHans Petter Selasky enum {
8897549c34SHans Petter Selasky MLX4_MAX_PORTS = 2,
89c3191c2eSHans Petter Selasky MLX4_MAX_PORT_PKEYS = 128,
90c3191c2eSHans Petter Selasky MLX4_MAX_PORT_GIDS = 128
9197549c34SHans Petter Selasky };
9297549c34SHans Petter Selasky
9397549c34SHans Petter Selasky /* base qkey for use in sriov tunnel-qp/proxy-qp communication.
9497549c34SHans Petter Selasky * These qkeys must not be allowed for general use. This is a 64k range,
9597549c34SHans Petter Selasky * and to test for violation, we use the mask (protect against future chg).
9697549c34SHans Petter Selasky */
9797549c34SHans Petter Selasky #define MLX4_RESERVED_QKEY_BASE (0xFFFF0000)
9897549c34SHans Petter Selasky #define MLX4_RESERVED_QKEY_MASK (0xFFFF0000)
9997549c34SHans Petter Selasky
10097549c34SHans Petter Selasky enum {
101c3191c2eSHans Petter Selasky MLX4_BOARD_ID_LEN = 64
10297549c34SHans Petter Selasky };
10397549c34SHans Petter Selasky
10497549c34SHans Petter Selasky enum {
10597549c34SHans Petter Selasky MLX4_MAX_NUM_PF = 16,
106c3191c2eSHans Petter Selasky MLX4_MAX_NUM_VF = 126,
107c3191c2eSHans Petter Selasky MLX4_MAX_NUM_VF_P_PORT = 64,
108c3191c2eSHans Petter Selasky MLX4_MFUNC_MAX = 128,
10997549c34SHans Petter Selasky MLX4_MAX_EQ_NUM = 1024,
11097549c34SHans Petter Selasky MLX4_MFUNC_EQ_NUM = 4,
11197549c34SHans Petter Selasky MLX4_MFUNC_MAX_EQES = 8,
11297549c34SHans Petter Selasky MLX4_MFUNC_EQE_MASK = (MLX4_MFUNC_MAX_EQES - 1)
11397549c34SHans Petter Selasky };
11497549c34SHans Petter Selasky
11597549c34SHans Petter Selasky /* Driver supports 3 different device methods to manage traffic steering:
11697549c34SHans Petter Selasky * -device managed - High level API for ib and eth flow steering. FW is
11797549c34SHans Petter Selasky * managing flow steering tables.
11897549c34SHans Petter Selasky * - B0 steering mode - Common low level API for ib and (if supported) eth.
11997549c34SHans Petter Selasky * - A0 steering mode - Limited low level API for eth. In case of IB,
12097549c34SHans Petter Selasky * B0 mode is in use.
12197549c34SHans Petter Selasky */
12297549c34SHans Petter Selasky enum {
12397549c34SHans Petter Selasky MLX4_STEERING_MODE_A0,
12497549c34SHans Petter Selasky MLX4_STEERING_MODE_B0,
12597549c34SHans Petter Selasky MLX4_STEERING_MODE_DEVICE_MANAGED
12697549c34SHans Petter Selasky };
12797549c34SHans Petter Selasky
128c3191c2eSHans Petter Selasky enum {
129c3191c2eSHans Petter Selasky MLX4_STEERING_DMFS_A0_DEFAULT,
130c3191c2eSHans Petter Selasky MLX4_STEERING_DMFS_A0_DYNAMIC,
131c3191c2eSHans Petter Selasky MLX4_STEERING_DMFS_A0_STATIC,
132c3191c2eSHans Petter Selasky MLX4_STEERING_DMFS_A0_DISABLE,
133c3191c2eSHans Petter Selasky MLX4_STEERING_DMFS_A0_NOT_SUPPORTED
134c3191c2eSHans Petter Selasky };
135c3191c2eSHans Petter Selasky
mlx4_steering_mode_str(int steering_mode)13697549c34SHans Petter Selasky static inline const char *mlx4_steering_mode_str(int steering_mode)
13797549c34SHans Petter Selasky {
13897549c34SHans Petter Selasky switch (steering_mode) {
13997549c34SHans Petter Selasky case MLX4_STEERING_MODE_A0:
14097549c34SHans Petter Selasky return "A0 steering";
14197549c34SHans Petter Selasky
14297549c34SHans Petter Selasky case MLX4_STEERING_MODE_B0:
14397549c34SHans Petter Selasky return "B0 steering";
14497549c34SHans Petter Selasky
14597549c34SHans Petter Selasky case MLX4_STEERING_MODE_DEVICE_MANAGED:
14697549c34SHans Petter Selasky return "Device managed flow steering";
14797549c34SHans Petter Selasky
14897549c34SHans Petter Selasky default:
14997549c34SHans Petter Selasky return "Unrecognize steering mode";
15097549c34SHans Petter Selasky }
15197549c34SHans Petter Selasky }
15297549c34SHans Petter Selasky
15397549c34SHans Petter Selasky enum {
154c3191c2eSHans Petter Selasky MLX4_TUNNEL_OFFLOAD_MODE_NONE,
155c3191c2eSHans Petter Selasky MLX4_TUNNEL_OFFLOAD_MODE_VXLAN
156c3191c2eSHans Petter Selasky };
157c3191c2eSHans Petter Selasky
158c3191c2eSHans Petter Selasky enum {
15997549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_RC = 1LL << 0,
16097549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_UC = 1LL << 1,
16197549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_UD = 1LL << 2,
16297549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_XRC = 1LL << 3,
16397549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_SRQ = 1LL << 6,
16497549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_IPOIB_CSUM = 1LL << 7,
16597549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1LL << 8,
16697549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1LL << 9,
16797549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_DPDP = 1LL << 12,
16897549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_BLH = 1LL << 15,
16997549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_MEM_WINDOW = 1LL << 16,
17097549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_APM = 1LL << 17,
17197549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_ATOMIC = 1LL << 18,
17297549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_RAW_MCAST = 1LL << 19,
17397549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_UD_AV_PORT = 1LL << 20,
17497549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_UD_MCAST = 1LL << 21,
17597549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_IBOE = 1LL << 30,
17697549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_UC_LOOPBACK = 1LL << 32,
17797549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_FCS_KEEP = 1LL << 34,
17897549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_WOL_PORT1 = 1LL << 37,
17997549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_WOL_PORT2 = 1LL << 38,
18097549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_UDP_RSS = 1LL << 40,
18197549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41,
18297549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42,
18397549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48,
184c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG_RSS_IP_FRAG = 1LL << 52,
185c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG_SET_ETH_SCHED = 1LL << 53,
18697549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55,
18797549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59,
18897549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_64B_EQE = 1LL << 61,
18997549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG_64B_CQE = 1LL << 62
19097549c34SHans Petter Selasky };
19197549c34SHans Petter Selasky
19297549c34SHans Petter Selasky enum {
19397549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG2_RSS = 1LL << 0,
19497549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG2_RSS_TOP = 1LL << 1,
19597549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG2_RSS_XOR = 1LL << 2,
19697549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG2_FS_EN = 1LL << 3,
197c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_REASSIGN_MAC_EN = 1LL << 4,
198c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_TS = 1LL << 5,
199c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_VLAN_CONTROL = 1LL << 6,
200c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_FSM = 1LL << 7,
201c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_UPDATE_QP = 1LL << 8,
202c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_DMFS_IPOIB = 1LL << 9,
203c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS = 1LL << 10,
204c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_MAD_DEMUX = 1LL << 11,
205c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_CQE_STRIDE = 1LL << 12,
206c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_EQE_STRIDE = 1LL << 13,
207c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL = 1LL << 14,
208c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP = 1LL << 15,
209c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_CONFIG_DEV = 1LL << 16,
210c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_SYS_EQS = 1LL << 17,
21197549c34SHans Petter Selasky MLX4_DEV_CAP_FLAG2_80_VFS = 1LL << 18,
212c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_FS_A0 = 1LL << 19,
213c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 20,
214c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_PORT_REMAP = 1LL << 21,
215c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_QCN = 1LL << 22,
216c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_QP_RATE_LIMIT = 1LL << 23,
217c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN = 1LL << 24,
218c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_QOS_VPP = 1LL << 25,
219c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_ETS_CFG = 1LL << 26,
220c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_PORT_BEACON = 1LL << 27,
221c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_IGNORE_FCS = 1LL << 28,
222c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_PHV_EN = 1LL << 29,
223c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_SKIP_OUTER_VLAN = 1LL << 30,
224c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB = 1ULL << 31,
225c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_LB_SRC_CHK = 1ULL << 32,
226c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_ROCE_V1_V2 = 1ULL << 33,
227c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_DMFS_UC_MC_SNIFFER = 1ULL << 34,
228c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT = 1ULL << 35,
229c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP = 1ULL << 36,
230c3191c2eSHans Petter Selasky MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT = 1ULL << 37,
231c3191c2eSHans Petter Selasky };
232c3191c2eSHans Petter Selasky
233c3191c2eSHans Petter Selasky enum {
234c3191c2eSHans Petter Selasky MLX4_QUERY_FUNC_FLAGS_BF_RES_QP = 1LL << 0,
235c3191c2eSHans Petter Selasky MLX4_QUERY_FUNC_FLAGS_A0_RES_QP = 1LL << 1
236c3191c2eSHans Petter Selasky };
237c3191c2eSHans Petter Selasky
238c3191c2eSHans Petter Selasky enum {
239c3191c2eSHans Petter Selasky MLX4_VF_CAP_FLAG_RESET = 1 << 0
24097549c34SHans Petter Selasky };
24197549c34SHans Petter Selasky
24297549c34SHans Petter Selasky /* bit enums for an 8-bit flags field indicating special use
24397549c34SHans Petter Selasky * QPs which require special handling in qp_reserve_range.
24497549c34SHans Petter Selasky * Currently, this only includes QPs used by the ETH interface,
24597549c34SHans Petter Selasky * where we expect to use blueflame. These QPs must not have
24697549c34SHans Petter Selasky * bits 6 and 7 set in their qp number.
24797549c34SHans Petter Selasky *
24897549c34SHans Petter Selasky * This enum may use only bits 0..7.
24997549c34SHans Petter Selasky */
25097549c34SHans Petter Selasky enum {
251c3191c2eSHans Petter Selasky MLX4_RESERVE_A0_QP = 1 << 6,
25264968e70SHans Petter Selasky MLX4_RESERVE_ETH_BF_QP = 1 << 7,
25364968e70SHans Petter Selasky };
25464968e70SHans Petter Selasky
25564968e70SHans Petter Selasky enum {
25697549c34SHans Petter Selasky MLX4_DEV_CAP_64B_EQE_ENABLED = 1LL << 0,
257c3191c2eSHans Petter Selasky MLX4_DEV_CAP_64B_CQE_ENABLED = 1LL << 1,
258c3191c2eSHans Petter Selasky MLX4_DEV_CAP_CQE_STRIDE_ENABLED = 1LL << 2,
259c3191c2eSHans Petter Selasky MLX4_DEV_CAP_EQE_STRIDE_ENABLED = 1LL << 3
26097549c34SHans Petter Selasky };
26197549c34SHans Petter Selasky
26297549c34SHans Petter Selasky enum {
263c3191c2eSHans Petter Selasky MLX4_USER_DEV_CAP_LARGE_CQE = 1L << 0
26497549c34SHans Petter Selasky };
26597549c34SHans Petter Selasky
26697549c34SHans Petter Selasky enum {
267c3191c2eSHans Petter Selasky MLX4_FUNC_CAP_64B_EQE_CQE = 1L << 0,
268c3191c2eSHans Petter Selasky MLX4_FUNC_CAP_EQE_CQE_STRIDE = 1L << 1,
269c3191c2eSHans Petter Selasky MLX4_FUNC_CAP_DMFS_A0_STATIC = 1L << 2
27097549c34SHans Petter Selasky };
27197549c34SHans Petter Selasky
27297549c34SHans Petter Selasky
27397549c34SHans Petter Selasky #define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
27497549c34SHans Petter Selasky
27597549c34SHans Petter Selasky enum {
27697549c34SHans Petter Selasky MLX4_BMME_FLAG_WIN_TYPE_2B = 1 << 1,
27797549c34SHans Petter Selasky MLX4_BMME_FLAG_LOCAL_INV = 1 << 6,
27897549c34SHans Petter Selasky MLX4_BMME_FLAG_REMOTE_INV = 1 << 7,
27997549c34SHans Petter Selasky MLX4_BMME_FLAG_TYPE_2_WIN = 1 << 9,
28097549c34SHans Petter Selasky MLX4_BMME_FLAG_RESERVED_LKEY = 1 << 10,
28197549c34SHans Petter Selasky MLX4_BMME_FLAG_FAST_REG_WR = 1 << 11,
282c3191c2eSHans Petter Selasky MLX4_BMME_FLAG_ROCE_V1_V2 = 1 << 19,
283c3191c2eSHans Petter Selasky MLX4_BMME_FLAG_PORT_REMAP = 1 << 24,
284c3191c2eSHans Petter Selasky MLX4_BMME_FLAG_VSD_INIT2RTR = 1 << 28,
285c3191c2eSHans Petter Selasky };
286c3191c2eSHans Petter Selasky
287c3191c2eSHans Petter Selasky enum {
288c3191c2eSHans Petter Selasky MLX4_FLAG_PORT_REMAP = MLX4_BMME_FLAG_PORT_REMAP,
289c3191c2eSHans Petter Selasky MLX4_FLAG_ROCE_V1_V2 = MLX4_BMME_FLAG_ROCE_V1_V2
29097549c34SHans Petter Selasky };
29197549c34SHans Petter Selasky
29297549c34SHans Petter Selasky enum mlx4_event {
29397549c34SHans Petter Selasky MLX4_EVENT_TYPE_COMP = 0x00,
29497549c34SHans Petter Selasky MLX4_EVENT_TYPE_PATH_MIG = 0x01,
29597549c34SHans Petter Selasky MLX4_EVENT_TYPE_COMM_EST = 0x02,
29697549c34SHans Petter Selasky MLX4_EVENT_TYPE_SQ_DRAINED = 0x03,
29797549c34SHans Petter Selasky MLX4_EVENT_TYPE_SRQ_QP_LAST_WQE = 0x13,
29897549c34SHans Petter Selasky MLX4_EVENT_TYPE_SRQ_LIMIT = 0x14,
29997549c34SHans Petter Selasky MLX4_EVENT_TYPE_CQ_ERROR = 0x04,
30097549c34SHans Petter Selasky MLX4_EVENT_TYPE_WQ_CATAS_ERROR = 0x05,
30197549c34SHans Petter Selasky MLX4_EVENT_TYPE_EEC_CATAS_ERROR = 0x06,
30297549c34SHans Petter Selasky MLX4_EVENT_TYPE_PATH_MIG_FAILED = 0x07,
30397549c34SHans Petter Selasky MLX4_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10,
30497549c34SHans Petter Selasky MLX4_EVENT_TYPE_WQ_ACCESS_ERROR = 0x11,
30597549c34SHans Petter Selasky MLX4_EVENT_TYPE_SRQ_CATAS_ERROR = 0x12,
30697549c34SHans Petter Selasky MLX4_EVENT_TYPE_LOCAL_CATAS_ERROR = 0x08,
30797549c34SHans Petter Selasky MLX4_EVENT_TYPE_PORT_CHANGE = 0x09,
30897549c34SHans Petter Selasky MLX4_EVENT_TYPE_EQ_OVERFLOW = 0x0f,
30997549c34SHans Petter Selasky MLX4_EVENT_TYPE_ECC_DETECT = 0x0e,
31097549c34SHans Petter Selasky MLX4_EVENT_TYPE_CMD = 0x0a,
31197549c34SHans Petter Selasky MLX4_EVENT_TYPE_VEP_UPDATE = 0x19,
31297549c34SHans Petter Selasky MLX4_EVENT_TYPE_COMM_CHANNEL = 0x18,
31397549c34SHans Petter Selasky MLX4_EVENT_TYPE_OP_REQUIRED = 0x1a,
31497549c34SHans Petter Selasky MLX4_EVENT_TYPE_FATAL_WARNING = 0x1b,
31597549c34SHans Petter Selasky MLX4_EVENT_TYPE_FLR_EVENT = 0x1c,
31697549c34SHans Petter Selasky MLX4_EVENT_TYPE_PORT_MNG_CHG_EVENT = 0x1d,
31797549c34SHans Petter Selasky MLX4_EVENT_TYPE_RECOVERABLE_ERROR_EVENT = 0x3e,
31897549c34SHans Petter Selasky MLX4_EVENT_TYPE_NONE = 0xff,
31997549c34SHans Petter Selasky };
32097549c34SHans Petter Selasky
32197549c34SHans Petter Selasky enum {
32297549c34SHans Petter Selasky MLX4_PORT_CHANGE_SUBTYPE_DOWN = 1,
32397549c34SHans Petter Selasky MLX4_PORT_CHANGE_SUBTYPE_ACTIVE = 4
32497549c34SHans Petter Selasky };
32597549c34SHans Petter Selasky
32697549c34SHans Petter Selasky enum {
32797549c34SHans Petter Selasky MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_BAD_CABLE = 1,
32897549c34SHans Petter Selasky MLX4_RECOVERABLE_ERROR_EVENT_SUBTYPE_UNSUPPORTED_CABLE = 2,
32997549c34SHans Petter Selasky };
33097549c34SHans Petter Selasky
33197549c34SHans Petter Selasky enum {
33297549c34SHans Petter Selasky MLX4_FATAL_WARNING_SUBTYPE_WARMING = 0,
33397549c34SHans Petter Selasky };
33497549c34SHans Petter Selasky
33597549c34SHans Petter Selasky enum slave_port_state {
33697549c34SHans Petter Selasky SLAVE_PORT_DOWN = 0,
33797549c34SHans Petter Selasky SLAVE_PENDING_UP,
33897549c34SHans Petter Selasky SLAVE_PORT_UP,
33997549c34SHans Petter Selasky };
34097549c34SHans Petter Selasky
34197549c34SHans Petter Selasky enum slave_port_gen_event {
34297549c34SHans Petter Selasky SLAVE_PORT_GEN_EVENT_DOWN = 0,
34397549c34SHans Petter Selasky SLAVE_PORT_GEN_EVENT_UP,
34497549c34SHans Petter Selasky SLAVE_PORT_GEN_EVENT_NONE,
34597549c34SHans Petter Selasky };
34697549c34SHans Petter Selasky
34797549c34SHans Petter Selasky enum slave_port_state_event {
34897549c34SHans Petter Selasky MLX4_PORT_STATE_DEV_EVENT_PORT_DOWN,
34997549c34SHans Petter Selasky MLX4_PORT_STATE_DEV_EVENT_PORT_UP,
35097549c34SHans Petter Selasky MLX4_PORT_STATE_IB_PORT_STATE_EVENT_GID_VALID,
35197549c34SHans Petter Selasky MLX4_PORT_STATE_IB_EVENT_GID_INVALID,
35297549c34SHans Petter Selasky };
35397549c34SHans Petter Selasky
35497549c34SHans Petter Selasky enum {
35597549c34SHans Petter Selasky MLX4_PERM_LOCAL_READ = 1 << 10,
35697549c34SHans Petter Selasky MLX4_PERM_LOCAL_WRITE = 1 << 11,
35797549c34SHans Petter Selasky MLX4_PERM_REMOTE_READ = 1 << 12,
35897549c34SHans Petter Selasky MLX4_PERM_REMOTE_WRITE = 1 << 13,
35997549c34SHans Petter Selasky MLX4_PERM_ATOMIC = 1 << 14,
36097549c34SHans Petter Selasky MLX4_PERM_BIND_MW = 1 << 15,
361c3191c2eSHans Petter Selasky MLX4_PERM_MASK = 0xFC00
36297549c34SHans Petter Selasky };
36397549c34SHans Petter Selasky
36497549c34SHans Petter Selasky enum {
36597549c34SHans Petter Selasky MLX4_OPCODE_NOP = 0x00,
36697549c34SHans Petter Selasky MLX4_OPCODE_SEND_INVAL = 0x01,
36797549c34SHans Petter Selasky MLX4_OPCODE_RDMA_WRITE = 0x08,
36897549c34SHans Petter Selasky MLX4_OPCODE_RDMA_WRITE_IMM = 0x09,
36997549c34SHans Petter Selasky MLX4_OPCODE_SEND = 0x0a,
37097549c34SHans Petter Selasky MLX4_OPCODE_SEND_IMM = 0x0b,
37197549c34SHans Petter Selasky MLX4_OPCODE_LSO = 0x0e,
37297549c34SHans Petter Selasky MLX4_OPCODE_RDMA_READ = 0x10,
37397549c34SHans Petter Selasky MLX4_OPCODE_ATOMIC_CS = 0x11,
37497549c34SHans Petter Selasky MLX4_OPCODE_ATOMIC_FA = 0x12,
37597549c34SHans Petter Selasky MLX4_OPCODE_MASKED_ATOMIC_CS = 0x14,
37697549c34SHans Petter Selasky MLX4_OPCODE_MASKED_ATOMIC_FA = 0x15,
37797549c34SHans Petter Selasky MLX4_OPCODE_BIND_MW = 0x18,
37897549c34SHans Petter Selasky MLX4_OPCODE_FMR = 0x19,
37997549c34SHans Petter Selasky MLX4_OPCODE_LOCAL_INVAL = 0x1b,
38097549c34SHans Petter Selasky MLX4_OPCODE_CONFIG_CMD = 0x1f,
38197549c34SHans Petter Selasky
38297549c34SHans Petter Selasky MLX4_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
38397549c34SHans Petter Selasky MLX4_RECV_OPCODE_SEND = 0x01,
38497549c34SHans Petter Selasky MLX4_RECV_OPCODE_SEND_IMM = 0x02,
38597549c34SHans Petter Selasky MLX4_RECV_OPCODE_SEND_INVAL = 0x03,
38697549c34SHans Petter Selasky
38797549c34SHans Petter Selasky MLX4_CQE_OPCODE_ERROR = 0x1e,
38897549c34SHans Petter Selasky MLX4_CQE_OPCODE_RESIZE = 0x16,
38997549c34SHans Petter Selasky };
39097549c34SHans Petter Selasky
39197549c34SHans Petter Selasky enum {
39297549c34SHans Petter Selasky MLX4_STAT_RATE_OFFSET = 5
39397549c34SHans Petter Selasky };
39497549c34SHans Petter Selasky
39597549c34SHans Petter Selasky enum mlx4_protocol {
39697549c34SHans Petter Selasky MLX4_PROT_IB_IPV6 = 0,
39797549c34SHans Petter Selasky MLX4_PROT_ETH,
39897549c34SHans Petter Selasky MLX4_PROT_IB_IPV4,
39997549c34SHans Petter Selasky MLX4_PROT_FCOE
40097549c34SHans Petter Selasky };
40197549c34SHans Petter Selasky
40297549c34SHans Petter Selasky enum {
40397549c34SHans Petter Selasky MLX4_MTT_FLAG_PRESENT = 1
40497549c34SHans Petter Selasky };
40597549c34SHans Petter Selasky
40697549c34SHans Petter Selasky enum mlx4_qp_region {
40797549c34SHans Petter Selasky MLX4_QP_REGION_FW = 0,
408c3191c2eSHans Petter Selasky MLX4_QP_REGION_RSS_RAW_ETH,
409c3191c2eSHans Petter Selasky MLX4_QP_REGION_BOTTOM = MLX4_QP_REGION_RSS_RAW_ETH,
41097549c34SHans Petter Selasky MLX4_QP_REGION_ETH_ADDR,
41197549c34SHans Petter Selasky MLX4_QP_REGION_FC_ADDR,
41297549c34SHans Petter Selasky MLX4_QP_REGION_FC_EXCH,
41397549c34SHans Petter Selasky MLX4_NUM_QP_REGION
41497549c34SHans Petter Selasky };
41597549c34SHans Petter Selasky
41697549c34SHans Petter Selasky enum mlx4_port_type {
41797549c34SHans Petter Selasky MLX4_PORT_TYPE_NONE = 0,
41897549c34SHans Petter Selasky MLX4_PORT_TYPE_IB = 1,
41997549c34SHans Petter Selasky MLX4_PORT_TYPE_ETH = 2,
420c3191c2eSHans Petter Selasky MLX4_PORT_TYPE_AUTO = 3
42197549c34SHans Petter Selasky };
42297549c34SHans Petter Selasky
42397549c34SHans Petter Selasky enum mlx4_special_vlan_idx {
42497549c34SHans Petter Selasky MLX4_NO_VLAN_IDX = 0,
42597549c34SHans Petter Selasky MLX4_VLAN_MISS_IDX,
42697549c34SHans Petter Selasky MLX4_VLAN_REGULAR
42797549c34SHans Petter Selasky };
42897549c34SHans Petter Selasky
42997549c34SHans Petter Selasky enum mlx4_steer_type {
43097549c34SHans Petter Selasky MLX4_MC_STEER = 0,
43197549c34SHans Petter Selasky MLX4_UC_STEER,
43297549c34SHans Petter Selasky MLX4_NUM_STEERS
43397549c34SHans Petter Selasky };
43497549c34SHans Petter Selasky
43597549c34SHans Petter Selasky enum {
43697549c34SHans Petter Selasky MLX4_NUM_FEXCH = 64 * 1024,
43797549c34SHans Petter Selasky };
43897549c34SHans Petter Selasky
43997549c34SHans Petter Selasky enum {
44097549c34SHans Petter Selasky MLX4_MAX_FAST_REG_PAGES = 511,
44197549c34SHans Petter Selasky };
44297549c34SHans Petter Selasky
44397549c34SHans Petter Selasky enum {
444c3191c2eSHans Petter Selasky /*
445c3191c2eSHans Petter Selasky * Max wqe size for rdma read is 512 bytes, so this
446c3191c2eSHans Petter Selasky * limits our max_sge_rd as the wqe needs to fit:
447c3191c2eSHans Petter Selasky * - ctrl segment (16 bytes)
448c3191c2eSHans Petter Selasky * - rdma segment (16 bytes)
449c3191c2eSHans Petter Selasky * - scatter elements (16 bytes each)
450c3191c2eSHans Petter Selasky */
451c3191c2eSHans Petter Selasky MLX4_MAX_SGE_RD = (512 - 16 - 16) / 16
452c3191c2eSHans Petter Selasky };
453c3191c2eSHans Petter Selasky
454c3191c2eSHans Petter Selasky enum {
45597549c34SHans Petter Selasky MLX4_DEV_PMC_SUBTYPE_GUID_INFO = 0x14,
45697549c34SHans Petter Selasky MLX4_DEV_PMC_SUBTYPE_PORT_INFO = 0x15,
45797549c34SHans Petter Selasky MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE = 0x16,
458c3191c2eSHans Petter Selasky MLX4_DEV_PMC_SUBTYPE_SL_TO_VL_MAP = 0x17,
45997549c34SHans Petter Selasky };
46097549c34SHans Petter Selasky
46197549c34SHans Petter Selasky /* Port mgmt change event handling */
46297549c34SHans Petter Selasky enum {
46397549c34SHans Petter Selasky MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK = 1 << 0,
46497549c34SHans Petter Selasky MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK = 1 << 1,
46597549c34SHans Petter Selasky MLX4_EQ_PORT_INFO_LID_CHANGE_MASK = 1 << 2,
46697549c34SHans Petter Selasky MLX4_EQ_PORT_INFO_CLIENT_REREG_MASK = 1 << 3,
46797549c34SHans Petter Selasky MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK = 1 << 4,
46897549c34SHans Petter Selasky };
46997549c34SHans Petter Selasky
470c3191c2eSHans Petter Selasky union sl2vl_tbl_to_u64 {
471c3191c2eSHans Petter Selasky u8 sl8[8];
472c3191c2eSHans Petter Selasky u64 sl64;
473c3191c2eSHans Petter Selasky };
474c3191c2eSHans Petter Selasky
475c3191c2eSHans Petter Selasky enum {
476c3191c2eSHans Petter Selasky MLX4_DEVICE_STATE_UP = 1 << 0,
477c3191c2eSHans Petter Selasky MLX4_DEVICE_STATE_INTERNAL_ERROR = 1 << 1,
478c3191c2eSHans Petter Selasky };
479c3191c2eSHans Petter Selasky
480c3191c2eSHans Petter Selasky enum {
481c3191c2eSHans Petter Selasky MLX4_INTERFACE_STATE_UP = 1 << 0,
482c3191c2eSHans Petter Selasky MLX4_INTERFACE_STATE_DELETION = 1 << 1,
483c3191c2eSHans Petter Selasky };
484c3191c2eSHans Petter Selasky
48597549c34SHans Petter Selasky #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
48697549c34SHans Petter Selasky MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK)
48797549c34SHans Petter Selasky
48897549c34SHans Petter Selasky enum mlx4_module_id {
48997549c34SHans Petter Selasky MLX4_MODULE_ID_SFP = 0x3,
49097549c34SHans Petter Selasky MLX4_MODULE_ID_QSFP = 0xC,
49197549c34SHans Petter Selasky MLX4_MODULE_ID_QSFP_PLUS = 0xD,
49297549c34SHans Petter Selasky MLX4_MODULE_ID_QSFP28 = 0x11,
49397549c34SHans Petter Selasky };
49497549c34SHans Petter Selasky
495c3191c2eSHans Petter Selasky enum { /* rl */
496c3191c2eSHans Petter Selasky MLX4_QP_RATE_LIMIT_NONE = 0,
497c3191c2eSHans Petter Selasky MLX4_QP_RATE_LIMIT_KBS = 1,
498c3191c2eSHans Petter Selasky MLX4_QP_RATE_LIMIT_MBS = 2,
499c3191c2eSHans Petter Selasky MLX4_QP_RATE_LIMIT_GBS = 3
500c3191c2eSHans Petter Selasky };
501c3191c2eSHans Petter Selasky
502c3191c2eSHans Petter Selasky struct mlx4_rate_limit_caps {
503c3191c2eSHans Petter Selasky u16 num_rates; /* Number of different rates */
504c3191c2eSHans Petter Selasky u8 min_unit;
505c3191c2eSHans Petter Selasky u16 min_val;
506c3191c2eSHans Petter Selasky u8 max_unit;
507c3191c2eSHans Petter Selasky u16 max_val;
508c3191c2eSHans Petter Selasky };
509c3191c2eSHans Petter Selasky
mlx4_fw_ver(u64 major,u64 minor,u64 subminor)51097549c34SHans Petter Selasky static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
51197549c34SHans Petter Selasky {
51297549c34SHans Petter Selasky return (major << 32) | (minor << 16) | subminor;
51397549c34SHans Petter Selasky }
51497549c34SHans Petter Selasky
51597549c34SHans Petter Selasky struct mlx4_phys_caps {
51697549c34SHans Petter Selasky u32 gid_phys_table_len[MLX4_MAX_PORTS + 1];
51797549c34SHans Petter Selasky u32 pkey_phys_table_len[MLX4_MAX_PORTS + 1];
51897549c34SHans Petter Selasky u32 num_phys_eqs;
51997549c34SHans Petter Selasky u32 base_sqpn;
52097549c34SHans Petter Selasky u32 base_proxy_sqpn;
52197549c34SHans Petter Selasky u32 base_tunnel_sqpn;
52297549c34SHans Petter Selasky };
52397549c34SHans Petter Selasky
52497549c34SHans Petter Selasky struct mlx4_caps {
52597549c34SHans Petter Selasky u64 fw_ver;
52697549c34SHans Petter Selasky u32 function;
52797549c34SHans Petter Selasky int num_ports;
52897549c34SHans Petter Selasky int vl_cap[MLX4_MAX_PORTS + 1];
52997549c34SHans Petter Selasky int ib_mtu_cap[MLX4_MAX_PORTS + 1];
53097549c34SHans Petter Selasky __be32 ib_port_def_cap[MLX4_MAX_PORTS + 1];
53197549c34SHans Petter Selasky u64 def_mac[MLX4_MAX_PORTS + 1];
53297549c34SHans Petter Selasky int eth_mtu_cap[MLX4_MAX_PORTS + 1];
53397549c34SHans Petter Selasky int gid_table_len[MLX4_MAX_PORTS + 1];
53497549c34SHans Petter Selasky int pkey_table_len[MLX4_MAX_PORTS + 1];
53597549c34SHans Petter Selasky int trans_type[MLX4_MAX_PORTS + 1];
53697549c34SHans Petter Selasky int vendor_oui[MLX4_MAX_PORTS + 1];
53797549c34SHans Petter Selasky int wavelength[MLX4_MAX_PORTS + 1];
53897549c34SHans Petter Selasky u64 trans_code[MLX4_MAX_PORTS + 1];
53997549c34SHans Petter Selasky int local_ca_ack_delay;
54097549c34SHans Petter Selasky int num_uars;
54197549c34SHans Petter Selasky u32 uar_page_size;
54297549c34SHans Petter Selasky int bf_reg_size;
54397549c34SHans Petter Selasky int bf_regs_per_page;
54497549c34SHans Petter Selasky int max_sq_sg;
54597549c34SHans Petter Selasky int max_rq_sg;
54697549c34SHans Petter Selasky int num_qps;
54797549c34SHans Petter Selasky int max_wqes;
54897549c34SHans Petter Selasky int max_sq_desc_sz;
54997549c34SHans Petter Selasky int max_rq_desc_sz;
55097549c34SHans Petter Selasky int max_qp_init_rdma;
55197549c34SHans Petter Selasky int max_qp_dest_rdma;
552c3191c2eSHans Petter Selasky int max_tc_eth;
553c3191c2eSHans Petter Selasky u32 *qp0_qkey;
55497549c34SHans Petter Selasky u32 *qp0_proxy;
55597549c34SHans Petter Selasky u32 *qp1_proxy;
55697549c34SHans Petter Selasky u32 *qp0_tunnel;
55797549c34SHans Petter Selasky u32 *qp1_tunnel;
55897549c34SHans Petter Selasky int num_srqs;
55997549c34SHans Petter Selasky int max_srq_wqes;
56097549c34SHans Petter Selasky int max_srq_sge;
56197549c34SHans Petter Selasky int reserved_srqs;
56297549c34SHans Petter Selasky int num_cqs;
56397549c34SHans Petter Selasky int max_cqes;
56497549c34SHans Petter Selasky int reserved_cqs;
5652cebcdc7SHans Petter Selasky int num_sys_eqs;
56697549c34SHans Petter Selasky int num_eqs;
56797549c34SHans Petter Selasky int reserved_eqs;
56897549c34SHans Petter Selasky int num_comp_vectors;
56997549c34SHans Petter Selasky int num_mpts;
57097549c34SHans Petter Selasky int max_fmr_maps;
571c3191c2eSHans Petter Selasky int num_mtts;
57297549c34SHans Petter Selasky int fmr_reserved_mtts;
57397549c34SHans Petter Selasky int reserved_mtts;
57497549c34SHans Petter Selasky int reserved_mrws;
57597549c34SHans Petter Selasky int reserved_uars;
57697549c34SHans Petter Selasky int num_mgms;
57797549c34SHans Petter Selasky int num_amgms;
57897549c34SHans Petter Selasky int reserved_mcgs;
57997549c34SHans Petter Selasky int num_qp_per_mgm;
58097549c34SHans Petter Selasky int steering_mode;
581c3191c2eSHans Petter Selasky int dmfs_high_steer_mode;
582c3191c2eSHans Petter Selasky int fs_log_max_ucast_qp_range_size;
58397549c34SHans Petter Selasky int num_pds;
58497549c34SHans Petter Selasky int reserved_pds;
58597549c34SHans Petter Selasky int max_xrcds;
58697549c34SHans Petter Selasky int reserved_xrcds;
58797549c34SHans Petter Selasky int mtt_entry_sz;
58897549c34SHans Petter Selasky u32 max_msg_sz;
58997549c34SHans Petter Selasky u32 page_size_cap;
59097549c34SHans Petter Selasky u64 flags;
59197549c34SHans Petter Selasky u64 flags2;
59297549c34SHans Petter Selasky u32 bmme_flags;
59397549c34SHans Petter Selasky u32 reserved_lkey;
59497549c34SHans Petter Selasky u16 stat_rate_support;
59597549c34SHans Petter Selasky u8 port_width_cap[MLX4_MAX_PORTS + 1];
59697549c34SHans Petter Selasky int max_gso_sz;
59797549c34SHans Petter Selasky int max_rss_tbl_sz;
59897549c34SHans Petter Selasky int reserved_qps_cnt[MLX4_NUM_QP_REGION];
59997549c34SHans Petter Selasky int reserved_qps;
60097549c34SHans Petter Selasky int reserved_qps_base[MLX4_NUM_QP_REGION];
60197549c34SHans Petter Selasky int log_num_macs;
60297549c34SHans Petter Selasky int log_num_vlans;
60397549c34SHans Petter Selasky enum mlx4_port_type port_type[MLX4_MAX_PORTS + 1];
60497549c34SHans Petter Selasky u8 supported_type[MLX4_MAX_PORTS + 1];
60597549c34SHans Petter Selasky u8 suggested_type[MLX4_MAX_PORTS + 1];
60697549c34SHans Petter Selasky u8 default_sense[MLX4_MAX_PORTS + 1];
60797549c34SHans Petter Selasky u32 port_mask[MLX4_MAX_PORTS + 1];
60897549c34SHans Petter Selasky enum mlx4_port_type possible_type[MLX4_MAX_PORTS + 1];
60997549c34SHans Petter Selasky u32 max_counters;
61097549c34SHans Petter Selasky u8 port_ib_mtu[MLX4_MAX_PORTS + 1];
61197549c34SHans Petter Selasky u16 sqp_demux;
61297549c34SHans Petter Selasky u32 eqe_size;
61397549c34SHans Petter Selasky u32 cqe_size;
61497549c34SHans Petter Selasky u8 eqe_factor;
615c3191c2eSHans Petter Selasky u32 userspace_caps; /* userspace must be aware of these */
616c3191c2eSHans Petter Selasky u32 function_caps; /* VFs must be aware of these */
61797549c34SHans Petter Selasky u16 hca_core_clock;
618c3191c2eSHans Petter Selasky u64 phys_port_id[MLX4_MAX_PORTS + 1];
619c3191c2eSHans Petter Selasky int tunnel_offload_mode;
620c3191c2eSHans Petter Selasky u8 rx_checksum_flags_port[MLX4_MAX_PORTS + 1];
621c3191c2eSHans Petter Selasky u8 phv_bit[MLX4_MAX_PORTS + 1];
62264968e70SHans Petter Selasky u8 alloc_res_qp_mask;
623c3191c2eSHans Petter Selasky u32 dmfs_high_rate_qpn_base;
624c3191c2eSHans Petter Selasky u32 dmfs_high_rate_qpn_range;
625c3191c2eSHans Petter Selasky u32 vf_caps;
626c3191c2eSHans Petter Selasky struct mlx4_rate_limit_caps rl_caps;
627*c8301cbbSHans Petter Selasky bool map_clock_to_user;
62897549c34SHans Petter Selasky };
62997549c34SHans Petter Selasky
63097549c34SHans Petter Selasky struct mlx4_buf_list {
63197549c34SHans Petter Selasky void *buf;
63297549c34SHans Petter Selasky dma_addr_t map;
63397549c34SHans Petter Selasky };
63497549c34SHans Petter Selasky
63597549c34SHans Petter Selasky struct mlx4_buf {
63697549c34SHans Petter Selasky struct mlx4_buf_list direct;
63797549c34SHans Petter Selasky struct mlx4_buf_list *page_list;
63897549c34SHans Petter Selasky int nbufs;
63997549c34SHans Petter Selasky int npages;
64097549c34SHans Petter Selasky int page_shift;
64197549c34SHans Petter Selasky };
64297549c34SHans Petter Selasky
64397549c34SHans Petter Selasky struct mlx4_mtt {
64497549c34SHans Petter Selasky u32 offset;
64597549c34SHans Petter Selasky int order;
64697549c34SHans Petter Selasky int page_shift;
64797549c34SHans Petter Selasky };
64897549c34SHans Petter Selasky
64997549c34SHans Petter Selasky enum {
65097549c34SHans Petter Selasky MLX4_DB_PER_PAGE = PAGE_SIZE / 4
65197549c34SHans Petter Selasky };
65297549c34SHans Petter Selasky
65397549c34SHans Petter Selasky struct mlx4_db_pgdir {
65497549c34SHans Petter Selasky struct list_head list;
65597549c34SHans Petter Selasky DECLARE_BITMAP(order0, MLX4_DB_PER_PAGE);
65697549c34SHans Petter Selasky DECLARE_BITMAP(order1, MLX4_DB_PER_PAGE / 2);
65797549c34SHans Petter Selasky unsigned long *bits[2];
65897549c34SHans Petter Selasky __be32 *db_page;
65997549c34SHans Petter Selasky dma_addr_t db_dma;
66097549c34SHans Petter Selasky };
66197549c34SHans Petter Selasky
66297549c34SHans Petter Selasky struct mlx4_ib_user_db_page;
66397549c34SHans Petter Selasky
66497549c34SHans Petter Selasky struct mlx4_db {
66597549c34SHans Petter Selasky __be32 *db;
66697549c34SHans Petter Selasky union {
66797549c34SHans Petter Selasky struct mlx4_db_pgdir *pgdir;
66897549c34SHans Petter Selasky struct mlx4_ib_user_db_page *user_page;
66997549c34SHans Petter Selasky } u;
67097549c34SHans Petter Selasky dma_addr_t dma;
67197549c34SHans Petter Selasky int index;
67297549c34SHans Petter Selasky int order;
67397549c34SHans Petter Selasky };
67497549c34SHans Petter Selasky
67597549c34SHans Petter Selasky struct mlx4_hwq_resources {
67697549c34SHans Petter Selasky struct mlx4_db db;
67797549c34SHans Petter Selasky struct mlx4_mtt mtt;
67897549c34SHans Petter Selasky struct mlx4_buf buf;
67997549c34SHans Petter Selasky };
68097549c34SHans Petter Selasky
68197549c34SHans Petter Selasky struct mlx4_mr {
68297549c34SHans Petter Selasky struct mlx4_mtt mtt;
68397549c34SHans Petter Selasky u64 iova;
68497549c34SHans Petter Selasky u64 size;
68597549c34SHans Petter Selasky u32 key;
68697549c34SHans Petter Selasky u32 pd;
68797549c34SHans Petter Selasky u32 access;
68897549c34SHans Petter Selasky int enabled;
68997549c34SHans Petter Selasky };
69097549c34SHans Petter Selasky
69197549c34SHans Petter Selasky enum mlx4_mw_type {
69297549c34SHans Petter Selasky MLX4_MW_TYPE_1 = 1,
69397549c34SHans Petter Selasky MLX4_MW_TYPE_2 = 2,
69497549c34SHans Petter Selasky };
69597549c34SHans Petter Selasky
69697549c34SHans Petter Selasky struct mlx4_mw {
69797549c34SHans Petter Selasky u32 key;
69897549c34SHans Petter Selasky u32 pd;
69997549c34SHans Petter Selasky enum mlx4_mw_type type;
70097549c34SHans Petter Selasky int enabled;
70197549c34SHans Petter Selasky };
70297549c34SHans Petter Selasky
70397549c34SHans Petter Selasky struct mlx4_fmr {
70497549c34SHans Petter Selasky struct mlx4_mr mr;
70597549c34SHans Petter Selasky struct mlx4_mpt_entry *mpt;
70697549c34SHans Petter Selasky __be64 *mtts;
70797549c34SHans Petter Selasky dma_addr_t dma_handle;
70897549c34SHans Petter Selasky int max_pages;
70997549c34SHans Petter Selasky int max_maps;
71097549c34SHans Petter Selasky int maps;
71197549c34SHans Petter Selasky u8 page_shift;
71297549c34SHans Petter Selasky };
71397549c34SHans Petter Selasky
71497549c34SHans Petter Selasky struct mlx4_uar {
71597549c34SHans Petter Selasky unsigned long pfn;
71697549c34SHans Petter Selasky int index;
71797549c34SHans Petter Selasky struct list_head bf_list;
71897549c34SHans Petter Selasky unsigned free_bf_bmap;
71997549c34SHans Petter Selasky void __iomem *map;
72097549c34SHans Petter Selasky void __iomem *bf_map;
72197549c34SHans Petter Selasky };
72297549c34SHans Petter Selasky
72397549c34SHans Petter Selasky struct mlx4_bf {
724c3191c2eSHans Petter Selasky unsigned int offset;
72597549c34SHans Petter Selasky int buf_size;
72697549c34SHans Petter Selasky struct mlx4_uar *uar;
72797549c34SHans Petter Selasky void __iomem *reg;
72897549c34SHans Petter Selasky };
72997549c34SHans Petter Selasky
73097549c34SHans Petter Selasky struct mlx4_cq {
73197549c34SHans Petter Selasky void (*comp) (struct mlx4_cq *);
73297549c34SHans Petter Selasky void (*event) (struct mlx4_cq *, enum mlx4_event);
73397549c34SHans Petter Selasky
73497549c34SHans Petter Selasky struct mlx4_uar *uar;
73597549c34SHans Petter Selasky
73697549c34SHans Petter Selasky u32 cons_index;
73797549c34SHans Petter Selasky
738c3191c2eSHans Petter Selasky u16 irq;
73997549c34SHans Petter Selasky __be32 *set_ci_db;
74097549c34SHans Petter Selasky __be32 *arm_db;
74197549c34SHans Petter Selasky int arm_sn;
74297549c34SHans Petter Selasky
74397549c34SHans Petter Selasky int cqn;
74497549c34SHans Petter Selasky unsigned vector;
74597549c34SHans Petter Selasky
74697549c34SHans Petter Selasky atomic_t refcount;
74797549c34SHans Petter Selasky struct completion free;
748c3191c2eSHans Petter Selasky int reset_notify_added;
749c3191c2eSHans Petter Selasky struct list_head reset_notify;
75097549c34SHans Petter Selasky };
75197549c34SHans Petter Selasky
75297549c34SHans Petter Selasky struct mlx4_qp {
75397549c34SHans Petter Selasky void (*event) (struct mlx4_qp *, enum mlx4_event);
75497549c34SHans Petter Selasky
75597549c34SHans Petter Selasky int qpn;
75697549c34SHans Petter Selasky
75797549c34SHans Petter Selasky atomic_t refcount;
75897549c34SHans Petter Selasky struct completion free;
75997549c34SHans Petter Selasky };
76097549c34SHans Petter Selasky
76197549c34SHans Petter Selasky struct mlx4_srq {
76297549c34SHans Petter Selasky void (*event) (struct mlx4_srq *, enum mlx4_event);
76397549c34SHans Petter Selasky
76497549c34SHans Petter Selasky int srqn;
76597549c34SHans Petter Selasky int max;
76697549c34SHans Petter Selasky int max_gs;
76797549c34SHans Petter Selasky int wqe_shift;
76897549c34SHans Petter Selasky
76997549c34SHans Petter Selasky atomic_t refcount;
77097549c34SHans Petter Selasky struct completion free;
77197549c34SHans Petter Selasky };
77297549c34SHans Petter Selasky
77397549c34SHans Petter Selasky struct mlx4_av {
77497549c34SHans Petter Selasky __be32 port_pd;
77597549c34SHans Petter Selasky u8 reserved1;
77697549c34SHans Petter Selasky u8 g_slid;
77797549c34SHans Petter Selasky __be16 dlid;
77897549c34SHans Petter Selasky u8 reserved2;
77997549c34SHans Petter Selasky u8 gid_index;
78097549c34SHans Petter Selasky u8 stat_rate;
78197549c34SHans Petter Selasky u8 hop_limit;
78297549c34SHans Petter Selasky __be32 sl_tclass_flowlabel;
78397549c34SHans Petter Selasky u8 dgid[16];
78497549c34SHans Petter Selasky };
78597549c34SHans Petter Selasky
78697549c34SHans Petter Selasky struct mlx4_eth_av {
78797549c34SHans Petter Selasky __be32 port_pd;
78897549c34SHans Petter Selasky u8 reserved1;
78997549c34SHans Petter Selasky u8 smac_idx;
79097549c34SHans Petter Selasky u16 reserved2;
79197549c34SHans Petter Selasky u8 reserved3;
79297549c34SHans Petter Selasky u8 gid_index;
79397549c34SHans Petter Selasky u8 stat_rate;
79497549c34SHans Petter Selasky u8 hop_limit;
79597549c34SHans Petter Selasky __be32 sl_tclass_flowlabel;
79697549c34SHans Petter Selasky u8 dgid[16];
79797549c34SHans Petter Selasky u8 s_mac[6];
79897549c34SHans Petter Selasky u8 reserved4[2];
79997549c34SHans Petter Selasky __be16 vlan;
800c3191c2eSHans Petter Selasky u8 mac[ETH_ALEN];
80197549c34SHans Petter Selasky };
80297549c34SHans Petter Selasky
80397549c34SHans Petter Selasky union mlx4_ext_av {
80497549c34SHans Petter Selasky struct mlx4_av ib;
80597549c34SHans Petter Selasky struct mlx4_eth_av eth;
80697549c34SHans Petter Selasky };
80797549c34SHans Petter Selasky
80855b1c6e7SHans Petter Selasky /* Counters should be saturate once they reach their maximum value */
80955b1c6e7SHans Petter Selasky #define ASSIGN_32BIT_COUNTER(counter, value) do { \
81055b1c6e7SHans Petter Selasky if ((value) > U32_MAX) \
81155b1c6e7SHans Petter Selasky counter = cpu_to_be32(U32_MAX); \
81255b1c6e7SHans Petter Selasky else \
81355b1c6e7SHans Petter Selasky counter = cpu_to_be32(value); \
81455b1c6e7SHans Petter Selasky } while (0)
81555b1c6e7SHans Petter Selasky
816c3191c2eSHans Petter Selasky struct mlx4_counter {
81797549c34SHans Petter Selasky u8 reserved1[3];
818c3191c2eSHans Petter Selasky u8 counter_mode;
819c3191c2eSHans Petter Selasky __be32 num_ifc;
820c3191c2eSHans Petter Selasky u32 reserved2[2];
821c3191c2eSHans Petter Selasky __be64 rx_frames;
822c3191c2eSHans Petter Selasky __be64 rx_bytes;
823c3191c2eSHans Petter Selasky __be64 tx_frames;
824c3191c2eSHans Petter Selasky __be64 tx_bytes;
82597549c34SHans Petter Selasky };
82697549c34SHans Petter Selasky
82797549c34SHans Petter Selasky struct mlx4_quotas {
82897549c34SHans Petter Selasky int qp;
82997549c34SHans Petter Selasky int cq;
83097549c34SHans Petter Selasky int srq;
83197549c34SHans Petter Selasky int mpt;
83297549c34SHans Petter Selasky int mtt;
83397549c34SHans Petter Selasky int counter;
83497549c34SHans Petter Selasky int xrcd;
83597549c34SHans Petter Selasky };
83697549c34SHans Petter Selasky
837c3191c2eSHans Petter Selasky struct mlx4_vf_dev {
838c3191c2eSHans Petter Selasky u8 min_port;
839c3191c2eSHans Petter Selasky u8 n_ports;
840c3191c2eSHans Petter Selasky };
841c3191c2eSHans Petter Selasky
842c3191c2eSHans Petter Selasky enum mlx4_pci_status {
843c3191c2eSHans Petter Selasky MLX4_PCI_STATUS_DISABLED,
844c3191c2eSHans Petter Selasky MLX4_PCI_STATUS_ENABLED,
845c3191c2eSHans Petter Selasky };
846c3191c2eSHans Petter Selasky
847c3191c2eSHans Petter Selasky struct mlx4_dev_persistent {
84897549c34SHans Petter Selasky struct pci_dev *pdev;
849c3191c2eSHans Petter Selasky struct mlx4_dev *dev;
850c3191c2eSHans Petter Selasky int nvfs[MLX4_MAX_PORTS + 1];
851c3191c2eSHans Petter Selasky int num_vfs;
852c3191c2eSHans Petter Selasky enum mlx4_port_type curr_port_type[MLX4_MAX_PORTS + 1];
853c3191c2eSHans Petter Selasky enum mlx4_port_type curr_port_poss_type[MLX4_MAX_PORTS + 1];
854c3191c2eSHans Petter Selasky struct work_struct catas_work;
855c3191c2eSHans Petter Selasky struct workqueue_struct *catas_wq;
856c3191c2eSHans Petter Selasky struct mutex device_state_mutex; /* protect HW state */
857c3191c2eSHans Petter Selasky u8 state;
858c3191c2eSHans Petter Selasky struct mutex interface_state_mutex; /* protect SW state */
859c3191c2eSHans Petter Selasky u8 interface_state;
860c3191c2eSHans Petter Selasky struct mutex pci_status_mutex; /* sync pci state */
861c3191c2eSHans Petter Selasky enum mlx4_pci_status pci_status;
862c3191c2eSHans Petter Selasky };
863c3191c2eSHans Petter Selasky
864c3191c2eSHans Petter Selasky struct mlx4_dev {
865c3191c2eSHans Petter Selasky struct mlx4_dev_persistent *persist;
86697549c34SHans Petter Selasky unsigned long flags;
86797549c34SHans Petter Selasky unsigned long num_slaves;
86897549c34SHans Petter Selasky struct mlx4_caps caps;
86997549c34SHans Petter Selasky struct mlx4_phys_caps phys_caps;
87097549c34SHans Petter Selasky struct mlx4_quotas quotas;
87197549c34SHans Petter Selasky struct radix_tree_root qp_table_tree;
87297549c34SHans Petter Selasky u8 rev_id;
873c3191c2eSHans Petter Selasky u8 port_random_macs;
87497549c34SHans Petter Selasky char board_id[MLX4_BOARD_ID_LEN];
87597549c34SHans Petter Selasky int numa_node;
87697549c34SHans Petter Selasky int oper_log_mgm_entry_size;
87797549c34SHans Petter Selasky u64 regid_promisc_array[MLX4_MAX_PORTS + 1];
87897549c34SHans Petter Selasky u64 regid_allmulti_array[MLX4_MAX_PORTS + 1];
879c3191c2eSHans Petter Selasky struct mlx4_vf_dev *dev_vfs;
880c3191c2eSHans Petter Selasky u8 uar_page_shift;
881c8aa6899SSlava Shwartsman struct sysctl_ctx_list hw_ctx;
882c8aa6899SSlava Shwartsman char fw_str[64];
88397549c34SHans Petter Selasky };
88497549c34SHans Petter Selasky
88597549c34SHans Petter Selasky struct mlx4_clock_params {
88697549c34SHans Petter Selasky u64 offset;
88797549c34SHans Petter Selasky u8 bar;
88897549c34SHans Petter Selasky u8 size;
88997549c34SHans Petter Selasky };
89097549c34SHans Petter Selasky
89197549c34SHans Petter Selasky struct mlx4_eqe {
89297549c34SHans Petter Selasky u8 reserved1;
89397549c34SHans Petter Selasky u8 type;
89497549c34SHans Petter Selasky u8 reserved2;
89597549c34SHans Petter Selasky u8 subtype;
89697549c34SHans Petter Selasky union {
89797549c34SHans Petter Selasky u32 raw[6];
89897549c34SHans Petter Selasky struct {
89997549c34SHans Petter Selasky __be32 cqn;
90097549c34SHans Petter Selasky } __packed comp;
90197549c34SHans Petter Selasky struct {
90297549c34SHans Petter Selasky u16 reserved1;
90397549c34SHans Petter Selasky __be16 token;
90497549c34SHans Petter Selasky u32 reserved2;
90597549c34SHans Petter Selasky u8 reserved3[3];
90697549c34SHans Petter Selasky u8 status;
90797549c34SHans Petter Selasky __be64 out_param;
90897549c34SHans Petter Selasky } __packed cmd;
90997549c34SHans Petter Selasky struct {
91097549c34SHans Petter Selasky __be32 qpn;
91197549c34SHans Petter Selasky } __packed qp;
91297549c34SHans Petter Selasky struct {
91397549c34SHans Petter Selasky __be32 srqn;
91497549c34SHans Petter Selasky } __packed srq;
91597549c34SHans Petter Selasky struct {
91697549c34SHans Petter Selasky __be32 cqn;
91797549c34SHans Petter Selasky u32 reserved1;
91897549c34SHans Petter Selasky u8 reserved2[3];
91997549c34SHans Petter Selasky u8 syndrome;
92097549c34SHans Petter Selasky } __packed cq_err;
92197549c34SHans Petter Selasky struct {
92297549c34SHans Petter Selasky u32 reserved1[2];
92397549c34SHans Petter Selasky __be32 port;
92497549c34SHans Petter Selasky } __packed port_change;
92597549c34SHans Petter Selasky struct {
92697549c34SHans Petter Selasky #define COMM_CHANNEL_BIT_ARRAY_SIZE 4
92797549c34SHans Petter Selasky u32 reserved;
92897549c34SHans Petter Selasky u32 bit_vec[COMM_CHANNEL_BIT_ARRAY_SIZE];
92997549c34SHans Petter Selasky } __packed comm_channel_arm;
93097549c34SHans Petter Selasky struct {
93197549c34SHans Petter Selasky u8 port;
93297549c34SHans Petter Selasky u8 reserved[3];
93397549c34SHans Petter Selasky __be64 mac;
93497549c34SHans Petter Selasky } __packed mac_update;
93597549c34SHans Petter Selasky struct {
93697549c34SHans Petter Selasky __be32 slave_id;
93797549c34SHans Petter Selasky } __packed flr_event;
93897549c34SHans Petter Selasky struct {
93997549c34SHans Petter Selasky __be16 current_temperature;
94097549c34SHans Petter Selasky __be16 warning_threshold;
94197549c34SHans Petter Selasky } __packed warming;
94297549c34SHans Petter Selasky struct {
94397549c34SHans Petter Selasky u8 reserved[3];
94497549c34SHans Petter Selasky u8 port;
94597549c34SHans Petter Selasky union {
94697549c34SHans Petter Selasky struct {
94797549c34SHans Petter Selasky __be16 mstr_sm_lid;
94897549c34SHans Petter Selasky __be16 port_lid;
94997549c34SHans Petter Selasky __be32 changed_attr;
95097549c34SHans Petter Selasky u8 reserved[3];
95197549c34SHans Petter Selasky u8 mstr_sm_sl;
95297549c34SHans Petter Selasky __be64 gid_prefix;
95397549c34SHans Petter Selasky } __packed port_info;
95497549c34SHans Petter Selasky struct {
95597549c34SHans Petter Selasky __be32 block_ptr;
95697549c34SHans Petter Selasky __be32 tbl_entries_mask;
95797549c34SHans Petter Selasky } __packed tbl_change_info;
958c3191c2eSHans Petter Selasky struct {
959c3191c2eSHans Petter Selasky u8 sl2vl_table[8];
960c3191c2eSHans Petter Selasky } __packed sl2vl_tbl_change_info;
96197549c34SHans Petter Selasky } params;
96297549c34SHans Petter Selasky } __packed port_mgmt_change;
96397549c34SHans Petter Selasky struct {
96497549c34SHans Petter Selasky u8 reserved[3];
96597549c34SHans Petter Selasky u8 port;
96697549c34SHans Petter Selasky u32 reserved1[5];
96797549c34SHans Petter Selasky } __packed bad_cable;
96897549c34SHans Petter Selasky } event;
96997549c34SHans Petter Selasky u8 slave_id;
97097549c34SHans Petter Selasky u8 reserved3[2];
97197549c34SHans Petter Selasky u8 owner;
97297549c34SHans Petter Selasky } __packed;
97397549c34SHans Petter Selasky
97497549c34SHans Petter Selasky struct mlx4_init_port_param {
97597549c34SHans Petter Selasky int set_guid0;
97697549c34SHans Petter Selasky int set_node_guid;
97797549c34SHans Petter Selasky int set_si_guid;
97897549c34SHans Petter Selasky u16 mtu;
97997549c34SHans Petter Selasky int port_width_cap;
98097549c34SHans Petter Selasky u16 vl_cap;
98197549c34SHans Petter Selasky u16 max_gid;
98297549c34SHans Petter Selasky u16 max_pkey;
98397549c34SHans Petter Selasky u64 guid0;
98497549c34SHans Petter Selasky u64 node_guid;
98597549c34SHans Petter Selasky u64 si_guid;
98697549c34SHans Petter Selasky };
98797549c34SHans Petter Selasky
98897549c34SHans Petter Selasky #define MAD_IFC_DATA_SZ 192
98997549c34SHans Petter Selasky /* MAD IFC Mailbox */
99097549c34SHans Petter Selasky struct mlx4_mad_ifc {
99197549c34SHans Petter Selasky u8 base_version;
99297549c34SHans Petter Selasky u8 mgmt_class;
99397549c34SHans Petter Selasky u8 class_version;
99497549c34SHans Petter Selasky u8 method;
99597549c34SHans Petter Selasky __be16 status;
99697549c34SHans Petter Selasky __be16 class_specific;
99797549c34SHans Petter Selasky __be64 tid;
99897549c34SHans Petter Selasky __be16 attr_id;
99997549c34SHans Petter Selasky __be16 resv;
100097549c34SHans Petter Selasky __be32 attr_mod;
100197549c34SHans Petter Selasky __be64 mkey;
100297549c34SHans Petter Selasky __be16 dr_slid;
100397549c34SHans Petter Selasky __be16 dr_dlid;
100497549c34SHans Petter Selasky u8 reserved[28];
100597549c34SHans Petter Selasky u8 data[MAD_IFC_DATA_SZ];
100697549c34SHans Petter Selasky } __packed;
100797549c34SHans Petter Selasky
100897549c34SHans Petter Selasky #define mlx4_foreach_port(port, dev, type) \
100997549c34SHans Petter Selasky for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \
101097549c34SHans Petter Selasky if ((type) == (dev)->caps.port_mask[(port)])
101197549c34SHans Petter Selasky
101297549c34SHans Petter Selasky #define mlx4_foreach_ib_transport_port(port, dev) \
101397549c34SHans Petter Selasky for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \
101497549c34SHans Petter Selasky if (((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_IB) || \
1015c3191c2eSHans Petter Selasky ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE) || \
1016c3191c2eSHans Petter Selasky ((dev)->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2))
101797549c34SHans Petter Selasky
101897549c34SHans Petter Selasky #define MLX4_INVALID_SLAVE_ID 0xFF
1019c3191c2eSHans Petter Selasky #define MLX4_SINK_COUNTER_INDEX(dev) (dev->caps.max_counters - 1)
102097549c34SHans Petter Selasky
102197549c34SHans Petter Selasky void handle_port_mgmt_change_event(struct work_struct *work);
102297549c34SHans Petter Selasky
mlx4_master_func_num(struct mlx4_dev * dev)102397549c34SHans Petter Selasky static inline int mlx4_master_func_num(struct mlx4_dev *dev)
102497549c34SHans Petter Selasky {
102597549c34SHans Petter Selasky return dev->caps.function;
102697549c34SHans Petter Selasky }
102797549c34SHans Petter Selasky
mlx4_is_master(struct mlx4_dev * dev)102897549c34SHans Petter Selasky static inline int mlx4_is_master(struct mlx4_dev *dev)
102997549c34SHans Petter Selasky {
103097549c34SHans Petter Selasky return dev->flags & MLX4_FLAG_MASTER;
103197549c34SHans Petter Selasky }
103297549c34SHans Petter Selasky
mlx4_num_reserved_sqps(struct mlx4_dev * dev)103397549c34SHans Petter Selasky static inline int mlx4_num_reserved_sqps(struct mlx4_dev *dev)
103497549c34SHans Petter Selasky {
103597549c34SHans Petter Selasky return dev->phys_caps.base_sqpn + 8 +
103697549c34SHans Petter Selasky 16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev);
103797549c34SHans Petter Selasky }
103897549c34SHans Petter Selasky
mlx4_is_qp_reserved(struct mlx4_dev * dev,u32 qpn)103997549c34SHans Petter Selasky static inline int mlx4_is_qp_reserved(struct mlx4_dev *dev, u32 qpn)
104097549c34SHans Petter Selasky {
104197549c34SHans Petter Selasky return (qpn < dev->phys_caps.base_sqpn + 8 +
1042c3191c2eSHans Petter Selasky 16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev) &&
1043c3191c2eSHans Petter Selasky qpn >= dev->phys_caps.base_sqpn) ||
1044c3191c2eSHans Petter Selasky (qpn < dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW]);
104597549c34SHans Petter Selasky }
104697549c34SHans Petter Selasky
mlx4_is_guest_proxy(struct mlx4_dev * dev,int slave,u32 qpn)104797549c34SHans Petter Selasky static inline int mlx4_is_guest_proxy(struct mlx4_dev *dev, int slave, u32 qpn)
104897549c34SHans Petter Selasky {
104997549c34SHans Petter Selasky int guest_proxy_base = dev->phys_caps.base_proxy_sqpn + slave * 8;
105097549c34SHans Petter Selasky
105197549c34SHans Petter Selasky if (qpn >= guest_proxy_base && qpn < guest_proxy_base + 8)
105297549c34SHans Petter Selasky return 1;
105397549c34SHans Petter Selasky
105497549c34SHans Petter Selasky return 0;
105597549c34SHans Petter Selasky }
105697549c34SHans Petter Selasky
mlx4_is_mfunc(struct mlx4_dev * dev)105797549c34SHans Petter Selasky static inline int mlx4_is_mfunc(struct mlx4_dev *dev)
105897549c34SHans Petter Selasky {
105997549c34SHans Petter Selasky return dev->flags & (MLX4_FLAG_SLAVE | MLX4_FLAG_MASTER);
106097549c34SHans Petter Selasky }
106197549c34SHans Petter Selasky
mlx4_is_slave(struct mlx4_dev * dev)106297549c34SHans Petter Selasky static inline int mlx4_is_slave(struct mlx4_dev *dev)
106397549c34SHans Petter Selasky {
106497549c34SHans Petter Selasky return dev->flags & MLX4_FLAG_SLAVE;
106597549c34SHans Petter Selasky }
106697549c34SHans Petter Selasky
mlx4_is_eth(struct mlx4_dev * dev,int port)1067c3191c2eSHans Petter Selasky static inline int mlx4_is_eth(struct mlx4_dev *dev, int port)
1068c3191c2eSHans Petter Selasky {
1069c3191c2eSHans Petter Selasky return dev->caps.port_type[port] == MLX4_PORT_TYPE_IB ? 0 : 1;
1070c3191c2eSHans Petter Selasky }
1071c3191c2eSHans Petter Selasky
107297549c34SHans Petter Selasky int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
1073c3191c2eSHans Petter Selasky struct mlx4_buf *buf, gfp_t gfp);
107497549c34SHans Petter Selasky void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf);
mlx4_buf_offset(struct mlx4_buf * buf,int offset)107597549c34SHans Petter Selasky static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset)
107697549c34SHans Petter Selasky {
107797549c34SHans Petter Selasky if (BITS_PER_LONG == 64 || buf->nbufs == 1)
107897549c34SHans Petter Selasky return (u8 *)buf->direct.buf + offset;
107997549c34SHans Petter Selasky else
108097549c34SHans Petter Selasky return (u8 *)buf->page_list[offset >> PAGE_SHIFT].buf +
108197549c34SHans Petter Selasky (offset & (PAGE_SIZE - 1));
108297549c34SHans Petter Selasky }
108397549c34SHans Petter Selasky
108497549c34SHans Petter Selasky int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn);
108597549c34SHans Petter Selasky void mlx4_pd_free(struct mlx4_dev *dev, u32 pdn);
108697549c34SHans Petter Selasky int mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
108797549c34SHans Petter Selasky void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
108897549c34SHans Petter Selasky
108997549c34SHans Petter Selasky int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar);
109097549c34SHans Petter Selasky void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar);
109197549c34SHans Petter Selasky int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, int node);
109297549c34SHans Petter Selasky void mlx4_bf_free(struct mlx4_dev *dev, struct mlx4_bf *bf);
109397549c34SHans Petter Selasky
109497549c34SHans Petter Selasky int mlx4_mtt_init(struct mlx4_dev *dev, int npages, int page_shift,
109597549c34SHans Petter Selasky struct mlx4_mtt *mtt);
109697549c34SHans Petter Selasky void mlx4_mtt_cleanup(struct mlx4_dev *dev, struct mlx4_mtt *mtt);
109797549c34SHans Petter Selasky u64 mlx4_mtt_addr(struct mlx4_dev *dev, struct mlx4_mtt *mtt);
109897549c34SHans Petter Selasky
109997549c34SHans Petter Selasky int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access,
110097549c34SHans Petter Selasky int npages, int page_shift, struct mlx4_mr *mr);
110197549c34SHans Petter Selasky int mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr);
110297549c34SHans Petter Selasky int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr);
110397549c34SHans Petter Selasky int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, enum mlx4_mw_type type,
110497549c34SHans Petter Selasky struct mlx4_mw *mw);
110597549c34SHans Petter Selasky void mlx4_mw_free(struct mlx4_dev *dev, struct mlx4_mw *mw);
110697549c34SHans Petter Selasky int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw);
110797549c34SHans Petter Selasky int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
110897549c34SHans Petter Selasky int start_index, int npages, u64 *page_list);
110997549c34SHans Petter Selasky int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
1110c3191c2eSHans Petter Selasky struct mlx4_buf *buf, gfp_t gfp);
111197549c34SHans Petter Selasky
1112c3191c2eSHans Petter Selasky int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order,
1113c3191c2eSHans Petter Selasky gfp_t gfp);
111497549c34SHans Petter Selasky void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db);
111597549c34SHans Petter Selasky
111697549c34SHans Petter Selasky int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres,
111797549c34SHans Petter Selasky int size, int max_direct);
111897549c34SHans Petter Selasky void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres,
111997549c34SHans Petter Selasky int size);
112097549c34SHans Petter Selasky
112197549c34SHans Petter Selasky int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
112297549c34SHans Petter Selasky struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq,
112397549c34SHans Petter Selasky unsigned vector, int collapsed, int timestamp_en);
112497549c34SHans Petter Selasky void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq);
112597549c34SHans Petter Selasky int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
112697549c34SHans Petter Selasky int *base, u8 flags);
112797549c34SHans Petter Selasky void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
112897549c34SHans Petter Selasky
1129c3191c2eSHans Petter Selasky int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp,
1130c3191c2eSHans Petter Selasky gfp_t gfp);
113197549c34SHans Petter Selasky void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp);
113297549c34SHans Petter Selasky
113397549c34SHans Petter Selasky int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn,
113497549c34SHans Petter Selasky struct mlx4_mtt *mtt, u64 db_rec, struct mlx4_srq *srq);
113597549c34SHans Petter Selasky void mlx4_srq_free(struct mlx4_dev *dev, struct mlx4_srq *srq);
113697549c34SHans Petter Selasky int mlx4_srq_arm(struct mlx4_dev *dev, struct mlx4_srq *srq, int limit_watermark);
113797549c34SHans Petter Selasky int mlx4_srq_query(struct mlx4_dev *dev, struct mlx4_srq *srq, int *limit_watermark);
113897549c34SHans Petter Selasky
113997549c34SHans Petter Selasky int mlx4_INIT_PORT(struct mlx4_dev *dev, int port);
114097549c34SHans Petter Selasky int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
114197549c34SHans Petter Selasky
114297549c34SHans Petter Selasky int mlx4_unicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
114397549c34SHans Petter Selasky int block_mcast_loopback, enum mlx4_protocol prot);
114497549c34SHans Petter Selasky int mlx4_unicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
114597549c34SHans Petter Selasky enum mlx4_protocol prot);
114697549c34SHans Petter Selasky int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
114797549c34SHans Petter Selasky u8 port, int block_mcast_loopback,
114897549c34SHans Petter Selasky enum mlx4_protocol protocol, u64 *reg_id);
114997549c34SHans Petter Selasky int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
115097549c34SHans Petter Selasky enum mlx4_protocol protocol, u64 reg_id);
115197549c34SHans Petter Selasky
115297549c34SHans Petter Selasky enum {
115397549c34SHans Petter Selasky MLX4_DOMAIN_UVERBS = 0x1000,
115497549c34SHans Petter Selasky MLX4_DOMAIN_ETHTOOL = 0x2000,
115597549c34SHans Petter Selasky MLX4_DOMAIN_RFS = 0x3000,
115697549c34SHans Petter Selasky MLX4_DOMAIN_NIC = 0x5000,
115797549c34SHans Petter Selasky };
115897549c34SHans Petter Selasky
115997549c34SHans Petter Selasky enum mlx4_net_trans_rule_id {
116097549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_ETH = 0,
116197549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_IB,
116297549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_IPV6,
116397549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_IPV4,
116497549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_TCP,
116597549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_UDP,
1166c3191c2eSHans Petter Selasky MLX4_NET_TRANS_RULE_ID_VXLAN,
116797549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_NUM, /* should be last */
116897549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_DUMMY = -1, /* force enum to be signed */
116997549c34SHans Petter Selasky };
117097549c34SHans Petter Selasky
117197549c34SHans Petter Selasky extern const u16 __sw_id_hw[];
117297549c34SHans Petter Selasky
map_hw_to_sw_id(u16 header_id)117397549c34SHans Petter Selasky static inline int map_hw_to_sw_id(u16 header_id)
117497549c34SHans Petter Selasky {
117597549c34SHans Petter Selasky
117697549c34SHans Petter Selasky int i;
117797549c34SHans Petter Selasky for (i = 0; i < MLX4_NET_TRANS_RULE_NUM; i++) {
117897549c34SHans Petter Selasky if (header_id == __sw_id_hw[i])
117997549c34SHans Petter Selasky return i;
118097549c34SHans Petter Selasky }
118197549c34SHans Petter Selasky return -EINVAL;
118297549c34SHans Petter Selasky }
118397549c34SHans Petter Selasky
118497549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode {
118597549c34SHans Petter Selasky MLX4_FS_REGULAR = 1,
118697549c34SHans Petter Selasky MLX4_FS_ALL_DEFAULT,
118797549c34SHans Petter Selasky MLX4_FS_MC_DEFAULT,
1188c3191c2eSHans Petter Selasky MLX4_FS_MIRROR_RX_PORT,
1189c3191c2eSHans Petter Selasky MLX4_FS_MIRROR_SX_PORT,
119097549c34SHans Petter Selasky MLX4_FS_UC_SNIFFER,
119197549c34SHans Petter Selasky MLX4_FS_MC_SNIFFER,
119297549c34SHans Petter Selasky MLX4_FS_MODE_NUM, /* should be last */
119397549c34SHans Petter Selasky MLX4_FS_MODE_DUMMY = -1, /* force enum to be signed */
119497549c34SHans Petter Selasky };
119597549c34SHans Petter Selasky
119697549c34SHans Petter Selasky struct mlx4_spec_eth {
1197c3191c2eSHans Petter Selasky u8 dst_mac[ETH_ALEN];
1198c3191c2eSHans Petter Selasky u8 dst_mac_msk[ETH_ALEN];
1199c3191c2eSHans Petter Selasky u8 src_mac[ETH_ALEN];
1200c3191c2eSHans Petter Selasky u8 src_mac_msk[ETH_ALEN];
120197549c34SHans Petter Selasky u8 ether_type_enable;
120297549c34SHans Petter Selasky __be16 ether_type;
120397549c34SHans Petter Selasky __be16 vlan_id_msk;
120497549c34SHans Petter Selasky __be16 vlan_id;
120597549c34SHans Petter Selasky };
120697549c34SHans Petter Selasky
120797549c34SHans Petter Selasky struct mlx4_spec_tcp_udp {
120897549c34SHans Petter Selasky __be16 dst_port;
120997549c34SHans Petter Selasky __be16 dst_port_msk;
121097549c34SHans Petter Selasky __be16 src_port;
121197549c34SHans Petter Selasky __be16 src_port_msk;
121297549c34SHans Petter Selasky };
121397549c34SHans Petter Selasky
121497549c34SHans Petter Selasky struct mlx4_spec_ipv4 {
121597549c34SHans Petter Selasky __be32 dst_ip;
121697549c34SHans Petter Selasky __be32 dst_ip_msk;
121797549c34SHans Petter Selasky __be32 src_ip;
121897549c34SHans Petter Selasky __be32 src_ip_msk;
121997549c34SHans Petter Selasky };
122097549c34SHans Petter Selasky
122197549c34SHans Petter Selasky struct mlx4_spec_ib {
122297549c34SHans Petter Selasky __be32 l3_qpn;
122397549c34SHans Petter Selasky __be32 qpn_msk;
122497549c34SHans Petter Selasky u8 dst_gid[16];
122597549c34SHans Petter Selasky u8 dst_gid_msk[16];
122697549c34SHans Petter Selasky };
122797549c34SHans Petter Selasky
1228c3191c2eSHans Petter Selasky struct mlx4_spec_vxlan {
1229c3191c2eSHans Petter Selasky __be32 vni;
1230c3191c2eSHans Petter Selasky __be32 vni_mask;
1231c3191c2eSHans Petter Selasky
1232c3191c2eSHans Petter Selasky };
1233c3191c2eSHans Petter Selasky
123497549c34SHans Petter Selasky struct mlx4_spec_list {
123597549c34SHans Petter Selasky struct list_head list;
123697549c34SHans Petter Selasky enum mlx4_net_trans_rule_id id;
123797549c34SHans Petter Selasky union {
123897549c34SHans Petter Selasky struct mlx4_spec_eth eth;
123997549c34SHans Petter Selasky struct mlx4_spec_ib ib;
124097549c34SHans Petter Selasky struct mlx4_spec_ipv4 ipv4;
124197549c34SHans Petter Selasky struct mlx4_spec_tcp_udp tcp_udp;
1242c3191c2eSHans Petter Selasky struct mlx4_spec_vxlan vxlan;
124397549c34SHans Petter Selasky };
124497549c34SHans Petter Selasky };
124597549c34SHans Petter Selasky
124697549c34SHans Petter Selasky enum mlx4_net_trans_hw_rule_queue {
124797549c34SHans Petter Selasky MLX4_NET_TRANS_Q_FIFO,
124897549c34SHans Petter Selasky MLX4_NET_TRANS_Q_LIFO,
124997549c34SHans Petter Selasky };
125097549c34SHans Petter Selasky
125197549c34SHans Petter Selasky struct mlx4_net_trans_rule {
125297549c34SHans Petter Selasky struct list_head list;
125397549c34SHans Petter Selasky enum mlx4_net_trans_hw_rule_queue queue_mode;
125497549c34SHans Petter Selasky bool exclusive;
125597549c34SHans Petter Selasky bool allow_loopback;
125697549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode promisc_mode;
125797549c34SHans Petter Selasky u8 port;
125897549c34SHans Petter Selasky u16 priority;
125997549c34SHans Petter Selasky u32 qpn;
126097549c34SHans Petter Selasky };
126197549c34SHans Petter Selasky
126297549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ctrl {
126397549c34SHans Petter Selasky __be16 prio;
126497549c34SHans Petter Selasky u8 type;
126597549c34SHans Petter Selasky u8 flags;
126697549c34SHans Petter Selasky u8 rsvd1;
126797549c34SHans Petter Selasky u8 funcid;
126897549c34SHans Petter Selasky u8 vep;
126997549c34SHans Petter Selasky u8 port;
127097549c34SHans Petter Selasky __be32 qpn;
127197549c34SHans Petter Selasky __be32 rsvd2;
127297549c34SHans Petter Selasky };
127397549c34SHans Petter Selasky
127497549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ib {
127597549c34SHans Petter Selasky u8 size;
127697549c34SHans Petter Selasky u8 rsvd1;
127797549c34SHans Petter Selasky __be16 id;
127897549c34SHans Petter Selasky u32 rsvd2;
127997549c34SHans Petter Selasky __be32 l3_qpn;
128097549c34SHans Petter Selasky __be32 qpn_mask;
128197549c34SHans Petter Selasky u8 dst_gid[16];
128297549c34SHans Petter Selasky u8 dst_gid_msk[16];
128397549c34SHans Petter Selasky } __packed;
128497549c34SHans Petter Selasky
128597549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_eth {
128697549c34SHans Petter Selasky u8 size;
128797549c34SHans Petter Selasky u8 rsvd;
128897549c34SHans Petter Selasky __be16 id;
128997549c34SHans Petter Selasky u8 rsvd1[6];
129097549c34SHans Petter Selasky u8 dst_mac[6];
129197549c34SHans Petter Selasky u16 rsvd2;
129297549c34SHans Petter Selasky u8 dst_mac_msk[6];
129397549c34SHans Petter Selasky u16 rsvd3;
129497549c34SHans Petter Selasky u8 src_mac[6];
129597549c34SHans Petter Selasky u16 rsvd4;
129697549c34SHans Petter Selasky u8 src_mac_msk[6];
129797549c34SHans Petter Selasky u8 rsvd5;
129897549c34SHans Petter Selasky u8 ether_type_enable;
129997549c34SHans Petter Selasky __be16 ether_type;
130097549c34SHans Petter Selasky __be16 vlan_tag_msk;
130197549c34SHans Petter Selasky __be16 vlan_tag;
130297549c34SHans Petter Selasky } __packed;
130397549c34SHans Petter Selasky
130497549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_tcp_udp {
130597549c34SHans Petter Selasky u8 size;
130697549c34SHans Petter Selasky u8 rsvd;
130797549c34SHans Petter Selasky __be16 id;
130897549c34SHans Petter Selasky __be16 rsvd1[3];
130997549c34SHans Petter Selasky __be16 dst_port;
131097549c34SHans Petter Selasky __be16 rsvd2;
131197549c34SHans Petter Selasky __be16 dst_port_msk;
131297549c34SHans Petter Selasky __be16 rsvd3;
131397549c34SHans Petter Selasky __be16 src_port;
131497549c34SHans Petter Selasky __be16 rsvd4;
131597549c34SHans Petter Selasky __be16 src_port_msk;
131697549c34SHans Petter Selasky } __packed;
131797549c34SHans Petter Selasky
131897549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ipv4 {
131997549c34SHans Petter Selasky u8 size;
132097549c34SHans Petter Selasky u8 rsvd;
132197549c34SHans Petter Selasky __be16 id;
132297549c34SHans Petter Selasky __be32 rsvd1;
132397549c34SHans Petter Selasky __be32 dst_ip;
132497549c34SHans Petter Selasky __be32 dst_ip_msk;
132597549c34SHans Petter Selasky __be32 src_ip;
132697549c34SHans Petter Selasky __be32 src_ip_msk;
132797549c34SHans Petter Selasky } __packed;
132897549c34SHans Petter Selasky
1329c3191c2eSHans Petter Selasky struct mlx4_net_trans_rule_hw_vxlan {
1330c3191c2eSHans Petter Selasky u8 size;
1331c3191c2eSHans Petter Selasky u8 rsvd;
1332c3191c2eSHans Petter Selasky __be16 id;
1333c3191c2eSHans Petter Selasky __be32 rsvd1;
1334c3191c2eSHans Petter Selasky __be32 vni;
1335c3191c2eSHans Petter Selasky __be32 vni_mask;
1336c3191c2eSHans Petter Selasky } __packed;
1337c3191c2eSHans Petter Selasky
133897549c34SHans Petter Selasky struct _rule_hw {
133997549c34SHans Petter Selasky union {
134097549c34SHans Petter Selasky struct {
134197549c34SHans Petter Selasky u8 size;
134297549c34SHans Petter Selasky u8 rsvd;
134397549c34SHans Petter Selasky __be16 id;
134497549c34SHans Petter Selasky };
134597549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_eth eth;
134697549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ib ib;
134797549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ipv4 ipv4;
134897549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp;
1349c3191c2eSHans Petter Selasky struct mlx4_net_trans_rule_hw_vxlan vxlan;
135097549c34SHans Petter Selasky };
135197549c34SHans Petter Selasky };
135297549c34SHans Petter Selasky
1353c3191c2eSHans Petter Selasky enum {
1354c3191c2eSHans Petter Selasky VXLAN_STEER_BY_OUTER_MAC = 1 << 0,
1355c3191c2eSHans Petter Selasky VXLAN_STEER_BY_OUTER_VLAN = 1 << 1,
1356c3191c2eSHans Petter Selasky VXLAN_STEER_BY_VSID_VNI = 1 << 2,
1357c3191c2eSHans Petter Selasky VXLAN_STEER_BY_INNER_MAC = 1 << 3,
1358c3191c2eSHans Petter Selasky VXLAN_STEER_BY_INNER_VLAN = 1 << 4,
1359c3191c2eSHans Petter Selasky };
1360c3191c2eSHans Petter Selasky
1361c3191c2eSHans Petter Selasky enum {
1362c3191c2eSHans Petter Selasky MLX4_OP_MOD_QUERY_TRANSPORT_CI_ERRORS = 0x2,
1363c3191c2eSHans Petter Selasky };
1364c3191c2eSHans Petter Selasky
136597549c34SHans Petter Selasky int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, u32 qpn,
136697549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode mode);
136797549c34SHans Petter Selasky int mlx4_flow_steer_promisc_remove(struct mlx4_dev *dev, u8 port,
136897549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode mode);
136997549c34SHans Petter Selasky int mlx4_multicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
137097549c34SHans Petter Selasky int mlx4_multicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
137197549c34SHans Petter Selasky int mlx4_unicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port);
137297549c34SHans Petter Selasky int mlx4_unicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port);
1373c3191c2eSHans Petter Selasky int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode);
137497549c34SHans Petter Selasky
137597549c34SHans Petter Selasky int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
137697549c34SHans Petter Selasky void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
137797549c34SHans Petter Selasky int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port);
137897549c34SHans Petter Selasky int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac);
137997549c34SHans Petter Selasky int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
138097549c34SHans Petter Selasky u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
138197549c34SHans Petter Selasky int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
138297549c34SHans Petter Selasky u8 promisc);
1383c3191c2eSHans Petter Selasky int mlx4_SET_PORT_BEACON(struct mlx4_dev *dev, u8 port, u16 time);
1384c3191c2eSHans Petter Selasky int mlx4_SET_PORT_fcs_check(struct mlx4_dev *dev, u8 port,
1385c3191c2eSHans Petter Selasky u8 ignore_fcs_value);
1386c3191c2eSHans Petter Selasky int mlx4_SET_PORT_VXLAN(struct mlx4_dev *dev, u8 port, u8 steering, int enable);
1387c3191c2eSHans Petter Selasky int set_phv_bit(struct mlx4_dev *dev, u8 port, int new_val);
1388c3191c2eSHans Petter Selasky int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv);
1389c3191c2eSHans Petter Selasky int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port,
1390c3191c2eSHans Petter Selasky bool *vlan_offload_disabled);
1391c3191c2eSHans Petter Selasky int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
139297549c34SHans Petter Selasky int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
139397549c34SHans Petter Selasky int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
139497549c34SHans Petter Selasky void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan);
139597549c34SHans Petter Selasky
139697549c34SHans Petter Selasky int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list,
139797549c34SHans Petter Selasky int npages, u64 iova, u32 *lkey, u32 *rkey);
139897549c34SHans Petter Selasky int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
139997549c34SHans Petter Selasky int max_maps, u8 page_shift, struct mlx4_fmr *fmr);
140097549c34SHans Petter Selasky int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr);
140197549c34SHans Petter Selasky void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr,
140297549c34SHans Petter Selasky u32 *lkey, u32 *rkey);
140397549c34SHans Petter Selasky int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr);
140497549c34SHans Petter Selasky int mlx4_SYNC_TPT(struct mlx4_dev *dev);
1405c3191c2eSHans Petter Selasky int mlx4_test_interrupt(struct mlx4_dev *dev, int vector);
1406c3191c2eSHans Petter Selasky int mlx4_test_async(struct mlx4_dev *dev);
1407c3191c2eSHans Petter Selasky int mlx4_query_diag_counters(struct mlx4_dev *dev, u8 op_modifier,
1408c3191c2eSHans Petter Selasky const u32 offset[], u32 value[],
1409c3191c2eSHans Petter Selasky size_t array_len, u8 port);
1410c3191c2eSHans Petter Selasky u32 mlx4_get_eqs_per_port(struct mlx4_dev *dev, u8 port);
1411c3191c2eSHans Petter Selasky bool mlx4_is_eq_vector_valid(struct mlx4_dev *dev, u8 port, int vector);
1412c3191c2eSHans Petter Selasky int mlx4_assign_eq(struct mlx4_dev *dev, u8 port, int *vector);
141397549c34SHans Petter Selasky void mlx4_release_eq(struct mlx4_dev *dev, int vec);
141497549c34SHans Petter Selasky
1415c3191c2eSHans Petter Selasky int mlx4_is_eq_shared(struct mlx4_dev *dev, int vector);
1416c3191c2eSHans Petter Selasky int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec);
1417c3191c2eSHans Petter Selasky
1418c3191c2eSHans Petter Selasky int mlx4_get_phys_port_id(struct mlx4_dev *dev);
141997549c34SHans Petter Selasky int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port);
142097549c34SHans Petter Selasky int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port);
142197549c34SHans Petter Selasky
1422c3191c2eSHans Petter Selasky int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx);
1423c3191c2eSHans Petter Selasky void mlx4_counter_free(struct mlx4_dev *dev, u32 idx);
1424c3191c2eSHans Petter Selasky int mlx4_get_default_counter_index(struct mlx4_dev *dev, int port);
142597549c34SHans Petter Selasky
1426c3191c2eSHans Petter Selasky void mlx4_set_admin_guid(struct mlx4_dev *dev, __be64 guid, int entry,
1427c3191c2eSHans Petter Selasky int port);
1428c3191c2eSHans Petter Selasky __be64 mlx4_get_admin_guid(struct mlx4_dev *dev, int entry, int port);
1429c3191c2eSHans Petter Selasky void mlx4_set_random_admin_guid(struct mlx4_dev *dev, int entry, int port);
143097549c34SHans Petter Selasky int mlx4_flow_attach(struct mlx4_dev *dev,
143197549c34SHans Petter Selasky struct mlx4_net_trans_rule *rule, u64 *reg_id);
143297549c34SHans Petter Selasky int mlx4_flow_detach(struct mlx4_dev *dev, u64 reg_id);
1433c3191c2eSHans Petter Selasky int mlx4_map_sw_to_hw_steering_mode(struct mlx4_dev *dev,
143497549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode flow_type);
1435c3191c2eSHans Petter Selasky int mlx4_map_sw_to_hw_steering_id(struct mlx4_dev *dev,
143697549c34SHans Petter Selasky enum mlx4_net_trans_rule_id id);
1437c3191c2eSHans Petter Selasky int mlx4_hw_rule_sz(struct mlx4_dev *dev, enum mlx4_net_trans_rule_id id);
1438c3191c2eSHans Petter Selasky
1439c3191c2eSHans Petter Selasky int mlx4_tunnel_steer_add(struct mlx4_dev *dev, unsigned char *addr,
1440c3191c2eSHans Petter Selasky int port, int qpn, u16 prio, u64 *reg_id);
144197549c34SHans Petter Selasky
144297549c34SHans Petter Selasky void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port,
144397549c34SHans Petter Selasky int i, int val);
144497549c34SHans Petter Selasky
144597549c34SHans Petter Selasky int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey);
144697549c34SHans Petter Selasky
144797549c34SHans Petter Selasky int mlx4_is_slave_active(struct mlx4_dev *dev, int slave);
144897549c34SHans Petter Selasky int mlx4_gen_pkey_eqe(struct mlx4_dev *dev, int slave, u8 port);
144997549c34SHans Petter Selasky int mlx4_gen_guid_change_eqe(struct mlx4_dev *dev, int slave, u8 port);
1450c3191c2eSHans Petter Selasky int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr);
145197549c34SHans Petter Selasky int mlx4_gen_port_state_change_eqe(struct mlx4_dev *dev, int slave, u8 port, u8 port_subtype_change);
145297549c34SHans Petter Selasky enum slave_port_state mlx4_get_slave_port_state(struct mlx4_dev *dev, int slave, u8 port);
145397549c34SHans 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);
145497549c34SHans Petter Selasky
145597549c34SHans Petter Selasky void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid);
145697549c34SHans Petter Selasky __be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave);
145797549c34SHans Petter Selasky
1458c3191c2eSHans Petter Selasky int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid,
1459c3191c2eSHans Petter Selasky int *slave_id);
1460c3191c2eSHans Petter Selasky int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev, int port, int slave_id,
1461c3191c2eSHans Petter Selasky u8 *gid);
1462c3191c2eSHans Petter Selasky
1463c3191c2eSHans Petter Selasky int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn,
1464c3191c2eSHans Petter Selasky u32 max_range_qpn);
146597549c34SHans Petter Selasky
1466b0259ad3SHans Petter Selasky s64 mlx4_read_clock(struct mlx4_dev *dev);
1467c3191c2eSHans Petter Selasky
1468c3191c2eSHans Petter Selasky struct mlx4_active_ports {
1469c3191c2eSHans Petter Selasky DECLARE_BITMAP(ports, MLX4_MAX_PORTS);
1470c3191c2eSHans Petter Selasky };
1471c3191c2eSHans Petter Selasky /* Returns a bitmap of the physical ports which are assigned to slave */
1472c3191c2eSHans Petter Selasky struct mlx4_active_ports mlx4_get_active_ports(struct mlx4_dev *dev, int slave);
1473c3191c2eSHans Petter Selasky
1474c3191c2eSHans Petter Selasky /* Returns the physical port that represents the virtual port of the slave, */
1475c3191c2eSHans Petter Selasky /* or a value < 0 in case of an error. If a slave has 2 ports, the identity */
1476c3191c2eSHans Petter Selasky /* mapping is returned. */
1477c3191c2eSHans Petter Selasky int mlx4_slave_convert_port(struct mlx4_dev *dev, int slave, int port);
1478c3191c2eSHans Petter Selasky
1479c3191c2eSHans Petter Selasky struct mlx4_slaves_pport {
1480c3191c2eSHans Petter Selasky DECLARE_BITMAP(slaves, MLX4_MFUNC_MAX);
1481c3191c2eSHans Petter Selasky };
1482c3191c2eSHans Petter Selasky /* Returns a bitmap of all slaves that are assigned to port. */
1483c3191c2eSHans Petter Selasky struct mlx4_slaves_pport mlx4_phys_to_slaves_pport(struct mlx4_dev *dev,
1484c3191c2eSHans Petter Selasky int port);
1485c3191c2eSHans Petter Selasky
1486c3191c2eSHans Petter Selasky /* Returns a bitmap of all slaves that are assigned exactly to all the */
1487c3191c2eSHans Petter Selasky /* the ports that are set in crit_ports. */
1488c3191c2eSHans Petter Selasky struct mlx4_slaves_pport mlx4_phys_to_slaves_pport_actv(
1489c3191c2eSHans Petter Selasky struct mlx4_dev *dev,
1490c3191c2eSHans Petter Selasky const struct mlx4_active_ports *crit_ports);
1491c3191c2eSHans Petter Selasky
1492c3191c2eSHans Petter Selasky /* Returns the slave's virtual port that represents the physical port. */
1493c3191c2eSHans Petter Selasky int mlx4_phys_to_slave_port(struct mlx4_dev *dev, int slave, int port);
1494c3191c2eSHans Petter Selasky
1495c3191c2eSHans Petter Selasky int mlx4_get_base_gid_ix(struct mlx4_dev *dev, int slave, int port);
1496c3191c2eSHans Petter Selasky
1497c3191c2eSHans Petter Selasky int mlx4_config_vxlan_port(struct mlx4_dev *dev, __be16 udp_port);
1498c3191c2eSHans Petter Selasky int mlx4_disable_rx_port_check(struct mlx4_dev *dev, bool dis);
1499c3191c2eSHans Petter Selasky int mlx4_config_roce_v2_port(struct mlx4_dev *dev, u16 udp_port);
1500c3191c2eSHans Petter Selasky int mlx4_virt2phy_port_map(struct mlx4_dev *dev, u32 port1, u32 port2);
1501c3191c2eSHans Petter Selasky int mlx4_vf_smi_enabled(struct mlx4_dev *dev, int slave, int port);
1502c3191c2eSHans Petter Selasky int mlx4_vf_get_enable_smi_admin(struct mlx4_dev *dev, int slave, int port);
1503c3191c2eSHans Petter Selasky int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev, int slave, int port,
1504c3191c2eSHans Petter Selasky int enable);
1505c3191c2eSHans Petter Selasky int mlx4_mr_hw_get_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr,
1506c3191c2eSHans Petter Selasky struct mlx4_mpt_entry ***mpt_entry);
1507c3191c2eSHans Petter Selasky int mlx4_mr_hw_write_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr,
1508c3191c2eSHans Petter Selasky struct mlx4_mpt_entry **mpt_entry);
1509c3191c2eSHans Petter Selasky int mlx4_mr_hw_change_pd(struct mlx4_dev *dev, struct mlx4_mpt_entry *mpt_entry,
1510c3191c2eSHans Petter Selasky u32 pdn);
1511c3191c2eSHans Petter Selasky int mlx4_mr_hw_change_access(struct mlx4_dev *dev,
1512c3191c2eSHans Petter Selasky struct mlx4_mpt_entry *mpt_entry,
1513c3191c2eSHans Petter Selasky u32 access);
1514c3191c2eSHans Petter Selasky void mlx4_mr_hw_put_mpt(struct mlx4_dev *dev,
1515c3191c2eSHans Petter Selasky struct mlx4_mpt_entry **mpt_entry);
1516c3191c2eSHans Petter Selasky void mlx4_mr_rereg_mem_cleanup(struct mlx4_dev *dev, struct mlx4_mr *mr);
1517c3191c2eSHans Petter Selasky int mlx4_mr_rereg_mem_write(struct mlx4_dev *dev, struct mlx4_mr *mr,
1518c3191c2eSHans Petter Selasky u64 iova, u64 size, int npages,
1519c3191c2eSHans Petter Selasky int page_shift, struct mlx4_mpt_entry *mpt_entry);
152097549c34SHans Petter Selasky
152197549c34SHans Petter Selasky int mlx4_get_module_info(struct mlx4_dev *dev, u8 port,
152297549c34SHans Petter Selasky u16 offset, u16 size, u8 *data);
1523c3191c2eSHans Petter Selasky int mlx4_max_tc(struct mlx4_dev *dev);
152497549c34SHans Petter Selasky
1525c3191c2eSHans Petter Selasky /* Returns true if running in low memory profile (kdump kernel) */
mlx4_low_memory_profile(void)1526c3191c2eSHans Petter Selasky static inline bool mlx4_low_memory_profile(void)
1527c3191c2eSHans Petter Selasky {
1528c3191c2eSHans Petter Selasky return false;
1529c3191c2eSHans Petter Selasky }
1530c3191c2eSHans Petter Selasky
1531c3191c2eSHans Petter Selasky /* ACCESS REG commands */
1532c3191c2eSHans Petter Selasky enum mlx4_access_reg_method {
1533c3191c2eSHans Petter Selasky MLX4_ACCESS_REG_QUERY = 0x1,
1534c3191c2eSHans Petter Selasky MLX4_ACCESS_REG_WRITE = 0x2,
1535c3191c2eSHans Petter Selasky };
1536c3191c2eSHans Petter Selasky
1537c3191c2eSHans Petter Selasky /* ACCESS PTYS Reg command */
1538c3191c2eSHans Petter Selasky enum mlx4_ptys_proto {
1539c3191c2eSHans Petter Selasky MLX4_PTYS_IB = 1<<0,
1540c3191c2eSHans Petter Selasky MLX4_PTYS_EN = 1<<2,
1541c3191c2eSHans Petter Selasky };
1542c3191c2eSHans Petter Selasky
1543c3191c2eSHans Petter Selasky struct mlx4_ptys_reg {
1544c3191c2eSHans Petter Selasky u8 resrvd1;
1545c3191c2eSHans Petter Selasky u8 local_port;
1546c3191c2eSHans Petter Selasky u8 resrvd2;
1547c3191c2eSHans Petter Selasky u8 proto_mask;
1548c3191c2eSHans Petter Selasky __be32 resrvd3[2];
1549c3191c2eSHans Petter Selasky __be32 eth_proto_cap;
1550c3191c2eSHans Petter Selasky __be16 ib_width_cap;
1551c3191c2eSHans Petter Selasky __be16 ib_speed_cap;
1552c3191c2eSHans Petter Selasky __be32 resrvd4;
1553c3191c2eSHans Petter Selasky __be32 eth_proto_admin;
1554c3191c2eSHans Petter Selasky __be16 ib_width_admin;
1555c3191c2eSHans Petter Selasky __be16 ib_speed_admin;
1556c3191c2eSHans Petter Selasky __be32 resrvd5;
1557c3191c2eSHans Petter Selasky __be32 eth_proto_oper;
1558c3191c2eSHans Petter Selasky __be16 ib_width_oper;
1559c3191c2eSHans Petter Selasky __be16 ib_speed_oper;
1560c3191c2eSHans Petter Selasky __be32 resrvd6;
1561c3191c2eSHans Petter Selasky __be32 eth_proto_lp_adv;
1562c3191c2eSHans Petter Selasky } __packed;
1563c3191c2eSHans Petter Selasky
1564c3191c2eSHans Petter Selasky int mlx4_ACCESS_PTYS_REG(struct mlx4_dev *dev,
1565c3191c2eSHans Petter Selasky enum mlx4_access_reg_method method,
1566c3191c2eSHans Petter Selasky struct mlx4_ptys_reg *ptys_reg);
1567c3191c2eSHans Petter Selasky
1568c3191c2eSHans Petter Selasky int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
1569c3191c2eSHans Petter Selasky struct mlx4_clock_params *params);
1570c3191c2eSHans Petter Selasky
mlx4_to_hw_uar_index(struct mlx4_dev * dev,int index)1571c3191c2eSHans Petter Selasky static inline int mlx4_to_hw_uar_index(struct mlx4_dev *dev, int index)
1572c3191c2eSHans Petter Selasky {
1573c3191c2eSHans Petter Selasky return (index << (PAGE_SHIFT - dev->uar_page_shift));
1574c3191c2eSHans Petter Selasky }
1575c3191c2eSHans Petter Selasky
mlx4_get_num_reserved_uar(struct mlx4_dev * dev)1576c3191c2eSHans Petter Selasky static inline int mlx4_get_num_reserved_uar(struct mlx4_dev *dev)
1577c3191c2eSHans Petter Selasky {
1578c3191c2eSHans Petter Selasky /* The first 128 UARs are used for EQ doorbells */
1579c3191c2eSHans Petter Selasky return (128 >> (PAGE_SHIFT - dev->uar_page_shift));
1580c3191c2eSHans Petter Selasky }
158197549c34SHans Petter Selasky #endif /* MLX4_DEVICE_H */
1582