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
6 Compute maximum configurable ackimeout/ctstimeout according to channel
9 Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
10 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
12 drivers/net/wireless/ath/ath9k/dynack.c | 38 +++++++++++++++++++------
13 1 file changed, 30 insertions(+), 8 deletions(-)
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
21 #define COMPUTE_TO (5 * HZ)
22 #define LATEACK_DELAY (10 * HZ)
23 -#define LATEACK_TO 256
24 -#define MAX_DELAY 300
29 + * ath_dynack_get_max_to - set max timeout according to channel width
33 +static u32 ath_dynack_get_max_to(struct ath_hw *ah)
35 + const struct ath9k_channel *chan = ah->curchan;
40 + if (IS_CHAN_HT40(chan))
42 + if (IS_CHAN_HALF_RATE(chan))
44 + if (IS_CHAN_QUARTER_RATE(chan))
50 * ath_dynack_ewma - EWMA (Exponentially Weighted Moving Average) calculation
52 @@ -126,15 +145,16 @@ static void ath_dynack_compute_ackto(struct ath_hw *ah)
54 static void ath_dynack_compute_to(struct ath_hw *ah)
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;
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;
77 - if (ackto < MAX_DELAY) {
78 + if (ackto < max_to) {
79 sta = ieee80211_find_sta_by_ifaddr(ah->hw, dst,
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);
88 ath_dbg(common, DYNACK, "late ack\n");
89 - ath_dynack_set_timeout(ah, LATEACK_TO);
90 + ath_dynack_set_timeout(ah, max_to);