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

Change-Id: I973a4836f862a727a66b10fd51c06b88fadd6e11
---
 .../mellanox/mlx5/core/en_fs_ethtool.c        | 39 +++++++++++++++++--
 1 file changed, 35 insertions(+), 4 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -40,7 +40,11 @@ static int flow_type_to_traffic_type(u32
 
 static u32 flow_type_mask(u32 flow_type)
 {
+#ifdef HAVE_FLOW_RSS
 	return flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS);
+#else
+	return flow_type & ~(FLOW_EXT | FLOW_MAC_EXT);
+#endif
 }
 
 struct mlx5e_ethtool_rule {
@@ -82,14 +86,18 @@ static struct mlx5e_ethtool_table *get_f
 	case ESP_V4_FLOW:
 	case ESP_V6_FLOW:
 #endif
+#ifdef HAVE_IPV6_USER_FLOW
 	case TCP_V6_FLOW:
 	case UDP_V6_FLOW:
+#endif
 		max_tuples = ETHTOOL_NUM_L3_L4_FTS;
 		prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
 		eth_ft = &priv->fs.ethtool.l3_l4_ft[prio];
 		break;
 	case IP_USER_FLOW:
+#ifdef HAVE_IPV6_USER_FLOW
 	case IPV6_USER_FLOW:
+#endif
 		max_tuples = ETHTOOL_NUM_L3_L4_FTS;
 		prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
 		eth_ft = &priv->fs.ethtool.l3_l4_ft[prio];
@@ -163,6 +171,7 @@ set_ip4(void *headers_c, void *headers_v
 	MLX5E_FTE_SET(headers_v, ethertype, ETH_P_IP);
 }
 
+#ifdef HAVE_IPV6_USER_FLOW
 static void
 set_ip6(void *headers_c, void *headers_v, __be32 ip6src_m[4],
 	__be32 ip6src_v[4], __be32 ip6dst_m[4], __be32 ip6dst_v[4])
@@ -185,6 +194,7 @@ set_ip6(void *headers_c, void *headers_v
 	MLX5E_FTE_SET(headers_c, ethertype, 0xffff);
 	MLX5E_FTE_SET(headers_v, ethertype, ETH_P_IPV6);
 }
+#endif
 
 static void
 set_tcp(void *headers_c, void *headers_v, __be16 psrc_m, __be16 psrc_v,
@@ -262,6 +272,7 @@ parse_ip4(void *headers_c, void *headers
 	}
 }
 
+#ifdef HAVE_IPV6_USER_FLOW
 static void
 parse_ip6(void *headers_c, void *headers_v, struct ethtool_rx_flow_spec *fs)
 {
@@ -302,6 +313,7 @@ parse_udp6(void *headers_c, void *header
 	set_udp(headers_c, headers_v, l4_mask->psrc, l4_val->psrc,
 		l4_mask->pdst, l4_val->pdst);
 }
+#endif
 
 static void
 parse_ether(void *headers_c, void *headers_v, struct ethtool_rx_flow_spec *fs)
@@ -365,6 +377,7 @@ static int set_flow_attrs(u32 *match_c,
 	case IP_USER_FLOW:
 		parse_ip4(outer_headers_c, outer_headers_v, fs);
 		break;
+#ifdef HAVE_IPV6_USER_FLOW
 	case TCP_V6_FLOW:
 		parse_tcp6(outer_headers_c, outer_headers_v, fs);
 		break;
@@ -374,6 +387,7 @@ static int set_flow_attrs(u32 *match_c,
 	case IPV6_USER_FLOW:
 		parse_ip6(outer_headers_c, outer_headers_v, fs);
 		break;
+#endif
 	case ETHER_FLOW:
 		parse_ether(outer_headers_c, outer_headers_v, fs);
 		break;
@@ -426,6 +440,7 @@ static int flow_get_tirn(struct mlx5e_pr
 			 struct ethtool_rx_flow_spec *fs,
 			 u32 rss_context, u32 *tirn)
 {
+#ifdef HAVE_FLOW_RSS
 	if (fs->flow_type & FLOW_RSS) {
 		struct mlx5e_packet_merge_param pkt_merge_param;
 		struct mlx5e_rss *rss;
@@ -448,7 +463,9 @@ static int flow_get_tirn(struct mlx5e_pr
 			return err;
 		eth_rule->rss = rss;
 		mlx5e_rss_refcnt_inc(eth_rule->rss);
-	} else {
+	} else
+#endif
+	{
 		struct mlx5e_params *params = &priv->channels.params;
 		enum mlx5e_rq_group group;
 		u16 ix;
@@ -460,6 +477,8 @@ static int flow_get_tirn(struct mlx5e_pr
 			mlx5e_rx_res_get_tirn_direct(priv->rx_res, ix);
 	}
 
+
+
 	return 0;
 }
 
@@ -628,6 +647,7 @@ static int validate_ip4(struct ethtool_r
 	return ++ntuples;
 }
 
+#ifdef HAVE_IPV6_USER_FLOW
 static int validate_ip6(struct ethtool_rx_flow_spec *fs)
 {
 	struct ethtool_usrip6_spec *l3_mask = &fs->m_u.usr_ip6_spec;
@@ -667,7 +687,7 @@ static int validate_tcpudp6(struct ethto
 	/* Flow is TCP/UDP */
 	return ++ntuples;
 }
-
+#endif
 static int validate_vlan(struct ethtool_rx_flow_spec *fs)
 {
 	if (fs->m_ext.vlan_etype ||
@@ -680,7 +700,6 @@ static int validate_vlan(struct ethtool_
 
 	return 1;
 }
-
 static int validate_flow(struct mlx5e_priv *priv,
 			 struct ethtool_rx_flow_spec *fs)
 {
@@ -731,6 +750,7 @@ static int validate_flow(struct mlx5e_pr
 			return ret;
 		num_tuples += ret;
 		break;
+#ifdef HAVE_IPV6_USER_FLOW
 	case TCP_V6_FLOW:
 	case UDP_V6_FLOW:
 		ret = validate_tcpudp6(fs);
@@ -744,6 +764,7 @@ static int validate_flow(struct mlx5e_pr
 			return ret;
 		num_tuples += ret;
 		break;
+#endif
 	default:
 		return -ENOTSUPP;
 	}
@@ -840,19 +861,23 @@ mlx5e_ethtool_get_flow(struct mlx5e_priv
 		return -EINVAL;
 
 	list_for_each_entry(eth_rule, &priv->fs.ethtool.rules, list) {
+#ifdef HAVE_FLOW_RSS
 		int index;
+#endif
 
 		if (eth_rule->flow_spec.location != location)
 			continue;
 		if (!info)
 			return 0;
 		info->fs = eth_rule->flow_spec;
+#ifdef HAVE_FLOW_RSS
 		if (!eth_rule->rss)
 			return 0;
 		index = mlx5e_rx_res_rss_index(priv->rx_res, eth_rule->rss);
 		if (index < 0)
 			return index;
 		info->rss_context = index;
+#endif
 		return 0;
 	}
 
@@ -985,13 +1010,19 @@ static int mlx5e_get_rss_hash_opt(struct
 	return 0;
 }
 
+#ifdef CONFIG_MLX5_EN_RXNFC
 int mlx5e_ethtool_set_rxnfc(struct mlx5e_priv *priv, struct ethtool_rxnfc *cmd)
 {
 	int err = 0;
 
 	switch (cmd->cmd) {
 	case ETHTOOL_SRXCLSRLINS:
+#ifdef HAVE_FLOW_RSS
 		err = mlx5e_ethtool_flow_replace(priv, &cmd->fs, cmd->rss_context);
+#else
+		err = mlx5e_ethtool_flow_replace(priv, &cmd->fs, 0);
+#endif
+
 		break;
 	case ETHTOOL_SRXCLSRLDEL:
 		err = mlx5e_ethtool_flow_remove(priv, cmd->fs.location);
@@ -1032,4 +1063,4 @@ int mlx5e_ethtool_get_rxnfc(struct mlx5e
 
 	return err;
 }
-
+#endif
