Skip to content

Commit 4160405

Browse files
mosheshemesh2kuba-moo
authored andcommitted
net/mlx5: fs, add HWS flow group API functions
Add API functions to create and destroy HW Steering flow groups. Each flow group consists of a Backward Compatible (BWC) HW Steering matcher which holds the flow group match criteria. Signed-off-by: Moshe Shemesh <[email protected]> Reviewed-by: Yevgeny Kliteynik <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0f3ecf5 commit 4160405

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fs_core.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ struct mlx5_flow_group_mask {
285285
/* Type of children is fs_fte */
286286
struct mlx5_flow_group {
287287
struct fs_node node;
288-
struct mlx5_fs_dr_matcher fs_dr_matcher;
288+
union {
289+
struct mlx5_fs_dr_matcher fs_dr_matcher;
290+
struct mlx5_fs_hws_matcher fs_hws_matcher;
291+
};
289292
struct mlx5_flow_group_mask mask;
290293
u32 start_index;
291294
u32 max_ftes;

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,53 @@ static int mlx5_cmd_hws_update_root_ft(struct mlx5_flow_root_namespace *ns,
153153
disconnect);
154154
}
155155

156+
static int mlx5_cmd_hws_create_flow_group(struct mlx5_flow_root_namespace *ns,
157+
struct mlx5_flow_table *ft, u32 *in,
158+
struct mlx5_flow_group *fg)
159+
{
160+
struct mlx5hws_match_parameters mask;
161+
struct mlx5hws_bwc_matcher *matcher;
162+
u8 match_criteria_enable;
163+
u32 priority;
164+
165+
if (mlx5_fs_cmd_is_fw_term_table(ft))
166+
return mlx5_fs_cmd_get_fw_cmds()->create_flow_group(ns, ft, in, fg);
167+
168+
mask.match_buf = MLX5_ADDR_OF(create_flow_group_in, in, match_criteria);
169+
mask.match_sz = sizeof(fg->mask.match_criteria);
170+
171+
match_criteria_enable = MLX5_GET(create_flow_group_in, in,
172+
match_criteria_enable);
173+
priority = MLX5_GET(create_flow_group_in, in, start_flow_index);
174+
matcher = mlx5hws_bwc_matcher_create(ft->fs_hws_table.hws_table,
175+
priority, match_criteria_enable,
176+
&mask);
177+
if (!matcher) {
178+
mlx5_core_err(ns->dev, "Failed creating matcher\n");
179+
return -EINVAL;
180+
}
181+
182+
fg->fs_hws_matcher.matcher = matcher;
183+
return 0;
184+
}
185+
186+
static int mlx5_cmd_hws_destroy_flow_group(struct mlx5_flow_root_namespace *ns,
187+
struct mlx5_flow_table *ft,
188+
struct mlx5_flow_group *fg)
189+
{
190+
if (mlx5_fs_cmd_is_fw_term_table(ft))
191+
return mlx5_fs_cmd_get_fw_cmds()->destroy_flow_group(ns, ft, fg);
192+
193+
return mlx5hws_bwc_matcher_destroy(fg->fs_hws_matcher.matcher);
194+
}
195+
156196
static const struct mlx5_flow_cmds mlx5_flow_cmds_hws = {
157197
.create_flow_table = mlx5_cmd_hws_create_flow_table,
158198
.destroy_flow_table = mlx5_cmd_hws_destroy_flow_table,
159199
.modify_flow_table = mlx5_cmd_hws_modify_flow_table,
160200
.update_root_ft = mlx5_cmd_hws_update_root_ft,
201+
.create_flow_group = mlx5_cmd_hws_create_flow_group,
202+
.destroy_flow_group = mlx5_cmd_hws_destroy_flow_group,
161203
.create_ns = mlx5_cmd_hws_create_ns,
162204
.destroy_ns = mlx5_cmd_hws_destroy_ns,
163205
.set_peer = mlx5_cmd_hws_set_peer,

drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ struct mlx5_fs_hws_table {
1515
bool miss_ft_set;
1616
};
1717

18+
struct mlx5_fs_hws_matcher {
19+
struct mlx5hws_bwc_matcher *matcher;
20+
};
21+
1822
#ifdef CONFIG_MLX5_HW_STEERING
1923

2024
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void);

0 commit comments

Comments
 (0)