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 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 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; 62797549c34SHans Petter Selasky }; 62897549c34SHans Petter Selasky 62997549c34SHans Petter Selasky struct mlx4_buf_list { 63097549c34SHans Petter Selasky void *buf; 63197549c34SHans Petter Selasky dma_addr_t map; 63297549c34SHans Petter Selasky }; 63397549c34SHans Petter Selasky 63497549c34SHans Petter Selasky struct mlx4_buf { 63597549c34SHans Petter Selasky struct mlx4_buf_list direct; 63697549c34SHans Petter Selasky struct mlx4_buf_list *page_list; 63797549c34SHans Petter Selasky int nbufs; 63897549c34SHans Petter Selasky int npages; 63997549c34SHans Petter Selasky int page_shift; 64097549c34SHans Petter Selasky }; 64197549c34SHans Petter Selasky 64297549c34SHans Petter Selasky struct mlx4_mtt { 64397549c34SHans Petter Selasky u32 offset; 64497549c34SHans Petter Selasky int order; 64597549c34SHans Petter Selasky int page_shift; 64697549c34SHans Petter Selasky }; 64797549c34SHans Petter Selasky 64897549c34SHans Petter Selasky enum { 64997549c34SHans Petter Selasky MLX4_DB_PER_PAGE = PAGE_SIZE / 4 65097549c34SHans Petter Selasky }; 65197549c34SHans Petter Selasky 65297549c34SHans Petter Selasky struct mlx4_db_pgdir { 65397549c34SHans Petter Selasky struct list_head list; 65497549c34SHans Petter Selasky DECLARE_BITMAP(order0, MLX4_DB_PER_PAGE); 65597549c34SHans Petter Selasky DECLARE_BITMAP(order1, MLX4_DB_PER_PAGE / 2); 65697549c34SHans Petter Selasky unsigned long *bits[2]; 65797549c34SHans Petter Selasky __be32 *db_page; 65897549c34SHans Petter Selasky dma_addr_t db_dma; 65997549c34SHans Petter Selasky }; 66097549c34SHans Petter Selasky 66197549c34SHans Petter Selasky struct mlx4_ib_user_db_page; 66297549c34SHans Petter Selasky 66397549c34SHans Petter Selasky struct mlx4_db { 66497549c34SHans Petter Selasky __be32 *db; 66597549c34SHans Petter Selasky union { 66697549c34SHans Petter Selasky struct mlx4_db_pgdir *pgdir; 66797549c34SHans Petter Selasky struct mlx4_ib_user_db_page *user_page; 66897549c34SHans Petter Selasky } u; 66997549c34SHans Petter Selasky dma_addr_t dma; 67097549c34SHans Petter Selasky int index; 67197549c34SHans Petter Selasky int order; 67297549c34SHans Petter Selasky }; 67397549c34SHans Petter Selasky 67497549c34SHans Petter Selasky struct mlx4_hwq_resources { 67597549c34SHans Petter Selasky struct mlx4_db db; 67697549c34SHans Petter Selasky struct mlx4_mtt mtt; 67797549c34SHans Petter Selasky struct mlx4_buf buf; 67897549c34SHans Petter Selasky }; 67997549c34SHans Petter Selasky 68097549c34SHans Petter Selasky struct mlx4_mr { 68197549c34SHans Petter Selasky struct mlx4_mtt mtt; 68297549c34SHans Petter Selasky u64 iova; 68397549c34SHans Petter Selasky u64 size; 68497549c34SHans Petter Selasky u32 key; 68597549c34SHans Petter Selasky u32 pd; 68697549c34SHans Petter Selasky u32 access; 68797549c34SHans Petter Selasky int enabled; 68897549c34SHans Petter Selasky }; 68997549c34SHans Petter Selasky 69097549c34SHans Petter Selasky enum mlx4_mw_type { 69197549c34SHans Petter Selasky MLX4_MW_TYPE_1 = 1, 69297549c34SHans Petter Selasky MLX4_MW_TYPE_2 = 2, 69397549c34SHans Petter Selasky }; 69497549c34SHans Petter Selasky 69597549c34SHans Petter Selasky struct mlx4_mw { 69697549c34SHans Petter Selasky u32 key; 69797549c34SHans Petter Selasky u32 pd; 69897549c34SHans Petter Selasky enum mlx4_mw_type type; 69997549c34SHans Petter Selasky int enabled; 70097549c34SHans Petter Selasky }; 70197549c34SHans Petter Selasky 70297549c34SHans Petter Selasky struct mlx4_fmr { 70397549c34SHans Petter Selasky struct mlx4_mr mr; 70497549c34SHans Petter Selasky struct mlx4_mpt_entry *mpt; 70597549c34SHans Petter Selasky __be64 *mtts; 70697549c34SHans Petter Selasky dma_addr_t dma_handle; 70797549c34SHans Petter Selasky int max_pages; 70897549c34SHans Petter Selasky int max_maps; 70997549c34SHans Petter Selasky int maps; 71097549c34SHans Petter Selasky u8 page_shift; 71197549c34SHans Petter Selasky }; 71297549c34SHans Petter Selasky 71397549c34SHans Petter Selasky struct mlx4_uar { 71497549c34SHans Petter Selasky unsigned long pfn; 71597549c34SHans Petter Selasky int index; 71697549c34SHans Petter Selasky struct list_head bf_list; 71797549c34SHans Petter Selasky unsigned free_bf_bmap; 71897549c34SHans Petter Selasky void __iomem *map; 71997549c34SHans Petter Selasky void __iomem *bf_map; 72097549c34SHans Petter Selasky }; 72197549c34SHans Petter Selasky 72297549c34SHans Petter Selasky struct mlx4_bf { 723c3191c2eSHans Petter Selasky unsigned int offset; 72497549c34SHans Petter Selasky int buf_size; 72597549c34SHans Petter Selasky struct mlx4_uar *uar; 72697549c34SHans Petter Selasky void __iomem *reg; 72797549c34SHans Petter Selasky }; 72897549c34SHans Petter Selasky 72997549c34SHans Petter Selasky struct mlx4_cq { 73097549c34SHans Petter Selasky void (*comp) (struct mlx4_cq *); 73197549c34SHans Petter Selasky void (*event) (struct mlx4_cq *, enum mlx4_event); 73297549c34SHans Petter Selasky 73397549c34SHans Petter Selasky struct mlx4_uar *uar; 73497549c34SHans Petter Selasky 73597549c34SHans Petter Selasky u32 cons_index; 73697549c34SHans Petter Selasky 737c3191c2eSHans Petter Selasky u16 irq; 73897549c34SHans Petter Selasky __be32 *set_ci_db; 73997549c34SHans Petter Selasky __be32 *arm_db; 74097549c34SHans Petter Selasky int arm_sn; 74197549c34SHans Petter Selasky 74297549c34SHans Petter Selasky int cqn; 74397549c34SHans Petter Selasky unsigned vector; 74497549c34SHans Petter Selasky 74597549c34SHans Petter Selasky atomic_t refcount; 74697549c34SHans Petter Selasky struct completion free; 747c3191c2eSHans Petter Selasky int reset_notify_added; 748c3191c2eSHans Petter Selasky struct list_head reset_notify; 74997549c34SHans Petter Selasky }; 75097549c34SHans Petter Selasky 75197549c34SHans Petter Selasky struct mlx4_qp { 75297549c34SHans Petter Selasky void (*event) (struct mlx4_qp *, enum mlx4_event); 75397549c34SHans Petter Selasky 75497549c34SHans Petter Selasky int qpn; 75597549c34SHans Petter Selasky 75697549c34SHans Petter Selasky atomic_t refcount; 75797549c34SHans Petter Selasky struct completion free; 75897549c34SHans Petter Selasky }; 75997549c34SHans Petter Selasky 76097549c34SHans Petter Selasky struct mlx4_srq { 76197549c34SHans Petter Selasky void (*event) (struct mlx4_srq *, enum mlx4_event); 76297549c34SHans Petter Selasky 76397549c34SHans Petter Selasky int srqn; 76497549c34SHans Petter Selasky int max; 76597549c34SHans Petter Selasky int max_gs; 76697549c34SHans Petter Selasky int wqe_shift; 76797549c34SHans Petter Selasky 76897549c34SHans Petter Selasky atomic_t refcount; 76997549c34SHans Petter Selasky struct completion free; 77097549c34SHans Petter Selasky }; 77197549c34SHans Petter Selasky 77297549c34SHans Petter Selasky struct mlx4_av { 77397549c34SHans Petter Selasky __be32 port_pd; 77497549c34SHans Petter Selasky u8 reserved1; 77597549c34SHans Petter Selasky u8 g_slid; 77697549c34SHans Petter Selasky __be16 dlid; 77797549c34SHans Petter Selasky u8 reserved2; 77897549c34SHans Petter Selasky u8 gid_index; 77997549c34SHans Petter Selasky u8 stat_rate; 78097549c34SHans Petter Selasky u8 hop_limit; 78197549c34SHans Petter Selasky __be32 sl_tclass_flowlabel; 78297549c34SHans Petter Selasky u8 dgid[16]; 78397549c34SHans Petter Selasky }; 78497549c34SHans Petter Selasky 78597549c34SHans Petter Selasky struct mlx4_eth_av { 78697549c34SHans Petter Selasky __be32 port_pd; 78797549c34SHans Petter Selasky u8 reserved1; 78897549c34SHans Petter Selasky u8 smac_idx; 78997549c34SHans Petter Selasky u16 reserved2; 79097549c34SHans Petter Selasky u8 reserved3; 79197549c34SHans Petter Selasky u8 gid_index; 79297549c34SHans Petter Selasky u8 stat_rate; 79397549c34SHans Petter Selasky u8 hop_limit; 79497549c34SHans Petter Selasky __be32 sl_tclass_flowlabel; 79597549c34SHans Petter Selasky u8 dgid[16]; 79697549c34SHans Petter Selasky u8 s_mac[6]; 79797549c34SHans Petter Selasky u8 reserved4[2]; 79897549c34SHans Petter Selasky __be16 vlan; 799c3191c2eSHans Petter Selasky u8 mac[ETH_ALEN]; 80097549c34SHans Petter Selasky }; 80197549c34SHans Petter Selasky 80297549c34SHans Petter Selasky union mlx4_ext_av { 80397549c34SHans Petter Selasky struct mlx4_av ib; 80497549c34SHans Petter Selasky struct mlx4_eth_av eth; 80597549c34SHans Petter Selasky }; 80697549c34SHans Petter Selasky 807*55b1c6e7SHans Petter Selasky /* Counters should be saturate once they reach their maximum value */ 808*55b1c6e7SHans Petter Selasky #define ASSIGN_32BIT_COUNTER(counter, value) do { \ 809*55b1c6e7SHans Petter Selasky if ((value) > U32_MAX) \ 810*55b1c6e7SHans Petter Selasky counter = cpu_to_be32(U32_MAX); \ 811*55b1c6e7SHans Petter Selasky else \ 812*55b1c6e7SHans Petter Selasky counter = cpu_to_be32(value); \ 813*55b1c6e7SHans Petter Selasky } while (0) 814*55b1c6e7SHans Petter Selasky 815c3191c2eSHans Petter Selasky struct mlx4_counter { 81697549c34SHans Petter Selasky u8 reserved1[3]; 817c3191c2eSHans Petter Selasky u8 counter_mode; 818c3191c2eSHans Petter Selasky __be32 num_ifc; 819c3191c2eSHans Petter Selasky u32 reserved2[2]; 820c3191c2eSHans Petter Selasky __be64 rx_frames; 821c3191c2eSHans Petter Selasky __be64 rx_bytes; 822c3191c2eSHans Petter Selasky __be64 tx_frames; 823c3191c2eSHans Petter Selasky __be64 tx_bytes; 82497549c34SHans Petter Selasky }; 82597549c34SHans Petter Selasky 82697549c34SHans Petter Selasky struct mlx4_quotas { 82797549c34SHans Petter Selasky int qp; 82897549c34SHans Petter Selasky int cq; 82997549c34SHans Petter Selasky int srq; 83097549c34SHans Petter Selasky int mpt; 83197549c34SHans Petter Selasky int mtt; 83297549c34SHans Petter Selasky int counter; 83397549c34SHans Petter Selasky int xrcd; 83497549c34SHans Petter Selasky }; 83597549c34SHans Petter Selasky 836c3191c2eSHans Petter Selasky struct mlx4_vf_dev { 837c3191c2eSHans Petter Selasky u8 min_port; 838c3191c2eSHans Petter Selasky u8 n_ports; 839c3191c2eSHans Petter Selasky }; 840c3191c2eSHans Petter Selasky 841c3191c2eSHans Petter Selasky enum mlx4_pci_status { 842c3191c2eSHans Petter Selasky MLX4_PCI_STATUS_DISABLED, 843c3191c2eSHans Petter Selasky MLX4_PCI_STATUS_ENABLED, 844c3191c2eSHans Petter Selasky }; 845c3191c2eSHans Petter Selasky 846c3191c2eSHans Petter Selasky struct mlx4_dev_persistent { 84797549c34SHans Petter Selasky struct pci_dev *pdev; 848c3191c2eSHans Petter Selasky struct mlx4_dev *dev; 849c3191c2eSHans Petter Selasky int nvfs[MLX4_MAX_PORTS + 1]; 850c3191c2eSHans Petter Selasky int num_vfs; 851c3191c2eSHans Petter Selasky enum mlx4_port_type curr_port_type[MLX4_MAX_PORTS + 1]; 852c3191c2eSHans Petter Selasky enum mlx4_port_type curr_port_poss_type[MLX4_MAX_PORTS + 1]; 853c3191c2eSHans Petter Selasky struct work_struct catas_work; 854c3191c2eSHans Petter Selasky struct workqueue_struct *catas_wq; 855c3191c2eSHans Petter Selasky struct mutex device_state_mutex; /* protect HW state */ 856c3191c2eSHans Petter Selasky u8 state; 857c3191c2eSHans Petter Selasky struct mutex interface_state_mutex; /* protect SW state */ 858c3191c2eSHans Petter Selasky u8 interface_state; 859c3191c2eSHans Petter Selasky struct mutex pci_status_mutex; /* sync pci state */ 860c3191c2eSHans Petter Selasky enum mlx4_pci_status pci_status; 861c3191c2eSHans Petter Selasky }; 862c3191c2eSHans Petter Selasky 863c3191c2eSHans Petter Selasky struct mlx4_dev { 864c3191c2eSHans Petter Selasky struct mlx4_dev_persistent *persist; 86597549c34SHans Petter Selasky unsigned long flags; 86697549c34SHans Petter Selasky unsigned long num_slaves; 86797549c34SHans Petter Selasky struct mlx4_caps caps; 86897549c34SHans Petter Selasky struct mlx4_phys_caps phys_caps; 86997549c34SHans Petter Selasky struct mlx4_quotas quotas; 87097549c34SHans Petter Selasky struct radix_tree_root qp_table_tree; 87197549c34SHans Petter Selasky u8 rev_id; 872c3191c2eSHans Petter Selasky u8 port_random_macs; 87397549c34SHans Petter Selasky char board_id[MLX4_BOARD_ID_LEN]; 87497549c34SHans Petter Selasky int numa_node; 87597549c34SHans Petter Selasky int oper_log_mgm_entry_size; 87697549c34SHans Petter Selasky u64 regid_promisc_array[MLX4_MAX_PORTS + 1]; 87797549c34SHans Petter Selasky u64 regid_allmulti_array[MLX4_MAX_PORTS + 1]; 878c3191c2eSHans Petter Selasky struct mlx4_vf_dev *dev_vfs; 879c3191c2eSHans Petter Selasky u8 uar_page_shift; 88097549c34SHans Petter Selasky }; 88197549c34SHans Petter Selasky 88297549c34SHans Petter Selasky struct mlx4_clock_params { 88397549c34SHans Petter Selasky u64 offset; 88497549c34SHans Petter Selasky u8 bar; 88597549c34SHans Petter Selasky u8 size; 88697549c34SHans Petter Selasky }; 88797549c34SHans Petter Selasky 88897549c34SHans Petter Selasky struct mlx4_eqe { 88997549c34SHans Petter Selasky u8 reserved1; 89097549c34SHans Petter Selasky u8 type; 89197549c34SHans Petter Selasky u8 reserved2; 89297549c34SHans Petter Selasky u8 subtype; 89397549c34SHans Petter Selasky union { 89497549c34SHans Petter Selasky u32 raw[6]; 89597549c34SHans Petter Selasky struct { 89697549c34SHans Petter Selasky __be32 cqn; 89797549c34SHans Petter Selasky } __packed comp; 89897549c34SHans Petter Selasky struct { 89997549c34SHans Petter Selasky u16 reserved1; 90097549c34SHans Petter Selasky __be16 token; 90197549c34SHans Petter Selasky u32 reserved2; 90297549c34SHans Petter Selasky u8 reserved3[3]; 90397549c34SHans Petter Selasky u8 status; 90497549c34SHans Petter Selasky __be64 out_param; 90597549c34SHans Petter Selasky } __packed cmd; 90697549c34SHans Petter Selasky struct { 90797549c34SHans Petter Selasky __be32 qpn; 90897549c34SHans Petter Selasky } __packed qp; 90997549c34SHans Petter Selasky struct { 91097549c34SHans Petter Selasky __be32 srqn; 91197549c34SHans Petter Selasky } __packed srq; 91297549c34SHans Petter Selasky struct { 91397549c34SHans Petter Selasky __be32 cqn; 91497549c34SHans Petter Selasky u32 reserved1; 91597549c34SHans Petter Selasky u8 reserved2[3]; 91697549c34SHans Petter Selasky u8 syndrome; 91797549c34SHans Petter Selasky } __packed cq_err; 91897549c34SHans Petter Selasky struct { 91997549c34SHans Petter Selasky u32 reserved1[2]; 92097549c34SHans Petter Selasky __be32 port; 92197549c34SHans Petter Selasky } __packed port_change; 92297549c34SHans Petter Selasky struct { 92397549c34SHans Petter Selasky #define COMM_CHANNEL_BIT_ARRAY_SIZE 4 92497549c34SHans Petter Selasky u32 reserved; 92597549c34SHans Petter Selasky u32 bit_vec[COMM_CHANNEL_BIT_ARRAY_SIZE]; 92697549c34SHans Petter Selasky } __packed comm_channel_arm; 92797549c34SHans Petter Selasky struct { 92897549c34SHans Petter Selasky u8 port; 92997549c34SHans Petter Selasky u8 reserved[3]; 93097549c34SHans Petter Selasky __be64 mac; 93197549c34SHans Petter Selasky } __packed mac_update; 93297549c34SHans Petter Selasky struct { 93397549c34SHans Petter Selasky __be32 slave_id; 93497549c34SHans Petter Selasky } __packed flr_event; 93597549c34SHans Petter Selasky struct { 93697549c34SHans Petter Selasky __be16 current_temperature; 93797549c34SHans Petter Selasky __be16 warning_threshold; 93897549c34SHans Petter Selasky } __packed warming; 93997549c34SHans Petter Selasky struct { 94097549c34SHans Petter Selasky u8 reserved[3]; 94197549c34SHans Petter Selasky u8 port; 94297549c34SHans Petter Selasky union { 94397549c34SHans Petter Selasky struct { 94497549c34SHans Petter Selasky __be16 mstr_sm_lid; 94597549c34SHans Petter Selasky __be16 port_lid; 94697549c34SHans Petter Selasky __be32 changed_attr; 94797549c34SHans Petter Selasky u8 reserved[3]; 94897549c34SHans Petter Selasky u8 mstr_sm_sl; 94997549c34SHans Petter Selasky __be64 gid_prefix; 95097549c34SHans Petter Selasky } __packed port_info; 95197549c34SHans Petter Selasky struct { 95297549c34SHans Petter Selasky __be32 block_ptr; 95397549c34SHans Petter Selasky __be32 tbl_entries_mask; 95497549c34SHans Petter Selasky } __packed tbl_change_info; 955c3191c2eSHans Petter Selasky struct { 956c3191c2eSHans Petter Selasky u8 sl2vl_table[8]; 957c3191c2eSHans Petter Selasky } __packed sl2vl_tbl_change_info; 95897549c34SHans Petter Selasky } params; 95997549c34SHans Petter Selasky } __packed port_mgmt_change; 96097549c34SHans Petter Selasky struct { 96197549c34SHans Petter Selasky u8 reserved[3]; 96297549c34SHans Petter Selasky u8 port; 96397549c34SHans Petter Selasky u32 reserved1[5]; 96497549c34SHans Petter Selasky } __packed bad_cable; 96597549c34SHans Petter Selasky } event; 96697549c34SHans Petter Selasky u8 slave_id; 96797549c34SHans Petter Selasky u8 reserved3[2]; 96897549c34SHans Petter Selasky u8 owner; 96997549c34SHans Petter Selasky } __packed; 97097549c34SHans Petter Selasky 97197549c34SHans Petter Selasky struct mlx4_init_port_param { 97297549c34SHans Petter Selasky int set_guid0; 97397549c34SHans Petter Selasky int set_node_guid; 97497549c34SHans Petter Selasky int set_si_guid; 97597549c34SHans Petter Selasky u16 mtu; 97697549c34SHans Petter Selasky int port_width_cap; 97797549c34SHans Petter Selasky u16 vl_cap; 97897549c34SHans Petter Selasky u16 max_gid; 97997549c34SHans Petter Selasky u16 max_pkey; 98097549c34SHans Petter Selasky u64 guid0; 98197549c34SHans Petter Selasky u64 node_guid; 98297549c34SHans Petter Selasky u64 si_guid; 98397549c34SHans Petter Selasky }; 98497549c34SHans Petter Selasky 98597549c34SHans Petter Selasky #define MAD_IFC_DATA_SZ 192 98697549c34SHans Petter Selasky /* MAD IFC Mailbox */ 98797549c34SHans Petter Selasky struct mlx4_mad_ifc { 98897549c34SHans Petter Selasky u8 base_version; 98997549c34SHans Petter Selasky u8 mgmt_class; 99097549c34SHans Petter Selasky u8 class_version; 99197549c34SHans Petter Selasky u8 method; 99297549c34SHans Petter Selasky __be16 status; 99397549c34SHans Petter Selasky __be16 class_specific; 99497549c34SHans Petter Selasky __be64 tid; 99597549c34SHans Petter Selasky __be16 attr_id; 99697549c34SHans Petter Selasky __be16 resv; 99797549c34SHans Petter Selasky __be32 attr_mod; 99897549c34SHans Petter Selasky __be64 mkey; 99997549c34SHans Petter Selasky __be16 dr_slid; 100097549c34SHans Petter Selasky __be16 dr_dlid; 100197549c34SHans Petter Selasky u8 reserved[28]; 100297549c34SHans Petter Selasky u8 data[MAD_IFC_DATA_SZ]; 100397549c34SHans Petter Selasky } __packed; 100497549c34SHans Petter Selasky 100597549c34SHans Petter Selasky #define mlx4_foreach_port(port, dev, type) \ 100697549c34SHans Petter Selasky for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \ 100797549c34SHans Petter Selasky if ((type) == (dev)->caps.port_mask[(port)]) 100897549c34SHans Petter Selasky 100997549c34SHans Petter Selasky #define mlx4_foreach_ib_transport_port(port, dev) \ 101097549c34SHans Petter Selasky for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \ 101197549c34SHans Petter Selasky if (((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_IB) || \ 1012c3191c2eSHans Petter Selasky ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE) || \ 1013c3191c2eSHans Petter Selasky ((dev)->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2)) 101497549c34SHans Petter Selasky 101597549c34SHans Petter Selasky #define MLX4_INVALID_SLAVE_ID 0xFF 1016c3191c2eSHans Petter Selasky #define MLX4_SINK_COUNTER_INDEX(dev) (dev->caps.max_counters - 1) 101797549c34SHans Petter Selasky 101897549c34SHans Petter Selasky void handle_port_mgmt_change_event(struct work_struct *work); 101997549c34SHans Petter Selasky 102097549c34SHans Petter Selasky static inline int mlx4_master_func_num(struct mlx4_dev *dev) 102197549c34SHans Petter Selasky { 102297549c34SHans Petter Selasky return dev->caps.function; 102397549c34SHans Petter Selasky } 102497549c34SHans Petter Selasky 102597549c34SHans Petter Selasky static inline int mlx4_is_master(struct mlx4_dev *dev) 102697549c34SHans Petter Selasky { 102797549c34SHans Petter Selasky return dev->flags & MLX4_FLAG_MASTER; 102897549c34SHans Petter Selasky } 102997549c34SHans Petter Selasky 103097549c34SHans Petter Selasky static inline int mlx4_num_reserved_sqps(struct mlx4_dev *dev) 103197549c34SHans Petter Selasky { 103297549c34SHans Petter Selasky return dev->phys_caps.base_sqpn + 8 + 103397549c34SHans Petter Selasky 16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev); 103497549c34SHans Petter Selasky } 103597549c34SHans Petter Selasky 103697549c34SHans Petter Selasky static inline int mlx4_is_qp_reserved(struct mlx4_dev *dev, u32 qpn) 103797549c34SHans Petter Selasky { 103897549c34SHans Petter Selasky return (qpn < dev->phys_caps.base_sqpn + 8 + 1039c3191c2eSHans Petter Selasky 16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev) && 1040c3191c2eSHans Petter Selasky qpn >= dev->phys_caps.base_sqpn) || 1041c3191c2eSHans Petter Selasky (qpn < dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW]); 104297549c34SHans Petter Selasky } 104397549c34SHans Petter Selasky 104497549c34SHans Petter Selasky static inline int mlx4_is_guest_proxy(struct mlx4_dev *dev, int slave, u32 qpn) 104597549c34SHans Petter Selasky { 104697549c34SHans Petter Selasky int guest_proxy_base = dev->phys_caps.base_proxy_sqpn + slave * 8; 104797549c34SHans Petter Selasky 104897549c34SHans Petter Selasky if (qpn >= guest_proxy_base && qpn < guest_proxy_base + 8) 104997549c34SHans Petter Selasky return 1; 105097549c34SHans Petter Selasky 105197549c34SHans Petter Selasky return 0; 105297549c34SHans Petter Selasky } 105397549c34SHans Petter Selasky 105497549c34SHans Petter Selasky static inline int mlx4_is_mfunc(struct mlx4_dev *dev) 105597549c34SHans Petter Selasky { 105697549c34SHans Petter Selasky return dev->flags & (MLX4_FLAG_SLAVE | MLX4_FLAG_MASTER); 105797549c34SHans Petter Selasky } 105897549c34SHans Petter Selasky 105997549c34SHans Petter Selasky static inline int mlx4_is_slave(struct mlx4_dev *dev) 106097549c34SHans Petter Selasky { 106197549c34SHans Petter Selasky return dev->flags & MLX4_FLAG_SLAVE; 106297549c34SHans Petter Selasky } 106397549c34SHans Petter Selasky 1064c3191c2eSHans Petter Selasky static inline int mlx4_is_eth(struct mlx4_dev *dev, int port) 1065c3191c2eSHans Petter Selasky { 1066c3191c2eSHans Petter Selasky return dev->caps.port_type[port] == MLX4_PORT_TYPE_IB ? 0 : 1; 1067c3191c2eSHans Petter Selasky } 1068c3191c2eSHans Petter Selasky 106997549c34SHans Petter Selasky int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, 1070c3191c2eSHans Petter Selasky struct mlx4_buf *buf, gfp_t gfp); 107197549c34SHans Petter Selasky void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); 107297549c34SHans Petter Selasky static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset) 107397549c34SHans Petter Selasky { 107497549c34SHans Petter Selasky if (BITS_PER_LONG == 64 || buf->nbufs == 1) 107597549c34SHans Petter Selasky return (u8 *)buf->direct.buf + offset; 107697549c34SHans Petter Selasky else 107797549c34SHans Petter Selasky return (u8 *)buf->page_list[offset >> PAGE_SHIFT].buf + 107897549c34SHans Petter Selasky (offset & (PAGE_SIZE - 1)); 107997549c34SHans Petter Selasky } 108097549c34SHans Petter Selasky 108197549c34SHans Petter Selasky int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn); 108297549c34SHans Petter Selasky void mlx4_pd_free(struct mlx4_dev *dev, u32 pdn); 108397549c34SHans Petter Selasky int mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn); 108497549c34SHans Petter Selasky void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn); 108597549c34SHans Petter Selasky 108697549c34SHans Petter Selasky int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar); 108797549c34SHans Petter Selasky void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar); 108897549c34SHans Petter Selasky int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, int node); 108997549c34SHans Petter Selasky void mlx4_bf_free(struct mlx4_dev *dev, struct mlx4_bf *bf); 109097549c34SHans Petter Selasky 109197549c34SHans Petter Selasky int mlx4_mtt_init(struct mlx4_dev *dev, int npages, int page_shift, 109297549c34SHans Petter Selasky struct mlx4_mtt *mtt); 109397549c34SHans Petter Selasky void mlx4_mtt_cleanup(struct mlx4_dev *dev, struct mlx4_mtt *mtt); 109497549c34SHans Petter Selasky u64 mlx4_mtt_addr(struct mlx4_dev *dev, struct mlx4_mtt *mtt); 109597549c34SHans Petter Selasky 109697549c34SHans Petter Selasky int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access, 109797549c34SHans Petter Selasky int npages, int page_shift, struct mlx4_mr *mr); 109897549c34SHans Petter Selasky int mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr); 109997549c34SHans Petter Selasky int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr); 110097549c34SHans Petter Selasky int mlx4_mw_alloc(struct mlx4_dev *dev, u32 pd, enum mlx4_mw_type type, 110197549c34SHans Petter Selasky struct mlx4_mw *mw); 110297549c34SHans Petter Selasky void mlx4_mw_free(struct mlx4_dev *dev, struct mlx4_mw *mw); 110397549c34SHans Petter Selasky int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw); 110497549c34SHans Petter Selasky int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, 110597549c34SHans Petter Selasky int start_index, int npages, u64 *page_list); 110697549c34SHans Petter Selasky int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, 1107c3191c2eSHans Petter Selasky struct mlx4_buf *buf, gfp_t gfp); 110897549c34SHans Petter Selasky 1109c3191c2eSHans Petter Selasky int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order, 1110c3191c2eSHans Petter Selasky gfp_t gfp); 111197549c34SHans Petter Selasky void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db); 111297549c34SHans Petter Selasky 111397549c34SHans Petter Selasky int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, 111497549c34SHans Petter Selasky int size, int max_direct); 111597549c34SHans Petter Selasky void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres, 111697549c34SHans Petter Selasky int size); 111797549c34SHans Petter Selasky 111897549c34SHans Petter Selasky int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, 111997549c34SHans Petter Selasky struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq, 112097549c34SHans Petter Selasky unsigned vector, int collapsed, int timestamp_en); 112197549c34SHans Petter Selasky void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); 112297549c34SHans Petter Selasky int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, 112397549c34SHans Petter Selasky int *base, u8 flags); 112497549c34SHans Petter Selasky void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); 112597549c34SHans Petter Selasky 1126c3191c2eSHans Petter Selasky int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, 1127c3191c2eSHans Petter Selasky gfp_t gfp); 112897549c34SHans Petter Selasky void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp); 112997549c34SHans Petter Selasky 113097549c34SHans Petter Selasky int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn, 113197549c34SHans Petter Selasky struct mlx4_mtt *mtt, u64 db_rec, struct mlx4_srq *srq); 113297549c34SHans Petter Selasky void mlx4_srq_free(struct mlx4_dev *dev, struct mlx4_srq *srq); 113397549c34SHans Petter Selasky int mlx4_srq_arm(struct mlx4_dev *dev, struct mlx4_srq *srq, int limit_watermark); 113497549c34SHans Petter Selasky int mlx4_srq_query(struct mlx4_dev *dev, struct mlx4_srq *srq, int *limit_watermark); 113597549c34SHans Petter Selasky 113697549c34SHans Petter Selasky int mlx4_INIT_PORT(struct mlx4_dev *dev, int port); 113797549c34SHans Petter Selasky int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port); 113897549c34SHans Petter Selasky 113997549c34SHans Petter Selasky int mlx4_unicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], 114097549c34SHans Petter Selasky int block_mcast_loopback, enum mlx4_protocol prot); 114197549c34SHans Petter Selasky int mlx4_unicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], 114297549c34SHans Petter Selasky enum mlx4_protocol prot); 114397549c34SHans Petter Selasky int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], 114497549c34SHans Petter Selasky u8 port, int block_mcast_loopback, 114597549c34SHans Petter Selasky enum mlx4_protocol protocol, u64 *reg_id); 114697549c34SHans Petter Selasky int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], 114797549c34SHans Petter Selasky enum mlx4_protocol protocol, u64 reg_id); 114897549c34SHans Petter Selasky 114997549c34SHans Petter Selasky enum { 115097549c34SHans Petter Selasky MLX4_DOMAIN_UVERBS = 0x1000, 115197549c34SHans Petter Selasky MLX4_DOMAIN_ETHTOOL = 0x2000, 115297549c34SHans Petter Selasky MLX4_DOMAIN_RFS = 0x3000, 115397549c34SHans Petter Selasky MLX4_DOMAIN_NIC = 0x5000, 115497549c34SHans Petter Selasky }; 115597549c34SHans Petter Selasky 115697549c34SHans Petter Selasky enum mlx4_net_trans_rule_id { 115797549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_ETH = 0, 115897549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_IB, 115997549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_IPV6, 116097549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_IPV4, 116197549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_TCP, 116297549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_ID_UDP, 1163c3191c2eSHans Petter Selasky MLX4_NET_TRANS_RULE_ID_VXLAN, 116497549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_NUM, /* should be last */ 116597549c34SHans Petter Selasky MLX4_NET_TRANS_RULE_DUMMY = -1, /* force enum to be signed */ 116697549c34SHans Petter Selasky }; 116797549c34SHans Petter Selasky 116897549c34SHans Petter Selasky extern const u16 __sw_id_hw[]; 116997549c34SHans Petter Selasky 117097549c34SHans Petter Selasky static inline int map_hw_to_sw_id(u16 header_id) 117197549c34SHans Petter Selasky { 117297549c34SHans Petter Selasky 117397549c34SHans Petter Selasky int i; 117497549c34SHans Petter Selasky for (i = 0; i < MLX4_NET_TRANS_RULE_NUM; i++) { 117597549c34SHans Petter Selasky if (header_id == __sw_id_hw[i]) 117697549c34SHans Petter Selasky return i; 117797549c34SHans Petter Selasky } 117897549c34SHans Petter Selasky return -EINVAL; 117997549c34SHans Petter Selasky } 118097549c34SHans Petter Selasky 118197549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode { 118297549c34SHans Petter Selasky MLX4_FS_REGULAR = 1, 118397549c34SHans Petter Selasky MLX4_FS_ALL_DEFAULT, 118497549c34SHans Petter Selasky MLX4_FS_MC_DEFAULT, 1185c3191c2eSHans Petter Selasky MLX4_FS_MIRROR_RX_PORT, 1186c3191c2eSHans Petter Selasky MLX4_FS_MIRROR_SX_PORT, 118797549c34SHans Petter Selasky MLX4_FS_UC_SNIFFER, 118897549c34SHans Petter Selasky MLX4_FS_MC_SNIFFER, 118997549c34SHans Petter Selasky MLX4_FS_MODE_NUM, /* should be last */ 119097549c34SHans Petter Selasky MLX4_FS_MODE_DUMMY = -1, /* force enum to be signed */ 119197549c34SHans Petter Selasky }; 119297549c34SHans Petter Selasky 119397549c34SHans Petter Selasky struct mlx4_spec_eth { 1194c3191c2eSHans Petter Selasky u8 dst_mac[ETH_ALEN]; 1195c3191c2eSHans Petter Selasky u8 dst_mac_msk[ETH_ALEN]; 1196c3191c2eSHans Petter Selasky u8 src_mac[ETH_ALEN]; 1197c3191c2eSHans Petter Selasky u8 src_mac_msk[ETH_ALEN]; 119897549c34SHans Petter Selasky u8 ether_type_enable; 119997549c34SHans Petter Selasky __be16 ether_type; 120097549c34SHans Petter Selasky __be16 vlan_id_msk; 120197549c34SHans Petter Selasky __be16 vlan_id; 120297549c34SHans Petter Selasky }; 120397549c34SHans Petter Selasky 120497549c34SHans Petter Selasky struct mlx4_spec_tcp_udp { 120597549c34SHans Petter Selasky __be16 dst_port; 120697549c34SHans Petter Selasky __be16 dst_port_msk; 120797549c34SHans Petter Selasky __be16 src_port; 120897549c34SHans Petter Selasky __be16 src_port_msk; 120997549c34SHans Petter Selasky }; 121097549c34SHans Petter Selasky 121197549c34SHans Petter Selasky struct mlx4_spec_ipv4 { 121297549c34SHans Petter Selasky __be32 dst_ip; 121397549c34SHans Petter Selasky __be32 dst_ip_msk; 121497549c34SHans Petter Selasky __be32 src_ip; 121597549c34SHans Petter Selasky __be32 src_ip_msk; 121697549c34SHans Petter Selasky }; 121797549c34SHans Petter Selasky 121897549c34SHans Petter Selasky struct mlx4_spec_ib { 121997549c34SHans Petter Selasky __be32 l3_qpn; 122097549c34SHans Petter Selasky __be32 qpn_msk; 122197549c34SHans Petter Selasky u8 dst_gid[16]; 122297549c34SHans Petter Selasky u8 dst_gid_msk[16]; 122397549c34SHans Petter Selasky }; 122497549c34SHans Petter Selasky 1225c3191c2eSHans Petter Selasky struct mlx4_spec_vxlan { 1226c3191c2eSHans Petter Selasky __be32 vni; 1227c3191c2eSHans Petter Selasky __be32 vni_mask; 1228c3191c2eSHans Petter Selasky 1229c3191c2eSHans Petter Selasky }; 1230c3191c2eSHans Petter Selasky 123197549c34SHans Petter Selasky struct mlx4_spec_list { 123297549c34SHans Petter Selasky struct list_head list; 123397549c34SHans Petter Selasky enum mlx4_net_trans_rule_id id; 123497549c34SHans Petter Selasky union { 123597549c34SHans Petter Selasky struct mlx4_spec_eth eth; 123697549c34SHans Petter Selasky struct mlx4_spec_ib ib; 123797549c34SHans Petter Selasky struct mlx4_spec_ipv4 ipv4; 123897549c34SHans Petter Selasky struct mlx4_spec_tcp_udp tcp_udp; 1239c3191c2eSHans Petter Selasky struct mlx4_spec_vxlan vxlan; 124097549c34SHans Petter Selasky }; 124197549c34SHans Petter Selasky }; 124297549c34SHans Petter Selasky 124397549c34SHans Petter Selasky enum mlx4_net_trans_hw_rule_queue { 124497549c34SHans Petter Selasky MLX4_NET_TRANS_Q_FIFO, 124597549c34SHans Petter Selasky MLX4_NET_TRANS_Q_LIFO, 124697549c34SHans Petter Selasky }; 124797549c34SHans Petter Selasky 124897549c34SHans Petter Selasky struct mlx4_net_trans_rule { 124997549c34SHans Petter Selasky struct list_head list; 125097549c34SHans Petter Selasky enum mlx4_net_trans_hw_rule_queue queue_mode; 125197549c34SHans Petter Selasky bool exclusive; 125297549c34SHans Petter Selasky bool allow_loopback; 125397549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode promisc_mode; 125497549c34SHans Petter Selasky u8 port; 125597549c34SHans Petter Selasky u16 priority; 125697549c34SHans Petter Selasky u32 qpn; 125797549c34SHans Petter Selasky }; 125897549c34SHans Petter Selasky 125997549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ctrl { 126097549c34SHans Petter Selasky __be16 prio; 126197549c34SHans Petter Selasky u8 type; 126297549c34SHans Petter Selasky u8 flags; 126397549c34SHans Petter Selasky u8 rsvd1; 126497549c34SHans Petter Selasky u8 funcid; 126597549c34SHans Petter Selasky u8 vep; 126697549c34SHans Petter Selasky u8 port; 126797549c34SHans Petter Selasky __be32 qpn; 126897549c34SHans Petter Selasky __be32 rsvd2; 126997549c34SHans Petter Selasky }; 127097549c34SHans Petter Selasky 127197549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ib { 127297549c34SHans Petter Selasky u8 size; 127397549c34SHans Petter Selasky u8 rsvd1; 127497549c34SHans Petter Selasky __be16 id; 127597549c34SHans Petter Selasky u32 rsvd2; 127697549c34SHans Petter Selasky __be32 l3_qpn; 127797549c34SHans Petter Selasky __be32 qpn_mask; 127897549c34SHans Petter Selasky u8 dst_gid[16]; 127997549c34SHans Petter Selasky u8 dst_gid_msk[16]; 128097549c34SHans Petter Selasky } __packed; 128197549c34SHans Petter Selasky 128297549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_eth { 128397549c34SHans Petter Selasky u8 size; 128497549c34SHans Petter Selasky u8 rsvd; 128597549c34SHans Petter Selasky __be16 id; 128697549c34SHans Petter Selasky u8 rsvd1[6]; 128797549c34SHans Petter Selasky u8 dst_mac[6]; 128897549c34SHans Petter Selasky u16 rsvd2; 128997549c34SHans Petter Selasky u8 dst_mac_msk[6]; 129097549c34SHans Petter Selasky u16 rsvd3; 129197549c34SHans Petter Selasky u8 src_mac[6]; 129297549c34SHans Petter Selasky u16 rsvd4; 129397549c34SHans Petter Selasky u8 src_mac_msk[6]; 129497549c34SHans Petter Selasky u8 rsvd5; 129597549c34SHans Petter Selasky u8 ether_type_enable; 129697549c34SHans Petter Selasky __be16 ether_type; 129797549c34SHans Petter Selasky __be16 vlan_tag_msk; 129897549c34SHans Petter Selasky __be16 vlan_tag; 129997549c34SHans Petter Selasky } __packed; 130097549c34SHans Petter Selasky 130197549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_tcp_udp { 130297549c34SHans Petter Selasky u8 size; 130397549c34SHans Petter Selasky u8 rsvd; 130497549c34SHans Petter Selasky __be16 id; 130597549c34SHans Petter Selasky __be16 rsvd1[3]; 130697549c34SHans Petter Selasky __be16 dst_port; 130797549c34SHans Petter Selasky __be16 rsvd2; 130897549c34SHans Petter Selasky __be16 dst_port_msk; 130997549c34SHans Petter Selasky __be16 rsvd3; 131097549c34SHans Petter Selasky __be16 src_port; 131197549c34SHans Petter Selasky __be16 rsvd4; 131297549c34SHans Petter Selasky __be16 src_port_msk; 131397549c34SHans Petter Selasky } __packed; 131497549c34SHans Petter Selasky 131597549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ipv4 { 131697549c34SHans Petter Selasky u8 size; 131797549c34SHans Petter Selasky u8 rsvd; 131897549c34SHans Petter Selasky __be16 id; 131997549c34SHans Petter Selasky __be32 rsvd1; 132097549c34SHans Petter Selasky __be32 dst_ip; 132197549c34SHans Petter Selasky __be32 dst_ip_msk; 132297549c34SHans Petter Selasky __be32 src_ip; 132397549c34SHans Petter Selasky __be32 src_ip_msk; 132497549c34SHans Petter Selasky } __packed; 132597549c34SHans Petter Selasky 1326c3191c2eSHans Petter Selasky struct mlx4_net_trans_rule_hw_vxlan { 1327c3191c2eSHans Petter Selasky u8 size; 1328c3191c2eSHans Petter Selasky u8 rsvd; 1329c3191c2eSHans Petter Selasky __be16 id; 1330c3191c2eSHans Petter Selasky __be32 rsvd1; 1331c3191c2eSHans Petter Selasky __be32 vni; 1332c3191c2eSHans Petter Selasky __be32 vni_mask; 1333c3191c2eSHans Petter Selasky } __packed; 1334c3191c2eSHans Petter Selasky 133597549c34SHans Petter Selasky struct _rule_hw { 133697549c34SHans Petter Selasky union { 133797549c34SHans Petter Selasky struct { 133897549c34SHans Petter Selasky u8 size; 133997549c34SHans Petter Selasky u8 rsvd; 134097549c34SHans Petter Selasky __be16 id; 134197549c34SHans Petter Selasky }; 134297549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_eth eth; 134397549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ib ib; 134497549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_ipv4 ipv4; 134597549c34SHans Petter Selasky struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp; 1346c3191c2eSHans Petter Selasky struct mlx4_net_trans_rule_hw_vxlan vxlan; 134797549c34SHans Petter Selasky }; 134897549c34SHans Petter Selasky }; 134997549c34SHans Petter Selasky 1350c3191c2eSHans Petter Selasky enum { 1351c3191c2eSHans Petter Selasky VXLAN_STEER_BY_OUTER_MAC = 1 << 0, 1352c3191c2eSHans Petter Selasky VXLAN_STEER_BY_OUTER_VLAN = 1 << 1, 1353c3191c2eSHans Petter Selasky VXLAN_STEER_BY_VSID_VNI = 1 << 2, 1354c3191c2eSHans Petter Selasky VXLAN_STEER_BY_INNER_MAC = 1 << 3, 1355c3191c2eSHans Petter Selasky VXLAN_STEER_BY_INNER_VLAN = 1 << 4, 1356c3191c2eSHans Petter Selasky }; 1357c3191c2eSHans Petter Selasky 1358c3191c2eSHans Petter Selasky enum { 1359c3191c2eSHans Petter Selasky MLX4_OP_MOD_QUERY_TRANSPORT_CI_ERRORS = 0x2, 1360c3191c2eSHans Petter Selasky }; 1361c3191c2eSHans Petter Selasky 136297549c34SHans Petter Selasky int mlx4_flow_steer_promisc_add(struct mlx4_dev *dev, u8 port, u32 qpn, 136397549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode mode); 136497549c34SHans Petter Selasky int mlx4_flow_steer_promisc_remove(struct mlx4_dev *dev, u8 port, 136597549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode mode); 136697549c34SHans Petter Selasky int mlx4_multicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port); 136797549c34SHans Petter Selasky int mlx4_multicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port); 136897549c34SHans Petter Selasky int mlx4_unicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port); 136997549c34SHans Petter Selasky int mlx4_unicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port); 1370c3191c2eSHans Petter Selasky int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode); 137197549c34SHans Petter Selasky 137297549c34SHans Petter Selasky int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac); 137397549c34SHans Petter Selasky void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac); 137497549c34SHans Petter Selasky int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port); 137597549c34SHans Petter Selasky int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac); 137697549c34SHans Petter Selasky int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, 137797549c34SHans Petter Selasky u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); 137897549c34SHans Petter Selasky int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, 137997549c34SHans Petter Selasky u8 promisc); 1380c3191c2eSHans Petter Selasky int mlx4_SET_PORT_BEACON(struct mlx4_dev *dev, u8 port, u16 time); 1381c3191c2eSHans Petter Selasky int mlx4_SET_PORT_fcs_check(struct mlx4_dev *dev, u8 port, 1382c3191c2eSHans Petter Selasky u8 ignore_fcs_value); 1383c3191c2eSHans Petter Selasky int mlx4_SET_PORT_VXLAN(struct mlx4_dev *dev, u8 port, u8 steering, int enable); 1384c3191c2eSHans Petter Selasky int set_phv_bit(struct mlx4_dev *dev, u8 port, int new_val); 1385c3191c2eSHans Petter Selasky int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv); 1386c3191c2eSHans Petter Selasky int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port, 1387c3191c2eSHans Petter Selasky bool *vlan_offload_disabled); 1388c3191c2eSHans Petter Selasky int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx); 138997549c34SHans Petter Selasky int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); 139097549c34SHans Petter Selasky int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); 139197549c34SHans Petter Selasky void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan); 139297549c34SHans Petter Selasky 139397549c34SHans Petter Selasky int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list, 139497549c34SHans Petter Selasky int npages, u64 iova, u32 *lkey, u32 *rkey); 139597549c34SHans Petter Selasky int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages, 139697549c34SHans Petter Selasky int max_maps, u8 page_shift, struct mlx4_fmr *fmr); 139797549c34SHans Petter Selasky int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr); 139897549c34SHans Petter Selasky void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr, 139997549c34SHans Petter Selasky u32 *lkey, u32 *rkey); 140097549c34SHans Petter Selasky int mlx4_fmr_free(struct mlx4_dev *dev, struct mlx4_fmr *fmr); 140197549c34SHans Petter Selasky int mlx4_SYNC_TPT(struct mlx4_dev *dev); 1402c3191c2eSHans Petter Selasky int mlx4_test_interrupt(struct mlx4_dev *dev, int vector); 1403c3191c2eSHans Petter Selasky int mlx4_test_async(struct mlx4_dev *dev); 1404c3191c2eSHans Petter Selasky int mlx4_query_diag_counters(struct mlx4_dev *dev, u8 op_modifier, 1405c3191c2eSHans Petter Selasky const u32 offset[], u32 value[], 1406c3191c2eSHans Petter Selasky size_t array_len, u8 port); 1407c3191c2eSHans Petter Selasky u32 mlx4_get_eqs_per_port(struct mlx4_dev *dev, u8 port); 1408c3191c2eSHans Petter Selasky bool mlx4_is_eq_vector_valid(struct mlx4_dev *dev, u8 port, int vector); 1409c3191c2eSHans Petter Selasky int mlx4_assign_eq(struct mlx4_dev *dev, u8 port, int *vector); 141097549c34SHans Petter Selasky void mlx4_release_eq(struct mlx4_dev *dev, int vec); 141197549c34SHans Petter Selasky 1412c3191c2eSHans Petter Selasky int mlx4_is_eq_shared(struct mlx4_dev *dev, int vector); 1413c3191c2eSHans Petter Selasky int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec); 1414c3191c2eSHans Petter Selasky 1415c3191c2eSHans Petter Selasky int mlx4_get_phys_port_id(struct mlx4_dev *dev); 141697549c34SHans Petter Selasky int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port); 141797549c34SHans Petter Selasky int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port); 141897549c34SHans Petter Selasky 1419c3191c2eSHans Petter Selasky int mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx); 1420c3191c2eSHans Petter Selasky void mlx4_counter_free(struct mlx4_dev *dev, u32 idx); 1421c3191c2eSHans Petter Selasky int mlx4_get_default_counter_index(struct mlx4_dev *dev, int port); 142297549c34SHans Petter Selasky 1423c3191c2eSHans Petter Selasky void mlx4_set_admin_guid(struct mlx4_dev *dev, __be64 guid, int entry, 1424c3191c2eSHans Petter Selasky int port); 1425c3191c2eSHans Petter Selasky __be64 mlx4_get_admin_guid(struct mlx4_dev *dev, int entry, int port); 1426c3191c2eSHans Petter Selasky void mlx4_set_random_admin_guid(struct mlx4_dev *dev, int entry, int port); 142797549c34SHans Petter Selasky int mlx4_flow_attach(struct mlx4_dev *dev, 142897549c34SHans Petter Selasky struct mlx4_net_trans_rule *rule, u64 *reg_id); 142997549c34SHans Petter Selasky int mlx4_flow_detach(struct mlx4_dev *dev, u64 reg_id); 1430c3191c2eSHans Petter Selasky int mlx4_map_sw_to_hw_steering_mode(struct mlx4_dev *dev, 143197549c34SHans Petter Selasky enum mlx4_net_trans_promisc_mode flow_type); 1432c3191c2eSHans Petter Selasky int mlx4_map_sw_to_hw_steering_id(struct mlx4_dev *dev, 143397549c34SHans Petter Selasky enum mlx4_net_trans_rule_id id); 1434c3191c2eSHans Petter Selasky int mlx4_hw_rule_sz(struct mlx4_dev *dev, enum mlx4_net_trans_rule_id id); 1435c3191c2eSHans Petter Selasky 1436c3191c2eSHans Petter Selasky int mlx4_tunnel_steer_add(struct mlx4_dev *dev, unsigned char *addr, 1437c3191c2eSHans Petter Selasky int port, int qpn, u16 prio, u64 *reg_id); 143897549c34SHans Petter Selasky 143997549c34SHans Petter Selasky void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port, 144097549c34SHans Petter Selasky int i, int val); 144197549c34SHans Petter Selasky 144297549c34SHans Petter Selasky int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey); 144397549c34SHans Petter Selasky 144497549c34SHans Petter Selasky int mlx4_is_slave_active(struct mlx4_dev *dev, int slave); 144597549c34SHans Petter Selasky int mlx4_gen_pkey_eqe(struct mlx4_dev *dev, int slave, u8 port); 144697549c34SHans Petter Selasky int mlx4_gen_guid_change_eqe(struct mlx4_dev *dev, int slave, u8 port); 1447c3191c2eSHans Petter Selasky int mlx4_gen_slaves_port_mgt_ev(struct mlx4_dev *dev, u8 port, int attr); 144897549c34SHans Petter Selasky int mlx4_gen_port_state_change_eqe(struct mlx4_dev *dev, int slave, u8 port, u8 port_subtype_change); 144997549c34SHans Petter Selasky enum slave_port_state mlx4_get_slave_port_state(struct mlx4_dev *dev, int slave, u8 port); 145097549c34SHans 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); 145197549c34SHans Petter Selasky 145297549c34SHans Petter Selasky void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid); 145397549c34SHans Petter Selasky __be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave); 145497549c34SHans Petter Selasky 1455c3191c2eSHans Petter Selasky int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid, 1456c3191c2eSHans Petter Selasky int *slave_id); 1457c3191c2eSHans Petter Selasky int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev, int port, int slave_id, 1458c3191c2eSHans Petter Selasky u8 *gid); 1459c3191c2eSHans Petter Selasky 1460c3191c2eSHans Petter Selasky int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn, 1461c3191c2eSHans Petter Selasky u32 max_range_qpn); 146297549c34SHans Petter Selasky 1463b0259ad3SHans Petter Selasky s64 mlx4_read_clock(struct mlx4_dev *dev); 1464c3191c2eSHans Petter Selasky 1465c3191c2eSHans Petter Selasky struct mlx4_active_ports { 1466c3191c2eSHans Petter Selasky DECLARE_BITMAP(ports, MLX4_MAX_PORTS); 1467c3191c2eSHans Petter Selasky }; 1468c3191c2eSHans Petter Selasky /* Returns a bitmap of the physical ports which are assigned to slave */ 1469c3191c2eSHans Petter Selasky struct mlx4_active_ports mlx4_get_active_ports(struct mlx4_dev *dev, int slave); 1470c3191c2eSHans Petter Selasky 1471c3191c2eSHans Petter Selasky /* Returns the physical port that represents the virtual port of the slave, */ 1472c3191c2eSHans Petter Selasky /* or a value < 0 in case of an error. If a slave has 2 ports, the identity */ 1473c3191c2eSHans Petter Selasky /* mapping is returned. */ 1474c3191c2eSHans Petter Selasky int mlx4_slave_convert_port(struct mlx4_dev *dev, int slave, int port); 1475c3191c2eSHans Petter Selasky 1476c3191c2eSHans Petter Selasky struct mlx4_slaves_pport { 1477c3191c2eSHans Petter Selasky DECLARE_BITMAP(slaves, MLX4_MFUNC_MAX); 1478c3191c2eSHans Petter Selasky }; 1479c3191c2eSHans Petter Selasky /* Returns a bitmap of all slaves that are assigned to port. */ 1480c3191c2eSHans Petter Selasky struct mlx4_slaves_pport mlx4_phys_to_slaves_pport(struct mlx4_dev *dev, 1481c3191c2eSHans Petter Selasky int port); 1482c3191c2eSHans Petter Selasky 1483c3191c2eSHans Petter Selasky /* Returns a bitmap of all slaves that are assigned exactly to all the */ 1484c3191c2eSHans Petter Selasky /* the ports that are set in crit_ports. */ 1485c3191c2eSHans Petter Selasky struct mlx4_slaves_pport mlx4_phys_to_slaves_pport_actv( 1486c3191c2eSHans Petter Selasky struct mlx4_dev *dev, 1487c3191c2eSHans Petter Selasky const struct mlx4_active_ports *crit_ports); 1488c3191c2eSHans Petter Selasky 1489c3191c2eSHans Petter Selasky /* Returns the slave's virtual port that represents the physical port. */ 1490c3191c2eSHans Petter Selasky int mlx4_phys_to_slave_port(struct mlx4_dev *dev, int slave, int port); 1491c3191c2eSHans Petter Selasky 1492c3191c2eSHans Petter Selasky int mlx4_get_base_gid_ix(struct mlx4_dev *dev, int slave, int port); 1493c3191c2eSHans Petter Selasky 1494c3191c2eSHans Petter Selasky int mlx4_config_vxlan_port(struct mlx4_dev *dev, __be16 udp_port); 1495c3191c2eSHans Petter Selasky int mlx4_disable_rx_port_check(struct mlx4_dev *dev, bool dis); 1496c3191c2eSHans Petter Selasky int mlx4_config_roce_v2_port(struct mlx4_dev *dev, u16 udp_port); 1497c3191c2eSHans Petter Selasky int mlx4_virt2phy_port_map(struct mlx4_dev *dev, u32 port1, u32 port2); 1498c3191c2eSHans Petter Selasky int mlx4_vf_smi_enabled(struct mlx4_dev *dev, int slave, int port); 1499c3191c2eSHans Petter Selasky int mlx4_vf_get_enable_smi_admin(struct mlx4_dev *dev, int slave, int port); 1500c3191c2eSHans Petter Selasky int mlx4_vf_set_enable_smi_admin(struct mlx4_dev *dev, int slave, int port, 1501c3191c2eSHans Petter Selasky int enable); 1502c3191c2eSHans Petter Selasky int mlx4_mr_hw_get_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr, 1503c3191c2eSHans Petter Selasky struct mlx4_mpt_entry ***mpt_entry); 1504c3191c2eSHans Petter Selasky int mlx4_mr_hw_write_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr, 1505c3191c2eSHans Petter Selasky struct mlx4_mpt_entry **mpt_entry); 1506c3191c2eSHans Petter Selasky int mlx4_mr_hw_change_pd(struct mlx4_dev *dev, struct mlx4_mpt_entry *mpt_entry, 1507c3191c2eSHans Petter Selasky u32 pdn); 1508c3191c2eSHans Petter Selasky int mlx4_mr_hw_change_access(struct mlx4_dev *dev, 1509c3191c2eSHans Petter Selasky struct mlx4_mpt_entry *mpt_entry, 1510c3191c2eSHans Petter Selasky u32 access); 1511c3191c2eSHans Petter Selasky void mlx4_mr_hw_put_mpt(struct mlx4_dev *dev, 1512c3191c2eSHans Petter Selasky struct mlx4_mpt_entry **mpt_entry); 1513c3191c2eSHans Petter Selasky void mlx4_mr_rereg_mem_cleanup(struct mlx4_dev *dev, struct mlx4_mr *mr); 1514c3191c2eSHans Petter Selasky int mlx4_mr_rereg_mem_write(struct mlx4_dev *dev, struct mlx4_mr *mr, 1515c3191c2eSHans Petter Selasky u64 iova, u64 size, int npages, 1516c3191c2eSHans Petter Selasky int page_shift, struct mlx4_mpt_entry *mpt_entry); 151797549c34SHans Petter Selasky 151897549c34SHans Petter Selasky int mlx4_get_module_info(struct mlx4_dev *dev, u8 port, 151997549c34SHans Petter Selasky u16 offset, u16 size, u8 *data); 1520c3191c2eSHans Petter Selasky int mlx4_max_tc(struct mlx4_dev *dev); 152197549c34SHans Petter Selasky 1522c3191c2eSHans Petter Selasky /* Returns true if running in low memory profile (kdump kernel) */ 1523c3191c2eSHans Petter Selasky static inline bool mlx4_low_memory_profile(void) 1524c3191c2eSHans Petter Selasky { 1525c3191c2eSHans Petter Selasky return false; 1526c3191c2eSHans Petter Selasky } 1527c3191c2eSHans Petter Selasky 1528c3191c2eSHans Petter Selasky /* ACCESS REG commands */ 1529c3191c2eSHans Petter Selasky enum mlx4_access_reg_method { 1530c3191c2eSHans Petter Selasky MLX4_ACCESS_REG_QUERY = 0x1, 1531c3191c2eSHans Petter Selasky MLX4_ACCESS_REG_WRITE = 0x2, 1532c3191c2eSHans Petter Selasky }; 1533c3191c2eSHans Petter Selasky 1534c3191c2eSHans Petter Selasky /* ACCESS PTYS Reg command */ 1535c3191c2eSHans Petter Selasky enum mlx4_ptys_proto { 1536c3191c2eSHans Petter Selasky MLX4_PTYS_IB = 1<<0, 1537c3191c2eSHans Petter Selasky MLX4_PTYS_EN = 1<<2, 1538c3191c2eSHans Petter Selasky }; 1539c3191c2eSHans Petter Selasky 1540c3191c2eSHans Petter Selasky struct mlx4_ptys_reg { 1541c3191c2eSHans Petter Selasky u8 resrvd1; 1542c3191c2eSHans Petter Selasky u8 local_port; 1543c3191c2eSHans Petter Selasky u8 resrvd2; 1544c3191c2eSHans Petter Selasky u8 proto_mask; 1545c3191c2eSHans Petter Selasky __be32 resrvd3[2]; 1546c3191c2eSHans Petter Selasky __be32 eth_proto_cap; 1547c3191c2eSHans Petter Selasky __be16 ib_width_cap; 1548c3191c2eSHans Petter Selasky __be16 ib_speed_cap; 1549c3191c2eSHans Petter Selasky __be32 resrvd4; 1550c3191c2eSHans Petter Selasky __be32 eth_proto_admin; 1551c3191c2eSHans Petter Selasky __be16 ib_width_admin; 1552c3191c2eSHans Petter Selasky __be16 ib_speed_admin; 1553c3191c2eSHans Petter Selasky __be32 resrvd5; 1554c3191c2eSHans Petter Selasky __be32 eth_proto_oper; 1555c3191c2eSHans Petter Selasky __be16 ib_width_oper; 1556c3191c2eSHans Petter Selasky __be16 ib_speed_oper; 1557c3191c2eSHans Petter Selasky __be32 resrvd6; 1558c3191c2eSHans Petter Selasky __be32 eth_proto_lp_adv; 1559c3191c2eSHans Petter Selasky } __packed; 1560c3191c2eSHans Petter Selasky 1561c3191c2eSHans Petter Selasky int mlx4_ACCESS_PTYS_REG(struct mlx4_dev *dev, 1562c3191c2eSHans Petter Selasky enum mlx4_access_reg_method method, 1563c3191c2eSHans Petter Selasky struct mlx4_ptys_reg *ptys_reg); 1564c3191c2eSHans Petter Selasky 1565c3191c2eSHans Petter Selasky int mlx4_get_internal_clock_params(struct mlx4_dev *dev, 1566c3191c2eSHans Petter Selasky struct mlx4_clock_params *params); 1567c3191c2eSHans Petter Selasky 1568c3191c2eSHans Petter Selasky static inline int mlx4_to_hw_uar_index(struct mlx4_dev *dev, int index) 1569c3191c2eSHans Petter Selasky { 1570c3191c2eSHans Petter Selasky return (index << (PAGE_SHIFT - dev->uar_page_shift)); 1571c3191c2eSHans Petter Selasky } 1572c3191c2eSHans Petter Selasky 1573c3191c2eSHans Petter Selasky static inline int mlx4_get_num_reserved_uar(struct mlx4_dev *dev) 1574c3191c2eSHans Petter Selasky { 1575c3191c2eSHans Petter Selasky /* The first 128 UARs are used for EQ doorbells */ 1576c3191c2eSHans Petter Selasky return (128 >> (PAGE_SHIFT - dev->uar_page_shift)); 1577c3191c2eSHans Petter Selasky } 157897549c34SHans Petter Selasky #endif /* MLX4_DEVICE_H */ 1579