]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/net/skge.c
skge: transmit locking improvements
[linux-2.6.git] / drivers / net / skge.c
index 63a6b3dfc0951fd647d1b0f98e3e8f232caad46d..bc531fdfc8e2bed8d4ffc1e0a740b6ee5fbe1f58 100644 (file)
@@ -11,8 +11,7 @@
  *
  * 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.
+ * the Free Software Foundation; either version 2 of the License.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,7 +23,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/config.h>
 #include <linux/in.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include "skge.h"
 
 #define DRV_NAME               "skge"
-#define DRV_VERSION            "1.5"
+#define DRV_VERSION            "1.10"
 #define PFX                    DRV_NAME " "
 
 #define DEFAULT_TX_RING_SIZE   128
 #define DEFAULT_RX_RING_SIZE   512
 #define MAX_TX_RING_SIZE       1024
+#define TX_LOW_WATER           (MAX_SKB_FRAGS + 1)
 #define MAX_RX_RING_SIZE       4096
 #define RX_COPY_THRESHOLD      128
 #define RX_BUF_SIZE            1536
 #define TX_WATCHDOG            (5 * HZ)
 #define NAPI_WEIGHT            64
 #define BLINK_MS               250
+#define LINK_HZ                        (HZ/2)
 
 MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver");
-MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>");
+MODULE_AUTHOR("Stephen Hemminger <shemminger@linux-foundation.org>");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
@@ -77,13 +77,13 @@ static const struct pci_device_id skge_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940B) },
        { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) },
        { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) },
-       { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T), },
+       { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T) },
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) },    /* DGE-530T */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) },
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */
        { PCI_DEVICE(PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD) },
        { PCI_DEVICE(PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1064) },
-       { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0015, },
+       { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0015 },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, skge_id_table);
@@ -91,7 +91,7 @@ MODULE_DEVICE_TABLE(pci, skge_id_table);
 static int skge_up(struct net_device *dev);
 static int skge_down(struct net_device *dev);
 static void skge_phy_reset(struct skge_port *skge);
-static void skge_tx_clean(struct skge_port *skge);
+static void skge_tx_clean(struct net_device *dev);
 static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
 static int gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
 static void genesis_get_stats(struct skge_port *skge, u64 *data);
@@ -105,6 +105,8 @@ static const int txqaddr[] = { Q_XA1, Q_XA2 };
 static const int rxqaddr[] = { Q_R1, Q_R2 };
 static const u32 rxirqmask[] = { IS_R1_F, IS_R2_F };
 static const u32 txirqmask[] = { IS_XA1_F, IS_XA2_F };
+static const u32 napimask[] = { IS_R1_F|IS_XA1_F, IS_R2_F|IS_XA2_F };
+static const u32 portmask[] = { IS_PORT_1, IS_PORT_2 };
 
 static int skge_get_regs_len(struct net_device *dev)
 {
@@ -131,18 +133,112 @@ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 }
 
 /* Wake on Lan only supported on Yukon chips with rev 1 or above */
-static int wol_supported(const struct skge_hw *hw)
+static u32 wol_supported(const struct skge_hw *hw)
 {
-       return !((hw->chip_id == CHIP_ID_GENESIS ||
-                 (hw->chip_id == CHIP_ID_YUKON && hw->chip_rev == 0)));
+       if (hw->chip_id == CHIP_ID_YUKON && hw->chip_rev != 0)
+               return WAKE_MAGIC | WAKE_PHY;
+       else
+               return 0;
+}
+
+static u32 pci_wake_enabled(struct pci_dev *dev)
+{
+       int pm = pci_find_capability(dev, PCI_CAP_ID_PM);
+       u16 value;
+
+       /* If device doesn't support PM Capabilities, but request is to disable
+        * wake events, it's a nop; otherwise fail */
+       if (!pm)
+               return 0;
+
+       pci_read_config_word(dev, pm + PCI_PM_PMC, &value);
+
+       value &= PCI_PM_CAP_PME_MASK;
+       value >>= ffs(PCI_PM_CAP_PME_MASK) - 1;   /* First bit of mask */
+
+       return value != 0;
+}
+
+static void skge_wol_init(struct skge_port *skge)
+{
+       struct skge_hw *hw = skge->hw;
+       int port = skge->port;
+       u16 ctrl;
+
+       skge_write16(hw, B0_CTST, CS_RST_CLR);
+       skge_write16(hw, SK_REG(port, GMAC_LINK_CTRL), GMLC_RST_CLR);
+
+       /* Turn on Vaux */
+       skge_write8(hw, B0_POWER_CTRL,
+                   PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_ON | PC_VCC_OFF);
+
+       /* WA code for COMA mode -- clear PHY reset */
+       if (hw->chip_id == CHIP_ID_YUKON_LITE &&
+           hw->chip_rev >= CHIP_REV_YU_LITE_A3) {
+               u32 reg = skge_read32(hw, B2_GP_IO);
+               reg |= GP_DIR_9;
+               reg &= ~GP_IO_9;
+               skge_write32(hw, B2_GP_IO, reg);
+       }
+
+       skge_write32(hw, SK_REG(port, GPHY_CTRL),
+                    GPC_DIS_SLEEP |
+                    GPC_HWCFG_M_3 | GPC_HWCFG_M_2 | GPC_HWCFG_M_1 | GPC_HWCFG_M_0 |
+                    GPC_ANEG_1 | GPC_RST_SET);
+
+       skge_write32(hw, SK_REG(port, GPHY_CTRL),
+                    GPC_DIS_SLEEP |
+                    GPC_HWCFG_M_3 | GPC_HWCFG_M_2 | GPC_HWCFG_M_1 | GPC_HWCFG_M_0 |
+                    GPC_ANEG_1 | GPC_RST_CLR);
+
+       skge_write32(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
+
+       /* Force to 10/100 skge_reset will re-enable on resume   */
+       gm_phy_write(hw, port, PHY_MARV_AUNE_ADV,
+                    PHY_AN_100FULL | PHY_AN_100HALF |
+                    PHY_AN_10FULL | PHY_AN_10HALF| PHY_AN_CSMA);
+       /* no 1000 HD/FD */
+       gm_phy_write(hw, port, PHY_MARV_1000T_CTRL, 0);
+       gm_phy_write(hw, port, PHY_MARV_CTRL,
+                    PHY_CT_RESET | PHY_CT_SPS_LSB | PHY_CT_ANE |
+                    PHY_CT_RE_CFG | PHY_CT_DUP_MD);
+
+
+       /* Set GMAC to no flow control and auto update for speed/duplex */
+       gma_write16(hw, port, GM_GP_CTRL,
+                   GM_GPCR_FC_TX_DIS|GM_GPCR_TX_ENA|GM_GPCR_RX_ENA|
+                   GM_GPCR_DUP_FULL|GM_GPCR_FC_RX_DIS|GM_GPCR_AU_FCT_DIS);
+
+       /* Set WOL address */
+       memcpy_toio(hw->regs + WOL_REGS(port, WOL_MAC_ADDR),
+                   skge->netdev->dev_addr, ETH_ALEN);
+
+       /* Turn on appropriate WOL control bits */
+       skge_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), WOL_CTL_CLEAR_RESULT);
+       ctrl = 0;
+       if (skge->wol & WAKE_PHY)
+               ctrl |= WOL_CTL_ENA_PME_ON_LINK_CHG|WOL_CTL_ENA_LINK_CHG_UNIT;
+       else
+               ctrl |= WOL_CTL_DIS_PME_ON_LINK_CHG|WOL_CTL_DIS_LINK_CHG_UNIT;
+
+       if (skge->wol & WAKE_MAGIC)
+               ctrl |= WOL_CTL_ENA_PME_ON_MAGIC_PKT|WOL_CTL_ENA_MAGIC_PKT_UNIT;
+       else
+               ctrl |= WOL_CTL_DIS_PME_ON_MAGIC_PKT|WOL_CTL_DIS_MAGIC_PKT_UNIT;;
+
+       ctrl |= WOL_CTL_DIS_PME_ON_PATTERN|WOL_CTL_DIS_PATTERN_UNIT;
+       skge_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl);
+
+       /* block receiver */
+       skge_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
 }
 
 static void skge_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
        struct skge_port *skge = netdev_priv(dev);
 
-       wol->supported = wol_supported(skge->hw) ? WAKE_MAGIC : 0;
-       wol->wolopts = skge->wol ? WAKE_MAGIC : 0;
+       wol->supported = wol_supported(skge->hw);
+       wol->wolopts = skge->wol;
 }
 
 static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
@@ -150,23 +246,10 @@ static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
        struct skge_port *skge = netdev_priv(dev);
        struct skge_hw *hw = skge->hw;
 
-       if (wol->wolopts != WAKE_MAGIC && wol->wolopts != 0)
+       if (wol->wolopts & ~wol_supported(hw))
                return -EOPNOTSUPP;
 
-       if (wol->wolopts == WAKE_MAGIC && !wol_supported(hw))
-               return -EOPNOTSUPP;
-
-       skge->wol = wol->wolopts == WAKE_MAGIC;
-
-       if (skge->wol) {
-               memcpy_toio(hw->regs + WOL_MAC_ADDR, dev->dev_addr, ETH_ALEN);
-
-               skge_write16(hw, WOL_CTRL_STAT,
-                            WOL_CTL_ENA_PME_ON_MAGIC_PKT |
-                            WOL_CTL_ENA_MAGIC_PKT_UNIT);
-       } else
-               skge_write16(hw, WOL_CTRL_STAT, WOL_CTL_DEFAULT);
-
+       skge->wol = wol->wolopts;
        return 0;
 }
 
@@ -195,8 +278,8 @@ static u32 skge_supported_modes(const struct skge_hw *hw)
                else if (hw->chip_id == CHIP_ID_YUKON)
                        supported &= ~SUPPORTED_1000baseT_Half;
        } else
-               supported = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE
-                       | SUPPORTED_Autoneg;
+               supported = SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Half
+                       | SUPPORTED_FIBRE | SUPPORTED_Autoneg;
 
        return supported;
 }
@@ -401,7 +484,7 @@ static int skge_set_ring_param(struct net_device *dev,
        int err;
 
        if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE ||
-           p->tx_pending == 0 || p->tx_pending > MAX_TX_RING_SIZE)
+           p->tx_pending < TX_LOW_WATER || p->tx_pending > MAX_TX_RING_SIZE)
                return -EINVAL;
 
        skge->rx_ring.count = p->rx_pending;
