Skip to content

Commit 618d28a

Browse files
Jianbo Liukuba-moo
authored andcommitted
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: Jianbo Liu <jianbol@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Link: https://lore.kernel.org/r/d3962c2b443ec8dde7a740dc742a1f052d5e256c.1690803944.git.leonro@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 0756384 commit 618d28a

File tree

1 file changed

+14
-15
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+14
-15
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -905,18 +905,17 @@ static struct mlx5_flow_table *find_closest_ft_recursive(struct fs_node *root,
905905
return ft;
906906
}
907907

908-
/* If reverse is false then return the first flow table in next priority of
909-
* prio in the tree, else return the last flow table in the previous priority
910-
* of prio in the tree.
908+
/* If reverse is false then return the first flow table next to the passed node
909+
* in the tree, else return the last flow table before the node in the tree.
911910
*/
912-
static struct mlx5_flow_table *find_closest_ft(struct fs_prio *prio, bool reverse)
911+
static struct mlx5_flow_table *find_closest_ft(struct fs_node *node, bool reverse)
913912
{
914913
struct mlx5_flow_table *ft = NULL;
915914
struct fs_node *curr_node;
916915
struct fs_node *parent;
917916

918-
parent = prio->node.parent;
919-
curr_node = &prio->node;
917+
parent = node->parent;
918+
curr_node = node;
920919
while (!ft && parent) {
921920
ft = find_closest_ft_recursive(parent, &curr_node->list, reverse);
922921
curr_node = parent;
@@ -926,15 +925,15 @@ static struct mlx5_flow_table *find_closest_ft(struct fs_prio *prio, bool revers
926925
}
927926

928927
/* Assuming all the tree is locked by mutex chain lock */
929-
static struct mlx5_flow_table *find_next_chained_ft(struct fs_prio *prio)
928+
static struct mlx5_flow_table *find_next_chained_ft(struct fs_node *node)
930929
{
931-
return find_closest_ft(prio, false);
930+
return find_closest_ft(node, false);
932931
}
933932

934933
/* Assuming all the tree is locked by mutex chain lock */
935-
static struct mlx5_flow_table *find_prev_chained_ft(struct fs_prio *prio)
934+
static struct mlx5_flow_table *find_prev_chained_ft(struct fs_node *node)
936935
{
937-
return find_closest_ft(prio, true);
936+
return find_closest_ft(node, true);
938937
}
939938

940939
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,
946945
next_ns = flow_act->action & MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS;
947946
fs_get_obj(prio, next_ns ? ft->ns->node.parent : ft->node.parent);
948947

949-
return find_next_chained_ft(prio);
948+
return find_next_chained_ft(&prio->node);
950949
}
951950

952951
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,
977976
{
978977
struct mlx5_flow_table *prev_ft;
979978

980-
prev_ft = find_prev_chained_ft(prio);
979+
prev_ft = find_prev_chained_ft(&prio->node);
981980
if (prev_ft) {
982981
struct fs_prio *prev_prio;
983982

@@ -1123,7 +1122,7 @@ static int connect_flow_table(struct mlx5_core_dev *dev, struct mlx5_flow_table
11231122
if (err)
11241123
return err;
11251124

1126-
next_ft = first_ft ? first_ft : find_next_chained_ft(prio);
1125+
next_ft = first_ft ? first_ft : find_next_chained_ft(&prio->node);
11271126
err = connect_fwd_rules(dev, ft, next_ft);
11281127
if (err)
11291128
return err;
@@ -1198,7 +1197,7 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
11981197

11991198
tree_init_node(&ft->node, del_hw_flow_table, del_sw_flow_table);
12001199
next_ft = unmanaged ? ft_attr->next_ft :
1201-
find_next_chained_ft(fs_prio);
1200+
find_next_chained_ft(&fs_prio->node);
12021201
ft->def_miss_action = ns->def_miss_action;
12031202
ft->ns = ns;
12041203
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)
22012200

22022201
if (!list_is_last(&ft->node.list, &prio->node.children))
22032202
return list_next_entry(ft, node.list);
2204-
return find_next_chained_ft(prio);
2203+
return find_next_chained_ft(&prio->node);
22052204
}
22062205

22072206
static int update_root_ft_destroy(struct mlx5_flow_table *ft)

0 commit comments

Comments
 (0)