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

Change-Id: I04a85c22668de7ccf0c68bb36262d728855f7a26
---
 .../net/ethernet/mellanox/mlx5/core/en/trap.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/trap.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
 /* Copyright (c) 2020 Mellanox Technologies */
 
+#ifdef HAVE_DEVLINK_TRAP_SUPPORT
+
 #include <net/page_pool.h>
 #include "en/txrx.h"
 #include "en/params.h"
@@ -53,7 +55,11 @@ static void mlx5e_init_trap_rq(struct ml
 	rq->hw_mtu       = MLX5E_SW2HW_MTU(params, params->sw_mtu);
 	rq->stats        = &priv->trap_stats.rq;
 	rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
+#ifdef HAVE_XDP_SUPPORT
+#ifdef HAVE_XDP_RXQ_INFO
 	xdp_rxq_info_unused(&rq->xdp_rxq);
+#endif
+#endif
 	mlx5e_rq_set_trap_handlers(rq, params);
 }
 
@@ -138,8 +144,11 @@ static struct mlx5e_trap *mlx5e_open_tra
 	t->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey);
 	t->stats    = &priv->trap_stats.ch;
 
+#ifdef HAVE_NETIF_NAPI_ADD_GET_3_PARAMS //forwardport
+	netif_napi_add(netdev, &t->napi, mlx5e_trap_napi_poll);
+#else
 	netif_napi_add(netdev, &t->napi, mlx5e_trap_napi_poll, 64);
-
+#endif
 	err = mlx5e_open_trap_rq(priv, t);
 	if (unlikely(err))
 		goto err_napi_del;
@@ -225,11 +234,13 @@ static int mlx5e_handle_action_trap(stru
 		if (err)
 			goto err_out;
 		break;
+#ifdef HAVE_DEVLINK_TRAP_DMAC_FILTER
 	case DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER:
 		err = mlx5e_add_mac_trap(priv, trap_id, mlx5e_trap_get_tirn(priv->en_trap));
 		if (err)
 			goto err_out;
 		break;
+#endif
 	default:
 		netdev_warn(priv->netdev, "%s: Unknown trap id %d\n", __func__, trap_id);
 		err = -EINVAL;
@@ -249,9 +260,11 @@ static int mlx5e_handle_action_drop(stru
 	case DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER:
 		mlx5e_remove_vlan_trap(priv);
 		break;
+#ifdef HAVE_DEVLINK_TRAP_DMAC_FILTER
 	case DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER:
 		mlx5e_remove_mac_trap(priv);
 		break;
+#endif
 	default:
 		netdev_warn(priv->netdev, "%s: Unknown trap id %d\n", __func__, trap_id);
 		return -EINVAL;
@@ -305,7 +318,9 @@ static int mlx5e_apply_trap(struct mlx5e
 
 static const int mlx5e_traps_arr[] = {
 	DEVLINK_TRAP_GENERIC_ID_INGRESS_VLAN_FILTER,
+#ifdef HAVE_DEVLINK_TRAP_DMAC_FILTER
 	DEVLINK_TRAP_GENERIC_ID_DMAC_FILTER,
+#endif
 };
 
 int mlx5e_apply_traps(struct mlx5e_priv *priv, bool enable)
@@ -320,3 +335,5 @@ int mlx5e_apply_traps(struct mlx5e_priv
 	}
 	return 0;
 }
+
+#endif /* HAVE_DEVLINK_TRAP_SUPPORT */
