1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -237,6 +237,7 @@ struct ath_atx_tid {
6 unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
11 @@ -282,6 +283,9 @@ struct ath_tx_control {
21 --- a/drivers/net/wireless/ath/ath9k/debug.c
22 +++ b/drivers/net/wireless/ath/ath9k/debug.c
23 @@ -1679,6 +1679,10 @@ int ath9k_init_debug(struct ath_hw *ah)
25 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
27 + debugfs_create_u32("qlen_single", S_IRUSR | S_IWUSR,
28 + sc->debug.debugfs_phy, &sc->tx.qlen_single);
29 + debugfs_create_u32("qlen_aggr", S_IRUSR | S_IWUSR,
30 + sc->debug.debugfs_phy, &sc->tx.qlen_aggr);
31 debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
33 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
34 --- a/drivers/net/wireless/ath/ath9k/xmit.c
35 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
36 @@ -350,6 +350,14 @@ static void ath_tx_count_frames(struct a
40 +static struct ath_atx_tid *ath_get_tid(struct ath_node *an, struct sk_buff *skb)
42 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
45 + tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
46 + return ATH_AN_2_TID(an, tidno);
49 static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
50 struct ath_buf *bf, struct list_head *bf_q,
51 @@ -438,6 +446,8 @@ static void ath_tx_complete_aggr(struct
52 __skb_queue_head_init(&bf_pending);
54 ath_tx_count_frames(sc, bf, ts, txok, &nframes, &nbad);
55 + tid->buf_pending -= nframes;
58 u16 seqno = bf->bf_state.seqno;
60 @@ -821,6 +831,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_
61 ath_tx_addto_baw(sc, tid, seqno);
62 bf->bf_state.ndelim = ndelim;
65 __skb_unlink(skb, &tid->buf_q);
66 list_add_tail(&bf->list, bf_q);
68 @@ -1680,6 +1691,8 @@ static void ath_tx_send_ampdu(struct ath
69 /* Add sub-frame to BAW */
70 ath_tx_addto_baw(sc, tid, bf->bf_state.seqno);
74 /* Queue to h/w without aggregation */
75 TX_STAT_INC(txctl->txq->axq_qnum, a_queued_hw);
77 @@ -1808,23 +1821,13 @@ error:
80 static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb,
81 - struct ath_tx_control *txctl)
82 + struct ath_tx_control *txctl,
83 + struct ath_atx_tid *tid)
85 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
86 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
87 - struct ath_atx_tid *tid = NULL;
91 spin_lock_bh(&txctl->txq->axq_lock);
92 - if ((sc->sc_flags & SC_OP_TXAGGR) && txctl->an &&
93 - ieee80211_is_data_qos(hdr->frame_control)) {
94 - tidno = ieee80211_get_qos_ctl(hdr)[0] &
95 - IEEE80211_QOS_CTL_TID_MASK;
96 - tid = ATH_AN_2_TID(txctl->an, tidno);
98 - WARN_ON(tid->ac->txq != txctl->txq);
101 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
103 @@ -1859,6 +1862,7 @@ int ath_tx_start(struct ieee80211_hw *hw
104 struct ieee80211_vif *vif = info->control.vif;
105 struct ath_softc *sc = hw->priv;
106 struct ath_txq *txq = txctl->txq;
107 + struct ath_atx_tid *tid = NULL;
109 int frmlen = skb->len + FCS_LEN;
111 @@ -1901,6 +1905,24 @@ int ath_tx_start(struct ieee80211_hw *hw
113 setup_frame_info(hw, skb, frmlen);
115 + if ((sc->sc_flags & SC_OP_TXAGGR) && txctl->an &&
116 + ieee80211_is_data_qos(hdr->frame_control)) {
117 + tid = ath_get_tid(txctl->an, skb);
119 + WARN_ON(tid->ac->txq != txq);
122 + if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
123 + if (sc->tx.qlen_aggr > 0 && skb_queue_len(&tid->buf_q) +
124 + tid->buf_pending >= sc->tx.qlen_aggr)
127 + if (sc->tx.qlen_single > 0 &&
128 + txq->axq_depth - txq->axq_ampdu_depth >=
129 + sc->tx.qlen_single)
134 * At this point, the vif, hw_key and sta pointers in the tx control
135 * info are no longer valid (overwritten by the ath_frame_info data.
136 @@ -1915,7 +1937,7 @@ int ath_tx_start(struct ieee80211_hw *hw
138 spin_unlock_bh(&txq->axq_lock);
140 - ath_tx_start_dma(sc, skb, txctl);
141 + ath_tx_start_dma(sc, skb, txctl, tid);