@@ -485,41 +568,44 @@ static void skge_get_pauseparam(struct net_device *dev,
 {
        struct skge_port *skge = netdev_priv(dev);
 
-       ecmd->tx_pause = (skge->flow_control == FLOW_MODE_LOC_SEND)
-               || (skge->flow_control == FLOW_MODE_SYMMETRIC);
-       ecmd->rx_pause = (skge->flow_control == FLOW_MODE_REM_SEND)
-               || (skge->flow_control == FLOW_MODE_SYMMETRIC);
+       ecmd->rx_pause = (skge->flow_control == FLOW_MODE_SYMMETRIC)
+               || (skge->flow_control == FLOW_MODE_SYM_OR_REM);
+       ecmd->tx_pause = ecmd->rx_pause || (skge->flow_control == FLOW_MODE_LOC_SEND);
 
-       ecmd->autoneg = skge->autoneg;
+       ecmd->autoneg = ecmd->rx_pause || ecmd->tx_pause;
 }
 
 static int skge_set_pauseparam(struct net_device *dev,
                               struct ethtool_pauseparam *ecmd)
 {
        struct skge_port *skge = netdev_priv(dev);
+       struct ethtool_pauseparam old;
 
-       skge->autoneg = ecmd->autoneg;
-       if (ecmd->rx_pause && ecmd->tx_pause)
-               skge->flow_control = FLOW_MODE_SYMMETRIC;
-       else if (ecmd->rx_pause && !ecmd->tx_pause)
-               skge->flow_control = FLOW_MODE_REM_SEND;
-       else if (!ecmd->rx_pause && ecmd->tx_pause)
-               skge->flow_control = FLOW_MODE_LOC_SEND;
-       else
-               skge->flow_control = FLOW_MODE_NONE;
+       skge_get_pauseparam(dev, &old);
+
+       if (ecmd->autoneg != old.autoneg)
+               skge->flow_control = ecmd->autoneg ? FLOW_MODE_NONE : FLOW_MODE_SYMMETRIC;
+       else {
+               if (ecmd->rx_pause && ecmd->tx_pause)
+                       skge->flow_control = FLOW_MODE_SYMMETRIC;
+               else if (ecmd->rx_pause && !ecmd->tx_pause)
+                       skge->flow_control = FLOW_MODE_SYM_OR_REM;
+               else if (!ecmd->rx_pause && ecmd->tx_pause)
+                       skge->flow_control = FLOW_MODE_LOC_SEND;
+               else
+                       skge->flow_control = FLOW_MODE_NONE;
+       }
 
        if (netif_running(dev))
                skge_phy_reset(skge);
+
        return 0;
 }
 
 /* Chip internal frequency for clock calculations */
 static inline u32 hwkhz(const struct skge_hw *hw)
 {
-       if (hw->chip_id == CHIP_ID_GENESIS)
-               return 53215; /* or:  53.125 MHz */
-       else
-               return 78215; /* or:  78.125 MHz */
+       return (hw->chip_id == CHIP_ID_GENESIS) ? 53125 : 78125;
 }
 
 /* Chip HZ to microseconds */
@@ -607,7 +693,12 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
        if (hw->chip_id == CHIP_ID_GENESIS) {
                switch (mode) {
                case LED_MODE_OFF:
-                       xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF);
+                       if (hw->phy_type == SK_PHY_BCOM)
+                               xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF);
+                       else {
+                               skge_write32(hw, SK_REG(port, TX_LED_VAL), 0);
+                               skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_T_OFF);
+                       }
                        skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
                        skge_write32(hw, SK_REG(port, RX_LED_VAL), 0);
                        skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF);
@@ -627,8 +718,14 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
                        skge_write32(hw, SK_REG(port, RX_LED_VAL), 100);
                        skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
 
-                       xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON);
-                       break;
+                       if (hw->phy_type == SK_PHY_BCOM)
+                               xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON);
+                       else {
+                               skge_write8(hw, SK_REG(port, TX_LED_TST), LED_T_ON);
+                               skge_write32(hw, SK_REG(port, TX_LED_VAL), 100);
+                               skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_START);
+                       }
+
                }
        } else {
                switch (mode) {
@@ -693,7 +790,7 @@ static int skge_phys_id(struct net_device *dev, u32 data)
        return 0;
 }
 
-static struct ethtool_ops skge_ethtool_ops = {
+static const struct ethtool_ops skge_ethtool_ops = {
        .get_settings   = skge_get_settings,
        .set_settings   = skge_set_settings,
        .get_drvinfo    = skge_get_drvinfo,
@@ -734,7 +831,7 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
        struct skge_element *e;
        int i;
 
-       ring->start = kcalloc(sizeof(*e), ring->count, GFP_KERNEL);
+       ring->start = kcalloc(ring->count, sizeof(*e), GFP_KERNEL);
        if (!ring->start)
                return -ENOMEM;
 
@@ -821,8 +918,9 @@ static void skge_rx_clean(struct skge_port *skge)
 /* Allocate buffers for receive ring
  * For receive:  to_clean is next received frame.
  */
-static int skge_rx_fill(struct skge_port *skge)
+static int skge_rx_fill(struct net_device *dev)
 {
+       struct skge_port *skge = netdev_priv(dev);
        struct skge_ring *ring = &skge->rx_ring;
        struct skge_element *e;
 
@@ -830,7 +928,8 @@ static int skge_rx_fill(struct skge_port *skge)
        do {
                struct sk_buff *skb;
 
-               skb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_KERNEL);
+               skb = __netdev_alloc_skb(dev, skge->rx_buf_size + NET_IP_ALIGN,
+                                        GFP_KERNEL);
                if (!skb)
                        return -ENOMEM;
 
@@ -842,6 +941,23 @@ static int skge_rx_fill(struct skge_port *skge)
        return 0;
 }
 
+static const char *skge_pause(enum pause_status status)
+{
+       switch(status) {
+       case FLOW_STAT_NONE:
+               return "none";
+       case FLOW_STAT_REM_SEND:
+               return "rx only";
+       case FLOW_STAT_LOC_SEND:
+               return "tx_only";
+       case FLOW_STAT_SYMMETRIC:               /* Both station may send PAUSE */
+               return "both";
+       default:
+               return "indeterminated";
+       }
+}
+
+
 static void skge_link_up(struct skge_port *skge)
 {
        skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG),
@@ -850,16 +966,13 @@ static void skge_link_up(struct skge_port *skge)
        netif_carrier_on(skge->netdev);
        netif_wake_queue(skge->netdev);
 
-       if (netif_msg_link(skge))
+       if (netif_msg_link(skge)) {
                printk(KERN_INFO PFX
                       "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
                       skge->netdev->name, skge->speed,
                       skge->duplex == DUPLEX_FULL ? "full" : "half",
-                      (skge->flow_control == FLOW_MODE_NONE) ? "none" :
-                      (skge->flow_control == FLOW_MODE_LOC_SEND) ? "tx only" :
-                      (skge->flow_control == FLOW_MODE_REM_SEND) ? "rx only" :
-                      (skge->flow_control == FLOW_MODE_SYMMETRIC) ? "tx and rx" :
-                      "unknown");
+                      skge_pause(skge->flow_status));
+       }
 }
 
 static void skge_link_down(struct skge_port *skge)
@@ -872,6 +985,29 @@ static void skge_link_down(struct skge_port *skge)
                printk(KERN_INFO PFX "%s: Link is down.\n", skge->netdev->name);
 }
 
+
+static void xm_link_down(struct skge_hw *hw, int port)
+{
+       struct net_device *dev = hw->dev[port];
+       struct skge_port *skge = netdev_priv(dev);
+       u16 cmd, msk;
+
+       if (hw->phy_type == SK_PHY_XMAC) {
+               msk = xm_read16(hw, port, XM_IMSK);
+               msk |= XM_IS_INP_ASS | XM_IS_LIPA_RC | XM_IS_RX_PAGE | XM_IS_AND;
+               xm_write16(hw, port, XM_IMSK, msk);
+       }
+
+       cmd = xm_read16(hw, port, XM_MMU_CMD);
+       cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
+       xm_write16(hw, port, XM_MMU_CMD, cmd);
+       /* dummy read to ensure writing */
+       (void) xm_read16(hw, port, XM_MMU_CMD);
+
+       if (netif_carrier_ok(dev))
+               skge_link_down(skge);
+}
+
 static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
 {
        int i;
@@ -879,6 +1015,9 @@ static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
        xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr);
        *val = xm_read16(hw, port, XM_PHY_DATA);
 
+       if (hw->phy_type == SK_PHY_XMAC)
+               goto ready;
+
        for (i = 0; i < PHY_RETRIES; i++) {
                if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY)
                        goto ready;
@@ -965,7 +1104,8 @@ static void genesis_reset(struct skge_hw *hw, int port)
        xm_write16(hw, port, XM_RX_CMD, 0);     /* reset RX CMD Reg */
 
        /* disable Broadcom PHY IRQ */
-       xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff);
+       if (hw->phy_type == SK_PHY_BCOM)
+               xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff);
 
        xm_outhash(hw, port, XM_HSM, zero);
 }
@@ -976,7 +1116,15 @@ static const u16 phy_pause_map[] = {
        [FLOW_MODE_NONE] =      0,
        [FLOW_MODE_LOC_SEND] =  PHY_AN_PAUSE_ASYM,
        [FLOW_MODE_SYMMETRIC] = PHY_AN_PAUSE_CAP,
-       [FLOW_MODE_REM_SEND]  = PHY_AN_PAUSE_CAP | PHY_AN_PAUSE_ASYM,
+       [FLOW_MODE_SYM_OR_REM]  = PHY_AN_PAUSE_CAP | PHY_AN_PAUSE_ASYM,
+};
+
+/* special defines for FIBER (88E1011S only) */
+static const u16 fiber_pause_map[] = {
+       [FLOW_MODE_NONE]        = PHY_X_P_NO_PAUSE,
+       [FLOW_MODE_LOC_SEND]    = PHY_X_P_ASYM_MD,
+       [FLOW_MODE_SYMMETRIC]   = PHY_X_P_SYM_MD,
+       [FLOW_MODE_SYM_OR_REM]  = PHY_X_P_BOTH_MD,
 };
 
 
@@ -992,68 +1140,64 @@ static void bcom_check_link(struct skge_hw *hw, int port)
        status = xm_phy_read(hw, port, PHY_BCOM_STAT);
 
        if ((status & PHY_ST_LSYNC) == 0) {
-               u16 cmd = xm_read16(hw, port, XM_MMU_CMD);
-               cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
-               xm_write16(hw, port, XM_MMU_CMD, cmd);
-               /* dummy read to ensure writing */
-               (void) xm_read16(hw, port, XM_MMU_CMD);
-
-               if (netif_carrier_ok(dev))
-                       skge_link_down(skge);
-       } else {
-               if (skge->autoneg == AUTONEG_ENABLE &&
-                   (status & PHY_ST_AN_OVER)) {
-                       u16 lpa = xm_phy_read(hw, port, PHY_BCOM_AUNE_LP);
-                       u16 aux = xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
-
-                       if (lpa & PHY_B_AN_RF) {
-                               printk(KERN_NOTICE PFX "%s: remote fault\n",
-                                      dev->name);
-                               return;
-                       }
+               xm_link_down(hw, port);
+               return;
+       }
 
-                       /* Check Duplex mismatch */
-                       switch (aux & PHY_B_AS_AN_RES_MSK) {
-                       case PHY_B_RES_1000FD:
-                               skge->duplex = DUPLEX_FULL;
-                               break;
-                       case PHY_B_RES_1000HD:
-                               skge->duplex = DUPLEX_HALF;
-                               break;
-                       default:
-                               printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
-                                      dev->name);
-                               return;
-                       }
+       if (skge->autoneg == AUTONEG_ENABLE) {
+               u16 lpa, aux;
 
+               if (!(status & PHY_ST_AN_OVER))
+                       return;
 
-                       /* We are using IEEE 802.3z/D5.0 Table 37-4 */
-                       switch (aux & PHY_B_AS_PAUSE_MSK) {
-                       case PHY_B_AS_PAUSE_MSK:
-                               skge->flow_control = FLOW_MODE_SYMMETRIC;
-                               break;
-                       case PHY_B_AS_PRR:
-                               skge->flow_control = FLOW_MODE_REM_SEND;
-                               break;
-                       case PHY_B_AS_PRT:
-                               skge->flow_control = FLOW_MODE_LOC_SEND;
-                               break;
-                       default:
-                               skge->flow_control = FLOW_MODE_NONE;
-                       }
+               lpa = xm_phy_read(hw, port, PHY_XMAC_AUNE_LP);
+               if (lpa & PHY_B_AN_RF) {
+                       printk(KERN_NOTICE PFX "%s: remote fault\n",
+                              dev->name);
+                       return;
+               }
 
-                       skge->speed = SPEED_1000;
+               aux = xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
+
+               /* Check Duplex mismatch */
+               switch (aux & PHY_B_AS_AN_RES_MSK) {
+               case PHY_B_RES_1000FD:
+                       skge->duplex = DUPLEX_FULL;
+                       break;
+               case PHY_B_RES_1000HD:
+                       skge->duplex = DUPLEX_HALF;
+                       break;
+               default:
+                       printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
+                              dev->name);
+                       return;
                }
 
-               if (!netif_carrier_ok(dev))
-                       genesis_link_up(skge);
+               /* We are using IEEE 802.3z/D5.0 Table 37-4 */
+               switch (aux & PHY_B_AS_PAUSE_MSK) {
+               case PHY_B_AS_PAUSE_MSK:
+                       skge->flow_status = FLOW_STAT_SYMMETRIC;
+                       break;
+               case PHY_B_AS_PRR:
+                       skge->flow_status = FLOW_STAT_REM_SEND;
+                       break;
+               case PHY_B_AS_PRT:
+                       skge->flow_status = FLOW_STAT_LOC_SEND;
+                       break;
+               default:
+                       skge->flow_status = FLOW_STAT_NONE;
+               }
+               skge->speed = SPEED_1000;
        }
+
+       if (!netif_carrier_ok(dev))
+               genesis_link_up(skge);
 }
 
 /* Broadcom 5400 only supports giagabit! SysKonnect did not put an additional
  * Phy on for 100 or 10Mbit operation
  */
-static void bcom_phy_init(struct skge_port *skge, int jumbo)
+static void bcom_phy_init(struct skge_port *skge)
 {
        struct skge_hw *hw = skge->hw;
        int port = skge->port;
@@ -1144,7 +1288,7 @@ static void bcom_phy_init(struct skge_port *skge, int jumbo)
                     phy_pause_map[skge->flow_control] | PHY_AN_CSMA);
 
        /* Handle Jumbo frames */
-       if (jumbo) {
+       if (hw->dev[port]->mtu > ETH_DATA_LEN) {
                xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
                             PHY_B_AC_TX_TST | PHY_B_AC_LONG_PACK);
 
@@ -1157,8 +1301,143 @@ static void bcom_phy_init(struct skge_port *skge, int jumbo)
 
        /* Use link status change interrupt */
        xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
+}
+
+static void xm_phy_init(struct skge_port *skge)
+{
+       struct skge_hw *hw = skge->hw;
+       int port = skge->port;
+       u16 ctrl = 0;
+
+       if (skge->autoneg == AUTONEG_ENABLE) {
+               if (skge->advertising & ADVERTISED_1000baseT_Half)
+                       ctrl |= PHY_X_AN_HD;
+               if (skge->advertising & ADVERTISED_1000baseT_Full)
+                       ctrl |= PHY_X_AN_FD;
+
+               ctrl |= fiber_pause_map[skge->flow_control];
+
+               xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl);
+
+               /* Restart Auto-negotiation */
+               ctrl = PHY_CT_ANE | PHY_CT_RE_CFG;
+       } else {
+               /* Set DuplexMode in Config register */
+               if (skge->duplex == DUPLEX_FULL)
+                       ctrl |= PHY_CT_DUP_MD;
+               /*
+                * Do NOT enable Auto-negotiation here. This would hold
+                * the link down because no IDLEs are transmitted
+                */
+       }
+
+       xm_phy_write(hw, port, PHY_XMAC_CTRL, ctrl);
+
+       /* Poll PHY for status changes */
+       mod_timer(&skge->link_timer, jiffies + LINK_HZ);
+}
+
+static void xm_check_link(struct net_device *dev)
+{
+       struct skge_port *skge = netdev_priv(dev);
+       struct skge_hw *hw = skge->hw;
+       int port = skge->port;
+       u16 status;
+
+       /* read twice because of latch */
+       (void) xm_phy_read(hw, port, PHY_XMAC_STAT);
+       status = xm_phy_read(hw, port, PHY_XMAC_STAT);
+
+       if ((status & PHY_ST_LSYNC) == 0) {
+               xm_link_down(hw, port);
+               return;
+       }
+
+       if (skge->autoneg == AUTONEG_ENABLE) {
+               u16 lpa, res;
+
+               if (!(status & PHY_ST_AN_OVER))
+                       return;
+
+               lpa = xm_phy_read(hw, port, PHY_XMAC_AUNE_LP);
+               if (lpa & PHY_B_AN_RF) {
+                       printk(KERN_NOTICE PFX "%s: remote fault\n",
+                              dev->name);
+                       return;
+               }
+
+               res = xm_phy_read(hw, port, PHY_XMAC_RES_ABI);
+
+               /* Check Duplex mismatch */
+               switch (res & (PHY_X_RS_HD | PHY_X_RS_FD)) {
+               case PHY_X_RS_FD:
+                       skge->duplex = DUPLEX_FULL;
+                       break;
+               case PHY_X_RS_HD:
+                       skge->duplex = DUPLEX_HALF;
+                       break;
+               default:
+                       printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
+                              dev->name);
+                       return;
+               }
+
+               /* We are using IEEE 802.3z/D5.0 Table 37-4 */
+               if ((skge->flow_control == FLOW_MODE_SYMMETRIC ||
+                    skge->flow_control == FLOW_MODE_SYM_OR_REM) &&
+                   (lpa & PHY_X_P_SYM_MD))
+                       skge->flow_status = FLOW_STAT_SYMMETRIC;
+               else if (skge->flow_control == FLOW_MODE_SYM_OR_REM &&
+                        (lpa & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD)
+                       /* Enable PAUSE receive, disable PAUSE transmit */
+                       skge->flow_status  = FLOW_STAT_REM_SEND;
+               else if (skge->flow_control == FLOW_MODE_LOC_SEND &&
+                        (lpa & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD)
+                       /* Disable PAUSE receive, enable PAUSE transmit */
+                       skge->flow_status = FLOW_STAT_LOC_SEND;
+               else
+                       skge->flow_status = FLOW_STAT_NONE;
+
+               skge->speed = SPEED_1000;
+       }
 
-       bcom_check_link(hw, port);
+       if (!netif_carrier_ok(dev))
+               genesis_link_up(skge);
+}
+
+/* Poll to check for link coming up.
+ * Since internal PHY is wired to a level triggered pin, can't
+ * get an interrupt when carrier is detected.
+ */
+static void xm_link_timer(unsigned long arg)
+{
+       struct skge_port *skge = (struct skge_port *) arg;
+       struct net_device *dev = skge->netdev;
+       struct skge_hw *hw = skge->hw;
+       int port = skge->port;
+
+       if (!netif_running(dev))
+               return;
+
+       if (netif_carrier_ok(dev)) {
+               xm_read16(hw, port, XM_ISRC);
+               if (!(xm_read16(hw, port, XM_ISRC) & XM_IS_INP_ASS))
+                       goto nochange;
+       } else {
+               if (xm_read32(hw, port, XM_GP_PORT) & XM_GP_INP_ASS)
+                       goto nochange;
+               xm_read16(hw, port, XM_ISRC);
+               if (xm_read16(hw, port, XM_ISRC) & XM_IS_INP_ASS)
+                       goto nochange;
+       }
+
+       spin_lock(&hw->phy_lock);
+       xm_check_link(dev);
+       spin_unlock(&hw->phy_lock);
+
+nochange:
+       if (netif_running(dev))
+               mod_timer(&skge->link_timer, jiffies + LINK_HZ);
 }
 
 static void genesis_mac_init(struct skge_hw *hw, int port)
@@ -1189,20 +1468,29 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
         * namely for the 1000baseTX cards that use the XMAC's
         * GMII mode.
         */
-       /* Take external Phy out of reset */
-       r = skge_read32(hw, B2_GP_IO);
-       if (port == 0)
-               r |= GP_DIR_0|GP_IO_0;
-       else
-               r |= GP_DIR_2|GP_IO_2;
+       if (hw->phy_type != SK_PHY_XMAC) {
+               /* Take external Phy out of reset */
+               r = skge_read32(hw, B2_GP_IO);
+               if (port == 0)
+                       r |= GP_DIR_0|GP_IO_0;
+               else
+                       r |= GP_DIR_2|GP_IO_2;
 
-       skge_write32(hw, B2_GP_IO, r);
+               skge_write32(hw, B2_GP_IO, r);
 
+               /* Enable GMII interface */
+               xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
+       }
 
-       /* Enable GMII interface */
-       xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
 
-       bcom_phy_init(skge, jumbo);
+       switch(hw->phy_type) {
+       case SK_PHY_XMAC:
+               xm_phy_init(skge);
+               break;
+       case SK_PHY_BCOM:
+               bcom_phy_init(skge);
+               bcom_check_link(hw, port);
+       }
 
        /* Set Station Address */
        xm_outaddr(hw, port, XM_SA, dev->dev_addr);
@@ -1335,16 +1623,18 @@ static void genesis_stop(struct skge_port *skge)
        skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST);
 
        /* For external PHYs there must be special handling */
