Author: hselasky
Date: Wed Nov 15 11:14:39 2017
New Revision: 325841
URL: https://svnweb.freebsd.org/changeset/base/325841

Log:
  Update the mlx4 core and mlx4en(4) modules towards Linux v4.9.
  
  Background:
  The coming ibcore update forces an update of mlx4ib(4) which in turn requires
  an updated mlx4 core module. This also affects the mlx4en(4) module because
  commonly used APIs are updated. This commit is a middle step updating the
  mlx4 modules towards the new ibcore.
  
  This change contains no major new features.
  
  Changes in mlx4:
    a) Improved error handling when mlx4 PCI devices are
    detached inside VMs.
    b) Major update of codebase towards Linux 4.9.
  
  Changes in mlx4ib(4):
    a) Minimal changes needed in order to compile using the
    updated mlx4 core APIs.
  
  Changes in mlx4en(4):
    a) Update flow steering code in mlx4en to use new APIs for
    registering MAC addresses and IP addresses.
    b) Update all statistics counters to be 64-bit.
    c) Minimal changes needed in order to compile using the
    updated mlx4 core APIs.
  
  Sponsored by: Mellanox Technologies
  MFC after:    1 week

Added:
  head/sys/dev/mlx4/mlx4_core/fw_qos.h   (contents, props changed)
  head/sys/dev/mlx4/mlx4_core/mlx4_fw_qos.c   (contents, props changed)
Deleted:
  head/sys/dev/mlx4/mlx4_core/mlx4_sys_tune.c
Modified:
  head/sys/conf/files
  head/sys/dev/mlx4/cmd.h
  head/sys/dev/mlx4/cq.h
  head/sys/dev/mlx4/device.h
  head/sys/dev/mlx4/driver.h
  head/sys/dev/mlx4/mlx4_core/fw.h
  head/sys/dev/mlx4/mlx4_core/icm.h
  head/sys/dev/mlx4/mlx4_core/mlx4.h
  head/sys/dev/mlx4/mlx4_core/mlx4_alloc.c
  head/sys/dev/mlx4/mlx4_core/mlx4_catas.c
  head/sys/dev/mlx4/mlx4_core/mlx4_cmd.c
  head/sys/dev/mlx4/mlx4_core/mlx4_cq.c
  head/sys/dev/mlx4/mlx4_core/mlx4_eq.c
  head/sys/dev/mlx4/mlx4_core/mlx4_fw.c
  head/sys/dev/mlx4/mlx4_core/mlx4_icm.c
  head/sys/dev/mlx4/mlx4_core/mlx4_intf.c
  head/sys/dev/mlx4/mlx4_core/mlx4_main.c
  head/sys/dev/mlx4/mlx4_core/mlx4_mcg.c
  head/sys/dev/mlx4/mlx4_core/mlx4_mr.c
  head/sys/dev/mlx4/mlx4_core/mlx4_pd.c
  head/sys/dev/mlx4/mlx4_core/mlx4_port.c
  head/sys/dev/mlx4/mlx4_core/mlx4_profile.c
  head/sys/dev/mlx4/mlx4_core/mlx4_qp.c
  head/sys/dev/mlx4/mlx4_core/mlx4_reset.c
  head/sys/dev/mlx4/mlx4_core/mlx4_resource_tracker.c
  head/sys/dev/mlx4/mlx4_core/mlx4_sense.c
  head/sys/dev/mlx4/mlx4_core/mlx4_srq.c
  head/sys/dev/mlx4/mlx4_en/en.h
  head/sys/dev/mlx4/mlx4_en/en_port.h
  head/sys/dev/mlx4/mlx4_en/mlx4_en_cq.c
  head/sys/dev/mlx4/mlx4_en/mlx4_en_main.c
  head/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c
  head/sys/dev/mlx4/mlx4_en/mlx4_en_port.c
  head/sys/dev/mlx4/mlx4_en/mlx4_en_resources.c
  head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c
  head/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib.h
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib_mr.c
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib_srq.c
  head/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c
  head/sys/dev/mlx4/qp.h
  head/sys/dev/mlx4/stats.h
  head/sys/modules/mlx4/Makefile

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files Wed Nov 15 06:45:33 2017        (r325840)
+++ head/sys/conf/files Wed Nov 15 11:14:39 2017        (r325841)
@@ -4569,6 +4569,8 @@ dev/mlx4/mlx4_core/mlx4_eq.c                      
optional mlx4 pci \
        compile-with "${OFED_C}"
 dev/mlx4/mlx4_core/mlx4_fw.c                   optional mlx4 pci \
        compile-with "${OFED_C}"
+dev/mlx4/mlx4_core/mlx4_fw_qos.c               optional mlx4 pci \
+       compile-with "${OFED_C}"
 dev/mlx4/mlx4_core/mlx4_icm.c                  optional mlx4 pci \
        compile-with "${OFED_C}"
 dev/mlx4/mlx4_core/mlx4_intf.c                 optional mlx4 pci \
@@ -4594,8 +4596,6 @@ dev/mlx4/mlx4_core/mlx4_sense.c                   
optional mlx4 pci \
 dev/mlx4/mlx4_core/mlx4_srq.c                  optional mlx4 pci \
        compile-with "${OFED_C}"
 dev/mlx4/mlx4_core/mlx4_resource_tracker.c     optional mlx4 pci \
-       compile-with "${OFED_C}"
-dev/mlx4/mlx4_core/mlx4_sys_tune.c             optional mlx4 pci \
        compile-with "${OFED_C}"
 
 dev/mlx4/mlx4_en/mlx4_en_cq.c                  optional mlx4en pci inet inet6  
\

Modified: head/sys/dev/mlx4/cmd.h
==============================================================================
--- head/sys/dev/mlx4/cmd.h     Wed Nov 15 06:45:33 2017        (r325840)
+++ head/sys/dev/mlx4/cmd.h     Wed Nov 15 11:14:39 2017        (r325841)
@@ -36,6 +36,8 @@
 #include <linux/dma-mapping.h>
 #include <linux/types.h>
 
