headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / net / igb / igb_ethtool.c
index 34a8a0f..deaea8f 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/interrupt.h>
 #include <linux/if_ether.h>
 #include <linux/ethtool.h>
+#include <linux/sched.h>
 
 #include "igb.h"
 
@@ -64,6 +65,7 @@ static const struct igb_stats igb_gstrings_stats[] = {
        { "rx_crc_errors", IGB_STAT(stats.crcerrs) },
        { "rx_frame_errors", IGB_STAT(net_stats.rx_frame_errors) },
        { "rx_no_buffer_count", IGB_STAT(stats.rnbc) },
+       { "rx_queue_drop_packet_count", IGB_STAT(net_stats.rx_fifo_errors) },
        { "rx_missed_errors", IGB_STAT(stats.mpc) },
        { "tx_aborted_errors", IGB_STAT(stats.ecol) },
        { "tx_carrier_errors", IGB_STAT(stats.tncrs) },
@@ -96,9 +98,10 @@ static const struct igb_stats igb_gstrings_stats[] = {
 };
 
 #define IGB_QUEUE_STATS_LEN \
-       ((((struct igb_adapter *)netdev_priv(netdev))->num_rx_queues + \
-        ((struct igb_adapter *)netdev_priv(netdev))->num_tx_queues) * \
-       (sizeof(struct igb_queue_stats) / sizeof(u64)))
+       (((((struct igb_adapter *)netdev_priv(netdev))->num_rx_queues)* \
+         (sizeof(struct igb_rx_queue_stats) / sizeof(u64))) + \
+        ((((struct igb_adapter *)netdev_priv(netdev))->num_tx_queues) * \
+         (sizeof(struct igb_tx_queue_stats) / sizeof(u64))))
 #define IGB_GLOBAL_STATS_LEN   \
        sizeof(igb_gstrings_stats) / sizeof(struct igb_stats)
 #define IGB_STATS_LEN (IGB_GLOBAL_STATS_LEN + IGB_QUEUE_STATS_LEN)
@@ -166,8 +169,7 @@ static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
                ecmd->duplex = -1;
        }
 
-       ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
-                        hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
+       ecmd->autoneg = hw->mac.autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE;
        return 0;
 }
 
@@ -189,23 +191,20 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 
        if (ecmd->autoneg == AUTONEG_ENABLE) {
                hw->mac.autoneg = 1;
-               if (hw->phy.media_type == e1000_media_type_fiber)
-                       hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full |
-                                                    ADVERTISED_FIBRE |
-                                                    ADVERTISED_Autoneg;
-               else
-                       hw->phy.autoneg_advertised = ecmd->advertising |
-                                                    ADVERTISED_TP |
-                                                    ADVERTISED_Autoneg;
+               hw->phy.autoneg_advertised = ecmd->advertising |
+                                            ADVERTISED_TP |
+                                            ADVERTISED_Autoneg;
                ecmd->advertising = hw->phy.autoneg_advertised;
-       } else
+               if (adapter->fc_autoneg)
+                       hw->fc.requested_mode = e1000_fc_default;
+       } else {
                if (igb_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
                        clear_bit(__IGB_RESETTING, &adapter->state);
                        return -EINVAL;
                }
+       }
 
        /* reset the link */
