update .gitignore
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 302-ath9k-limit-retries-for-powersave-response-frames.patch
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
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@openwrt.org>
12 ---
13
14 --- a/drivers/net/wireless/ath/ath9k/xmit.c
15 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
16 @@ -177,10 +177,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 @@ -1462,7 +1477,7 @@ ath_tx_form_burst(struct ath_softc *sc,
44                         break;
45                 }
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 @@ -1493,7 +1508,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                 aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf);
60         else
61 @@ -1651,7 +1666,7 @@ void ath9k_release_buffered_frames(struc
62                                 break;
63  
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 @@ -2343,7 +2358,7 @@ int ath_tx_start(struct ieee80211_hw *hw
71         if (txctl->paprd)
72                 bf->bf_state.bfs_paprd_timestamp = jiffies;
73  
74 -       ath_set_rates(vif, sta, bf);
75 +       ath_set_rates(vif, sta, bf, ps_resp);
76         ath_tx_send_normal(sc, txq, tid, skb);
77  
78  out:
79 @@ -2382,7 +2397,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw
80                         break;
81  
82                 bf->bf_lastbf = bf;
83 -               ath_set_rates(vif, NULL, bf);
84 +               ath_set_rates(vif, NULL, bf, false);
85                 ath_buf_set_rate(sc, bf, &info, fi->framelen, false);
86                 duration += info.rates[0].PktDuration;
87                 if (bf_tail)
88 @@ -2898,7 +2913,7 @@ int ath9k_tx99_send(struct ath_softc *sc
89                 return -EINVAL;
90         }
91  
92 -       ath_set_rates(sc->tx99_vif, NULL, bf);
93 +       ath_set_rates(sc->tx99_vif, NULL, bf, false);
94  
95         ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr);
96         ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum);