mac80211: Fix dynamic power save for scanning.
authorVivek Natarajan <vnatarajan@atheros.com>
Wed, 16 Dec 2009 16:51:45 +0000 (11:51 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 18 Dec 2009 22:05:24 +0000 (14:05 -0800)
Upstream commit: 7c3f4bbedc241ddcd3abe1f419c356e625231da1

Not only ps_sdata but also IEEE80211_CONF_PS is to be considered
before restoring PS in scan_ps_disable(). For instance, when ps_sdata
is set but CONF_PS is not set just because the dynamic timer is still
running, a sw scan leads to setting of CONF_PS in scan_ps_disable
instead of restarting the dynamic PS timer.
Also for the above case, a null data frame is to be sent after
returning to operating channel which was not happening with the
current implementation. This patch fixes this too.

Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Reviewed-by: Kalle Valo <kalle.valo@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/mac80211/ieee80211_i.h
net/mac80211/scan.c

index 10d316e455de26424110df78364beb3cd12732b3..5a461641e94ee8cfbd6d9c7d82b2f7dcc1f235ea 100644 (file)
@@ -808,6 +808,7 @@ struct ieee80211_local {
        unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
 
        bool pspolling;
+       bool scan_ps_enabled;
        /*
         * PS can only be enabled when we have exactly one managed
         * interface (and monitors) in PS, this then points there.
index 736537fc03dd22fab81e5c1de9fe4c7e1dc89956..1a4190947970b45f3f945ce7ddafceeb91f3fad9 100644 (file)
@@ -196,7 +196,8 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
 static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata)
 {
        struct ieee80211_local *local = sdata->local;
-       bool ps = false;
+
+       local->scan_ps_enabled = false;
 
        /* FIXME: what to do when local->pspolling is true? */
 
@@ -204,12 +205,13 @@ static void ieee80211_scan_ps_enable(struct ieee80211_sub_if_data *sdata)
        cancel_work_sync(&local->dynamic_ps_enable_work);
 
        if (local->hw.conf.flags & IEEE80211_CONF_PS) {
-               ps = true;
+               local->scan_ps_enabled = true;
                local->hw.conf.flags &= ~IEEE80211_CONF_PS;
                ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
        }
 
-       if (!ps || !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+       if (!(local->scan_ps_enabled) ||
+           !(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
                /*
                 * If power save was enabled, no need to send a nullfunc
                 * frame because AP knows that we are sleeping. But if the
@@ -230,7 +232,7 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata)
 
        if (!local->ps_sdata)
                ieee80211_send_nullfunc(local, sdata, 0);
-       else {
+       else if (local->scan_ps_enabled) {
                /*
                 * In !IEEE80211_HW_PS_NULLFUNC_STACK case the hardware
                 * will send a nullfunc frame with the powersave bit set
@@ -246,6 +248,16 @@ static void ieee80211_scan_ps_disable(struct ieee80211_sub_if_data *sdata)
                 */
                local->hw.conf.flags |= IEEE80211_CONF_PS;
                ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
+       } else if (local->hw.conf.dynamic_ps_timeout > 0) {
+               /*
+                * If IEEE80211_CONF_PS was not set and the dynamic_ps_timer
+                * had been running before leaving the operating channel,
+                * restart the timer now and send a nullfunc frame to inform
+                * the AP that we are awake.
+                */
+               ieee80211_send_nullfunc(local, sdata, 0);
+               mod_timer(&local->dynamic_ps_timer, jiffies +
+                         msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout));
        }
 }