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

Change-Id: Ib15b08b1fb3f4966a8b1f65f59a39b48aeaa6638
---
 .../mellanox/mlx5/core/en_accel/ktls.c        | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
 // Copyright (c) 2019 Mellanox Technologies.
 
+#ifdef HAVE_KTLS_STRUCTS
+
 #include "en.h"
 #include "en_accel/tls.h"
 #include "en_accel/ktls.h"
@@ -22,7 +24,11 @@ static int mlx5e_ktls_add(struct net_dev
 	if (direction == TLS_OFFLOAD_CTX_DIR_TX)
 		err = mlx5e_ktls_add_tx(netdev, sk, crypto_info, start_offload_tcp_sn);
 	else
+#ifdef HAVE_KTLS_RX_SUPPORT
 		err = mlx5e_ktls_add_rx(netdev, sk, crypto_info, start_offload_tcp_sn);
+#else
+		err = -EOPNOTSUPP;
+#endif
 
 	return err;
 }
@@ -33,10 +39,13 @@ static void mlx5e_ktls_del(struct net_de
 {
 	if (direction == TLS_OFFLOAD_CTX_DIR_TX)
 		mlx5e_ktls_del_tx(netdev, tls_ctx);
+#ifdef HAVE_KTLS_RX_SUPPORT
 	else
 		mlx5e_ktls_del_rx(netdev, tls_ctx);
+#endif
 }
 
+#ifdef HAVE_TLSDEV_OPS_HAS_TLS_DEV_RESYNC
 static int mlx5e_ktls_resync(struct net_device *netdev,
 			     struct sock *sk, u32 seq, u8 *rcd_sn,
 			     enum tls_offload_ctx_dir direction)
@@ -44,14 +53,21 @@ static int mlx5e_ktls_resync(struct net_
 	if (unlikely(direction != TLS_OFFLOAD_CTX_DIR_RX))
 		return -EOPNOTSUPP;
 
+#ifdef HAVE_KTLS_RX_SUPPORT
 	mlx5e_ktls_rx_resync(netdev, sk, seq, rcd_sn);
 	return 0;
+#else
+	return -EOPNOTSUPP;
+#endif
 }
+#endif
 
 static const struct tlsdev_ops mlx5e_ktls_ops = {
 	.tls_dev_add = mlx5e_ktls_add,
 	.tls_dev_del = mlx5e_ktls_del,
+#ifdef HAVE_TLSDEV_OPS_HAS_TLS_DEV_RESYNC
 	.tls_dev_resync = mlx5e_ktls_resync,
+#endif
 };
 
 bool mlx5e_accel_is_ktls_rx(struct mlx5_core_dev *mdev)
@@ -85,12 +101,15 @@ void mlx5e_ktls_build_netdev(struct mlx5
 		netdev->features    |= NETIF_F_HW_TLS_TX;
 	}
 
-	if (mlx5e_accel_is_ktls_rx(mdev))
-		netdev->hw_features |= NETIF_F_HW_TLS_RX;
+#ifdef HAVE_KTLS_RX_SUPPORT
+       if (mlx5e_accel_is_ktls_rx(mdev))
+       	netdev->hw_features |= NETIF_F_HW_TLS_RX;
+#endif
 
 	netdev->tlsdev_ops = &mlx5e_ktls_ops;
 }
 
+#ifdef HAVE_KTLS_RX_SUPPORT
 int mlx5e_ktls_set_feature_rx(struct net_device *netdev, bool enable)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -138,3 +157,6 @@ void mlx5e_ktls_cleanup_rx(struct mlx5e_
 
 	destroy_workqueue(priv->tls->rx_wq);
 }
+#endif /* HAVE_KTLS_RX_SUPPORT */
+
+#endif
