]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/e1000e/ethtool.c
e1000e: fail when try to setup unsupported features
[mv-sheeva.git] / drivers / net / e1000e / ethtool.c
index db86850b1636e9dfe3e4ebc09809ad49e431d60d..6355a1b779d3e7f0833c7cd6e96e23b3c9671fc9 100644 (file)
@@ -118,7 +118,6 @@ static int e1000_get_settings(struct net_device *netdev,
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
-       u32 status;
 
        if (hw->phy.media_type == e1000_media_type_copper) {
 
@@ -156,22 +155,29 @@ static int e1000_get_settings(struct net_device *netdev,
                ecmd->transceiver = XCVR_EXTERNAL;
        }
 
-       status = er32(STATUS);
-       if (status & E1000_STATUS_LU) {
-               if (status & E1000_STATUS_SPEED_1000)
-                       ecmd->speed = 1000;
-               else if (status & E1000_STATUS_SPEED_100)
-                       ecmd->speed = 100;
-               else
-                       ecmd->speed = 10;
+       ecmd->speed = -1;
+       ecmd->duplex = -1;
 
-               if (status & E1000_STATUS_FD)
-                       ecmd->duplex = DUPLEX_FULL;
-               else
-                       ecmd->duplex = DUPLEX_HALF;
+       if (netif_running(netdev)) {
+               if (netif_carrier_ok(netdev)) {
+                       ecmd->speed = adapter->link_speed;
+                       ecmd->duplex = adapter->link_duplex - 1;
+               }
        } else {
-               ecmd->speed = -1;
-               ecmd->duplex = -1;
+               u32 status = er32(STATUS);
+               if (status & E1000_STATUS_LU) {
+                       if (status & E1000_STATUS_SPEED_1000)
+                               ecmd->speed = 1000;
+                       else if (status & E1000_STATUS_SPEED_100)
+                               ecmd->speed = 100;
+                       else
+                               ecmd->speed = 10;
+
+                       if (status & E1000_STATUS_FD)
+                               ecmd->duplex = DUPLEX_FULL;
+                       else
+                               ecmd->duplex = DUPLEX_HALF;
+               }
        }
 
        ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
@@ -179,7 +185,7 @@ static int e1000_get_settings(struct net_device *netdev,
 
        /* MDI-X => 2; MDI =>1; Invalid =>0 */
        if ((hw->phy.media_type == e1000_media_type_copper) &&
-           !hw->mac.get_link_status)
+           netif_carrier_ok(netdev))
                ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X :
                                                      ETH_TP_MDI;
        else
@@ -191,19 +197,15 @@ static int e1000_get_settings(struct net_device *netdev,
 static u32 e1000_get_link(struct net_device *netdev)
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
-       struct e1000_mac_info *mac = &adapter->hw.mac;
+       struct e1000_hw *hw = &adapter->hw;
 
        /*
-        * If the link is not reported up to netdev, interrupts are disabled,
-        * and so the physical link state may have changed since we last
-        * looked. Set get_link_status to make sure that the true link
-        * state is interrogated, rather than pulling a cached and possibly
-        * stale link state from the driver.
+        * Avoid touching hardware registers when possible, otherwise
+        * link negotiation can get messed up when user-level scripts
+        * are rapidly polling the driver to see if link is up.
         */
-       if (!netif_carrier_ok(netdev))
-               mac->get_link_status = 1;
-
-       return e1000e_has_link(adapter);
+       return netif_running(netdev) ? netif_carrier_ok(netdev) :
+           !!(er32(STATUS) & E1000_STATUS_LU);
 }
 
 static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
@@ -2049,7 +2051,6 @@ static const struct ethtool_ops e1000_ethtool_ops = {
        .get_coalesce           = e1000_get_coalesce,
        .set_coalesce           = e1000_set_coalesce,
        .get_flags              = ethtool_op_get_flags,
-       .set_flags              = ethtool_op_set_flags,
 };
 
 void e1000e_set_ethtool_ops(struct net_device *netdev)