From: Rongwei Liu Date: Tue, 12 Oct 2021 07:40:52 +0000 (+0300) Subject: net/mlx5: Use native_port_num as 1st option of device index X-Git-Tag: block-5.16-2021-11-13~96^2~181^2~1 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1021d0645d593ea86193c5fc371e33e5b208e14d;p=linux-2.6-block.git net/mlx5: Use native_port_num as 1st option of device index Using "native_port_num" can support more NICs. Fallback to PCIe IDs if "native_port_num" query fails. Signed-off-by: Rongwei Liu Reviewed-by: Mark Bloch Signed-off-by: Saeed Mahameed --- diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index aecc38b90de5..cf508685abca 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -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 {