]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/tc35815.c
tc35815: Use managed pci iomap helper
[linux-2.6-omap-h63xx.git] / drivers / net / tc35815.c
index 7f94ca930988d08e63271469a3f3910494831259..60eff784d5e4c585dc16ecd314e1026e4934728d 100644 (file)
@@ -94,37 +94,37 @@ static struct tc35815_options {
  * Registers
  */
 struct tc35815_regs {
-       volatile __u32 DMA_Ctl;         /* 0x00 */
-       volatile __u32 TxFrmPtr;
-       volatile __u32 TxThrsh;
-       volatile __u32 TxPollCtr;
-       volatile __u32 BLFrmPtr;
-       volatile __u32 RxFragSize;
-       volatile __u32 Int_En;
-       volatile __u32 FDA_Bas;
-       volatile __u32 FDA_Lim;         /* 0x20 */
-       volatile __u32 Int_Src;
-       volatile __u32 unused0[2];
-       volatile __u32 PauseCnt;
-       volatile __u32 RemPauCnt;
-       volatile __u32 TxCtlFrmStat;
-       volatile __u32 unused1;
-       volatile __u32 MAC_Ctl;         /* 0x40 */
-       volatile __u32 CAM_Ctl;
-       volatile __u32 Tx_Ctl;
-       volatile __u32 Tx_Stat;
-       volatile __u32 Rx_Ctl;
-       volatile __u32 Rx_Stat;
-       volatile __u32 MD_Data;
-       volatile __u32 MD_CA;
-       volatile __u32 CAM_Adr;         /* 0x60 */
-       volatile __u32 CAM_Data;
-       volatile __u32 CAM_Ena;
-       volatile __u32 PROM_Ctl;
-       volatile __u32 PROM_Data;
-       volatile __u32 Algn_Cnt;
-       volatile __u32 CRC_Cnt;
-       volatile __u32 Miss_Cnt;
+       __u32 DMA_Ctl;          /* 0x00 */
+       __u32 TxFrmPtr;
+       __u32 TxThrsh;
+       __u32 TxPollCtr;
+       __u32 BLFrmPtr;
+       __u32 RxFragSize;
+       __u32 Int_En;
+       __u32 FDA_Bas;
+       __u32 FDA_Lim;          /* 0x20 */
+       __u32 Int_Src;
+       __u32 unused0[2];
+       __u32 PauseCnt;
+       __u32 RemPauCnt;
+       __u32 TxCtlFrmStat;
+       __u32 unused1;
+       __u32 MAC_Ctl;          /* 0x40 */
+       __u32 CAM_Ctl;
+       __u32 Tx_Ctl;
+       __u32 Tx_Stat;
+       __u32 Rx_Ctl;
+       __u32 Rx_Stat;
+       __u32 MD_Data;
+       __u32 MD_CA;
+       __u32 CAM_Adr;          /* 0x60 */
+       __u32 CAM_Data;
+       __u32 CAM_Ena;
+       __u32 PROM_Ctl;
+       __u32 PROM_Data;
+       __u32 Algn_Cnt;
+       __u32 CRC_Cnt;
+       __u32 Miss_Cnt;
 };
 
 /*
@@ -396,8 +396,8 @@ struct FrFD {
 };
 
 
-#define tc_readl(addr) readl(addr)
-#define tc_writel(d, addr)     writel(d, addr)
+#define tc_readl(addr) ioread32(addr)
+#define tc_writel(d, addr)     iowrite32(d, addr)
 
 #define TC35815_TX_TIMEOUT  msecs_to_jiffies(400)
 
@@ -414,8 +414,10 @@ enum tc35815_timer_state {
 struct tc35815_local {
        struct pci_dev *pci_dev;
 
+       struct net_device *dev;
+       struct napi_struct napi;
+
        /* statistics */
-       struct net_device_stats stats;
        struct {
                int max_tx_qlen;
                int tx_ints;
@@ -566,7 +568,7 @@ static int  tc35815_send_packet(struct sk_buff *skb, struct net_device *dev);
 static irqreturn_t     tc35815_interrupt(int irq, void *dev_id);
 #ifdef TC35815_NAPI
 static int     tc35815_rx(struct net_device *dev, int limit);
-static int     tc35815_poll(struct net_device *dev, int *budget);
+static int     tc35815_poll(struct napi_struct *napi, int budget);
 #else
 static void    tc35815_rx(struct net_device *dev);
 #endif
@@ -608,13 +610,13 @@ static int __devinit tc35815_mac_match(struct device *dev, void *data)
 {
        struct platform_device *plat_dev = to_platform_device(dev);
        struct pci_dev *pci_dev = data;
-       unsigned int id = (pci_dev->bus->number << 8) | pci_dev->devfn;
+       unsigned int id = pci_dev->irq;
        return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id;
 }
 
 static int __devinit tc35815_read_plat_dev_addr(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct device *pd = bus_find_device(&platform_bus_type, NULL,
                                            lp->pci_dev, tc35815_mac_match);
        if (pd) {
@@ -661,7 +663,7 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
        struct net_device *dev;
        struct tc35815_local *lp;
        int rc;
-       unsigned long mmio_start, mmio_end, mmio_flags, mmio_len;
+       DECLARE_MAC_BUF(mac);
 
        static int printed_version;
        if (!printed_version++) {
@@ -682,50 +684,19 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
                dev_err(&pdev->dev, "unable to alloc new ethernet\n");
                return -ENOMEM;
        }
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
-       lp = dev->priv;
+       lp = netdev_priv(dev);
+       lp->dev = dev;
 
        /* enable device (incl. PCI PM wakeup), and bus-mastering */
-       rc = pci_enable_device (pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                goto err_out;
-
-       mmio_start = pci_resource_start (pdev, 1);
-       mmio_end = pci_resource_end (pdev, 1);
-       mmio_flags = pci_resource_flags (pdev, 1);
-       mmio_len = pci_resource_len (pdev, 1);
-
-       /* set this immediately, we need to know before
-        * we talk to the chip directly */
-
-       /* make sure PCI base addr 1 is MMIO */
-       if (!(mmio_flags & IORESOURCE_MEM)) {
-               dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n");
-               rc = -ENODEV;
-               goto err_out;
-       }
-
-       /* check for weird/broken PCI region reporting */
-       if ((mmio_len < sizeof(struct tc35815_regs))) {
-               dev_err(&pdev->dev, "Invalid PCI region size(s), aborting\n");
-               rc = -ENODEV;
-               goto err_out;
-       }
-
-       rc = pci_request_regions (pdev, MODNAME);
+       rc = pcim_iomap_regions(pdev, 1 << 1, MODNAME);
        if (rc)
                goto err_out;
-
-       pci_set_master (pdev);
-
-       /* ioremap MMIO region */
-       ioaddr = ioremap (mmio_start, mmio_len);
-       if (ioaddr == NULL) {
-               dev_err(&pdev->dev, "cannot remap MMIO, aborting\n");
-               rc = -EIO;
-               goto err_out_free_res;
-       }
+       pci_set_master(pdev);
+       ioaddr = pcim_iomap_table(pdev)[1];
 
        /* Initialize the device structure. */
        dev->open = tc35815_open;
@@ -738,8 +709,7 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
        dev->tx_timeout = tc35815_tx_timeout;
        dev->watchdog_timeo = TC35815_TX_TIMEOUT;
 #ifdef TC35815_NAPI
-       dev->poll = tc35815_poll;
-       dev->weight = NAPI_WEIGHT;
+       netif_napi_add(dev, &lp->napi, tc35815_poll, NAPI_WEIGHT);
 #endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
        dev->poll_controller = tc35815_poll_controller;
@@ -748,8 +718,6 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
        dev->irq = pdev->irq;
        dev->base_addr = (unsigned long) ioaddr;
 
-       /* dev->priv/lp zeroed and aligned in alloc_etherdev */
-       lp = dev->priv;
        spin_lock_init(&lp->lock);
        lp->pci_dev = pdev;
        lp->boardtype = ent->driver_data;
@@ -768,18 +736,14 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
 
        rc = register_netdev (dev);
        if (rc)
-               goto err_out_unmap;
+               goto err_out;
 
        memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
-       printk(KERN_INFO "%s: %s at 0x%lx, "
-               "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, "
-               "IRQ %d\n",
+       printk(KERN_INFO "%s: %s at 0x%lx, %s, IRQ %d\n",
                dev->name,
                board_info[ent->driver_data].name,
                dev->base_addr,
-               dev->dev_addr[0], dev->dev_addr[1],
-               dev->dev_addr[2], dev->dev_addr[3],
-               dev->dev_addr[4], dev->dev_addr[5],
+               print_mac(mac, dev->dev_addr),
                dev->irq);
 
        setup_timer(&lp->timer, tc35815_timer, (unsigned long) dev);
@@ -795,10 +759,6 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev,
 
        return 0;
 
-err_out_unmap:
-       iounmap(ioaddr);
-err_out_free_res:
-       pci_release_regions (pdev);
 err_out:
        free_netdev (dev);
        return rc;
@@ -808,17 +768,8 @@ err_out:
 static void __devexit tc35815_remove_one (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
-       unsigned long mmio_addr;
-
-       mmio_addr = dev->base_addr;
 
        unregister_netdev (dev);
-
-       if (mmio_addr) {
-               iounmap ((void __iomem *)mmio_addr);
-               pci_release_regions (pdev);
-       }
-
        free_netdev (dev);
 
        pci_set_drvdata (pdev, NULL);
@@ -827,7 +778,7 @@ static void __devexit tc35815_remove_one (struct pci_dev *pdev)
 static int
 tc35815_init_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
        unsigned long fd_addr;
 
@@ -964,7 +915,7 @@ tc35815_init_queues(struct net_device *dev)
 static void
 tc35815_clear_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
 
        for (i = 0; i < TX_FD_NUM; i++) {
@@ -995,7 +946,7 @@ tc35815_clear_queues(struct net_device *dev)
 static void
 tc35815_free_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
 
        if (lp->tfd_base) {
@@ -1109,7 +1060,7 @@ dump_frfd(struct FrFD *fd)
 static void
 panic_queues(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int i;
 
        printk("TxFD base %p, start %u, end %u\n",
@@ -1128,28 +1079,25 @@ panic_queues(struct net_device *dev)
 }
 #endif
 
-static void print_eth(char *add)
+static void print_eth(const u8 *add)
 {
-       int i;
+       DECLARE_MAC_BUF(mac);
 
-       printk("print_eth(%p)\n", add);
-       for (i = 0; i < 6; i++)
-               printk(" %2.2X", (unsigned char) add[i + 6]);
-       printk(" =>");
-       for (i = 0; i < 6; i++)
-               printk(" %2.2X", (unsigned char) add[i]);
-       printk(" : %2.2X%2.2X\n", (unsigned char) add[12], (unsigned char) add[13]);
+       printk(KERN_DEBUG "print_eth(%p)\n", add);
+       printk(KERN_DEBUG " %s =>", print_mac(mac, add + 6));
+       printk(KERN_CONT " %s : %02x%02x\n",
+               print_mac(mac, add), add[12], add[13]);
 }
 
 static int tc35815_tx_full(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        return ((lp->tfd_start + 1) % TX_FD_NUM == lp->tfd_end);
 }
 
 static void tc35815_restart(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        int do_phy_reset = 1;
        del_timer(&lp->timer);          /* Kill if running      */
@@ -1180,7 +1128,7 @@ static void tc35815_restart(struct net_device *dev)
 
 static void tc35815_tx_timeout(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
 
@@ -1192,7 +1140,7 @@ static void tc35815_tx_timeout(struct net_device *dev)
        tc35815_restart(dev);
        spin_unlock_irq(&lp->lock);
 
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
 
        /* If we have space available to accept new transmit
         * requests, wake up the queueing layer.  This would
@@ -1219,7 +1167,7 @@ static void tc35815_tx_timeout(struct net_device *dev)
 static int
 tc35815_open(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
 
        /*
         * This is used if the interrupt line can turned off (shared).
@@ -1237,6 +1185,10 @@ tc35815_open(struct net_device *dev)
                return -EAGAIN;
        }
 
+#ifdef TC35815_NAPI
+       napi_enable(&lp->napi);
+#endif
+
        /* Reset the hardware here. Don't forget to set the station address. */
        spin_lock_irq(&lp->lock);
        tc35815_chip_init(dev);
@@ -1257,7 +1209,7 @@ tc35815_open(struct net_device *dev)
  */
 static int tc35815_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct TxFD *txfd;
        unsigned long flags;
 
@@ -1371,7 +1323,7 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status, int limit)
 static int tc35815_do_interrupt(struct net_device *dev, u32 status)
 #endif
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        int ret = -1;
@@ -1388,7 +1340,7 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
                printk(KERN_WARNING
                       "%s: Free Descriptor Area Exhausted (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                ret = 0;
        }
        if (status & Int_IntBLEx) {
@@ -1397,14 +1349,14 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
                printk(KERN_WARNING
                       "%s: Buffer List Exhausted (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                ret = 0;
        }
        if (status & Int_IntExBD) {
                printk(KERN_WARNING
                       "%s: Excessive Buffer Descriptiors (%#x).\n",
                       dev->name, status);
-               lp->stats.rx_length_errors++;
+               dev->stats.rx_length_errors++;
                ret = 0;
        }
 
@@ -1436,6 +1388,7 @@ static int tc35815_do_interrupt(struct net_device *dev, u32 status)
 static irqreturn_t tc35815_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
 #ifdef TC35815_NAPI
@@ -1444,8 +1397,8 @@ static irqreturn_t tc35815_interrupt(int irq, void *dev_id)
        if (!(dmactl & DMA_IntMask)) {
                /* disable interrupts */
                tc_writel(dmactl | DMA_IntMask, &tr->DMA_Ctl);
-               if (netif_rx_schedule_prep(dev))
-                       __netif_rx_schedule(dev);
+               if (netif_rx_schedule_prep(dev, &lp->napi))
+                       __netif_rx_schedule(dev, &lp->napi);
                else {
                        printk(KERN_ERR "%s: interrupt taken in poll\n",
                               dev->name);
@@ -1456,7 +1409,6 @@ static irqreturn_t tc35815_interrupt(int irq, void *dev_id)
        }
        return IRQ_NONE;
 #else
-       struct tc35815_local *lp = dev->priv;
        int handled;
        u32 status;
 
@@ -1488,7 +1440,7 @@ static void
 tc35815_rx(struct net_device *dev)
 #endif
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        unsigned int fdctl;
        int i;
        int buf_free_count = 0;
@@ -1528,7 +1480,7 @@ tc35815_rx(struct net_device *dev)
                        if (skb == NULL) {
                                printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
                                       dev->name);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                break;
                        }
                        skb_reserve(skb, 2);   /* 16 bit alignment */
@@ -1598,10 +1550,10 @@ tc35815_rx(struct net_device *dev)
                        netif_rx(skb);
 #endif
                        dev->last_rx = jiffies;
-                       lp->stats.rx_packets++;
-                       lp->stats.rx_bytes += pkt_len;
+                       dev->stats.rx_packets++;
+                       dev->stats.rx_bytes += pkt_len;
                } else {
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_errors++;
                        printk(KERN_DEBUG "%s: Rx error (status %x)\n",
                               dev->name, status & Rx_Stat_Mask);
                        /* WORKAROUND: LongErr and CRCErr means Overflow. */
@@ -1609,10 +1561,14 @@ tc35815_rx(struct net_device *dev)
                                status &= ~(Rx_LongErr|Rx_CRCErr);
                                status |= Rx_Over;
                        }
-                       if (status & Rx_LongErr) lp->stats.rx_length_errors++;
-                       if (status & Rx_Over) lp->stats.rx_fifo_errors++;
-                       if (status & Rx_CRCErr) lp->stats.rx_crc_errors++;
-                       if (status & Rx_Align) lp->stats.rx_frame_errors++;
+                       if (status & Rx_LongErr)
+                               dev->stats.rx_length_errors++;
+                       if (status & Rx_Over)
+                               dev->stats.rx_fifo_errors++;
+                       if (status & Rx_CRCErr)
+                               dev->stats.rx_crc_errors++;
+                       if (status & Rx_Align)
+                               dev->stats.rx_frame_errors++;
                }
 
                if (bd_count > 0) {
@@ -1650,7 +1606,7 @@ tc35815_rx(struct net_device *dev)
                                        panic_queues(dev);
                                }
 #endif
-                               /* pass BD to controler */
+                               /* pass BD to controller */
 #ifndef TC35815_USE_PACKEDBUFFER
                                if (!lp->rx_skbs[curid].skb) {
                                        lp->rx_skbs[curid].skb =
@@ -1690,7 +1646,7 @@ tc35815_rx(struct net_device *dev)
                }
 #endif
                for (i = 0; i < (bd_count + 1) / 2 + 1; i++) {
-                       /* pass FD to controler */
+                       /* pass FD to controller */
 #ifdef DEBUG
                        lp->rfd_cur->fd.FDNext = cpu_to_le32(0xdeaddead);
 #else
@@ -1726,13 +1682,12 @@ tc35815_rx(struct net_device *dev)
 }
 
 #ifdef TC35815_NAPI
-static int
-tc35815_poll(struct net_device *dev, int *budget)
+static int tc35815_poll(struct napi_struct *napi, int budget)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = container_of(napi, struct tc35815_local, napi);
+       struct net_device *dev = lp->dev;
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
-       int limit = min(*budget, dev->quota);
        int received = 0, handled;
        u32 status;
 
@@ -1744,23 +1699,19 @@ tc35815_poll(struct net_device *dev, int *budget)
                handled = tc35815_do_interrupt(dev, status, limit);
                if (handled >= 0) {
                        received += handled;
-                       limit -= handled;
-                       if (limit <= 0)
+                       if (received >= budget)
                                break;
                }
                status = tc_readl(&tr->Int_Src);
        } while (status);
        spin_unlock(&lp->lock);
 
-       dev->quota -= received;
-       *budget -= received;
-       if (limit <= 0)
-               return 1;
-
-       netif_rx_complete(dev);
-       /* enable interrupts */
-       tc_writel(tc_readl(&tr->DMA_Ctl) & ~DMA_IntMask, &tr->DMA_Ctl);
-       return 0;
+       if (received < budget) {
+               netif_rx_complete(dev, napi);
+               /* enable interrupts */
+               tc_writel(tc_readl(&tr->DMA_Ctl) & ~DMA_IntMask, &tr->DMA_Ctl);
+       }
+       return received;
 }
 #endif
 
@@ -1773,14 +1724,14 @@ tc35815_poll(struct net_device *dev, int *budget)
 static void
 tc35815_check_tx_stat(struct net_device *dev, int status)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        const char *msg = NULL;
 
        /* count collisions */
        if (status & Tx_ExColl)
-               lp->stats.collisions += 16;
+               dev->stats.collisions += 16;
        if (status & Tx_TxColl_MASK)
-               lp->stats.collisions += status & Tx_TxColl_MASK;
+               dev->stats.collisions += status & Tx_TxColl_MASK;
 
 #ifndef NO_CHECK_CARRIER
        /* TX4939 does not have NCarr */
@@ -1796,17 +1747,17 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
 
        if (!(status & TX_STA_ERR)) {
                /* no error. */
-               lp->stats.tx_packets++;
+               dev->stats.tx_packets++;
                return;
        }
 
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
        if (status & Tx_ExColl) {
-               lp->stats.tx_aborted_errors++;
+               dev->stats.tx_aborted_errors++;
                msg = "Excessive Collision.";
        }
        if (status & Tx_Under) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Tx FIFO Underrun.";
                if (lp->lstats.tx_underrun < TX_THRESHOLD_KEEP_LIMIT) {
                        lp->lstats.tx_underrun++;
@@ -1819,25 +1770,25 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
                }
        }
        if (status & Tx_Defer) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Excessive Deferral.";
        }
 #ifndef NO_CHECK_CARRIER
        if (status & Tx_NCarr) {
-               lp->stats.tx_carrier_errors++;
+               dev->stats.tx_carrier_errors++;
                msg = "Lost Carrier Sense.";
        }
 #endif
        if (status & Tx_LateColl) {
-               lp->stats.tx_aborted_errors++;
+               dev->stats.tx_aborted_errors++;
                msg = "Late Collision.";
        }
        if (status & Tx_TxPar) {
-               lp->stats.tx_fifo_errors++;
+               dev->stats.tx_fifo_errors++;
                msg = "Transmit Parity Error.";
        }
        if (status & Tx_SQErr) {
-               lp->stats.tx_heartbeat_errors++;
+               dev->stats.tx_heartbeat_errors++;
                msg = "Signal Quality Error.";
        }
        if (msg && netif_msg_tx_err(lp))
@@ -1850,7 +1801,7 @@ tc35815_check_tx_stat(struct net_device *dev, int status)
 static void
 tc35815_txdone(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct TxFD *txfd;
        unsigned int fdctl;
 
@@ -1879,7 +1830,7 @@ tc35815_txdone(struct net_device *dev)
                BUG_ON(lp->tx_skbs[lp->tfd_end].skb != skb);
 #endif
                if (skb) {
-                       lp->stats.tx_bytes += skb->len;
+                       dev->stats.tx_bytes += skb->len;
                        pci_unmap_single(lp->pci_dev, lp->tx_skbs[lp->tfd_end].skb_dma, skb->len, PCI_DMA_TODEVICE);
                        lp->tx_skbs[lp->tfd_end].skb = NULL;
                        lp->tx_skbs[lp->tfd_end].skb_dma = 0;
@@ -1948,8 +1899,12 @@ tc35815_txdone(struct net_device *dev)
 static int
 tc35815_close(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
+
        netif_stop_queue(dev);
+#ifdef TC35815_NAPI
+       napi_disable(&lp->napi);
+#endif
 
        /* Flush the Tx and disable Rx here. */
 
@@ -1969,34 +1924,30 @@ tc35815_close(struct net_device *dev)
  */
 static struct net_device_stats *tc35815_get_stats(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
-       if (netif_running(dev)) {
+       if (netif_running(dev))
                /* Update the statistics from the device registers. */
-               lp->stats.rx_missed_errors = tc_readl(&tr->Miss_Cnt);
-       }
+               dev->stats.rx_missed_errors = tc_readl(&tr->Miss_Cnt);
 
-       return &lp->stats;
+       return &dev->stats;
 }
 
 static void tc35815_set_cam_entry(struct net_device *dev, int index, unsigned char *addr)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        int cam_index = index * 6;
        u32 cam_data;
        u32 saved_addr;
+       DECLARE_MAC_BUF(mac);
+
        saved_addr = tc_readl(&tr->CAM_Adr);
 
-       if (netif_msg_hw(lp)) {
-               int i;
-               printk(KERN_DEBUG "%s: CAM %d:", dev->name, index);
-               for (i = 0; i < 6; i++)
-                       printk(" %02x", addr[i]);
-               printk("\n");
-       }
+       if (netif_msg_hw(lp))
+               printk(KERN_DEBUG "%s: CAM %d: %s\n",
+                       dev->name, index, print_mac(mac, addr));
        if (index & 1) {
                /* read modify write */
                tc_writel(cam_index - 2, &tr->CAM_Adr);
@@ -2041,7 +1992,7 @@ tc35815_set_multicast_list(struct net_device *dev)
 #ifdef WORKAROUND_100HALF_PROMISC
                /* With some (all?) 100MHalf HUB, controller will hang
                 * if we enabled promiscuous mode before linkup... */
-               struct tc35815_local *lp = dev->priv;
+               struct tc35815_local *lp = netdev_priv(dev);
                int pid = lp->phy_addr;
                if (!(tc_mdio_read(dev, pid, MII_BMSR) & BMSR_LSTATUS))
                        return;
@@ -2081,7 +2032,7 @@ tc35815_set_multicast_list(struct net_device *dev)
 
 static void tc35815_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        strcpy(info->driver, MODNAME);
        strcpy(info->version, DRV_VERSION);
        strcpy(info->bus_info, pci_name(lp->pci_dev));
@@ -2089,7 +2040,7 @@ static void tc35815_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *
 
 static int tc35815_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        spin_lock_irq(&lp->lock);
        mii_ethtool_gset(&lp->mii, cmd);
        spin_unlock_irq(&lp->lock);
@@ -2098,7 +2049,7 @@ static int tc35815_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 static int tc35815_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
 #if 1  /* use our negotiation method... */
        /* Verify the settings we care about. */
@@ -2128,7 +2079,7 @@ static int tc35815_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 static int tc35815_nway_reset(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
        spin_lock_irq(&lp->lock);
        rc = mii_nway_restart(&lp->mii);
@@ -2138,7 +2089,7 @@ static int tc35815_nway_reset(struct net_device *dev)
 
 static u32 tc35815_get_link(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
        spin_lock_irq(&lp->lock);
        rc = mii_link_ok(&lp->mii);
@@ -2148,25 +2099,31 @@ static u32 tc35815_get_link(struct net_device *dev)
 
 static u32 tc35815_get_msglevel(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        return lp->msg_enable;
 }
 
 static void tc35815_set_msglevel(struct net_device *dev, u32 datum)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        lp->msg_enable = datum;
 }
 
-static int tc35815_get_stats_count(struct net_device *dev)
+static int tc35815_get_sset_count(struct net_device *dev, int sset)
 {
-       struct tc35815_local *lp = dev->priv;
-       return sizeof(lp->lstats) / sizeof(int);
+       struct tc35815_local *lp = netdev_priv(dev);
+
+       switch (sset) {
+       case ETH_SS_STATS:
+               return sizeof(lp->lstats) / sizeof(int);
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
 static void tc35815_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        data[0] = lp->lstats.max_tx_qlen;
        data[1] = lp->lstats.tx_ints;
        data[2] = lp->lstats.rx_ints;
@@ -2196,14 +2153,13 @@ static const struct ethtool_ops tc35815_ethtool_ops = {
        .get_msglevel           = tc35815_get_msglevel,
        .set_msglevel           = tc35815_set_msglevel,
        .get_strings            = tc35815_get_strings,
-       .get_stats_count        = tc35815_get_stats_count,
+       .get_sset_count         = tc35815_get_sset_count,
        .get_ethtool_stats      = tc35815_get_ethtool_stats,
-       .get_perm_addr          = ethtool_op_get_perm_addr,
 };
 
 static int tc35815_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int rc;
 
        if (!netif_running(dev))
@@ -2275,7 +2231,7 @@ static void tc_mdio_write(struct net_device *dev, int phy_id, int location,
 
 static int tc35815_try_next_permutation(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmcr;
 
@@ -2304,7 +2260,7 @@ static int tc35815_try_next_permutation(struct net_device *dev)
 static void
 tc35815_display_link_mode(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short lpa, bmcr;
        char *speed = "", *duplex = "";
@@ -2330,7 +2286,7 @@ tc35815_display_link_mode(struct net_device *dev)
 
 static void tc35815_display_forced_link_mode(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmcr;
        char *speed = "", *duplex = "";
@@ -2352,7 +2308,7 @@ static void tc35815_display_forced_link_mode(struct net_device *dev)
 
 static void tc35815_set_link_modes(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        int pid = lp->phy_addr;
@@ -2419,7 +2375,7 @@ static void tc35815_set_link_modes(struct net_device *dev)
 static void tc35815_timer(unsigned long data)
 {
        struct net_device *dev = (struct net_device *)data;
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmsr, bmcr, lpa;
        int restart_timer = 0;
@@ -2627,7 +2583,7 @@ out:
 static void tc35815_start_auto_negotiation(struct net_device *dev,
                                           struct ethtool_cmd *ep)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmsr, bmcr, advertize;
        int timeout;
@@ -2751,7 +2707,7 @@ force_link:
 
 static void tc35815_find_phy(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short id0;
 
@@ -2780,7 +2736,7 @@ static void tc35815_find_phy(struct net_device *dev)
 
 static void tc35815_phy_chip_init(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        int pid = lp->phy_addr;
        unsigned short bmcr;
        struct ethtool_cmd ecmd, *ep;
@@ -2854,7 +2810,7 @@ static void tc35815_chip_reset(struct net_device *dev)
 
 static void tc35815_chip_init(struct net_device *dev)
 {
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        struct tc35815_regs __iomem *tr =
                (struct tc35815_regs __iomem *)dev->base_addr;
        unsigned long txctl = TX_CTL_CMD;
@@ -2916,7 +2872,7 @@ static void tc35815_chip_init(struct net_device *dev)
 static int tc35815_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        unsigned long flags;
 
        pci_save_state(pdev);
@@ -2934,7 +2890,7 @@ static int tc35815_suspend(struct pci_dev *pdev, pm_message_t state)
 static int tc35815_resume(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
-       struct tc35815_local *lp = dev->priv;
+       struct tc35815_local *lp = netdev_priv(dev);
        unsigned long flags;
 
        pci_restore_state(pdev);