-       reg = skge_read32(hw, B2_GP_IO);
-       if (port == 0) {
-               reg |= GP_DIR_0;
-               reg &= ~GP_IO_0;
-       } else {
-               reg |= GP_DIR_2;
-               reg &= ~GP_IO_2;
+       if (hw->phy_type != SK_PHY_XMAC) {
+               reg = skge_read32(hw, B2_GP_IO);
+               if (port == 0) {
+                       reg |= GP_DIR_0;
+                       reg &= ~GP_IO_0;
+               } else {
+                       reg |= GP_DIR_2;
+                       reg &= ~GP_IO_2;
+               }
+               skge_write32(hw, B2_GP_IO, reg);
+               skge_read32(hw, B2_GP_IO);
        }
-       skge_write32(hw, B2_GP_IO, reg);
-       skge_read32(hw, B2_GP_IO);
 
        xm_write16(hw, port, XM_MMU_CMD,
                        xm_read16(hw, port, XM_MMU_CMD)
@@ -1391,6 +1681,10 @@ static void genesis_mac_intr(struct skge_hw *hw, int port)
                printk(KERN_DEBUG PFX "%s: mac interrupt status 0x%x\n",
                       skge->netdev->name, status);
 
+       if (hw->phy_type == SK_PHY_XMAC &&
+           (status & (XM_IS_INP_ASS | XM_IS_LIPA_RC)))
+               xm_link_down(hw, port);
+
        if (status & XM_IS_TXF_UR) {
                xm_write32(hw, port, XM_MODE, XM_MD_FTF);
                ++skge->net_stats.tx_fifo_errors;
@@ -1405,8 +1699,8 @@ static void genesis_link_up(struct skge_port *skge)
 {
        struct skge_hw *hw = skge->hw;
        int port = skge->port;
-       u16 cmd;
-       u32 mode, msk;
+       u16 cmd, msk;
+       u32 mode;
 
        cmd = xm_read16(hw, port, XM_MMU_CMD);
 
@@ -1414,8 +1708,8 @@ static void genesis_link_up(struct skge_port *skge)
         * enabling pause frame reception is required for 1000BT
         * because the XMAC is not reset if the link is going down
         */
-       if (skge->flow_control == FLOW_MODE_NONE ||
-           skge->flow_control == FLOW_MODE_LOC_SEND)
+       if (skge->flow_status == FLOW_STAT_NONE ||
+           skge->flow_status == FLOW_STAT_LOC_SEND)
                /* Disable Pause Frame Reception */
                cmd |= XM_MMU_IGN_PF;
        else
@@ -1425,8 +1719,8 @@ static void genesis_link_up(struct skge_port *skge)
        xm_write16(hw, port, XM_MMU_CMD, cmd);
 
        mode = xm_read32(hw, port, XM_MODE);
-       if (skge->flow_control == FLOW_MODE_SYMMETRIC ||
-           skge->flow_control == FLOW_MODE_LOC_SEND) {
+       if (skge->flow_status== FLOW_STAT_SYMMETRIC ||
+           skge->flow_status == FLOW_STAT_LOC_SEND) {
                /*
                 * Configure Pause Frame Generation
                 * Use internal and external Pause Frame Generation.
@@ -1454,27 +1748,28 @@ static void genesis_link_up(struct skge_port *skge)
        }
 
        xm_write32(hw, port, XM_MODE, mode);
-
        msk = XM_DEF_MSK;
-       /* disable GP0 interrupt bit for external Phy */
-       msk |= XM_IS_INP_ASS;
+       if (hw->phy_type != SK_PHY_XMAC)
+               msk |= XM_IS_INP_ASS;   /* disable GP0 interrupt bit */
 
        xm_write16(hw, port, XM_IMSK, msk);
        xm_read16(hw, port, XM_ISRC);
 
        /* get MMU Command Reg. */
        cmd = xm_read16(hw, port, XM_MMU_CMD);
-       if (skge->duplex == DUPLEX_FULL)
+       if (hw->phy_type != SK_PHY_XMAC && skge->duplex == DUPLEX_FULL)
                cmd |= XM_MMU_GMII_FD;
 
        /*
         * Workaround BCOM Errata (#10523) for all BCom Phys
         * Enable Power Management after link up
         */
-       xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
-                    xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL)
-                    & ~PHY_B_AC_DIS_PM);
-       xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
+       if (hw->phy_type == SK_PHY_BCOM) {
+               xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
+                            xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL)
+                            & ~PHY_B_AC_DIS_PM);
+               xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
+       }
 
        /* enable Rx/Tx */
        xm_write16(hw, port, XM_MMU_CMD,
@@ -1605,11 +1900,17 @@ static void yukon_init(struct skge_hw *hw, int port)
                                adv |= PHY_M_AN_10_FD;
                        if (skge->advertising & ADVERTISED_10baseT_Half)
                                adv |= PHY_M_AN_10_HD;
-               } else  /* special defines for FIBER (88E1011S only) */
-                       adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD;
 
-               /* Set Flow-control capabilities */
-               adv |= phy_pause_map[skge->flow_control];
+                       /* Set Flow-control capabilities */
+                       adv |= phy_pause_map[skge->flow_control];
+               } else {
+                       if (skge->advertising & ADVERTISED_1000baseT_Full)
+                               adv |= PHY_M_AN_1000X_AFD;
+                       if (skge->advertising & ADVERTISED_1000baseT_Half)
+                               adv |= PHY_M_AN_1000X_AHD;
+
+                       adv |= fiber_pause_map[skge->flow_control];
+               }
 
                /* Restart Auto-negotiation */
                ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
@@ -1743,6 +2044,11 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
        case FLOW_MODE_LOC_SEND:
                /* disable Rx flow-control */
                reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
+               break;
+       case FLOW_MODE_SYMMETRIC:
+       case FLOW_MODE_SYM_OR_REM:
+               /* enable Tx & Rx flow-control */
+               break;
        }
 
        gma_write16(hw, port, GM_GP_CTRL, reg);
@@ -1931,22 +2237,17 @@ static void yukon_link_down(struct skge_port *skge)
        int port = skge->port;
        u16 ctrl;
 
-       gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
-
        ctrl = gma_read16(hw, port, GM_GP_CTRL);
        ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
        gma_write16(hw, port, GM_GP_CTRL, ctrl);
 
-       if (skge->flow_control == FLOW_MODE_REM_SEND) {
+       if (skge->flow_status == FLOW_STAT_REM_SEND) {
+               ctrl = gm_phy_read(hw, port, PHY_MARV_AUNE_ADV);
+               ctrl |= PHY_M_AN_ASP;
                /* restore Asymmetric Pause bit */
-               gm_phy_write(hw, port, PHY_MARV_AUNE_ADV,
-                                 gm_phy_read(hw, port,
-                                                  PHY_MARV_AUNE_ADV)
-                                 | PHY_M_AN_ASP);
-
+               gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, ctrl);
        }
 
-       yukon_reset(hw, port);
        skge_link_down(skge);
 
        yukon_init(hw, port);
@@ -1990,19 +2291,19 @@ static void yukon_phy_intr(struct skge_port *skge)
                /* We are using IEEE 802.3z/D5.0 Table 37-4 */
                switch (phystat & PHY_M_PS_PAUSE_MSK) {
                case PHY_M_PS_PAUSE_MSK:
-                       skge->flow_control = FLOW_MODE_SYMMETRIC;
+                       skge->flow_status = FLOW_STAT_SYMMETRIC;
                        break;
                case PHY_M_PS_RX_P_EN:
-                       skge->flow_control = FLOW_MODE_REM_SEND;
+                       skge->flow_status = FLOW_STAT_REM_SEND;
                        break;
                case PHY_M_PS_TX_P_EN:
-                       skge->flow_control = FLOW_MODE_LOC_SEND;
+                       skge->flow_status = FLOW_STAT_LOC_SEND;
                        break;
                default:
-                       skge->flow_control = FLOW_MODE_NONE;
+                       skge->flow_status = FLOW_STAT_NONE;
                }
 
-               if (skge->flow_control == FLOW_MODE_NONE ||
+               if (skge->flow_status == FLOW_STAT_NONE ||
                    (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF))
                        skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
                else
@@ -2034,6 +2335,7 @@ static void skge_phy_reset(struct skge_port *skge)
 {
        struct skge_hw *hw = skge->hw;
        int port = skge->port;
+       struct net_device *dev = hw->dev[port];
 
        netif_stop_queue(skge->netdev);
        netif_carrier_off(skge->netdev);
@@ -2047,6 +2349,8 @@ static void skge_phy_reset(struct skge_port *skge)
                yukon_init(hw, port);
        }
        spin_unlock_bh(&hw->phy_lock);
+
+       dev->set_multicast_list(dev);
 }
 
 /* Basic MII support */
@@ -2151,6 +2455,9 @@ static int skge_up(struct net_device *dev)
        size_t rx_size, tx_size;
        int err;
 
+       if (!is_valid_ether_addr(dev->dev_addr))
+               return -EINVAL;
+
        if (netif_msg_ifup(skge))
                printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
 
@@ -2170,7 +2477,7 @@ static int skge_up(struct net_device *dev)
        BUG_ON(skge->dma & 7);
 
        if ((u64)skge->dma >> 32 != ((u64) skge->dma + skge->mem_size) >> 32) {
-               printk(KERN_ERR PFX "pci_alloc_consistent region crosses 4G boundary\n");
+               dev_err(&hw->pdev->dev, "pci_alloc_consistent region crosses 4G boundary\n");
                err = -EINVAL;
                goto free_pci_mem;
        }
@@ -2181,7 +2488,7 @@ static int skge_up(struct net_device *dev)
        if (err)
                goto free_pci_mem;
 
-       err = skge_rx_fill(skge);
+       err = skge_rx_fill(dev);
        if (err)
                goto free_rx_ring;
 
@@ -2214,6 +2521,12 @@ static int skge_up(struct net_device *dev)
        skge_write8(hw, Q_ADDR(rxqaddr[port], Q_CSR), CSR_START | CSR_IRQ_CL_F);
        skge_led(skge, LED_MODE_ON);
 
+       spin_lock_irq(&hw->hw_lock);
+       hw->intr_mask |= portmask[port];
+       skge_write32(hw, B0_IMSK, hw->intr_mask);
+       spin_unlock_irq(&hw->hw_lock);
+
+       netif_poll_enable(dev);
        return 0;
 
  free_rx_ring:
@@ -2240,6 +2553,17 @@ static int skge_down(struct net_device *dev)
 
        netif_stop_queue(dev);
 
+       if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)
+               del_timer_sync(&skge->link_timer);
+
+       netif_poll_disable(dev);
+       netif_carrier_off(dev);
+
+       spin_lock_irq(&hw->hw_lock);
+       hw->intr_mask &= ~portmask[port];
+       skge_write32(hw, B0_IMSK, hw->intr_mask);
+       spin_unlock_irq(&hw->hw_lock);
+
        skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
        if (hw->chip_id == CHIP_ID_GENESIS)
                genesis_stop(skge);
@@ -2282,7 +2606,10 @@ static int skge_down(struct net_device *dev)
 
        skge_led(skge, LED_MODE_OFF);
 
-       skge_tx_clean(skge);
+       netif_tx_lock_bh(dev);
+       skge_tx_clean(dev);
+       netif_tx_unlock_bh(dev);
+
        skge_rx_clean(skge);
 
        kfree(skge->rx_ring.start);
@@ -2294,6 +2621,7 @@ static int skge_down(struct net_device *dev)
 
 static inline int skge_avail(const struct skge_ring *ring)
 {
+       smp_mb();
        return ((ring->to_clean > ring->to_use) ? 0 : ring->count)
                + (ring->to_clean - ring->to_use) - 1;
 }
@@ -2302,35 +2630,21 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 {
        struct skge_port *skge = netdev_priv(dev);
        struct skge_hw *hw = skge->hw;
-       struct skge_ring *ring = &skge->tx_ring;
        struct skge_element *e;
        struct skge_tx_desc *td;
        int i;
        u32 control, len;
        u64 map;
 
-       skb = skb_padto(skb, ETH_ZLEN);
-       if (!skb)
+       if (skb_padto(skb, ETH_ZLEN))
                return NETDEV_TX_OK;
 
-       if (!spin_trylock(&skge->tx_lock)) {
-               /* Collision - tell upper layer to requeue */
-               return NETDEV_TX_LOCKED;
-       }
-
-       if (unlikely(skge_avail(&skge->tx_ring) < skb_shinfo(skb)->nr_frags + 1)) {
-               if (!netif_queue_stopped(dev)) {
-                       netif_stop_queue(dev);
-
-                       printk(KERN_WARNING PFX "%s: ring full when queue awake!\n",
-                              dev->name);
-               }
-               spin_unlock(&skge->tx_lock);
+       if (unlikely(skge_avail(&skge->tx_ring) < skb_shinfo(skb)->nr_frags + 1))
                return NETDEV_TX_BUSY;
-       }
 
-       e = ring->to_use;
+       e = skge->tx_ring.to_use;
        td = e->desc;
+       BUG_ON(td->control & BMU_OWN);
        e->skb = skb;
        len = skb_headlen(skb);
        map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
@@ -2340,13 +2654,13 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
        td->dma_lo = map;
        td->dma_hi = map >> 32;
 
-       if (skb->ip_summed == CHECKSUM_HW) {
-               int offset = skb->h.raw - skb->data;
+       if (skb->ip_summed == CHECKSUM_PARTIAL) {
+               const int offset = skb_transport_offset(skb);
 
                /* This seems backwards, but it is what the sk98lin
                 * does.  Looks like hardware is wrong?
                 */
-               if (skb->h.ipiph->protocol == IPPROTO_UDP
+               if (ipip_hdr(skb)->protocol == IPPROTO_UDP
                    && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON)
                        control = BMU_TCP_CHECK;
                else
@@ -2354,7 +2668,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 
                td->csum_offs = 0;
                td->csum_start = offset;
-               td->csum_write = offset + skb->csum;
+               td->csum_write = offset + skb->csum_offset;
        } else
                control = BMU_CHECK;
 
@@ -2371,8 +2685,10 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
                                           frag->size, PCI_DMA_TODEVICE);
 
                        e = e->next;
-                       e->skb = NULL;
+                       e->skb = skb;
                        tf = e->desc;
+                       BUG_ON(tf->control & BMU_OWN);
+
                        tf->dma_lo = map;
                        tf->dma_hi = (u64) map >> 32;
                        pci_unmap_addr_set(e, mapaddr, map);
@@ -2389,56 +2705,63 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 
        skge_write8(hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_START);
 
-       if (netif_msg_tx_queued(skge))
+       if (unlikely(netif_msg_tx_queued(skge)))
                printk(KERN_DEBUG "%s: tx queued, slot %td, len %d\n",
-                      dev->name, e - ring->start, skb->len);
+                      dev->name, e - skge->tx_ring.start, skb->len);
+
+       skge->tx_ring.to_use = e->next;
+       smp_wmb();
 
-       ring->to_use = e->next;
-       if (skge_avail(&skge->tx_ring) <= MAX_SKB_FRAGS + 1) {
+       if (skge_avail(&skge->tx_ring) <= TX_LOW_WATER) {
                pr_debug("%s: transmit queue full\n", dev->name);
                netif_stop_queue(dev);
        }
 
-       mmiowb();
-       spin_unlock(&skge->tx_lock);
-
        dev->trans_start = jiffies;
 
        return NETDEV_TX_OK;
 }
 
-static void skge_tx_complete(struct skge_port *skge, struct skge_element *last)
+
+/* Free resources associated with this reing element */
+static void skge_tx_free(struct skge_port *skge, struct skge_element *e,
+                        u32 control)
 {
        struct pci_dev *pdev = skge->hw->pdev;
-       struct skge_element *e;
-
-       for (e = skge->tx_ring.to_clean; e != last; e = e->next) {
-               struct sk_buff *skb = e->skb;
-               int i;
 
-               e->skb = NULL;
+       /* skb header vs. fragment */
+       if (control & BMU_STF)
                pci_unmap_single(pdev, pci_unmap_addr(e, mapaddr),
-                                skb_headlen(skb), PCI_DMA_TODEVICE);
+                                pci_unmap_len(e, maplen),
+                                PCI_DMA_TODEVICE);
+       else
+               pci_unmap_page(pdev, pci_unmap_addr(e, mapaddr),
+                              pci_unmap_len(e, maplen),
+                              PCI_DMA_TODEVICE);
 
-               for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-                       e = e->next;
-                       pci_unmap_page(pdev, pci_unmap_addr(e, mapaddr),
-                                      skb_shinfo(skb)->frags[i].size,
-                                      PCI_DMA_TODEVICE);
-               }
+       if (control & BMU_EOF) {
+               if (unlikely(netif_msg_tx_done(skge)))
+                       printk(KERN_DEBUG PFX "%s: tx done slot %td\n",
+                              skge->netdev->name, e - skge->tx_ring.start);
 
-               dev_kfree_skb(skb);
+               dev_kfree_skb(e->skb);
        }
-       skge->tx_ring.to_clean = e;
 }
 
-static void skge_tx_clean(struct skge_port *skge)
+/* Free all buffers in transmit ring */
+static void skge_tx_clean(struct net_device *dev)
 {
+       struct skge_port *skge = netdev_priv(dev);
+       struct skge_element *e;
 
-       spin_lock_bh(&skge->tx_lock);
-       skge_tx_complete(skge, skge->tx_ring.to_use);
-       netif_wake_queue(skge->netdev);
-       spin_unlock_bh(&skge->tx_lock);
+       for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) {
+               struct skge_tx_desc *td = e->desc;
+               skge_tx_free(skge, e, td->control);
+               td->control = 0;
+       }
+
+       skge->tx_ring.to_clean = e;
+       netif_wake_queue(dev);
 }
 
 static void skge_tx_timeout(struct net_device *dev)
@@ -2449,7 +2772,7 @@ static void skge_tx_timeout(struct net_device *dev)
                printk(KERN_DEBUG PFX "%s: tx timeout\n", dev->name);
 
        skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_STOP);
-       skge_tx_clean(skge);
+       skge_tx_clean(dev);
 }
 
 static int skge_change_mtu(struct net_device *dev, int new_mtu)
@@ -2475,6 +2798,17 @@ static int skge_change_mtu(struct net_device *dev, int new_mtu)
        return err;
 }
 
+static const u8 pause_mc_addr[ETH_ALEN] = { 0x1, 0x80, 0xc2, 0x0, 0x0, 0x1 };
+
+static void genesis_add_filter(u8 filter[8], const u8 *addr)
+{
+       u32 crc, bit;
+
+       crc = ether_crc_le(ETH_ALEN, addr);
+       bit = ~crc & 0x3f;
+       filter[bit/8] |= 1 << (bit%8);
+}
+
 static void genesis_set_multicast(struct net_device *dev)
 {
        struct skge_port *skge = netdev_priv(dev);
@@ -2496,24 +2830,33 @@ static void genesis_set_multicast(struct net_device *dev)
                memset(filter, 0xff, sizeof(filter));
        else {
                memset(filter, 0, sizeof(filter));
-               for (i = 0; list && i < count; i++, list = list->next) {
-                       u32 crc, bit;
-                       crc = ether_crc_le(ETH_ALEN, list->dmi_addr);
-                       bit = ~crc & 0x3f;
-                       filter[bit/8] |= 1 << (bit%8);
-               }
+
+               if (skge->flow_status == FLOW_STAT_REM_SEND
+                   || skge->flow_status == FLOW_STAT_SYMMETRIC)
+                       genesis_add_filter(filter, pause_mc_addr);
+
+               for (i = 0; list && i < count; i++, list = list->next)
+                       genesis_add_filter(filter, list->dmi_addr);
        }
 
        xm_write32(hw, port, XM_MODE, mode);
        xm_outhash(hw, port, XM_HSM, filter);
 }
 
+static void yukon_add_filter(u8 filter[8], const u8 *addr)
+{
+        u32 bit = ether_crc(ETH_ALEN, addr) & 0x3f;
+        filter[bit/8] |= 1 << (bit%8);
+}
+
 static void yukon_set_multicast(struct net_device *dev)
 {
        struct skge_port *skge = netdev_priv(dev);
        struct skge_hw *hw = skge->hw;
        int port = skge->port;
        struct dev_mc_list *list = dev->mc_list;
+       int rx_pause = (skge->flow_status == FLOW_STAT_REM_SEND
+                       || skge->flow_status == FLOW_STAT_SYMMETRIC);
        u16 reg;
        u8 filter[8];
 
@@ -2526,16 +2869,17 @@ static void yukon_set_multicast(struct net_device *dev)
                reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
        else if (dev->flags & IFF_ALLMULTI)     /* all multicast */
                memset(filter, 0xff, sizeof(filter));
-       else if (dev->mc_count == 0)            /* no multicast */
+       else if (dev->mc_count == 0 && !rx_pause)/* no multicast */
                reg &= ~GM_RXCR_MCF_ENA;
        else {
                int i;
                reg |= GM_RXCR_MCF_ENA;
 
-               for (i = 0; list && i < dev->mc_count; i++, list = list->next) {
-                       u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f;
-                       filter[bit/8] |= 1 << (bit%8);
-               }
+               if (rx_pause)
+                       yukon_add_filter(filter, pause_mc_addr);
+
+               for (i = 0; list && i < dev->mc_count; i++, list = list->next)
+                       yukon_add_filter(filter, list->dmi_addr);
        }
 
 
@@ -2572,16 +2916,17 @@ static inline int bad_phy_status(const struct skge_hw *hw, u32 status)
 /* Get receive buffer from descriptor.
  * Handles copy of small buffers and reallocation failures
  */
-static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
-                                         struct skge_element *e,
-                                         u32 control, u32 status, u16 csum)
+static struct sk_buff *skge_rx_get(struct net_device *dev,
+                                  struct skge_element *e,
+                                  u32 control, u32 status, u16 csum)
 {
+       struct skge_port *skge = netdev_priv(dev);
        struct sk_buff *skb;
        u16 len = control & BMU_BBC;
 
        if (unlikely(netif_msg_rx_status(skge)))
                printk(KERN_DEBUG PFX "%s: rx slot %td status 0x%x len %d\n",
-                      skge->netdev->name, e - skge->rx_ring.start,
+                      dev->name, e - skge->rx_ring.start,
                       status, len);
 
        if (len > skge->rx_buf_size)
@@ -2597,7 +2942,7 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
                goto error;
 
        if (len < RX_COPY_THRESHOLD) {
-               skb = alloc_skb(len + 2, GFP_ATOMIC);
+               skb = netdev_alloc_skb(dev, len + 2);
                if (!skb)
                        goto resubmit;
 
@@ -2605,14 +2950,14 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
                pci_dma_sync_single_for_cpu(skge->hw->pdev,
                                            pci_unmap_addr(e, mapaddr),
                                            len, PCI_DMA_FROMDEVICE);
-               memcpy(skb->data, e->skb->data, len);
+               skb_copy_from_linear_data(e->skb, skb->data, len);
                pci_dma_sync_single_for_device(skge->hw->pdev,
                                               pci_unmap_addr(e, mapaddr),
                                               len, PCI_DMA_FROMDEVICE);
                skge_rx_reuse(e, skge->rx_buf_size);
        } else {
                struct sk_buff *nskb;
-               nskb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_ATOMIC);
+               nskb = netdev_alloc_skb(dev, skge->rx_buf_size + NET_IP_ALIGN);
                if (!nskb)
                        goto resubmit;
 
@@ -2627,20 +2972,19 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
        }
 
        skb_put(skb, len);
