Blame SOURCES/0236-netdrv-net-mlx5-E-Switch-Get-reg_c1-value-on-miss.patch

d8f823
From 28d18d2bc0d56e447a0adeebc3e48b7da6890b2a Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Tue, 19 May 2020 07:48:58 -0400
d8f823
Subject: [PATCH 236/312] [netdrv] net/mlx5: E-Switch, Get reg_c1 value on miss
d8f823
d8f823
Message-id: <20200519074934.6303-28-ahleihel@redhat.com>
d8f823
Patchwork-id: 310530
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1663246 27/63] net/mlx5: E-Switch, Get reg_c1 value on miss
d8f823
Bugzilla: 1790219 1790218 1663246
d8f823
RH-Acked-by: Marcelo Leitner <mleitner@redhat.com>
d8f823
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
d8f823
RH-Acked-by: John Linville <linville@redhat.com>
d8f823
RH-Acked-by: Ivan Vecera <ivecera@redhat.com>
d8f823
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
d8f823
RH-Acked-by: Kamal Heib <kheib@redhat.com>
d8f823
d8f823
Bugzilla: http://bugzilla.redhat.com/1663246
d8f823
Bugzilla: http://bugzilla.redhat.com/1790219
d8f823
Bugzilla: http://bugzilla.redhat.com/1790218
d8f823
Upstream: v5.7-rc1
d8f823
d8f823
commit 6724e66b90eebb19d146b7623b3e2af15616782b
d8f823
Author: Paul Blakey <paulb@mellanox.com>
d8f823
Date:   Sun Feb 16 12:01:35 2020 +0200
d8f823
d8f823
    net/mlx5: E-Switch, Get reg_c1 value on miss
d8f823
d8f823
    The HW model implicitly decapsulates tunnels on chain 0 and sets reg_c1
d8f823
    with the mapped tunnel id. On miss, the packet does not have the outer
d8f823
    header and the driver restores the tunnel information from the tunnel id.
d8f823
d8f823
    Getting reg_c1 value in software requires enabling reg_c1 loopback and
d8f823
    copying reg_c1 to reg_b. reg_b comes up on CQE as cqe->imm_inval_pkey.
d8f823
d8f823
    Use the reg_c0 restoration rules to also copy reg_c1 to reg_B.
d8f823
d8f823
    Signed-off-by: Paul Blakey <paulb@mellanox.com>
d8f823
    Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
d8f823
    Reviewed-by: Mark Bloch <markb@mellanox.com>
d8f823
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
d8f823
d8f823
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
d8f823
---
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  |  1 +
d8f823
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 31 +++++++++++++++++++---
d8f823
 2 files changed, 29 insertions(+), 3 deletions(-)
d8f823
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
d8f823
index a384cab195c1..3240f6de94bd 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
d8f823
@@ -233,6 +233,7 @@ struct mlx5_esw_offload {
d8f823
 #ifndef __GENKSYMS__
d8f823
 	struct mlx5_flow_table *ft_offloads_restore;
d8f823
 	struct mlx5_flow_group *restore_group;
d8f823
+	struct mlx5_modify_hdr *restore_copy_hdr_id;
d8f823
 #endif
d8f823
 
d8f823
 	struct mlx5_flow_table *ft_offloads;
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
d8f823
index eab876a2208a..a9b2522b9f03 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
d8f823
@@ -782,9 +782,11 @@ static int esw_set_passing_vport_metadata(struct mlx5_eswitch *esw, bool enable)
d8f823
 					 esw_vport_context.fdb_to_vport_reg_c_id);
d8f823
 
d8f823
 	if (enable)
d8f823
-		fdb_to_vport_reg_c_id |= MLX5_FDB_TO_VPORT_REG_C_0;
d8f823
+		fdb_to_vport_reg_c_id |= MLX5_FDB_TO_VPORT_REG_C_0 |
d8f823
+					 MLX5_FDB_TO_VPORT_REG_C_1;
d8f823
 	else
d8f823
-		fdb_to_vport_reg_c_id &= ~MLX5_FDB_TO_VPORT_REG_C_0;
d8f823
+		fdb_to_vport_reg_c_id &= ~(MLX5_FDB_TO_VPORT_REG_C_0 |
d8f823
+					   MLX5_FDB_TO_VPORT_REG_C_1);
d8f823
 
d8f823
 	MLX5_SET(modify_esw_vport_context_in, in,
d8f823
 		 esw_vport_context.fdb_to_vport_reg_c_id, fdb_to_vport_reg_c_id);
d8f823
@@ -1045,7 +1047,9 @@ esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)
d8f823
 			    misc_parameters_2);
d8f823
 	MLX5_SET(fte_match_set_misc2, misc, metadata_reg_c_0, tag);
d8f823
 	spec->match_criteria_enable = MLX5_MATCH_MISC_PARAMETERS_2;
d8f823
-	flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
d8f823
+	flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
d8f823
+			  MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
d8f823
+	flow_act.modify_hdr = esw->offloads.restore_copy_hdr_id;
d8f823
 
d8f823
 	flow_context = &spec->flow_context;
d8f823
 	flow_context->flags |= FLOW_CONTEXT_HAS_TAG;
d8f823
@@ -1404,16 +1408,19 @@ static void esw_destroy_restore_table(struct mlx5_eswitch *esw)
d8f823
 {
d8f823
 	struct mlx5_esw_offload *offloads = &esw->offloads;
d8f823
 
d8f823
+	mlx5_modify_header_dealloc(esw->dev, offloads->restore_copy_hdr_id);
d8f823
 	mlx5_destroy_flow_group(offloads->restore_group);
d8f823
 	mlx5_destroy_flow_table(offloads->ft_offloads_restore);
d8f823
 }
d8f823
 
d8f823
 static int esw_create_restore_table(struct mlx5_eswitch *esw)
d8f823
 {
d8f823
+	u8 modact[MLX5_UN_SZ_BYTES(set_action_in_add_action_in_auto)] = {};
d8f823
 	int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
d8f823
 	struct mlx5_flow_table_attr ft_attr = {};
d8f823
 	struct mlx5_core_dev *dev = esw->dev;
d8f823
 	struct mlx5_flow_namespace *ns;
d8f823
+	struct mlx5_modify_hdr *mod_hdr;
d8f823
 	void *match_criteria, *misc;
d8f823
 	struct mlx5_flow_table *ft;
d8f823
 	struct mlx5_flow_group *g;
d8f823
@@ -1462,11 +1469,29 @@ static int esw_create_restore_table(struct mlx5_eswitch *esw)
d8f823
 		goto err_group;
d8f823
 	}
d8f823
 
d8f823
+	MLX5_SET(copy_action_in, modact, action_type, MLX5_ACTION_TYPE_COPY);
d8f823
+	MLX5_SET(copy_action_in, modact, src_field,
d8f823
+		 MLX5_ACTION_IN_FIELD_METADATA_REG_C_1);
d8f823
+	MLX5_SET(copy_action_in, modact, dst_field,
d8f823
+		 MLX5_ACTION_IN_FIELD_METADATA_REG_B);
d8f823
+	mod_hdr = mlx5_modify_header_alloc(esw->dev,
d8f823
+					   MLX5_FLOW_NAMESPACE_KERNEL, 1,
d8f823
+					   modact);
d8f823
+	if (IS_ERR(mod_hdr)) {
d8f823
+		esw_warn(dev, "Failed to create restore mod header, err: %d\n",
d8f823
+			 err);
d8f823
+		err = PTR_ERR(mod_hdr);
d8f823
+		goto err_mod_hdr;
d8f823
+	}
d8f823
+
d8f823
 	esw->offloads.ft_offloads_restore = ft;
d8f823
 	esw->offloads.restore_group = g;
d8f823
+	esw->offloads.restore_copy_hdr_id = mod_hdr;
d8f823
 
d8f823
 	return 0;
d8f823
 
d8f823
+err_mod_hdr:
d8f823
+	mlx5_destroy_flow_group(g);
d8f823
 err_group:
d8f823
 	mlx5_destroy_flow_table(ft);
d8f823
 out_free:
d8f823
-- 
d8f823
2.13.6
d8f823