Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.git] / drivers / net / epic100.c
index 1197784..0b365b8 100644 (file)
@@ -262,6 +262,7 @@ struct epic_private {
        /* Ring pointers. */
        spinlock_t lock;                                /* Group with Tx control cache line. */
        spinlock_t napi_lock;
+       struct napi_struct napi;
        unsigned int reschedule_in_poll;
        unsigned int cur_tx, dirty_tx;
 
@@ -294,7 +295,7 @@ static void epic_tx_timeout(struct net_device *dev);
 static void epic_init_ring(struct net_device *dev);
 static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int epic_rx(struct net_device *dev, int budget);
-static int epic_poll(struct net_device *dev, int *budget);
+static int epic_poll(struct napi_struct *napi, int budget);
 static irqreturn_t epic_interrupt(int irq, void *dev_instance);
 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static const struct ethtool_ops netdev_ethtool_ops;
@@ -316,6 +317,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
        int i, ret, option = 0, duplex = 0;
        void *ring_space;
        dma_addr_t ring_dma;
+       DECLARE_MAC_BUF(mac);
 
 /* when built into the kernel, we only print version if device is found */
 #ifndef MODULE
@@ -351,7 +353,6 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
                dev_err(&pdev->dev, "no memory for eth device\n");
                goto err_out_free_res;
        }
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
 #ifdef USE_IO_OPS
@@ -487,18 +488,15 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
        dev->ethtool_ops = &netdev_ethtool_ops;
        dev->watchdog_timeo = TX_TIMEOUT;
        dev->tx_timeout = &epic_tx_timeout;
-       dev->poll = epic_poll;
-       dev->weight = 64;
+       netif_napi_add(dev, &ep->napi, epic_poll, 64);
 
        ret = register_netdev(dev);
        if (ret < 0)
                goto err_out_unmap_rx;
 
-       printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ",
-                  dev->name, pci_id_tbl[chip_idx].name, ioaddr, dev->irq);
-       for (i = 0; i < 5; i++)
-               printk("%2.2x:", dev->dev_addr[i]);
-       printk("%2.2x.\n", dev->dev_addr[i]);
+       printk(KERN_INFO "%s: %s at %#lx, IRQ %d, %s\n",
+              dev->name, pci_id_tbl[chip_idx].name, ioaddr, dev->irq,
+              print_mac(mac, dev->dev_addr));
 
 out:
        return ret;
@@ -660,8 +658,11 @@ static int epic_open(struct net_device *dev)
        /* Soft reset the chip. */
        outl(0x4001, ioaddr + GENCTL);
 
-       if ((retval = request_irq(dev->irq, &epic_interrupt, IRQF_SHARED, dev->name, dev)))
+       napi_enable(&ep->napi);
+       if ((retval = request_irq(dev->irq, &epic_interrupt, IRQF_SHARED, dev->name, dev))) {
+               napi_disable(&ep->napi);
                return retval;
+       }
 
        epic_init_ring(dev);
 
@@ -1103,9 +1104,9 @@ static irqreturn_t epic_interrupt(int irq, void *dev_instance)
 
        if ((status & EpicNapiEvent) && !ep->reschedule_in_poll) {
                spin_lock(&ep->napi_lock);
-               if (netif_rx_schedule_prep(dev)) {
+               if (netif_rx_schedule_prep(dev, &ep->napi)) {
                        epic_napi_irq_off(dev, ep);
-                       __netif_rx_schedule(dev);
+                       __netif_rx_schedule(dev, &ep->napi);
                } else
                        ep->reschedule_in_poll++;
                spin_unlock(&ep->napi_lock);
@@ -1257,26 +1258,22 @@ static void epic_rx_err(struct net_device *dev, struct epic_private *ep)
                outw(RxQueued, ioaddr + COMMAND);
 }
 
-static int epic_poll(struct net_device *dev, int *budget)
+static int epic_poll(struct napi_struct *napi, int budget)
 {
-       struct epic_private *ep = dev->priv;
-       int work_done = 0, orig_budget;
+       struct epic_private *ep = container_of(napi, struct epic_private, napi);
+       struct net_device *dev = ep->mii.dev;
+       int work_done = 0;
        long ioaddr = dev->base_addr;
 
-       orig_budget = (*budget > dev->quota) ? dev->quota : *budget;
-
 rx_action:
 
        epic_tx(dev, ep);
 
-       work_done += epic_rx(dev, *budget);
+       work_done += epic_rx(dev, budget);
 
        epic_rx_err(dev, ep);
 
-       *budget -= work_done;
-       dev->quota -= work_done;
-
-       if (netif_running(dev) && (work_done < orig_budget)) {
+       if (work_done < budget) {
                unsigned long flags;
                int more;
 
@@ -1286,7 +1283,7 @@ rx_action:
 
                more = ep->reschedule_in_poll;
                if (!more) {
-                       __netif_rx_complete(dev);
+                       __netif_rx_complete(dev, napi);
                        outl(EpicNapiEvent, ioaddr + INTSTAT);
                        epic_napi_irq_on(dev, ep);
                } else
@@ -1298,7 +1295,7 @@ rx_action:
                        goto rx_action;
        }
 
-       return (work_done >= orig_budget);
+       return work_done;
 }
 
 static int epic_close(struct net_device *dev)
@@ -1309,6 +1306,7 @@ static int epic_close(struct net_device *dev)
        int i;
 
        netif_stop_queue(dev);
+       napi_disable(&ep->napi);
 
        if (debug > 1)
                printk(KERN_DEBUG "%s: Shutting down ethercard, status was %2.2x.\n",
@@ -1495,8 +1493,6 @@ static const struct ethtool_ops netdev_ethtool_ops = {
        .get_link               = netdev_get_link,
        .get_msglevel           = netdev_get_msglevel,
        .set_msglevel           = netdev_set_msglevel,
-       .get_sg                 = ethtool_op_get_sg,
-       .get_tx_csum            = ethtool_op_get_tx_csum,
        .begin                  = ethtool_begin,
        .complete               = ethtool_complete
 };