1 Index: madwifi-trunk-r3314/ath/if_ath.c
2 ===================================================================
3 --- madwifi-trunk-r3314.orig/ath/if_ath.c
4 +++ madwifi-trunk-r3314/ath/if_ath.c
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 -static void ath_rx_tasklet(TQUEUE_ARG);
10 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
11 +static int ath_rx_poll(struct napi_struct *napi, int budget);
13 +static int ath_rx_poll(struct net_device *dev, int *budget);
15 static int ath_hardstart(struct sk_buff *, struct net_device *);
16 static int ath_mgtstart(struct ieee80211com *, struct sk_buff *);
17 #ifdef ATH_SUPERG_COMP
19 u_int32_t new_clamped_maxtxpower);
20 static u_int32_t ath_get_real_maxtxpower(struct ath_softc *sc);
22 +static void ath_poll_disable(struct net_device *dev);
23 +static void ath_poll_enable(struct net_device *dev);
25 /* calibrate every 30 secs in steady state but check every second at first. */
26 static int ath_calinterval = ATH_SHORT_CALINTERVAL;
27 static int ath_countrycode = CTRY_DEFAULT; /* country code */
30 atomic_set(&sc->sc_txbuf_counter, 0);
32 - ATH_INIT_TQUEUE(&sc->sc_rxtq, ath_rx_tasklet, dev);
33 ATH_INIT_TQUEUE(&sc->sc_txtq, ath_tx_tasklet, dev);
34 ATH_INIT_TQUEUE(&sc->sc_bmisstq, ath_bmiss_tasklet, dev);
35 ATH_INIT_TQUEUE(&sc->sc_bstucktq, ath_bstuck_tasklet, dev);
37 dev->set_mac_address = ath_set_mac_address;
38 dev->change_mtu = ath_change_mtu;
39 dev->tx_queue_len = ATH_TXBUF - ATH_TXBUF_MGT_RESERVED;
40 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
41 + netif_napi_add(dev, &sc->sc_napi, ath_rx_poll, 64);
43 + dev->poll = ath_rx_poll;
46 #ifdef USE_HEADERLEN_RESV
47 dev->hard_header_len += sizeof(struct ieee80211_qosframe) +
50 (status & HAL_INT_GLOBAL) ? " HAL_INT_GLOBAL" : ""
53 + sc->sc_isr = status;
54 status &= sc->sc_imask; /* discard unasked for bits */
55 /* As soon as we know we have a real interrupt we intend to service,
56 * we will check to see if we need an initial hardware TSF reading.
57 @@ -2273,7 +2286,23 @@
59 if (status & (HAL_INT_RX | HAL_INT_RXPHY)) {
60 ath_uapsd_processtriggers(sc, hw_tsf);
61 - ATH_SCHEDULE_TQUEUE(&sc->sc_rxtq, &needmark);
62 + sc->sc_isr &= ~HAL_INT_RX;
63 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
64 + if (netif_rx_schedule_prep(dev, &sc->sc_napi))
66 + if (netif_rx_schedule_prep(dev))
69 +#ifndef ATH_PRECISE_TSF
70 + sc->sc_imask &= ~HAL_INT_RX;
71 + ath_hal_intrset(ah, sc->sc_imask);
73 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
74 + __netif_rx_schedule(dev, &sc->sc_napi);
76 + __netif_rx_schedule(dev);
80 if (status & HAL_INT_TX) {
81 #ifdef ATH_SUPERG_DYNTURBO
82 @@ -2299,6 +2328,11 @@
86 + /* disable transmit interrupt */
87 + sc->sc_isr &= ~HAL_INT_TX;
88 + ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_TX);
89 + sc->sc_imask &= ~HAL_INT_TX;
91 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, &needmark);
93 if (status & HAL_INT_BMISS) {
95 if (sc->sc_tx99 != NULL)
96 sc->sc_tx99->start(sc->sc_tx99);
98 + ath_poll_enable(dev);
102 @@ -2551,6 +2586,9 @@
103 if (sc->sc_tx99 != NULL)
104 sc->sc_tx99->stop(sc->sc_tx99);
106 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
107 + ath_poll_disable(dev);
109 netif_stop_queue(dev); /* XXX re-enabled by ath_newstate */
110 dev->flags &= ~IFF_RUNNING; /* NB: avoid recursion */
111 ieee80211_stop_running(ic); /* stop all VAPs */
112 @@ -4009,6 +4047,39 @@
113 return ath_keyset(sc, k, mac, vap->iv_bss);
116 +static void ath_poll_disable(struct net_device *dev)
118 + struct ath_softc *sc = dev->priv;
121 + * XXX Using in_softirq is not right since we might
122 + * be called from other soft irq contexts than
125 + if (!in_softirq()) {
126 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
127 + napi_disable(&sc->sc_napi);
129 + netif_poll_disable(dev);
134 +static void ath_poll_enable(struct net_device *dev)
136 + struct ath_softc *sc = dev->priv;
138 + /* NB: see above */
139 + if (!in_softirq()) {
140 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
141 + napi_enable(&sc->sc_napi);
143 + netif_poll_enable(dev);
150 * Block/unblock tx+rx processing while a key change is done.
151 * We assume the caller serializes key management operations
152 @@ -4026,13 +4097,7 @@
153 * When called from the rx tasklet we cannot use
154 * tasklet_disable because it will block waiting
155 * for us to complete execution.
157 - * XXX Using in_softirq is not right since we might
158 - * be called from other soft irq contexts than
162 - tasklet_disable(&sc->sc_rxtq);
163 netif_stop_queue(dev);
166 @@ -4043,9 +4108,9 @@
167 struct ath_softc *sc = dev->priv;
169 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "End\n");
170 - netif_wake_queue(dev);
171 - if (!in_softirq()) /* NB: see above */
172 - tasklet_enable(&sc->sc_rxtq);
174 + if (dev->flags&IFF_RUNNING)
175 + netif_wake_queue(dev);
179 @@ -6350,15 +6415,25 @@
180 sc->sc_rxotherant = 0;
184 -ath_rx_tasklet(TQUEUE_ARG data)
186 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
187 +ath_rx_poll(struct napi_struct *napi, int budget)
189 +ath_rx_poll(struct net_device *dev, int *budget)
192 #define PA2DESC(_sc, _pa) \
193 ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
194 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
195 - struct net_device *dev = (struct net_device *)data;
196 - struct ath_buf *bf;
197 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
198 + struct ath_softc *sc = container_of(napi, struct ath_softc, sc_napi);
199 + struct net_device *dev = sc->sc_dev;
200 + u_int rx_limit = budget;
202 struct ath_softc *sc = dev->priv;
203 + u_int rx_limit = min(dev->quota, *budget);
205 + struct ath_buf *bf;
206 struct ieee80211com *ic = &sc->sc_ic;
207 struct ath_hal *ah = sc ? sc->sc_ah : NULL;
209 @@ -6368,8 +6443,10 @@
213 + u_int processed = 0, early_stop = 0;
215 DPRINTF(sc, ATH_DEBUG_RX_PROC, "invoked\n");
218 bf = STAILQ_FIRST(&sc->sc_rxbuf);
219 if (bf == NULL) { /* XXX ??? can this happen */
220 @@ -6393,6 +6470,15 @@
221 /* NB: never process the self-linked entry at the end */
225 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
228 + if (rx_limit-- < 0) {
235 EPRINTF(sc, "Dropping; buffer contains NULL skbuff.\n");
236 @@ -6440,6 +6526,7 @@
237 sc->sc_stats.ast_rx_phyerr++;
238 phyerr = rs->rs_phyerr & 0x1f;
239 sc->sc_stats.ast_rx_phy[phyerr]++;
242 if (rs->rs_status & HAL_RXERR_DECRYPT) {
244 @@ -6635,9 +6722,43 @@
245 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
246 ATH_RXBUF_UNLOCK_IRQ(sc);
247 } while (ath_rxbuf_init(sc, bf) == 0);
249 + unsigned long flags;
250 + /* Check if more data is received while we were
251 + * processing the descriptor chain.
253 +#ifndef ATH_PRECISE_TSF
254 + local_irq_save(flags);
255 + if (sc->sc_isr & HAL_INT_RX) {
256 + u_int64_t hw_tsf = ath_hal_gettsf64(ah);
257 + sc->sc_isr &= ~HAL_INT_RX;
258 + local_irq_restore(flags);
259 + ath_uapsd_processtriggers(sc, hw_tsf);
260 + goto process_rx_again;
263 +#ifndef ATH_PRECISE_TSF
264 + sc->sc_imask |= HAL_INT_RX;
265 + ath_hal_intrset(ah, sc->sc_imask);
266 + local_irq_restore(flags);
270 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
271 + netif_rx_complete(dev, napi);
273 + netif_rx_complete(dev);
274 + *budget -= processed;
275 + dev->quota -= processed;
278 /* rx signal state monitoring */
279 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
280 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
288 @@ -8288,12 +8409,24 @@
290 struct net_device *dev = (struct net_device *)data;
291 struct ath_softc *sc = dev->priv;
292 + unsigned long flags;
295 if (txqactive(sc->sc_ah, 0))
296 ath_tx_processq(sc, &sc->sc_txq[0]);
297 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum))
298 ath_tx_processq(sc, sc->sc_cabq);
300 + local_irq_save(flags);
301 + if (sc->sc_isr & HAL_INT_TX) {
302 + sc->sc_isr &= ~HAL_INT_TX;
303 + local_irq_restore(flags);
304 + goto process_tx_again;
306 + sc->sc_imask |= HAL_INT_TX;
307 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
308 + local_irq_restore(flags);
310 netif_wake_queue(dev);
313 @@ -8309,7 +8442,9 @@
315 struct net_device *dev = (struct net_device *)data;
316 struct ath_softc *sc = dev->priv;
317 + unsigned long flags;
321 * Process each active queue.
323 @@ -8330,6 +8465,16 @@
324 if (sc->sc_uapsdq && txqactive(sc->sc_ah, sc->sc_uapsdq->axq_qnum))
325 ath_tx_processq(sc, sc->sc_uapsdq);
327 + local_irq_save(flags);
328 + if (sc->sc_isr & HAL_INT_TX) {
329 + sc->sc_isr &= ~HAL_INT_TX;
330 + local_irq_restore(flags);
331 + goto process_tx_again;
333 + sc->sc_imask |= HAL_INT_TX;
334 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
335 + local_irq_restore(flags);
337 netif_wake_queue(dev);
340 @@ -8345,13 +8490,25 @@
341 struct net_device *dev = (struct net_device *)data;
342 struct ath_softc *sc = dev->priv;
344 + unsigned long flags;
346 /* Process each active queue. This includes sc_cabq, sc_xrtq and
349 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
350 if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i))
351 ath_tx_processq(sc, &sc->sc_txq[i]);
353 + local_irq_save(flags);
354 + if (sc->sc_isr & HAL_INT_TX) {
355 + sc->sc_isr &= ~HAL_INT_TX;
356 + local_irq_restore(flags);
357 + goto process_tx_again;
359 + sc->sc_imask |= HAL_INT_TX;
360 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
361 + local_irq_restore(flags);
363 netif_wake_queue(dev);
366 @@ -10284,9 +10441,9 @@
368 if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
369 /* NB: the rx buffers may need to be reallocated */
370 - tasklet_disable(&sc->sc_rxtq);
371 + ath_poll_disable(dev);
372 error = ath_reset(dev);
373 - tasklet_enable(&sc->sc_rxtq);
374 + ath_poll_enable(dev);
378 Index: madwifi-trunk-r3314/ath/if_athvar.h
379 ===================================================================
380 --- madwifi-trunk-r3314.orig/ath/if_athvar.h
381 +++ madwifi-trunk-r3314/ath/if_athvar.h
383 # include <asm/bitops.h>
386 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
387 +#define irqs_disabled() 0
391 * Deduce if tasklets are available. If not then
392 * fall back to using the immediate work queue.
395 struct ieee80211com sc_ic; /* NB: must be first */
396 struct net_device *sc_dev;
397 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
398 + struct napi_struct sc_napi;
400 void __iomem *sc_iobase; /* address of the device */
401 struct semaphore sc_lock; /* dev-level lock */
402 struct net_device_stats sc_devstats; /* device statistics */
404 struct ath_buf *sc_rxbufcur; /* current rx buffer */
405 u_int32_t *sc_rxlink; /* link ptr in last RX desc */
406 spinlock_t sc_rxbuflock;
407 - struct ATH_TQ_STRUCT sc_rxtq; /* rx intr tasklet */
408 struct ATH_TQ_STRUCT sc_rxorntq; /* rxorn intr tasklet */
409 u_int8_t sc_defant; /* current default antenna */
410 u_int8_t sc_rxotherant; /* RXs on non-default antenna */
412 u_int sc_txintrperiod; /* tx interrupt batching */
413 struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
414 struct ath_txq *sc_ac2q[WME_NUM_AC]; /* WME AC -> h/w qnum */
415 + HAL_INT sc_isr; /* unmasked ISR state */
416 struct ATH_TQ_STRUCT sc_txtq; /* tx intr tasklet */
417 u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];
418 struct ath_descdma sc_bdma; /* beacon descriptors */
420 #define ATH_TXBUF_LOCK_CHECK(_sc)
423 +#define ATH_DISABLE_INTR local_irq_disable
424 +#define ATH_ENABLE_INTR local_irq_enable
426 #define ATH_RXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_rxbuflock)
427 #define ATH_RXBUF_LOCK_DESTROY(_sc)
428 Index: madwifi-trunk-r3314/net80211/ieee80211_input.c
429 ===================================================================
430 --- madwifi-trunk-r3314.orig/net80211/ieee80211_input.c
431 +++ madwifi-trunk-r3314/net80211/ieee80211_input.c
432 @@ -1198,7 +1198,7 @@
433 /* attach vlan tag */
434 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
435 if (vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan) == NET_RX_DROP) {
436 - /* If netif_rx dropped the packet because
437 + /* If netif_receive_skb dropped the packet because
438 * device was too busy */
439 if (ni_tmp != NULL) {
440 /* node reference was leaked */
441 @@ -1209,8 +1209,8 @@
442 skb = NULL; /* SKB is no longer ours */
444 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
445 - if (netif_rx(skb) == NET_RX_DROP) {
446 - /* If netif_rx dropped the packet because
447 + if (netif_receive_skb(skb) == NET_RX_DROP) {
448 + /* If netif_receive_skb dropped the packet because
449 * device was too busy */
450 if (ni_tmp != NULL) {
451 /* node reference was leaked */
452 @@ -2322,8 +2322,8 @@
453 skb1->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */
455 ni_tmp = SKB_CB(skb1)->ni;
456 - if (netif_rx(skb1) == NET_RX_DROP) {
457 - /* If netif_rx dropped the packet because
458 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
459 + /* If netif_receive_skb dropped the packet because
460 * device was too busy */
461 if (ni_tmp != NULL) {
462 /* node reference was leaked */
463 Index: madwifi-trunk-r3314/net80211/ieee80211_monitor.c
464 ===================================================================
465 --- madwifi-trunk-r3314.orig/net80211/ieee80211_monitor.c
466 +++ madwifi-trunk-r3314/net80211/ieee80211_monitor.c
469 __constant_htons(0x0019); /* ETH_P_80211_RAW */
471 - if (netif_rx(skb1) == NET_RX_DROP) {
472 - /* If netif_rx dropped the packet because
473 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
474 + /* If netif_receive_skb dropped the packet because
475 * device was too busy, reclaim the ref. in
477 if (SKB_CB(skb1)->ni != NULL)
478 Index: madwifi-trunk-r3314/net80211/ieee80211_skb.c
479 ===================================================================
480 --- madwifi-trunk-r3314.orig/net80211/ieee80211_skb.c
481 +++ madwifi-trunk-r3314/net80211/ieee80211_skb.c
483 #undef dev_queue_xmit
485 #undef kfree_skb_fast
487 +#undef netif_receive_skb
495 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line) {
496 - return netif_rx(untrack_skb(skb, 0, func, line, __func__, __LINE__));
497 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line) {
498 + return netif_receive_skb(untrack_skb(skb, 0, func, line, __func__, __LINE__));
501 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
505 EXPORT_SYMBOL(vlan_hwaccel_receive_skb_debug);
506 -EXPORT_SYMBOL(netif_rx_debug);
507 +EXPORT_SYMBOL(netif_receive_skb_debug);
508 EXPORT_SYMBOL(alloc_skb_debug);
509 EXPORT_SYMBOL(dev_alloc_skb_debug);
510 EXPORT_SYMBOL(skb_clone_debug);
511 Index: madwifi-trunk-r3314/net80211/ieee80211_skb.h
512 ===================================================================
513 --- madwifi-trunk-r3314.orig/net80211/ieee80211_skb.h
514 +++ madwifi-trunk-r3314/net80211/ieee80211_skb.h
516 int vlan_hwaccel_receive_skb_debug(struct sk_buff *skb,
517 struct vlan_group *grp, unsigned short vlan_tag,
518 const char* func, int line);
519 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line);
520 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line);
521 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
522 const char *func, int line);
523 struct sk_buff * dev_alloc_skb_debug(unsigned int length,
525 #undef dev_queue_xmit
527 #undef kfree_skb_fast
529 +#undef netif_receive_skb
534 skb_copy_expand_debug(_skb, _newheadroom, _newtailroom, _gfp_mask, __func__, __LINE__)
535 #define vlan_hwaccel_receive_skb(_skb, _grp, _tag) \
536 vlan_hwaccel_receive_skb_debug(_skb, _grp, _tag, __func__, __LINE__)
537 -#define netif_rx(_skb) \
538 - netif_rx_debug(_skb, __func__, __LINE__)
539 +#define netif_receive_skb(_skb) \
540 + netif_receive_skb_debug(_skb, __func__, __LINE__)
541 #define alloc_skb(_length, _gfp_mask) \
542 alloc_skb_debug(_length, _gfp_mask, __func__, __LINE__)
543 #define dev_alloc_skb(_length) \