Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[safe/jmp/linux-2.6] / drivers / net / sky2.c
index 5383997..13f08a3 100644 (file)
 #include <linux/ethtool.h>
 #include <linux/pci.h>
 #include <linux/ip.h>
+#include <net/ip.h>
 #include <linux/tcp.h>
 #include <linux/in.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
 #include <linux/if_vlan.h>
 #include <linux/prefetch.h>
+#include <linux/debugfs.h>
 #include <linux/mii.h>
 
 #include <asm/irq.h>
@@ -49,7 +51,7 @@
 #include "sky2.h"
 
 #define DRV_NAME               "sky2"
-#define DRV_VERSION            "1.13"
+#define DRV_VERSION            "1.16"
 #define PFX                    DRV_NAME " "
 
 /*
@@ -63,7 +65,6 @@
 #define RX_MAX_PENDING         (RX_LE_SIZE/6 - 2)
 #define RX_DEF_PENDING         RX_MAX_PENDING
 #define RX_SKB_ALIGN           8
-#define RX_BUF_WRITE           16
 
 #define TX_RING_SIZE           512
 #define TX_DEF_PENDING         (TX_RING_SIZE - 1)
@@ -76,6 +77,9 @@
 #define NAPI_WEIGHT            64
 #define PHY_RETRIES            1000
 
+#define SKY2_EEPROM_MAGIC      0x9955aabb
+
+
 #define RING_NEXT(x,s) (((x)+1) & ((s)-1))
 
 static const u32 default_msg =
@@ -95,7 +99,7 @@ static int disable_msi = 0;
 module_param(disable_msi, int, 0);
 MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
 
-static int idle_timeout = 0;
+static int idle_timeout = 100;
 module_param(idle_timeout, int, 0);
 MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)");
 
@@ -216,13 +220,24 @@ static void sky2_power_on(struct sky2_hw *hw)
                sky2_write8(hw, B2_Y2_CLK_GATE, 0);
 
        if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
-               u32 reg1;
+               u32 reg;
 
-               sky2_pci_write32(hw, PCI_DEV_REG3, 0);
-               reg1 = sky2_pci_read32(hw, PCI_DEV_REG4);
-               reg1 &= P_ASPM_CONTROL_MSK;
-               sky2_pci_write32(hw, PCI_DEV_REG4, reg1);
-               sky2_pci_write32(hw, PCI_DEV_REG5, 0);
+               reg = sky2_pci_read32(hw, PCI_DEV_REG4);
+               /* set all bits to 0 except bits 15..12 and 8 */
+               reg &= P_ASPM_CONTROL_MSK;
+               sky2_pci_write32(hw, PCI_DEV_REG4, reg);
+
+               reg = sky2_pci_read32(hw, PCI_DEV_REG5);
+               /* set all bits to 0 except bits 28 & 27 */
+               reg &= P_CTL_TIM_VMAIN_AV_MSK;
+               sky2_pci_write32(hw, PCI_DEV_REG5, reg);
+
+               sky2_pci_write32(hw, PCI_CFG_REG_1, 0);
+
+               /* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */
+               reg = sky2_read32(hw, B2_GP_IO);
+               reg |= GLB_GPIO_STAT_RACE_DIS;
+               sky2_write32(hw, B2_GP_IO, reg);
        }
 }
 
@@ -303,10 +318,13 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                           PHY_M_EC_MAC_S_MSK);
                ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ);
 
+               /* on PHY 88E1040 Rev.D0 (and newer) downshift control changed */
                if (hw->chip_id == CHIP_ID_YUKON_EC)
+                       /* set downshift counter to 3x and enable downshift */
                        ectrl |= PHY_M_EC_DSC_2(2) | PHY_M_EC_DOWN_S_ENA;
                else
-                       ectrl |= PHY_M_EC_M_DSC(2) | PHY_M_EC_S_DSC(3);
+                       /* set master & slave downshift counter to 1x */
+                       ectrl |= PHY_M_EC_M_DSC(0) | PHY_M_EC_S_DSC(1);
 
                gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, ectrl);
        }
@@ -323,10 +341,12 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                        /* enable automatic crossover */
                        ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO);
 
+                       /* downshift on PHY 88E1112 and 88E1149 is changed */
                        if (sky2->autoneg == AUTONEG_ENABLE
                            && (hw->chip_id == CHIP_ID_YUKON_XL
                                || hw->chip_id == CHIP_ID_YUKON_EC_U
                                || hw->chip_id == CHIP_ID_YUKON_EX)) {
+                               /* set downshift counter to 3x and enable downshift */
                                ctrl &= ~PHY_M_PC_DSC_MSK;
                                ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA;
                        }
@@ -358,7 +378,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                        /* for SFP-module set SIGDET polarity to low */
                        ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL);
                        ctrl |= PHY_M_FIB_SIGD_POL;
-                       gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
+                       gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl);
                }
 
                gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
@@ -510,9 +530,9 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                ledover &= ~PHY_M_LED_MO_RX;
        }
 
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) {
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
+           hw->chip_rev == CHIP_REV_YU_EC_U_A1) {
                /* apply fixes in PHY AFE */
-               pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
                gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 255);
 
                /* increase differential signal amplitude in 10BASE-T */
@@ -524,7 +544,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                gm_phy_write(hw, port, 0x17, 0x2002);
 
                /* set page register to 0 */
-               gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
+               gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0);
        } else if (hw->chip_id != CHIP_ID_YUKON_EX) {
                gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
 
@@ -644,15 +664,40 @@ static void sky2_wol_init(struct sky2_port *sky2)
 
 }
 
+static void sky2_set_tx_stfwd(struct sky2_hw *hw, unsigned port)
+{
+       if (hw->chip_id == CHIP_ID_YUKON_EX && hw->chip_rev != CHIP_REV_YU_EX_A0) {
+               sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
+                            TX_STFW_ENA |
+                            (hw->dev[port]->mtu > ETH_DATA_LEN) ? TX_JUMBO_ENA : TX_JUMBO_DIS);
+       } else {
+               if (hw->dev[port]->mtu > ETH_DATA_LEN) {
+                       /* set Tx GMAC FIFO Almost Empty Threshold */
+                       sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR),
+                                    (ECU_JUMBO_WM << 16) | ECU_AE_THR);
+
+                       sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
+                                    TX_JUMBO_ENA | TX_STFW_DIS);
+
+                       /* Can't do offload because of lack of store/forward */
+                       hw->dev[port]->features &= ~(NETIF_F_TSO | NETIF_F_SG
+                                                    | NETIF_F_ALL_CSUM);
+               } else
+                       sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
+                                    TX_JUMBO_DIS | TX_STFW_ENA);
+       }
+}
+
 static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
 {
        struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
        u16 reg;
+       u32 rx_reg;
        int i;
        const u8 *addr = hw->dev[port]->dev_addr;
 
        sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
-       sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR|GPC_ENA_PAUSE);
+       sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR);
 
        sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
 
@@ -724,8 +769,11 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
 
        /* Configure Rx MAC FIFO */
        sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR);
