Commit 5a228c03 authored by Saeed Mahameed's avatar Saeed Mahameed Committed by David S. Miller

net/mlx4_en: Use ethtool cmd->autoneg as a hint for ethtool set settings

Use cmd->autoneg as a user hint to decide what to set in ethtool set settings callback.
When cmd->autoneg == AUTONEG_ENABLE set according to ethtool->advertise otherwise,
set according to ethtool->speed.

Usage:
	- ethtool -s eth<x> speed 56000 autoneg off
	- ethtool -s eth<x> advertise 0x800000 autoneg on

While we're here:
	- Move proto_admin masking outcome check to be adjacent to the operation.
	- Move en_warn("port reset..") print to "port reset" block.

Fixes: 312df74c ("net/mlx4_en: mlx4_en_set_settings() always fails when autoneg is set")
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarAmir Vadai <amirv@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ef0223e6
...@@ -770,22 +770,20 @@ static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -770,22 +770,20 @@ static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
return 0; return 0;
} }
proto_admin = cpu_to_be32(ptys_adv); proto_admin = cmd->autoneg == AUTONEG_ENABLE ?
if (speed >= 0 && speed != priv->port_state.link_speed) cpu_to_be32(ptys_adv) :
/* If speed was set then speed decides :-) */ speed_set_ptys_admin(priv, speed,
proto_admin = speed_set_ptys_admin(priv, speed,
ptys_reg.eth_proto_cap); ptys_reg.eth_proto_cap);
proto_admin &= ptys_reg.eth_proto_cap; proto_admin &= ptys_reg.eth_proto_cap;
if (proto_admin == ptys_reg.eth_proto_admin)
return 0; /* Nothing to change */
if (!proto_admin) { if (!proto_admin) {
en_warn(priv, "Not supported link mode(s) requested, check supported link modes.\n"); en_warn(priv, "Not supported link mode(s) requested, check supported link modes.\n");
return -EINVAL; /* nothing to change due to bad input */ return -EINVAL; /* nothing to change due to bad input */
} }
if (proto_admin == ptys_reg.eth_proto_admin)
return 0; /* Nothing to change */
en_dbg(DRV, priv, "mlx4_ACCESS_PTYS_REG SET: ptys_reg.eth_proto_admin = 0x%x\n", en_dbg(DRV, priv, "mlx4_ACCESS_PTYS_REG SET: ptys_reg.eth_proto_admin = 0x%x\n",
be32_to_cpu(proto_admin)); be32_to_cpu(proto_admin));
...@@ -798,9 +796,9 @@ static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -798,9 +796,9 @@ static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
return ret; return ret;
} }
en_warn(priv, "Port link mode changed, restarting port...\n");
mutex_lock(&priv->mdev->state_lock); mutex_lock(&priv->mdev->state_lock);
if (priv->port_up) { if (priv->port_up) {
en_warn(priv, "Port link mode changed, restarting port...\n");
mlx4_en_stop_port(dev, 1); mlx4_en_stop_port(dev, 1);
if (mlx4_en_start_port(dev)) if (mlx4_en_start_port(dev))
en_err(priv, "Failed restarting port %d\n", priv->port); en_err(priv, "Failed restarting port %d\n", priv->port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment