wl1251: add powersave exit logic for transfers
[pandora-kernel.git] / drivers / net / wireless / wl1251 / main.c
index 5924cc6..e6a1475 100644 (file)
@@ -376,6 +376,8 @@ static int wl1251_join(struct wl1251 *wl, u8 bss_type, u8 channel,
        if (ret < 0)
                wl1251_warning("join timeout");
 
+       wl1251_no_ps_event(wl);
+
 out:
        return ret;
 }
@@ -510,6 +512,7 @@ static void wl1251_op_stop(struct ieee80211_hw *hw)
        wl->channel = WL1251_DEFAULT_CHANNEL;
        wl->monitor_present = false;
        wl->joined = false;
+       wl->long_doze_mode_set = false;
 
        wl1251_debugfs_reset(wl);
 
@@ -651,8 +654,9 @@ static void wl1251_ps_work(struct work_struct *work)
                }
        }
 
-       need_ps = wl->psm_requested && !wl->bss_lost;
        have_ps = wl->station_mode == STATION_POWER_SAVE_MODE;
+       need_ps = wl->psm_requested && !wl->bss_lost
+               && wl->rate < wl->ps_rate_threshold;
 
        if (need_ps == have_ps) {
                //wl1251_info("ps: already in mode %d", have_ps);
@@ -663,11 +667,13 @@ static void wl1251_ps_work(struct work_struct *work)
        if (need_ps) {
                wait = 0;
 
-               diff = jiffies - wl->last_io_jiffies;
-               if (diff < msecs_to_jiffies(150)) {
-                       //wl1251_info("ps: postponed psm, j %ld", diff);
-                       wait = msecs_to_jiffies(150) - diff + 1;
-               }
+               diff = jiffies - wl->last_no_ps_jiffies[1];
+               if (diff < msecs_to_jiffies(1000))
+                       wait = msecs_to_jiffies(1000) - diff + 1;
+
+               diff = jiffies - wl->last_no_ps_jiffies[0];
+               if (diff < msecs_to_jiffies(3000))
+                       wait += msecs_to_jiffies(1000);
 
                for (i = 0; i < ARRAY_SIZE(wl->tx_frames); i++) {
                        if (wl->tx_frames[i] != NULL) {
@@ -697,8 +703,7 @@ static void wl1251_ps_work(struct work_struct *work)
        if (ret < 0)
                goto out_sleep;
 
-       //wl1251_info("psm %d, j %ld, d %ld", need_ps,
-       //      jiffies - wl->last_io_jiffies);
+       // wl1251_info("psm %d, r %u", need_ps, wl->rate);
 
 out_sleep:
        wl1251_ps_elp_sleep(wl);
@@ -820,16 +825,6 @@ static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
                wl->power_level = conf->power_level;
        }
 
-       /*
-        * Tell stack that connection is lost because hw encryption isn't
-        * supported in monitor mode.
-        * This requires temporary enabling of the hw connection monitor flag
-        */
-       if ((changed & IEEE80211_CONF_CHANGE_MONITOR) && wl->vif) {
-               wl->hw->flags |= IEEE80211_HW_CONNECTION_MONITOR;
-               ieee80211_connection_loss(wl->vif);
-       }
-
 out_sleep:
        wl1251_ps_elp_sleep(wl);
 
@@ -1239,9 +1234,6 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
        }
 
        if (changed & BSS_CHANGED_ASSOC) {
-               /* Disable temporary enabled hw connection monitor flag */
-               wl->hw->flags &= ~IEEE80211_HW_CONNECTION_MONITOR;
-
                if (bss_conf->assoc) {
                        wl->beacon_int = bss_conf->beacon_int;
 
@@ -1613,6 +1605,7 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 
        wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
                IEEE80211_HW_SUPPORTS_PS |
+               IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
                IEEE80211_HW_BEACON_FILTER |
                IEEE80211_HW_SUPPORTS_UAPSD |
                IEEE80211_HW_SUPPORTS_CQM_RSSI;
@@ -1689,6 +1682,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
        wl->beacon_int = WL1251_DEFAULT_BEACON_INT;
        wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD;
        wl->vif = NULL;
+       wl->ps_rate_threshold = 100000;
 
        for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
                wl->tx_frames[i] = NULL;