-       sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T),
-                    GMF_OPER_ON | GMF_RX_F_FL_ON);
+       rx_reg = GMF_OPER_ON | GMF_RX_F_FL_ON;
+       if (hw->chip_id == CHIP_ID_YUKON_EX)
+               rx_reg |= GMF_RX_OVER_ON;
+
+       sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), rx_reg);
 
        /* Flush Rx MAC FIFO on any flow control or error */
        sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR);
@@ -740,12 +788,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
        if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
                sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
                sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
-               if (hw->dev[port]->mtu > ETH_DATA_LEN) {
-                       /* set Tx GMAC FIFO Almost Empty Threshold */
-                       sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR), 0x180);
-                       /* Disable Store & Forward mode for TX */
-                       sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_DIS);
-               }
+
+               sky2_set_tx_stfwd(hw, port);
        }
 
 }
@@ -833,10 +877,12 @@ static inline struct tx_ring_info *tx_le_re(struct sky2_port *sky2,
 /* Update chip's next pointer */
 static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
 {
-       q = Y2_QADDR(q, PREF_UNIT_PUT_IDX);
+       /* Make sure write' to descriptors are complete before we tell hardware */
        wmb();
-       sky2_write16(hw, q, idx);
-       sky2_read16(hw, q);
+       sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx);
+
+       /* Synchronize I/O on since next processor may write to tail */
+       mmiowb();
 }
 
 
@@ -848,24 +894,18 @@ static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2)
        return le;
 }
 
-/* Return high part of DMA address (could be 32 or 64 bit) */
-static inline u32 high32(dma_addr_t a)
-{
-       return sizeof(a) > sizeof(u32) ? (a >> 16) >> 16 : 0;
-}
-
 /* Build description to hardware for one receive segment */
 static void sky2_rx_add(struct sky2_port *sky2,  u8 op,
                        dma_addr_t map, unsigned len)
 {
        struct sky2_rx_le *le;
-       u32 hi = high32(map);
+       u32 hi = upper_32_bits(map);
 
        if (sky2->rx_addr64 != hi) {
                le = sky2_next_rx(sky2);
                le->addr = cpu_to_le32(hi);
                le->opcode = OP_ADDR64 | HW_OWNER;
-               sky2->rx_addr64 = high32(map + len);
+               sky2->rx_addr64 = upper_32_bits(map + len);
        }
 
        le = sky2_next_rx(sky2);
@@ -926,14 +966,16 @@ static void rx_set_checksum(struct sky2_port *sky2)
 {
        struct sky2_rx_le *le;
 
-       le = sky2_next_rx(sky2);
-       le->addr = cpu_to_le32((ETH_HLEN << 16) | ETH_HLEN);
-       le->ctrl = 0;
-       le->opcode = OP_TCPSTART | HW_OWNER;
+       if (sky2->hw->chip_id != CHIP_ID_YUKON_EX) {
+               le = sky2_next_rx(sky2);
+               le->addr = cpu_to_le32((ETH_HLEN << 16) | ETH_HLEN);
+               le->ctrl = 0;
+               le->opcode = OP_TCPSTART | HW_OWNER;
 
-       sky2_write32(sky2->hw,
-                    Q_ADDR(rxqaddr[sky2->port], Q_CSR),
-                    sky2->rx_csum ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
+               sky2_write32(sky2->hw,
+                            Q_ADDR(rxqaddr[sky2->port], Q_CSR),
+                            sky2->rx_csum ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
+       }
 
 }
 
@@ -968,6 +1010,7 @@ stopped:
 
        /* reset the Rx prefetch unit */
        sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
+       mmiowb();
 }
 
 /* Clean out receive buffer area, assumes receiver hardware stopped */
@@ -1035,26 +1078,22 @@ static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp
        u16 port = sky2->port;
 
        netif_tx_lock_bh(dev);
+       netif_poll_disable(sky2->hw->dev[0]);
 
-       sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_ON);
-       sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_ON);
        sky2->vlgrp = grp;
+       if (grp) {
+               sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T),
+                            RX_VLAN_STRIP_ON);
+               sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
+                            TX_VLAN_TAG_ON);
+       } else {
+               sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T),
+                            RX_VLAN_STRIP_OFF);
+               sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
+                            TX_VLAN_TAG_OFF);
+       }
 
-       netif_tx_unlock_bh(dev);
-}
-
-static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
-{
-       struct sky2_port *sky2 = netdev_priv(dev);
-       struct sky2_hw *hw = sky2->hw;
-       u16 port = sky2->port;
-
-       netif_tx_lock_bh(dev);
-
-       sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_OFF);
-       sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_OFF);
-       vlan_group_set_device(sky2->vlgrp, vid, NULL);
-
+       netif_poll_enable(sky2->hw->dev[0]);
        netif_tx_unlock_bh(dev);
 }
 #endif
@@ -1096,6 +1135,11 @@ nomem:
        return NULL;
 }
 
+static inline void sky2_rx_update(struct sky2_port *sky2, unsigned rxq)
+{
+       sky2_put_idx(sky2->hw, rxq, sky2->rx_put);
+}
+
 /*
  * Allocate and setup receiver buffer pool.
  * Normal case this ends up creating one list element for skb
@@ -1124,15 +1168,14 @@ static int sky2_rx_start(struct sky2_port *sky2)
        if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
            (hw->chip_rev == CHIP_REV_YU_EC_U_A1
             || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
-               sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
+               sky2_write32(hw, Q_ADDR(rxq, Q_TEST), F_M_RX_RAM_DIS);
 
        sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
 
        rx_set_checksum(sky2);
 
        /* Space needed for frame data + headers rounded up */
-       size = ALIGN(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8)
-               + 8;
+       size = roundup(sky2->netdev->mtu + ETH_HLEN + VLAN_HLEN, 8);
 
        /* Stopping point for hardware truncation */
        thresh = (size - 8) / sizeof(u32);
@@ -1187,7 +1230,7 @@ static int sky2_rx_start(struct sky2_port *sky2)
        }
 
        /* Tell chip about available buffers */
-       sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put);
+       sky2_rx_update(sky2, rxq);
        return 0;
 nomem:
        sky2_rx_clean(sky2);
@@ -1224,6 +1267,8 @@ static int sky2_up(struct net_device *dev)
        if (netif_msg_ifup(sky2))
                printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
 
+       netif_carrier_off(dev);
+
        /* must be power of 2 */
        sky2->tx_le = pci_alloc_consistent(hw->pdev,
                                           TX_RING_SIZE *
@@ -1275,10 +1320,14 @@ static int sky2_up(struct net_device *dev)
 
        sky2_qset(hw, txqaddr[port]);
 
+       /* This is copied from sk98lin 10.0.5.3; no one tells me about erratta's */
+       if (hw->chip_id == CHIP_ID_YUKON_EX && hw->chip_rev == CHIP_REV_YU_EX_B0)
+               sky2_write32(hw, Q_ADDR(txqaddr[port], Q_TEST), F_TX_CHK_AUTO_OFF);
+
        /* Set almost empty threshold */
        if (hw->chip_id == CHIP_ID_YUKON_EC_U
            && hw->chip_rev == CHIP_REV_YU_EC_U_A0)
-               sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0);
+               sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), ECU_TXFF_LEV);
 
        sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map,
                           TX_RING_SIZE - 1);
