sharkcz / rpms / kernel

Forked from rpms/kernel 6 years ago
Clone
f63d946
From c790794fcb461842e6ae1d764b7f68e9a789d149 Mon Sep 17 00:00:00 2001
f63d946
From: Stanislaw Gruszka <sgruszka@redhat.com>
f63d946
Date: Wed, 23 Jan 2013 12:32:45 +0100
f63d946
Subject: [PATCH] mac80211: improve latency and throughput while software
f63d946
 scanning
f63d946
f63d946
Patch vastly improve latency while scanning. Slight throughput
f63d946
improvements were observed as well. Is intended for improve performance
f63d946
of voice and video applications, when scan is periodically requested by
f63d946
user space (i.e. default NetworkManager behaviour).
f63d946
f63d946
Patch remove latency requirement based on PM_QOS_NETWORK_LATENCY,
f63d946
this value is 2000 seconds by default (i.e. approximately 0.5 hour !?!).
f63d946
f63d946
Also remove listen interval requirement, which based on beaconing and
f63d946
depending on BSS parameters. It can make we stay off-channel for a
f63d946
second or more.
f63d946
f63d946
Instead try to offer the best latency that we could, i.e. be off-channel
f63d946
no longer than PASSIVE channel scan time: 125 ms. That mean we will
f63d946
scan two ACTIVE channels and go back to on-channel, and one PASSIVE
f63d946
channel, and go back to on-channel.
f63d946
f63d946
Patch also decrease PASSIVE channel scan time to about 110 ms.
f63d946
f63d946
As drawback patch increase overall scan time. On my tests, when scanning
f63d946
both 2GHz and 5GHz bands, scanning time increase from 5 seconds up to 10
f63d946
seconds. Since that increase happen only when we are associated, I think
f63d946
it can be acceptable. If eventually better scan time is needed for
f63d946
situations when we lose signal and quickly need to decide to which AP
f63d946
roam, additional scan flag or parameter can be introduced.
f63d946
f63d946
I tested patch by doing:
f63d946
f63d946
while true; do iw dev wlan0 scan; sleep 3; done > /dev/null
f63d946
f63d946
and
f63d946
f63d946
ping -i0.2 -c 1000 HOST
f63d946
f63d946
on remote and local machine, results are as below:
f63d946
f63d946
* Ping from local periodically scanning machine to AP:
f63d946
Unpatched: rtt min/avg/max/mdev = 0.928/24.946/182.135/36.873 ms
f63d946
Patched:   rtt min/avg/max/mdev = 0.928/19.678/150.845/33.130 ms
f63d946
f63d946
* Ping from remote machine to periodically scanning machine:
f63d946
Unpatched: rtt min/avg/max/mdev = 1.637/120.683/709.139/164.337 ms
f63d946
Patched:   rtt min/avg/max/mdev = 1.807/26.893/201.435/40.284 ms
f63d946
f63d946
Throughput measured by scp show following results.
f63d946
f63d946
* Upload to periodically scanning machine:
f63d946
Unpatched: 3.9MB/s   03:15
f63d946
Patched:   4.3MB/s   02:58
f63d946
f63d946
* Download from periodically scanning machine:
f63d946
Unpatched: 5.5MB/s   02:17
f63d946
Patched:   6.2MB/s   02:02
f63d946
f63d946
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
f63d946
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
f63d946
---
f63d946
 net/mac80211/scan.c | 32 +++++---------------------------
f63d946
 1 file changed, 5 insertions(+), 27 deletions(-)
f63d946
f63d946
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
f63d946
index bf82e69..e6b2ebc 100644
f63d946
--- a/net/mac80211/scan.c
f63d946
+++ b/net/mac80211/scan.c
f63d946
@@ -27,7 +27,7 @@
f63d946
 
f63d946
 #define IEEE80211_PROBE_DELAY (HZ / 33)
f63d946
 #define IEEE80211_CHANNEL_TIME (HZ / 33)
f63d946
-#define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 8)
f63d946
+#define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 9)
f63d946
 
f63d946
 static void ieee80211_rx_bss_free(struct cfg80211_bss *cbss)
f63d946
 {
f63d946
@@ -547,8 +547,6 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local,
f63d946
 	bool associated = false;
f63d946
 	bool tx_empty = true;
f63d946
 	bool bad_latency;
f63d946
-	bool listen_int_exceeded;
f63d946
-	unsigned long min_beacon_int = 0;
f63d946
 	struct ieee80211_sub_if_data *sdata;
f63d946
 	struct ieee80211_channel *next_chan;
f63d946
 	enum mac80211_scan_state next_scan_state;
f63d946
@@ -567,11 +565,6 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local,
f63d946
 			if (sdata->u.mgd.associated) {
f63d946
 				associated = true;
f63d946
 
f63d946
-				if (sdata->vif.bss_conf.beacon_int <
f63d946
-				    min_beacon_int || min_beacon_int == 0)
f63d946
-					min_beacon_int =
f63d946
-						sdata->vif.bss_conf.beacon_int;
f63d946
-
f63d946
 				if (!qdisc_all_tx_empty(sdata->dev)) {
f63d946
 					tx_empty = false;
f63d946
 					break;
f63d946
@@ -588,34 +581,19 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local,
f63d946
 	 * see if we can scan another channel without interfering
f63d946
 	 * with the current traffic situation.
f63d946
 	 *
f63d946
-	 * Since we don't know if the AP has pending frames for us
f63d946
-	 * we can only check for our tx queues and use the current
f63d946
-	 * pm_qos requirements for rx. Hence, if no tx traffic occurs
f63d946
-	 * at all we will scan as many channels in a row as the pm_qos
f63d946
-	 * latency allows us to. Additionally we also check for the
f63d946
-	 * currently negotiated listen interval to prevent losing
f63d946
-	 * frames unnecessarily.
f63d946
-	 *
f63d946
-	 * Otherwise switch back to the operating channel.
f63d946
+	 * Keep good latency, do not stay off-channel more than 125 ms.
f63d946
 	 */
f63d946
 
f63d946
 	bad_latency = time_after(jiffies +
f63d946
-			ieee80211_scan_get_channel_time(next_chan),
f63d946
-			local->leave_oper_channel_time +
f63d946
-			usecs_to_jiffies(pm_qos_request(PM_QOS_NETWORK_LATENCY)));
f63d946
-
f63d946
-	listen_int_exceeded = time_after(jiffies +
f63d946
-			ieee80211_scan_get_channel_time(next_chan),
f63d946
-			local->leave_oper_channel_time +
f63d946
-			usecs_to_jiffies(min_beacon_int * 1024) *
f63d946
-			local->hw.conf.listen_interval);
f63d946
+				 ieee80211_scan_get_channel_time(next_chan),
f63d946
+				 local->leave_oper_channel_time + HZ / 8);
f63d946
 
f63d946
 	if (associated && !tx_empty) {
f63d946
 		if (local->scan_req->flags & NL80211_SCAN_FLAG_LOW_PRIORITY)
f63d946
 			next_scan_state = SCAN_ABORT;
f63d946
 		else
f63d946
 			next_scan_state = SCAN_SUSPEND;
f63d946
-	} else if (associated && (bad_latency || listen_int_exceeded)) {
f63d946
+	} else if (associated && bad_latency) {
f63d946
 		next_scan_state = SCAN_SUSPEND;
f63d946
 	} else {
f63d946
 		next_scan_state = SCAN_SET_CHANNEL;
f63d946
-- 
f63d946
1.8.1
f63d946