Blame SOURCES/0142-netdrv-net-mlx5-fs_core-Introduce-unmanaged-flow-tab.patch

d8f823
From 033fa865cbce7eef7ccf369fa254ab03c8b6a2fc Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Tue, 12 May 2020 10:54:02 -0400
d8f823
Subject: [PATCH 142/312] [netdrv] net/mlx5: fs_core: Introduce unmanaged flow
d8f823
 tables
d8f823
d8f823
Message-id: <20200512105530.4207-37-ahleihel@redhat.com>
d8f823
Patchwork-id: 306908
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1789382 036/124] net/mlx5: fs_core: Introduce unmanaged flow tables
d8f823
Bugzilla: 1789382
d8f823
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
d8f823
RH-Acked-by: Kamal Heib <kheib@redhat.com>
d8f823
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
d8f823
d8f823
Bugzilla: http://bugzilla.redhat.com/1789382
d8f823
Upstream: v5.6-rc1
d8f823
d8f823
commit 5281a0c909194c477656e89401ac11dd7b29ad2d
d8f823
Author: Paul Blakey <paulb@mellanox.com>
d8f823
Date:   Tue Jul 23 11:43:57 2019 +0300
d8f823
d8f823
    net/mlx5: fs_core: Introduce unmanaged flow tables
d8f823
d8f823
    Currently, Most of the steering tree is statically declared ahead of time,
d8f823
    with steering prios instances allocated for each fdb chain to assign max
d8f823
    number of levels for each of them. This allows fs_core to manage the
d8f823
    connections and  levels of the flow tables hierarcy to prevent loops, but
d8f823
    restricts us with the number of supported chains and priorities.
d8f823
d8f823
    Introduce unmananged flow tables, allowing the user to manage the flow
d8f823
    table connections. A unamanged table is detached from the fs_core flow
d8f823
    table hierarcy, and is only connected back to the hierarchy by explicit
d8f823
    FTEs forward actions.
d8f823
d8f823
    This will be used together with firmware that supports ignoring the flow
d8f823
    table levels to increase the number of supported chains and prios.
d8f823
d8f823
    Signed-off-by: Paul Blakey <paulb@mellanox.com>
d8f823
    Reviewed-by: Roi Dayan <roid@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/fs_core.c | 41 ++++++++++++++++-------
d8f823
 include/linux/mlx5/fs.h                           |  2 ++
d8f823
 2 files changed, 31 insertions(+), 12 deletions(-)
d8f823
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
d8f823
index cb5f2643fecb..703799975f22 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
d8f823
@@ -1006,7 +1006,8 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
d8f823
 							u16 vport)
d8f823
 {
d8f823
 	struct mlx5_flow_root_namespace *root = find_root(&ns->node);
d8f823
-	struct mlx5_flow_table *next_ft = NULL;
d8f823
+	bool unmanaged = ft_attr->flags & MLX5_FLOW_TABLE_UNMANAGED;
d8f823
+	struct mlx5_flow_table *next_ft;
d8f823
 	struct fs_prio *fs_prio = NULL;
d8f823
 	struct mlx5_flow_table *ft;
d8f823
 	int log_table_sz;
d8f823
@@ -1023,14 +1024,21 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
d8f823
 		err = -EINVAL;
d8f823
 		goto unlock_root;
d8f823
 	}
d8f823
-	if (ft_attr->level >= fs_prio->num_levels) {
d8f823
-		err = -ENOSPC;
d8f823
-		goto unlock_root;
d8f823
+	if (!unmanaged) {
d8f823
+		/* The level is related to the
d8f823
+		 * priority level range.
d8f823
+		 */
d8f823
+		if (ft_attr->level >= fs_prio->num_levels) {
d8f823
+			err = -ENOSPC;
d8f823
+			goto unlock_root;
d8f823
+		}
d8f823
+
d8f823
+		ft_attr->level += fs_prio->start_level;
d8f823
 	}
d8f823
+
d8f823
 	/* The level is related to the
d8f823
 	 * priority level range.
d8f823
 	 */
d8f823
-	ft_attr->level += fs_prio->start_level;
d8f823
 	ft = alloc_flow_table(ft_attr->level,
d8f823
 			      vport,
d8f823
 			      ft_attr->max_fte ? roundup_pow_of_two(ft_attr->max_fte) : 0,
d8f823
@@ -1043,19 +1051,27 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
d8f823
 
d8f823
 	tree_init_node(&ft->node, del_hw_flow_table, del_sw_flow_table);
d8f823
 	log_table_sz = ft->max_fte ? ilog2(ft->max_fte) : 0;
d8f823
-	next_ft = find_next_chained_ft(fs_prio);
d8f823
+	next_ft = unmanaged ? ft_attr->next_ft :
d8f823
+			      find_next_chained_ft(fs_prio);
d8f823
 	ft->def_miss_action = ns->def_miss_action;
d8f823
 	err = root->cmds->create_flow_table(root, ft, log_table_sz, next_ft);
d8f823
 	if (err)
d8f823
 		goto free_ft;
d8f823
 
d8f823
-	err = connect_flow_table(root->dev, ft, fs_prio);
d8f823
-	if (err)
d8f823
-		goto destroy_ft;
d8f823
+	if (!unmanaged) {
d8f823
+		err = connect_flow_table(root->dev, ft, fs_prio);
d8f823
+		if (err)
d8f823
+			goto destroy_ft;
d8f823
+	}
d8f823
+
d8f823
 	ft->node.active = true;
d8f823
 	down_write_ref_node(&fs_prio->node, false);
d8f823
-	tree_add_node(&ft->node, &fs_prio->node);
d8f823
-	list_add_flow_table(ft, fs_prio);
d8f823
+	if (!unmanaged) {
d8f823
+		tree_add_node(&ft->node, &fs_prio->node);
d8f823
+		list_add_flow_table(ft, fs_prio);
d8f823
+	} else {
d8f823
+		ft->node.root = fs_prio->node.root;
d8f823
+	}
d8f823
 	fs_prio->num_ft++;
d8f823
 	up_write_ref_node(&fs_prio->node, false);
d8f823
 	mutex_unlock(&root->chain_lock);
d8f823
@@ -2044,7 +2060,8 @@ int mlx5_destroy_flow_table(struct mlx5_flow_table *ft)
d8f823
 	int err = 0;
d8f823
 
d8f823
 	mutex_lock(&root->chain_lock);
d8f823
-	err = disconnect_flow_table(ft);
d8f823
+	if (!(ft->flags & MLX5_FLOW_TABLE_UNMANAGED))
d8f823
+		err = disconnect_flow_table(ft);
d8f823
 	if (err) {
d8f823
 		mutex_unlock(&root->chain_lock);
d8f823
 		return err;
d8f823
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
d8f823
index a9de8e28ae6f..72bc6585f732 100644
d8f823
--- a/include/linux/mlx5/fs.h
d8f823
+++ b/include/linux/mlx5/fs.h
d8f823
@@ -48,6 +48,7 @@ enum {
d8f823
 	MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT = BIT(0),
d8f823
 	MLX5_FLOW_TABLE_TUNNEL_EN_DECAP = BIT(1),
d8f823
 	MLX5_FLOW_TABLE_TERMINATION = BIT(2),
d8f823
+	MLX5_FLOW_TABLE_UNMANAGED = BIT(3),
d8f823
 };
d8f823
 
d8f823
 #define LEFTOVERS_RULE_NUM	 2
d8f823
@@ -160,6 +161,7 @@ struct mlx5_flow_table_attr {
d8f823
 	int max_fte;
d8f823
 	u32 level;
d8f823
 	u32 flags;
d8f823
+	struct mlx5_flow_table *next_ft;
d8f823
 
d8f823
 	struct {
d8f823
 		int max_num_groups;
d8f823
-- 
d8f823
2.13.6
d8f823