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 "ps.h" |
| 25 | #include "io.h" |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 26 | #include "tx.h" |
Luciano Coelho | 0f4e312 | 2011-10-07 11:02:42 +0300 | [diff] [blame] | 27 | #include "debug.h" |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 28 | |
| 29 | #define WL1271_WAKEUP_TIMEOUT 500 |
| 30 | |
Eliad Peller | 1ab0f21 | 2012-05-15 17:08:52 +0300 | [diff] [blame^] | 31 | #define ELP_ENTRY_DELAY 5 |
| 32 | |
Juuso Oikarinen | 37b70a8 | 2009-10-08 21:56:21 +0300 | [diff] [blame] | 33 | void wl1271_elp_work(struct work_struct *work) |
| 34 | { |
| 35 | struct delayed_work *dwork; |
| 36 | struct wl1271 *wl; |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 37 | struct wl12xx_vif *wlvif; |
Juuso Oikarinen | 37b70a8 | 2009-10-08 21:56:21 +0300 | [diff] [blame] | 38 | |
| 39 | dwork = container_of(work, struct delayed_work, work); |
| 40 | wl = container_of(dwork, struct wl1271, elp_work); |
| 41 | |
| 42 | wl1271_debug(DEBUG_PSM, "elp work"); |
| 43 | |
| 44 | mutex_lock(&wl->mutex); |
| 45 | |
Juuso Oikarinen | 8c7f4f3 | 2010-09-21 06:23:29 +0200 | [diff] [blame] | 46 | if (unlikely(wl->state == WL1271_STATE_OFF)) |
| 47 | goto out; |
| 48 | |
Eliad Peller | a665d6e | 2011-04-03 02:01:59 +0300 | [diff] [blame] | 49 | /* our work might have been already cancelled */ |
| 50 | if (unlikely(!test_bit(WL1271_FLAG_ELP_REQUESTED, &wl->flags))) |
| 51 | goto out; |
| 52 | |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 53 | if (test_bit(WL1271_FLAG_IN_ELP, &wl->flags)) |
Juuso Oikarinen | 37b70a8 | 2009-10-08 21:56:21 +0300 | [diff] [blame] | 54 | goto out; |
| 55 | |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 56 | wl12xx_for_each_wlvif(wl, wlvif) { |
Eliad Peller | a0c7b78 | 2011-12-18 20:25:41 +0200 | [diff] [blame] | 57 | if (wlvif->bss_type == BSS_TYPE_AP_BSS) |
| 58 | goto out; |
| 59 | |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 60 | if (!test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags) && |
Eliad Peller | a0c7b78 | 2011-12-18 20:25:41 +0200 | [diff] [blame] | 61 | test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 62 | goto out; |
| 63 | } |
| 64 | |
Juuso Oikarinen | 37b70a8 | 2009-10-08 21:56:21 +0300 | [diff] [blame] | 65 | wl1271_debug(DEBUG_PSM, "chip to elp"); |
Luciano Coelho | 0078213 | 2011-11-29 13:38:37 +0200 | [diff] [blame] | 66 | wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG, ELPCTRL_SLEEP); |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 67 | set_bit(WL1271_FLAG_IN_ELP, &wl->flags); |
Juuso Oikarinen | 37b70a8 | 2009-10-08 21:56:21 +0300 | [diff] [blame] | 68 | |
| 69 | out: |
| 70 | mutex_unlock(&wl->mutex); |
| 71 | } |
| 72 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 73 | /* Routines to toggle sleep mode while in ELP */ |
| 74 | void wl1271_ps_elp_sleep(struct wl1271 *wl) |
| 75 | { |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 76 | struct wl12xx_vif *wlvif; |
Eliad Peller | 1ab0f21 | 2012-05-15 17:08:52 +0300 | [diff] [blame^] | 77 | u32 timeout; |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 78 | |
Luciano Coelho | 441101f | 2011-11-30 15:07:20 +0200 | [diff] [blame] | 79 | if (wl->quirks & WLCORE_QUIRK_NO_ELP) |
| 80 | return; |
| 81 | |
Eliad Peller | a665d6e | 2011-04-03 02:01:59 +0300 | [diff] [blame] | 82 | /* we shouldn't get consecutive sleep requests */ |
| 83 | if (WARN_ON(test_and_set_bit(WL1271_FLAG_ELP_REQUESTED, &wl->flags))) |
| 84 | return; |
| 85 | |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 86 | wl12xx_for_each_wlvif(wl, wlvif) { |
Eliad Peller | a0c7b78 | 2011-12-18 20:25:41 +0200 | [diff] [blame] | 87 | if (wlvif->bss_type == BSS_TYPE_AP_BSS) |
| 88 | return; |
| 89 | |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 90 | if (!test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags) && |
Eliad Peller | a0c7b78 | 2011-12-18 20:25:41 +0200 | [diff] [blame] | 91 | test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) |
Eliad Peller | c29bb00 | 2011-10-10 10:13:03 +0200 | [diff] [blame] | 92 | return; |
| 93 | } |
Eliad Peller | a665d6e | 2011-04-03 02:01:59 +0300 | [diff] [blame] | 94 | |
Eliad Peller | 1ab0f21 | 2012-05-15 17:08:52 +0300 | [diff] [blame^] | 95 | if (wl->conf.conn.forced_ps) |
| 96 | timeout = ELP_ENTRY_DELAY; |
| 97 | else |
| 98 | timeout = wl->conf.conn.dynamic_ps_timeout; |
| 99 | |
Eliad Peller | a665d6e | 2011-04-03 02:01:59 +0300 | [diff] [blame] | 100 | ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, |
Eliad Peller | 1ab0f21 | 2012-05-15 17:08:52 +0300 | [diff] [blame^] | 101 | msecs_to_jiffies(timeout)); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 102 | } |
| 103 | |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 104 | int wl1271_ps_elp_wakeup(struct wl1271 *wl) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 105 | { |
| 106 | DECLARE_COMPLETION_ONSTACK(compl); |
| 107 | unsigned long flags; |
| 108 | int ret; |
| 109 | u32 start_time = jiffies; |
| 110 | bool pending = false; |
| 111 | |
Eliad Peller | a665d6e | 2011-04-03 02:01:59 +0300 | [diff] [blame] | 112 | /* |
| 113 | * we might try to wake up even if we didn't go to sleep |
| 114 | * before (e.g. on boot) |
| 115 | */ |
| 116 | if (!test_and_clear_bit(WL1271_FLAG_ELP_REQUESTED, &wl->flags)) |
| 117 | return 0; |
| 118 | |
| 119 | /* don't cancel_sync as it might contend for a mutex and deadlock */ |
| 120 | cancel_delayed_work(&wl->elp_work); |
| 121 | |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 122 | if (!test_bit(WL1271_FLAG_IN_ELP, &wl->flags)) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 123 | return 0; |
| 124 | |
| 125 | wl1271_debug(DEBUG_PSM, "waking up chip from elp"); |
| 126 | |
| 127 | /* |
| 128 | * The spinlock is required here to synchronize both the work and |
| 129 | * the completion variable in one entity. |
| 130 | */ |
| 131 | spin_lock_irqsave(&wl->wl_lock, flags); |
Ido Yariv | a620865 | 2011-03-01 15:14:41 +0200 | [diff] [blame] | 132 | if (test_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags)) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 133 | pending = true; |
| 134 | else |
| 135 | wl->elp_compl = &compl; |
| 136 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
| 137 | |
Luciano Coelho | 0078213 | 2011-11-29 13:38:37 +0200 | [diff] [blame] | 138 | wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG, ELPCTRL_WAKE_UP); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 139 | |
| 140 | if (!pending) { |
| 141 | ret = wait_for_completion_timeout( |
| 142 | &compl, msecs_to_jiffies(WL1271_WAKEUP_TIMEOUT)); |
| 143 | if (ret == 0) { |
| 144 | wl1271_error("ELP wakeup timeout!"); |
Ido Yariv | baacb9ae | 2011-06-06 14:57:05 +0300 | [diff] [blame] | 145 | wl12xx_queue_recovery_work(wl); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 146 | ret = -ETIMEDOUT; |
| 147 | goto err; |
| 148 | } else if (ret < 0) { |
| 149 | wl1271_error("ELP wakeup completion error."); |
| 150 | goto err; |
| 151 | } |
| 152 | } |
| 153 | |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 154 | clear_bit(WL1271_FLAG_IN_ELP, &wl->flags); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 155 | |
| 156 | wl1271_debug(DEBUG_PSM, "wakeup time: %u ms", |
| 157 | jiffies_to_msecs(jiffies - start_time)); |
| 158 | goto out; |
| 159 | |
| 160 | err: |
| 161 | spin_lock_irqsave(&wl->wl_lock, flags); |
| 162 | wl->elp_compl = NULL; |
| 163 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
| 164 | return ret; |
| 165 | |
| 166 | out: |
| 167 | return 0; |
| 168 | } |
| 169 | |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 170 | int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
Eyal Shapira | 248a001 | 2012-01-31 11:57:23 +0200 | [diff] [blame] | 171 | enum wl1271_cmd_ps_mode mode) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 172 | { |
| 173 | int ret; |
Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 174 | u16 timeout = wl->conf.conn.dynamic_ps_timeout; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 175 | |
| 176 | switch (mode) { |
Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 177 | case STATION_AUTO_PS_MODE: |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 178 | case STATION_POWER_SAVE_MODE: |
Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 179 | wl1271_debug(DEBUG_PSM, "entering psm (mode=%d,timeout=%u)", |
| 180 | mode, timeout); |
Juuso Oikarinen | 1922167 | 2009-10-08 21:56:35 +0300 | [diff] [blame] | 181 | |
Eyal Shapira | dae728f | 2012-02-02 12:03:39 +0200 | [diff] [blame] | 182 | ret = wl1271_acx_wake_up_conditions(wl, wlvif, |
| 183 | wl->conf.conn.wake_up_event, |
| 184 | wl->conf.conn.listen_interval); |
Juuso Oikarinen | 03f06b7 | 2010-08-10 06:38:36 +0200 | [diff] [blame] | 185 | if (ret < 0) { |
| 186 | wl1271_error("couldn't set wake up conditions"); |
| 187 | return ret; |
| 188 | } |
| 189 | |
Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 190 | ret = wl1271_cmd_ps_mode(wl, wlvif, mode, timeout); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 191 | if (ret < 0) |
| 192 | return ret; |
| 193 | |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 194 | set_bit(WLVIF_FLAG_IN_PS, &wlvif->flags); |
Eyal Shapira | ed471d3 | 2012-01-31 11:57:24 +0200 | [diff] [blame] | 195 | |
| 196 | /* enable beacon early termination. Not relevant for 5GHz */ |
| 197 | if (wlvif->band == IEEE80211_BAND_2GHZ) { |
| 198 | ret = wl1271_acx_bet_enable(wl, wlvif, true); |
| 199 | if (ret < 0) |
| 200 | return ret; |
| 201 | } |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 202 | break; |
| 203 | case STATION_ACTIVE_MODE: |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 204 | wl1271_debug(DEBUG_PSM, "leaving psm"); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 205 | |
Juuso Oikarinen | 11f70f9 | 2009-10-13 12:47:46 +0300 | [diff] [blame] | 206 | /* disable beacon early termination */ |
Eliad Peller | 1b92f15 | 2011-10-10 10:13:09 +0200 | [diff] [blame] | 207 | if (wlvif->band == IEEE80211_BAND_2GHZ) { |
Eliad Peller | 0603d89 | 2011-10-05 11:55:51 +0200 | [diff] [blame] | 208 | ret = wl1271_acx_bet_enable(wl, wlvif, false); |
Shahar Levi | 0e44eb2 | 2011-05-16 15:35:30 +0300 | [diff] [blame] | 209 | if (ret < 0) |
| 210 | return ret; |
| 211 | } |
Juuso Oikarinen | 11f70f9 | 2009-10-13 12:47:46 +0300 | [diff] [blame] | 212 | |
Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 213 | ret = wl1271_cmd_ps_mode(wl, wlvif, mode, 0); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 214 | if (ret < 0) |
| 215 | return ret; |
| 216 | |
Eyal Shapira | 5c0dc2f | 2012-02-02 19:06:45 +0200 | [diff] [blame] | 217 | clear_bit(WLVIF_FLAG_IN_PS, &wlvif->flags); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 218 | break; |
Eyal Shapira | f1d63a5 | 2012-01-31 11:57:21 +0200 | [diff] [blame] | 219 | default: |
| 220 | wl1271_warning("trying to set ps to unsupported mode %d", mode); |
| 221 | ret = -EINVAL; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | return ret; |
| 225 | } |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 226 | |
| 227 | static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid) |
| 228 | { |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 229 | int i; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 230 | struct sk_buff *skb; |
| 231 | struct ieee80211_tx_info *info; |
| 232 | unsigned long flags; |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 233 | int filtered[NUM_TX_QUEUES]; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 234 | |
Arik Nemtsov | f8e0af6 | 2011-08-25 12:43:12 +0300 | [diff] [blame] | 235 | /* filter all frames currently in the low level queues for this hlid */ |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 236 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 237 | filtered[i] = 0; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 238 | while ((skb = skb_dequeue(&wl->links[hlid].tx_queue[i]))) { |
Arik Nemtsov | f8e0af6 | 2011-08-25 12:43:12 +0300 | [diff] [blame] | 239 | filtered[i]++; |
| 240 | |
| 241 | if (WARN_ON(wl12xx_is_dummy_packet(wl, skb))) |
| 242 | continue; |
| 243 | |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 244 | info = IEEE80211_SKB_CB(skb); |
| 245 | info->flags |= IEEE80211_TX_STAT_TX_FILTERED; |
| 246 | info->status.rates[0].idx = -1; |
Eliad Peller | c27d3ac | 2011-06-07 10:40:39 +0300 | [diff] [blame] | 247 | ieee80211_tx_status_ni(wl->hw, skb); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | |
| 251 | spin_lock_irqsave(&wl->wl_lock, flags); |
Arik Nemtsov | f1a4638 | 2011-07-07 14:25:23 +0300 | [diff] [blame] | 252 | for (i = 0; i < NUM_TX_QUEUES; i++) |
| 253 | wl->tx_queue_count[i] -= filtered[i]; |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 254 | spin_unlock_irqrestore(&wl->wl_lock, flags); |
| 255 | |
| 256 | wl1271_handle_tx_low_watermark(wl); |
| 257 | } |
| 258 | |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 259 | void wl12xx_ps_link_start(struct wl1271 *wl, struct wl12xx_vif *wlvif, |
| 260 | u8 hlid, bool clean_queues) |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 261 | { |
| 262 | struct ieee80211_sta *sta; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 263 | struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 264 | |
| 265 | if (test_bit(hlid, &wl->ap_ps_map)) |
| 266 | return; |
| 267 | |
Arik Nemtsov | 9b17f1b | 2011-08-14 13:17:35 +0300 | [diff] [blame] | 268 | wl1271_debug(DEBUG_PSM, "start mac80211 PSM on hlid %d pkts %d " |
| 269 | "clean_queues %d", hlid, wl->links[hlid].allocated_pkts, |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 270 | clean_queues); |
| 271 | |
| 272 | rcu_read_lock(); |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 273 | sta = ieee80211_find_sta(vif, wl->links[hlid].addr); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 274 | if (!sta) { |
| 275 | wl1271_error("could not find sta %pM for starting ps", |
| 276 | wl->links[hlid].addr); |
| 277 | rcu_read_unlock(); |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | ieee80211_sta_ps_transition_ni(sta, true); |
| 282 | rcu_read_unlock(); |
| 283 | |
| 284 | /* do we want to filter all frames from this link's queues? */ |
| 285 | if (clean_queues) |
| 286 | wl1271_ps_filter_frames(wl, hlid); |
| 287 | |
| 288 | __set_bit(hlid, &wl->ap_ps_map); |
| 289 | } |
| 290 | |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 291 | void wl12xx_ps_link_end(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 292 | { |
| 293 | struct ieee80211_sta *sta; |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 294 | struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 295 | |
| 296 | if (!test_bit(hlid, &wl->ap_ps_map)) |
| 297 | return; |
| 298 | |
| 299 | wl1271_debug(DEBUG_PSM, "end mac80211 PSM on hlid %d", hlid); |
| 300 | |
| 301 | __clear_bit(hlid, &wl->ap_ps_map); |
| 302 | |
| 303 | rcu_read_lock(); |
Eliad Peller | 6e8cd33 | 2011-10-10 10:13:13 +0200 | [diff] [blame] | 304 | sta = ieee80211_find_sta(vif, wl->links[hlid].addr); |
Arik Nemtsov | b622d99 | 2011-02-23 00:22:31 +0200 | [diff] [blame] | 305 | if (!sta) { |
| 306 | wl1271_error("could not find sta %pM for ending ps", |
| 307 | wl->links[hlid].addr); |
| 308 | goto end; |
| 309 | } |
| 310 | |
| 311 | ieee80211_sta_ps_transition_ni(sta, false); |
| 312 | end: |
| 313 | rcu_read_unlock(); |
| 314 | } |