182d83d9ccc699360f6e2128392c56ca5c2b5f48
[librecmc/librecmc.git] / package / madwifi / patches / 329-new_napi.patch
1 Index: madwifi-trunk-r3314/ath/if_ath.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/ath/if_ath.c       2008-01-31 04:25:11.617671781 +0100
4 +++ madwifi-trunk-r3314/ath/if_ath.c    2008-01-31 05:06:04.606254148 +0100
5 @@ -184,7 +184,11 @@
6         struct sk_buff *, int, int, u_int64_t);
7  static void ath_setdefantenna(struct ath_softc *, u_int);
8  static struct ath_txq *ath_txq_setup(struct ath_softc *, int, int);
9 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
10 +static int ath_rx_poll(struct napi_struct *napi, int budget);
11 +#else
12  static int ath_rx_poll(struct net_device *dev, int *budget);
13 +#endif
14  static int ath_hardstart(struct sk_buff *, struct net_device *);
15  static int ath_mgtstart(struct ieee80211com *, struct sk_buff *);
16  #ifdef ATH_SUPERG_COMP
17 @@ -374,6 +378,9 @@
18                 u_int32_t new_clamped_maxtxpower);
19  static u_int32_t ath_get_real_maxtxpower(struct ath_softc *sc);
20  
21 +static void ath_poll_disable(struct net_device *dev);
22 +static void ath_poll_enable(struct net_device *dev);
23 +
24  /* calibrate every 30 secs in steady state but check every second at first. */
25  static int ath_calinterval = ATH_SHORT_CALINTERVAL;
26  static int ath_countrycode = CTRY_DEFAULT;     /* country code */
27 @@ -818,8 +825,12 @@
28         dev->set_mac_address = ath_set_mac_address;
29         dev->change_mtu = ath_change_mtu;
30         dev->tx_queue_len = ATH_TXBUF - ATH_TXBUF_MGT_RESERVED;
31 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
32 +       netif_napi_add(dev, &sc->sc_napi, ath_rx_poll, 64);
33 +#else
34         dev->poll = ath_rx_poll;
35         dev->weight = 64;
36 +#endif
37  #ifdef USE_HEADERLEN_RESV
38         dev->hard_header_len += sizeof(struct ieee80211_qosframe) +
39                                 sizeof(struct llc) +
40 @@ -2268,12 +2279,21 @@
41                 if (status & (HAL_INT_RX | HAL_INT_RXPHY)) {
42                         ath_uapsd_processtriggers(sc, hw_tsf);
43                         sc->sc_isr &= ~HAL_INT_RX;
44 -                       if (netif_rx_schedule_prep(dev)) {
45 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
46 +                       if (netif_rx_schedule_prep(dev, &sc->sc_napi))
47 +#else
48 +                       if (netif_rx_schedule_prep(dev))
49 +#endif
50 +                       {
51  #ifndef ATH_PRECISE_TSF
52                                 sc->sc_imask &= ~HAL_INT_RX;
53                                 ath_hal_intrset(ah, sc->sc_imask);
54  #endif
55 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
56 +                               __netif_rx_schedule(dev, &sc->sc_napi);
57 +#else
58                                 __netif_rx_schedule(dev);
59 +#endif
60                         }
61                 }
62                 if (status & HAL_INT_TX) {
63 @@ -2557,6 +2577,9 @@
64                 if (sc->sc_tx99 != NULL)
65                         sc->sc_tx99->stop(sc->sc_tx99);
66  #endif
67 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
68 +               ath_poll_disable(dev);
69 +#endif
70                 netif_stop_queue(dev);  /* XXX re-enabled by ath_newstate */
71                 dev->flags &= ~IFF_RUNNING;     /* NB: avoid recursion */
72                 ieee80211_stop_running(ic);     /* stop all VAPs */
73 @@ -4015,6 +4038,39 @@
74         return ath_keyset(sc, k, mac, vap->iv_bss);
75  }
76  
77 +static void ath_poll_disable(struct net_device *dev)
78 +{
79 +       struct ath_softc *sc = dev->priv;
80 +
81 +       /*
82 +        * XXX Using in_softirq is not right since we might
83 +        * be called from other soft irq contexts than
84 +        * ath_rx_poll
85 +        */
86 +       if (!in_softirq()) {
87 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
88 +               napi_disable(&sc->sc_napi);
89 +#else
90 +               netif_poll_disable(dev);
91 +#endif
92 +       }
93 +}
94 +
95 +static void ath_poll_enable(struct net_device *dev)
96 +{
97 +       struct ath_softc *sc = dev->priv;
98 +
99 +       /* NB: see above */
100 +       if (!in_softirq()) {
101 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
102 +               napi_enable(&sc->sc_napi);
103 +#else
104 +               netif_poll_enable(dev);
105 +#endif
106 +       }
107 +}
108 +
109 +
110  /*
111   * Block/unblock tx+rx processing while a key change is done.
112   * We assume the caller serializes key management operations
113 @@ -4032,13 +4088,8 @@
114          * When called from the rx tasklet we cannot use
115          * tasklet_disable because it will block waiting
116          * for us to complete execution.
117 -        *
118 -        * XXX Using in_softirq is not right since we might
119 -        * be called from other soft irq contexts than
120 -        * ath_rx_poll
121          */
122 -       if (!in_softirq())
123 -               netif_poll_disable(dev);
124 +       ath_poll_disable(dev);
125         netif_stop_queue(dev);
126  }
127  
128 @@ -4050,8 +4101,7 @@
129  
130         DPRINTF(sc, ATH_DEBUG_KEYCACHE, "End\n");
131         netif_wake_queue(dev);
132 -       if (!in_softirq())              /* NB: see above */
133 -               netif_poll_enable(dev);
134 +       ath_poll_enable(dev);
135  }
136  
137  /*
138 @@ -6359,24 +6409,34 @@
139  }
140  
141  static int
142 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
143 +ath_rx_poll(struct napi_struct *napi, int budget)
144 +#else
145  ath_rx_poll(struct net_device *dev, int *budget)
146 +#endif
147  {
148  #define        PA2DESC(_sc, _pa) \
149         ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
150                 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
151 -       struct ath_buf *bf;
152 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
153 +       struct ath_softc *sc = container_of(napi, struct ath_softc, sc_napi);
154 +       struct net_device *dev = sc->sc_dev;
155 +       u_int rx_limit = budget;
156 +#else
157         struct ath_softc *sc = dev->priv;
158 +       u_int rx_limit = dev->quota;
159 +#endif
160         struct ieee80211com *ic = &sc->sc_ic;
161         struct ath_hal *ah = sc ? sc->sc_ah : NULL;
162         struct ath_desc *ds;
163         struct ath_rx_status *rs;
164         struct sk_buff *skb = NULL;
165         struct ieee80211_node *ni;
166 +       struct ath_buf *bf;
167         unsigned int len;
168         int type;
169         u_int phyerr;
170         u_int processed = 0, early_stop = 0;
171 -       u_int rx_limit = dev->quota;
172         u_int mic_fail = 0;
173  
174         DPRINTF(sc, ATH_DEBUG_RX_PROC, "invoked\n");
175 @@ -6405,7 +6465,9 @@
176                         break;
177                 }
178  
179 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
180                 processed++;
181 +#endif
182                 if (rx_limit-- < 0) {
183                         early_stop = 1;
184                         break;
185 @@ -6675,8 +6737,6 @@
186                         goto process_rx_again;
187                 }
188  #endif
189 -               netif_rx_complete(dev);
190 -
191  #ifndef ATH_PRECISE_TSF
192                 sc->sc_imask |= HAL_INT_RX;
193                 ath_hal_intrset(ah, sc->sc_imask);
194 @@ -6684,11 +6744,17 @@
195  #endif
196         }
197  
198 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
199 +       netif_rx_complete(dev, napi);
200 +#else
201 +       netif_rx_complete(dev);
202         *budget -= processed;
203 +#endif
204  
205         /* rx signal state monitoring, only necessary/applicable for sta mode */
206         if (sc->sc_opmode == HAL_M_STA)
207                 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
208 +
209         return early_stop;
210  #undef PA2DESC
211  }
212 @@ -10395,9 +10461,9 @@
213         dev->mtu = mtu;
214         if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
215                 /* NB: the rx buffers may need to be reallocated */
216 -               netif_poll_disable(dev);
217 +               ath_poll_disable(dev);
218                 error = ath_reset(dev);
219 -               netif_poll_enable(dev);
220 +               ath_poll_enable(dev);
221         }
222         ATH_UNLOCK(sc);
223  
224 Index: madwifi-trunk-r3314/ath/if_athvar.h
225 ===================================================================
226 --- madwifi-trunk-r3314.orig/ath/if_athvar.h    2008-01-31 04:25:14.001807644 +0100
227 +++ madwifi-trunk-r3314/ath/if_athvar.h 2008-01-31 04:32:31.858759693 +0100
228 @@ -620,6 +620,9 @@
229  struct ath_softc {
230         struct ieee80211com sc_ic;              /* NB: must be first */
231         struct net_device *sc_dev;
232 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
233 +       struct napi_struct sc_napi;
234 +#endif
235         void __iomem *sc_iobase;                /* address of the device */
236         struct semaphore sc_lock;               /* dev-level lock */
237         struct net_device_stats sc_devstats;    /* device statistics */