-       skb->dev = skge->netdev;
        if (skge->rx_csum) {
                skb->csum = csum;
-               skb->ip_summed = CHECKSUM_HW;
+               skb->ip_summed = CHECKSUM_COMPLETE;
        }
 
-       skb->protocol = eth_type_trans(skb, skge->netdev);
+       skb->protocol = eth_type_trans(skb, dev);
 
        return skb;
 error:
 
        if (netif_msg_rx_err(skge))
                printk(KERN_DEBUG PFX "%s: rx err, slot %td control 0x%x status 0x%x\n",
-                      skge->netdev->name, e - skge->rx_ring.start,
+                      dev->name, e - skge->rx_ring.start,
                       control, status);
 
        if (skge->hw->chip_id == CHIP_ID_GENESIS) {
@@ -2664,35 +3008,38 @@ resubmit:
        return NULL;
 }
 
-static void skge_tx_done(struct skge_port *skge)
+/* Free all buffers in Tx ring which are no longer owned by device */
+static void skge_tx_done(struct net_device *dev)
 {
+       struct skge_port *skge = netdev_priv(dev);
        struct skge_ring *ring = &skge->tx_ring;
-       struct skge_element *e, *last;
+       struct skge_element *e;
+
+       skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
 
-       spin_lock(&skge->tx_lock);
-       last = ring->to_clean;
        for (e = ring->to_clean; e != ring->to_use; e = e->next) {
-               struct skge_tx_desc *td = e->desc;
+               u32 control = ((const struct skge_tx_desc *) e->desc)->control;
 
-               if (td->control & BMU_OWN)
+               if (control & BMU_OWN)
                        break;
 
-               if (td->control & BMU_EOF) {
-                       last = e->next;
-                       if (unlikely(netif_msg_tx_done(skge)))
-                               printk(KERN_DEBUG PFX "%s: tx done slot %td\n",
-                                      skge->netdev->name, e - ring->start);
-               }
+               skge_tx_free(skge, e, control);
        }
+       skge->tx_ring.to_clean = e;
 
-       skge_tx_complete(skge, last);
+       /* Can run lockless until we need to synchronize to restart queue. */
+       smp_mb();
 
-       skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
+       if (unlikely(netif_queue_stopped(dev) &&
+                    skge_avail(&skge->tx_ring) > TX_LOW_WATER)) {
+               netif_tx_lock(dev);
+               if (unlikely(netif_queue_stopped(dev) &&
+                            skge_avail(&skge->tx_ring) > TX_LOW_WATER)) {
+                       netif_wake_queue(dev);
 
-       if (skge_avail(&skge->tx_ring) > MAX_SKB_FRAGS + 1)
-               netif_wake_queue(skge->netdev);
-
-       spin_unlock(&skge->tx_lock);
+               }
+               netif_tx_unlock(dev);
+       }
 }
 
 static int skge_poll(struct net_device *dev, int *budget)
@@ -2701,10 +3048,13 @@ static int skge_poll(struct net_device *dev, int *budget)
        struct skge_hw *hw = skge->hw;
        struct skge_ring *ring = &skge->rx_ring;
        struct skge_element *e;
+       unsigned long flags;
        int to_do = min(dev->quota, *budget);
        int work_done = 0;
 
-       skge_tx_done(skge);
+       skge_tx_done(dev);
+
+       skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
 
        for (e = ring->to_clean; prefetch(e->next), work_done < to_do; e = e->next) {
                struct skge_rx_desc *rd = e->desc;
@@ -2716,8 +3066,7 @@ static int skge_poll(struct net_device *dev, int *budget)
                if (control & BMU_OWN)
                        break;
 
-               skb = skge_rx_get(skge, e, control, rd->status,
-                                 le16_to_cpu(rd->csum2));
+               skb = skge_rx_get(dev, e, control, rd->status, rd->csum2);
                if (likely(skb)) {
                        dev->last_rx = jiffies;
                        netif_receive_skb(skb);
@@ -2737,11 +3086,12 @@ static int skge_poll(struct net_device *dev, int *budget)
        if (work_done >=  to_do)
                return 1; /* not done */
 
-       netif_rx_complete(dev);
-       mmiowb();
-
-       hw->intr_mask |= skge->port == 0 ? (IS_R1_F|IS_XA1_F) : (IS_R2_F|IS_XA2_F);
+       spin_lock_irqsave(&hw->hw_lock, flags);
+       __netif_rx_complete(dev);
+       hw->intr_mask |= napimask[skge->port];
        skge_write32(hw, B0_IMSK, hw->intr_mask);
+       skge_read32(hw, B0_IMSK);
+       spin_unlock_irqrestore(&hw->hw_lock, flags);
 
        return 0;
 }
@@ -2779,6 +3129,7 @@ static void skge_mac_intr(struct skge_hw *hw, int port)
 /* Handle device specific framing and timeout interrupts */
 static void skge_error_irq(struct skge_hw *hw)
 {
+       struct pci_dev *pdev = hw->pdev;
        u32 hwstatus = skge_read32(hw, B0_HWE_ISRC);
 
        if (hw->chip_id == CHIP_ID_GENESIS) {
@@ -2794,12 +3145,12 @@ static void skge_error_irq(struct skge_hw *hw)
        }
 
        if (hwstatus & IS_RAM_RD_PAR) {
-               printk(KERN_ERR PFX "Ram read data parity error\n");
+               dev_err(&pdev->dev, "Ram read data parity error\n");
                skge_write16(hw, B3_RI_CTRL, RI_CLR_RD_PERR);
        }
 
        if (hwstatus & IS_RAM_WR_PAR) {
-               printk(KERN_ERR PFX "Ram write data parity error\n");
+               dev_err(&pdev->dev, "Ram write data parity error\n");
                skge_write16(hw, B3_RI_CTRL, RI_CLR_WR_PERR);
        }
 
@@ -2810,131 +3161,141 @@ static void skge_error_irq(struct skge_hw *hw)
                skge_mac_parity(hw, 1);
 
        if (hwstatus & IS_R1_PAR_ERR) {
-               printk(KERN_ERR PFX "%s: receive queue parity error\n",
-                      hw->dev[0]->name);
+               dev_err(&pdev->dev, "%s: receive queue parity error\n",
+                       hw->dev[0]->name);
                skge_write32(hw, B0_R1_CSR, CSR_IRQ_CL_P);
        }
 
        if (hwstatus & IS_R2_PAR_ERR) {
-               printk(KERN_ERR PFX "%s: receive queue parity error\n",
-                      hw->dev[1]->name);
+               dev_err(&pdev->dev, "%s: receive queue parity error\n",
+                       hw->dev[1]->name);
                skge_write32(hw, B0_R2_CSR, CSR_IRQ_CL_P);
        }
 
        if (hwstatus & (IS_IRQ_MST_ERR|IS_IRQ_STAT)) {
                u16 pci_status, pci_cmd;
 
-               pci_read_config_word(hw->pdev, PCI_COMMAND, &pci_cmd);
-               pci_read_config_word(hw->pdev, PCI_STATUS, &pci_status);
+               pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd);
+               pci_read_config_word(pdev, PCI_STATUS, &pci_status);
 
-               printk(KERN_ERR PFX "%s: PCI error cmd=%#x status=%#x\n",
-                              pci_name(hw->pdev), pci_cmd, pci_status);
+               dev_err(&pdev->dev, "PCI error cmd=%#x status=%#x\n",
+                       pci_cmd, pci_status);
 
                /* Write the error bits back to clear them. */
                pci_status &= PCI_STATUS_ERROR_BITS;
                skge_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-               pci_write_config_word(hw->pdev, PCI_COMMAND,
+               pci_write_config_word(pdev, PCI_COMMAND,
                                      pci_cmd | PCI_COMMAND_SERR | PCI_COMMAND_PARITY);
-               pci_write_config_word(hw->pdev, PCI_STATUS, pci_status);
+               pci_write_config_word(pdev, PCI_STATUS, pci_status);
                skge_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
 
                /* if error still set then just ignore it */
                hwstatus = skge_read32(hw, B0_HWE_ISRC);
                if (hwstatus & IS_IRQ_STAT) {
-                       printk(KERN_INFO PFX "unable to clear error (so ignoring them)\n");
+                       dev_warn(&hw->pdev->dev, "unable to clear error (so ignoring them)\n");
                        hw->intr_mask &= ~IS_HW_ERR;
                }
        }
 }
 
 /*
- * Interrupt from PHY are handled in tasklet (soft irq)
+ * Interrupt from PHY are handled in tasklet (softirq)
  * because accessing phy registers requires spin wait which might
  * cause excess interrupt latency.
  */
-static void skge_extirq(unsigned long data)
+static void skge_extirq(unsigned long arg)
 {
-       struct skge_hw *hw = (struct skge_hw *) data;
+       struct skge_hw *hw = (struct skge_hw *) arg;
        int port;
 
-       spin_lock(&hw->phy_lock);
        for (port = 0; port < hw->ports; port++) {
                struct net_device *dev = hw->dev[port];
-               struct skge_port *skge = netdev_priv(dev);
 
                if (netif_running(dev)) {
+                       struct skge_port *skge = netdev_priv(dev);
+
+                       spin_lock(&hw->phy_lock);
                        if (hw->chip_id != CHIP_ID_GENESIS)
                                yukon_phy_intr(skge);
-                       else
+                       else if (hw->phy_type == SK_PHY_BCOM)
                                bcom_phy_intr(skge);
+                       spin_unlock(&hw->phy_lock);
                }
        }
-       spin_unlock(&hw->phy_lock);
 
+       spin_lock_irq(&hw->hw_lock);
        hw->intr_mask |= IS_EXT_REG;
        skge_write32(hw, B0_IMSK, hw->intr_mask);
+       skge_read32(hw, B0_IMSK);
+       spin_unlock_irq(&hw->hw_lock);
 }
 
-static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t skge_intr(int irq, void *dev_id)
 {
        struct skge_hw *hw = dev_id;
        u32 status;
+       int handled = 0;
 
+       spin_lock(&hw->hw_lock);
        /* Reading this register masks IRQ */
        status = skge_read32(hw, B0_SP_ISRC);
-       if (status == 0)
-               return IRQ_NONE;
+       if (status == 0 || status == ~0)
+               goto out;
 
+       handled = 1;
+       status &= hw->intr_mask;
        if (status & IS_EXT_REG) {
                hw->intr_mask &= ~IS_EXT_REG;
-               tasklet_schedule(&hw->ext_tasklet);
+               tasklet_schedule(&hw->phy_task);
        }
 
-       if (status & (IS_R1_F|IS_XA1_F)) {
-               skge_write8(hw, Q_ADDR(Q_R1, Q_CSR), CSR_IRQ_CL_F);
-               hw->intr_mask &= ~(IS_R1_F|IS_XA1_F);
+       if (status & (IS_XA1_F|IS_R1_F)) {
+               hw->intr_mask &= ~(IS_XA1_F|IS_R1_F);
                netif_rx_schedule(hw->dev[0]);
        }
 
-       if (status & (IS_R2_F|IS_XA2_F)) {
-               skge_write8(hw, Q_ADDR(Q_R2, Q_CSR), CSR_IRQ_CL_F);
-               hw->intr_mask &= ~(IS_R2_F|IS_XA2_F);
-               netif_rx_schedule(hw->dev[1]);
-       }
-
-       if (likely((status & hw->intr_mask) == 0))
-               return IRQ_HANDLED;
+       if (status & IS_PA_TO_TX1)
+               skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX1);
 
        if (status & IS_PA_TO_RX1) {
                struct skge_port *skge = netdev_priv(hw->dev[0]);
-               ++skge->net_stats.rx_over_errors;
-               skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX1);
-       }
 
-       if (status & IS_PA_TO_RX2) {
-               struct skge_port *skge = netdev_priv(hw->dev[1]);
                ++skge->net_stats.rx_over_errors;
-               skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX2);
+               skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX1);
        }
 
