From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT:
 drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c

Change-Id: I5206500a7d045f100cf33258a0f280db308c0eeb
---
 .../ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 56 +++++++++++++++++--
 1 file changed, 51 insertions(+), 5 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -47,11 +47,17 @@ static int mlx5i_change_mtu(struct net_d
 static const struct net_device_ops mlx5i_netdev_ops = {
 	.ndo_open                = mlx5i_open,
 	.ndo_stop                = mlx5i_close,
-	.ndo_get_stats64         = mlx5i_get_stats,
-	.ndo_init                = mlx5i_dev_init,
-	.ndo_uninit              = mlx5i_dev_cleanup,
-	.ndo_change_mtu          = mlx5i_change_mtu,
+       .ndo_get_stats64         = mlx5i_get_stats,
+       .ndo_init                = mlx5i_dev_init,
+       .ndo_uninit              = mlx5i_dev_cleanup,
+       .ndo_change_mtu          = mlx5i_change_mtu,
+
+#ifdef HAVE_NDO_ETH_IOCTL
 	.ndo_eth_ioctl            = mlx5i_ioctl,
+#else
+	.ndo_do_ioctl		  = mlx5i_ioctl,
+#endif
+
 };
 
 /* IPoIB mlx5 netdev profile */
@@ -76,6 +82,22 @@ static void mlx5i_build_nic_params(struc
 	MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS, params->rx_cqe_compress_def);
 }
 
+#ifdef CONFIG_COMPAT_LRO_ENABLED_IPOIB
+void set_lro_features_bit(struct mlx5e_priv *priv)
+{
+	struct mlx5e_params *params = &priv->channels.params;
+	u64 hw_support_lro = 0;
+
+	hw_support_lro = priv->netdev->hw_features & NETIF_F_RXCSUM;
+	if (hw_support_lro) {
+		priv->netdev->hw_features |= NETIF_F_LRO;
+		priv->netdev->features |= NETIF_F_LRO;
+		priv->netdev->wanted_features |= NETIF_F_LRO;
+	}
+	params->lro_en = hw_support_lro;
+}
+#endif
+
 /* Called directly after IPoIB netdevice was created to initialize SW structs */
 int mlx5i_init(struct mlx5_core_dev *mdev, struct net_device *netdev)
 {
@@ -85,7 +107,12 @@ int mlx5i_init(struct mlx5_core_dev *mde
 	mlx5e_set_netdev_mtu_boundaries(priv);
 	netdev->mtu = netdev->max_mtu;
 
-	mlx5e_build_nic_params(priv, NULL, netdev->mtu);
+	mlx5e_build_nic_params(priv,
+#ifdef HAVE_XSK_ZERO_COPY_SUPPORT
+			       NULL,
+#endif
+			       netdev->mtu);
+
 	mlx5i_build_nic_params(mdev, &priv->channels.params);
 
 	mlx5e_timestamp_init(priv);
@@ -99,6 +126,9 @@ int mlx5i_init(struct mlx5_core_dev *mde
 	netdev->hw_features    |= NETIF_F_TSO6;
 	netdev->hw_features    |= NETIF_F_RXCSUM;
 	netdev->hw_features    |= NETIF_F_RXHASH;
+#ifdef CONFIG_COMPAT_LRO_ENABLED_IPOIB
+	set_lro_features_bit(priv);
+#endif
 
 	netdev->netdev_ops = &mlx5i_netdev_ops;
 	netdev->ethtool_ops = &mlx5i_ethtool_ops;
@@ -376,7 +406,9 @@ static int mlx5i_create_flow_steering(st
 	if (err) {
 		netdev_err(priv->netdev, "Failed to create arfs tables, err=%d\n",
 			   err);
+#ifdef CONFIG_RFS_ACCEL
 		priv->netdev->hw_features &= ~NETIF_F_NTUPLE;
+#endif
 	}
 
 	err = mlx5e_create_ttc_table(priv->fs, priv->rx_res);
@@ -542,13 +574,21 @@ int mlx5i_dev_init(struct net_device *de
 {
 	struct mlx5e_priv    *priv   = mlx5i_epriv(dev);
 	struct mlx5i_priv    *ipriv  = priv->ppriv;
+#ifdef HAVE_DEV_ADDR_MOD
 	u8 addr_mod[3];
+#endif
 
 	/* Set dev address using underlay QP */
+#ifdef HAVE_DEV_ADDR_MOD
 	addr_mod[0] = (ipriv->qpn >> 16) & 0xff;
 	addr_mod[1] = (ipriv->qpn >>  8) & 0xff;
 	addr_mod[2] = (ipriv->qpn) & 0xff;
 	dev_addr_mod(dev, 1, addr_mod, sizeof(addr_mod));
+#else
+	dev->dev_addr[1] = (ipriv->qpn >> 16) & 0xff;
+	dev->dev_addr[2] = (ipriv->qpn >>  8) & 0xff;
+	dev->dev_addr[3] = (ipriv->qpn) & 0xff;
+#endif
 
 	/* Add QPN to net-device mapping to HT */
 	mlx5i_pkey_add_qpn(dev, ipriv->qpn);
@@ -708,7 +748,13 @@ static int mlx5i_xmit(struct net_device
 	struct mlx5_ib_ah *mah   = to_mah(address);
 	struct mlx5i_priv *ipriv = epriv->ppriv;
 
+#ifdef HAVE_NETDEV_XMIT_MORE
 	mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey, netdev_xmit_more());
+#elif defined(HAVE_SK_BUFF_XMIT_MORE)
+	mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey, skb->xmit_more);
+#else
+	mlx5i_sq_xmit(sq, skb, &mah->av, dqpn, ipriv->qkey);
+#endif
 
 	return NETDEV_TX_OK;
 }
