mac80211: add a few tx related fixes
authorFelix Fietkau <nbd@openwrt.org>
Thu, 20 Jan 2011 23:35:26 +0000 (23:35 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 20 Jan 2011 23:35:26 +0000 (23:35 +0000)
SVN-Revision: 25054

package/mac80211/patches/310-ath9k_pending_work.patch [new file with mode: 0644]
package/mac80211/patches/530-ath9k_cleanup_queue_wake.patch [new file with mode: 0644]
package/mac80211/patches/531-ath9k_suppress_bogus_error_message.patch [new file with mode: 0644]

diff --git a/package/mac80211/patches/310-ath9k_pending_work.patch b/package/mac80211/patches/310-ath9k_pending_work.patch
new file mode 100644 (file)
index 0000000..0a3372c
--- /dev/null
@@ -0,0 +1,90 @@
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -1221,49 +1221,59 @@ void ath_tx_cleanupq(struct ath_softc *s
+       sc->tx.txqsetup &= ~(1<<txq->axq_qnum);
+ }
++/* For each axq_acq entry, for each tid, try to schedule packets
++ * for transmit until ampdu_depth has reached min Q depth.
++ */
+ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
+ {
+-      struct ath_atx_ac *ac;
+-      struct ath_atx_tid *tid, *last;
++      struct ath_atx_ac *ac, *ac_tmp, *last_ac;
++      struct ath_atx_tid *tid, *last_tid;
+       if (list_empty(&txq->axq_acq) ||
+           txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
+               return;
+       ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
+-      last = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
+-      list_del(&ac->list);
+-      ac->sched = false;
++      last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list);
+-      do {
+-              if (list_empty(&ac->tid_q))
+-                      return;
+-
+-              tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, list);
+-              list_del(&tid->list);
+-              tid->sched = false;
++      list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) {
++              last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
++              list_del(&ac->list);
++              ac->sched = false;
++
++              while (!list_empty(&ac->tid_q)) {
++                      tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
++                                             list);
++                      list_del(&tid->list);
++                      tid->sched = false;
+-              if (tid->paused)
+-                      continue;
++                      if (tid->paused)
++                              continue;
+-              ath_tx_sched_aggr(sc, txq, tid);
++                      ath_tx_sched_aggr(sc, txq, tid);
+-              /*
+-               * add tid to round-robin queue if more frames
+-               * are pending for the tid
+-               */
+-              if (!list_empty(&tid->buf_q))
+-                      ath_tx_queue_tid(txq, tid);
++                      /*
++                       * add tid to round-robin queue if more frames
++                       * are pending for the tid
++                       */
++                      if (!list_empty(&tid->buf_q))
++                              ath_tx_queue_tid(txq, tid);
+-              if (tid == last || txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
+-                      break;
+-      } while (!list_empty(&ac->tid_q));
++                      if (tid == last_tid ||
++                          txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
++                              break;
++              }
+-      if (!list_empty(&ac->tid_q)) {
+-              if (!ac->sched) {
+-                      ac->sched = true;
+-                      list_add_tail(&ac->list, &txq->axq_acq);
++              if (!list_empty(&ac->tid_q)) {
++                      if (!ac->sched) {
++                              ac->sched = true;
++                              list_add_tail(&ac->list, &txq->axq_acq);
++                      }
+               }
++
++              if (ac == last_ac ||
++                  txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
++                      return;
+       }
+ }
diff --git a/package/mac80211/patches/530-ath9k_cleanup_queue_wake.patch b/package/mac80211/patches/530-ath9k_cleanup_queue_wake.patch
new file mode 100644 (file)
index 0000000..0d9511f
--- /dev/null
@@ -0,0 +1,118 @@
+--- a/drivers/net/wireless/ath/ath9k/xmit.c
++++ b/drivers/net/wireless/ath/ath9k/xmit.c
+@@ -1208,8 +1208,17 @@ bool ath_drain_all_txq(struct ath_softc 
+               ath_err(common, "Failed to stop TX DMA!\n");
+       for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
+-              if (ATH_TXQ_SETUP(sc, i))
+-                      ath_draintxq(sc, &sc->tx.txq[i], retry_tx);
++              if (!ATH_TXQ_SETUP(sc, i))
++                      continue;
++
++              /*
++               * The caller will resume queues with ieee80211_wake_queues.
++               * Mark the queue as not stopped to prevent ath_tx_complete
++               * from waking the queue too early.
++               */
++              txq = &sc->tx.txq[i];
++              txq->stopped = false;
++              ath_draintxq(sc, txq, retry_tx);
+       }
+       return !npend;
+@@ -1873,6 +1882,11 @@ static void ath_tx_complete(struct ath_s
+                       spin_lock_bh(&txq->axq_lock);
+                       if (WARN_ON(--txq->pending_frames < 0))
+                               txq->pending_frames = 0;
++
++                      if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
++                              if (ath_mac80211_start_queue(sc, q))
++                                      txq->stopped = 0;
++                      }
+                       spin_unlock_bh(&txq->axq_lock);
+               }
+@@ -1982,19 +1996,6 @@ static void ath_tx_rc_status(struct ath_
+       tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1;
+ }
+-static void ath_wake_mac80211_queue(struct ath_softc *sc, int qnum)
+-{
+-      struct ath_txq *txq;
+-
+-      txq = sc->tx.txq_map[qnum];
+-      spin_lock_bh(&txq->axq_lock);
+-      if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
+-              if (ath_mac80211_start_queue(sc, qnum))
+-                      txq->stopped = 0;
+-      }
+-      spin_unlock_bh(&txq->axq_lock);
+-}
+-
+ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
+ {
+       struct ath_hw *ah = sc->sc_ah;
+@@ -2005,7 +2006,6 @@ static void ath_tx_processq(struct ath_s
+       struct ath_tx_status ts;
+       int txok;
+       int status;
+-      int qnum;
+       ath_dbg(common, ATH_DBG_QUEUE, "tx queue %d (%x), link %p\n",
+               txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
+@@ -2084,17 +2084,12 @@ static void ath_tx_processq(struct ath_s
+                       ath_tx_rc_status(bf, &ts, 1, txok ? 0 : 1, txok, true);
+               }
+-              qnum = skb_get_queue_mapping(bf->bf_mpdu);
+-
+               if (bf_isampdu(bf))
+                       ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, txok,
+                                            true);
+               else
+                       ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, txok, 0);
+-              if (txq == sc->tx.txq_map[qnum])
+-                      ath_wake_mac80211_queue(sc, qnum);
+-
+               spin_lock_bh(&txq->axq_lock);
+               if (sc->sc_flags & SC_OP_TXAGGR)
+                       ath_txq_schedule(sc, txq);
+@@ -2163,7 +2158,6 @@ void ath_tx_edma_tasklet(struct ath_soft
+       struct list_head bf_head;
+       int status;
+       int txok;
+-      int qnum;
+       for (;;) {
+               status = ath9k_hw_txprocdesc(ah, NULL, (void *)&txs);
+@@ -2209,8 +2203,6 @@ void ath_tx_edma_tasklet(struct ath_soft
+                       ath_tx_rc_status(bf, &txs, 1, txok ? 0 : 1, txok, true);
+               }
+-              qnum = skb_get_queue_mapping(bf->bf_mpdu);
+-
+               if (bf_isampdu(bf))
+                       ath_tx_complete_aggr(sc, txq, bf, &bf_head, &txs,
+                                            txok, true);
+@@ -2218,9 +2210,6 @@ void ath_tx_edma_tasklet(struct ath_soft
+                       ath_tx_complete_buf(sc, bf, txq, &bf_head,
+                                           &txs, txok, 0);
+-              if (txq == sc->tx.txq_map[qnum])
+-                      ath_wake_mac80211_queue(sc, qnum);
+-
+               spin_lock_bh(&txq->axq_lock);
+               if (!list_empty(&txq->txq_fifo_pending)) {
+                       INIT_LIST_HEAD(&bf_head);
+--- a/drivers/net/wireless/ath/ath9k/main.c
++++ b/drivers/net/wireless/ath/ath9k/main.c
+@@ -295,6 +295,8 @@ int ath_set_channel(struct ath_softc *sc
+       }
+  ps_restore:
++      ieee80211_wake_queues(hw);
++
+       spin_unlock_bh(&sc->sc_pcu_lock);
+       ath9k_ps_restore(sc);
diff --git a/package/mac80211/patches/531-ath9k_suppress_bogus_error_message.patch b/package/mac80211/patches/531-ath9k_suppress_bogus_error_message.patch
new file mode 100644 (file)
index 0000000..6200602
--- /dev/null
@@ -0,0 +1,14 @@
+--- a/drivers/net/wireless/ath/ath9k/beacon.c
++++ b/drivers/net/wireless/ath/ath9k/beacon.c
+@@ -279,10 +279,8 @@ int ath_beacon_alloc(struct ath_wiphy *a
+       /* NB: the beacon data buffer must be 32-bit aligned. */
+       skb = ieee80211_beacon_get(sc->hw, vif);
+-      if (skb == NULL) {
+-              ath_err(common, "ieee80211_beacon_get failed\n");
++      if (skb == NULL)
+               return -ENOMEM;
+-      }
+       tstamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
+       sc->beacon.bc_tstamp = le64_to_cpu(tstamp);