diff mbox series

[net-next,3/3] net/mlx5: Support GRE conntrack offload

Message ID 20220203115941.3107572-4-toshiaki.makita1@gmail.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series Conntrack GRE offload | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 5 maintainers not CCed: roid@nvidia.com ozsh@nvidia.com cmi@nvidia.com leon@kernel.org linux-rdma@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Toshiaki Makita Feb. 3, 2022, 11:59 a.m. UTC
Support GREv0 without NAT.

Signed-off-by: Toshiaki Makita <toshiaki.makita1@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

Comments

Paul Blakey Feb. 10, 2022, 12:44 p.m. UTC | #1
On Thu, 3 Feb 2022, Toshiaki Makita wrote:

> Support GREv0 without NAT.
> 
> Signed-off-by: Toshiaki Makita <toshiaki.makita1@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
> index 0f4d3b9d..465643c 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
> @@ -258,7 +258,8 @@ struct mlx5_ct_entry {
>  			return -EOPNOTSUPP;
>  		}
>  	} else {
> -		return -EOPNOTSUPP;
> +		if (tuple->ip_proto != IPPROTO_GRE)
> +			return -EOPNOTSUPP;
>  	}
>  
>  	return 0;
> @@ -807,7 +808,11 @@ struct mlx5_ct_entry {
>  	attr->dest_chain = 0;
>  	attr->dest_ft = mlx5e_tc_post_act_get_ft(ct_priv->post_act);
>  	attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct;
> -	attr->outer_match_level = MLX5_MATCH_L4;
> +	if (entry->tuple.ip_proto == IPPROTO_TCP ||
> +	    entry->tuple.ip_proto == IPPROTO_UDP)
> +		attr->outer_match_level = MLX5_MATCH_L4;
> +	else
> +		attr->outer_match_level = MLX5_MATCH_L3;
>  	attr->counter = entry->counter->counter;
>  	attr->flags |= MLX5_ATTR_FLAG_NO_IN_PORT;
>  	if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB)
> @@ -1224,16 +1229,20 @@ static void mlx5_tc_ct_entry_del_work(struct work_struct *work)
>  	struct flow_keys flow_keys;
>  
>  	skb_reset_network_header(skb);
> -	skb_flow_dissect_flow_keys(skb, &flow_keys, 0);
> +	skb_flow_dissect_flow_keys(skb, &flow_keys, FLOW_DISSECTOR_F_STOP_BEFORE_ENCAP);
>  
>  	tuple->zone = zone;
>  
>  	if (flow_keys.basic.ip_proto != IPPROTO_TCP &&
> -	    flow_keys.basic.ip_proto != IPPROTO_UDP)
> +	    flow_keys.basic.ip_proto != IPPROTO_UDP &&
> +	    flow_keys.basic.ip_proto != IPPROTO_GRE)
>  		return false;
>  
> -	tuple->port.src = flow_keys.ports.src;
> -	tuple->port.dst = flow_keys.ports.dst;
> +	if (flow_keys.basic.ip_proto == IPPROTO_TCP ||
> +	    flow_keys.basic.ip_proto == IPPROTO_UDP) {
> +		tuple->port.src = flow_keys.ports.src;
> +		tuple->port.dst = flow_keys.ports.dst;
> +	}
>  	tuple->n_proto = flow_keys.basic.n_proto;
>  	tuple->ip_proto = flow_keys.basic.ip_proto;
>  
> -- 
> 1.8.3.1
> 
> 

Acked-by: Paul Blakey <paulb@nvidia.com>

Looks good to me.
Thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
index 0f4d3b9d..465643c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
@@ -258,7 +258,8 @@  struct mlx5_ct_entry {
 			return -EOPNOTSUPP;
 		}
 	} else {
-		return -EOPNOTSUPP;
+		if (tuple->ip_proto != IPPROTO_GRE)
+			return -EOPNOTSUPP;
 	}
 
 	return 0;
@@ -807,7 +808,11 @@  struct mlx5_ct_entry {
 	attr->dest_chain = 0;
 	attr->dest_ft = mlx5e_tc_post_act_get_ft(ct_priv->post_act);
 	attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct;
-	attr->outer_match_level = MLX5_MATCH_L4;
+	if (entry->tuple.ip_proto == IPPROTO_TCP ||
+	    entry->tuple.ip_proto == IPPROTO_UDP)
+		attr->outer_match_level = MLX5_MATCH_L4;
+	else
+		attr->outer_match_level = MLX5_MATCH_L3;
 	attr->counter = entry->counter->counter;
 	attr->flags |= MLX5_ATTR_FLAG_NO_IN_PORT;
 	if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB)
@@ -1224,16 +1229,20 @@  static void mlx5_tc_ct_entry_del_work(struct work_struct *work)
 	struct flow_keys flow_keys;
 
 	skb_reset_network_header(skb);
-	skb_flow_dissect_flow_keys(skb, &flow_keys, 0);
+	skb_flow_dissect_flow_keys(skb, &flow_keys, FLOW_DISSECTOR_F_STOP_BEFORE_ENCAP);
 
 	tuple->zone = zone;
 
 	if (flow_keys.basic.ip_proto != IPPROTO_TCP &&
-	    flow_keys.basic.ip_proto != IPPROTO_UDP)
+	    flow_keys.basic.ip_proto != IPPROTO_UDP &&
+	    flow_keys.basic.ip_proto != IPPROTO_GRE)
 		return false;
 
-	tuple->port.src = flow_keys.ports.src;
-	tuple->port.dst = flow_keys.ports.dst;
+	if (flow_keys.basic.ip_proto == IPPROTO_TCP ||
+	    flow_keys.basic.ip_proto == IPPROTO_UDP) {
+		tuple->port.src = flow_keys.ports.src;
+		tuple->port.dst = flow_keys.ports.dst;
+	}
 	tuple->n_proto = flow_keys.basic.n_proto;
 	tuple->ip_proto = flow_keys.basic.ip_proto;