update madwifi to latest trunk - performance enhancements
[librecmc/librecmc.git] / package / madwifi / patches / 300-napi_polling.patch
index d5c2dfc5439a2a2cf59f1cebce3fc14171ea01eb..b0d5af8390415b39d9abf1a984756d81d2e5a83f 100644 (file)
@@ -1,7 +1,7 @@
-diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath.c
---- madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c        2007-05-13 18:17:56.576968032 +0200
-+++ madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath.c        2007-05-13 18:17:56.594965296 +0200
-@@ -170,7 +170,7 @@
+diff -urN madwifi-ng-r2377-20070526.old/ath/if_ath.c madwifi-ng-r2377-20070526.dev/ath/if_ath.c
+--- madwifi-ng-r2377-20070526.old/ath/if_ath.c 2007-05-26 18:51:09.318670888 +0200
++++ madwifi-ng-r2377-20070526.dev/ath/if_ath.c 2007-05-26 18:51:09.331668912 +0200
+@@ -167,7 +167,7 @@
        int, u_int32_t);
  static void ath_setdefantenna(struct ath_softc *, u_int);
  static struct ath_txq *ath_txq_setup(struct ath_softc *, int, int);
@@ -10,7 +10,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  static int ath_hardstart(struct sk_buff *, struct net_device *);
  static int ath_mgtstart(struct ieee80211com *, struct sk_buff *);
  #ifdef ATH_SUPERG_COMP
-@@ -420,7 +420,6 @@
+@@ -429,7 +429,6 @@
        ATH_TXBUF_LOCK_INIT(sc);
        ATH_RXBUF_LOCK_INIT(sc);
  
@@ -18,7 +18,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        ATH_INIT_TQUEUE(&sc->sc_txtq,     ath_tx_tasklet,       dev);
        ATH_INIT_TQUEUE(&sc->sc_bmisstq,  ath_bmiss_tasklet,    dev);
        ATH_INIT_TQUEUE(&sc->sc_bstucktq, ath_bstuck_tasklet,   dev);
-@@ -674,6 +673,8 @@
+@@ -685,6 +684,8 @@
        dev->set_mac_address = ath_set_mac_address;
        dev->change_mtu = ath_change_mtu;
        dev->tx_queue_len = ATH_TXBUF - 1;              /* 1 for mgmt frame */
@@ -27,7 +27,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  #ifdef USE_HEADERLEN_RESV
        dev->hard_header_len += sizeof(struct ieee80211_qosframe) +
                                sizeof(struct llc) +
-@@ -1645,6 +1646,7 @@
+@@ -1653,6 +1654,7 @@
         */
        ath_hal_getisr(ah, &status);            /* NB: clears ISR too */
        DPRINTF(sc, ATH_DEBUG_INTR, "%s: status 0x%x\n", __func__, status);
@@ -35,10 +35,10 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        status &= sc->sc_imask;                 /* discard unasked for bits */
        if (status & HAL_INT_FATAL) {
                sc->sc_stats.ast_hardware++;
-@@ -1684,7 +1686,12 @@
-                        * might take too long to fire */
-                       ath_hal_process_noisefloor(ah);
-                       sc->sc_channoise = ath_hal_get_channel_noise(ah, &(sc->sc_curchan));
+@@ -1688,7 +1690,12 @@
+               if (status & HAL_INT_RX) {
+                       sc->sc_tsf = ath_hal_gettsf64(ah);
+                       ath_uapsd_processtriggers(sc);
 -                      ATH_SCHEDULE_TQUEUE(&sc->sc_rxtq, &needmark);
 +                      sc->sc_isr &= ~HAL_INT_RX;
 +                      if (netif_rx_schedule_prep(dev)) {
@@ -49,7 +49,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                }
                if (status & HAL_INT_TX) {
  #ifdef ATH_SUPERG_DYNTURBO
-@@ -1710,6 +1717,11 @@
+@@ -1714,6 +1721,11 @@
                                }
                        } 
  #endif
@@ -59,14 +59,14 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
 +                      sc->sc_imask &= ~HAL_INT_TX;
 +
                        ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, &needmark);
-                       sc->sc_tx_start = 0;
                }
-@@ -2221,12 +2233,13 @@
+               if (status & HAL_INT_BMISS) {
+@@ -2176,12 +2188,13 @@
         * Insert the frame on the outbound list and
         * pass it on to the hardware.
         */
 -      ATH_TXQ_LOCK(txq);
-+      ATH_TXQ_LOCK_BH(txq);
++      ATH_TXQ_LOCK_IRQ(txq);
        if (ni && ni->ni_vap && txq == &ATH_VAP(ni->ni_vap)->av_mcastq) {
                /*
                 * The CAB queue is started from the SWBA handler since
@@ -76,7 +76,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_SWBA);
                ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
                DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: txq depth = %d\n", __func__, txq->axq_depth);
-@@ -2242,6 +2255,7 @@
+@@ -2197,6 +2210,7 @@
                                ito64(bf->bf_daddr), bf->bf_desc);
                }
                txq->axq_link = &lastds->ds_link;
@@ -84,16 +84,16 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                ath_hal_intrset(ah, sc->sc_imask);
        } else {
                ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
-@@ -2275,7 +2289,7 @@
-                       sc->sc_tx_start = jiffies;
+@@ -2232,7 +2246,7 @@
+                       }
                }
        }
 -      ATH_TXQ_UNLOCK(txq);
-+      ATH_TXQ_UNLOCK_BH(txq);
++      ATH_TXQ_UNLOCK_IRQ(txq);
  
        sc->sc_devstats.tx_packets++;
        sc->sc_devstats.tx_bytes += framelen;
-@@ -2426,8 +2440,14 @@
+@@ -2383,8 +2397,14 @@
        unsigned int pktlen;
        int framecnt;
  
@@ -109,7 +109,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                bf_ff = TAILQ_LAST(&txq->axq_stageq, axq_headtype);
                if ((!bf_ff) || ath_ff_flushdonetest(txq, bf_ff)) {
-@@ -2441,7 +2461,7 @@
+@@ -2398,7 +2418,7 @@
                ATH_NODE(ni)->an_tx_ffbuf[bf_ff->bf_skb->priority] = NULL;
                TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist);
  
@@ -118,7 +118,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                /* encap and xmit */
                bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt);
-@@ -2462,15 +2482,16 @@
+@@ -2419,15 +2439,16 @@
                }
                bf_ff->bf_node = NULL;
  
@@ -138,7 +138,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        bf = STAILQ_FIRST(&sc->sc_txbuf);                               \
        if (bf != NULL) {                                               \
                STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list);             \
-@@ -2485,10 +2506,21 @@
+@@ -2442,11 +2463,23 @@
                sc->sc_devstopped = 1;                                  \
                ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL);                \
        }                                                               \
@@ -159,9 +159,11 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                        "%s: discard, no xmit buf\n", __func__);        \
 +          ATH_TXQ_UNLOCK_BH(txq);                                     \
                sc->sc_stats.ast_tx_nobuf++;                            \
-               goto hardstart_fail;                                    \
++              goto hardstart_fail;                                    \
        }
-@@ -2552,6 +2584,7 @@
+ /*
+@@ -2508,6 +2541,7 @@
        if (M_FLAG_GET(skb, M_UAPSD)) {
                /* bypass FF handling */
                ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
@@ -169,7 +171,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                if (bf == NULL)
                        goto hardstart_fail;
                goto ff_bypass;
-@@ -2573,7 +2606,7 @@
+@@ -2529,7 +2563,7 @@
        /* NB: use this lock to protect an->an_ff_txbuf in athff_can_aggregate()
         *     call too.
         */
@@ -178,7 +180,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        if (athff_can_aggregate(sc, eh, an, skb, vap->iv_fragthreshold, &ff_flush)) {
  
                if (an->an_tx_ffbuf[skb->priority]) { /* i.e., frame on the staging queue */
-@@ -2583,7 +2616,7 @@
+@@ -2539,7 +2573,7 @@
                        TAILQ_REMOVE(&txq->axq_stageq, bf, bf_stagelist);
                        an->an_tx_ffbuf[skb->priority] = NULL;
  
@@ -187,7 +189,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                        /*
                         * chain skbs and add FF magic
-@@ -2610,6 +2643,7 @@
+@@ -2566,6 +2600,7 @@
                         *     to give the buffer back.
                         */
                        ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
@@ -195,7 +197,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                        if (bf == NULL) {
                                ATH_TXQ_UNLOCK(txq);
                                goto hardstart_fail;
-@@ -2624,7 +2658,7 @@
+@@ -2580,7 +2615,7 @@
  
                        TAILQ_INSERT_HEAD(&txq->axq_stageq, bf, bf_stagelist);
  
@@ -204,7 +206,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                        return 0;
                }
-@@ -2635,7 +2669,7 @@
+@@ -2591,7 +2626,7 @@
                        TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist);
                        an->an_tx_ffbuf[skb->priority] = NULL;
  
@@ -213,7 +215,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                        /* encap and xmit */
                        bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt);
-@@ -2665,9 +2699,9 @@
+@@ -2621,9 +2656,9 @@
                        }
                        bf_ff->bf_node = NULL;
  
@@ -225,7 +227,25 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                        goto ff_flushdone;
                }
                /*
-@@ -2691,6 +2725,7 @@
+@@ -2633,14 +2668,13 @@
+               else if (an->an_tx_ffbuf[skb->priority]) {
+                       DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF,
+                               "%s: Out-Of-Order fast-frame\n", __func__);
+-                      ATH_TXQ_UNLOCK(txq);
++                      ATH_TXQ_UNLOCK_BH(txq);
+               } else
+-                      ATH_TXQ_UNLOCK(txq);
++                      ATH_TXQ_UNLOCK_BH(txq);
+       ff_flushdone:
+               ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
+-              if (bf == NULL)
+-                      goto hardstart_fail;
++              ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF;
+       }
+ ff_bypass:
+@@ -2648,6 +2682,7 @@
  #else /* ATH_SUPERG_FF */
  
        ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
@@ -233,7 +253,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
  #endif /* ATH_SUPERG_FF */
  
-@@ -2712,7 +2747,7 @@
+@@ -2669,7 +2704,7 @@
                 *  Allocate 1 ath_buf for each frame given 1 was 
                 *  already alloc'd
                 */
@@ -242,7 +262,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                for (bfcnt = 1; bfcnt < framecnt; ++bfcnt) {
                        if ((tbf = STAILQ_FIRST(&sc->sc_txbuf)) != NULL) {
                                STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list);
-@@ -2733,11 +2768,11 @@
+@@ -2690,11 +2725,11 @@
                                        STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list);
                                }
                        }
@@ -256,7 +276,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                while ((bf = STAILQ_FIRST(&bf_head)) != NULL && skb != NULL) {
                        unsigned int nextfraglen = 0;
-@@ -2773,7 +2808,7 @@
+@@ -2730,7 +2765,7 @@
  
  hardstart_fail:
        if (!STAILQ_EMPTY(&bf_head)) {
@@ -265,7 +285,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                STAILQ_FOREACH_SAFE(tbf, &bf_head, bf_list, tempbf) {
                        tbf->bf_skb = NULL;
                        tbf->bf_node = NULL;
-@@ -2783,7 +2818,7 @@
+@@ -2740,7 +2775,7 @@
  
                        STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list);
                }
@@ -274,7 +294,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        }
  
        /* free sk_buffs */
-@@ -2826,7 +2861,7 @@
+@@ -2783,7 +2818,7 @@
        /*
         * Grab a TX buffer and associated resources.
         */
@@ -283,7 +303,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        bf = STAILQ_FIRST(&sc->sc_txbuf);
        if (bf != NULL)
                STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list);
-@@ -2837,7 +2872,7 @@
+@@ -2794,7 +2829,7 @@
                sc->sc_devstopped=1;
                ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL);
        }
@@ -292,7 +312,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        if (bf == NULL) {
                printk("ath_mgtstart: discard, no xmit buf\n");
                sc->sc_stats.ast_tx_nobufmgt++;
-@@ -2866,9 +2901,9 @@
+@@ -2823,9 +2858,9 @@
                bf->bf_skb = NULL;
                bf->bf_node = NULL;
  
@@ -304,7 +324,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        }
        dev_kfree_skb_any(skb);
        skb = NULL;
-@@ -3336,10 +3371,10 @@
+@@ -3293,10 +3328,10 @@
         *
         * XXX Using in_softirq is not right since we might
         * be called from other soft irq contexts than
@@ -317,7 +337,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        netif_stop_queue(dev);
  }
  
-@@ -3352,7 +3387,7 @@
+@@ -3309,7 +3344,7 @@
        DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__);
        netif_start_queue(dev);
        if (!in_softirq())              /* NB: see above */
@@ -326,7 +346,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  }
  
  /*
-@@ -4912,9 +4947,9 @@
+@@ -4875,9 +4910,9 @@
                bf->bf_node = NULL;
                bf->bf_desc->ds_link = 0;
                
@@ -338,7 +358,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                an->an_uapsd_overflowqdepth--;
        }
-@@ -5585,13 +5620,12 @@
+@@ -5553,13 +5588,12 @@
        sc->sc_rxotherant = 0;
  }
  
@@ -354,23 +374,23 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        struct ath_buf *bf;
        struct ath_softc *sc = dev->priv;
        struct ieee80211com *ic = &sc->sc_ic;
-@@ -5602,11 +5636,15 @@
+@@ -5571,12 +5605,15 @@
        unsigned int len;
        int type;
        u_int phyerr;
-+      int processed = 0, early_stop = 0;
-+      int rx_limit = dev->quota;
++      u_int processed = 0, early_stop = 0;
++      u_int rx_limit = dev->quota;
  
        /* Let the 802.11 layer know about the new noise floor */
+       sc->sc_channoise = ath_hal_get_channel_noise(ah, &(sc->sc_curchan));
        ic->ic_channoise = sc->sc_channoise;
        
        DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s\n", __func__);
-+
 +process_rx_again:
        do {
                bf = STAILQ_FIRST(&sc->sc_rxbuf);
                if (bf == NULL) {               /* XXX ??? can this happen */
-@@ -5630,6 +5668,13 @@
+@@ -5600,6 +5637,13 @@
                        /* NB: never process the self-linked entry at the end */
                        break;
                }
@@ -384,7 +404,15 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                skb = bf->bf_skb;
                if (skb == NULL) {              /* XXX ??? can this happen */
                        printk("%s: no skbuff (%s)\n", dev->name, __func__);
-@@ -5878,6 +5923,25 @@
+@@ -5638,6 +5682,7 @@
+                               sc->sc_stats.ast_rx_phyerr++;
+                               phyerr = rs->rs_phyerr & 0x1f;
+                               sc->sc_stats.ast_rx_phy[phyerr]++;
++                              goto rx_next;
+                       }
+                       if (rs->rs_status & HAL_RXERR_DECRYPT) {
+                               /*
+@@ -5841,9 +5886,29 @@
                STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
                ATH_RXBUF_UNLOCK_IRQ(sc);
        } while (ath_rxbuf_init(sc, bf) == 0);
@@ -410,15 +438,11 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        
        /* rx signal state monitoring */
        ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
-@@ -5885,6 +5949,7 @@
-               sc->sc_rtasksched = 1;
-               schedule_work(&sc->sc_radartask);
-       }
 +      return early_stop;
  #undef PA2DESC
  }
  
-@@ -6160,22 +6225,22 @@
+@@ -6119,22 +6184,22 @@
                                }
                        }
  
@@ -445,7 +469,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
  
                        bf->bf_skbaddr = bus_map_single(sc->sc_bdev,
                                skb->data, skb->len, BUS_DMA_TODEVICE);
-@@ -6641,9 +6706,9 @@
+@@ -6600,9 +6665,9 @@
                dev_kfree_skb(lastbuf->bf_skb);
                lastbuf->bf_skb = NULL;
                ieee80211_unref_node(&lastbuf->bf_node);
@@ -457,7 +481,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                
                /*
                 *  move oldest from overflow to delivery
-@@ -7462,9 +7527,6 @@
+@@ -7427,9 +7492,6 @@
                        if (sc->sc_reapcount > ATH_TXBUF_FREE_THRESHOLD) {
                                if (!sc->sc_dfswait)
                                        netif_start_queue(sc->sc_dev);
@@ -467,7 +491,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
                                sc->sc_reapcount = 0;
                                sc->sc_devstopped = 0;
                        } else
-@@ -7499,11 +7561,22 @@
+@@ -7464,11 +7526,22 @@
        struct net_device *dev = (struct net_device *)data;
        struct ath_softc *sc = dev->priv;
  
@@ -490,7 +514,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        netif_wake_queue(dev);
  
        if (sc->sc_softled)
-@@ -7520,6 +7593,7 @@
+@@ -7485,6 +7558,7 @@
        struct net_device *dev = (struct net_device *)data;
        struct ath_softc *sc = dev->priv;
  
@@ -498,7 +522,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        /*
         * Process each active queue.
         */
-@@ -7540,6 +7614,16 @@
+@@ -7505,6 +7579,16 @@
        if (sc->sc_uapsdq && txqactive(sc->sc_ah, sc->sc_uapsdq->axq_qnum))
                ath_tx_processq(sc, sc->sc_uapsdq);
  
@@ -515,7 +539,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        netif_wake_queue(dev);
  
        if (sc->sc_softled)
-@@ -7557,6 +7641,7 @@
+@@ -7522,6 +7606,7 @@
        unsigned int i;
  
        /* Process each active queue. */
@@ -523,7 +547,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
                if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i))
                        ath_tx_processq(sc, &sc->sc_txq[i]);
-@@ -7565,6 +7650,16 @@
+@@ -7530,6 +7615,16 @@
                ath_tx_processq(sc, sc->sc_xrtxq);
  #endif
  
@@ -540,7 +564,15 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        netif_wake_queue(dev);
  
        if (sc->sc_softled)
-@@ -9221,9 +9316,9 @@
+@@ -7628,6 +7723,7 @@
+ ath_draintxq(struct ath_softc *sc)
+ {
+       struct ath_hal *ah = sc->sc_ah;
++      int npend = 0;
+       unsigned int i;
+       /* XXX return value */
+@@ -9161,9 +9257,9 @@
        dev->mtu = mtu;
        if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
                /* NB: the rx buffers may need to be reallocated */
@@ -552,10 +584,10 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcoun
        }
        ATH_UNLOCK(sc);
  
-diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refcount-r2313-20070505.dev/ath/if_athvar.h
---- madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h     2007-05-13 18:17:56.363000560 +0200
-+++ madwifi-ng-refcount-r2313-20070505.dev/ath/if_athvar.h     2007-05-13 18:17:56.595965144 +0200
-@@ -47,6 +47,10 @@
+diff -urN madwifi-ng-r2377-20070526.old/ath/if_athvar.h madwifi-ng-r2377-20070526.dev/ath/if_athvar.h
+--- madwifi-ng-r2377-20070526.old/ath/if_athvar.h      2007-05-26 18:51:09.020716184 +0200
++++ madwifi-ng-r2377-20070526.dev/ath/if_athvar.h      2007-05-26 18:51:09.331668912 +0200
+@@ -48,6 +48,10 @@
  #include "if_athioctl.h"
  #include "net80211/ieee80211.h"               /* XXX for WME_NUM_AC */
  
@@ -566,7 +598,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refc
  /*
   * Deduce if tasklets are available.  If not then
   * fall back to using the immediate work queue.
-@@ -477,8 +481,12 @@
+@@ -478,8 +482,12 @@
  #define       ATH_TXQ_LOCK_DESTROY(_tq)       
  #define       ATH_TXQ_LOCK(_tq)               spin_lock(&(_tq)->axq_lock)
  #define       ATH_TXQ_UNLOCK(_tq)             spin_unlock(&(_tq)->axq_lock)
@@ -581,7 +613,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refc
  #define ATH_TXQ_LOCK_IRQ(_tq)         do {    \
        unsigned long __axq_lockflags;          \
        spin_lock_irqsave(&(_tq)->axq_lock, __axq_lockflags);
-@@ -627,7 +635,6 @@
+@@ -623,7 +631,6 @@
        struct ath_buf *sc_rxbufcur;            /* current rx buffer */
        u_int32_t *sc_rxlink;                   /* link ptr in last RX desc */
        spinlock_t sc_rxbuflock; 
@@ -589,7 +621,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refc
        struct ATH_TQ_STRUCT sc_rxorntq;        /* rxorn intr tasklet */
        u_int8_t sc_defant;                     /* current default antenna */
        u_int8_t sc_rxotherant;                 /* rx's on non-default antenna*/
