Added mlx4_en backport for RHEL7.6
authorVladimir Sokolovsky <vlad@mellanox.com>
Wed, 28 Aug 2019 21:23:36 +0000 (16:23 -0500)
committerVladimir Sokolovsky <vlad@mellanox.com>
Wed, 28 Aug 2019 21:23:36 +0000 (16:23 -0500)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
patches/0004-BACKPORT-mlx4.patch

index 0ebde22..c96ad75 100644 (file)
@@ -3,21 +3,38 @@ Subject: [PATCH] BACKPORT: mlx4
 
 Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
 ---
- drivers/net/ethernet/mellanox/mlx4/catas.c    |  17 +
+ drivers/net/ethernet/mellanox/mlx4/catas.c    |  21 +
+ drivers/net/ethernet/mellanox/mlx4/crdump.c   |  16 +
  .../net/ethernet/mellanox/mlx4/en_dcb_nl.c    |  29 ++
  .../net/ethernet/mellanox/mlx4/en_ethtool.c   |   8 +
- .../net/ethernet/mellanox/mlx4/en_netdev.c    | 424 +++++++++++++++++-
- drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  70 ++-
+ .../net/ethernet/mellanox/mlx4/en_netdev.c    | 425 +++++++++++++++++-
+ drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  74 ++-
  .../net/ethernet/mellanox/mlx4/en_selftest.c  |   4 +-
- drivers/net/ethernet/mellanox/mlx4/main.c     |   2 +
- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h  |  12 +
- 8 files changed, 558 insertions(+), 8 deletions(-)
+ drivers/net/ethernet/mellanox/mlx4/en_tx.c    |  40 ++
+ drivers/net/ethernet/mellanox/mlx4/eq.c       |   4 +
+ drivers/net/ethernet/mellanox/mlx4/icm.c      |   2 +
+ drivers/net/ethernet/mellanox/mlx4/main.c     |  35 ++
+ drivers/net/ethernet/mellanox/mlx4/mlx4.h     |   4 +
+ drivers/net/ethernet/mellanox/mlx4/mlx4_en.h  |  29 ++
+ 13 files changed, 683 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/net/ethernet/mellanox/mlx4/catas.c b/drivers/net/ethernet/mellanox/mlx4/catas.c
 index xxxxxxx..xxxxxxx 100644
 --- a/drivers/net/ethernet/mellanox/mlx4/catas.c
 +++ b/drivers/net/ethernet/mellanox/mlx4/catas.c
-@@ -229,10 +229,19 @@ static void dump_err_buf(struct mlx4_dev *dev)
+@@ -210,7 +210,11 @@ static void mlx4_handle_error_state(struct mlx4_dev_persistent *persist)
+       mutex_lock(&persist->interface_state_mutex);
+       if (persist->interface_state & MLX4_INTERFACE_STATE_UP &&
+           !(persist->interface_state & MLX4_INTERFACE_STATE_DELETION)) {
++#ifdef HAVE_DEVLINK_DRIVERINIT_VAL
+               err = mlx4_restart_one(persist->pdev, false, NULL);
++#else
++              err = mlx4_restart_one(persist->pdev);
++#endif
+               mlx4_info(persist->dev, "mlx4_restart_one was ended, ret=%d\n",
+                         err);
+       }
+@@ -229,10 +233,19 @@ static void dump_err_buf(struct mlx4_dev *dev)
                         i, swab32(readl(priv->catas_err.map + i)));
  }
  
@@ -37,7 +54,7 @@ index xxxxxxx..xxxxxxx 100644
        u32 slave_read;
  
        if (mlx4_is_slave(dev)) {
-@@ -275,7 +284,11 @@ void mlx4_start_catas_poll(struct mlx4_dev *dev)
+@@ -275,7 +288,11 @@ void mlx4_start_catas_poll(struct mlx4_dev *dev)
        phys_addr_t addr;
  
        INIT_LIST_HEAD(&priv->catas_err.list);
@@ -49,7 +66,7 @@ index xxxxxxx..xxxxxxx 100644
        priv->catas_err.map = NULL;
  
        if (!mlx4_is_slave(dev)) {
-@@ -291,6 +304,10 @@ void mlx4_start_catas_poll(struct mlx4_dev *dev)
+@@ -291,6 +308,10 @@ void mlx4_start_catas_poll(struct mlx4_dev *dev)
                }
        }
  