+struct mlx4_counter;
+
 enum {
        /* initialization and general commands */
        MLX4_CMD_SYS_EN          = 0x1,
@@ -67,8 +69,13 @@ enum {
        MLX4_CMD_MAP_ICM_AUX     = 0xffc,
        MLX4_CMD_UNMAP_ICM_AUX   = 0xffb,
        MLX4_CMD_SET_ICM_SIZE    = 0xffd,
+       MLX4_CMD_ACCESS_REG      = 0x3b,
+       MLX4_CMD_ALLOCATE_VPP    = 0x80,
+       MLX4_CMD_SET_VPORT_QOS   = 0x81,
+
        /*master notify fw on finish for slave's flr*/
        MLX4_CMD_INFORM_FLR_DONE = 0x5b,
+       MLX4_CMD_VIRT_PORT_MAP   = 0x5c,
        MLX4_CMD_GET_OP_REQ      = 0x59,
 
        /* TPT commands */
@@ -116,6 +123,7 @@ enum {
        /* special QP and management commands */
        MLX4_CMD_CONF_SPECIAL_QP = 0x23,
        MLX4_CMD_MAD_IFC         = 0x24,
+       MLX4_CMD_MAD_DEMUX       = 0x203,
 
        /* multicast commands */
        MLX4_CMD_READ_MCG        = 0x25,
@@ -125,6 +133,7 @@ enum {
        /* miscellaneous commands */
        MLX4_CMD_DIAG_RPRT       = 0x30,
        MLX4_CMD_NOP             = 0x31,
+       MLX4_CMD_CONFIG_DEV      = 0x3a,
        MLX4_CMD_ACCESS_MEM      = 0x2e,
        MLX4_CMD_SET_VEP         = 0x52,
 
@@ -158,6 +167,9 @@ enum {
        MLX4_QP_FLOW_STEERING_ATTACH = 0x65,
        MLX4_QP_FLOW_STEERING_DETACH = 0x66,
        MLX4_FLOW_STEERING_IB_UC_QP_RANGE = 0x64,
+
+       /* Update and read QCN parameters */
+       MLX4_CMD_CONGESTION_CTRL_OPCODE = 0x68,
 };
 
 enum {
@@ -167,27 +179,85 @@ enum {
 };
 
 enum {
+       /* virtual to physical port mapping opcode modifiers */
+       MLX4_GET_PORT_VIRT2PHY = 0x0,
+       MLX4_SET_PORT_VIRT2PHY = 0x1,
+};
+
+enum {
        MLX4_MAILBOX_SIZE       = 4096,
        MLX4_ACCESS_MEM_ALIGN   = 256,
 };
 
 enum {
-       /* set port opcode modifiers */
-       MLX4_SET_PORT_GENERAL           = 0x0,
-       MLX4_SET_PORT_RQP_CALC          = 0x1,
-       MLX4_SET_PORT_MAC_TABLE         = 0x2,
-       MLX4_SET_PORT_VLAN_TABLE        = 0x3,
-       MLX4_SET_PORT_PRIO_MAP          = 0x4,
-       MLX4_SET_PORT_GID_TABLE         = 0x5,
-       MLX4_SET_PORT_PRIO2TC           = 0x8,
-       MLX4_SET_PORT_SCHEDULER         = 0x9
+       /* Set port opcode modifiers */
+       MLX4_SET_PORT_IB_OPCODE         = 0x0,
+       MLX4_SET_PORT_ETH_OPCODE        = 0x1,
+       MLX4_SET_PORT_BEACON_OPCODE     = 0x4,
 };
 
 enum {
+       /* Set port Ethernet input modifiers */
+       MLX4_SET_PORT_GENERAL   = 0x0,
+       MLX4_SET_PORT_RQP_CALC  = 0x1,
+       MLX4_SET_PORT_MAC_TABLE = 0x2,
+       MLX4_SET_PORT_VLAN_TABLE = 0x3,
+       MLX4_SET_PORT_PRIO_MAP  = 0x4,
+       MLX4_SET_PORT_GID_TABLE = 0x5,
+       MLX4_SET_PORT_PRIO2TC   = 0x8,
+       MLX4_SET_PORT_SCHEDULER = 0x9,
+       MLX4_SET_PORT_VXLAN     = 0xB,
+       MLX4_SET_PORT_ROCE_ADDR = 0xD
+};
+
+enum {
+       MLX4_CMD_MAD_DEMUX_CONFIG       = 0,
+       MLX4_CMD_MAD_DEMUX_QUERY_STATE  = 1,
+       MLX4_CMD_MAD_DEMUX_QUERY_RESTR  = 2, /* Query mad demux restrictions */
+};
+
+enum {
        MLX4_CMD_WRAPPED,
        MLX4_CMD_NATIVE
 };
 
+/*
+ * MLX4_RX_CSUM_MODE_VAL_NON_TCP_UDP -
+ * Receive checksum value is reported in CQE also for non TCP/UDP packets.
+ *
+ * MLX4_RX_CSUM_MODE_L4 -
+ * L4_CSUM bit in CQE, which indicates whether or not L4 checksum
+ * was validated correctly, is supported.
+ *
+ * MLX4_RX_CSUM_MODE_IP_OK_IP_NON_TCP_UDP -
+ * IP_OK CQE's field is supported also for non TCP/UDP IP packets.
+ *
+ * MLX4_RX_CSUM_MODE_MULTI_VLAN -
+ * Receive Checksum offload is supported for packets with more than 2 vlan 
headers.
+ */
+enum mlx4_rx_csum_mode {
+       MLX4_RX_CSUM_MODE_VAL_NON_TCP_UDP               = 1UL << 0,
+       MLX4_RX_CSUM_MODE_L4                            = 1UL << 1,
+       MLX4_RX_CSUM_MODE_IP_OK_IP_NON_TCP_UDP          = 1UL << 2,
+       MLX4_RX_CSUM_MODE_MULTI_VLAN                    = 1UL << 3
+};
+
+struct mlx4_config_dev_params {
+       u16     vxlan_udp_dport;
+       u8      rx_csum_flags_port_1;
+       u8      rx_csum_flags_port_2;
+};
+
+enum mlx4_en_congestion_control_algorithm {
+       MLX4_CTRL_ALGO_802_1_QAU_REACTION_POINT = 0,
+};
+
+enum mlx4_en_congestion_control_opmod {
+       MLX4_CONGESTION_CONTROL_GET_PARAMS,
+       MLX4_CONGESTION_CONTROL_GET_STATISTICS,
+       MLX4_CONGESTION_CONTROL_SET_PARAMS = 4,
+};
+
 struct mlx4_dev;
 
 struct mlx4_cmd_mailbox {
@@ -233,26 +303,28 @@ static inline int mlx4_cmd_imm(struct mlx4_dev *dev, u
 struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev);
 void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox 
*mailbox);
 
+int mlx4_get_counter_stats(struct mlx4_dev *dev, int counter_index,
+                          struct mlx4_counter *counter_stats, int reset);
 u32 mlx4_comm_get_version(void);
-int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u8 *mac);
-int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos);
+int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac);
+int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan,
+                    u8 qos, __be16 proto);
+int mlx4_set_vf_rate(struct mlx4_dev *dev, int port, int vf, int min_tx_rate,
+                    int max_tx_rate);
 int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting);
