Commit 60ab4584 authored by Amir Vadai's avatar Amir Vadai Committed by David S. Miller

net/mlx5_core: Set flow steering dest only for forward rules

We need to handle flow table entry destinations only if the action
associated with the rule is forwarding (MLX5_FLOW_CONTEXT_ACTION_FWD_DEST).

Fixes: 26a81453 ('net/mlx5_core: Introduce flow steering firmware commands')
Signed-off-by: default avatarAmir Vadai <amir@vadai.me>
Signed-off-by: default avatarMaor Gottlieb <maorg@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 519afb18
...@@ -218,19 +218,22 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, ...@@ -218,19 +218,22 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
match_value); match_value);
memcpy(in_match_value, &fte->val, MLX5_ST_SZ_BYTES(fte_match_param)); memcpy(in_match_value, &fte->val, MLX5_ST_SZ_BYTES(fte_match_param));
in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination); if (fte->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
list_for_each_entry(dst, &fte->node.children, node.list) { in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination);
unsigned int id; list_for_each_entry(dst, &fte->node.children, node.list) {
unsigned int id;
MLX5_SET(dest_format_struct, in_dests, destination_type,
dst->dest_attr.type); MLX5_SET(dest_format_struct, in_dests, destination_type,
if (dst->dest_attr.type == dst->dest_attr.type);
MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE) if (dst->dest_attr.type ==
id = dst->dest_attr.ft->id; MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE) {
else id = dst->dest_attr.ft->id;
id = dst->dest_attr.tir_num; } else {
MLX5_SET(dest_format_struct, in_dests, destination_id, id); id = dst->dest_attr.tir_num;
in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); }
MLX5_SET(dest_format_struct, in_dests, destination_id, id);
in_dests += MLX5_ST_SZ_BYTES(dest_format_struct);
}
} }
memset(out, 0, sizeof(out)); memset(out, 0, sizeof(out));
err = mlx5_cmd_exec_check_status(dev, in, inlen, out, err = mlx5_cmd_exec_check_status(dev, in, inlen, out,
......
...@@ -360,8 +360,8 @@ static void del_rule(struct fs_node *node) ...@@ -360,8 +360,8 @@ static void del_rule(struct fs_node *node)
memcpy(match_value, fte->val, sizeof(fte->val)); memcpy(match_value, fte->val, sizeof(fte->val));
fs_get_obj(ft, fg->node.parent); fs_get_obj(ft, fg->node.parent);
list_del(&rule->node.list); list_del(&rule->node.list);
fte->dests_size--; if ((fte->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) &&
if (fte->dests_size) { --fte->dests_size) {
err = mlx5_cmd_update_fte(dev, ft, err = mlx5_cmd_update_fte(dev, ft,
fg->id, fte); fg->id, fte);
if (err) if (err)
...@@ -763,7 +763,8 @@ static struct mlx5_flow_rule *alloc_rule(struct mlx5_flow_destination *dest) ...@@ -763,7 +763,8 @@ static struct mlx5_flow_rule *alloc_rule(struct mlx5_flow_destination *dest)
return NULL; return NULL;
rule->node.type = FS_TYPE_FLOW_DEST; rule->node.type = FS_TYPE_FLOW_DEST;
memcpy(&rule->dest_attr, dest, sizeof(*dest)); if (dest)
memcpy(&rule->dest_attr, dest, sizeof(*dest));
return rule; return rule;
} }
...@@ -785,8 +786,9 @@ static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte, ...@@ -785,8 +786,9 @@ static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte,
/* Add dest to dests list- added as first element after the head */ /* Add dest to dests list- added as first element after the head */
tree_init_node(&rule->node, 1, del_rule); tree_init_node(&rule->node, 1, del_rule);
list_add_tail(&rule->node.list, &fte->node.children); list_add_tail(&rule->node.list, &fte->node.children);
fte->dests_size++; if (dest)
if (fte->dests_size == 1) fte->dests_size++;
if (fte->dests_size == 1 || !dest)
err = mlx5_cmd_create_fte(get_dev(&ft->node), err = mlx5_cmd_create_fte(get_dev(&ft->node),
ft, fg->id, fte); ft, fg->id, fte);
else else
...@@ -802,7 +804,8 @@ static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte, ...@@ -802,7 +804,8 @@ static struct mlx5_flow_rule *add_rule_fte(struct fs_fte *fte,
free_rule: free_rule:
list_del(&rule->node.list); list_del(&rule->node.list);
kfree(rule); kfree(rule);
fte->dests_size--; if (dest)
fte->dests_size--;
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -996,6 +999,9 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft, ...@@ -996,6 +999,9 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft,
struct mlx5_flow_group *g; struct mlx5_flow_group *g;
struct mlx5_flow_rule *rule; struct mlx5_flow_rule *rule;
if ((action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) && !dest)
return ERR_PTR(-EINVAL);
nested_lock_ref_node(&ft->node, FS_MUTEX_GRANDPARENT); nested_lock_ref_node(&ft->node, FS_MUTEX_GRANDPARENT);
fs_for_each_fg(g, ft) fs_for_each_fg(g, ft)
if (compare_match_criteria(g->mask.match_criteria_enable, if (compare_match_criteria(g->mask.match_criteria_enable,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment