ath9k: backport dynack improvements
[oweals/openwrt.git] / package / kernel / mac80211 / patches / 557-ath9k-dynack-introduce-ath_dynack_set_timeout-routin.patch
1 From 4420866ef1b602682b009e0186fbb8aefd2125be Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Tue, 20 Aug 2019 18:20:19 +0200
4 Subject: [PATCH 1/4] ath9k: dynack: introduce ath_dynack_set_timeout routine
5
6 Introduce ath_dynack_set_timeout routine to configure slottime/ack/cts
7 timeouts and remove duplicated code
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 | 37 ++++++++++++++-----------
13  1 file changed, 21 insertions(+), 16 deletions(-)
14
15 diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
16 index f112fa5b2eac..38dbe25919f7 100644
17 --- a/drivers/net/wireless/ath/ath9k/dynack.c
18 +++ b/drivers/net/wireless/ath/ath9k/dynack.c
19 @@ -78,6 +78,24 @@ static inline bool ath_dynack_bssidmask(struct ath_hw *ah, const u8 *mac)
20         return true;
21  }
22  
23 +/**
24 + * ath_dynack_set_timeout - configure timeouts/slottime registers
25 + * @ah: ath hw
26 + * @to: timeout value
27 + *
28 + */
29 +static void ath_dynack_set_timeout(struct ath_hw *ah, int to)
30 +{
31 +       struct ath_common *common = ath9k_hw_common(ah);
32 +       int slottime = (to - 3) / 2;
33 +
34 +       ath_dbg(common, DYNACK, "ACK timeout %u slottime %u\n",
35 +               to, slottime);
36 +       ath9k_hw_setslottime(ah, slottime);
37 +       ath9k_hw_set_ack_timeout(ah, to);
38 +       ath9k_hw_set_cts_timeout(ah, to);
39 +}
40 +
41  /**
42   * ath_dynack_compute_ackto - compute ACK timeout as the maximum STA timeout
43   * @ah: ath hw
44 @@ -86,7 +104,6 @@ static inline bool ath_dynack_bssidmask(struct ath_hw *ah, const u8 *mac)
45   */
46  static void ath_dynack_compute_ackto(struct ath_hw *ah)
47  {
48 -       struct ath_common *common = ath9k_hw_common(ah);
49         struct ath_dynack *da = &ah->dynack;
50         struct ath_node *an;
51         int to = 0;
52 @@ -96,15 +113,8 @@ static void ath_dynack_compute_ackto(struct ath_hw *ah)
53                         to = an->ackto;
54  
55         if (to && da->ackto != to) {
56 -               u32 slottime;
57 -
58 -               slottime = (to - 3) / 2;
59 +               ath_dynack_set_timeout(ah, to);
60                 da->ackto = to;
61 -               ath_dbg(common, DYNACK, "ACK timeout %u slottime %u\n",
62 -                       da->ackto, slottime);
63 -               ath9k_hw_setslottime(ah, slottime);
64 -               ath9k_hw_set_ack_timeout(ah, da->ackto);
65 -               ath9k_hw_set_cts_timeout(ah, da->ackto);
66         }
67  }
68  
69 @@ -198,10 +208,7 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
70                     ieee80211_is_assoc_resp(hdr->frame_control) ||
71                     ieee80211_is_auth(hdr->frame_control)) {
72                         ath_dbg(common, DYNACK, "late ack\n");
73 -
74 -                       ath9k_hw_setslottime(ah, (LATEACK_TO - 3) / 2);
75 -                       ath9k_hw_set_ack_timeout(ah, LATEACK_TO);
76 -                       ath9k_hw_set_cts_timeout(ah, LATEACK_TO);
77 +                       ath_dynack_set_timeout(ah, LATEACK_TO);
78                         if (sta) {
79                                 struct ath_node *an;
80  
81 @@ -340,9 +347,7 @@ void ath_dynack_reset(struct ath_hw *ah)
82         da->ack_rbf.h_rb = 0;
83  
84         /* init acktimeout */
85 -       ath9k_hw_setslottime(ah, (ackto - 3) / 2);
86 -       ath9k_hw_set_ack_timeout(ah, ackto);
87 -       ath9k_hw_set_cts_timeout(ah, ackto);
88 +       ath_dynack_set_timeout(ah, ackto);
89  }
90  EXPORT_SYMBOL(ath_dynack_reset);
91  
92 -- 
93 2.17.1
94