-       if (status & IS_PA_TO_TX1)
-               skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX1);
-
-       if (status & IS_PA_TO_TX2)
-               skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX2);
 
        if (status & IS_MAC1)
                skge_mac_intr(hw, 0);
 
-       if (status & IS_MAC2)
-               skge_mac_intr(hw, 1);
+       if (hw->dev[1]) {
+               if (status & (IS_XA2_F|IS_R2_F)) {
+                       hw->intr_mask &= ~(IS_XA2_F|IS_R2_F);
+                       netif_rx_schedule(hw->dev[1]);
+               }
+
+               if (status & IS_PA_TO_RX2) {
+                       struct skge_port *skge = netdev_priv(hw->dev[1]);
+                       ++skge->net_stats.rx_over_errors;
+                       skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX2);
+               }
+
+               if (status & IS_PA_TO_TX2)
+                       skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX2);
+
+               if (status & IS_MAC2)
+                       skge_mac_intr(hw, 1);
+       }
 
        if (status & IS_HW_ERR)
                skge_error_irq(hw);
 
        skge_write32(hw, B0_IMSK, hw->intr_mask);
+       skge_read32(hw, B0_IMSK);
+out:
+       spin_unlock(&hw->hw_lock);
 
-       return IRQ_HANDLED;
+       return IRQ_RETVAL(handled);
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2943,7 +3304,7 @@ static void skge_netpoll(struct net_device *dev)
        struct skge_port *skge = netdev_priv(dev);
 
        disable_irq(dev->irq);
-       skge_intr(dev->irq, skge->hw, NULL);
+       skge_intr(dev->irq, skge->hw);
        enable_irq(dev->irq);
 }
 #endif
@@ -2954,24 +3315,35 @@ static int skge_set_mac_address(struct net_device *dev, void *p)
        struct skge_hw *hw = skge->hw;
        unsigned port = skge->port;
        const struct sockaddr *addr = p;
+       u16 ctrl;
 
        if (!is_valid_ether_addr(addr->sa_data))
                return -EADDRNOTAVAIL;
 
-       spin_lock_bh(&hw->phy_lock);
        memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
-       memcpy_toio(hw->regs + B2_MAC_1 + port*8,
-                   dev->dev_addr, ETH_ALEN);
-       memcpy_toio(hw->regs + B2_MAC_2 + port*8,
-                   dev->dev_addr, ETH_ALEN);
 
-       if (hw->chip_id == CHIP_ID_GENESIS)
-               xm_outaddr(hw, port, XM_SA, dev->dev_addr);
-       else {
-               gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr);
-               gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr);
+       if (!netif_running(dev)) {
+               memcpy_toio(hw->regs + B2_MAC_1 + port*8, dev->dev_addr, ETH_ALEN);
+               memcpy_toio(hw->regs + B2_MAC_2 + port*8, dev->dev_addr, ETH_ALEN);
+       } else {
+               /* disable Rx */
+               spin_lock_bh(&hw->phy_lock);
+               ctrl = gma_read16(hw, port, GM_GP_CTRL);
+               gma_write16(hw, port, GM_GP_CTRL, ctrl & ~GM_GPCR_RX_ENA);
+
+               memcpy_toio(hw->regs + B2_MAC_1 + port*8, dev->dev_addr, ETH_ALEN);
+               memcpy_toio(hw->regs + B2_MAC_2 + port*8, dev->dev_addr, ETH_ALEN);
+
+               if (hw->chip_id == CHIP_ID_GENESIS)
+                       xm_outaddr(hw, port, XM_SA, dev->dev_addr);
+               else {
+                       gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr);
+                       gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr);
+               }
+
+               gma_write16(hw, port, GM_GP_CTRL, ctrl);
+               spin_unlock_bh(&hw->phy_lock);
        }
-       spin_unlock_bh(&hw->phy_lock);
 
        return 0;
 }
@@ -3008,7 +3380,7 @@ static int skge_reset(struct skge_hw *hw)
 {
        u32 reg;
        u16 ctst, pci_status;
-       u8 t8, mac_cfg, pmd_type, phy_type;
+       u8 t8, mac_cfg, pmd_type;
        int i;
 
        ctst = skge_read16(hw, B0_CTST);
@@ -3032,19 +3404,22 @@ static int skge_reset(struct skge_hw *hw)
                     ctst & (CS_CLK_RUN_HOT|CS_CLK_RUN_RST|CS_CLK_RUN_ENA));
 
        hw->chip_id = skge_read8(hw, B2_CHIP_ID);
-       phy_type = skge_read8(hw, B2_E_1) & 0xf;
+       hw->phy_type = skge_read8(hw, B2_E_1) & 0xf;
        pmd_type = skge_read8(hw, B2_PMD_TYP);
        hw->copper = (pmd_type == 'T' || pmd_type == '1');
 
        switch (hw->chip_id) {
        case CHIP_ID_GENESIS:
-               switch (phy_type) {
+               switch (hw->phy_type) {
+               case SK_PHY_XMAC:
+                       hw->phy_addr = PHY_ADDR_XMAC;
+                       break;
                case SK_PHY_BCOM:
                        hw->phy_addr = PHY_ADDR_BCOM;
                        break;
                default:
-                       printk(KERN_ERR PFX "%s: unsupported phy type 0x%x\n",
-                              pci_name(hw->pdev), phy_type);
+                       dev_err(&hw->pdev->dev, "unsupported phy type 0x%x\n",
+                              hw->phy_type);
                        return -EOPNOTSUPP;
                }
                break;
@@ -3052,15 +3427,15 @@ static int skge_reset(struct skge_hw *hw)
        case CHIP_ID_YUKON:
        case CHIP_ID_YUKON_LITE:
        case CHIP_ID_YUKON_LP:
-               if (phy_type < SK_PHY_MARV_COPPER && pmd_type != 'S')
+               if (hw->phy_type < SK_PHY_MARV_COPPER && pmd_type != 'S')
                        hw->copper = 1;
 
                hw->phy_addr = PHY_ADDR_MARV;
                break;
 
        default:
-               printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n",
-                      pci_name(hw->pdev), hw->chip_id);
+               dev_err(&hw->pdev->dev, "unsupported chip type 0x%x\n",
+                      hw->chip_id);
                return -EOPNOTSUPP;
        }
 
@@ -3083,9 +3458,11 @@ static int skge_reset(struct skge_hw *hw)
        else
                hw->ram_size = t8 * 4096;
 
-       hw->intr_mask = IS_HW_ERR | IS_EXT_REG | IS_PORT_1;
-       if (hw->ports > 1)
-               hw->intr_mask |= IS_PORT_2;
+       hw->intr_mask = IS_HW_ERR;
+
+       /* Use PHY IRQ for all but fiber based Genesis board */
+       if (!(hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC))
+               hw->intr_mask |= IS_EXT_REG;
 
        if (hw->chip_id == CHIP_ID_GENESIS)
                genesis_init(hw);
@@ -3097,7 +3474,7 @@ static int skge_reset(struct skge_hw *hw)
                /* avoid boards with stuck Hardware error bits */
                if ((skge_read32(hw, B0_ISRC) & IS_HW_ERR) &&
                    (skge_read32(hw, B0_HWE_ISRC) & IS_IRQ_SENSOR)) {
-                       printk(KERN_WARNING PFX "stuck hardware sensor bit\n");
+                       dev_warn(&hw->pdev->dev, "stuck hardware sensor bit\n");
                        hw->intr_mask &= ~IS_HW_ERR;
                }
 
@@ -3151,14 +3528,12 @@ static int skge_reset(struct skge_hw *hw)
 
        skge_write32(hw, B0_IMSK, hw->intr_mask);
 
-       spin_lock_bh(&hw->phy_lock);
        for (i = 0; i < hw->ports; i++) {
                if (hw->chip_id == CHIP_ID_GENESIS)
                        genesis_reset(hw, i);
                else
                        yukon_reset(hw, i);
        }
-       spin_unlock_bh(&hw->phy_lock);
 
        return 0;
 }
@@ -3171,7 +3546,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
        struct net_device *dev = alloc_etherdev(sizeof(*skge));
 
        if (!dev) {
-               printk(KERN_ERR "skge etherdev alloc failed");
+               dev_err(&hw->pdev->dev, "etherdev alloc failed\n");
                return NULL;
        }
 
@@ -3198,7 +3573,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
        dev->poll_controller = skge_netpoll;
 #endif
        dev->irq = hw->pdev->irq;
