ath9k: backport dynack improvements
[oweals/openwrt.git] / package / kernel / mac80211 / patches / 559-ath9k-dynack-set-max-timeout-according-to-channel-wi.patch
1 From 3f737abb7d53cc80d619a3b4a30b6fa63cdc8df7 Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Tue, 20 Aug 2019 18:20:21 +0200
4 Subject: [PATCH 3/4] ath9k: dynack: set max timeout according to channel width
5
6 Compute maximum configurable ackimeout/ctstimeout according to channel
7 width (clockrate)
8
9 Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
10 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
11 ---
12  drivers/net/wireless/ath/ath9k/dynack.c | 38 +++++++++++++++++++------
13  1 file changed, 30 insertions(+), 8 deletions(-)
14
15 diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
16 index 398ea872751f..fe9181533de3 100644
17 --- a/drivers/net/wireless/ath/ath9k/dynack.c
18 +++ b/drivers/net/wireless/ath/ath9k/dynack.c
19 @@ -20,11 +20,30 @@
20  
21  #define COMPUTE_TO             (5 * HZ)
22  #define LATEACK_DELAY          (10 * HZ)
23 -#define LATEACK_TO             256
24 -#define MAX_DELAY              300
25  #define EWMA_LEVEL             96
26  #define EWMA_DIV               128
27  
28 +/**
29 + * ath_dynack_get_max_to - set max timeout according to channel width
30 + * @ah: ath hw
31 + *
32 + */
33 +static u32 ath_dynack_get_max_to(struct ath_hw *ah)
34 +{
35 +       const struct ath9k_channel *chan = ah->curchan;
36 +
37 +       if (!chan)
38 +               return 300;
39 +
40 +       if (IS_CHAN_HT40(chan))
41 +               return 300;
42 +       if (IS_CHAN_HALF_RATE(chan))
43 +               return 750;
44 +       if (IS_CHAN_QUARTER_RATE(chan))
45 +               return 1500;
46 +       return 600;
47 +}
48 +
49  /**
50   * ath_dynack_ewma - EWMA (Exponentially Weighted Moving Average) calculation
51   *
52 @@ -126,15 +145,16 @@ static void ath_dynack_compute_ackto(struct ath_hw *ah)
53   */
54  static void ath_dynack_compute_to(struct ath_hw *ah)
55  {
56 -       u32 ackto, ack_ts;
57 -       u8 *dst, *src;
58 +       struct ath_dynack *da = &ah->dynack;
59 +       u32 ackto, ack_ts, max_to;
60         struct ieee80211_sta *sta;
61 -       struct ath_node *an;
62         struct ts_info *st_ts;
63 -       struct ath_dynack *da = &ah->dynack;
64 +       struct ath_node *an;
65 +       u8 *dst, *src;
66  
67         rcu_read_lock();
68  
69 +       max_to = ath_dynack_get_max_to(ah);
70         while (da->st_rbf.h_rb != da->st_rbf.t_rb &&
71                da->ack_rbf.h_rb != da->ack_rbf.t_rb) {
72                 ack_ts = da->ack_rbf.tstamp[da->ack_rbf.h_rb];
73 @@ -150,7 +170,7 @@ static void ath_dynack_compute_to(struct ath_hw *ah)
74                 if (ack_ts > st_ts->tstamp + st_ts->dur) {
75                         ackto = ack_ts - st_ts->tstamp - st_ts->dur;
76  
77 -                       if (ackto < MAX_DELAY) {
78 +                       if (ackto < max_to) {
79                                 sta = ieee80211_find_sta_by_ifaddr(ah->hw, dst,
80                                                                    src);
81                                 if (sta) {
82 @@ -207,8 +227,10 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
83                 if (ieee80211_is_assoc_req(hdr->frame_control) ||
84                     ieee80211_is_assoc_resp(hdr->frame_control) ||
85                     ieee80211_is_auth(hdr->frame_control)) {
86 +                       u32 max_to = ath_dynack_get_max_to(ah);
87 +
88                         ath_dbg(common, DYNACK, "late ack\n");
89 -                       ath_dynack_set_timeout(ah, LATEACK_TO);
90 +                       ath_dynack_set_timeout(ah, max_to);
91                         if (sta) {
92                                 struct ath_node *an;
93  
94 -- 
95 2.17.1
96