Commit 7e5856bd authored by Matt Carlson's avatar Matt Carlson Committed by David S. Miller

tg3: Update ethtool set_settings error checks

The ethtool interface has acquired some new enumerations since the
tg3 driver's tg3_set_settings() error checking code was written.  The
error checking code is no longer complete.  This patch rewrites the
error checking so that it is future-proofed.
Signed-off-by: default avatarMatt Carlson <mcarlson@broadcom.com>
Signed-off-by: default avatarBenjamin Li <benli@broadcom.com>
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f7b493e0
...@@ -8552,7 +8552,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -8552,7 +8552,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
cmd->duplex = tp->link_config.active_duplex; cmd->duplex = tp->link_config.active_duplex;
} }
cmd->phy_address = PHY_ADDR; cmd->phy_address = PHY_ADDR;
cmd->transceiver = 0; cmd->transceiver = XCVR_INTERNAL;
cmd->autoneg = tp->link_config.autoneg; cmd->autoneg = tp->link_config.autoneg;
cmd->maxtxpkt = 0; cmd->maxtxpkt = 0;
cmd->maxrxpkt = 0; cmd->maxrxpkt = 0;
...@@ -8569,25 +8569,57 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -8569,25 +8569,57 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
return phy_ethtool_sset(tp->mdio_bus->phy_map[PHY_ADDR], cmd); return phy_ethtool_sset(tp->mdio_bus->phy_map[PHY_ADDR], cmd);
} }
if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) { if (cmd->autoneg != AUTONEG_ENABLE &&
/* These are the only valid advertisement bits allowed. */ cmd->autoneg != AUTONEG_DISABLE)
if (cmd->autoneg == AUTONEG_ENABLE && return -EINVAL;
(cmd->advertising & ~(ADVERTISED_1000baseT_Half |
ADVERTISED_1000baseT_Full | if (cmd->autoneg == AUTONEG_DISABLE &&
ADVERTISED_Autoneg | cmd->duplex != DUPLEX_FULL &&
ADVERTISED_FIBRE))) cmd->duplex != DUPLEX_HALF)
return -EINVAL;
if (cmd->autoneg == AUTONEG_ENABLE) {
u32 mask = ADVERTISED_Autoneg |
ADVERTISED_Pause |
ADVERTISED_Asym_Pause;
if (!(tp->tg3_flags2 & TG3_FLAG_10_100_ONLY))
mask |= ADVERTISED_1000baseT_Half |
ADVERTISED_1000baseT_Full;
if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES))
mask |= ADVERTISED_100baseT_Half |
ADVERTISED_100baseT_Full |
ADVERTISED_10baseT_Half |
ADVERTISED_10baseT_Full |
ADVERTISED_TP;
else
mask |= ADVERTISED_FIBRE;
if (cmd->advertising & ~mask)
return -EINVAL; return -EINVAL;
/* Fiber can only do SPEED_1000. */
else if ((cmd->autoneg != AUTONEG_ENABLE) && mask &= (ADVERTISED_1000baseT_Half |
(cmd->speed != SPEED_1000)) ADVERTISED_1000baseT_Full |
ADVERTISED_100baseT_Half |
ADVERTISED_100baseT_Full |
ADVERTISED_10baseT_Half |
ADVERTISED_10baseT_Full);
cmd->advertising &= mask;
} else {
if (tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) {
if (cmd->speed != SPEED_1000)
return -EINVAL; return -EINVAL;
/* Copper cannot force SPEED_1000. */
} else if ((cmd->autoneg != AUTONEG_ENABLE) && if (cmd->duplex != DUPLEX_FULL)
(cmd->speed == SPEED_1000))
return -EINVAL; return -EINVAL;
else if ((cmd->speed == SPEED_1000) && } else {
(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) if (cmd->speed != SPEED_100 &&
cmd->speed != SPEED_10)
return -EINVAL; return -EINVAL;
}
}
tg3_full_lock(tp, 0); tg3_full_lock(tp, 0);
......
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