Commit f7ad1eed authored by David Gnedt's avatar David Gnedt Committed by John W. Linville

wl1251: retry power save entry

Port of the power save entry retry code from wl1251 driver version included
in the Maemo Fremantle kernel.
This tries to enable power save mode up to 3 times before failing.
Signed-off-by: default avatarDavid Gnedt <david.gnedt@davizone.at>
Signed-off-by: default avatarPali Rohár <pali.rohar@gmail.com>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 64322e28
...@@ -299,7 +299,8 @@ int wl1251_boot_run_firmware(struct wl1251 *wl) ...@@ -299,7 +299,8 @@ int wl1251_boot_run_firmware(struct wl1251 *wl)
ROAMING_TRIGGER_LOW_RSSI_EVENT_ID | ROAMING_TRIGGER_LOW_RSSI_EVENT_ID |
ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID | ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID |
REGAINED_BSS_EVENT_ID | BT_PTA_SENSE_EVENT_ID | REGAINED_BSS_EVENT_ID | BT_PTA_SENSE_EVENT_ID |
BT_PTA_PREDICTION_EVENT_ID | JOIN_EVENT_COMPLETE_ID; BT_PTA_PREDICTION_EVENT_ID | JOIN_EVENT_COMPLETE_ID |
PS_REPORT_EVENT_ID;
ret = wl1251_event_unmask(wl); ret = wl1251_event_unmask(wl);
if (ret < 0) { if (ret < 0) {
......
...@@ -46,6 +46,43 @@ static int wl1251_event_scan_complete(struct wl1251 *wl, ...@@ -46,6 +46,43 @@ static int wl1251_event_scan_complete(struct wl1251 *wl,
return ret; return ret;
} }
#define WL1251_PSM_ENTRY_RETRIES 3
static int wl1251_event_ps_report(struct wl1251 *wl,
struct event_mailbox *mbox)
{
int ret = 0;
wl1251_debug(DEBUG_EVENT, "ps status: %x", mbox->ps_status);
switch (mbox->ps_status) {
case EVENT_ENTER_POWER_SAVE_FAIL:
wl1251_debug(DEBUG_PSM, "PSM entry failed");
if (wl->station_mode != STATION_POWER_SAVE_MODE) {
/* remain in active mode */
wl->psm_entry_retry = 0;
break;
}
if (wl->psm_entry_retry < WL1251_PSM_ENTRY_RETRIES) {
wl->psm_entry_retry++;
ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
} else {
wl1251_error("Power save entry failed, giving up");
wl->psm_entry_retry = 0;
}
break;
case EVENT_ENTER_POWER_SAVE_SUCCESS:
case EVENT_EXIT_POWER_SAVE_FAIL:
case EVENT_EXIT_POWER_SAVE_SUCCESS:
default:
wl->psm_entry_retry = 0;
break;
}
return 0;
}
static void wl1251_event_mbox_dump(struct event_mailbox *mbox) static void wl1251_event_mbox_dump(struct event_mailbox *mbox)
{ {
wl1251_debug(DEBUG_EVENT, "MBOX DUMP:"); wl1251_debug(DEBUG_EVENT, "MBOX DUMP:");
...@@ -80,6 +117,13 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox) ...@@ -80,6 +117,13 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
} }
} }
if (vector & PS_REPORT_EVENT_ID) {
wl1251_debug(DEBUG_EVENT, "PS_REPORT_EVENT");
ret = wl1251_event_ps_report(wl, mbox);
if (ret < 0)
return ret;
}
if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID) { if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID) {
wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT"); wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT");
......
...@@ -112,6 +112,13 @@ struct event_mailbox { ...@@ -112,6 +112,13 @@ struct event_mailbox {
u8 padding[19]; u8 padding[19];
} __packed; } __packed;
enum {
EVENT_ENTER_POWER_SAVE_FAIL = 0,
EVENT_ENTER_POWER_SAVE_SUCCESS,
EVENT_EXIT_POWER_SAVE_FAIL,
EVENT_EXIT_POWER_SAVE_SUCCESS,
};
int wl1251_event_unmask(struct wl1251 *wl); int wl1251_event_unmask(struct wl1251 *wl);
void wl1251_event_mbox_config(struct wl1251 *wl); void wl1251_event_mbox_config(struct wl1251 *wl);
int wl1251_event_handle(struct wl1251 *wl, u8 mbox); int wl1251_event_handle(struct wl1251 *wl, u8 mbox);
......
...@@ -479,6 +479,7 @@ static void wl1251_op_stop(struct ieee80211_hw *hw) ...@@ -479,6 +479,7 @@ static void wl1251_op_stop(struct ieee80211_hw *hw)
wl->next_tx_complete = 0; wl->next_tx_complete = 0;
wl->elp = false; wl->elp = false;
wl->station_mode = STATION_ACTIVE_MODE; wl->station_mode = STATION_ACTIVE_MODE;
wl->psm_entry_retry = 0;
wl->tx_queue_stopped = false; wl->tx_queue_stopped = false;
wl->power_level = WL1251_DEFAULT_POWER_LEVEL; wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
wl->rssi_thold = 0; wl->rssi_thold = 0;
...@@ -1414,6 +1415,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void) ...@@ -1414,6 +1415,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
wl->elp = false; wl->elp = false;
wl->station_mode = STATION_ACTIVE_MODE; wl->station_mode = STATION_ACTIVE_MODE;
wl->psm_requested = false; wl->psm_requested = false;
wl->psm_entry_retry = 0;
wl->tx_queue_stopped = false; wl->tx_queue_stopped = false;
wl->power_level = WL1251_DEFAULT_POWER_LEVEL; wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
wl->rssi_thold = 0; wl->rssi_thold = 0;
......
...@@ -368,6 +368,9 @@ struct wl1251 { ...@@ -368,6 +368,9 @@ struct wl1251 {
/* PSM mode requested */ /* PSM mode requested */
bool psm_requested; bool psm_requested;
/* retry counter for PSM entries */
u8 psm_entry_retry;
u16 beacon_int; u16 beacon_int;
u8 dtim_period; u8 dtim_period;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment