linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] ath9k: dynack: fixes + cleanup
@ 2019-08-20 16:20 Lorenzo Bianconi
  2019-08-20 16:20 ` [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine Lorenzo Bianconi
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2019-08-20 16:20 UTC (permalink / raw)
  To: kvalo; +Cc: lorenzo.bianconi, linux-wireless, koen.vandeputte

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(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine
  2019-08-20 16:20 [PATCH 0/4] ath9k: dynack: fixes + cleanup Lorenzo Bianconi
@ 2019-08-20 16:20 ` Lorenzo Bianconi
  2019-09-04  6:20   ` Kalle Valo
  2019-08-20 16:20 ` [PATCH 2/4] ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset Lorenzo Bianconi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Lorenzo Bianconi @ 2019-08-20 16:20 UTC (permalink / raw)
  To: kvalo; +Cc: lorenzo.bianconi, linux-wireless, koen.vandeputte

Introduce ath_dynack_set_timeout routine to configure slottime/ack/cts
timeouts and remove duplicated code

Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/ath/ath9k/dynack.c | 37 ++++++++++++++-----------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
index 1ccf20d8c160..c244dd15dce4 100644
--- a/drivers/net/wireless/ath/ath9k/dynack.c
+++ b/drivers/net/wireless/ath/ath9k/dynack.c
@@ -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);
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset
  2019-08-20 16:20 [PATCH 0/4] ath9k: dynack: fixes + cleanup Lorenzo Bianconi
  2019-08-20 16:20 ` [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine Lorenzo Bianconi
@ 2019-08-20 16:20 ` Lorenzo Bianconi
  2019-08-20 16:20 ` [PATCH 3/4] ath9k: dynack: set max timeout according to channel width Lorenzo Bianconi
  2019-08-20 16:20 ` [PATCH 4/4] ath9k: dynack: set ackto to max timeout in ath_dynack_reset Lorenzo Bianconi
  3 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2019-08-20 16:20 UTC (permalink / raw)
  To: kvalo; +Cc: lorenzo.bianconi, linux-wireless, koen.vandeputte

Add compute timeout to last computation timestamp in
ath_dynack_reset in order to not run ath_dynack_compute_ackto
immediately

Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/ath/ath9k/dynack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
index c244dd15dce4..5d5809d160af 100644
--- a/drivers/net/wireless/ath/ath9k/dynack.c
+++ b/drivers/net/wireless/ath/ath9k/dynack.c
@@ -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;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] ath9k: dynack: set max timeout according to channel width
  2019-08-20 16:20 [PATCH 0/4] ath9k: dynack: fixes + cleanup Lorenzo Bianconi
  2019-08-20 16:20 ` [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine Lorenzo Bianconi
  2019-08-20 16:20 ` [PATCH 2/4] ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset Lorenzo Bianconi
@ 2019-08-20 16:20 ` Lorenzo Bianconi
  2019-08-20 16:20 ` [PATCH 4/4] ath9k: dynack: set ackto to max timeout in ath_dynack_reset Lorenzo Bianconi
  3 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2019-08-20 16:20 UTC (permalink / raw)
  To: kvalo; +Cc: lorenzo.bianconi, linux-wireless, koen.vandeputte

Compute maximum configurable ackimeout/ctstimeout according to channel
width (clockrate)

Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/ath/ath9k/dynack.c | 38 +++++++++++++++++++------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
index 5d5809d160af..f5acaa577d62 100644
--- a/drivers/net/wireless/ath/ath9k/dynack.c
+++ b/drivers/net/wireless/ath/ath9k/dynack.c
@@ -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;
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] ath9k: dynack: set ackto to max timeout in ath_dynack_reset
  2019-08-20 16:20 [PATCH 0/4] ath9k: dynack: fixes + cleanup Lorenzo Bianconi
                   ` (2 preceding siblings ...)
  2019-08-20 16:20 ` [PATCH 3/4] ath9k: dynack: set max timeout according to channel width Lorenzo Bianconi
@ 2019-08-20 16:20 ` Lorenzo Bianconi
  3 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Bianconi @ 2019-08-20 16:20 UTC (permalink / raw)
  To: kvalo; +Cc: lorenzo.bianconi, linux-wireless, koen.vandeputte

Initialize 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

Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/wireless/ath/ath9k/dynack.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c
index f5acaa577d62..fbeb4a739d32 100644
--- a/drivers/net/wireless/ath/ath9k/dynack.c
+++ b/drivers/net/wireless/ath/ath9k/dynack.c
@@ -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;
 }
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine
  2019-08-20 16:20 ` [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine Lorenzo Bianconi
@ 2019-09-04  6:20   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2019-09-04  6:20 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: lorenzo.bianconi, linux-wireless, koen.vandeputte

Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Introduce ath_dynack_set_timeout routine to configure slottime/ack/cts
> timeouts and remove duplicated code
> 
> Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

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

-- 
https://patchwork.kernel.org/patch/11104373/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-04  6:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 16:20 [PATCH 0/4] ath9k: dynack: fixes + cleanup Lorenzo Bianconi
2019-08-20 16:20 ` [PATCH 1/4] ath9k: dyanck: introduce ath_dynack_set_timeout routine Lorenzo Bianconi
2019-09-04  6:20   ` Kalle Valo
2019-08-20 16:20 ` [PATCH 2/4] ath9k: dynack: properly set last timeout timestamp in ath_dynack_reset Lorenzo Bianconi
2019-08-20 16:20 ` [PATCH 3/4] ath9k: dynack: set max timeout according to channel width Lorenzo Bianconi
2019-08-20 16:20 ` [PATCH 4/4] ath9k: dynack: set ackto to max timeout in ath_dynack_reset Lorenzo Bianconi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).