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>
 
 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 {