power.c 15 KB

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