ath9k: dynack: fixes + cleanup
cover ath9k: dynack: fixes + cleanup
Improve ath9k dynack reliability in p2p/p2mp dynamic topologies. Improve code readability removing duplicated code.
This series has been tested by Koen Vandeputte on multiple outdoor links/devices.
This series is based on 'ath9k: dynack: fix possible deadlock in ath_dynack_node_{de}init'
https://patchwork.kernel.org/patch/11100409/
Lorenzo Bianconi (4):
ath9k: dyanck: introduce ath_dynack_set_timeout routine
ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset
ath9k: dynack: set max timeout according to channel width
ath9k: dynack: set ackto to max timeout in ath_dynack_reset
drivers/net/wireless/ath/ath9k/dynack.c | 93 +++++++++++++++++-------- 1 file changed, 63 insertions(+), 30 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/4 ath9k: dyanck: introduce ath_dynack_set_timeout routine
Introduce ath_dynack_set_timeout routine to configure slottime/ack/cts timeouts and remove duplicated code
--- drivers/net/wireless/ath/ath9k/dynack.c | 37 ++++++++++++++----------- 1 file changed, 21 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath9k/dynack.c +21 -16
@@ -78,6 +78,24 @@ static inline bool ath_dynack_bssidmask(struct ath_hw *ah, const u8 *mac)return true; } +/** +* ath_dynack_set_timeout - configure timeouts/slottime registers +* @ah: ath hw +* @to: timeout value +* +*/ +static void ath_dynack_set_timeout (struct ath_hw *ah,int to) +{ +struct ath_common *common =ath9k_hw_common (ah); +int slottime = (to -3 ) /2 ; + +ath_dbg (common,DYNACK ,"ACK timeout %u slottime %u\n" , + to, slottime); +ath9k_hw_setslottime (ah, slottime); +ath9k_hw_set_ack_timeout (ah, to); +ath9k_hw_set_cts_timeout (ah, to); +} +/** * ath_dynack_compute_ackto - compute ACK timeout as the maximum STA timeout * @ah: ath hw
@@ -86,7 +104,6 @@ static inline bool ath_dynack_bssidmask(struct ath_hw *ah, const u8 *mac)*/ static void ath_dynack_compute_ackto (struct ath_hw *ah) { -struct ath_common *common =ath9k_hw_common (ah);struct ath_dynack *da = &ah->dynack;struct ath_node *an;int to =0 ;
@@ -96,15 +113,8 @@ static void ath_dynack_compute_ackto(struct ath_hw *ah) to = an->ackto;if (to && da->ackto != to) { -u32 slottime; - - slottime = (to -3 ) /2 ; +ath_dynack_set_timeout (ah, to); da->ackto = to; -ath_dbg (common,DYNACK ,"ACK timeout %u slottime %u\n" , - da->ackto, slottime); -ath9k_hw_setslottime (ah, slottime); -ath9k_hw_set_ack_timeout (ah, da->ackto); -ath9k_hw_set_cts_timeout (ah, da->ackto); } }
@@ -198,10 +208,7 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb, ieee80211_is_assoc_resp(hdr->frame_control) || ieee80211_is_auth(hdr->frame_control)) {ath_dbg (common,DYNACK ,"late ack\n" ); - -ath9k_hw_setslottime (ah, (LATEACK_TO -3 ) /2 ); -ath9k_hw_set_ack_timeout (ah,LATEACK_TO ); -ath9k_hw_set_cts_timeout (ah,LATEACK_TO ); +ath_dynack_set_timeout (ah,LATEACK_TO );if (sta) {struct ath_node *an;
@@ -340,9 +347,7 @@ void ath_dynack_reset(struct ath_hw *ah) da->ack_rbf.h_rb =0 ;/* init acktimeout */ -ath9k_hw_setslottime (ah, (ackto -3 ) /2 ); -ath9k_hw_set_ack_timeout (ah, ackto); -ath9k_hw_set_cts_timeout (ah, ackto); +ath_dynack_set_timeout (ah, ackto); }EXPORT_SYMBOL (ath_dynack_reset);
Signature · 1 line
2.21.0
Re: [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine
Quoted 6 lines · Lorenzo Bianconi
Introduce
ath_dynack_set_timeoutroutine to configure slottime/ack/cts timeouts and remove duplicated codeTested-by Koen Vandeputte <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Kalle Valo <[email protected]>
4 patches applied to ath-next branch of ath.git, thanks.
5df65dd52dd5 ath9k: dyanck: introduce ath_dynack_set_timeout routine 6999e40d5f1d ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset 86e392994dee ath9k: dynack: set max timeout according to channel width 72bb1aa91ff8 ath9k: dynack: set ackto to max timeout in ath_dynack_reset
Signature · 3 lines
https://patchwork.kernel.org/patch/11104373/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 2/4 ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset
In reply to Lorenzo BianconiAdd compute timeout to last computation timestamp in ath_dynack_reset in order to not run ath_dynack_compute_ackto immediately
--- drivers/net/wireless/ath/ath9k/dynack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/dynack.c +1 -1
@@ -338,7 +338,7 @@ void ath_dynack_reset(struct ath_hw *ah)u32 ackto =9 +16 +64 ;struct ath_dynack *da = &ah->dynack; - da->lto = jiffies; + da->lto = jiffies +COMPUTE_TO ; da->ackto = ackto; da->st_rbf.t_rb =0 ;
Signature · 1 line
2.21.0
PATCH 3/4 ath9k: dynack: set max timeout according to channel width
In reply to Lorenzo BianconiCompute maximum configurable ackimeout/ctstimeout according to channel width (clockrate)
--- drivers/net/wireless/ath/ath9k/dynack.c | 38 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath9k/dynack.c +30 -8
@@ -20,11 +20,30 @@#define COMPUTE_TO (5 * HZ)#define LATEACK_DELAY (10 * HZ) -#define LATEACK_TO 256 -#define MAX_DELAY 300#define EWMA_LEVEL 96#define EWMA_DIV 128 +/** +* ath_dynack_get_max_to - set max timeout according to channel width +* @ah: ath hw +* +*/ +static u32 ath_dynack_get_max_to (struct ath_hw *ah) +{ +const struct ath9k_channel *chan = ah->curchan; + +if (!chan) +return 300 ; + +if (IS_CHAN_HT40 (chan)) +return 300 ; +if (IS_CHAN_HALF_RATE (chan)) +return 750 ; +if (IS_CHAN_QUARTER_RATE (chan)) +return 1500 ; +return 600 ; +} +/** * ath_dynack_ewma - EWMA (Exponentially Weighted Moving Average) calculation *
@@ -126,15 +145,16 @@ static void ath_dynack_compute_ackto(struct ath_hw *ah)*/ static void ath_dynack_compute_to (struct ath_hw *ah) { -u32 ackto, ack_ts; -u8 *dst, *src; +struct ath_dynack *da = &ah->dynack; +u32 ackto, ack_ts, max_to;struct ieee80211_sta *sta; -struct ath_node *an;struct ts_info *st_ts; -struct ath_dynack *da = &ah->dynack; +struct ath_node *an; +u8 *dst, *src;rcu_read_lock (); + max_to =ath_dynack_get_max_to (ah);while (da->st_rbf.h_rb != da->st_rbf.t_rb && da->ack_rbf.h_rb != da->ack_rbf.t_rb) { ack_ts = da->ack_rbf.tstamp[da->ack_rbf.h_rb];
@@ -150,7 +170,7 @@ static void ath_dynack_compute_to(struct ath_hw *ah)if (ack_ts > st_ts->tstamp + st_ts->dur) { ackto = ack_ts - st_ts->tstamp - st_ts->dur; -if (ackto <MAX_DELAY ) { +if (ackto < max_to) { sta =ieee80211_find_sta_by_ifaddr (ah->hw, dst, src);if (sta) {
@@ -207,8 +227,10 @@ void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,if (ieee80211_is_assoc_req (hdr->frame_control) ||ieee80211_is_assoc_resp (hdr->frame_control) ||ieee80211_is_auth (hdr->frame_control)) { +u32 max_to =ath_dynack_get_max_to (ah); +ath_dbg (common,DYNACK ,"late ack\n" ); -ath_dynack_set_timeout (ah,LATEACK_TO ); +ath_dynack_set_timeout (ah, max_to);if (sta) {struct ath_node *an;
Signature · 1 line
2.21.0
PATCH 4/4 ath9k: dynack: set ackto to max timeout in ath_dynack_reset
In reply to Lorenzo BianconiInitialize acktimeout to the maximum configurable value in ath_dynack_reset in order to not disconnect long distance static links enabling dynack and even to take care of possible errors configuring a static timeout. Moreover initialize station timeout value to the current acktimeout value
--- drivers/net/wireless/ath/ath9k/dynack.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath9k/dynack.c +13 -7
@@ -321,11 +321,9 @@ EXPORT_SYMBOL(ath_dynack_sample_ack_ts);*/ void ath_dynack_node_init (struct ath_hw *ah,struct ath_node *an) { -/* ackto = slottime + sifs + air delay */ -u32 ackto =9 +16 +64 ;struct ath_dynack *da = &ah->dynack; - an->ackto = ackto; + an->ackto = da->ackto;spin_lock_bh (&da->qlock);list_add_tail (&an->list, &da->nodes);
@@ -356,20 +354,26 @@ EXPORT_SYMBOL(ath_dynack_node_deinit);*/ void ath_dynack_reset (struct ath_hw *ah) { -/* ackto = slottime + sifs + air delay */ -u32 ackto =9 +16 +64 ;struct ath_dynack *da = &ah->dynack; +struct ath_node *an; + +spin_lock_bh (&da->qlock); da->lto = jiffies +COMPUTE_TO ; - da->ackto = ackto; da->st_rbf.t_rb =0 ; da->st_rbf.h_rb =0 ; da->ack_rbf.t_rb =0 ; da->ack_rbf.h_rb =0 ; + da->ackto =ath_dynack_get_max_to (ah); +list_for_each_entry (an, &da->nodes, list) + an->ackto = da->ackto; +/* init acktimeout */ -ath_dynack_set_timeout (ah, ackto); +ath_dynack_set_timeout (ah, da->ackto); + +spin_unlock_bh (&da->qlock); }EXPORT_SYMBOL (ath_dynack_reset);
@@ -386,6 +390,8 @@ void ath_dynack_init(struct ath_hw *ah)spin_lock_init (&da->qlock);INIT_LIST_HEAD (&da->nodes); +/* ackto = slottime + sifs + air delay */ + da->ackto =9 +16 +64 ; ah->hw->wiphy->features |=NL80211_FEATURE_ACKTO_ESTIMATION ; }
Signature · 1 line
2.21.0