[PATCH 02/11] net/mlx5/hws: add check for matcher rule update support

Dariusz Sosnowski dsosnowski at nvidia.com
Wed Feb 28 18:00:37 CET 2024


From: Erez Shitrit <erezsh at 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 <erezsh at 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 d612f300c6..781b11e681 100644
--- a/drivers/net/mlx5/hws/mlx5dr.h
+++ b/drivers/net/mlx5/hws/mlx5dr.h
@@ -491,6 +491,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



More information about the dev mailing list