mac80211: Optimize scans on current operating channel.
PATCH v9 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.
* Removes SCAN_OFF_CHANNEL flag, uses SDATA_STATE_OFFCHANNEL and is-scanning flags instead.
* Add helper method to determine if we are currently configured for the operating channel.
* Do no blindly go off/on channel in work.c Instead, only call appropriate on/off code when we really need to change channels.
* Consolidate ieee80211_offchannel_stop_station and ieee80211_offchannel_stop_beaconing, call it ieee80211_offchannel_stop_vifs instead.
* Accept non-beacon frames when scanning on operating channel.
* Scan state machine optimized to minimize on/off channel transitions. Also, when going on-channel, go ahead and re-enable beaconing. We're going to be there for 200ms, so seems like some useful beaconing could happen.
* Grab local->mtx earlier in __ieee80211_scan_completed_finish so that we are protected when calling hw_config(), etc.
* Pass probe-responses up the stack if scanning on local channel, so that mlme can take a look.
---
v9: Change 'ooc' variable names to 'on_oper_chan'.
Fix up some comments.
There should be no logical changes from v8
:100644 100644 c47d7c0... abf0521... M net/mac80211/ieee80211_i.h
:100644 100644 09a2744... c155c0b... M net/mac80211/main.c
:100644 100644 b4e5267... 5400da6... M net/mac80211/offchannel.c
:100644 100644 7185c93... 030c3e9... M net/mac80211/rx.c
:100644 100644 f246d8a... 6599c64... M net/mac80211/scan.c
:100644 100644 ffc6749... 5f8b4a6... M net/mac80211/tx.c
:100644 100644 36305e0... 22b8f70... M net/mac80211/work.c
net/mac80211/ieee80211_i.h | 7 +--- net/mac80211/main.c | 53 +++++++++++++++++++++++++++--- net/mac80211/offchannel.c | 48 +++++++-------------------- net/mac80211/rx.c | 12 ++----- net/mac80211/scan.c | 76 +++++++++++++++++++++++++++++--------------- net/mac80211/tx.c | 3 +- net/mac80211/work.c | 55 +++++++++++++++++++++++++------ 7 files changed, 161 insertions(+), 93 deletions(-)
net/mac80211/ieee80211_i.h +2 -5
@@ -654,8 +654,6 @@ struct tpt_led_trigger {* well be on the operating channel * @SCAN_HW_SCANNING: The hardware is scanning for us, we have no way to * determine if we are on the operating channel or not -* @SCAN_OFF_CHANNEL: We're off our operating channel for scanning, -* gets only set in conjunction with SCAN_SW_SCANNING * @SCAN_COMPLETED: Set for our scan work function when the driver reported * that the scan completed. * @SCAN_ABORTED: Set for our scan work function when the driver reported
@@ -664,7 +662,6 @@ struct tpt_led_trigger {enum {SCAN_SW_SCANNING ,SCAN_HW_SCANNING , -SCAN_OFF_CHANNEL ,SCAN_COMPLETED ,SCAN_ABORTED , };
@@ -1147,8 +1144,8 @@ void ieee80211_rx_bss_put(struct ieee80211_local *local, struct ieee80211_bss *bss);/* off-channel helpers */ -void ieee80211_offchannel_stop_beaconing (struct ieee80211_local *local); -void ieee80211_offchannel_stop_station (struct ieee80211_local *local); +bool ieee80211_cfg_on_oper_channel (struct ieee80211_local *local); +void ieee80211_offchannel_stop_vifs (struct ieee80211_local *local);void ieee80211_offchannel_return (struct ieee80211_local *local,bool enable_beaconing);void ieee80211_hw_roc_setup (struct ieee80211_local *local);
net/mac80211/main.c +47 -6
81 lines not on this page · raw message
net/mac80211/offchannel.c +13 -35
75 lines not on this page · raw message
net/mac80211/rx.c +3 -9
@@ -409,16 +409,10 @@ ieee80211_rx_h_passive_scan(struct ieee80211_rx_data *rx)if (likely (!(status->rx_flags &IEEE80211_RX_IN_SCAN )))return RX_CONTINUE ; -if (test_bit (SCAN_HW_SCANNING , &local->scanning)) +if (test_bit (SCAN_HW_SCANNING , &local->scanning) || +test_bit (SCAN_SW_SCANNING , &local->scanning))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 ) -dev_kfree_skb (skb); -return RX_QUEUED ; - } -/* scanning finished during invoking of handlers */ I802_DEBUG_INC (local->rx_handlers_drop_passive_scan);return RX_DROP_UNUSABLE ;
@@ -2766,7 +2760,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, local->dot11ReceivedFragmentCount++;if (unlikely (test_bit (SCAN_HW_SCANNING , &local->scanning) || -test_bit (SCAN_OFF_CHANNEL , &local->scanning))) +test_bit (SCAN_SW_SCANNING , &local->scanning))) status->rx_flags |=IEEE80211_RX_IN_SCAN ;if (ieee80211_is_mgmt (fc))
net/mac80211/scan.c +50 -26
143 lines not on this page · raw message
net/mac80211/tx.c +2 -1
@@ -257,7 +257,8 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)if (unlikely (info->flags &IEEE80211_TX_CTL_INJECTED ))return TX_CONTINUE ; -if (unlikely (test_bit (SCAN_OFF_CHANNEL , &tx->local->scanning)) && +if (unlikely (test_bit (SCAN_SW_SCANNING , &tx->local->scanning)) && +test_bit (SDATA_STATE_OFFCHANNEL , &tx->sdata->state) && !ieee80211_is_probe_req (hdr->frame_control) && !ieee80211_is_nullfunc (hdr->frame_control))/*
net/mac80211/work.c +44 -11
71 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Johannes Berg
maintainerQuoted 2 lines · On Wed, 2011-02-02 at 10:18 -0800, [email protected] wrote:
* Do no blindly go off/on channel in
work.cInstead, only call appropriate on/off code when we really need to change channels.
Based on the powersave comments I had earlier, maybe we should remove that bit for now? Work items here require powersave is disabled, but we won't do that right now if we're on the same channel.
Scan, on the other hand, will still disable powersave (right?)
johannes
Quoted 8 lines · Johannes Berg
Quoted 2 lines · On Wed, 2011-02-02 at 10:18 -0800, [email protected] wrote:
* Do no blindly go off/on channel in
work.cInstead, only call appropriate on/off code when we really need to change channels.Based on the powersave comments I had earlier, maybe we should remove that bit for now? Work items here require powersave is disabled, but we won't do that right now if we're on the same channel.
The problem is, if we leave the work_work() in the original manner, the on/off channel state changes are not properly tracked because work blindly assumes it goes off/on channel. This breaks assumptions about when we must call the return-to-channel logic. I think if we do not religiously track the on/off channel state changes it would be too easy to get in a state where we think we are on-channel but haven't actually re-enabled xmit queues, etc.
I think I would rather change the work logic to expressly disable/enable powersave. That wouldn't be difficult, would it?
Quoted 1 line
Scan, on the other hand, will still disable powersave (right?)
I don't think it does anything if we are scanning on-channel with my patch.
The enable/disable logic is now in the offchannel code...
Do we need to disable it if we are scanning on channel? If so, I can add that explicitly to the scanning code.
While we are on that topic, it seems the conf.flags are set opposite to what I expect. Is that code below correct?
/* inform AP that we are awake again, unless power save is enabled */ static void ieee80211_offchannel_ps_disable(struct ieee80211_sub_if_data *sdata) {
struct ieee80211_local *local = sdata->local;
if (!local->ps_sdata)
ieee80211_send_nullfunc(local, sdata, 0);
else if (local->offchannel_ps_enabled) {
/*
* In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware
* will send a nullfunc frame with the powersave bit set
* even though the AP already knows that we are sleeping.
* This could be avoided by sending a null frame with power
* save bit disabled before enabling the power save, but
* this doesn't gain anything.
*
* When IEEE80211_HW_PS_NULLFUNC_STACK is enabled, no need
* to send a nullfunc frame because AP already knows that
* we are sleeping, let's just enable power save mode in
* hardware.
*/
local->hw.conf.flags |= IEEE80211_CONF_PS;
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 · Ben Greear
Quoted 3 lines
Based on the powersave comments I had earlier, maybe we should remove that bit for now? Work items here require powersave is disabled, but we won't do that right now if we're on the same channel.
The problem is, if we leave the
work_work()in the original manner, the on/off channel state changes are not properly tracked because work blindly assumes it goes off/on channel. This breaks assumptions about when we must call the return-to-channel logic. I think if we do not religiously track the on/off channel state changes it would be too easy to get in a state where we think we are on-channel but haven't actually re-enabled xmit queues, etc.
But if we pretend all work is off-channel, won't it be OK to return from off-channel, even if it isn't really another channel?
Quoted 2 lines
I think I would rather change the work logic to expressly disable/enable powersave. That wouldn't be difficult, would it?
Probably not -- but the code you modified regarding powersave probably needs adjustment then.
Quoted 6 lines
I don't think it does anything if we are scanning on-channel with my patch.
The enable/disable logic is now in the offchannel code...Do we need to disable it if we are scanning on channel? If so, I can add that explicitly to the scanning code.
Yes, I think we do need to do that, since otherwise we won't actually receive any beacons other than from our own AP.
Quoted 2 lines
While we are on that topic, it seems the conf.flags are set opposite to what I expect. Is that code below correct?
I think so.
Quoted 1 line
/* inform AP that we are awake again, unless power save is enabled */
When we return from scanning, we're awake, but the AP thinks we're asleep.
Quoted 6 lines
static void
ieee80211_offchannel_ps_disable(struct ieee80211_sub_if_data *sdata){ struct ieee80211_local *local = sdata->local; if (!local->ps_sdata) ieee80211_send_nullfunc(local, sdata, 0);
So in the case we shouldn't go to sleep we just tell the AP that we woke up again.
Quoted 7 lines
else if (
local->offchannel_ps_enabled) {
/*
* In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware
* will send a nullfunc frame with the powersave bit set
* even though the AP already knows that we are sleeping.
* This could be avoided by sending a null frame with power
* save bit disabled before enabling the power save, but
Quoted 8 lines
* this doesn't gain anything.
*
* WhenIEEE80211_HW_PS_NULLFUNC_STACKis enabled, no need
* to send a nullfunc frame because AP already knows that
* we are sleeping, let's just enable power save mode in
* hardware.
*/
local->hw.conf.flags|=IEEE80211_CONF_PS;
And in the other case we really go to sleep.
johannes
johannes
Quoted 14 lines · Johannes Berg
Quoted 11 lines · Ben Greear
Quoted 3 lines
Based on the powersave comments I had earlier, maybe we should remove that bit for now? Work items here require powersave is disabled, but we won't do that right now if we're on the same channel.
The problem is, if we leave the
work_work()in the original manner, the on/off channel state changes are not properly tracked because work blindly assumes it goes off/on channel. This breaks assumptions about when we must call the return-to-channel logic. I think if we do not religiously track the on/off channel state changes it would be too easy to get in a state where we think we are on-channel but haven't actually re-enabled xmit queues, etc.
Quoted 2 lines
But if we pretend all work is off-channel, won't it be OK to return from off-channel, even if it isn't really another channel?
That should be fine unless a scan can run in conjunction with work. Then, it could confuse scan's idea of whether it is off or on channel.
Seems they are currently mutually-exclusive, so I guess it doesn't matter currently.
I'll take a look at what it would take to do the power-save stuff and we can then decide if it should be broken into separate patches...
Quoted 10 lines
Quoted 2 lines
I think I would rather change the work logic to expressly disable/enable powersave. That wouldn't be difficult, would it?
Probably not -- but the code you modified regarding powersave probably needs adjustment then.
Quoted 4 lines
I don't think it does anything if we are scanning on-channel with my patch.
The enable/disable logic is now in the offchannel code...
Quoted 5 lines
Quoted 2 lines
Do we need to disable it if we are scanning on channel? If so, I can add that explicitly to the scanning code.
Yes, I think we do need to do that, since otherwise we won't actually receive any beacons other than from our own AP.
I'm seeing multiple APs reported in my testing. Receiving all beacons seems to be related to setting the filter properly. I'm using ath9k though...maybe other nics behave differently about this?
Or maybe my NIC is so busy it never goes to power-save anyway?
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 7 lines · Ben Greear
Quoted 2 lines
But if we pretend all work is off-channel, won't it be OK to return from off-channel, even if it isn't really another channel?
That should be fine unless a scan can run in conjunction with work. Then, it could confuse scan's idea of whether it is off or on channel.
Quoted 6 lines
Seems they are currently mutually-exclusive, so I guess it doesn't matter currently.
I'll take a look at what it would take to do the power-save stuff and we can then decide if it should be broken into separate patches...
Ok, thanks.
Quoted 5 lines
I'm seeing multiple APs reported in my testing. Receiving all beacons seems to be related to setting the filter properly. I'm using ath9k though...maybe other nics behave differently about this?
Or maybe my NIC is so busy it never goes to power-save anyway?
ath9k doesn't enable PS by default -- you'd have to enable it with iwconfig or iw.
johannes
Quoted 10 lines · Johannes Berg
Quoted 2 lines · On Wed, 2011-02-02 at 10:18 -0800, [email protected] wrote:
* Do no blindly go off/on channel in
work.cInstead, only call appropriate on/off code when we really need to change channels.Based on the powersave comments I had earlier, maybe we should remove that bit for now? Work items here require powersave is disabled, but we won't do that right now if we're on the same channel.
Scan, on the other hand, will still disable powersave (right?)
With regard to scanning and power-save: If we are scanning on channel, I think we should still be able to receive normal traffic.
The offchannel_ps_enable has this comment:
/*
* inform AP that we will go to sleep so that it will buffer the frames
* while we scan
*/
static void ieee80211_offchannel_ps_enable(struct ieee80211_sub_if_data *sdata)
So, do we really need to call this method for on-channel scanning?
My naive assumption is that we would actually want the NIC to disable it's local power-save logic while we are scanning so that it doesn't get sleepy and miss beacons?
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 24 lines · Ben Greear
Quoted 10 lines · Johannes Berg
Quoted 2 lines · On Wed, 2011-02-02 at 10:18 -0800, [email protected] wrote:
* Do no blindly go off/on channel in
work.cInstead, only call appropriate on/off code when we really need to change channels.Based on the powersave comments I had earlier, maybe we should remove that bit for now? Work items here require powersave is disabled, but we won't do that right now if we're on the same channel.
Scan, on the other hand, will still disable powersave (right?)
With regard to scanning and power-save: If we are scanning on channel, I think we should still be able to receive normal traffic.
The
offchannel_ps_enablehas this comment:/*
* inform AP that we will go to sleep so that it will buffer the frames
* while we scan
*/
static voidieee80211_offchannel_ps_enable(struct ieee80211_sub_if_data *sdata)
Quoted 5 lines
So, do we really need to call this method for on-channel scanning?
My naive assumption is that we would actually want the NIC to disable it's local power-save logic while we are scanning so that it doesn't get sleepy and miss beacons?
Right. We don't need this for on-channel stuff. But we do need to disable PS for on-channel stuff as you point out.
johannes