1 /******************************************************************************
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.
8 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
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.
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.
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,
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
33 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
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
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.
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.
62 *****************************************************************************/
64 #include <linux/kernel.h>
65 #include <linux/module.h>
66 #include <linux/slab.h>
67 #include <linux/init.h>
69 #include <net/mac80211.h>
71 #include "iwl-debug.h"
73 #include "iwl-modparams.h"
74 #include "fw-api-power.h"
76 #define POWER_KEEP_ALIVE_PERIOD_SEC 25
78 int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm,
79 struct iwl_beacon_filter_cmd *cmd)
83 ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_BEACON_FILTERING_CMD, CMD_SYNC,
84 sizeof(struct iwl_beacon_filter_cmd), cmd);
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));
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)
118 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
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);
127 cmd->ba_enable_beacon_abort = cpu_to_le32(mvmvif->bf_data.ba_enabled);
130 int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm,
131 struct ieee80211_vif *vif, bool enable)
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),
140 if (!mvmvif->bf_data.bf_enabled)
143 if (mvm->cur_ucode == IWL_UCODE_WOWLAN)
144 cmd.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_D3);
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);
152 static void iwl_mvm_power_log(struct iwl_mvm *mvm,
153 struct iwl_mac_power_cmd *cmd)
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));
162 if (!(cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK))) {
163 IWL_DEBUG_POWER(mvm, "Disable power management\n");
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);
189 static void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm,
190 struct ieee80211_vif *vif,
191 struct iwl_mac_power_cmd *cmd)
193 struct ieee80211_hw *hw = mvm->hw;
194 struct ieee80211_chanctx_conf *chanctx_conf;
195 struct ieee80211_channel *chan;
196 int dtimper, dtimper_msec;
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;
204 cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
206 dtimper = hw->conf.ps_dtim_period ?: 1;
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
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);
220 if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM)
223 cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK);
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);
230 if (!vif->bss_conf.ps)
233 cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK);
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;
242 /* Check if radar detection is required on current channel */
244 chanctx_conf = rcu_dereference(vif->chanctx_conf);
245 WARN_ON(!chanctx_conf);
247 chan = chanctx_conf->def.chan;
248 radar_detect = chan->flags & IEEE80211_CHAN_RADAR;
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;
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);
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);
272 for (ac = IEEE80211_AC_VO; ac <= IEEE80211_AC_BK; ac++) {
273 if (!mvmvif->queue_params[ac].uapsd)
276 if (mvm->cur_ucode != IWL_UCODE_WOWLAN)
278 cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK);
280 cmd->uapsd_ac_flags |= BIT(ac);
282 /* QNDP TID - the highest TID with no admission control */
283 if (!tid_found && !mvmvif->queue_params[ac].acm) {
286 case IEEE80211_AC_VO:
289 case IEEE80211_AC_VI:
292 case IEEE80211_AC_BE:
295 case IEEE80211_AC_BK:
302 if (cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
303 if (cmd->uapsd_ac_flags == (BIT(IEEE80211_AC_VO) |
304 BIT(IEEE80211_AC_VI) |
305 BIT(IEEE80211_AC_BE) |
306 BIT(IEEE80211_AC_BK))) {
307 cmd->flags |= cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
308 cmd->snooze_interval =
309 cpu_to_le16(IWL_MVM_PS_SNOOZE_INTERVAL);
311 (mvm->cur_ucode == IWL_UCODE_WOWLAN) ?
312 cpu_to_le16(IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW) :
313 cpu_to_le16(IWL_MVM_PS_SNOOZE_WINDOW);
316 cmd->uapsd_max_sp = IWL_UAPSD_MAX_SP;
318 if (mvm->cur_ucode == IWL_UCODE_WOWLAN || cmd->flags &
319 cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
320 cmd->rx_data_timeout_uapsd =
321 cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT);
322 cmd->tx_data_timeout_uapsd =
323 cpu_to_le32(IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT);
325 cmd->rx_data_timeout_uapsd =
326 cpu_to_le32(IWL_MVM_UAPSD_RX_DATA_TIMEOUT);
327 cmd->tx_data_timeout_uapsd =
328 cpu_to_le32(IWL_MVM_UAPSD_TX_DATA_TIMEOUT);
331 if (cmd->flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
332 cmd->heavy_tx_thld_packets =
333 IWL_MVM_PS_SNOOZE_HEAVY_TX_THLD_PACKETS;
334 cmd->heavy_rx_thld_packets =
335 IWL_MVM_PS_SNOOZE_HEAVY_RX_THLD_PACKETS;
337 cmd->heavy_tx_thld_packets =
338 IWL_MVM_PS_HEAVY_TX_THLD_PACKETS;
339 cmd->heavy_rx_thld_packets =
340 IWL_MVM_PS_HEAVY_RX_THLD_PACKETS;
342 cmd->heavy_tx_thld_percentage =
343 IWL_MVM_PS_HEAVY_TX_THLD_PERCENT;
344 cmd->heavy_rx_thld_percentage =
345 IWL_MVM_PS_HEAVY_RX_THLD_PERCENT;
348 #ifdef CONFIG_IWLWIFI_DEBUGFS
349 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE)
350 cmd->keep_alive_seconds =
351 cpu_to_le16(mvmvif->dbgfs_pm.keep_alive_seconds);
352 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) {
353 if (mvmvif->dbgfs_pm.skip_over_dtim)
355 cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
358 cpu_to_le16(~POWER_FLAGS_SKIP_OVER_DTIM_MSK);
360 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_RX_DATA_TIMEOUT)
361 cmd->rx_data_timeout =
362 cpu_to_le32(mvmvif->dbgfs_pm.rx_data_timeout);
363 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_TX_DATA_TIMEOUT)
364 cmd->tx_data_timeout =
365 cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout);
366 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS)
367 cmd->skip_dtim_periods = mvmvif->dbgfs_pm.skip_dtim_periods;
368 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) {
369 if (mvmvif->dbgfs_pm.lprx_ena)
370 cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK);
372 cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK);
374 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD)
375 cmd->lprx_rssi_threshold = mvmvif->dbgfs_pm.lprx_rssi_threshold;
376 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SNOOZE_ENABLE) {
377 if (mvmvif->dbgfs_pm.snooze_ena)
379 cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
382 cpu_to_le16(~POWER_FLAGS_SNOOZE_ENA_MSK);
384 #endif /* CONFIG_IWLWIFI_DEBUGFS */
387 static int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm,
388 struct ieee80211_vif *vif)
392 struct iwl_mac_power_cmd cmd = {};
394 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
398 * TODO: The following vif_count verification is temporary condition.
399 * Avoid power mode update if more than one interface is currently
400 * active. Remove this condition when FW will support power management
403 IWL_DEBUG_POWER(mvm, "Currently %d interfaces active\n",
405 if (mvm->vif_count > 1)
408 iwl_mvm_power_build_cmd(mvm, vif, &cmd);
409 iwl_mvm_power_log(mvm, &cmd);
411 ret = iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_SYNC,
416 ba_enable = !!(cmd.flags &
417 cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK));
419 return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable);
422 static int iwl_mvm_power_mac_disable(struct iwl_mvm *mvm,
423 struct ieee80211_vif *vif)
425 struct iwl_mac_power_cmd cmd = {};
426 struct iwl_mvm_vif *mvmvif __maybe_unused =
427 iwl_mvm_vif_from_mac80211(vif);
429 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
432 cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
435 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
436 cmd.flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK);
438 #ifdef CONFIG_IWLWIFI_DEBUGFS
439 if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF &&
440 mvmvif->dbgfs_pm.disable_power_off)
441 cmd.flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK);
443 iwl_mvm_power_log(mvm, &cmd);
445 return iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_ASYNC,
449 static int iwl_mvm_power_update_device(struct iwl_mvm *mvm)
451 struct iwl_device_power_cmd cmd = {
452 .flags = cpu_to_le16(DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK),
455 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD))
458 if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM)
459 cmd.flags |= cpu_to_le16(DEVICE_POWER_FLAGS_CAM_MSK);
461 #ifdef CONFIG_IWLWIFI_DEBUGFS
462 if ((mvm->cur_ucode == IWL_UCODE_WOWLAN) ? mvm->disable_power_off_d3 :
463 mvm->disable_power_off)
465 cpu_to_le16(~DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK);
468 "Sending device power command with flags = 0x%X\n",
471 return iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, CMD_SYNC, sizeof(cmd),
475 #ifdef CONFIG_IWLWIFI_DEBUGFS
476 static int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm,
477 struct ieee80211_vif *vif, char *buf,
480 struct iwl_mac_power_cmd cmd = {};
483 iwl_mvm_power_build_cmd(mvm, vif, &cmd);
485 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD))
486 pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n",
488 cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ?
490 pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n",
491 iwlmvm_mod_params.power_scheme);
492 pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n",
493 le16_to_cpu(cmd.flags));
494 pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n",
495 le16_to_cpu(cmd.keep_alive_seconds));
497 if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) {
498 pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n",
500 cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ?
502 pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n",
503 cmd.skip_dtim_periods);
505 cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK))) {
506 pos += scnprintf(buf+pos, bufsz-pos,
507 "rx_data_timeout = %d\n",
508 le32_to_cpu(cmd.rx_data_timeout));
509 pos += scnprintf(buf+pos, bufsz-pos,
510 "tx_data_timeout = %d\n",
511 le32_to_cpu(cmd.tx_data_timeout));
513 if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
514 pos += scnprintf(buf+pos, bufsz-pos,
515 "lprx_rssi_threshold = %d\n",
516 cmd.lprx_rssi_threshold);
517 if (cmd.flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
519 scnprintf(buf+pos, bufsz-pos,
520 "rx_data_timeout_uapsd = %d\n",
521 le32_to_cpu(cmd.rx_data_timeout_uapsd));
523 scnprintf(buf+pos, bufsz-pos,
524 "tx_data_timeout_uapsd = %d\n",
525 le32_to_cpu(cmd.tx_data_timeout_uapsd));
526 pos += scnprintf(buf+pos, bufsz-pos, "qndp_tid = %d\n",
528 pos += scnprintf(buf+pos, bufsz-pos,
529 "uapsd_ac_flags = 0x%x\n",
531 pos += scnprintf(buf+pos, bufsz-pos,
532 "uapsd_max_sp = %d\n",
534 pos += scnprintf(buf+pos, bufsz-pos,
535 "heavy_tx_thld_packets = %d\n",
536 cmd.heavy_tx_thld_packets);
537 pos += scnprintf(buf+pos, bufsz-pos,
538 "heavy_rx_thld_packets = %d\n",
539 cmd.heavy_rx_thld_packets);
540 pos += scnprintf(buf+pos, bufsz-pos,
541 "heavy_tx_thld_percentage = %d\n",
542 cmd.heavy_tx_thld_percentage);
543 pos += scnprintf(buf+pos, bufsz-pos,
544 "heavy_rx_thld_percentage = %d\n",
545 cmd.heavy_rx_thld_percentage);
547 scnprintf(buf+pos, bufsz-pos, "snooze_enable = %d\n",
549 cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) ?
552 if (cmd.flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
553 pos += scnprintf(buf+pos, bufsz-pos,
554 "snooze_interval = %d\n",
555 cmd.snooze_interval);
556 pos += scnprintf(buf+pos, bufsz-pos,
557 "snooze_window = %d\n",
565 iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
566 struct iwl_beacon_filter_cmd *cmd)
568 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
569 struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf;
571 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ENERGY_DELTA)
572 cmd->bf_energy_delta = cpu_to_le32(dbgfs_bf->bf_energy_delta);
573 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA)
574 cmd->bf_roaming_energy_delta =
575 cpu_to_le32(dbgfs_bf->bf_roaming_energy_delta);
576 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_STATE)
577 cmd->bf_roaming_state = cpu_to_le32(dbgfs_bf->bf_roaming_state);
578 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_THRESHOLD)
579 cmd->bf_temp_threshold =
580 cpu_to_le32(dbgfs_bf->bf_temp_threshold);
581 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_FAST_FILTER)
582 cmd->bf_temp_fast_filter =
583 cpu_to_le32(dbgfs_bf->bf_temp_fast_filter);
584 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_SLOW_FILTER)
585 cmd->bf_temp_slow_filter =
586 cpu_to_le32(dbgfs_bf->bf_temp_slow_filter);
587 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_DEBUG_FLAG)
588 cmd->bf_debug_flag = cpu_to_le32(dbgfs_bf->bf_debug_flag);
589 if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ESCAPE_TIMER)
590 cmd->bf_escape_timer = cpu_to_le32(dbgfs_bf->bf_escape_timer);
591 if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ESCAPE_TIMER)
592 cmd->ba_escape_timer = cpu_to_le32(dbgfs_bf->ba_escape_timer);
593 if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT)
594 cmd->ba_enable_beacon_abort =
595 cpu_to_le32(dbgfs_bf->ba_enable_beacon_abort);
599 int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
600 struct ieee80211_vif *vif)
602 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
603 struct iwl_beacon_filter_cmd cmd = {
604 IWL_BF_CMD_CONFIG_DEFAULTS,
605 .bf_enable_beacon_filter = cpu_to_le32(1),
609 if (mvmvif != mvm->bf_allowed_vif ||
610 vif->type != NL80211_IFTYPE_STATION || vif->p2p)
613 iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, &cmd);
614 iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd);
615 ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
618 mvmvif->bf_data.bf_enabled = true;
623 int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
624 struct ieee80211_vif *vif)
626 struct iwl_beacon_filter_cmd cmd = {};
627 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
630 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED) ||
631 vif->type != NL80211_IFTYPE_STATION || vif->p2p)
634 ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd);
637 mvmvif->bf_data.bf_enabled = false;
642 int iwl_mvm_update_beacon_filter(struct iwl_mvm *mvm,
643 struct ieee80211_vif *vif)
645 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
647 if (!mvmvif->bf_data.bf_enabled)
650 return iwl_mvm_enable_beacon_filter(mvm, vif);
653 const struct iwl_mvm_power_ops pm_mac_ops = {
654 .power_update_mode = iwl_mvm_power_mac_update_mode,
655 .power_update_device_mode = iwl_mvm_power_update_device,
656 .power_disable = iwl_mvm_power_mac_disable,
657 #ifdef CONFIG_IWLWIFI_DEBUGFS
658 .power_dbgfs_read = iwl_mvm_power_mac_dbgfs_read,