IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
[linux-2.6.git] / drivers / net / e1000 / e1000_ethtool.c
index 8edbc6b..773821e 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,26 +56,30 @@ 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) },
@@ -183,6 +201,9 @@ e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
                return -EINVAL;
        }
 
+       while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
+               msleep(1);
+
        if (ecmd->autoneg == AUTONEG_ENABLE) {
                hw->autoneg = 1;
                if (hw->media_type == e1000_media_type_fiber)
@@ -190,25 +211,25 @@ 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))
+               if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
+                       clear_bit(__E1000_RESETTING, &adapter->flags);
                        return -EINVAL;
+               }
 
        /* reset the link */
 
-       if (netif_running(adapter->netdev))
-               e1000_reinit_locked(adapter);
-       else
+       if (netif_running(adapter->netdev)) {
+               e1000_down(adapter);
+               e1000_up(adapter);
+       } else
                e1000_reset(adapter);
 
+       clear_bit(__E1000_RESETTING, &adapter->flags);
        return 0;
 }
 
@@ -222,11 +243,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;
        }
@@ -238,30 +259,36 @@ e1000_set_pauseparam(struct net_device *netdev,
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
+       int retval = 0;
 
        adapter->fc_autoneg = pause->autoneg;
 
+       while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
+               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;
 
        if (adapter->fc_autoneg == AUTONEG_ENABLE) {
-               if (netif_running(adapter->netdev))
-                       e1000_reinit_locked(adapter);
-               else
+               if (netif_running(adapter->netdev)) {
+                       e1000_down(adapter);
+                       e1000_up(adapter);
+               } else
                        e1000_reset(adapter);
        } else
-               return ((hw->media_type == e1000_media_type_fiber) ?
-                       e1000_setup_link(hw) : e1000_force_mac_fc(hw));
+               retval = ((hw->media_type == e1000_media_type_fiber) ?
+                          e1000_setup_link(hw) : e1000_force_mac_fc(hw));
 
-       return 0;
+       clear_bit(__E1000_RESETTING, &adapter->flags);
+       return retval;
 }
 
 static uint32_t
@@ -415,12 +442,12 @@ e1000_get_regs(struct net_device *netdev,
                regs_buff[23] = regs_buff[18]; /* mdix mode */
                e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
        } else {
-               e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
+               e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
                regs_buff[13] = (uint32_t)phy_data; /* cable length */
                regs_buff[14] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
                regs_buff[15] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
                regs_buff[16] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
-               e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
+               e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
                regs_buff[17] = (uint32_t)phy_data; /* extended 10bt distance */
                regs_buff[18] = regs_buff[13]; /* cable polarity */
                regs_buff[19] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
@@ -619,8 +646,8 @@ 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;
+       struct e1000_tx_ring *txdr, *tx_old;
+       struct e1000_rx_ring *rxdr, *rx_old;
        int i, err, tx_ring_size, rx_ring_size;
 
        if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
@@ -638,23 +665,17 @@ 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 = kzalloc(tx_ring_size, 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 = kzalloc(rx_ring_size, 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 ?
@@ -681,28 +702,29 @@ 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;
        }
 
        clear_bit(__E1000_RESETTING, &adapter->flags);
-
        return 0;
 err_setup_tx:
        e1000_free_all_rx_resources(adapter);
 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);
@@ -861,8 +883,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)
+               void *data)
 {
        struct net_device *netdev = (struct net_device *) data;
        struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -881,21 +902,22 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
 
        *data = 0;
 
+       /* 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)) {
-               shared_int = FALSE;
-       } else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
-                             netdev->name, netdev)){
+                        netdev->name, netdev))
+               shared_int = FALSE;
+       else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
+                             netdev->name, netdev)) {
                *data = 1;
                return -1;
        }
-       DPRINTK(PROBE,INFO, "testing %s interrupt\n",
+       DPRINTK(HW, INFO, "testing %s interrupt\n",
                (shared_int ? "shared" : "unshared"));
 
        /* Disable all the interrupts */
        E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
-       msec_delay(10);
+       msleep(10);
 
        /* Test each interrupt */
        for (; i < 10; i++) {
@@ -915,7 +937,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
                        adapter->test_icr = 0;
                        E1000_WRITE_REG(&adapter->hw, IMC, mask);
                        E1000_WRITE_REG(&adapter->hw, ICS, mask);
-                       msec_delay(10);
+                       msleep(10);
 
                        if (adapter->test_icr & mask) {
                                *data = 3;
@@ -932,7 +954,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
                adapter->test_icr = 0;
                E1000_WRITE_REG(&adapter->hw, IMS, mask);
                E1000_WRITE_REG(&adapter->hw, ICS, mask);
-               msec_delay(10);
+               msleep(10);
 
                if (!(adapter->test_icr & mask)) {
                        *data = 4;
@@ -949,7 +971,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
                        adapter->test_icr = 0;
                        E1000_WRITE_REG(&adapter->hw, IMC, ~mask & 0x00007FFF);
                        E1000_WRITE_REG(&adapter->hw, ICS, ~mask & 0x00007FFF);
-                       msec_delay(10);
+                       msleep(10);
 
                        if (adapter->test_icr) {
                                *data = 5;
@@ -960,7 +982,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
 
        /* Disable all the interrupts */
        E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
-       msec_delay(10);
+       msleep(10);
 
        /* Unhook test interrupt handler */
        free_irq(irq, netdev);
@@ -1256,11 +1278,10 @@ e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
                e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140);
                /* autoneg off */
                e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140);
-       } else if (adapter->hw.phy_type == e1000_phy_gg82563) {
+       } else if (adapter->hw.phy_type == e1000_phy_gg82563)
                e1000_write_phy_reg(&adapter->hw,
                                    GG82563_PHY_KMRN_MODE_CTRL,
                                    0x1CC);
-       }
 
        ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
 
@@ -1288,9 +1309,9 @@ e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
        }
 
        if (adapter->hw.media_type == e1000_media_type_copper &&
-          adapter->hw.phy_type == e1000_phy_m88) {
+          adapter->hw.phy_type == e1000_phy_m88)
                ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
