Merge branch 'linus' into cont_syslog
[safe/jmp/linux-2.6] / drivers / net / e100.c
index e52a201..b194bad 100644 (file)
  *      - add clean lowlevel I/O emulation for cards with MII-lacking PHYs
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/dmapool.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/string.h>
 #include <linux/firmware.h>
+#include <linux/rtnetlink.h>
 #include <asm/unaligned.h>
 
 
 #define DRV_VERSION            "3.5.24-k2"DRV_EXT
 #define DRV_DESCRIPTION                "Intel(R) PRO/100 Network Driver"
 #define DRV_COPYRIGHT          "Copyright(c) 1999-2006 Intel Corporation"
-#define PFX                    DRV_NAME ": "
 
 #define E100_WATCHDOG_PERIOD   (2 * HZ)
 #define E100_NAPI_WEIGHT       16
@@ -198,15 +202,11 @@ module_param(use_io, int, 0);
 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 MODULE_PARM_DESC(eeprom_bad_csum_allow, "Allow bad eeprom checksums");
 MODULE_PARM_DESC(use_io, "Force use of i/o access mode");
-#define DPRINTK(nlevel, klevel, fmt, args...) \
-       (void)((NETIF_MSG_##nlevel & nic->msg_enable) && \
-       printk(KERN_##klevel PFX "%s: %s: " fmt, nic->netdev->name, \
-               __func__ , ## args))
 
 #define INTEL_8255X_ETHERNET_DEVICE(device_id, ich) {\
        PCI_VENDOR_ID_INTEL, device_id, PCI_ANY_ID, PCI_ANY_ID, \
        PCI_CLASS_NETWORK_ETHERNET << 8, 0xFFFF00, ich }
-static struct pci_device_id e100_id_table[] = {
+static DEFINE_PCI_DEVICE_TABLE(e100_id_table) = {
        INTEL_8255X_ETHERNET_DEVICE(0x1029, 0),
        INTEL_8255X_ETHERNET_DEVICE(0x1030, 0),
        INTEL_8255X_ETHERNET_DEVICE(0x1031, 3),
@@ -601,6 +601,7 @@ struct nic {
        struct mem *mem;
        dma_addr_t dma_addr;
 
+       struct pci_pool *cbs_pool;
        dma_addr_t cbs_dma_addr;
        u8 adaptive_ifs;
        u8 tx_threshold;
@@ -621,6 +622,7 @@ struct nic {
        u16 eeprom_wc;
        __le16 eeprom[256];
        spinlock_t mdio_lock;
+       const struct firmware *fw;
 };
 
 static inline void e100_write_flush(struct nic *nic)
@@ -685,12 +687,13 @@ static int e100_self_test(struct nic *nic)
 
        /* Check results of self-test */
        if (nic->mem->selftest.result != 0) {
-               DPRINTK(HW, ERR, "Self-test failed: result=0x%08X\n",
-                       nic->mem->selftest.result);
+               netif_err(nic, hw, nic->netdev,
+                         "Self-test failed: result=0x%08X\n",
+                         nic->mem->selftest.result);
                return -ETIMEDOUT;
        }
        if (nic->mem->selftest.signature == 0) {
-               DPRINTK(HW, ERR, "Self-test failed: timed out\n");
+               netif_err(nic, hw, nic->netdev, "Self-test failed: timed out\n");
                return -ETIMEDOUT;
        }
 
@@ -793,7 +796,7 @@ static int e100_eeprom_load(struct nic *nic)
        /* The checksum, stored in the last word, is calculated such that
         * the sum of words should be 0xBABA */
        if (cpu_to_le16(0xBABA - checksum) != nic->eeprom[nic->eeprom_wc - 1]) {
-               DPRINTK(PROBE, ERR, "EEPROM corrupted\n");
+               netif_err(nic, probe, nic->netdev, "EEPROM corrupted\n");
                if (!eeprom_bad_csum_allow)
                        return -EAGAIN;
        }
@@ -949,8 +952,7 @@ static u16 mdio_ctrl_hw(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data)
                udelay(20);
        }
        if (unlikely(!i)) {
-               printk("e100.mdio_ctrl(%s) won't go Ready\n",
-                       nic->netdev->name );
+               netdev_err(nic->netdev, "e100.mdio_ctrl won't go Ready\n");
                spin_unlock_irqrestore(&nic->mdio_lock, flags);
                return 0;               /* No way to indicate timeout error */
        }
@@ -962,9 +964,10 @@ static u16 mdio_ctrl_hw(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data)
                        break;
        }
        spin_unlock_irqrestore(&nic->mdio_lock, flags);
-       DPRINTK(HW, DEBUG,
-               "%s:addr=%d, reg=%d, data_in=0x%04X, data_out=0x%04X\n",
-               dir == mdi_read ? "READ" : "WRITE", addr, reg, data, data_out);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                    "%s:addr=%d, reg=%d, data_in=0x%04X, data_out=0x%04X\n",
+                    dir == mdi_read ? "READ" : "WRITE",
+                    addr, reg, data, data_out);
        return (u16)data_out;
 }
 
@@ -1024,17 +1027,19 @@ static u16 mdio_ctrl_phy_mii_emulated(struct nic *nic,
                        return  ADVERTISE_10HALF |
                                ADVERTISE_10FULL;
                default:
-                       DPRINTK(HW, DEBUG,
-               "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n",
-               dir == mdi_read ? "READ" : "WRITE", addr, reg, data);
+                       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                                    "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n",
+                                    dir == mdi_read ? "READ" : "WRITE",
+                                    addr, reg, data);
                        return 0xFFFF;
                }
        } else {
                switch (reg) {
                default:
-                       DPRINTK(HW, DEBUG,
-               "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n",
-               dir == mdi_read ? "READ" : "WRITE", addr, reg, data);
+                       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                                    "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n",
+                                    dir == mdi_read ? "READ" : "WRITE",
+                                    addr, reg, data);
                        return 0xFFFF;
                }
        }
