1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Thu, 2 Jul 2015 15:20:56 +0200
3 Subject: [PATCH] ath9k: limit retries for powersave response frames
5 In some cases, the channel might be busy enough that an ath9k AP's
6 response to PS-Poll frames might be too slow and the station has already
7 gone to sleep. To avoid wasting too much airtime on this, limit the
8 number of retries on such frames and ensure that no sample rate gets
11 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
14 --- a/drivers/net/wireless/ath/ath9k/xmit.c
15 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
16 @@ -136,10 +136,25 @@ static void ath_send_bar(struct ath_atx_
19 static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
21 + struct ath_buf *bf, bool ps)
23 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(bf->bf_mpdu);
26 + /* Clear the first rate to avoid using a sample rate for PS frames */
27 + info->control.rates[0].idx = -1;
28 + info->control.rates[0].count = 0;
31 ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
32 ARRAY_SIZE(bf->rates));
36 + if (bf->rates[0].count > 2)
37 + bf->rates[0].count = 2;
39 + bf->rates[1].idx = -1;
42 static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
43 @@ -1419,7 +1434,7 @@ ath_tx_form_burst(struct ath_softc *sc,
44 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
47 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
48 + ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
52 @@ -1450,7 +1465,7 @@ static bool ath_tx_sched_aggr(struct ath
56 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
57 + ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
59 last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
61 @@ -1632,7 +1647,7 @@ void ath9k_release_buffered_frames(struc
63 __skb_unlink(bf->bf_mpdu, tid_q);
64 list_add_tail(&bf->list, &bf_q);
65 - ath_set_rates(tid->an->vif, tid->an->sta, bf);
66 + ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
68 ath_tx_addto_baw(sc, tid, bf);
69 bf->bf_state.bf_type &= ~BUF_AGGR;
70 @@ -2278,7 +2293,7 @@ int ath_tx_start(struct ieee80211_hw *hw
71 struct ath_txq *txq = txctl->txq;
72 struct ath_atx_tid *tid = NULL;
74 - bool queue, skip_uapsd = false, ps_resp;
75 + bool queue, ps_resp;
79 @@ -2325,13 +2340,13 @@ int ath_tx_start(struct ieee80211_hw *hw
81 txctl->an = &avp->mcast_node;
87 if (txctl->an && queue)
88 tid = ath_get_skb_tid(sc, txctl->an, skb);
90 - if (!skip_uapsd && ps_resp) {
92 ath_txq_unlock(sc, txq);
94 ath_txq_lock(sc, txq);
95 @@ -2369,7 +2384,7 @@ int ath_tx_start(struct ieee80211_hw *hw
97 bf->bf_state.bfs_paprd_timestamp = jiffies;
99 - ath_set_rates(vif, sta, bf);
100 + ath_set_rates(vif, sta, bf, ps_resp);
101 ath_tx_send_normal(sc, txq, tid, skb);
104 @@ -2408,7 +2423,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
108 - ath_set_rates(vif, NULL, bf);
109 + ath_set_rates(vif, NULL, bf, false);
110 ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
111 duration += info.rates[0].PktDuration;
113 @@ -2911,7 +2926,7 @@ int ath9k_tx99_send(struct ath_softc *sc
117 - ath_set_rates(sc->tx99_vif, NULL, bf);
118 + ath_set_rates(sc->tx99_vif, NULL, bf, false);
120 ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr);
121 ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum);