All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>,
	Jianbo Liu <jianbol@nvidia.com>,
	Ariel Levkovich <lariel@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net 03/16] net/mlx5: Set reformat action when needed for termination rules
Date: Tue, 18 May 2021 23:05:10 -0700	[thread overview]
Message-ID: <20210519060523.17875-4-saeed@kernel.org> (raw)
In-Reply-To: <20210519060523.17875-1-saeed@kernel.org>

From: Jianbo Liu <jianbol@nvidia.com>

For remote mirroring, after the tunnel packets are received, they are
decapsulated and sent to representor, then re-encapsulated and sent
out over another tunnel. So reformat action is set only when the
destination is required to do encapsulation.

Fixes: 249ccc3c95bd ("net/mlx5e: Add support for offloading traffic from uplink to uplink")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Ariel Levkovich <lariel@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../mlx5/core/eswitch_offloads_termtbl.c      | 31 ++++++-------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
index a81ece94f599..e3e7fdd396ad 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
@@ -172,19 +172,6 @@ mlx5_eswitch_termtbl_put(struct mlx5_eswitch *esw,
 	}
 }
 
-static bool mlx5_eswitch_termtbl_is_encap_reformat(struct mlx5_pkt_reformat *rt)
-{
-	switch (rt->reformat_type) {
-	case MLX5_REFORMAT_TYPE_L2_TO_VXLAN:
-	case MLX5_REFORMAT_TYPE_L2_TO_NVGRE:
-	case MLX5_REFORMAT_TYPE_L2_TO_L2_TUNNEL:
-	case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL:
-		return true;
-	default:
-		return false;
-	}
-}
-
 static void
 mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,
 				  struct mlx5_flow_act *dst)
@@ -202,14 +189,6 @@ mlx5_eswitch_termtbl_actions_move(struct mlx5_flow_act *src,
 			memset(&src->vlan[1], 0, sizeof(src->vlan[1]));
 		}
 	}
-
-	if (src->action & MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT &&
-	    mlx5_eswitch_termtbl_is_encap_reformat(src->pkt_reformat)) {
-		src->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
-		dst->action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
-		dst->pkt_reformat = src->pkt_reformat;
-		src->pkt_reformat = NULL;
-	}
 }
 
 static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
@@ -279,6 +258,14 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
 		if (dest[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
 			continue;
 
+		if (attr->dests[num_vport_dests].flags & MLX5_ESW_DEST_ENCAP) {
+			term_tbl_act.action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
+			term_tbl_act.pkt_reformat = attr->dests[num_vport_dests].pkt_reformat;
+		} else {
+			term_tbl_act.action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
+			term_tbl_act.pkt_reformat = NULL;
+		}
+
 		/* get the terminating table for the action list */
 		tt = mlx5_eswitch_termtbl_get_create(esw, &term_tbl_act,
 						     &dest[i], attr);
@@ -301,6 +288,8 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
 		goto revert_changes;
 
 	/* create the FTE */
+	flow_act->action &= ~MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT;
+	flow_act->pkt_reformat = NULL;
 	rule = mlx5_add_flow_rules(fdb, spec, flow_act, dest, num_dest);
 	if (IS_ERR(rule))
 		goto revert_changes;
-- 
2.31.1


  parent reply	other threads:[~2021-05-19  6:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  6:05 [pull request][net 00/16] mlx5 fixes 2021-05-18 Saeed Mahameed
2021-05-19  6:05 ` [net 01/16] {net, RDMA}/mlx5: Fix override of log_max_qp by other device Saeed Mahameed
2021-05-19 19:30   ` patchwork-bot+netdevbpf
2021-05-19  6:05 ` [net 02/16] net/mlx5e: Fix nullptr in add_vlan_push_action() Saeed Mahameed
2021-05-19  6:05 ` Saeed Mahameed [this message]
2021-05-19  6:05 ` [net 04/16] net/mlx5: Fix err prints and return when creating termination table Saeed Mahameed
2021-05-19  6:05 ` [net 05/16] net/mlx5: SF, Fix show state inactive when its inactivated Saeed Mahameed
2021-05-19  6:05 ` [net 06/16] net/mlx5e: Fix nullptr in mlx5e_tc_add_fdb_flow() Saeed Mahameed
2021-05-19  6:05 ` [net 07/16] net/mlx5e: Fix null deref accessing lag dev Saeed Mahameed
2021-05-19  6:05 ` [net 08/16] net/mlx5e: Make sure fib dev exists in fib event Saeed Mahameed
2021-05-19  6:05 ` [net 09/16] net/mlx5e: reset XPS on error flow if netdev isn't registered yet Saeed Mahameed
2021-05-19  6:05 ` [net 10/16] net/mlx5e: Fix multipath lag activation Saeed Mahameed
2021-05-19  6:05 ` [net 11/16] net/mlx5e: Reject mirroring on source port change encap rules Saeed Mahameed
2021-05-19  6:05 ` [net 12/16] net/mlx5e: Fix error path of updating netdev queues Saeed Mahameed
2021-05-19  6:05 ` [net 13/16] {net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table Saeed Mahameed
2021-05-19  6:05 ` [net 14/16] net/mlx5: Don't overwrite HCA capabilities when setting MSI-X count Saeed Mahameed
2021-05-19  6:05 ` [net 15/16] net/mlx5: Set term table as an unmanaged flow table Saeed Mahameed
2021-05-19  6:05 ` [net 16/16] mlx5e: add add missing BH locking around napi_schdule() Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210519060523.17875-4-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jianbol@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=lariel@nvidia.com \
    --cc=leonro@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.