@@ -1151,12 +1156,15 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
                }
        }
 
-       DPRINTK(HW, DEBUG, "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
-               c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
-       DPRINTK(HW, DEBUG, "[08-15]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
-               c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]);
-       DPRINTK(HW, DEBUG, "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
-               c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                    "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
+                    c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                    "[08-15]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
+                    c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                    "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
+                    c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
 }
 
 /*************************************************************************
@@ -1222,9 +1230,9 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
 static const struct firmware *e100_request_firmware(struct nic *nic)
 {
        const char *fw_name;
-       const struct firmware *fw;
+       const struct firmware *fw = nic->fw;
        u8 timer, bundle, min_size;
-       int err;
+       int err = 0;
 
        /* do not load u-code for ICH devices */
        if (nic->flags & ich)
@@ -1240,17 +1248,27 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
        else /* No ucode on other devices */
                return NULL;
 
-       err = request_firmware(&fw, fw_name, &nic->pdev->dev);
+       /* If the firmware has not previously been loaded, request a pointer
+        * to it. If it was previously loaded, we are reinitializing the
+        * adapter, possibly in a resume from hibernate, in which case
+        * request_firmware() cannot be used.
+        */
+       if (!fw)
+               err = request_firmware(&fw, fw_name, &nic->pdev->dev);
+
        if (err) {
-               DPRINTK(PROBE, ERR, "Failed to load firmware \"%s\": %d\n",
-                       fw_name, err);
+               netif_err(nic, probe, nic->netdev,
+                         "Failed to load firmware \"%s\": %d\n",
+                         fw_name, err);
                return ERR_PTR(err);
        }
+
        /* Firmware should be precisely UCODE_SIZE (words) plus three bytes
           indicating the offsets for BUNDLESMALL, BUNDLEMAX, INTDELAY */
        if (fw->size != UCODE_SIZE * 4 + 3) {
-               DPRINTK(PROBE, ERR, "Firmware \"%s\" has wrong size %zu\n",
-                       fw_name, fw->size);
+               netif_err(nic, probe, nic->netdev,
+                         "Firmware \"%s\" has wrong size %zu\n",
+                         fw_name, fw->size);
                release_firmware(fw);
                return ERR_PTR(-EINVAL);
        }
@@ -1262,13 +1280,16 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
 
        if (timer >= UCODE_SIZE || bundle >= UCODE_SIZE ||
            min_size >= UCODE_SIZE) {
-               DPRINTK(PROBE, ERR,
-                       "\"%s\" has bogus offset values (0x%x,0x%x,0x%x)\n",
-                       fw_name, timer, bundle, min_size);
+               netif_err(nic, probe, nic->netdev,
+                         "\"%s\" has bogus offset values (0x%x,0x%x,0x%x)\n",
+                         fw_name, timer, bundle, min_size);
                release_firmware(fw);
                return ERR_PTR(-EINVAL);
        }
-       /* OK, firmware is validated and ready to use... */
+
+       /* OK, firmware is validated and ready to use. Save a pointer
+        * to it in the nic */
+       nic->fw = fw;
        return fw;
 }
 
@@ -1313,7 +1334,8 @@ static inline int e100_load_ucode_wait(struct nic *nic)
                return PTR_ERR(fw);
 
        if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode)))
-               DPRINTK(PROBE,ERR, "ucode cmd failed with error %d\n", err);
+               netif_err(nic, probe, nic->netdev,
+                         "ucode cmd failed with error %d\n", err);
 
        /* must restart cuc */
        nic->cuc_cmd = cuc_start;
@@ -1333,7 +1355,7 @@ static inline int e100_load_ucode_wait(struct nic *nic)
 
        /* if the command failed, or is not OK, notify and return */
        if (!counter || !(cb->status & cpu_to_le16(cb_ok))) {
-               DPRINTK(PROBE,ERR, "ucode load failed\n");
+               netif_err(nic, probe, nic->netdev, "ucode load failed\n");
                err = -EPERM;
        }
 
@@ -1371,8 +1393,8 @@ static int e100_phy_check_without_mii(struct nic *nic)
                 * media is sensed automatically based on how the link partner
                 * is configured.  This is, in essence, manual configuration.
                 */
-               DPRINTK(PROBE, INFO,
-                        "found MII-less i82503 or 80c24 or other PHY\n");
+               netif_info(nic, probe, nic->netdev,
+                          "found MII-less i82503 or 80c24 or other PHY\n");
 
                nic->mdio_ctrl = mdio_ctrl_phy_mii_emulated;
                nic->mii.phy_id = 0; /* is this ok for an MII-less PHY? */
@@ -1419,25 +1441,39 @@ static int e100_phy_init(struct nic *nic)
                        return 0; /* simply return and hope for the best */
                else {
                        /* for unknown cases log a fatal error */
-                       DPRINTK(HW, ERR,
-                               "Failed to locate any known PHY, aborting.\n");
+                       netif_err(nic, hw, nic->netdev,
+                                 "Failed to locate any known PHY, aborting\n");
                        return -EAGAIN;
                }
        } else
-               DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id);
-
-       /* Isolate all the PHY ids */
-       for (addr = 0; addr < 32; addr++)
-               mdio_write(netdev, addr, MII_BMCR, BMCR_ISOLATE);
-       /* Select the discovered PHY */
-       bmcr &= ~BMCR_ISOLATE;
-       mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr);
+               netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                            "phy_addr = %d\n", nic->mii.phy_id);
 
        /* Get phy ID */
        id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1);
        id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2);
        nic->phy = (u32)id_hi << 16 | (u32)id_lo;
-       DPRINTK(HW, DEBUG, "phy ID = 0x%08X\n", nic->phy);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                    "phy ID = 0x%08X\n", nic->phy);
+
+       /* Select the phy and isolate the rest */
+       for (addr = 0; addr < 32; addr++) {
+               if (addr != nic->mii.phy_id) {
+                       mdio_write(netdev, addr, MII_BMCR, BMCR_ISOLATE);
+               } else if (nic->phy != phy_82552_v) {
+                       bmcr = mdio_read(netdev, addr, MII_BMCR);
+                       mdio_write(netdev, addr, MII_BMCR,
+                               bmcr & ~BMCR_ISOLATE);
+               }
+       }
+       /*
+        * Workaround for 82552:
+        * Clear the ISOLATE bit on selected phy_id last (mirrored on all
+        * other phy_id's) using bmcr value from addr discovery loop above.
+        */
+       if (nic->phy == phy_82552_v)
+               mdio_write(netdev, nic->mii.phy_id, MII_BMCR,
+                       bmcr & ~BMCR_ISOLATE);
 
        /* Handle National tx phys */
 #define NCS_PHY_MODEL_MASK     0xFFF0FFFF
@@ -1480,7 +1516,7 @@ static int e100_hw_init(struct nic *nic)
 
        e100_hw_reset(nic);
 
-       DPRINTK(HW, ERR, "e100_hw_init\n");
+       netif_err(nic, hw, nic->netdev, "e100_hw_init\n");
        if (!in_interrupt() && (err = e100_self_test(nic)))
                return err;
 
@@ -1510,22 +1546,27 @@ static int e100_hw_init(struct nic *nic)
 static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
 {
        struct net_device *netdev = nic->netdev;
-       struct dev_mc_list *list = netdev->mc_list;
-       u16 i, count = min(netdev->mc_count, E100_MAX_MULTICAST_ADDRS);
+       struct netdev_hw_addr *ha;
+       u16 i, count = min(netdev_mc_count(netdev), E100_MAX_MULTICAST_ADDRS);
 
        cb->command = cpu_to_le16(cb_multi);
        cb->u.multi.count = cpu_to_le16(count * ETH_ALEN);
-       for (i = 0; list && i < count; i++, list = list->next)
-               memcpy(&cb->u.multi.addr[i*ETH_ALEN], &list->dmi_addr,
+       i = 0;
+       netdev_for_each_mc_addr(ha, netdev) {
+               if (i == count)
+                       break;
+               memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
                        ETH_ALEN);
+       }
 }
 
 static void e100_set_multicast_list(struct net_device *netdev)
 {
        struct nic *nic = netdev_priv(netdev);
 
-       DPRINTK(HW, DEBUG, "mc_count=%d, flags=0x%04X\n",
-               netdev->mc_count, netdev->flags);
+       netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
+                    "mc_count=%d, flags=0x%04X\n",
+                    netdev_mc_count(netdev), netdev->flags);
 
        if (netdev->flags & IFF_PROMISC)
                nic->flags |= promiscuous;
@@ -1533,7 +1574,7 @@ static void e100_set_multicast_list(struct net_device *netdev)
                nic->flags &= ~promiscuous;
 
        if (netdev->flags & IFF_ALLMULTI ||
-               netdev->mc_count > E100_MAX_MULTICAST_ADDRS)
+               netdev_mc_count(netdev) > E100_MAX_MULTICAST_ADDRS)
                nic->flags |= multicast_all;
        else
                nic->flags &= ~multicast_all;
@@ -1598,7 +1639,8 @@ static void e100_update_stats(struct nic *nic)
 
 
        if (e100_exec_cmd(nic, cuc_dump_reset, 0))
-               DPRINTK(TX_ERR, DEBUG, "exec cuc_dump_reset failed\n");
+               netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
+                            "exec cuc_dump_reset failed\n");
 }
 
 static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
@@ -1628,20 +1670,19 @@ static void e100_watchdog(unsigned long data)
        struct nic *nic = (struct nic *)data;
        struct ethtool_cmd cmd;
 
-       DPRINTK(TIMER, DEBUG, "right now = %ld\n", jiffies);
+       netif_printk(nic, timer, KERN_DEBUG, nic->netdev,
+                    "right now = %ld\n", jiffies);
 
        /* mii library handles link maintenance tasks */
 
        mii_ethtool_gset(&nic->mii, &cmd);
 
        if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) {
-               printk(KERN_INFO "e100: %s NIC Link is Up %s Mbps %s Duplex\n",
-                      nic->netdev->name,
-                      cmd.speed == SPEED_100 ? "100" : "10",
-                      cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
+               netdev_info(nic->netdev, "NIC Link is Up %u Mbps %s Duplex\n",
+                           cmd.speed == SPEED_100 ? 100 : 10,
+                           cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
        } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) {
-               printk(KERN_INFO "e100: %s NIC Link is Down\n",
-                      nic->netdev->name);
+               netdev_info(nic->netdev, "NIC Link is Down\n");
        }
 
        mii_check_link(&nic->mii);
@@ -1690,7 +1731,8 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
        cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
 }
 
-static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
+static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
+                                  struct net_device *netdev)
 {
        struct nic *nic = netdev_priv(netdev);
        int err;
@@ -1700,7 +1742,8 @@ static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                   Issue a NOP command followed by a 1us delay before
                   issuing the Tx command. */
                if (e100_exec_cmd(nic, cuc_nop, 0))
-                       DPRINTK(TX_ERR, DEBUG, "exec cuc_nop failed\n");
+                       netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
+                                    "exec cuc_nop failed\n");
                udelay(1);
        }
 
@@ -1709,18 +1752,19 @@ static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        switch (err) {
        case -ENOSPC:
                /* We queued the skb, but now we're out of space. */
-               DPRINTK(TX_ERR, DEBUG, "No space for CB\n");
+               netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
+                            "No space for CB\n");
                netif_stop_queue(netdev);
                break;
        case -ENOMEM:
                /* This is a hard error - log it. */
-               DPRINTK(TX_ERR, DEBUG, "Out of Tx resources, returning skb\n");
+               netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
+                            "Out of Tx resources, returning skb\n");
                netif_stop_queue(netdev);
                return NETDEV_TX_BUSY;
        }
 
-       netdev->trans_start = jiffies;
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static int e100_tx_clean(struct nic *nic)
@@ -1735,9 +1779,10 @@ static int e100_tx_clean(struct nic *nic)
        for (cb = nic->cb_to_clean;
            cb->status & cpu_to_le16(cb_complete);
            cb = nic->cb_to_clean = cb->next) {
-               DPRINTK(TX_DONE, DEBUG, "cb[%d]->status = 0x%04X\n",
-                       (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)),
-                       cb->status);
+               netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev,
+                            "cb[%d]->status = 0x%04X\n",
+                            (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)),
+                            cb->status);
 
                if (likely(cb->skb != NULL)) {
                        dev->stats.tx_packets++;
@@ -1779,9 +1824,7 @@ static void e100_clean_cbs(struct nic *nic)
                        nic->cb_to_clean = nic->cb_to_clean->next;
                        nic->cbs_avail++;
                }
-               pci_free_consistent(nic->pdev,
-                       sizeof(struct cb) * nic->params.cbs.count,
-                       nic->cbs, nic->cbs_dma_addr);
+               pci_pool_free(nic->cbs_pool, nic->cbs, nic->cbs_dma_addr);
                nic->cbs = NULL;
                nic->cbs_avail = 0;
        }
@@ -1799,10 +1842,11 @@ static int e100_alloc_cbs(struct nic *nic)
        nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = NULL;
        nic->cbs_avail = 0;
 
-       nic->cbs = pci_alloc_consistent(nic->pdev,
-               sizeof(struct cb) * count, &nic->cbs_dma_addr);
+       nic->cbs = pci_pool_alloc(nic->cbs_pool, GFP_KERNEL,
+                                 &nic->cbs_dma_addr);
        if (!nic->cbs)
                return -ENOMEM;
+       memset(nic->cbs, 0, count * sizeof(struct cb));
 
        for (cb = nic->cbs, i = 0; i < count; cb++, i++) {
                cb->next = (i + 1 < count) ? cb + 1 : nic->cbs;
@@ -1811,7 +1855,6 @@ static int e100_alloc_cbs(struct nic *nic)
                cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb);
                cb->link = cpu_to_le32(nic->cbs_dma_addr +
                        ((i+1) % count) * sizeof(struct cb));
-               cb->skb = NULL;
        }
 
        nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs;
@@ -1838,11 +1881,10 @@ static inline void e100_start_receiver(struct nic *nic, struct rx *rx)
 #define RFD_BUF_LEN (sizeof(struct rfd) + VLAN_ETH_FRAME_LEN)
 static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
 {
-       if (!(rx->skb = netdev_alloc_skb(nic->netdev, RFD_BUF_LEN + NET_IP_ALIGN)))
+       if (!(rx->skb = netdev_alloc_skb_ip_align(nic->netdev, RFD_BUF_LEN)))
                return -ENOMEM;
 
-       /* Align, init, and map the RFD. */
-       skb_reserve(rx->skb, NET_IP_ALIGN);
+       /* Init, and map the RFD. */
        skb_copy_to_linear_data(rx->skb, &nic->blank_rfd, sizeof(struct rfd));
        rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data,
                RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
@@ -1883,7 +1925,8 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
                sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL);
        rfd_status = le16_to_cpu(rfd->status);
 
-       DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status);
+       netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev,
+                    "status=0x%04X\n", rfd_status);
 
        /* If data isn't ready, nothing to indicate */
        if (unlikely(!(rfd_status & cb_complete))) {
@@ -1897,6 +1940,9 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 
                        if (ioread8(&nic->csr->scb.status) & rus_no_res)
                                nic->ru_running = RU_SUSPENDED;
+               pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr,
+                                              sizeof(struct rfd),
+                                              PCI_DMA_FROMDEVICE);
                return -ENODATA;
        }
 
