Re: [net-next 03/12] net/mlx5e: Ethtool steering, ip6 support

2018-08-11 Thread Or Gerlitz
On Sat, Aug 11, 2018 at 1:26 AM, Saeed Mahameed  wrote:
> Add ip6 support for ethtool flow steering.
>
> New supported flow types: ip6|tcp6|udp6|
> Supported fields: src-ip|dst-ip|src-port|dst-port
>
> Signed-off-by: Saeed Mahameed 
> ---
>  .../mellanox/mlx5/core/en_fs_ethtool.c| 138 ++
>  1 file changed, 138 insertions(+)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c 
> b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
> index f2fa189adc4f..646b659fe805 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
> @@ -66,11 +66,14 @@ static struct mlx5e_ethtool_table *get_flow_table(struct 
> mlx5e_priv *priv,
> switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) {
> case TCP_V4_FLOW:
> case UDP_V4_FLOW:
> +   case TCP_V6_FLOW:
> +   case UDP_V6_FLOW:
> max_tuples = ETHTOOL_NUM_L3_L4_FTS;
> prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
> eth_ft = >fs.ethtool.l3_l4_ft[prio];
> break;
> case IP_USER_FLOW:
> +   case IPV6_USER_FLOW:
> max_tuples = ETHTOOL_NUM_L3_L4_FTS;
> prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
> eth_ft = >fs.ethtool.l3_l4_ft[prio];
> @@ -142,6 +145,39 @@ set_ip4(void *headers_c, void *headers_v, __be32 
> ip4src_m,
> MLX5E_FTE_SET(headers_v, ethertype, ETH_P_IP);
>  }
>
> +static bool is_zero_ip6(__be32 ip6[4])
> +{
> +   int i;
> +
> +   for (i = 0; i < 4; i++)
> +   if (ip6[i] != 0)
> +   return false;
> +   return true;
> +}
> +
> +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])
> +{
> +   u8 ip6_sz = MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6);
> +
> +   if (!is_zero_ip6(ip6src_m)) {
> +   memcpy(MLX5E_FTE_ADDR_OF(headers_v, 
> src_ipv4_src_ipv6.ipv6_layout.ipv6),
> +  ip6src_v, ip6_sz);
> +   memset(MLX5E_FTE_ADDR_OF(headers_c, 
> src_ipv4_src_ipv6.ipv6_layout.ipv6),
> +  0xff, ip6_sz);

ip6src_m is the mask provided by the user, right? so why not use it
instead of all-one (0xffs)?


Re: [net-next 03/12] net/mlx5e: Ethtool steering, ip6 support

2018-08-10 Thread David Miller
From: Saeed Mahameed 
Date: Fri, 10 Aug 2018 15:26:21 -0700

> +static bool is_zero_ip6(__be32 ip6[4])
> +{
> + int i;
> +
> + for (i = 0; i < 4; i++)
> + if (ip6[i] != 0)
> + return false;
> + return true;
> +}

This is ipv6_addr_any().


[net-next 03/12] net/mlx5e: Ethtool steering, ip6 support

2018-08-10 Thread Saeed Mahameed
Add ip6 support for ethtool flow steering.

New supported flow types: ip6|tcp6|udp6|
Supported fields: src-ip|dst-ip|src-port|dst-port

Signed-off-by: Saeed Mahameed 
---
 .../mellanox/mlx5/core/en_fs_ethtool.c| 138 ++
 1 file changed, 138 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
index f2fa189adc4f..646b659fe805 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c
@@ -66,11 +66,14 @@ static struct mlx5e_ethtool_table *get_flow_table(struct 
mlx5e_priv *priv,
switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) {
case TCP_V4_FLOW:
case UDP_V4_FLOW:
+   case TCP_V6_FLOW:
+   case UDP_V6_FLOW:
max_tuples = ETHTOOL_NUM_L3_L4_FTS;
prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
eth_ft = >fs.ethtool.l3_l4_ft[prio];
break;
case IP_USER_FLOW:
+   case IPV6_USER_FLOW:
max_tuples = ETHTOOL_NUM_L3_L4_FTS;
prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
eth_ft = >fs.ethtool.l3_l4_ft[prio];
@@ -142,6 +145,39 @@ set_ip4(void *headers_c, void *headers_v, __be32 ip4src_m,
MLX5E_FTE_SET(headers_v, ethertype, ETH_P_IP);
 }
 
+static bool is_zero_ip6(__be32 ip6[4])
+{
+   int i;
+
+   for (i = 0; i < 4; i++)
+   if (ip6[i] != 0)
+   return false;
+   return true;
+}
+
+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])
+{
+   u8 ip6_sz = MLX5_FLD_SZ_BYTES(ipv6_layout, ipv6);
+
+   if (!is_zero_ip6(ip6src_m)) {
+   memcpy(MLX5E_FTE_ADDR_OF(headers_v, 
src_ipv4_src_ipv6.ipv6_layout.ipv6),
+  ip6src_v, ip6_sz);
+   memset(MLX5E_FTE_ADDR_OF(headers_c, 
src_ipv4_src_ipv6.ipv6_layout.ipv6),
+  0xff, ip6_sz);
+   }
+   if (!is_zero_ip6(ip6dst_m)) {
+   memcpy(MLX5E_FTE_ADDR_OF(headers_v, 
dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
+  ip6dst_v, ip6_sz);
+   memset(MLX5E_FTE_ADDR_OF(headers_c, 
dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
+  0xff, ip6_sz);
+   }
+
+   MLX5E_FTE_SET(headers_c, ethertype, 0x);
+   MLX5E_FTE_SET(headers_v, ethertype, ETH_P_IPV6);
+}
+
 static void
 set_tcp(void *headers_c, void *headers_v, __be16 psrc_m, __be16 psrc_v,
__be16 pdst_m, __be16 pdst_v)
@@ -213,6 +249,42 @@ parse_ip4(void *headers_c, void *headers_v, struct 
ethtool_rx_flow_spec *fs)
l3_mask->ip4dst, l3_val->ip4dst);
 }
 
