From af2dbf701797d5c2bb5b8ea24bc1832ac79a7d7a Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Fri, 7 Oct 2005 13:45:10 -0700 Subject: [PATCH] ethtool: Fix default advertsing Change 'ethtool -s eth0 autoneg on' to pass in only the supported speeds to advertise if speed and duplex are not specified by the user. This makes more sense than the current behavior of advertising 10/100/ 1000, some of which may not be supported by the device. Signed-off-by: Michael Chan Signed-off-by: Jeff Garzik --- ethtool.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'ethtool.c') diff --git a/ethtool.c b/ethtool.c index cfcba68..4ee0f90 100644 --- a/ethtool.c +++ b/ethtool.c @@ -614,13 +614,10 @@ static void parse_cmdline(int argc, char **argp) duplex_wanted == DUPLEX_FULL) advertising_wanted = ADVERTISED_1000baseT_Full; else - /* auto negotiate without forcing */ - advertising_wanted = ADVERTISED_100baseT_Full | - ADVERTISED_100baseT_Half | - ADVERTISED_10baseT_Full | - ADVERTISED_10baseT_Half | - ADVERTISED_1000baseT_Full | - ADVERTISED_1000baseT_Half; + /* auto negotiate without forcing, + * all supported speed will be assigned in do_sset() + */ + advertising_wanted = 0; } @@ -1588,8 +1585,18 @@ static int do_sset(int fd, struct ifreq *ifr) ecmd.phy_address = phyad_wanted; if (xcvr_wanted != -1) ecmd.transceiver = xcvr_wanted; - if (advertising_wanted != -1) - ecmd.advertising = advertising_wanted; + if (advertising_wanted != -1) { + if (advertising_wanted == 0) + ecmd.advertising = ecmd.supported & + (ADVERTISED_10baseT_Half | + ADVERTISED_10baseT_Full | + ADVERTISED_100baseT_Half | + ADVERTISED_100baseT_Full | + ADVERTISED_1000baseT_Half | + ADVERTISED_1000baseT_Full); + else + ecmd.advertising = advertising_wanted; + } /* Try to perform the update. */ ecmd.cmd = ETHTOOL_SSET; -- cgit v1.2.1