Skip to content

Commit 20d80b9

Browse files
danielj-mellanoxkuba-moo
authored andcommitted
net/mlx5: Set default max eqs for SFs
If the user hasn't configured max_io_eqs set a low default. The SF driver shouldn't try to create more than this, but FW will enforce this limit. Signed-off-by: Daniel Jurgens <[email protected]> Reviewed-by: William Tu <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2ece6c7 commit 20d80b9

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ struct mlx5_vport {
223223

224224
u16 vport;
225225
bool enabled;
226+
bool max_eqs_set;
226227
enum mlx5_eswitch_vport_event enabled_events;
227228
int index;
228229
struct mlx5_devlink_port *dl_port;
@@ -579,6 +580,8 @@ int mlx5_devlink_port_fn_max_io_eqs_get(struct devlink_port *port,
579580
int mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port,
580581
u32 max_io_eqs,
581582
struct netlink_ext_ack *extack);
583+
int mlx5_devlink_port_fn_max_io_eqs_set_sf_default(struct devlink_port *port,
584+
struct netlink_ext_ack *extack);
582585

583586
void *mlx5_eswitch_get_uplink_priv(struct mlx5_eswitch *esw, u8 rep_type);
584587

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#define MLX5_ESW_FT_OFFLOADS_DROP_RULE (1)
6969

7070
#define MLX5_ESW_MAX_CTRL_EQS 4
71+
#define MLX5_ESW_DEFAULT_SF_COMP_EQS 8
7172

7273
static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
7374
.max_fte = MLX5_ESW_VPORT_TBL_SIZE,
@@ -4683,9 +4684,18 @@ mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port, u32 max_io_eqs,
46834684
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE2);
46844685
if (err)
46854686
NL_SET_ERR_MSG_MOD(extack, "Failed setting HCA caps");
4686-
4687+
vport->max_eqs_set = true;
46874688
out:
46884689
mutex_unlock(&esw->state_lock);
46894690
kfree(query_ctx);
46904691
return err;
46914692
}
4693+
4694+
int
4695+
mlx5_devlink_port_fn_max_io_eqs_set_sf_default(struct devlink_port *port,
4696+
struct netlink_ext_ack *extack)
4697+
{
4698+
return mlx5_devlink_port_fn_max_io_eqs_set(port,
4699+
MLX5_ESW_DEFAULT_SF_COMP_EQS,
4700+
extack);
4701+
}

drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ int mlx5_devlink_sf_port_fn_state_get(struct devlink_port *dl_port,
161161
static int mlx5_sf_activate(struct mlx5_core_dev *dev, struct mlx5_sf *sf,
162162
struct netlink_ext_ack *extack)
163163
{
164+
struct mlx5_vport *vport;
164165
int err;
165166

166167
if (mlx5_sf_is_active(sf))
@@ -170,6 +171,13 @@ static int mlx5_sf_activate(struct mlx5_core_dev *dev, struct mlx5_sf *sf,
170171
return -EBUSY;
171172
}
172173

174+
vport = mlx5_devlink_port_vport_get(&sf->dl_port.dl_port);
175+
if (!vport->max_eqs_set && MLX5_CAP_GEN_2(dev, max_num_eqs_24b)) {
176+
err = mlx5_devlink_port_fn_max_io_eqs_set_sf_default(&sf->dl_port.dl_port,
177+
extack);
178+
if (err)
179+
return err;
180+
}
173181
err = mlx5_cmd_sf_enable_hca(dev, sf->hw_fn_id);
174182
if (err)
175183
return err;
@@ -318,7 +326,11 @@ int mlx5_devlink_sf_port_new(struct devlink *devlink,
318326

319327
static void mlx5_sf_dealloc(struct mlx5_sf_table *table, struct mlx5_sf *sf)
320328
{
329+
struct mlx5_vport *vport;
330+
321331
mutex_lock(&table->sf_state_lock);
332+
vport = mlx5_devlink_port_vport_get(&sf->dl_port.dl_port);
333+
vport->max_eqs_set = false;
322334

323335
mlx5_sf_function_id_erase(table, sf);
324336

0 commit comments

Comments
 (0)