netdev.vger.kernel.org archive mirror
 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>,
	Jianbo Liu <jianbol@nvidia.com>
Subject: [net-next 06/14] net/mlx5: E-switch, Add checking for flow rule destinations
Date: Mon, 14 Aug 2023 14:41:36 -0700	[thread overview]
Message-ID: <20230814214144.159464-7-saeed@kernel.org> (raw)
In-Reply-To: <20230814214144.159464-1-saeed@kernel.org>

From: Jianbo Liu <jianbol@nvidia.com>

Firmware doesn't allow flow rules in FDB to do header rewrite and send
packets to both internal and uplink vports. The following syndrome
will be generated when trying to offload such kind of rules:

mlx5_core 0000:08:00.0: mlx5_cmd_out_err:803:(pid 23569): SET_FLOW_TABLE_ENTRY(0x936) op_mod(0x0) failed, status bad parameter(0x3), syndrome (0x8c8f08), err(-22)

To avoid this syndrome, add a checking before creating FTE. If a rule
with header rewrite action forwards packets to both VF and PF, an
error is returned directly.

Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../mellanox/mlx5/core/eswitch_offloads.c     | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index e391535e1ab1..46b8c60ac39a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -535,6 +535,28 @@ esw_src_port_rewrite_supported(struct mlx5_eswitch *esw)
 	       MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ignore_flow_level);
 }
 
+static bool
+esw_dests_to_vf_pf_vports(struct mlx5_flow_destination *dests, int max_dest)
+{
+	bool vf_dest = false, pf_dest = false;
+	int i;
+
+	for (i = 0; i < max_dest; i++) {
+		if (dests[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
+			continue;
+
+		if (dests[i].vport.num == MLX5_VPORT_UPLINK)
+			pf_dest = true;
+		else
+			vf_dest = true;
+
+		if (vf_dest && pf_dest)
+			return true;
+	}
+
+	return false;
+}
+
 static int
 esw_setup_dests(struct mlx5_flow_destination *dest,
 		struct mlx5_flow_act *flow_act,
@@ -671,6 +693,15 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
 			rule = ERR_PTR(err);
 			goto err_create_goto_table;
 		}
+
+		/* Header rewrite with combined wire+loopback in FDB is not allowed */
+		if ((flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) &&
+		    esw_dests_to_vf_pf_vports(dest, i)) {
+			esw_warn(esw->dev,
+				 "FDB: Header rewrite with forwarding to both PF and VF is not allowed\n");
+			rule = ERR_PTR(-EINVAL);
+			goto err_esw_get;
+		}
 	}
 
 	if (esw_attr->decap_pkt_reformat)
-- 
2.41.0


  parent reply	other threads:[~2023-08-14 21:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14 21:41 [pull request][net-next 00/14] mlx5 updates 2023-08-14 Saeed Mahameed
2023-08-14 21:41 ` [net-next 01/14] net/mlx5: Consolidate devlink documentation in devlink/mlx5.rst Saeed Mahameed
2023-08-16  2:40   ` patchwork-bot+netdevbpf
2023-08-14 21:41 ` [net-next 02/14] net/mlx5e: Make tx_port_ts logic resilient to out-of-order CQEs Saeed Mahameed
2023-08-14 21:41 ` [net-next 03/14] net/mlx5e: Add recovery flow for tx devlink health reporter for unhealthy PTP SQ Saeed Mahameed
2023-08-14 21:41 ` [net-next 04/14] net/mlx5: Expose max possible SFs via devlink resource Saeed Mahameed
2023-08-14 21:41 ` [net-next 05/14] net/mlx5: Check with FW that sync reset completed successfully Saeed Mahameed
2023-08-14 21:41 ` Saeed Mahameed [this message]
2023-08-14 21:41 ` [net-next 07/14] net/mlx5: Use auxiliary_device_uninit() instead of device_put() Saeed Mahameed
2023-08-14 21:41 ` [net-next 08/14] net/mlx5: Remove redundant SF supported check from mlx5_sf_hw_table_init() Saeed Mahameed
2023-08-14 21:41 ` [net-next 09/14] net/mlx5: Use mlx5_sf_start_function_id() helper instead of directly calling MLX5_CAP_GEN() Saeed Mahameed
2023-08-14 21:41 ` [net-next 10/14] net/mlx5: Remove redundant check of mlx5_vhca_event_supported() Saeed Mahameed
2023-08-14 21:41 ` [net-next 11/14] net/mlx5: Fix error message in mlx5_sf_dev_state_change_handler() Saeed Mahameed
2023-08-14 21:41 ` [net-next 12/14] net/mlx5: Remove unused CAPs Saeed Mahameed
2023-08-14 21:41 ` [net-next 13/14] net/mlx5: Remove unused MAX HCA capabilities Saeed Mahameed
2023-08-14 21:41 ` [net-next 14/14] net/mlx5: Don't query MAX caps twice 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=20230814214144.159464-7-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jianbol@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).