@@ -384,7 +384,6 @@ static void del_flow_table(struct fs_node *node)
384384 err = mlx5_cmd_destroy_flow_table (dev , ft );
385385 if (err )
386386 mlx5_core_warn (dev , "flow steering can't destroy ft\n" );
387- ida_destroy (& ft -> fte_allocator );
388387 rhltable_destroy (& ft -> fgs_hash );
389388 fs_get_obj (prio , ft -> node .parent );
390389 prio -> num_ft -- ;
@@ -445,7 +444,7 @@ static void destroy_fte(struct fs_fte *fte, struct mlx5_flow_group *fg)
445444 WARN_ON (ret );
446445 fte -> status = 0 ;
447446 fs_get_obj (ft , fg -> node .parent );
448- ida_simple_remove (& ft -> fte_allocator , fte -> index );
447+ ida_simple_remove (& fg -> fte_allocator , fte -> index - fg -> start_index );
449448}
450449
451450static void del_fte (struct fs_node * node )
@@ -488,6 +487,7 @@ static void del_flow_group(struct fs_node *node)
488487 ft -> autogroup .num_groups -- ;
489488
490489 rhashtable_destroy (& fg -> ftes_hash );
490+ ida_destroy (& fg -> fte_allocator );
491491 err = rhltable_remove (& ft -> fgs_hash ,
492492 & fg -> hash ,
493493 rhash_fg );
@@ -537,6 +537,7 @@ static struct mlx5_flow_group *alloc_flow_group(u32 *create_fg_in)
537537 kfree (fg );
538538 return ERR_PTR (ret );
539539 }
540+ ida_init (& fg -> fte_allocator );
540541 fg -> mask .match_criteria_enable = match_criteria_enable ;
541542 memcpy (& fg -> mask .match_criteria , match_criteria ,
542543 sizeof (fg -> mask .match_criteria ));
@@ -575,7 +576,6 @@ static struct mlx5_flow_table *alloc_flow_table(int level, u16 vport, int max_ft
575576 ft -> flags = flags ;
576577 INIT_LIST_HEAD (& ft -> fwd_rules );
577578 mutex_init (& ft -> lock );
578- ida_init (& ft -> fte_allocator );
579579
580580 return ft ;
581581}
@@ -892,7 +892,6 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
892892destroy_ft :
893893 mlx5_cmd_destroy_flow_table (root -> dev , ft );
894894free_ft :
895- ida_destroy (& ft -> fte_allocator );
896895 kfree (ft );
897896unlock_root :
898897 mutex_unlock (& root -> chain_lock );
@@ -1003,6 +1002,7 @@ static struct mlx5_flow_group *create_flow_group_common(struct mlx5_flow_table *
10031002 rhash_fg ));
10041003err_free_fg :
10051004 rhashtable_destroy (& fg -> ftes_hash );
1005+ ida_destroy (& fg -> fte_allocator );
10061006 kfree (fg );
10071007
10081008 return ERR_PTR (err );
@@ -1181,18 +1181,18 @@ static struct fs_fte *create_fte(struct mlx5_flow_group *fg,
11811181 u32 * match_value ,
11821182 struct mlx5_flow_act * flow_act )
11831183{
1184- struct mlx5_flow_table * ft ;
11851184 struct fs_fte * fte ;
11861185 int index ;
11871186 int ret ;
11881187
1189- fs_get_obj (ft , fg -> node .parent );
1190- index = ida_simple_get (& ft -> fte_allocator , fg -> start_index ,
1191- fg -> start_index + fg -> max_ftes ,
1188+ index = ida_simple_get (& fg -> fte_allocator , 0 ,
1189+ fg -> max_ftes ,
11921190 GFP_KERNEL );
11931191 if (index < 0 )
11941192 return ERR_PTR (index );
11951193
1194+ index += fg -> start_index ;
1195+
11961196 fte = alloc_fte (flow_act , match_value , index );
11971197 if (IS_ERR (fte )) {
11981198 ret = PTR_ERR (fte );
@@ -1207,7 +1207,7 @@ static struct fs_fte *create_fte(struct mlx5_flow_group *fg,
12071207err_hash :
12081208 kfree (fte );
12091209err_alloc :
1210- ida_simple_remove (& ft -> fte_allocator , index );
1210+ ida_simple_remove (& fg -> fte_allocator , index - fg -> start_index );
12111211 return ERR_PTR (ret );
12121212}
12131213
0 commit comments