Skip to content

Commit 22767ee

Browse files
committed
Merge branch 'mlx5-misc-2023-07-08-sf-max-eq'
Saeed Mahameed says: ==================== mlx5 misc 2023-07-08 (sf max eq) Link: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents f7023b3 + 4b66be7 commit 22767ee

File tree

6 files changed

+41
-12
lines changed

6 files changed

+41
-12
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,6 @@ static int get_num_eqs(struct mlx5_core_dev *dev)
11871187
{
11881188
struct mlx5_eq_table *eq_table = dev->priv.eq_table;
11891189
int max_dev_eqs;
1190-
int max_eqs_sf;
11911190
int num_eqs;
11921191

11931192
/* If ethernet is disabled we use just a single completion vector to
@@ -1202,7 +1201,11 @@ static int get_num_eqs(struct mlx5_core_dev *dev)
12021201
num_eqs = min_t(int, mlx5_irq_table_get_num_comp(eq_table->irq_table),
12031202
max_dev_eqs - MLX5_MAX_ASYNC_EQS);
12041203
if (mlx5_core_is_sf(dev)) {
1205-
max_eqs_sf = min_t(int, MLX5_COMP_EQS_PER_SF,
1204+
int max_eqs_sf = MLX5_CAP_GEN_2(dev, sf_eq_usage) ?
1205+
MLX5_CAP_GEN_2(dev, max_num_eqs_24b) :
1206+
MLX5_COMP_EQS_PER_SF;
1207+
1208+
max_eqs_sf = min_t(int, max_eqs_sf,
12061209
mlx5_irq_table_get_sfs_vec(eq_table->irq_table));
12071210
num_eqs = min_t(int, num_eqs, max_eqs_sf);
12081211
}

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: 14 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,
@@ -4676,13 +4677,25 @@ mlx5_devlink_port_fn_max_io_eqs_set(struct devlink_port *port, u32 max_io_eqs,
46764677
hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability);
46774678
MLX5_SET(cmd_hca_cap_2, hca_caps, max_num_eqs_24b, max_eqs);
46784679

4680+
if (mlx5_esw_is_sf_vport(esw, vport_num))
4681+
MLX5_SET(cmd_hca_cap_2, hca_caps, sf_eq_usage, 1);
4682+
46794683
err = mlx5_vport_set_other_func_cap(esw->dev, hca_caps, vport_num,
46804684
MLX5_SET_HCA_CAP_OP_MOD_GENERAL_DEVICE2);
46814685
if (err)
46824686
NL_SET_ERR_MSG_MOD(extack, "Failed setting HCA caps");
4683-
4687+
vport->max_eqs_set = true;
46844688
out:
46854689
mutex_unlock(&esw->state_lock);
46864690
kfree(query_ctx);
46874691
return err;
46884692
}
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/pci_irq.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#endif
1717

1818
#define MLX5_SFS_PER_CTRL_IRQ 64
19+
#define MLX5_MAX_MSIX_PER_SF 256
1920
#define MLX5_IRQ_CTRL_SF_MAX 8
2021
/* min num of vectors for SFs to be enabled */
2122
#define MLX5_IRQ_VEC_COMP_BASE_SF 2
@@ -589,8 +590,6 @@ static void irq_pool_free(struct mlx5_irq_pool *pool)
589590
static int irq_pools_init(struct mlx5_core_dev *dev, int sf_vec, int pcif_vec)
590591
{
591592
struct mlx5_irq_table *table = dev->priv.irq_table;
592-
int num_sf_ctrl_by_msix;
593-
int num_sf_ctrl_by_sfs;
594593
int num_sf_ctrl;
595594
int err;
596595

@@ -608,10 +607,8 @@ static int irq_pools_init(struct mlx5_core_dev *dev, int sf_vec, int pcif_vec)
608607
}
609608

610609
/* init sf_ctrl_pool */
611-
num_sf_ctrl_by_msix = DIV_ROUND_UP(sf_vec, MLX5_COMP_EQS_PER_SF);
612-
num_sf_ctrl_by_sfs = DIV_ROUND_UP(mlx5_sf_max_functions(dev),
613-
MLX5_SFS_PER_CTRL_IRQ);
614-
num_sf_ctrl = min_t(int, num_sf_ctrl_by_msix, num_sf_ctrl_by_sfs);
610+
num_sf_ctrl = DIV_ROUND_UP(mlx5_sf_max_functions(dev),
611+
MLX5_SFS_PER_CTRL_IRQ);
615612
num_sf_ctrl = min_t(int, MLX5_IRQ_CTRL_SF_MAX, num_sf_ctrl);
616613
table->sf_ctrl_pool = irq_pool_alloc(dev, pcif_vec, num_sf_ctrl,
617614
"mlx5_sf_ctrl",
@@ -726,8 +723,7 @@ int mlx5_irq_table_create(struct mlx5_core_dev *dev)
726723

727724
total_vec = pcif_vec;
728725
if (mlx5_sf_max_functions(dev))
729-
total_vec += MLX5_IRQ_CTRL_SF_MAX +
730-
MLX5_COMP_EQS_PER_SF * mlx5_sf_max_functions(dev);
726+
total_vec += MLX5_MAX_MSIX_PER_SF * mlx5_sf_max_functions(dev);
731727
total_vec = min_t(int, total_vec, pci_msix_vec_count(dev->pdev));
732728
pcif_vec = min_t(int, pcif_vec, pci_msix_vec_count(dev->pdev));
733729

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

include/linux/mlx5/mlx5_ifc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,9 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {
19941994
u8 migration_tracking_state[0x1];
19951995
u8 reserved_at_ca[0x6];
19961996
u8 migration_in_chunks[0x1];
1997-
u8 reserved_at_d1[0xf];
1997+
u8 reserved_at_d1[0x1];
1998+
u8 sf_eq_usage[0x1];
1999+
u8 reserved_at_d3[0xd];
19982000

19992001
u8 cross_vhca_object_to_object_supported[0x20];
20002002

0 commit comments

Comments
 (0)