Blame SOURCES/0240-netdrv-net-mlx5-E-Switch-Introduce-global-tables.patch

d8f823
From a56298693c73f43b0b603c702eeb66b4c80ba6fb Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Tue, 19 May 2020 07:49:02 -0400
d8f823
Subject: [PATCH 240/312] [netdrv] net/mlx5: E-Switch, Introduce global tables
d8f823
d8f823
Message-id: <20200519074934.6303-32-ahleihel@redhat.com>
d8f823
Patchwork-id: 310534
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1663246 31/63] net/mlx5: E-Switch, Introduce global tables
d8f823
Bugzilla: 1790219 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
Upstream: v5.7-rc1
d8f823
d8f823
commit d18296ffd9ccde82c82c220263fca2e76d5258be
d8f823
Author: Paul Blakey <paulb@mellanox.com>
d8f823
Date:   Thu Mar 12 12:23:10 2020 +0200
d8f823
d8f823
    net/mlx5: E-Switch, Introduce global tables
d8f823
d8f823
    Currently, flow tables are automatically connected according to their
d8f823
    <chain,prio,level> tuple.
d8f823
d8f823
    Introduce global tables which are flow tables that are detached from the
d8f823
    eswitch chains processing, and will be connected by explicitly referencing
d8f823
    them from multiple chains.
d8f823
d8f823
    Add this new table type, and allow connecting them by refenece.
d8f823
d8f823
    Signed-off-by: Paul Blakey <paulb@mellanox.com>
d8f823
    Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
d8f823
    Signed-off-by: David S. Miller <davem@davemloft.net>
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  |  2 ++
d8f823
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 18 +++++++++----
d8f823
 .../mellanox/mlx5/core/eswitch_offloads_chains.c   | 30 ++++++++++++++++++++++
d8f823
 .../mellanox/mlx5/core/eswitch_offloads_chains.h   |  6 +++++
d8f823
 4 files changed, 51 insertions(+), 5 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 ccb4f0f566ea..e7de5e8e5605 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
d8f823
@@ -462,6 +462,8 @@ struct mlx5_esw_flow_attr {
d8f823
 	u32	dest_chain;
d8f823
 #ifndef __GENKSYMS__
d8f823
 	u32	flags;
d8f823
+	struct mlx5_flow_table *fdb;
d8f823
+	struct mlx5_flow_table *dest_ft;
d8f823
 #endif
d8f823
 	struct mlx5e_tc_flow_parse_attr *parse_attr;
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 da5730c8c3fb..e8d9a0bd943a 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
d8f823
@@ -324,7 +324,12 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
d8f823
 	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
d8f823
 		struct mlx5_flow_table *ft;
d8f823
 
d8f823
-		if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
d8f823
+		if (attr->dest_ft) {
d8f823
+			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
d8f823
+			dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
d8f823
+			dest[i].ft = attr->dest_ft;
d8f823
+			i++;
d8f823
+		} else if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
d8f823
 			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
d8f823
 			dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
d8f823
 			dest[i].ft = mlx5_esw_chains_get_tc_end_ft(esw);
d8f823
@@ -378,8 +383,11 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
d8f823
 	if (split) {
d8f823
 		fdb = esw_vport_tbl_get(esw, attr);
d8f823
 	} else {
d8f823
-		fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio,
d8f823
-						0);
d8f823
+		if (attr->chain || attr->prio)
d8f823
+			fdb = mlx5_esw_chains_get_table(esw, attr->chain,
d8f823
+							attr->prio, 0);
d8f823
+		else
d8f823
+			fdb = attr->fdb;
d8f823
 		mlx5_eswitch_set_rule_source_port(esw, spec, attr);
d8f823
 	}
d8f823
 	if (IS_ERR(fdb)) {
d8f823
@@ -402,7 +410,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
d8f823
 err_add_rule:
d8f823
 	if (split)
d8f823
 		esw_vport_tbl_put(esw, attr);
d8f823
-	else
d8f823
+	else if (attr->chain || attr->prio)
d8f823
 		mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, 0);
d8f823
 err_esw_get:
d8f823
 	if (!(attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) && attr->dest_chain)
d8f823
@@ -499,7 +507,7 @@ __mlx5_eswitch_del_rule(struct mlx5_eswitch *esw,
d8f823
 	} else {
d8f823
 		if (split)
d8f823
 			esw_vport_tbl_put(esw, attr);
d8f823
-		else
d8f823
+		else if (attr->chain || attr->prio)
d8f823
 			mlx5_esw_chains_put_table(esw, attr->chain, attr->prio,
d8f823
 						  0);
d8f823
 		if (attr->dest_chain)
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c
d8f823
index 12ca184cd795..6f62a326071a 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c
d8f823
@@ -719,6 +719,36 @@ mlx5_esw_chains_get_tc_end_ft(struct mlx5_eswitch *esw)
d8f823
 	return tc_end_fdb(esw);
d8f823
 }
d8f823
 
d8f823
+struct mlx5_flow_table *
d8f823
+mlx5_esw_chains_create_global_table(struct mlx5_eswitch *esw)
d8f823
+{
d8f823
+	int chain, prio, level, err;
d8f823
+
d8f823
+	if (!fdb_ignore_flow_level_supported(esw)) {
d8f823
+		err = -EOPNOTSUPP;
d8f823
+
d8f823
+		esw_warn(esw->dev,
d8f823
+			 "Couldn't create global flow table, ignore_flow_level not supported.");
d8f823
+		goto err_ignore;
d8f823
+	}
d8f823
+
d8f823
+	chain = mlx5_esw_chains_get_chain_range(esw),
d8f823
+	prio = mlx5_esw_chains_get_prio_range(esw);
d8f823
+	level = mlx5_esw_chains_get_level_range(esw);
d8f823
+
d8f823
+	return mlx5_esw_chains_create_fdb_table(esw, chain, prio, level);
d8f823
+
d8f823
+err_ignore:
d8f823
+	return ERR_PTR(err);
d8f823
+}
d8f823
+
d8f823
+void
d8f823
+mlx5_esw_chains_destroy_global_table(struct mlx5_eswitch *esw,
d8f823
+				     struct mlx5_flow_table *ft)
d8f823
+{
d8f823
+	mlx5_esw_chains_destroy_fdb_table(esw, ft);
d8f823
+}
d8f823
+
d8f823
 static int
d8f823
 mlx5_esw_chains_init(struct mlx5_eswitch *esw)
d8f823
 {
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h
d8f823
index e806d8de868e..c7bc609acb91 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h
d8f823
@@ -25,6 +25,12 @@ mlx5_esw_chains_put_table(struct mlx5_eswitch *esw, u32 chain, u32 prio,
d8f823
 struct mlx5_flow_table *
d8f823
 mlx5_esw_chains_get_tc_end_ft(struct mlx5_eswitch *esw);
d8f823
 
d8f823
+struct mlx5_flow_table *
d8f823
+mlx5_esw_chains_create_global_table(struct mlx5_eswitch *esw);
d8f823
+void
d8f823
+mlx5_esw_chains_destroy_global_table(struct mlx5_eswitch *esw,
d8f823
+				     struct mlx5_flow_table *ft);
d8f823
+
d8f823
 int mlx5_esw_chains_create(struct mlx5_eswitch *esw);
d8f823
 void mlx5_esw_chains_destroy(struct mlx5_eswitch *esw);
d8f823
 
d8f823
-- 
d8f823
2.13.6
d8f823