Skip to content

Commit 0477d51

Browse files
shayshyiSaeed Mahameed
authored andcommitted
net/mlx5: Expose SFs IRQs
Expose the sysfs files for the IRQs that the mlx5 PCI SFs are using. These entries are similar to PCI PFs and VFs in 'msi_irqs' directory. Reviewed-by: Parav Pandit <[email protected]> Signed-off-by: Shay Drory <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> --- v8-v9: - add Przemek RB v6->v7: - remove not needed changes to mlx5 sfnum SF sysfs v5->v6: - fail IRQ creation in case auxiliary_device_sysfs_irq_add() failed (Parav and Przemek) v2->v3: - fix mlx5 sfnum SF sysfs
1 parent a808878 commit 0477d51

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ static int create_async_eqs(struct mlx5_core_dev *dev)
714714
err1:
715715
mlx5_cmd_allowed_opcode(dev, CMD_ALLOWED_OPCODE_ALL);
716716
mlx5_eq_notifier_unregister(dev, &table->cq_err_nb);
717-
mlx5_ctrl_irq_release(table->ctrl_irq);
717+
mlx5_ctrl_irq_release(dev, table->ctrl_irq);
718718
return err;
719719
}
720720

@@ -730,7 +730,7 @@ static void destroy_async_eqs(struct mlx5_core_dev *dev)
730730
cleanup_async_eq(dev, &table->cmd_eq, "cmd");
731731
mlx5_cmd_allowed_opcode(dev, CMD_ALLOWED_OPCODE_ALL);
732732
mlx5_eq_notifier_unregister(dev, &table->cq_err_nb);
733-
mlx5_ctrl_irq_release(table->ctrl_irq);
733+
mlx5_ctrl_irq_release(dev, table->ctrl_irq);
734734
}
735735

736736
struct mlx5_eq *mlx5_get_async_eq(struct mlx5_core_dev *dev)
@@ -918,7 +918,7 @@ static int comp_irq_request_sf(struct mlx5_core_dev *dev, u16 vecidx)
918918
af_desc.is_managed = 1;
919919
cpumask_copy(&af_desc.mask, cpu_online_mask);
920920
cpumask_andnot(&af_desc.mask, &af_desc.mask, &table->used_cpus);
921-
irq = mlx5_irq_affinity_request(pool, &af_desc);
921+
irq = mlx5_irq_affinity_request(dev, pool, &af_desc);
922922
if (IS_ERR(irq))
923923
return PTR_ERR(irq);
924924

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,18 @@ irq_pool_find_least_loaded(struct mlx5_irq_pool *pool, const struct cpumask *req
112112

113113
/**
114114
* mlx5_irq_affinity_request - request an IRQ according to the given mask.
115+
* @dev: mlx5 core device which is requesting the IRQ.
115116
* @pool: IRQ pool to request from.
116117
* @af_desc: affinity descriptor for this IRQ.
117118
*
118119
* This function returns a pointer to IRQ, or ERR_PTR in case of error.
119120
*/
120121
struct mlx5_irq *
121-
mlx5_irq_affinity_request(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_desc)
122+
mlx5_irq_affinity_request(struct mlx5_core_dev *dev, struct mlx5_irq_pool *pool,
123+
struct irq_affinity_desc *af_desc)
122124
{
123125
struct mlx5_irq *least_loaded_irq, *new_irq;
126+
int ret;
124127

125128
mutex_lock(&pool->lock);
126129
least_loaded_irq = irq_pool_find_least_loaded(pool, &af_desc->mask);
@@ -153,6 +156,16 @@ mlx5_irq_affinity_request(struct mlx5_irq_pool *pool, struct irq_affinity_desc *
153156
mlx5_irq_read_locked(least_loaded_irq) / MLX5_EQ_REFS_PER_IRQ);
154157
unlock:
155158
mutex_unlock(&pool->lock);
159+
if (mlx5_irq_pool_is_sf_pool(pool)) {
160+
ret = auxiliary_device_sysfs_irq_add(mlx5_sf_coredev_to_adev(dev),
161+
mlx5_irq_get_irq(least_loaded_irq));
162+
if (ret) {
163+
mlx5_core_err(dev, "Failed to create sysfs entry for irq %d, ret = %d\n",
164+
mlx5_irq_get_irq(least_loaded_irq), ret);
165+
mlx5_irq_put(least_loaded_irq);
166+
least_loaded_irq = ERR_PTR(ret);
167+
}
168+
}
156169
return least_loaded_irq;
157170
}
158171

@@ -164,6 +177,9 @@ void mlx5_irq_affinity_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *i
164177
cpu = cpumask_first(mlx5_irq_get_affinity_mask(irq));
165178
synchronize_irq(pci_irq_vector(pool->dev->pdev,
166179
mlx5_irq_get_index(irq)));
180+
if (mlx5_irq_pool_is_sf_pool(pool))
181+
auxiliary_device_sysfs_irq_remove(mlx5_sf_coredev_to_adev(dev),
182+
mlx5_irq_get_irq(irq));
167183
if (mlx5_irq_put(irq))
168184
if (pool->irqs_per_cpu)
169185
cpu_put(pool, cpu);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ static inline bool mlx5_core_is_sf(const struct mlx5_core_dev *dev)
320320
return dev->coredev_type == MLX5_COREDEV_SF;
321321
}
322322

