History

net/mlx5: Allow creating autogroups with reserved entries

Exclude the last n entries for an autogrouped flow table. Reserving entries at the end of the FT will ensure that this FG will be the last to be evaluated. This will be used in the next patch to create a miss group enabling custom actions on FT miss.

Paul Blakey committed 7 years ago

Commit 79cdb0a1 parent ff189b43 files · +19 −9Browse files

Unified · Split

3 files
  1. drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +17 −9
  2. drivers/net/ethernet/mellanox/mlx5/core/fs_core.h +1 −0
  3. include/linux/mlx5/fs.h +1 −0
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c+17−9
@@ -579,7 +579,9 @@ static void del_sw_flow_group(struct fs_node *node) · 578 unmodified lines
579579
580580 rhashtable_destroy(&fg->ftes_hash);
581581 ida_destroy(&fg->fte_allocator);
582− if (ft->autogroup.active && fg->max_ftes == ft->autogroup.group_size)
582+ if (ft->autogroup.active &&
583+ fg->max_ftes == ft->autogroup.group_size &&
584+ fg->start_index < ft->autogroup.max_fte)
583585 ft->autogroup.num_groups--;
584586 err = rhltable_remove(&ft->fgs_hash,
585587 &fg->hash,
@@ -1121,9 +1123,14 @@ struct mlx5_flow_table* · 535 unmodified lines
11211123 mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
11221124 struct mlx5_flow_table_attr *ft_attr)
11231125 {
1126+ int num_reserved_entries = ft_attr->autogroup.num_reserved_entries;
1127+ int autogroups_max_fte = ft_attr->max_fte - num_reserved_entries;
1128+ int max_num_groups = ft_attr->autogroup.max_num_groups;
11241129 struct mlx5_flow_table *ft;
11251130
1126− if (ft_attr->autogroup.max_num_groups > ft_attr->max_fte)
1131+ if (max_num_groups > autogroups_max_fte)
1132+ return ERR_PTR(-EINVAL);
1133+ if (num_reserved_entries > ft_attr->max_fte)
11271134 return ERR_PTR(-EINVAL);
11281135
11291136 ft = mlx5_create_flow_table(ns, ft_attr);
@@ -1131,10 +1138,10 @@ mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns, · 1 unmodified line
11311138 return ft;
11321139
11331140 ft->autogroup.active = true;
1134− ft->autogroup.required_groups = ft_attr->autogroup.max_num_groups;
1141+ ft->autogroup.required_groups = max_num_groups;
1142+ ft->autogroup.max_fte = autogroups_max_fte;
11351143 /* We save place for flow groups in addition to max types */
1136− ft->autogroup.group_size = ft->max_fte /
1137− (ft->autogroup.required_groups + 1);
1144+ ft->autogroup.group_size = autogroups_max_fte / (max_num_groups + 1);
11381145
11391146 return ft;
11401147 }
@@ -1156,7 +1163,7 @@ struct mlx5_flow_group *mlx5_create_flow_group(struct mlx5_flow_table *ft, · 15 unmodified lines
11561163 struct mlx5_flow_group *fg;
11571164 int err;
11581165
1159− if (ft->autogroup.active)
1166+ if (ft->autogroup.active && start_index < ft->autogroup.max_fte)
11601167 return ERR_PTR(-EPERM);
11611168
11621169 down_write_ref_node(&ft->node, false);
@@ -1329,9 +1336,10 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft · 166 unmodified lines
13291336 const struct mlx5_flow_spec *spec)
13301337 {
13311338 struct list_head *prev = &ft->node.children;
1332− struct mlx5_flow_group *fg;
1339+ u32 max_fte = ft->autogroup.max_fte;
13331340 unsigned int candidate_index = 0;
13341341 unsigned int group_size = 0;
1342+ struct mlx5_flow_group *fg;
13351343
13361344 if (!ft->autogroup.active)
13371345 return ERR_PTR(-ENOENT);
@@ -1339,7 +1347,7 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft · 1 unmodified line
13391347 if (ft->autogroup.num_groups < ft->autogroup.required_groups)
13401348 group_size = ft->autogroup.group_size;
13411349
1342− /* ft->max_fte == ft->autogroup.max_types */
1350+ /* max_fte == ft->autogroup.max_types */
13431351 if (group_size == 0)
13441352 group_size = 1;
13451353
@@ -1352,7 +1360,7 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft · 6 unmodified lines
13521360 prev = &fg->node.list;
13531361 }
13541362
1355− if (candidate_index + group_size > ft->max_fte)
1363+ if (candidate_index + group_size > max_fte)
13561364 return ERR_PTR(-ENOSPC);
13571365
13581366 fg = alloc_insert_flow_group(ft,
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h+1−0
@@ -164,6 +164,7 @@ struct mlx5_flow_table { · 163 unmodified lines
164164 unsigned int required_groups;
165165 unsigned int group_size;
166166 unsigned int num_groups;
167+ unsigned int max_fte;
167168 } autogroup;
168169 /* Protect fwd_rules */
169170 struct mutex lock;
include/linux/mlx5/fs.h+1−0
@@ -155,6 +155,7 @@ struct mlx5_flow_table_attr { · 154 unmodified lines
155155
156156 struct {
157157 int max_num_groups;
158+ int num_reserved_entries;
158159 } autogroup;
159160 };
160161