diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2008-05-11 08:51:00 -0400 |
---|---|---|
committer | Francois Romieu <romieu@electric-eye.fr.zoreil.com> | 2008-06-29 09:08:28 -0400 |
commit | 865c652d6be9929927cabdc54b137b7541eb6612 (patch) | |
tree | c8ac0d480874385c9493b8b67360af6e1709b966 /drivers/net | |
parent | 1087f4f4af302e6e2fa40dd741f306444d90bece (diff) |
r8169: remove non-napi code
It will almost unavoidably cause some breakage but it
is long overdue.
The driver identification string has been updated, a
lost tabulation and some unused code have been removed.
Otherwise the code paths should stay the same.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Edward Hsu <edward_hsu@realtek.com.tw>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/Kconfig | 16 | ||||
-rw-r--r-- | drivers/net/r8169.c | 139 |
2 files changed, 41 insertions, 114 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index d85b9d067597..84925915dce4 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -2122,27 +2122,13 @@ config R8169 | |||
2122 | To compile this driver as a module, choose M here: the module | 2122 | To compile this driver as a module, choose M here: the module |
2123 | will be called r8169. This is recommended. | 2123 | will be called r8169. This is recommended. |
2124 | 2124 | ||
2125 | config R8169_NAPI | ||
2126 | bool "Use Rx Polling (NAPI) (EXPERIMENTAL)" | ||
2127 | depends on R8169 && EXPERIMENTAL | ||
2128 | help | ||
2129 | NAPI is a new driver API designed to reduce CPU and interrupt load | ||
2130 | when the driver is receiving lots of packets from the card. It is | ||
2131 | still somewhat experimental and thus not yet enabled by default. | ||
2132 | |||
2133 | If your estimated Rx load is 10kpps or more, or if the card will be | ||
2134 | deployed on potentially unfriendly networks (e.g. in a firewall), | ||
2135 | then say Y here. | ||
2136 | |||
2137 | If in doubt, say N. | ||
2138 | |||
2139 | config R8169_VLAN | 2125 | config R8169_VLAN |
2140 | bool "VLAN support" | 2126 | bool "VLAN support" |
2141 | depends on R8169 && VLAN_8021Q | 2127 | depends on R8169 && VLAN_8021Q |
2142 | ---help--- | 2128 | ---help--- |
2143 | Say Y here for the r8169 driver to support the functions required | 2129 | Say Y here for the r8169 driver to support the functions required |
2144 | by the kernel 802.1Q code. | 2130 | by the kernel 802.1Q code. |
2145 | 2131 | ||
2146 | If in doubt, say Y. | 2132 | If in doubt, say Y. |
2147 | 2133 | ||
2148 | config SB1250_MAC | 2134 | config SB1250_MAC |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 9086e819d742..cfe8829ed31f 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -28,13 +28,7 @@ | |||
28 | #include <asm/io.h> | 28 | #include <asm/io.h> |
29 | #include <asm/irq.h> | 29 | #include <asm/irq.h> |
30 | 30 | ||
31 | #ifdef CONFIG_R8169_NAPI | 31 | #define RTL8169_VERSION "2.3LK-NAPI" |
32 | #define NAPI_SUFFIX "-NAPI" | ||
33 | #else | ||
34 | #define NAPI_SUFFIX "" | ||
35 | #endif | ||
36 | |||
37 | #define RTL8169_VERSION "2.2LK" NAPI_SUFFIX | ||
38 | #define MODULENAME "r8169" | 32 | #define MODULENAME "r8169" |
39 | #define PFX MODULENAME ": " | 33 | #define PFX MODULENAME ": " |
40 | 34 | ||
@@ -57,16 +51,6 @@ | |||
57 | #define TX_BUFFS_AVAIL(tp) \ | 51 | #define TX_BUFFS_AVAIL(tp) \ |
58 | (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1) | 52 | (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1) |
59 | 53 | ||
60 | #ifdef CONFIG_R8169_NAPI | ||
61 | #define rtl8169_rx_skb netif_receive_skb | ||
62 | #define rtl8169_rx_hwaccel_skb vlan_hwaccel_receive_skb | ||
63 | #define rtl8169_rx_quota(count, quota) min(count, quota) | ||
64 | #else | ||
65 | #define rtl8169_rx_skb netif_rx | ||
66 | #define rtl8169_rx_hwaccel_skb vlan_hwaccel_rx | ||
67 | #define rtl8169_rx_quota(count, quota) count | ||
68 | #endif | ||
69 | |||
70 | /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ | 54 | /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ |
71 | static const int max_interrupt_work = 20; | 55 | static const int max_interrupt_work = 20; |
72 | 56 | ||
@@ -394,9 +378,7 @@ struct rtl8169_private { | |||
394 | void __iomem *mmio_addr; /* memory map physical address */ | 378 | void __iomem *mmio_addr; /* memory map physical address */ |
395 | struct pci_dev *pci_dev; /* Index of PCI device */ | 379 | struct pci_dev *pci_dev; /* Index of PCI device */ |
396 | struct net_device *dev; | 380 | struct net_device *dev; |
397 | #ifdef CONFIG_R8169_NAPI | ||
398 | struct napi_struct napi; | 381 | struct napi_struct napi; |
399 | #endif | ||
400 | spinlock_t lock; /* spin lock flag */ | 382 | spinlock_t lock; /* spin lock flag */ |
401 | u32 msg_enable; | 383 | u32 msg_enable; |
402 | int chipset; | 384 | int chipset; |
@@ -458,10 +440,7 @@ static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *, | |||
458 | static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); | 440 | static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); |
459 | static void rtl8169_down(struct net_device *dev); | 441 | static void rtl8169_down(struct net_device *dev); |
460 | static void rtl8169_rx_clear(struct rtl8169_private *tp); | 442 | static void rtl8169_rx_clear(struct rtl8169_private *tp); |
461 | |||
462 | #ifdef CONFIG_R8169_NAPI | ||
463 | static int rtl8169_poll(struct napi_struct *napi, int budget); | 443 | static int rtl8169_poll(struct napi_struct *napi, int budget); |
464 | #endif | ||
465 | 444 | ||
466 | static const unsigned int rtl8169_rx_config = | 445 | static const unsigned int rtl8169_rx_config = |
467 | (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); | 446 | (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift); |
@@ -843,10 +822,11 @@ static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, | |||
843 | struct sk_buff *skb) | 822 | struct sk_buff *skb) |
844 | { | 823 | { |
845 | u32 opts2 = le32_to_cpu(desc->opts2); | 824 | u32 opts2 = le32_to_cpu(desc->opts2); |
825 | struct vlan_group *vlgrp = tp->vlgrp; | ||
846 | int ret; | 826 | int ret; |
847 | 827 | ||
848 | if (tp->vlgrp && (opts2 & RxVlanTag)) { | 828 | if (vlgrp && (opts2 & RxVlanTag)) { |
849 | rtl8169_rx_hwaccel_skb(skb, tp->vlgrp, swab16(opts2 & 0xffff)); | 829 | vlan_hwaccel_receive_skb(skb, vlgrp, swab16(opts2 & 0xffff)); |
850 | ret = 0; | 830 | ret = 0; |
851 | } else | 831 | } else |
852 | ret = -1; | 832 | ret = -1; |
@@ -1764,9 +1744,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1764 | dev->change_mtu = rtl8169_change_mtu; | 1744 | dev->change_mtu = rtl8169_change_mtu; |
1765 | dev->set_mac_address = rtl_set_mac_address; | 1745 | dev->set_mac_address = rtl_set_mac_address; |
1766 | 1746 | ||
1767 | #ifdef CONFIG_R8169_NAPI | ||
1768 | netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); | 1747 | netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT); |
1769 | #endif | ||
1770 | 1748 | ||
1771 | #ifdef CONFIG_R8169_VLAN | 1749 | #ifdef CONFIG_R8169_VLAN |
1772 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | 1750 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; |
@@ -1887,9 +1865,7 @@ static int rtl8169_open(struct net_device *dev) | |||
1887 | if (retval < 0) | 1865 | if (retval < 0) |
1888 | goto err_release_ring_2; | 1866 | goto err_release_ring_2; |
1889 | 1867 | ||
1890 | #ifdef CONFIG_R8169_NAPI | ||
1891 | napi_enable(&tp->napi); | 1868 | napi_enable(&tp->napi); |
1892 | #endif | ||
1893 | 1869 | ||
1894 | rtl_hw_start(dev); | 1870 | rtl_hw_start(dev); |
1895 | 1871 | ||
@@ -2197,9 +2173,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) | |||
2197 | if (ret < 0) | 2173 | if (ret < 0) |
2198 | goto out; | 2174 | goto out; |
2199 | 2175 | ||
2200 | #ifdef CONFIG_R8169_NAPI | ||
2201 | napi_enable(&tp->napi); | 2176 | napi_enable(&tp->napi); |
2202 | #endif | ||
2203 | 2177 | ||
2204 | rtl_hw_start(dev); | 2178 | rtl_hw_start(dev); |
2205 | 2179 | ||
@@ -2391,17 +2365,13 @@ static void rtl8169_wait_for_quiescence(struct net_device *dev) | |||
2391 | synchronize_irq(dev->irq); | 2365 | synchronize_irq(dev->irq); |
2392 | 2366 | ||
2393 | /* Wait for any pending NAPI task to complete */ | 2367 | /* Wait for any pending NAPI task to complete */ |
2394 | #ifdef CONFIG_R8169_NAPI | ||
2395 | napi_disable(&tp->napi); | 2368 | napi_disable(&tp->napi); |
2396 | #endif | ||
2397 | 2369 | ||
2398 | rtl8169_irq_mask_and_ack(ioaddr); | 2370 | rtl8169_irq_mask_and_ack(ioaddr); |
2399 | 2371 | ||
2400 | #ifdef CONFIG_R8169_NAPI | ||
2401 | tp->intr_mask = 0xffff; | 2372 | tp->intr_mask = 0xffff; |
2402 | RTL_W16(IntrMask, tp->intr_event); | 2373 | RTL_W16(IntrMask, tp->intr_event); |
2403 | napi_enable(&tp->napi); | 2374 | napi_enable(&tp->napi); |
2404 | #endif | ||
2405 | } | 2375 | } |
2406 | 2376 | ||
2407 | static void rtl8169_reinit_task(struct work_struct *work) | 2377 | static void rtl8169_reinit_task(struct work_struct *work) |
@@ -2767,7 +2737,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
2767 | 2737 | ||
2768 | cur_rx = tp->cur_rx; | 2738 | cur_rx = tp->cur_rx; |
2769 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; | 2739 | rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; |
2770 | rx_left = rtl8169_rx_quota(rx_left, budget); | 2740 | rx_left = min(rx_left, budget); |
2771 | 2741 | ||
2772 | for (; rx_left > 0; rx_left--, cur_rx++) { | 2742 | for (; rx_left > 0; rx_left--, cur_rx++) { |
2773 | unsigned int entry = cur_rx % NUM_RX_DESC; | 2743 | unsigned int entry = cur_rx % NUM_RX_DESC; |
@@ -2829,7 +2799,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
2829 | skb->protocol = eth_type_trans(skb, dev); | 2799 | skb->protocol = eth_type_trans(skb, dev); |
2830 | 2800 | ||
2831 | if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0) | 2801 | if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0) |
2832 | rtl8169_rx_skb(skb); | 2802 | netif_receive_skb(skb); |
2833 | 2803 | ||
2834 | dev->last_rx = jiffies; | 2804 | dev->last_rx = jiffies; |
2835 | dev->stats.rx_bytes += pkt_size; | 2805 | dev->stats.rx_bytes += pkt_size; |
@@ -2869,87 +2839,61 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) | |||
2869 | { | 2839 | { |
2870 | struct net_device *dev = dev_instance; | 2840 | struct net_device *dev = dev_instance; |
2871 | struct rtl8169_private *tp = netdev_priv(dev); | 2841 | struct rtl8169_private *tp = netdev_priv(dev); |
2872 | int boguscnt = max_interrupt_work; | ||
2873 | void __iomem *ioaddr = tp->mmio_addr; | 2842 | void __iomem *ioaddr = tp->mmio_addr; |
2874 | int status; | ||
2875 | int handled = 0; | 2843 | int handled = 0; |
2844 | int status; | ||
2876 | 2845 | ||
2877 | do { | 2846 | status = RTL_R16(IntrStatus); |
2878 | status = RTL_R16(IntrStatus); | ||
2879 | 2847 | ||
2880 | /* hotplug/major error/no more work/shared irq */ | 2848 | /* hotplug/major error/no more work/shared irq */ |
2881 | if ((status == 0xFFFF) || !status) | 2849 | if ((status == 0xffff) || !status) |
2882 | break; | 2850 | goto out; |
2883 | 2851 | ||
2884 | handled = 1; | 2852 | handled = 1; |
2885 | 2853 | ||
2886 | if (unlikely(!netif_running(dev))) { | 2854 | if (unlikely(!netif_running(dev))) { |
2887 | rtl8169_asic_down(ioaddr); | 2855 | rtl8169_asic_down(ioaddr); |
2888 | goto out; | 2856 | goto out; |
2889 | } | 2857 | } |
2890 | 2858 | ||
2891 | status &= tp->intr_mask; | 2859 | status &= tp->intr_mask; |
2892 | RTL_W16(IntrStatus, | 2860 | RTL_W16(IntrStatus, |
2893 | (status & RxFIFOOver) ? (status | RxOverflow) : status); | 2861 | (status & RxFIFOOver) ? (status | RxOverflow) : status); |
2894 | 2862 | ||
2895 | if (!(status & tp->intr_event)) | 2863 | if (!(status & tp->intr_event)) |
2896 | break; | 2864 | goto out; |
2897 | 2865 | ||
2898 | /* Work around for rx fifo overflow */ | 2866 | /* Work around for rx fifo overflow */ |
2899 | if (unlikely(status & RxFIFOOver) && | 2867 | if (unlikely(status & RxFIFOOver) && |
2900 | (tp->mac_version == RTL_GIGA_MAC_VER_11)) { | 2868 | (tp->mac_version == RTL_GIGA_MAC_VER_11)) { |
2901 | netif_stop_queue(dev); | 2869 | netif_stop_queue(dev); |
2902 | rtl8169_tx_timeout(dev); | 2870 | rtl8169_tx_timeout(dev); |
2903 | break; | 2871 | goto out; |
2904 | } | 2872 | } |
2905 | 2873 | ||
2906 | if (unlikely(status & SYSErr)) { | 2874 | if (unlikely(status & SYSErr)) { |
2907 | rtl8169_pcierr_interrupt(dev); | 2875 | rtl8169_pcierr_interrupt(dev); |
2908 | break; | 2876 | goto out; |
2909 | } | 2877 | } |
2910 | 2878 | ||
2911 | if (status & LinkChg) | 2879 | if (status & LinkChg) |
2912 | rtl8169_check_link_status(dev, tp, ioaddr); | 2880 | rtl8169_check_link_status(dev, tp, ioaddr); |
2913 | 2881 | ||
2914 | #ifdef CONFIG_R8169_NAPI | 2882 | if (status & tp->napi_event) { |
2915 | if (status & tp->napi_event) { | 2883 | RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event); |
2916 | RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event); | 2884 | tp->intr_mask = ~tp->napi_event; |
2917 | tp->intr_mask = ~tp->napi_event; | ||
2918 | 2885 | ||
2919 | if (likely(netif_rx_schedule_prep(dev, &tp->napi))) | 2886 | if (likely(netif_rx_schedule_prep(dev, &tp->napi))) |
2920 | __netif_rx_schedule(dev, &tp->napi); | 2887 | __netif_rx_schedule(dev, &tp->napi); |
2921 | else if (netif_msg_intr(tp)) { | 2888 | else if (netif_msg_intr(tp)) { |
2922 | printk(KERN_INFO "%s: interrupt %04x in poll\n", | 2889 | printk(KERN_INFO "%s: interrupt %04x in poll\n", |
2923 | dev->name, status); | 2890 | dev->name, status); |
2924 | } | ||
2925 | } | ||
2926 | break; | ||
2927 | #else | ||
2928 | /* Rx interrupt */ | ||
2929 | if (status & (RxOK | RxOverflow | RxFIFOOver)) | ||
2930 | rtl8169_rx_interrupt(dev, tp, ioaddr, ~(u32)0); | ||
2931 | |||
2932 | /* Tx interrupt */ | ||
2933 | if (status & (TxOK | TxErr)) | ||
2934 | rtl8169_tx_interrupt(dev, tp, ioaddr); | ||
2935 | #endif | ||
2936 | |||
2937 | boguscnt--; | ||
2938 | } while (boguscnt > 0); | ||
2939 | |||
2940 | if (boguscnt <= 0) { | ||
2941 | if (netif_msg_intr(tp) && net_ratelimit() ) { | ||
2942 | printk(KERN_WARNING | ||
2943 | "%s: Too much work at interrupt!\n", dev->name); | ||
2944 | } | 2891 | } |
2945 | /* Clear all interrupt sources. */ | ||
2946 | RTL_W16(IntrStatus, 0xffff); | ||
2947 | } | 2892 | } |
2948 | out: | 2893 | out: |
2949 | return IRQ_RETVAL(handled); | 2894 | return IRQ_RETVAL(handled); |
2950 | } | 2895 | } |
2951 | 2896 | ||
2952 | #ifdef CONFIG_R8169_NAPI | ||
2953 | static int rtl8169_poll(struct napi_struct *napi, int budget) | 2897 | static int rtl8169_poll(struct napi_struct *napi, int budget) |
2954 | { | 2898 | { |
2955 | struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi); | 2899 | struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi); |
@@ -2975,7 +2919,6 @@ static int rtl8169_poll(struct napi_struct *napi, int budget) | |||
2975 | 2919 | ||
2976 | return work_done; | 2920 | return work_done; |
2977 | } | 2921 | } |
2978 | #endif | ||
2979 | 2922 | ||
2980 | static void rtl8169_down(struct net_device *dev) | 2923 | static void rtl8169_down(struct net_device *dev) |
2981 | { | 2924 | { |
@@ -2987,9 +2930,7 @@ static void rtl8169_down(struct net_device *dev) | |||
2987 | 2930 | ||
2988 | netif_stop_queue(dev); | 2931 | netif_stop_queue(dev); |
2989 | 2932 | ||
2990 | #ifdef CONFIG_R8169_NAPI | ||
2991 | napi_disable(&tp->napi); | 2933 | napi_disable(&tp->napi); |
2992 | #endif | ||
2993 | 2934 | ||
2994 | core_down: | 2935 | core_down: |
2995 | spin_lock_irq(&tp->lock); | 2936 | spin_lock_irq(&tp->lock); |