Skip to content

Commit a622498

Browse files
mark-blochrleon
authored andcommitted
net/mlx5: Group similer rules under the same fte
When adding a new rule, if we can match it with compare_match_value and flow tag we might be able to insert the rule to the same fte. In order to do that, there must be an overlap between the actions of the fte and the new rule. When updating the action of an existing fte, we must tell the firmware we are doing so. Signed-off-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 814fb87 commit a622498

File tree

1 file changed

+16
-6
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,8 @@ static struct mlx5_flow_rule *alloc_rule(struct mlx5_flow_destination *dest)
920920
/* fte should not be deleted while calling this function */
921921
static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte,
922922
struct mlx5_flow_group *fg,
923-
struct mlx5_flow_destination *dest)
923+
struct mlx5_flow_destination *dest,
924+
bool update_action)
924925
{
925926
struct mlx5_flow_table *ft;
926927
struct mlx5_flow_rule *rule;
@@ -931,6 +932,9 @@ static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte,
931932
if (!rule)
932933
return ERR_PTR(-ENOMEM);
933934

935+
if (update_action)
936+
modify_mask |= BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION);
937+
934938
fs_get_obj(ft, fg->node.parent);
935939
/* Add dest to dests list- we need flow tables to be in the
936940
* end of the list for forward to next prio rules.
@@ -1109,19 +1113,25 @@ static struct mlx5_flow_rule *add_rule_fg(struct mlx5_flow_group *fg,
11091113
fs_for_each_fte(fte, fg) {
11101114
nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD);
11111115
if (compare_match_value(&fg->mask, match_value, &fte->val) &&
1112-
action == fte->action && flow_tag == fte->flow_tag) {
1116+
(action & fte->action) && flow_tag == fte->flow_tag) {
1117+
int old_action = fte->action;
1118+
11131119
rule = find_flow_rule(fte, dest);
11141120
if (rule) {
11151121
atomic_inc(&rule->node.refcount);
11161122
unlock_ref_node(&fte->node);
11171123
unlock_ref_node(&fg->node);
11181124
return rule;
11191125
}
1120-
rule = add_rule_fte(fte, fg, dest);
1121-
if (IS_ERR(rule))
1126+
fte->action |= action;
1127+
rule = add_rule_fte(fte, fg, dest,
1128+
old_action != action);
1129+
if (IS_ERR(rule)) {
1130+
fte->action = old_action;
11221131
goto unlock_fte;
1123-
else
1132+
} else {
11241133
goto add_rule;
1134+
}
11251135
}
11261136
unlock_ref_node(&fte->node);
11271137
}
@@ -1138,7 +1148,7 @@ static struct mlx5_flow_rule *add_rule_fg(struct mlx5_flow_group *fg,
11381148
}
11391149
tree_init_node(&fte->node, 0, del_fte);
11401150
nested_lock_ref_node(&fte->node, FS_MUTEX_CHILD);
1141-
rule = add_rule_fte(fte, fg, dest);
1151+
rule = add_rule_fte(fte, fg, dest, false);
11421152
if (IS_ERR(rule)) {
11431153
kfree(fte);
11441154
goto unlock_fg;

0 commit comments

Comments
 (0)