power.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  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 - 2014 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 - 2014 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. #include <linux/kernel.h>
  64. #include <linux/module.h>
  65. #include <linux/slab.h>
  66. #include <net/mac80211.h>
  67. #include "iwl-debug.h"
  68. #include "mvm.h"
  69. #include "iwl-modparams.h"
  70. #include "fw-api-power.h"
  71. #define POWER_KEEP_ALIVE_PERIOD_SEC 25
  72. static
  73. int iwl_mvm_beacon_filter_send_cmd(struct iwl_mvm *mvm,
  74. struct iwl_beacon_filter_cmd *cmd,
  75. u32 flags)
  76. {
  77. IWL_DEBUG_POWER(mvm, "ba_enable_beacon_abort is: %d\n",
  78. le32_to_cpu(cmd->ba_enable_beacon_abort));
  79. IWL_DEBUG_POWER(mvm, "ba_escape_timer is: %d\n",
  80. le32_to_cpu(cmd->ba_escape_timer));
  81. IWL_DEBUG_POWER(mvm, "bf_debug_flag is: %d\n",
  82. le32_to_cpu(cmd->bf_debug_flag));
  83. IWL_DEBUG_POWER(mvm, "bf_enable_beacon_filter is: %d\n",
  84. le32_to_cpu(cmd->bf_enable_beacon_filter));
  85. IWL_DEBUG_POWER(mvm, "bf_energy_delta is: %d\n",
  86. le32_to_cpu(cmd->bf_energy_delta));
  87. IWL_DEBUG_POWER(mvm, "bf_escape_timer is: %d\n",
  88. le32_to_cpu(cmd->bf_escape_timer));
  89. IWL_DEBUG_POWER(mvm, "bf_roaming_energy_delta is: %d\n",
  90. le32_to_cpu(cmd->bf_roaming_energy_delta));
  91. IWL_DEBUG_POWER(mvm, "bf_roaming_state is: %d\n",
  92. le32_to_cpu(cmd->bf_roaming_state));
  93. IWL_DEBUG_POWER(mvm, "bf_temp_threshold is: %d\n",
  94. le32_to_cpu(cmd->bf_temp_threshold));
  95. IWL_DEBUG_POWER(mvm, "bf_temp_fast_filter is: %d\n",
  96. le32_to_cpu(cmd->bf_temp_fast_filter));
  97. IWL_DEBUG_POWER(mvm, "bf_temp_slow_filter is: %d\n",
  98. le32_to_cpu(cmd->bf_temp_slow_filter));
  99. return iwl_mvm_send_cmd_pdu(mvm, REPLY_BEACON_FILTERING_CMD, flags,
  100. sizeof(struct iwl_beacon_filter_cmd), cmd);
  101. }
  102. static
  103. void iwl_mvm_beacon_filter_set_cqm_params(struct iwl_mvm *mvm,
  104. struct ieee80211_vif *vif,
  105. struct iwl_beacon_filter_cmd *cmd)
  106. {
  107. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  108. if (vif->bss_conf.cqm_rssi_thold) {
  109. cmd->bf_energy_delta =
  110. cpu_to_le32(vif->bss_conf.cqm_rssi_hyst);
  111. /* fw uses an absolute value for this */
  112. cmd->bf_roaming_state =
  113. cpu_to_le32(-vif->bss_conf.cqm_rssi_thold);
  114. }
  115. cmd->ba_enable_beacon_abort = cpu_to_le32(mvmvif->bf_data.ba_enabled);
  116. }
  117. static void iwl_mvm_power_log(struct iwl_mvm *mvm,
  118. struct iwl_mac_power_cmd *cmd)
  119. {
  120. IWL_DEBUG_POWER(mvm,
  121. "Sending power table command on mac id 0x%X for power level %d, flags = 0x%X\n",
  122. cmd->id_and_color, iwlmvm_mod_params.power_scheme,
  123. le16_to_cpu(cmd->flags));
  124. IWL_DEBUG_POWER(mvm, "Keep alive = %u sec\n",
  125. le16_to_cpu(cmd->keep_alive_seconds));
  126. if (!(cmd->flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK))) {
  127. IWL_DEBUG_POWER(mvm, "Disable power management\n");
  128. return;
  129. }
  130. IWL_DEBUG_POWER(mvm, "Rx timeout = %u usec\n",
  131. le32_to_cpu(cmd->rx_data_timeout));
  132. IWL_DEBUG_POWER(mvm, "Tx timeout = %u usec\n",
  133. le32_to_cpu(cmd->tx_data_timeout));
  134. if (cmd->flags & cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK))
  135. IWL_DEBUG_POWER(mvm, "DTIM periods to skip = %u\n",
  136. cmd->skip_dtim_periods);
  137. if (cmd->flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
  138. IWL_DEBUG_POWER(mvm, "LP RX RSSI threshold = %u\n",
  139. cmd->lprx_rssi_threshold);
  140. if (cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)) {
  141. IWL_DEBUG_POWER(mvm, "uAPSD enabled\n");
  142. IWL_DEBUG_POWER(mvm, "Rx timeout (uAPSD) = %u usec\n",
  143. le32_to_cpu(cmd->rx_data_timeout_uapsd));
  144. IWL_DEBUG_POWER(mvm, "Tx timeout (uAPSD) = %u usec\n",
  145. le32_to_cpu(cmd->tx_data_timeout_uapsd));
  146. IWL_DEBUG_POWER(mvm, "QNDP TID = %d\n", cmd->qndp_tid);
  147. IWL_DEBUG_POWER(mvm, "ACs flags = 0x%x\n", cmd->uapsd_ac_flags);
  148. IWL_DEBUG_POWER(mvm, "Max SP = %d\n", cmd->uapsd_max_sp);
  149. }
  150. }
  151. static void iwl_mvm_power_configure_uapsd(struct iwl_mvm *mvm,
  152. struct ieee80211_vif *vif,
  153. struct iwl_mac_power_cmd *cmd)
  154. {
  155. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  156. enum ieee80211_ac_numbers ac;
  157. bool tid_found = false;
  158. for (ac = IEEE80211_AC_VO; ac <= IEEE80211_AC_BK; ac++) {
  159. if (!mvmvif->queue_params[ac].uapsd)
  160. continue;
  161. if (mvm->cur_ucode != IWL_UCODE_WOWLAN)
  162. cmd->flags |=
  163. cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK);
  164. cmd->uapsd_ac_flags |= BIT(ac);
  165. /* QNDP TID - the highest TID with no admission control */
  166. if (!tid_found && !mvmvif->queue_params[ac].acm) {
  167. tid_found = true;
  168. switch (ac) {
  169. case IEEE80211_AC_VO:
  170. cmd->qndp_tid = 6;
  171. break;
  172. case IEEE80211_AC_VI:
  173. cmd->qndp_tid = 5;
  174. break;
  175. case IEEE80211_AC_BE:
  176. cmd->qndp_tid = 0;
  177. break;
  178. case IEEE80211_AC_BK:
  179. cmd->qndp_tid = 1;
  180. break;
  181. }
  182. }
  183. }
  184. if (!(cmd->flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)))
  185. return;
  186. cmd->flags |= cpu_to_le16(POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK);
  187. if (cmd->uapsd_ac_flags == (BIT(IEEE80211_AC_VO) |
  188. BIT(IEEE80211_AC_VI) |
  189. BIT(IEEE80211_AC_BE) |
  190. BIT(IEEE80211_AC_BK))) {
  191. cmd->flags |= cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
  192. cmd->snooze_interval = cpu_to_le16(IWL_MVM_PS_SNOOZE_INTERVAL);
  193. cmd->snooze_window = (mvm->cur_ucode == IWL_UCODE_WOWLAN) ?
  194. cpu_to_le16(IWL_MVM_WOWLAN_PS_SNOOZE_WINDOW) :
  195. cpu_to_le16(IWL_MVM_PS_SNOOZE_WINDOW);
  196. }
  197. cmd->uapsd_max_sp = IWL_UAPSD_MAX_SP;
  198. if (mvm->cur_ucode == IWL_UCODE_WOWLAN || cmd->flags &
  199. cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
  200. cmd->rx_data_timeout_uapsd =
  201. cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT);
  202. cmd->tx_data_timeout_uapsd =
  203. cpu_to_le32(IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT);
  204. } else {
  205. cmd->rx_data_timeout_uapsd =
  206. cpu_to_le32(IWL_MVM_UAPSD_RX_DATA_TIMEOUT);
  207. cmd->tx_data_timeout_uapsd =
  208. cpu_to_le32(IWL_MVM_UAPSD_TX_DATA_TIMEOUT);
  209. }
  210. if (cmd->flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)) {
  211. cmd->heavy_tx_thld_packets =
  212. IWL_MVM_PS_SNOOZE_HEAVY_TX_THLD_PACKETS;
  213. cmd->heavy_rx_thld_packets =
  214. IWL_MVM_PS_SNOOZE_HEAVY_RX_THLD_PACKETS;
  215. } else {
  216. cmd->heavy_tx_thld_packets =
  217. IWL_MVM_PS_HEAVY_TX_THLD_PACKETS;
  218. cmd->heavy_rx_thld_packets =
  219. IWL_MVM_PS_HEAVY_RX_THLD_PACKETS;
  220. }
  221. cmd->heavy_tx_thld_percentage =
  222. IWL_MVM_PS_HEAVY_TX_THLD_PERCENT;
  223. cmd->heavy_rx_thld_percentage =
  224. IWL_MVM_PS_HEAVY_RX_THLD_PERCENT;
  225. }
  226. static bool iwl_mvm_power_allow_uapsd(struct iwl_mvm *mvm,
  227. struct ieee80211_vif *vif)
  228. {
  229. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  230. if (!memcmp(mvmvif->uapsd_misbehaving_bssid, vif->bss_conf.bssid,
  231. ETH_ALEN))
  232. return false;
  233. if (vif->p2p &&
  234. !(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD))
  235. return false;
  236. /*
  237. * Avoid using uAPSD if P2P client is associated to GO that uses
  238. * opportunistic power save. This is due to current FW limitation.
  239. */
  240. if (vif->p2p &&
  241. (vif->bss_conf.p2p_noa_attr.oppps_ctwindow &
  242. IEEE80211_P2P_OPPPS_ENABLE_BIT))
  243. return false;
  244. /*
  245. * Avoid using uAPSD if client is in DCM -
  246. * low latency issue in Miracast
  247. */
  248. if (iwl_mvm_phy_ctx_count(mvm) >= 2)
  249. return false;
  250. return true;
  251. }
  252. static void iwl_mvm_power_build_cmd(struct iwl_mvm *mvm,
  253. struct ieee80211_vif *vif,
  254. struct iwl_mac_power_cmd *cmd)
  255. {
  256. struct ieee80211_chanctx_conf *chanctx_conf;
  257. struct ieee80211_channel *chan;
  258. int dtimper, dtimper_msec;
  259. int keep_alive;
  260. bool radar_detect = false;
  261. struct iwl_mvm_vif *mvmvif __maybe_unused =
  262. iwl_mvm_vif_from_mac80211(vif);
  263. cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
  264. mvmvif->color));
  265. dtimper = vif->bss_conf.dtim_period;
  266. /*
  267. * Regardless of power management state the driver must set
  268. * keep alive period. FW will use it for sending keep alive NDPs
  269. * immediately after association. Check that keep alive period
  270. * is at least 3 * DTIM
  271. */
  272. dtimper_msec = dtimper * vif->bss_conf.beacon_int;
  273. keep_alive = max_t(int, 3 * dtimper_msec,
  274. MSEC_PER_SEC * POWER_KEEP_ALIVE_PERIOD_SEC);
  275. keep_alive = DIV_ROUND_UP(keep_alive, MSEC_PER_SEC);
  276. cmd->keep_alive_seconds = cpu_to_le16(keep_alive);
  277. if (mvm->ps_disabled)
  278. return;
  279. cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_SAVE_ENA_MSK);
  280. if (!vif->bss_conf.ps || iwl_mvm_vif_low_latency(mvmvif) ||
  281. !mvmvif->pm_enabled)
  282. return;
  283. cmd->flags |= cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK);
  284. if (vif->bss_conf.beacon_rate &&
  285. (vif->bss_conf.beacon_rate->bitrate == 10 ||
  286. vif->bss_conf.beacon_rate->bitrate == 60)) {
  287. cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK);
  288. cmd->lprx_rssi_threshold = POWER_LPRX_RSSI_THRESHOLD;
  289. }
  290. /* Check if radar detection is required on current channel */
  291. rcu_read_lock();
  292. chanctx_conf = rcu_dereference(vif->chanctx_conf);
  293. WARN_ON(!chanctx_conf);
  294. if (chanctx_conf) {
  295. chan = chanctx_conf->def.chan;
  296. radar_detect = chan->flags & IEEE80211_CHAN_RADAR;
  297. }
  298. rcu_read_unlock();
  299. /* Check skip over DTIM conditions */
  300. if (!radar_detect && (dtimper <= 10) &&
  301. (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_LP ||
  302. mvm->cur_ucode == IWL_UCODE_WOWLAN)) {
  303. cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
  304. cmd->skip_dtim_periods = 3;
  305. }
  306. if (mvm->cur_ucode != IWL_UCODE_WOWLAN) {
  307. cmd->rx_data_timeout =
  308. cpu_to_le32(IWL_MVM_DEFAULT_PS_RX_DATA_TIMEOUT);
  309. cmd->tx_data_timeout =
  310. cpu_to_le32(IWL_MVM_DEFAULT_PS_TX_DATA_TIMEOUT);
  311. } else {
  312. cmd->rx_data_timeout =
  313. cpu_to_le32(IWL_MVM_WOWLAN_PS_RX_DATA_TIMEOUT);
  314. cmd->tx_data_timeout =
  315. cpu_to_le32(IWL_MVM_WOWLAN_PS_TX_DATA_TIMEOUT);
  316. }
  317. if (iwl_mvm_power_allow_uapsd(mvm, vif))
  318. iwl_mvm_power_configure_uapsd(mvm, vif, cmd);
  319. #ifdef CONFIG_IWLWIFI_DEBUGFS
  320. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_KEEP_ALIVE)
  321. cmd->keep_alive_seconds =
  322. cpu_to_le16(mvmvif->dbgfs_pm.keep_alive_seconds);
  323. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_OVER_DTIM) {
  324. if (mvmvif->dbgfs_pm.skip_over_dtim)
  325. cmd->flags |=
  326. cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
  327. else
  328. cmd->flags &=
  329. cpu_to_le16(~POWER_FLAGS_SKIP_OVER_DTIM_MSK);
  330. }
  331. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_RX_DATA_TIMEOUT)
  332. cmd->rx_data_timeout =
  333. cpu_to_le32(mvmvif->dbgfs_pm.rx_data_timeout);
  334. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_TX_DATA_TIMEOUT)
  335. cmd->tx_data_timeout =
  336. cpu_to_le32(mvmvif->dbgfs_pm.tx_data_timeout);
  337. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SKIP_DTIM_PERIODS)
  338. cmd->skip_dtim_periods = mvmvif->dbgfs_pm.skip_dtim_periods;
  339. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_ENA) {
  340. if (mvmvif->dbgfs_pm.lprx_ena)
  341. cmd->flags |= cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK);
  342. else
  343. cmd->flags &= cpu_to_le16(~POWER_FLAGS_LPRX_ENA_MSK);
  344. }
  345. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_LPRX_RSSI_THRESHOLD)
  346. cmd->lprx_rssi_threshold = mvmvif->dbgfs_pm.lprx_rssi_threshold;
  347. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_SNOOZE_ENABLE) {
  348. if (mvmvif->dbgfs_pm.snooze_ena)
  349. cmd->flags |=
  350. cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK);
  351. else
  352. cmd->flags &=
  353. cpu_to_le16(~POWER_FLAGS_SNOOZE_ENA_MSK);
  354. }
  355. if (mvmvif->dbgfs_pm.mask & MVM_DEBUGFS_PM_UAPSD_MISBEHAVING) {
  356. u16 flag = POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK;
  357. if (mvmvif->dbgfs_pm.uapsd_misbehaving)
  358. cmd->flags |= cpu_to_le16(flag);
  359. else
  360. cmd->flags &= cpu_to_le16(flag);
  361. }
  362. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  363. }
  364. static int iwl_mvm_power_send_cmd(struct iwl_mvm *mvm,
  365. struct ieee80211_vif *vif)
  366. {
  367. struct iwl_mac_power_cmd cmd = {};
  368. iwl_mvm_power_build_cmd(mvm, vif, &cmd);
  369. iwl_mvm_power_log(mvm, &cmd);
  370. #ifdef CONFIG_IWLWIFI_DEBUGFS
  371. memcpy(&iwl_mvm_vif_from_mac80211(vif)->mac_pwr_cmd, &cmd, sizeof(cmd));
  372. #endif
  373. return iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, 0,
  374. sizeof(cmd), &cmd);
  375. }
  376. int iwl_mvm_power_update_device(struct iwl_mvm *mvm)
  377. {
  378. struct iwl_device_power_cmd cmd = {
  379. .flags = cpu_to_le16(DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK),
  380. };
  381. if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM)
  382. mvm->ps_disabled = true;
  383. if (mvm->ps_disabled)
  384. cmd.flags |= cpu_to_le16(DEVICE_POWER_FLAGS_CAM_MSK);
  385. #ifdef CONFIG_IWLWIFI_DEBUGFS
  386. if ((mvm->cur_ucode == IWL_UCODE_WOWLAN) ? mvm->disable_power_off_d3 :
  387. mvm->disable_power_off)
  388. cmd.flags &=
  389. cpu_to_le16(~DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK);
  390. #endif
  391. IWL_DEBUG_POWER(mvm,
  392. "Sending device power command with flags = 0x%X\n",
  393. cmd.flags);
  394. return iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, 0, sizeof(cmd),
  395. &cmd);
  396. }
  397. void iwl_mvm_power_vif_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
  398. {
  399. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  400. if (memcmp(vif->bss_conf.bssid, mvmvif->uapsd_misbehaving_bssid,
  401. ETH_ALEN))
  402. memset(mvmvif->uapsd_misbehaving_bssid, 0, ETH_ALEN);
  403. }
  404. static void iwl_mvm_power_uapsd_misbehav_ap_iterator(void *_data, u8 *mac,
  405. struct ieee80211_vif *vif)
  406. {
  407. u8 *ap_sta_id = _data;
  408. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  409. /* The ap_sta_id is not expected to change during current association
  410. * so no explicit protection is needed
  411. */
  412. if (mvmvif->ap_sta_id == *ap_sta_id)
  413. memcpy(mvmvif->uapsd_misbehaving_bssid, vif->bss_conf.bssid,
  414. ETH_ALEN);
  415. }
  416. int iwl_mvm_power_uapsd_misbehaving_ap_notif(struct iwl_mvm *mvm,
  417. struct iwl_rx_cmd_buffer *rxb,
  418. struct iwl_device_cmd *cmd)
  419. {
  420. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  421. struct iwl_uapsd_misbehaving_ap_notif *notif = (void *)pkt->data;
  422. u8 ap_sta_id = le32_to_cpu(notif->sta_id);
  423. ieee80211_iterate_active_interfaces_atomic(
  424. mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
  425. iwl_mvm_power_uapsd_misbehav_ap_iterator, &ap_sta_id);
  426. return 0;
  427. }
  428. struct iwl_power_vifs {
  429. struct iwl_mvm *mvm;
  430. struct ieee80211_vif *bf_vif;
  431. struct ieee80211_vif *bss_vif;
  432. struct ieee80211_vif *p2p_vif;
  433. struct ieee80211_vif *ap_vif;
  434. struct ieee80211_vif *monitor_vif;
  435. bool p2p_active;
  436. bool bss_active;
  437. bool ap_active;
  438. bool monitor_active;
  439. bool bss_tdls;
  440. bool p2p_tdls;
  441. };
  442. static void iwl_mvm_power_iterator(void *_data, u8 *mac,
  443. struct ieee80211_vif *vif)
  444. {
  445. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  446. struct iwl_power_vifs *power_iterator = _data;
  447. mvmvif->pm_enabled = false;
  448. switch (ieee80211_vif_type_p2p(vif)) {
  449. case NL80211_IFTYPE_P2P_DEVICE:
  450. break;
  451. case NL80211_IFTYPE_P2P_GO:
  452. case NL80211_IFTYPE_AP:
  453. /* only a single MAC of the same type */
  454. WARN_ON(power_iterator->ap_vif);
  455. power_iterator->ap_vif = vif;
  456. if (mvmvif->phy_ctxt)
  457. if (mvmvif->phy_ctxt->id < MAX_PHYS)
  458. power_iterator->ap_active = true;
  459. break;
  460. case NL80211_IFTYPE_MONITOR:
  461. /* only a single MAC of the same type */
  462. WARN_ON(power_iterator->monitor_vif);
  463. power_iterator->monitor_vif = vif;
  464. if (mvmvif->phy_ctxt)
  465. if (mvmvif->phy_ctxt->id < MAX_PHYS)
  466. power_iterator->monitor_active = true;
  467. break;
  468. case NL80211_IFTYPE_P2P_CLIENT:
  469. /* only a single MAC of the same type */
  470. WARN_ON(power_iterator->p2p_vif);
  471. power_iterator->p2p_vif = vif;
  472. power_iterator->p2p_tdls =
  473. !!iwl_mvm_tdls_sta_count(power_iterator->mvm, vif);
  474. if (mvmvif->phy_ctxt)
  475. if (mvmvif->phy_ctxt->id < MAX_PHYS)
  476. power_iterator->p2p_active = true;
  477. break;
  478. case NL80211_IFTYPE_STATION:
  479. /* only a single MAC of the same type */
  480. WARN_ON(power_iterator->bss_vif);
  481. power_iterator->bss_vif = vif;
  482. power_iterator->bss_tdls =
  483. !!iwl_mvm_tdls_sta_count(power_iterator->mvm, vif);
  484. if (mvmvif->phy_ctxt)
  485. if (mvmvif->phy_ctxt->id < MAX_PHYS)
  486. power_iterator->bss_active = true;
  487. if (mvmvif->bf_data.bf_enabled &&
  488. !WARN_ON(power_iterator->bf_vif))
  489. power_iterator->bf_vif = vif;
  490. break;
  491. default:
  492. break;
  493. }
  494. }
  495. static void
  496. iwl_mvm_power_set_pm(struct iwl_mvm *mvm,
  497. struct iwl_power_vifs *vifs)
  498. {
  499. struct iwl_mvm_vif *bss_mvmvif = NULL;
  500. struct iwl_mvm_vif *p2p_mvmvif = NULL;
  501. struct iwl_mvm_vif *ap_mvmvif = NULL;
  502. bool client_same_channel = false;
  503. bool ap_same_channel = false;
  504. lockdep_assert_held(&mvm->mutex);
  505. /* get vifs info + set pm_enable to false */
  506. ieee80211_iterate_active_interfaces_atomic(mvm->hw,
  507. IEEE80211_IFACE_ITER_NORMAL,
  508. iwl_mvm_power_iterator, vifs);
  509. if (vifs->bss_vif)
  510. bss_mvmvif = iwl_mvm_vif_from_mac80211(vifs->bss_vif);
  511. if (vifs->p2p_vif)
  512. p2p_mvmvif = iwl_mvm_vif_from_mac80211(vifs->p2p_vif);
  513. if (vifs->ap_vif)
  514. ap_mvmvif = iwl_mvm_vif_from_mac80211(vifs->ap_vif);
  515. /* enable PM on bss if bss stand alone */
  516. if (vifs->bss_active && !vifs->p2p_active && !vifs->ap_active &&
  517. !vifs->bss_tdls) {
  518. bss_mvmvif->pm_enabled = true;
  519. return;
  520. }
  521. /* enable PM on p2p if p2p stand alone */
  522. if (vifs->p2p_active && !vifs->bss_active && !vifs->ap_active &&
  523. !vifs->p2p_tdls) {
  524. if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PM)
  525. p2p_mvmvif->pm_enabled = true;
  526. return;
  527. }
  528. if (vifs->bss_active && vifs->p2p_active)
  529. client_same_channel = (bss_mvmvif->phy_ctxt->id ==
  530. p2p_mvmvif->phy_ctxt->id);
  531. if (vifs->bss_active && vifs->ap_active)
  532. ap_same_channel = (bss_mvmvif->phy_ctxt->id ==
  533. ap_mvmvif->phy_ctxt->id);
  534. /* clients are not stand alone: enable PM if DCM */
  535. if (!(client_same_channel || ap_same_channel) &&
  536. (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM)) {
  537. if (vifs->bss_active)
  538. bss_mvmvif->pm_enabled = true;
  539. if (vifs->p2p_active &&
  540. (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PM))
  541. p2p_mvmvif->pm_enabled = true;
  542. return;
  543. }
  544. /*
  545. * There is only one channel in the system and there are only
  546. * bss and p2p clients that share it
  547. */
  548. if (client_same_channel && !vifs->ap_active &&
  549. (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_SCM)) {
  550. /* share same channel*/
  551. bss_mvmvif->pm_enabled = true;
  552. if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_P2P_PM)
  553. p2p_mvmvif->pm_enabled = true;
  554. }
  555. }
  556. #ifdef CONFIG_IWLWIFI_DEBUGFS
  557. int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm,
  558. struct ieee80211_vif *vif, char *buf,
  559. int bufsz)
  560. {
  561. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  562. struct iwl_mac_power_cmd cmd = {};
  563. int pos = 0;
  564. mutex_lock(&mvm->mutex);
  565. memcpy(&cmd, &mvmvif->mac_pwr_cmd, sizeof(cmd));
  566. mutex_unlock(&mvm->mutex);
  567. pos += scnprintf(buf+pos, bufsz-pos, "power_scheme = %d\n",
  568. iwlmvm_mod_params.power_scheme);
  569. pos += scnprintf(buf+pos, bufsz-pos, "flags = 0x%x\n",
  570. le16_to_cpu(cmd.flags));
  571. pos += scnprintf(buf+pos, bufsz-pos, "keep_alive = %d\n",
  572. le16_to_cpu(cmd.keep_alive_seconds));
  573. if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK)))
  574. return pos;
  575. pos += scnprintf(buf+pos, bufsz-pos, "skip_over_dtim = %d\n",
  576. (cmd.flags &
  577. cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK)) ? 1 : 0);
  578. pos += scnprintf(buf+pos, bufsz-pos, "skip_dtim_periods = %d\n",
  579. cmd.skip_dtim_periods);
  580. if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK))) {
  581. pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout = %d\n",
  582. le32_to_cpu(cmd.rx_data_timeout));
  583. pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout = %d\n",
  584. le32_to_cpu(cmd.tx_data_timeout));
  585. }
  586. if (cmd.flags & cpu_to_le16(POWER_FLAGS_LPRX_ENA_MSK))
  587. pos += scnprintf(buf+pos, bufsz-pos,
  588. "lprx_rssi_threshold = %d\n",
  589. cmd.lprx_rssi_threshold);
  590. if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_ADVANCE_PM_ENA_MSK)))
  591. return pos;
  592. pos += scnprintf(buf+pos, bufsz-pos, "rx_data_timeout_uapsd = %d\n",
  593. le32_to_cpu(cmd.rx_data_timeout_uapsd));
  594. pos += scnprintf(buf+pos, bufsz-pos, "tx_data_timeout_uapsd = %d\n",
  595. le32_to_cpu(cmd.tx_data_timeout_uapsd));
  596. pos += scnprintf(buf+pos, bufsz-pos, "qndp_tid = %d\n", cmd.qndp_tid);
  597. pos += scnprintf(buf+pos, bufsz-pos, "uapsd_ac_flags = 0x%x\n",
  598. cmd.uapsd_ac_flags);
  599. pos += scnprintf(buf+pos, bufsz-pos, "uapsd_max_sp = %d\n",
  600. cmd.uapsd_max_sp);
  601. pos += scnprintf(buf+pos, bufsz-pos, "heavy_tx_thld_packets = %d\n",
  602. cmd.heavy_tx_thld_packets);
  603. pos += scnprintf(buf+pos, bufsz-pos, "heavy_rx_thld_packets = %d\n",
  604. cmd.heavy_rx_thld_packets);
  605. pos += scnprintf(buf+pos, bufsz-pos, "heavy_tx_thld_percentage = %d\n",
  606. cmd.heavy_tx_thld_percentage);
  607. pos += scnprintf(buf+pos, bufsz-pos, "heavy_rx_thld_percentage = %d\n",
  608. cmd.heavy_rx_thld_percentage);
  609. pos += scnprintf(buf+pos, bufsz-pos, "uapsd_misbehaving_enable = %d\n",
  610. (cmd.flags &
  611. cpu_to_le16(POWER_FLAGS_UAPSD_MISBEHAVING_ENA_MSK)) ?
  612. 1 : 0);
  613. if (!(cmd.flags & cpu_to_le16(POWER_FLAGS_SNOOZE_ENA_MSK)))
  614. return pos;
  615. pos += scnprintf(buf+pos, bufsz-pos, "snooze_interval = %d\n",
  616. cmd.snooze_interval);
  617. pos += scnprintf(buf+pos, bufsz-pos, "snooze_window = %d\n",
  618. cmd.snooze_window);
  619. return pos;
  620. }
  621. void
  622. iwl_mvm_beacon_filter_debugfs_parameters(struct ieee80211_vif *vif,
  623. struct iwl_beacon_filter_cmd *cmd)
  624. {
  625. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  626. struct iwl_dbgfs_bf *dbgfs_bf = &mvmvif->dbgfs_bf;
  627. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ENERGY_DELTA)
  628. cmd->bf_energy_delta = cpu_to_le32(dbgfs_bf->bf_energy_delta);
  629. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_ENERGY_DELTA)
  630. cmd->bf_roaming_energy_delta =
  631. cpu_to_le32(dbgfs_bf->bf_roaming_energy_delta);
  632. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ROAMING_STATE)
  633. cmd->bf_roaming_state = cpu_to_le32(dbgfs_bf->bf_roaming_state);
  634. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_THRESHOLD)
  635. cmd->bf_temp_threshold =
  636. cpu_to_le32(dbgfs_bf->bf_temp_threshold);
  637. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_FAST_FILTER)
  638. cmd->bf_temp_fast_filter =
  639. cpu_to_le32(dbgfs_bf->bf_temp_fast_filter);
  640. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_TEMP_SLOW_FILTER)
  641. cmd->bf_temp_slow_filter =
  642. cpu_to_le32(dbgfs_bf->bf_temp_slow_filter);
  643. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_DEBUG_FLAG)
  644. cmd->bf_debug_flag = cpu_to_le32(dbgfs_bf->bf_debug_flag);
  645. if (dbgfs_bf->mask & MVM_DEBUGFS_BF_ESCAPE_TIMER)
  646. cmd->bf_escape_timer = cpu_to_le32(dbgfs_bf->bf_escape_timer);
  647. if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ESCAPE_TIMER)
  648. cmd->ba_escape_timer = cpu_to_le32(dbgfs_bf->ba_escape_timer);
  649. if (dbgfs_bf->mask & MVM_DEBUGFS_BA_ENABLE_BEACON_ABORT)
  650. cmd->ba_enable_beacon_abort =
  651. cpu_to_le32(dbgfs_bf->ba_enable_beacon_abort);
  652. }
  653. #endif
  654. static int _iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  655. struct ieee80211_vif *vif,
  656. struct iwl_beacon_filter_cmd *cmd,
  657. u32 cmd_flags,
  658. bool d0i3)
  659. {
  660. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  661. int ret;
  662. if (mvmvif != mvm->bf_allowed_vif || !vif->bss_conf.dtim_period ||
  663. vif->type != NL80211_IFTYPE_STATION || vif->p2p)
  664. return 0;
  665. iwl_mvm_beacon_filter_set_cqm_params(mvm, vif, cmd);
  666. if (!d0i3)
  667. iwl_mvm_beacon_filter_debugfs_parameters(vif, cmd);
  668. ret = iwl_mvm_beacon_filter_send_cmd(mvm, cmd, cmd_flags);
  669. /* don't change bf_enabled in case of temporary d0i3 configuration */
  670. if (!ret && !d0i3)
  671. mvmvif->bf_data.bf_enabled = true;
  672. return ret;
  673. }
  674. int iwl_mvm_enable_beacon_filter(struct iwl_mvm *mvm,
  675. struct ieee80211_vif *vif,
  676. u32 flags)
  677. {
  678. struct iwl_beacon_filter_cmd cmd = {
  679. IWL_BF_CMD_CONFIG_DEFAULTS,
  680. .bf_enable_beacon_filter = cpu_to_le32(1),
  681. };
  682. return _iwl_mvm_enable_beacon_filter(mvm, vif, &cmd, flags, false);
  683. }
  684. static int iwl_mvm_update_beacon_abort(struct iwl_mvm *mvm,
  685. struct ieee80211_vif *vif,
  686. bool enable)
  687. {
  688. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  689. struct iwl_beacon_filter_cmd cmd = {
  690. IWL_BF_CMD_CONFIG_DEFAULTS,
  691. .bf_enable_beacon_filter = cpu_to_le32(1),
  692. };
  693. if (!mvmvif->bf_data.bf_enabled)
  694. return 0;
  695. if (mvm->cur_ucode == IWL_UCODE_WOWLAN)
  696. cmd.ba_escape_timer = cpu_to_le32(IWL_BA_ESCAPE_TIMER_D3);
  697. mvmvif->bf_data.ba_enabled = enable;
  698. return _iwl_mvm_enable_beacon_filter(mvm, vif, &cmd, 0, false);
  699. }
  700. int iwl_mvm_disable_beacon_filter(struct iwl_mvm *mvm,
  701. struct ieee80211_vif *vif,
  702. u32 flags)
  703. {
  704. struct iwl_beacon_filter_cmd cmd = {};
  705. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  706. int ret;
  707. if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
  708. return 0;
  709. ret = iwl_mvm_beacon_filter_send_cmd(mvm, &cmd, flags);
  710. if (!ret)
  711. mvmvif->bf_data.bf_enabled = false;
  712. return ret;
  713. }
  714. int iwl_mvm_power_update_mac(struct iwl_mvm *mvm)
  715. {
  716. struct iwl_mvm_vif *mvmvif;
  717. struct iwl_power_vifs vifs = {
  718. .mvm = mvm,
  719. };
  720. bool ba_enable;
  721. int ret;
  722. lockdep_assert_held(&mvm->mutex);
  723. iwl_mvm_power_set_pm(mvm, &vifs);
  724. /* disable PS if CAM */
  725. if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM) {
  726. mvm->ps_disabled = true;
  727. } else {
  728. /* don't update device power state unless we add / remove monitor */
  729. if (vifs.monitor_vif) {
  730. if (vifs.monitor_active)
  731. mvm->ps_disabled = true;
  732. ret = iwl_mvm_power_update_device(mvm);
  733. if (ret)
  734. return ret;
  735. }
  736. }
  737. if (vifs.bss_vif) {
  738. ret = iwl_mvm_power_send_cmd(mvm, vifs.bss_vif);
  739. if (ret)
  740. return ret;
  741. }
  742. if (vifs.p2p_vif) {
  743. ret = iwl_mvm_power_send_cmd(mvm, vifs.p2p_vif);
  744. if (ret)
  745. return ret;
  746. }
  747. if (!vifs.bf_vif)
  748. return 0;
  749. mvmvif = iwl_mvm_vif_from_mac80211(vifs.bf_vif);
  750. ba_enable = !(!mvmvif->pm_enabled || mvm->ps_disabled ||
  751. !vifs.bf_vif->bss_conf.ps ||
  752. iwl_mvm_vif_low_latency(mvmvif));
  753. return iwl_mvm_update_beacon_abort(mvm, vifs.bf_vif, ba_enable);
  754. }
  755. int iwl_mvm_update_d0i3_power_mode(struct iwl_mvm *mvm,
  756. struct ieee80211_vif *vif,
  757. bool enable, u32 flags)
  758. {
  759. int ret;
  760. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  761. struct iwl_mac_power_cmd cmd = {};
  762. if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
  763. return 0;
  764. if (!vif->bss_conf.assoc)
  765. return 0;
  766. iwl_mvm_power_build_cmd(mvm, vif, &cmd);
  767. if (enable) {
  768. /* configure skip over dtim up to 300 msec */
  769. int dtimper = vif->bss_conf.dtim_period ?: 1;
  770. int dtimper_msec = dtimper * vif->bss_conf.beacon_int;
  771. if (WARN_ON(!dtimper_msec))
  772. return 0;
  773. cmd.skip_dtim_periods = 300 / dtimper_msec;
  774. if (cmd.skip_dtim_periods)
  775. cmd.flags |=
  776. cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK);
  777. }
  778. iwl_mvm_power_log(mvm, &cmd);
  779. #ifdef CONFIG_IWLWIFI_DEBUGFS
  780. memcpy(&mvmvif->mac_pwr_cmd, &cmd, sizeof(cmd));
  781. #endif
  782. ret = iwl_mvm_send_cmd_pdu(mvm, MAC_PM_POWER_TABLE, flags,
  783. sizeof(cmd), &cmd);
  784. if (ret)
  785. return ret;
  786. /* configure beacon filtering */
  787. if (mvmvif != mvm->bf_allowed_vif)
  788. return 0;
  789. if (enable) {
  790. struct iwl_beacon_filter_cmd cmd_bf = {
  791. IWL_BF_CMD_CONFIG_D0I3,
  792. .bf_enable_beacon_filter = cpu_to_le32(1),
  793. };
  794. ret = _iwl_mvm_enable_beacon_filter(mvm, vif, &cmd_bf,
  795. flags, true);
  796. } else {
  797. if (mvmvif->bf_data.bf_enabled)
  798. ret = iwl_mvm_enable_beacon_filter(mvm, vif, flags);
  799. else
  800. ret = iwl_mvm_disable_beacon_filter(mvm, vif, flags);
  801. }
  802. return ret;
  803. }