@@ -1370,27 +1419,30 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 
        len = skb_headlen(skb);
        mapping = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
-       addr64 = high32(mapping);
+       addr64 = upper_32_bits(mapping);
 
        /* Send high bits if changed or crosses boundary */
-       if (addr64 != sky2->tx_addr64 || high32(mapping + len) != sky2->tx_addr64) {
+       if (addr64 != sky2->tx_addr64 ||
+           upper_32_bits(mapping + len) != sky2->tx_addr64) {
                le = get_tx_le(sky2);
                le->addr = cpu_to_le32(addr64);
                le->opcode = OP_ADDR64 | HW_OWNER;
-               sky2->tx_addr64 = high32(mapping + len);
+               sky2->tx_addr64 = upper_32_bits(mapping + len);
        }
 
        /* Check for TCP Segmentation Offload */
        mss = skb_shinfo(skb)->gso_size;
        if (mss != 0) {
-               mss += ((skb->h.th->doff - 5) * 4);     /* TCP options */
-               mss += (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
-               mss += ETH_HLEN;
-
-               if (mss != sky2->tx_last_mss) {
-                       le = get_tx_le(sky2);
-                       le->addr = cpu_to_le32(mss);
-                       le->opcode = OP_LRGLEN | HW_OWNER;
+               if (hw->chip_id != CHIP_ID_YUKON_EX)
+                       mss += ETH_HLEN + ip_hdrlen(skb) + tcp_hdrlen(skb);
+
+               if (mss != sky2->tx_last_mss) {
+                       le = get_tx_le(sky2);
+                       le->addr = cpu_to_le32(mss);
+                       if (hw->chip_id == CHIP_ID_YUKON_EX)
+                               le->opcode = OP_MSS | HW_OWNER;
+                       else
+                               le->opcode = OP_LRGLEN | HW_OWNER;
                        sky2->tx_last_mss = mss;
                }
        }
@@ -1412,24 +1464,30 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 
        /* Handle TCP checksum offload */
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               unsigned offset = skb->h.raw - skb->data;
-               u32 tcpsum;
-
-               tcpsum = offset << 16;          /* sum start */
-               tcpsum |= offset + skb->csum_offset;    /* sum write */
-
-               ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
-               if (skb->nh.iph->protocol == IPPROTO_UDP)
-                       ctrl |= UDPTCP;
-
-               if (tcpsum != sky2->tx_tcpsum) {
-                       sky2->tx_tcpsum = tcpsum;
-
-                       le = get_tx_le(sky2);
-                       le->addr = cpu_to_le32(tcpsum);
-                       le->length = 0; /* initial checksum value */
-                       le->ctrl = 1;   /* one packet */
-                       le->opcode = OP_TCPLISW | HW_OWNER;
+               /* On Yukon EX (some versions) encoding change. */
+               if (hw->chip_id == CHIP_ID_YUKON_EX
+                   && hw->chip_rev != CHIP_REV_YU_EX_B0)
+                       ctrl |= CALSUM; /* auto checksum */
+               else {
+                       const unsigned offset = skb_transport_offset(skb);
+                       u32 tcpsum;
+
+                       tcpsum = offset << 16;                  /* sum start */
+                       tcpsum |= offset + skb->csum_offset;    /* sum write */
+
+                       ctrl |= CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
+                       if (ip_hdr(skb)->protocol == IPPROTO_UDP)
+                               ctrl |= UDPTCP;
+
+                       if (tcpsum != sky2->tx_tcpsum) {
+                               sky2->tx_tcpsum = tcpsum;
+
+                               le = get_tx_le(sky2);
+                               le->addr = cpu_to_le32(tcpsum);
+                               le->length = 0; /* initial checksum value */
+                               le->ctrl = 1;   /* one packet */
+                               le->opcode = OP_TCPLISW | HW_OWNER;
+                       }
                }
        }
 
@@ -1449,7 +1507,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 
                mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset,
                                       frag->size, PCI_DMA_TODEVICE);
-               addr64 = high32(mapping);
+               addr64 = upper_32_bits(mapping);
                if (addr64 != sky2->tx_addr64) {
                        le = get_tx_le(sky2);
                        le->addr = cpu_to_le32(addr64);
@@ -1519,16 +1577,18 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
                        if (unlikely(netif_msg_tx_done(sky2)))
                                printk(KERN_DEBUG "%s: tx done %u\n",
                                       dev->name, idx);
+
                        sky2->net_stats.tx_packets++;
                        sky2->net_stats.tx_bytes += re->skb->len;
 
                        dev_kfree_skb_any(re->skb);
+                       sky2->tx_next = RING_NEXT(idx, TX_RING_SIZE);
                }
-
-               le->opcode = 0; /* paranoia */
        }
 
        sky2->tx_cons = idx;
+       smp_mb();
+
        if (tx_avail(sky2) > MAX_SKB_TX_LE + 4)
                netif_wake_queue(dev);
 }
@@ -1567,13 +1627,6 @@ static int sky2_down(struct net_device *dev)
        imask &= ~portirq_msk[port];
        sky2_write32(hw, B0_IMSK, imask);
 
-       /*
-        * Both ports share the NAPI poll on port 0, so if necessary undo the
-        * the disable that is done in dev_close.
-        */
-       if (sky2->port == 0 && hw->ports > 1)
-               netif_poll_enable(dev);
-
        sky2_gmac_reset(hw, port);
 
        /* Stop transmitter */
@@ -1583,13 +1636,6 @@ static int sky2_down(struct net_device *dev)
        sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL),
                     RB_RST_SET | RB_DIS_OP_MD);
 
-       /* WA for dev. #4.209 */
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U
-           && (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
-               sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
-                            sky2->speed != SPEED_1000 ?
-                            TX_STFW_ENA : TX_STFW_DIS);
-
        ctrl = gma_read16(hw, port, GM_GP_CTRL);
        ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA);
        gma_write16(hw, port, GM_GP_CTRL, ctrl);
@@ -1626,6 +1672,8 @@ static int sky2_down(struct net_device *dev)
 
        sky2_phy_power(hw, port, 0);
 
+       netif_carrier_off(dev);
+
        /* turn off LED's */
        sky2_write16(hw, B0_Y2LED, LED_STAT_OFF);
 
@@ -1690,7 +1738,6 @@ static void sky2_link_up(struct sky2_port *sky2)
        gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK);
 
        netif_carrier_on(sky2->netdev);
