Skip to content

Commit

Permalink
RDMA/mlx5: Move SMI caps logic
Browse files Browse the repository at this point in the history
We store the SMI information in the core device's struct, make sure we set
that information only once (and not per port), while here make the for
loop based on the actual size of the array.

Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Mark Bloch authored and Jason Gunthorpe committed Apr 10, 2019
1 parent 35b0aa6 commit a989ea0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/infiniband/hw/mlx5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4538,7 +4538,7 @@ static int set_has_smi_cap(struct mlx5_ib_dev *dev)
int err;
int port;

for (port = 1; port <= dev->num_ports; port++) {
for (port = 1; port <= ARRAY_SIZE(dev->mdev->port_caps); port++) {
dev->mdev->port_caps[port - 1].has_smi = false;
if (MLX5_CAP_GEN(dev->mdev, port_type) ==
MLX5_CAP_PORT_TYPE_IB) {
Expand Down Expand Up @@ -4584,10 +4584,6 @@ static int get_port_caps(struct mlx5_ib_dev *dev, u8 port)
if (!dprops)
goto out;

err = set_has_smi_cap(dev);
if (err)
goto out;

err = mlx5_ib_query_device(&dev->ib_dev, dprops, &uhw);
if (err) {
mlx5_ib_warn(dev, "query_device failed %d\n", err);
Expand Down Expand Up @@ -5890,6 +5886,10 @@ int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
if (err)
return err;

err = set_has_smi_cap(dev);
if (err)
return err;

if (!mlx5_core_mp_enabled(mdev)) {
for (i = 1; i <= dev->num_ports; i++) {
err = get_port_caps(dev, i);
Expand Down

0 comments on commit a989ea0

Please sign in to comment.