From: Maor Gottlieb <ma...@mellanox.com>

Introduce API to get mlx5_flow_match which contains:
1. match_criteria_enable
2. match_criteria
3. match_value

Signed-off-by: Maor Gottlieb <ma...@mellanox.com>
Signed-off-by: Saeed Mahameed <sae...@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 19 +++++++++++++++++++
 include/linux/mlx5/fs.h                           |  3 +++
 2 files changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index d60d578..b7ddcd2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -2077,3 +2077,22 @@ unlock:
 
        return 0;
 }
+
+void mlx5_get_rule_flow_match(struct mlx5_flow_match *flow_match,
+                             struct mlx5_flow_rule *rule)
+{
+       struct mlx5_flow_group *fg;
+       struct fs_node *pnode;
+       struct fs_fte *fte;
+
+       pnode = rule->node.parent;
+       WARN_ON(!pnode);
+       fs_get_obj(fte, pnode);
+       pnode = pnode->parent;
+       WARN_ON(!pnode);
+       fs_get_obj(fg, pnode);
+
+       flow_match->match_value = fte->val;
+       flow_match->match_criteria = fg->mask.match_criteria;
+       flow_match->match_criteria_enable = fg->mask.match_criteria_enable;
+}
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h
index ae82e00..db1f06e 100644
--- a/include/linux/mlx5/fs.h
+++ b/include/linux/mlx5/fs.h
@@ -173,4 +173,7 @@ struct mlx5_event_data {
        struct mlx5_flow_table *ft;
        struct mlx5_flow_rule *rule;
 };
+
+void mlx5_get_rule_flow_match(struct mlx5_flow_match *flow_match,
+                             struct mlx5_flow_rule *rule);
 #endif
-- 
2.8.0

Reply via email to