Skip to content

Commit 33a1f8b

Browse files
Maor Gottliebdavem330
authored andcommitted
net/mlx4_core: Avoid setting ports to auto when only one port type is supported
When only one port type is supported, it should be read only. We reject changing requests, even to the auto sense mode. Fixes: 27bf91d ("mlx4_core: Add link type autosensing") Signed-off-by: Maor Gottlieb <[email protected]> Signed-off-by: Moshe Shemesh <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aa0c08f commit 33a1f8b

File tree

1 file changed

+9
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+9
-1
lines changed

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,14 @@ static int __set_port_type(struct mlx4_port_info *info,
11021102
int i;
11031103
int err = 0;
11041104

1105+
if ((port_type & mdev->caps.supported_type[info->port]) != port_type) {
1106+
mlx4_err(mdev,
1107+
"Requested port type for port %d is not supported on this HCA\n",
1108+
info->port);
1109+
err = -EINVAL;
1110+
goto err_sup;
1111+
}
1112+
11051113
mlx4_stop_sense(mdev);
11061114
mutex_lock(&priv->port_mutex);
11071115
info->tmp_type = port_type;
@@ -1147,7 +1155,7 @@ static int __set_port_type(struct mlx4_port_info *info,
11471155
out:
11481156
mlx4_start_sense(mdev);
11491157
mutex_unlock(&priv->port_mutex);
1150-
1158+
err_sup:
11511159
return err;
11521160
}
11531161

0 commit comments

Comments
 (0)