-       dev->features = NETIF_F_LLTX;
+
        if (highmem)
                dev->features |= NETIF_F_HIGHDMA;
 
@@ -3206,21 +3581,24 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
        skge->netdev = dev;
        skge->hw = hw;
        skge->msg_enable = netif_msg_init(debug, default_msg);
+
        skge->tx_ring.count = DEFAULT_TX_RING_SIZE;
        skge->rx_ring.count = DEFAULT_RX_RING_SIZE;
 
        /* Auto speed and flow control */
        skge->autoneg = AUTONEG_ENABLE;
-       skge->flow_control = FLOW_MODE_SYMMETRIC;
+       skge->flow_control = FLOW_MODE_SYM_OR_REM;
        skge->duplex = -1;
        skge->speed = -1;
        skge->advertising = skge_supported_modes(hw);
+       skge->wol = pci_wake_enabled(hw->pdev) ? wol_supported(hw) : 0;
 
        hw->dev[port] = dev;
 
        skge->port = port;
 
-       spin_lock_init(&skge->tx_lock);
+       /* Only used for Genesis XMAC */
+       setup_timer(&skge->link_timer, xm_link_timer, (unsigned long) skge);
 
        if (hw->chip_id != CHIP_ID_GENESIS) {
                dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
@@ -3258,15 +3636,13 @@ static int __devinit skge_probe(struct pci_dev *pdev,
 
        err = pci_enable_device(pdev);
        if (err) {
-               printk(KERN_ERR PFX "%s cannot enable PCI device\n",
-                      pci_name(pdev));
+               dev_err(&pdev->dev, "cannot enable PCI device\n");
                goto err_out;
        }
 
        err = pci_request_regions(pdev, DRV_NAME);
        if (err) {
-               printk(KERN_ERR PFX "%s cannot obtain PCI resources\n",
-                      pci_name(pdev));
+               dev_err(&pdev->dev, "cannot obtain PCI resources\n");
                goto err_out_disable_pdev;
        }
 
@@ -3281,8 +3657,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
        }
 
        if (err) {
-               printk(KERN_ERR PFX "%s no usable DMA configuration\n",
-                      pci_name(pdev));
+               dev_err(&pdev->dev, "no usable DMA configuration\n");
                goto err_out_free_regions;
        }
 
@@ -3300,48 +3675,49 @@ static int __devinit skge_probe(struct pci_dev *pdev,
        err = -ENOMEM;
        hw = kzalloc(sizeof(*hw), GFP_KERNEL);
        if (!hw) {
-               printk(KERN_ERR PFX "%s: cannot allocate hardware struct\n",
-                      pci_name(pdev));
+               dev_err(&pdev->dev, "cannot allocate hardware struct\n");
                goto err_out_free_regions;
        }
 
        hw->pdev = pdev;
+       spin_lock_init(&hw->hw_lock);
        spin_lock_init(&hw->phy_lock);
-       tasklet_init(&hw->ext_tasklet, skge_extirq, (unsigned long) hw);
+       tasklet_init(&hw->phy_task, &skge_extirq, (unsigned long) hw);
 
        hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
        if (!hw->regs) {
-               printk(KERN_ERR PFX "%s: cannot map device registers\n",
-                      pci_name(pdev));
+               dev_err(&pdev->dev, "cannot map device registers\n");
                goto err_out_free_hw;
        }
 
-       err = request_irq(pdev->irq, skge_intr, SA_SHIRQ, DRV_NAME, hw);
-       if (err) {
-               printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
-                      pci_name(pdev), pdev->irq);
-               goto err_out_iounmap;
-       }
-       pci_set_drvdata(pdev, hw);
-
        err = skge_reset(hw);
        if (err)
-               goto err_out_free_irq;
+               goto err_out_iounmap;
 
-       printk(KERN_INFO PFX DRV_VERSION " addr 0x%lx irq %d chip %s rev %d\n",
-              pci_resource_start(pdev, 0), pdev->irq,
+       printk(KERN_INFO PFX DRV_VERSION " addr 0x%llx irq %d chip %s rev %d\n",
+              (unsigned long long)pci_resource_start(pdev, 0), pdev->irq,
               skge_board_name(hw), hw->chip_rev);
 
-       if ((dev = skge_devinit(hw, 0, using_dac)) == NULL)
+       dev = skge_devinit(hw, 0, using_dac);
+       if (!dev)
                goto err_out_led_off;
 
+       /* Some motherboards are broken and has zero in ROM. */
+       if (!is_valid_ether_addr(dev->dev_addr))
+               dev_warn(&pdev->dev, "bad (zero?) ethernet address in rom\n");
+
        err = register_netdev(dev);
        if (err) {
-               printk(KERN_ERR PFX "%s: cannot register net device\n",
-                      pci_name(pdev));
+               dev_err(&pdev->dev, "cannot register net device\n");
                goto err_out_free_netdev;
        }
 
+       err = request_irq(pdev->irq, skge_intr, IRQF_SHARED, dev->name, hw);
+       if (err) {
+               dev_err(&pdev->dev, "%s: cannot assign irq %d\n",
+                      dev->name, pdev->irq);
+               goto err_out_unregister;
+       }
        skge_show_addr(dev);
 
        if (hw->ports > 1 && (dev1 = skge_devinit(hw, 1, using_dac))) {
@@ -3349,20 +3725,21 @@ static int __devinit skge_probe(struct pci_dev *pdev,
                        skge_show_addr(dev1);
                else {
                        /* Failure to register second port need not be fatal */
-                       printk(KERN_WARNING PFX "register of second port failed\n");
+                       dev_warn(&pdev->dev, "register of second port failed\n");
                        hw->dev[1] = NULL;
                        free_netdev(dev1);
                }
        }
+       pci_set_drvdata(pdev, hw);
 
        return 0;
 
+err_out_unregister:
+       unregister_netdev(dev);
 err_out_free_netdev:
        free_netdev(dev);
 err_out_led_off:
        skge_write16(hw, B0_LED, LED_STAT_OFF);
-err_out_free_irq:
-       free_irq(pdev->irq, hw);
 err_out_iounmap:
        iounmap(hw->regs);
 err_out_free_hw:
@@ -3384,17 +3761,24 @@ static void __devexit skge_remove(struct pci_dev *pdev)
        if (!hw)
                return;
 
+       flush_scheduled_work();
+
        if ((dev1 = hw->dev[1]))
                unregister_netdev(dev1);
        dev0 = hw->dev[0];
        unregister_netdev(dev0);
 
+       tasklet_disable(&hw->phy_task);
+
+       spin_lock_irq(&hw->hw_lock);
+       hw->intr_mask = 0;
        skge_write32(hw, B0_IMSK, 0);
+       skge_read32(hw, B0_IMSK);
+       spin_unlock_irq(&hw->hw_lock);
+
        skge_write16(hw, B0_LED, LED_STAT_OFF);
        skge_write8(hw, B0_CTST, CS_RST_SET);
 
-       tasklet_kill(&hw->ext_tasklet);
-
        free_irq(pdev->irq, hw);
        pci_release_regions(pdev);
        pci_disable_device(pdev);
@@ -3411,28 +3795,26 @@ static void __devexit skge_remove(struct pci_dev *pdev)
 static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct skge_hw *hw  = pci_get_drvdata(pdev);
-       int i, wol = 0;
+       int i, err, wol = 0;
+
+       err = pci_save_state(pdev);
+       if (err)
+               return err;
 
-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < hw->ports; i++) {
                struct net_device *dev = hw->dev[i];
+               struct skge_port *skge = netdev_priv(dev);
 
-               if (dev) {
-                       struct skge_port *skge = netdev_priv(dev);
-                       if (netif_running(dev)) {
-                               netif_carrier_off(dev);
-                               if (skge->wol)
-                                       netif_stop_queue(dev);
-                               else
-                                       skge_down(dev);
-                       }
-                       netif_device_detach(dev);
-                       wol |= skge->wol;
-               }
+               if (netif_running(dev))
+                       skge_down(dev);
+               if (skge->wol)
+                       skge_wol_init(skge);
+
+               wol |= skge->wol;
        }
 
-       pci_save_state(pdev);
+       skge_write32(hw, B0_IMSK, 0);
        pci_enable_wake(pdev, pci_choose_state(pdev, state), wol);
-       pci_disable_device(pdev);
        pci_set_power_state(pdev, pci_choose_state(pdev, state));
 
        return 0;
@@ -3441,26 +3823,63 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
 static int skge_resume(struct pci_dev *pdev)
 {
        struct skge_hw *hw  = pci_get_drvdata(pdev);
-       int i;
+       int i, err;
+
+       err = pci_set_power_state(pdev, PCI_D0);
+       if (err)
+               goto out;
+
+       err = pci_restore_state(pdev);
+       if (err)
+               goto out;
 
-       pci_set_power_state(pdev, PCI_D0);
-       pci_restore_state(pdev);
        pci_enable_wake(pdev, PCI_D0, 0);
 
-       skge_reset(hw);
+       err = skge_reset(hw);
+       if (err)
+               goto out;
 
-       for (i = 0; i < 2; i++) {
+       for (i = 0; i < hw->ports; i++) {
                struct net_device *dev = hw->dev[i];
-               if (dev) {
-                       netif_device_attach(dev);
-                       if (netif_running(dev) && skge_up(dev))
+
+               if (netif_running(dev)) {
+                       err = skge_up(dev);
+
+                       if (err) {
+                               printk(KERN_ERR PFX "%s: could not up: %d\n",
+                                      dev->name, err);
                                dev_close(dev);
+                               goto out;
+                       }
                }
        }
-       return 0;
+out:
+       return err;
 }
 #endif
 
+static void skge_shutdown(struct pci_dev *pdev)
+{
+       struct skge_hw *hw  = pci_get_drvdata(pdev);
+       int i, wol = 0;
+
+       for (i = 0; i < hw->ports; i++) {
+               struct net_device *dev = hw->dev[i];
+               struct skge_port *skge = netdev_priv(dev);
+
+               if (skge->wol)
+                       skge_wol_init(skge);
+               wol |= skge->wol;
+       }
+
+       pci_enable_wake(pdev, PCI_D3hot, wol);
+       pci_enable_wake(pdev, PCI_D3cold, wol);
+
+       pci_disable_device(pdev);
+       pci_set_power_state(pdev, PCI_D3hot);
+
+}
+
 static struct pci_driver skge_driver = {
        .name =         DRV_NAME,
        .id_table =     skge_id_table,
@@ -3470,11 +3889,12 @@ static struct pci_driver skge_driver = {
        .suspend =      skge_suspend,
        .resume =       skge_resume,
 #endif
+       .shutdown =     skge_shutdown,
 };
 
 static int __init skge_init_module(void)
 {
-       return pci_module_init(&skge_driver);
+       return pci_register_driver(&skge_driver);
 }
 
 static void __exit skge_cleanup_module(void)