1 | // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB |
2 | /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. */ |
3 | |
4 | #include <linux/kernel.h> |
5 | #include <linux/mlx5/driver.h> |
6 | |
7 | #include "smfs.h" |
8 | |
9 | struct mlx5dr_matcher * |
10 | mlx5_smfs_matcher_create(struct mlx5dr_table *table, u32 priority, struct mlx5_flow_spec *spec) |
11 | { |
12 | struct mlx5dr_match_parameters matcher_mask = {}; |
13 | |
14 | matcher_mask.match_buf = (u64 *)&spec->match_criteria; |
15 | matcher_mask.match_sz = DR_SZ_MATCH_PARAM; |
16 | |
17 | return mlx5dr_matcher_create(table, priority, match_criteria_enable: spec->match_criteria_enable, mask: &matcher_mask); |
18 | } |
19 | |
20 | void |
21 | mlx5_smfs_matcher_destroy(struct mlx5dr_matcher *matcher) |
22 | { |
23 | mlx5dr_matcher_destroy(matcher); |
24 | } |
25 | |
26 | struct mlx5dr_table * |
27 | mlx5_smfs_table_get_from_fs_ft(struct mlx5_flow_table *ft) |
28 | { |
29 | return mlx5dr_table_get_from_fs_ft(ft); |
30 | } |
31 | |
32 | struct mlx5dr_action * |
33 | mlx5_smfs_action_create_dest_table(struct mlx5dr_table *table) |
34 | { |
35 | return mlx5dr_action_create_dest_table(table); |
36 | } |
37 | |
38 | struct mlx5dr_action * |
39 | mlx5_smfs_action_create_flow_counter(u32 counter_id) |
40 | { |
41 | return mlx5dr_action_create_flow_counter(counter_id); |
42 | } |
43 | |
44 | void |
45 | mlx5_smfs_action_destroy(struct mlx5dr_action *action) |
46 | { |
47 | mlx5dr_action_destroy(action); |
48 | } |
49 | |
50 | struct mlx5dr_rule * |
51 | mlx5_smfs_rule_create(struct mlx5dr_matcher *matcher, struct mlx5_flow_spec *spec, |
52 | size_t num_actions, struct mlx5dr_action *actions[], |
53 | u32 flow_source) |
54 | { |
55 | struct mlx5dr_match_parameters value = {}; |
56 | |
57 | value.match_buf = (u64 *)spec->match_value; |
58 | value.match_sz = DR_SZ_MATCH_PARAM; |
59 | |
60 | return mlx5dr_rule_create(matcher, value: &value, num_actions, actions, flow_source); |
61 | } |
62 | |
63 | void |
64 | mlx5_smfs_rule_destroy(struct mlx5dr_rule *rule) |
65 | { |
66 | mlx5dr_rule_destroy(rule); |
67 | } |
68 | |
69 | |