-       netif_wake_queue(sky2->netdev);
 
        /* Turn on link LED */
        sky2_write8(hw, SK_REG(port, LNK_LED_REG),
@@ -1742,7 +1789,6 @@ static void sky2_link_down(struct sky2_port *sky2)
        gma_write16(hw, port, GM_GP_CTRL, reg);
 
        netif_carrier_off(sky2->netdev);
-       netif_stop_queue(sky2->netdev);
 
        /* Turn on link LED */
        sky2_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
@@ -1889,6 +1935,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
 {
        struct sky2_port *sky2 = netdev_priv(dev);
        struct sky2_hw *hw = sky2->hw;
+       unsigned port = sky2->port;
        int err;
        u16 ctl, mode;
        u32 imask;
@@ -1896,9 +1943,8 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
        if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
                return -EINVAL;
 
-       /* TSO on Yukon Ultra and MTU > 1500 not supported */
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U && new_mtu > ETH_DATA_LEN)
-               dev->features &= ~NETIF_F_TSO;
+       if (new_mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_FE)
+               return -EINVAL;
 
        if (!netif_running(dev)) {
                dev->mtu = new_mtu;
@@ -1914,8 +1960,11 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
 
        synchronize_irq(hw->pdev->irq);
 
-       ctl = gma_read16(hw, sky2->port, GM_GP_CTRL);
-       gma_write16(hw, sky2->port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA);
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX)
+               sky2_set_tx_stfwd(hw, port);
+
+       ctl = gma_read16(hw, port, GM_GP_CTRL);
+       gma_write16(hw, port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA);
        sky2_rx_stop(sky2);
        sky2_rx_clean(sky2);
 
@@ -1927,9 +1976,9 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
        if (dev->mtu > ETH_DATA_LEN)
                mode |= GM_SMOD_JUMBO_ENA;
 
-       gma_write16(hw, sky2->port, GM_SERIAL_MODE, mode);
+       gma_write16(hw, port, GM_SERIAL_MODE, mode);
 
-       sky2_write8(hw, RB_ADDR(rxqaddr[sky2->port], RB_CTRL), RB_ENA_OP_MD);
+       sky2_write8(hw, RB_ADDR(rxqaddr[port], RB_CTRL), RB_ENA_OP_MD);
 
        err = sky2_rx_start(sky2);
        sky2_write32(hw, B0_IMSK, imask);
@@ -1937,7 +1986,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
        if (err)
                dev_close(dev);
        else {
-               gma_write16(hw, sky2->port, GM_GP_CTRL, ctl);
+               gma_write16(hw, port, GM_GP_CTRL, ctl);
 
                netif_poll_enable(hw->dev[0]);
                netif_wake_queue(dev);
@@ -1958,7 +2007,7 @@ static struct sk_buff *receive_copy(struct sky2_port *sky2,
                skb_reserve(skb, 2);
                pci_dma_sync_single_for_cpu(sky2->hw->pdev, re->data_addr,
                                            length, PCI_DMA_FROMDEVICE);
-               memcpy(skb->data, re->skb->data, length);
+               skb_copy_from_linear_data(re->skb, skb->data, length);
                skb->ip_summed = re->skb->ip_summed;
                skb->csum = re->skb->csum;
                pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr,
@@ -2010,8 +2059,6 @@ static struct sk_buff *receive_new(struct sky2_port *sky2,
        struct sk_buff *skb, *nskb;
        unsigned hdr_space = sky2->rx_data_size;
 
-       pr_debug(PFX "receive new length=%d\n", length);
-
        /* Don't be tricky about reusing pages (yet) */
        nskb = sky2_rx_alloc(sky2);
        if (unlikely(!nskb))
@@ -2055,6 +2102,9 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
        if (!(status & GMR_FS_RX_OK))
                goto resubmit;
 
+       if (status >> 16 != length)
+               goto len_mismatch;
+
        if (length < copybreak)
                skb = receive_copy(sky2, re, length);
        else
@@ -2064,6 +2114,11 @@ resubmit:
 
        return skb;
 
+len_mismatch:
+       /* Truncation of overlength packets
+          causes PHY length to not match MAC length */
+       ++sky2->net_stats.rx_length_errors;
+
 error:
        ++sky2->net_stats.rx_errors;
        if (status & GMR_FS_RX_FF_OV) {
@@ -2100,15 +2155,16 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last)
 /* Process status response ring */
 static int sky2_status_intr(struct sky2_hw *hw, int to_do)
 {
-       struct sky2_port *sky2;
        int work_done = 0;
-       unsigned buf_write[2] = { 0, 0 };
+       unsigned rx[2] = { 0, 0 };
        u16 hwidx = sky2_read16(hw, STAT_PUT_IDX);
 
        rmb();
 
        while (hw->st_idx != hwidx) {
+               struct sky2_port *sky2;
                struct sky2_status_le *le  = hw->st_le + hw->st_idx;
+               unsigned port = le->css & CSS_LINK_BIT;
                struct net_device *dev;
                struct sk_buff *skb;
                u32 status;
@@ -2116,18 +2172,29 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
 
                hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE);
 
-               BUG_ON(le->link >= 2);
-               dev = hw->dev[le->link];
-
+               dev = hw->dev[port];
                sky2 = netdev_priv(dev);
                length = le16_to_cpu(le->length);
                status = le32_to_cpu(le->status);
 
                switch (le->opcode & ~HW_OWNER) {
                case OP_RXSTAT:
+                       ++rx[port];
                        skb = sky2_receive(dev, length, status);
-                       if (!skb)
-                               goto force_update;
+                       if (unlikely(!skb)) {
+                               sky2->net_stats.rx_dropped++;
+                               break;
+                       }
+
+                       /* This chip reports checksum status differently */
+                       if (hw->chip_id == CHIP_ID_YUKON_EX) {
+                               if (sky2->rx_csum &&
+                                   (le->css & (CSS_ISIPV4 | CSS_ISIPV6)) &&
+                                   (le->css & CSS_TCPUDPCSOK))
+                                       skb->ip_summed = CHECKSUM_UNNECESSARY;
+                               else
+                                       skb->ip_summed = CHECKSUM_NONE;
+                       }
 
                        skb->protocol = eth_type_trans(skb, dev);
                        sky2->net_stats.rx_packets++;
@@ -2143,13 +2210,6 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
 #endif
                                netif_receive_skb(skb);
 
-                       /* Update receiver after 16 frames */
-                       if (++buf_write[le->link] == RX_BUF_WRITE) {
-force_update:
-                               sky2_put_idx(hw, rxqaddr[le->link], sky2->rx_put);
-                               buf_write[le->link] = 0;
-                       }
-
                        /* Stop after net poll weight */
                        if (++work_done >= to_do)
                                goto exit_loop;
@@ -2165,9 +2225,30 @@ force_update:
                        /* fall through */
 #endif
                case OP_RXCHKS:
-                       skb = sky2->rx_ring[sky2->rx_next].skb;
-                       skb->ip_summed = CHECKSUM_COMPLETE;
-                       skb->csum = status & 0xffff;
+                       if (!sky2->rx_csum)
+                               break;
+
+                       if (hw->chip_id == CHIP_ID_YUKON_EX)
+                               break;
+
+                       /* Both checksum counters are programmed to start at
+                        * the same offset, so unless there is a problem they
+                        * should match. This failure is an early indication that
+                        * hardware receive checksumming won't work.
+                        */
+                       if (likely(status >> 16 == (status & 0xffff))) {
+                               skb = sky2->rx_ring[sky2->rx_next].skb;
+                               skb->ip_summed = CHECKSUM_COMPLETE;
+                               skb->csum = status & 0xffff;
+                       } else {
+                               printk(KERN_NOTICE PFX "%s: hardware receive "
+                                      "checksum problem (status = %#x)\n",
+                                      dev->name, status);
+                               sky2->rx_csum = 0;
+                               sky2_write32(sky2->hw,
+                                            Q_ADDR(rxqaddr[port], Q_CSR),
+                                            BMU_DIS_RX_CHKSUM);
+                       }
                        break;
 
                case OP_TXINDEXLE:
@@ -2184,7 +2265,6 @@ force_update:
                        if (net_ratelimit())
                                printk(KERN_WARNING PFX
                                       "unknown status opcode 0x%x\n", le->opcode);
-                       goto exit_loop;
                }
        }
 
@@ -2192,15 +2272,11 @@ force_update:
        sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
 
 exit_loop:
-       if (buf_write[0]) {
-               sky2 = netdev_priv(hw->dev[0]);
-               sky2_put_idx(hw, Q_R1, sky2->rx_put);
-       }
+       if (rx[0])
+               sky2_rx_update(netdev_priv(hw->dev[0]), Q_R1);
 
-       if (buf_write[1]) {
-               sky2 = netdev_priv(hw->dev[1]);
-               sky2_put_idx(hw, Q_R2, sky2->rx_put);
-       }
+       if (rx[1])
+               sky2_rx_update(netdev_priv(hw->dev[1]), Q_R2);
 
        return work_done;
 }
@@ -2310,6 +2386,12 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
                printk(KERN_INFO PFX "%s: mac interrupt status 0x%x\n",
                       dev->name, status);
 
+       if (status & GM_IS_RX_CO_OV)
+               gma_read16(hw, port, GM_RX_IRQ_SRC);
+
+       if (status & GM_IS_TX_CO_OV)
+               gma_read16(hw, port, GM_TX_IRQ_SRC);
+
        if (status & GM_IS_RX_FF_OR) {
                ++sky2->net_stats.rx_fifo_errors;
                sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO);
@@ -2321,26 +2403,22 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
        }
 }
 
-/* This should never happen it is a fatal situation */
-static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port,
-                                 const char *rxtx, u32 mask)
+/* This should never happen it is a bug. */
+static void sky2_le_error(struct sky2_hw *hw, unsigned port,
+                         u16 q, unsigned ring_size)
 {
        struct net_device *dev = hw->dev[port];
        struct sky2_port *sky2 = netdev_priv(dev);
-       u32 imask;
-
-       printk(KERN_ERR PFX "%s: %s descriptor error (hardware problem)\n",
-              dev ? dev->name : "<not registered>", rxtx);
+       unsigned idx;
+       const u64 *le = (q == Q_R1 || q == Q_R2)
+               ? (u64 *) sky2->rx_le : (u64 *) sky2->tx_le;
 
-       imask = sky2_read32(hw, B0_IMSK);
-       imask &= ~mask;
-       sky2_write32(hw, B0_IMSK, imask);
+       idx = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX));
+       printk(KERN_ERR PFX "%s: descriptor error q=%#x get=%u [%llx] put=%u\n",
+              dev->name, (unsigned) q, idx, (unsigned long long) le[idx],
+              (unsigned) sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX)));
 
