rpcd: iwinfo plugin fixes
[openwrt.git] / package / kernel / mac80211 / patches / 301-ath9k-limit-retries-for-powersave-response-frames.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 2 Jul 2015 15:20:56 +0200
3 Subject: [PATCH] ath9k: limit retries for powersave response frames
4
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
9 used.
10
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 ---
13
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_
17  }
18  
19  static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
20 -                         struct ath_buf *bf)
21 +                         struct ath_buf *bf, bool ps)
22  {
23 +       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(bf->bf_mpdu);
24 +
25 +       if (ps) {
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;
29 +       }
30 +
31         ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
32                                ARRAY_SIZE(bf->rates));
33 +       if (!ps)
34 +               return;
35 +
36 +       if (bf->rates[0].count > 2)
37 +               bf->rates[0].count = 2;
38 +
39 +       bf->rates[1].idx = -1;
40  }
41  
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)
45                         break;
46  
47 -               ath_set_rates(tid->an->vif, tid->an->sta, bf);
48 +               ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
49         } while (1);
50  }
51  
52 @@ -1450,7 +1465,7 @@ static bool ath_tx_sched_aggr(struct ath
53                 return false;
54         }
55  
56 -       ath_set_rates(tid->an->vif, tid->an->sta, bf);
57 +       ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
58         if (aggr)
59                 last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
60                                         tid_q, &aggr_len);
61 @@ -1647,7 +1662,7 @@ void ath9k_release_buffered_frames(struc
62  
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);
67                         if (bf_isampdu(bf)) {
68                                 ath_tx_addto_baw(sc, tid, bf);
69                                 bf->bf_state.bf_type &= ~BUF_AGGR;
70 @@ -2293,7 +2308,7 @@ int ath_tx_start(struct ieee80211_hw *hw
71         struct ath_txq *txq = txctl->txq;
72         struct ath_atx_tid *tid = NULL;
73         struct ath_buf *bf;
74 -       bool queue, skip_uapsd = false, ps_resp;
75 +       bool queue, ps_resp;
76         int q, ret;
77  
78         if (vif)
79 @@ -2346,13 +2361,13 @@ int ath_tx_start(struct ieee80211_hw *hw
80                 if (!txctl->an)
81                         txctl->an = &avp->mcast_node;
82                 queue = true;
83 -               skip_uapsd = true;
84 +               ps_resp = false;
85         }
86  
87         if (txctl->an && queue)
88                 tid = ath_get_skb_tid(sc, txctl->an, skb);
89  
90 -       if (!skip_uapsd && ps_resp) {
91 +       if (ps_resp) {
92                 ath_txq_unlock(sc, txq);
93                 txq = sc->tx.uapsdq;
94                 ath_txq_lock(sc, txq);
95 @@ -2390,7 +2405,7 @@ int ath_tx_start(struct ieee80211_hw *hw
96         if (txctl->paprd)
97                 bf->bf_state.bfs_paprd_timestamp = jiffies;
98  
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);
102  
103  out:
104 @@ -2429,7 +2444,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
105                         break;
106  
107                 bf->bf_lastbf = bf;
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;
112                 if (bf_tail)
113 @@ -2932,7 +2947,7 @@ int ath9k_tx99_send(struct ath_softc *sc
114                 return -EINVAL;
115         }
116  
117 -       ath_set_rates(sc->tx99_vif, NULL, bf);
118 +       ath_set_rates(sc->tx99_vif, NULL, bf, false);
119  
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);