3 @@ -184,7 +184,11 @@ static void ath_recv_mgmt(struct ieee802
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
16 @@ -376,6 +380,9 @@ static u_int32_t ath_set_clamped_maxtxpo
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 */
26 @@ -547,7 +554,6 @@ ath_attach(u_int16_t devid, struct net_d
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);
34 @@ -821,6 +827,12 @@ ath_attach(u_int16_t devid, struct net_d
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) +
47 @@ -2220,6 +2232,7 @@ ath_intr(int irq, void *dev_id, struct p
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,21 @@ ath_intr(int irq, void *dev_id, struct p
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 + sc->sc_imask &= ~HAL_INT_RX;
68 + ath_hal_intrset(ah, sc->sc_imask);
69 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
70 + __netif_rx_schedule(dev, &sc->sc_napi);
72 + __netif_rx_schedule(dev);
76 if (status & HAL_INT_TX) {
77 #ifdef ATH_SUPERG_DYNTURBO
78 @@ -2303,6 +2330,11 @@ ath_intr(int irq, void *dev_id, struct p
82 + /* disable transmit interrupt */
83 + sc->sc_isr &= ~HAL_INT_TX;
84 + ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_TX);
85 + sc->sc_imask &= ~HAL_INT_TX;
87 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, &needmark);
89 if (status & HAL_INT_BMISS) {
90 @@ -2515,6 +2547,7 @@ ath_init(struct net_device *dev)
91 if (sc->sc_tx99 != NULL)
92 sc->sc_tx99->start(sc->sc_tx99);
94 + ath_poll_enable(dev);
98 @@ -2555,6 +2588,9 @@ ath_stop_locked(struct net_device *dev)
99 if (sc->sc_tx99 != NULL)
100 sc->sc_tx99->stop(sc->sc_tx99);
102 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
103 + ath_poll_disable(dev);
105 netif_stop_queue(dev); /* XXX re-enabled by ath_newstate */
106 dev->flags &= ~IFF_RUNNING; /* NB: avoid recursion */
107 ieee80211_stop_running(ic); /* stop all VAPs */
108 @@ -4013,12 +4049,47 @@ ath_key_set(struct ieee80211vap *vap, co
109 return ath_keyset(sc, k, mac, vap->iv_bss);
112 +static void ath_poll_disable(struct net_device *dev)
114 + struct ath_softc *sc = dev->priv;
117 + * XXX Using in_softirq is not right since we might
118 + * be called from other soft irq contexts than
121 + if (!in_softirq()) {
122 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
123 + napi_disable(&sc->sc_napi);
125 + netif_poll_disable(dev);
130 +static void ath_poll_enable(struct net_device *dev)
132 + struct ath_softc *sc = dev->priv;
134 + /* NB: see above */
135 + if (!in_softirq()) {
136 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
137 + napi_enable(&sc->sc_napi);
139 + netif_poll_enable(dev);
146 * Block/unblock tx+rx processing while a key change is done.
147 * We assume the caller serializes key management operations
148 * so we only need to worry about synchronization with other
149 * uses that originate in the driver.
151 +#define IS_UP(_dev) \
152 + (((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
154 ath_key_update_begin(struct ieee80211vap *vap)
156 @@ -4032,14 +4103,9 @@ ath_key_update_begin(struct ieee80211vap
157 * When called from the rx tasklet we cannot use
158 * tasklet_disable because it will block waiting
159 * for us to complete execution.
161 - * XXX Using in_softirq is not right since we might
162 - * be called from other soft irq contexts than
166 - tasklet_disable(&sc->sc_rxtq);
167 - netif_stop_queue(dev);
168 + if (IS_UP(vap->iv_dev))
169 + netif_stop_queue(dev);
173 @@ -4051,9 +4117,9 @@ ath_key_update_end(struct ieee80211vap *
176 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "End\n");
177 - netif_wake_queue(dev);
178 - if (!in_softirq()) /* NB: see above */
179 - tasklet_enable(&sc->sc_rxtq);
181 + if (IS_UP(vap->iv_dev))
182 + netif_wake_queue(dev);
186 @@ -6360,15 +6426,25 @@ ath_setdefantenna(struct ath_softc *sc,
187 sc->sc_rxotherant = 0;
191 -ath_rx_tasklet(TQUEUE_ARG data)
193 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
194 +ath_rx_poll(struct napi_struct *napi, int budget)
196 +ath_rx_poll(struct net_device *dev, int *budget)
199 #define PA2DESC(_sc, _pa) \
200 ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
201 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
202 - struct net_device *dev = (struct net_device *)data;
203 - struct ath_buf *bf;
204 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
205 + struct ath_softc *sc = container_of(napi, struct ath_softc, sc_napi);
206 + struct net_device *dev = sc->sc_dev;
207 + u_int rx_limit = budget;
209 struct ath_softc *sc = dev->priv;
210 + u_int rx_limit = min(dev->quota, *budget);
212 + struct ath_buf *bf;
213 struct ieee80211com *ic = &sc->sc_ic;
214 struct ath_hal *ah = sc ? sc->sc_ah : NULL;
216 @@ -6378,8 +6454,10 @@ ath_rx_tasklet(TQUEUE_ARG data)
220 + u_int processed = 0, early_stop = 0;
222 DPRINTF(sc, ATH_DEBUG_RX_PROC, "invoked\n");
225 bf = STAILQ_FIRST(&sc->sc_rxbuf);
226 if (bf == NULL) { /* XXX ??? can this happen */
227 @@ -6403,6 +6481,15 @@ ath_rx_tasklet(TQUEUE_ARG data)
228 /* NB: never process the self-linked entry at the end */
232 + if (rx_limit-- < 2) {
236 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
242 EPRINTF(sc, "Dropping; buffer contains NULL skbuff.\n");
243 @@ -6450,6 +6537,7 @@ ath_rx_tasklet(TQUEUE_ARG data)
244 sc->sc_stats.ast_rx_phyerr++;
245 phyerr = rs->rs_phyerr & 0x1f;
246 sc->sc_stats.ast_rx_phy[phyerr]++;
249 if (rs->rs_status & HAL_RXERR_DECRYPT) {
251 @@ -6645,9 +6733,39 @@ rx_next:
252 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
253 ATH_RXBUF_UNLOCK_IRQ(sc);
254 } while (ath_rxbuf_init(sc, bf) == 0);
256 + unsigned long flags;
257 + /* Check if more data is received while we were
258 + * processing the descriptor chain.
260 + local_irq_save(flags);
261 + if (sc->sc_isr & HAL_INT_RX) {
262 + u_int64_t hw_tsf = ath_hal_gettsf64(ah);
263 + sc->sc_isr &= ~HAL_INT_RX;
264 + local_irq_restore(flags);
265 + ath_uapsd_processtriggers(sc, hw_tsf);
266 + goto process_rx_again;
268 + local_irq_restore(flags);
271 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
272 + netif_rx_complete(dev, napi);
274 + netif_rx_complete(dev);
275 + *budget -= processed;
276 + dev->quota -= processed;
278 + sc->sc_imask |= HAL_INT_RX;
279 + ath_hal_intrset(ah, sc->sc_imask);
281 /* rx signal state monitoring */
282 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
283 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
291 @@ -8298,12 +8416,24 @@ ath_tx_tasklet_q0(TQUEUE_ARG data)
293 struct net_device *dev = (struct net_device *)data;
294 struct ath_softc *sc = dev->priv;
295 + unsigned long flags;
298 if (txqactive(sc->sc_ah, 0))
299 ath_tx_processq(sc, &sc->sc_txq[0]);
300 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum))
301 ath_tx_processq(sc, sc->sc_cabq);
303 + local_irq_save(flags);
304 + if (sc->sc_isr & HAL_INT_TX) {
305 + sc->sc_isr &= ~HAL_INT_TX;
306 + local_irq_restore(flags);
307 + goto process_tx_again;
309 + sc->sc_imask |= HAL_INT_TX;
310 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
311 + local_irq_restore(flags);
313 netif_wake_queue(dev);
316 @@ -8319,7 +8449,9 @@ ath_tx_tasklet_q0123(TQUEUE_ARG data)
318 struct net_device *dev = (struct net_device *)data;
319 struct ath_softc *sc = dev->priv;
320 + unsigned long flags;
324 * Process each active queue.
326 @@ -8340,6 +8472,16 @@ ath_tx_tasklet_q0123(TQUEUE_ARG data)
327 if (sc->sc_uapsdq && txqactive(sc->sc_ah, sc->sc_uapsdq->axq_qnum))
328 ath_tx_processq(sc, sc->sc_uapsdq);
330 + local_irq_save(flags);
331 + if (sc->sc_isr & HAL_INT_TX) {
332 + sc->sc_isr &= ~HAL_INT_TX;
333 + local_irq_restore(flags);
334 + goto process_tx_again;
336 + sc->sc_imask |= HAL_INT_TX;
337 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
338 + local_irq_restore(flags);
340 netif_wake_queue(dev);
343 @@ -8355,13 +8497,25 @@ ath_tx_tasklet(TQUEUE_ARG data)
344 struct net_device *dev = (struct net_device *)data;
345 struct ath_softc *sc = dev->priv;
347 + unsigned long flags;
349 /* Process each active queue. This includes sc_cabq, sc_xrtq and
352 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
353 if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i))
354 ath_tx_processq(sc, &sc->sc_txq[i]);
356 + local_irq_save(flags);
357 + if (sc->sc_isr & HAL_INT_TX) {
358 + sc->sc_isr &= ~HAL_INT_TX;
359 + local_irq_restore(flags);
360 + goto process_tx_again;
362 + sc->sc_imask |= HAL_INT_TX;
363 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
364 + local_irq_restore(flags);
366 netif_wake_queue(dev);
369 @@ -10296,9 +10450,9 @@ ath_change_mtu(struct net_device *dev, i
371 if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
372 /* NB: the rx buffers may need to be reallocated */
373 - tasklet_disable(&sc->sc_rxtq);
374 + ath_poll_disable(dev);
375 error = ath_reset(dev);
376 - tasklet_enable(&sc->sc_rxtq);
377 + ath_poll_enable(dev);
381 --- a/ath/if_athvar.h
382 +++ b/ath/if_athvar.h
384 # include <asm/bitops.h>
387 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
388 +#define irqs_disabled() 0
392 * Deduce if tasklets are available. If not then
393 * fall back to using the immediate work queue.
394 @@ -616,6 +620,9 @@ struct ath_rp {
396 struct ieee80211com sc_ic; /* NB: must be first */
397 struct net_device *sc_dev;
398 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
399 + struct napi_struct sc_napi;
401 void __iomem *sc_iobase; /* address of the device */
402 struct semaphore sc_lock; /* dev-level lock */
403 struct net_device_stats sc_devstats; /* device statistics */
404 @@ -730,7 +737,6 @@ struct ath_softc {
405 struct ath_buf *sc_rxbufcur; /* current rx buffer */
406 u_int32_t *sc_rxlink; /* link ptr in last RX desc */
407 spinlock_t sc_rxbuflock;
408 - struct ATH_TQ_STRUCT sc_rxtq; /* rx intr tasklet */
409 struct ATH_TQ_STRUCT sc_rxorntq; /* rxorn intr tasklet */
410 u_int8_t sc_defant; /* current default antenna */
411 u_int8_t sc_rxotherant; /* RXs on non-default antenna */
412 @@ -745,6 +751,7 @@ struct ath_softc {
413 u_int sc_txintrperiod; /* tx interrupt batching */
414 struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
415 struct ath_txq *sc_ac2q[WME_NUM_AC]; /* WME AC -> h/w qnum */
416 + HAL_INT sc_isr; /* unmasked ISR state */
417 struct ATH_TQ_STRUCT sc_txtq; /* tx intr tasklet */
418 u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];
419 struct ath_descdma sc_bdma; /* beacon descriptors */
420 @@ -858,6 +865,8 @@ typedef void (*ath_callback) (struct ath
421 #define ATH_TXBUF_LOCK_CHECK(_sc)
424 +#define ATH_DISABLE_INTR local_irq_disable
425 +#define ATH_ENABLE_INTR local_irq_enable
427 #define ATH_RXBUF_LOCK_INIT(_sc) spin_lock_init(&(_sc)->sc_rxbuflock)
428 #define ATH_RXBUF_LOCK_DESTROY(_sc)
429 --- a/net80211/ieee80211_input.c
430 +++ b/net80211/ieee80211_input.c
431 @@ -1198,7 +1198,7 @@ ieee80211_deliver_data(struct ieee80211_
432 /* attach vlan tag */
433 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
434 if (vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan) == NET_RX_DROP) {
435 - /* If netif_rx dropped the packet because
436 + /* If netif_receive_skb dropped the packet because
437 * device was too busy */
438 if (ni_tmp != NULL) {
439 /* node reference was leaked */
440 @@ -1209,8 +1209,8 @@ ieee80211_deliver_data(struct ieee80211_
441 skb = NULL; /* SKB is no longer ours */
443 struct ieee80211_node *ni_tmp = SKB_CB(skb)->ni;
444 - if (netif_rx(skb) == NET_RX_DROP) {
445 - /* If netif_rx dropped the packet because
446 + if (netif_receive_skb(skb) == NET_RX_DROP) {
447 + /* If netif_receive_skb dropped the packet because
448 * device was too busy */
449 if (ni_tmp != NULL) {
450 /* node reference was leaked */
451 @@ -2322,8 +2322,8 @@ forward_mgmt_to_app(struct ieee80211vap
452 skb1->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */
454 ni_tmp = SKB_CB(skb1)->ni;
455 - if (netif_rx(skb1) == NET_RX_DROP) {
456 - /* If netif_rx dropped the packet because
457 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
458 + /* If netif_receive_skb dropped the packet because
459 * device was too busy */
460 if (ni_tmp != NULL) {
461 /* node reference was leaked */
462 --- a/net80211/ieee80211_monitor.c
463 +++ b/net80211/ieee80211_monitor.c
464 @@ -584,8 +584,8 @@ ieee80211_input_monitor(struct ieee80211
466 __constant_htons(0x0019); /* ETH_P_80211_RAW */
468 - if (netif_rx(skb1) == NET_RX_DROP) {
469 - /* If netif_rx dropped the packet because
470 + if (netif_receive_skb(skb1) == NET_RX_DROP) {
471 + /* If netif_receive_skb dropped the packet because
472 * device was too busy, reclaim the ref. in
474 if (SKB_CB(skb1)->ni != NULL)
475 --- a/net80211/ieee80211_skb.c
476 +++ b/net80211/ieee80211_skb.c
478 #undef dev_queue_xmit
480 #undef kfree_skb_fast
482 +#undef netif_receive_skb
486 @@ -638,8 +638,8 @@ int vlan_hwaccel_receive_skb_debug(stru
490 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line) {
491 - return netif_rx(untrack_skb(skb, 0, func, line, __func__, __LINE__));
492 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line) {
493 + return netif_receive_skb(untrack_skb(skb, 0, func, line, __func__, __LINE__));
496 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
497 @@ -760,7 +760,7 @@ struct sk_buff * skb_copy_expand_debug(c
500 EXPORT_SYMBOL(vlan_hwaccel_receive_skb_debug);
501 -EXPORT_SYMBOL(netif_rx_debug);
502 +EXPORT_SYMBOL(netif_receive_skb_debug);
503 EXPORT_SYMBOL(alloc_skb_debug);
504 EXPORT_SYMBOL(dev_alloc_skb_debug);
505 EXPORT_SYMBOL(skb_clone_debug);
506 --- a/net80211/ieee80211_skb.h
507 +++ b/net80211/ieee80211_skb.h
508 @@ -116,7 +116,7 @@ int ieee80211_skb_references(void);
509 int vlan_hwaccel_receive_skb_debug(struct sk_buff *skb,
510 struct vlan_group *grp, unsigned short vlan_tag,
511 const char* func, int line);
512 -int netif_rx_debug(struct sk_buff *skb, const char* func, int line);
513 +int netif_receive_skb_debug(struct sk_buff *skb, const char* func, int line);
514 struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask,
515 const char *func, int line);
516 struct sk_buff * dev_alloc_skb_debug(unsigned int length,
517 @@ -151,7 +151,7 @@ struct sk_buff * skb_copy_expand_debug(c
518 #undef dev_queue_xmit
520 #undef kfree_skb_fast
522 +#undef netif_receive_skb
526 @@ -168,8 +168,8 @@ struct sk_buff * skb_copy_expand_debug(c
527 skb_copy_expand_debug(_skb, _newheadroom, _newtailroom, _gfp_mask, __func__, __LINE__)
528 #define vlan_hwaccel_receive_skb(_skb, _grp, _tag) \
529 vlan_hwaccel_receive_skb_debug(_skb, _grp, _tag, __func__, __LINE__)
530 -#define netif_rx(_skb) \
531 - netif_rx_debug(_skb, __func__, __LINE__)
532 +#define netif_receive_skb(_skb) \
533 + netif_receive_skb_debug(_skb, __func__, __LINE__)
534 #define alloc_skb(_length, _gfp_mask) \
535 alloc_skb_debug(_length, _gfp_mask, __func__, __LINE__)
536 #define dev_alloc_skb(_length) \