-
        if (netif_running(adapter->netdev)) {
                igb_down(adapter);
                igb_up(adapter);
@@ -225,11 +224,11 @@ static void igb_get_pauseparam(struct net_device *netdev,
        pause->autoneg =
                (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
 
-       if (hw->fc.type == e1000_fc_rx_pause)
+       if (hw->fc.current_mode == e1000_fc_rx_pause)
                pause->rx_pause = 1;
-       else if (hw->fc.type == e1000_fc_tx_pause)
+       else if (hw->fc.current_mode == e1000_fc_tx_pause)
                pause->tx_pause = 1;
-       else if (hw->fc.type == e1000_fc_full) {
+       else if (hw->fc.current_mode == e1000_fc_full) {
                pause->rx_pause = 1;
                pause->tx_pause = 1;
        }
@@ -247,26 +246,28 @@ static int igb_set_pauseparam(struct net_device *netdev,
        while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
                msleep(1);
 
-       if (pause->rx_pause && pause->tx_pause)
-               hw->fc.type = e1000_fc_full;
-       else if (pause->rx_pause && !pause->tx_pause)
-               hw->fc.type = e1000_fc_rx_pause;
-       else if (!pause->rx_pause && pause->tx_pause)
-               hw->fc.type = e1000_fc_tx_pause;
-       else if (!pause->rx_pause && !pause->tx_pause)
-               hw->fc.type = e1000_fc_none;
-
-       hw->fc.original_type = hw->fc.type;
-
        if (adapter->fc_autoneg == AUTONEG_ENABLE) {
+               hw->fc.requested_mode = e1000_fc_default;
                if (netif_running(adapter->netdev)) {
                        igb_down(adapter);
                        igb_up(adapter);
                } else
                        igb_reset(adapter);
-       } else
-               retval = ((hw->phy.media_type == e1000_media_type_fiber) ?
-                         igb_setup_link(hw) : igb_force_mac_fc(hw));
+       } else {
+               if (pause->rx_pause && pause->tx_pause)
+                       hw->fc.requested_mode = e1000_fc_full;
+               else if (pause->rx_pause && !pause->tx_pause)
+                       hw->fc.requested_mode = e1000_fc_rx_pause;
+               else if (!pause->rx_pause && pause->tx_pause)
+                       hw->fc.requested_mode = e1000_fc_tx_pause;
+               else if (!pause->rx_pause && !pause->tx_pause)
+                       hw->fc.requested_mode = e1000_fc_none;
+
+               hw->fc.current_mode = hw->fc.requested_mode;
+
+               retval = ((hw->phy.media_type == e1000_media_type_copper) ?
+                         igb_force_mac_fc(hw) : igb_setup_link(hw));
+       }
 
        clear_bit(__IGB_RESETTING, &adapter->state);
        return retval;
@@ -275,13 +276,17 @@ static int igb_set_pauseparam(struct net_device *netdev,
 static u32 igb_get_rx_csum(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
-       return adapter->rx_csum;
+       return !(adapter->flags & IGB_FLAG_RX_CSUM_DISABLED);
 }
 
 static int igb_set_rx_csum(struct net_device *netdev, u32 data)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
-       adapter->rx_csum = data;
+
+       if (data)
+               adapter->flags &= ~IGB_FLAG_RX_CSUM_DISABLED;
+       else
+               adapter->flags |= IGB_FLAG_RX_CSUM_DISABLED;
 
        return 0;
 }
@@ -293,10 +298,16 @@ static u32 igb_get_tx_csum(struct net_device *netdev)
 
 static int igb_set_tx_csum(struct net_device *netdev, u32 data)
 {
-       if (data)
+       struct igb_adapter *adapter = netdev_priv(netdev);
+
+       if (data) {
                netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
-       else
-               netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
+               if (adapter->hw.mac.type == e1000_82576)
+                       netdev->features |= NETIF_F_SCTP_CSUM;
+       } else {
+               netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
+                                     NETIF_F_SCTP_CSUM);
+       }
 
        return 0;
 }
@@ -1419,7 +1430,6 @@ static int igb_integrated_phy_loopback(struct igb_adapter *adapter)
 {
        struct e1000_hw *hw = &adapter->hw;
        u32 ctrl_reg = 0;
-       u32 stat_reg = 0;
 
        hw->mac.autoneg = false;
 
@@ -1443,18 +1453,11 @@ static int igb_integrated_phy_loopback(struct igb_adapter *adapter)
        ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
                     E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
                     E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
-                    E1000_CTRL_FD);     /* Force Duplex to FULL */
+                    E1000_CTRL_FD |     /* Force Duplex to FULL */
+                    E1000_CTRL_SLU);    /* Set link up enable bit */
 
-       if (hw->phy.media_type == e1000_media_type_copper &&
-           hw->phy.type == e1000_phy_m88)
+       if (hw->phy.type == e1000_phy_m88)
                ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
-       else {
-               /* Set the ILOS bit on the fiber Nic if half duplex link is
-                * detected. */
-               stat_reg = rd32(E1000_STATUS);
-               if ((stat_reg & E1000_STATUS_FD) == 0)
-                       ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
-       }
 
        wr32(E1000_CTRL, ctrl_reg);
 
@@ -1479,8 +1482,7 @@ static int igb_setup_loopback_test(struct igb_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        u32 reg;
 
-       if (hw->phy.media_type == e1000_media_type_fiber ||
-           hw->phy.media_type == e1000_media_type_internal_serdes) {
+       if (hw->phy.media_type == e1000_media_type_internal_serdes) {
                reg = rd32(E1000_RCTL);
                reg |= E1000_RCTL_LBM_TCVR;
                wr32(E1000_RCTL, reg);
@@ -1779,6 +1781,15 @@ static int igb_wol_exclusion(struct igb_adapter *adapter,
                /* return success for non excluded adapter ports */
                retval = 0;
                break;
+       case E1000_DEV_ID_82576_QUAD_COPPER:
+               /* quad port adapters only support WoL on port A */
+               if (!(adapter->flags & IGB_FLAG_QUAD_PORT_A)) {
+                       wol->supported = 0;
+                       break;
+               }
+               /* return success for non excluded adapter ports */
+               retval = 0;
+               break;
        default:
                /* dual port cards only support WoL on port A from now on
                 * unless it was enabled in the eeprom for port B
@@ -1830,7 +1841,6 @@ static void igb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
 static int igb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
-       struct e1000_hw *hw = &adapter->hw;
 
        if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
                return -EOPNOTSUPP;
@@ -1839,11 +1849,6 @@ static int igb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
            !device_can_wakeup(&adapter->pdev->dev))
                return wol->wolopts ? -EOPNOTSUPP : 0;
 
-       switch (hw->device_id) {
-       default:
-               break;
-       }
-
        /* these settings will always override what we currently have */
        adapter->wol = 0;
 
@@ -1949,7 +1954,8 @@ static void igb_get_ethtool_stats(struct net_device *netdev,
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        u64 *queue_stat;
-       int stat_count = sizeof(struct igb_queue_stats) / sizeof(u64);
+       int stat_count_tx = sizeof(struct igb_tx_queue_stats) / sizeof(u64);
+       int stat_count_rx = sizeof(struct igb_rx_queue_stats) / sizeof(u64);
        int j;
        int i;
 
@@ -1962,14 +1968,14 @@ static void igb_get_ethtool_stats(struct net_device *netdev,
        for (j = 0; j < adapter->num_tx_queues; j++) {
                int k;
                queue_stat = (u64 *)&adapter->tx_ring[j].tx_stats;
-               for (k = 0; k < stat_count; k++)
+               for (k = 0; k < stat_count_tx; k++)
                        data[i + k] = queue_stat[k];
                i += k;
        }
        for (j = 0; j < adapter->num_rx_queues; j++) {
                int k;
                queue_stat = (u64 *)&adapter->rx_ring[j].rx_stats;
-               for (k = 0; k < stat_count; k++)
+               for (k = 0; k < stat_count_rx; k++)
                        data[i + k] = queue_stat[k];
                i += k;
        }
@@ -2003,13 +2009,15 @@ static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
                        p += ETH_GSTRING_LEN;
                        sprintf(p, "rx_queue_%u_bytes", i);
                        p += ETH_GSTRING_LEN;
+                       sprintf(p, "rx_queue_%u_drops", i);
+                       p += ETH_GSTRING_LEN;
                }
 /*             BUG_ON(p - data != IGB_STATS_LEN * ETH_GSTRING_LEN); */
                break;
        }
 }
 
-static struct ethtool_ops igb_ethtool_ops = {
+static const struct ethtool_ops igb_ethtool_ops = {
        .get_settings           = igb_get_settings,
        .set_settings           = igb_set_settings,
        .get_drvinfo            = igb_get_drvinfo,