Skip to content

Commit

Permalink
net/mlx5: Introduce mlx5_cpumask_default_spread
Browse files Browse the repository at this point in the history
For better code readability in the completion IRQ request code, define
the cpu lookup per completion vector logic in a separate function.

The new method mlx5_cpumask_default_spread() given a vector index 'n'
will return the 'nth' cpu. This new method will be used also in the next
patch.

Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Maher Sanalla authored and Saeed Mahameed committed Aug 7, 2023
1 parent e3e5677 commit ddd2c79
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/eq.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,20 +826,18 @@ static void comp_irq_release_pci(struct mlx5_core_dev *dev, u16 vecidx)
mlx5_irq_release_vector(irq);
}

static int comp_irq_request_pci(struct mlx5_core_dev *dev, u16 vecidx)
static int mlx5_cpumask_default_spread(int numa_node, int index)
{
struct mlx5_eq_table *table = dev->priv.eq_table;
const struct cpumask *prev = cpu_none_mask;
const struct cpumask *mask;
struct mlx5_irq *irq;
int found_cpu = 0;
int i = 0;
int cpu;

rcu_read_lock();
for_each_numa_hop_mask(mask, dev->priv.numa_node) {
for_each_numa_hop_mask(mask, numa_node) {
for_each_cpu_andnot(cpu, mask, prev) {
if (i++ == vecidx) {
if (i++ == index) {
found_cpu = cpu;
goto spread_done;
}
Expand All @@ -849,7 +847,17 @@ static int comp_irq_request_pci(struct mlx5_core_dev *dev, u16 vecidx)

spread_done:
rcu_read_unlock();
irq = mlx5_irq_request_vector(dev, found_cpu, vecidx, &table->rmap);
return found_cpu;
}

static int comp_irq_request_pci(struct mlx5_core_dev *dev, u16 vecidx)
{
struct mlx5_eq_table *table = dev->priv.eq_table;
struct mlx5_irq *irq;
int cpu;

cpu = mlx5_cpumask_default_spread(dev->priv.numa_node, vecidx);
irq = mlx5_irq_request_vector(dev, cpu, vecidx, &table->rmap);
if (IS_ERR(irq))
return PTR_ERR(irq);

Expand Down

0 comments on commit ddd2c79

Please sign in to comment.