--- src/r8168.h~ 2008-04-01 09:26:11.000000000 +0200 +++ src/r8168.h 2008-04-25 21:02:18.000000000 +0200 @@ -957,6 +957,7 @@ void __iomem *mmio_addr; /* memory map physical address */ struct pci_dev *pci_dev; /* Index of PCI device */ struct net_device *dev; + struct napi_struct napi; struct net_device_stats stats; /* statistics of net device */ spinlock_t lock; /* spin lock flag */ spinlock_t phy_lock; /* spin lock flag for GPHY */ --- src/r8168_n.c~ 2008-04-01 09:30:28.000000000 +0200 +++ src/r8168_n.c 2008-04-25 21:02:18.000000000 +0200 @@ -168,7 +168,7 @@ static void rtl8168_set_rx_mode(struct net_device *dev); static void rtl8168_tx_timeout(struct net_device *dev); static struct net_device_stats *rtl8168_get_stats(struct net_device *dev); -static int rtl8168_rx_interrupt(struct net_device *, struct rtl8168_private *, void __iomem *); +static int rtl8168_rx_interrupt(struct net_device *, struct rtl8168_private *, void __iomem *, u32 budget); static int rtl8168_change_mtu(struct net_device *dev, int new_mtu); static void rtl8168_down(struct net_device *dev); @@ -184,7 +184,7 @@ #ifdef CONFIG_R8168_NAPI -static int rtl8168_poll(struct net_device *dev, int *budget); +static int rtl8168_poll(struct napi_struct *napi, int budget); #endif static u16 rtl8168_intr_mask = @@ -2296,8 +2296,9 @@ #endif //LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) goto err_out; } - - SET_MODULE_OWNER(dev); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) && defined(SET_MODULE_OWNER) + SET_MODULE_OWNER(dev); +#endif SET_NETDEV_DEV(dev, &pdev->dev); tp = netdev_priv(dev); tp->dev = dev; @@ -2597,8 +2598,9 @@ dev->do_ioctl = rtl8168_do_ioctl; #ifdef CONFIG_R8168_NAPI - dev->poll = rtl8168_poll; - dev->weight = R8168_NAPI_WEIGHT; +/* dev->poll = rtl8168_poll; */ +/* dev->weight = R8168_NAPI_WEIGHT; */ + netif_napi_add(dev, &tp->napi, rtl8168_poll, R8168_NAPI_WEIGHT); #endif #ifdef CONFIG_R8168_VLAN @@ -2732,6 +2734,8 @@ INIT_DELAYED_WORK(&tp->task, NULL); #endif + napi_enable(&tp->napi); + rtl8168_hw_start(dev); if (tp->esd_flag == 0) { @@ -3312,9 +3316,9 @@ } #ifdef NAPI - netif_poll_enable(dev); +/* netif_poll_enable(dev);*/ #endif - + napi_enable(&tp->napi); rtl8168_hw_start(dev); out: @@ -3567,14 +3571,15 @@ /* Wait for any pending NAPI task to complete */ #ifdef NAPI - netif_poll_disable(dev); +/* netif_poll_disable(dev);*/ #endif - + napi_disable(&tp->napi); rtl8168_irq_mask_and_ack(ioaddr); #ifdef NAPI - netif_poll_enable(dev); +/* netif_poll_enable(dev);*/ #endif + napi_enable(&tp->napi); } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) @@ -3630,7 +3635,7 @@ rtl8168_wait_for_quiescence(dev); - rtl8168_rx_interrupt(dev, tp, tp->mmio_addr); + rtl8168_rx_interrupt(dev, tp, tp->mmio_addr, ~(u32)0); rtl8168_tx_clear(tp); if (tp->dirty_rx == tp->cur_rx) { @@ -4015,7 +4020,8 @@ static int rtl8168_rx_interrupt(struct net_device *dev, struct rtl8168_private *tp, - void __iomem *ioaddr) + void __iomem *ioaddr, + u32 budget) { unsigned int cur_rx, rx_left; unsigned int delta, count = 0; @@ -4026,7 +4032,7 @@ cur_rx = tp->cur_rx; rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; - rx_left = rtl8168_rx_quota(rx_left, (u32) dev->quota); + rx_left = rtl8168_rx_quota(rx_left, budget); if ((tp->RxDescArray == NULL) || (tp->Rx_skbuff == NULL)) { goto rx_out; @@ -4222,8 +4228,11 @@ RTL_W16(IntrMask, rtl8168_intr_mask & ~rtl8168_napi_event); tp->intr_mask = ~rtl8168_napi_event; - if (likely(netif_rx_schedule_prep(dev))) +/* if (likely(netif_rx_schedule_prep(dev))) __netif_rx_schedule(dev); +*/ + if (likely(netif_rx_schedule_prep(dev, &tp->napi))) + __netif_rx_schedule(dev, &tp->napi); else if (netif_msg_intr(tp)) { printk(KERN_INFO "%s: interrupt %04x taken in poll\n", dev->name, status); @@ -4232,7 +4241,7 @@ #else /* Rx interrupt */ if (status & (RxOK | RxDescUnavail | RxFIFOOver)) { - rtl8168_rx_interrupt(dev, tp, ioaddr); + rtl8168_rx_interrupt(dev, tp, ioaddr, ~(u32)0); } /* Tx interrupt */ if (status & (TxOK | TxErr)) @@ -4268,21 +4277,26 @@ #ifdef CONFIG_R8168_NAPI static int -rtl8168_poll(struct net_device *dev, - int *budget) +rtl8168_poll(struct napi_struct *napi, + int budget) { - unsigned int work_done, work_to_do = min(*budget, dev->quota); +/* unsigned int work_done, work_to_do = min(*budget, dev->quota); struct rtl8168_private *tp = netdev_priv(dev); +*/ + struct rtl8168_private *tp = container_of(napi, struct rtl8168_private, napi); + struct net_device *dev = tp->dev; void __iomem *ioaddr = tp->mmio_addr; + int work_done; - work_done = rtl8168_rx_interrupt(dev, tp, ioaddr); + work_done = rtl8168_rx_interrupt(dev, tp, ioaddr, (u32) budget); rtl8168_tx_interrupt(dev, tp, ioaddr); - *budget -= work_done; +/* *budget -= work_done; dev->quota -= work_done; +*/ - if (work_done < work_to_do) { - netif_rx_complete(dev); + if (work_done < budget) { + netif_rx_complete(dev, napi); tp->intr_mask = rtl8168_intr_mask; /* * 20040426: the barrier is not strictly required but the @@ -4294,7 +4308,7 @@ RTL_W16(IntrMask, rtl8168_intr_mask); } - return (work_done >= work_to_do); + return work_done; } #endif @@ -4322,8 +4336,9 @@ if (!poll_locked) { #ifdef NAPI - netif_poll_disable(dev); +/* netif_poll_disable(dev);*/ #endif + napi_disable(&tp->napi); poll_locked++; } @@ -4362,7 +4377,7 @@ free_irq(dev->irq, dev); #ifdef NAPI - netif_poll_enable(dev); +/* netif_poll_enable(dev);*/ #endif pci_free_consistent(pdev, R8168_RX_RING_BYTES, tp->RxDescArray,