-@@ -640,6 +647,7 @@
+@@ -636,6 +643,7 @@
        u_int sc_txintrperiod;                  /* tx interrupt batching */
        struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
        struct ath_txq *sc_ac2q[WME_NUM_AC];    /* WME AC -> h/w qnum */ 
@@ -597,7 +629,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refc
        struct ATH_TQ_STRUCT sc_txtq;           /* tx intr tasklet */
        u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];  
        struct ath_descdma sc_bdma;             /* beacon descriptors */
-@@ -706,8 +714,12 @@
+@@ -702,8 +710,12 @@
  #define       ATH_TXBUF_LOCK_DESTROY(_sc)
  #define       ATH_TXBUF_LOCK(_sc)             spin_lock(&(_sc)->sc_txbuflock)
  #define       ATH_TXBUF_UNLOCK(_sc)           spin_unlock(&(_sc)->sc_txbuflock)
@@ -612,7 +644,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refc
  #define       ATH_TXBUF_LOCK_IRQ(_sc)         do {    \
        unsigned long __txbuflockflags;         \
        spin_lock_irqsave(&(_sc)->sc_txbuflock, __txbuflockflags);
-@@ -725,8 +737,12 @@
+@@ -721,8 +733,12 @@
  #define       ATH_RXBUF_LOCK_DESTROY(_sc)
  #define       ATH_RXBUF_LOCK(_sc)             spin_lock(&(_sc)->sc_rxbuflock)
  #define       ATH_RXBUF_UNLOCK(_sc)           spin_unlock(&(_sc)->sc_rxbuflock)
@@ -627,7 +659,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refc
  #define       ATH_RXBUF_LOCK_IRQ(_sc)         do {    \
        unsigned long __rxbuflockflags;         \
        spin_lock_irqsave(&(_sc)->sc_rxbuflock, __rxbuflockflags);
-@@ -736,6 +752,8 @@
+@@ -732,6 +748,8 @@
  #define       ATH_RXBUF_UNLOCK_IRQ_EARLY(_sc)         \
        spin_unlock_irqrestore(&(_sc)->sc_rxbuflock, __rxbuflockflags);
  
@@ -636,9 +668,9 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refc
  
  /* Protects the device from concurrent accesses */
  #define       ATH_LOCK_INIT(_sc)              init_MUTEX(&(_sc)->sc_lock)
-diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_beacon.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_beacon.c
---- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_beacon.c 2007-01-30 05:01:29.000000000 +0100
-+++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_beacon.c 2007-05-13 18:17:56.596964992 +0200
+diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_beacon.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_beacon.c
+--- madwifi-ng-r2377-20070526.old/net80211/ieee80211_beacon.c  2007-01-30 05:01:29.000000000 +0100
++++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_beacon.c  2007-05-26 18:51:09.332668760 +0200
 @@ -286,7 +286,7 @@
        int len_changed = 0;
        u_int16_t capinfo;
@@ -657,10 +689,10 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_beacon.c mad
  
        return len_changed;
  }
-diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_input.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_input.c
---- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_input.c  2007-05-13 18:17:56.106039624 +0200
-+++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_input.c  2007-05-13 18:17:56.597964840 +0200
-@@ -1148,8 +1148,9 @@
+diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_input.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_input.c
+--- madwifi-ng-r2377-20070526.old/net80211/ieee80211_input.c   2007-05-26 18:51:09.107702960 +0200
++++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_input.c   2007-05-26 18:51:09.333668608 +0200
+@@ -1169,8 +1169,9 @@
                if (ni->ni_vlan != 0 && vap->iv_vlgrp != NULL) {
                        /* attach vlan tag */
                        vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan);
@@ -672,7 +704,7 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_input.c madw
                dev->last_rx = jiffies;
        }
  }
-@@ -3623,9 +3624,9 @@
+@@ -3668,9 +3669,9 @@
        }
  
        /* Okay, take the first queued packet and put it out... */
@@ -684,9 +716,9 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_input.c madw
        if (skb == NULL) {
                IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_POWER, wh->i_addr2,
                        "%s", "recv ps-poll, but queue empty");
-diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_linux.h madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_linux.h
---- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_linux.h  2007-05-04 02:10:06.000000000 +0200
-+++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_linux.h  2007-05-13 18:17:56.598964688 +0200
+diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_linux.h madwifi-ng-r2377-20070526.dev/net80211/ieee80211_linux.h
+--- madwifi-ng-r2377-20070526.old/net80211/ieee80211_linux.h   2007-05-24 19:31:37.000000000 +0200
++++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_linux.h   2007-05-26 18:51:09.334668456 +0200
 @@ -31,6 +31,10 @@
  
  #include <linux/wireless.h>
@@ -787,9 +819,9 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_linux.h madw
  
  #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)
  #define       ACL_LOCK_ASSERT(_as) \
-diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_node.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_node.c
---- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_node.c   2007-05-13 18:17:56.273014240 +0200
-+++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_node.c   2007-05-13 18:17:56.599964536 +0200
+diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_node.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_node.c
+--- madwifi-ng-r2377-20070526.old/net80211/ieee80211_node.c    2007-05-26 18:51:08.748757528 +0200
++++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_node.c    2007-05-26 18:51:09.335668304 +0200
 @@ -1567,7 +1567,7 @@
        struct ieee80211_node *ni;
        u_int gen;
@@ -808,9 +840,9 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_node.c madwi
  }
  EXPORT_SYMBOL(ieee80211_iterate_dev_nodes);
  
-diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_power.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_power.c
---- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_power.c  2007-04-25 22:29:55.000000000 +0200
-+++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_power.c  2007-05-13 18:17:56.599964536 +0200
+diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_power.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_power.c
+--- madwifi-ng-r2377-20070526.old/net80211/ieee80211_power.c   2007-05-24 19:31:37.000000000 +0200
++++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_power.c   2007-05-26 18:51:09.336668152 +0200
 @@ -147,7 +147,7 @@
  #endif
                struct sk_buff *skb;
@@ -847,19 +879,19 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_power.c madw
  }
  
  /*
-@@ -297,9 +297,9 @@
-               struct sk_buff *skb;
-               int qlen;
--              IEEE80211_NODE_SAVEQ_LOCK(ni);
-+              IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
-               IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen);
--              IEEE80211_NODE_SAVEQ_UNLOCK(ni);
-+              IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
-               if (skb == NULL)
-                       break;
-               /* 
-@@ -363,9 +363,9 @@
+@@ -295,9 +295,9 @@
+                       struct sk_buff *skb;
+                       int qlen;
+-                      IEEE80211_NODE_SAVEQ_LOCK(ni);
++                      IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
+                       IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen);
+-                      IEEE80211_NODE_SAVEQ_UNLOCK(ni);
++                      IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
+                       if (skb == NULL)
+                               break;
+                       /* 
+@@ -362,9 +362,9 @@
                        for (;;) {
                                struct sk_buff *skb;
  
@@ -871,9 +903,9 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_power.c madw
                                if (skb == NULL)
                                        break;
                                ieee80211_parent_queue_xmit(skb);
-diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_proto.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_proto.c
---- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_proto.c  2007-05-13 18:17:56.578967728 +0200
-+++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_proto.c  2007-05-13 18:17:56.600964384 +0200
+diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_proto.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_proto.c
+--- madwifi-ng-r2377-20070526.old/net80211/ieee80211_proto.c   2007-05-26 18:51:09.321670432 +0200
++++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_proto.c   2007-05-26 18:51:09.337668000 +0200
 @@ -635,9 +635,9 @@
  {
        struct ieee80211com *ic = vap->iv_ic;
@@ -898,9 +930,9 @@ diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_proto.c madw
        }
  }
  
-diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_scan_sta.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_scan_sta.c
---- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_scan_sta.c       2007-02-01 21:49:37.000000000 +0100
-+++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_scan_sta.c       2007-05-13 18:17:56.601964232 +0200
+diff -urN madwifi-ng-r2377-20070526.old/net80211/ieee80211_scan_sta.c madwifi-ng-r2377-20070526.dev/net80211/ieee80211_scan_sta.c
+--- madwifi-ng-r2377-20070526.old/net80211/ieee80211_scan_sta.c        2007-05-21 17:53:39.000000000 +0200
++++ madwifi-ng-r2377-20070526.dev/net80211/ieee80211_scan_sta.c        2007-05-26 18:51:09.338667848 +0200
 @@ -163,9 +163,11 @@
  {
        struct sta_table *st = ss->ss_priv;