sky2: fix sky2_link_down copy/paste comment error
[safe/jmp/linux-2.6] / drivers / net / gianfar.c
index 9057a1d..5bf31f1 100644 (file)
@@ -75,6 +75,7 @@
 #include <linux/if_vlan.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
+#include <linux/of_mdio.h>
 #include <linux/of_platform.h>
 #include <linux/ip.h>
 #include <linux/tcp.h>
@@ -93,7 +94,7 @@
 #include <linux/of.h>
 
 #include "gianfar.h"
-#include "gianfar_mii.h"
+#include "fsl_pq_mdio.h"
 
 #define TX_TIMEOUT      (1*HZ)
 #undef BRIEF_GFAR_ERRORS
@@ -140,13 +141,28 @@ static void gfar_halt_nodisable(struct net_device *dev);
 void gfar_start(struct net_device *dev);
 static void gfar_clear_exact_match(struct net_device *dev);
 static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr);
-
-extern const struct ethtool_ops gfar_ethtool_ops;
+static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 
 MODULE_AUTHOR("Freescale Semiconductor, Inc");
 MODULE_DESCRIPTION("Gianfar Ethernet Driver");
 MODULE_LICENSE("GPL");
 
+static const struct net_device_ops gfar_netdev_ops = {
+       .ndo_open = gfar_enet_open,
+       .ndo_start_xmit = gfar_start_xmit,
+       .ndo_stop = gfar_close,
+       .ndo_change_mtu = gfar_change_mtu,
+       .ndo_set_multicast_list = gfar_set_multi,
+       .ndo_tx_timeout = gfar_timeout,
+       .ndo_do_ioctl = gfar_ioctl,
+       .ndo_vlan_rx_register = gfar_vlan_rx_register,
+       .ndo_set_mac_address = eth_mac_addr,
+       .ndo_validate_addr = eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller = gfar_netpoll,
+#endif
+};
+
 /* Returns 1 if incoming frames use an FCB */
 static inline int gfar_uses_fcb(struct gfar_private *priv)
 {
@@ -155,17 +171,16 @@ static inline int gfar_uses_fcb(struct gfar_private *priv)
 
 static int gfar_of_init(struct net_device *dev)
 {
-       struct device_node *phy, *mdio;
-       const unsigned int *id;
        const char *model;
        const char *ctype;
        const void *mac_addr;
-       const phandle *ph;
        u64 addr, size;
        int err = 0;
        struct gfar_private *priv = netdev_priv(dev);
        struct device_node *np = priv->node;
-       char bus_name[MII_BUS_ID_SIZE];
+       const u32 *stash;
+       const u32 *stash_len;
+       const u32 *stash_idx;
 
        if (!np || !of_device_is_available(np))
                return -ENODEV;
@@ -195,6 +210,26 @@ static int gfar_of_init(struct net_device *dev)
                }
        }
 
+       stash = of_get_property(np, "bd-stash", NULL);
+
+       if(stash) {
+               priv->device_flags |= FSL_GIANFAR_DEV_HAS_BD_STASHING;
+               priv->bd_stash_en = 1;
+       }
+
+       stash_len = of_get_property(np, "rx-stash-len", NULL);
+
+       if (stash_len)
+               priv->rx_stash_size = *stash_len;
+
+       stash_idx = of_get_property(np, "rx-stash-idx", NULL);
+
+       if (stash_idx)
+               priv->rx_stash_index = *stash_idx;
+
+       if (stash_len || stash_idx)
+               priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;
+
        mac_addr = of_get_mac_address(np);
        if (mac_addr)
                memcpy(dev->dev_addr, mac_addr, MAC_ADDR_LEN);
@@ -228,66 +263,10 @@ static int gfar_of_init(struct net_device *dev)
        if (of_get_property(np, "fsl,magic-packet", NULL))
                priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
 
-       ph = of_get_property(np, "phy-handle", NULL);
-       if (ph == NULL) {
-               u32 *fixed_link;
-
-               fixed_link = (u32 *)of_get_property(np, "fixed-link", NULL);
-               if (!fixed_link) {
-                       err = -ENODEV;
-                       goto err_out;
-               }
-
-               snprintf(priv->phy_bus_id, BUS_ID_SIZE, PHY_ID_FMT, "0",
-                               fixed_link[0]);
-       } else {
-               phy = of_find_node_by_phandle(*ph);
-
-               if (phy == NULL) {
-                       err = -ENODEV;
-                       goto err_out;
-               }
-
-               mdio = of_get_parent(phy);
-
-               id = of_get_property(phy, "reg", NULL);
-
-               of_node_put(phy);
-               of_node_put(mdio);
-
-               gfar_mdio_bus_name(bus_name, mdio);
-               snprintf(priv->phy_bus_id, BUS_ID_SIZE, "%s:%02x",
-                               bus_name, *id);
-       }
+       priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
 
        /* Find the TBI PHY.  If it's not there, we don't support SGMII */
-       ph = of_get_property(np, "tbi-handle", NULL);
-       if (ph) {
-               struct device_node *tbi = of_find_node_by_phandle(*ph);
-               struct of_device *ofdev;
-               struct mii_bus *bus;
-
-               if (!tbi)
-                       return 0;
-
-               mdio = of_get_parent(tbi);
-               if (!mdio)
-                       return 0;
-
-               ofdev = of_find_device_by_node(mdio);
-
-               of_node_put(mdio);
-
-               id = of_get_property(tbi, "reg", NULL);
-               if (!id)
-                       return 0;
-
-               of_node_put(tbi);
-
-               bus = dev_get_drvdata(&ofdev->dev);
-
-               priv->tbiphy = bus->phy_map[*id];
-       }
+       priv->tbi_node = of_parse_phandle(np, "tbi-handle", 0);
 
        return 0;
 
@@ -296,6 +275,20 @@ err_out:
        return err;
 }
 
