From: Chris Mi <cmi@nvidia.com>
Subject: [PATCH] BACKPORT:
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c

Change-Id: Ibdb8fde20dd1828c60a8b1ca8db1a52648b68754
---
 .../mellanox/mlx5/core/en/tc/act/police.c         | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
@@ -17,21 +17,30 @@ static int
 fill_meter_params_from_act(const struct flow_action_entry *act,
 			   struct mlx5e_flow_meter_params *params)
 {
+#if defined(HAVE_FLOW_ACTION_POLICE_INDEX) || defined(HAVE_FLOW_ACTION_HW_INDEX)
+#ifdef HAVE_FLOW_ACTION_HW_INDEX
 	params->index = act->hw_index;
+#else
+	params->index = act->police.index;
+#endif
 	if (act->police.rate_bytes_ps) {
 		params->mode = MLX5_RATE_LIMIT_BPS;
 		/* change rate to bits per second */
 		params->rate = act->police.rate_bytes_ps << 3;
 		params->burst = act->police.burst;
+#ifdef HAVE_FLOW_ACTION_POLICE_RATE_PKT_PS
 	} else if (act->police.rate_pkt_ps) {
 		params->mode = MLX5_RATE_LIMIT_PPS;
 		params->rate = act->police.rate_pkt_ps;
 		params->burst = act->police.burst_pkt;
+#endif
 	} else {
 		return -EOPNOTSUPP;
 	}
-
 	return 0;
+#else
+	return -EOPNOTSUPP;
+#endif
 }
 
 static int
@@ -60,6 +69,7 @@ tc_act_is_multi_table_act_police(struct
 	return true;
 }
 
+#ifdef HAVE_FLOW_OFFLOAD_ACTION
 static int
 tc_act_police_offload(struct mlx5e_priv *priv,
 		      struct flow_offload_action *fl_act,
@@ -132,12 +142,15 @@ tc_act_police_stats(struct mlx5e_priv *p
 	mlx5e_tc_meter_put(meter);
 	return 0;
 }
+#endif /* HAVE_FLOW_OFFLOAD_ACTION */
 
 struct mlx5e_tc_act mlx5e_tc_act_police = {
 	.can_offload = tc_act_can_offload_police,
 	.parse_action = tc_act_parse_police,
 	.is_multi_table_act = tc_act_is_multi_table_act_police,
+#ifdef HAVE_FLOW_OFFLOAD_ACTION
 	.offload_action = tc_act_police_offload,
 	.destroy_action = tc_act_police_destroy,
 	.stats_action = tc_act_police_stats,
+#endif
 };
