Skip to content

Commit 0f3ecf5

Browse files
mosheshemesh2kuba-moo
authored andcommitted
net/mlx5: fs, add HWS flow table API functions
Add API functions to create, modify and destroy HW Steering flow tables. Modify table enables change, connect or disconnect default miss table. Add update root flow table API function. 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 cbfdefc commit 0f3ecf5

File tree

3 files changed

+122
-1
lines changed

3 files changed

+122
-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
@@ -192,7 +192,10 @@ struct mlx5_flow_handle {
192192
/* Type of children is mlx5_flow_group */
193193
struct mlx5_flow_table {
194194
struct fs_node node;
195-
struct mlx5_fs_dr_table fs_dr_table;
195+
union {
196+
struct mlx5_fs_dr_table fs_dr_table;
197+
struct mlx5_fs_hws_table fs_hws_table;
198+
};
196199
u32 id;
197200
u16 vport;
198201
unsigned int max_fte;

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

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,120 @@ static int mlx5_cmd_hws_set_peer(struct mlx5_flow_root_namespace *ns,
4444
return 0;
4545
}
4646

47+
static int mlx5_fs_set_ft_default_miss(struct mlx5_flow_root_namespace *ns,
48+
struct mlx5_flow_table *ft,
49+
struct mlx5_flow_table *next_ft)
50+
{
51+
struct mlx5hws_table *next_tbl;
52+
int err;
53+
54+
if (!ns->fs_hws_context.hws_ctx)
55+
return -EINVAL;
56+
57+
/* if no change required, return */
58+
if (!next_ft && !ft->fs_hws_table.miss_ft_set)
59+
return 0;
60+
61+
next_tbl = next_ft ? next_ft->fs_hws_table.hws_table : NULL;
62+
err = mlx5hws_table_set_default_miss(ft->fs_hws_table.hws_table, next_tbl);
63+
if (err) {
64+
mlx5_core_err(ns->dev, "Failed setting FT default miss (%d)\n", err);
65+
return err;
66+
}
67+
ft->fs_hws_table.miss_ft_set = !!next_tbl;
68+
return 0;
69+
}
70+
71+
static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns,
72+
struct mlx5_flow_table *ft,
73+
struct mlx5_flow_table_attr *ft_attr,
74+
struct mlx5_flow_table *next_ft)
75+
{
76+
struct mlx5hws_context *ctx = ns->fs_hws_context.hws_ctx;
77+
struct mlx5hws_table_attr tbl_attr = {};
78+
struct mlx5hws_table *tbl;
79+
int err;
80+
81+
if (mlx5_fs_cmd_is_fw_term_table(ft))
82+
return mlx5_fs_cmd_get_fw_cmds()->create_flow_table(ns, ft, ft_attr,
83+
next_ft);
84+
85+
if (ns->table_type != FS_FT_FDB) {
86+
mlx5_core_err(ns->dev, "Table type %d not supported for HWS\n",
87+
ns->table_type);
88+
return -EOPNOTSUPP;
89+
}
90+
91+
tbl_attr.type = MLX5HWS_TABLE_TYPE_FDB;
92+
tbl_attr.level = ft_attr->level;
93+
tbl = mlx5hws_table_create(ctx, &tbl_attr);
94+
if (!tbl) {
95+
mlx5_core_err(ns->dev, "Failed creating hws flow_table\n");
96+
return -EINVAL;
97+
}
98+
99+
ft->fs_hws_table.hws_table = tbl;
100+
ft->id = mlx5hws_table_get_id(tbl);
101+
102+
if (next_ft) {
103+
err = mlx5_fs_set_ft_default_miss(ns, ft, next_ft);
104+
if (err)
105+
goto destroy_table;
106+
}
107+
108+
ft->max_fte = INT_MAX;
109+
110+
return 0;
111+
112+
destroy_table:
113+
mlx5hws_table_destroy(tbl);
114+
ft->fs_hws_table.hws_table = NULL;
115+
return err;
116+
}
117+
118+
static int mlx5_cmd_hws_destroy_flow_table(struct mlx5_flow_root_namespace *ns,
119+
struct mlx5_flow_table *ft)
120+
{
121+
int err;
122+
123+
if (mlx5_fs_cmd_is_fw_term_table(ft))
124+
return mlx5_fs_cmd_get_fw_cmds()->destroy_flow_table(ns, ft);
125+
126+
err = mlx5_fs_set_ft_default_miss(ns, ft, NULL);
127+
if (err)
128+
mlx5_core_err(ns->dev, "Failed to disconnect next table (%d)\n", err);
129+
130+
err = mlx5hws_table_destroy(ft->fs_hws_table.hws_table);
131+
if (err)
132+
mlx5_core_err(ns->dev, "Failed to destroy flow_table (%d)\n", err);
133+
134+
return err;
135+
}
136+
137+
static int mlx5_cmd_hws_modify_flow_table(struct mlx5_flow_root_namespace *ns,
138+
struct mlx5_flow_table *ft,
139+
struct mlx5_flow_table *next_ft)
140+
{
141+
if (mlx5_fs_cmd_is_fw_term_table(ft))
142+
return mlx5_fs_cmd_get_fw_cmds()->modify_flow_table(ns, ft, next_ft);
143+
144+
return mlx5_fs_set_ft_default_miss(ns, ft, next_ft);
145+
}
146+
147+
static int mlx5_cmd_hws_update_root_ft(struct mlx5_flow_root_namespace *ns,
148+
struct mlx5_flow_table *ft,
149+
u32 underlay_qpn,
150+
bool disconnect)
151+
{
152+
return mlx5_fs_cmd_get_fw_cmds()->update_root_ft(ns, ft, underlay_qpn,
153+
disconnect);
154+
}
155+
47156
static const struct mlx5_flow_cmds mlx5_flow_cmds_hws = {
157+
.create_flow_table = mlx5_cmd_hws_create_flow_table,
158+
.destroy_flow_table = mlx5_cmd_hws_destroy_flow_table,
159+
.modify_flow_table = mlx5_cmd_hws_modify_flow_table,
160+
.update_root_ft = mlx5_cmd_hws_update_root_ft,
48161
.create_ns = mlx5_cmd_hws_create_ns,
49162
.destroy_ns = mlx5_cmd_hws_destroy_ns,
50163
.set_peer = mlx5_cmd_hws_set_peer,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ struct mlx5_fs_hws_context {
1010
struct mlx5hws_context *hws_ctx;
1111
};
1212

13+
struct mlx5_fs_hws_table {
14+
struct mlx5hws_table *hws_table;
15+
bool miss_ft_set;
16+
};
17+
1318
#ifdef CONFIG_MLX5_HW_STEERING
1419

1520
const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void);

0 commit comments

Comments
 (0)