Skip to content

Commit

Permalink
net/mlx5: Use native_port_num as 1st option of device index
Browse files Browse the repository at this point in the history
Using "native_port_num" can support more NICs.

Fallback to PCIe IDs if "native_port_num" query fails.

Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Rongwei Liu authored and Saeed Mahameed committed Oct 16, 2021
1 parent 2ec16dd commit 1021d06
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/linux/mlx5/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,12 @@ static inline int mlx5_core_native_port_num(struct mlx5_core_dev *dev)

static inline int mlx5_get_dev_index(struct mlx5_core_dev *dev)
{
return PCI_FUNC(dev->pdev->devfn);
int idx = MLX5_CAP_GEN(dev, native_port_num);

if (idx >= 1 && idx <= MLX5_MAX_PORTS)
return idx - 1;
else
return PCI_FUNC(dev->pdev->devfn);
}

enum {
Expand Down

0 comments on commit 1021d06

Please sign in to comment.