diff -c ./r8168.h ../../r8168-8.005.00.new/src/r8168.h *** ./r8168.h 2008-01-09 05:27:22.000000000 -0800 --- ../../r8168-8.005.00.new/src/r8168.h 2008-04-14 15:20:55.000000000 -0700 *************** *** 942,947 **** --- 942,948 ---- 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 */ diff -c ./r8168_n.c ../../r8168-8.005.00.new/src/r8168_n.c *** ./r8168_n.c 2008-01-09 05:28:01.000000000 -0800 --- ../../r8168-8.005.00.new/src/r8168_n.c 2008-04-14 15:30:02.000000000 -0700 *************** *** 168,174 **** 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_change_mtu(struct net_device *dev, int new_mtu); static void rtl8168_down(struct net_device *dev); --- 168,174 ---- 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 *, u32 budget); static int rtl8168_change_mtu(struct net_device *dev, int new_mtu); static void rtl8168_down(struct net_device *dev); *************** *** 184,190 **** #ifdef CONFIG_R8168_NAPI ! static int rtl8168_poll(struct net_device *dev, int *budget); #endif static u16 rtl8168_intr_mask = --- 184,190 ---- #ifdef CONFIG_R8168_NAPI ! static int rtl8168_poll(struct napi_struct *napi, int budget); #endif static u16 rtl8168_intr_mask = *************** *** 2266,2273 **** #endif //LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) goto err_out; } ! ! SET_MODULE_OWNER(dev); SET_NETDEV_DEV(dev, &pdev->dev); tp = netdev_priv(dev); tp->dev = dev; --- 2266,2274 ---- #endif //LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) goto err_out; } ! #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; *************** *** 2567,2574 **** dev->do_ioctl = rtl8168_do_ioctl; #ifdef CONFIG_R8168_NAPI ! dev->poll = rtl8168_poll; ! dev->weight = R8168_NAPI_WEIGHT; #endif #ifdef CONFIG_R8168_VLAN --- 2568,2576 ---- dev->do_ioctl = rtl8168_do_ioctl; #ifdef CONFIG_R8168_NAPI ! /* 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 *************** *** 2699,2704 **** --- 2701,2708 ---- INIT_DELAYED_WORK(&tp->task, NULL); #endif + napi_enable(&tp->napi); + rtl8168_hw_start(dev); if (tp->esd_flag == 0) { *************** *** 3073,3081 **** goto out; #ifdef NAPI ! netif_poll_enable(dev); #endif ! rtl8168_hw_start(dev); out: --- 3077,3085 ---- goto out; #ifdef NAPI ! /* netif_poll_enable(dev);*/ #endif ! napi_enable(&tp->napi); rtl8168_hw_start(dev); out: *************** *** 3328,3341 **** /* Wait for any pending NAPI task to complete */ #ifdef NAPI ! netif_poll_disable(dev); #endif ! rtl8168_irq_mask_and_ack(ioaddr); #ifdef NAPI ! netif_poll_enable(dev); #endif } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) --- 3332,3346 ---- /* Wait for any pending NAPI task to complete */ #ifdef NAPI ! /* netif_poll_disable(dev);*/ #endif ! napi_disable(&tp->napi); rtl8168_irq_mask_and_ack(ioaddr); #ifdef NAPI ! /* netif_poll_enable(dev);*/ #endif + napi_enable(&tp->napi); } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) *************** *** 3391,3397 **** rtl8168_wait_for_quiescence(dev); ! rtl8168_rx_interrupt(dev, tp, tp->mmio_addr); rtl8168_tx_clear(tp); if (tp->dirty_rx == tp->cur_rx) { --- 3396,3402 ---- rtl8168_wait_for_quiescence(dev); ! rtl8168_rx_interrupt(dev, tp, tp->mmio_addr, ~(u32)0); rtl8168_tx_clear(tp); if (tp->dirty_rx == tp->cur_rx) { *************** *** 3776,3782 **** static int rtl8168_rx_interrupt(struct net_device *dev, struct rtl8168_private *tp, ! void __iomem *ioaddr) { unsigned int cur_rx, rx_left; unsigned int delta, count = 0; --- 3781,3788 ---- static int rtl8168_rx_interrupt(struct net_device *dev, struct rtl8168_private *tp, ! void __iomem *ioaddr, ! u32 budget) { unsigned int cur_rx, rx_left; unsigned int delta, count = 0; *************** *** 3787,3793 **** 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); if ((tp->RxDescArray == NULL) || (tp->Rx_skbuff == NULL)) { goto rx_out; --- 3793,3799 ---- cur_rx = tp->cur_rx; rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; ! rx_left = rtl8168_rx_quota(rx_left, budget); if ((tp->RxDescArray == NULL) || (tp->Rx_skbuff == NULL)) { goto rx_out; *************** *** 3983,3990 **** RTL_W16(IntrMask, rtl8168_intr_mask & ~rtl8168_napi_event); tp->intr_mask = ~rtl8168_napi_event; ! if (likely(netif_rx_schedule_prep(dev))) __netif_rx_schedule(dev); else if (netif_msg_intr(tp)) { printk(KERN_INFO "%s: interrupt %04x taken in poll\n", dev->name, status); --- 3989,3999 ---- RTL_W16(IntrMask, rtl8168_intr_mask & ~rtl8168_napi_event); tp->intr_mask = ~rtl8168_napi_event; ! /* 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); *************** *** 3993,3999 **** #else /* Rx interrupt */ if (status & (RxOK | RxDescUnavail | RxFIFOOver)) { ! rtl8168_rx_interrupt(dev, tp, ioaddr); } /* Tx interrupt */ if (status & (TxOK | TxErr)) --- 4002,4008 ---- #else /* Rx interrupt */ if (status & (RxOK | RxDescUnavail | RxFIFOOver)) { ! rtl8168_rx_interrupt(dev, tp, ioaddr, ~(u32)0); } /* Tx interrupt */ if (status & (TxOK | TxErr)) *************** *** 4029,4049 **** #ifdef CONFIG_R8168_NAPI static int ! rtl8168_poll(struct net_device *dev, ! int *budget) { ! unsigned int work_done, work_to_do = min(*budget, dev->quota); struct rtl8168_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; ! work_done = rtl8168_rx_interrupt(dev, tp, ioaddr); rtl8168_tx_interrupt(dev, tp, ioaddr); ! *budget -= work_done; dev->quota -= work_done; ! if (work_done < work_to_do) { ! netif_rx_complete(dev); tp->intr_mask = rtl8168_intr_mask; /* * 20040426: the barrier is not strictly required but the --- 4038,4063 ---- #ifdef CONFIG_R8168_NAPI static int ! rtl8168_poll(struct napi_struct *napi, ! int budget) { ! /* 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, (u32) budget); rtl8168_tx_interrupt(dev, tp, ioaddr); ! /* *budget -= work_done; dev->quota -= work_done; + */ ! if (work_done < budget) { ! netif_rx_complete(dev, napi); tp->intr_mask = rtl8168_intr_mask; /* * 20040426: the barrier is not strictly required but the *************** *** 4055,4061 **** RTL_W16(IntrMask, rtl8168_intr_mask); } ! return (work_done >= work_to_do); } #endif --- 4069,4075 ---- RTL_W16(IntrMask, rtl8168_intr_mask); } ! return work_done; } #endif *************** *** 4083,4090 **** if (!poll_locked) { #ifdef NAPI ! netif_poll_disable(dev); #endif poll_locked++; } --- 4097,4105 ---- if (!poll_locked) { #ifdef NAPI ! /* netif_poll_disable(dev);*/ #endif + napi_disable(&tp->napi); poll_locked++; } *************** *** 4123,4129 **** free_irq(dev->irq, dev); #ifdef NAPI ! netif_poll_enable(dev); #endif pci_free_consistent(pdev, R8168_RX_RING_BYTES, tp->RxDescArray, --- 4138,4144 ---- free_irq(dev->irq, dev); #ifdef NAPI ! /* netif_poll_enable(dev);*/ #endif pci_free_consistent(pdev, R8168_RX_RING_BYTES, tp->RxDescArray,