-int mlx4_set_vf_link_state(struct mlx4_dev *dev, int port, int vf, int 
link_state);
-int mlx4_get_vf_link_state(struct mlx4_dev *dev, int port, int vf);
+int mlx4_config_dev_retrieval(struct mlx4_dev *dev,
+                             struct mlx4_config_dev_params *params);
+void mlx4_cmd_wake_completions(struct mlx4_dev *dev);
+void mlx4_report_internal_err_comm_event(struct mlx4_dev *dev);
 /*
  * mlx4_get_slave_default_vlan -
- * retrun true if VST ( default vlan)
- * if VST will fill vlan & qos (if not NULL)
+ * return true if VST ( default vlan)
+ * if VST, will return vlan & qos (if not NULL)
  */
-bool mlx4_get_slave_default_vlan(struct mlx4_dev *dev, int port, int slave, 
u16 *vlan, u8 *qos);
+bool mlx4_get_slave_default_vlan(struct mlx4_dev *dev, int port, int slave,
+                                u16 *vlan, u8 *qos);
 
-enum {
-       IFLA_VF_LINK_STATE_AUTO,        /* link state of the uplink */
-       IFLA_VF_LINK_STATE_ENABLE,      /* link always up */
-       IFLA_VF_LINK_STATE_DISABLE,     /* link always down */
-       __IFLA_VF_LINK_STATE_MAX,
-};
-
 #define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8)
+#define COMM_CHAN_EVENT_INTERNAL_ERR (1 << 17)
 
 #endif /* MLX4_CMD_H */

Modified: head/sys/dev/mlx4/cq.h
==============================================================================
--- head/sys/dev/mlx4/cq.h      Wed Nov 15 06:45:33 2017        (r325840)
+++ head/sys/dev/mlx4/cq.h      Wed Nov 15 11:14:39 2017        (r325841)
@@ -42,31 +42,22 @@ struct mlx4_cqe {
        __be32                  vlan_my_qpn;
        __be32                  immed_rss_invalid;
        __be32                  g_mlpath_rqpn;
+       __be16                  sl_vid;
        union {
                struct {
-                       union {
-                               struct {
-                                       __be16                  sl_vid;
-                                       __be16  rlid;
-                               };
-                               __be32                  timestamp_16_47;
-                       };
+                       __be16  rlid;
                        __be16  status;
                        u8      ipv6_ext_mask;
                        u8      badfcs_enc;
                };
-               struct {
-                       __be16 reserved1;
-                       u8  smac[6];
-               };
+               u8  smac[ETH_ALEN];
        };
        __be32                  byte_cnt;
        __be16                  wqe_index;
        __be16                  checksum;
-       u8                      reserved2[1];
-       __be16                  timestamp_0_15;
+       u8                      reserved[3];
        u8                      owner_sr_opcode;
-} __packed;
+};
 
 struct mlx4_err_cqe {
        __be32                  my_qpn;
@@ -95,7 +86,13 @@ struct mlx4_ts_cqe {
 } __packed;
 
 enum {
-       MLX4_CQE_VLAN_PRESENT_MASK      = 1 << 29,
+       MLX4_CQE_L2_TUNNEL_IPOK         = 1 << 31,
+       MLX4_CQE_CVLAN_PRESENT_MASK     = 1 << 29,
+       MLX4_CQE_SVLAN_PRESENT_MASK     = 1 << 30,
+       MLX4_CQE_L2_TUNNEL              = 1 << 27,
+       MLX4_CQE_L2_TUNNEL_CSUM         = 1 << 26,
+       MLX4_CQE_L2_TUNNEL_IPV4         = 1 << 25,
+
        MLX4_CQE_QPN_MASK               = 0xffffff,
        MLX4_CQE_VID_MASK               = 0xfff,
 };
@@ -177,5 +174,5 @@ int mlx4_cq_modify(struct mlx4_dev *dev, struct mlx4_c
                   u16 count, u16 period);
 int mlx4_cq_resize(struct mlx4_dev *dev, struct mlx4_cq *cq,
                   int entries, struct mlx4_mtt *mtt);
-int mlx4_cq_ignore_overrun(struct mlx4_dev *dev, struct mlx4_cq *cq);
+
 #endif /* MLX4_CQ_H */

Modified: head/sys/dev/mlx4/device.h
==============================================================================
--- head/sys/dev/mlx4/device.h  Wed Nov 15 06:45:33 2017        (r325840)
+++ head/sys/dev/mlx4/device.h  Wed Nov 15 11:14:39 2017        (r325841)
@@ -39,20 +39,21 @@
 #include <linux/types.h>
 #include <linux/bitops.h>
 #include <linux/workqueue.h>
+#include <linux/if_ether.h>
+#include <linux/mutex.h>
+
 #include <asm/atomic.h>
 
 #include <linux/clocksource.h>
 
+#define DEFAULT_UAR_PAGE_SHIFT  12
+
 #define MAX_MSIX_P_PORT                17
 #define MAX_MSIX               64
-#define MSIX_LEGACY_SZ         4
 #define MIN_MSIX_P_PORT                5
+#define MLX4_IS_LEGACY_EQ_MODE(dev_cap) ((dev_cap).num_comp_vectors < \
+                                        (dev_cap).num_ports * MIN_MSIX_P_PORT)
 
-#define MLX4_ROCE_MAX_GIDS     128
-#define MLX4_ROCE_PF_GIDS      16
-
-#define MLX4_NUM_UP                    8
-#define MLX4_NUM_TC                    8
 #define MLX4_MAX_100M_UNITS_VAL                255     /*
                                                 * work around: can't set values
                                                 * greater then this value when
