public inbox for netdev@vger.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>, Paolo Abeni <pabeni@redhat•com>,
	Eric Dumazet <edumazet@google•com>
Cc: Saeed Mahameed <saeedm@nvidia•com>,
	netdev@vger•kernel.org, Tariq Toukan <tariqt@nvidia•com>,
	Roi Dayan <roid@nvidia•com>, Maor Dickman <maord@nvidia•com>
Subject: [net-next 09/15] net/mlx5e: Don't use termination table when redundant
Date: Tue, 29 Nov 2022 21:11:46 -0800	[thread overview]
Message-ID: <20221130051152.479480-10-saeed@kernel.org> (raw)
In-Reply-To: <20221130051152.479480-1-saeed@kernel.org>

From: Roi Dayan <roid@nvidia•com>

Current code used termination table for each vport destination
while it's only required for hairpin, i.e. uplink to uplink, or
when vlan push on rx action being used.
Fix to skip using termination table for vport destinations that
do not require it.

Signed-off-by: Roi Dayan <roid@nvidia•com>
Reviewed-by: Maor Dickman <maord@nvidia•com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia•com>
---
 .../mlx5/core/eswitch_offloads_termtbl.c      | 32 ++++++++++++++++---
 1 file changed, 28 insertions(+), 4 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 edd910258314..3a9a6bb9158d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
@@ -210,6 +210,18 @@ static bool mlx5_eswitch_offload_is_uplink_port(const struct mlx5_eswitch *esw,
 	return (port_mask & port_value) == MLX5_VPORT_UPLINK;
 }
 
+static bool
+mlx5_eswitch_is_push_vlan_no_cap(struct mlx5_eswitch *esw,
+				 struct mlx5_flow_act *flow_act)
+{
+	if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH &&
+	    !(mlx5_fs_get_capabilities(esw->dev, MLX5_FLOW_NAMESPACE_FDB) &
+	      MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX))
+		return true;
+
+	return false;
+}
+
 bool
 mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
 			      struct mlx5_flow_attr *attr,
@@ -225,10 +237,7 @@ mlx5_eswitch_termtbl_required(struct mlx5_eswitch *esw,
 	    (!mlx5_eswitch_offload_is_uplink_port(esw, spec) && !esw_attr->int_port))
 		return false;
 
-	/* push vlan on RX */
-	if (flow_act->action & MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH &&
-	    !(mlx5_fs_get_capabilities(esw->dev, MLX5_FLOW_NAMESPACE_FDB) &
-	      MLX5_FLOW_STEERING_CAP_VLAN_PUSH_ON_RX))
+	if (mlx5_eswitch_is_push_vlan_no_cap(esw, flow_act))
 		return true;
 
 	/* hairpin */
@@ -252,19 +261,31 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
 	struct mlx5_flow_act term_tbl_act = {};
 	struct mlx5_flow_handle *rule = NULL;
 	bool term_table_created = false;
+	bool is_push_vlan_on_rx;
 	int num_vport_dests = 0;
 	int i, curr_dest;
 
+	is_push_vlan_on_rx = mlx5_eswitch_is_push_vlan_no_cap(esw, flow_act);
 	mlx5_eswitch_termtbl_actions_move(flow_act, &term_tbl_act);
 	term_tbl_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 
 	for (i = 0; i < num_dest; i++) {
 		struct mlx5_termtbl_handle *tt;
+		bool hairpin = false;
 
 		/* only vport destinations can be terminated */
 		if (dest[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
 			continue;
 
+		if (attr->dests[num_vport_dests].rep &&
+		    attr->dests[num_vport_dests].rep->vport == MLX5_VPORT_UPLINK)
+			hairpin = true;
+
+		if (!is_push_vlan_on_rx && !hairpin) {
+			num_vport_dests++;
+			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;
@@ -312,6 +333,9 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,
 	for (curr_dest = 0; curr_dest < num_vport_dests; curr_dest++) {
 		struct mlx5_termtbl_handle *tt = attr->dests[curr_dest].termtbl;
 
+		if (!tt)
+			continue;
+
 		attr->dests[curr_dest].termtbl = NULL;
 
 		/* search for the destination associated with the
-- 
2.38.1


  parent reply	other threads:[~2022-11-30  5:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  5:11 [pull request][net-next 00/15] mlx5 updates 2022-11-29 Saeed Mahameed
2022-11-30  5:11 ` [net-next 01/15] net/mlx5e: Remove unneeded io-mapping.h #include Saeed Mahameed
2022-12-01  6:40   ` patchwork-bot+netdevbpf
2022-11-30  5:11 ` [net-next 02/15] net/mlx5e: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper Saeed Mahameed
2022-11-30  5:11 ` [net-next 03/15] net/mlx5: Remove unused ctx variables Saeed Mahameed
2022-11-30  5:11 ` [net-next 04/15] net/mlx5e: Add padding when needed in UMR WQEs Saeed Mahameed
2022-11-30  5:11 ` [net-next 05/15] net/mlx5: Remove unused UMR MTT definitions Saeed Mahameed
2022-11-30  5:11 ` [net-next 06/15] net/mlx5: Generalize name of UMR alignment definition Saeed Mahameed
2022-11-30  5:11 ` [net-next 07/15] net/mlx5: Use generic definition for UMR KLM alignment Saeed Mahameed
2022-11-30  5:11 ` [net-next 08/15] net/mlx5: Fix orthography errors in documentation Saeed Mahameed
2022-11-30  5:11 ` Saeed Mahameed [this message]
2022-11-30  5:11 ` [net-next 10/15] net/mlx5e: Don't access directly DMA device pointer Saeed Mahameed
2022-11-30  5:11 ` [net-next 11/15] net/mlx5e: Delete always true DMA check Saeed Mahameed
2022-11-30  5:11 ` [net-next 12/15] net/mlx5: Remove redundant check Saeed Mahameed
2022-11-30  5:11 ` [net-next 13/15] net/mlx5e: Do early return when setup vports dests for slow path flow Saeed Mahameed
2022-11-30  5:11 ` [net-next 14/15] net/mlx5e: TC, Add offload support for trap with additional actions Saeed Mahameed
2022-11-30  5:11 ` [net-next 15/15] net/mlx5e: Support devlink reload of IPsec core 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=20221130051152.479480-10-saeed@kernel.org \
    --to=saeed@kernel$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=maord@nvidia$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=roid@nvidia$(echo .)com \
    --cc=saeedm@nvidia$(echo .)com \
    --cc=tariqt@nvidia$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox