Skip to content

Commit 4b83c3c

Browse files
mark-blochrleon
authored andcommitted
RDMA/mlx5: Use the proper number of ports
The cited commit allowed the driver to operate over HCAs that have 4 physical ports. Use the number of ports of the RDMA device in the for loop instead of using the struct size. Fixes: 4cd14d4 ("net/mlx5: Support devices with more than 2 ports") Link: https://lore.kernel.org/r/a54a56c2ede16044a29d119209b35189c662ac72.1659944855.git.leonro@nvidia.com Signed-off-by: Mark Bloch <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]>
1 parent d6d142c commit 4b83c3c

File tree

1 file changed

+16
-18
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+16
-18
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,26 +2738,24 @@ static int set_has_smi_cap(struct mlx5_ib_dev *dev)
27382738
int err;
27392739
int port;
27402740

2741-
for (port = 1; port <= ARRAY_SIZE(dev->port_caps); port++) {
2742-
dev->port_caps[port - 1].has_smi = false;
2743-
if (MLX5_CAP_GEN(dev->mdev, port_type) ==
2744-
MLX5_CAP_PORT_TYPE_IB) {
2745-
if (MLX5_CAP_GEN(dev->mdev, ib_virt)) {
2746-
err = mlx5_query_hca_vport_context(dev->mdev, 0,
2747-
port, 0,
2748-
&vport_ctx);
2749-
if (err) {
2750-
mlx5_ib_err(dev, "query_hca_vport_context for port=%d failed %d\n",
2751-
port, err);
2752-
return err;
2753-
}
2754-
dev->port_caps[port - 1].has_smi =
2755-
vport_ctx.has_smi;
2756-
} else {
2757-
dev->port_caps[port - 1].has_smi = true;
2758-
}
2741+
if (MLX5_CAP_GEN(dev->mdev, port_type) != MLX5_CAP_PORT_TYPE_IB)
2742+
return 0;
2743+
2744+
for (port = 1; port <= dev->num_ports; port++) {
2745+
if (!MLX5_CAP_GEN(dev->mdev, ib_virt)) {
2746+
dev->port_caps[port - 1].has_smi = true;
2747+
continue;
27592748
}
2749+
err = mlx5_query_hca_vport_context(dev->mdev, 0, port, 0,
2750+
&vport_ctx);
2751+
if (err) {
2752+
mlx5_ib_err(dev, "query_hca_vport_context for port=%d failed %d\n",
2753+
port, err);
2754+
return err;
2755+
}
2756+
dev->port_caps[port - 1].has_smi = vport_ctx.has_smi;
27602757
}
2758+
27612759
return 0;
27622760
}
27632761

0 commit comments

Comments
 (0)