-       } else {
+       else {
                /* Set the ILOS bit on the fiber Nic is half
                 * duplex link is detected. */
                stat_reg = E1000_READ_REG(&adapter->hw, STATUS);
@@ -1383,7 +1404,7 @@ e1000_setup_loopback_test(struct e1000_adapter *adapter)
 #define E1000_SERDES_LB_ON 0x410
                        e1000_set_phy_loopback(adapter);
                        E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_ON);
-                       msec_delay(10);
+                       msleep(10);
                        return 0;
                        break;
                default:
@@ -1416,7 +1437,7 @@ e1000_loopback_cleanup(struct e1000_adapter *adapter)
                    hw->media_type == e1000_media_type_internal_serdes) {
 #define E1000_SERDES_LB_OFF 0x400
                        E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_OFF);
-                       msec_delay(10);
+                       msleep(10);
                        break;
                }
                /* Fall Through */
@@ -1426,11 +1447,10 @@ e1000_loopback_cleanup(struct e1000_adapter *adapter)
        case e1000_82546_rev_3:
        default:
                hw->autoneg = TRUE;
-               if (hw->phy_type == e1000_phy_gg82563) {
+               if (hw->phy_type == e1000_phy_gg82563)
                        e1000_write_phy_reg(hw,
                                            GG82563_PHY_KMRN_MODE_CTRL,
                                            0x180);
-               }
                e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
                if (phy_reg & MII_CR_LOOPBACK) {
                        phy_reg &= ~MII_CR_LOOPBACK;
@@ -1497,7 +1517,7 @@ e1000_run_loopback_test(struct e1000_adapter *adapter)
                        if (unlikely(++k == txdr->count)) k = 0;
                }
                E1000_WRITE_REG(&adapter->hw, TDT, k);
