Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of wl1271 |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 Nokia Corporation |
| 5 | * |
| 6 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License |
| 10 | * version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | * 02110-1301 USA |
| 21 | * |
| 22 | */ |
| 23 | |
Shahar Levi | 00d2010 | 2010-11-08 11:20:10 +0000 | [diff] [blame] | 24 | #include "wl12xx.h" |
| 25 | #include "reg.h" |
| 26 | #include "io.h" |
| 27 | #include "event.h" |
| 28 | #include "ps.h" |
| 29 | #include "scan.h" |
Juuso Oikarinen | 66497dc | 2009-10-08 21:56:30 +0300 | [diff] [blame] | 30 | #include "wl12xx_80211.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 31 | |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 32 | void wl1271_pspoll_work(struct work_struct *work) |
| 33 | { |
| 34 | struct delayed_work *dwork; |
| 35 | struct wl1271 *wl; |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 36 | int ret; |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 37 | |
| 38 | dwork = container_of(work, struct delayed_work, work); |
| 39 | wl = container_of(dwork, struct wl1271, pspoll_work); |
| 40 | |
| 41 | wl1271_debug(DEBUG_EVENT, "pspoll work"); |
| 42 | |
| 43 | mutex_lock(&wl->mutex); |
| 44 | |
Juuso Oikarinen | 8c7f4f3 | 2010-09-21 06:23:29 +0200 | [diff] [blame] | 45 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 46 | goto out; |
| 47 | |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 48 | if (!test_and_clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags)) |
| 49 | goto out; |
| 50 | |
| 51 | if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) |
| 52 | goto out; |
| 53 | |
| 54 | /* |
| 55 | * if we end up here, then we were in powersave when the pspoll |
| 56 | * delivery failure occurred, and no-one changed state since, so |
| 57 | * we should go back to powersave. |
| 58 | */ |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 59 | ret = wl1271_ps_elp_wakeup(wl); |
| 60 | if (ret < 0) |
| 61 | goto out; |
| 62 | |
Juuso Oikarinen | 65cddbf | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 63 | wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, wl->basic_rate, true); |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 64 | |
Eliad Peller | c1b193e | 2011-03-23 22:22:15 +0200 | [diff] [blame] | 65 | wl1271_ps_elp_sleep(wl); |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 66 | out: |
| 67 | mutex_unlock(&wl->mutex); |
| 68 | }; |
| 69 | |
| 70 | static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl) |
| 71 | { |
| 72 | int delay = wl->conf.conn.ps_poll_recovery_period; |
| 73 | int ret; |
| 74 | |
| 75 | wl->ps_poll_failures++; |
| 76 | if (wl->ps_poll_failures == 1) |
| 77 | wl1271_info("AP with dysfunctional ps-poll, " |
| 78 | "trying to work around it."); |
| 79 | |
| 80 | /* force active mode receive data from the AP */ |
| 81 | if (test_bit(WL1271_FLAG_PSM, &wl->flags)) { |
Juuso Oikarinen | 65cddbf | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 82 | ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, |
| 83 | wl->basic_rate, true); |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 84 | if (ret < 0) |
| 85 | return; |
| 86 | set_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); |
| 87 | ieee80211_queue_delayed_work(wl->hw, &wl->pspoll_work, |
| 88 | msecs_to_jiffies(delay)); |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * If already in active mode, lets we should be getting data from |
| 93 | * the AP right away. If we enter PSM too fast after this, and data |
| 94 | * remains on the AP, we will get another event like this, and we'll |
| 95 | * go into active once more. |
| 96 | */ |
| 97 | } |
| 98 | |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 99 | static int wl1271_event_ps_report(struct wl1271 *wl, |
| 100 | struct event_mailbox *mbox, |
| 101 | bool *beacon_loss) |
| 102 | { |
| 103 | int ret = 0; |
Juuso Oikarinen | 65cddbf | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 104 | u32 total_retries = wl->conf.conn.psm_entry_retries; |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 105 | |
| 106 | wl1271_debug(DEBUG_EVENT, "ps_status: 0x%x", mbox->ps_status); |
| 107 | |
| 108 | switch (mbox->ps_status) { |
| 109 | case EVENT_ENTER_POWER_SAVE_FAIL: |
Juuso Oikarinen | d8c42c0 | 2010-02-18 13:25:36 +0200 | [diff] [blame] | 110 | wl1271_debug(DEBUG_PSM, "PSM entry failed"); |
| 111 | |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 112 | if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { |
Juuso Oikarinen | d8c42c0 | 2010-02-18 13:25:36 +0200 | [diff] [blame] | 113 | /* remain in active mode */ |
Juuso Oikarinen | 461fa13 | 2009-11-23 23:22:13 +0200 | [diff] [blame] | 114 | wl->psm_entry_retry = 0; |
| 115 | break; |
| 116 | } |
| 117 | |
Juuso Oikarinen | 65cddbf | 2010-08-24 06:28:03 +0300 | [diff] [blame] | 118 | if (wl->psm_entry_retry < total_retries) { |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 119 | wl->psm_entry_retry++; |
Juuso Oikarinen | d8c42c0 | 2010-02-18 13:25:36 +0200 | [diff] [blame] | 120 | ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, |
Juuso Oikarinen | 8eab7b4 | 2010-09-24 03:10:11 +0200 | [diff] [blame] | 121 | wl->basic_rate, true); |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 122 | } else { |
Juuso Oikarinen | 1a186a5 | 2010-04-01 11:38:23 +0300 | [diff] [blame] | 123 | wl1271_info("No ack to nullfunc from AP."); |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 124 | wl->psm_entry_retry = 0; |
Juuso Oikarinen | d60772f | 2010-03-26 12:53:29 +0200 | [diff] [blame] | 125 | *beacon_loss = true; |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 126 | } |
| 127 | break; |
| 128 | case EVENT_ENTER_POWER_SAVE_SUCCESS: |
| 129 | wl->psm_entry_retry = 0; |
Juuso Oikarinen | d8c42c0 | 2010-02-18 13:25:36 +0200 | [diff] [blame] | 130 | |
| 131 | /* enable beacon filtering */ |
| 132 | ret = wl1271_acx_beacon_filter_opt(wl, true); |
| 133 | if (ret < 0) |
| 134 | break; |
| 135 | |
Shahar Levi | 0e44eb2 | 2011-05-16 15:35:30 +0300 | [diff] [blame] | 136 | /* |
| 137 | * BET has only a minor effect in 5GHz and masks |
| 138 | * channel switch IEs, so we only enable BET on 2.4GHz |
| 139 | */ |
| 140 | if (wl->band == IEEE80211_BAND_2GHZ) |
| 141 | /* enable beacon early termination */ |
| 142 | ret = wl1271_acx_bet_enable(wl, true); |
Eliad Peller | 9439064 | 2011-05-13 11:57:13 +0300 | [diff] [blame] | 143 | |
| 144 | if (wl->ps_compl) { |
| 145 | complete(wl->ps_compl); |
| 146 | wl->ps_compl = NULL; |
| 147 | } |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 148 | break; |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 149 | default: |
| 150 | break; |
| 151 | } |
| 152 | |
| 153 | return ret; |
| 154 | } |
| 155 | |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 156 | static void wl1271_event_rssi_trigger(struct wl1271 *wl, |
| 157 | struct event_mailbox *mbox) |
| 158 | { |
| 159 | enum nl80211_cqm_rssi_threshold_event event; |
| 160 | s8 metric = mbox->rssi_snr_trigger_metric[0]; |
| 161 | |
| 162 | wl1271_debug(DEBUG_EVENT, "RSSI trigger metric: %d", metric); |
| 163 | |
| 164 | if (metric <= wl->rssi_thold) |
| 165 | event = NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW; |
| 166 | else |
| 167 | event = NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH; |
| 168 | |
| 169 | if (event != wl->last_rssi_event) |
| 170 | ieee80211_cqm_rssi_notify(wl->vif, event, GFP_KERNEL); |
| 171 | wl->last_rssi_event = event; |
| 172 | } |
| 173 | |
Shahar Levi | 70559a0 | 2011-05-22 16:10:22 +0300 | [diff] [blame] | 174 | static void wl1271_stop_ba_event(struct wl1271 *wl, u8 ba_allowed) |
| 175 | { |
| 176 | /* Convert the value to bool */ |
| 177 | wl->ba_allowed = !!ba_allowed; |
| 178 | |
| 179 | /* |
| 180 | * Return in case: |
| 181 | * there are not BA open or the event indication is to allowed BA |
| 182 | */ |
| 183 | if ((!wl->ba_rx_bitmap) || (wl->ba_allowed)) |
| 184 | return; |
| 185 | |
| 186 | ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, wl->bssid); |
| 187 | } |
| 188 | |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 189 | static void wl12xx_event_soft_gemini_sense(struct wl1271 *wl, |
| 190 | u8 enable) |
| 191 | { |
| 192 | if (enable) { |
| 193 | /* disable dynamic PS when requested by the firmware */ |
| 194 | ieee80211_disable_dyn_ps(wl->vif); |
| 195 | set_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); |
| 196 | } else { |
| 197 | ieee80211_enable_dyn_ps(wl->vif); |
| 198 | clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); |
| 199 | wl1271_recalc_rx_streaming(wl); |
| 200 | } |
| 201 | |
| 202 | } |
| 203 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 204 | static void wl1271_event_mbox_dump(struct event_mailbox *mbox) |
| 205 | { |
| 206 | wl1271_debug(DEBUG_EVENT, "MBOX DUMP:"); |
| 207 | wl1271_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector); |
| 208 | wl1271_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask); |
| 209 | } |
| 210 | |
| 211 | static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) |
| 212 | { |
| 213 | int ret; |
| 214 | u32 vector; |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 215 | bool beacon_loss = false; |
Arik Nemtsov | 203c903 | 2010-10-25 11:17:44 +0200 | [diff] [blame] | 216 | bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); |
Arik Nemtsov | 3618f30 | 2011-06-26 10:36:03 +0300 | [diff] [blame^] | 217 | bool disconnect_sta = false; |
| 218 | unsigned long sta_bitmap = 0; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 219 | |
| 220 | wl1271_event_mbox_dump(mbox); |
| 221 | |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 222 | vector = le32_to_cpu(mbox->events_vector); |
| 223 | vector &= ~(le32_to_cpu(mbox->events_mask)); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 224 | wl1271_debug(DEBUG_EVENT, "vector: 0x%x", vector); |
| 225 | |
| 226 | if (vector & SCAN_COMPLETE_EVENT_ID) { |
Luciano Coelho | 34dd2aa | 2010-07-08 17:50:06 +0300 | [diff] [blame] | 227 | wl1271_debug(DEBUG_EVENT, "status: 0x%x", |
| 228 | mbox->scheduled_scan_status); |
| 229 | |
Luciano Coelho | 08688d6 | 2010-07-08 17:50:07 +0300 | [diff] [blame] | 230 | wl1271_scan_stm(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 231 | } |
| 232 | |
Luciano Coelho | 6394c01 | 2011-05-10 14:28:27 +0300 | [diff] [blame] | 233 | if (vector & PERIODIC_SCAN_REPORT_EVENT_ID) { |
| 234 | wl1271_debug(DEBUG_EVENT, "PERIODIC_SCAN_REPORT_EVENT " |
| 235 | "(status 0x%0x)", mbox->scheduled_scan_status); |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 236 | |
| 237 | wl1271_scan_sched_scan_results(wl); |
Luciano Coelho | 6394c01 | 2011-05-10 14:28:27 +0300 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | if (vector & PERIODIC_SCAN_COMPLETE_EVENT_ID) { |
| 241 | wl1271_debug(DEBUG_EVENT, "PERIODIC_SCAN_COMPLETE_EVENT " |
| 242 | "(status 0x%0x)", mbox->scheduled_scan_status); |
Luciano Coelho | 33c2c06 | 2011-05-10 14:46:02 +0300 | [diff] [blame] | 243 | if (wl->sched_scanning) { |
| 244 | wl1271_scan_sched_scan_stop(wl); |
| 245 | ieee80211_sched_scan_stopped(wl->hw); |
| 246 | } |
Luciano Coelho | 6394c01 | 2011-05-10 14:28:27 +0300 | [diff] [blame] | 247 | } |
| 248 | |
Juuso Oikarinen | 8d2ef7b | 2010-07-08 17:50:03 +0300 | [diff] [blame] | 249 | if (vector & SOFT_GEMINI_SENSE_EVENT_ID && |
Eliad Peller | 77ddaa1 | 2011-05-15 11:10:29 +0300 | [diff] [blame] | 250 | wl->bss_type == BSS_TYPE_STA_BSS) |
| 251 | wl12xx_event_soft_gemini_sense(wl, |
| 252 | mbox->soft_gemini_sense_info); |
Juuso Oikarinen | 8d2ef7b | 2010-07-08 17:50:03 +0300 | [diff] [blame] | 253 | |
Juuso Oikarinen | b771eee | 2009-10-08 21:56:34 +0300 | [diff] [blame] | 254 | /* |
| 255 | * The BSS_LOSE_EVENT_ID is only needed while psm (and hence beacon |
| 256 | * filtering) is enabled. Without PSM, the stack will receive all |
| 257 | * beacons and can detect beacon loss by itself. |
Teemu Paasikivi | 64e29e44 | 2010-03-26 12:53:26 +0200 | [diff] [blame] | 258 | * |
| 259 | * As there's possibility that the driver disables PSM before receiving |
| 260 | * BSS_LOSE_EVENT, beacon loss has to be reported to the stack. |
| 261 | * |
Juuso Oikarinen | b771eee | 2009-10-08 21:56:34 +0300 | [diff] [blame] | 262 | */ |
Arik Nemtsov | 203c903 | 2010-10-25 11:17:44 +0200 | [diff] [blame] | 263 | if ((vector & BSS_LOSE_EVENT_ID) && !is_ap) { |
Juuso Oikarinen | 1a186a5 | 2010-04-01 11:38:23 +0300 | [diff] [blame] | 264 | wl1271_info("Beacon loss detected."); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 265 | |
Juuso Oikarinen | b771eee | 2009-10-08 21:56:34 +0300 | [diff] [blame] | 266 | /* indicate to the stack, that beacons have been lost */ |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 267 | beacon_loss = true; |
| 268 | } |
| 269 | |
Arik Nemtsov | 203c903 | 2010-10-25 11:17:44 +0200 | [diff] [blame] | 270 | if ((vector & PS_REPORT_EVENT_ID) && !is_ap) { |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 271 | wl1271_debug(DEBUG_EVENT, "PS_REPORT_EVENT"); |
| 272 | ret = wl1271_event_ps_report(wl, mbox, &beacon_loss); |
| 273 | if (ret < 0) |
| 274 | return ret; |
| 275 | } |
| 276 | |
Arik Nemtsov | 203c903 | 2010-10-25 11:17:44 +0200 | [diff] [blame] | 277 | if ((vector & PSPOLL_DELIVERY_FAILURE_EVENT_ID) && !is_ap) |
Juuso Oikarinen | 90494a9 | 2010-07-08 17:50:00 +0300 | [diff] [blame] | 278 | wl1271_event_pspoll_delivery_fail(wl); |
| 279 | |
Juuso Oikarinen | 00236aed | 2010-04-09 11:07:30 +0300 | [diff] [blame] | 280 | if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) { |
| 281 | wl1271_debug(DEBUG_EVENT, "RSSI_SNR_TRIGGER_0_EVENT"); |
| 282 | if (wl->vif) |
| 283 | wl1271_event_rssi_trigger(wl, mbox); |
| 284 | } |
| 285 | |
Shahar Levi | 70559a0 | 2011-05-22 16:10:22 +0300 | [diff] [blame] | 286 | if ((vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID) && !is_ap) { |
| 287 | wl1271_debug(DEBUG_EVENT, "BA_SESSION_RX_CONSTRAINT_EVENT_ID. " |
| 288 | "ba_allowed = 0x%x", mbox->ba_allowed); |
| 289 | |
| 290 | if (wl->vif) |
| 291 | wl1271_stop_ba_event(wl, mbox->ba_allowed); |
| 292 | } |
| 293 | |
Shahar Levi | ae47c45 | 2011-03-06 16:32:14 +0200 | [diff] [blame] | 294 | if ((vector & DUMMY_PACKET_EVENT_ID) && !is_ap) { |
| 295 | wl1271_debug(DEBUG_EVENT, "DUMMY_PACKET_ID_EVENT_ID"); |
| 296 | if (wl->vif) |
| 297 | wl1271_tx_dummy_packet(wl); |
| 298 | } |
| 299 | |
Arik Nemtsov | 3618f30 | 2011-06-26 10:36:03 +0300 | [diff] [blame^] | 300 | /* |
| 301 | * "TX retries exceeded" has a different meaning according to mode. |
| 302 | * In AP mode the offending station is disconnected. |
| 303 | */ |
| 304 | if ((vector & MAX_TX_RETRY_EVENT_ID) && is_ap) { |
| 305 | wl1271_debug(DEBUG_EVENT, "MAX_TX_RETRY_EVENT_ID"); |
| 306 | sta_bitmap |= le16_to_cpu(mbox->sta_tx_retry_exceeded); |
| 307 | disconnect_sta = true; |
| 308 | } |
| 309 | |
| 310 | if ((vector & INACTIVE_STA_EVENT_ID) && is_ap) { |
| 311 | wl1271_debug(DEBUG_EVENT, "INACTIVE_STA_EVENT_ID"); |
| 312 | sta_bitmap |= le16_to_cpu(mbox->sta_aging_status); |
| 313 | disconnect_sta = true; |
| 314 | } |
| 315 | |
| 316 | if (is_ap && disconnect_sta) { |
| 317 | u32 num_packets = wl->conf.tx.max_tx_retries; |
| 318 | struct ieee80211_sta *sta; |
| 319 | const u8 *addr; |
| 320 | int h; |
| 321 | |
| 322 | for (h = find_first_bit(&sta_bitmap, AP_MAX_LINKS); |
| 323 | h < AP_MAX_LINKS; |
| 324 | h = find_next_bit(&sta_bitmap, AP_MAX_LINKS, h+1)) { |
| 325 | if (!wl1271_is_active_sta(wl, h)) |
| 326 | continue; |
| 327 | |
| 328 | addr = wl->links[h].addr; |
| 329 | |
| 330 | rcu_read_lock(); |
| 331 | sta = ieee80211_find_sta(wl->vif, addr); |
| 332 | if (sta) { |
| 333 | wl1271_debug(DEBUG_EVENT, "remove sta %d", h); |
| 334 | ieee80211_report_low_ack(sta, num_packets); |
| 335 | } |
| 336 | rcu_read_unlock(); |
| 337 | } |
| 338 | } |
| 339 | |
Juuso Oikarinen | d60772f | 2010-03-26 12:53:29 +0200 | [diff] [blame] | 340 | if (wl->vif && beacon_loss) |
| 341 | ieee80211_connection_loss(wl->vif); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 342 | |
| 343 | return 0; |
| 344 | } |
| 345 | |
| 346 | int wl1271_event_unmask(struct wl1271 *wl) |
| 347 | { |
| 348 | int ret; |
| 349 | |
| 350 | ret = wl1271_acx_event_mbox_mask(wl, ~(wl->event_mask)); |
| 351 | if (ret < 0) |
| 352 | return ret; |
| 353 | |
| 354 | return 0; |
| 355 | } |
| 356 | |
| 357 | void wl1271_event_mbox_config(struct wl1271 *wl) |
| 358 | { |
Teemu Paasikivi | 7b048c5 | 2010-02-18 13:25:55 +0200 | [diff] [blame] | 359 | wl->mbox_ptr[0] = wl1271_read32(wl, REG_EVENT_MAILBOX_PTR); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 360 | wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox); |
| 361 | |
| 362 | wl1271_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x", |
| 363 | wl->mbox_ptr[0], wl->mbox_ptr[1]); |
| 364 | } |
| 365 | |
Juuso Oikarinen | 13f2dc5 | 2009-12-11 15:40:59 +0200 | [diff] [blame] | 366 | int wl1271_event_handle(struct wl1271 *wl, u8 mbox_num) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 367 | { |
| 368 | struct event_mailbox mbox; |
| 369 | int ret; |
| 370 | |
| 371 | wl1271_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num); |
| 372 | |
| 373 | if (mbox_num > 1) |
| 374 | return -EINVAL; |
| 375 | |
| 376 | /* first we read the mbox descriptor */ |
Teemu Paasikivi | 7b048c5 | 2010-02-18 13:25:55 +0200 | [diff] [blame] | 377 | wl1271_read(wl, wl->mbox_ptr[mbox_num], &mbox, |
| 378 | sizeof(struct event_mailbox), false); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 379 | |
| 380 | /* process the descriptor */ |
| 381 | ret = wl1271_event_process(wl, &mbox); |
| 382 | if (ret < 0) |
| 383 | return ret; |
| 384 | |
| 385 | /* then we let the firmware know it can go on...*/ |
Teemu Paasikivi | 7b048c5 | 2010-02-18 13:25:55 +0200 | [diff] [blame] | 386 | wl1271_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 387 | |
| 388 | return 0; |
| 389 | } |