-       if (dev) {
-               spin_lock(&sky2->phy_lock);
-               sky2_link_down(sky2);
-               spin_unlock(&sky2->phy_lock);
-       }
+       sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_IRQ_CHK);
 }
 
 /* If idle then force a fake soft NAPI poll once a second
@@ -2364,23 +2442,15 @@ static void sky2_idle(unsigned long arg)
        mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout));
 }
 
-
-static int sky2_poll(struct net_device *dev0, int *budget)
+/* Hardware/software error handling */
+static void sky2_err_intr(struct sky2_hw *hw, u32 status)
 {
-       struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
-       int work_limit = min(dev0->quota, *budget);
-       int work_done = 0;
-       u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
+       if (net_ratelimit())
+               dev_warn(&hw->pdev->dev, "error interrupt status=%#x\n", status);
 
        if (status & Y2_IS_HW_ERR)
                sky2_hw_intr(hw);
 
-       if (status & Y2_IS_IRQ_PHY1)
-               sky2_phy_intr(hw, 0);
-
-       if (status & Y2_IS_IRQ_PHY2)
-               sky2_phy_intr(hw, 1);
-
        if (status & Y2_IS_IRQ_MAC1)
                sky2_mac_intr(hw, 0);
 
@@ -2388,28 +2458,52 @@ static int sky2_poll(struct net_device *dev0, int *budget)
                sky2_mac_intr(hw, 1);
 
        if (status & Y2_IS_CHK_RX1)
-               sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1);
+               sky2_le_error(hw, 0, Q_R1, RX_LE_SIZE);
 
        if (status & Y2_IS_CHK_RX2)
-               sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2);
+               sky2_le_error(hw, 1, Q_R2, RX_LE_SIZE);
 
        if (status & Y2_IS_CHK_TXA1)
-               sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1);
+               sky2_le_error(hw, 0, Q_XA1, TX_RING_SIZE);
 
        if (status & Y2_IS_CHK_TXA2)
-               sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2);
+               sky2_le_error(hw, 1, Q_XA2, TX_RING_SIZE);
+}
 
-       work_done = sky2_status_intr(hw, work_limit);
-       if (work_done < work_limit) {
-               netif_rx_complete(dev0);
+static int sky2_poll(struct net_device *dev0, int *budget)
+{
+       struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
+       int work_done;
+       u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
 
-               sky2_read32(hw, B0_Y2_SP_LISR);
-               return 0;
-       } else {
-               *budget -= work_done;
-               dev0->quota -= work_done;
+       if (unlikely(status & Y2_IS_ERROR))
+               sky2_err_intr(hw, status);
+
+       if (status & Y2_IS_IRQ_PHY1)
+               sky2_phy_intr(hw, 0);
+
+       if (status & Y2_IS_IRQ_PHY2)
+               sky2_phy_intr(hw, 1);
+
+       work_done = sky2_status_intr(hw, min(dev0->quota, *budget));
+       *budget -= work_done;
+       dev0->quota -= work_done;
+
+       /* More work? */
+       if (hw->st_idx != sky2_read16(hw, STAT_PUT_IDX))
                return 1;
+
+       /* Bug/Errata workaround?
+        * Need to kick the TX irq moderation timer.
+        */
+       if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_START) {
+               sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
+               sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
        }
+       netif_rx_complete(dev0);
+
+       sky2_read32(hw, B0_Y2_SP_LISR);
+       return 0;
 }
 
 static irqreturn_t sky2_intr(int irq, void *dev_id)
