Commit | Line | Data |
---|---|---|
8ca151b5 JB |
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 | |
410dc5aa | 25 | * in the file called COPYING. |
8ca151b5 JB |
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 | ||
e811ada7 AB |
78 | int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm, |
79 | struct iwl_beacon_filter_cmd *cmd) | |
071d4990 AB |
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 | cmd->ba_enable_beacon_abort); | |
89 | IWL_DEBUG_POWER(mvm, "ba_escape_timer is: %d\n", | |
90 | cmd->ba_escape_timer); | |
91 | IWL_DEBUG_POWER(mvm, "bf_debug_flag is: %d\n", | |
92 | cmd->bf_debug_flag); | |
93 | IWL_DEBUG_POWER(mvm, "bf_enable_beacon_filter is: %d\n", | |
94 | cmd->bf_enable_beacon_filter); | |
95 | IWL_DEBUG_POWER(mvm, "bf_energy_delta is: %d\n", | |
96 | cmd->bf_energy_delta); | |
97 | IWL_DEBUG_POWER(mvm, "bf_escape_timer is: %d\n", | |
98 | cmd->bf_escape_timer); | |
99 | IWL_DEBUG_POWER(mvm, "bf_roaming_energy_delta is: %d\n", | |
100 | cmd->bf_roaming_energy_delta); | |
101 | IWL_DEBUG_POWER(mvm, "bf_roaming_state is: %d\n", | |
102 | cmd->bf_roaming_state); | |
103 | IWL_DEBUG_POWER(mvm, "bf_temperature_delta is: %d\n", | |
104 | cmd->bf_temperature_delta); | |
105 | } | |
106 | return ret; | |
107 | } | |
108 | ||
e811ada7 AB |
109 | int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm, |
110 | struct ieee80211_vif *vif, bool enable) | |
071d4990 AB |
111 | { |
112 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
113 | struct iwl_beacon_filter_cmd cmd = { | |
114 | IWL_BF_CMD_CONFIG_DEFAULTS, | |
115 | .bf_enable_beacon_filter = 1, | |
116 | .ba_enable_beacon_abort = enable, | |
117 | }; | |
118 | ||
119 | if (!mvmvif->bf_enabled) | |
120 | return 0; | |
121 | ||
b571a697 | 122 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); |
071d4990 AB |
123 | return iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); |
124 | } | |
125 | ||
3f0b2b3e | 126 | static void iwl_mvm_power_log(struct iwl_mvm *mvm, |
e811ada7 | 127 | struct iwl_mac_power_cmd *cmd) |
3f0b2b3e AB |
128 | { |
129 | IWL_DEBUG_POWER(mvm, | |
e811ada7 AB |
130 | "Sending power table command on mac id 0x%X for power level %d, flags = 0x%X\n", |
131 | cmd->id_and_color, iwlmvm_mod_params.power_scheme, | |
3f0b2b3e | 132 | le16_to_cpu(cmd->flags)); |
e811ada7 AB |
133 | IWL_DEBUG_POWER(mvm, "Keep alive = %u sec\n", |
134 | le16_to_cpu(cmd->keep_alive_seconds)); | |
3f0b2b3e AB |
135 | |
136 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) { | |
137 | IWL_DEBUG_POWER(mvm, "Rx timeout = %u usec\n", | |
138 | le32_to_cpu(cmd->rx_data_timeout)); | |
139 | IWL_DEBUG_POWER(mvm, "Tx timeout = %u usec\n", | |
140 | le32_to_cpu(cmd->tx_data_timeout)); | |
5b1dbfc3 | 141 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) |
1bd2d175 | 142 | IWL_DEBUG_POWER(mvm, "DTIM periods to skip = %u\n", |
e811ada7 | 143 | cmd->skip_dtim_periods); |
bd4ace2a AB |
144 | if (cmd->flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) |
145 | IWL_DEBUG_POWER(mvm, "LP RX RSSI threshold = %u\n", | |
e811ada7 | 146 | cmd->lprx_rssi_threshold); |
3f0b2b3e AB |
147 | } |
148 | } | |
149 | ||
e811ada7 AB |
150 | static void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm, |
151 | struct ieee80211_vif *vif, | |
152 | struct iwl_mac_power_cmd *cmd) | |
8ca151b5 JB |
153 | { |
154 | struct ieee80211_hw *hw = mvm->hw; | |
8ca151b5 JB |
155 | struct ieee80211_chanctx_conf *chanctx_conf; |
156 | struct ieee80211_channel *chan; | |
157 | int dtimper, dtimper_msec; | |
158 | int keep_alive; | |
159 | bool radar_detect = false; | |
b571a697 AB |
160 | struct iwl_mvm_vif *mvmvif __maybe_unused = |
161 | iwl_mvm_vif_from_mac80211(vif); | |
8ca151b5 | 162 | |
e811ada7 AB |
163 | cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, |
164 | mvmvif->color)); | |
165 | dtimper = hw->conf.ps_dtim_period ?: 1; | |
166 | ||
e16cf7ec AB |
167 | /* |
168 | * Regardless of power management state the driver must set | |
169 | * keep alive period. FW will use it for sending keep alive NDPs | |
e811ada7 AB |
170 | * immediately after association. Check that keep alive period |
171 | * is at least 3 * DTIM | |
e16cf7ec | 172 | */ |
e811ada7 AB |
173 | dtimper_msec = dtimper * vif->bss_conf.beacon_int; |
174 | keep_alive = max_t(int, 3 * dtimper_msec, | |
175 | MSEC_PER_SEC * POWER_KEEP_ALIVE_PERIOD_SEC); | |
176 | keep_alive = DIV_ROUND_UP(keep_alive, MSEC_PER_SEC); | |
177 | cmd->keep_alive_seconds = cpu_to_le16(keep_alive); | |
e16cf7ec | 178 | |
ade50652 | 179 | if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM) |
8ca151b5 JB |
180 | return; |
181 | ||
9a613048 AB |
182 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); |
183 | ||
b571a697 AB |
184 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
185 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF && | |
186 | mvmvif->dbgfs_pm.disable_power_off) | |
187 | cmd->flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK); | |
188 | #endif | |
9a613048 AB |
189 | if (!vif->bss_conf.ps) |
190 | return; | |
191 | ||
192 | cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK); | |
8ca151b5 | 193 | |
bd4ace2a AB |
194 | if (vif->bss_conf.beacon_rate && |
195 | (vif->bss_conf.beacon_rate->bitrate == 10 || | |
196 | vif->bss_conf.beacon_rate->bitrate == 60)) { | |
197 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); | |
e811ada7 | 198 | cmd->lprx_rssi_threshold = POWER_LPRX_RSSI_THRESHOLD; |
bd4ace2a AB |
199 | } |
200 | ||
8ca151b5 JB |
201 | /* Check if radar detection is required on current channel */ |
202 | rcu_read_lock(); | |
203 | chanctx_conf = rcu_dereference(vif->chanctx_conf); | |
204 | WARN_ON(!chanctx_conf); | |
205 | if (chanctx_conf) { | |
206 | chan = chanctx_conf->def.chan; | |
207 | radar_detect = chan->flags & IEEE80211_CHAN_RADAR; | |
208 | } | |
209 | rcu_read_unlock(); | |
210 | ||
211 | /* Check skip over DTIM conditions */ | |
212 | if (!radar_detect && (dtimper <= 10) && | |
ee1e8422 AB |
213 | (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_LP || |
214 | mvm->cur_ucode == IWL_UCODE_WOWLAN)) { | |
f4a3e2fe | 215 | cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); |
e811ada7 | 216 | cmd->skip_dtim_periods = 3; |
5b1dbfc3 | 217 | } |
8ca151b5 | 218 | |
ee1e8422 AB |
219 | if (mvm->cur_ucode != IWL_UCODE_WOWLAN) { |
220 | cmd->rx_data_timeout = cpu_to_le32(100 * USEC_PER_MSEC); | |
221 | cmd->tx_data_timeout = cpu_to_le32(100 * USEC_PER_MSEC); | |
222 | } else { | |
223 | cmd->rx_data_timeout = cpu_to_le32(10 * USEC_PER_MSEC); | |
224 | cmd->tx_data_timeout = cpu_to_le32(10 * USEC_PER_MSEC); | |
225 | } | |
b571a697 AB |
226 | |
227 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
228 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE) | |
e811ada7 AB |
229 | cmd->keep_alive_seconds = |
230 | cpu_to_le16(mvmvif->dbgfs_pm.keep_alive_seconds); | |
b571a697 AB |
231 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) { |
232 | if (mvmvif->dbgfs_pm.skip_over_dtim) | |
233 | cmd->flags |= | |
234 | cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); | |
235 | else | |
236 | cmd->flags &= | |
237 | cpu_to_le16(~POWER_FLAGS_SKIP_OVER_DTIM_MSK); | |
238 | } | |
239 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_RX_DATA_TIMEOUT) | |
240 | cmd->rx_data_timeout = | |
241 | cpu_to_le32(mvmvif->dbgfs_pm.rx_data_timeout); | |
242 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_TX_DATA_TIMEOUT) | |
243 | cmd->tx_data_timeout = | |
244 | cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout); | |
245 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS) | |
e811ada7 | 246 | cmd->skip_dtim_periods = mvmvif->dbgfs_pm.skip_dtim_periods; |
bd4ace2a AB |
247 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) { |
248 | if (mvmvif->dbgfs_pm.lprx_ena) | |
249 | cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK); | |
250 | else | |
251 | cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK); | |
252 | } | |
253 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD) | |
e811ada7 | 254 | cmd->lprx_rssi_threshold = mvmvif->dbgfs_pm.lprx_rssi_threshold; |
b571a697 | 255 | #endif /* CONFIG_IWLWIFI_DEBUGFS */ |
8ca151b5 JB |
256 | } |
257 | ||
e811ada7 AB |
258 | static int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm, |
259 | struct ieee80211_vif *vif) | |
8ca151b5 | 260 | { |
071d4990 AB |
261 | int ret; |
262 | bool ba_enable; | |
e811ada7 | 263 | struct iwl_mac_power_cmd cmd = {}; |
8ca151b5 | 264 | |
8ca151b5 JB |
265 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) |
266 | return 0; | |
267 | ||
4bf881f5 AB |
268 | /* |
269 | * TODO: The following vif_count verification is temporary condition. | |
270 | * Avoid power mode update if more than one interface is currently | |
271 | * active. Remove this condition when FW will support power management | |
272 | * on multiple MACs. | |
273 | */ | |
274 | IWL_DEBUG_POWER(mvm, "Currently %d interfaces active\n", | |
275 | mvm->vif_count); | |
276 | if (mvm->vif_count > 1) | |
277 | return 0; | |
278 | ||
f4a3e2fe | 279 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); |
3f0b2b3e | 280 | iwl_mvm_power_log(mvm, &cmd); |
8ca151b5 | 281 | |
e811ada7 | 282 | ret = iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_SYNC, |
071d4990 AB |
283 | sizeof(cmd), &cmd); |
284 | if (ret) | |
285 | return ret; | |
286 | ||
287 | ba_enable = !!(cmd.flags & | |
288 | cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)); | |
289 | ||
290 | return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable); | |
8ca151b5 JB |
291 | } |
292 | ||
e811ada7 AB |
293 | static int iwl_mvm_power_mac_disable(struct iwl_mvm *mvm, |
294 | struct ieee80211_vif *vif) | |
8ca151b5 | 295 | { |
e811ada7 | 296 | struct iwl_mac_power_cmd cmd = {}; |
b571a697 AB |
297 | struct iwl_mvm_vif *mvmvif __maybe_unused = |
298 | iwl_mvm_vif_from_mac80211(vif); | |
8ca151b5 | 299 | |
8ca151b5 JB |
300 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) |
301 | return 0; | |
302 | ||
e811ada7 AB |
303 | cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, |
304 | mvmvif->color)); | |
305 | ||
ade50652 | 306 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
9a613048 AB |
307 | cmd.flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK); |
308 | ||
b571a697 AB |
309 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
310 | if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_DISABLE_POWER_OFF && | |
311 | mvmvif->dbgfs_pm.disable_power_off) | |
312 | cmd.flags &= cpu_to_le16(~POWER_FLAGS_POWER_SAVE_ENA_MSK); | |
313 | #endif | |
3f0b2b3e | 314 | iwl_mvm_power_log(mvm, &cmd); |
8ca151b5 | 315 | |
e811ada7 | 316 | return iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, CMD_ASYNC, |
8ca151b5 JB |
317 | sizeof(cmd), &cmd); |
318 | } | |
7df15b1e | 319 | |
b571a697 | 320 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
e811ada7 AB |
321 | static int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, |
322 | struct ieee80211_vif *vif, char *buf, | |
323 | int bufsz) | |
324 | { | |
325 | struct iwl_mac_power_cmd cmd = {}; | |
326 | int pos = 0; | |
327 | ||
328 | iwl_mvm_power_build_cmd(mvm, vif, &cmd); | |
329 | ||
330 | pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off = %d\n", | |
331 | (cmd.flags & | |
332 | cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK)) ? | |
333 | 0 : 1); | |
334 | pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n", | |
335 | cmd.skip_dtim_periods); | |
336 | pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n", | |
337 | iwlmvm_mod_params.power_scheme); | |
338 | pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n", | |
339 | le16_to_cpu(cmd.flags)); | |
340 | pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n", | |
341 | le16_to_cpu(cmd.keep_alive_seconds)); | |
342 | ||
343 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)) { | |
344 | pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n", | |
345 | (cmd.flags & | |
346 | cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ? | |
347 | 1 : 0); | |
348 | pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout = %d\n", | |
349 | le32_to_cpu(cmd.rx_data_timeout)); | |
350 | pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout = %d\n", | |
351 | le32_to_cpu(cmd.tx_data_timeout)); | |
352 | if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK)) | |
353 | pos += scnprintf(buf+pos, bufsz-pos, | |
354 | "lprx_rssi_threshold = %d\n", | |
355 | cmd.lprx_rssi_threshold); | |
356 | } | |
357 | return pos; | |
358 | } | |
359 | ||
b571a697 AB |
360 | void |
361 | iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif, | |
362 | struct iwl_beacon_filter_cmd *cmd) | |
363 | { | |
364 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
365 | struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf; | |
366 | ||
367 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ENERGY_DELTA) | |
368 | cmd->bf_energy_delta = dbgfs_bf->bf_energy_delta; | |
369 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA) | |
370 | cmd->bf_roaming_energy_delta = | |
371 | dbgfs_bf->bf_roaming_energy_delta; | |
372 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_STATE) | |
373 | cmd->bf_roaming_state = dbgfs_bf->bf_roaming_state; | |
374 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMPERATURE_DELTA) | |
375 | cmd->bf_temperature_delta = dbgfs_bf->bf_temperature_delta; | |
376 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_DEBUG_FLAG) | |
377 | cmd->bf_debug_flag = dbgfs_bf->bf_debug_flag; | |
378 | if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ESCAPE_TIMER) | |
379 | cmd->bf_escape_timer = cpu_to_le32(dbgfs_bf->bf_escape_timer); | |
380 | if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ESCAPE_TIMER) | |
381 | cmd->ba_escape_timer = cpu_to_le32(dbgfs_bf->ba_escape_timer); | |
382 | if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT) | |
383 | cmd->ba_enable_beacon_abort = dbgfs_bf->ba_enable_beacon_abort; | |
384 | } | |
385 | #endif | |
386 | ||
7df15b1e HG |
387 | int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm, |
388 | struct ieee80211_vif *vif) | |
389 | { | |
390 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
391 | struct iwl_beacon_filter_cmd cmd = { | |
071d4990 | 392 | IWL_BF_CMD_CONFIG_DEFAULTS, |
7df15b1e | 393 | .bf_enable_beacon_filter = 1, |
7df15b1e | 394 | }; |
071d4990 | 395 | int ret; |
7df15b1e HG |
396 | |
397 | if (mvmvif != mvm->bf_allowed_vif || | |
398 | vif->type != NL80211_IFTYPE_STATION || vif->p2p) | |
399 | return 0; | |
400 | ||
b571a697 | 401 | iwl_mvm_beacon_filter_debugfs_parameters(vif, &cmd); |
071d4990 AB |
402 | ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); |
403 | ||
404 | if (!ret) | |
405 | mvmvif->bf_enabled = true; | |
406 | ||
407 | return ret; | |
7df15b1e HG |
408 | } |
409 | ||
410 | int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm, | |
411 | struct ieee80211_vif *vif) | |
412 | { | |
071d4990 AB |
413 | struct iwl_beacon_filter_cmd cmd = {}; |
414 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
415 | int ret; | |
7df15b1e HG |
416 | |
417 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) | |
418 | return 0; | |
419 | ||
071d4990 AB |
420 | ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd); |
421 | ||
422 | if (!ret) | |
423 | mvmvif->bf_enabled = false; | |
424 | ||
425 | return ret; | |
7df15b1e | 426 | } |
e811ada7 AB |
427 | |
428 | const struct iwl_mvm_power_ops pm_mac_ops = { | |
429 | .power_update_mode = iwl_mvm_power_mac_update_mode, | |
430 | .power_disable = iwl_mvm_power_mac_disable, | |
431 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
432 | .power_dbgfs_read = iwl_mvm_power_mac_dbgfs_read, | |
433 | #endif | |
434 | }; |