mac80211.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609
  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/slab.h>
  65. #include <linux/skbuff.h>
  66. #include <linux/netdevice.h>
  67. #include <linux/etherdevice.h>
  68. #include <linux/ip.h>
  69. #include <net/mac80211.h>
  70. #include <net/tcp.h>
  71. #include "iwl-op-mode.h"
  72. #include "iwl-io.h"
  73. #include "mvm.h"
  74. #include "sta.h"
  75. #include "time-event.h"
  76. #include "iwl-eeprom-parse.h"
  77. #include "fw-api-scan.h"
  78. #include "iwl-phy-db.h"
  79. static const struct ieee80211_iface_limit iwl_mvm_limits[] = {
  80. {
  81. .max = 1,
  82. .types = BIT(NL80211_IFTYPE_STATION),
  83. },
  84. {
  85. .max = 1,
  86. .types = BIT(NL80211_IFTYPE_AP) |
  87. BIT(NL80211_IFTYPE_P2P_CLIENT) |
  88. BIT(NL80211_IFTYPE_P2P_GO),
  89. },
  90. {
  91. .max = 1,
  92. .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
  93. },
  94. };
  95. static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = {
  96. {
  97. .num_different_channels = 1,
  98. .max_interfaces = 3,
  99. .limits = iwl_mvm_limits,
  100. .n_limits = ARRAY_SIZE(iwl_mvm_limits),
  101. },
  102. };
  103. #ifdef CONFIG_PM_SLEEP
  104. static const struct nl80211_wowlan_tcp_data_token_feature
  105. iwl_mvm_wowlan_tcp_token_feature = {
  106. .min_len = 0,
  107. .max_len = 255,
  108. .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS,
  109. };
  110. static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = {
  111. .tok = &iwl_mvm_wowlan_tcp_token_feature,
  112. .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN -
  113. sizeof(struct ethhdr) -
  114. sizeof(struct iphdr) -
  115. sizeof(struct tcphdr),
  116. .data_interval_max = 65535, /* __le16 in API */
  117. .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN -
  118. sizeof(struct ethhdr) -
  119. sizeof(struct iphdr) -
  120. sizeof(struct tcphdr),
  121. .seq = true,
  122. };
  123. #endif
  124. static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm)
  125. {
  126. int i;
  127. memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts));
  128. for (i = 0; i < NUM_PHY_CTX; i++) {
  129. mvm->phy_ctxts[i].id = i;
  130. mvm->phy_ctxts[i].ref = 0;
  131. }
  132. }
  133. int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
  134. {
  135. struct ieee80211_hw *hw = mvm->hw;
  136. int num_mac, ret, i;
  137. /* Tell mac80211 our characteristics */
  138. hw->flags = IEEE80211_HW_SIGNAL_DBM |
  139. IEEE80211_HW_SPECTRUM_MGMT |
  140. IEEE80211_HW_REPORTS_TX_ACK_STATUS |
  141. IEEE80211_HW_QUEUE_CONTROL |
  142. IEEE80211_HW_WANT_MONITOR_VIF |
  143. IEEE80211_HW_SUPPORTS_PS |
  144. IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
  145. IEEE80211_HW_AMPDU_AGGREGATION |
  146. IEEE80211_HW_TIMING_BEACON_ONLY |
  147. IEEE80211_HW_CONNECTION_MONITOR |
  148. IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
  149. IEEE80211_HW_SUPPORTS_STATIC_SMPS |
  150. IEEE80211_HW_SUPPORTS_UAPSD;
  151. hw->queues = IWL_MVM_FIRST_AGG_QUEUE;
  152. hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE;
  153. hw->rate_control_algorithm = "iwl-mvm-rs";
  154. /*
  155. * Enable 11w if advertised by firmware and software crypto
  156. * is not enabled (as the firmware will interpret some mgmt
  157. * packets, so enabling it with software crypto isn't safe)
  158. */
  159. if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP &&
  160. !iwlwifi_mod_params.sw_crypto)
  161. hw->flags |= IEEE80211_HW_MFP_CAPABLE;
  162. hw->sta_data_size = sizeof(struct iwl_mvm_sta);
  163. hw->vif_data_size = sizeof(struct iwl_mvm_vif);
  164. hw->chanctx_data_size = sizeof(u16);
  165. hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
  166. BIT(NL80211_IFTYPE_P2P_CLIENT) |
  167. BIT(NL80211_IFTYPE_AP) |
  168. BIT(NL80211_IFTYPE_P2P_GO) |
  169. BIT(NL80211_IFTYPE_P2P_DEVICE);
  170. hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
  171. WIPHY_FLAG_DISABLE_BEACON_HINTS |
  172. WIPHY_FLAG_IBSS_RSN;
  173. hw->wiphy->iface_combinations = iwl_mvm_iface_combinations;
  174. hw->wiphy->n_iface_combinations =
  175. ARRAY_SIZE(iwl_mvm_iface_combinations);
  176. hw->wiphy->max_remain_on_channel_duration = 10000;
  177. hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL;
  178. hw->uapsd_queues = IWL_UAPSD_AC_INFO;
  179. hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP;
  180. /* Extract MAC address */
  181. memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN);
  182. hw->wiphy->addresses = mvm->addresses;
  183. hw->wiphy->n_addresses = 1;
  184. /* Extract additional MAC addresses if available */
  185. num_mac = (mvm->nvm_data->n_hw_addrs > 1) ?
  186. min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1;
  187. for (i = 1; i < num_mac; i++) {
  188. memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr,
  189. ETH_ALEN);
  190. mvm->addresses[i].addr[5]++;
  191. hw->wiphy->n_addresses++;
  192. }
  193. iwl_mvm_reset_phy_ctxts(mvm);
  194. /* we create the 802.11 header and a max-length SSID element */
  195. hw->wiphy->max_scan_ie_len =
  196. mvm->fw->ucode_capa.max_probe_length - 24 - 34;
  197. hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
  198. if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels)
  199. hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
  200. &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ];
  201. if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels)
  202. hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
  203. &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ];
  204. hw->wiphy->hw_version = mvm->trans->hw_id;
  205. if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
  206. hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
  207. else
  208. hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
  209. hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN |
  210. NL80211_FEATURE_P2P_GO_OPPPS;
  211. mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
  212. #ifdef CONFIG_PM_SLEEP
  213. if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len &&
  214. mvm->trans->ops->d3_suspend &&
  215. mvm->trans->ops->d3_resume &&
  216. device_can_wakeup(mvm->trans->dev)) {
  217. mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT |
  218. WIPHY_WOWLAN_DISCONNECT |
  219. WIPHY_WOWLAN_EAP_IDENTITY_REQ |
  220. WIPHY_WOWLAN_RFKILL_RELEASE;
  221. if (!iwlwifi_mod_params.sw_crypto)
  222. mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY |
  223. WIPHY_WOWLAN_GTK_REKEY_FAILURE |
  224. WIPHY_WOWLAN_4WAY_HANDSHAKE;
  225. mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS;
  226. mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN;
  227. mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN;
  228. mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support;
  229. hw->wiphy->wowlan = &mvm->wowlan;
  230. }
  231. #endif
  232. ret = iwl_mvm_leds_init(mvm);
  233. if (ret)
  234. return ret;
  235. ret = ieee80211_register_hw(mvm->hw);
  236. if (ret)
  237. iwl_mvm_leds_exit(mvm);
  238. return ret;
  239. }
  240. static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
  241. struct ieee80211_tx_control *control,
  242. struct sk_buff *skb)
  243. {
  244. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  245. if (iwl_mvm_is_radio_killed(mvm)) {
  246. IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n");
  247. goto drop;
  248. }
  249. if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
  250. !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status))
  251. goto drop;
  252. if (control->sta) {
  253. if (iwl_mvm_tx_skb(mvm, skb, control->sta))
  254. goto drop;
  255. return;
  256. }
  257. if (iwl_mvm_tx_skb_non_sta(mvm, skb))
  258. goto drop;
  259. return;
  260. drop:
  261. ieee80211_free_txskb(hw, skb);
  262. }
  263. static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
  264. struct ieee80211_vif *vif,
  265. enum ieee80211_ampdu_mlme_action action,
  266. struct ieee80211_sta *sta, u16 tid,
  267. u16 *ssn, u8 buf_size)
  268. {
  269. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  270. int ret;
  271. IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n",
  272. sta->addr, tid, action);
  273. if (!(mvm->nvm_data->sku_cap_11n_enable))
  274. return -EACCES;
  275. mutex_lock(&mvm->mutex);
  276. switch (action) {
  277. case IEEE80211_AMPDU_RX_START:
  278. if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) {
  279. ret = -EINVAL;
  280. break;
  281. }
  282. ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true);
  283. break;
  284. case IEEE80211_AMPDU_RX_STOP:
  285. ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false);
  286. break;
  287. case IEEE80211_AMPDU_TX_START:
  288. if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) {
  289. ret = -EINVAL;
  290. break;
  291. }
  292. ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn);
  293. break;
  294. case IEEE80211_AMPDU_TX_STOP_CONT:
  295. ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid);
  296. break;
  297. case IEEE80211_AMPDU_TX_STOP_FLUSH:
  298. case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
  299. ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid);
  300. break;
  301. case IEEE80211_AMPDU_TX_OPERATIONAL:
  302. ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size);
  303. break;
  304. default:
  305. WARN_ON_ONCE(1);
  306. ret = -EINVAL;
  307. break;
  308. }
  309. mutex_unlock(&mvm->mutex);
  310. return ret;
  311. }
  312. static void iwl_mvm_cleanup_iterator(void *data, u8 *mac,
  313. struct ieee80211_vif *vif)
  314. {
  315. struct iwl_mvm *mvm = data;
  316. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  317. mvmvif->uploaded = false;
  318. mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
  319. /* does this make sense at all? */
  320. mvmvif->color++;
  321. spin_lock_bh(&mvm->time_event_lock);
  322. iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data);
  323. spin_unlock_bh(&mvm->time_event_lock);
  324. mvmvif->phy_ctxt = NULL;
  325. }
  326. static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
  327. {
  328. iwl_trans_stop_device(mvm->trans);
  329. iwl_trans_stop_hw(mvm->trans, false);
  330. mvm->scan_status = IWL_MVM_SCAN_NONE;
  331. /* just in case one was running */
  332. ieee80211_remain_on_channel_expired(mvm->hw);
  333. ieee80211_iterate_active_interfaces_atomic(
  334. mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
  335. iwl_mvm_cleanup_iterator, mvm);
  336. mvm->p2p_device_vif = NULL;
  337. iwl_mvm_reset_phy_ctxts(mvm);
  338. memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
  339. memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained));
  340. ieee80211_wake_queues(mvm->hw);
  341. mvm->vif_count = 0;
  342. mvm->rx_ba_sessions = 0;
  343. }
  344. static int iwl_mvm_mac_start(struct ieee80211_hw *hw)
  345. {
  346. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  347. int ret;
  348. mutex_lock(&mvm->mutex);
  349. /* Clean up some internal and mac80211 state on restart */
  350. if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
  351. iwl_mvm_restart_cleanup(mvm);
  352. ret = iwl_mvm_up(mvm);
  353. mutex_unlock(&mvm->mutex);
  354. return ret;
  355. }
  356. static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw)
  357. {
  358. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  359. int ret;
  360. mutex_lock(&mvm->mutex);
  361. clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
  362. ret = iwl_mvm_update_quotas(mvm, NULL);
  363. if (ret)
  364. IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n",
  365. ret);
  366. mutex_unlock(&mvm->mutex);
  367. }
  368. static void iwl_mvm_mac_stop(struct ieee80211_hw *hw)
  369. {
  370. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  371. flush_work(&mvm->async_handlers_wk);
  372. mutex_lock(&mvm->mutex);
  373. /* async_handlers_wk is now blocked */
  374. /*
  375. * The work item could be running or queued if the
  376. * ROC time event stops just as we get here.
  377. */
  378. cancel_work_sync(&mvm->roc_done_wk);
  379. iwl_trans_stop_device(mvm->trans);
  380. iwl_trans_stop_hw(mvm->trans, false);
  381. iwl_mvm_async_handlers_purge(mvm);
  382. /* async_handlers_list is empty and will stay empty: HW is stopped */
  383. /* the fw is stopped, the aux sta is dead: clean up driver state */
  384. iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta);
  385. mutex_unlock(&mvm->mutex);
  386. /*
  387. * The worker might have been waiting for the mutex, let it run and
  388. * discover that its list is now empty.
  389. */
  390. cancel_work_sync(&mvm->async_handlers_wk);
  391. }
  392. static void iwl_mvm_pm_disable_iterator(void *data, u8 *mac,
  393. struct ieee80211_vif *vif)
  394. {
  395. struct iwl_mvm *mvm = data;
  396. int ret;
  397. ret = iwl_mvm_power_disable(mvm, vif);
  398. if (ret)
  399. IWL_ERR(mvm, "failed to disable power management\n");
  400. }
  401. static void iwl_mvm_power_update_iterator(void *data, u8 *mac,
  402. struct ieee80211_vif *vif)
  403. {
  404. struct iwl_mvm *mvm = data;
  405. iwl_mvm_power_update_mode(mvm, vif);
  406. }
  407. static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
  408. {
  409. u16 i;
  410. lockdep_assert_held(&mvm->mutex);
  411. for (i = 0; i < NUM_PHY_CTX; i++)
  412. if (!mvm->phy_ctxts[i].ref)
  413. return &mvm->phy_ctxts[i];
  414. IWL_ERR(mvm, "No available PHY context\n");
  415. return NULL;
  416. }
  417. static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
  418. struct ieee80211_vif *vif)
  419. {
  420. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  421. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  422. int ret;
  423. /*
  424. * Not much to do here. The stack will not allow interface
  425. * types or combinations that we didn't advertise, so we
  426. * don't really have to check the types.
  427. */
  428. mutex_lock(&mvm->mutex);
  429. /* Allocate resources for the MAC context, and add it to the fw */
  430. ret = iwl_mvm_mac_ctxt_init(mvm, vif);
  431. if (ret)
  432. goto out_unlock;
  433. /*
  434. * TODO: remove this temporary code.
  435. * Currently MVM FW supports power management only on single MAC.
  436. * If new interface added, disable PM on existing interface.
  437. * P2P device is a special case, since it is handled by FW similary to
  438. * scan. If P2P deviced is added, PM remains enabled on existing
  439. * interface.
  440. * Note: the method below does not count the new interface being added
  441. * at this moment.
  442. */
  443. if (vif->type != NL80211_IFTYPE_P2P_DEVICE)
  444. mvm->vif_count++;
  445. if (mvm->vif_count > 1) {
  446. IWL_DEBUG_MAC80211(mvm,
  447. "Disable power on existing interfaces\n");
  448. ieee80211_iterate_active_interfaces_atomic(
  449. mvm->hw,
  450. IEEE80211_IFACE_ITER_NORMAL,
  451. iwl_mvm_pm_disable_iterator, mvm);
  452. }
  453. /*
  454. * The AP binding flow can be done only after the beacon
  455. * template is configured (which happens only in the mac80211
  456. * start_ap() flow), and adding the broadcast station can happen
  457. * only after the binding.
  458. * In addition, since modifying the MAC before adding a bcast
  459. * station is not allowed by the FW, delay the adding of MAC context to
  460. * the point where we can also add the bcast station.
  461. * In short: there's not much we can do at this point, other than
  462. * allocating resources :)
  463. */
  464. if (vif->type == NL80211_IFTYPE_AP) {
  465. u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif);
  466. ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta,
  467. qmask);
  468. if (ret) {
  469. IWL_ERR(mvm, "Failed to allocate bcast sta\n");
  470. goto out_release;
  471. }
  472. iwl_mvm_vif_dbgfs_register(mvm, vif);
  473. goto out_unlock;
  474. }
  475. ret = iwl_mvm_mac_ctxt_add(mvm, vif);
  476. if (ret)
  477. goto out_release;
  478. /*
  479. * Update power state on the new interface. Admittedly, based on
  480. * mac80211 logics this power update will disable power management
  481. */
  482. iwl_mvm_power_update_mode(mvm, vif);
  483. /* beacon filtering */
  484. ret = iwl_mvm_disable_beacon_filter(mvm, vif);
  485. if (ret)
  486. goto out_remove_mac;
  487. if (!mvm->bf_allowed_vif &&
  488. vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
  489. mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED){
  490. mvm->bf_allowed_vif = mvmvif;
  491. vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
  492. IEEE80211_VIF_SUPPORTS_CQM_RSSI;
  493. }
  494. /*
  495. * P2P_DEVICE interface does not have a channel context assigned to it,
  496. * so a dedicated PHY context is allocated to it and the corresponding
  497. * MAC context is bound to it at this stage.
  498. */
  499. if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
  500. mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
  501. if (!mvmvif->phy_ctxt) {
  502. ret = -ENOSPC;
  503. goto out_free_bf;
  504. }
  505. iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
  506. ret = iwl_mvm_binding_add_vif(mvm, vif);
  507. if (ret)
  508. goto out_unref_phy;
  509. ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta);
  510. if (ret)
  511. goto out_unbind;
  512. /* Save a pointer to p2p device vif, so it can later be used to
  513. * update the p2p device MAC when a GO is started/stopped */
  514. mvm->p2p_device_vif = vif;
  515. }
  516. iwl_mvm_vif_dbgfs_register(mvm, vif);
  517. goto out_unlock;
  518. out_unbind:
  519. iwl_mvm_binding_remove_vif(mvm, vif);
  520. out_unref_phy:
  521. iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
  522. out_free_bf:
  523. if (mvm->bf_allowed_vif == mvmvif) {
  524. mvm->bf_allowed_vif = NULL;
  525. vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER |
  526. IEEE80211_VIF_SUPPORTS_CQM_RSSI);
  527. }
  528. out_remove_mac:
  529. mvmvif->phy_ctxt = NULL;
  530. iwl_mvm_mac_ctxt_remove(mvm, vif);
  531. out_release:
  532. if (vif->type != NL80211_IFTYPE_P2P_DEVICE)
  533. mvm->vif_count--;
  534. ieee80211_iterate_active_interfaces(
  535. mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
  536. iwl_mvm_power_update_iterator, mvm);
  537. iwl_mvm_mac_ctxt_release(mvm, vif);
  538. out_unlock:
  539. mutex_unlock(&mvm->mutex);
  540. return ret;
  541. }
  542. static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
  543. struct ieee80211_vif *vif)
  544. {
  545. u32 tfd_msk = 0, ac;
  546. for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
  547. if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE)
  548. tfd_msk |= BIT(vif->hw_queue[ac]);
  549. if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE)
  550. tfd_msk |= BIT(vif->cab_queue);
  551. if (tfd_msk) {
  552. mutex_lock(&mvm->mutex);
  553. iwl_mvm_flush_tx_path(mvm, tfd_msk, true);
  554. mutex_unlock(&mvm->mutex);
  555. }
  556. if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
  557. /*
  558. * Flush the ROC worker which will flush the OFFCHANNEL queue.
  559. * We assume here that all the packets sent to the OFFCHANNEL
  560. * queue are sent in ROC session.
  561. */
  562. flush_work(&mvm->roc_done_wk);
  563. } else {
  564. /*
  565. * By now, all the AC queues are empty. The AGG queues are
  566. * empty too. We already got all the Tx responses for all the
  567. * packets in the queues. The drain work can have been
  568. * triggered. Flush it.
  569. */
  570. flush_work(&mvm->sta_drained_wk);
  571. }
  572. }
  573. static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
  574. struct ieee80211_vif *vif)
  575. {
  576. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  577. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  578. iwl_mvm_prepare_mac_removal(mvm, vif);
  579. mutex_lock(&mvm->mutex);
  580. if (mvm->bf_allowed_vif == mvmvif) {
  581. mvm->bf_allowed_vif = NULL;
  582. vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER |
  583. IEEE80211_VIF_SUPPORTS_CQM_RSSI);
  584. }
  585. iwl_mvm_vif_dbgfs_clean(mvm, vif);
  586. /*
  587. * For AP/GO interface, the tear down of the resources allocated to the
  588. * interface is be handled as part of the stop_ap flow.
  589. */
  590. if (vif->type == NL80211_IFTYPE_AP) {
  591. iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta);
  592. goto out_release;
  593. }
  594. if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
  595. mvm->p2p_device_vif = NULL;
  596. iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
  597. iwl_mvm_binding_remove_vif(mvm, vif);
  598. iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
  599. mvmvif->phy_ctxt = NULL;
  600. }
  601. /*
  602. * TODO: remove this temporary code.
  603. * Currently MVM FW supports power management only on single MAC.
  604. * Check if only one additional interface remains after removing
  605. * current one. Update power mode on the remaining interface.
  606. */
  607. if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE)
  608. mvm->vif_count--;
  609. IWL_DEBUG_MAC80211(mvm, "Currently %d interfaces active\n",
  610. mvm->vif_count);
  611. if (mvm->vif_count == 1) {
  612. ieee80211_iterate_active_interfaces(
  613. mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
  614. iwl_mvm_power_update_iterator, mvm);
  615. }
  616. iwl_mvm_mac_ctxt_remove(mvm, vif);
  617. out_release:
  618. iwl_mvm_mac_ctxt_release(mvm, vif);
  619. mutex_unlock(&mvm->mutex);
  620. }
  621. static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
  622. s8 tx_power)
  623. {
  624. /* FW is in charge of regulatory enforcement */
  625. struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = {
  626. .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id,
  627. .pwr_restriction = cpu_to_le16(tx_power),
  628. };
  629. return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC,
  630. sizeof(reduce_txpwr_cmd),
  631. &reduce_txpwr_cmd);
  632. }
  633. static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed)
  634. {
  635. return 0;
  636. }
  637. static void iwl_mvm_configure_filter(struct ieee80211_hw *hw,
  638. unsigned int changed_flags,
  639. unsigned int *total_flags,
  640. u64 multicast)
  641. {
  642. *total_flags = 0;
  643. }
  644. static int iwl_mvm_configure_mcast_filter(struct iwl_mvm *mvm,
  645. struct ieee80211_vif *vif)
  646. {
  647. struct iwl_mcast_filter_cmd mcast_filter_cmd = {
  648. .pass_all = 1,
  649. };
  650. memcpy(mcast_filter_cmd.bssid, vif->bss_conf.bssid, ETH_ALEN);
  651. return iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC,
  652. sizeof(mcast_filter_cmd),
  653. &mcast_filter_cmd);
  654. }
  655. static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,
  656. struct ieee80211_vif *vif,
  657. struct ieee80211_bss_conf *bss_conf,
  658. u32 changes)
  659. {
  660. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  661. int ret;
  662. ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
  663. if (ret)
  664. IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
  665. if (changes & BSS_CHANGED_ASSOC) {
  666. if (bss_conf->assoc) {
  667. /* add quota for this interface */
  668. ret = iwl_mvm_update_quotas(mvm, vif);
  669. if (ret) {
  670. IWL_ERR(mvm, "failed to update quotas\n");
  671. return;
  672. }
  673. iwl_mvm_configure_mcast_filter(mvm, vif);
  674. } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {
  675. /* remove AP station now that the MAC is unassoc */
  676. ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id);
  677. if (ret)
  678. IWL_ERR(mvm, "failed to remove AP station\n");
  679. mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
  680. /* remove quota for this interface */
  681. ret = iwl_mvm_update_quotas(mvm, NULL);
  682. if (ret)
  683. IWL_ERR(mvm, "failed to update quotas\n");
  684. }
  685. /* reset rssi values */
  686. mvmvif->bf_data.ave_beacon_signal = 0;
  687. if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD)) {
  688. /* Workaround for FW bug, otherwise FW disables device
  689. * power save upon disassociation
  690. */
  691. ret = iwl_mvm_power_update_mode(mvm, vif);
  692. if (ret)
  693. IWL_ERR(mvm, "failed to update power mode\n");
  694. }
  695. iwl_mvm_bt_coex_vif_assoc(mvm, vif);
  696. } else if (changes & BSS_CHANGED_BEACON_INFO) {
  697. /*
  698. * We received a beacon _after_ association so
  699. * remove the session protection.
  700. */
  701. iwl_mvm_remove_time_event(mvm, mvmvif,
  702. &mvmvif->time_event_data);
  703. } else if (changes & (BSS_CHANGED_PS | BSS_CHANGED_QOS)) {
  704. ret = iwl_mvm_power_update_mode(mvm, vif);
  705. if (ret)
  706. IWL_ERR(mvm, "failed to update power mode\n");
  707. }
  708. if (changes & BSS_CHANGED_TXPOWER) {
  709. IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n",
  710. bss_conf->txpower);
  711. iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower);
  712. }
  713. if (changes & BSS_CHANGED_CQM) {
  714. IWL_DEBUG_MAC80211(mvm, "cqm info_changed");
  715. /* reset cqm events tracking */
  716. mvmvif->bf_data.last_cqm_event = 0;
  717. ret = iwl_mvm_update_beacon_filter(mvm, vif);
  718. if (ret)
  719. IWL_ERR(mvm, "failed to update CQM thresholds\n");
  720. }
  721. }
  722. static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  723. {
  724. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  725. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  726. int ret;
  727. mutex_lock(&mvm->mutex);
  728. /* Send the beacon template */
  729. ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif);
  730. if (ret)
  731. goto out_unlock;
  732. /* Add the mac context */
  733. ret = iwl_mvm_mac_ctxt_add(mvm, vif);
  734. if (ret)
  735. goto out_unlock;
  736. /* Perform the binding */
  737. ret = iwl_mvm_binding_add_vif(mvm, vif);
  738. if (ret)
  739. goto out_remove;
  740. mvmvif->ap_active = true;
  741. /* Send the bcast station. At this stage the TBTT and DTIM time events
  742. * are added and applied to the scheduler */
  743. ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta);
  744. if (ret)
  745. goto out_unbind;
  746. ret = iwl_mvm_update_quotas(mvm, vif);
  747. if (ret)
  748. goto out_rm_bcast;
  749. /* Need to update the P2P Device MAC */
  750. if (vif->p2p && mvm->p2p_device_vif)
  751. iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif);
  752. mutex_unlock(&mvm->mutex);
  753. return 0;
  754. out_rm_bcast:
  755. iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
  756. out_unbind:
  757. iwl_mvm_binding_remove_vif(mvm, vif);
  758. out_remove:
  759. iwl_mvm_mac_ctxt_remove(mvm, vif);
  760. out_unlock:
  761. mutex_unlock(&mvm->mutex);
  762. return ret;
  763. }
  764. static void iwl_mvm_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
  765. {
  766. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  767. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  768. iwl_mvm_prepare_mac_removal(mvm, vif);
  769. mutex_lock(&mvm->mutex);
  770. mvmvif->ap_active = false;
  771. /* Need to update the P2P Device MAC */
  772. if (vif->p2p && mvm->p2p_device_vif)
  773. iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif);
  774. iwl_mvm_update_quotas(mvm, NULL);
  775. iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
  776. iwl_mvm_binding_remove_vif(mvm, vif);
  777. iwl_mvm_mac_ctxt_remove(mvm, vif);
  778. mutex_unlock(&mvm->mutex);
  779. }
  780. static void iwl_mvm_bss_info_changed_ap(struct iwl_mvm *mvm,
  781. struct ieee80211_vif *vif,
  782. struct ieee80211_bss_conf *bss_conf,
  783. u32 changes)
  784. {
  785. /* Need to send a new beacon template to the FW */
  786. if (changes & BSS_CHANGED_BEACON) {
  787. if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif))
  788. IWL_WARN(mvm, "Failed updating beacon data\n");
  789. }
  790. }
  791. static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
  792. struct ieee80211_vif *vif,
  793. struct ieee80211_bss_conf *bss_conf,
  794. u32 changes)
  795. {
  796. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  797. mutex_lock(&mvm->mutex);
  798. switch (vif->type) {
  799. case NL80211_IFTYPE_STATION:
  800. iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes);
  801. break;
  802. case NL80211_IFTYPE_AP:
  803. iwl_mvm_bss_info_changed_ap(mvm, vif, bss_conf, changes);
  804. break;
  805. default:
  806. /* shouldn't happen */
  807. WARN_ON_ONCE(1);
  808. }
  809. mutex_unlock(&mvm->mutex);
  810. }
  811. static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
  812. struct ieee80211_vif *vif,
  813. struct cfg80211_scan_request *req)
  814. {
  815. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  816. int ret;
  817. if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS)
  818. return -EINVAL;
  819. mutex_lock(&mvm->mutex);
  820. if (mvm->scan_status == IWL_MVM_SCAN_NONE)
  821. ret = iwl_mvm_scan_request(mvm, vif, req);
  822. else
  823. ret = -EBUSY;
  824. mutex_unlock(&mvm->mutex);
  825. return ret;
  826. }
  827. static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
  828. struct ieee80211_vif *vif)
  829. {
  830. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  831. mutex_lock(&mvm->mutex);
  832. iwl_mvm_cancel_scan(mvm);
  833. mutex_unlock(&mvm->mutex);
  834. }
  835. static void
  836. iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw,
  837. struct ieee80211_sta *sta, u16 tid,
  838. int num_frames,
  839. enum ieee80211_frame_release_type reason,
  840. bool more_data)
  841. {
  842. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  843. /* TODO: how do we tell the fw to send frames for a specific TID */
  844. /*
  845. * The fw will send EOSP notification when the last frame will be
  846. * transmitted.
  847. */
  848. iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames);
  849. }
  850. static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw,
  851. struct ieee80211_vif *vif,
  852. enum sta_notify_cmd cmd,
  853. struct ieee80211_sta *sta)
  854. {
  855. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  856. struct iwl_mvm_sta *mvmsta = (void *)sta->drv_priv;
  857. switch (cmd) {
  858. case STA_NOTIFY_SLEEP:
  859. if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0)
  860. ieee80211_sta_block_awake(hw, sta, true);
  861. /*
  862. * The fw updates the STA to be asleep. Tx packets on the Tx
  863. * queues to this station will not be transmitted. The fw will
  864. * send a Tx response with TX_STATUS_FAIL_DEST_PS.
  865. */
  866. break;
  867. case STA_NOTIFY_AWAKE:
  868. if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
  869. break;
  870. iwl_mvm_sta_modify_ps_wake(mvm, sta);
  871. break;
  872. default:
  873. break;
  874. }
  875. }
  876. static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
  877. struct ieee80211_vif *vif,
  878. struct ieee80211_sta *sta,
  879. enum ieee80211_sta_state old_state,
  880. enum ieee80211_sta_state new_state)
  881. {
  882. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  883. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  884. int ret;
  885. IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n",
  886. sta->addr, old_state, new_state);
  887. /* this would be a mac80211 bug ... but don't crash */
  888. if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
  889. return -EINVAL;
  890. /* if a STA is being removed, reuse its ID */
  891. flush_work(&mvm->sta_drained_wk);
  892. mutex_lock(&mvm->mutex);
  893. if (old_state == IEEE80211_STA_NOTEXIST &&
  894. new_state == IEEE80211_STA_NONE) {
  895. /*
  896. * Firmware bug - it'll crash if the beacon interval is less
  897. * than 16. We can't avoid connecting at all, so refuse the
  898. * station state change, this will cause mac80211 to abandon
  899. * attempts to connect to this AP, and eventually wpa_s will
  900. * blacklist the AP...
  901. */
  902. if (vif->type == NL80211_IFTYPE_STATION &&
  903. vif->bss_conf.beacon_int < 16) {
  904. IWL_ERR(mvm,
  905. "AP %pM beacon interval is %d, refusing due to firmware bug!\n",
  906. sta->addr, vif->bss_conf.beacon_int);
  907. ret = -EINVAL;
  908. goto out_unlock;
  909. }
  910. ret = iwl_mvm_add_sta(mvm, vif, sta);
  911. } else if (old_state == IEEE80211_STA_NONE &&
  912. new_state == IEEE80211_STA_AUTH) {
  913. ret = 0;
  914. } else if (old_state == IEEE80211_STA_AUTH &&
  915. new_state == IEEE80211_STA_ASSOC) {
  916. ret = iwl_mvm_update_sta(mvm, vif, sta);
  917. if (ret == 0)
  918. iwl_mvm_rs_rate_init(mvm, sta,
  919. mvmvif->phy_ctxt->channel->band);
  920. } else if (old_state == IEEE80211_STA_ASSOC &&
  921. new_state == IEEE80211_STA_AUTHORIZED) {
  922. /* enable beacon filtering */
  923. WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif));
  924. ret = 0;
  925. } else if (old_state == IEEE80211_STA_AUTHORIZED &&
  926. new_state == IEEE80211_STA_ASSOC) {
  927. /* disable beacon filtering */
  928. WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif));
  929. ret = 0;
  930. } else if (old_state == IEEE80211_STA_ASSOC &&
  931. new_state == IEEE80211_STA_AUTH) {
  932. ret = 0;
  933. } else if (old_state == IEEE80211_STA_AUTH &&
  934. new_state == IEEE80211_STA_NONE) {
  935. ret = 0;
  936. } else if (old_state == IEEE80211_STA_NONE &&
  937. new_state == IEEE80211_STA_NOTEXIST) {
  938. ret = iwl_mvm_rm_sta(mvm, vif, sta);
  939. } else {
  940. ret = -EIO;
  941. }
  942. out_unlock:
  943. mutex_unlock(&mvm->mutex);
  944. return ret;
  945. }
  946. static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
  947. {
  948. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  949. mvm->rts_threshold = value;
  950. return 0;
  951. }
  952. static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw,
  953. struct ieee80211_vif *vif, u16 ac,
  954. const struct ieee80211_tx_queue_params *params)
  955. {
  956. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  957. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  958. mvmvif->queue_params[ac] = *params;
  959. /*
  960. * No need to update right away, we'll get BSS_CHANGED_QOS
  961. * The exception is P2P_DEVICE interface which needs immediate update.
  962. */
  963. if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
  964. int ret;
  965. mutex_lock(&mvm->mutex);
  966. ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
  967. mutex_unlock(&mvm->mutex);
  968. return ret;
  969. }
  970. return 0;
  971. }
  972. static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
  973. struct ieee80211_vif *vif)
  974. {
  975. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  976. u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS,
  977. 200 + vif->bss_conf.beacon_int);
  978. u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS,
  979. 100 + vif->bss_conf.beacon_int);
  980. if (WARN_ON_ONCE(vif->bss_conf.assoc))
  981. return;
  982. mutex_lock(&mvm->mutex);
  983. /* Try really hard to protect the session and hear a beacon */
  984. iwl_mvm_protect_session(mvm, vif, duration, min_duration);
  985. mutex_unlock(&mvm->mutex);
  986. }
  987. static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
  988. enum set_key_cmd cmd,
  989. struct ieee80211_vif *vif,
  990. struct ieee80211_sta *sta,
  991. struct ieee80211_key_conf *key)
  992. {
  993. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  994. int ret;
  995. if (iwlwifi_mod_params.sw_crypto) {
  996. IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n");
  997. return -EOPNOTSUPP;
  998. }
  999. switch (key->cipher) {
  1000. case WLAN_CIPHER_SUITE_TKIP:
  1001. key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
  1002. /* fall-through */
  1003. case WLAN_CIPHER_SUITE_CCMP:
  1004. key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
  1005. break;
  1006. case WLAN_CIPHER_SUITE_AES_CMAC:
  1007. WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE));
  1008. break;
  1009. case WLAN_CIPHER_SUITE_WEP40:
  1010. case WLAN_CIPHER_SUITE_WEP104:
  1011. /*
  1012. * Support for TX only, at least for now, so accept
  1013. * the key and do nothing else. Then mac80211 will
  1014. * pass it for TX but we don't have to use it for RX.
  1015. */
  1016. return 0;
  1017. default:
  1018. return -EOPNOTSUPP;
  1019. }
  1020. mutex_lock(&mvm->mutex);
  1021. switch (cmd) {
  1022. case SET_KEY:
  1023. if (vif->type == NL80211_IFTYPE_AP && !sta) {
  1024. /* GTK on AP interface is a TX-only key, return 0 */
  1025. ret = 0;
  1026. key->hw_key_idx = STA_KEY_IDX_INVALID;
  1027. break;
  1028. }
  1029. IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n");
  1030. ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false);
  1031. if (ret) {
  1032. IWL_WARN(mvm, "set key failed\n");
  1033. /*
  1034. * can't add key for RX, but we don't need it
  1035. * in the device for TX so still return 0
  1036. */
  1037. key->hw_key_idx = STA_KEY_IDX_INVALID;
  1038. ret = 0;
  1039. }
  1040. break;
  1041. case DISABLE_KEY:
  1042. if (key->hw_key_idx == STA_KEY_IDX_INVALID) {
  1043. ret = 0;
  1044. break;
  1045. }
  1046. IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n");
  1047. ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key);
  1048. break;
  1049. default:
  1050. ret = -EINVAL;
  1051. }
  1052. mutex_unlock(&mvm->mutex);
  1053. return ret;
  1054. }
  1055. static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw,
  1056. struct ieee80211_vif *vif,
  1057. struct ieee80211_key_conf *keyconf,
  1058. struct ieee80211_sta *sta,
  1059. u32 iv32, u16 *phase1key)
  1060. {
  1061. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1062. iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key);
  1063. }
  1064. static int iwl_mvm_roc(struct ieee80211_hw *hw,
  1065. struct ieee80211_vif *vif,
  1066. struct ieee80211_channel *channel,
  1067. int duration,
  1068. enum ieee80211_roc_type type)
  1069. {
  1070. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1071. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1072. struct cfg80211_chan_def chandef;
  1073. struct iwl_mvm_phy_ctxt *phy_ctxt;
  1074. int ret, i;
  1075. IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
  1076. duration, type);
  1077. if (vif->type != NL80211_IFTYPE_P2P_DEVICE) {
  1078. IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type);
  1079. return -EINVAL;
  1080. }
  1081. mutex_lock(&mvm->mutex);
  1082. for (i = 0; i < NUM_PHY_CTX; i++) {
  1083. phy_ctxt = &mvm->phy_ctxts[i];
  1084. if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt)
  1085. continue;
  1086. if (phy_ctxt->ref && channel == phy_ctxt->channel) {
  1087. /*
  1088. * Unbind the P2P_DEVICE from the current PHY context,
  1089. * and if the PHY context is not used remove it.
  1090. */
  1091. ret = iwl_mvm_binding_remove_vif(mvm, vif);
  1092. if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
  1093. goto out_unlock;
  1094. iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
  1095. /* Bind the P2P_DEVICE to the current PHY Context */
  1096. mvmvif->phy_ctxt = phy_ctxt;
  1097. ret = iwl_mvm_binding_add_vif(mvm, vif);
  1098. if (WARN(ret, "Failed binding P2P_DEVICE\n"))
  1099. goto out_unlock;
  1100. iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
  1101. goto schedule_time_event;
  1102. }
  1103. }
  1104. /* Need to update the PHY context only if the ROC channel changed */
  1105. if (channel == mvmvif->phy_ctxt->channel)
  1106. goto schedule_time_event;
  1107. cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT);
  1108. /*
  1109. * Change the PHY context configuration as it is currently referenced
  1110. * only by the P2P Device MAC
  1111. */
  1112. if (mvmvif->phy_ctxt->ref == 1) {
  1113. ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt,
  1114. &chandef, 1, 1);
  1115. if (ret)
  1116. goto out_unlock;
  1117. } else {
  1118. /*
  1119. * The PHY context is shared with other MACs. Need to remove the
  1120. * P2P Device from the binding, allocate an new PHY context and
  1121. * create a new binding
  1122. */
  1123. phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
  1124. if (!phy_ctxt) {
  1125. ret = -ENOSPC;
  1126. goto out_unlock;
  1127. }
  1128. ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef,
  1129. 1, 1);
  1130. if (ret) {
  1131. IWL_ERR(mvm, "Failed to change PHY context\n");
  1132. goto out_unlock;
  1133. }
  1134. /* Unbind the P2P_DEVICE from the current PHY context */
  1135. ret = iwl_mvm_binding_remove_vif(mvm, vif);
  1136. if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
  1137. goto out_unlock;
  1138. iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
  1139. /* Bind the P2P_DEVICE to the new allocated PHY context */
  1140. mvmvif->phy_ctxt = phy_ctxt;
  1141. ret = iwl_mvm_binding_add_vif(mvm, vif);
  1142. if (WARN(ret, "Failed binding P2P_DEVICE\n"))
  1143. goto out_unlock;
  1144. iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
  1145. }
  1146. schedule_time_event:
  1147. /* Schedule the time events */
  1148. ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type);
  1149. out_unlock:
  1150. mutex_unlock(&mvm->mutex);
  1151. IWL_DEBUG_MAC80211(mvm, "leave\n");
  1152. return ret;
  1153. }
  1154. static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw)
  1155. {
  1156. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1157. IWL_DEBUG_MAC80211(mvm, "enter\n");
  1158. mutex_lock(&mvm->mutex);
  1159. iwl_mvm_stop_p2p_roc(mvm);
  1160. mutex_unlock(&mvm->mutex);
  1161. IWL_DEBUG_MAC80211(mvm, "leave\n");
  1162. return 0;
  1163. }
  1164. static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw,
  1165. struct ieee80211_chanctx_conf *ctx)
  1166. {
  1167. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1168. u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
  1169. struct iwl_mvm_phy_ctxt *phy_ctxt;
  1170. int ret;
  1171. IWL_DEBUG_MAC80211(mvm, "Add channel context\n");
  1172. mutex_lock(&mvm->mutex);
  1173. phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
  1174. if (!phy_ctxt) {
  1175. ret = -ENOSPC;
  1176. goto out;
  1177. }
  1178. ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def,
  1179. ctx->rx_chains_static,
  1180. ctx->rx_chains_dynamic);
  1181. if (ret) {
  1182. IWL_ERR(mvm, "Failed to add PHY context\n");
  1183. goto out;
  1184. }
  1185. iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt);
  1186. *phy_ctxt_id = phy_ctxt->id;
  1187. out:
  1188. mutex_unlock(&mvm->mutex);
  1189. return ret;
  1190. }
  1191. static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,
  1192. struct ieee80211_chanctx_conf *ctx)
  1193. {
  1194. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1195. u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
  1196. struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
  1197. mutex_lock(&mvm->mutex);
  1198. iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt);
  1199. mutex_unlock(&mvm->mutex);
  1200. }
  1201. static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
  1202. struct ieee80211_chanctx_conf *ctx,
  1203. u32 changed)
  1204. {
  1205. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1206. u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
  1207. struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
  1208. if (WARN_ONCE((phy_ctxt->ref > 1) &&
  1209. (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH |
  1210. IEEE80211_CHANCTX_CHANGE_RX_CHAINS |
  1211. IEEE80211_CHANCTX_CHANGE_RADAR)),
  1212. "Cannot change PHY. Ref=%d, changed=0x%X\n",
  1213. phy_ctxt->ref, changed))
  1214. return;
  1215. mutex_lock(&mvm->mutex);
  1216. iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def,
  1217. ctx->rx_chains_static,
  1218. ctx->rx_chains_dynamic);
  1219. mutex_unlock(&mvm->mutex);
  1220. }
  1221. static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
  1222. struct ieee80211_vif *vif,
  1223. struct ieee80211_chanctx_conf *ctx)
  1224. {
  1225. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1226. u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
  1227. struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
  1228. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1229. int ret;
  1230. mutex_lock(&mvm->mutex);
  1231. mvmvif->phy_ctxt = phy_ctxt;
  1232. switch (vif->type) {
  1233. case NL80211_IFTYPE_AP:
  1234. /*
  1235. * The AP binding flow is handled as part of the start_ap flow
  1236. * (in bss_info_changed).
  1237. */
  1238. ret = 0;
  1239. goto out_unlock;
  1240. case NL80211_IFTYPE_STATION:
  1241. case NL80211_IFTYPE_ADHOC:
  1242. case NL80211_IFTYPE_MONITOR:
  1243. break;
  1244. default:
  1245. ret = -EINVAL;
  1246. goto out_unlock;
  1247. }
  1248. ret = iwl_mvm_binding_add_vif(mvm, vif);
  1249. if (ret)
  1250. goto out_unlock;
  1251. /*
  1252. * Setting the quota at this stage is only required for monitor
  1253. * interfaces. For the other types, the bss_info changed flow
  1254. * will handle quota settings.
  1255. */
  1256. if (vif->type == NL80211_IFTYPE_MONITOR) {
  1257. mvmvif->monitor_active = true;
  1258. ret = iwl_mvm_update_quotas(mvm, vif);
  1259. if (ret)
  1260. goto out_remove_binding;
  1261. }
  1262. goto out_unlock;
  1263. out_remove_binding:
  1264. iwl_mvm_binding_remove_vif(mvm, vif);
  1265. out_unlock:
  1266. mutex_unlock(&mvm->mutex);
  1267. if (ret)
  1268. mvmvif->phy_ctxt = NULL;
  1269. return ret;
  1270. }
  1271. static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw,
  1272. struct ieee80211_vif *vif,
  1273. struct ieee80211_chanctx_conf *ctx)
  1274. {
  1275. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1276. struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
  1277. mutex_lock(&mvm->mutex);
  1278. iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data);
  1279. if (vif->type == NL80211_IFTYPE_AP)
  1280. goto out_unlock;
  1281. switch (vif->type) {
  1282. case NL80211_IFTYPE_MONITOR:
  1283. mvmvif->monitor_active = false;
  1284. iwl_mvm_update_quotas(mvm, NULL);
  1285. break;
  1286. default:
  1287. break;
  1288. }
  1289. iwl_mvm_binding_remove_vif(mvm, vif);
  1290. out_unlock:
  1291. mvmvif->phy_ctxt = NULL;
  1292. mutex_unlock(&mvm->mutex);
  1293. }
  1294. static int iwl_mvm_set_tim(struct ieee80211_hw *hw,
  1295. struct ieee80211_sta *sta,
  1296. bool set)
  1297. {
  1298. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1299. struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv;
  1300. if (!mvm_sta || !mvm_sta->vif) {
  1301. IWL_ERR(mvm, "Station is not associated to a vif\n");
  1302. return -EINVAL;
  1303. }
  1304. return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif);
  1305. }
  1306. static void iwl_mvm_mac_rssi_callback(struct ieee80211_hw *hw,
  1307. struct ieee80211_vif *vif,
  1308. enum ieee80211_rssi_event rssi_event)
  1309. {
  1310. struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
  1311. iwl_mvm_bt_rssi_event(mvm, vif, rssi_event);
  1312. }
  1313. struct ieee80211_ops iwl_mvm_hw_ops = {
  1314. .tx = iwl_mvm_mac_tx,
  1315. .ampdu_action = iwl_mvm_mac_ampdu_action,
  1316. .start = iwl_mvm_mac_start,
  1317. .restart_complete = iwl_mvm_mac_restart_complete,
  1318. .stop = iwl_mvm_mac_stop,
  1319. .add_interface = iwl_mvm_mac_add_interface,
  1320. .remove_interface = iwl_mvm_mac_remove_interface,
  1321. .config = iwl_mvm_mac_config,
  1322. .configure_filter = iwl_mvm_configure_filter,
  1323. .bss_info_changed = iwl_mvm_bss_info_changed,
  1324. .hw_scan = iwl_mvm_mac_hw_scan,
  1325. .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
  1326. .sta_state = iwl_mvm_mac_sta_state,
  1327. .sta_notify = iwl_mvm_mac_sta_notify,
  1328. .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames,
  1329. .set_rts_threshold = iwl_mvm_mac_set_rts_threshold,
  1330. .conf_tx = iwl_mvm_mac_conf_tx,
  1331. .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx,
  1332. .set_key = iwl_mvm_mac_set_key,
  1333. .update_tkip_key = iwl_mvm_mac_update_tkip_key,
  1334. .remain_on_channel = iwl_mvm_roc,
  1335. .cancel_remain_on_channel = iwl_mvm_cancel_roc,
  1336. .rssi_callback = iwl_mvm_mac_rssi_callback,
  1337. .add_chanctx = iwl_mvm_add_chanctx,
  1338. .remove_chanctx = iwl_mvm_remove_chanctx,
  1339. .change_chanctx = iwl_mvm_change_chanctx,
  1340. .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx,
  1341. .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx,
  1342. .start_ap = iwl_mvm_start_ap,
  1343. .stop_ap = iwl_mvm_stop_ap,
  1344. .set_tim = iwl_mvm_set_tim,
  1345. #ifdef CONFIG_PM_SLEEP
  1346. /* look at d3.c */
  1347. .suspend = iwl_mvm_suspend,
  1348. .resume = iwl_mvm_resume,
  1349. .set_wakeup = iwl_mvm_set_wakeup,
  1350. .set_rekey_data = iwl_mvm_set_rekey_data,
  1351. #if IS_ENABLED(CONFIG_IPV6)
  1352. .ipv6_addr_change = iwl_mvm_ipv6_addr_change,
  1353. #endif
  1354. .set_default_unicast_key = iwl_mvm_set_default_unicast_key,
  1355. #endif
  1356. };