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
579 579
580 rhashtable_destroy(&fg->ftes_hash);580 rhashtable_destroy(&fg->ftes_hash);
581 ida_destroy(&fg->fte_allocator);581 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)
583 ft->autogroup.num_groups--;585 ft->autogroup.num_groups--;
584 err = rhltable_remove(&ft->fgs_hash,586 err = rhltable_remove(&ft->fgs_hash,
585 &fg->hash,587 &fg->hash,
@@ -1121,9 +1123,14 @@ struct mlx5_flow_table* · 535 unmodified lines
1121mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,1123mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,
1122 struct mlx5_flow_table_attr *ft_attr)1124 struct mlx5_flow_table_attr *ft_attr)
1123{1125{
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;
1124 struct mlx5_flow_table *ft;1129 struct mlx5_flow_table *ft;
1125 1130
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)
1127 return ERR_PTR(-EINVAL);1134 return ERR_PTR(-EINVAL);
1128 1135
1129 ft = mlx5_create_flow_table(ns, ft_attr);1136 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
1131 return ft;1138 return ft;
1132 1139
1133 ft->autogroup.active = true;1140 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;
1135 /* We save place for flow groups in addition to max types */1143 /* We save place for flow groups in addition to max types */
1136 ft->autogroup.group_size = ft->max_fte /1144 ft->autogroup.group_size = autogroups_max_fte / (max_num_groups + 1);
1137 (ft->autogroup.required_groups + 1);
1138 1145
1139 return ft;1146 return ft;
1140}1147}
@@ -1156,7 +1163,7 @@ struct mlx5_flow_group *mlx5_create_flow_group(struct mlx5_flow_table *ft, · 15 unmodified lines
1156 struct mlx5_flow_group *fg;1163 struct mlx5_flow_group *fg;
1157 int err;1164 int err;
1158 1165
1159 if (ft->autogroup.active)1166 if (ft->autogroup.active && start_index < ft->autogroup.max_fte)
1160 return ERR_PTR(-EPERM);1167 return ERR_PTR(-EPERM);
1161 1168
1162 down_write_ref_node(&ft->node, false);1169 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
1329 const struct mlx5_flow_spec *spec)1336 const struct mlx5_flow_spec *spec)
1330{1337{
1331 struct list_head *prev = &ft->node.children;1338 struct list_head *prev = &ft->node.children;
1332 struct mlx5_flow_group *fg;1339 u32 max_fte = ft->autogroup.max_fte;
1333 unsigned int candidate_index = 0;1340 unsigned int candidate_index = 0;
1334 unsigned int group_size = 0;1341 unsigned int group_size = 0;
1342 struct mlx5_flow_group *fg;
1335 1343
1336 if (!ft->autogroup.active)1344 if (!ft->autogroup.active)
1337 return ERR_PTR(-ENOENT);1345 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
1339 if (ft->autogroup.num_groups < ft->autogroup.required_groups)1347 if (ft->autogroup.num_groups < ft->autogroup.required_groups)
1340 group_size = ft->autogroup.group_size;1348 group_size = ft->autogroup.group_size;
1341 1349
1342 /* ft->max_fte == ft->autogroup.max_types */1350 /* max_fte == ft->autogroup.max_types */
1343 if (group_size == 0)1351 if (group_size == 0)
1344 group_size = 1;1352 group_size = 1;
1345 1353
@@ -1352,7 +1360,7 @@ static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table *ft · 6 unmodified lines
1352 prev = &fg->node.list;1360 prev = &fg->node.list;
1353 }1361 }
1354 1362
1355 if (candidate_index + group_size > ft->max_fte)1363 if (candidate_index + group_size > max_fte)
1356 return ERR_PTR(-ENOSPC);1364 return ERR_PTR(-ENOSPC);
1357 1365
1358 fg = alloc_insert_flow_group(ft,1366 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
164 unsigned int required_groups;164 unsigned int required_groups;
165 unsigned int group_size;165 unsigned int group_size;
166 unsigned int num_groups;166 unsigned int num_groups;
167 unsigned int max_fte;
167 } autogroup;168 } autogroup;
168 /* Protect fwd_rules */169 /* Protect fwd_rules */
169 struct mutex lock;170 struct mutex lock;
include/linux/mlx5/fs.h+1−0
@@ -155,6 +155,7 @@ struct mlx5_flow_table_attr { · 154 unmodified lines
155 155
156 struct {156 struct {
157 int max_num_groups;157 int max_num_groups;
158 int num_reserved_entries;
158 } autogroup;159 } autogroup;
159};160};
160 161