ath9k: fix tx queue pending frame counter when dropping packets
[openwrt/staging/mkresin.git] / package / kernel / mac80211 / patches / 557-ath9k_fix_tx_queue_accounting.patch
1 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3 @@ -146,6 +146,28 @@ static void ath_set_rates(struct ieee802
4 ARRAY_SIZE(bf->rates));
5 }
6
7 +static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
8 + struct sk_buff *skb)
9 +{
10 + int q;
11 +
12 + q = skb_get_queue_mapping(skb);
13 + if (txq == sc->tx.uapsdq)
14 + txq = sc->tx.txq_map[q];
15 +
16 + if (txq != sc->tx.txq_map[q])
17 + return;
18 +
19 + if (WARN_ON(--txq->pending_frames < 0))
20 + txq->pending_frames = 0;
21 +
22 + if (txq->stopped &&
23 + txq->pending_frames < sc->tx.txq_max_pending[q]) {
24 + ieee80211_wake_queue(sc->hw, q);
25 + txq->stopped = false;
26 + }
27 +}
28 +
29 static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
30 {
31 struct ath_txq *txq = tid->ac->txq;
32 @@ -167,6 +189,7 @@ static void ath_tx_flush_tid(struct ath_
33 if (!bf) {
34 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
35 if (!bf) {
36 + ath_txq_skb_done(sc, txq, skb);
37 ieee80211_free_txskb(sc->hw, skb);
38 continue;
39 }
40 @@ -811,6 +834,7 @@ ath_tx_get_tid_subframe(struct ath_softc
41
42 if (!bf) {
43 __skb_unlink(skb, &tid->buf_q);
44 + ath_txq_skb_done(sc, txq, skb);
45 ieee80211_free_txskb(sc->hw, skb);
46 continue;
47 }
48 @@ -1824,6 +1848,7 @@ static void ath_tx_send_ampdu(struct ath
49
50 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
51 if (!bf) {
52 + ath_txq_skb_done(sc, txq, skb);
53 ieee80211_free_txskb(sc->hw, skb);
54 return;
55 }
56 @@ -2090,6 +2115,7 @@ int ath_tx_start(struct ieee80211_hw *hw
57
58 bf = ath_tx_setup_buffer(sc, txq, tid, skb);
59 if (!bf) {
60 + ath_txq_skb_done(sc, txq, skb);
61 if (txctl->paprd)
62 dev_kfree_skb_any(skb);
63 else
64 @@ -2189,7 +2215,7 @@ static void ath_tx_complete(struct ath_s
65 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
66 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
67 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
68 - int q, padpos, padsize;
69 + int padpos, padsize;
70 unsigned long flags;
71
72 ath_dbg(common, XMIT, "TX complete: skb: %p\n", skb);
73 @@ -2225,21 +2251,7 @@ static void ath_tx_complete(struct ath_s
74 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
75
76 __skb_queue_tail(&txq->complete_q, skb);
77 -
78 - q = skb_get_queue_mapping(skb);
79 - if (txq == sc->tx.uapsdq)
80 - txq = sc->tx.txq_map[q];
81 -
82 - if (txq == sc->tx.txq_map[q]) {
83 - if (WARN_ON(--txq->pending_frames < 0))
84 - txq->pending_frames = 0;
85 -
86 - if (txq->stopped &&
87 - txq->pending_frames < sc->tx.txq_max_pending[q]) {
88 - ieee80211_wake_queue(sc->hw, q);
89 - txq->stopped = false;
90 - }
91 - }
92 + ath_txq_skb_done(sc, txq, skb);
93 }
94
95 static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,