1 diff -urN madwifi-ng-r2377-20070526.old/ath/if_ath.c madwifi-ng-r2377-20070526.dev/ath/if_ath.c
2 --- madwifi-ng-r2377-20070526.old/ath/if_ath.c 2007-05-26 18:51:09.318670888 +0200
3 +++ madwifi-ng-r2377-20070526.dev/ath/if_ath.c 2007-05-26 18:51:09.331668912 +0200
6 static void ath_setdefantenna(struct ath_softc *, u_int);
7 static struct ath_txq *ath_txq_setup(struct ath_softc *, int, int);
8 -static void ath_rx_tasklet(TQUEUE_ARG);
9 +static int ath_rx_poll(struct net_device *dev, int *budget);
10 static int ath_hardstart(struct sk_buff *, struct net_device *);
11 static int ath_mgtstart(struct ieee80211com *, struct sk_buff *);
12 #ifdef ATH_SUPERG_COMP
14 ATH_TXBUF_LOCK_INIT(sc);
15 ATH_RXBUF_LOCK_INIT(sc);
17 - ATH_INIT_TQUEUE(&sc->sc_rxtq, ath_rx_tasklet, dev);
18 ATH_INIT_TQUEUE(&sc->sc_txtq, ath_tx_tasklet, dev);
19 ATH_INIT_TQUEUE(&sc->sc_bmisstq, ath_bmiss_tasklet, dev);
20 ATH_INIT_TQUEUE(&sc->sc_bstucktq, ath_bstuck_tasklet, dev);
22 dev->set_mac_address = ath_set_mac_address;
23 dev->change_mtu = ath_change_mtu;
24 dev->tx_queue_len = ATH_TXBUF - 1; /* 1 for mgmt frame */
25 + dev->poll = ath_rx_poll;
27 #ifdef USE_HEADERLEN_RESV
28 dev->hard_header_len += sizeof(struct ieee80211_qosframe) +
32 ath_hal_getisr(ah, &status); /* NB: clears ISR too */
33 DPRINTF(sc, ATH_DEBUG_INTR, "%s: status 0x%x\n", __func__, status);
34 + sc->sc_isr = status;
35 status &= sc->sc_imask; /* discard unasked for bits */
36 if (status & HAL_INT_FATAL) {
37 sc->sc_stats.ast_hardware++;
38 @@ -1688,7 +1690,12 @@
39 if (status & HAL_INT_RX) {
40 sc->sc_tsf = ath_hal_gettsf64(ah);
41 ath_uapsd_processtriggers(sc);
42 - ATH_SCHEDULE_TQUEUE(&sc->sc_rxtq, &needmark);
43 + sc->sc_isr &= ~HAL_INT_RX;
44 + if (netif_rx_schedule_prep(dev)) {
45 + sc->sc_imask &= ~HAL_INT_RX;
46 + ath_hal_intrset(ah, sc->sc_imask);
47 + __netif_rx_schedule(dev);
50 if (status & HAL_INT_TX) {
51 #ifdef ATH_SUPERG_DYNTURBO
52 @@ -1714,6 +1721,11 @@
56 + /* disable transmit interrupt */
57 + sc->sc_isr &= ~HAL_INT_TX;
58 + ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_TX);
59 + sc->sc_imask &= ~HAL_INT_TX;
61 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, &needmark);
63 if (status & HAL_INT_BMISS) {
64 @@ -2176,12 +2188,13 @@
65 * Insert the frame on the outbound list and
66 * pass it on to the hardware.
69 + ATH_TXQ_LOCK_IRQ(txq);
70 if (ni && ni->ni_vap && txq == &ATH_VAP(ni->ni_vap)->av_mcastq) {
72 * The CAB queue is started from the SWBA handler since
73 * frames only go out on DTIM and to avoid possible races.
75 + sc->sc_imask &= ~HAL_INT_SWBA;
76 ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_SWBA);
77 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
78 DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: txq depth = %d\n", __func__, txq->axq_depth);
80 ito64(bf->bf_daddr), bf->bf_desc);
82 txq->axq_link = &lastds->ds_link;
83 + sc->sc_imask |= HAL_INT_SWBA;
84 ath_hal_intrset(ah, sc->sc_imask);
86 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
91 - ATH_TXQ_UNLOCK(txq);
92 + ATH_TXQ_UNLOCK_IRQ(txq);
94 sc->sc_devstats.tx_packets++;
95 sc->sc_devstats.tx_bytes += framelen;
96 @@ -2383,8 +2397,14 @@
101 + * NB: using _BH style locking even though this function may be called
102 + * at interrupt time (within tasklet or bh). This should be harmless
103 + * and this function calls others (i.e., ath_tx_start()) which do
108 + ATH_TXQ_LOCK_BH(txq);
110 bf_ff = TAILQ_LAST(&txq->axq_stageq, axq_headtype);
111 if ((!bf_ff) || ath_ff_flushdonetest(txq, bf_ff)) {
112 @@ -2398,7 +2418,7 @@
113 ATH_NODE(ni)->an_tx_ffbuf[bf_ff->bf_skb->priority] = NULL;
114 TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist);
116 - ATH_TXQ_UNLOCK(txq);
117 + ATH_TXQ_UNLOCK_BH(txq);
120 bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt);
121 @@ -2419,15 +2439,16 @@
123 bf_ff->bf_node = NULL;
125 - ATH_TXBUF_LOCK_IRQ(sc);
126 + ATH_TXBUF_LOCK_BH(sc);
127 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list);
128 - ATH_TXBUF_UNLOCK_IRQ(sc);
129 + ATH_TXBUF_UNLOCK_BH(sc);
131 + ATH_TXQ_UNLOCK_BH(txq);
135 #define ATH_HARDSTART_GET_TX_BUF_WITH_LOCK \
136 - ATH_TXBUF_LOCK_IRQ(sc); \
137 + ATH_TXBUF_LOCK_BH(sc); \
138 bf = STAILQ_FIRST(&sc->sc_txbuf); \
140 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); \
141 @@ -2442,11 +2463,23 @@
142 sc->sc_devstopped = 1; \
143 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL); \
145 - ATH_TXBUF_UNLOCK_IRQ(sc); \
147 +#define ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF \
148 + ATH_TXBUF_UNLOCK_BH(sc); \
149 + if (bf == NULL) { /* NB: should not happen */ \
150 + DPRINTF(sc,ATH_DEBUG_XMIT,"%s: discard, no xmit buf\n", __func__); \
151 + sc->sc_stats.ast_tx_nobuf++; \
152 + goto hardstart_fail; \
155 +#define ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_ON \
156 + ATH_TXBUF_UNLOCK_BH(sc); \
157 if (bf == NULL) { /* NB: should not happen */ \
158 DPRINTF(sc,ATH_DEBUG_XMIT, \
159 "%s: discard, no xmit buf\n", __func__); \
160 + ATH_TXQ_UNLOCK_BH(txq); \
161 sc->sc_stats.ast_tx_nobuf++; \
162 + goto hardstart_fail; \
166 @@ -2508,6 +2541,7 @@
167 if (M_FLAG_GET(skb, M_UAPSD)) {
168 /* bypass FF handling */
169 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
170 + ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF;
174 @@ -2529,7 +2563,7 @@
175 /* NB: use this lock to protect an->an_ff_txbuf in athff_can_aggregate()
179 + ATH_TXQ_LOCK_BH(txq);
180 if (athff_can_aggregate(sc, eh, an, skb, vap->iv_fragthreshold, &ff_flush)) {
182 if (an->an_tx_ffbuf[skb->priority]) { /* i.e., frame on the staging queue */
183 @@ -2539,7 +2573,7 @@
184 TAILQ_REMOVE(&txq->axq_stageq, bf, bf_stagelist);
185 an->an_tx_ffbuf[skb->priority] = NULL;
187 - ATH_TXQ_UNLOCK(txq);
188 + ATH_TXQ_UNLOCK_BH(txq);
191 * chain skbs and add FF magic
192 @@ -2566,6 +2600,7 @@
193 * to give the buffer back.
195 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
196 + ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_ON;
200 @@ -2580,7 +2615,7 @@
202 TAILQ_INSERT_HEAD(&txq->axq_stageq, bf, bf_stagelist);
204 - ATH_TXQ_UNLOCK(txq);
205 + ATH_TXQ_UNLOCK_BH(txq);
209 @@ -2591,7 +2626,7 @@
210 TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist);
211 an->an_tx_ffbuf[skb->priority] = NULL;
213 - ATH_TXQ_UNLOCK(txq);
214 + ATH_TXQ_UNLOCK_BH(txq);
217 bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt);
218 @@ -2621,9 +2656,9 @@
220 bf_ff->bf_node = NULL;
222 - ATH_TXBUF_LOCK(sc);
223 + ATH_TXBUF_LOCK_BH(sc);
224 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list);
225 - ATH_TXBUF_UNLOCK(sc);
226 + ATH_TXBUF_UNLOCK_BH(sc);
230 @@ -2633,14 +2668,13 @@
231 else if (an->an_tx_ffbuf[skb->priority]) {
232 DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF,
233 "%s: Out-Of-Order fast-frame\n", __func__);
234 - ATH_TXQ_UNLOCK(txq);
235 + ATH_TXQ_UNLOCK_BH(txq);
237 - ATH_TXQ_UNLOCK(txq);
238 + ATH_TXQ_UNLOCK_BH(txq);
241 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
243 - goto hardstart_fail;
244 + ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF;
248 @@ -2648,6 +2682,7 @@
249 #else /* ATH_SUPERG_FF */
251 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
252 + ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF;
254 #endif /* ATH_SUPERG_FF */
256 @@ -2669,7 +2704,7 @@
257 * Allocate 1 ath_buf for each frame given 1 was
260 - ATH_TXBUF_LOCK(sc);
261 + ATH_TXBUF_LOCK_BH(sc);
262 for (bfcnt = 1; bfcnt < framecnt; ++bfcnt) {
263 if ((tbf = STAILQ_FIRST(&sc->sc_txbuf)) != NULL) {
264 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list);
265 @@ -2690,11 +2725,11 @@
266 STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list);
269 - ATH_TXBUF_UNLOCK(sc);
270 + ATH_TXBUF_UNLOCK_BH(sc);
271 STAILQ_INIT(&bf_head);
274 - ATH_TXBUF_UNLOCK(sc);
275 + ATH_TXBUF_UNLOCK_BH(sc);
277 while ((bf = STAILQ_FIRST(&bf_head)) != NULL && skb != NULL) {
278 unsigned int nextfraglen = 0;
279 @@ -2730,7 +2765,7 @@
282 if (!STAILQ_EMPTY(&bf_head)) {
283 - ATH_TXBUF_LOCK(sc);
284 + ATH_TXBUF_LOCK_BH(sc);
285 STAILQ_FOREACH_SAFE(tbf, &bf_head, bf_list, tempbf) {
288 @@ -2740,7 +2775,7 @@
290 STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list);
292 - ATH_TXBUF_UNLOCK(sc);
293 + ATH_TXBUF_UNLOCK_BH(sc);
297 @@ -2783,7 +2818,7 @@
299 * Grab a TX buffer and associated resources.
301 - ATH_TXBUF_LOCK_IRQ(sc);
302 + ATH_TXBUF_LOCK_BH(sc);
303 bf = STAILQ_FIRST(&sc->sc_txbuf);
305 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list);
306 @@ -2794,7 +2829,7 @@
308 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL);
310 - ATH_TXBUF_UNLOCK_IRQ(sc);
311 + ATH_TXBUF_UNLOCK_BH(sc);
313 printk("ath_mgtstart: discard, no xmit buf\n");
314 sc->sc_stats.ast_tx_nobufmgt++;
315 @@ -2823,9 +2858,9 @@
319 - ATH_TXBUF_LOCK_IRQ(sc);
320 + ATH_TXBUF_LOCK_BH(sc);
321 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
322 - ATH_TXBUF_UNLOCK_IRQ(sc);
323 + ATH_TXBUF_UNLOCK_BH(sc);
325 dev_kfree_skb_any(skb);
327 @@ -3293,10 +3328,10 @@
329 * XXX Using in_softirq is not right since we might
330 * be called from other soft irq contexts than
335 - tasklet_disable(&sc->sc_rxtq);
336 + netif_poll_disable(dev);
337 netif_stop_queue(dev);
340 @@ -3309,7 +3344,7 @@
341 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__);
342 netif_start_queue(dev);
343 if (!in_softirq()) /* NB: see above */
344 - tasklet_enable(&sc->sc_rxtq);
345 + netif_poll_enable(dev);
349 @@ -4875,9 +4910,9 @@
351 bf->bf_desc->ds_link = 0;
353 - ATH_TXBUF_LOCK_IRQ(sc);
354 + ATH_TXBUF_LOCK_BH(sc);
355 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
356 - ATH_TXBUF_UNLOCK_IRQ(sc);
357 + ATH_TXBUF_UNLOCK_BH(sc);
359 an->an_uapsd_overflowqdepth--;
361 @@ -5553,13 +5588,12 @@
362 sc->sc_rxotherant = 0;
366 -ath_rx_tasklet(TQUEUE_ARG data)
368 +ath_rx_poll(struct net_device *dev, int *budget)
370 #define PA2DESC(_sc, _pa) \
371 ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
372 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
373 - struct net_device *dev = (struct net_device *)data;
375 struct ath_softc *sc = dev->priv;
376 struct ieee80211com *ic = &sc->sc_ic;
377 @@ -5571,12 +5605,15 @@
381 + u_int processed = 0, early_stop = 0;
382 + u_int rx_limit = dev->quota;
384 /* Let the 802.11 layer know about the new noise floor */
385 sc->sc_channoise = ath_hal_get_channel_noise(ah, &(sc->sc_curchan));
386 ic->ic_channoise = sc->sc_channoise;
388 DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s\n", __func__);
391 bf = STAILQ_FIRST(&sc->sc_rxbuf);
392 if (bf == NULL) { /* XXX ??? can this happen */
393 @@ -5600,6 +5637,13 @@
394 /* NB: never process the self-linked entry at the end */
399 + if (rx_limit-- < 0) {
405 if (skb == NULL) { /* XXX ??? can this happen */
406 printk("%s: no skbuff (%s)\n", dev->name, __func__);
407 @@ -5638,6 +5682,7 @@
408 sc->sc_stats.ast_rx_phyerr++;
409 phyerr = rs->rs_phyerr & 0x1f;
410 sc->sc_stats.ast_rx_phy[phyerr]++;
413 if (rs->rs_status & HAL_RXERR_DECRYPT) {
415 @@ -5841,9 +5886,29 @@
416 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
417 ATH_RXBUF_UNLOCK_IRQ(sc);
418 } while (ath_rxbuf_init(sc, bf) == 0);
420 + /* Check if more data is received while we were
421 + * processing the descriptor chain.
423 + ATH_DISABLE_INTR();
424 + if (sc->sc_isr & HAL_INT_RX) {
425 + sc->sc_isr &= ~HAL_INT_RX;
427 + ath_uapsd_processtriggers(sc);
428 + goto process_rx_again;
430 + netif_rx_complete(dev);
432 + sc->sc_imask |= HAL_INT_RX;
433 + ath_hal_intrset(ah, sc->sc_imask);
437 + *budget -= processed;
439 /* rx signal state monitoring */
440 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
445 @@ -6119,22 +6184,22 @@
449 - ATH_TXBUF_LOCK_IRQ(sc);
450 + ATH_TXBUF_LOCK_BH(sc);
451 bf = STAILQ_FIRST(&sc->sc_grppollbuf);
453 STAILQ_REMOVE_HEAD(&sc->sc_grppollbuf, bf_list);
455 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: No more TxBufs\n", __func__);
456 - ATH_TXBUF_UNLOCK_IRQ_EARLY(sc);
457 + ATH_TXBUF_UNLOCK_BH(sc);
460 /* XXX use a counter and leave at least one for mgmt frames */
461 if (STAILQ_EMPTY(&sc->sc_grppollbuf)) {
462 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: No more TxBufs left\n", __func__);
463 - ATH_TXBUF_UNLOCK_IRQ_EARLY(sc);
464 + ATH_TXBUF_UNLOCK_BH(sc);
467 - ATH_TXBUF_UNLOCK_IRQ(sc);
468 + ATH_TXBUF_UNLOCK_BH(sc);
470 bf->bf_skbaddr = bus_map_single(sc->sc_bdev,
471 skb->data, skb->len, BUS_DMA_TODEVICE);
472 @@ -6600,9 +6665,9 @@
473 dev_kfree_skb(lastbuf->bf_skb);
474 lastbuf->bf_skb = NULL;
475 ieee80211_unref_node(&lastbuf->bf_node);
476 - ATH_TXBUF_LOCK_IRQ(sc);
477 + ATH_TXBUF_LOCK_BH(sc);
478 STAILQ_INSERT_TAIL(&sc->sc_txbuf, lastbuf, bf_list);
479 - ATH_TXBUF_UNLOCK_IRQ(sc);
480 + ATH_TXBUF_UNLOCK_BH(sc);
483 * move oldest from overflow to delivery
484 @@ -7427,9 +7492,6 @@
485 if (sc->sc_reapcount > ATH_TXBUF_FREE_THRESHOLD) {
487 netif_start_queue(sc->sc_dev);
488 - DPRINTF(sc, ATH_DEBUG_TX_PROC,
489 - "%s: tx tasklet restart the queue\n",
491 sc->sc_reapcount = 0;
492 sc->sc_devstopped = 0;
494 @@ -7464,11 +7526,22 @@
495 struct net_device *dev = (struct net_device *)data;
496 struct ath_softc *sc = dev->priv;
499 if (txqactive(sc->sc_ah, 0))
500 ath_tx_processq(sc, &sc->sc_txq[0]);
501 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum))
502 ath_tx_processq(sc, sc->sc_cabq);
504 + ATH_DISABLE_INTR();
505 + if (sc->sc_isr & HAL_INT_TX) {
506 + sc->sc_isr &= ~HAL_INT_TX;
508 + goto process_tx_again;
510 + sc->sc_imask |= HAL_INT_TX;
511 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
514 netif_wake_queue(dev);
517 @@ -7485,6 +7558,7 @@
518 struct net_device *dev = (struct net_device *)data;
519 struct ath_softc *sc = dev->priv;
523 * Process each active queue.
525 @@ -7505,6 +7579,16 @@
526 if (sc->sc_uapsdq && txqactive(sc->sc_ah, sc->sc_uapsdq->axq_qnum))
527 ath_tx_processq(sc, sc->sc_uapsdq);
529 + ATH_DISABLE_INTR();
530 + if (sc->sc_isr & HAL_INT_TX) {
531 + sc->sc_isr &= ~HAL_INT_TX;
533 + goto process_tx_again;
535 + sc->sc_imask |= HAL_INT_TX;
536 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
539 netif_wake_queue(dev);
542 @@ -7522,6 +7606,7 @@
545 /* Process each active queue. */
547 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
548 if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i))
549 ath_tx_processq(sc, &sc->sc_txq[i]);
550 @@ -7530,6 +7615,16 @@
551 ath_tx_processq(sc, sc->sc_xrtxq);
554 + ATH_DISABLE_INTR();
555 + if (sc->sc_isr & HAL_INT_TX) {
556 + sc->sc_isr &= ~HAL_INT_TX;
558 + goto process_tx_again;
560 + sc->sc_imask |= HAL_INT_TX;
561 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
564 netif_wake_queue(dev);
567 @@ -7628,6 +7723,7 @@
568 ath_draintxq(struct ath_softc *sc)
570 struct ath_hal *ah = sc->sc_ah;
574 /* XXX return value */
575 @@ -9161,9 +9257,9 @@
577 if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
578 /* NB: the rx buffers may need to be reallocated */
579 - tasklet_disable(&sc->sc_rxtq);
580 + netif_poll_disable(dev);
581 error = ath_reset(dev);
582 - tasklet_enable(&sc->sc_rxtq);
583 + netif_poll_enable(dev);
587 diff -urN madwifi-ng-r2377-20070526.old/ath/if_athvar.h madwifi-ng-r2377-20070526.dev/ath/if_athvar.h
588 --- madwifi-ng-r2377-20070526.old/ath/if_athvar.h 2007-05-26 18:51:09.020716184 +0200
589 +++ madwifi-ng-r2377-20070526.dev/ath/if_athvar.h 2007-05-26 18:51:09.331668912 +0200
591 #include "if_athioctl.h"
592 #include "net80211/ieee80211.h" /* XXX for WME_NUM_AC */
594 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
595 +#define irqs_disabled() 0
599 * Deduce if tasklets are available. If not then
600 * fall back to using the immediate work queue.
602 #define ATH_TXQ_LOCK_DESTROY(_tq)
603 #define ATH_TXQ_LOCK(_tq) spin_lock(&(_tq)->axq_lock)
604 #define ATH_TXQ_UNLOCK(_tq) spin_unlock(&(_tq)->axq_lock)
605 -#define ATH_TXQ_LOCK_BH(_tq) spin_lock_bh(&(_tq)->axq_lock)
606 -#define ATH_TXQ_UNLOCK_BH(_tq) spin_unlock_bh(&(_tq)->axq_lock)
607 +#define ATH_TXQ_LOCK_BH(_tq) \
608 + if (!irqs_disabled()) \
609 + spin_lock_bh(&(_tq)->axq_lock)
610 +#define ATH_TXQ_UNLOCK_BH(_tq) \
611 + if (!irqs_disabled()) \
612 + spin_unlock_bh(&(_tq)->axq_lock)
613 #define ATH_TXQ_LOCK_IRQ(_tq) do { \
614 unsigned long __axq_lockflags; \
615 spin_lock_irqsave(&(_tq)->axq_lock, __axq_lockflags);
617 struct ath_buf *sc_rxbufcur; /* current rx buffer */
618 u_int32_t *sc_rxlink; /* link ptr in last RX desc */
619 spinlock_t sc_rxbuflock;
620 - struct ATH_TQ_STRUCT sc_rxtq; /* rx intr tasklet */
621 struct ATH_TQ_STRUCT sc_rxorntq; /* rxorn intr tasklet */
622 u_int8_t sc_defant; /* current default antenna */
623 u_int8_t sc_rxotherant; /* rx's on non-default antenna*/
625 u_int sc_txintrperiod; /* tx interrupt batching */
626 struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
627 struct ath_txq *sc_ac2q[WME_NUM_AC]; /* WME AC -> h/w qnum */
628 + HAL_INT sc_isr; /* unmasked ISR state */
629 struct ATH_TQ_STRUCT sc_txtq; /* tx intr tasklet */
630 u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];
631 struct ath_descdma sc_bdma; /* beacon descriptors */
633 #define ATH_TXBUF_LOCK_DESTROY(_sc)
634 #define ATH_TXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_txbuflock)
635 #define ATH_TXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_txbuflock)
636 -#define ATH_TXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_txbuflock)
637 -#define ATH_TXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_txbuflock)
638 +#define ATH_TXBUF_LOCK_BH(_sc) \
639 + if (!irqs_disabled()) \
640 + spin_lock_bh(&(_sc)->sc_txbuflock)
641 +#define ATH_TXBUF_UNLOCK_BH(_sc) \
642 + if (!irqs_disabled()) \
643 + spin_unlock_bh(&(_sc)->sc_txbuflock)
644 #define ATH_TXBUF_LOCK_IRQ(_sc) do { \
645 unsigned long __txbuflockflags; \
646 spin_lock_irqsave(&(_sc)->sc_txbuflock, __txbuflockflags);
648 #define ATH_RXBUF_LOCK_DESTROY(_sc)
649 #define ATH_RXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_rxbuflock)
650 #define ATH_RXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_rxbuflock)
651 -#define ATH_RXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_rxbuflock)
652 -#define ATH_RXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_rxbuflock)
653 +#define ATH_RXBUF_LOCK_BH(_sc) \
654 + if (!irqs_disabled()) \
655 + spin_lock_bh(&(_sc)->sc_rxbuflock)
656 +#define ATH_RXBUF_UNLOCK_BH(_sc) \
657 + if (!irqs_disabled()) \
658 + spin_unlock_bh(&(_sc)->sc_rxbuflock)
659 #define ATH_RXBUF_LOCK_IRQ(_sc) do { \
660 unsigned long __rxbuflockflags; \
661 spin_lock_irqsave(&(_sc)->sc_rxbuflock, __rxbuflockflags);
663 #define ATH_RXBUF_UNLOCK_IRQ_EARLY(_sc) \
664 spin_unlock_irqrestore(&(_sc)->sc_rxbuflock, __rxbuflockflags);
666 +#define ATH_DISABLE_INTR local_irq_disable
667 +#define ATH_ENABLE_INTR local_irq_enable
669 /* Protects the device from concurrent accesses */
670 #define ATH_LOCK_INIT(_sc) init_MUTEX(&(_sc)->sc_lock)
671 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_beacon.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_beacon.c
672 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_beacon.c 2007-01-30 05:01:29.000000000 +0100
673 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_beacon.c 2007-05-26 18:51:09.332668760 +0200
678 - IEEE80211_LOCK(ic);
679 + IEEE80211_BEACON_LOCK(ic);
681 if ((ic->ic_flags & IEEE80211_F_DOTH) &&
682 (vap->iv_flags & IEEE80211_F_CHANSWITCH) &&
684 vap->iv_flags_ext &= ~IEEE80211_FEXT_APPIE_UPDATE;
687 - IEEE80211_UNLOCK(ic);
688 + IEEE80211_BEACON_UNLOCK(ic);
692 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_input.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_input.c
693 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_input.c 2007-05-26 18:51:09.107702960 +0200
694 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_input.c 2007-05-26 18:51:09.333668608 +0200
695 @@ -1169,8 +1169,9 @@
696 if (ni->ni_vlan != 0 && vap->iv_vlgrp != NULL) {
697 /* attach vlan tag */
698 vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan);
702 + netif_receive_skb(skb);
704 dev->last_rx = jiffies;
707 @@ -3668,9 +3669,9 @@
710 /* Okay, take the first queued packet and put it out... */
711 - IEEE80211_NODE_SAVEQ_LOCK(ni);
712 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
713 IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen);
714 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
715 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
717 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_POWER, wh->i_addr2,
718 "%s", "recv ps-poll, but queue empty");
719 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_linux.h madwifi-ng-r2377-20070526.dev/net80211/ieee80211_linux.h
720 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_linux.h 2007-05-24 19:31:37.000000000 +0200
721 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_linux.h 2007-05-26 18:51:09.334668456 +0200
724 #include <linux/wireless.h>
726 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
727 +#define irqs_disabled() 0
735 #define IEEE80211_UNLOCK_IRQ_EARLY(_ic) \
736 spin_unlock_irqrestore(&(_ic)->ic_comlock, __ilockflags);
737 -#define IEEE80211_LOCK_BH(_ic) spin_lock_bh(&(_ic)->ic_comlock)
738 -#define IEEE80211_UNLOCK_BH(_ic) spin_unlock_bh(&(_ic)->ic_comlock)
739 +#define IEEE80211_LOCK_BH(_ic) \
740 + if (!irqs_disabled()) \
741 + spin_lock_bh(&(_ic)->ic_comlock)
742 +#define IEEE80211_UNLOCK_BH(_ic) \
743 + if (!irqs_disabled()) \
744 + spin_unlock_bh(&(_ic)->ic_comlock)
745 #define IEEE80211_LOCK(_ic) spin_lock(&(_ic)->ic_comlock)
746 #define IEEE80211_UNLOCK(_ic) spin_unlock(&(_ic)->ic_comlock)
748 @@ -104,15 +112,22 @@
749 #define IEEE80211_VAPS_LOCK_DESTROY(_ic)
750 #define IEEE80211_VAPS_LOCK(_ic) spin_lock(&(_ic)->ic_vapslock);
751 #define IEEE80211_VAPS_UNLOCK(_ic) spin_unlock(&(_ic)->ic_vapslock);
752 -#define IEEE80211_VAPS_LOCK_BH(_ic) spin_lock_bh(&(_ic)->ic_vapslock);
753 -#define IEEE80211_VAPS_UNLOCK_BH(_ic) spin_unlock_bh(&(_ic)->ic_vapslock);
754 -#define IEEE80211_VAPS_LOCK_IRQ(_ic) do { \
755 - int _vaps_lockflags; \
756 - spin_lock_irqsave(&(_ic)->ic_vapslock, _vaps_lockflags);
757 -#define IEEE80211_VAPS_UNLOCK_IRQ(_ic) \
758 - spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags); \
760 -#define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic) spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags)
761 +#define IEEE80211_VAPS_LOCK_BH(_ic) \
762 + if (!irqs_disabled()) \
763 + spin_lock_bh(&(_ic)->ic_vapslock);
764 +#define IEEE80211_VAPS_UNLOCK_BH(_ic) \
765 + if (!irqs_disabled()) \
766 + spin_unlock_bh(&(_ic)->ic_vapslock);
767 +#define IEEE80211_VAPS_LOCK_IRQ(_ic) do { \
768 + unsigned long __vlockflags=0; \
769 + unsigned int __vlocked=0; \
770 + __vlocked=spin_is_locked(&(_ic)->ic_vapslock); \
771 + if(!__vlocked) spin_lock_irqsave(&(_ic)->ic_vapslock, __vlockflags);
772 +#define IEEE80211_VAPS_UNLOCK_IRQ(_ic) \
773 + if(!__vlocked) spin_unlock_irqrestore(&(_ic)->ic_vapslock, __vlockflags); \
775 +#define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic) \
776 + if (!__vlocked) spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags)
778 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)
779 #define IEEE80211_VAPS_LOCK_ASSERT(_ic) \
781 #define IEEE80211_VAPS_LOCK_ASSERT(_ic)
785 + * Beacon locking definitions; piggyback on com lock.
787 +#define IEEE80211_BEACON_LOCK(_ic) IEEE80211_LOCK_IRQ(_ic)
788 +#define IEEE80211_BEACON_UNLOCK(_ic) IEEE80211_UNLOCK_IRQ(_ic)
791 * Node locking definitions.
793 typedef spinlock_t ieee80211_scan_lock_t;
794 #define IEEE80211_SCAN_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_scanlock)
795 #define IEEE80211_SCAN_LOCK_DESTROY(_nt)
796 -#define IEEE80211_SCAN_LOCK_BH(_nt) spin_lock_bh(&(_nt)->nt_scanlock)
797 -#define IEEE80211_SCAN_UNLOCK_BH(_nt) spin_unlock_bh(&(_nt)->nt_scanlock)
798 +#define IEEE80211_SCAN_LOCK_BH(_nt) \
799 + if (!irqs_disabled()) \
800 + spin_lock_bh(&(_nt)->nt_scanlock)
801 +#define IEEE80211_SCAN_UNLOCK_BH(_nt) \
802 + if (!irqs_disabled()) \
803 + spin_unlock_bh(&(_nt)->nt_scanlock)
804 #define IEEE80211_SCAN_LOCK_IRQ(_nt) do { \
805 unsigned long __scan_lockflags; \
806 spin_lock_irqsave(&(_nt)->nt_scanlock, __scan_lockflags);
808 #define ACL_LOCK_DESTROY(_as)
809 #define ACL_LOCK(_as) spin_lock(&(_as)->as_lock)
810 #define ACL_UNLOCK(_as) spin_unlock(&(_as)->as_lock)
811 -#define ACL_LOCK_BH(_as) spin_lock_bh(&(_as)->as_lock)
812 -#define ACL_UNLOCK_BH(_as) spin_unlock_bh(&(_as)->as_lock)
813 +#define ACL_LOCK_BH(_as) \
814 + if (!irqs_disabled()) \
815 + spin_lock_bh(&(_as)->as_lock)
816 +#define ACL_UNLOCK_BH(_as) \
817 + if (!irqs_disabled()) \
818 + spin_unlock_bh(&(_as)->as_lock)
820 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)
821 #define ACL_LOCK_ASSERT(_as) \
822 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_node.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_node.c
823 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_node.c 2007-05-26 18:51:08.748757528 +0200
824 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_node.c 2007-05-26 18:51:09.335668304 +0200
825 @@ -1567,7 +1567,7 @@
826 struct ieee80211_node *ni;
829 - IEEE80211_SCAN_LOCK_IRQ(nt);
830 + IEEE80211_SCAN_LOCK_BH(nt);
831 gen = ++nt->nt_scangen;
834 @@ -1587,7 +1587,7 @@
836 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
838 - IEEE80211_SCAN_UNLOCK_IRQ(nt);
839 + IEEE80211_SCAN_UNLOCK_BH(nt);
841 EXPORT_SYMBOL(ieee80211_iterate_dev_nodes);
843 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_power.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_power.c
844 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_power.c 2007-05-24 19:31:37.000000000 +0200
845 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_power.c 2007-05-26 18:51:09.336668152 +0200
850 - IEEE80211_NODE_SAVEQ_LOCK(ni);
851 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
852 while ((skb = skb_peek(&ni->ni_savedq)) != NULL &&
853 M_AGE_GET(skb) < IEEE80211_INACT_WAIT) {
854 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
858 M_AGE_SUB(skb, IEEE80211_INACT_WAIT);
859 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
860 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
862 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
863 "discard %u frames for age", discard);
865 KASSERT(aid < vap->iv_max_aid,
866 ("bogus aid %u, max %u", aid, vap->iv_max_aid));
868 - IEEE80211_LOCK(ni->ni_ic);
869 + IEEE80211_BEACON_LOCK(ni->ni_ic);
870 if (set != (isset(vap->iv_tim_bitmap, aid) != 0)) {
872 setbit(vap->iv_tim_bitmap, aid);
875 vap->iv_flags |= IEEE80211_F_TIMUPDATE;
877 - IEEE80211_UNLOCK(ni->ni_ic);
878 + IEEE80211_BEACON_UNLOCK(ni->ni_ic);
886 - IEEE80211_NODE_SAVEQ_LOCK(ni);
887 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
888 IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen);
889 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
890 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
898 - IEEE80211_NODE_SAVEQ_LOCK(ni);
899 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
900 skb = __skb_dequeue(&ni->ni_savedq);
901 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
902 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
905 ieee80211_parent_queue_xmit(skb);
906 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_proto.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_proto.c
907 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_proto.c 2007-05-26 18:51:09.321670432 +0200
908 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_proto.c 2007-05-26 18:51:09.337668000 +0200
911 struct ieee80211com *ic = vap->iv_ic;
913 - IEEE80211_LOCK(ic);
914 + IEEE80211_BEACON_LOCK(ic);
915 ieee80211_wme_initparams_locked(vap);
916 - IEEE80211_UNLOCK(ic);
917 + IEEE80211_BEACON_UNLOCK(ic);
922 struct ieee80211com *ic = vap->iv_ic;
924 if (ic->ic_caps & IEEE80211_C_WME) {
925 - IEEE80211_LOCK(ic);
926 + IEEE80211_BEACON_LOCK(ic);
927 ieee80211_wme_updateparams_locked(vap);
928 - IEEE80211_UNLOCK(ic);
929 + IEEE80211_BEACON_UNLOCK(ic);
933 diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_scan_sta.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_scan_sta.c
934 --- madwifi-ng-r2377-20070526.old/net80211/ieee80211_scan_sta.c 2007-05-21 17:53:39.000000000 +0200
935 +++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_scan_sta.c 2007-05-26 18:51:09.338667848 +0200
938 struct sta_table *st = ss->ss_priv;
940 - spin_lock(&st->st_lock);
941 + if (!irqs_disabled())
942 + spin_lock_bh(&st->st_lock);
944 - spin_unlock(&st->st_lock);
945 + if (!irqs_disabled())
946 + spin_unlock_bh(&st->st_lock);
953 hash = STA_HASH(macaddr);
954 - spin_lock(&st->st_lock);
955 + if (!irqs_disabled())
956 + spin_lock_bh(&st->st_lock);
957 LIST_FOREACH(se, &st->st_hash[hash], se_hash)
958 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr) &&
959 sp->ssid[1] == se->base.se_ssid[1] &&
961 MALLOC(se, struct sta_entry *, sizeof(struct sta_entry),
962 M_80211_SCAN, M_NOWAIT | M_ZERO);
964 - spin_unlock(&st->st_lock);
965 + spin_unlock_bh(&st->st_lock);
968 se->se_scangen = st->st_scangen-1;
973 - spin_unlock(&st->st_lock);
974 + if (!irqs_disabled())
975 + spin_unlock_bh(&st->st_lock);
978 * If looking for a quick choice and nothing's
979 @@ -1063,7 +1067,8 @@
983 - spin_lock(&st->st_scanlock);
984 + if (!irqs_disabled())
985 + spin_lock_bh(&st->st_scanlock);
986 gen = st->st_scangen++;
988 spin_lock(&st->st_lock);
989 @@ -1086,7 +1091,8 @@
990 spin_unlock(&st->st_lock);
993 - spin_unlock(&st->st_scanlock);
994 + if (!irqs_disabled())
995 + spin_unlock_bh(&st->st_scanlock);
999 @@ -1235,7 +1241,8 @@
1003 - spin_lock(&st->st_lock);
1004 + if (!irqs_disabled())
1005 + spin_lock_bh(&st->st_lock);
1006 for (i = 0; i < ss->ss_last; i++) {
1007 c = ss->ss_chans[i];
1009 @@ -1248,7 +1255,8 @@
1010 if (bestchan == NULL || maxrssi < bestrssi)
1013 - spin_unlock(&st->st_lock);
1014 + if (!irqs_disabled())
1015 + spin_unlock_bh(&st->st_lock);