@@ -2471,6 +2565,9 @@ static int __devinit sky2_init(struct sky2_hw *hw)
 {
        u8 t8;
 
+       /* Enable all clocks */
+       sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+
        sky2_write8(hw, B0_CTST, CS_RST_CLR);
 
        hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
@@ -2480,14 +2577,6 @@ static int __devinit sky2_init(struct sky2_hw *hw)
                return -EOPNOTSUPP;
        }
 
-       if (hw->chip_id == CHIP_ID_YUKON_EX)
-               dev_warn(&hw->pdev->dev, "this driver not yet tested on this chip type\n"
-                        "Please report success or failure to <netdev@vger.kernel.org>\n");
-
-       /* Make sure and enable all clocks */
-       if (hw->chip_id == CHIP_ID_YUKON_EX || hw->chip_id == CHIP_ID_YUKON_EC_U)
-               sky2_pci_write32(hw, PCI_DEV_REG3, 0);
-
        hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4;
 
        /* This rev is really old, and requires untested workarounds */
@@ -2515,16 +2604,14 @@ static void sky2_reset(struct sky2_hw *hw)
        int i;
 
        /* disable ASF */
-       if (hw->chip_id <= CHIP_ID_YUKON_EC) {
-               if (hw->chip_id == CHIP_ID_YUKON_EX) {
-                       status = sky2_read16(hw, HCU_CCSR);
-                       status &= ~(HCU_CCSR_AHB_RST | HCU_CCSR_CPU_RST_MODE |
-                                   HCU_CCSR_UC_STATE_MSK);
-                       sky2_write16(hw, HCU_CCSR, status);
-               } else
-                       sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
-               sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
-       }
+       if (hw->chip_id == CHIP_ID_YUKON_EX) {
+               status = sky2_read16(hw, HCU_CCSR);
+               status &= ~(HCU_CCSR_AHB_RST | HCU_CCSR_CPU_RST_MODE |
+                           HCU_CCSR_UC_STATE_MSK);
+               sky2_write16(hw, HCU_CCSR, status);
+       } else
+               sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
+       sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
 
        /* do a SW reset */
        sky2_write8(hw, B0_CTST, CS_RST_SET);
@@ -2549,6 +2636,11 @@ static void sky2_reset(struct sky2_hw *hw)
        for (i = 0; i < hw->ports; i++) {
                sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET);
                sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_CLR);
+
+               if (hw->chip_id == CHIP_ID_YUKON_EX)
+                       sky2_write16(hw, SK_REG(i, GMAC_CTRL),
+                                    GMC_BYP_MACSECRX_ON | GMC_BYP_MACSECTX_ON
+                                    | GMC_BYP_RETR_ON);
        }
 
        sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
@@ -2635,8 +2727,6 @@ static void sky2_restart(struct work_struct *work)
        struct net_device *dev;
        int i, err;
 
-       dev_dbg(&hw->pdev->dev, "restarting\n");
-
        del_timer_sync(&hw->idle_timer);
 
        rtnl_lock();
@@ -2695,7 +2785,7 @@ static int sky2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 
        sky2->wol = wol->wolopts;
 
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U)
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX)
                sky2_write32(hw, B0_CTST, sky2->wol
                             ? Y2_HW_WOL_ON : Y2_HW_WOL_OFF);
 
@@ -3290,7 +3380,7 @@ static int sky2_get_regs_len(struct net_device *dev)
 
 /*
  * Returns copy of control register region
- * Note: access to the RAM address register set will cause timeouts.
+ * Note: ethtool_get_regs always provides full size (16k) buffer
  */
 static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
                          void *p)
@@ -3298,50 +3388,358 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
        const struct sky2_port *sky2 = netdev_priv(dev);
        const void __iomem *io = sky2->hw->regs;
 
-       BUG_ON(regs->len < B3_RI_WTO_R1);
        regs->version = 1;
        memset(p, 0, regs->len);
 
        memcpy_fromio(p, io, B3_RAM_ADDR);
 
-       memcpy_fromio(p + B3_RI_WTO_R1,
-                     io + B3_RI_WTO_R1,
-                     regs->len - B3_RI_WTO_R1);
+       /* skip diagnostic ram region */
+       memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, 0x2000 - B3_RI_WTO_R1);
+
+       /* copy GMAC registers */
+       memcpy_fromio(p + BASE_GMAC_1, io + BASE_GMAC_1, 0x1000);
+       if (sky2->hw->ports > 1)
+               memcpy_fromio(p + BASE_GMAC_2, io + BASE_GMAC_2, 0x1000);
+
 }
 
