Skip to content

Commit 9ab8947

Browse files
alexveskergregkh
authored andcommitted
net/mlx5: HWS, Fix table creation UID
[ Upstream commit 8a51507 ] During table creation, caller passes a UID using ft_attr. The UID value was ignored, which leads to problems when the caller sets the UID to a non-zero value, such as SHARED_RESOURCE_UID (0xffff) - the internal FT objects will be created with UID=0. Fixes: 0869701 ("net/mlx5: HWS, added FW commands handling") Signed-off-by: Alex Vesker <valex@nvidia.com> Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com> Signed-off-by: Mark Bloch <mbloch@nvidia.com> Link: https://patch.msgid.link/20250817202323.308604-7-mbloch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 37d54bc commit 9ab8947

File tree

7 files changed

+20
-5
lines changed

7 files changed

+20
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ int mlx5hws_cmd_flow_table_create(struct mlx5_core_dev *mdev,
5555

5656
MLX5_SET(create_flow_table_in, in, opcode, MLX5_CMD_OP_CREATE_FLOW_TABLE);
5757
MLX5_SET(create_flow_table_in, in, table_type, ft_attr->type);
58+
MLX5_SET(create_flow_table_in, in, uid, ft_attr->uid);
5859

5960
ft_ctx = MLX5_ADDR_OF(create_flow_table_in, in, flow_table_context);
6061
MLX5_SET(flow_table_context, ft_ctx, level, ft_attr->level);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct mlx5hws_cmd_set_fte_attr {
3636
struct mlx5hws_cmd_ft_create_attr {
3737
u8 type;
3838
u8 level;
39+
u16 uid;
3940
bool rtc_valid;
4041
bool decap_en;
4142
bool reformat_en;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns,
267267

268268
tbl_attr.type = MLX5HWS_TABLE_TYPE_FDB;
269269
tbl_attr.level = ft_attr->level;
270+
tbl_attr.uid = ft_attr->uid;
270271
tbl = mlx5hws_table_create(ctx, &tbl_attr);
271272
if (!tbl) {
272273
mlx5_core_err(ns->dev, "Failed creating hws flow_table\n");

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static int hws_matcher_create_end_ft_isolated(struct mlx5hws_matcher *matcher)
8585

8686
ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev,
8787
tbl,
88+
0,
8889
&matcher->end_ft_id);
8990
if (ret) {
9091
mlx5hws_err(tbl->ctx, "Isolated matcher: failed to create end flow table\n");
@@ -112,7 +113,9 @@ static int hws_matcher_create_end_ft(struct mlx5hws_matcher *matcher)
112113
if (mlx5hws_matcher_is_isolated(matcher))
113114
ret = hws_matcher_create_end_ft_isolated(matcher);
114115
else
115-
ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev, tbl,
116+
ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev,
117+
tbl,
118+
0,
116119
&matcher->end_ft_id);
117120

118121
if (ret) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct mlx5hws_context_attr {
7575
struct mlx5hws_table_attr {
7676
enum mlx5hws_table_type type;
7777
u32 level;
78+
u16 uid;
7879
};
7980

8081
enum mlx5hws_matcher_flow_src {

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ u32 mlx5hws_table_get_id(struct mlx5hws_table *tbl)
99
}
1010

1111
static void hws_table_init_next_ft_attr(struct mlx5hws_table *tbl,
12+
u16 uid,
1213
struct mlx5hws_cmd_ft_create_attr *ft_attr)
1314
{
1415
ft_attr->type = tbl->fw_ft_type;
1516
if (tbl->type == MLX5HWS_TABLE_TYPE_FDB)
1617
ft_attr->level = tbl->ctx->caps->fdb_ft.max_level - 1;
1718
else
1819
ft_attr->level = tbl->ctx->caps->nic_ft.max_level - 1;
20+
1921
ft_attr->rtc_valid = true;
22+
ft_attr->uid = uid;
2023
}
2124

2225
static void hws_table_set_cap_attr(struct mlx5hws_table *tbl,
@@ -119,12 +122,12 @@ static int hws_table_connect_to_default_miss_tbl(struct mlx5hws_table *tbl, u32
119122

120123
int mlx5hws_table_create_default_ft(struct mlx5_core_dev *mdev,
121124
struct mlx5hws_table *tbl,
122-
u32 *ft_id)
125+
u16 uid, u32 *ft_id)
123126
{
124127
struct mlx5hws_cmd_ft_create_attr ft_attr = {0};
125128
int ret;
126129

127-
hws_table_init_next_ft_attr(tbl, &ft_attr);
130+
hws_table_init_next_ft_attr(tbl, uid, &ft_attr);
128131
hws_table_set_cap_attr(tbl, &ft_attr);
129132

130133
ret = mlx5hws_cmd_flow_table_create(mdev, &ft_attr, ft_id);
@@ -189,7 +192,10 @@ static int hws_table_init(struct mlx5hws_table *tbl)
189192
}
190193

191194
mutex_lock(&ctx->ctrl_lock);
192-
ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev, tbl, &tbl->ft_id);
195+
ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev,
196+
tbl,
197+
tbl->uid,
198+
&tbl->ft_id);
193199
if (ret) {
194200
mlx5hws_err(tbl->ctx, "Failed to create flow table object\n");
195201
mutex_unlock(&ctx->ctrl_lock);
@@ -239,6 +245,7 @@ struct mlx5hws_table *mlx5hws_table_create(struct mlx5hws_context *ctx,
239245
tbl->ctx = ctx;
240246
tbl->type = attr->type;
241247
tbl->level = attr->level;
248+
tbl->uid = attr->uid;
242249

243250
ret = hws_table_init(tbl);
244251
if (ret) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct mlx5hws_table {
1818
enum mlx5hws_table_type type;
1919
u32 fw_ft_type;
2020
u32 level;
21+
u16 uid;
2122
struct list_head matchers_list;
2223
struct list_head tbl_list_node;
2324
struct mlx5hws_default_miss default_miss;
@@ -47,7 +48,7 @@ u32 mlx5hws_table_get_res_fw_ft_type(enum mlx5hws_table_type tbl_type,
4748

4849
int mlx5hws_table_create_default_ft(struct mlx5_core_dev *mdev,
4950
struct mlx5hws_table *tbl,
50-
u32 *ft_id);
51+
u16 uid, u32 *ft_id);
5152

5253
void mlx5hws_table_destroy_default_ft(struct mlx5hws_table *tbl,
5354
u32 ft_id);

0 commit comments

Comments
 (0)