323+
static inline struct auxiliary_device *
324+
mlx5_sf_coredev_to_adev(struct mlx5_core_dev *mdev)
325+
{
326+
return container_of(mdev->device, struct auxiliary_device, dev);
327+
}
328+
323329
int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx);
324330
void mlx5_mdev_uninit(struct mlx5_core_dev *dev);
325331
int mlx5_init_one(struct mlx5_core_dev *dev);

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int mlx5_set_msix_vec_count(struct mlx5_core_dev *dev, int devfn,
2525
int mlx5_get_default_msix_vec_count(struct mlx5_core_dev *dev, int num_vfs);
2626

2727
struct mlx5_irq *mlx5_ctrl_irq_request(struct mlx5_core_dev *dev);
28-
void mlx5_ctrl_irq_release(struct mlx5_irq *ctrl_irq);
28+
void mlx5_ctrl_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *ctrl_irq);
2929
struct mlx5_irq *mlx5_irq_request(struct mlx5_core_dev *dev, u16 vecidx,
3030
struct irq_affinity_desc *af_desc,
3131
struct cpu_rmap **rmap);
@@ -36,13 +36,15 @@ int mlx5_irq_attach_nb(struct mlx5_irq *irq, struct notifier_block *nb);
3636
int mlx5_irq_detach_nb(struct mlx5_irq *irq, struct notifier_block *nb);
3737
struct cpumask *mlx5_irq_get_affinity_mask(struct mlx5_irq *irq);
3838
int mlx5_irq_get_index(struct mlx5_irq *irq);
39+
int mlx5_irq_get_irq(const struct mlx5_irq *irq);
3940

4041
struct mlx5_irq_pool;
4142
#ifdef CONFIG_MLX5_SF
4243
struct mlx5_irq *mlx5_irq_affinity_irq_request_auto(struct mlx5_core_dev *dev,
4344
struct cpumask *used_cpus, u16 vecidx);
44-
struct mlx5_irq *mlx5_irq_affinity_request(struct mlx5_irq_pool *pool,
45-
struct irq_affinity_desc *af_desc);
45+
struct mlx5_irq *
46+
mlx5_irq_affinity_request(struct mlx5_core_dev *dev, struct mlx5_irq_pool *pool,
47+
struct irq_affinity_desc *af_desc);
4648
void mlx5_irq_affinity_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *irq);
4749
#else
4850
static inline
@@ -53,14 +55,16 @@ struct mlx5_irq *mlx5_irq_affinity_irq_request_auto(struct mlx5_core_dev *dev,
5355
}
5456

5557
static inline struct mlx5_irq *
56-
mlx5_irq_affinity_request(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_desc)
58+
mlx5_irq_affinity_request(struct mlx5_core_dev *dev, struct mlx5_irq_pool *pool,
59+
struct irq_affinity_desc *af_desc)
5760
{
5861
return ERR_PTR(-EOPNOTSUPP);
5962
}
6063

6164
static inline
6265
void mlx5_irq_affinity_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *irq)
6366
{
67+
mlx5_irq_release_vector(irq);
6468
}
6569
#endif
6670
#endif /* __MLX5_IRQ_H__ */

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ struct cpumask *mlx5_irq_get_affinity_mask(struct mlx5_irq *irq)
367367
return irq->mask;
368368
}
369369

370+
int mlx5_irq_get_irq(const struct mlx5_irq *irq)
371+
{
372+
return irq->map.virq;
373+
}
374+
370375
int mlx5_irq_get_index(struct mlx5_irq *irq)
371376
{
372377
return irq->map.index;
@@ -440,11 +445,12 @@ static void _mlx5_irq_release(struct mlx5_irq *irq)
440445

441446
/**
442447
* mlx5_ctrl_irq_release - release a ctrl IRQ back to the system.
448+
* @dev: mlx5 device that releasing the IRQ.
443449
* @ctrl_irq: ctrl IRQ to be released.
444450
*/
445-
void mlx5_ctrl_irq_release(struct mlx5_irq *ctrl_irq)
451+
void mlx5_ctrl_irq_release(struct mlx5_core_dev *dev, struct mlx5_irq *ctrl_irq)
446452
{
447-
_mlx5_irq_release(ctrl_irq);
453+
mlx5_irq_affinity_irq_release(dev, ctrl_irq);
448454
}
449455

450456
/**
@@ -473,7 +479,7 @@ struct mlx5_irq *mlx5_ctrl_irq_request(struct mlx5_core_dev *dev)
473479
/* Allocate the IRQ in index 0. The vector was already allocated */
474480
irq = irq_pool_request_vector(pool, 0, &af_desc, NULL);
475481
} else {
476-
irq = mlx5_irq_affinity_request(pool, &af_desc);
482+
irq = mlx5_irq_affinity_request(dev, pool, &af_desc);
477483
}
478484

479485
return irq;

0 commit comments

Comments
 (0)