+/* In order to do Jumbo packets on these chips, need to turn off the
+ * transmit store/forward. Therefore checksum offload won't work.
+ */
+static int no_tx_offload(struct net_device *dev)
+{
+       const struct sky2_port *sky2 = netdev_priv(dev);
+       const struct sky2_hw *hw = sky2->hw;
+
+       return dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U;
+}
+
+static int sky2_set_tx_csum(struct net_device *dev, u32 data)
+{
+       if (data && no_tx_offload(dev))
+               return -EINVAL;
+
+       return ethtool_op_set_tx_csum(dev, data);
+}
+
+
+static int sky2_set_tso(struct net_device *dev, u32 data)
+{
+       if (data && no_tx_offload(dev))
+               return -EINVAL;
+
+       return ethtool_op_set_tso(dev, data);
+}
+
+static int sky2_get_eeprom_len(struct net_device *dev)
+{
+       struct sky2_port *sky2 = netdev_priv(dev);
+       u16 reg2;
+
+       reg2 = sky2_pci_read32(sky2->hw, PCI_DEV_REG2);
+       return 1 << ( ((reg2 & PCI_VPD_ROM_SZ) >> 14) + 8);
+}
+
+static u32 sky2_vpd_read(struct sky2_hw *hw, int cap, u16 offset)
+{
+       sky2_pci_write16(hw, cap + PCI_VPD_ADDR, offset);
+
+       while (!(sky2_pci_read16(hw, cap + PCI_VPD_ADDR) & PCI_VPD_ADDR_F))
+                       cpu_relax();
+       return sky2_pci_read32(hw, cap + PCI_VPD_DATA);
+}
+
+static void sky2_vpd_write(struct sky2_hw *hw, int cap, u16 offset, u32 val)
+{
+       sky2_pci_write32(hw, cap + PCI_VPD_DATA, val);
+       sky2_pci_write16(hw, cap + PCI_VPD_ADDR, offset | PCI_VPD_ADDR_F);
+       do {
+               cpu_relax();
+       } while (sky2_pci_read16(hw, cap + PCI_VPD_ADDR) & PCI_VPD_ADDR_F);
+}
+
+static int sky2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
+                          u8 *data)
+{
+       struct sky2_port *sky2 = netdev_priv(dev);
+       int cap = pci_find_capability(sky2->hw->pdev, PCI_CAP_ID_VPD);
+       int length = eeprom->len;
+       u16 offset = eeprom->offset;
+
+       if (!cap)
+               return -EINVAL;
+
+       eeprom->magic = SKY2_EEPROM_MAGIC;
+
+       while (length > 0) {
+               u32 val = sky2_vpd_read(sky2->hw, cap, offset);
+               int n = min_t(int, length, sizeof(val));
+
+               memcpy(data, &val, n);
+               length -= n;
+               data += n;
+               offset += n;
+       }
+       return 0;
+}
+
+static int sky2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
+                          u8 *data)
+{
+       struct sky2_port *sky2 = netdev_priv(dev);
+       int cap = pci_find_capability(sky2->hw->pdev, PCI_CAP_ID_VPD);
+       int length = eeprom->len;
+       u16 offset = eeprom->offset;
+
+       if (!cap)
+               return -EINVAL;
+
+       if (eeprom->magic != SKY2_EEPROM_MAGIC)
+               return -EINVAL;
+
+       while (length > 0) {
+               u32 val;
+               int n = min_t(int, length, sizeof(val));
+
+               if (n < sizeof(val))
+                       val = sky2_vpd_read(sky2->hw, cap, offset);
+               memcpy(&val, data, n);
+
+               sky2_vpd_write(sky2->hw, cap, offset, val);
+
+               length -= n;
+               data += n;
+               offset += n;
+       }
+       return 0;
+}
+
+
 static const struct ethtool_ops sky2_ethtool_ops = {
-       .get_settings = sky2_get_settings,
-       .set_settings = sky2_set_settings,
-       .get_drvinfo  = sky2_get_drvinfo,
-       .get_wol      = sky2_get_wol,
-       .set_wol      = sky2_set_wol,
-       .get_msglevel = sky2_get_msglevel,
-       .set_msglevel = sky2_set_msglevel,
-       .nway_reset   = sky2_nway_reset,
-       .get_regs_len = sky2_get_regs_len,
-       .get_regs = sky2_get_regs,
-       .get_link = ethtool_op_get_link,
-       .get_sg = ethtool_op_get_sg,
-       .set_sg = ethtool_op_set_sg,
-       .get_tx_csum = ethtool_op_get_tx_csum,
-       .set_tx_csum = ethtool_op_set_tx_csum,
-       .get_tso = ethtool_op_get_tso,
-       .set_tso = ethtool_op_set_tso,
-       .get_rx_csum = sky2_get_rx_csum,
-       .set_rx_csum = sky2_set_rx_csum,
-       .get_strings = sky2_get_strings,
-       .get_coalesce = sky2_get_coalesce,
-       .set_coalesce = sky2_set_coalesce,
-       .get_ringparam = sky2_get_ringparam,
-       .set_ringparam = sky2_set_ringparam,
+       .get_settings   = sky2_get_settings,
+       .set_settings   = sky2_set_settings,
+       .get_drvinfo    = sky2_get_drvinfo,
+       .get_wol        = sky2_get_wol,
+       .set_wol        = sky2_set_wol,
+       .get_msglevel   = sky2_get_msglevel,
+       .set_msglevel   = sky2_set_msglevel,
+       .nway_reset     = sky2_nway_reset,
+       .get_regs_len   = sky2_get_regs_len,
+       .get_regs       = sky2_get_regs,
+       .get_link       = ethtool_op_get_link,
+       .get_eeprom_len = sky2_get_eeprom_len,
+       .get_eeprom     = sky2_get_eeprom,
+       .set_eeprom     = sky2_set_eeprom,
+       .get_sg         = ethtool_op_get_sg,
+       .set_sg         = ethtool_op_set_sg,
+       .get_tx_csum    = ethtool_op_get_tx_csum,
+       .set_tx_csum    = sky2_set_tx_csum,
+       .get_tso        = ethtool_op_get_tso,
+       .set_tso        = sky2_set_tso,
+       .get_rx_csum    = sky2_get_rx_csum,
+       .set_rx_csum    = sky2_set_rx_csum,
+       .get_strings    = sky2_get_strings,
+       .get_coalesce   = sky2_get_coalesce,
+       .set_coalesce   = sky2_set_coalesce,
+       .get_ringparam  = sky2_get_ringparam,
+       .set_ringparam  = sky2_set_ringparam,
        .get_pauseparam = sky2_get_pauseparam,
        .set_pauseparam = sky2_set_pauseparam,
-       .phys_id = sky2_phys_id,
+       .phys_id        = sky2_phys_id,
        .get_stats_count = sky2_get_stats_count,
        .get_ethtool_stats = sky2_get_ethtool_stats,
        .get_perm_addr  = ethtool_op_get_perm_addr,
 };
 