@@ -2091,7 +2137,8 @@ static irqreturn_t e100_intr(int irq, void *dev_id)
        struct nic *nic = netdev_priv(netdev);
        u8 stat_ack = ioread8(&nic->csr->scb.stat_ack);
 
-       DPRINTK(INTR, DEBUG, "stat_ack = 0x%02X\n", stat_ack);
+       netif_printk(nic, intr, KERN_DEBUG, nic->netdev,
+                    "stat_ack = 0x%02X\n", stat_ack);
 
        if (stat_ack == stat_ack_not_ours ||    /* Not our interrupt */
           stat_ack == stat_ack_not_present)    /* Hardware is ejected */
@@ -2231,10 +2278,15 @@ static void e100_tx_timeout_task(struct work_struct *work)
        struct nic *nic = container_of(work, struct nic, tx_timeout_task);
        struct net_device *netdev = nic->netdev;
 
-       DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
-               ioread8(&nic->csr->scb.status));
-       e100_down(netdev_priv(netdev));
-       e100_up(netdev_priv(netdev));
+       netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
+                    "scb.status=0x%02X\n", ioread8(&nic->csr->scb.status));
+
+       rtnl_lock();
+       if (netif_running(netdev)) {
+               e100_down(netdev_priv(netdev));
+               e100_up(netdev_priv(netdev));
+       }
+       rtnl_unlock();
 }
 
 static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
@@ -2494,8 +2546,8 @@ static int e100_set_ringparam(struct net_device *netdev,
        rfds->count = min(rfds->count, rfds->max);
        cbs->count = max(ring->tx_pending, cbs->min);
        cbs->count = min(cbs->count, cbs->max);
-       DPRINTK(DRV, INFO, "Ring Param settings: rx: %d, tx %d\n",
-               rfds->count, cbs->count);
+       netif_info(nic, drv, nic->netdev, "Ring Param settings: rx: %d, tx %d\n",
+                  rfds->count, cbs->count);
        if (netif_running(netdev))
                e100_up(nic);
 
@@ -2672,7 +2724,7 @@ static int e100_open(struct net_device *netdev)
 
        netif_carrier_off(netdev);
        if ((err = e100_up(nic)))
-               DPRINTK(IFUP, ERR, "Cannot open interface, aborting.\n");
+               netif_err(nic, ifup, nic->netdev, "Cannot open interface, aborting\n");
        return err;
 }
 
@@ -2706,7 +2758,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
 
        if (!(netdev = alloc_etherdev(sizeof(struct nic)))) {
                if (((1 << debug) - 1) & NETIF_MSG_PROBE)
-                       printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n");
+                       pr_err("Etherdev alloc failed, aborting\n");
                return -ENOMEM;
        }
 
@@ -2724,35 +2776,34 @@ static int __devinit e100_probe(struct pci_dev *pdev,
        pci_set_drvdata(pdev, netdev);
 
        if ((err = pci_enable_device(pdev))) {
-               DPRINTK(PROBE, ERR, "Cannot enable PCI device, aborting.\n");
+               netif_err(nic, probe, nic->netdev, "Cannot enable PCI device, aborting\n");
                goto err_out_free_dev;
        }
 
        if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
-               DPRINTK(PROBE, ERR, "Cannot find proper PCI device "
-                       "base address, aborting.\n");
+               netif_err(nic, probe, nic->netdev, "Cannot find proper PCI device base address, aborting\n");
                err = -ENODEV;
                goto err_out_disable_pdev;
        }
 
        if ((err = pci_request_regions(pdev, DRV_NAME))) {
-               DPRINTK(PROBE, ERR, "Cannot obtain PCI resources, aborting.\n");
+               netif_err(nic, probe, nic->netdev, "Cannot obtain PCI resources, aborting\n");
                goto err_out_disable_pdev;
        }
 
        if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) {
-               DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n");
+               netif_err(nic, probe, nic->netdev, "No usable DMA configuration, aborting\n");
                goto err_out_free_res;
        }
 
        SET_NETDEV_DEV(netdev, &pdev->dev);
 
        if (use_io)
-               DPRINTK(PROBE, INFO, "using i/o access mode\n");
+               netif_info(nic, probe, nic->netdev, "using i/o access mode\n");
 
        nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr));
        if (!nic->csr) {
-               DPRINTK(PROBE, ERR, "Cannot map device registers, aborting.\n");
+               netif_err(nic, probe, nic->netdev, "Cannot map device registers, aborting\n");
                err = -ENOMEM;
                goto err_out_free_res;
        }
