blob: 436c7e0ae6b1276a38eb307d2cdfb3f118643e8d [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02008 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8ca151b2013-01-24 14:25:36 +01009 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020025 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010026 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020033 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8ca151b2013-01-24 14:25:36 +010034 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63
64#include <linux/kernel.h>
65#include <linux/module.h>
66#include <linux/slab.h>
Johannes Berg8ca151b2013-01-24 14:25:36 +010067
68#include <net/mac80211.h>
69
70#include "iwl-debug.h"
71#include "mvm.h"
72#include "iwl-modparams.h"
73#include "fw-api-power.h"
74
75#define POWER_KEEP_ALIVE_PERIOD_SEC 25
76
Alexander Bondare811ada2013-03-10 15:29:44 +020077int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm,
78 struct iwl_beacon_filter_cmd *cmd)
Alexander Bondar071d49902013-05-06 13:03:59 +030079{
80 int ret;
81
82 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_BEACON_FILTERING_CMD, CMD_SYNC,
83 sizeof(struct iwl_beacon_filter_cmd), cmd);
84
85 if (!ret) {
86 IWL_DEBUG_POWER(mvm, "ba_enable_beacon_abort is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +030087 le32_to_cpu(cmd->ba_enable_beacon_abort));
Alexander Bondar071d49902013-05-06 13:03:59 +030088 IWL_DEBUG_POWER(mvm, "ba_escape_timer is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +030089 le32_to_cpu(cmd->ba_escape_timer));
Alexander Bondar071d49902013-05-06 13:03:59 +030090 IWL_DEBUG_POWER(mvm, "bf_debug_flag is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +030091 le32_to_cpu(cmd->bf_debug_flag));
Alexander Bondar071d49902013-05-06 13:03:59 +030092 IWL_DEBUG_POWER(mvm, "bf_enable_beacon_filter is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +030093 le32_to_cpu(cmd->bf_enable_beacon_filter));
Alexander Bondar071d49902013-05-06 13:03:59 +030094 IWL_DEBUG_POWER(mvm, "bf_energy_delta is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +030095 le32_to_cpu(cmd->bf_energy_delta));
Alexander Bondar071d49902013-05-06 13:03:59 +030096 IWL_DEBUG_POWER(mvm, "bf_escape_timer is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +030097 le32_to_cpu(cmd->bf_escape_timer));
Alexander Bondar071d49902013-05-06 13:03:59 +030098 IWL_DEBUG_POWER(mvm, "bf_roaming_energy_delta is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +030099 le32_to_cpu(cmd->bf_roaming_energy_delta));
Alexander Bondar071d49902013-05-06 13:03:59 +0300100 IWL_DEBUG_POWER(mvm, "bf_roaming_state is: %d\n",
Hila Gonen5dca7c22013-07-16 11:15:35 +0300101 le32_to_cpu(cmd->bf_roaming_state));
102 IWL_DEBUG_POWER(mvm, "bf_temp_threshold is: %d\n",
103 le32_to_cpu(cmd->bf_temp_threshold));
104 IWL_DEBUG_POWER(mvm, "bf_temp_fast_filter is: %d\n",
105 le32_to_cpu(cmd->bf_temp_fast_filter));
106 IWL_DEBUG_POWER(mvm, "bf_temp_slow_filter is: %d\n",
107 le32_to_cpu(cmd->bf_temp_slow_filter));
Alexander Bondar071d49902013-05-06 13:03:59 +0300108 }
109 return ret;
110}
111
Andrei Otcheretianskia20fd392013-07-21 17:23:59 +0300112static
113void iwl_mvm_beacon_filter_set_cqm_params(struct iwl_mvm *mvm,
114 struct ieee80211_vif *vif,
115 struct iwl_beacon_filter_cmd *cmd)
116{
117 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
118
119 if (vif->bss_conf.cqm_rssi_thold) {
120 cmd->bf_energy_delta =
121 cpu_to_le32(vif->bss_conf.cqm_rssi_hyst);
122 /* fw uses an absolute value for this */
123 cmd->bf_roaming_state =
124 cpu_to_le32(-vif->bss_conf.cqm_rssi_thold);
125 }
126 cmd->ba_enable_beacon_abort = cpu_to_le32(mvmvif->bf_data.ba_enabled);
127}
128
Alexander Bondare811ada2013-03-10 15:29:44 +0200129int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm,
130 struct ieee80211_vif *vif, bool enable)
Alexander Bondar071d49902013-05-06 13:03:59 +0300131{
132 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
133 struct iwl_beacon_filter_cmd cmd = {
134 IWL_BF_CMD_CONFIG_DEFAULTS,
Hila Gonen5dca7c22013-07-16 11:15:35 +0300135 .bf_enable_beacon_filter = cpu_to_le32(1),
136 .ba_enable_beacon_abort = cpu_to_le32(enable),
Alexander Bondar071d49902013-05-06 13:03:59 +0300137 };
138
Andrei Otcheretianskia20fd392013-07-21 17:23:59 +0300139 if (!mvmvif->bf_data.bf_enabled)
Alexander Bondar071d49902013-05-06 13:03:59 +0300140 return 0;
141
Alexander Bondar84349252013-07-22 15:39:26 +0300142 if (mvm->cur_ucode == IWL_UCODE_WOWLAN)
143 cmd.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_D3);
144
Andrei Otcheretianskia20fd392013-07-21 17:23:59 +0300145 mvmvif->bf_data.ba_enabled = enable;
146 iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, &cmd);
Alexander Bondarb571a692013-05-21 14:49:09 +0300147 iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
Alexander Bondar071d49902013-05-06 13:03:59 +0300148 return iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
149}
150
Alexander Bondar3f0b2b32013-03-05 14:08:23 +0200151static void iwl_mvm_power_log(struct iwl_mvm *mvm,
Alexander Bondare811ada2013-03-10 15:29:44 +0200152 struct iwl_mac_power_cmd *cmd)
Alexander Bondar3f0b2b32013-03-05 14:08:23 +0200153{
154 IWL_DEBUG_POWER(mvm,
Alexander Bondare811ada2013-03-10 15:29:44 +0200155 "Sending power table command on mac id 0x%X for power level %d, flags = 0x%X\n",
156 cmd->id_and_color, iwlmvm_mod_params.power_scheme,
Alexander Bondar3f0b2b32013-03-05 14:08:23 +0200157 le16_to_cpu(cmd->flags));
Alexander Bondare811ada2013-03-10 15:29:44 +0200158 IWL_DEBUG_POWER(mvm, "Keep alive = %u sec\n",
159 le16_to_cpu(cmd->keep_alive_seconds));
Alexander Bondar3f0b2b32013-03-05 14:08:23 +0200160
Alexander Bondare3c588e2013-04-07 14:08:59 +0300161 if (!(cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK))) {
162 IWL_DEBUG_POWER(mvm, "Disable power management\n");
163 return;
164 }
165
166 IWL_DEBUG_POWER(mvm, "Rx timeout = %u usec\n",
167 le32_to_cpu(cmd->rx_data_timeout));
168 IWL_DEBUG_POWER(mvm, "Tx timeout = %u usec\n",
169 le32_to_cpu(cmd->tx_data_timeout));
170 if (cmd->flags & cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK))
171 IWL_DEBUG_POWER(mvm, "DTIM periods to skip = %u\n",
172 cmd->skip_dtim_periods);
173 if (cmd->flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
174 IWL_DEBUG_POWER(mvm, "LP RX RSSI threshold = %u\n",
175 cmd->lprx_rssi_threshold);
176 if (cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
177 IWL_DEBUG_POWER(mvm, "uAPSD enabled\n");
178 IWL_DEBUG_POWER(mvm, "Rx timeout (uAPSD) = %u usec\n",
179 le32_to_cpu(cmd->rx_data_timeout_uapsd));
180 IWL_DEBUG_POWER(mvm, "Tx timeout (uAPSD) = %u usec\n",
181 le32_to_cpu(cmd->tx_data_timeout_uapsd));
182 IWL_DEBUG_POWER(mvm, "QNDP TID = %d\n", cmd->qndp_tid);
183 IWL_DEBUG_POWER(mvm, "ACs flags = 0x%x\n", cmd->uapsd_ac_flags);
184 IWL_DEBUG_POWER(mvm, "Max SP = %d\n", cmd->uapsd_max_sp);
Alexander Bondar3f0b2b32013-03-05 14:08:23 +0200185 }
186}
187
Alexander Bondar175a70b2013-04-14 20:59:37 +0300188static void iwl_mvm_power_configure_uapsd(struct iwl_mvm *mvm,
189 struct ieee80211_vif *vif,
190 struct iwl_mac_power_cmd *cmd)
191{
192 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
193 enum ieee80211_ac_numbers ac;
194 bool tid_found = false;
195
196 for (ac = IEEE80211_AC_VO; ac <= IEEE80211_AC_BK; ac++) {
197 if (!mvmvif->queue_params[ac].uapsd)
198 continue;
199
200 if (mvm->cur_ucode != IWL_UCODE_WOWLAN)
201 cmd->flags |=
202 cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK);
203
204 cmd->uapsd_ac_flags |= BIT(ac);
205
206 /* QNDP TID - the highest TID with no admission control */
207 if (!tid_found && !mvmvif->queue_params[ac].acm) {
208 tid_found = true;
209 switch (ac) {
210 case IEEE80211_AC_VO:
211 cmd->qndp_tid = 6;
212 break;
213 case IEEE80211_AC_VI:
214 cmd->qndp_tid = 5;
215 break;
216 case IEEE80211_AC_BE:
217 cmd->qndp_tid = 0;
218 break;
219 case IEEE80211_AC_BK:
220 cmd->qndp_tid = 1;
221 break;
222 }
223 }
224 }
225
226 if (!(cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)))
227 return;
228
229 cmd->flags |= cpu_to_le16(POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK);
230
231 if (cmd->uapsd_ac_flags == (BIT(IEEE80211_AC_VO) |
232 BIT(IEEE80211_AC_VI) |
233 BIT(IEEE80211_AC_BE) |
234 BIT(IEEE80211_AC_BK))) {
235 cmd->flags |= cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
236 cmd->snooze_interval = cpu_to_le16(IWL_MVM_PS_SNOOZE_INTERVAL);
237 cmd->snooze_window = (mvm->cur_ucode == IWL_UCODE_WOWLAN) ?
238 cpu_to_le16(IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW) :
239 cpu_to_le16(IWL_MVM_PS_SNOOZE_WINDOW);
240 }
241
242 cmd->uapsd_max_sp = IWL_UAPSD_MAX_SP;
243
244 if (mvm->cur_ucode == IWL_UCODE_WOWLAN || cmd->flags &
245 cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
246 cmd->rx_data_timeout_uapsd =
247 cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT);
248 cmd->tx_data_timeout_uapsd =
249 cpu_to_le32(IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT);
250 } else {
251 cmd->rx_data_timeout_uapsd =
252 cpu_to_le32(IWL_MVM_UAPSD_RX_DATA_TIMEOUT);
253 cmd->tx_data_timeout_uapsd =
254 cpu_to_le32(IWL_MVM_UAPSD_TX_DATA_TIMEOUT);
255 }
256
257 if (cmd->flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
258 cmd->heavy_tx_thld_packets =
259 IWL_MVM_PS_SNOOZE_HEAVY_TX_THLD_PACKETS;
260 cmd->heavy_rx_thld_packets =
261 IWL_MVM_PS_SNOOZE_HEAVY_RX_THLD_PACKETS;
262 } else {
263 cmd->heavy_tx_thld_packets =
264 IWL_MVM_PS_HEAVY_TX_THLD_PACKETS;
265 cmd->heavy_rx_thld_packets =
266 IWL_MVM_PS_HEAVY_RX_THLD_PACKETS;
267 }
268 cmd->heavy_tx_thld_percentage =
269 IWL_MVM_PS_HEAVY_TX_THLD_PERCENT;
270 cmd->heavy_rx_thld_percentage =
271 IWL_MVM_PS_HEAVY_RX_THLD_PERCENT;
272}
273
Alexander Bondare811ada2013-03-10 15:29:44 +0200274static void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm,
275 struct ieee80211_vif *vif,
276 struct iwl_mac_power_cmd *cmd)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100277{
278 struct ieee80211_hw *hw = mvm->hw;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100279 struct ieee80211_chanctx_conf *chanctx_conf;
280 struct ieee80211_channel *chan;
281 int dtimper, dtimper_msec;
282 int keep_alive;
283 bool radar_detect = false;
Alexander Bondarb571a692013-05-21 14:49:09 +0300284 struct iwl_mvm_vif *mvmvif __maybe_unused =
285 iwl_mvm_vif_from_mac80211(vif);
Alexander Bondar51498cf2013-09-02 17:10:14 +0300286 bool allow_uapsd = true;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100287
Alexander Bondare811ada2013-03-10 15:29:44 +0200288 cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
289 mvmvif->color));
290 dtimper = hw->conf.ps_dtim_period ?: 1;
291
Alexander Bondare16cf7e2013-03-05 14:01:27 +0200292 /*
293 * Regardless of power management state the driver must set
294 * keep alive period. FW will use it for sending keep alive NDPs
Alexander Bondare811ada2013-03-10 15:29:44 +0200295 * immediately after association. Check that keep alive period
296 * is at least 3 * DTIM
Alexander Bondare16cf7e2013-03-05 14:01:27 +0200297 */
Alexander Bondare811ada2013-03-10 15:29:44 +0200298 dtimper_msec = dtimper * vif->bss_conf.beacon_int;
299 keep_alive = max_t(int, 3 * dtimper_msec,
300 MSEC_PER_SEC * POWER_KEEP_ALIVE_PERIOD_SEC);
301 keep_alive = DIV_ROUND_UP(keep_alive, MSEC_PER_SEC);
302 cmd->keep_alive_seconds = cpu_to_le16(keep_alive);
Alexander Bondare16cf7e2013-03-05 14:01:27 +0200303
Alexander Bondar92d85562013-10-23 11:50:34 +0200304 if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM ||
305 mvm->ps_prevented)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100306 return;
307
Alexander Bondar9a613042013-03-05 12:54:00 +0200308 cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK);
309
Alexander Bondarb571a692013-05-21 14:49:09 +0300310#ifdef CONFIG_IWLWIFI_DEBUGFS
311 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF &&
312 mvmvif->dbgfs_pm.disable_power_off)
313 cmd->flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK);
314#endif
Johannes Berge03f9bef2013-11-13 17:16:19 +0100315 if (!vif->bss_conf.ps || mvmvif->pm_prevented ||
316 iwl_mvm_vif_low_latency(mvmvif))
Alexander Bondar9a613042013-03-05 12:54:00 +0200317 return;
318
319 cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100320
Alexander Bondarbd4ace22013-03-21 17:14:14 +0200321 if (vif->bss_conf.beacon_rate &&
322 (vif->bss_conf.beacon_rate->bitrate == 10 ||
323 vif->bss_conf.beacon_rate->bitrate == 60)) {
324 cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK);
Alexander Bondare811ada2013-03-10 15:29:44 +0200325 cmd->lprx_rssi_threshold = POWER_LPRX_RSSI_THRESHOLD;
Alexander Bondarbd4ace22013-03-21 17:14:14 +0200326 }
327
Johannes Berg8ca151b2013-01-24 14:25:36 +0100328 /* Check if radar detection is required on current channel */
329 rcu_read_lock();
330 chanctx_conf = rcu_dereference(vif->chanctx_conf);
331 WARN_ON(!chanctx_conf);
332 if (chanctx_conf) {
333 chan = chanctx_conf->def.chan;
334 radar_detect = chan->flags & IEEE80211_CHAN_RADAR;
335 }
336 rcu_read_unlock();
337
338 /* Check skip over DTIM conditions */
339 if (!radar_detect && (dtimper <= 10) &&
Alexander Bondaree1e8422013-04-23 13:52:10 +0300340 (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_LP ||
341 mvm->cur_ucode == IWL_UCODE_WOWLAN)) {
Alexander Bondarf4a3e2f2013-03-05 13:47:04 +0200342 cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
Alexander Bondare811ada2013-03-10 15:29:44 +0200343 cmd->skip_dtim_periods = 3;
Alexander Bondar5b1dbfc2013-04-23 13:32:35 +0300344 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100345
Alexander Bondaree1e8422013-04-23 13:52:10 +0300346 if (mvm->cur_ucode != IWL_UCODE_WOWLAN) {
Johannes Berg99545922013-06-14 13:36:21 +0200347 cmd->rx_data_timeout =
348 cpu_to_le32(IWL_MVM_DEFAULT_PS_RX_DATA_TIMEOUT);
349 cmd->tx_data_timeout =
350 cpu_to_le32(IWL_MVM_DEFAULT_PS_TX_DATA_TIMEOUT);
Alexander Bondaree1e8422013-04-23 13:52:10 +0300351 } else {
Johannes Berg99545922013-06-14 13:36:21 +0200352 cmd->rx_data_timeout =
353 cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT);
354 cmd->tx_data_timeout =
355 cpu_to_le32(IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT);
Alexander Bondaree1e8422013-04-23 13:52:10 +0300356 }
Alexander Bondarb571a692013-05-21 14:49:09 +0300357
Alexander Bondar51498cf2013-09-02 17:10:14 +0300358 if (!memcmp(mvmvif->uapsd_misbehaving_bssid, vif->bss_conf.bssid,
359 ETH_ALEN))
360 allow_uapsd = false;
Alexander Bondar75209672013-11-12 14:47:59 +0200361
362 if (vif->p2p &&
363 !(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD))
364 allow_uapsd = false;
Alexander Bondar51498cf2013-09-02 17:10:14 +0300365 /*
366 * Avoid using uAPSD if P2P client is associated to GO that uses
367 * opportunistic power save. This is due to current FW limitation.
368 */
369 if (vif->p2p &&
370 vif->bss_conf.p2p_noa_attr.oppps_ctwindow &
371 IEEE80211_P2P_OPPPS_ENABLE_BIT)
372 allow_uapsd = false;
373
374 if (allow_uapsd)
Alexander Bondar175a70b2013-04-14 20:59:37 +0300375 iwl_mvm_power_configure_uapsd(mvm, vif, cmd);
Alexander Bondare3c588e2013-04-07 14:08:59 +0300376
Alexander Bondarb571a692013-05-21 14:49:09 +0300377#ifdef CONFIG_IWLWIFI_DEBUGFS
378 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE)
Alexander Bondare811ada2013-03-10 15:29:44 +0200379 cmd->keep_alive_seconds =
380 cpu_to_le16(mvmvif->dbgfs_pm.keep_alive_seconds);
Alexander Bondarb571a692013-05-21 14:49:09 +0300381 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) {
382 if (mvmvif->dbgfs_pm.skip_over_dtim)
383 cmd->flags |=
384 cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
385 else
386 cmd->flags &=
387 cpu_to_le16(~POWER_FLAGS_SKIP_OVER_DTIM_MSK);
388 }
389 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_RX_DATA_TIMEOUT)
390 cmd->rx_data_timeout =
391 cpu_to_le32(mvmvif->dbgfs_pm.rx_data_timeout);
392 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_TX_DATA_TIMEOUT)
393 cmd->tx_data_timeout =
394 cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout);
395 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS)
Alexander Bondare811ada2013-03-10 15:29:44 +0200396 cmd->skip_dtim_periods = mvmvif->dbgfs_pm.skip_dtim_periods;
Alexander Bondarbd4ace22013-03-21 17:14:14 +0200397 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) {
398 if (mvmvif->dbgfs_pm.lprx_ena)
399 cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK);
400 else
401 cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK);
402 }
403 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD)
Alexander Bondare811ada2013-03-10 15:29:44 +0200404 cmd->lprx_rssi_threshold = mvmvif->dbgfs_pm.lprx_rssi_threshold;
Alexander Bondar89716342013-08-04 17:52:23 +0300405 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SNOOZE_ENABLE) {
406 if (mvmvif->dbgfs_pm.snooze_ena)
407 cmd->flags |=
408 cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
409 else
410 cmd->flags &=
411 cpu_to_le16(~POWER_FLAGS_SNOOZE_ENA_MSK);
412 }
Alexander Bondare45a9412013-12-04 10:13:24 +0200413 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_UAPSD_MISBEHAVING) {
414 u16 flag = POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK;
415 if (mvmvif->dbgfs_pm.uapsd_misbehaving)
416 cmd->flags |= cpu_to_le16(flag);
417 else
418 cmd->flags &= cpu_to_le16(flag);
419 }
Alexander Bondarb571a692013-05-21 14:49:09 +0300420#endif /* CONFIG_IWLWIFI_DEBUGFS */
Johannes Berg8ca151b2013-01-24 14:25:36 +0100421}
422
Alexander Bondare811ada2013-03-10 15:29:44 +0200423static int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm,
424 struct ieee80211_vif *vif)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100425{
Alexander Bondar071d49902013-05-06 13:03:59 +0300426 int ret;
427 bool ba_enable;
Alexander Bondare811ada2013-03-10 15:29:44 +0200428 struct iwl_mac_power_cmd cmd = {};
Johannes Berg8ca151b2013-01-24 14:25:36 +0100429
Alexander Bondar51498cf2013-09-02 17:10:14 +0300430 if (vif->type != NL80211_IFTYPE_STATION)
431 return 0;
432
433 if (vif->p2p &&
434 !(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PS))
Johannes Berg8ca151b2013-01-24 14:25:36 +0100435 return 0;
436
Alexander Bondarf4a3e2f2013-03-05 13:47:04 +0200437 iwl_mvm_power_build_cmd(mvm, vif, &cmd);
Alexander Bondar3f0b2b32013-03-05 14:08:23 +0200438 iwl_mvm_power_log(mvm, &cmd);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100439
Alexander Bondare811ada2013-03-10 15:29:44 +0200440 ret = iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_SYNC,
Alexander Bondar071d49902013-05-06 13:03:59 +0300441 sizeof(cmd), &cmd);
442 if (ret)
443 return ret;
444
445 ba_enable = !!(cmd.flags &
446 cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK));
447
448 return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100449}
450
Alexander Bondare811ada2013-03-10 15:29:44 +0200451static int iwl_mvm_power_mac_disable(struct iwl_mvm *mvm,
452 struct ieee80211_vif *vif)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100453{
Alexander Bondare811ada2013-03-10 15:29:44 +0200454 struct iwl_mac_power_cmd cmd = {};
Alexander Bondarb571a692013-05-21 14:49:09 +0300455 struct iwl_mvm_vif *mvmvif __maybe_unused =
456 iwl_mvm_vif_from_mac80211(vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100457
Johannes Berg8ca151b2013-01-24 14:25:36 +0100458 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
459 return 0;
460
Alexander Bondare811ada2013-03-10 15:29:44 +0200461 cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
462 mvmvif->color));
463
Alexander Bondarade50652013-04-03 16:28:47 +0300464 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
Alexander Bondar9a613042013-03-05 12:54:00 +0200465 cmd.flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK);
466
Alexander Bondarb571a692013-05-21 14:49:09 +0300467#ifdef CONFIG_IWLWIFI_DEBUGFS
468 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF &&
469 mvmvif->dbgfs_pm.disable_power_off)
470 cmd.flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK);
471#endif
Alexander Bondar3f0b2b32013-03-05 14:08:23 +0200472 iwl_mvm_power_log(mvm, &cmd);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100473
Alexander Bondare811ada2013-03-10 15:29:44 +0200474 return iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_ASYNC,
Johannes Berg8ca151b2013-01-24 14:25:36 +0100475 sizeof(cmd), &cmd);
476}
Hila Gonen7df15b12012-12-12 11:16:19 +0200477
Alexander Bondar92d85562013-10-23 11:50:34 +0200478static int _iwl_mvm_power_update_device(struct iwl_mvm *mvm, bool force_disable)
Alexander Bondar64b928c2013-09-03 14:18:03 +0300479{
480 struct iwl_device_power_cmd cmd = {
481 .flags = cpu_to_le16(DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK),
482 };
483
484 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD))
485 return 0;
486
Alexander Bondar92d85562013-10-23 11:50:34 +0200487 if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM ||
488 force_disable)
Alexander Bondar64b928c2013-09-03 14:18:03 +0300489 cmd.flags |= cpu_to_le16(DEVICE_POWER_FLAGS_CAM_MSK);
490
491#ifdef CONFIG_IWLWIFI_DEBUGFS
492 if ((mvm->cur_ucode == IWL_UCODE_WOWLAN) ? mvm->disable_power_off_d3 :
493 mvm->disable_power_off)
494 cmd.flags &=
495 cpu_to_le16(~DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK);
496#endif
497 IWL_DEBUG_POWER(mvm,
498 "Sending device power command with flags = 0x%X\n",
499 cmd.flags);
500
501 return iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, CMD_SYNC, sizeof(cmd),
502 &cmd);
503}
504
Alexander Bondar92d85562013-10-23 11:50:34 +0200505static int iwl_mvm_power_update_device(struct iwl_mvm *mvm)
506{
507 return _iwl_mvm_power_update_device(mvm, false);
508}
509
Alexander Bondar175a70b2013-04-14 20:59:37 +0300510void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
511{
512 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
513
514 if (memcmp(vif->bss_conf.bssid, mvmvif->uapsd_misbehaving_bssid,
515 ETH_ALEN))
516 memset(mvmvif->uapsd_misbehaving_bssid, 0, ETH_ALEN);
517}
518
519static void iwl_mvm_power_uapsd_misbehav_ap_iterator(void *_data, u8 *mac,
520 struct ieee80211_vif *vif)
521{
522 u8 *ap_sta_id = _data;
523 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
524
525 /* The ap_sta_id is not expected to change during current association
526 * so no explicit protection is needed
527 */
528 if (mvmvif->ap_sta_id == *ap_sta_id)
529 memcpy(mvmvif->uapsd_misbehaving_bssid, vif->bss_conf.bssid,
530 ETH_ALEN);
531}
532
533int iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
534 struct iwl_rx_cmd_buffer *rxb,
535 struct iwl_device_cmd *cmd)
536{
537 struct iwl_rx_packet *pkt = rxb_addr(rxb);
538 struct iwl_uapsd_misbehaving_ap_notif *notif = (void *)pkt->data;
539 u8 ap_sta_id = le32_to_cpu(notif->sta_id);
540
541 ieee80211_iterate_active_interfaces_atomic(
542 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
543 iwl_mvm_power_uapsd_misbehav_ap_iterator, &ap_sta_id);
544
545 return 0;
546}
547
Alexander Bondar1c2abf72013-08-27 20:31:48 +0300548static void iwl_mvm_power_binding_iterator(void *_data, u8 *mac,
549 struct ieee80211_vif *vif)
550{
551 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
552 struct iwl_mvm *mvm = _data;
553 int ret;
554
555 mvmvif->pm_prevented = (mvm->bound_vif_cnt <= 1) ? false : true;
556
557 ret = iwl_mvm_power_mac_update_mode(mvm, vif);
558 WARN_ONCE(ret, "Failed to update power parameters on a specific vif\n");
559}
560
561static void _iwl_mvm_power_update_binding(struct iwl_mvm *mvm,
Alexander Bondar92d85562013-10-23 11:50:34 +0200562 struct ieee80211_vif *vif,
563 bool assign)
Alexander Bondar1c2abf72013-08-27 20:31:48 +0300564{
Alexander Bondar92d85562013-10-23 11:50:34 +0200565 if (vif->type == NL80211_IFTYPE_MONITOR) {
566 int ret = _iwl_mvm_power_update_device(mvm, assign);
567 mvm->ps_prevented = assign;
568 WARN_ONCE(ret, "Failed to update power device state\n");
569 }
570
Alexander Bondar1c2abf72013-08-27 20:31:48 +0300571 ieee80211_iterate_active_interfaces(mvm->hw,
572 IEEE80211_IFACE_ITER_NORMAL,
573 iwl_mvm_power_binding_iterator,
574 mvm);
575}
576
Alexander Bondarb571a692013-05-21 14:49:09 +0300577#ifdef CONFIG_IWLWIFI_DEBUGFS
Alexander Bondare811ada2013-03-10 15:29:44 +0200578static int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm,
579 struct ieee80211_vif *vif, char *buf,
580 int bufsz)
581{
582 struct iwl_mac_power_cmd cmd = {};
583 int pos = 0;
584
585 iwl_mvm_power_build_cmd(mvm, vif, &cmd);
586
Alexander Bondar64b928c2013-09-03 14:18:03 +0300587 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD))
588 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n",
589 (cmd.flags &
590 cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ?
591 0 : 1);
Alexander Bondare811ada2013-03-10 15:29:44 +0200592 pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n",
593 iwlmvm_mod_params.power_scheme);
594 pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n",
595 le16_to_cpu(cmd.flags));
596 pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n",
597 le16_to_cpu(cmd.keep_alive_seconds));
598
Alexander Bondar175a70b2013-04-14 20:59:37 +0300599 if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)))
600 return pos;
601
602 pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n",
603 (cmd.flags &
604 cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ? 1 : 0);
605 pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n",
606 cmd.skip_dtim_periods);
607 if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK))) {
608 pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout = %d\n",
609 le32_to_cpu(cmd.rx_data_timeout));
610 pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout = %d\n",
611 le32_to_cpu(cmd.tx_data_timeout));
Alexander Bondare811ada2013-03-10 15:29:44 +0200612 }
Alexander Bondar175a70b2013-04-14 20:59:37 +0300613 if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
614 pos += scnprintf(buf+pos, bufsz-pos,
615 "lprx_rssi_threshold = %d\n",
616 cmd.lprx_rssi_threshold);
617
618 if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)))
619 return pos;
620
621 pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout_uapsd = %d\n",
622 le32_to_cpu(cmd.rx_data_timeout_uapsd));
623 pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout_uapsd = %d\n",
624 le32_to_cpu(cmd.tx_data_timeout_uapsd));
625 pos += scnprintf(buf+pos, bufsz-pos, "qndp_tid = %d\n", cmd.qndp_tid);
626 pos += scnprintf(buf+pos, bufsz-pos, "uapsd_ac_flags = 0x%x\n",
627 cmd.uapsd_ac_flags);
628 pos += scnprintf(buf+pos, bufsz-pos, "uapsd_max_sp = %d\n",
629 cmd.uapsd_max_sp);
630 pos += scnprintf(buf+pos, bufsz-pos, "heavy_tx_thld_packets = %d\n",
631 cmd.heavy_tx_thld_packets);
632 pos += scnprintf(buf+pos, bufsz-pos, "heavy_rx_thld_packets = %d\n",
633 cmd.heavy_rx_thld_packets);
634 pos += scnprintf(buf+pos, bufsz-pos, "heavy_tx_thld_percentage = %d\n",
635 cmd.heavy_tx_thld_percentage);
636 pos += scnprintf(buf+pos, bufsz-pos, "heavy_rx_thld_percentage = %d\n",
637 cmd.heavy_rx_thld_percentage);
638 pos += scnprintf(buf+pos, bufsz-pos, "uapsd_misbehaving_enable = %d\n",
639 (cmd.flags &
640 cpu_to_le16(POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK)) ?
641 1 : 0);
642
643 if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)))
644 return pos;
645
646 pos += scnprintf(buf+pos, bufsz-pos, "snooze_interval = %d\n",
647 cmd.snooze_interval);
648 pos += scnprintf(buf+pos, bufsz-pos, "snooze_window = %d\n",
649 cmd.snooze_window);
650
Alexander Bondare811ada2013-03-10 15:29:44 +0200651 return pos;
652}
653
Alexander Bondarb571a692013-05-21 14:49:09 +0300654void
655iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
656 struct iwl_beacon_filter_cmd *cmd)
657{
658 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
659 struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf;
660
661 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ENERGY_DELTA)
Hila Gonen5dca7c22013-07-16 11:15:35 +0300662 cmd->bf_energy_delta = cpu_to_le32(dbgfs_bf->bf_energy_delta);
Alexander Bondarb571a692013-05-21 14:49:09 +0300663 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA)
664 cmd->bf_roaming_energy_delta =
Hila Gonen5dca7c22013-07-16 11:15:35 +0300665 cpu_to_le32(dbgfs_bf->bf_roaming_energy_delta);
Alexander Bondarb571a692013-05-21 14:49:09 +0300666 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_STATE)
Hila Gonen5dca7c22013-07-16 11:15:35 +0300667 cmd->bf_roaming_state = cpu_to_le32(dbgfs_bf->bf_roaming_state);
668 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_THRESHOLD)
669 cmd->bf_temp_threshold =
670 cpu_to_le32(dbgfs_bf->bf_temp_threshold);
671 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_FAST_FILTER)
672 cmd->bf_temp_fast_filter =
673 cpu_to_le32(dbgfs_bf->bf_temp_fast_filter);
674 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_SLOW_FILTER)
675 cmd->bf_temp_slow_filter =
676 cpu_to_le32(dbgfs_bf->bf_temp_slow_filter);
Alexander Bondarb571a692013-05-21 14:49:09 +0300677 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_DEBUG_FLAG)
Hila Gonen5dca7c22013-07-16 11:15:35 +0300678 cmd->bf_debug_flag = cpu_to_le32(dbgfs_bf->bf_debug_flag);
Alexander Bondarb571a692013-05-21 14:49:09 +0300679 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ESCAPE_TIMER)
680 cmd->bf_escape_timer = cpu_to_le32(dbgfs_bf->bf_escape_timer);
681 if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ESCAPE_TIMER)
682 cmd->ba_escape_timer = cpu_to_le32(dbgfs_bf->ba_escape_timer);
683 if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT)
Hila Gonen5dca7c22013-07-16 11:15:35 +0300684 cmd->ba_enable_beacon_abort =
685 cpu_to_le32(dbgfs_bf->ba_enable_beacon_abort);
Alexander Bondarb571a692013-05-21 14:49:09 +0300686}
687#endif
688
Hila Gonen7df15b12012-12-12 11:16:19 +0200689int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
690 struct ieee80211_vif *vif)
691{
692 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
693 struct iwl_beacon_filter_cmd cmd = {
Alexander Bondar071d49902013-05-06 13:03:59 +0300694 IWL_BF_CMD_CONFIG_DEFAULTS,
Hila Gonen5dca7c22013-07-16 11:15:35 +0300695 .bf_enable_beacon_filter = cpu_to_le32(1),
Hila Gonen7df15b12012-12-12 11:16:19 +0200696 };
Alexander Bondar071d49902013-05-06 13:03:59 +0300697 int ret;
Hila Gonen7df15b12012-12-12 11:16:19 +0200698
699 if (mvmvif != mvm->bf_allowed_vif ||
700 vif->type != NL80211_IFTYPE_STATION || vif->p2p)
701 return 0;
702
Andrei Otcheretianskia20fd392013-07-21 17:23:59 +0300703 iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, &cmd);
Alexander Bondarb571a692013-05-21 14:49:09 +0300704 iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
Alexander Bondar071d49902013-05-06 13:03:59 +0300705 ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
706
707 if (!ret)
Andrei Otcheretianskia20fd392013-07-21 17:23:59 +0300708 mvmvif->bf_data.bf_enabled = true;
Alexander Bondar071d49902013-05-06 13:03:59 +0300709
710 return ret;
Hila Gonen7df15b12012-12-12 11:16:19 +0200711}
712
713int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
714 struct ieee80211_vif *vif)
715{
Alexander Bondar071d49902013-05-06 13:03:59 +0300716 struct iwl_beacon_filter_cmd cmd = {};
717 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
718 int ret;
Hila Gonen7df15b12012-12-12 11:16:19 +0200719
Hila Gonen5dca7c22013-07-16 11:15:35 +0300720 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED) ||
721 vif->type != NL80211_IFTYPE_STATION || vif->p2p)
Hila Gonen7df15b12012-12-12 11:16:19 +0200722 return 0;
723
Alexander Bondar071d49902013-05-06 13:03:59 +0300724 ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
725
726 if (!ret)
Andrei Otcheretianskia20fd392013-07-21 17:23:59 +0300727 mvmvif->bf_data.bf_enabled = false;
Alexander Bondar071d49902013-05-06 13:03:59 +0300728
729 return ret;
Hila Gonen7df15b12012-12-12 11:16:19 +0200730}
Alexander Bondare811ada2013-03-10 15:29:44 +0200731
Andrei Otcheretianskia20fd392013-07-21 17:23:59 +0300732int iwl_mvm_update_beacon_filter(struct iwl_mvm *mvm,
733 struct ieee80211_vif *vif)
734{
735 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
736
737 if (!mvmvif->bf_data.bf_enabled)
738 return 0;
739
740 return iwl_mvm_enable_beacon_filter(mvm, vif);
741}
742
Alexander Bondare811ada2013-03-10 15:29:44 +0200743const struct iwl_mvm_power_ops pm_mac_ops = {
744 .power_update_mode = iwl_mvm_power_mac_update_mode,
Alexander Bondar64b928c2013-09-03 14:18:03 +0300745 .power_update_device_mode = iwl_mvm_power_update_device,
Alexander Bondare811ada2013-03-10 15:29:44 +0200746 .power_disable = iwl_mvm_power_mac_disable,
Alexander Bondar1c2abf72013-08-27 20:31:48 +0300747 .power_update_binding = _iwl_mvm_power_update_binding,
Alexander Bondare811ada2013-03-10 15:29:44 +0200748#ifdef CONFIG_IWLWIFI_DEBUGFS
749 .power_dbgfs_read = iwl_mvm_power_mac_dbgfs_read,
750#endif
751};