@@ -60,6 +77,97 @@ index xxxxxxx..xxxxxxx 100644
        priv->catas_err.timer.expires  =
                round_jiffies(jiffies + MLX4_CATAS_POLL_INTERVAL);
        add_timer(&priv->catas_err.timer);
+diff --git a/drivers/net/ethernet/mellanox/mlx4/crdump.c b/drivers/net/ethernet/mellanox/mlx4/crdump.c
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlx4/crdump.c
++++ b/drivers/net/ethernet/mellanox/mlx4/crdump.c
+@@ -38,8 +38,10 @@
+ #define CR_ENABLE_BIT_OFFSET          0xF3F04
+ #define MAX_NUM_OF_DUMPS_TO_STORE     (8)
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+ static const char *region_cr_space_str = "cr-space";
+ static const char *region_fw_health_str = "fw-health";
++#endif
+ /* Set to true in case cr enable bit was set to true before crdump */
+ static bool crdump_enbale_bit_set;
+@@ -74,6 +76,7 @@ static void crdump_disable_crspace_access(struct mlx4_dev *dev,
+                      cr_space + CR_ENABLE_BIT_OFFSET);
+ }
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+ static void mlx4_crdump_collect_crspace(struct mlx4_dev *dev,
+                                       u8 __iomem *cr_space,
+                                       u32 id)
+@@ -154,15 +157,20 @@ static void mlx4_crdump_collect_fw_health(struct mlx4_dev *dev,
+               mlx4_err(dev, "crdump: Failed to allocate health buffer\n");
+       }
+ }
++#endif
+ int mlx4_crdump_collect(struct mlx4_dev *dev)
+ {
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       struct devlink *devlink = priv_to_devlink(mlx4_priv(dev));
++#endif
+       struct mlx4_fw_crdump *crdump = &dev->persist->crdump;
+       struct pci_dev *pdev = dev->persist->pdev;
+       unsigned long cr_res_size;
+       u8 __iomem *cr_space;
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       u32 id;
++#endif
+       if (!dev->caps.health_buffer_addrs) {
+               mlx4_info(dev, "crdump: FW doesn't support health buffer access, skipping\n");
+@@ -184,12 +192,14 @@ int mlx4_crdump_collect(struct mlx4_dev *dev)
+       crdump_enable_crspace_access(dev, cr_space);
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       /* Get the available snapshot ID for the dumps */
+       id = devlink_region_shapshot_id_get(devlink);
+       /* Try to capture dumps */
+       mlx4_crdump_collect_crspace(dev, cr_space, id);
+       mlx4_crdump_collect_fw_health(dev, cr_space, id);
++#endif
+       crdump_disable_crspace_access(dev, cr_space);
+@@ -199,10 +209,13 @@ int mlx4_crdump_collect(struct mlx4_dev *dev)
+ int mlx4_crdump_init(struct mlx4_dev *dev)
+ {
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       struct devlink *devlink = priv_to_devlink(mlx4_priv(dev));
+       struct mlx4_fw_crdump *crdump = &dev->persist->crdump;
+       struct pci_dev *pdev = dev->persist->pdev;
++#endif
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       crdump->snapshot_enable = false;
+       /* Create cr-space region */
+@@ -226,14 +239,17 @@ int mlx4_crdump_init(struct mlx4_dev *dev)
+               mlx4_warn(dev, "crdump: create devlink region %s err %ld\n",
+                         region_fw_health_str,
+                         PTR_ERR(crdump->region_fw_health));
++#endif
+       return 0;
+ }
+ void mlx4_crdump_end(struct mlx4_dev *dev)
+ {
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       struct mlx4_fw_crdump *crdump = &dev->persist->crdump;
+       devlink_region_destroy(crdump->region_fw_health);
+       devlink_region_destroy(crdump->region_crspace);
++#endif
+ }
 diff --git a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c b/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
 index xxxxxxx..xxxxxxx 100644
 --- a/drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c
@@ -727,7 +835,7 @@ index xxxxxxx..xxxxxxx 100644
 +{
 +      struct mlx4_en_priv *priv = netdev_priv(dev);
 +      __be16 current_port;
-+
 +      if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
 +              return;
 +
@@ -767,7 +875,7 @@ index xxxxxxx..xxxxxxx 100644
 +}
 +#endif
 +#endif /* HAVE_KERNEL_WITH_VXLAN_SUPPORT_ON */
++
 +#ifdef HAVE_NETDEV_FEATURES_T
  static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
                                                struct net_device *dev,
@@ -1057,7 +1165,7 @@ index xxxxxxx..xxxxxxx 100644
  
        if (mlx4_is_slave(mdev->dev)) {
                bool vlan_offload_disabled;
-@@ -3458,44 +3809,91 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
+@@ -3458,44 +3809,92 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
                        dev->hw_features |= NETIF_F_HW_VLAN_STAG_TX;
        }
  
@@ -1125,6 +1233,7 @@ index xxxxxxx..xxxxxxx 100644
                                    NETIF_F_GSO_PARTIAL;
 +#else
 +                                  0;
++#endif
 +#endif
                dev->features    |= NETIF_F_GSO_UDP_TUNNEL |
 +#ifdef NETIF_F_GSO_UDP_TUNNEL_CSUM
@@ -1143,13 +1252,13 @@ index xxxxxxx..xxxxxxx 100644
        dev->min_mtu = ETH_MIN_MTU;
        dev->max_mtu = priv->max_mtu;
 +#elif defined(HAVE_NET_DEVICE_MIN_MAX_MTU_EXTENDED)
-+      dev->extended->min_mtu = MLX4_EN_MIN_MTU;
++      dev->extended->min_mtu = ETH_MIN_MTU;
 +      dev->extended->max_mtu = priv->max_mtu;
 +#endif
  
        mdev->pndev[port] = dev;
        mdev->upper[port] = NULL;
-@@ -3581,8 +3979,12 @@ int mlx4_en_reset_config(struct net_device *dev,
+@@ -3581,8 +3980,12 @@ int mlx4_en_reset_config(struct net_device *dev,
  
        if (priv->hwtstamp_config.tx_type == ts_config.tx_type &&
            priv->hwtstamp_config.rx_filter == ts_config.rx_filter &&
@@ -1162,7 +1271,7 @@ index xxxxxxx..xxxxxxx 100644
                return 0; /* Nothing to change */
  
        if (DEV_FEATURE_CHANGED(dev, features, NETIF_F_HW_VLAN_CTAG_RX) &&
-@@ -3601,7 +4003,11 @@ int mlx4_en_reset_config(struct net_device *dev,
+@@ -3601,7 +4004,11 @@ int mlx4_en_reset_config(struct net_device *dev,
        memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile));
        memcpy(&new_prof.hwtstamp_config, &ts_config, sizeof(ts_config));
  
@@ -1174,7 +1283,7 @@ index xxxxxxx..xxxxxxx 100644
        if (err)
                goto out;
  
-@@ -3621,18 +4027,26 @@ int mlx4_en_reset_config(struct net_device *dev,
+@@ -3621,18 +4028,26 @@ int mlx4_en_reset_config(struct net_device *dev,
                /* RX time-stamping is OFF, update the RX vlan offload
                 * to the latest wanted state
                 */
@@ -1385,7 +1494,19 @@ index xxxxxxx..xxxxxxx 100644
  
                ring->bytes += length;
                ring->packets++;
-@@ -901,13 +946,17 @@ next:
+@@ -890,7 +935,11 @@ csum_none:
+                       skb->data_len = length;
+                       napi_gro_frags(&cq->napi);
+               } else {
++#ifdef HAVE__VLAN_HWACCEL_CLEAR_TAG
+                       __vlan_hwaccel_clear_tag(skb);
++#else
++                      skb->vlan_tci = 0;
++#endif
+                       skb_clear_hash(skb);
+               }
+ next:
+@@ -901,13 +950,17 @@ next:
                        break;
        }
  
@@ -1403,7 +1524,7 @@ index xxxxxxx..xxxxxxx 100644
  
                mlx4_cq_set_ci(&cq->mcq);
                wmb(); /* ensure HW sees CQ consumer before we post new buffers */
-@@ -956,7 +1005,9 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
+@@ -956,7 +1009,9 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
        /* If we used up all the quota - we're probably not done yet... */
        if (done == budget || !clean_complete) {
                const struct cpumask *aff;
@@ -1413,7 +1534,7 @@ index xxxxxxx..xxxxxxx 100644
                int cpu_curr;
  
                /* in case we got here because of !clean_complete */
-@@ -965,8 +1016,12 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
+@@ -965,8 +1020,12 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
                INC_PERF_COUNTER(priv->pstats.napi_quota);
  
                cpu_curr = smp_processor_id();
@@ -1426,7 +1547,7 @@ index xxxxxxx..xxxxxxx 100644
  
                if (likely(cpumask_test_cpu(cpu_curr, aff)))
                        return budget;
-@@ -981,8 +1036,18 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
+@@ -981,8 +1040,18 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget)
                        done--;
        }
        /* Done for now */
@@ -1445,7 +1566,7 @@ index xxxxxxx..xxxxxxx 100644
        return done;
  }
  
-@@ -992,6 +1057,7 @@ void mlx4_en_calc_rx_buf(struct net_device *dev)
+@@ -992,6 +1061,7 @@ void mlx4_en_calc_rx_buf(struct net_device *dev)
        int eff_mtu = MLX4_EN_EFF_MTU(dev->mtu);
        int i = 0;
  
@@ -1453,7 +1574,7 @@ index xxxxxxx..xxxxxxx 100644
        /* bpf requires buffers to be set up as 1 packet per page.
         * This only works when num_frags == 1.
         */
-@@ -1004,7 +1070,9 @@ void mlx4_en_calc_rx_buf(struct net_device *dev)
+@@ -1004,7 +1074,9 @@ void mlx4_en_calc_rx_buf(struct net_device *dev)
                priv->dma_dir = PCI_DMA_BIDIRECTIONAL;
                priv->rx_headroom = XDP_PACKET_HEADROOM;
                i = 1;
@@ -1479,11 +1600,160 @@ index xxxxxxx..xxxxxxx 100644
        memcpy(ethh->h_dest, priv->dev->dev_addr, ETH_ALEN);
        eth_zero_addr(ethh->h_source);
        ethh->h_proto = htons(ETH_P_ARP);
+diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
++++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+@@ -684,16 +684,44 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc,
+       }
+ }
++#ifdef NDO_SELECT_QUEUE_HAS_3_PARMS_NO_FALLBACK
+ u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
++                     struct net_device *sb_dev)
++
++#elif defined(NDO_SELECT_QUEUE_HAS_ACCEL_PRIV) || defined(HAVE_SELECT_QUEUE_FALLBACK_T)
++
++u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
++#ifdef HAVE_SELECT_QUEUE_FALLBACK_T
++#ifdef HAVE_SELECT_QUEUE_NET_DEVICE
+                        struct net_device *sb_dev)
++#else
++                     void *accel_priv,
++#endif /* HAVE_SELECT_QUEUE_NET_DEVICE */
++                     select_queue_fallback_t fallback)
++#else
++                     void *accel_priv)
++#endif
++#else /* NDO_SELECT_QUEUE_HAS_ACCEL_PRIV || HAVE_SELECT_QUEUE_FALLBACK_T */
++u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb)
++#endif
+ {
+       struct mlx4_en_priv *priv = netdev_priv(dev);
+       u16 rings_p_up = priv->num_tx_rings_p_up;
+       if (netdev_get_num_tc(dev))
++#ifdef NDO_SELECT_QUEUE_HAS_3_PARMS_NO_FALLBACK
+               return netdev_pick_tx(dev, skb, NULL);
+       return netdev_pick_tx(dev, skb, NULL) % rings_p_up;
++#elif defined (HAVE_SELECT_QUEUE_FALLBACK_T_3_PARAMS)
++              return fallback(dev, skb, NULL);
++ 
++      return fallback(dev, skb, NULL) % rings_p_up;
++#else
++              return fallback(dev, skb);
++
++      return fallback(dev, skb) % rings_p_up;
++#endif
+ }
+ static void mlx4_bf_copy(void __iomem *dst, const void *src,
+@@ -1040,9 +1068,21 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
+               ring->queue_stopped++;
+       }
++#ifdef HAVE_SK_BUFF_XMIT_MORE
++#ifdef HAVE_NETDEV_TX_SEND_QUEUE
+       send_doorbell = __netdev_tx_sent_queue(ring->tx_queue,
+                                              tx_info->nr_bytes,
++#ifdef HAVE_NETDEV_XMIT_MORE
+                                              netdev_xmit_more());
++#else
++                                             skb->xmit_more);
++#endif
++#else
++      send_doorbell = !skb->xmit_more || netif_xmit_stopped(ring->tx_queue);
++#endif
++#else
++      send_doorbell = true;
++#endif
+       real_size = (real_size / 16) & 0x3f;
+diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
++++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
+@@ -240,8 +240,12 @@ static void mlx4_set_eq_affinity_hint(struct mlx4_priv *priv, int vec)
+       struct mlx4_dev *dev = &priv->dev;
+       struct mlx4_eq *eq = &priv->eq_table.eq[vec];
++#ifdef HAVE_CPUMASK_AVAILABLE 
+       if (!cpumask_available(eq->affinity_mask) ||
+           cpumask_empty(eq->affinity_mask))
++#else
++      if (!eq->affinity_mask || cpumask_empty(eq->affinity_mask))
++#endif
+               return;
+       hint_err = irq_set_affinity_hint(eq->irq, eq->affinity_mask);
+diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlx4/icm.c
++++ b/drivers/net/ethernet/mellanox/mlx4/icm.c
+@@ -180,8 +180,10 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages,
+                       --cur_order;
+               mask = gfp_mask;
++#ifdef HAVE_GFP_DIRECT_RECLAIM
+               if (cur_order)
+                       mask &= ~__GFP_DIRECT_RECLAIM;
++#endif
+               if (coherent)
+                       ret = mlx4_alloc_icm_coherent(&dev->persist->pdev->dev,
 diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
 index xxxxxxx..xxxxxxx 100644
 --- a/drivers/net/ethernet/mellanox/mlx4/main.c
 +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
-@@ -3511,12 +3511,14 @@ slave_start:
+@@ -178,6 +178,7 @@ struct mlx4_port_config {
+ static atomic_t pf_loading = ATOMIC_INIT(0);
++#ifdef HAVE_DEVLINK_PARAM 
+ static int mlx4_devlink_ierr_reset_get(struct devlink *devlink, u32 id,
+                                      struct devlink_param_gset_ctx *ctx)
+ {
+@@ -192,6 +193,7 @@ static int mlx4_devlink_ierr_reset_set(struct devlink *devlink, u32 id,
+       return 0;
+ }
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+ static int mlx4_devlink_crdump_snapshot_get(struct devlink *devlink, u32 id,
+                                           struct devlink_param_gset_ctx *ctx)
+ {
+@@ -211,6 +213,7 @@ static int mlx4_devlink_crdump_snapshot_set(struct devlink *devlink, u32 id,
+       dev->persist->crdump.snapshot_enable = ctx->val.vbool;
+       return 0;
+ }
++#endif
+ static int
+ mlx4_devlink_max_macs_validate(struct devlink *devlink, u32 id,
+@@ -245,11 +248,13 @@ static const struct devlink_param mlx4_devlink_params[] = {
+       DEVLINK_PARAM_GENERIC(MAX_MACS,
+                             BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+                             NULL, NULL, mlx4_devlink_max_macs_validate),
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       DEVLINK_PARAM_GENERIC(REGION_SNAPSHOT,
+                             BIT(DEVLINK_PARAM_CMODE_RUNTIME) |
+                             BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+                             mlx4_devlink_crdump_snapshot_get,
+                             mlx4_devlink_crdump_snapshot_set, NULL),
++#endif
+       DEVLINK_PARAM_DRIVER(MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE,
+                            "enable_64b_cqe_eqe", DEVLINK_PARAM_TYPE_BOOL,
+                            BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
+@@ -289,6 +294,7 @@ static void mlx4_devlink_set_params_init_values(struct devlink *devlink)
+                                          DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
+                                          value);
+ }
++#endif
+ static inline void mlx4_set_num_reserved_uars(struct mlx4_dev *dev,
+                                             struct mlx4_dev_cap *dev_cap)
+@@ -3511,12 +3517,14 @@ slave_start:
                }
        }
  
@@ -1498,6 +1768,136 @@ index xxxxxxx..xxxxxxx 100644
  
        /* In master functions, the communication channel must be initialized
         * after obtaining its address from fw */
+@@ -3877,11 +3885,14 @@ static int mlx4_devlink_port_type_set(struct devlink_port *devlink_port,
+       return __set_port_type(info, mlx4_port_type);
+ }
++#ifdef HAVE_DEVLINK_DRIVERINIT_VAL
+ static void mlx4_devlink_param_load_driverinit_values(struct devlink *devlink)
+ {
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       struct mlx4_priv *priv = devlink_priv(devlink);
+       struct mlx4_dev *dev = &priv->dev;
+       struct mlx4_fw_crdump *crdump = &dev->persist->crdump;
++#endif
+       union devlink_param_value saved_value;
+       int err;
+@@ -3909,6 +3920,7 @@ static void mlx4_devlink_param_load_driverinit_values(struct devlink *devlink)
+                                                &saved_value);
+       if (!err)
+               enable_4k_uar = saved_value.vbool;
++#ifdef HAVE_DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT
+       err = devlink_param_driverinit_value_get(devlink,
+                                                DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT,
+                                                &saved_value);
+@@ -3917,6 +3929,7 @@ static void mlx4_devlink_param_load_driverinit_values(struct devlink *devlink)
+               devlink_param_value_changed(devlink,
+                                           DEVLINK_PARAM_GENERIC_ID_REGION_SNAPSHOT);
+       }
++#endif
+ }
+ static int mlx4_devlink_reload(struct devlink *devlink,
+@@ -3935,10 +3948,13 @@ static int mlx4_devlink_reload(struct devlink *devlink,
+       return err;
+ }
++#endif /*HAVE_DEVLINK_DRIVERINIT_VAL*/
+ static const struct devlink_ops mlx4_devlink_ops = {
+       .port_type_set  = mlx4_devlink_port_type_set,
++#ifdef HAVE_DEVLINK_DRIVERINIT_VAL
+       .reload         = mlx4_devlink_reload,
++#endif /*HAVE_DEVLINK_DRIVERINIT_VAL*/
+ };
+ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
+@@ -3972,22 +3988,33 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
+       ret = devlink_register(devlink, &pdev->dev);
+       if (ret)
+               goto err_persist_free;
++#ifdef HAVE_DEVLINK_PARAM
+       ret = devlink_params_register(devlink, mlx4_devlink_params,
+                                     ARRAY_SIZE(mlx4_devlink_params));
+       if (ret)
+               goto err_devlink_unregister;
+       mlx4_devlink_set_params_init_values(devlink);
++#endif
+       ret =  __mlx4_init_one(pdev, id->driver_data, priv);
++#ifdef HAVE_DEVLINK_PARAM
+       if (ret)
+               goto err_params_unregister;
++#else
++      if (ret)
++              goto err_devlink_unregister;
++#endif /* HAVE_DEVLINK_PARAM  */
++#ifdef HAVE_DEVLINK_PARAMS_PUBLISHED
+       devlink_params_publish(devlink);
++#endif
+       pci_save_state(pdev);
+       return 0;
++#ifdef HAVE_DEVLINK_PARAM
+ err_params_unregister:
+       devlink_params_unregister(devlink, mlx4_devlink_params,
+                                 ARRAY_SIZE(mlx4_devlink_params));
++#endif
+ err_devlink_unregister:
+       devlink_unregister(devlink);
+ err_persist_free:
+@@ -4125,8 +4152,10 @@ static void mlx4_remove_one(struct pci_dev *pdev)
+       pci_release_regions(pdev);
+       mlx4_pci_disable_device(dev);
++#ifdef HAVE_DEVLINK_PARAM
+       devlink_params_unregister(devlink, mlx4_devlink_params,
+                                 ARRAY_SIZE(mlx4_devlink_params));
++#endif
+       devlink_unregister(devlink);
+       kfree(dev->persist);
+       devlink_free(devlink);
+@@ -4151,7 +4180,11 @@ static int restore_current_port_types(struct mlx4_dev *dev,
+       return err;
+ }
++#ifdef HAVE_DEVLINK_DRIVERINIT_VAL
+ int mlx4_restart_one(struct pci_dev *pdev, bool reload, struct devlink *devlink)
++#else
++int mlx4_restart_one(struct pci_dev *pdev)
++#endif
+ {
+       struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
+       struct mlx4_dev  *dev  = persist->dev;
+@@ -4164,8 +4197,10 @@ int mlx4_restart_one(struct pci_dev *pdev, bool reload, struct devlink *devlink)
+       memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
+       mlx4_unload_one(pdev);
++#ifdef HAVE_DEVLINK_DRIVERINIT_VAL
+       if (reload)
+               mlx4_devlink_param_load_driverinit_values(devlink);
++#endif
+       err = mlx4_load_one(pdev, pci_dev_data, total_vfs, nvfs, priv, 1);
+       if (err) {
+               mlx4_err(dev, "%s: ERROR: mlx4_load_one failed, pci_name=%s, err=%d\n",
+diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
++++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+@@ -1043,8 +1043,12 @@ int mlx4_catas_init(struct mlx4_dev *dev);
+ void mlx4_catas_end(struct mlx4_dev *dev);
+ int mlx4_crdump_init(struct mlx4_dev *dev);
+ void mlx4_crdump_end(struct mlx4_dev *dev);
++#ifdef HAVE_DEVLINK_DRIVERINIT_VAL
+ int mlx4_restart_one(struct pci_dev *pdev, bool reload,
+                    struct devlink *devlink);
++#else
++int mlx4_restart_one(struct pci_dev *pdev);
++#endif
+ int mlx4_register_device(struct mlx4_dev *dev);
+ void mlx4_unregister_device(struct mlx4_dev *dev);
+ void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,
 diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
 index xxxxxxx..xxxxxxx 100644
 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -1545,9 +1945,29 @@ index xxxxxxx..xxxxxxx 100644
  void mlx4_en_safe_replace_resources(struct mlx4_en_priv *priv,
                                    struct mlx4_en_priv *tmp);
  
-@@ -700,10 +710,12 @@ void mlx4_en_tx_irq(struct mlx4_cq *mcq);
+@@ -697,13 +707,32 @@ int mlx4_en_set_cq_moder(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
+ void mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
+ void mlx4_en_tx_irq(struct mlx4_cq *mcq);
++#ifdef NDO_SELECT_QUEUE_HAS_3_PARMS_NO_FALLBACK
  u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
++                     struct net_device *sb_dev);
++#elif defined(NDO_SELECT_QUEUE_HAS_ACCEL_PRIV) || defined(HAVE_SELECT_QUEUE_FALLBACK_T)
++
++u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
++#ifdef HAVE_SELECT_QUEUE_FALLBACK_T
++#ifdef HAVE_SELECT_QUEUE_NET_DEVICE
                         struct net_device *sb_dev);
++#else
++                     void *accel_priv,
++#endif /* HAVE_SELECT_QUEUE_NET_DEVICE */
++                     select_queue_fallback_t fallback);
++#else
++                     void *accel_priv);
++#endif
++#else /* NDO_SELECT_QUEUE_HAS_ACCEL_PRIV || HAVE_SELECT_QUEUE_FALLBACK_T */
++u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb);
++#endif /* HAVE_3_PARAMS_FOR_NDO_SELECT_QUEUE */
  netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev);
 +#ifdef HAVE_XDP_BUFF
  netdev_tx_t mlx4_en_xmit_frame(struct mlx4_en_rx_ring *rx_ring,