@@ -2786,7 +2837,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
        INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
 
        if ((err = e100_alloc(nic))) {
-               DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
+               netif_err(nic, probe, nic->netdev, "Cannot alloc driver memory, aborting\n");
                goto err_out_iounmap;
        }
 
@@ -2799,13 +2850,11 @@ static int __devinit e100_probe(struct pci_dev *pdev,
        memcpy(netdev->perm_addr, nic->eeprom, ETH_ALEN);
        if (!is_valid_ether_addr(netdev->perm_addr)) {
                if (!eeprom_bad_csum_allow) {
-                       DPRINTK(PROBE, ERR, "Invalid MAC address from "
-                               "EEPROM, aborting.\n");
+                       netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, aborting\n");
                        err = -EAGAIN;
                        goto err_out_free;
                } else {
-                       DPRINTK(PROBE, ERR, "Invalid MAC address from EEPROM, "
-                               "you MUST configure one.\n");
+                       netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, you MUST configure one.\n");
                }
        }
 
@@ -2821,13 +2870,18 @@ static int __devinit e100_probe(struct pci_dev *pdev,
 
        strcpy(netdev->name, "eth%d");
        if ((err = register_netdev(netdev))) {
-               DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n");
+               netif_err(nic, probe, nic->netdev, "Cannot register net device, aborting\n");
                goto err_out_free;
        }
-
-       DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, MAC addr %pM\n",
-               (unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
-               pdev->irq, netdev->dev_addr);
+       nic->cbs_pool = pci_pool_create(netdev->name,
+                          nic->pdev,
+                          nic->params.cbs.max * sizeof(struct cb),
+                          sizeof(u32),
+                          0);
+       netif_info(nic, probe, nic->netdev,
+                  "addr 0x%llx, irq %d, MAC addr %pM\n",
+                  (unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
+                  pdev->irq, netdev->dev_addr);
 
        return 0;
 
@@ -2854,6 +2908,7 @@ static void __devexit e100_remove(struct pci_dev *pdev)
                unregister_netdev(netdev);
                e100_free(nic);
                pci_iounmap(pdev, nic->csr);
+               pci_pool_destroy(nic->cbs_pool);
                free_netdev(netdev);
                pci_release_regions(pdev);
                pci_disable_device(pdev);
@@ -2895,12 +2950,13 @@ static void __e100_shutdown(struct pci_dev *pdev, bool *enable_wake)
 
 static int __e100_power_off(struct pci_dev *pdev, bool wake)
 {
-       if (wake) {
+       if (wake)
                return pci_prepare_to_sleep(pdev);
-       } else {
-               pci_wake_from_d3(pdev, false);
-               return pci_set_power_state(pdev, PCI_D3hot);
-       }
+
+       pci_wake_from_d3(pdev, false);
+       pci_set_power_state(pdev, PCI_D3hot);
+
+       return 0;
 }
 
 #ifdef CONFIG_PM
@@ -2921,7 +2977,7 @@ static int e100_resume(struct pci_dev *pdev)
        /* ack any pending wake events, disable PME */
        pci_enable_wake(pdev, 0, 0);
 
-       /* disbale reverse auto-negotiation */
+       /* disable reverse auto-negotiation */
        if (nic->phy == phy_82552_v) {
                u16 smartspeed = mdio_read(netdev, nic->mii.phy_id,
                                           E100_82552_SMARTSPEED);
@@ -2983,7 +3039,7 @@ static pci_ers_result_t e100_io_slot_reset(struct pci_dev *pdev)
        struct nic *nic = netdev_priv(netdev);
 
        if (pci_enable_device(pdev)) {
-               printk(KERN_ERR "e100: Cannot re-enable PCI device after reset.\n");
+               pr_err("Cannot re-enable PCI device after reset\n");
                return PCI_ERS_RESULT_DISCONNECT;
        }
        pci_set_master(pdev);
@@ -3042,8 +3098,8 @@ static struct pci_driver e100_driver = {
 static int __init e100_init_module(void)
 {
        if (((1 << debug) - 1) & NETIF_MSG_DRV) {
-               printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
-               printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT);
+               pr_info("%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
+               pr_info("%s\n", DRV_COPYRIGHT);
        }
        return pci_register_driver(&e100_driver);
 }