+/* Ioctl MII Interface */
+static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+       struct gfar_private *priv = netdev_priv(dev);
+
+       if (!netif_running(dev))
+               return -EINVAL;
+
+       if (!priv->phydev)
+               return -ENODEV;
+
+       return phy_mii_ioctl(priv->phydev, if_mii(rq), cmd);
+}
+
 /* Set up the ethernet device structure, private data,
  * and anything else we need before we start */
 static int gfar_probe(struct of_device *ofdev,
@@ -305,7 +298,7 @@ static int gfar_probe(struct of_device *ofdev,
        struct net_device *dev = NULL;
        struct gfar_private *priv = NULL;
        int err = 0;
-       DECLARE_MAC_BUF(mac);
+       int len_devname;
 
        /* Create an ethernet device instance */
        dev = alloc_etherdev(sizeof (*priv));
@@ -314,8 +307,10 @@ static int gfar_probe(struct of_device *ofdev,
                return -ENOMEM;
 
        priv = netdev_priv(dev);
-       priv->dev = dev;
+       priv->ndev = dev;
+       priv->ofdev = ofdev;
        priv->node = ofdev->node;
+       SET_NETDEV_DEV(dev, &ofdev->dev);
 
        err = gfar_of_init(dev);
 
@@ -336,6 +331,9 @@ static int gfar_probe(struct of_device *ofdev,
        /* Reset MAC layer */
        gfar_write(&priv->regs->maccfg1, MACCFG1_SOFT_RESET);
 
+       /* We need to delay at least 3 TX clocks */
+       udelay(2);
+
        tempval = (MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
        gfar_write(&priv->regs->maccfg1, tempval);
 
@@ -351,34 +349,23 @@ static int gfar_probe(struct of_device *ofdev,
        SET_NETDEV_DEV(dev, &ofdev->dev);
 
        /* Fill in the dev structure */
-       dev->open = gfar_enet_open;
-       dev->hard_start_xmit = gfar_start_xmit;
-       dev->tx_timeout = gfar_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
        netif_napi_add(dev, &priv->napi, gfar_poll, GFAR_DEV_WEIGHT);
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       dev->poll_controller = gfar_netpoll;
-#endif
-       dev->stop = gfar_close;
-       dev->change_mtu = gfar_change_mtu;
        dev->mtu = 1500;
-       dev->set_multicast_list = gfar_set_multi;
 
+       dev->netdev_ops = &gfar_netdev_ops;
        dev->ethtool_ops = &gfar_ethtool_ops;
 
        if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
                priv->rx_csum_enable = 1;
-               dev->features |= NETIF_F_IP_CSUM;
+               dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA;
        } else
                priv->rx_csum_enable = 0;
 
        priv->vlgrp = NULL;
 
-       if (priv->device_flags & FSL_GIANFAR_DEV_HAS_VLAN) {
-               dev->vlan_rx_register = gfar_vlan_rx_register;
-
+       if (priv->device_flags & FSL_GIANFAR_DEV_HAS_VLAN)
                dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
-       }
 
        if (priv->device_flags & FSL_GIANFAR_DEV_HAS_EXTENDED_HASH) {
                priv->extended_hash = 1;
@@ -406,7 +393,7 @@ static int gfar_probe(struct of_device *ofdev,
                priv->hash_width = 8;
 
                priv->hash_regs[0] = &priv->regs->gaddr0;
-                priv->hash_regs[1] = &priv->regs->gaddr1;
+               priv->hash_regs[1] = &priv->regs->gaddr1;
                priv->hash_regs[2] = &priv->regs->gaddr2;
                priv->hash_regs[3] = &priv->regs->gaddr3;
                priv->hash_regs[4] = &priv->regs->gaddr4;
@@ -426,6 +413,7 @@ static int gfar_probe(struct of_device *ofdev,
        priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE;
        priv->tx_ring_size = DEFAULT_TX_RING_SIZE;
        priv->rx_ring_size = DEFAULT_RX_RING_SIZE;
+       priv->num_txbdfree = DEFAULT_TX_RING_SIZE;
 
        priv->txcoalescing = DEFAULT_TX_COALESCE;
        priv->txic = DEFAULT_TXIC;
@@ -446,6 +434,26 @@ static int gfar_probe(struct of_device *ofdev,
                goto register_fail;
        }
 
+       device_init_wakeup(&dev->dev,
+               priv->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
+
+       /* fill out IRQ number and name fields */
+       len_devname = strlen(dev->name);
+       strncpy(&priv->int_name_tx[0], dev->name, len_devname);
+       if (priv->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
+               strncpy(&priv->int_name_tx[len_devname],
+                       "_tx", sizeof("_tx") + 1);
+
+               strncpy(&priv->int_name_rx[0], dev->name, len_devname);
+               strncpy(&priv->int_name_rx[len_devname],
+                       "_rx", sizeof("_rx") + 1);
+
+               strncpy(&priv->int_name_er[0], dev->name, len_devname);
+               strncpy(&priv->int_name_er[len_devname],
+                       "_er", sizeof("_er") + 1);
+       } else
+               priv->int_name_tx[len_devname] = '\0';
+
        /* Create all the sysfs files */
        gfar_init_sysfs(dev);
 
@@ -463,6 +471,10 @@ static int gfar_probe(struct of_device *ofdev,
 register_fail:
        iounmap(priv->regs);
 regs_fail:
+       if (priv->phy_node)
+               of_node_put(priv->phy_node);
+       if (priv->tbi_node)
+               of_node_put(priv->tbi_node);
        free_netdev(dev);
        return err;
 }
@@ -471,10 +483,16 @@ static int gfar_remove(struct of_device *ofdev)
 {
        struct gfar_private *priv = dev_get_drvdata(&ofdev->dev);
 
+       if (priv->phy_node)
+               of_node_put(priv->phy_node);
+       if (priv->tbi_node)
+               of_node_put(priv->tbi_node);
+
        dev_set_drvdata(&ofdev->dev, NULL);
 
+       unregister_netdev(priv->ndev);
        iounmap(priv->regs);
-       free_netdev(priv->dev);
+       free_netdev(priv->ndev);
 
        return 0;
 }
@@ -483,7 +501,7 @@ static int gfar_remove(struct of_device *ofdev)
 static int gfar_suspend(struct of_device *ofdev, pm_message_t state)
 {
        struct gfar_private *priv = dev_get_drvdata(&ofdev->dev);
-       struct net_device *dev = priv->dev;
+       struct net_device *dev = priv->ndev;
        unsigned long flags;
        u32 tempval;
 
@@ -532,7 +550,7 @@ static int gfar_suspend(struct of_device *ofdev, pm_message_t state)
 static int gfar_resume(struct of_device *ofdev)
 {
        struct gfar_private *priv = dev_get_drvdata(&ofdev->dev);
-       struct net_device *dev = priv->dev;
+       struct net_device *dev = priv->ndev;
        unsigned long flags;
        u32 tempval;
        int magic_packet = priv->wol_en &&
@@ -624,7 +642,6 @@ static int init_phy(struct net_device *dev)
        uint gigabit_support =
                priv->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
                SUPPORTED_1000baseT_Full : 0;
-       struct phy_device *phydev;
        phy_interface_t interface;
 
        priv->oldlink = 0;
@@ -633,21 +650,22 @@ static int init_phy(struct net_device *dev)
 
        interface = gfar_get_interface(dev);
 
-       phydev = phy_connect(dev, priv->phy_bus_id, &adjust_link, 0, interface);
+       priv->phydev = of_phy_connect(dev, priv->phy_node, &adjust_link, 0,
+                                     interface);
+       if (!priv->phydev)
+               priv->phydev = of_phy_connect_fixed_link(dev, &adjust_link,
+                                                        interface);
+       if (!priv->phydev) {
+               dev_err(&dev->dev, "could not attach to PHY\n");
+               return -ENODEV;
+       }
 
        if (interface == PHY_INTERFACE_MODE_SGMII)
                gfar_configure_serdes(dev);
 
-       if (IS_ERR(phydev)) {
-               printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
-               return PTR_ERR(phydev);
-       }
-
        /* Remove any features not supported by the controller */
-       phydev->supported &= (GFAR_SUPPORTED | gigabit_support);
-       phydev->advertising = phydev->supported;
-
-       priv->phydev = phydev;
+       priv->phydev->supported &= (GFAR_SUPPORTED | gigabit_support);
+       priv->phydev->advertising = priv->phydev->supported;
 
        return 0;
 }
@@ -664,10 +682,17 @@ static int init_phy(struct net_device *dev)
 static void gfar_configure_serdes(struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
+       struct phy_device *tbiphy;
+
+       if (!priv->tbi_node) {
+               dev_warn(&dev->dev, "error: SGMII mode requires that the "
+                                   "device tree specify a tbi-handle\n");
+               return;
+       }
 
-       if (!priv->tbiphy) {
-               printk(KERN_WARNING "SGMII mode requires that the device "
-                               "tree specify a tbi-handle\n");
+       tbiphy = of_phy_find_device(priv->tbi_node);
+       if (!tbiphy) {
+               dev_err(&dev->dev, "error: Could not get TBI device\n");
                return;
        }
 
@@ -677,17 +702,17 @@ static void gfar_configure_serdes(struct net_device *dev)
         * everything for us?  Resetting it takes the link down and requires
         * several seconds for it to come back.
         */
-       if (phy_read(priv->tbiphy, MII_BMSR) & BMSR_LSTATUS)
+       if (phy_read(tbiphy, MII_BMSR) & BMSR_LSTATUS)
                return;
 
        /* Single clk mode, mii mode off(for serdes communication) */
-       phy_write(priv->tbiphy, MII_TBICON, TBICON_CLK_SELECT);
+       phy_write(tbiphy, MII_TBICON, TBICON_CLK_SELECT);
 
-       phy_write(priv->tbiphy, MII_ADVERTISE,
+       phy_write(tbiphy, MII_ADVERTISE,
                        ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE |
                        ADVERTISE_1000XPSE_ASYM);
 
-       phy_write(priv->tbiphy, MII_BMCR, BMCR_ANENABLE |
+       phy_write(tbiphy, MII_BMCR, BMCR_ANENABLE |
                        BMCR_ANRESTART | BMCR_FULLDPLX | BMCR_SPEED1000);
 }
 
@@ -801,12 +826,12 @@ void stop_gfar(struct net_device *dev)
                free_irq(priv->interruptTransmit, dev);
                free_irq(priv->interruptReceive, dev);
        } else {
-               free_irq(priv->interruptTransmit, dev);
+               free_irq(priv->interruptTransmit, dev);
        }
 
        free_skb_resources(priv);
 
-       dma_free_coherent(&dev->dev,
+       dma_free_coherent(&priv->ofdev->dev,
                        sizeof(struct txbd8)*priv->tx_ring_size
                        + sizeof(struct rxbd8)*priv->rx_ring_size,
                        priv->tx_bd_base,
@@ -819,22 +844,26 @@ static void free_skb_resources(struct gfar_private *priv)
 {
        struct rxbd8 *rxbdp;
        struct txbd8 *txbdp;
-       int i;
+       int i, j;
 
        /* Go through all the buffer descriptors and free their data buffers */
        txbdp = priv->tx_bd_base;
 
        for (i = 0; i < priv->tx_ring_size; i++) {
-
-               if (priv->tx_skbuff[i]) {
-                       dma_unmap_single(&priv->dev->dev, txbdp->bufPtr,
-                                       txbdp->length,
-                                       DMA_TO_DEVICE);
-                       dev_kfree_skb_any(priv->tx_skbuff[i]);
-                       priv->tx_skbuff[i] = NULL;
+               if (!priv->tx_skbuff[i])
+                       continue;
+
+               dma_unmap_single(&priv->ofdev->dev, txbdp->bufPtr,
+                               txbdp->length, DMA_TO_DEVICE);
+               txbdp->lstatus = 0;
+               for (j = 0; j < skb_shinfo(priv->tx_skbuff[i])->nr_frags; j++) {
+                       txbdp++;
+                       dma_unmap_page(&priv->ofdev->dev, txbdp->bufPtr,
+                                       txbdp->length, DMA_TO_DEVICE);
                }
-
                txbdp++;
+               dev_kfree_skb_any(priv->tx_skbuff[i]);
+               priv->tx_skbuff[i] = NULL;
        }
 
        kfree(priv->tx_skbuff);
@@ -846,7 +875,7 @@ static void free_skb_resources(struct gfar_private *priv)
        if(priv->rx_skbuff != NULL) {
                for (i = 0; i < priv->rx_ring_size; i++) {
                        if (priv->rx_skbuff[i]) {
-                               dma_unmap_single(&priv->dev->dev, rxbdp->bufPtr,
+                               dma_unmap_single(&priv->ofdev->dev, rxbdp->bufPtr,
                                                priv->rx_buffer_size,
                                                DMA_FROM_DEVICE);
 
@@ -854,8 +883,7 @@ static void free_skb_resources(struct gfar_private *priv)
                                priv->rx_skbuff[i] = NULL;
                        }
 
-                       rxbdp->status = 0;
-                       rxbdp->length = 0;
+                       rxbdp->lstatus = 0;
                        rxbdp->bufPtr = 0;
 
                        rxbdp++;
@@ -908,12 +936,13 @@ int startup_gfar(struct net_device *dev)
        struct gfar __iomem *regs = priv->regs;
        int err = 0;
        u32 rctrl = 0;
+       u32 tctrl = 0;
        u32 attrs = 0;
 
        gfar_write(&regs->imask, IMASK_INIT_CLEAR);
 
        /* Allocate memory for the buffer descriptors */
-       vaddr = (unsigned long) dma_alloc_coherent(&dev->dev,
+       vaddr = (unsigned long) dma_alloc_coherent(&priv->ofdev->dev,
                        sizeof (struct txbd8) * priv->tx_ring_size +
                        sizeof (struct rxbd8) * priv->rx_ring_size,
                        &addr, GFP_KERNEL);
@@ -968,6 +997,7 @@ int startup_gfar(struct net_device *dev)
                priv->rx_skbuff[i] = NULL;
 
        /* Initialize some variables in our dev structure */
+       priv->num_txbdfree = priv->tx_ring_size;
        priv->dirty_tx = priv->cur_tx = priv->tx_bd_base;
        priv->cur_rx = priv->rx_bd_base;
        priv->skb_curtx = priv->skb_dirtytx = 0;
@@ -976,8 +1006,7 @@ int startup_gfar(struct net_device *dev)
        /* Initialize Transmit Descriptor Ring */
        txbdp = priv->tx_bd_base;
        for (i = 0; i < priv->tx_ring_size; i++) {
-               txbdp->status = 0;
-               txbdp->length = 0;
+               txbdp->lstatus = 0;
                txbdp->bufPtr = 0;
                txbdp++;
        }
@@ -1016,7 +1045,7 @@ int startup_gfar(struct net_device *dev)
                /* Install our interrupt handlers for Error,
                 * Transmit, and Receive */
                if (request_irq(priv->interruptError, gfar_error,
-                               0, "enet_error", dev) < 0) {
+                               0, priv->int_name_er, dev) < 0) {
                        if (netif_msg_intr(priv))
                                printk(KERN_ERR "%s: Can't get IRQ %d\n",
                                        dev->name, priv->interruptError);
@@ -1026,7 +1055,7 @@ int startup_gfar(struct net_device *dev)
                }
 
                if (request_irq(priv->interruptTransmit, gfar_transmit,
-                               0, "enet_tx", dev) < 0) {
+                               0, priv->int_name_tx, dev) < 0) {
                        if (netif_msg_intr(priv))
                                printk(KERN_ERR "%s: Can't get IRQ %d\n",
                                        dev->name, priv->interruptTransmit);
@@ -1037,7 +1066,7 @@ int startup_gfar(struct net_device *dev)
                }
 
                if (request_irq(priv->interruptReceive, gfar_receive,
-                               0, "enet_rx", dev) < 0) {
+                               0, priv->int_name_rx, dev) < 0) {
                        if (netif_msg_intr(priv))
                                printk(KERN_ERR "%s: Can't get IRQ %d (receive0)\n",
                                                dev->name, priv->interruptReceive);
@@ -1047,10 +1076,10 @@ int startup_gfar(struct net_device *dev)
                }
        } else {
                if (request_irq(priv->interruptTransmit, gfar_interrupt,
-                               0, "gfar_interrupt", dev) < 0) {
+                               0, priv->int_name_tx, dev) < 0) {
                        if (netif_msg_intr(priv))
                                printk(KERN_ERR "%s: Can't get IRQ %d\n",
-                                       dev->name, priv->interruptError);
+                                       dev->name, priv->interruptTransmit);
 
                        err = -1;
                        goto err_irq_fail;
@@ -1083,11 +1112,19 @@ int startup_gfar(struct net_device *dev)
                rctrl |= RCTRL_PADDING(priv->padding);
        }
 
+       /* keep vlan related bits if it's enabled */
+       if (priv->vlgrp) {
+               rctrl |= RCTRL_VLEX | RCTRL_PRSDEP_INIT;
+               tctrl |= TCTRL_VLINS;
+       }
+
        /* Init rctrl based on our settings */
        gfar_write(&priv->regs->rctrl, rctrl);
 
        if (dev->features & NETIF_F_IP_CSUM)
-               gfar_write(&priv->regs->tctrl, TCTRL_INIT_CSUM);
+               tctrl |= TCTRL_INIT_CSUM;
+
+       gfar_write(&priv->regs->tctrl, tctrl);
 
        /* Set the extraction length and index */
        attrs = ATTRELI_EL(priv->rx_stash_size) |
@@ -1125,7 +1162,7 @@ err_rxalloc_fail:
 rx_skb_fail:
        free_skb_resources(priv);
 tx_skb_fail:
-       dma_free_coherent(&dev->dev,
+       dma_free_coherent(&priv->ofdev->dev,
                        sizeof(struct txbd8)*priv->tx_ring_size
                        + sizeof(struct rxbd8)*priv->rx_ring_size,
                        priv->tx_bd_base,
@@ -1143,6 +1180,8 @@ static int gfar_enet_open(struct net_device *dev)
 
        napi_enable(&priv->napi);
 
+       skb_queue_head_init(&priv->rx_recycle);
+
        /* Initialize a bunch of registers */
        init_registers(dev);
 
@@ -1163,12 +1202,14 @@ static int gfar_enet_open(struct net_device *dev)
 
        netif_start_queue(dev);
 
+       device_set_wakeup_enable(&dev->dev, priv->wol_en);
+
        return err;
 }
 
-static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb, struct txbd8 *bdp)
+static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
 {
-       struct txfcb *fcb = (struct txfcb *)skb_push (skb, GMAC_FCB_LEN);
+       struct txfcb *fcb = (struct txfcb *)skb_push(skb, GMAC_FCB_LEN);
 
        memset(fcb, 0, GMAC_FCB_LEN);
 
@@ -1209,101 +1250,163 @@ void inline gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb)
        fcb->vlctl = vlan_tx_tag_get(skb);
 }
 
+static inline struct txbd8 *skip_txbd(struct txbd8 *bdp, int stride,
+                              struct txbd8 *base, int ring_size)
+{
+       struct txbd8 *new_bd = bdp + stride;
+
+       return (new_bd >= (base + ring_size)) ? (new_bd - ring_size) : new_bd;
+}
+
+static inline struct txbd8 *next_txbd(struct txbd8 *bdp, struct txbd8 *base,
+               int ring_size)
+{
+       return skip_txbd(bdp, 1, base, ring_size);
+}
+
 /* This is called by the kernel when a frame is ready for transmission. */
 /* It is pointed to by the dev->hard_start_xmit function pointer */
 static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
        struct txfcb *fcb = NULL;
-       struct txbd8 *txbdp;
-       u16 status;
+       struct txbd8 *txbdp, *txbdp_start, *base;
+       u32 lstatus;
+       int i;
+       u32 bufaddr;
        unsigned long flags;
+       unsigned int nr_frags, length;
+
+       base = priv->tx_bd_base;
+
+       /* make space for additional header when fcb is needed */
+       if (((skb->ip_summed == CHECKSUM_PARTIAL) ||
+                       (priv->vlgrp && vlan_tx_tag_present(skb))) &&
+                       (skb_headroom(skb) < GMAC_FCB_LEN)) {
+               struct sk_buff *skb_new;
+
+               skb_new = skb_realloc_headroom(skb, GMAC_FCB_LEN);
+               if (!skb_new) {
+                       dev->stats.tx_errors++;
+                       kfree_skb(skb);
+                       return NETDEV_TX_OK;
+               }
+               kfree_skb(skb);
+               skb = skb_new;
+       }
+
+       /* total number of fragments in the SKB */
+       nr_frags = skb_shinfo(skb)->nr_frags;
+
+       spin_lock_irqsave(&priv->txlock, flags);
+
+       /* check if there is space to queue this packet */
+       if ((nr_frags+1) > priv->num_txbdfree) {
+               /* no space, stop the queue */
+               netif_stop_queue(dev);
+               dev->stats.tx_fifo_errors++;
+               spin_unlock_irqrestore(&priv->txlock, flags);
+               return NETDEV_TX_BUSY;
+       }
 
        /* Update transmit stats */
        dev->stats.tx_bytes += skb->len;
 
-       /* Lock priv now */
-       spin_lock_irqsave(&priv->txlock, flags);
+       txbdp = txbdp_start = priv->cur_tx;
+
+       if (nr_frags == 0) {
+               lstatus = txbdp->lstatus | BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT);
+       } else {
+               /* Place the fragment addresses and lengths into the TxBDs */
+               for (i = 0; i < nr_frags; i++) {
+                       /* Point at the next BD, wrapping as needed */
+                       txbdp = next_txbd(txbdp, base, priv->tx_ring_size);
+
+                       length = skb_shinfo(skb)->frags[i].size;
+
+                       lstatus = txbdp->lstatus | length |
+                               BD_LFLAG(TXBD_READY);
+
+                       /* Handle the last BD specially */
+                       if (i == nr_frags - 1)
+                               lstatus |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT);
+
+                       bufaddr = dma_map_page(&priv->ofdev->dev,
+                                       skb_shinfo(skb)->frags[i].page,
+                                       skb_shinfo(skb)->frags[i].page_offset,
+                                       length,
+                                       DMA_TO_DEVICE);
 
-       /* Point at the first free tx descriptor */
-       txbdp = priv->cur_tx;
+                       /* set the TxBD length and buffer pointer */
+                       txbdp->bufPtr = bufaddr;
+                       txbdp->lstatus = lstatus;
+               }
 
-       /* Clear all but the WRAP status flags */
-       status = txbdp->status & TXBD_WRAP;
+               lstatus = txbdp_start->lstatus;
+       }
 
        /* Set up checksumming */
        if (CHECKSUM_PARTIAL == skb->ip_summed) {
-               fcb = gfar_add_fcb(skb, txbdp);
-               status |= TXBD_TOE;
+               fcb = gfar_add_fcb(skb);
+               lstatus |= BD_LFLAG(TXBD_TOE);
                gfar_tx_checksum(skb, fcb);
        }
 
        if (priv->vlgrp && vlan_tx_tag_present(skb)) {
                if (unlikely(NULL == fcb)) {
-                       fcb = gfar_add_fcb(skb, txbdp);
-                       status |= TXBD_TOE;
+                       fcb = gfar_add_fcb(skb);
+                       lstatus |= BD_LFLAG(TXBD_TOE);
                }
 
                gfar_tx_vlan(skb, fcb);
        }
 
-       /* Set buffer length and pointer */
-       txbdp->length = skb->len;
-       txbdp->bufPtr = dma_map_single(&dev->dev, skb->data,
-                       skb->len, DMA_TO_DEVICE);
-
-       /* Save the skb pointer so we can free it later */
+       /* setup the TxBD length and buffer pointer for the first BD */
        priv->tx_skbuff[priv->skb_curtx] = skb;
+       txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data,
+                       skb_headlen(skb), DMA_TO_DEVICE);
 
-       /* Update the current skb pointer (wrapping if this was the last) */
-       priv->skb_curtx =
-           (priv->skb_curtx + 1) & TX_RING_MOD_MASK(priv->tx_ring_size);
-
-       /* Flag the BD as interrupt-causing */
-       status |= TXBD_INTERRUPT;
-
-       /* Flag the BD as ready to go, last in frame, and  */
-       /* in need of CRC */
-       status |= (TXBD_READY | TXBD_LAST | TXBD_CRC);
-
-       dev->trans_start = jiffies;
+       lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb);
 
-       /* The powerpc-specific eieio() is used, as wmb() has too strong
+       /*
+        * The powerpc-specific eieio() is used, as wmb() has too strong
         * semantics (it requires synchronization between cacheable and
         * uncacheable mappings, which eieio doesn't provide and which we
         * don't need), thus requiring a more expensive sync instruction.  At
         * some point, the set of architecture-independent barrier functions
         * should be expanded to include weaker barriers.
         */
-
        eieio();
-       txbdp->status = status;
 
-       /* If this was the last BD in the ring, the next one */
-       /* is at the beginning of the ring */
-       if (txbdp->status & TXBD_WRAP)
-               txbdp = priv->tx_bd_base;
-       else
-               txbdp++;
+       txbdp_start->lstatus = lstatus;
+
+       /* Update the current skb pointer to the next entry we will use
+        * (wrapping if necessary) */
+       priv->skb_curtx = (priv->skb_curtx + 1) &
+               TX_RING_MOD_MASK(priv->tx_ring_size);
+
+       priv->cur_tx = next_txbd(txbdp, base, priv->tx_ring_size);
+
+       /* reduce TxBD free count */
+       priv->num_txbdfree -= (nr_frags + 1);
+
+       dev->trans_start = jiffies;
 
        /* If the next BD still needs to be cleaned up, then the bds
           are full.  We need to tell the kernel to stop sending us stuff. */
-       if (txbdp == priv->dirty_tx) {
+       if (!priv->num_txbdfree) {
                netif_stop_queue(dev);
 
                dev->stats.tx_fifo_errors++;
        }
 
-       /* Update the current txbd to the next one */
-       priv->cur_tx = txbdp;
-
        /* Tell the DMA to go go go */
        gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT);
 
        /* Unlock priv */
        spin_unlock_irqrestore(&priv->txlock, flags);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /* Stops the kernel queue, and halts the controller */
@@ -1313,6 +1416,7 @@ static int gfar_close(struct net_device *dev)
 
        napi_disable(&priv->napi);
 
+       skb_queue_purge(&priv->rx_recycle);
        cancel_work_sync(&priv->reset_task);
        stop_gfar(dev);
 
@@ -1340,15 +1444,11 @@ static void gfar_vlan_rx_register(struct net_device *dev,
 {
        struct gfar_private *priv = netdev_priv(dev);
        unsigned long flags;
-       struct vlan_group *old_grp;
        u32 tempval;
 
        spin_lock_irqsave(&priv->rxlock, flags);
 
-       old_grp = priv->vlgrp;
-
-       if (old_grp == grp)
-               return;
+       priv->vlgrp = grp;
 
        if (grp) {
                /* Enable VLAN tag insertion */
@@ -1359,7 +1459,6 @@ static void gfar_vlan_rx_register(struct net_device *dev,
 
                /* Enable VLAN tag extraction */
                tempval = gfar_read(&priv->regs->rctrl);
-               tempval |= RCTRL_VLEX;
                tempval |= (RCTRL_VLEX | RCTRL_PRSDEP_INIT);
                gfar_write(&priv->regs->rctrl, tempval);
        } else {
@@ -1449,11 +1548,13 @@ static void gfar_reset_task(struct work_struct *work)
 {
        struct gfar_private *priv = container_of(work, struct gfar_private,
                        reset_task);
-       struct net_device *dev = priv->dev;
+       struct net_device *dev = priv->ndev;
 
        if (dev->flags & IFF_UP) {
+               netif_stop_queue(dev);
                stop_gfar(dev);
                startup_gfar(dev);
+               netif_start_queue(dev);
        }
 
        netif_tx_schedule_all(dev);
@@ -1470,82 +1571,109 @@ static void gfar_timeout(struct net_device *dev)
 /* Interrupt Handler for Transmit complete */
 static int gfar_clean_tx_ring(struct net_device *dev)
 {
-       struct txbd8 *bdp;
        struct gfar_private *priv = netdev_priv(dev);
+       struct txbd8 *bdp;
+       struct txbd8 *lbdp = NULL;
+       struct txbd8 *base = priv->tx_bd_base;
+       struct sk_buff *skb;
+       int skb_dirtytx;
+       int tx_ring_size = priv->tx_ring_size;
+       int frags = 0;
+       int i;
        int howmany = 0;
+       u32 lstatus;
 
        bdp = priv->dirty_tx;
-       while ((bdp->status & TXBD_READY) == 0) {
-               /* If dirty_tx and cur_tx are the same, then either the */
-               /* ring is empty or full now (it could only be full in the beginning, */
-               /* obviously).  If it is empty, we are done. */
-               if ((bdp == priv->cur_tx) && (netif_queue_stopped(dev) == 0))
-                       break;
+       skb_dirtytx = priv->skb_dirtytx;
 
-               howmany++;
+       while ((skb = priv->tx_skbuff[skb_dirtytx])) {
+               frags = skb_shinfo(skb)->nr_frags;
+               lbdp = skip_txbd(bdp, frags, base, tx_ring_size);
 
-               /* Deferred means some collisions occurred during transmit, */
-               /* but we eventually sent the packet. */
-               if (bdp->status & TXBD_DEF)
-                       dev->stats.collisions++;
+               lstatus = lbdp->lstatus;
 
-               /* Unmap the DMA memory */
-               dma_unmap_single(&priv->dev->dev, bdp->bufPtr,
-                               bdp->length, DMA_TO_DEVICE);
+               /* Only clean completed frames */
+               if ((lstatus & BD_LFLAG(TXBD_READY)) &&
+                               (lstatus & BD_LENGTH_MASK))
+                       break;
 
-               /* Free the sk buffer associated with this TxBD */
-               dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]);
+               dma_unmap_single(&priv->ofdev->dev,
+                               bdp->bufPtr,
+                               bdp->length,
+                               DMA_TO_DEVICE);
 
-               priv->tx_skbuff[priv->skb_dirtytx] = NULL;
-               priv->skb_dirtytx =
-                   (priv->skb_dirtytx +
-                    1) & TX_RING_MOD_MASK(priv->tx_ring_size);
+               bdp->lstatus &= BD_LFLAG(TXBD_WRAP);
+               bdp = next_txbd(bdp, base, tx_ring_size);
 
-               /* Clean BD length for empty detection */
-               bdp->length = 0;
+               for (i = 0; i < frags; i++) {
+                       dma_unmap_page(&priv->ofdev->dev,
+                                       bdp->bufPtr,
+                                       bdp->length,
+                                       DMA_TO_DEVICE);
+                       bdp->lstatus &= BD_LFLAG(TXBD_WRAP);
+                       bdp = next_txbd(bdp, base, tx_ring_size);
+               }
 
-               /* update bdp to point at next bd in the ring (wrapping if necessary) */
-               if (bdp->status & TXBD_WRAP)
-                       bdp = priv->tx_bd_base;
+               /*
+                * If there's room in the queue (limit it to rx_buffer_size)
+                * we add this skb back into the pool, if it's the right size
+                */
+               if (skb_queue_len(&priv->rx_recycle) < priv->rx_ring_size &&
+                               skb_recycle_check(skb, priv->rx_buffer_size +
+                                       RXBUF_ALIGNMENT))
+                       __skb_queue_head(&priv->rx_recycle, skb);
                else
-                       bdp++;
+                       dev_kfree_skb_any(skb);
 
-               /* Move dirty_tx to be the next bd */
-               priv->dirty_tx = bdp;
+               priv->tx_skbuff[skb_dirtytx] = NULL;
 
-               /* We freed a buffer, so now we can restart transmission */
-               if (netif_queue_stopped(dev))
-                       netif_wake_queue(dev);
-       } /* while ((bdp->status & TXBD_READY) == 0) */
+               skb_dirtytx = (skb_dirtytx + 1) &
+                       TX_RING_MOD_MASK(tx_ring_size);
+
+               howmany++;
+               priv->num_txbdfree += frags + 1;
+       }
+
+       /* If we freed a buffer, we can restart transmission, if necessary */
+       if (netif_queue_stopped(dev) && priv->num_txbdfree)
+               netif_wake_queue(dev);
+
+       /* Update dirty indicators */
+       priv->skb_dirtytx = skb_dirtytx;
+       priv->dirty_tx = bdp;
 
        dev->stats.tx_packets += howmany;
 
        return howmany;
 }
 
-/* Interrupt Handler for Transmit complete */
-static irqreturn_t gfar_transmit(int irq, void *dev_id)
+static void gfar_schedule_cleanup(struct net_device *dev)
 {
-       struct net_device *dev = (struct net_device *) dev_id;
        struct gfar_private *priv = netdev_priv(dev);
+       unsigned long flags;
 
-       /* Clear IEVENT */
-       gfar_write(&priv->regs->ievent, IEVENT_TX_MASK);
-
-       /* Lock priv */
-       spin_lock(&priv->txlock);
-
-       gfar_clean_tx_ring(dev);
+       spin_lock_irqsave(&priv->txlock, flags);
+       spin_lock(&priv->rxlock);
 
-       /* If we are coalescing the interrupts, reset the timer */
-       /* Otherwise, clear it */
-       if (likely(priv->txcoalescing)) {
-               gfar_write(&priv->regs->txic, 0);
-               gfar_write(&priv->regs->txic, priv->txic);
+       if (napi_schedule_prep(&priv->napi)) {
+               gfar_write(&priv->regs->imask, IMASK_RTX_DISABLED);
+               __napi_schedule(&priv->napi);
+       } else {
+               /*
+                * Clear IEVENT, so interrupts aren't called again
+                * because of the packets that have already arrived.
+                */
+               gfar_write(&priv->regs->ievent, IEVENT_RTX_MASK);
        }
 
-       spin_unlock(&priv->txlock);
+       spin_unlock(&priv->rxlock);
+       spin_unlock_irqrestore(&priv->txlock, flags);
+}
 
+/* Interrupt Handler for Transmit complete */
+static irqreturn_t gfar_transmit(int irq, void *dev_id)
+{
+       gfar_schedule_cleanup((struct net_device *)dev_id);
        return IRQ_HANDLED;
 }
 
@@ -1553,20 +1681,19 @@ static void gfar_new_rxbdp(struct net_device *dev, struct rxbd8 *bdp,
                struct sk_buff *skb)
 {
        struct gfar_private *priv = netdev_priv(dev);
-       u32 * status_len = (u32 *)bdp;
-       u16 flags;
+       u32 lstatus;
 
-       bdp->bufPtr = dma_map_single(&dev->dev, skb->data,
+       bdp->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data,
                        priv->rx_buffer_size, DMA_FROM_DEVICE);
 
-       flags = RXBD_EMPTY | RXBD_INTERRUPT;
+       lstatus = BD_LFLAG(RXBD_EMPTY | RXBD_INTERRUPT);
 
        if (bdp == priv->rx_bd_base + priv->rx_ring_size - 1)
-               flags |= RXBD_WRAP;
+               lstatus |= BD_LFLAG(RXBD_WRAP);
 
        eieio();
 
-       *status_len = (u32)flags << 16;
+       bdp->lstatus = lstatus;
 }
 
 
@@ -1576,8 +1703,10 @@ struct sk_buff * gfar_new_skb(struct net_device *dev)
        struct gfar_private *priv = netdev_priv(dev);
        struct sk_buff *skb = NULL;
 
-       /* We have to allocate the skb, so keep trying till we succeed */
-       skb = netdev_alloc_skb(dev, priv->rx_buffer_size + RXBUF_ALIGNMENT);
+       skb = __skb_dequeue(&priv->rx_recycle);
+       if (!skb)
+               skb = netdev_alloc_skb(dev,
+                               priv->rx_buffer_size + RXBUF_ALIGNMENT);
 
        if (!skb)
                return NULL;
@@ -1633,28 +1762,7 @@ static inline void count_errors(unsigned short status, struct net_device *dev)
 
 irqreturn_t gfar_receive(int irq, void *dev_id)
 {
-       struct net_device *dev = (struct net_device *) dev_id;
-       struct gfar_private *priv = netdev_priv(dev);
-       u32 tempval;
-
-       /* support NAPI */
-       /* Clear IEVENT, so interrupts aren't called again
-        * because of the packets that have already arrived */
-       gfar_write(&priv->regs->ievent, IEVENT_RTX_MASK);
-
-       if (netif_rx_schedule_prep(dev, &priv->napi)) {
-               tempval = gfar_read(&priv->regs->imask);
-               tempval &= IMASK_RTX_DISABLED;
-               gfar_write(&priv->regs->imask, tempval);
-
-               __netif_rx_schedule(dev, &priv->napi);
-       } else {
-               if (netif_msg_rx_err(priv))
-                       printk(KERN_DEBUG "%s: receive called twice (%x)[%x]\n",
-                               dev->name, gfar_read(&priv->regs->ievent),
-                               gfar_read(&priv->regs->imask));
-       }
-
+       gfar_schedule_cleanup((struct net_device *)dev_id);
        return IRQ_HANDLED;
 }
 
@@ -1712,7 +1820,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
  */
 int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
 {
-       struct rxbd8 *bdp;
+       struct rxbd8 *bdp, *base;
        struct sk_buff *skb;
        int pkt_len;
        int amount_pull;
@@ -1721,6 +1829,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
 
        /* Get the first full descriptor */
        bdp = priv->cur_rx;
+       base = priv->rx_bd_base;
 
        amount_pull = (gfar_uses_fcb(priv) ? GMAC_FCB_LEN : 0) +
                priv->padding;
@@ -1734,7 +1843,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
 
                skb = priv->rx_skbuff[priv->skb_currx];
 
-               dma_unmap_single(&priv->dev->dev, bdp->bufPtr,
+               dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr,
                                priv->rx_buffer_size, DMA_FROM_DEVICE);
 
                /* We drop the frame if we failed to allocate a new buffer */
@@ -1744,9 +1853,17 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
 
                        if (unlikely(!newskb))
                                newskb = skb;
-
-                       if (skb)
-                               dev_kfree_skb_any(skb);
+                       else if (skb) {
+                               /*
+                                * We need to reset ->data to what it
+                                * was before gfar_new_skb() re-aligned
+                                * it to an RXBUF_ALIGNMENT boundary
+                                * before we put the skb back on the
+                                * recycle list.
+                                */
+                               skb->data = skb->head + NET_SKB_PAD;
+                               __skb_queue_head(&priv->rx_recycle, skb);
+                       }
                } else {
                        /* Increment the number of packets */
                        dev->stats.rx_packets++;
@@ -1758,6 +1875,8 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
                                skb_put(skb, pkt_len);
                                dev->stats.rx_bytes += pkt_len;
 
+                               if (in_irq() || irqs_disabled())
+                                       printk("Interrupt problem!\n");
                                gfar_process_frame(dev, skb, amount_pull);
 
                        } else {
@@ -1776,10 +1895,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
                gfar_new_rxbdp(dev, bdp, newskb);
 
                /* Update to the next pointer */
-               if (bdp->status & RXBD_WRAP)
-                       bdp = priv->rx_bd_base;
-               else
-                       bdp++;
+               bdp = next_bd(bdp, base, priv->rx_ring_size);
 
                /* update to point at the next skb */
                priv->skb_currx =
@@ -1796,20 +1912,28 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
 static int gfar_poll(struct napi_struct *napi, int budget)
 {
        struct gfar_private *priv = container_of(napi, struct gfar_private, napi);
-       struct net_device *dev = priv->dev;
-       int howmany;
+       struct net_device *dev = priv->ndev;
+       int tx_cleaned = 0;
+       int rx_cleaned = 0;
        unsigned long flags;
 
+       /* Clear IEVENT, so interrupts aren't called again
+        * because of the packets that have already arrived */
+       gfar_write(&priv->regs->ievent, IEVENT_RTX_MASK);
+
        /* If we fail to get the lock, don't bother with the TX BDs */
        if (spin_trylock_irqsave(&priv->txlock, flags)) {
-               gfar_clean_tx_ring(dev);
+               tx_cleaned = gfar_clean_tx_ring(dev);
                spin_unlock_irqrestore(&priv->txlock, flags);
        }
 
-       howmany = gfar_clean_rx_ring(dev, budget);
+       rx_cleaned = gfar_clean_rx_ring(dev, budget);
+
+       if (tx_cleaned)
+               return budget;
 
-       if (howmany < budget) {
-               netif_rx_complete(dev, napi);
+       if (rx_cleaned < budget) {
+               napi_complete(napi);
 
                /* Clear the halt bit in RSTAT */
                gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT);
@@ -1822,9 +1946,13 @@ static int gfar_poll(struct napi_struct *napi, int budget)
                        gfar_write(&priv->regs->rxic, 0);
                        gfar_write(&priv->regs->rxic, priv->rxic);
                }
+               if (likely(priv->txcoalescing)) {
+                       gfar_write(&priv->regs->txic, 0);
+                       gfar_write(&priv->regs->txic, priv->txic);
+               }
        }
 
-       return howmany;
+       return rx_cleaned;
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1915,6 +2043,8 @@ static void adjust_link(struct net_device *dev)
                        case 1000:
                                tempval =
                                    ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII);
+
+                               ecntrl &= ~(ECNTRL_R100);
                                break;
                        case 100:
                        case 10:
@@ -2195,9 +2325,6 @@ static irqreturn_t gfar_error(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-/* work with hotplug and coldplug */
-MODULE_ALIAS("platform:fsl-gianfar");
-
 static struct of_device_id gfar_match[] =
 {
        {
@@ -2206,6 +2333,7 @@ static struct of_device_id gfar_match[] =
        },
        {},
 };
+MODULE_DEVICE_TABLE(of, gfar_match);
 
 /* Structure for a device driver */
 static struct of_platform_driver gfar_driver = {
@@ -2220,23 +2348,12 @@ static struct of_platform_driver gfar_driver = {
 
 static int __init gfar_init(void)
 {
-       int err = gfar_mdio_init();
-
-       if (err)
-               return err;
-
-       err = of_register_platform_driver(&gfar_driver);
-
-       if (err)
-               gfar_mdio_exit();
-
-       return err;
+       return of_register_platform_driver(&gfar_driver);
 }
 
 static void __exit gfar_exit(void)
 {
        of_unregister_platform_driver(&gfar_driver);
-       gfar_mdio_exit();
 }
 
 module_init(gfar_init);