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

Change-Id: I7dc5c95ebd0bd5adaa4ac9551b5a034ca3be9b38
---
 .../mellanox/mlx5/core/eswitch_devlink_compat.c     | 13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_devlink_compat.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_devlink_compat.c
@@ -35,10 +35,12 @@ static char *steering_mode_to_str[] = {
 	[DEVLINK_ESWITCH_STEERING_MODE_SMFS] = "smfs",
 };
 
+#ifdef HAVE_XFRM_OFFLOAD_PACKET
 static char *ipsec_to_str[] = {
 	[DEVLINK_ESWITCH_IPSEC_MODE_NONE] = "none",
 	[DEVLINK_ESWITCH_IPSEC_MODE_FULL] = "full",
 };
+#endif
 
 static char *vport_match_to_str[] = {
 	[DEVLINK_ESWITCH_VPORT_MATCH_MODE_METADATA] = "metadata",
@@ -93,7 +95,12 @@ struct devlink_compat_op {
 	int (*read_param_bool)(struct devlink *devlink, u32 id,
 			       struct devlink_param_gset_ctx *ctx);
 	int (*write_param_bool)(struct devlink *devlink, u32 id,
+#ifdef HAVE_DEVLINK_PARAM_SET_FUNCTION_POINTER_HAS_EXTACK
+				struct devlink_param_gset_ctx *ctx,
+				struct netlink_ext_ack *extack);
+#else
 				struct devlink_param_gset_ctx *ctx);
+#endif
 
 	char **map;
 	int map_size;
@@ -135,6 +142,7 @@ static struct devlink_compat_op devlink_
 		.compat_name = "steering_mode",
 	},
 /* only for kernel linux-5.4.0-1020.21.g8ebdd1f-bluefield*/
+#ifdef HAVE_XFRM_OFFLOAD_PACKET
 	{
 		.read_enum_ipsec = mlx5_devlink_eswitch_ipsec_mode_get,
 		.write_enum_ipsec = mlx5_devlink_eswitch_ipsec_mode_set,
@@ -142,6 +150,7 @@ static struct devlink_compat_op devlink_
 		.map_size = ARRAY_SIZE(ipsec_to_str),
 		.compat_name = "ipsec_mode",
 	},
+#endif
 
 	{
 		.read_vport_match_mode = mlx5_devlink_eswitch_vport_match_mode_get,
@@ -330,7 +339,11 @@ static ssize_t esw_compat_write(struct k
 		struct devlink_param_gset_ctx ctx;
 
 		ctx.val.vbool = set;
+#ifdef HAVE_DEVLINK_PARAM_SET_FUNCTION_POINTER_HAS_EXTACK
+		ret = op->write_param_bool(devlink, 0, &ctx, &ack);
+#else
 		ret = op->write_param_bool(devlink, 0, &ctx);
+#endif
 	} else if (op->write_vport_match_mode)
 		ret = op->write_vport_match_mode(devlink, set);
 	else if (op->write_enum_ipsec)
