4 struct sk_buff *, int, int, u_int64_t);
5 static void ath_setdefantenna(struct ath_softc *, u_int);
6 static struct ath_txq *ath_txq_setup(struct ath_softc *, int, int);
7 -static void ath_rx_tasklet(TQUEUE_ARG);
8 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
9 +static int ath_rx_poll(struct napi_struct *napi, int budget);
11 +static int ath_rx_poll(struct net_device *dev, int *budget);
13 static int ath_hardstart(struct sk_buff *, struct net_device *);
14 static int ath_mgtstart(struct ieee80211com *, struct sk_buff *);
15 #ifdef ATH_SUPERG_COMP
17 u_int32_t new_clamped_maxtxpower);
18 static u_int32_t ath_get_real_maxtxpower(struct ath_softc *sc);
20 +static void ath_poll_disable(struct net_device *dev);
21 +static void ath_poll_enable(struct net_device *dev);
23 /* calibrate every 30 secs in steady state but check every second at first. */
24 static int ath_calinterval = ATH_SHORT_CALINTERVAL;
25 static int ath_countrycode = CTRY_DEFAULT; /* country code */
28 atomic_set(&sc->sc_txbuf_counter, 0);
30 - ATH_INIT_TQUEUE(&sc->sc_rxtq, ath_rx_tasklet, dev);
31 ATH_INIT_TQUEUE(&sc->sc_txtq, ath_tx_tasklet, dev);
32 ATH_INIT_TQUEUE(&sc->sc_bmisstq, ath_bmiss_tasklet, dev);
33 ATH_INIT_TQUEUE(&sc->sc_bstucktq, ath_bstuck_tasklet, dev);
35 dev->set_mac_address = ath_set_mac_address;
36 dev->change_mtu = ath_change_mtu;
37 dev->tx_queue_len = ATH_TXBUF - ATH_TXBUF_MGT_RESERVED;
38 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
39 + netif_napi_add(dev, &sc->sc_napi, ath_rx_poll, 64);
41 + dev->poll = ath_rx_poll;
44 #ifdef USE_HEADERLEN_RESV
45 dev->hard_header_len += sizeof(struct ieee80211_qosframe) +
48 (status & HAL_INT_GLOBAL) ? " HAL_INT_GLOBAL" : ""
51 + sc->sc_isr = status;
52 status &= sc->sc_imask; /* discard unasked for bits */
53 /* As soon as we know we have a real interrupt we intend to service,
54 * we will check to see if we need an initial hardware TSF reading.
55 @@ -2273,7 +2286,23 @@
57 if (status & (HAL_INT_RX | HAL_INT_RXPHY)) {
58 ath_uapsd_processtriggers(sc, hw_tsf);
59 - ATH_SCHEDULE_TQUEUE(&sc->sc_rxtq, &needmark);
60 + sc->sc_isr &= ~HAL_INT_RX;
61 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
62 + if (netif_rx_schedule_prep(dev, &sc->sc_napi))
64 + if (netif_rx_schedule_prep(dev))
67 +#ifndef ATH_PRECISE_TSF
68 + sc->sc_imask &= ~HAL_INT_RX;
69 + ath_hal_intrset(ah, sc->sc_imask);
71 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
72 + __netif_rx_schedule(dev, &sc->sc_napi);
74 + __netif_rx_schedule(dev);
78 if (status & HAL_INT_TX) {
79 #ifdef ATH_SUPERG_DYNTURBO
80 @@ -2299,6 +2328,11 @@
84 + /* disable transmit interrupt */
85 + sc->sc_isr &= ~HAL_INT_TX;
86 + ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_TX);
87 + sc->sc_imask &= ~HAL_INT_TX;
89 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, &needmark);
91 if (status & HAL_INT_BMISS) {
93 if (sc->sc_tx99 != NULL)
94 sc->sc_tx99->start(sc->sc_tx99);
96 + ath_poll_enable(dev);
100 @@ -2551,6 +2586,9 @@
101 if (sc->sc_tx99 != NULL)
102 sc->sc_tx99->stop(sc->sc_tx99);
104 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
105 + ath_poll_disable(dev);
107 netif_stop_queue(dev); /* XXX re-enabled by ath_newstate */
108 dev->flags &= ~IFF_RUNNING; /* NB: avoid recursion */
109 ieee80211_stop_running(ic); /* stop all VAPs */
110 @@ -4009,6 +4047,39 @@
111 return ath_keyset(sc, k, mac, vap->iv_bss);
114 +static void ath_poll_disable(struct net_device *dev)
116 + struct ath_softc *sc = dev->priv;
119 + * XXX Using in_softirq is not right since we might
120 + * be called from other soft irq contexts than
123 + if (!in_softirq()) {
124 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
125 + napi_disable(&sc->sc_napi);
127 + netif_poll_disable(dev);
132 +static void ath_poll_enable(struct net_device *dev)
134 + struct ath_softc *sc = dev->priv;
136 + /* NB: see above */
137 + if (!in_softirq()) {
138 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
139 + napi_enable(&sc->sc_napi);
141 + netif_poll_enable(dev);
148 * Block/unblock tx+rx processing while a key change is done.
149 * We assume the caller serializes key management operations
150 @@ -4026,13 +4097,7 @@
151 * When called from the rx tasklet we cannot use
152 * tasklet_disable because it will block waiting
153 * for us to complete execution.
155 - * XXX Using in_softirq is not right since we might
156 - * be called from other soft irq contexts than
160 - tasklet_disable(&sc->sc_rxtq);
161 netif_stop_queue(dev);
164 @@ -4043,9 +4108,9 @@
165 struct ath_softc *sc = dev->priv;
167 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "End\n");
168 - netif_wake_queue(dev);
169 - if (!in_softirq()) /* NB: see above */
170 - tasklet_enable(&sc->sc_rxtq);
172 + if (dev->flags&IFF_RUNNING)
173 + netif_wake_queue(dev);
177 @@ -6350,15 +6415,25 @@
178 sc->sc_rxotherant = 0;
182 -ath_rx_tasklet(TQUEUE_ARG data)
184 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
185 +ath_rx_poll(struct napi_struct *napi, int budget)
187 +ath_rx_poll(struct net_device *dev, int *budget)
190 #define PA2DESC(_sc, _pa) \
191 ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
192 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
193 - struct net_device *dev = (struct net_device *)data;
194 - struct ath_buf *bf;
195 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
196 + struct ath_softc *sc = container_of(napi, struct ath_softc, sc_napi);
197 + struct net_device *dev = sc->sc_dev;
198 + u_int rx_limit = budget;
200 struct ath_softc *sc = dev->priv;
201 + u_int rx_limit = min(dev->quota, *budget);
203 + struct ath_buf *bf;
204 struct ieee80211com *ic = &sc->sc_ic;
205 struct ath_hal *ah = sc ? sc->sc_ah : NULL;
207 @@ -6368,8 +6443,10 @@
211 + u_int processed = 0, early_stop = 0;
213 DPRINTF(sc, ATH_DEBUG_RX_PROC, "invoked\n");
216 bf = STAILQ_FIRST(&sc->sc_rxbuf);
217 if (bf == NULL) { /* XXX ??? can this happen */
218 @@ -6393,6 +6470,15 @@
219 /* NB: never process the self-linked entry at the end */
223 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
226 + if (rx_limit-- < 0) {
233 EPRINTF(sc, "Dropping; buffer contains NULL skbuff.\n");
234 @@ -6440,6 +6526,7 @@
235 sc->sc_stats.ast_rx_phyerr++;
236 phyerr = rs->rs_phyerr & 0x1f;
237 sc->sc_stats.ast_rx_phy[phyerr]++;
240 if (rs->rs_status & HAL_RXERR_DECRYPT) {
242 @@ -6635,9 +6722,43 @@
243 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
244 ATH_RXBUF_UNLOCK_IRQ(sc);
245 } while (ath_rxbuf_init(sc, bf) == 0);
247 + unsigned long flags;
248 + /* Check if more data is received while we were
249 + * processing the descriptor chain.
251 +#ifndef ATH_PRECISE_TSF
252 + local_irq_save(flags);
253 + if (sc->sc_isr & HAL_INT_RX) {
254 + u_int64_t hw_tsf = ath_hal_gettsf64(ah);
255 + sc->sc_isr &= ~HAL_INT_RX;
256 + local_irq_restore(flags);
257 + ath_uapsd_processtriggers(sc, hw_tsf);
258 + goto process_rx_again;
261 +#ifndef ATH_PRECISE_TSF
262 + sc->sc_imask |= HAL_INT_RX;
263 + ath_hal_intrset(ah, sc->sc_imask);
264 + local_irq_restore(flags);
268 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
269 + netif_rx_complete(dev, napi);
271 + netif_rx_complete(dev);
272 + *budget -= processed;
273 + dev->quota -= processed;
276 /* rx signal state monitoring */
277 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
278 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
286 @@ -8288,12 +8409,24 @@
288 struct net_device *dev = (struct net_device *)data;
289 struct ath_softc *sc = dev->priv;
290 + unsigned long flags;
293 if (txqactive(sc->sc_ah, 0))
294 ath_tx_processq(sc, &sc->sc_txq[0]);
295 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum))
296 ath_tx_processq(sc, sc->sc_cabq);
298 + local_irq_save(flags);
299 + if (sc->sc_isr & HAL_INT_TX) {
300 + sc->sc_isr &= ~HAL_INT_TX;
301 + local_irq_restore(flags);
302 + goto process_tx_again;
304 + sc->sc_imask |= HAL_INT_TX;
305 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
306 + local_irq_restore(flags);
308 netif_wake_queue(dev);
311 @@ -8309,7 +8442,9 @@
313 struct net_device *dev = (struct net_device *)data;
314 struct ath_softc *sc = dev->priv;
315 + unsigned long flags;
319 * Process each active queue.
321 @@ -8330,6 +8465,16 @@
322 if (sc->sc_uapsdq && txqactive(sc->sc_ah, sc->sc_uapsdq->axq_qnum))
323 ath_tx_processq(sc, sc->sc_uapsdq);
325 + local_irq_save(flags);
326 + if (sc->sc_isr & HAL_INT_TX) {
327 + sc->sc_isr &= ~HAL_INT_TX;
328 + local_irq_restore(flags);
329 + goto process_tx_again;
331 + sc->sc_imask |= HAL_INT_TX;
332 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
333 + local_irq_restore(flags);
335 netif_wake_queue(dev);
338 @@ -8345,13 +8490,25 @@
339 struct net_device *dev = (struct net_device *)data;
340 struct ath_softc *sc = dev->priv;
342 + unsigned long flags;
344 /* Process each active queue. This includes sc_cabq, sc_xrtq and
347 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
348 if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i))
349 ath_tx_processq(sc, &sc->sc_txq[i]);
351 + local_irq_save(flags);
352 + if (sc->sc_isr & HAL_INT_TX) {
353 + sc->sc_isr &= ~HAL_INT_TX;
354 + local_irq_restore(flags);
355 + goto process_tx_again;
357 + sc->sc_imask |= HAL_INT_TX;
358 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
359 + local_irq_restore(flags);
361 netif_wake_queue(dev);
364 @@ -10284,9 +10441,9 @@
366 if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
367 /* NB: the rx buffers may need to be reallocated */
368 - tasklet_disable(&sc->sc_rxtq);
369 + ath_poll_disable(dev);
370 error = ath_reset(dev);
371 - tasklet_enable(&sc->sc_rxtq);
372 + ath_poll_enable(dev);
376 --- a/ath/if_athvar.h
377 +++ b/ath/if_athvar.h
379 # include <asm/bitops.h>
382 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
383 +#define irqs_disabled() 0
387 * Deduce if tasklets are available. If not then
388 * fall back to using the immediate work queue.
391 struct ieee80211com sc_ic; /* NB: must be first */
392 struct net_device *sc_dev;
393 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
394 + struct napi_struct sc_napi;
396 void __iomem *sc_iobase; /* address of the device */
397 struct semaphore sc_lock; /* dev-level lock */
398 struct net_device_stats sc_devstats; /* device statistics */
400 struct ath_buf *sc_rxbufcur; /* current rx buffer */
401 u_int32_t *sc_rxlink; /* link ptr in last RX desc */
402 spinlock_t sc_rxbuflock;
403 - struct ATH_TQ_STRUCT sc_rxtq; /* rx intr tasklet */
404 struct ATH_TQ_STRUCT sc_rxorntq; /* rxorn intr tasklet */
405 u_int8_t sc_defant; /* current default antenna */
406 u_int8_t sc_rxotherant; /* RXs on non-default antenna */
408 u_int sc_txintrperiod; /* tx interrupt batching */
409 struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
410 struct ath_txq *sc_ac2q[WME_NUM_AC]; /* WME AC -> h/w qnum */
411 + HAL_INT sc_isr; /* unmasked ISR state */
412 struct ATH_TQ_STRUCT sc_txtq; /* tx intr tasklet */
413 u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];
414 struct ath_descdma sc_bdma; /* beacon descriptors */
416 #define ATH_TXBUF_LOCK_CHECK(_sc)
419 +#define ATH_DISABLE_INTR local_irq_disable
420 +#define ATH_ENABLE_INTR local_irq_enable
422 #define ATH_RXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_rxbuflock)
423 #define ATH_RXBUF_LOCK_DESTROY(_sc)
424 --- a/net80211/ieee80211_input.c
425 +++ b/net80211/ieee80211_input.c
426 @@ -1198,7 +1198,7 @@
427 /* attach vlan tag */
428 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
429 if (vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan) == NET_RX_DROP) {
430 - /* If netif_rx dropped the packet because
431 + /* If netif_receive_skb dropped the packet because
432 * device was too busy */
433 if (ni_tmp != NULL) {
434 /* node reference was leaked */
435 @@ -1209,8 +1209,8 @@
436 skb = NULL; /* SKB is no longer ours */
438 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
439 - if (netif_rx(skb) == NET_RX_DROP) {
440 - /* If netif_rx dropped the packet because
441 + if (netif_receive_skb(skb) == NET_RX_DROP) {
442 + /* If netif_receive_skb dropped the packet because
443 * device was too busy */
444 if (ni_tmp != NULL) {
445 /* node reference was leaked */
446 @@ -2322,8 +2322,8 @@
447 skb1->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */
449 ni_tmp = SKB_CB(skb1)->ni;
450 - if (netif_rx(skb1) == NET_RX_DROP) {
451 - /* If netif_rx dropped the packet because
452 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
453 + /* If netif_receive_skb dropped the packet because
454 * device was too busy */
455 if (ni_tmp != NULL) {
456 /* node reference was leaked */
457 --- a/net80211/ieee80211_monitor.c
458 +++ b/net80211/ieee80211_monitor.c
461 __constant_htons(0x0019); /* ETH_P_80211_RAW */
463 - if (netif_rx(skb1) == NET_RX_DROP) {
464 - /* If netif_rx dropped the packet because
465 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
466 + /* If netif_receive_skb dropped the packet because
467 * device was too busy, reclaim the ref. in
469 if (SKB_CB(skb1)->ni != NULL)
470 --- a/net80211/ieee80211_skb.c
471 +++ b/net80211/ieee80211_skb.c
473 #undef dev_queue_xmit
475 #undef kfree_skb_fast
477 +#undef netif_receive_skb
485 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line) {
486 - return netif_rx(untrack_skb(skb, 0, func, line, __func__, __LINE__));
487 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line) {
488 + return netif_receive_skb(untrack_skb(skb, 0, func, line, __func__, __LINE__));
491 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
495 EXPORT_SYMBOL(vlan_hwaccel_receive_skb_debug);
496 -EXPORT_SYMBOL(netif_rx_debug);
497 +EXPORT_SYMBOL(netif_receive_skb_debug);
498 EXPORT_SYMBOL(alloc_skb_debug);
499 EXPORT_SYMBOL(dev_alloc_skb_debug);
500 EXPORT_SYMBOL(skb_clone_debug);
501 --- a/net80211/ieee80211_skb.h
502 +++ b/net80211/ieee80211_skb.h
504 int vlan_hwaccel_receive_skb_debug(struct sk_buff *skb,
505 struct vlan_group *grp, unsigned short vlan_tag,
506 const char* func, int line);
507 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line);
508 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line);
509 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
510 const char *func, int line);
511 struct sk_buff * dev_alloc_skb_debug(unsigned int length,
513 #undef dev_queue_xmit
515 #undef kfree_skb_fast
517 +#undef netif_receive_skb
522 skb_copy_expand_debug(_skb, _newheadroom, _newtailroom, _gfp_mask, __func__, __LINE__)
523 #define vlan_hwaccel_receive_skb(_skb, _grp, _tag) \
524 vlan_hwaccel_receive_skb_debug(_skb, _grp, _tag, __func__, __LINE__)
525 -#define netif_rx(_skb) \
526 - netif_rx_debug(_skb, __func__, __LINE__)
527 +#define netif_receive_skb(_skb) \
528 + netif_receive_skb_debug(_skb, __func__, __LINE__)
529 #define alloc_skb(_length, _gfp_mask) \
530 alloc_skb_debug(_length, _gfp_mask, __func__, __LINE__)
531 #define dev_alloc_skb(_length) \