@@ -62,6 +63,9 @@
 #define MLX4_RATELIMIT_1G_UNITS                4       /* 1 Gbps */
 #define MLX4_RATELIMIT_DEFAULT         0x00ff
 
+#define MLX4_ROCE_MAX_GIDS     128
+#define MLX4_ROCE_PF_GIDS      16
+
 #define CORE_CLOCK_MASK 0xffffffffffffULL
 
 enum {
@@ -70,8 +74,9 @@ enum {
        MLX4_FLAG_MASTER        = 1 << 2,
        MLX4_FLAG_SLAVE         = 1 << 3,
        MLX4_FLAG_SRIOV         = 1 << 4,
-       MLX4_FLAG_DEV_NUM_STR   = 1 << 5,
-       MLX4_FLAG_OLD_REG_MAC   = 1 << 6,
+       MLX4_FLAG_OLD_REG_MAC   = 1 << 6,
+       MLX4_FLAG_BONDED        = 1 << 7,
+       MLX4_FLAG_SECURE_HOST   = 1 << 8,
 };
 
 enum {
@@ -81,7 +86,8 @@ enum {
 
 enum {
        MLX4_MAX_PORTS          = 2,
-       MLX4_MAX_PORT_PKEYS     = 128
+       MLX4_MAX_PORT_PKEYS     = 128,
+       MLX4_MAX_PORT_GIDS      = 128
 };
 
 /* base qkey for use in sriov tunnel-qp/proxy-qp communication.
@@ -92,14 +98,14 @@ enum {
 #define MLX4_RESERVED_QKEY_MASK  (0xFFFF0000)
 
 enum {
-       MLX4_BOARD_ID_LEN = 64,
-       MLX4_VSD_LEN = 208
+       MLX4_BOARD_ID_LEN = 64
 };
 
 enum {
        MLX4_MAX_NUM_PF         = 16,
-       MLX4_MAX_NUM_VF         = 64,
-       MLX4_MFUNC_MAX          = 80,
+       MLX4_MAX_NUM_VF         = 126,
+       MLX4_MAX_NUM_VF_P_PORT  = 64,
+       MLX4_MFUNC_MAX          = 128,
        MLX4_MAX_EQ_NUM         = 1024,
        MLX4_MFUNC_EQ_NUM       = 4,
        MLX4_MFUNC_MAX_EQES     = 8,
@@ -119,6 +125,14 @@ enum {
        MLX4_STEERING_MODE_DEVICE_MANAGED
 };
 
+enum {
+       MLX4_STEERING_DMFS_A0_DEFAULT,
+       MLX4_STEERING_DMFS_A0_DYNAMIC,
+       MLX4_STEERING_DMFS_A0_STATIC,
+       MLX4_STEERING_DMFS_A0_DISABLE,
+       MLX4_STEERING_DMFS_A0_NOT_SUPPORTED
+};
+
 static inline const char *mlx4_steering_mode_str(int steering_mode)
 {
        switch (steering_mode) {
@@ -137,6 +151,11 @@ static inline const char *mlx4_steering_mode_str(int s
 }
 
 enum {
+       MLX4_TUNNEL_OFFLOAD_MODE_NONE,
+       MLX4_TUNNEL_OFFLOAD_MODE_VXLAN
+};
+
+enum {
        MLX4_DEV_CAP_FLAG_RC            = 1LL <<  0,
        MLX4_DEV_CAP_FLAG_UC            = 1LL <<  1,
        MLX4_DEV_CAP_FLAG_UD            = 1LL <<  2,
@@ -161,12 +180,10 @@ enum {
        MLX4_DEV_CAP_FLAG_UDP_RSS       = 1LL << 40,
        MLX4_DEV_CAP_FLAG_VEP_UC_STEER  = 1LL << 41,
        MLX4_DEV_CAP_FLAG_VEP_MC_STEER  = 1LL << 42,
-       MLX4_DEV_CAP_FLAG_CROSS_CHANNEL = 1LL << 44,
        MLX4_DEV_CAP_FLAG_COUNTERS      = 1LL << 48,
-       MLX4_DEV_CAP_FLAG_COUNTERS_EXT  = 1LL << 49,
-       MLX4_DEV_CAP_FLAG_SET_PORT_ETH_SCHED = 1LL << 53,
+       MLX4_DEV_CAP_FLAG_RSS_IP_FRAG   = 1LL << 52,
+       MLX4_DEV_CAP_FLAG_SET_ETH_SCHED = 1LL << 53,
        MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55,
-       MLX4_DEV_CAP_FLAG_FAST_DROP     = 1LL << 57,
        MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59,
        MLX4_DEV_CAP_FLAG_64B_EQE       = 1LL << 61,
        MLX4_DEV_CAP_FLAG_64B_CQE       = 1LL << 62
@@ -177,51 +194,51 @@ enum {
        MLX4_DEV_CAP_FLAG2_RSS_TOP              = 1LL <<  1,
        MLX4_DEV_CAP_FLAG2_RSS_XOR              = 1LL <<  2,
        MLX4_DEV_CAP_FLAG2_FS_EN                = 1LL <<  3,
-       MLX4_DEV_CAP_FLAG2_FSM                  = 1LL <<  4,
-       MLX4_DEV_CAP_FLAG2_VLAN_CONTROL         = 1LL <<  5,
-       MLX4_DEV_CAP_FLAG2_UPDATE_QP            = 1LL <<  6,
-       MLX4_DEV_CAP_FLAG2_LB_SRC_CHK           = 1LL <<  7,
-       MLX4_DEV_CAP_FLAG2_DMFS_IPOIB           = 1LL <<  8,
-       MLX4_DEV_CAP_FLAG2_ETS_CFG              = 1LL <<  9,
-       MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP    = 1LL <<  10,
-       MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN         = 1LL <<  11,
-       MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 12,
-       MLX4_DEV_CAP_FLAG2_TS                   = 1LL <<  13,
-       MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW    = 1LL <<  14,
-       MLX4_DEV_CAP_FLAG2_REASSIGN_MAC_EN      = 1LL <<  15,
-       MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS       = 1LL <<  16,
-       MLX4_DEV_CAP_FLAG2_FS_EN_NCSI           = 1LL <<  17,
+       MLX4_DEV_CAP_FLAG2_REASSIGN_MAC_EN      = 1LL <<  4,
+       MLX4_DEV_CAP_FLAG2_TS                   = 1LL <<  5,
+       MLX4_DEV_CAP_FLAG2_VLAN_CONTROL         = 1LL <<  6,
+       MLX4_DEV_CAP_FLAG2_FSM                  = 1LL <<  7,
+       MLX4_DEV_CAP_FLAG2_UPDATE_QP            = 1LL <<  8,
+       MLX4_DEV_CAP_FLAG2_DMFS_IPOIB           = 1LL <<  9,
+       MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS       = 1LL <<  10,
+       MLX4_DEV_CAP_FLAG2_MAD_DEMUX            = 1LL <<  11,
+       MLX4_DEV_CAP_FLAG2_CQE_STRIDE           = 1LL <<  12,
+       MLX4_DEV_CAP_FLAG2_EQE_STRIDE           = 1LL <<  13,
+       MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL        = 1LL <<  14,
+       MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP    = 1LL <<  15,
+       MLX4_DEV_CAP_FLAG2_CONFIG_DEV           = 1LL <<  16,
+       MLX4_DEV_CAP_FLAG2_SYS_EQS              = 1LL <<  17,
        MLX4_DEV_CAP_FLAG2_80_VFS               = 1LL <<  18,
-       MLX4_DEV_CAP_FLAG2_DMFS_TAG_MODE        = 1LL <<  19,
-       MLX4_DEV_CAP_FLAG2_ROCEV2               = 1LL <<  20,
-       MLX4_DEV_CAP_FLAG2_ETH_PROT_CTRL        = 1LL <<  21,
-       MLX4_DEV_CAP_FLAG2_CQE_STRIDE           = 1LL <<  22,
-       MLX4_DEV_CAP_FLAG2_EQE_STRIDE           = 1LL <<  23,
-       MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB = 1LL << 24,
-       MLX4_DEV_CAP_FLAG2_RX_CSUM_MODE         = 1LL <<  25,
-       MLX4_DEV_CAP_FLAG2_SYS_EQS              = 1LL <<  26,
+       MLX4_DEV_CAP_FLAG2_FS_A0                = 1LL <<  19,
+       MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 20,
+       MLX4_DEV_CAP_FLAG2_PORT_REMAP           = 1LL <<  21,
+       MLX4_DEV_CAP_FLAG2_QCN                  = 1LL <<  22,
+       MLX4_DEV_CAP_FLAG2_QP_RATE_LIMIT        = 1LL <<  23,
+       MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN         = 1LL <<  24,
+       MLX4_DEV_CAP_FLAG2_QOS_VPP              = 1LL <<  25,
+       MLX4_DEV_CAP_FLAG2_ETS_CFG              = 1LL <<  26,
+       MLX4_DEV_CAP_FLAG2_PORT_BEACON          = 1LL <<  27,
+       MLX4_DEV_CAP_FLAG2_IGNORE_FCS           = 1LL <<  28,
+       MLX4_DEV_CAP_FLAG2_PHV_EN               = 1LL <<  29,
+       MLX4_DEV_CAP_FLAG2_SKIP_OUTER_VLAN      = 1LL <<  30,
+       MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB = 1ULL << 31,
+       MLX4_DEV_CAP_FLAG2_LB_SRC_CHK           = 1ULL << 32,
+       MLX4_DEV_CAP_FLAG2_ROCE_V1_V2           = 1ULL <<  33,
+       MLX4_DEV_CAP_FLAG2_DMFS_UC_MC_SNIFFER   = 1ULL <<  34,
+       MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT        = 1ULL <<  35,
+       MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP          = 1ULL <<  36,
+       MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT = 1ULL << 37,
 };
 
-/* bit enums for an 8-bit flags field indicating special use
- * QPs which require special handling in qp_reserve_range.
- * Currently, this only includes QPs used by the ETH interface,
- * where we expect to use blueflame.  These QPs must not have
- * bits 6 and 7 set in their qp number.
- *
- * This enum may use only bits 0..7.
- */
 enum {
-       MLX4_RESERVE_BF_QP      = 1 << 7,
+       MLX4_QUERY_FUNC_FLAGS_BF_RES_QP         = 1LL << 0,
+       MLX4_QUERY_FUNC_FLAGS_A0_RES_QP         = 1LL << 1
 };
 
 enum {
-       MLX4_DEV_CAP_CQ_FLAG_IO                 = 1 <<  0
+       MLX4_VF_CAP_FLAG_RESET                  = 1 << 0
 };
 
-enum {
-       MLX4_QUERY_FUNC_FLAGS_BF_RES_QP = 1LL << 0
-};
-
 /* bit enums for an 8-bit flags field indicating special use
  * QPs which require special handling in qp_reserve_range.
  * Currently, this only includes QPs used by the ETH interface,
@@ -231,35 +248,47 @@ enum {
  * This enum may use only bits 0..7.
  */
 enum {
-       MLX4_RESERVE_ETH_BF_QP          = 1 << 7,
+       MLX4_RESERVE_A0_QP      = 1 << 6,
+       MLX4_RESERVE_ETH_BF_QP  = 1 << 7,
 };
 
-
 enum {
        MLX4_DEV_CAP_64B_EQE_ENABLED    = 1LL << 0,
-       MLX4_DEV_CAP_64B_CQE_ENABLED    = 1LL << 1
+       MLX4_DEV_CAP_64B_CQE_ENABLED    = 1LL << 1,
+       MLX4_DEV_CAP_CQE_STRIDE_ENABLED = 1LL << 2,
+       MLX4_DEV_CAP_EQE_STRIDE_ENABLED = 1LL << 3
 };
 
 enum {
-       MLX4_USER_DEV_CAP_64B_CQE       = 1L << 0
+       MLX4_USER_DEV_CAP_LARGE_CQE     = 1L << 0
 };
 
 enum {
-       MLX4_FUNC_CAP_64B_EQE_CQE       = 1L << 0
+       MLX4_FUNC_CAP_64B_EQE_CQE       = 1L << 0,
+       MLX4_FUNC_CAP_EQE_CQE_STRIDE    = 1L << 1,
+       MLX4_FUNC_CAP_DMFS_A0_STATIC    = 1L << 2
 };
 
 
 #define MLX4_ATTR_EXTENDED_PORT_INFO   cpu_to_be16(0xff90)
 
 enum {
-       MLX4_BMME_FLAG_WIN_TYPE_2B      = 1 << 1,
+       MLX4_BMME_FLAG_WIN_TYPE_2B      = 1 <<  1,
        MLX4_BMME_FLAG_LOCAL_INV        = 1 <<  6,
        MLX4_BMME_FLAG_REMOTE_INV       = 1 <<  7,
        MLX4_BMME_FLAG_TYPE_2_WIN       = 1 <<  9,
        MLX4_BMME_FLAG_RESERVED_LKEY    = 1 << 10,
        MLX4_BMME_FLAG_FAST_REG_WR      = 1 << 11,
+       MLX4_BMME_FLAG_ROCE_V1_V2       = 1 << 19,
+       MLX4_BMME_FLAG_PORT_REMAP       = 1 << 24,
+       MLX4_BMME_FLAG_VSD_INIT2RTR     = 1 << 28,
 };
 
+enum {
+       MLX4_FLAG_PORT_REMAP            = MLX4_BMME_FLAG_PORT_REMAP,
+       MLX4_FLAG_ROCE_V1_V2            = MLX4_BMME_FLAG_ROCE_V1_V2
+};
+
 enum mlx4_event {
        MLX4_EVENT_TYPE_COMP               = 0x00,
        MLX4_EVENT_TYPE_PATH_MIG           = 0x01,
@@ -329,6 +358,7 @@ enum {
        MLX4_PERM_REMOTE_WRITE  = 1 << 13,
        MLX4_PERM_ATOMIC        = 1 << 14,
        MLX4_PERM_BIND_MW       = 1 << 15,
+       MLX4_PERM_MASK          = 0xFC00
 };
 
 enum {
@@ -373,12 +403,10 @@ enum {
        MLX4_MTT_FLAG_PRESENT           = 1
 };
 
-enum {
-       MLX4_MAX_MTT_SHIFT              = 31
-};
-
 enum mlx4_qp_region {
        MLX4_QP_REGION_FW = 0,
+       MLX4_QP_REGION_RSS_RAW_ETH,
+       MLX4_QP_REGION_BOTTOM = MLX4_QP_REGION_RSS_RAW_ETH,
        MLX4_QP_REGION_ETH_ADDR,
        MLX4_QP_REGION_FC_ADDR,
        MLX4_QP_REGION_FC_EXCH,
@@ -389,8 +417,7 @@ enum mlx4_port_type {
        MLX4_PORT_TYPE_NONE     = 0,
        MLX4_PORT_TYPE_IB       = 1,
        MLX4_PORT_TYPE_ETH      = 2,
-       MLX4_PORT_TYPE_AUTO     = 3,
-       MLX4_PORT_TYPE_NA       = 4
+       MLX4_PORT_TYPE_AUTO     = 3
 };
 
 enum mlx4_special_vlan_idx {
@@ -414,9 +441,21 @@ enum {
 };
 
 enum {
+       /*
+        * Max wqe size for rdma read is 512 bytes, so this
+        * limits our max_sge_rd as the wqe needs to fit:
+        * - ctrl segment (16 bytes)
+        * - rdma segment (16 bytes)
+        * - scatter elements (16 bytes each)
+        */
+       MLX4_MAX_SGE_RD = (512 - 16 - 16) / 16
+};
+
+enum {
        MLX4_DEV_PMC_SUBTYPE_GUID_INFO   = 0x14,
        MLX4_DEV_PMC_SUBTYPE_PORT_INFO   = 0x15,
        MLX4_DEV_PMC_SUBTYPE_PKEY_TABLE  = 0x16,
+       MLX4_DEV_PMC_SUBTYPE_SL_TO_VL_MAP = 0x17,
 };
 
 /* Port mgmt change event handling */
@@ -428,16 +467,46 @@ enum {
        MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK        = 1 << 4,
 };
 
+union sl2vl_tbl_to_u64 {
+       u8      sl8[8];
+       u64     sl64;
+};
+
+enum {
+       MLX4_DEVICE_STATE_UP                    = 1 << 0,
+       MLX4_DEVICE_STATE_INTERNAL_ERROR        = 1 << 1,
+};
+
+enum {
+       MLX4_INTERFACE_STATE_UP         = 1 << 0,
+       MLX4_INTERFACE_STATE_DELETION   = 1 << 1,
+};
+
 #define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
                             MLX4_EQ_PORT_INFO_MSTR_SM_LID_CHANGE_MASK)
 
 enum mlx4_module_id {
-       MLX4_MODULE_ID_SFP              = 0x3,
-       MLX4_MODULE_ID_QSFP             = 0xC,
-       MLX4_MODULE_ID_QSFP_PLUS        = 0xD,
-       MLX4_MODULE_ID_QSFP28           = 0x11,
+       MLX4_MODULE_ID_SFP              = 0x3,
+       MLX4_MODULE_ID_QSFP             = 0xC,
+       MLX4_MODULE_ID_QSFP_PLUS        = 0xD,
+       MLX4_MODULE_ID_QSFP28           = 0x11,
 };
 
+enum { /* rl */
+       MLX4_QP_RATE_LIMIT_NONE         = 0,
+       MLX4_QP_RATE_LIMIT_KBS          = 1,
+       MLX4_QP_RATE_LIMIT_MBS          = 2,
+       MLX4_QP_RATE_LIMIT_GBS          = 3
+};
+
+struct mlx4_rate_limit_caps {
+       u16     num_rates; /* Number of different rates */
+       u8      min_unit;
+       u16     min_val;
+       u8      max_unit;
+       u16     max_val;
+};
+
 static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
 {
        return (major << 32) | (minor << 16) | subminor;
@@ -480,6 +549,8 @@ struct mlx4_caps {
        int                     max_rq_desc_sz;
        int                     max_qp_init_rdma;
        int                     max_qp_dest_rdma;
+       int                     max_tc_eth;
+       u32                     *qp0_qkey;
        u32                     *qp0_proxy;
        u32                     *qp1_proxy;
        u32                     *qp0_tunnel;
@@ -495,10 +566,9 @@ struct mlx4_caps {
        int                     num_eqs;
        int                     reserved_eqs;
        int                     num_comp_vectors;
-       int                     comp_pool;
        int                     num_mpts;
        int                     max_fmr_maps;
-       u64                     num_mtts;
+       int                     num_mtts;
        int                     fmr_reserved_mtts;
        int                     reserved_mtts;
        int                     reserved_mrws;
@@ -508,6 +578,8 @@ struct mlx4_caps {
        int                     reserved_mcgs;
        int                     num_qp_per_mgm;
        int                     steering_mode;
+       int                     dmfs_high_steer_mode;
+       int                     fs_log_max_ucast_qp_range_size;
        int                     num_pds;
        int                     reserved_pds;
        int                     max_xrcds;
@@ -520,7 +592,6 @@ struct mlx4_caps {
        u32                     bmme_flags;
        u32                     reserved_lkey;
        u16                     stat_rate_support;
-       u8                      cq_timestamp;
        u8                      port_width_cap[MLX4_MAX_PORTS + 1];
        int                     max_gso_sz;
        int                     max_rss_tbl_sz;
@@ -538,19 +609,21 @@ struct mlx4_caps {
        u32                     max_counters;
        u8                      port_ib_mtu[MLX4_MAX_PORTS + 1];
        u16                     sqp_demux;
-       u32                     sync_qp;
-       u32                     cq_flags;
        u32                     eqe_size;
        u32                     cqe_size;
        u8                      eqe_factor;
-       u32                     userspace_caps; /* userspace must be aware to */
-       u32                     function_caps;  /* functions must be aware to */
-       u8                      fast_drop;
+       u32                     userspace_caps; /* userspace must be aware of 
these */
+       u32                     function_caps;  /* VFs must be aware of these */
        u16                     hca_core_clock;
-       u32                     max_basic_counters;
-       u32                     max_extended_counters;
-       u8                      def_counter_index[MLX4_MAX_PORTS + 1];
+       u64                     phys_port_id[MLX4_MAX_PORTS + 1];
+       int                     tunnel_offload_mode;
+       u8                      rx_checksum_flags_port[MLX4_MAX_PORTS + 1];
+       u8                      phv_bit[MLX4_MAX_PORTS + 1];
        u8                      alloc_res_qp_mask;
+       u32                     dmfs_high_rate_qpn_base;
+       u32                     dmfs_high_rate_qpn_range;
+       u32                     vf_caps;
+       struct mlx4_rate_limit_caps rl_caps;
 };
 
 struct mlx4_buf_list {
@@ -647,7 +720,7 @@ struct mlx4_uar {
 };
 
 struct mlx4_bf {
-       unsigned long           offset;
+       unsigned int            offset;
        int                     buf_size;
        struct mlx4_uar        *uar;
        void __iomem           *reg;
@@ -661,6 +734,7 @@ struct mlx4_cq {
 
        u32                     cons_index;
 
+       u16                     irq;
        __be32                 *set_ci_db;
        __be32                 *arm_db;
        int                     arm_sn;
@@ -670,8 +744,8 @@ struct mlx4_cq {
 
        atomic_t                refcount;
        struct completion       free;
-       int                     eqn;
-       u16                     irq;
+       int             reset_notify_added;
+       struct list_head        reset_notify;
 };
 
 struct mlx4_qp {
@@ -720,9 +794,9 @@ struct mlx4_eth_av {
        __be32          sl_tclass_flowlabel;
        u8              dgid[16];
        u8              s_mac[6];
-       u8      reserved4[2];
+       u8              reserved4[2];
        __be16          vlan;
-       u8              mac[6];
+       u8              mac[ETH_ALEN];
 };
 
 union mlx4_ext_av {
@@ -730,66 +804,17 @@ union mlx4_ext_av {
        struct mlx4_eth_av      eth;
 };
 
-struct mlx4_if_stat_control {
-       u8 reserved1[3];
-       /* Extended counters enabled */
-       u8 cnt_mode;
-       /* Number of interfaces */
-       __be32 num_of_if;
-       __be32 reserved[2];
+struct mlx4_counter {
+       u8      reserved1[3];
+       u8      counter_mode;
+       __be32  num_ifc;
+       u32     reserved2[2];
+       __be64  rx_frames;
+       __be64  rx_bytes;
+       __be64  tx_frames;
+       __be64  tx_bytes;
 };
 
-struct mlx4_if_stat_basic {
-       struct mlx4_if_stat_control control;
-       struct {
-               __be64 IfRxFrames;
-               __be64 IfRxOctets;
-               __be64 IfTxFrames;
-               __be64 IfTxOctets;
-       } counters[];
-};
-#define MLX4_IF_STAT_BSC_SZ(ports)(sizeof(struct mlx4_if_stat_extended) +\
-                                  sizeof(((struct mlx4_if_stat_extended *)0)->\
-                                  counters[0]) * ports)
-
-struct mlx4_if_stat_extended {
-       struct mlx4_if_stat_control control;
-       struct {
-               __be64 IfRxUnicastFrames;
-               __be64 IfRxUnicastOctets;
-               __be64 IfRxMulticastFrames;
-               __be64 IfRxMulticastOctets;
-               __be64 IfRxBroadcastFrames;
-               __be64 IfRxBroadcastOctets;
-               __be64 IfRxNoBufferFrames;
-               __be64 IfRxNoBufferOctets;
-               __be64 IfRxErrorFrames;
-               __be64 IfRxErrorOctets;
-               __be32 reserved[39];
-               __be64 IfTxUnicastFrames;
-               __be64 IfTxUnicastOctets;
-               __be64 IfTxMulticastFrames;
-               __be64 IfTxMulticastOctets;
-               __be64 IfTxBroadcastFrames;
-               __be64 IfTxBroadcastOctets;
-               __be64 IfTxDroppedFrames;
-               __be64 IfTxDroppedOctets;
-               __be64 IfTxRequestedFramesSent;
-               __be64 IfTxGeneratedFramesSent;
-               __be64 IfTxTsoOctets;
-       } __packed counters[];
-};
-#define MLX4_IF_STAT_EXT_SZ(ports)   (sizeof(struct mlx4_if_stat_extended) +\
-                                     sizeof(((struct mlx4_if_stat_extended *)\
-                                     0)->counters[0]) * ports)
-
-union mlx4_counter {
-       struct mlx4_if_stat_control     control;
-       struct mlx4_if_stat_basic       basic;
-       struct mlx4_if_stat_extended    ext;
-};
-#define MLX4_IF_STAT_SZ(ports)         MLX4_IF_STAT_EXT_SZ(ports)
-
 struct mlx4_quotas {
        int qp;
        int cq;
@@ -800,8 +825,35 @@ struct mlx4_quotas {
        int xrcd;
 };
 
-struct mlx4_dev {
+struct mlx4_vf_dev {
+       u8                      min_port;
+       u8                      n_ports;
+};
+
+enum mlx4_pci_status {
+       MLX4_PCI_STATUS_DISABLED,
+       MLX4_PCI_STATUS_ENABLED,
+};
+
+struct mlx4_dev_persistent {
        struct pci_dev         *pdev;
+       struct mlx4_dev        *dev;
+       int                     nvfs[MLX4_MAX_PORTS + 1];
+       int                     num_vfs;
+       enum mlx4_port_type curr_port_type[MLX4_MAX_PORTS + 1];
+       enum mlx4_port_type curr_port_poss_type[MLX4_MAX_PORTS + 1];
+       struct work_struct      catas_work;
+       struct workqueue_struct *catas_wq;
+       struct mutex    device_state_mutex; /* protect HW state */
+       u8              state;
+       struct mutex    interface_state_mutex; /* protect SW state */
+       u8      interface_state;
+       struct mutex            pci_status_mutex; /* sync pci state */
+       enum mlx4_pci_status    pci_status;
+};
+
+struct mlx4_dev {
+       struct mlx4_dev_persistent *persist;
        unsigned long           flags;
        unsigned long           num_slaves;
        struct mlx4_caps        caps;
@@ -809,14 +861,14 @@ struct mlx4_dev {
        struct mlx4_quotas      quotas;
        struct radix_tree_root  qp_table_tree;
        u8                      rev_id;
+       u8                      port_random_macs;
        char                    board_id[MLX4_BOARD_ID_LEN];
-       u16                     vsd_vendor_id;
-       char                    vsd[MLX4_VSD_LEN];
-       int                     num_vfs;
        int                     numa_node;
        int                     oper_log_mgm_entry_size;
        u64                     regid_promisc_array[MLX4_MAX_PORTS + 1];
        u64                     regid_allmulti_array[MLX4_MAX_PORTS + 1];
+       struct mlx4_vf_dev     *dev_vfs;
+       u8  uar_page_shift;
 };
 
 struct mlx4_clock_params {
@@ -892,6 +944,9 @@ struct mlx4_eqe {
                                        __be32 block_ptr;
                                        __be32 tbl_entries_mask;
                                } __packed tbl_change_info;
+                               struct {
+                                       u8 sl2vl_table[8];
+                               } __packed sl2vl_tbl_change_info;
                        } params;
                } __packed port_mgmt_change;
                struct {
@@ -922,40 +977,36 @@ struct mlx4_init_port_param {
 #define MAD_IFC_DATA_SZ 192
 /* MAD IFC Mailbox */
 struct mlx4_mad_ifc {
-       u8      base_version;
-       u8      mgmt_class;
-       u8      class_version;
-       u8      method;
-       __be16  status;
-       __be16  class_specific;
-       __be64  tid;
-       __be16  attr_id;
-       __be16  resv;
-       __be32  attr_mod;
-       __be64  mkey;
-       __be16  dr_slid;
-       __be16  dr_dlid;
-       u8      reserved[28];
-       u8      data[MAD_IFC_DATA_SZ];
+       u8      base_version;
+       u8      mgmt_class;
+       u8      class_version;
+       u8      method;
+       __be16  status;
+       __be16  class_specific;
+       __be64  tid;
+       __be16  attr_id;
+       __be16  resv;
+       __be32  attr_mod;
+       __be64  mkey;
+       __be16  dr_slid;
+       __be16  dr_dlid;
+       u8      reserved[28];
+       u8      data[MAD_IFC_DATA_SZ];
 } __packed;
 
 #define mlx4_foreach_port(port, dev, type)                             \
        for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++)     \
                if ((type) == (dev)->caps.port_mask[(port)])
 
-#define mlx4_foreach_non_ib_transport_port(port, dev)                     \
-       for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++)       \
-               if (((dev)->caps.port_mask[port] != MLX4_PORT_TYPE_IB))
-
 #define mlx4_foreach_ib_transport_port(port, dev)                         \
-       for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++)       \
+       for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++)       \
                if (((dev)->caps.port_mask[port] == MLX4_PORT_TYPE_IB) || \
-                       ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
+                       ((dev)->caps.flags & MLX4_DEV_CAP_FLAG_IBOE) || \
+                       ((dev)->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2))
 
 #define MLX4_INVALID_SLAVE_ID  0xFF
+#define MLX4_SINK_COUNTER_INDEX(dev)   (dev->caps.max_counters - 1)
 
-#define MLX4_SINK_COUNTER_INDEX 0xff
-
 void handle_port_mgmt_change_event(struct work_struct *work);
 
 static inline int mlx4_master_func_num(struct mlx4_dev *dev)
@@ -977,7 +1028,9 @@ static inline int mlx4_num_reserved_sqps(struct mlx4_d
 static inline int mlx4_is_qp_reserved(struct mlx4_dev *dev, u32 qpn)
 {
        return (qpn < dev->phys_caps.base_sqpn + 8 +
-               16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev));
+               16 * MLX4_MFUNC_MAX * !!mlx4_is_master(dev) &&
+               qpn >= dev->phys_caps.base_sqpn) ||
+              (qpn < dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW]);
 }
 
 static inline int mlx4_is_guest_proxy(struct mlx4_dev *dev, int slave, u32 qpn)
@@ -1000,8 +1053,13 @@ static inline int mlx4_is_slave(struct mlx4_dev *dev)
        return dev->flags & MLX4_FLAG_SLAVE;
 }
 
+static inline int mlx4_is_eth(struct mlx4_dev *dev, int port)
+{
+       return dev->caps.port_type[port] == MLX4_PORT_TYPE_IB ? 0 : 1;
+}
+
 int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
-                  struct mlx4_buf *buf);
+                  struct mlx4_buf *buf, gfp_t gfp);
 void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf);
 static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset)
 {
@@ -1038,9 +1096,10 @@ int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_m
 int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
                   int start_index, int npages, u64 *page_list);
 int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
-                      struct mlx4_buf *buf);
+                      struct mlx4_buf *buf, gfp_t gfp);
 
-int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order);
+int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order,
+                 gfp_t gfp);
 void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db);
 
 int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres,
@@ -1052,12 +1111,12 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, stru
                  struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq,
                  unsigned vector, int collapsed, int timestamp_en);
 void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq);
-
 int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
                          int *base, u8 flags);
 void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
 
-int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp);
+int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp,

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to