Commit dc638d11 authored by Eli Cohen's avatar Eli Cohen Committed by Saeed Mahameed

net/mlx5: Avoid group version scan when not necessary

Group version is used when modifying a rule is allowed
(FLOW_ACT_NO_APPEND is clear) to detect a case where the rule was found
but while the groups where unlocked a new FTE was added. In this case,
the added FTE could be one with identical match value so we need to
attempt again with group lock held.

Change the code so version is retrieved only when FLOW_ACT_NO_APPEND is
cleared. As result, later compare can also be avoided if FLOW_ACT_NO_APPEND
is cleared.

Also improve comments text.
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 0aad2a0b
......@@ -1680,7 +1680,7 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
struct match_list *iter;
bool take_write = false;
struct fs_fte *fte;
u64 version;
u64 version = 0;
int err;
fte = alloc_fte(ft, spec, flow_act);
......@@ -1688,10 +1688,12 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
return ERR_PTR(-ENOMEM);
search_again_locked:
version = matched_fgs_get_version(match_head);
if (flow_act->flags & FLOW_ACT_NO_APPEND)
goto skip_search;
/* Try to find a fg that already contains a matching fte */
version = matched_fgs_get_version(match_head);
/* Try to find an fte with identical match value and attempt update its
* action.
*/
list_for_each_entry(iter, match_head, list) {
struct fs_fte *fte_tmp;
......@@ -1719,10 +1721,12 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft,
goto out;
}
/* Check the fgs version, for case the new FTE with the
* same values was added while the fgs weren't locked
/* Check the fgs version. If version have changed it could be that an
* FTE with the same match value was added while the fgs weren't
* locked.
*/
if (version != matched_fgs_get_version(match_head)) {
if (!(flow_act->flags & FLOW_ACT_NO_APPEND) &&
version != matched_fgs_get_version(match_head)) {
take_write = true;
goto search_again_locked;
}
......
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