Commit 618d28a5 authored by Jianbo Liu's avatar Jianbo Liu Committed by Jakub Kicinski

net/mlx5: fs_core: Make find_closest_ft more generic

As find_closest_ft_recursive is called to find the closest FT, the
first parameter of find_closest_ft can be changed from fs_prio to
fs_node. Thus this function is extended to find the closest FT for the
nodes of any type, not only prios, but also the sub namespaces.
Signed-off-by: default avatarJianbo Liu <jianbol@nvidia.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/d3962c2b443ec8dde7a740dc742a1f052d5e256c.1690803944.git.leonro@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 0756384f
...@@ -905,18 +905,17 @@ static struct mlx5_flow_table *find_closest_ft_recursive(struct fs_node *root, ...@@ -905,18 +905,17 @@ static struct mlx5_flow_table *find_closest_ft_recursive(struct fs_node *root,
return ft; return ft;
} }
/* If reverse is false then return the first flow table in next priority of /* If reverse is false then return the first flow table next to the passed node
* prio in the tree, else return the last flow table in the previous priority * in the tree, else return the last flow table before the node in the tree.
* of prio in the tree.
*/ */
static struct mlx5_flow_table *find_closest_ft(struct fs_prio *prio, bool reverse) static struct mlx5_flow_table *find_closest_ft(struct fs_node *node, bool reverse)
{ {
struct mlx5_flow_table *ft = NULL; struct mlx5_flow_table *ft = NULL;
struct fs_node *curr_node; struct fs_node *curr_node;
struct fs_node *parent; struct fs_node *parent;
parent = prio->node.parent; parent = node->parent;
curr_node = &prio->node; curr_node = node;
while (!ft && parent) { while (!ft && parent) {
ft = find_closest_ft_recursive(parent, &curr_node->list, reverse); ft = find_closest_ft_recursive(parent, &curr_node->list, reverse);
curr_node = parent; curr_node = parent;
...@@ -926,15 +925,15 @@ static struct mlx5_flow_table *find_closest_ft(struct fs_prio *prio, bool revers ...@@ -926,15 +925,15 @@ static struct mlx5_flow_table *find_closest_ft(struct fs_prio *prio, bool revers
} }
/* Assuming all the tree is locked by mutex chain lock */ /* Assuming all the tree is locked by mutex chain lock */
static struct mlx5_flow_table *find_next_chained_ft(struct fs_prio *prio) static struct mlx5_flow_table *find_next_chained_ft(struct fs_node *node)
{ {
return find_closest_ft(prio, false); return find_closest_ft(node, false);
} }
/* Assuming all the tree is locked by mutex chain lock */ /* Assuming all the tree is locked by mutex chain lock */
static struct mlx5_flow_table *find_prev_chained_ft(struct fs_prio *prio) static struct mlx5_flow_table *find_prev_chained_ft(struct fs_node *node)
{ {
return find_closest_ft(prio, true); return find_closest_ft(node, true);
} }
static struct mlx5_flow_table *find_next_fwd_ft(struct mlx5_flow_table *ft, static struct mlx5_flow_table *find_next_fwd_ft(struct mlx5_flow_table *ft,
...@@ -946,7 +945,7 @@ static struct mlx5_flow_table *find_next_fwd_ft(struct mlx5_flow_table *ft, ...@@ -946,7 +945,7 @@ static struct mlx5_flow_table *find_next_fwd_ft(struct mlx5_flow_table *ft,
next_ns = flow_act->action & MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS; next_ns = flow_act->action & MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS;
fs_get_obj(prio, next_ns ? ft->ns->node.parent : ft->node.parent); fs_get_obj(prio, next_ns ? ft->ns->node.parent : ft->node.parent);
return find_next_chained_ft(prio); return find_next_chained_ft(&prio->node);
} }
static int connect_fts_in_prio(struct mlx5_core_dev *dev, static int connect_fts_in_prio(struct mlx5_core_dev *dev,
...@@ -977,7 +976,7 @@ static int connect_prev_fts(struct mlx5_core_dev *dev, ...@@ -977,7 +976,7 @@ static int connect_prev_fts(struct mlx5_core_dev *dev,
{ {
struct mlx5_flow_table *prev_ft; struct mlx5_flow_table *prev_ft;
prev_ft = find_prev_chained_ft(prio); prev_ft = find_prev_chained_ft(&prio->node);
if (prev_ft) { if (prev_ft) {
struct fs_prio *prev_prio; struct fs_prio *prev_prio;
...@@ -1123,7 +1122,7 @@ static int connect_flow_table(struct mlx5_core_dev *dev, struct mlx5_flow_table ...@@ -1123,7 +1122,7 @@ static int connect_flow_table(struct mlx5_core_dev *dev, struct mlx5_flow_table
if (err) if (err)
return err; return err;
next_ft = first_ft ? first_ft : find_next_chained_ft(prio); next_ft = first_ft ? first_ft : find_next_chained_ft(&prio->node);
err = connect_fwd_rules(dev, ft, next_ft); err = connect_fwd_rules(dev, ft, next_ft);
if (err) if (err)
return err; return err;
...@@ -1198,7 +1197,7 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa ...@@ -1198,7 +1197,7 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
tree_init_node(&ft->node, del_hw_flow_table, del_sw_flow_table); tree_init_node(&ft->node, del_hw_flow_table, del_sw_flow_table);
next_ft = unmanaged ? ft_attr->next_ft : next_ft = unmanaged ? ft_attr->next_ft :
find_next_chained_ft(fs_prio); find_next_chained_ft(&fs_prio->node);
ft->def_miss_action = ns->def_miss_action; ft->def_miss_action = ns->def_miss_action;
ft->ns = ns; ft->ns = ns;
err = root->cmds->create_flow_table(root, ft, ft_attr, next_ft); err = root->cmds->create_flow_table(root, ft, ft_attr, next_ft);
...@@ -2201,7 +2200,7 @@ static struct mlx5_flow_table *find_next_ft(struct mlx5_flow_table *ft) ...@@ -2201,7 +2200,7 @@ static struct mlx5_flow_table *find_next_ft(struct mlx5_flow_table *ft)
if (!list_is_last(&ft->node.list, &prio->node.children)) if (!list_is_last(&ft->node.list, &prio->node.children))
return list_next_entry(ft, node.list); return list_next_entry(ft, node.list);
return find_next_chained_ft(prio); return find_next_chained_ft(&prio->node);
} }
static int update_root_ft_destroy(struct mlx5_flow_table *ft) static int update_root_ft_destroy(struct mlx5_flow_table *ft)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment