Merge branch 'sg' of git://git.kernel.dk/linux-2.6-block
[safe/jmp/linux-2.6] / drivers / net / e1000 / e1000_ethtool.c
index e39aa1f..6c9a643 100644 (file)
@@ -1,25 +1,24 @@
 /*******************************************************************************
 
-  
-  Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
-  
-  This program is free software; you can redistribute it and/or modify it 
-  under the terms of the GNU General Public License as published by the Free 
-  Software Foundation; either version 2 of the License, or (at your option) 
-  any later version.
-  
-  This program is distributed in the hope that it will be useful, but WITHOUT 
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
+  Intel PRO/1000 Linux driver
+  Copyright(c) 1999 - 2006 Intel Corporation.
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.
-  
+
   You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc., 59 
-  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-  
-  The full GNU General Public License is included in this distribution in the
-  file called LICENSE.
-  
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
   Contact Information:
   Linux NICS <linux.nics@intel.com>
   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
 
 #include <asm/uaccess.h>
 
+extern char e1000_driver_name[];
+extern char e1000_driver_version[];
+
+extern int e1000_up(struct e1000_adapter *adapter);
+extern void e1000_down(struct e1000_adapter *adapter);
+extern void e1000_reinit_locked(struct e1000_adapter *adapter);
+extern void e1000_reset(struct e1000_adapter *adapter);
+extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
+extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
+extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
+extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
+extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
+extern void e1000_update_stats(struct e1000_adapter *adapter);
+
+
 struct e1000_stats {
        char stat_string[ETH_GSTRING_LEN];
        int sizeof_stat;
@@ -42,31 +56,36 @@ struct e1000_stats {
 #define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
                      offsetof(struct e1000_adapter, m)
 static const struct e1000_stats e1000_gstrings_stats[] = {
-       { "rx_packets", E1000_STAT(net_stats.rx_packets) },
-       { "tx_packets", E1000_STAT(net_stats.tx_packets) },
-       { "rx_bytes", E1000_STAT(net_stats.rx_bytes) },
-       { "tx_bytes", E1000_STAT(net_stats.tx_bytes) },
-       { "rx_errors", E1000_STAT(net_stats.rx_errors) },
-       { "tx_errors", E1000_STAT(net_stats.tx_errors) },
+       { "rx_packets", E1000_STAT(stats.gprc) },
+       { "tx_packets", E1000_STAT(stats.gptc) },
+       { "rx_bytes", E1000_STAT(stats.gorcl) },
+       { "tx_bytes", E1000_STAT(stats.gotcl) },
+       { "rx_broadcast", E1000_STAT(stats.bprc) },
+       { "tx_broadcast", E1000_STAT(stats.bptc) },
+       { "rx_multicast", E1000_STAT(stats.mprc) },
+       { "tx_multicast", E1000_STAT(stats.mptc) },
+       { "rx_errors", E1000_STAT(stats.rxerrc) },
+       { "tx_errors", E1000_STAT(stats.txerrc) },
        { "tx_dropped", E1000_STAT(net_stats.tx_dropped) },
-       { "multicast", E1000_STAT(net_stats.multicast) },
-       { "collisions", E1000_STAT(net_stats.collisions) },
-       { "rx_length_errors", E1000_STAT(net_stats.rx_length_errors) },
+       { "multicast", E1000_STAT(stats.mprc) },
+       { "collisions", E1000_STAT(stats.colc) },
+       { "rx_length_errors", E1000_STAT(stats.rlerrc) },
        { "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) },
-       { "rx_crc_errors", E1000_STAT(net_stats.rx_crc_errors) },
+       { "rx_crc_errors", E1000_STAT(stats.crcerrs) },
        { "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) },
        { "rx_no_buffer_count", E1000_STAT(stats.rnbc) },
-       { "rx_missed_errors", E1000_STAT(net_stats.rx_missed_errors) },
-       { "tx_aborted_errors", E1000_STAT(net_stats.tx_aborted_errors) },
-       { "tx_carrier_errors", E1000_STAT(net_stats.tx_carrier_errors) },
+       { "rx_missed_errors", E1000_STAT(stats.mpc) },
+       { "tx_aborted_errors", E1000_STAT(stats.ecol) },
+       { "tx_carrier_errors", E1000_STAT(stats.tncrs) },
        { "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) },
        { "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) },
-       { "tx_window_errors", E1000_STAT(net_stats.tx_window_errors) },
+       { "tx_window_errors", E1000_STAT(stats.latecol) },
        { "tx_abort_late_coll", E1000_STAT(stats.latecol) },
        { "tx_deferred_ok", E1000_STAT(stats.dc) },
        { "tx_single_coll_ok", E1000_STAT(stats.scc) },
        { "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
        { "tx_timeout_count", E1000_STAT(tx_timeout_count) },
+       { "tx_restart_queue", E1000_STAT(restart_queue) },
        { "rx_long_length_errors", E1000_STAT(stats.roc) },
        { "rx_short_length_errors", E1000_STAT(stats.ruc) },
        { "rx_align_errors", E1000_STAT(stats.algnerrc) },
@@ -81,11 +100,13 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
        { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) },
        { "rx_header_split", E1000_STAT(rx_hdr_split) },
        { "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed) },
+       { "tx_smbus", E1000_STAT(stats.mgptc) },
+       { "rx_smbus", E1000_STAT(stats.mgprc) },
+       { "dropped_smbus", E1000_STAT(stats.mgpdc) },
 };
 
 #define E1000_QUEUE_STATS_LEN 0
-#define E1000_GLOBAL_STATS_LEN \
-       sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
+#define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN + E1000_QUEUE_STATS_LEN)
 static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
        "Register test  (offline)", "Eeprom test    (offline)",
@@ -115,9 +136,7 @@ e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 
                if (hw->autoneg == 1) {
                        ecmd->advertising |= ADVERTISED_Autoneg;
-
                        /* the e1000 autoneg seems to match ethtool nicely */
-
                        ecmd->advertising |= hw->autoneg_advertised;
                }
 
@@ -146,7 +165,7 @@ e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
                        ecmd->transceiver = XCVR_EXTERNAL;
        }
 
-       if (netif_carrier_ok(adapter->netdev)) {
+       if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) {
 
                e1000_get_speed_and_duplex(hw, &adapter->link_speed,
                                                   &adapter->link_duplex);
@@ -193,13 +212,9 @@ e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
                                     ADVERTISED_FIBRE |
                                     ADVERTISED_Autoneg;
                else
-                       hw->autoneg_advertised = ADVERTISED_10baseT_Half |
-                                                 ADVERTISED_10baseT_Full |
-                                                 ADVERTISED_100baseT_Half |
-                                                 ADVERTISED_100baseT_Full |
-                                                 ADVERTISED_1000baseT_Full|
-                                                 ADVERTISED_Autoneg |
-                                                 ADVERTISED_TP;
+                       hw->autoneg_advertised = ecmd->advertising |
+                                                ADVERTISED_TP |
+                                                ADVERTISED_Autoneg;
                ecmd->advertising = hw->autoneg_advertised;
        } else
                if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
@@ -229,11 +244,11 @@ e1000_get_pauseparam(struct net_device *netdev,
        pause->autoneg =
                (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
 
-       if (hw->fc == e1000_fc_rx_pause)
+       if (hw->fc == E1000_FC_RX_PAUSE)
                pause->rx_pause = 1;
-       else if (hw->fc == e1000_fc_tx_pause)
+       else if (hw->fc == E1000_FC_TX_PAUSE)
                pause->tx_pause = 1;
-       else if (hw->fc == e1000_fc_full) {
+       else if (hw->fc == E1000_FC_FULL) {
                pause->rx_pause = 1;
                pause->tx_pause = 1;
        }
@@ -253,13 +268,13 @@ e1000_set_pauseparam(struct net_device *netdev,
                msleep(1);
 
        if (pause->rx_pause && pause->tx_pause)
-               hw->fc = e1000_fc_full;
+               hw->fc = E1000_FC_FULL;
        else if (pause->rx_pause && !pause->tx_pause)
-               hw->fc = e1000_fc_rx_pause;
+               hw->fc = E1000_FC_RX_PAUSE;
        else if (!pause->rx_pause && pause->tx_pause)
-               hw->fc = e1000_fc_tx_pause;
+               hw->fc = E1000_FC_TX_PAUSE;
        else if (!pause->rx_pause && !pause->tx_pause)
-               hw->fc = e1000_fc_none;
+               hw->fc = E1000_FC_NONE;
 
        hw->original_fc = hw->fc;
 
@@ -271,7 +286,7 @@ e1000_set_pauseparam(struct net_device *netdev,
                        e1000_reset(adapter);
        } else
                retval = ((hw->media_type == e1000_media_type_fiber) ?
-                          e1000_setup_link(hw) : e1000_force_mac_fc(hw));
+                         e1000_setup_link(hw) : e1000_force_mac_fc(hw));
 
        clear_bit(__E1000_RESETTING, &adapter->flags);
        return retval;
@@ -322,7 +337,6 @@ e1000_set_tx_csum(struct net_device *netdev, uint32_t data)
        return 0;
 }
 
-#ifdef NETIF_F_TSO
 static int
 e1000_set_tso(struct net_device *netdev, uint32_t data)
 {
@@ -336,11 +350,15 @@ e1000_set_tso(struct net_device *netdev, uint32_t data)
        else
                netdev->features &= ~NETIF_F_TSO;
 
+       if (data)
+               netdev->features |= NETIF_F_TSO6;
+       else
+               netdev->features &= ~NETIF_F_TSO6;
+
        DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled");
        adapter->tso_force = TRUE;
        return 0;
 }
-#endif /* NETIF_F_TSO */
 
 static uint32_t
 e1000_get_msglevel(struct net_device *netdev)
@@ -447,7 +465,8 @@ e1000_get_regs(struct net_device *netdev,
        regs_buff[24] = (uint32_t)phy_data;  /* phy local receiver status */
        regs_buff[25] = regs_buff[24];  /* phy remote receiver status */
        if (hw->mac_type >= e1000_82540 &&
-          hw->media_type == e1000_media_type_copper) {
+           hw->mac_type < e1000_82571 &&
+           hw->media_type == e1000_media_type_copper) {
                regs_buff[26] = E1000_READ_REG(hw, MANC);
        }
 }
@@ -599,8 +618,6 @@ e1000_get_drvinfo(struct net_device *netdev,
 
        strncpy(drvinfo->fw_version, firmware_version, 32);
        strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
-       drvinfo->n_stats = E1000_STATS_LEN;
-       drvinfo->testinfo_len = E1000_TEST_LEN;
        drvinfo->regdump_len = e1000_get_regs_len(netdev);
        drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
 }
@@ -632,16 +649,13 @@ e1000_set_ringparam(struct net_device *netdev,
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
        e1000_mac_type mac_type = adapter->hw.mac_type;
-       struct e1000_tx_ring *txdr, *tx_old, *tx_new;
-       struct e1000_rx_ring *rxdr, *rx_old, *rx_new;
-       int i, err, tx_ring_size, rx_ring_size;
+       struct e1000_tx_ring *txdr, *tx_old;
+       struct e1000_rx_ring *rxdr, *rx_old;
+       int i, err;
 
        if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
                return -EINVAL;
 
-       tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
-       rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
-
        while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
                msleep(1);
 
@@ -651,33 +665,27 @@ e1000_set_ringparam(struct net_device *netdev,
        tx_old = adapter->tx_ring;
        rx_old = adapter->rx_ring;
 
-       adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL);
-       if (!adapter->tx_ring) {
-               err = -ENOMEM;
-               goto err_setup_rx;
-       }
-       memset(adapter->tx_ring, 0, tx_ring_size);
+       err = -ENOMEM;
+       txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL);
+       if (!txdr)
+               goto err_alloc_tx;
 
-       adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL);
-       if (!adapter->rx_ring) {
-               kfree(adapter->tx_ring);
-               err = -ENOMEM;
-               goto err_setup_rx;
-       }
-       memset(adapter->rx_ring, 0, rx_ring_size);
+       rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL);
+       if (!rxdr)
+               goto err_alloc_rx;
 
-       txdr = adapter->tx_ring;
-       rxdr = adapter->rx_ring;
+       adapter->tx_ring = txdr;
+       adapter->rx_ring = rxdr;
 
        rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
        rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
                E1000_MAX_RXD : E1000_MAX_82544_RXD));
-       E1000_ROUNDUP(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
+       rxdr->count = ALIGN(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
 
        txdr->count = max(ring->tx_pending,(uint32_t)E1000_MIN_TXD);
        txdr->count = min(txdr->count,(uint32_t)(mac_type < e1000_82544 ?
                E1000_MAX_TXD : E1000_MAX_82544_TXD));
-       E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
+       txdr->count = ALIGN(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
 
        for (i = 0; i < adapter->num_tx_queues; i++)
                txdr[i].count = txdr->count;
@@ -694,16 +702,14 @@ e1000_set_ringparam(struct net_device *netdev,
                /* save the new, restore the old in order to free it,
                 * then restore the new back again */
 
-               rx_new = adapter->rx_ring;
-               tx_new = adapter->tx_ring;
                adapter->rx_ring = rx_old;
                adapter->tx_ring = tx_old;
                e1000_free_all_rx_resources(adapter);
                e1000_free_all_tx_resources(adapter);
                kfree(tx_old);
                kfree(rx_old);
-               adapter->rx_ring = rx_new;
-               adapter->tx_ring = tx_new;
+               adapter->rx_ring = rxdr;
+               adapter->tx_ring = txdr;
                if ((err = e1000_up(adapter)))
                        goto err_setup;
        }
@@ -715,6 +721,10 @@ err_setup_tx:
 err_setup_rx:
        adapter->rx_ring = rx_old;
        adapter->tx_ring = tx_old;
+       kfree(rxdr);
+err_alloc_rx:
+       kfree(txdr);
+err_alloc_tx:
        e1000_up(adapter);
 err_setup:
        clear_bit(__E1000_RESETTING, &adapter->flags);
@@ -726,7 +736,7 @@ err_setup:
        uint32_t pat, value;                                                   \
        uint32_t test[] =                                                      \
                {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};              \
-       for (pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) {              \
+       for (pat = 0; pat < ARRAY_SIZE(test); pat++) {              \
                E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W));             \
                value = E1000_READ_REG(&adapter->hw, R);                       \
                if (value != (test[pat] & W & M)) {                             \
@@ -763,7 +773,7 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
        /* The status register is Read Only, so a write should fail.
         * Some bits that get toggled are ignored.
         */
-        switch (adapter->hw.mac_type) {
+       switch (adapter->hw.mac_type) {
        /* there are several bits on newer hardware that are r/w */
        case e1000_82571:
        case e1000_82572:
@@ -791,12 +801,14 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
        }
        /* restore previous status */
        E1000_WRITE_REG(&adapter->hw, STATUS, before);
+
        if (adapter->hw.mac_type != e1000_ich8lan) {
                REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
                REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
                REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
                REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
        }
+
        REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
        REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
        REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
@@ -809,8 +821,9 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
        REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
 
        REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
+
        before = (adapter->hw.mac_type == e1000_ich8lan ?
-                       0x06C3B33E : 0x06DFB3FE);
+                 0x06C3B33E : 0x06DFB3FE);
        REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB);
        REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
 
@@ -823,10 +836,10 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
                REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
                REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
                value = (adapter->hw.mac_type == e1000_ich8lan ?
-                               E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES);
+                        E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES);
                for (i = 0; i < value; i++) {
                        REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
-                                        0xFFFFFFFF);
+                                        0xFFFFFFFF);
                }
 
        } else {
@@ -872,9 +885,7 @@ e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
 }
 
 static irqreturn_t
-e1000_test_intr(int irq,
-               void *data,
-               struct pt_regs *regs)
+e1000_test_intr(int irq, void *data)
 {
        struct net_device *netdev = (struct net_device *) data;
        struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -895,11 +906,11 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
 
        /* NOTE: we don't test MSI interrupts here, yet */
        /* Hook up test interrupt handler just for this test */
-       if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED,
-                        netdev->name, netdev))
+       if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
+                        netdev))
                shared_int = FALSE;
        else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
-                             netdev->name, netdev)) {
+                netdev->name, netdev)) {
                *data = 1;
                return -1;
        }
@@ -915,6 +926,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
 
                if (adapter->hw.mac_type == e1000_ich8lan && i == 8)
                        continue;
+
                /* Interrupt to test */
                mask = 1 << i;
 
@@ -1035,23 +1047,24 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
        struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
        struct pci_dev *pdev = adapter->pdev;
        uint32_t rctl;
-       int size, i, ret_val;
+       int i, ret_val;
 
        /* Setup Tx descriptor ring and Tx buffers */
 
        if (!txdr->count)
                txdr->count = E1000_DEFAULT_TXD;
 
-       size = txdr->count * sizeof(struct e1000_buffer);
-       if (!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+       if (!(txdr->buffer_info = kcalloc(txdr->count,
+                                         sizeof(struct e1000_buffer),
+                                         GFP_KERNEL))) {
                ret_val = 1;
                goto err_nomem;
        }
-       memset(txdr->buffer_info, 0, size);
 
        txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
-       E1000_ROUNDUP(txdr->size, 4096);
-       if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) {
+       txdr->size = ALIGN(txdr->size, 4096);
+       if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size,
+                                               &txdr->dma))) {
                ret_val = 2;
                goto err_nomem;
        }
@@ -1098,12 +1111,12 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
        if (!rxdr->count)
                rxdr->count = E1000_DEFAULT_RXD;
 
-       size = rxdr->count * sizeof(struct e1000_buffer);
-       if (!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+       if (!(rxdr->buffer_info = kcalloc(rxdr->count,
+                                         sizeof(struct e1000_buffer),
+                                         GFP_KERNEL))) {
                ret_val = 4;
                goto err_nomem;
        }
-       memset(rxdr->buffer_info, 0, size);
 
        rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
        if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
@@ -1596,9 +1609,16 @@ e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
 }
 
 static int