+#ifdef CONFIG_SKY2_DEBUG
+
+static struct dentry *sky2_debug;
+
+static int sky2_debug_show(struct seq_file *seq, void *v)
+{
+       struct net_device *dev = seq->private;
+       const struct sky2_port *sky2 = netdev_priv(dev);
+       const struct sky2_hw *hw = sky2->hw;
+       unsigned port = sky2->port;
+       unsigned idx, last;
+       int sop;
+
+       if (!netif_running(dev))
+               return -ENETDOWN;
+
+       seq_printf(seq, "IRQ src=%x mask=%x control=%x\n",
+                  sky2_read32(hw, B0_ISRC),
+                  sky2_read32(hw, B0_IMSK),
+                  sky2_read32(hw, B0_Y2_SP_ICR));
+
+       netif_poll_disable(hw->dev[0]);
+       last = sky2_read16(hw, STAT_PUT_IDX);
+
+       if (hw->st_idx == last)
+               seq_puts(seq, "Status ring (empty)\n");
+       else {
+               seq_puts(seq, "Status ring\n");
+               for (idx = hw->st_idx; idx != last && idx < STATUS_RING_SIZE;
+                    idx = RING_NEXT(idx, STATUS_RING_SIZE)) {
+                       const struct sky2_status_le *le = hw->st_le + idx;
+                       seq_printf(seq, "[%d] %#x %d %#x\n",
+                                  idx, le->opcode, le->length, le->status);
+               }
+               seq_puts(seq, "\n");
+       }
+
+       seq_printf(seq, "Tx ring pending=%u...%u report=%d done=%d\n",
+                  sky2->tx_cons, sky2->tx_prod,
+                  sky2_read16(hw, port == 0 ? STAT_TXA1_RIDX : STAT_TXA2_RIDX),
+                  sky2_read16(hw, Q_ADDR(txqaddr[port], Q_DONE)));
+
+       /* Dump contents of tx ring */
+       sop = 1;
+       for (idx = sky2->tx_next; idx != sky2->tx_prod && idx < TX_RING_SIZE;
+            idx = RING_NEXT(idx, TX_RING_SIZE)) {
+               const struct sky2_tx_le *le = sky2->tx_le + idx;
+               u32 a = le32_to_cpu(le->addr);
+
+               if (sop)
+                       seq_printf(seq, "%u:", idx);
+               sop = 0;
+
+               switch(le->opcode & ~HW_OWNER) {
+               case OP_ADDR64:
+                       seq_printf(seq, " %#x:", a);
+                       break;
+               case OP_LRGLEN:
+                       seq_printf(seq, " mtu=%d", a);
+                       break;
+               case OP_VLAN:
+                       seq_printf(seq, " vlan=%d", be16_to_cpu(le->length));
+                       break;
+               case OP_TCPLISW:
+                       seq_printf(seq, " csum=%#x", a);
+                       break;
+               case OP_LARGESEND:
+                       seq_printf(seq, " tso=%#x(%d)", a, le16_to_cpu(le->length));
+                       break;
+               case OP_PACKET:
+                       seq_printf(seq, " %#x(%d)", a, le16_to_cpu(le->length));
+                       break;
+               case OP_BUFFER:
+                       seq_printf(seq, " frag=%#x(%d)", a, le16_to_cpu(le->length));
+                       break;
+               default:
+                       seq_printf(seq, " op=%#x,%#x(%d)", le->opcode,
+                                  a, le16_to_cpu(le->length));
+               }
+
+               if (le->ctrl & EOP) {
+                       seq_putc(seq, '\n');
+                       sop = 1;
+               }
+       }
+
+       seq_printf(seq, "\nRx ring hw get=%d put=%d last=%d\n",
+                  sky2_read16(hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_GET_IDX)),
+                  last = sky2_read16(hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_PUT_IDX)),
+                  sky2_read16(hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_LAST_IDX)));
+
+       netif_poll_enable(hw->dev[0]);
+       return 0;
+}
+
+static int sky2_debug_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, sky2_debug_show, inode->i_private);
+}
+
+static const struct file_operations sky2_debug_fops = {
+       .owner          = THIS_MODULE,
+       .open           = sky2_debug_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+/*
+ * Use network device events to create/remove/rename
+ * debugfs file entries
+ */
+static int sky2_device_event(struct notifier_block *unused,
+                            unsigned long event, void *ptr)
+{
+       struct net_device *dev = ptr;
+
+       if (dev->open == sky2_up) {
+               struct sky2_port *sky2 = netdev_priv(dev);
+
+               switch(event) {
+               case NETDEV_CHANGENAME:
+                       if (!netif_running(dev))
+                               break;
+                       /* fallthrough */
+               case NETDEV_DOWN:
+               case NETDEV_GOING_DOWN:
+                       if (sky2->debugfs) {
+                               printk(KERN_DEBUG PFX "%s: remove debugfs\n",
+                                      dev->name);
+                               debugfs_remove(sky2->debugfs);
+                               sky2->debugfs = NULL;
+                       }
+
+                       if (event != NETDEV_CHANGENAME)
+                               break;
+                       /* fallthrough for changename */
+               case NETDEV_UP:
+                       if (sky2_debug) {
+                               struct dentry *d;
+                               d = debugfs_create_file(dev->name, S_IRUGO,
+                                                       sky2_debug, dev,
+                                                       &sky2_debug_fops);
+                               if (d == NULL || IS_ERR(d))
+                                       printk(KERN_INFO PFX
+                                              "%s: debugfs create failed\n",
+                                              dev->name);
+                               else
+                                       sky2->debugfs = d;
+                       }
+                       break;
+               }
+       }
+
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block sky2_notifier = {
+       .notifier_call = sky2_device_event,
+};
+
+
+static __init void sky2_debug_init(void)
+{
+       struct dentry *ent;
+
+       ent = debugfs_create_dir("sky2", NULL);
+       if (!ent || IS_ERR(ent))
+               return;
+
+       sky2_debug = ent;
+       register_netdevice_notifier(&sky2_notifier);
+}
+
+static __exit void sky2_debug_cleanup(void)
+{
+       if (sky2_debug) {
+               unregister_netdevice_notifier(&sky2_notifier);
+               debugfs_remove(sky2_debug);
+               sky2_debug = NULL;
+       }
+}
+
+#else
+#define sky2_debug_init()
+#define sky2_debug_cleanup()
+#endif
+
+
 /* Initialize network device */
 static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
                                                     unsigned port,
@@ -3410,17 +3808,12 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
 #ifdef SKY2_VLAN_TAG_USED
        dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
        dev->vlan_rx_register = sky2_vlan_rx_register;
-       dev->vlan_rx_kill_vid = sky2_vlan_rx_kill_vid;
 #endif
 
        /* read the mac address */
        memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN);
        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 
-       /* device is off until link detection */
-       netif_carrier_off(dev);
-       netif_stop_queue(dev);
-
        return dev;
 }
 
@@ -3520,7 +3913,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
        err = pci_request_regions(pdev, DRV_NAME);
        if (err) {
                dev_err(&pdev->dev, "cannot obtain PCI resources\n");
-               goto err_out;
+               goto err_out_disable;
        }
 
        pci_set_master(pdev);
@@ -3657,8 +4050,10 @@ err_out_free_hw:
        kfree(hw);
 err_out_free_regions:
        pci_release_regions(pdev);
+err_out_disable:
        pci_disable_device(pdev);
 err_out:
+       pci_set_drvdata(pdev, NULL);
        return err;
 }
 
@@ -3711,6 +4106,9 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
        struct sky2_hw *hw = pci_get_drvdata(pdev);
        int i, wol = 0;
 
+       if (!hw)
+               return 0;
+
        del_timer_sync(&hw->idle_timer);
        netif_poll_disable(hw->dev[0]);
 
@@ -3742,6 +4140,9 @@ static int sky2_resume(struct pci_dev *pdev)
        struct sky2_hw *hw = pci_get_drvdata(pdev);
        int i, err;
 
+       if (!hw)
+               return 0;
+
        err = pci_set_power_state(pdev, PCI_D0);
        if (err)
                goto out;
@@ -3751,6 +4152,11 @@ static int sky2_resume(struct pci_dev *pdev)
                goto out;
 
        pci_enable_wake(pdev, PCI_D0, 0);
+
+       /* Re-enable all clocks */
+       if (hw->chip_id == CHIP_ID_YUKON_EX || hw->chip_id == CHIP_ID_YUKON_EC_U)
+               sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+
        sky2_reset(hw);
 
        sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
@@ -3783,6 +4189,9 @@ static void sky2_shutdown(struct pci_dev *pdev)
        struct sky2_hw *hw = pci_get_drvdata(pdev);
        int i, wol = 0;
 
+       if (!hw)
+               return;
+
        del_timer_sync(&hw->idle_timer);
        netif_poll_disable(hw->dev[0]);
 
@@ -3821,12 +4230,14 @@ static struct pci_driver sky2_driver = {
 
 static int __init sky2_init_module(void)
 {
+       sky2_debug_init();
        return pci_register_driver(&sky2_driver);
 }
 
 static void __exit sky2_cleanup_module(void)
 {
        pci_unregister_driver(&sky2_driver);
+       sky2_debug_cleanup();
 }
 
 module_init(sky2_init_module);