Skip to content

Commit 1021d06

Browse files
lrw514Saeed Mahameed
authored andcommitted
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 <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 2ec16dd commit 1021d06

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/linux/mlx5/driver.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,12 @@ static inline int mlx5_core_native_port_num(struct mlx5_core_dev *dev)
12451245

12461246
static inline int mlx5_get_dev_index(struct mlx5_core_dev *dev)
12471247
{
1248-
return PCI_FUNC(dev->pdev->devfn);
1248+
int idx = MLX5_CAP_GEN(dev, native_port_num);
1249+
1250+
if (idx >= 1 && idx <= MLX5_MAX_PORTS)
1251+
return idx - 1;
1252+
else
1253+
return PCI_FUNC(dev->pdev->devfn);
12491254
}
12501255

12511256
enum {

0 commit comments

Comments
 (0)