-e1000_diag_test_count(struct net_device *netdev)
+e1000_get_sset_count(struct net_device *netdev, int sset)
 {
-       return E1000_TEST_LEN;
+       switch (sset) {
+       case ETH_SS_TEST:
+               return E1000_TEST_LEN;
+       case ETH_SS_STATS:
+               return E1000_STATS_LEN;
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
 extern void e1000_power_up_phy(struct e1000_adapter *);
@@ -1610,7 +1630,7 @@ e1000_diag_test(struct net_device *netdev,
        struct e1000_adapter *adapter = netdev_priv(netdev);
        boolean_t if_running = netif_running(netdev);
 
-       set_bit(__E1000_DRIVER_TESTING, &adapter->flags);
+       set_bit(__E1000_TESTING, &adapter->flags);
        if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
                /* Offline tests */
 
@@ -1655,7 +1675,7 @@ e1000_diag_test(struct net_device *netdev,
                adapter->hw.autoneg = autoneg;
 
                e1000_reset(adapter);
-               clear_bit(__E1000_DRIVER_TESTING, &adapter->flags);
+               clear_bit(__E1000_TESTING, &adapter->flags);
                if (if_running)
                        dev_open(netdev);
        } else {
@@ -1664,13 +1684,13 @@ e1000_diag_test(struct net_device *netdev,
                if (e1000_link_test(adapter, &data[4]))
                        eth_test->flags |= ETH_TEST_FL_FAILED;
 
-               /* Offline tests aren't run; pass by default */
+               /* Online tests aren't run; pass by default */
                data[0] = 0;
                data[1] = 0;
                data[2] = 0;
                data[3] = 0;
 
-               clear_bit(__E1000_DRIVER_TESTING, &adapter->flags);
+               clear_bit(__E1000_TESTING, &adapter->flags);
        }
        msleep_interruptible(4 * 1000);
 }
@@ -1681,6 +1701,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wol
        int retval = 1; /* fail by default */
 
        switch (hw->device_id) {
+       case E1000_DEV_ID_82542:
        case E1000_DEV_ID_82543GC_FIBER:
        case E1000_DEV_ID_82543GC_COPPER:
        case E1000_DEV_ID_82544EI_FIBER:
@@ -1689,6 +1710,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wol
        case E1000_DEV_ID_82545EM_COPPER:
        case E1000_DEV_ID_82546GB_QUAD_COPPER:
        case E1000_DEV_ID_82546GB_PCIE:
+       case E1000_DEV_ID_82571EB_SERDES_QUAD:
                /* these don't support WoL at all */
                wol->supported = 0;
                break;
@@ -1706,6 +1728,9 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wol
                retval = 0;
                break;
        case E1000_DEV_ID_82571EB_QUAD_COPPER:
+       case E1000_DEV_ID_82571EB_QUAD_FIBER:
+       case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
+       case E1000_DEV_ID_82571PT_QUAD_COPPER:
        case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
                /* quad port adapters only support WoL on port A */
                if (!adapter->quad_port_a) {
@@ -1878,12 +1903,6 @@ e1000_nway_reset(struct net_device *netdev)
        return 0;
 }
 
-static int
-e1000_get_stats_count(struct net_device *netdev)
-{
-       return E1000_STATS_LEN;
-}
-
 static void
 e1000_get_ethtool_stats(struct net_device *netdev,
                struct ethtool_stats *stats, uint64_t *data)
@@ -1945,19 +1964,13 @@ static const struct ethtool_ops e1000_ethtool_ops = {
        .set_rx_csum            = e1000_set_rx_csum,
        .get_tx_csum            = e1000_get_tx_csum,
        .set_tx_csum            = e1000_set_tx_csum,
-       .get_sg                 = ethtool_op_get_sg,
        .set_sg                 = ethtool_op_set_sg,
-#ifdef NETIF_F_TSO
-       .get_tso                = ethtool_op_get_tso,
        .set_tso                = e1000_set_tso,
-#endif
-       .self_test_count        = e1000_diag_test_count,
        .self_test              = e1000_diag_test,
        .get_strings            = e1000_get_strings,
        .phys_id                = e1000_phys_id,
-       .get_stats_count        = e1000_get_stats_count,
        .get_ethtool_stats      = e1000_get_ethtool_stats,
-       .get_perm_addr          = ethtool_op_get_perm_addr,
+       .get_sset_count         = e1000_get_sset_count,
 };
 
 void e1000_set_ethtool_ops(struct net_device *netdev)