mac80211: Optimize scans on current operating channel.
PATCH v2 1/1 mac80211: Optimize scans on current operating channel.
From: Ben Greear <[email protected]>
This should decrease un-necessary flushes, on/off channel work, and channel changes in cases where the only scanned channel is the current operating channel.
---
v2: Check channels instead of flag when determining if we should
do a channel change in scan_completed_finish.
:100644 100644 c47d7c0... 59fe5e7... M net/mac80211/ieee80211_i.h
:100644 100644 1236710... e6de0e7... M net/mac80211/rx.c
:100644 100644 3e660db... fa0aeb9... M net/mac80211/scan.c
net/mac80211/ieee80211_i.h | 5 +++++ net/mac80211/rx.c | 11 ++++++++--- net/mac80211/scan.c | 41 +++++++++++++++++++++++++---------------- 3 files changed, 38 insertions(+), 19 deletions(-)
net/mac80211/ieee80211_i.h +5 -0
@@ -660,6 +660,10 @@ struct tpt_led_trigger {* that the scan completed. * @SCAN_ABORTED: Set for our scan work function when the driver reported * a scan complete for an aborted scan. +* @SCAN_LEFT_OPER_CHANNEL: Set this flag if the scan process leaves the +* operating channel at any time. If scanning ONLY the current operating +* channel this flag should not be set, and this will allow fewer +* offchannel changes. */ enum {SCAN_SW_SCANNING ,
@@ -667,6 +671,7 @@ enum {SCAN_OFF_CHANNEL ,SCAN_COMPLETED ,SCAN_ABORTED , + SCAN_LEFT_OPER_CHANNEL, };/**
net/mac80211/rx.c +8 -3
@@ -388,6 +388,7 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)struct ieee80211_local *local = rx->local;struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (rx->skb);struct sk_buff *skb = rx->skb; +int ret;if (likely (!(status->rx_flags &IEEE80211_RX_IN_SCAN )))return RX_CONTINUE ;
@@ -396,10 +397,14 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)return ieee80211_scan_rx (rx->sdata, skb);if (test_bit (SCAN_SW_SCANNING , &local->scanning)) { -/* drop all the other packets during a software scan anyway */ -if (ieee80211_scan_rx (rx->sdata, skb) !=RX_QUEUED ) + ret =ieee80211_scan_rx (rx->sdata, skb); +/* drop all the other packets while scanning off channel */ +if (ret !=RX_QUEUED && +test_bit (SCAN_OFF_CHANNEL , &local->scanning)) {dev_kfree_skb (skb); -return RX_QUEUED ; +return RX_QUEUED ; + } +return ret; }/* scanning finished during invoking of handlers */
net/mac80211/scan.c +25 -16
92 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Johannes Berg
maintainerQuoted 4 lines · On Fri, 2011-01-21 at 10:05 -0800, [email protected] wrote:
+ * @SCAN_LEFT_OPER_CHANNEL: Set this flag if the scan process leaves the
+ * operating channel at any time. If scanning ONLY the current operating + * channel this flag should not be set, and this will allow fewer + * offchannel changes.
Why does this make sense? In the code below, you do
net/mac80211/scan.c static void __ieee80211_scan_completed_finish(struct ieee80211_hw *hw, · line 303
Quoted 10 lines
net/mac80211/scan.c +5
-2-ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_CHANNEL ); +if ((local->oper_channel != local->hw.conf.channel) || was_hw_scan) +ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_CHANNEL ); +if (!was_hw_scan) {ieee80211_configure_filter (local);drv_sw_scan_complete (local); -ieee80211_offchannel_return (local, true); +if (test_bit (SCAN_LEFT_OPER_CHANNEL , &local->scanning)) +ieee80211_offchannel_return (local, true);
so you could just as well use a local variable (the first if you add is exactly this test).
net/mac80211/scan.c static void ieee80211_scan_state_decision(struct ieee80211_local *local, · line 599
Quoted 5 lines
static void ieee80211_scan_state_leave_oper_channel(struct
ieee80211_local*local,net/mac80211/scan.c +2
-0unsigned long *next_delay) { +ieee80211_offchannel_stop_beaconing (local); +
Won't that confuse drivers that expect not to be beaconing between sw_scan_start and sw_scan_end?
Also, are you sure the filter configuration works correctly this way? If you can, I'd like to look at a binary trace of the commands going to the device with this change: "trace-cmd record -e mac80211".
johannes
Quoted 10 lines · Johannes Berg
Quoted 4 lines · On Fri, 2011-01-21 at 10:05 -0800, [email protected] wrote:
+ * @SCAN_LEFT_OPER_CHANNEL: Set this flag if the scan process leaves the
+ * operating channel at any time. If scanning ONLY the current operating + * channel this flag should not be set, and this will allow fewer + * offchannel changes.Why does this make sense? In the code below, you do
Quoted 13 lines
net/mac80211/scan.c static void __ieee80211_scan_completed_finish(struct ieee80211_hw *hw, · line 303
Quoted 10 lines
net/mac80211/scan.c +5
-2-ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_CHANNEL ); +if ((local->oper_channel != local->hw.conf.channel) || was_hw_scan) +ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_CHANNEL ); +if (!was_hw_scan) {ieee80211_configure_filter (local);drv_sw_scan_complete (local); -ieee80211_offchannel_return (local, true); +if (test_bit (SCAN_LEFT_OPER_CHANNEL ,&local->scanning)) +ieee80211_offchannel_return (local, true);so you could just as well use a local variable (the first if you add is exactly this test).
I'm sorry, but I don't understand your comments. I need some way to track whether we ever called the offchannel-stop-beaconing code so that it can be selectively re-enabled in the code above. I was using a flag instead of adding another boolean to the local struct.
The flag could be called 'SCAN_STOPPED_BEACONING' instead if that makes more sense?
Quoted 8 lines
net/mac80211/scan.c static void ieee80211_scan_state_decision(struct ieee80211_local *local, · line 599
Quoted 5 lines
static void ieee80211_scan_state_leave_oper_channel(struct
ieee80211_local*local,
unsigned long*next_delay)
{net/mac80211/scan.c +2
-0+ieee80211_offchannel_stop_beaconing (local); +Won't that confuse drivers that expect not to be beaconing between
sw_scan_startandsw_scan_end?
I didn't know that any would care. Maybe we need a phy_features set of flags and let each driver enable this optimization as it is tested/verified? Seems to work fine for ath9k with multiple VIFs, for what that's worth.
Quoted 3 lines
Also, are you sure the filter configuration works correctly this way? If you can, I'd like to look at a binary trace of the commands going to the device with this change: "trace-cmd record -e mac80211".
I'll try to run this soon and post the results.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 3 lines · Johannes Berg
Also, are you sure the filter configuration works correctly this way? If you can, I'd like to look at a binary trace of the commands going to the device with this change: "trace-cmd record -e mac80211".
I uploaded two trace files. One that scans the single operating channel, and a second that scans all channels. This is with my -v2 patch applied, using ath9k as the driver. There are two virtual STA interfaces configured on this system for this test.
http://www.candelatech.com/~greearb/trace-scan-all.dat.bz2
http://www.candelatech.com/~greearb/trace-scan-one.dat.bz2
Please let me know what you think.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 12 lines · Ben Greear
Quoted 3 lines · Johannes Berg
Also, are you sure the filter configuration works correctly this way? If you can, I'd like to look at a binary trace of the commands going to the device with this change: "trace-cmd record -e mac80211".
I uploaded two trace files. One that scans the single operating channel, and a second that scans all channels. This is with my -v2 patch applied, using ath9k as the driver. There are two virtual STA interfaces configured on this system for this test.
Quoted 4 lines
http://www.candelatech.com/~greearb/trace-scan-all.dat.bz2
http://www.candelatech.com/~greearb/trace-scan-one.dat.bz2Please let me know what you think.
Thanks. I don't think the -one one really is just a single scan? But anyway, looking at it now.
johannes
Quoted 13 lines · Johannes Berg
Quoted 12 lines · Ben Greear
Quoted 3 lines · Johannes Berg
Also, are you sure the filter configuration works correctly this way? If you can, I'd like to look at a binary trace of the commands going to the device with this change: "trace-cmd record -e mac80211".
I uploaded two trace files. One that scans the single operating channel, and a second that scans all channels. This is with my -v2 patch applied, using ath9k as the driver. There are two virtual STA interfaces configured on this system for this test.
Quoted 7 lines
Quoted 4 lines
http://www.candelatech.com/~greearb/trace-scan-all.dat.bz2
http://www.candelatech.com/~greearb/trace-scan-one.dat.bz2Please let me know what you think.
Thanks. I don't think the -one one really is just a single scan? But anyway, looking at it now.
No, sorry..it's probably several scans and other things..but it should not scan more than one (operating) channel.
Also, I'm seeing problems where sometimes wpa_supplicant doesn't see scan results when scanning a single operating channel. I think this is probably a bug in my mac80211 patch. I plan to look at that in detail today.
Thanks,
Ben
Quoted 2 lines
johannes
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 11 lines · On Fri, 2011-01-21 at 10:05 -0800, [email protected] wrote:
From: Ben Greear <[email protected]>
This should decrease un-necessary flushes, on/off channel work, and channel changes in cases where the only scanned channel is the current operating channel.
Signed-off-by Ben Greear <[email protected]>---
v2: Check channels instead of flag when determining if we should
do a channel change inscan_completed_finish.
Can you look at work.c -- where we callieee80211_offchannel_stop_beaconing etc.
In this patch, you're moving the call toieee80211_offchannel_stop_beaconing next toieee80211_offchannel_stop_station in scan.c.
Therefore, you can combine those two into one function.
However, I guess it'd also be nice to also address the TODO in work.c and move the "don't do so much if not really off-channel" logic into that function? You must run into that when trying to associate on one vif and the others get stopped etc. unnecessarily to do that.
johannes
Quoted 20 lines · Johannes Berg
Quoted 11 lines · On Fri, 2011-01-21 at 10:05 -0800, [email protected] wrote:
From: Ben Greear<[email protected]>
This should decrease un-necessary flushes, on/off channel work, and channel changes in cases where the only scanned channel is the current operating channel.
Signed-off-by Ben Greear<[email protected]>---
v2: Check channels instead of flag when determining if we should
do a channel change inscan_completed_finish.Can you look at
work.c-- where we callieee80211_offchannel_stop_beaconingetc.In this patch, you're moving the call to
ieee80211_offchannel_stop_beaconingnext toieee80211_offchannel_stop_stationinscan.c.
Quoted 6 lines
Therefore, you can combine those two into one function.
However, I guess it'd also be nice to also address the TODO in
work.cand move the "don't do so much if not really off-channel" logic into that function? You must run into that when trying to associate on one vif and the others get stopped etc. unnecessarily to do that.
I think you are right about this, but due to the tricky nature of this code, maybe save that for a second patch?
Thanks,
Ben
Quoted 7 lines
johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 7 lines · Ben Greear
Quoted 4 lines
However, I guess it'd also be nice to also address the TODO in
work.cand move the "don't do so much if not really off-channel" logic into that function? You must run into that when trying to associate on one vif and the others get stopped etc. unnecessarily to do that.I think you are right about this, but due to the tricky nature of this code, maybe save that for a second patch?
Yeah, I think that might be good -- but maybe prepare in your current version by not having the offchannel bit in the scan?
In fact -- I'm not even sure why you have two off-channel bits there, but please reply to my comments on v3 rather than here.
johannes
Quoted 13 lines · Johannes Berg
Quoted 11 lines · On Fri, 2011-01-21 at 10:05 -0800, [email protected] wrote:
From: Ben Greear<[email protected]>
This should decrease un-necessary flushes, on/off channel work, and channel changes in cases where the only scanned channel is the current operating channel.
Signed-off-by Ben Greear<[email protected]>---
v2: Check channels instead of flag when determining if we should
do a channel change inscan_completed_finish.
Quoted 6 lines
Can you look at
work.c-- where we callieee80211_offchannel_stop_beaconingetc.In this patch, you're moving the call to
ieee80211_offchannel_stop_beaconingnext toieee80211_offchannel_stop_stationinscan.c.
The offchannel_stop_beaconing doesn't actually change state, it just calls
ieee80211_bss_info_change_notify(
sdata, BSS_CHANGED_BEACON_ENABLED);
That method will disable beaconing if SCAN_SW_SCANNING is set, regardless of current channel.
So, if that work.c logic is happening during a scan, we will always disable scanning, but if we are not SW scanning, then that offchannel_stop_beaconing won't actually do anything useful.
My first inclination is to add another check in bss_info_change_notify to test if we are really off-channel:
if (local->quiescing || !ieee80211_sdata_running(sdata) ||
(test_bit(SCAN_SW_SCANNING, &local->scanning) &&
test_bit(SCAN_OFF_CHANNEL, &local->scanning)) {
sdata->vif.bss_conf.enable_beacon = false;And either set the SCAN_OFF_CHANNEL flag before calling offchannel_stop_beaconing, or perhaps set that flag in offchannel_stop_beaconing. The first might be less risky, but that leaves the work.c logic funky in my opinion, since if we are not actually scanning, beacons will still be enabled.
I could use some suggestions on how to proceed. I am overly tempted to start changing everything in sight, but that is likely to cause all sorts of bugs, subtle and otherwise....
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 23 lines · Ben Greear
The
offchannel_stop_beaconingdoesn't actually change state, it just callsieee80211_bss_info_change_notify(
sdata, BSS_CHANGED_BEACON_ENABLED);That method will disable beaconing if
SCAN_SW_SCANNINGis set, regardless of current channel.So, if that
work.clogic is happening during a scan, we will always disable scanning, but if we are not SW scanning, then thatoffchannel_stop_beaconingwon't actually do anything useful.My first inclination is to add another check in
bss_info_change_notifyto test if we are really off-channel:if (local->quiescing || !ieee80211_sdata_running(sdata) || (test_bit(SCAN_SW_SCANNING, &local->scanning) && test_bit(SCAN_OFF_CHANNEL, &local->scanning)) { sdata->vif.bss_conf.enable_beacon = false;
Quoted 4 lines
And either set the
SCAN_OFF_CHANNELflag before callingoffchannel_stop_beaconing, or perhaps set that flag inoffchannel_stop_beaconing. The first might be less risky, but that leaves thework.clogic funky in my opinion, since if we are not actually scanning, beacons will still be enabled.
Yes, I'm a bit concerned about that too -- that bit really shouldn't be in the scan bits, and then we can set it in offchannel_stop_beaconing or whatever the combination ends up being called.
Quoted 3 lines
I could use some suggestions on how to proceed. I am overly tempted to start changing everything in sight, but that is likely to cause all sorts of bugs, subtle and otherwise....
:)
I've long been tempted to rewrite scanning in terms of off-channel work items ... Not really sure what to do.
johannes