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 @@ -2277,7 +2290,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 @@ -2303,6 +2332,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 @@ -2555,6 +2590,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 @@ -4013,12 +4051,47 @@
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 * so we only need to worry about synchronization with other
151 * uses that originate in the driver.
153 +#define IS_UP(_dev) \
154 + (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
156 ath_key_update_begin(struct ieee80211vap *vap)
158 @@ -4032,14 +4105,9 @@
159 * When called from the rx tasklet we cannot use
160 * tasklet_disable because it will block waiting
161 * for us to complete execution.
163 - * XXX Using in_softirq is not right since we might
164 - * be called from other soft irq contexts than
168 - tasklet_disable(&sc->sc_rxtq);
169 - netif_stop_queue(dev);
170 + if (IS_UP(vap->iv_dev))
171 + netif_stop_queue(dev);
175 @@ -4051,9 +4119,9 @@
178 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "End\n");
179 - netif_wake_queue(dev);
180 - if (!in_softirq()) /* NB: see above */
181 - tasklet_enable(&sc->sc_rxtq);
183 + if (IS_UP(vap->iv_dev))
184 + netif_wake_queue(dev);
188 @@ -6360,15 +6428,25 @@
189 sc->sc_rxotherant = 0;
193 -ath_rx_tasklet(TQUEUE_ARG data)
195 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
196 +ath_rx_poll(struct napi_struct *napi, int budget)
198 +ath_rx_poll(struct net_device *dev, int *budget)
201 #define PA2DESC(_sc, _pa) \
202 ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
203 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
204 - struct net_device *dev = (struct net_device *)data;
205 - struct ath_buf *bf;
206 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
207 + struct ath_softc *sc = container_of(napi, struct ath_softc, sc_napi);
208 + struct net_device *dev = sc->sc_dev;
209 + u_int rx_limit = budget;
211 struct ath_softc *sc = dev->priv;
212 + u_int rx_limit = min(dev->quota, *budget);
214 + struct ath_buf *bf;
215 struct ieee80211com *ic = &sc->sc_ic;
216 struct ath_hal *ah = sc ? sc->sc_ah : NULL;
218 @@ -6378,8 +6456,10 @@
222 + u_int processed = 0, early_stop = 0;
224 DPRINTF(sc, ATH_DEBUG_RX_PROC, "invoked\n");
227 bf = STAILQ_FIRST(&sc->sc_rxbuf);
228 if (bf == NULL) { /* XXX ??? can this happen */
229 @@ -6403,6 +6483,15 @@
230 /* NB: never process the self-linked entry at the end */
234 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
237 + if (rx_limit-- < 0) {
244 EPRINTF(sc, "Dropping; buffer contains NULL skbuff.\n");
245 @@ -6450,6 +6539,7 @@
246 sc->sc_stats.ast_rx_phyerr++;
247 phyerr = rs->rs_phyerr & 0x1f;
248 sc->sc_stats.ast_rx_phy[phyerr]++;
251 if (rs->rs_status & HAL_RXERR_DECRYPT) {
253 @@ -6645,9 +6735,43 @@
254 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
255 ATH_RXBUF_UNLOCK_IRQ(sc);
256 } while (ath_rxbuf_init(sc, bf) == 0);
258 + unsigned long flags;
259 + /* Check if more data is received while we were
260 + * processing the descriptor chain.
262 +#ifndef ATH_PRECISE_TSF
263 + local_irq_save(flags);
264 + if (sc->sc_isr & HAL_INT_RX) {
265 + u_int64_t hw_tsf = ath_hal_gettsf64(ah);
266 + sc->sc_isr &= ~HAL_INT_RX;
267 + local_irq_restore(flags);
268 + ath_uapsd_processtriggers(sc, hw_tsf);
269 + goto process_rx_again;
272 +#ifndef ATH_PRECISE_TSF
273 + sc->sc_imask |= HAL_INT_RX;
274 + ath_hal_intrset(ah, sc->sc_imask);
275 + local_irq_restore(flags);
279 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
280 + netif_rx_complete(dev, napi);
282 + netif_rx_complete(dev);
283 + *budget -= processed;
284 + dev->quota -= processed;
287 /* rx signal state monitoring */
288 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
289 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
297 @@ -8298,12 +8422,24 @@
299 struct net_device *dev = (struct net_device *)data;
300 struct ath_softc *sc = dev->priv;
301 + unsigned long flags;
304 if (txqactive(sc->sc_ah, 0))
305 ath_tx_processq(sc, &sc->sc_txq[0]);
306 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum))
307 ath_tx_processq(sc, sc->sc_cabq);
309 + local_irq_save(flags);
310 + if (sc->sc_isr & HAL_INT_TX) {
311 + sc->sc_isr &= ~HAL_INT_TX;
312 + local_irq_restore(flags);
313 + goto process_tx_again;
315 + sc->sc_imask |= HAL_INT_TX;
316 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
317 + local_irq_restore(flags);
319 netif_wake_queue(dev);
322 @@ -8319,7 +8455,9 @@
324 struct net_device *dev = (struct net_device *)data;
325 struct ath_softc *sc = dev->priv;
326 + unsigned long flags;
330 * Process each active queue.
332 @@ -8340,6 +8478,16 @@
333 if (sc->sc_uapsdq && txqactive(sc->sc_ah, sc->sc_uapsdq->axq_qnum))
334 ath_tx_processq(sc, sc->sc_uapsdq);
336 + local_irq_save(flags);
337 + if (sc->sc_isr & HAL_INT_TX) {
338 + sc->sc_isr &= ~HAL_INT_TX;
339 + local_irq_restore(flags);
340 + goto process_tx_again;
342 + sc->sc_imask |= HAL_INT_TX;
343 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
344 + local_irq_restore(flags);
346 netif_wake_queue(dev);
349 @@ -8355,13 +8503,25 @@
350 struct net_device *dev = (struct net_device *)data;
351 struct ath_softc *sc = dev->priv;
353 + unsigned long flags;
355 /* Process each active queue. This includes sc_cabq, sc_xrtq and
358 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
359 if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i))
360 ath_tx_processq(sc, &sc->sc_txq[i]);
362 + local_irq_save(flags);
363 + if (sc->sc_isr & HAL_INT_TX) {
364 + sc->sc_isr &= ~HAL_INT_TX;
365 + local_irq_restore(flags);
366 + goto process_tx_again;
368 + sc->sc_imask |= HAL_INT_TX;
369 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
370 + local_irq_restore(flags);
372 netif_wake_queue(dev);
375 @@ -10296,9 +10456,9 @@
377 if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
378 /* NB: the rx buffers may need to be reallocated */
379 - tasklet_disable(&sc->sc_rxtq);
380 + ath_poll_disable(dev);
381 error = ath_reset(dev);
382 - tasklet_enable(&sc->sc_rxtq);
383 + ath_poll_enable(dev);
387 --- a/ath/if_athvar.h
388 +++ b/ath/if_athvar.h
390 # include <asm/bitops.h>
393 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
394 +#define irqs_disabled() 0
398 * Deduce if tasklets are available. If not then
399 * fall back to using the immediate work queue.
402 struct ieee80211com sc_ic; /* NB: must be first */
403 struct net_device *sc_dev;
404 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
405 + struct napi_struct sc_napi;
407 void __iomem *sc_iobase; /* address of the device */
408 struct semaphore sc_lock; /* dev-level lock */
409 struct net_device_stats sc_devstats; /* device statistics */
411 struct ath_buf *sc_rxbufcur; /* current rx buffer */
412 u_int32_t *sc_rxlink; /* link ptr in last RX desc */
413 spinlock_t sc_rxbuflock;
414 - struct ATH_TQ_STRUCT sc_rxtq; /* rx intr tasklet */
415 struct ATH_TQ_STRUCT sc_rxorntq; /* rxorn intr tasklet */
416 u_int8_t sc_defant; /* current default antenna */
417 u_int8_t sc_rxotherant; /* RXs on non-default antenna */
419 u_int sc_txintrperiod; /* tx interrupt batching */
420 struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
421 struct ath_txq *sc_ac2q[WME_NUM_AC]; /* WME AC -> h/w qnum */
422 + HAL_INT sc_isr; /* unmasked ISR state */
423 struct ATH_TQ_STRUCT sc_txtq; /* tx intr tasklet */
424 u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];
425 struct ath_descdma sc_bdma; /* beacon descriptors */
427 #define ATH_TXBUF_LOCK_CHECK(_sc)
430 +#define ATH_DISABLE_INTR local_irq_disable
431 +#define ATH_ENABLE_INTR local_irq_enable
433 #define ATH_RXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_rxbuflock)
434 #define ATH_RXBUF_LOCK_DESTROY(_sc)
435 --- a/net80211/ieee80211_input.c
436 +++ b/net80211/ieee80211_input.c
437 @@ -1198,7 +1198,7 @@
438 /* attach vlan tag */
439 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
440 if (vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan) == NET_RX_DROP) {
441 - /* If netif_rx dropped the packet because
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 @@ -1209,8 +1209,8 @@
447 skb = NULL; /* SKB is no longer ours */
449 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
450 - if (netif_rx(skb) == NET_RX_DROP) {
451 - /* If netif_rx dropped the packet because
452 + if (netif_receive_skb(skb) == 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 @@ -2322,8 +2322,8 @@
458 skb1->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */
460 ni_tmp = SKB_CB(skb1)->ni;
461 - if (netif_rx(skb1) == NET_RX_DROP) {
462 - /* If netif_rx dropped the packet because
463 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
464 + /* If netif_receive_skb dropped the packet because
465 * device was too busy */
466 if (ni_tmp != NULL) {
467 /* node reference was leaked */
468 --- a/net80211/ieee80211_monitor.c
469 +++ b/net80211/ieee80211_monitor.c
472 __constant_htons(0x0019); /* ETH_P_80211_RAW */
474 - if (netif_rx(skb1) == NET_RX_DROP) {
475 - /* If netif_rx dropped the packet because
476 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
477 + /* If netif_receive_skb dropped the packet because
478 * device was too busy, reclaim the ref. in
480 if (SKB_CB(skb1)->ni != NULL)
481 --- a/net80211/ieee80211_skb.c
482 +++ b/net80211/ieee80211_skb.c
484 #undef dev_queue_xmit
486 #undef kfree_skb_fast
488 +#undef netif_receive_skb
496 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line) {
497 - return netif_rx(untrack_skb(skb, 0, func, line, __func__, __LINE__));
498 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line) {
499 + return netif_receive_skb(untrack_skb(skb, 0, func, line, __func__, __LINE__));
502 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
506 EXPORT_SYMBOL(vlan_hwaccel_receive_skb_debug);
507 -EXPORT_SYMBOL(netif_rx_debug);
508 +EXPORT_SYMBOL(netif_receive_skb_debug);
509 EXPORT_SYMBOL(alloc_skb_debug);
510 EXPORT_SYMBOL(dev_alloc_skb_debug);
511 EXPORT_SYMBOL(skb_clone_debug);
512 --- a/net80211/ieee80211_skb.h
513 +++ b/net80211/ieee80211_skb.h
515 int vlan_hwaccel_receive_skb_debug(struct sk_buff *skb,
516 struct vlan_group *grp, unsigned short vlan_tag,
517 const char* func, int line);
518 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line);
519 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line);
520 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
521 const char *func, int line);
522 struct sk_buff * dev_alloc_skb_debug(unsigned int length,
524 #undef dev_queue_xmit
526 #undef kfree_skb_fast
528 +#undef netif_receive_skb
533 skb_copy_expand_debug(_skb, _newheadroom, _newtailroom, _gfp_mask, __func__, __LINE__)
534 #define vlan_hwaccel_receive_skb(_skb, _grp, _tag) \
535 vlan_hwaccel_receive_skb_debug(_skb, _grp, _tag, __func__, __LINE__)
536 -#define netif_rx(_skb) \
537 - netif_rx_debug(_skb, __func__, __LINE__)
538 +#define netif_receive_skb(_skb) \
539 + netif_receive_skb_debug(_skb, __func__, __LINE__)
540 #define alloc_skb(_length, _gfp_mask) \
541 alloc_skb_debug(_length, _gfp_mask, __func__, __LINE__)
542 #define dev_alloc_skb(_length) \