+static void
+parse_ip6(void *headers_c, void *headers_v, struct ethtool_rx_flow_spec *fs)
+{
+   struct ethtool_usrip6_spec *l3_mask = >m_u.usr_ip6_spec;
+   struct ethtool_usrip6_spec *l3_val  = >h_u.usr_ip6_spec;
+
+   set_ip6(headers_c, headers_v, l3_mask->ip6src,
+   l3_val->ip6src, l3_mask->ip6dst, l3_val->ip6dst);
+}
+
+static void
+parse_tcp6(void *headers_c, void *headers_v, struct ethtool_rx_flow_spec *fs)
+{
+   struct ethtool_tcpip6_spec *l4_mask = >m_u.tcp_ip6_spec;
+   struct ethtool_tcpip6_spec *l4_val  = >h_u.tcp_ip6_spec;
+
+   set_ip6(headers_c, headers_v, l4_mask->ip6src,
+   l4_val->ip6src, l4_mask->ip6dst, l4_val->ip6dst);
+
+   set_tcp(headers_c, headers_v, l4_mask->psrc, l4_val->psrc,
+   l4_mask->pdst, l4_val->pdst);
+}
+
+static void
+parse_udp6(void *headers_c, void *headers_v, struct ethtool_rx_flow_spec *fs)
+{
+   struct ethtool_tcpip6_spec *l4_mask = >m_u.udp_ip6_spec;
+   struct ethtool_tcpip6_spec *l4_val  = >h_u.udp_ip6_spec;
+
+   set_ip6(headers_c, headers_v, l4_mask->ip6src,
+   l4_val->ip6src, l4_mask->ip6dst, l4_val->ip6dst);
+
+   set_udp(headers_c, headers_v, l4_mask->psrc, l4_val->psrc,
+   l4_mask->pdst, l4_val->pdst);
+}
+
 static void
 parse_ether(void *headers_c, void *headers_v, struct ethtool_rx_flow_spec *fs)
 {
@@ -264,6 +336,15 @@ static int set_flow_attrs(u32 *match_c, u32 *match_v,
case IP_USER_FLOW:
parse_ip4(outer_headers_c, outer_headers_v, fs);
break;
+   case TCP_V6_FLOW:
+   parse_tcp6(outer_headers_c, outer_headers_v, fs);
+   break;
+   case UDP_V6_FLOW:
+   parse_udp6(outer_headers_c, outer_headers_v, fs);
+   break;
+   case IPV6_USER_FLOW:
+   parse_ip6(outer_headers_c, outer_headers_v, fs);
+   break;
case ETHER_FLOW:
parse_ether(outer_headers_c, outer_headers_v, fs);
break;
@@ -473,6 +554,50 @@ static int validate_ip4(struct ethtool_rx_flow_spec *fs)
return ++ntuples;
 }
 
+static int