Skip to content

Commit c635ca4

Browse files
Jianbo Liukuba-moo
authored andcommitted
net/mlx5: fs_core: Skip the FTs in the same FS_TYPE_PRIO_CHAINS fs_prio
In the cited commit, new type of FS_TYPE_PRIO_CHAINS fs_prio was added to support multiple parallel namespaces for multi-chains. And we skip all the flow tables under the fs_node of this type unconditionally, when searching for the next or previous flow table to connect for a new table. As this search function is also used for find new root table when the old one is being deleted, it will skip the entire FS_TYPE_PRIO_CHAINS fs_node next to the old root. However, new root table should be chosen from it if there is any table in it. Fix it by skipping only the flow tables in the same FS_TYPE_PRIO_CHAINS fs_node when finding the closest FT for a fs_node. Besides, complete the connecting from FTs of previous priority of prio because there should be multiple prevs after this fs_prio type is introduced. And also the next FT should be chosen from the first flow table next to the prio in the same FS_TYPE_PRIO_CHAINS fs_prio, if this prio is the first child. Fixes: 328edb4 ("net/mlx5: Split FDB fast path prio to multiple namespaces") Signed-off-by: Jianbo Liu <jianbol@nvidia.com> Reviewed-by: Paul Blakey <paulb@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Link: https://lore.kernel.org/r/7a95754df479e722038996c97c97b062b372591f.1690803944.git.leonro@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 618d28a commit c635ca4

File tree

1 file changed

+72
-8
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+72
-8
lines changed

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

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ static struct mlx5_flow_table *find_closest_ft_recursive(struct fs_node *root,
889889
struct fs_node *iter = list_entry(start, struct fs_node, list);
890890
struct mlx5_flow_table *ft = NULL;
891891

892-
if (!root || root->type == FS_TYPE_PRIO_CHAINS)
892+
if (!root)
893893
return NULL;
894894

895895
list_for_each_advance_continue(iter, &root->children, reverse) {
@@ -905,19 +905,42 @@ static struct mlx5_flow_table *find_closest_ft_recursive(struct fs_node *root,
905905
return ft;
906906
}
907907

908+
static struct fs_node *find_prio_chains_parent(struct fs_node *parent,
909+
struct fs_node **child)
910+
{
911+
struct fs_node *node = NULL;
912+
913+
while (parent && parent->type != FS_TYPE_PRIO_CHAINS) {
914+
node = parent;
915+
parent = parent->parent;
916+
}
917+
918+
if (child)
919+
*child = node;
920+
921+
return parent;
922+
}
923+
908924
/* If reverse is false then return the first flow table next to the passed node
909925
* in the tree, else return the last flow table before the node in the tree.
926+
* If skip is true, skip the flow tables in the same prio_chains prio.
910927
*/
911-
static struct mlx5_flow_table *find_closest_ft(struct fs_node *node, bool reverse)
928+
static struct mlx5_flow_table *find_closest_ft(struct fs_node *node, bool reverse,
929+
bool skip)
912930
{
931+
struct fs_node *prio_chains_parent = NULL;
913932
struct mlx5_flow_table *ft = NULL;
914933
struct fs_node *curr_node;
915934
struct fs_node *parent;
916935

936+
if (skip)
937+
prio_chains_parent = find_prio_chains_parent(node, NULL);
917938
parent = node->parent;
918939
curr_node = node;
919940
while (!ft && parent) {
920-
ft = find_closest_ft_recursive(parent, &curr_node->list, reverse);
941+
if (parent != prio_chains_parent)
942+
ft = find_closest_ft_recursive(parent, &curr_node->list,
943+
reverse);
921944
curr_node = parent;
922945
parent = curr_node->parent;
923946
}
@@ -927,13 +950,13 @@ static struct mlx5_flow_table *find_closest_ft(struct fs_node *node, bool revers
927950
/* Assuming all the tree is locked by mutex chain lock */
928951
static struct mlx5_flow_table *find_next_chained_ft(struct fs_node *node)
929952
{
930-
return find_closest_ft(node, false);
953+
return find_closest_ft(node, false, true);
931954
}
932955

933956
/* Assuming all the tree is locked by mutex chain lock */
934957
static struct mlx5_flow_table *find_prev_chained_ft(struct fs_node *node)
935958
{
936-
return find_closest_ft(node, true);
959+
return find_closest_ft(node, true, true);
937960
}
938961

939962
static struct mlx5_flow_table *find_next_fwd_ft(struct mlx5_flow_table *ft,
@@ -969,21 +992,55 @@ static int connect_fts_in_prio(struct mlx5_core_dev *dev,
969992
return 0;
970993
}
971994

995+
static struct mlx5_flow_table *find_closet_ft_prio_chains(struct fs_node *node,
996+
struct fs_node *parent,
997+
struct fs_node **child,
998+
bool reverse)
999+
{
1000+
struct mlx5_flow_table *ft;
1001+
1002+
ft = find_closest_ft(node, reverse, false);
1003+
1004+
if (ft && parent == find_prio_chains_parent(&ft->node, child))
1005+
return ft;
1006+
1007+
return NULL;
1008+
}
1009+
9721010
/* Connect flow tables from previous priority of prio to ft */
9731011
static int connect_prev_fts(struct mlx5_core_dev *dev,
9741012
struct mlx5_flow_table *ft,
9751013
struct fs_prio *prio)
9761014
{
1015+
struct fs_node *prio_parent, *parent = NULL, *child, *node;
9771016
struct mlx5_flow_table *prev_ft;
1017+
int err = 0;
1018+
1019+
prio_parent = find_prio_chains_parent(&prio->node, &child);
1020+
1021+
/* return directly if not under the first sub ns of prio_chains prio */
1022+
if (prio_parent && !list_is_first(&child->list, &prio_parent->children))
1023+
return 0;
9781024

9791025
prev_ft = find_prev_chained_ft(&prio->node);
980-
if (prev_ft) {
1026+
while (prev_ft) {
9811027
struct fs_prio *prev_prio;
9821028

9831029
fs_get_obj(prev_prio, prev_ft->node.parent);
984-
return connect_fts_in_prio(dev, prev_prio, ft);
1030+
err = connect_fts_in_prio(dev, prev_prio, ft);
1031+
if (err)
1032+
break;
1033+
1034+
if (!parent) {
1035+
parent = find_prio_chains_parent(&prev_prio->node, &child);
1036+
if (!parent)
1037+
break;
1038+
}
1039+
1040+
node = child;
1041+
prev_ft = find_closet_ft_prio_chains(node, parent, &child, true);
9851042
}
986-
return 0;
1043+
return err;
9871044
}
9881045

9891046
static int update_root_ft_create(struct mlx5_flow_table *ft, struct fs_prio
@@ -2194,12 +2251,19 @@ EXPORT_SYMBOL(mlx5_del_flow_rules);
21942251
/* Assuming prio->node.children(flow tables) is sorted by level */
21952252
static struct mlx5_flow_table *find_next_ft(struct mlx5_flow_table *ft)
21962253
{
2254+
struct fs_node *prio_parent, *child;
21972255
struct fs_prio *prio;
21982256

21992257
fs_get_obj(prio, ft->node.parent);
22002258

22012259
if (!list_is_last(&ft->node.list, &prio->node.children))
22022260
return list_next_entry(ft, node.list);
2261+
2262+
prio_parent = find_prio_chains_parent(&prio->node, &child);
2263+
2264+
if (prio_parent && list_is_first(&child->list, &prio_parent->children))
2265+
return find_closest_ft(&prio->node, false, false);
2266+
22032267
return find_next_chained_ft(&prio->node);
22042268
}
22052269

0 commit comments

Comments
 (0)