]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
net/mlx4_core: Avoid setting ports to auto when only one port type is supported
authorMaor Gottlieb <maorg@mellanox.com>
Thu, 27 Oct 2016 13:27:14 +0000 (16:27 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 Oct 2016 20:23:48 +0000 (16:23 -0400)
When only one port type is supported, it should be read only.
We reject changing requests, even to the auto sense mode.

Fixes: 27bf91d6a0d5 ("mlx4_core: Add link type autosensing")
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/main.c

index 7183ac4135d2f97dbb1e7b63f2d57db4c95a5d0c..6f4e67bc35382e7a0b8de7c0b52cc24b3d81df91 100644 (file)
@@ -1102,6 +1102,14 @@ static int __set_port_type(struct mlx4_port_info *info,
        int i;
        int err = 0;
 
+       if ((port_type & mdev->caps.supported_type[info->port]) != port_type) {
+               mlx4_err(mdev,
+                        "Requested port type for port %d is not supported on this HCA\n",
+                        info->port);
+               err = -EINVAL;
+               goto err_sup;
+       }
+
        mlx4_stop_sense(mdev);
        mutex_lock(&priv->port_mutex);
        info->tmp_type = port_type;
@@ -1147,7 +1155,7 @@ static int __set_port_type(struct mlx4_port_info *info,
 out:
        mlx4_start_sense(mdev);
        mutex_unlock(&priv->port_mutex);
-
+err_sup:
        return err;
 }