-               msec_delay(200);
+               msleep(200);
                time = jiffies; /* set the start time for the receive */
                good_cnt = 0;
                do { /* receive the sent packets */
@@ -1568,14 +1588,14 @@ e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
                        e1000_check_for_link(&adapter->hw);
                        if (adapter->hw.serdes_link_down == FALSE)
                                return *data;
-                       msec_delay(20);
+                       msleep(20);
                } while (i++ < 3750);
 
                *data = 1;
        } else {
                e1000_check_for_link(&adapter->hw);
                if (adapter->hw.autoneg)  /* if auto_neg is set wait for it */
-                       msec_delay(4000);
+                       msleep(4000);
 
                if (!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
                        *data = 1;
@@ -1599,7 +1619,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 */
 
@@ -1644,7 +1664,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 {
@@ -1659,19 +1679,17 @@ e1000_diag_test(struct net_device *netdev,
                data[2] = 0;
                data[3] = 0;
 
-               clear_bit(__E1000_DRIVER_TESTING, &adapter->flags);
+               clear_bit(__E1000_TESTING, &adapter->flags);
        }
        msleep_interruptible(4 * 1000);
 }
 
-static void
-e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
+static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
 {
-       struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
+       int retval = 1; /* fail by default */
 
-       switch (adapter->hw.device_id) {
-       case E1000_DEV_ID_82542:
+       switch (hw->device_id) {
        case E1000_DEV_ID_82543GC_FIBER:
        case E1000_DEV_ID_82543GC_COPPER:
        case E1000_DEV_ID_82544EI_FIBER:
@@ -1679,52 +1697,87 @@ e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
        case E1000_DEV_ID_82545EM_FIBER:
        case E1000_DEV_ID_82545EM_COPPER:
        case E1000_DEV_ID_82546GB_QUAD_COPPER:
+       case E1000_DEV_ID_82546GB_PCIE:
+               /* these don't support WoL at all */
                wol->supported = 0;
-               wol->wolopts   = 0;
-               return;
-
-       case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
-               /* device id 10B5 port-A supports wol */
-               if (!adapter->ksp3_port_a) {
-                       wol->supported = 0;
-                       return;
-               }
-               /* KSP3 does not suppport UCAST wake-ups for any interface */
-               wol->supported = WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
-
-               if (adapter->wol & E1000_WUFC_EX)
-                       DPRINTK(DRV, ERR, "Interface does not support "
-                       "directed (unicast) frame wake-up packets\n");
-               wol->wolopts = 0;
-               goto do_defaults;
-
+               break;
        case E1000_DEV_ID_82546EB_FIBER:
        case E1000_DEV_ID_82546GB_FIBER:
        case E1000_DEV_ID_82571EB_FIBER:
-               /* Wake events only supported on port A for dual fiber */
+       case E1000_DEV_ID_82571EB_SERDES:
+       case E1000_DEV_ID_82571EB_COPPER:
+               /* Wake events not supported on port B */
                if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1) {
                        wol->supported = 0;
-                       wol->wolopts   = 0;
-                       return;
+                       break;
                }
-               /* Fall Through */
-
+               /* return success for non excluded adapter ports */
+               retval = 0;
+               break;
+       case E1000_DEV_ID_82571EB_QUAD_COPPER:
+       case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
+               /* quad port adapters only support WoL on port A */
+               if (!adapter->quad_port_a) {
+                       wol->supported = 0;
+                       break;
+               }
+               /* return success for non excluded adapter ports */
+               retval = 0;
+               break;
        default:
-               wol->supported = WAKE_UCAST | WAKE_MCAST |
-                                WAKE_BCAST | WAKE_MAGIC;
-               wol->wolopts = 0;
+               /* dual port cards only support WoL on port A from now on
+                * unless it was enabled in the eeprom for port B
+                * so exclude FUNC_1 ports from having WoL enabled */
+               if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1 &&
+                   !adapter->eeprom_wol) {
+                       wol->supported = 0;
+                       break;
+               }
 
-do_defaults:
-               if (adapter->wol & E1000_WUFC_EX)
-                       wol->wolopts |= WAKE_UCAST;
-               if (adapter->wol & E1000_WUFC_MC)
-                       wol->wolopts |= WAKE_MCAST;
-               if (adapter->wol & E1000_WUFC_BC)
-                       wol->wolopts |= WAKE_BCAST;
-               if (adapter->wol & E1000_WUFC_MAG)
-                       wol->wolopts |= WAKE_MAGIC;
+               retval = 0;
+       }
+
+       return retval;
+}
+
+static void
+e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
+{
+       struct e1000_adapter *adapter = netdev_priv(netdev);
+
+       wol->supported = WAKE_UCAST | WAKE_MCAST |
+                        WAKE_BCAST | WAKE_MAGIC;
+       wol->wolopts = 0;
+
+       /* this function will set ->supported = 0 and return 1 if wol is not
+        * supported by this hardware */
+       if (e1000_wol_exclusion(adapter, wol))
                return;
+
+       /* apply any specific unsupported masks here */
+       switch (adapter->hw.device_id) {
+       case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
+               /* KSP3 does not suppport UCAST wake-ups */
+               wol->supported &= ~WAKE_UCAST;
+
+               if (adapter->wol & E1000_WUFC_EX)
+                       DPRINTK(DRV, ERR, "Interface does not support "
+                       "directed (unicast) frame wake-up packets\n");
+               break;
+       default:
+               break;
        }
+
+       if (adapter->wol & E1000_WUFC_EX)
+               wol->wolopts |= WAKE_UCAST;
+       if (adapter->wol & E1000_WUFC_MC)
+               wol->wolopts |= WAKE_MCAST;
+       if (adapter->wol & E1000_WUFC_BC)
+               wol->wolopts |= WAKE_BCAST;
+       if (adapter->wol & E1000_WUFC_MAG)
+               wol->wolopts |= WAKE_MAGIC;
+
+       return;
 }
 
 static int
@@ -1733,51 +1786,35 @@ e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 
-       switch (adapter->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:
-       case E1000_DEV_ID_82546EB_QUAD_COPPER:
-       case E1000_DEV_ID_82546GB_QUAD_COPPER:
-       case E1000_DEV_ID_82545EM_FIBER:
-       case E1000_DEV_ID_82545EM_COPPER:
+       if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
+               return -EOPNOTSUPP;
+
+       if (e1000_wol_exclusion(adapter, wol))
                return wol->wolopts ? -EOPNOTSUPP : 0;
 
+       switch (hw->device_id) {
        case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
-               /* device id 10B5 port-A supports wol */
-               if (!adapter->ksp3_port_a)
-                       return wol->wolopts ? -EOPNOTSUPP : 0;
-
                if (wol->wolopts & WAKE_UCAST) {
                        DPRINTK(DRV, ERR, "Interface does not support "
                        "directed (unicast) frame wake-up packets\n");
                        return -EOPNOTSUPP;
                }
-
-       case E1000_DEV_ID_82546EB_FIBER:
-       case E1000_DEV_ID_82546GB_FIBER:
-       case E1000_DEV_ID_82571EB_FIBER:
-               /* Wake events only supported on port A for dual fiber */
-               if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
-                       return wol->wolopts ? -EOPNOTSUPP : 0;
-               /* Fall Through */
-
+               break;
        default:
-               if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
-                       return -EOPNOTSUPP;
+               break;
+       }
 
-               adapter->wol = 0;
+       /* these settings will always override what we currently have */
+       adapter->wol = 0;
 
-               if (wol->wolopts & WAKE_UCAST)
-                       adapter->wol |= E1000_WUFC_EX;
-               if (wol->wolopts & WAKE_MCAST)
-                       adapter->wol |= E1000_WUFC_MC;
-               if (wol->wolopts & WAKE_BCAST)
-                       adapter->wol |= E1000_WUFC_BC;
-               if (wol->wolopts & WAKE_MAGIC)
-                       adapter->wol |= E1000_WUFC_MAG;
-       }
+       if (wol->wolopts & WAKE_UCAST)
+               adapter->wol |= E1000_WUFC_EX;
+       if (wol->wolopts & WAKE_MCAST)
+               adapter->wol |= E1000_WUFC_MC;
+       if (wol->wolopts & WAKE_BCAST)
+               adapter->wol |= E1000_WUFC_BC;
+       if (wol->wolopts & WAKE_MAGIC)
+               adapter->wol |= E1000_WUFC_MAG;
 
        return 0;
 }
@@ -1894,7 +1931,7 @@ e1000_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
        }
 }
 
-static struct ethtool_ops e1000_ethtool_ops = {
+static const struct ethtool_ops e1000_ethtool_ops = {
        .get_settings           = e1000_get_settings,
        .set_settings           = e1000_set_settings,
        .get_drvinfo            = e1000_get_drvinfo,
@@ -1902,8 +1939,8 @@ static struct ethtool_ops e1000_ethtool_ops = {
        .get_regs               = e1000_get_regs,
        .get_wol                = e1000_get_wol,
        .set_wol                = e1000_set_wol,
-       .get_msglevel           = e1000_get_msglevel,
-       .set_msglevel           = e1000_set_msglevel,
+       .get_msglevel           = e1000_get_msglevel,
+       .set_msglevel           = e1000_set_msglevel,
        .nway_reset             = e1000_nway_reset,
        .get_link               = ethtool_op_get_link,
        .get_eeprom_len         = e1000_get_eeprom_len,
@@ -1911,17 +1948,17 @@ static struct ethtool_ops e1000_ethtool_ops = {
        .set_eeprom             = e1000_set_eeprom,
        .get_ringparam          = e1000_get_ringparam,
        .set_ringparam          = e1000_set_ringparam,
-       .get_pauseparam         = e1000_get_pauseparam,
-       .set_pauseparam         = e1000_set_pauseparam,
-       .get_rx_csum            = e1000_get_rx_csum,
-       .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,
+       .get_pauseparam         = e1000_get_pauseparam,
+       .set_pauseparam         = e1000_set_pauseparam,
+       .get_rx_csum            = e1000_get_rx_csum,
+       .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,
+       .get_tso                = ethtool_op_get_tso,
+       .set_tso                = e1000_set_tso,
 #endif
        .self_test_count        = e1000_diag_test_count,
        .self_test              = e1000_diag_test,
@@ -1929,7 +1966,7 @@ static struct ethtool_ops e1000_ethtool_ops = {
        .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_perm_addr          = ethtool_op_get_perm_addr,
 };
 
 void e1000_set_ethtool_ops(struct net_device *netdev)