Merge remote-tracking branch 'regulator/topic/tps65910' into regulator-next
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / mvm / power.c
1 /******************************************************************************
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 *
8 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
9 *
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
25 * in the file called COPYING.
26 *
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 *
33 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
34 * 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>
67 #include <linux/init.h>
68
69 #include <net/mac80211.h>
70
71 #include "iwl-debug.h"
72 #include "mvm.h"
73 #include "iwl-modparams.h"
74 #include "fw-api-power.h"
75
76 #define POWER_KEEP_ALIVE_PERIOD_SEC 25
77
78 int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm,
79 struct iwl_beacon_filter_cmd *cmd)
80 {
81 int ret;
82
83 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_BEACON_FILTERING_CMD, CMD_SYNC,
84 sizeof(struct iwl_beacon_filter_cmd), cmd);
85
86 if (!ret) {
87 IWL_DEBUG_POWER(mvm, "ba_enable_beacon_abort is: %d\n",
88 le32_to_cpu(cmd->ba_enable_beacon_abort));
89 IWL_DEBUG_POWER(mvm, "ba_escape_timer is: %d\n",
90 le32_to_cpu(cmd->ba_escape_timer));
91 IWL_DEBUG_POWER(mvm, "bf_debug_flag is: %d\n",
92 le32_to_cpu(cmd->bf_debug_flag));
93 IWL_DEBUG_POWER(mvm, "bf_enable_beacon_filter is: %d\n",
94 le32_to_cpu(cmd->bf_enable_beacon_filter));
95 IWL_DEBUG_POWER(mvm, "bf_energy_delta is: %d\n",
96 le32_to_cpu(cmd->bf_energy_delta));
97 IWL_DEBUG_POWER(mvm, "bf_escape_timer is: %d\n",
98 le32_to_cpu(cmd->bf_escape_timer));
99 IWL_DEBUG_POWER(mvm, "bf_roaming_energy_delta is: %d\n",
100 le32_to_cpu(cmd->bf_roaming_energy_delta));
101 IWL_DEBUG_POWER(mvm, "bf_roaming_state is: %d\n",
102 le32_to_cpu(cmd->bf_roaming_state));
103 IWL_DEBUG_POWER(mvm, "bf_temp_threshold is: %d\n",
104 le32_to_cpu(cmd->bf_temp_threshold));
105 IWL_DEBUG_POWER(mvm, "bf_temp_fast_filter is: %d\n",
106 le32_to_cpu(cmd->bf_temp_fast_filter));
107 IWL_DEBUG_POWER(mvm, "bf_temp_slow_filter is: %d\n",
108 le32_to_cpu(cmd->bf_temp_slow_filter));
109 }
110 return ret;
111 }
112
113 static
114 void iwl_mvm_beacon_filter_set_cqm_params(struct iwl_mvm *mvm,
115 struct ieee80211_vif *vif,
116 struct iwl_beacon_filter_cmd *cmd)
117 {
118 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
119
120 if (vif->bss_conf.cqm_rssi_thold) {
121 cmd->bf_energy_delta =
122 cpu_to_le32(vif->bss_conf.cqm_rssi_hyst);
123 /* fw uses an absolute value for this */
124 cmd->bf_roaming_state =
125 cpu_to_le32(-vif->bss_conf.cqm_rssi_thold);
126 }
127 cmd->ba_enable_beacon_abort = cpu_to_le32(mvmvif->bf_data.ba_enabled);
128 }
129
130 int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm,
131 struct ieee80211_vif *vif, bool enable)
132 {
133 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
134 struct iwl_beacon_filter_cmd cmd = {
135 IWL_BF_CMD_CONFIG_DEFAULTS,
136 .bf_enable_beacon_filter = cpu_to_le32(1),
137 .ba_enable_beacon_abort = cpu_to_le32(enable),
138 };
139
140 if (!mvmvif->bf_data.bf_enabled)
141 return 0;
142
143 if (mvm->cur_ucode == IWL_UCODE_WOWLAN)
144 cmd.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_D3);
145
146 mvmvif->bf_data.ba_enabled = enable;
147 iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, &cmd);
148 iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
149 return iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
150 }
151
152 static void iwl_mvm_power_log(struct iwl_mvm *mvm,
153 struct iwl_mac_power_cmd *cmd)
154 {
155 IWL_DEBUG_POWER(mvm,
156 "Sending power table command on mac id 0x%X for power level %d, flags = 0x%X\n",
157 cmd->id_and_color, iwlmvm_mod_params.power_scheme,
158 le16_to_cpu(cmd->flags));
159 IWL_DEBUG_POWER(mvm, "Keep alive = %u sec\n",
160 le16_to_cpu(cmd->keep_alive_seconds));
161
162 if (!(cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK))) {
163 IWL_DEBUG_POWER(mvm, "Disable power management\n");
164 return;
165 }
166
167 IWL_DEBUG_POWER(mvm, "Rx timeout = %u usec\n",
168 le32_to_cpu(cmd->rx_data_timeout));
169 IWL_DEBUG_POWER(mvm, "Tx timeout = %u usec\n",
170 le32_to_cpu(cmd->tx_data_timeout));
171 if (cmd->flags & cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK))
172 IWL_DEBUG_POWER(mvm, "DTIM periods to skip = %u\n",
173 cmd->skip_dtim_periods);
174 if (cmd->flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
175 IWL_DEBUG_POWER(mvm, "LP RX RSSI threshold = %u\n",
176 cmd->lprx_rssi_threshold);
177 if (cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
178 IWL_DEBUG_POWER(mvm, "uAPSD enabled\n");
179 IWL_DEBUG_POWER(mvm, "Rx timeout (uAPSD) = %u usec\n",
180 le32_to_cpu(cmd->rx_data_timeout_uapsd));
181 IWL_DEBUG_POWER(mvm, "Tx timeout (uAPSD) = %u usec\n",
182 le32_to_cpu(cmd->tx_data_timeout_uapsd));
183 IWL_DEBUG_POWER(mvm, "QNDP TID = %d\n", cmd->qndp_tid);
184 IWL_DEBUG_POWER(mvm, "ACs flags = 0x%x\n", cmd->uapsd_ac_flags);
185 IWL_DEBUG_POWER(mvm, "Max SP = %d\n", cmd->uapsd_max_sp);
186 }
187 }
188
189 static void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm,
190 struct ieee80211_vif *vif,
191 struct iwl_mac_power_cmd *cmd)
192 {
193 struct ieee80211_hw *hw = mvm->hw;
194 struct ieee80211_chanctx_conf *chanctx_conf;
195 struct ieee80211_channel *chan;
196 int dtimper, dtimper_msec;
197 int keep_alive;
198 bool radar_detect = false;
199 struct iwl_mvm_vif *mvmvif __maybe_unused =
200 iwl_mvm_vif_from_mac80211(vif);
201 enum ieee80211_ac_numbers ac;
202 bool tid_found = false;
203
204 cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
205 mvmvif->color));
206 dtimper = hw->conf.ps_dtim_period ?: 1;
207
208 /*
209 * Regardless of power management state the driver must set
210 * keep alive period. FW will use it for sending keep alive NDPs
211 * immediately after association. Check that keep alive period
212 * is at least 3 * DTIM
213 */
214 dtimper_msec = dtimper * vif->bss_conf.beacon_int;
215 keep_alive = max_t(int, 3 * dtimper_msec,
216 MSEC_PER_SEC * POWER_KEEP_ALIVE_PERIOD_SEC);
217 keep_alive = DIV_ROUND_UP(keep_alive, MSEC_PER_SEC);
218 cmd->keep_alive_seconds = cpu_to_le16(keep_alive);
219
220 if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM)
221 return;
222
223 cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK);
224
225 #ifdef CONFIG_IWLWIFI_DEBUGFS
226 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF &&
227 mvmvif->dbgfs_pm.disable_power_off)
228 cmd->flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK);
229 #endif
230 if (!vif->bss_conf.ps)
231 return;
232
233 cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK);
234
235 if (vif->bss_conf.beacon_rate &&
236 (vif->bss_conf.beacon_rate->bitrate == 10 ||
237 vif->bss_conf.beacon_rate->bitrate == 60)) {
238 cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK);
239 cmd->lprx_rssi_threshold = POWER_LPRX_RSSI_THRESHOLD;
240 }
241
242 /* Check if radar detection is required on current channel */
243 rcu_read_lock();
244 chanctx_conf = rcu_dereference(vif->chanctx_conf);
245 WARN_ON(!chanctx_conf);
246 if (chanctx_conf) {
247 chan = chanctx_conf->def.chan;
248 radar_detect = chan->flags & IEEE80211_CHAN_RADAR;
249 }
250 rcu_read_unlock();
251
252 /* Check skip over DTIM conditions */
253 if (!radar_detect && (dtimper <= 10) &&
254 (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_LP ||
255 mvm->cur_ucode == IWL_UCODE_WOWLAN)) {
256 cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
257 cmd->skip_dtim_periods = 3;
258 }
259
260 if (mvm->cur_ucode != IWL_UCODE_WOWLAN) {
261 cmd->rx_data_timeout =
262 cpu_to_le32(IWL_MVM_DEFAULT_PS_RX_DATA_TIMEOUT);
263 cmd->tx_data_timeout =
264 cpu_to_le32(IWL_MVM_DEFAULT_PS_TX_DATA_TIMEOUT);
265 } else {
266 cmd->rx_data_timeout =
267 cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT);
268 cmd->tx_data_timeout =
269 cpu_to_le32(IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT);
270 }
271
272 for (ac = IEEE80211_AC_VO; ac <= IEEE80211_AC_BK; ac++) {
273 if (!mvmvif->queue_params[ac].uapsd)
274 continue;
275
276 cmd->flags |= cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK);
277 cmd->uapsd_ac_flags |= BIT(ac);
278
279 /* QNDP TID - the highest TID with no admission control */
280 if (!tid_found && !mvmvif->queue_params[ac].acm) {
281 tid_found = true;
282 switch (ac) {
283 case IEEE80211_AC_VO:
284 cmd->qndp_tid = 6;
285 break;
286 case IEEE80211_AC_VI:
287 cmd->qndp_tid = 5;
288 break;
289 case IEEE80211_AC_BE:
290 cmd->qndp_tid = 0;
291 break;
292 case IEEE80211_AC_BK:
293 cmd->qndp_tid = 1;
294 break;
295 }
296 }
297 }
298
299 if (cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
300 cmd->rx_data_timeout_uapsd =
301 cpu_to_le32(IWL_MVM_UAPSD_RX_DATA_TIMEOUT);
302 cmd->tx_data_timeout_uapsd =
303 cpu_to_le32(IWL_MVM_UAPSD_TX_DATA_TIMEOUT);
304
305 if (cmd->uapsd_ac_flags == (BIT(IEEE80211_AC_VO) |
306 BIT(IEEE80211_AC_VI) |
307 BIT(IEEE80211_AC_BE) |
308 BIT(IEEE80211_AC_BK))) {
309 cmd->flags |= cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
310 cmd->snooze_interval =
311 cpu_to_le16(IWL_MVM_PS_SNOOZE_INTERVAL);
312 cmd->snooze_window =
313 (mvm->cur_ucode == IWL_UCODE_WOWLAN) ?
314 cpu_to_le16(IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW) :
315 cpu_to_le16(IWL_MVM_PS_SNOOZE_WINDOW);
316 }
317
318 cmd->uapsd_max_sp = IWL_UAPSD_MAX_SP;
319 cmd->heavy_tx_thld_packets =
320 IWL_MVM_PS_HEAVY_TX_THLD_PACKETS;
321 cmd->heavy_rx_thld_packets =
322 IWL_MVM_PS_HEAVY_RX_THLD_PACKETS;
323 cmd->heavy_tx_thld_percentage =
324 IWL_MVM_PS_HEAVY_TX_THLD_PERCENT;
325 cmd->heavy_rx_thld_percentage =
326 IWL_MVM_PS_HEAVY_RX_THLD_PERCENT;
327 }
328
329 #ifdef CONFIG_IWLWIFI_DEBUGFS
330 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE)
331 cmd->keep_alive_seconds =
332 cpu_to_le16(mvmvif->dbgfs_pm.keep_alive_seconds);
333 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) {
334 if (mvmvif->dbgfs_pm.skip_over_dtim)
335 cmd->flags |=
336 cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
337 else
338 cmd->flags &=
339 cpu_to_le16(~POWER_FLAGS_SKIP_OVER_DTIM_MSK);
340 }
341 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_RX_DATA_TIMEOUT)
342 cmd->rx_data_timeout =
343 cpu_to_le32(mvmvif->dbgfs_pm.rx_data_timeout);
344 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_TX_DATA_TIMEOUT)
345 cmd->tx_data_timeout =
346 cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout);
347 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS)
348 cmd->skip_dtim_periods = mvmvif->dbgfs_pm.skip_dtim_periods;
349 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) {
350 if (mvmvif->dbgfs_pm.lprx_ena)
351 cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK);
352 else
353 cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK);
354 }
355 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD)
356 cmd->lprx_rssi_threshold = mvmvif->dbgfs_pm.lprx_rssi_threshold;
357 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SNOOZE_ENABLE) {
358 if (mvmvif->dbgfs_pm.snooze_ena)
359 cmd->flags |=
360 cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
361 else
362 cmd->flags &=
363 cpu_to_le16(~POWER_FLAGS_SNOOZE_ENA_MSK);
364 }
365 #endif /* CONFIG_IWLWIFI_DEBUGFS */
366 }
367
368 static int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm,
369 struct ieee80211_vif *vif)
370 {
371 int ret;
372 bool ba_enable;
373 struct iwl_mac_power_cmd cmd = {};
374
375 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
376 return 0;
377
378 /*
379 * TODO: The following vif_count verification is temporary condition.
380 * Avoid power mode update if more than one interface is currently
381 * active. Remove this condition when FW will support power management
382 * on multiple MACs.
383 */
384 IWL_DEBUG_POWER(mvm, "Currently %d interfaces active\n",
385 mvm->vif_count);
386 if (mvm->vif_count > 1)
387 return 0;
388
389 iwl_mvm_power_build_cmd(mvm, vif, &cmd);
390 iwl_mvm_power_log(mvm, &cmd);
391
392 ret = iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_SYNC,
393 sizeof(cmd), &cmd);
394 if (ret)
395 return ret;
396
397 ba_enable = !!(cmd.flags &
398 cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK));
399
400 return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable);
401 }
402
403 static int iwl_mvm_power_mac_disable(struct iwl_mvm *mvm,
404 struct ieee80211_vif *vif)
405 {
406 struct iwl_mac_power_cmd cmd = {};
407 struct iwl_mvm_vif *mvmvif __maybe_unused =
408 iwl_mvm_vif_from_mac80211(vif);
409
410 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
411 return 0;
412
413 cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
414 mvmvif->color));
415
416 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
417 cmd.flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK);
418
419 #ifdef CONFIG_IWLWIFI_DEBUGFS
420 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF &&
421 mvmvif->dbgfs_pm.disable_power_off)
422 cmd.flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK);
423 #endif
424 iwl_mvm_power_log(mvm, &cmd);
425
426 return iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_ASYNC,
427 sizeof(cmd), &cmd);
428 }
429
430 #ifdef CONFIG_IWLWIFI_DEBUGFS
431 static int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm,
432 struct ieee80211_vif *vif, char *buf,
433 int bufsz)
434 {
435 struct iwl_mac_power_cmd cmd = {};
436 int pos = 0;
437
438 iwl_mvm_power_build_cmd(mvm, vif, &cmd);
439
440 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n",
441 (cmd.flags &
442 cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ?
443 0 : 1);
444 pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n",
445 iwlmvm_mod_params.power_scheme);
446 pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n",
447 le16_to_cpu(cmd.flags));
448 pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n",
449 le16_to_cpu(cmd.keep_alive_seconds));
450
451 if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) {
452 pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n",
453 (cmd.flags &
454 cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ?
455 1 : 0);
456 pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n",
457 cmd.skip_dtim_periods);
458 if (!(cmd.flags &
459 cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK))) {
460 pos += scnprintf(buf+pos, bufsz-pos,
461 "rx_data_timeout = %d\n",
462 le32_to_cpu(cmd.rx_data_timeout));
463 pos += scnprintf(buf+pos, bufsz-pos,
464 "tx_data_timeout = %d\n",
465 le32_to_cpu(cmd.tx_data_timeout));
466 }
467 if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
468 pos += scnprintf(buf+pos, bufsz-pos,
469 "lprx_rssi_threshold = %d\n",
470 cmd.lprx_rssi_threshold);
471 if (cmd.flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
472 pos +=
473 scnprintf(buf+pos, bufsz-pos,
474 "rx_data_timeout_uapsd = %d\n",
475 le32_to_cpu(cmd.rx_data_timeout_uapsd));
476 pos +=
477 scnprintf(buf+pos, bufsz-pos,
478 "tx_data_timeout_uapsd = %d\n",
479 le32_to_cpu(cmd.tx_data_timeout_uapsd));
480 pos += scnprintf(buf+pos, bufsz-pos, "qndp_tid = %d\n",
481 cmd.qndp_tid);
482 pos += scnprintf(buf+pos, bufsz-pos,
483 "uapsd_ac_flags = 0x%x\n",
484 cmd.uapsd_ac_flags);
485 pos += scnprintf(buf+pos, bufsz-pos,
486 "uapsd_max_sp = %d\n",
487 cmd.uapsd_max_sp);
488 pos += scnprintf(buf+pos, bufsz-pos,
489 "heavy_tx_thld_packets = %d\n",
490 cmd.heavy_tx_thld_packets);
491 pos += scnprintf(buf+pos, bufsz-pos,
492 "heavy_rx_thld_packets = %d\n",
493 cmd.heavy_rx_thld_packets);
494 pos += scnprintf(buf+pos, bufsz-pos,
495 "heavy_tx_thld_percentage = %d\n",
496 cmd.heavy_tx_thld_percentage);
497 pos += scnprintf(buf+pos, bufsz-pos,
498 "heavy_rx_thld_percentage = %d\n",
499 cmd.heavy_rx_thld_percentage);
500 pos +=
501 scnprintf(buf+pos, bufsz-pos, "snooze_enable = %d\n",
502 (cmd.flags &
503 cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) ?
504 1 : 0);
505 }
506 if (cmd.flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
507 pos += scnprintf(buf+pos, bufsz-pos,
508 "snooze_interval = %d\n",
509 cmd.snooze_interval);
510 pos += scnprintf(buf+pos, bufsz-pos,
511 "snooze_window = %d\n",
512 cmd.snooze_window);
513 }
514 }
515 return pos;
516 }
517
518 void
519 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
520 struct iwl_beacon_filter_cmd *cmd)
521 {
522 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
523 struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf;
524
525 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ENERGY_DELTA)
526 cmd->bf_energy_delta = cpu_to_le32(dbgfs_bf->bf_energy_delta);
527 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA)
528 cmd->bf_roaming_energy_delta =
529 cpu_to_le32(dbgfs_bf->bf_roaming_energy_delta);
530 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_STATE)
531 cmd->bf_roaming_state = cpu_to_le32(dbgfs_bf->bf_roaming_state);
532 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_THRESHOLD)
533 cmd->bf_temp_threshold =
534 cpu_to_le32(dbgfs_bf->bf_temp_threshold);
535 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_FAST_FILTER)
536 cmd->bf_temp_fast_filter =
537 cpu_to_le32(dbgfs_bf->bf_temp_fast_filter);
538 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_SLOW_FILTER)
539 cmd->bf_temp_slow_filter =
540 cpu_to_le32(dbgfs_bf->bf_temp_slow_filter);
541 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_DEBUG_FLAG)
542 cmd->bf_debug_flag = cpu_to_le32(dbgfs_bf->bf_debug_flag);
543 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ESCAPE_TIMER)
544 cmd->bf_escape_timer = cpu_to_le32(dbgfs_bf->bf_escape_timer);
545 if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ESCAPE_TIMER)
546 cmd->ba_escape_timer = cpu_to_le32(dbgfs_bf->ba_escape_timer);
547 if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT)
548 cmd->ba_enable_beacon_abort =
549 cpu_to_le32(dbgfs_bf->ba_enable_beacon_abort);
550 }
551 #endif
552
553 int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
554 struct ieee80211_vif *vif)
555 {
556 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
557 struct iwl_beacon_filter_cmd cmd = {
558 IWL_BF_CMD_CONFIG_DEFAULTS,
559 .bf_enable_beacon_filter = cpu_to_le32(1),
560 };
561 int ret;
562
563 if (mvmvif != mvm->bf_allowed_vif ||
564 vif->type != NL80211_IFTYPE_STATION || vif->p2p)
565 return 0;
566
567 iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, &cmd);
568 iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
569 ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
570
571 if (!ret)
572 mvmvif->bf_data.bf_enabled = true;
573
574 return ret;
575 }
576
577 int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
578 struct ieee80211_vif *vif)
579 {
580 struct iwl_beacon_filter_cmd cmd = {};
581 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
582 int ret;
583
584 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED) ||
585 vif->type != NL80211_IFTYPE_STATION || vif->p2p)
586 return 0;
587
588 ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
589
590 if (!ret)
591 mvmvif->bf_data.bf_enabled = false;
592
593 return ret;
594 }
595
596 int iwl_mvm_update_beacon_filter(struct iwl_mvm *mvm,
597 struct ieee80211_vif *vif)
598 {
599 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
600
601 if (!mvmvif->bf_data.bf_enabled)
602 return 0;
603
604 return iwl_mvm_enable_beacon_filter(mvm, vif);
605 }
606
607 const struct iwl_mvm_power_ops pm_mac_ops = {
608 .power_update_mode = iwl_mvm_power_mac_update_mode,
609 .power_disable = iwl_mvm_power_mac_disable,
610 #ifdef CONFIG_IWLWIFI_DEBUGFS
611 .power_dbgfs_read = iwl_mvm_power_mac_dbgfs_read,
612 #endif
613 };
This page took 0.048859 seconds and 5 git commands to generate.