From: Erez Shitrit <ere...@nvidia.com> The user want to know before trying to update a rule if that matcher that keeps the original rule supports updating.
Signed-off-by: Erez Shitrit <ere...@nvidia.com> Acked-by: Ori Kam <or...@nvidia.com> --- drivers/net/mlx5/hws/mlx5dr.h | 8 ++++++++ drivers/net/mlx5/hws/mlx5dr_matcher.c | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index 8441ae97e9..c5824a6480 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -492,6 +492,14 @@ int mlx5dr_matcher_resize_rule_move(struct mlx5dr_matcher *src_matcher, struct mlx5dr_rule *rule, struct mlx5dr_rule_attr *attr); +/* Check matcher ability to update existing rules + * + * @param[in] matcher + * that the rule belongs to. + * @return true when the matcher is updatable false otherwise. + */ +bool mlx5dr_matcher_is_updatable(struct mlx5dr_matcher *matcher); + /* Get the size of the rule handle (mlx5dr_rule) to be used on rule creation. * * @return size in bytes of rule handle struct. diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index 8a74a1ed7d..4e4da8e8f6 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -1530,6 +1530,18 @@ int mlx5dr_match_template_destroy(struct mlx5dr_match_template *mt) return 0; } +bool mlx5dr_matcher_is_updatable(struct mlx5dr_matcher *matcher) +{ + if (mlx5dr_table_is_root(matcher->tbl) || + mlx5dr_matcher_req_fw_wqe(matcher) || + mlx5dr_matcher_is_resizable(matcher) || + (!matcher->attr.optimize_using_rule_idx && + !mlx5dr_matcher_is_insert_by_idx(matcher))) + return false; + + return true; +} + static int mlx5dr_matcher_resize_precheck(struct mlx5dr_matcher *src_matcher, struct mlx5dr_matcher *dst_matcher) { -- 2.39.2