diff options
author | David Decotigny <decot@google.com> | 2011-04-27 14:32:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-29 17:03:00 -0400 |
commit | 25db0338813a8915457636b1f6abe6a28fa73f8d (patch) | |
tree | 29ea39e45de1342beb4e3c58da0cfbc9915b617e /drivers/net | |
parent | 8ae6daca85c8bbd6a32c382db5e2a2a989f8bed2 (diff) |
ethtool: Use full 32 bit speed range in ethtool's set_settings
This makes sure the ethtool's set_settings() callback of network
drivers don't ignore the 16 most significant bits when ethtool calls
their set_settings().
All drivers compiled with make allyesconfig on x86_64 have been
updated.
Signed-off-by: David Decotigny <decot@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
43 files changed, 161 insertions, 129 deletions
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c index ee648fe5d96f..0b4d8d13c488 100644 --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c | |||
@@ -2718,7 +2718,7 @@ static int ace_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
2718 | link |= LNK_TX_FLOW_CTL_Y; | 2718 | link |= LNK_TX_FLOW_CTL_Y; |
2719 | if (ecmd->autoneg == AUTONEG_ENABLE) | 2719 | if (ecmd->autoneg == AUTONEG_ENABLE) |
2720 | link |= LNK_NEGOTIATE; | 2720 | link |= LNK_NEGOTIATE; |
2721 | if (ecmd->speed != speed) { | 2721 | if (ethtool_cmd_speed(ecmd) != speed) { |
2722 | link &= ~(LNK_1000MB | LNK_100MB | LNK_10MB); | 2722 | link &= ~(LNK_1000MB | LNK_100MB | LNK_10MB); |
2723 | switch (speed) { | 2723 | switch (speed) { |
2724 | case SPEED_1000: | 2724 | case SPEED_1000: |
diff --git a/drivers/net/atl1c/atl1c_ethtool.c b/drivers/net/atl1c/atl1c_ethtool.c index 3af5a336a5af..b1eceee424aa 100644 --- a/drivers/net/atl1c/atl1c_ethtool.c +++ b/drivers/net/atl1c/atl1c_ethtool.c | |||
@@ -77,7 +77,8 @@ static int atl1c_set_settings(struct net_device *netdev, | |||
77 | if (ecmd->autoneg == AUTONEG_ENABLE) { | 77 | if (ecmd->autoneg == AUTONEG_ENABLE) { |
78 | autoneg_advertised = ADVERTISED_Autoneg; | 78 | autoneg_advertised = ADVERTISED_Autoneg; |
79 | } else { | 79 | } else { |
80 | if (ecmd->speed == SPEED_1000) { | 80 | u32 speed = ethtool_cmd_speed(ecmd); |
81 | if (speed == SPEED_1000) { | ||
81 | if (ecmd->duplex != DUPLEX_FULL) { | 82 | if (ecmd->duplex != DUPLEX_FULL) { |
82 | if (netif_msg_link(adapter)) | 83 | if (netif_msg_link(adapter)) |
83 | dev_warn(&adapter->pdev->dev, | 84 | dev_warn(&adapter->pdev->dev, |
@@ -86,7 +87,7 @@ static int atl1c_set_settings(struct net_device *netdev, | |||
86 | return -EINVAL; | 87 | return -EINVAL; |
87 | } | 88 | } |
88 | autoneg_advertised = ADVERTISED_1000baseT_Full; | 89 | autoneg_advertised = ADVERTISED_1000baseT_Full; |
89 | } else if (ecmd->speed == SPEED_100) { | 90 | } else if (speed == SPEED_100) { |
90 | if (ecmd->duplex == DUPLEX_FULL) | 91 | if (ecmd->duplex == DUPLEX_FULL) |
91 | autoneg_advertised = ADVERTISED_100baseT_Full; | 92 | autoneg_advertised = ADVERTISED_100baseT_Full; |
92 | else | 93 | else |
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c index dffa6919a419..37a092fa2ba6 100644 --- a/drivers/net/atlx/atl1.c +++ b/drivers/net/atlx/atl1.c | |||
@@ -3268,7 +3268,8 @@ static int atl1_set_settings(struct net_device *netdev, | |||
3268 | if (ecmd->autoneg == AUTONEG_ENABLE) | 3268 | if (ecmd->autoneg == AUTONEG_ENABLE) |
3269 | hw->media_type = MEDIA_TYPE_AUTO_SENSOR; | 3269 | hw->media_type = MEDIA_TYPE_AUTO_SENSOR; |
3270 | else { | 3270 | else { |
3271 | if (ecmd->speed == SPEED_1000) { | 3271 | u32 speed = ethtool_cmd_speed(ecmd); |
3272 | if (speed == SPEED_1000) { | ||
3272 | if (ecmd->duplex != DUPLEX_FULL) { | 3273 | if (ecmd->duplex != DUPLEX_FULL) { |
3273 | if (netif_msg_link(adapter)) | 3274 | if (netif_msg_link(adapter)) |
3274 | dev_warn(&adapter->pdev->dev, | 3275 | dev_warn(&adapter->pdev->dev, |
@@ -3277,7 +3278,7 @@ static int atl1_set_settings(struct net_device *netdev, | |||
3277 | goto exit_sset; | 3278 | goto exit_sset; |
3278 | } | 3279 | } |
3279 | hw->media_type = MEDIA_TYPE_1000M_FULL; | 3280 | hw->media_type = MEDIA_TYPE_1000M_FULL; |
3280 | } else if (ecmd->speed == SPEED_100) { | 3281 | } else if (speed == SPEED_100) { |
3281 | if (ecmd->duplex == DUPLEX_FULL) | 3282 | if (ecmd->duplex == DUPLEX_FULL) |
3282 | hw->media_type = MEDIA_TYPE_100M_FULL; | 3283 | hw->media_type = MEDIA_TYPE_100M_FULL; |
3283 | else | 3284 | else |
diff --git a/drivers/net/b44.c b/drivers/net/b44.c index 2e2b76258ab4..909cc4b2a2f3 100644 --- a/drivers/net/b44.c +++ b/drivers/net/b44.c | |||
@@ -1831,6 +1831,7 @@ static int b44_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1831 | static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1831 | static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
1832 | { | 1832 | { |
1833 | struct b44 *bp = netdev_priv(dev); | 1833 | struct b44 *bp = netdev_priv(dev); |
1834 | u32 speed = ethtool_cmd_speed(cmd); | ||
1834 | 1835 | ||
1835 | /* We do not support gigabit. */ | 1836 | /* We do not support gigabit. */ |
1836 | if (cmd->autoneg == AUTONEG_ENABLE) { | 1837 | if (cmd->autoneg == AUTONEG_ENABLE) { |
@@ -1838,8 +1839,8 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1838 | (ADVERTISED_1000baseT_Half | | 1839 | (ADVERTISED_1000baseT_Half | |
1839 | ADVERTISED_1000baseT_Full)) | 1840 | ADVERTISED_1000baseT_Full)) |
1840 | return -EINVAL; | 1841 | return -EINVAL; |
1841 | } else if ((cmd->speed != SPEED_100 && | 1842 | } else if ((speed != SPEED_100 && |
1842 | cmd->speed != SPEED_10) || | 1843 | speed != SPEED_10) || |
1843 | (cmd->duplex != DUPLEX_HALF && | 1844 | (cmd->duplex != DUPLEX_HALF && |
1844 | cmd->duplex != DUPLEX_FULL)) { | 1845 | cmd->duplex != DUPLEX_FULL)) { |
1845 | return -EINVAL; | 1846 | return -EINVAL; |
@@ -1873,7 +1874,7 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1873 | } else { | 1874 | } else { |
1874 | bp->flags |= B44_FLAG_FORCE_LINK; | 1875 | bp->flags |= B44_FLAG_FORCE_LINK; |
1875 | bp->flags &= ~(B44_FLAG_100_BASE_T | B44_FLAG_FULL_DUPLEX); | 1876 | bp->flags &= ~(B44_FLAG_100_BASE_T | B44_FLAG_FULL_DUPLEX); |
1876 | if (cmd->speed == SPEED_100) | 1877 | if (speed == SPEED_100) |
1877 | bp->flags |= B44_FLAG_100_BASE_T; | 1878 | bp->flags |= B44_FLAG_100_BASE_T; |
1878 | if (cmd->duplex == DUPLEX_FULL) | 1879 | if (cmd->duplex == DUPLEX_FULL) |
1879 | bp->flags |= B44_FLAG_FULL_DUPLEX; | 1880 | bp->flags |= B44_FLAG_FULL_DUPLEX; |
diff --git a/drivers/net/bna/bnad_ethtool.c b/drivers/net/bna/bnad_ethtool.c index c51e078e8f0d..ae1e118f9c3a 100644 --- a/drivers/net/bna/bnad_ethtool.c +++ b/drivers/net/bna/bnad_ethtool.c | |||
@@ -256,7 +256,8 @@ bnad_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd) | |||
256 | /* 10G full duplex setting supported only */ | 256 | /* 10G full duplex setting supported only */ |
257 | if (cmd->autoneg == AUTONEG_ENABLE) | 257 | if (cmd->autoneg == AUTONEG_ENABLE) |
258 | return -EOPNOTSUPP; else { | 258 | return -EOPNOTSUPP; else { |
259 | if ((cmd->speed == SPEED_10000) && (cmd->duplex == DUPLEX_FULL)) | 259 | if ((ethtool_cmd_speed(cmd) == SPEED_10000) |
260 | && (cmd->duplex == DUPLEX_FULL)) | ||
260 | return 0; | 261 | return 0; |
261 | } | 262 | } |
262 | 263 | ||
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index bf729ee6acbd..e43efd86425b 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -6758,21 +6758,21 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
6758 | advertising |= ADVERTISED_Autoneg; | 6758 | advertising |= ADVERTISED_Autoneg; |
6759 | } | 6759 | } |
6760 | else { | 6760 | else { |
6761 | u32 speed = ethtool_cmd_speed(cmd); | ||
6761 | if (cmd->port == PORT_FIBRE) { | 6762 | if (cmd->port == PORT_FIBRE) { |
6762 | if ((cmd->speed != SPEED_1000 && | 6763 | if ((speed != SPEED_1000 && |
6763 | cmd->speed != SPEED_2500) || | 6764 | speed != SPEED_2500) || |
6764 | (cmd->duplex != DUPLEX_FULL)) | 6765 | (cmd->duplex != DUPLEX_FULL)) |
6765 | goto err_out_unlock; | 6766 | goto err_out_unlock; |
6766 | 6767 | ||
6767 | if (cmd->speed == SPEED_2500 && | 6768 | if (speed == SPEED_2500 && |
6768 | !(bp->phy_flags & BNX2_PHY_FLAG_2_5G_CAPABLE)) | 6769 | !(bp->phy_flags & BNX2_PHY_FLAG_2_5G_CAPABLE)) |
6769 | goto err_out_unlock; | 6770 | goto err_out_unlock; |
6770 | } | 6771 | } else if (speed == SPEED_1000 || speed == SPEED_2500) |
6771 | else if (cmd->speed == SPEED_1000 || cmd->speed == SPEED_2500) | ||
6772 | goto err_out_unlock; | 6772 | goto err_out_unlock; |
6773 | 6773 | ||
6774 | autoneg &= ~AUTONEG_SPEED; | 6774 | autoneg &= ~AUTONEG_SPEED; |
6775 | req_line_speed = cmd->speed; | 6775 | req_line_speed = speed; |
6776 | req_duplex = cmd->duplex; | 6776 | req_duplex = cmd->duplex; |
6777 | advertising = 0; | 6777 | advertising = 0; |
6778 | } | 6778 | } |
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c index 143a28c666af..a6c3f8c8c302 100644 --- a/drivers/net/cassini.c +++ b/drivers/net/cassini.c | |||
@@ -709,10 +709,11 @@ static void cas_begin_auto_negotiation(struct cas *cp, struct ethtool_cmd *ep) | |||
709 | if (ep->autoneg == AUTONEG_ENABLE) | 709 | if (ep->autoneg == AUTONEG_ENABLE) |
710 | cp->link_cntl = BMCR_ANENABLE; | 710 | cp->link_cntl = BMCR_ANENABLE; |
711 | else { | 711 | else { |
712 | u32 speed = ethtool_cmd_speed(ep); | ||
712 | cp->link_cntl = 0; | 713 | cp->link_cntl = 0; |
713 | if (ep->speed == SPEED_100) | 714 | if (speed == SPEED_100) |
714 | cp->link_cntl |= BMCR_SPEED100; | 715 | cp->link_cntl |= BMCR_SPEED100; |
715 | else if (ep->speed == SPEED_1000) | 716 | else if (speed == SPEED_1000) |
716 | cp->link_cntl |= CAS_BMCR_SPEED1000; | 717 | cp->link_cntl |= CAS_BMCR_SPEED1000; |
717 | if (ep->duplex == DUPLEX_FULL) | 718 | if (ep->duplex == DUPLEX_FULL) |
718 | cp->link_cntl |= BMCR_FULLDPLX; | 719 | cp->link_cntl |= BMCR_FULLDPLX; |
@@ -4653,6 +4654,7 @@ static int cas_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
4653 | { | 4654 | { |
4654 | struct cas *cp = netdev_priv(dev); | 4655 | struct cas *cp = netdev_priv(dev); |
4655 | unsigned long flags; | 4656 | unsigned long flags; |
4657 | u32 speed = ethtool_cmd_speed(cmd); | ||
4656 | 4658 | ||
4657 | /* Verify the settings we care about. */ | 4659 | /* Verify the settings we care about. */ |
4658 | if (cmd->autoneg != AUTONEG_ENABLE && | 4660 | if (cmd->autoneg != AUTONEG_ENABLE && |
@@ -4660,9 +4662,9 @@ static int cas_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
4660 | return -EINVAL; | 4662 | return -EINVAL; |
4661 | 4663 | ||
4662 | if (cmd->autoneg == AUTONEG_DISABLE && | 4664 | if (cmd->autoneg == AUTONEG_DISABLE && |
4663 | ((cmd->speed != SPEED_1000 && | 4665 | ((speed != SPEED_1000 && |
4664 | cmd->speed != SPEED_100 && | 4666 | speed != SPEED_100 && |
4665 | cmd->speed != SPEED_10) || | 4667 | speed != SPEED_10) || |
4666 | (cmd->duplex != DUPLEX_HALF && | 4668 | (cmd->duplex != DUPLEX_HALF && |
4667 | cmd->duplex != DUPLEX_FULL))) | 4669 | cmd->duplex != DUPLEX_FULL))) |
4668 | return -EINVAL; | 4670 | return -EINVAL; |
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c index 5f82c9c34978..8e14d652996b 100644 --- a/drivers/net/chelsio/cxgb2.c +++ b/drivers/net/chelsio/cxgb2.c | |||
@@ -638,11 +638,12 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
638 | return -EOPNOTSUPP; /* can't change speed/duplex */ | 638 | return -EOPNOTSUPP; /* can't change speed/duplex */ |
639 | 639 | ||
640 | if (cmd->autoneg == AUTONEG_DISABLE) { | 640 | if (cmd->autoneg == AUTONEG_DISABLE) { |
641 | int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex); | 641 | u32 speed = ethtool_cmd_speed(cmd); |
642 | int cap = speed_duplex_to_caps(speed, cmd->duplex); | ||
642 | 643 | ||
643 | if (!(lc->supported & cap) || cmd->speed == SPEED_1000) | 644 | if (!(lc->supported & cap) || (speed == SPEED_1000)) |
644 | return -EINVAL; | 645 | return -EINVAL; |
645 | lc->requested_speed = cmd->speed; | 646 | lc->requested_speed = speed; |
646 | lc->requested_duplex = cmd->duplex; | 647 | lc->requested_duplex = cmd->duplex; |
647 | lc->advertising = 0; | 648 | lc->advertising = 0; |
648 | } else { | 649 | } else { |
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index 040491804efb..0526715cc8c7 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -1821,7 +1821,8 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1821 | * being requested. | 1821 | * being requested. |
1822 | */ | 1822 | */ |
1823 | if (cmd->autoneg == AUTONEG_DISABLE) { | 1823 | if (cmd->autoneg == AUTONEG_DISABLE) { |
1824 | int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex); | 1824 | u32 speed = ethtool_cmd_speed(cmd); |
1825 | int cap = speed_duplex_to_caps(speed, cmd->duplex); | ||
1825 | if (lc->supported & cap) | 1826 | if (lc->supported & cap) |
1826 | return 0; | 1827 | return 0; |
1827 | } | 1828 | } |
@@ -1829,11 +1830,12 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1829 | } | 1830 | } |
1830 | 1831 | ||
1831 | if (cmd->autoneg == AUTONEG_DISABLE) { | 1832 | if (cmd->autoneg == AUTONEG_DISABLE) { |
1832 | int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex); | 1833 | u32 speed = ethtool_cmd_speed(cmd); |
1834 | int cap = speed_duplex_to_caps(speed, cmd->duplex); | ||
1833 | 1835 | ||
1834 | if (!(lc->supported & cap) || cmd->speed == SPEED_1000) | 1836 | if (!(lc->supported & cap) || (speed == SPEED_1000)) |
1835 | return -EINVAL; | 1837 | return -EINVAL; |
1836 | lc->requested_speed = cmd->speed; | 1838 | lc->requested_speed = speed; |
1837 | lc->requested_duplex = cmd->duplex; | 1839 | lc->requested_duplex = cmd->duplex; |
1838 | lc->advertising = 0; | 1840 | lc->advertising = 0; |
1839 | } else { | 1841 | } else { |
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c index bdc868ca47ec..c02b4d3b73fc 100644 --- a/drivers/net/cxgb4/cxgb4_main.c +++ b/drivers/net/cxgb4/cxgb4_main.c | |||
@@ -1460,6 +1460,7 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1460 | unsigned int cap; | 1460 | unsigned int cap; |
1461 | struct port_info *p = netdev_priv(dev); | 1461 | struct port_info *p = netdev_priv(dev); |
1462 | struct link_config *lc = &p->link_cfg; | 1462 | struct link_config *lc = &p->link_cfg; |
1463 | u32 speed = ethtool_cmd_speed(cmd); | ||
1463 | 1464 | ||
1464 | if (cmd->duplex != DUPLEX_FULL) /* only full-duplex supported */ | 1465 | if (cmd->duplex != DUPLEX_FULL) /* only full-duplex supported */ |
1465 | return -EINVAL; | 1466 | return -EINVAL; |
@@ -1470,16 +1471,16 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1470 | * being requested. | 1471 | * being requested. |
1471 | */ | 1472 | */ |
1472 | if (cmd->autoneg == AUTONEG_DISABLE && | 1473 | if (cmd->autoneg == AUTONEG_DISABLE && |
1473 | (lc->supported & speed_to_caps(cmd->speed))) | 1474 | (lc->supported & speed_to_caps(speed))) |
1474 | return 0; | 1475 | return 0; |
1475 | return -EINVAL; | 1476 | return -EINVAL; |
1476 | } | 1477 | } |
1477 | 1478 | ||
1478 | if (cmd->autoneg == AUTONEG_DISABLE) { | 1479 | if (cmd->autoneg == AUTONEG_DISABLE) { |
1479 | cap = speed_to_caps(cmd->speed); | 1480 | cap = speed_to_caps(speed); |
1480 | 1481 | ||
1481 | if (!(lc->supported & cap) || cmd->speed == SPEED_1000 || | 1482 | if (!(lc->supported & cap) || (speed == SPEED_1000) || |
1482 | cmd->speed == SPEED_10000) | 1483 | (speed == SPEED_10000)) |
1483 | return -EINVAL; | 1484 | return -EINVAL; |
1484 | lc->requested_speed = cap; | 1485 | lc->requested_speed = cap; |
1485 | lc->advertising = 0; | 1486 | lc->advertising = 0; |
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c index c05db6046050..ab63989619d4 100644 --- a/drivers/net/dl2k.c +++ b/drivers/net/dl2k.c | |||
@@ -1219,31 +1219,20 @@ static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1219 | } else { | 1219 | } else { |
1220 | np->an_enable = 0; | 1220 | np->an_enable = 0; |
1221 | if (np->speed == 1000) { | 1221 | if (np->speed == 1000) { |
1222 | cmd->speed = SPEED_100; | 1222 | ethtool_cmd_speed_set(cmd, SPEED_100); |
1223 | cmd->duplex = DUPLEX_FULL; | 1223 | cmd->duplex = DUPLEX_FULL; |
1224 | printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n"); | 1224 | printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n"); |
1225 | } | 1225 | } |
1226 | switch(cmd->speed + cmd->duplex) { | 1226 | switch (ethtool_cmd_speed(cmd)) { |
1227 | 1227 | case SPEED_10: | |
1228 | case SPEED_10 + DUPLEX_HALF: | ||
1229 | np->speed = 10; | ||
1230 | np->full_duplex = 0; | ||
1231 | break; | ||
1232 | |||
1233 | case SPEED_10 + DUPLEX_FULL: | ||
1234 | np->speed = 10; | 1228 | np->speed = 10; |
1235 | np->full_duplex = 1; | 1229 | np->full_duplex = (cmd->duplex == DUPLEX_FULL); |
1236 | break; | 1230 | break; |
1237 | case SPEED_100 + DUPLEX_HALF: | 1231 | case SPEED_100: |
1238 | np->speed = 100; | 1232 | np->speed = 100; |
1239 | np->full_duplex = 0; | 1233 | np->full_duplex = (cmd->duplex == DUPLEX_FULL); |
1240 | break; | ||
1241 | case SPEED_100 + DUPLEX_FULL: | ||
1242 | np->speed = 100; | ||
1243 | np->full_duplex = 1; | ||
1244 | break; | 1234 | break; |
1245 | case SPEED_1000 + DUPLEX_HALF:/* not supported */ | 1235 | case SPEED_1000: /* not supported */ |
1246 | case SPEED_1000 + DUPLEX_FULL:/* not supported */ | ||
1247 | default: | 1236 | default: |
1248 | return -EINVAL; | 1237 | return -EINVAL; |
1249 | } | 1238 | } |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 66ba596a4d37..c810cda3bf1f 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -1669,6 +1669,7 @@ static void e100_watchdog(unsigned long data) | |||
1669 | { | 1669 | { |
1670 | struct nic *nic = (struct nic *)data; | 1670 | struct nic *nic = (struct nic *)data; |
1671 | struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET }; | 1671 | struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET }; |
1672 | u32 speed; | ||
1672 | 1673 | ||
1673 | netif_printk(nic, timer, KERN_DEBUG, nic->netdev, | 1674 | netif_printk(nic, timer, KERN_DEBUG, nic->netdev, |
1674 | "right now = %ld\n", jiffies); | 1675 | "right now = %ld\n", jiffies); |
@@ -1676,10 +1677,11 @@ static void e100_watchdog(unsigned long data) | |||
1676 | /* mii library handles link maintenance tasks */ | 1677 | /* mii library handles link maintenance tasks */ |
1677 | 1678 | ||
1678 | mii_ethtool_gset(&nic->mii, &cmd); | 1679 | mii_ethtool_gset(&nic->mii, &cmd); |
1680 | speed = ethtool_cmd_speed(&cmd); | ||
1679 | 1681 | ||
1680 | if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) { | 1682 | if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) { |
1681 | netdev_info(nic->netdev, "NIC Link is Up %u Mbps %s Duplex\n", | 1683 | netdev_info(nic->netdev, "NIC Link is Up %u Mbps %s Duplex\n", |
1682 | cmd.speed == SPEED_100 ? 100 : 10, | 1684 | speed == SPEED_100 ? 100 : 10, |
1683 | cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); | 1685 | cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); |
1684 | } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { | 1686 | } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { |
1685 | netdev_info(nic->netdev, "NIC Link is Down\n"); | 1687 | netdev_info(nic->netdev, "NIC Link is Down\n"); |
@@ -1698,13 +1700,13 @@ static void e100_watchdog(unsigned long data) | |||
1698 | spin_unlock_irq(&nic->cmd_lock); | 1700 | spin_unlock_irq(&nic->cmd_lock); |
1699 | 1701 | ||
1700 | e100_update_stats(nic); | 1702 | e100_update_stats(nic); |
1701 | e100_adjust_adaptive_ifs(nic, cmd.speed, cmd.duplex); | 1703 | e100_adjust_adaptive_ifs(nic, speed, cmd.duplex); |
1702 | 1704 | ||
1703 | if (nic->mac <= mac_82557_D100_C) | 1705 | if (nic->mac <= mac_82557_D100_C) |
1704 | /* Issue a multicast command to workaround a 557 lock up */ | 1706 | /* Issue a multicast command to workaround a 557 lock up */ |
1705 | e100_set_multicast_list(nic->netdev); | 1707 | e100_set_multicast_list(nic->netdev); |
1706 | 1708 | ||
1707 | if (nic->flags & ich && cmd.speed==SPEED_10 && cmd.duplex==DUPLEX_HALF) | 1709 | if (nic->flags & ich && speed == SPEED_10 && cmd.duplex == DUPLEX_HALF) |
1708 | /* Need SW workaround for ICH[x] 10Mbps/half duplex Tx hang. */ | 1710 | /* Need SW workaround for ICH[x] 10Mbps/half duplex Tx hang. */ |
1709 | nic->flags |= ich_10h_workaround; | 1711 | nic->flags |= ich_10h_workaround; |
1710 | else | 1712 | else |
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index dd70738eb2f4..a53629d9325d 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c | |||
@@ -197,11 +197,13 @@ static int e1000_set_settings(struct net_device *netdev, | |||
197 | ADVERTISED_TP | | 197 | ADVERTISED_TP | |
198 | ADVERTISED_Autoneg; | 198 | ADVERTISED_Autoneg; |
199 | ecmd->advertising = hw->autoneg_advertised; | 199 | ecmd->advertising = hw->autoneg_advertised; |
200 | } else | 200 | } else { |
201 | if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { | 201 | u32 speed = ethtool_cmd_speed(ecmd); |
202 | if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) { | ||
202 | clear_bit(__E1000_RESETTING, &adapter->flags); | 203 | clear_bit(__E1000_RESETTING, &adapter->flags); |
203 | return -EINVAL; | 204 | return -EINVAL; |
204 | } | 205 | } |
206 | } | ||
205 | 207 | ||
206 | /* reset the link */ | 208 | /* reset the link */ |
207 | 209 | ||
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 1d7bf4049c02..bc02c6b91f15 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c | |||
@@ -269,7 +269,8 @@ static int e1000_set_settings(struct net_device *netdev, | |||
269 | if (adapter->fc_autoneg) | 269 | if (adapter->fc_autoneg) |
270 | hw->fc.requested_mode = e1000_fc_default; | 270 | hw->fc.requested_mode = e1000_fc_default; |
271 | } else { | 271 | } else { |
272 | if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { | 272 | u32 speed = ethtool_cmd_speed(ecmd); |
273 | if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) { | ||
273 | clear_bit(__E1000_RESETTING, &adapter->state); | 274 | clear_bit(__E1000_RESETTING, &adapter->state); |
274 | return -EINVAL; | 275 | return -EINVAL; |
275 | } | 276 | } |
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 907b05a1c659..81a793747f2e 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c | |||
@@ -1499,7 +1499,8 @@ enc28j60_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1499 | static int | 1499 | static int |
1500 | enc28j60_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1500 | enc28j60_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
1501 | { | 1501 | { |
1502 | return enc28j60_setlink(dev, cmd->autoneg, cmd->speed, cmd->duplex); | 1502 | return enc28j60_setlink(dev, cmd->autoneg, |
1503 | ethtool_cmd_speed(cmd), cmd->duplex); | ||
1503 | } | 1504 | } |
1504 | 1505 | ||
1505 | static u32 enc28j60_get_msglevel(struct net_device *dev) | 1506 | static u32 enc28j60_get_msglevel(struct net_device *dev) |
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 0e1c76a8c045..d24b3f3e646b 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -4029,6 +4029,7 @@ static int nv_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
4029 | static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 4029 | static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
4030 | { | 4030 | { |
4031 | struct fe_priv *np = netdev_priv(dev); | 4031 | struct fe_priv *np = netdev_priv(dev); |
4032 | u32 speed = ethtool_cmd_speed(ecmd); | ||
4032 | 4033 | ||
4033 | if (ecmd->port != PORT_MII) | 4034 | if (ecmd->port != PORT_MII) |
4034 | return -EINVAL; | 4035 | return -EINVAL; |
@@ -4054,7 +4055,7 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
4054 | /* Note: autonegotiation disable, speed 1000 intentionally | 4055 | /* Note: autonegotiation disable, speed 1000 intentionally |
4055 | * forbidden - no one should need that. */ | 4056 | * forbidden - no one should need that. */ |
4056 | 4057 | ||
4057 | if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100) | 4058 | if (speed != SPEED_10 && speed != SPEED_100) |
4058 | return -EINVAL; | 4059 | return -EINVAL; |
4059 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) | 4060 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) |
4060 | return -EINVAL; | 4061 | return -EINVAL; |
@@ -4138,13 +4139,13 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
4138 | 4139 | ||
4139 | adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); | 4140 | adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); |
4140 | adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM); | 4141 | adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM); |
4141 | if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_HALF) | 4142 | if (speed == SPEED_10 && ecmd->duplex == DUPLEX_HALF) |
4142 | adv |= ADVERTISE_10HALF; | 4143 | adv |= ADVERTISE_10HALF; |
4143 | if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_FULL) | 4144 | if (speed == SPEED_10 && ecmd->duplex == DUPLEX_FULL) |
4144 | adv |= ADVERTISE_10FULL; | 4145 | adv |= ADVERTISE_10FULL; |
4145 | if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_HALF) | 4146 | if (speed == SPEED_100 && ecmd->duplex == DUPLEX_HALF) |
4146 | adv |= ADVERTISE_100HALF; | 4147 | adv |= ADVERTISE_100HALF; |
4147 | if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_FULL) | 4148 | if (speed == SPEED_100 && ecmd->duplex == DUPLEX_FULL) |
4148 | adv |= ADVERTISE_100FULL; | 4149 | adv |= ADVERTISE_100FULL; |
4149 | np->pause_flags &= ~(NV_PAUSEFRAME_AUTONEG|NV_PAUSEFRAME_RX_ENABLE|NV_PAUSEFRAME_TX_ENABLE); | 4150 | np->pause_flags &= ~(NV_PAUSEFRAME_AUTONEG|NV_PAUSEFRAME_RX_ENABLE|NV_PAUSEFRAME_TX_ENABLE); |
4150 | if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) {/* for rx we set both advertisements but disable tx pause */ | 4151 | if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) {/* for rx we set both advertisements but disable tx pause */ |
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index d976733bbcc2..2cc221b65cd4 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -223,7 +223,8 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) | |||
223 | if (adapter->fc_autoneg) | 223 | if (adapter->fc_autoneg) |
224 | hw->fc.requested_mode = e1000_fc_default; | 224 | hw->fc.requested_mode = e1000_fc_default; |
225 | } else { | 225 | } else { |
226 | if (igb_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { | 226 | u32 speed = ethtool_cmd_speed(ecmd); |
227 | if (igb_set_spd_dplx(adapter, speed + ecmd->duplex)) { | ||
227 | clear_bit(__IGB_RESETTING, &adapter->state); | 228 | clear_bit(__IGB_RESETTING, &adapter->state); |
228 | return -EINVAL; | 229 | return -EINVAL; |
229 | } | 230 | } |
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c index cc53aa1541ba..edb3d7eaf6d5 100644 --- a/drivers/net/ixgb/ixgb_ethtool.c +++ b/drivers/net/ixgb/ixgb_ethtool.c | |||
@@ -129,9 +129,10 @@ static int | |||
129 | ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) | 129 | ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
130 | { | 130 | { |
131 | struct ixgb_adapter *adapter = netdev_priv(netdev); | 131 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
132 | u32 speed = ethtool_cmd_speed(ecmd); | ||
132 | 133 | ||
133 | if (ecmd->autoneg == AUTONEG_ENABLE || | 134 | if (ecmd->autoneg == AUTONEG_ENABLE || |
134 | ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL) | 135 | (speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)) |
135 | return -EINVAL; | 136 | return -EINVAL; |
136 | 137 | ||
137 | if (netif_running(adapter->netdev)) { | 138 | if (netif_running(adapter->netdev)) { |
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c index 7279345b1ed7..c52243d67edc 100644 --- a/drivers/net/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ixgbe/ixgbe_ethtool.c | |||
@@ -346,9 +346,10 @@ static int ixgbe_set_settings(struct net_device *netdev, | |||
346 | } | 346 | } |
347 | } else { | 347 | } else { |
348 | /* in this case we currently only support 10Gb/FULL */ | 348 | /* in this case we currently only support 10Gb/FULL */ |
349 | u32 speed = ethtool_cmd_speed(ecmd); | ||
349 | if ((ecmd->autoneg == AUTONEG_ENABLE) || | 350 | if ((ecmd->autoneg == AUTONEG_ENABLE) || |
350 | (ecmd->advertising != ADVERTISED_10000baseT_Full) || | 351 | (ecmd->advertising != ADVERTISED_10000baseT_Full) || |
351 | (ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)) | 352 | (speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)) |
352 | return -EINVAL; | 353 | return -EINVAL; |
353 | } | 354 | } |
354 | 355 | ||
diff --git a/drivers/net/jme.c b/drivers/net/jme.c index be4773f54a24..b5b174a8c149 100644 --- a/drivers/net/jme.c +++ b/drivers/net/jme.c | |||
@@ -2555,7 +2555,8 @@ jme_set_settings(struct net_device *netdev, | |||
2555 | struct jme_adapter *jme = netdev_priv(netdev); | 2555 | struct jme_adapter *jme = netdev_priv(netdev); |
2556 | int rc, fdc = 0; | 2556 | int rc, fdc = 0; |
2557 | 2557 | ||
2558 | if (ecmd->speed == SPEED_1000 && ecmd->autoneg != AUTONEG_ENABLE) | 2558 | if (ethtool_cmd_speed(ecmd) == SPEED_1000 |
2559 | && ecmd->autoneg != AUTONEG_ENABLE) | ||
2559 | return -EINVAL; | 2560 | return -EINVAL; |
2560 | 2561 | ||
2561 | /* | 2562 | /* |
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c index 2c37a3804303..41ea5920c158 100644 --- a/drivers/net/ksz884x.c +++ b/drivers/net/ksz884x.c | |||
@@ -5998,6 +5998,7 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
5998 | struct dev_priv *priv = netdev_priv(dev); | 5998 | struct dev_priv *priv = netdev_priv(dev); |
5999 | struct dev_info *hw_priv = priv->adapter; | 5999 | struct dev_info *hw_priv = priv->adapter; |
6000 | struct ksz_port *port = &priv->port; | 6000 | struct ksz_port *port = &priv->port; |
6001 | u32 speed = ethtool_cmd_speed(cmd); | ||
6001 | int rc; | 6002 | int rc; |
6002 | 6003 | ||
6003 | /* | 6004 | /* |
@@ -6006,11 +6007,11 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
6006 | */ | 6007 | */ |
6007 | if (cmd->autoneg && priv->advertising == cmd->advertising) { | 6008 | if (cmd->autoneg && priv->advertising == cmd->advertising) { |
6008 | cmd->advertising |= ADVERTISED_ALL; | 6009 | cmd->advertising |= ADVERTISED_ALL; |
6009 | if (10 == cmd->speed) | 6010 | if (10 == speed) |
6010 | cmd->advertising &= | 6011 | cmd->advertising &= |
6011 | ~(ADVERTISED_100baseT_Full | | 6012 | ~(ADVERTISED_100baseT_Full | |
6012 | ADVERTISED_100baseT_Half); | 6013 | ADVERTISED_100baseT_Half); |
6013 | else if (100 == cmd->speed) | 6014 | else if (100 == speed) |
6014 | cmd->advertising &= | 6015 | cmd->advertising &= |
6015 | ~(ADVERTISED_10baseT_Full | | 6016 | ~(ADVERTISED_10baseT_Full | |
6016 | ADVERTISED_10baseT_Half); | 6017 | ADVERTISED_10baseT_Half); |
@@ -6032,8 +6033,8 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
6032 | port->force_link = 0; | 6033 | port->force_link = 0; |
6033 | } else { | 6034 | } else { |
6034 | port->duplex = cmd->duplex + 1; | 6035 | port->duplex = cmd->duplex + 1; |
6035 | if (cmd->speed != 1000) | 6036 | if (1000 != speed) |
6036 | port->speed = cmd->speed; | 6037 | port->speed = speed; |
6037 | if (cmd->autoneg) | 6038 | if (cmd->autoneg) |
6038 | port->force_link = 0; | 6039 | port->force_link = 0; |
6039 | else | 6040 | else |
diff --git a/drivers/net/mii.c b/drivers/net/mii.c index 05acca78f63a..e8198edeaa76 100644 --- a/drivers/net/mii.c +++ b/drivers/net/mii.c | |||
@@ -157,10 +157,11 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
157 | int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | 157 | int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) |
158 | { | 158 | { |
159 | struct net_device *dev = mii->dev; | 159 | struct net_device *dev = mii->dev; |
160 | u32 speed = ethtool_cmd_speed(ecmd); | ||
160 | 161 | ||
161 | if (ecmd->speed != SPEED_10 && | 162 | if (speed != SPEED_10 && |
162 | ecmd->speed != SPEED_100 && | 163 | speed != SPEED_100 && |
163 | ecmd->speed != SPEED_1000) | 164 | speed != SPEED_1000) |
164 | return -EINVAL; | 165 | return -EINVAL; |
165 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) | 166 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) |
166 | return -EINVAL; | 167 | return -EINVAL; |
@@ -172,7 +173,7 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
172 | return -EINVAL; | 173 | return -EINVAL; |
173 | if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE) | 174 | if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE) |
174 | return -EINVAL; | 175 | return -EINVAL; |
175 | if ((ecmd->speed == SPEED_1000) && (!mii->supports_gmii)) | 176 | if ((speed == SPEED_1000) && (!mii->supports_gmii)) |
176 | return -EINVAL; | 177 | return -EINVAL; |
177 | 178 | ||
178 | /* ignore supported, maxtxpkt, maxrxpkt */ | 179 | /* ignore supported, maxtxpkt, maxrxpkt */ |
@@ -230,9 +231,9 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
230 | bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR); | 231 | bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR); |
231 | tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 | | 232 | tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 | |
232 | BMCR_SPEED1000 | BMCR_FULLDPLX); | 233 | BMCR_SPEED1000 | BMCR_FULLDPLX); |
233 | if (ecmd->speed == SPEED_1000) | 234 | if (speed == SPEED_1000) |
234 | tmp |= BMCR_SPEED1000; | 235 | tmp |= BMCR_SPEED1000; |
235 | else if (ecmd->speed == SPEED_100) | 236 | else if (speed == SPEED_100) |
236 | tmp |= BMCR_SPEED100; | 237 | tmp |= BMCR_SPEED100; |
237 | if (ecmd->duplex == DUPLEX_FULL) { | 238 | if (ecmd->duplex == DUPLEX_FULL) { |
238 | tmp |= BMCR_FULLDPLX; | 239 | tmp |= BMCR_FULLDPLX; |
diff --git a/drivers/net/mlx4/en_ethtool.c b/drivers/net/mlx4/en_ethtool.c index da1b64d68607..be4a9e0b2406 100644 --- a/drivers/net/mlx4/en_ethtool.c +++ b/drivers/net/mlx4/en_ethtool.c | |||
@@ -292,7 +292,8 @@ static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
292 | static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 292 | static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
293 | { | 293 | { |
294 | if ((cmd->autoneg == AUTONEG_ENABLE) || | 294 | if ((cmd->autoneg == AUTONEG_ENABLE) || |
295 | (cmd->speed != SPEED_10000) || (cmd->duplex != DUPLEX_FULL)) | 295 | (ethtool_cmd_speed(cmd) != SPEED_10000) || |
296 | (cmd->duplex != DUPLEX_FULL)) | ||
296 | return -EINVAL; | 297 | return -EINVAL; |
297 | 298 | ||
298 | /* Nothing to change */ | 299 | /* Nothing to change */ |
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c index 1074231f0a0d..7633c67b7842 100644 --- a/drivers/net/natsemi.c +++ b/drivers/net/natsemi.c | |||
@@ -2908,7 +2908,8 @@ static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
2908 | return -EINVAL; | 2908 | return -EINVAL; |
2909 | } | 2909 | } |
2910 | } else if (ecmd->autoneg == AUTONEG_DISABLE) { | 2910 | } else if (ecmd->autoneg == AUTONEG_DISABLE) { |
2911 | if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100) | 2911 | u32 speed = ethtool_cmd_speed(ecmd); |
2912 | if (speed != SPEED_10 && speed != SPEED_100) | ||
2912 | return -EINVAL; | 2913 | return -EINVAL; |
2913 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) | 2914 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) |
2914 | return -EINVAL; | 2915 | return -EINVAL; |
@@ -2956,7 +2957,7 @@ static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
2956 | if (ecmd->advertising & ADVERTISED_100baseT_Full) | 2957 | if (ecmd->advertising & ADVERTISED_100baseT_Full) |
2957 | np->advertising |= ADVERTISE_100FULL; | 2958 | np->advertising |= ADVERTISE_100FULL; |
2958 | } else { | 2959 | } else { |
2959 | np->speed = ecmd->speed; | 2960 | np->speed = ethtool_cmd_speed(ecmd); |
2960 | np->duplex = ecmd->duplex; | 2961 | np->duplex = ecmd->duplex; |
2961 | /* user overriding the initial full duplex parm? */ | 2962 | /* user overriding the initial full duplex parm? */ |
2962 | if (np->duplex == DUPLEX_HALF) | 2963 | if (np->duplex == DUPLEX_HALF) |
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 29f90baaa79b..e8d16f6f11e3 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c | |||
@@ -251,6 +251,7 @@ static int | |||
251 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 251 | netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
252 | { | 252 | { |
253 | struct netxen_adapter *adapter = netdev_priv(dev); | 253 | struct netxen_adapter *adapter = netdev_priv(dev); |
254 | u32 speed = ethtool_cmd_speed(ecmd); | ||
254 | int ret; | 255 | int ret; |
255 | 256 | ||
256 | if (adapter->ahw.port_type != NETXEN_NIC_GBE) | 257 | if (adapter->ahw.port_type != NETXEN_NIC_GBE) |
@@ -259,14 +260,14 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
259 | if (!(adapter->capabilities & NX_FW_CAPABILITY_GBE_LINK_CFG)) | 260 | if (!(adapter->capabilities & NX_FW_CAPABILITY_GBE_LINK_CFG)) |
260 | return -EOPNOTSUPP; | 261 | return -EOPNOTSUPP; |
261 | 262 | ||
262 | ret = nx_fw_cmd_set_gbe_port(adapter, ecmd->speed, ecmd->duplex, | 263 | ret = nx_fw_cmd_set_gbe_port(adapter, speed, ecmd->duplex, |
263 | ecmd->autoneg); | 264 | ecmd->autoneg); |
264 | if (ret == NX_RCODE_NOT_SUPPORTED) | 265 | if (ret == NX_RCODE_NOT_SUPPORTED) |
265 | return -EOPNOTSUPP; | 266 | return -EOPNOTSUPP; |
266 | else if (ret) | 267 | else if (ret) |
267 | return -EIO; | 268 | return -EIO; |
268 | 269 | ||
269 | adapter->link_speed = ecmd->speed; | 270 | adapter->link_speed = speed; |
270 | adapter->link_duplex = ecmd->duplex; | 271 | adapter->link_duplex = ecmd->duplex; |
271 | adapter->link_autoneg = ecmd->autoneg; | 272 | adapter->link_autoneg = ecmd->autoneg; |
272 | 273 | ||
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index a7072174ffa7..524e800ddcf4 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -6859,7 +6859,7 @@ static int niu_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
6859 | struct niu_link_config *lp = &np->link_config; | 6859 | struct niu_link_config *lp = &np->link_config; |
6860 | 6860 | ||
6861 | lp->advertising = cmd->advertising; | 6861 | lp->advertising = cmd->advertising; |
6862 | lp->speed = cmd->speed; | 6862 | lp->speed = ethtool_cmd_speed(cmd); |
6863 | lp->duplex = cmd->duplex; | 6863 | lp->duplex = cmd->duplex; |
6864 | lp->autoneg = cmd->autoneg; | 6864 | lp->autoneg = cmd->autoneg; |
6865 | return niu_init_link(np); | 6865 | return niu_init_link(np); |
diff --git a/drivers/net/pch_gbe/pch_gbe_ethtool.c b/drivers/net/pch_gbe/pch_gbe_ethtool.c index c35d105ab285..ea2d8e41887a 100644 --- a/drivers/net/pch_gbe/pch_gbe_ethtool.c +++ b/drivers/net/pch_gbe/pch_gbe_ethtool.c | |||
@@ -92,7 +92,7 @@ static int pch_gbe_get_settings(struct net_device *netdev, | |||
92 | ecmd->advertising &= ~(ADVERTISED_TP | ADVERTISED_1000baseT_Half); | 92 | ecmd->advertising &= ~(ADVERTISED_TP | ADVERTISED_1000baseT_Half); |
93 | 93 | ||
94 | if (!netif_carrier_ok(adapter->netdev)) | 94 | if (!netif_carrier_ok(adapter->netdev)) |
95 | ecmd->speed = -1; | 95 | ethtool_cmd_speed_set(ecmd, -1); |
96 | return ret; | 96 | return ret; |
97 | } | 97 | } |
98 | 98 | ||
@@ -109,12 +109,15 @@ static int pch_gbe_set_settings(struct net_device *netdev, | |||
109 | { | 109 | { |
110 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); | 110 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); |
111 | struct pch_gbe_hw *hw = &adapter->hw; | 111 | struct pch_gbe_hw *hw = &adapter->hw; |
112 | u32 speed = ethtool_cmd_speed(ecmd); | ||
112 | int ret; | 113 | int ret; |
113 | 114 | ||
114 | pch_gbe_hal_write_phy_reg(hw, MII_BMCR, BMCR_RESET); | 115 | pch_gbe_hal_write_phy_reg(hw, MII_BMCR, BMCR_RESET); |
115 | 116 | ||
116 | if (ecmd->speed == USHRT_MAX) { | 117 | /* when set_settings() is called with a ethtool_cmd previously |
117 | ecmd->speed = SPEED_1000; | 118 | * filled by get_settings() on a down link, speed is -1: */ |
119 | if (speed == UINT_MAX) { | ||
120 | speed = SPEED_1000; | ||
118 | ecmd->duplex = DUPLEX_FULL; | 121 | ecmd->duplex = DUPLEX_FULL; |
119 | } | 122 | } |
120 | ret = mii_ethtool_sset(&adapter->mii, ecmd); | 123 | ret = mii_ethtool_sset(&adapter->mii, ecmd); |
@@ -122,7 +125,7 @@ static int pch_gbe_set_settings(struct net_device *netdev, | |||
122 | pr_err("Error: mii_ethtool_sset\n"); | 125 | pr_err("Error: mii_ethtool_sset\n"); |
123 | return ret; | 126 | return ret; |
124 | } | 127 | } |
125 | hw->mac.link_speed = ecmd->speed; | 128 | hw->mac.link_speed = speed; |
126 | hw->mac.link_duplex = ecmd->duplex; | 129 | hw->mac.link_duplex = ecmd->duplex; |
127 | hw->phy.autoneg_advertised = ecmd->advertising; | 130 | hw->phy.autoneg_advertised = ecmd->advertising; |
128 | hw->mac.autoneg = ecmd->autoneg; | 131 | hw->mac.autoneg = ecmd->autoneg; |
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 108591756440..bc71cb260ff4 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -1875,8 +1875,8 @@ static int smc_netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
1875 | u16 tmp; | 1875 | u16 tmp; |
1876 | unsigned int ioaddr = dev->base_addr; | 1876 | unsigned int ioaddr = dev->base_addr; |
1877 | 1877 | ||
1878 | if (ecmd->speed != SPEED_10) | 1878 | if (ethtool_cmd_speed(ecmd) != SPEED_10) |
1879 | return -EINVAL; | 1879 | return -EINVAL; |
1880 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) | 1880 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) |
1881 | return -EINVAL; | 1881 | return -EINVAL; |
1882 | if (ecmd->port != PORT_TP && ecmd->port != PORT_AUI) | 1882 | if (ecmd->port != PORT_TP && ecmd->port != PORT_AUI) |
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index f7670330f988..e3f3501d4347 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -238,6 +238,8 @@ static void phy_sanitize_settings(struct phy_device *phydev) | |||
238 | */ | 238 | */ |
239 | int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) | 239 | int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) |
240 | { | 240 | { |
241 | u32 speed = ethtool_cmd_speed(cmd); | ||
242 | |||
241 | if (cmd->phy_address != phydev->addr) | 243 | if (cmd->phy_address != phydev->addr) |
242 | return -EINVAL; | 244 | return -EINVAL; |
243 | 245 | ||
@@ -253,16 +255,16 @@ int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) | |||
253 | return -EINVAL; | 255 | return -EINVAL; |
254 | 256 | ||
255 | if (cmd->autoneg == AUTONEG_DISABLE && | 257 | if (cmd->autoneg == AUTONEG_DISABLE && |
256 | ((cmd->speed != SPEED_1000 && | 258 | ((speed != SPEED_1000 && |
257 | cmd->speed != SPEED_100 && | 259 | speed != SPEED_100 && |
258 | cmd->speed != SPEED_10) || | 260 | speed != SPEED_10) || |
259 | (cmd->duplex != DUPLEX_HALF && | 261 | (cmd->duplex != DUPLEX_HALF && |
260 | cmd->duplex != DUPLEX_FULL))) | 262 | cmd->duplex != DUPLEX_FULL))) |
261 | return -EINVAL; | 263 | return -EINVAL; |
262 | 264 | ||
263 | phydev->autoneg = cmd->autoneg; | 265 | phydev->autoneg = cmd->autoneg; |
264 | 266 | ||
265 | phydev->speed = cmd->speed; | 267 | phydev->speed = speed; |
266 | 268 | ||
267 | phydev->advertising = cmd->advertising; | 269 | phydev->advertising = cmd->advertising; |
268 | 270 | ||
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 6364e0b03fdd..b52ee17de74d 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -1349,7 +1349,8 @@ static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1349 | 1349 | ||
1350 | spin_lock_irqsave(&tp->lock, flags); | 1350 | spin_lock_irqsave(&tp->lock, flags); |
1351 | ret = rtl8169_set_speed(dev, | 1351 | ret = rtl8169_set_speed(dev, |
1352 | cmd->autoneg, cmd->speed, cmd->duplex, cmd->advertising); | 1352 | cmd->autoneg, ethtool_cmd_speed(cmd), |
1353 | cmd->duplex, cmd->advertising); | ||
1353 | spin_unlock_irqrestore(&tp->lock, flags); | 1354 | spin_unlock_irqrestore(&tp->lock, flags); |
1354 | 1355 | ||
1355 | return ret; | 1356 | return ret; |
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 58b78f46e54f..5443985c019e 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -5380,7 +5380,7 @@ static int s2io_ethtool_sset(struct net_device *dev, | |||
5380 | { | 5380 | { |
5381 | struct s2io_nic *sp = netdev_priv(dev); | 5381 | struct s2io_nic *sp = netdev_priv(dev); |
5382 | if ((info->autoneg == AUTONEG_ENABLE) || | 5382 | if ((info->autoneg == AUTONEG_ENABLE) || |
5383 | (info->speed != SPEED_10000) || | 5383 | (ethtool_cmd_speed(info) != SPEED_10000) || |
5384 | (info->duplex != DUPLEX_FULL)) | 5384 | (info->duplex != DUPLEX_FULL)) |
5385 | return -EINVAL; | 5385 | return -EINVAL; |
5386 | else { | 5386 | else { |
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c index 76290a8c3c14..f3ffc1df3b2d 100644 --- a/drivers/net/sc92031.c +++ b/drivers/net/sc92031.c | |||
@@ -1188,10 +1188,11 @@ static int sc92031_ethtool_set_settings(struct net_device *dev, | |||
1188 | { | 1188 | { |
1189 | struct sc92031_priv *priv = netdev_priv(dev); | 1189 | struct sc92031_priv *priv = netdev_priv(dev); |
1190 | void __iomem *port_base = priv->port_base; | 1190 | void __iomem *port_base = priv->port_base; |
1191 | u32 speed = ethtool_cmd_speed(cmd); | ||
1191 | u32 phy_ctrl; | 1192 | u32 phy_ctrl; |
1192 | u32 old_phy_ctrl; | 1193 | u32 old_phy_ctrl; |
1193 | 1194 | ||
1194 | if (!(cmd->speed == SPEED_10 || cmd->speed == SPEED_100)) | 1195 | if (!(speed == SPEED_10 || speed == SPEED_100)) |
1195 | return -EINVAL; | 1196 | return -EINVAL; |
1196 | if (!(cmd->duplex == DUPLEX_HALF || cmd->duplex == DUPLEX_FULL)) | 1197 | if (!(cmd->duplex == DUPLEX_HALF || cmd->duplex == DUPLEX_FULL)) |
1197 | return -EINVAL; | 1198 | return -EINVAL; |
@@ -1229,7 +1230,7 @@ static int sc92031_ethtool_set_settings(struct net_device *dev, | |||
1229 | // FIXME: Whole branch guessed | 1230 | // FIXME: Whole branch guessed |
1230 | phy_ctrl = 0; | 1231 | phy_ctrl = 0; |
1231 | 1232 | ||
1232 | if (cmd->speed == SPEED_10) | 1233 | if (speed == SPEED_10) |
1233 | phy_ctrl |= PhyCtrlSpd10; | 1234 | phy_ctrl |= PhyCtrlSpd10; |
1234 | else /* cmd->speed == SPEED_100 */ | 1235 | else /* cmd->speed == SPEED_100 */ |
1235 | phy_ctrl |= PhyCtrlSpd100; | 1236 | phy_ctrl |= PhyCtrlSpd100; |
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c index 5d8468fc5804..10b160a508f3 100644 --- a/drivers/net/sfc/ethtool.c +++ b/drivers/net/sfc/ethtool.c | |||
@@ -234,7 +234,8 @@ static int efx_ethtool_set_settings(struct net_device *net_dev, | |||
234 | int rc; | 234 | int rc; |
235 | 235 | ||
236 | /* GMAC does not support 1000Mbps HD */ | 236 | /* GMAC does not support 1000Mbps HD */ |
237 | if (ecmd->speed == SPEED_1000 && ecmd->duplex != DUPLEX_FULL) { | 237 | if ((ethtool_cmd_speed(ecmd) == SPEED_1000) && |
238 | (ecmd->duplex != DUPLEX_FULL)) { | ||
238 | netif_dbg(efx, drv, efx->net_dev, | 239 | netif_dbg(efx, drv, efx->net_dev, |
239 | "rejecting unsupported 1000Mbps HD setting\n"); | 240 | "rejecting unsupported 1000Mbps HD setting\n"); |
240 | return -EINVAL; | 241 | return -EINVAL; |
diff --git a/drivers/net/sfc/mcdi_phy.c b/drivers/net/sfc/mcdi_phy.c index 1fcda2d82399..6c5fccbdeca2 100644 --- a/drivers/net/sfc/mcdi_phy.c +++ b/drivers/net/sfc/mcdi_phy.c | |||
@@ -545,7 +545,7 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec | |||
545 | caps = (ethtool_to_mcdi_cap(ecmd->advertising) | | 545 | caps = (ethtool_to_mcdi_cap(ecmd->advertising) | |
546 | 1 << MC_CMD_PHY_CAP_AN_LBN); | 546 | 1 << MC_CMD_PHY_CAP_AN_LBN); |
547 | } else if (ecmd->duplex) { | 547 | } else if (ecmd->duplex) { |
548 | switch (ecmd->speed) { | 548 | switch (ethtool_cmd_speed(ecmd)) { |
549 | case 10: caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN; break; | 549 | case 10: caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN; break; |
550 | case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break; | 550 | case 100: caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN; break; |
551 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break; | 551 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN; break; |
@@ -553,7 +553,7 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec | |||
553 | default: return -EINVAL; | 553 | default: return -EINVAL; |
554 | } | 554 | } |
555 | } else { | 555 | } else { |
556 | switch (ecmd->speed) { | 556 | switch (ethtool_cmd_speed(ecmd)) { |
557 | case 10: caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN; break; | 557 | case 10: caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN; break; |
558 | case 100: caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN; break; | 558 | case 100: caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN; break; |
559 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN; break; | 559 | case 1000: caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN; break; |
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 176d784cbb54..a05e864de674 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -321,8 +321,9 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
321 | skge->speed = -1; | 321 | skge->speed = -1; |
322 | } else { | 322 | } else { |
323 | u32 setting; | 323 | u32 setting; |
324 | u32 speed = ethtool_cmd_speed(ecmd); | ||
324 | 325 | ||
325 | switch (ecmd->speed) { | 326 | switch (speed) { |
326 | case SPEED_1000: | 327 | case SPEED_1000: |
327 | if (ecmd->duplex == DUPLEX_FULL) | 328 | if (ecmd->duplex == DUPLEX_FULL) |
328 | setting = SUPPORTED_1000baseT_Full; | 329 | setting = SUPPORTED_1000baseT_Full; |
@@ -355,7 +356,7 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
355 | if ((setting & supported) == 0) | 356 | if ((setting & supported) == 0) |
356 | return -EINVAL; | 357 | return -EINVAL; |
357 | 358 | ||
358 | skge->speed = ecmd->speed; | 359 | skge->speed = speed; |
359 | skge->duplex = ecmd->duplex; | 360 | skge->duplex = ecmd->duplex; |
360 | } | 361 | } |
361 | 362 | ||
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index c8d045114c66..5c7e2d68df2a 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -3452,8 +3452,9 @@ static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
3452 | sky2->speed = -1; | 3452 | sky2->speed = -1; |
3453 | } else { | 3453 | } else { |
3454 | u32 setting; | 3454 | u32 setting; |
3455 | u32 speed = ethtool_cmd_speed(ecmd); | ||
3455 | 3456 | ||
3456 | switch (ecmd->speed) { | 3457 | switch (speed) { |
3457 | case SPEED_1000: | 3458 | case SPEED_1000: |
3458 | if (ecmd->duplex == DUPLEX_FULL) | 3459 | if (ecmd->duplex == DUPLEX_FULL) |
3459 | setting = SUPPORTED_1000baseT_Full; | 3460 | setting = SUPPORTED_1000baseT_Full; |
@@ -3486,7 +3487,7 @@ static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
3486 | if ((setting & supported) == 0) | 3487 | if ((setting & supported) == 0) |
3487 | return -EINVAL; | 3488 | return -EINVAL; |
3488 | 3489 | ||
3489 | sky2->speed = ecmd->speed; | 3490 | sky2->speed = speed; |
3490 | sky2->duplex = ecmd->duplex; | 3491 | sky2->duplex = ecmd->duplex; |
3491 | sky2->flags &= ~SKY2_FLAG_AUTO_SPEED; | 3492 | sky2->flags &= ~SKY2_FLAG_AUTO_SPEED; |
3492 | } | 3493 | } |
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index 81b6eb8ed4d7..40a755dd1a26 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c | |||
@@ -1294,7 +1294,7 @@ static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep) | |||
1294 | autoneg = 1; | 1294 | autoneg = 1; |
1295 | } else { | 1295 | } else { |
1296 | autoneg = 0; | 1296 | autoneg = 0; |
1297 | speed = ep->speed; | 1297 | speed = ethtool_cmd_speed(ep); |
1298 | duplex = ep->duplex; | 1298 | duplex = ep->duplex; |
1299 | } | 1299 | } |
1300 | 1300 | ||
@@ -2686,6 +2686,7 @@ static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
2686 | static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 2686 | static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
2687 | { | 2687 | { |
2688 | struct gem *gp = netdev_priv(dev); | 2688 | struct gem *gp = netdev_priv(dev); |
2689 | u32 speed = ethtool_cmd_speed(cmd); | ||
2689 | 2690 | ||
2690 | /* Verify the settings we care about. */ | 2691 | /* Verify the settings we care about. */ |
2691 | if (cmd->autoneg != AUTONEG_ENABLE && | 2692 | if (cmd->autoneg != AUTONEG_ENABLE && |
@@ -2697,9 +2698,9 @@ static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
2697 | return -EINVAL; | 2698 | return -EINVAL; |
2698 | 2699 | ||
2699 | if (cmd->autoneg == AUTONEG_DISABLE && | 2700 | if (cmd->autoneg == AUTONEG_DISABLE && |
2700 | ((cmd->speed != SPEED_1000 && | 2701 | ((speed != SPEED_1000 && |
2701 | cmd->speed != SPEED_100 && | 2702 | speed != SPEED_100 && |
2702 | cmd->speed != SPEED_10) || | 2703 | speed != SPEED_10) || |
2703 | (cmd->duplex != DUPLEX_HALF && | 2704 | (cmd->duplex != DUPLEX_HALF && |
2704 | cmd->duplex != DUPLEX_FULL))) | 2705 | cmd->duplex != DUPLEX_FULL))) |
2705 | return -EINVAL; | 2706 | return -EINVAL; |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index 80e907df36b4..8f3f02802427 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -1383,7 +1383,7 @@ force_link: | |||
1383 | if (ep == NULL || ep->autoneg == AUTONEG_ENABLE) { | 1383 | if (ep == NULL || ep->autoneg == AUTONEG_ENABLE) { |
1384 | hp->sw_bmcr = BMCR_SPEED100; | 1384 | hp->sw_bmcr = BMCR_SPEED100; |
1385 | } else { | 1385 | } else { |
1386 | if (ep->speed == SPEED_100) | 1386 | if (ethtool_cmd_speed(ep) == SPEED_100) |
1387 | hp->sw_bmcr = BMCR_SPEED100; | 1387 | hp->sw_bmcr = BMCR_SPEED100; |
1388 | else | 1388 | else |
1389 | hp->sw_bmcr = 0; | 1389 | hp->sw_bmcr = 0; |
@@ -2452,8 +2452,8 @@ static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
2452 | cmd->autoneg != AUTONEG_DISABLE) | 2452 | cmd->autoneg != AUTONEG_DISABLE) |
2453 | return -EINVAL; | 2453 | return -EINVAL; |
2454 | if (cmd->autoneg == AUTONEG_DISABLE && | 2454 | if (cmd->autoneg == AUTONEG_DISABLE && |
2455 | ((cmd->speed != SPEED_100 && | 2455 | ((ethtool_cmd_speed(cmd) != SPEED_100 && |
2456 | cmd->speed != SPEED_10) || | 2456 | ethtool_cmd_speed(cmd) != SPEED_10) || |
2457 | (cmd->duplex != DUPLEX_HALF && | 2457 | (cmd->duplex != DUPLEX_HALF && |
2458 | cmd->duplex != DUPLEX_FULL))) | 2458 | cmd->duplex != DUPLEX_FULL))) |
2459 | return -EINVAL; | 2459 | return -EINVAL; |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index fa57e3d699de..004f266e4352 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -10042,6 +10042,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
10042 | static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 10042 | static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
10043 | { | 10043 | { |
10044 | struct tg3 *tp = netdev_priv(dev); | 10044 | struct tg3 *tp = netdev_priv(dev); |
10045 | u32 speed = ethtool_cmd_speed(cmd); | ||
10045 | 10046 | ||
10046 | if (tg3_flag(tp, USE_PHYLIB)) { | 10047 | if (tg3_flag(tp, USE_PHYLIB)) { |
10047 | struct phy_device *phydev; | 10048 | struct phy_device *phydev; |
@@ -10091,14 +10092,14 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
10091 | cmd->advertising &= mask; | 10092 | cmd->advertising &= mask; |
10092 | } else { | 10093 | } else { |
10093 | if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) { | 10094 | if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) { |
10094 | if (cmd->speed != SPEED_1000) | 10095 | if (speed != SPEED_1000) |
10095 | return -EINVAL; | 10096 | return -EINVAL; |
10096 | 10097 | ||
10097 | if (cmd->duplex != DUPLEX_FULL) | 10098 | if (cmd->duplex != DUPLEX_FULL) |
10098 | return -EINVAL; | 10099 | return -EINVAL; |
10099 | } else { | 10100 | } else { |
10100 | if (cmd->speed != SPEED_100 && | 10101 | if (speed != SPEED_100 && |
10101 | cmd->speed != SPEED_10) | 10102 | speed != SPEED_10) |
10102 | return -EINVAL; | 10103 | return -EINVAL; |
10103 | } | 10104 | } |
10104 | } | 10105 | } |
@@ -10113,7 +10114,7 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
10113 | tp->link_config.duplex = DUPLEX_INVALID; | 10114 | tp->link_config.duplex = DUPLEX_INVALID; |
10114 | } else { | 10115 | } else { |
10115 | tp->link_config.advertising = 0; | 10116 | tp->link_config.advertising = 0; |
10116 | tp->link_config.speed = cmd->speed; | 10117 | tp->link_config.speed = speed; |
10117 | tp->link_config.duplex = cmd->duplex; | 10118 | tp->link_config.duplex = cmd->duplex; |
10118 | } | 10119 | } |
10119 | 10120 | ||
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c index b13c6b040be3..f8d26bf9b2c4 100644 --- a/drivers/net/tulip/de2104x.c +++ b/drivers/net/tulip/de2104x.c | |||
@@ -1549,10 +1549,11 @@ static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd) | |||
1549 | { | 1549 | { |
1550 | u32 new_media; | 1550 | u32 new_media; |
1551 | unsigned int media_lock; | 1551 | unsigned int media_lock; |
1552 | u32 speed = ethtool_cmd_speed(ecmd); | ||
1552 | 1553 | ||
1553 | if (ecmd->speed != SPEED_10 && ecmd->speed != 5 && ecmd->speed != 2) | 1554 | if (speed != SPEED_10 && speed != 5 && speed != 2) |
1554 | return -EINVAL; | 1555 | return -EINVAL; |
1555 | if (de->de21040 && ecmd->speed == 2) | 1556 | if (de->de21040 && speed == 2) |
1556 | return -EINVAL; | 1557 | return -EINVAL; |
1557 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) | 1558 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) |
1558 | return -EINVAL; | 1559 | return -EINVAL; |
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c index 119c394f71ce..9f11c111b65d 100644 --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c | |||
@@ -1068,25 +1068,26 @@ static int | |||
1068 | typhoon_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1068 | typhoon_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
1069 | { | 1069 | { |
1070 | struct typhoon *tp = netdev_priv(dev); | 1070 | struct typhoon *tp = netdev_priv(dev); |
1071 | u32 speed = ethtool_cmd_speed(cmd); | ||
1071 | struct cmd_desc xp_cmd; | 1072 | struct cmd_desc xp_cmd; |
1072 | __le16 xcvr; | 1073 | __le16 xcvr; |
1073 | int err; | 1074 | int err; |
1074 | 1075 | ||
1075 | err = -EINVAL; | 1076 | err = -EINVAL; |
1076 | if(cmd->autoneg == AUTONEG_ENABLE) { | 1077 | if (cmd->autoneg == AUTONEG_ENABLE) { |
1077 | xcvr = TYPHOON_XCVR_AUTONEG; | 1078 | xcvr = TYPHOON_XCVR_AUTONEG; |
1078 | } else { | 1079 | } else { |
1079 | if(cmd->duplex == DUPLEX_HALF) { | 1080 | if (cmd->duplex == DUPLEX_HALF) { |
1080 | if(cmd->speed == SPEED_10) | 1081 | if (speed == SPEED_10) |
1081 | xcvr = TYPHOON_XCVR_10HALF; | 1082 | xcvr = TYPHOON_XCVR_10HALF; |
1082 | else if(cmd->speed == SPEED_100) | 1083 | else if (speed == SPEED_100) |
1083 | xcvr = TYPHOON_XCVR_100HALF; | 1084 | xcvr = TYPHOON_XCVR_100HALF; |
1084 | else | 1085 | else |
1085 | goto out; | 1086 | goto out; |
1086 | } else if(cmd->duplex == DUPLEX_FULL) { | 1087 | } else if (cmd->duplex == DUPLEX_FULL) { |
1087 | if(cmd->speed == SPEED_10) | 1088 | if (speed == SPEED_10) |
1088 | xcvr = TYPHOON_XCVR_10FULL; | 1089 | xcvr = TYPHOON_XCVR_10FULL; |
1089 | else if(cmd->speed == SPEED_100) | 1090 | else if (speed == SPEED_100) |
1090 | xcvr = TYPHOON_XCVR_100FULL; | 1091 | xcvr = TYPHOON_XCVR_100FULL; |
1091 | else | 1092 | else |
1092 | goto out; | 1093 | goto out; |
@@ -1105,7 +1106,7 @@ typhoon_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1105 | tp->speed = 0xff; /* invalid */ | 1106 | tp->speed = 0xff; /* invalid */ |
1106 | tp->duplex = 0xff; /* invalid */ | 1107 | tp->duplex = 0xff; /* invalid */ |
1107 | } else { | 1108 | } else { |
1108 | tp->speed = cmd->speed; | 1109 | tp->speed = speed; |
1109 | tp->duplex = cmd->duplex; | 1110 | tp->duplex = cmd->duplex; |
1110 | } | 1111 | } |
1111 | 1112 | ||
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index baf04b0a6575..9a8f116e6920 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c | |||
@@ -3247,9 +3247,11 @@ static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd | |||
3247 | return 0; | 3247 | return 0; |
3248 | } | 3248 | } |
3249 | 3249 | ||
3250 | static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 3250 | static int velocity_set_settings(struct net_device *dev, |
3251 | struct ethtool_cmd *cmd) | ||
3251 | { | 3252 | { |
3252 | struct velocity_info *vptr = netdev_priv(dev); | 3253 | struct velocity_info *vptr = netdev_priv(dev); |
3254 | u32 speed = ethtool_cmd_speed(cmd); | ||
3253 | u32 curr_status; | 3255 | u32 curr_status; |
3254 | u32 new_status = 0; | 3256 | u32 new_status = 0; |
3255 | int ret = 0; | 3257 | int ret = 0; |
@@ -3258,9 +3260,9 @@ static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd | |||
3258 | curr_status &= (~VELOCITY_LINK_FAIL); | 3260 | curr_status &= (~VELOCITY_LINK_FAIL); |
3259 | 3261 | ||
3260 | new_status |= ((cmd->autoneg) ? VELOCITY_AUTONEG_ENABLE : 0); | 3262 | new_status |= ((cmd->autoneg) ? VELOCITY_AUTONEG_ENABLE : 0); |
3261 | new_status |= ((cmd->speed == SPEED_1000) ? VELOCITY_SPEED_1000 : 0); | 3263 | new_status |= ((speed == SPEED_1000) ? VELOCITY_SPEED_1000 : 0); |
3262 | new_status |= ((cmd->speed == SPEED_100) ? VELOCITY_SPEED_100 : 0); | 3264 | new_status |= ((speed == SPEED_100) ? VELOCITY_SPEED_100 : 0); |
3263 | new_status |= ((cmd->speed == SPEED_10) ? VELOCITY_SPEED_10 : 0); | 3265 | new_status |= ((speed == SPEED_10) ? VELOCITY_SPEED_10 : 0); |
3264 | new_status |= ((cmd->duplex == DUPLEX_FULL) ? VELOCITY_DUPLEX_FULL : 0); | 3266 | new_status |= ((cmd->duplex == DUPLEX_FULL) ? VELOCITY_DUPLEX_FULL : 0); |
3265 | 3267 | ||
3266 | if ((new_status & VELOCITY_AUTONEG_ENABLE) && | 3268 | if ((new_status & VELOCITY_AUTONEG_ENABLE) && |
diff --git a/drivers/net/vxge/vxge-ethtool.c b/drivers/net/vxge/vxge-ethtool.c index 5aef6c893aee..a70874e64d0e 100644 --- a/drivers/net/vxge/vxge-ethtool.c +++ b/drivers/net/vxge/vxge-ethtool.c | |||
@@ -33,7 +33,8 @@ static int vxge_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info) | |||
33 | { | 33 | { |
34 | /* We currently only support 10Gb/FULL */ | 34 | /* We currently only support 10Gb/FULL */ |
35 | if ((info->autoneg == AUTONEG_ENABLE) || | 35 | if ((info->autoneg == AUTONEG_ENABLE) || |
36 | (info->speed != SPEED_10000) || (info->duplex != DUPLEX_FULL)) | 36 | (ethtool_cmd_speed(info) != SPEED_10000) || |
37 | (info->duplex != DUPLEX_FULL)) | ||
37 | return -EINVAL; | 38 | return -EINVAL; |
38 | 39 | ||
39 | return 0; | 40 | return 0; |