Blame SOURCES/0252-netdrv-net-mlx5-E-Switch-Enable-restore-table-only-i.patch

d8f823
From 3277bd11a6f6e94fef4fa83f1d7e4da1d3f66a8a Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Tue, 19 May 2020 07:49:14 -0400
d8f823
Subject: [PATCH 252/312] [netdrv] net/mlx5: E-Switch, Enable restore table
d8f823
 only if reg_c1 is supported
d8f823
d8f823
Message-id: <20200519074934.6303-44-ahleihel@redhat.com>
d8f823
Patchwork-id: 310545
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1663246 43/63] net/mlx5: E-Switch, Enable restore table only if reg_c1 is supported
d8f823
Bugzilla: 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
Upstream: v5.7-rc1
d8f823
d8f823
commit 60acc105cbc23c525ddb6fed595cac4796c0040b
d8f823
Author: Paul Blakey <paulb@mellanox.com>
d8f823
Date:   Wed Mar 18 10:55:12 2020 +0200
d8f823
d8f823
    net/mlx5: E-Switch, Enable restore table only if reg_c1 is supported
d8f823
d8f823
    Reg c0/c1 matching, rewrite of regs c0/c1, and copy header of regs c1,B
d8f823
    is needed for the restore table to function, might not be supported by
d8f823
    firmware, and creation of the restore table or the copy header will
d8f823
    fail.
d8f823
d8f823
    Check reg_c1 loopback support, as firmware which supports this,
d8f823
    should have all of the above.
d8f823
d8f823
    Fixes: 11b717d61526 ("net/mlx5: E-Switch, Get reg_c0 value on CQE")
d8f823
    Signed-off-by: Paul Blakey <paulb@mellanox.com>
d8f823
    Reviewed-by: Roi Dayan <roid@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_offloads.c | 9 +++++++++
d8f823
 1 file changed, 9 insertions(+)
d8f823
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 02340328f11b..0c49033a3e73 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
d8f823
@@ -1061,6 +1061,9 @@ esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)
d8f823
 	struct mlx5_flow_spec *spec;
d8f823
 	void *misc;
d8f823
 
d8f823
+	if (!mlx5_eswitch_reg_c1_loopback_supported(esw))
d8f823
+		return ERR_PTR(-EOPNOTSUPP);
d8f823
+
d8f823
 	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
d8f823
 	if (!spec)
d8f823
 		return ERR_PTR(-ENOMEM);
d8f823
@@ -1434,6 +1437,9 @@ static void esw_destroy_restore_table(struct mlx5_eswitch *esw)
d8f823
 {
d8f823
 	struct mlx5_esw_offload *offloads = &esw->offloads;
d8f823
 
d8f823
+	if (!mlx5_eswitch_reg_c1_loopback_supported(esw))
d8f823
+		return;
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
@@ -1453,6 +1459,9 @@ static int esw_create_restore_table(struct mlx5_eswitch *esw)
d8f823
 	u32 *flow_group_in;
d8f823
 	int err = 0;
d8f823
 
d8f823
+	if (!mlx5_eswitch_reg_c1_loopback_supported(esw))
d8f823
+		return 0;
d8f823
+
d8f823
 	ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_OFFLOADS);
d8f823
 	if (!ns) {
d8f823
 		esw_warn(esw->dev, "Failed to get offloads flow namespace\n");
d8f823
-- 
d8f823
2.13.6
d8f823