Commit 814fb875 authored by Mark Bloch's avatar Mark Bloch Committed by Leon Romanovsky
Browse files

net/mlx5: Refactor find_flow_rule

The way we compare between two dests will need to be used in other
places in the future, so we factor out the comparison logic
between two dests into a separate function.

Signed-off-by: default avatarMark Bloch <>
Signed-off-by: default avatarSaeed Mahameed <>
Signed-off-by: default avatarLeon Romanovsky <>
parent 0501fc47
......@@ -153,6 +153,8 @@ static void del_rule(struct fs_node *node);
static void del_flow_table(struct fs_node *node);
static void del_flow_group(struct fs_node *node);
static void del_fte(struct fs_node *node);
static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
struct mlx5_flow_destination *d2);
static void tree_init_node(struct fs_node *node,
unsigned int refcount,
......@@ -1064,21 +1066,30 @@ static struct mlx5_flow_group *create_autogroup(struct mlx5_flow_table *ft,
return fg;
static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
struct mlx5_flow_destination *d2)
if (d1->type == d2->type) {
d1->vport_num == d2->vport_num) ||
d1->ft == d2->ft) ||
d1->tir_num == d2->tir_num))
return true;
return false;
static struct mlx5_flow_rule *find_flow_rule(struct fs_fte *fte,
struct mlx5_flow_destination *dest)
struct mlx5_flow_rule *rule;
list_for_each_entry(rule, &fte->node.children, node.list) {
if (rule->dest_attr.type == dest->type) {
if ((dest->type == MLX5_FLOW_DESTINATION_TYPE_VPORT &&
dest->vport_num == rule->dest_attr.vport_num) ||
dest->ft == rule->dest_attr.ft) ||
dest->tir_num == rule->dest_attr.tir_num))
return rule;
if (mlx5_flow_dests_cmp(&rule->dest_attr, dest))
return rule;
return NULL;
Supports Markdown
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