1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
25 * The full GNU General Public License is included in this distribution
26 * in the file called COPYING.
28 * Contact Information:
29 * Intel Linux Wireless <ilw@linux.intel.com>
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
34 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
35 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
36 * All rights reserved.
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
42 * * Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * * Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in
46 * the documentation and/or other materials provided with the
48 * * Neither the name Intel Corporation nor the names of its
49 * contributors may be used to endorse or promote products derived
50 * from this software without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 *****************************************************************************/
65 #include <linux/kernel.h>
66 #include <linux/slab.h>
67 #include <linux/skbuff.h>
68 #include <linux/netdevice.h>
69 #include <linux/etherdevice.h>
71 #include <linux/if_arp.h>
72 #include <linux/devcoredump.h>
73 #include <net/mac80211.h>
74 #include <net/ieee80211_radiotap.h>
77 #include "iwl-op-mode.h"
81 #include "time-event.h"
82 #include "iwl-eeprom-parse.h"
83 #include "fw-api-scan.h"
84 #include "iwl-phy-db.h"
86 #include "iwl-fw-error-dump.h"
90 static const struct ieee80211_iface_limit iwl_mvm_limits[] = {
93 .types = BIT(NL80211_IFTYPE_STATION),
97 .types = BIT(NL80211_IFTYPE_AP) |
98 BIT(NL80211_IFTYPE_P2P_CLIENT) |
99 BIT(NL80211_IFTYPE_P2P_GO),
103 .types = BIT(NL80211_IFTYPE_P2P_DEVICE),
107 static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = {
109 .num_different_channels = 1,
111 .limits = iwl_mvm_limits,
112 .n_limits = ARRAY_SIZE(iwl_mvm_limits),
116 #ifdef CONFIG_PM_SLEEP
117 static const struct nl80211_wowlan_tcp_data_token_feature
118 iwl_mvm_wowlan_tcp_token_feature = {
121 .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS,
124 static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = {
125 .tok = &iwl_mvm_wowlan_tcp_token_feature,
126 .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN -
127 sizeof(struct ethhdr) -
128 sizeof(struct iphdr) -
129 sizeof(struct tcphdr),
130 .data_interval_max = 65535, /* __le16 in API */
131 .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN -
132 sizeof(struct ethhdr) -
133 sizeof(struct iphdr) -
134 sizeof(struct tcphdr),
139 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
141 * Use the reserved field to indicate magic values.
142 * these values will only be used internally by the driver,
143 * and won't make it to the fw (reserved will be 0).
144 * BC_FILTER_MAGIC_IP - configure the val of this attribute to
145 * be the vif's ip address. in case there is not a single
146 * ip address (0, or more than 1), this attribute will
148 * BC_FILTER_MAGIC_MAC - set the val of this attribute to
149 * the LSB bytes of the vif's mac address
152 BC_FILTER_MAGIC_NONE = 0,
157 static const struct iwl_fw_bcast_filter iwl_mvm_default_bcast_filters[] = {
161 .frame_type = BCAST_FILTER_FRAME_TYPE_ALL,
164 /* frame type - arp, hw type - ethernet */
166 BCAST_FILTER_OFFSET_PAYLOAD_START,
167 .offset = sizeof(rfc1042_header),
168 .val = cpu_to_be32(0x08060001),
169 .mask = cpu_to_be32(0xffffffff),
174 BCAST_FILTER_OFFSET_PAYLOAD_START,
175 .offset = sizeof(rfc1042_header) + 2 +
176 sizeof(struct arphdr) +
177 ETH_ALEN + sizeof(__be32) +
179 .mask = cpu_to_be32(0xffffffff),
180 /* mark it as special field */
181 .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_IP),
186 /* dhcp offer bcast */
188 .frame_type = BCAST_FILTER_FRAME_TYPE_IPV4,
191 /* udp dest port - 68 (bootp client)*/
192 .offset_type = BCAST_FILTER_OFFSET_IP_END,
193 .offset = offsetof(struct udphdr, dest),
194 .val = cpu_to_be32(0x00440000),
195 .mask = cpu_to_be32(0xffff0000),
198 /* dhcp - lsb bytes of client hw address */
199 .offset_type = BCAST_FILTER_OFFSET_IP_END,
201 .mask = cpu_to_be32(0xffffffff),
202 /* mark it as special field */
203 .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_MAC),
207 /* last filter must be empty */
212 void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type)
214 if (!iwl_mvm_is_d0i3_supported(mvm))
217 IWL_DEBUG_RPM(mvm, "Take mvm reference - type %d\n", ref_type);
218 spin_lock_bh(&mvm->refs_lock);
219 mvm->refs[ref_type]++;
220 spin_unlock_bh(&mvm->refs_lock);
221 iwl_trans_ref(mvm->trans);
224 void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type)
226 if (!iwl_mvm_is_d0i3_supported(mvm))
229 IWL_DEBUG_RPM(mvm, "Leave mvm reference - type %d\n", ref_type);
230 spin_lock_bh(&mvm->refs_lock);
231 WARN_ON(!mvm->refs[ref_type]--);
232 spin_unlock_bh(&mvm->refs_lock);
233 iwl_trans_unref(mvm->trans);
236 static void iwl_mvm_unref_all_except(struct iwl_mvm *mvm,
237 enum iwl_mvm_ref_type except_ref)
241 if (!iwl_mvm_is_d0i3_supported(mvm))
244 spin_lock_bh(&mvm->refs_lock);
245 for (i = 0; i < IWL_MVM_REF_COUNT; i++) {
246 if (except_ref == i || !mvm->refs[i])
249 IWL_DEBUG_RPM(mvm, "Cleanup: remove mvm ref type %d (%d)\n",
251 for (j = 0; j < mvm->refs[i]; j++)
252 iwl_trans_unref(mvm->trans);
255 spin_unlock_bh(&mvm->refs_lock);
258 bool iwl_mvm_ref_taken(struct iwl_mvm *mvm)
263 if (!iwl_mvm_is_d0i3_supported(mvm))
266 spin_lock_bh(&mvm->refs_lock);
267 for (i = 0; i < IWL_MVM_REF_COUNT; i++) {
273 spin_unlock_bh(&mvm->refs_lock);
278 int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type)
280 iwl_mvm_ref(mvm, ref_type);
282 if (!wait_event_timeout(mvm->d0i3_exit_waitq,
283 !test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status),
286 iwl_mvm_unref(mvm, ref_type);
293 static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm)
297 memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts));
298 for (i = 0; i < NUM_PHY_CTX; i++) {
299 mvm->phy_ctxts[i].id = i;
300 mvm->phy_ctxts[i].ref = 0;
304 int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
306 struct ieee80211_hw *hw = mvm->hw;
309 /* Tell mac80211 our characteristics */
310 hw->flags = IEEE80211_HW_SIGNAL_DBM |
311 IEEE80211_HW_SPECTRUM_MGMT |
312 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
313 IEEE80211_HW_QUEUE_CONTROL |
314 IEEE80211_HW_WANT_MONITOR_VIF |
315 IEEE80211_HW_SUPPORTS_PS |
316 IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
317 IEEE80211_HW_AMPDU_AGGREGATION |
318 IEEE80211_HW_TIMING_BEACON_ONLY |
319 IEEE80211_HW_CONNECTION_MONITOR |
320 IEEE80211_HW_CHANCTX_STA_CSA |
321 IEEE80211_HW_SUPPORTS_CLONED_SKBS;
323 hw->queues = mvm->first_agg_queue;
324 hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE;
325 hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC |
326 IEEE80211_RADIOTAP_MCS_HAVE_STBC;
327 hw->radiotap_vht_details |= IEEE80211_RADIOTAP_VHT_KNOWN_STBC |
328 IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED;
329 hw->rate_control_algorithm = "iwl-mvm-rs";
332 * Enable 11w if advertised by firmware and software crypto
333 * is not enabled (as the firmware will interpret some mgmt
334 * packets, so enabling it with software crypto isn't safe)
336 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP &&
337 !iwlwifi_mod_params.sw_crypto)
338 hw->flags |= IEEE80211_HW_MFP_CAPABLE;
340 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT &&
341 !iwlwifi_mod_params.uapsd_disable) {
342 hw->flags |= IEEE80211_HW_SUPPORTS_UAPSD;
343 hw->uapsd_queues = IWL_MVM_UAPSD_QUEUES;
344 hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP;
347 if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN ||
348 mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN) {
349 hw->flags |= IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS;
350 hw->wiphy->features |=
351 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR |
352 NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
355 hw->sta_data_size = sizeof(struct iwl_mvm_sta);
356 hw->vif_data_size = sizeof(struct iwl_mvm_vif);
357 hw->chanctx_data_size = sizeof(u16);
359 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
360 BIT(NL80211_IFTYPE_P2P_CLIENT) |
361 BIT(NL80211_IFTYPE_AP) |
362 BIT(NL80211_IFTYPE_P2P_GO) |
363 BIT(NL80211_IFTYPE_P2P_DEVICE) |
364 BIT(NL80211_IFTYPE_ADHOC);
366 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
367 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG |
368 REGULATORY_DISABLE_BEACON_HINTS;
370 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_GO_UAPSD)
371 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
373 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
375 hw->wiphy->iface_combinations = iwl_mvm_iface_combinations;
376 hw->wiphy->n_iface_combinations =
377 ARRAY_SIZE(iwl_mvm_iface_combinations);
379 hw->wiphy->max_remain_on_channel_duration = 10000;
380 hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL;
381 /* we can compensate an offset of up to 3 channels = 15 MHz */
382 hw->wiphy->max_adj_channel_rssi_comp = 3 * 5;
384 /* Extract MAC address */
385 memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN);
386 hw->wiphy->addresses = mvm->addresses;
387 hw->wiphy->n_addresses = 1;
389 /* Extract additional MAC addresses if available */
390 num_mac = (mvm->nvm_data->n_hw_addrs > 1) ?
391 min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1;
393 for (i = 1; i < num_mac; i++) {
394 memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr,
396 mvm->addresses[i].addr[5]++;
397 hw->wiphy->n_addresses++;
400 iwl_mvm_reset_phy_ctxts(mvm);
402 hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm, false);
404 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
406 if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels)
407 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
408 &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ];
409 if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels)
410 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
411 &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ];
413 hw->wiphy->hw_version = mvm->trans->hw_id;
415 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
416 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
418 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
420 if (IWL_UCODE_API(mvm->fw->ucode_ver) >= 10) {
421 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
422 hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX;
423 hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES;
424 /* we create the 802.11 header and zero length SSID IE. */
425 hw->wiphy->max_sched_scan_ie_len =
426 SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2;
429 hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN |
430 NL80211_FEATURE_LOW_PRIORITY_SCAN |
431 NL80211_FEATURE_P2P_GO_OPPPS |
432 NL80211_FEATURE_DYNAMIC_SMPS |
433 NL80211_FEATURE_STATIC_SMPS |
434 NL80211_FEATURE_SUPPORTS_WMM_ADMISSION;
436 if (mvm->fw->ucode_capa.capa[0] &
437 IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT)
438 hw->wiphy->features |= NL80211_FEATURE_TX_POWER_INSERTION;
439 if (mvm->fw->ucode_capa.capa[0] &
440 IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT)
441 hw->wiphy->features |= NL80211_FEATURE_QUIET;
443 if (mvm->fw->ucode_capa.capa[0] &
444 IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT)
445 hw->wiphy->features |=
446 NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES;
448 if (mvm->fw->ucode_capa.capa[0] &
449 IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT)
450 hw->wiphy->features |= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES;
452 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
454 /* currently FW API supports only one optional cipher scheme */
455 if (mvm->fw->cs[0].cipher) {
456 mvm->hw->n_cipher_schemes = 1;
457 mvm->hw->cipher_schemes = &mvm->fw->cs[0];
460 #ifdef CONFIG_PM_SLEEP
461 if (iwl_mvm_is_d0i3_supported(mvm) &&
462 device_can_wakeup(mvm->trans->dev)) {
463 mvm->wowlan.flags = WIPHY_WOWLAN_ANY;
464 hw->wiphy->wowlan = &mvm->wowlan;
467 if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len &&
468 mvm->trans->ops->d3_suspend &&
469 mvm->trans->ops->d3_resume &&
470 device_can_wakeup(mvm->trans->dev)) {
471 mvm->wowlan.flags |= WIPHY_WOWLAN_MAGIC_PKT |
472 WIPHY_WOWLAN_DISCONNECT |
473 WIPHY_WOWLAN_EAP_IDENTITY_REQ |
474 WIPHY_WOWLAN_RFKILL_RELEASE |
475 WIPHY_WOWLAN_NET_DETECT;
476 if (!iwlwifi_mod_params.sw_crypto)
477 mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY |
478 WIPHY_WOWLAN_GTK_REKEY_FAILURE |
479 WIPHY_WOWLAN_4WAY_HANDSHAKE;
481 mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS;
482 mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN;
483 mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN;
484 mvm->wowlan.max_nd_match_sets = IWL_SCAN_MAX_PROFILES;
485 mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support;
486 hw->wiphy->wowlan = &mvm->wowlan;
490 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
491 /* assign default bcast filtering configuration */
492 mvm->bcast_filters = iwl_mvm_default_bcast_filters;
495 ret = iwl_mvm_leds_init(mvm);
499 if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_TDLS_SUPPORT) {
500 IWL_DEBUG_TDLS(mvm, "TDLS supported\n");
501 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS;
504 if (mvm->fw->ucode_capa.capa[0] &
505 IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH) {
506 IWL_DEBUG_TDLS(mvm, "TDLS channel switch supported\n");
507 hw->wiphy->features |= NL80211_FEATURE_TDLS_CHANNEL_SWITCH;
510 ret = ieee80211_register_hw(mvm->hw);
512 iwl_mvm_leds_exit(mvm);
517 static bool iwl_mvm_defer_tx(struct iwl_mvm *mvm,
518 struct ieee80211_sta *sta,
521 struct iwl_mvm_sta *mvmsta;
525 * double check the IN_D0I3 flag both before and after
526 * taking the spinlock, in order to prevent taking
527 * the spinlock when not needed.
529 if (likely(!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status)))
532 spin_lock(&mvm->d0i3_tx_lock);
534 * testing the flag again ensures the skb dequeue
535 * loop (on d0i3 exit) hasn't run yet.
537 if (!test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status))
540 mvmsta = iwl_mvm_sta_from_mac80211(sta);
541 if (mvmsta->sta_id == IWL_MVM_STATION_COUNT ||
542 mvmsta->sta_id != mvm->d0i3_ap_sta_id)
545 __skb_queue_tail(&mvm->d0i3_tx, skb);
546 ieee80211_stop_queues(mvm->hw);
549 iwl_mvm_ref(mvm, IWL_MVM_REF_TX);
550 iwl_mvm_unref(mvm, IWL_MVM_REF_TX);
554 spin_unlock(&mvm->d0i3_tx_lock);
558 static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
559 struct ieee80211_tx_control *control,
562 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
563 struct ieee80211_sta *sta = control->sta;
564 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
565 struct ieee80211_hdr *hdr = (void *)skb->data;
567 if (iwl_mvm_is_radio_killed(mvm)) {
568 IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n");
572 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
573 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) &&
574 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status))
577 /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */
578 if (unlikely(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER &&
579 ieee80211_is_mgmt(hdr->frame_control) &&
580 !ieee80211_is_deauth(hdr->frame_control) &&
581 !ieee80211_is_disassoc(hdr->frame_control) &&
582 !ieee80211_is_action(hdr->frame_control)))
586 if (iwl_mvm_defer_tx(mvm, sta, skb))
588 if (iwl_mvm_tx_skb(mvm, skb, sta))
593 if (iwl_mvm_tx_skb_non_sta(mvm, skb))
597 ieee80211_free_txskb(hw, skb);
600 static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg)
602 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
607 static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg)
609 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
611 if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG)
614 /* enabled by default */
618 static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
619 struct ieee80211_vif *vif,
620 enum ieee80211_ampdu_mlme_action action,
621 struct ieee80211_sta *sta, u16 tid,
622 u16 *ssn, u8 buf_size)
624 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
626 bool tx_agg_ref = false;
628 IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n",
629 sta->addr, tid, action);
631 if (!(mvm->nvm_data->sku_cap_11n_enable))
634 /* return from D0i3 before starting a new Tx aggregation */
636 case IEEE80211_AMPDU_TX_START:
637 case IEEE80211_AMPDU_TX_STOP_CONT:
638 case IEEE80211_AMPDU_TX_STOP_FLUSH:
639 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
640 case IEEE80211_AMPDU_TX_OPERATIONAL:
642 * for tx start, wait synchronously until D0i3 exit to
643 * get the correct sequence number for the tid.
644 * additionally, some other ampdu actions use direct
645 * target access, which is not handled automatically
646 * by the trans layer (unlike commands), so wait for
647 * d0i3 exit in these cases as well.
649 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_TX_AGG);
659 mutex_lock(&mvm->mutex);
662 case IEEE80211_AMPDU_RX_START:
663 if (!iwl_enable_rx_ampdu(mvm->cfg)) {
667 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true);
669 case IEEE80211_AMPDU_RX_STOP:
670 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false);
672 case IEEE80211_AMPDU_TX_START:
673 if (!iwl_enable_tx_ampdu(mvm->cfg)) {
677 ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn);
679 case IEEE80211_AMPDU_TX_STOP_CONT:
680 ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid);
682 case IEEE80211_AMPDU_TX_STOP_FLUSH:
683 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
684 ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid);
686 case IEEE80211_AMPDU_TX_OPERATIONAL:
687 ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size);
694 mutex_unlock(&mvm->mutex);
697 * If the tid is marked as started, we won't use it for offloaded
698 * traffic on the next D0i3 entry. It's safe to unref.
701 iwl_mvm_unref(mvm, IWL_MVM_REF_TX_AGG);
706 static void iwl_mvm_cleanup_iterator(void *data, u8 *mac,
707 struct ieee80211_vif *vif)
709 struct iwl_mvm *mvm = data;
710 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
712 mvmvif->uploaded = false;
713 mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
715 /* does this make sense at all? */
718 spin_lock_bh(&mvm->time_event_lock);
719 iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data);
720 spin_unlock_bh(&mvm->time_event_lock);
722 mvmvif->phy_ctxt = NULL;
723 memset(&mvmvif->bf_data, 0, sizeof(mvmvif->bf_data));
726 static ssize_t iwl_mvm_read_coredump(char *buffer, loff_t offset, size_t count,
727 const void *data, size_t datalen)
729 const struct iwl_mvm_dump_ptrs *dump_ptrs = data;
731 ssize_t bytes_read_trans;
733 if (offset < dump_ptrs->op_mode_len) {
734 bytes_read = min_t(ssize_t, count,
735 dump_ptrs->op_mode_len - offset);
736 memcpy(buffer, (u8 *)dump_ptrs->op_mode_ptr + offset,
738 offset += bytes_read;
747 if (!dump_ptrs->trans_ptr)
750 offset -= dump_ptrs->op_mode_len;
751 bytes_read_trans = min_t(ssize_t, count,
752 dump_ptrs->trans_ptr->len - offset);
753 memcpy(buffer + bytes_read,
754 (u8 *)dump_ptrs->trans_ptr->data + offset,
757 return bytes_read + bytes_read_trans;
760 static void iwl_mvm_free_coredump(const void *data)
762 const struct iwl_mvm_dump_ptrs *fw_error_dump = data;
764 vfree(fw_error_dump->op_mode_ptr);
765 vfree(fw_error_dump->trans_ptr);
766 kfree(fw_error_dump);
769 void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm)
771 struct iwl_fw_error_dump_file *dump_file;
772 struct iwl_fw_error_dump_data *dump_data;
773 struct iwl_fw_error_dump_info *dump_info;
774 struct iwl_fw_error_dump_mem *dump_mem;
775 struct iwl_mvm_dump_ptrs *fw_error_dump;
776 u32 sram_len, sram_ofs;
777 u32 file_len, rxf_len;
780 u32 smem_len = mvm->cfg->smem_len;
782 lockdep_assert_held(&mvm->mutex);
784 /* W/A for 8000 HW family A-step */
785 if (mvm->cfg->smem_len &&
786 mvm->cfg->device_family == IWL_DEVICE_FAMILY_8000 &&
787 CSR_HW_REV_STEP(mvm->trans->hw_rev) == SILICON_A_STEP)
790 fw_error_dump = kzalloc(sizeof(*fw_error_dump), GFP_KERNEL);
794 /* SRAM - include stack CCM if driver knows the values for it */
795 if (!mvm->cfg->dccm_offset || !mvm->cfg->dccm_len) {
796 const struct fw_img *img;
798 img = &mvm->fw->img[mvm->cur_ucode];
799 sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
800 sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
802 sram_ofs = mvm->cfg->dccm_offset;
803 sram_len = mvm->cfg->dccm_len;
806 /* reading buffer size */
807 reg_val = iwl_trans_read_prph(mvm->trans, RXF_SIZE_ADDR);
808 rxf_len = (reg_val & RXF_SIZE_BYTE_CNT_MSK) >> RXF_SIZE_BYTE_CND_POS;
810 /* the register holds the value divided by 128 */
811 rxf_len = rxf_len << 7;
813 file_len = sizeof(*dump_file) +
814 sizeof(*dump_data) * 3 +
815 sram_len + sizeof(*dump_mem) +
819 /* Make room for the SMEM, if it exists */
821 file_len += sizeof(*dump_data) + sizeof(*dump_mem) + smem_len;
823 dump_file = vzalloc(file_len);
825 kfree(fw_error_dump);
829 fw_error_dump->op_mode_ptr = dump_file;
831 dump_file->barker = cpu_to_le32(IWL_FW_ERROR_DUMP_BARKER);
832 dump_data = (void *)dump_file->data;
834 dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_DEV_FW_INFO);
835 dump_data->len = cpu_to_le32(sizeof(*dump_info));
836 dump_info = (void *) dump_data->data;
837 dump_info->device_family =
838 mvm->cfg->device_family == IWL_DEVICE_FAMILY_7000 ?
839 cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_7) :
840 cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_8);
841 dump_info->hw_step = cpu_to_le32(CSR_HW_REV_STEP(mvm->trans->hw_rev));
842 memcpy(dump_info->fw_human_readable, mvm->fw->human_readable,
843 sizeof(dump_info->fw_human_readable));
844 strncpy(dump_info->dev_human_readable, mvm->cfg->name,
845 sizeof(dump_info->dev_human_readable));
846 strncpy(dump_info->bus_human_readable, mvm->dev->bus->name,
847 sizeof(dump_info->bus_human_readable));
849 dump_data = iwl_fw_error_next_data(dump_data);
850 dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_RXF);
851 dump_data->len = cpu_to_le32(rxf_len);
853 if (iwl_trans_grab_nic_access(mvm->trans, false, &flags)) {
854 u32 *rxf = (void *)dump_data->data;
857 for (i = 0; i < (rxf_len / sizeof(u32)); i++) {
858 iwl_trans_write_prph(mvm->trans,
859 RXF_LD_FENCE_OFFSET_ADDR,
861 rxf[i] = iwl_trans_read_prph(mvm->trans,
862 RXF_FIFO_RD_FENCE_ADDR);
864 iwl_trans_release_nic_access(mvm->trans, &flags);
867 dump_data = iwl_fw_error_next_data(dump_data);
868 dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_MEM);
869 dump_data->len = cpu_to_le32(sram_len + sizeof(*dump_mem));
870 dump_mem = (void *)dump_data->data;
871 dump_mem->type = cpu_to_le32(IWL_FW_ERROR_DUMP_MEM_SRAM);
872 dump_mem->offset = cpu_to_le32(sram_ofs);
873 iwl_trans_read_mem_bytes(mvm->trans, sram_ofs, dump_mem->data,
877 dump_data = iwl_fw_error_next_data(dump_data);
878 dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_MEM);
879 dump_data->len = cpu_to_le32(smem_len + sizeof(*dump_mem));
880 dump_mem = (void *)dump_data->data;
881 dump_mem->type = cpu_to_le32(IWL_FW_ERROR_DUMP_MEM_SMEM);
882 dump_mem->offset = cpu_to_le32(mvm->cfg->smem_offset);
883 iwl_trans_read_mem_bytes(mvm->trans, mvm->cfg->smem_offset,
884 dump_mem->data, smem_len);
887 fw_error_dump->trans_ptr = iwl_trans_dump_data(mvm->trans);
888 fw_error_dump->op_mode_len = file_len;
889 if (fw_error_dump->trans_ptr)
890 file_len += fw_error_dump->trans_ptr->len;
891 dump_file->file_len = cpu_to_le32(file_len);
893 dev_coredumpm(mvm->trans->dev, THIS_MODULE, fw_error_dump, 0,
894 GFP_KERNEL, iwl_mvm_read_coredump, iwl_mvm_free_coredump);
897 static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
899 /* clear the D3 reconfig, we only need it to avoid dumping a
900 * firmware coredump on reconfiguration, we shouldn't do that
901 * on D3->D0 transition
903 if (!test_and_clear_bit(IWL_MVM_STATUS_D3_RECONFIG, &mvm->status))
904 iwl_mvm_fw_error_dump(mvm);
906 iwl_trans_stop_device(mvm->trans);
908 mvm->scan_status = IWL_MVM_SCAN_NONE;
909 mvm->ps_disabled = false;
910 mvm->calibrating = false;
912 /* just in case one was running */
913 ieee80211_remain_on_channel_expired(mvm->hw);
915 ieee80211_iterate_active_interfaces_atomic(
916 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
917 iwl_mvm_cleanup_iterator, mvm);
919 mvm->p2p_device_vif = NULL;
920 mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT;
922 iwl_mvm_reset_phy_ctxts(mvm);
923 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
924 memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained));
925 memset(mvm->tfd_drained, 0, sizeof(mvm->tfd_drained));
926 memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif));
927 memset(&mvm->last_bt_notif_old, 0, sizeof(mvm->last_bt_notif_old));
928 memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd));
929 memset(&mvm->last_bt_ci_cmd_old, 0, sizeof(mvm->last_bt_ci_cmd_old));
930 memset(&mvm->bt_ack_kill_msk, 0, sizeof(mvm->bt_ack_kill_msk));
931 memset(&mvm->bt_cts_kill_msk, 0, sizeof(mvm->bt_cts_kill_msk));
933 ieee80211_wake_queues(mvm->hw);
935 /* cleanup all stale references (scan, roc), but keep the
936 * ucode_down ref until reconfig is complete */
937 iwl_mvm_unref_all_except(mvm, IWL_MVM_REF_UCODE_DOWN);
939 /* clear any stale d0i3 state */
940 clear_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status);
943 mvm->rx_ba_sessions = 0;
946 int __iwl_mvm_mac_start(struct iwl_mvm *mvm)
950 lockdep_assert_held(&mvm->mutex);
952 /* Clean up some internal and mac80211 state on restart */
953 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
954 iwl_mvm_restart_cleanup(mvm);
956 ret = iwl_mvm_up(mvm);
958 if (ret && test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
959 /* Something went wrong - we need to finish some cleanup
960 * that normally iwl_mvm_mac_restart_complete() below
963 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
964 iwl_mvm_d0i3_enable_tx(mvm, NULL);
970 static int iwl_mvm_mac_start(struct ieee80211_hw *hw)
972 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
975 mutex_lock(&mvm->mutex);
976 ret = __iwl_mvm_mac_start(mvm);
977 mutex_unlock(&mvm->mutex);
982 static void iwl_mvm_restart_complete(struct iwl_mvm *mvm)
986 mutex_lock(&mvm->mutex);
988 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
989 iwl_mvm_d0i3_enable_tx(mvm, NULL);
990 ret = iwl_mvm_update_quotas(mvm, NULL);
992 IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n",
995 /* allow transport/FW low power modes */
996 iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN);
999 * If we have TDLS peers, remove them. We don't know the last seqno/PN
1000 * of packets the FW sent out, so we must reconnect.
1002 iwl_mvm_teardown_tdls_peers(mvm);
1004 mutex_unlock(&mvm->mutex);
1007 static void iwl_mvm_resume_complete(struct iwl_mvm *mvm)
1011 if (!iwl_mvm_is_d0i3_supported(mvm))
1014 mutex_lock(&mvm->d0i3_suspend_mutex);
1015 __clear_bit(D0I3_DEFER_WAKEUP, &mvm->d0i3_suspend_flags);
1016 exit_now = __test_and_clear_bit(D0I3_PENDING_WAKEUP,
1017 &mvm->d0i3_suspend_flags);
1018 mutex_unlock(&mvm->d0i3_suspend_mutex);
1021 IWL_DEBUG_RPM(mvm, "Run deferred d0i3 exit\n");
1022 _iwl_mvm_exit_d0i3(mvm);
1027 iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw,
1028 enum ieee80211_reconfig_type reconfig_type)
1030 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1032 switch (reconfig_type) {
1033 case IEEE80211_RECONFIG_TYPE_RESTART:
1034 iwl_mvm_restart_complete(mvm);
1036 case IEEE80211_RECONFIG_TYPE_SUSPEND:
1037 iwl_mvm_resume_complete(mvm);
1042 void __iwl_mvm_mac_stop(struct iwl_mvm *mvm)
1044 lockdep_assert_held(&mvm->mutex);
1046 /* disallow low power states when the FW is down */
1047 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN);
1049 /* async_handlers_wk is now blocked */
1052 * The work item could be running or queued if the
1053 * ROC time event stops just as we get here.
1055 cancel_work_sync(&mvm->roc_done_wk);
1057 iwl_trans_stop_device(mvm->trans);
1059 iwl_mvm_async_handlers_purge(mvm);
1060 /* async_handlers_list is empty and will stay empty: HW is stopped */
1062 /* the fw is stopped, the aux sta is dead: clean up driver state */
1063 iwl_mvm_del_aux_sta(mvm);
1065 mvm->ucode_loaded = false;
1068 static void iwl_mvm_mac_stop(struct ieee80211_hw *hw)
1070 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1072 flush_work(&mvm->d0i3_exit_work);
1073 flush_work(&mvm->async_handlers_wk);
1074 flush_work(&mvm->fw_error_dump_wk);
1076 mutex_lock(&mvm->mutex);
1077 __iwl_mvm_mac_stop(mvm);
1078 mutex_unlock(&mvm->mutex);
1081 * The worker might have been waiting for the mutex, let it run and
1082 * discover that its list is now empty.
1084 cancel_work_sync(&mvm->async_handlers_wk);
1087 static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
1091 lockdep_assert_held(&mvm->mutex);
1093 for (i = 0; i < NUM_PHY_CTX; i++)
1094 if (!mvm->phy_ctxts[i].ref)
1095 return &mvm->phy_ctxts[i];
1097 IWL_ERR(mvm, "No available PHY context\n");
1101 static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1104 /* FW is in charge of regulatory enforcement */
1105 struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = {
1106 .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id,
1107 .pwr_restriction = cpu_to_le16(tx_power),
1110 return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0,
1111 sizeof(reduce_txpwr_cmd),
1115 static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
1116 struct ieee80211_vif *vif)
1118 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1119 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1123 * make sure D0i3 exit is completed, otherwise a target access
1124 * during tx queue configuration could be done when still in
1127 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_ADD_IF);
1132 * Not much to do here. The stack will not allow interface
1133 * types or combinations that we didn't advertise, so we
1134 * don't really have to check the types.
1137 mutex_lock(&mvm->mutex);
1139 /* Allocate resources for the MAC context, and add it to the fw */
1140 ret = iwl_mvm_mac_ctxt_init(mvm, vif);
1144 /* Counting number of interfaces is needed for legacy PM */
1145 if (vif->type != NL80211_IFTYPE_P2P_DEVICE)
1149 * The AP binding flow can be done only after the beacon
1150 * template is configured (which happens only in the mac80211
1151 * start_ap() flow), and adding the broadcast station can happen
1152 * only after the binding.
1153 * In addition, since modifying the MAC before adding a bcast
1154 * station is not allowed by the FW, delay the adding of MAC context to
1155 * the point where we can also add the bcast station.
1156 * In short: there's not much we can do at this point, other than
1157 * allocating resources :)
1159 if (vif->type == NL80211_IFTYPE_AP ||
1160 vif->type == NL80211_IFTYPE_ADHOC) {
1161 ret = iwl_mvm_alloc_bcast_sta(mvm, vif);
1163 IWL_ERR(mvm, "Failed to allocate bcast sta\n");
1167 iwl_mvm_vif_dbgfs_register(mvm, vif);
1171 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
1175 ret = iwl_mvm_power_update_mac(mvm);
1179 /* beacon filtering */
1180 ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0);
1182 goto out_remove_mac;
1184 if (!mvm->bf_allowed_vif &&
1185 vif->type == NL80211_IFTYPE_STATION && !vif->p2p) {
1186 mvm->bf_allowed_vif = mvmvif;
1187 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
1188 IEEE80211_VIF_SUPPORTS_CQM_RSSI;
1192 * P2P_DEVICE interface does not have a channel context assigned to it,
1193 * so a dedicated PHY context is allocated to it and the corresponding
1194 * MAC context is bound to it at this stage.
1196 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1198 mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
1199 if (!mvmvif->phy_ctxt) {
1204 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
1205 ret = iwl_mvm_binding_add_vif(mvm, vif);
1209 ret = iwl_mvm_add_bcast_sta(mvm, vif);
1213 /* Save a pointer to p2p device vif, so it can later be used to
1214 * update the p2p device MAC when a GO is started/stopped */
1215 mvm->p2p_device_vif = vif;
1218 iwl_mvm_vif_dbgfs_register(mvm, vif);
1222 iwl_mvm_binding_remove_vif(mvm, vif);
1224 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1226 if (mvm->bf_allowed_vif == mvmvif) {
1227 mvm->bf_allowed_vif = NULL;
1228 vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER |
1229 IEEE80211_VIF_SUPPORTS_CQM_RSSI);
1232 mvmvif->phy_ctxt = NULL;
1233 iwl_mvm_mac_ctxt_remove(mvm, vif);
1235 if (vif->type != NL80211_IFTYPE_P2P_DEVICE)
1238 iwl_mvm_mac_ctxt_release(mvm, vif);
1240 mutex_unlock(&mvm->mutex);
1242 iwl_mvm_unref(mvm, IWL_MVM_REF_ADD_IF);
1247 static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
1248 struct ieee80211_vif *vif)
1250 u32 tfd_msk = iwl_mvm_mac_get_queues_mask(vif);
1253 mutex_lock(&mvm->mutex);
1254 iwl_mvm_flush_tx_path(mvm, tfd_msk, true);
1255 mutex_unlock(&mvm->mutex);
1258 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1260 * Flush the ROC worker which will flush the OFFCHANNEL queue.
1261 * We assume here that all the packets sent to the OFFCHANNEL
1262 * queue are sent in ROC session.
1264 flush_work(&mvm->roc_done_wk);
1267 * By now, all the AC queues are empty. The AGG queues are
1268 * empty too. We already got all the Tx responses for all the
1269 * packets in the queues. The drain work can have been
1270 * triggered. Flush it.
1272 flush_work(&mvm->sta_drained_wk);
1276 static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
1277 struct ieee80211_vif *vif)
1279 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1280 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1282 iwl_mvm_prepare_mac_removal(mvm, vif);
1284 mutex_lock(&mvm->mutex);
1286 if (mvm->bf_allowed_vif == mvmvif) {
1287 mvm->bf_allowed_vif = NULL;
1288 vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER |
1289 IEEE80211_VIF_SUPPORTS_CQM_RSSI);
1292 iwl_mvm_vif_dbgfs_clean(mvm, vif);
1295 * For AP/GO interface, the tear down of the resources allocated to the
1296 * interface is be handled as part of the stop_ap flow.
1298 if (vif->type == NL80211_IFTYPE_AP ||
1299 vif->type == NL80211_IFTYPE_ADHOC) {
1300 #ifdef CONFIG_NL80211_TESTMODE
1301 if (vif == mvm->noa_vif) {
1302 mvm->noa_vif = NULL;
1303 mvm->noa_duration = 0;
1306 iwl_mvm_dealloc_bcast_sta(mvm, vif);
1310 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1311 mvm->p2p_device_vif = NULL;
1312 iwl_mvm_rm_bcast_sta(mvm, vif);
1313 iwl_mvm_binding_remove_vif(mvm, vif);
1314 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1315 mvmvif->phy_ctxt = NULL;
1318 if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE)
1321 iwl_mvm_power_update_mac(mvm);
1322 iwl_mvm_mac_ctxt_remove(mvm, vif);
1325 iwl_mvm_mac_ctxt_release(mvm, vif);
1326 mutex_unlock(&mvm->mutex);
1329 static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed)
1334 struct iwl_mvm_mc_iter_data {
1335 struct iwl_mvm *mvm;
1339 static void iwl_mvm_mc_iface_iterator(void *_data, u8 *mac,
1340 struct ieee80211_vif *vif)
1342 struct iwl_mvm_mc_iter_data *data = _data;
1343 struct iwl_mvm *mvm = data->mvm;
1344 struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd;
1347 /* if we don't have free ports, mcast frames will be dropped */
1348 if (WARN_ON_ONCE(data->port_id >= MAX_PORT_ID_NUM))
1351 if (vif->type != NL80211_IFTYPE_STATION ||
1352 !vif->bss_conf.assoc)
1355 cmd->port_id = data->port_id++;
1356 memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN);
1357 len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4);
1359 ret = iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_ASYNC, len, cmd);
1361 IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret);
1364 static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm)
1366 struct iwl_mvm_mc_iter_data iter_data = {
1370 lockdep_assert_held(&mvm->mutex);
1372 if (WARN_ON_ONCE(!mvm->mcast_filter_cmd))
1375 ieee80211_iterate_active_interfaces_atomic(
1376 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
1377 iwl_mvm_mc_iface_iterator, &iter_data);
1380 static u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw,
1381 struct netdev_hw_addr_list *mc_list)
1383 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1384 struct iwl_mcast_filter_cmd *cmd;
1385 struct netdev_hw_addr *addr;
1390 addr_count = netdev_hw_addr_list_count(mc_list);
1391 pass_all = addr_count > MAX_MCAST_FILTERING_ADDRESSES ||
1392 IWL_MVM_FW_MCAST_FILTER_PASS_ALL;
1396 len = roundup(sizeof(*cmd) + addr_count * ETH_ALEN, 4);
1397 cmd = kzalloc(len, GFP_ATOMIC);
1403 return (u64)(unsigned long)cmd;
1406 netdev_hw_addr_list_for_each(addr, mc_list) {
1407 IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %pM\n",
1408 cmd->count, addr->addr);
1409 memcpy(&cmd->addr_list[cmd->count * ETH_ALEN],
1410 addr->addr, ETH_ALEN);
1414 return (u64)(unsigned long)cmd;
1417 static void iwl_mvm_configure_filter(struct ieee80211_hw *hw,
1418 unsigned int changed_flags,
1419 unsigned int *total_flags,
1422 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1423 struct iwl_mcast_filter_cmd *cmd = (void *)(unsigned long)multicast;
1425 mutex_lock(&mvm->mutex);
1427 /* replace previous configuration */
1428 kfree(mvm->mcast_filter_cmd);
1429 mvm->mcast_filter_cmd = cmd;
1434 iwl_mvm_recalc_multicast(mvm);
1436 mutex_unlock(&mvm->mutex);
1440 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1441 struct iwl_bcast_iter_data {
1442 struct iwl_mvm *mvm;
1443 struct iwl_bcast_filter_cmd *cmd;
1448 iwl_mvm_set_bcast_filter(struct ieee80211_vif *vif,
1449 const struct iwl_fw_bcast_filter *in_filter,
1450 struct iwl_fw_bcast_filter *out_filter)
1452 struct iwl_fw_bcast_filter_attr *attr;
1455 memcpy(out_filter, in_filter, sizeof(*out_filter));
1457 for (i = 0; i < ARRAY_SIZE(out_filter->attrs); i++) {
1458 attr = &out_filter->attrs[i];
1463 switch (attr->reserved1) {
1464 case cpu_to_le16(BC_FILTER_MAGIC_IP):
1465 if (vif->bss_conf.arp_addr_cnt != 1) {
1470 attr->val = vif->bss_conf.arp_addr_list[0];
1472 case cpu_to_le16(BC_FILTER_MAGIC_MAC):
1473 attr->val = *(__be32 *)&vif->addr[2];
1478 attr->reserved1 = 0;
1479 out_filter->num_attrs++;
1483 static void iwl_mvm_bcast_filter_iterator(void *_data, u8 *mac,
1484 struct ieee80211_vif *vif)
1486 struct iwl_bcast_iter_data *data = _data;
1487 struct iwl_mvm *mvm = data->mvm;
1488 struct iwl_bcast_filter_cmd *cmd = data->cmd;
1489 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1490 struct iwl_fw_bcast_mac *bcast_mac;
1493 if (WARN_ON(mvmvif->id >= ARRAY_SIZE(cmd->macs)))
1496 bcast_mac = &cmd->macs[mvmvif->id];
1499 * enable filtering only for associated stations, but not for P2P
1502 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p ||
1503 !vif->bss_conf.assoc)
1506 bcast_mac->default_discard = 1;
1508 /* copy all configured filters */
1509 for (i = 0; mvm->bcast_filters[i].attrs[0].mask; i++) {
1511 * Make sure we don't exceed our filters limit.
1512 * if there is still a valid filter to be configured,
1513 * be on the safe side and just allow bcast for this mac.
1515 if (WARN_ON_ONCE(data->current_filter >=
1516 ARRAY_SIZE(cmd->filters))) {
1517 bcast_mac->default_discard = 0;
1518 bcast_mac->attached_filters = 0;
1522 iwl_mvm_set_bcast_filter(vif,
1523 &mvm->bcast_filters[i],
1524 &cmd->filters[data->current_filter]);
1526 /* skip current filter if it contains no attributes */
1527 if (!cmd->filters[data->current_filter].num_attrs)
1530 /* attach the filter to current mac */
1531 bcast_mac->attached_filters |=
1532 cpu_to_le16(BIT(data->current_filter));
1534 data->current_filter++;
1538 bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm,
1539 struct iwl_bcast_filter_cmd *cmd)
1541 struct iwl_bcast_iter_data iter_data = {
1546 if (IWL_MVM_FW_BCAST_FILTER_PASS_ALL)
1549 memset(cmd, 0, sizeof(*cmd));
1550 cmd->max_bcast_filters = ARRAY_SIZE(cmd->filters);
1551 cmd->max_macs = ARRAY_SIZE(cmd->macs);
1553 #ifdef CONFIG_IWLWIFI_DEBUGFS
1554 /* use debugfs filters/macs if override is configured */
1555 if (mvm->dbgfs_bcast_filtering.override) {
1556 memcpy(cmd->filters, &mvm->dbgfs_bcast_filtering.cmd.filters,
1557 sizeof(cmd->filters));
1558 memcpy(cmd->macs, &mvm->dbgfs_bcast_filtering.cmd.macs,
1564 /* if no filters are configured, do nothing */
1565 if (!mvm->bcast_filters)
1568 /* configure and attach these filters for each associated sta vif */
1569 ieee80211_iterate_active_interfaces(
1570 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
1571 iwl_mvm_bcast_filter_iterator, &iter_data);
1575 static int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm,
1576 struct ieee80211_vif *vif)
1578 struct iwl_bcast_filter_cmd cmd;
1580 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING))
1583 if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd))
1586 return iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, 0,
1590 static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm,
1591 struct ieee80211_vif *vif)
1597 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,
1598 struct ieee80211_vif *vif,
1599 struct ieee80211_bss_conf *bss_conf,
1602 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1606 * Re-calculate the tsf id, as the master-slave relations depend on the
1607 * beacon interval, which was not known when the station interface was
1610 if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc)
1611 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif);
1614 * If we're not associated yet, take the (new) BSSID before associating
1615 * so the firmware knows. If we're already associated, then use the old
1616 * BSSID here, and we'll send a cleared one later in the CHANGED_ASSOC
1617 * branch for disassociation below.
1619 if (changes & BSS_CHANGED_BSSID && !mvmvif->associated)
1620 memcpy(mvmvif->bssid, bss_conf->bssid, ETH_ALEN);
1622 ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, mvmvif->bssid);
1624 IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
1626 /* after sending it once, adopt mac80211 data */
1627 memcpy(mvmvif->bssid, bss_conf->bssid, ETH_ALEN);
1628 mvmvif->associated = bss_conf->assoc;
1630 if (changes & BSS_CHANGED_ASSOC) {
1631 if (bss_conf->assoc) {
1632 /* add quota for this interface */
1633 ret = iwl_mvm_update_quotas(mvm, NULL);
1635 IWL_ERR(mvm, "failed to update quotas\n");
1639 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART,
1642 * If we're restarting then the firmware will
1643 * obviously have lost synchronisation with
1644 * the AP. It will attempt to synchronise by
1645 * itself, but we can make it more reliable by
1646 * scheduling a session protection time event.
1648 * The firmware needs to receive a beacon to
1649 * catch up with synchronisation, use 110% of
1650 * the beacon interval.
1652 * Set a large maximum delay to allow for more
1653 * than a single interface.
1655 u32 dur = (11 * vif->bss_conf.beacon_int) / 10;
1656 iwl_mvm_protect_session(mvm, vif, dur, dur,
1660 iwl_mvm_sf_update(mvm, vif, false);
1661 iwl_mvm_power_vif_assoc(mvm, vif);
1663 iwl_mvm_ref(mvm, IWL_MVM_REF_P2P_CLIENT);
1664 iwl_mvm_update_smps(mvm, vif,
1665 IWL_MVM_SMPS_REQ_PROT,
1666 IEEE80211_SMPS_DYNAMIC);
1668 } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {
1670 * If update fails - SF might be running in associated
1671 * mode while disassociated - which is forbidden.
1673 WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false),
1674 "Failed to update SF upon disassociation\n");
1676 /* remove AP station now that the MAC is unassoc */
1677 ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id);
1679 IWL_ERR(mvm, "failed to remove AP station\n");
1681 if (mvm->d0i3_ap_sta_id == mvmvif->ap_sta_id)
1682 mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT;
1683 mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
1684 /* remove quota for this interface */
1685 ret = iwl_mvm_update_quotas(mvm, NULL);
1687 IWL_ERR(mvm, "failed to update quotas\n");
1690 iwl_mvm_unref(mvm, IWL_MVM_REF_P2P_CLIENT);
1692 /* this will take the cleared BSSID from bss_conf */
1693 ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
1696 "failed to update MAC %pM (clear after unassoc)\n",
1700 iwl_mvm_recalc_multicast(mvm);
1701 iwl_mvm_configure_bcast_filter(mvm, vif);
1703 /* reset rssi values */
1704 mvmvif->bf_data.ave_beacon_signal = 0;
1706 iwl_mvm_bt_coex_vif_change(mvm);
1707 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT,
1708 IEEE80211_SMPS_AUTOMATIC);
1709 } else if (changes & BSS_CHANGED_BEACON_INFO) {
1711 * We received a beacon _after_ association so
1712 * remove the session protection.
1714 iwl_mvm_remove_time_event(mvm, mvmvif,
1715 &mvmvif->time_event_data);
1718 if (changes & BSS_CHANGED_BEACON_INFO) {
1719 iwl_mvm_sf_update(mvm, vif, false);
1720 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0));
1723 if (changes & (BSS_CHANGED_PS | BSS_CHANGED_P2P_PS | BSS_CHANGED_QOS)) {
1724 ret = iwl_mvm_power_update_mac(mvm);
1726 IWL_ERR(mvm, "failed to update power mode\n");
1729 if (changes & BSS_CHANGED_TXPOWER) {
1730 IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n",
1732 iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower);
1735 if (changes & BSS_CHANGED_CQM) {
1736 IWL_DEBUG_MAC80211(mvm, "cqm info_changed\n");
1737 /* reset cqm events tracking */
1738 mvmvif->bf_data.last_cqm_event = 0;
1739 if (mvmvif->bf_data.bf_enabled) {
1740 ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0);
1743 "failed to update CQM thresholds\n");
1747 if (changes & BSS_CHANGED_ARP_FILTER) {
1748 IWL_DEBUG_MAC80211(mvm, "arp filter changed\n");
1749 iwl_mvm_configure_bcast_filter(mvm, vif);
1753 static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw,
1754 struct ieee80211_vif *vif)
1756 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1757 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1761 * iwl_mvm_mac_ctxt_add() might read directly from the device
1762 * (the system time), so make sure it is available.
1764 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_START_AP);
1768 mutex_lock(&mvm->mutex);
1770 /* Send the beacon template */
1771 ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif);
1776 * Re-calculate the tsf id, as the master-slave relations depend on the
1777 * beacon interval, which was not known when the AP interface was added.
1779 if (vif->type == NL80211_IFTYPE_AP)
1780 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif);
1782 /* Add the mac context */
1783 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
1787 /* Perform the binding */
1788 ret = iwl_mvm_binding_add_vif(mvm, vif);
1792 /* Send the bcast station. At this stage the TBTT and DTIM time events
1793 * are added and applied to the scheduler */
1794 ret = iwl_mvm_send_add_bcast_sta(mvm, vif);
1798 /* must be set before quota calculations */
1799 mvmvif->ap_ibss_active = true;
1801 /* power updated needs to be done before quotas */
1802 iwl_mvm_power_update_mac(mvm);
1804 ret = iwl_mvm_update_quotas(mvm, NULL);
1806 goto out_quota_failed;
1808 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
1809 if (vif->p2p && mvm->p2p_device_vif)
1810 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL);
1812 iwl_mvm_ref(mvm, IWL_MVM_REF_AP_IBSS);
1814 iwl_mvm_bt_coex_vif_change(mvm);
1816 /* we don't support TDLS during DCM */
1817 if (iwl_mvm_phy_ctx_count(mvm) > 1)
1818 iwl_mvm_teardown_tdls_peers(mvm);
1820 mutex_unlock(&mvm->mutex);
1824 iwl_mvm_power_update_mac(mvm);
1825 mvmvif->ap_ibss_active = false;
1826 iwl_mvm_send_rm_bcast_sta(mvm, vif);
1828 iwl_mvm_binding_remove_vif(mvm, vif);
1830 iwl_mvm_mac_ctxt_remove(mvm, vif);
1832 mutex_unlock(&mvm->mutex);
1833 iwl_mvm_unref(mvm, IWL_MVM_REF_START_AP);
1837 static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw,
1838 struct ieee80211_vif *vif)
1840 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1841 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1843 iwl_mvm_prepare_mac_removal(mvm, vif);
1845 mutex_lock(&mvm->mutex);
1847 /* Handle AP stop while in CSA */
1848 if (rcu_access_pointer(mvm->csa_vif) == vif) {
1849 iwl_mvm_remove_time_event(mvm, mvmvif,
1850 &mvmvif->time_event_data);
1851 RCU_INIT_POINTER(mvm->csa_vif, NULL);
1854 if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) {
1855 RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL);
1856 mvm->csa_tx_block_bcn_timeout = 0;
1859 mvmvif->ap_ibss_active = false;
1860 mvm->ap_last_beacon_gp2 = 0;
1862 iwl_mvm_bt_coex_vif_change(mvm);
1864 iwl_mvm_unref(mvm, IWL_MVM_REF_AP_IBSS);
1866 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
1867 if (vif->p2p && mvm->p2p_device_vif)
1868 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL);
1870 iwl_mvm_update_quotas(mvm, NULL);
1871 iwl_mvm_send_rm_bcast_sta(mvm, vif);
1872 iwl_mvm_binding_remove_vif(mvm, vif);
1874 iwl_mvm_power_update_mac(mvm);
1876 iwl_mvm_mac_ctxt_remove(mvm, vif);
1878 mutex_unlock(&mvm->mutex);
1882 iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm,
1883 struct ieee80211_vif *vif,
1884 struct ieee80211_bss_conf *bss_conf,
1887 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1889 /* Changes will be applied when the AP/IBSS is started */
1890 if (!mvmvif->ap_ibss_active)
1893 if (changes & (BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_HT |
1894 BSS_CHANGED_BANDWIDTH | BSS_CHANGED_QOS) &&
1895 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL))
1896 IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
1898 /* Need to send a new beacon template to the FW */
1899 if (changes & BSS_CHANGED_BEACON &&
1900 iwl_mvm_mac_ctxt_beacon_changed(mvm, vif))
1901 IWL_WARN(mvm, "Failed updating beacon data\n");
1903 if (changes & BSS_CHANGED_TXPOWER) {
1904 IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n",
1906 iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower);
1911 static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
1912 struct ieee80211_vif *vif,
1913 struct ieee80211_bss_conf *bss_conf,
1916 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1919 * iwl_mvm_bss_info_changed_station() might call
1920 * iwl_mvm_protect_session(), which reads directly from
1921 * the device (the system time), so make sure it is available.
1923 if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_BSS_CHANGED))
1926 mutex_lock(&mvm->mutex);
1928 if (changes & BSS_CHANGED_IDLE && !bss_conf->idle)
1929 iwl_mvm_scan_offload_stop(mvm, true);
1931 switch (vif->type) {
1932 case NL80211_IFTYPE_STATION:
1933 iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes);
1935 case NL80211_IFTYPE_AP:
1936 case NL80211_IFTYPE_ADHOC:
1937 iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes);
1940 /* shouldn't happen */
1944 mutex_unlock(&mvm->mutex);
1945 iwl_mvm_unref(mvm, IWL_MVM_REF_BSS_CHANGED);
1948 static int iwl_mvm_cancel_scan_wait_notif(struct iwl_mvm *mvm,
1949 enum iwl_scan_status scan_type)
1952 bool wait_for_handlers = false;
1954 mutex_lock(&mvm->mutex);
1956 if (mvm->scan_status != scan_type) {
1958 /* make sure there are no pending notifications */
1959 wait_for_handlers = true;
1963 switch (scan_type) {
1964 case IWL_MVM_SCAN_SCHED:
1965 ret = iwl_mvm_scan_offload_stop(mvm, true);
1967 case IWL_MVM_SCAN_OS:
1968 ret = iwl_mvm_cancel_scan(mvm);
1970 case IWL_MVM_SCAN_NONE:
1979 wait_for_handlers = true;
1981 mutex_unlock(&mvm->mutex);
1983 /* make sure we consume the completion notification */
1984 if (wait_for_handlers)
1985 iwl_mvm_wait_for_async_handlers(mvm);
1989 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
1990 struct ieee80211_vif *vif,
1991 struct ieee80211_scan_request *hw_req)
1993 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1994 struct cfg80211_scan_request *req = &hw_req->req;
1997 if (req->n_channels == 0 ||
1998 req->n_channels > mvm->fw->ucode_capa.n_scan_channels)
2001 if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
2002 ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_SCHED);
2007 mutex_lock(&mvm->mutex);
2009 if (mvm->scan_status != IWL_MVM_SCAN_NONE) {
2014 iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN);
2016 if (mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)
2017 ret = iwl_mvm_scan_umac(mvm, vif, hw_req);
2018 else if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN)
2019 ret = iwl_mvm_unified_scan_lmac(mvm, vif, hw_req);
2021 ret = iwl_mvm_scan_request(mvm, vif, req);
2024 iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
2026 mutex_unlock(&mvm->mutex);
2030 static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
2031 struct ieee80211_vif *vif)
2033 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2035 mutex_lock(&mvm->mutex);
2037 iwl_mvm_cancel_scan(mvm);
2039 mutex_unlock(&mvm->mutex);
2043 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw,
2044 struct ieee80211_sta *sta, u16 tids,
2046 enum ieee80211_frame_release_type reason,
2049 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2051 /* Called when we need to transmit (a) frame(s) from mac80211 */
2053 iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames,
2054 tids, more_data, false);
2058 iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw,
2059 struct ieee80211_sta *sta, u16 tids,
2061 enum ieee80211_frame_release_type reason,
2064 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2066 /* Called when we need to transmit (a) frame(s) from agg queue */
2068 iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames,
2069 tids, more_data, true);
2072 static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw,
2073 struct ieee80211_vif *vif,
2074 enum sta_notify_cmd cmd,
2075 struct ieee80211_sta *sta)
2077 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2078 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
2082 case STA_NOTIFY_SLEEP:
2083 if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0)
2084 ieee80211_sta_block_awake(hw, sta, true);
2085 spin_lock_bh(&mvmsta->lock);
2086 for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) {
2087 struct iwl_mvm_tid_data *tid_data;
2089 tid_data = &mvmsta->tid_data[tid];
2090 if (tid_data->state != IWL_AGG_ON &&
2091 tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA)
2093 if (iwl_mvm_tid_queued(tid_data) == 0)
2095 ieee80211_sta_set_buffered(sta, tid, true);
2097 spin_unlock_bh(&mvmsta->lock);
2099 * The fw updates the STA to be asleep. Tx packets on the Tx
2100 * queues to this station will not be transmitted. The fw will
2101 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
2104 case STA_NOTIFY_AWAKE:
2105 if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
2107 iwl_mvm_sta_modify_ps_wake(mvm, sta);
2114 static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw,
2115 struct ieee80211_vif *vif,
2116 struct ieee80211_sta *sta)
2118 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2119 struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv;
2122 * This is called before mac80211 does RCU synchronisation,
2123 * so here we already invalidate our internal RCU-protected
2124 * station pointer. The rest of the code will thus no longer
2125 * be able to find the station this way, and we don't rely
2126 * on further RCU synchronisation after the sta_state()
2127 * callback deleted the station.
2129 mutex_lock(&mvm->mutex);
2130 if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id]))
2131 rcu_assign_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id],
2133 mutex_unlock(&mvm->mutex);
2136 static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
2137 struct ieee80211_vif *vif,
2138 struct ieee80211_sta *sta,
2139 enum ieee80211_sta_state old_state,
2140 enum ieee80211_sta_state new_state)
2142 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2143 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
2146 IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n",
2147 sta->addr, old_state, new_state);
2149 /* this would be a mac80211 bug ... but don't crash */
2150 if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
2153 /* if a STA is being removed, reuse its ID */
2154 flush_work(&mvm->sta_drained_wk);
2156 mutex_lock(&mvm->mutex);
2157 if (old_state == IEEE80211_STA_NOTEXIST &&
2158 new_state == IEEE80211_STA_NONE) {
2160 * Firmware bug - it'll crash if the beacon interval is less
2161 * than 16. We can't avoid connecting at all, so refuse the
2162 * station state change, this will cause mac80211 to abandon
2163 * attempts to connect to this AP, and eventually wpa_s will
2164 * blacklist the AP...
2166 if (vif->type == NL80211_IFTYPE_STATION &&
2167 vif->bss_conf.beacon_int < 16) {
2169 "AP %pM beacon interval is %d, refusing due to firmware bug!\n",
2170 sta->addr, vif->bss_conf.beacon_int);
2177 iwl_mvm_tdls_sta_count(mvm, NULL) ==
2178 IWL_MVM_TDLS_STA_COUNT ||
2179 iwl_mvm_phy_ctx_count(mvm) > 1)) {
2180 IWL_DEBUG_MAC80211(mvm, "refusing TDLS sta\n");
2185 ret = iwl_mvm_add_sta(mvm, vif, sta);
2186 if (sta->tdls && ret == 0)
2187 iwl_mvm_recalc_tdls_state(mvm, vif, true);
2188 } else if (old_state == IEEE80211_STA_NONE &&
2189 new_state == IEEE80211_STA_AUTH) {
2191 * EBS may be disabled due to previous failures reported by FW.
2192 * Reset EBS status here assuming environment has been changed.
2194 mvm->last_ebs_successful = true;
2196 } else if (old_state == IEEE80211_STA_AUTH &&
2197 new_state == IEEE80211_STA_ASSOC) {
2198 ret = iwl_mvm_update_sta(mvm, vif, sta);
2200 iwl_mvm_rs_rate_init(mvm, sta,
2201 mvmvif->phy_ctxt->channel->band,
2203 } else if (old_state == IEEE80211_STA_ASSOC &&
2204 new_state == IEEE80211_STA_AUTHORIZED) {
2206 /* we don't support TDLS during DCM */
2207 if (iwl_mvm_phy_ctx_count(mvm) > 1)
2208 iwl_mvm_teardown_tdls_peers(mvm);
2210 /* enable beacon filtering */
2211 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0));
2213 } else if (old_state == IEEE80211_STA_AUTHORIZED &&
2214 new_state == IEEE80211_STA_ASSOC) {
2215 /* disable beacon filtering */
2216 WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif, 0));
2218 } else if (old_state == IEEE80211_STA_ASSOC &&
2219 new_state == IEEE80211_STA_AUTH) {
2221 } else if (old_state == IEEE80211_STA_AUTH &&
2222 new_state == IEEE80211_STA_NONE) {
2224 } else if (old_state == IEEE80211_STA_NONE &&
2225 new_state == IEEE80211_STA_NOTEXIST) {
2226 ret = iwl_mvm_rm_sta(mvm, vif, sta);
2228 iwl_mvm_recalc_tdls_state(mvm, vif, false);
2233 mutex_unlock(&mvm->mutex);
2235 if (sta->tdls && ret == 0) {
2236 if (old_state == IEEE80211_STA_NOTEXIST &&
2237 new_state == IEEE80211_STA_NONE)
2238 ieee80211_reserve_tid(sta, IWL_MVM_TDLS_FW_TID);
2239 else if (old_state == IEEE80211_STA_NONE &&
2240 new_state == IEEE80211_STA_NOTEXIST)
2241 ieee80211_unreserve_tid(sta, IWL_MVM_TDLS_FW_TID);
2247 static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
2249 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2251 mvm->rts_threshold = value;
2256 static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw,
2257 struct ieee80211_vif *vif,
2258 struct ieee80211_sta *sta, u32 changed)
2260 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2262 if (vif->type == NL80211_IFTYPE_STATION &&
2263 changed & IEEE80211_RC_NSS_CHANGED)
2264 iwl_mvm_sf_update(mvm, vif, false);
2267 static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw,
2268 struct ieee80211_vif *vif, u16 ac,
2269 const struct ieee80211_tx_queue_params *params)
2271 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2272 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
2274 mvmvif->queue_params[ac] = *params;
2277 * No need to update right away, we'll get BSS_CHANGED_QOS
2278 * The exception is P2P_DEVICE interface which needs immediate update.
2280 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
2283 mutex_lock(&mvm->mutex);
2284 ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
2285 mutex_unlock(&mvm->mutex);
2291 static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
2292 struct ieee80211_vif *vif)
2294 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2295 u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS,
2296 200 + vif->bss_conf.beacon_int);
2297 u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS,
2298 100 + vif->bss_conf.beacon_int);
2300 if (WARN_ON_ONCE(vif->bss_conf.assoc))
2304 * iwl_mvm_protect_session() reads directly from the device
2305 * (the system time), so make sure it is available.
2307 if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PREPARE_TX))
2310 mutex_lock(&mvm->mutex);
2311 /* Try really hard to protect the session and hear a beacon */
2312 iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500, false);
2313 mutex_unlock(&mvm->mutex);
2315 iwl_mvm_unref(mvm, IWL_MVM_REF_PREPARE_TX);
2318 static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw,
2319 struct ieee80211_vif *vif,
2320 struct cfg80211_sched_scan_request *req,
2321 struct ieee80211_scan_ies *ies)
2323 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2326 if (!(mvm->fw->ucode_capa.capa[0] & IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
2327 ret = iwl_mvm_cancel_scan_wait_notif(mvm, IWL_MVM_SCAN_OS);
2332 mutex_lock(&mvm->mutex);
2334 /* Newest FW fixes sched scan while connected on another interface */
2335 if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) {
2336 if (!vif->bss_conf.idle) {
2340 } else if (!iwl_mvm_is_idle(mvm)) {
2345 if (mvm->scan_status != IWL_MVM_SCAN_NONE) {
2350 ret = iwl_mvm_scan_offload_start(mvm, vif, req, ies);
2352 mvm->scan_status = IWL_MVM_SCAN_NONE;
2355 mutex_unlock(&mvm->mutex);
2359 static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw,
2360 struct ieee80211_vif *vif)
2362 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2365 mutex_lock(&mvm->mutex);
2366 ret = iwl_mvm_scan_offload_stop(mvm, false);
2367 mutex_unlock(&mvm->mutex);
2368 iwl_mvm_wait_for_async_handlers(mvm);
2374 static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
2375 enum set_key_cmd cmd,
2376 struct ieee80211_vif *vif,
2377 struct ieee80211_sta *sta,
2378 struct ieee80211_key_conf *key)
2380 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2383 if (iwlwifi_mod_params.sw_crypto) {
2384 IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n");
2388 switch (key->cipher) {
2389 case WLAN_CIPHER_SUITE_TKIP:
2390 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
2392 case WLAN_CIPHER_SUITE_CCMP:
2393 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
2395 case WLAN_CIPHER_SUITE_AES_CMAC:
2396 WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE));
2398 case WLAN_CIPHER_SUITE_WEP40:
2399 case WLAN_CIPHER_SUITE_WEP104:
2400 /* For non-client mode, only use WEP keys for TX as we probably
2401 * don't have a station yet anyway and would then have to keep
2402 * track of the keys, linking them to each of the clients/peers
2403 * as they appear. For now, don't do that, for performance WEP
2404 * offload doesn't really matter much, but we need it for some
2405 * other offload features in client mode.
2407 if (vif->type != NL80211_IFTYPE_STATION)
2411 /* currently FW supports only one optional cipher scheme */
2412 if (hw->n_cipher_schemes &&
2413 hw->cipher_schemes->cipher == key->cipher)
2414 key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE;
2419 mutex_lock(&mvm->mutex);
2423 if ((vif->type == NL80211_IFTYPE_ADHOC ||
2424 vif->type == NL80211_IFTYPE_AP) && !sta) {
2426 * GTK on AP interface is a TX-only key, return 0;
2427 * on IBSS they're per-station and because we're lazy
2428 * we don't support them for RX, so do the same.
2431 key->hw_key_idx = STA_KEY_IDX_INVALID;
2435 IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n");
2436 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false);
2438 IWL_WARN(mvm, "set key failed\n");
2440 * can't add key for RX, but we don't need it
2441 * in the device for TX so still return 0
2443 key->hw_key_idx = STA_KEY_IDX_INVALID;
2449 if (key->hw_key_idx == STA_KEY_IDX_INVALID) {
2454 IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n");
2455 ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key);
2461 mutex_unlock(&mvm->mutex);
2465 static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw,
2466 struct ieee80211_vif *vif,
2467 struct ieee80211_key_conf *keyconf,
2468 struct ieee80211_sta *sta,
2469 u32 iv32, u16 *phase1key)
2471 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2473 if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID)
2476 iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key);
2480 static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data *notif_wait,
2481 struct iwl_rx_packet *pkt, void *data)
2483 struct iwl_mvm *mvm =
2484 container_of(notif_wait, struct iwl_mvm, notif_wait);
2485 struct iwl_hs20_roc_res *resp;
2486 int resp_len = iwl_rx_packet_payload_len(pkt);
2487 struct iwl_mvm_time_event_data *te_data = data;
2489 if (WARN_ON(pkt->hdr.cmd != HOT_SPOT_CMD))
2492 if (WARN_ON_ONCE(resp_len != sizeof(*resp))) {
2493 IWL_ERR(mvm, "Invalid HOT_SPOT_CMD response\n");
2497 resp = (void *)pkt->data;
2500 "Aux ROC: Recieved response from ucode: status=%d uid=%d\n",
2501 resp->status, resp->event_unique_id);
2503 te_data->uid = le32_to_cpu(resp->event_unique_id);
2504 IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n",
2507 spin_lock_bh(&mvm->time_event_lock);
2508 list_add_tail(&te_data->list, &mvm->aux_roc_te_list);
2509 spin_unlock_bh(&mvm->time_event_lock);
2514 #define AUX_ROC_MAX_DELAY_ON_CHANNEL 5000
2515 static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
2516 struct ieee80211_channel *channel,
2517 struct ieee80211_vif *vif,
2520 int res, time_reg = DEVICE_SYSTEM_TIME_REG;
2521 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
2522 struct iwl_mvm_time_event_data *te_data = &mvmvif->hs_time_event_data;
2523 static const u8 time_event_response[] = { HOT_SPOT_CMD };
2524 struct iwl_notification_wait wait_time_event;
2525 struct iwl_hs20_roc_req aux_roc_req = {
2526 .action = cpu_to_le32(FW_CTXT_ACTION_ADD),
2528 cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX, 0)),
2529 .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id),
2530 /* Set the channel info data */
2531 .channel_info.band = (channel->band == IEEE80211_BAND_2GHZ) ?
2532 PHY_BAND_24 : PHY_BAND_5,
2533 .channel_info.channel = channel->hw_value,
2534 .channel_info.width = PHY_VHT_CHANNEL_MODE20,
2535 /* Set the time and duration */
2536 .apply_time = cpu_to_le32(iwl_read_prph(mvm->trans, time_reg)),
2537 .apply_time_max_delay =
2538 cpu_to_le32(MSEC_TO_TU(AUX_ROC_MAX_DELAY_ON_CHANNEL)),
2539 .duration = cpu_to_le32(MSEC_TO_TU(duration)),
2542 /* Set the node address */
2543 memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN);
2545 lockdep_assert_held(&mvm->mutex);
2547 spin_lock_bh(&mvm->time_event_lock);
2549 if (WARN_ON(te_data->id == HOT_SPOT_CMD)) {
2550 spin_unlock_bh(&mvm->time_event_lock);
2555 te_data->duration = duration;
2556 te_data->id = HOT_SPOT_CMD;
2558 spin_unlock_bh(&mvm->time_event_lock);
2561 * Use a notification wait, which really just processes the
2562 * command response and doesn't wait for anything, in order
2563 * to be able to process the response and get the UID inside
2564 * the RX path. Using CMD_WANT_SKB doesn't work because it
2565 * stores the buffer and then wakes up this thread, by which
2566 * time another notification (that the time event started)
2567 * might already be processed unsuccessfully.
2569 iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
2570 time_event_response,
2571 ARRAY_SIZE(time_event_response),
2572 iwl_mvm_rx_aux_roc, te_data);
2574 res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, sizeof(aux_roc_req),
2578 IWL_ERR(mvm, "Couldn't send HOT_SPOT_CMD: %d\n", res);
2579 iwl_remove_notification(&mvm->notif_wait, &wait_time_event);
2583 /* No need to wait for anything, so just pass 1 (0 isn't valid) */
2584 res = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1);
2585 /* should never fail */
2590 spin_lock_bh(&mvm->time_event_lock);
2591 iwl_mvm_te_clear_data(mvm, te_data);
2592 spin_unlock_bh(&mvm->time_event_lock);
2598 static int iwl_mvm_roc(struct ieee80211_hw *hw,
2599 struct ieee80211_vif *vif,
2600 struct ieee80211_channel *channel,
2602 enum ieee80211_roc_type type)
2604 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2605 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
2606 struct cfg80211_chan_def chandef;
2607 struct iwl_mvm_phy_ctxt *phy_ctxt;
2610 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
2613 mutex_lock(&mvm->mutex);
2615 switch (vif->type) {
2616 case NL80211_IFTYPE_STATION:
2617 if (mvm->fw->ucode_capa.capa[0] &
2618 IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT) {
2619 /* Use aux roc framework (HS20) */
2620 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel,
2624 IWL_ERR(mvm, "hotspot not supported\n");
2627 case NL80211_IFTYPE_P2P_DEVICE:
2631 IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type);
2636 for (i = 0; i < NUM_PHY_CTX; i++) {
2637 phy_ctxt = &mvm->phy_ctxts[i];
2638 if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt)
2641 if (phy_ctxt->ref && channel == phy_ctxt->channel) {
2643 * Unbind the P2P_DEVICE from the current PHY context,
2644 * and if the PHY context is not used remove it.
2646 ret = iwl_mvm_binding_remove_vif(mvm, vif);
2647 if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
2650 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
2652 /* Bind the P2P_DEVICE to the current PHY Context */
2653 mvmvif->phy_ctxt = phy_ctxt;
2655 ret = iwl_mvm_binding_add_vif(mvm, vif);
2656 if (WARN(ret, "Failed binding P2P_DEVICE\n"))
2659 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
2660 goto schedule_time_event;
2664 /* Need to update the PHY context only if the ROC channel changed */
2665 if (channel == mvmvif->phy_ctxt->channel)
2666 goto schedule_time_event;
2668 cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT);
2671 * Change the PHY context configuration as it is currently referenced
2672 * only by the P2P Device MAC
2674 if (mvmvif->phy_ctxt->ref == 1) {
2675 ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt,
2681 * The PHY context is shared with other MACs. Need to remove the
2682 * P2P Device from the binding, allocate an new PHY context and
2683 * create a new binding
2685 phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
2691 ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef,
2694 IWL_ERR(mvm, "Failed to change PHY context\n");
2698 /* Unbind the P2P_DEVICE from the current PHY context */
2699 ret = iwl_mvm_binding_remove_vif(mvm, vif);
2700 if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
2703 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
2705 /* Bind the P2P_DEVICE to the new allocated PHY context */
2706 mvmvif->phy_ctxt = phy_ctxt;
2708 ret = iwl_mvm_binding_add_vif(mvm, vif);
2709 if (WARN(ret, "Failed binding P2P_DEVICE\n"))
2712 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
2715 schedule_time_event:
2716 /* Schedule the time events */
2717 ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type);
2720 mutex_unlock(&mvm->mutex);
2721 IWL_DEBUG_MAC80211(mvm, "leave\n");
2725 static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw)
2727 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2729 IWL_DEBUG_MAC80211(mvm, "enter\n");
2731 mutex_lock(&mvm->mutex);
2732 iwl_mvm_stop_roc(mvm);
2733 mutex_unlock(&mvm->mutex);
2735 IWL_DEBUG_MAC80211(mvm, "leave\n");
2739 static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm,
2740 struct ieee80211_chanctx_conf *ctx)
2742 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
2743 struct iwl_mvm_phy_ctxt *phy_ctxt;
2746 lockdep_assert_held(&mvm->mutex);
2748 IWL_DEBUG_MAC80211(mvm, "Add channel context\n");
2750 phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
2756 ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def,
2757 ctx->rx_chains_static,
2758 ctx->rx_chains_dynamic);
2760 IWL_ERR(mvm, "Failed to add PHY context\n");
2764 iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt);
2765 *phy_ctxt_id = phy_ctxt->id;
2770 static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw,
2771 struct ieee80211_chanctx_conf *ctx)
2773 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2776 mutex_lock(&mvm->mutex);
2777 ret = __iwl_mvm_add_chanctx(mvm, ctx);
2778 mutex_unlock(&mvm->mutex);
2783 static void __iwl_mvm_remove_chanctx(struct iwl_mvm *mvm,
2784 struct ieee80211_chanctx_conf *ctx)
2786 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
2787 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
2789 lockdep_assert_held(&mvm->mutex);
2791 iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt);
2794 static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,
2795 struct ieee80211_chanctx_conf *ctx)
2797 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2799 mutex_lock(&mvm->mutex);
2800 __iwl_mvm_remove_chanctx(mvm, ctx);
2801 mutex_unlock(&mvm->mutex);
2804 static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
2805 struct ieee80211_chanctx_conf *ctx,
2808 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2809 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
2810 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
2812 if (WARN_ONCE((phy_ctxt->ref > 1) &&
2813 (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH |
2814 IEEE80211_CHANCTX_CHANGE_RX_CHAINS |
2815 IEEE80211_CHANCTX_CHANGE_RADAR |
2816 IEEE80211_CHANCTX_CHANGE_MIN_WIDTH)),
2817 "Cannot change PHY. Ref=%d, changed=0x%X\n",
2818 phy_ctxt->ref, changed))
2821 mutex_lock(&mvm->mutex);
2822 iwl_mvm_bt_coex_vif_change(mvm);
2823 iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def,
2824 ctx->rx_chains_static,
2825 ctx->rx_chains_dynamic);
2826 mutex_unlock(&mvm->mutex);
2829 static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
2830 struct ieee80211_vif *vif,
2831 struct ieee80211_chanctx_conf *ctx,
2832 bool switching_chanctx)
2834 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
2835 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
2836 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
2839 lockdep_assert_held(&mvm->mutex);
2841 mvmvif->phy_ctxt = phy_ctxt;
2843 switch (vif->type) {
2844 case NL80211_IFTYPE_AP:
2845 /* only needed if we're switching chanctx (i.e. during CSA) */
2846 if (switching_chanctx) {
2847 mvmvif->ap_ibss_active = true;
2850 case NL80211_IFTYPE_ADHOC:
2852 * The AP binding flow is handled as part of the start_ap flow
2853 * (in bss_info_changed), similarly for IBSS.
2857 case NL80211_IFTYPE_STATION:
2859 case NL80211_IFTYPE_MONITOR:
2860 /* always disable PS when a monitor interface is active */
2861 mvmvif->ps_disabled = true;
2868 ret = iwl_mvm_binding_add_vif(mvm, vif);
2873 * Power state must be updated before quotas,
2874 * otherwise fw will complain.
2876 iwl_mvm_power_update_mac(mvm);
2878 /* Setting the quota at this stage is only required for monitor
2879 * interfaces. For the other types, the bss_info changed flow
2880 * will handle quota settings.
2882 if (vif->type == NL80211_IFTYPE_MONITOR) {
2883 mvmvif->monitor_active = true;
2884 ret = iwl_mvm_update_quotas(mvm, NULL);
2886 goto out_remove_binding;
2889 /* Handle binding during CSA */
2890 if (vif->type == NL80211_IFTYPE_AP) {
2891 iwl_mvm_update_quotas(mvm, NULL);
2892 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
2895 if (switching_chanctx && vif->type == NL80211_IFTYPE_STATION) {
2896 u32 duration = 2 * vif->bss_conf.beacon_int;
2898 /* iwl_mvm_protect_session() reads directly from the
2899 * device (the system time), so make sure it is
2902 ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PROTECT_CSA);
2904 goto out_remove_binding;
2906 /* Protect the session to make sure we hear the first
2907 * beacon on the new channel.
2909 iwl_mvm_protect_session(mvm, vif, duration, duration,
2910 vif->bss_conf.beacon_int / 2,
2913 iwl_mvm_unref(mvm, IWL_MVM_REF_PROTECT_CSA);
2915 iwl_mvm_update_quotas(mvm, NULL);
2921 iwl_mvm_binding_remove_vif(mvm, vif);
2922 iwl_mvm_power_update_mac(mvm);
2925 mvmvif->phy_ctxt = NULL;
2928 static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
2929 struct ieee80211_vif *vif,
2930 struct ieee80211_chanctx_conf *ctx)
2932 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2935 mutex_lock(&mvm->mutex);
2936 ret = __iwl_mvm_assign_vif_chanctx(mvm, vif, ctx, false);
2937 mutex_unlock(&mvm->mutex);
2942 static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
2943 struct ieee80211_vif *vif,
2944 struct ieee80211_chanctx_conf *ctx,
2945 bool switching_chanctx)
2947 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
2948 struct ieee80211_vif *disabled_vif = NULL;
2950 lockdep_assert_held(&mvm->mutex);
2952 iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data);
2954 switch (vif->type) {
2955 case NL80211_IFTYPE_ADHOC:
2957 case NL80211_IFTYPE_MONITOR:
2958 mvmvif->monitor_active = false;
2959 mvmvif->ps_disabled = false;
2961 case NL80211_IFTYPE_AP:
2962 /* This part is triggered only during CSA */
2963 if (!switching_chanctx || !mvmvif->ap_ibss_active)
2966 mvmvif->csa_countdown = false;
2968 /* Set CS bit on all the stations */
2969 iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true);
2971 /* Save blocked iface, the timeout is set on the next beacon */
2972 rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif);
2974 mvmvif->ap_ibss_active = false;
2976 case NL80211_IFTYPE_STATION:
2977 if (!switching_chanctx)
2982 iwl_mvm_mac_ctxt_changed(mvm, vif, true, NULL);
2988 iwl_mvm_update_quotas(mvm, disabled_vif);
2989 iwl_mvm_binding_remove_vif(mvm, vif);
2992 mvmvif->phy_ctxt = NULL;
2993 iwl_mvm_power_update_mac(mvm);
2996 static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw,
2997 struct ieee80211_vif *vif,
2998 struct ieee80211_chanctx_conf *ctx)
3000 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3002 mutex_lock(&mvm->mutex);
3003 __iwl_mvm_unassign_vif_chanctx(mvm, vif, ctx, false);
3004 mutex_unlock(&mvm->mutex);
3008 iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm *mvm,
3009 struct ieee80211_vif_chanctx_switch *vifs)
3013 mutex_lock(&mvm->mutex);
3014 __iwl_mvm_unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true);
3015 __iwl_mvm_remove_chanctx(mvm, vifs[0].old_ctx);
3017 ret = __iwl_mvm_add_chanctx(mvm, vifs[0].new_ctx);
3019 IWL_ERR(mvm, "failed to add new_ctx during channel switch\n");
3023 ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx,
3027 "failed to assign new_ctx during channel switch\n");
3031 /* we don't support TDLS during DCM - can be caused by channel switch */
3032 if (iwl_mvm_phy_ctx_count(mvm) > 1)
3033 iwl_mvm_teardown_tdls_peers(mvm);
3038 __iwl_mvm_remove_chanctx(mvm, vifs[0].new_ctx);
3041 if (__iwl_mvm_add_chanctx(mvm, vifs[0].old_ctx)) {
3042 IWL_ERR(mvm, "failed to add old_ctx back after failure.\n");
3046 if (__iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx,
3048 IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n");
3055 /* things keep failing, better restart the hw */
3056 iwl_mvm_nic_restart(mvm, false);
3059 mutex_unlock(&mvm->mutex);
3065 iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm *mvm,
3066 struct ieee80211_vif_chanctx_switch *vifs)
3070 mutex_lock(&mvm->mutex);
3071 __iwl_mvm_unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true);
3073 ret = __iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx,
3077 "failed to assign new_ctx during channel switch\n");
3084 if (__iwl_mvm_assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx,
3086 IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n");
3093 /* things keep failing, better restart the hw */
3094 iwl_mvm_nic_restart(mvm, false);
3097 mutex_unlock(&mvm->mutex);
3102 static int iwl_mvm_switch_vif_chanctx(struct ieee80211_hw *hw,
3103 struct ieee80211_vif_chanctx_switch *vifs,
3105 enum ieee80211_chanctx_switch_mode mode)
3107 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3110 /* we only support a single-vif right now */
3115 case CHANCTX_SWMODE_SWAP_CONTEXTS:
3116 ret = iwl_mvm_switch_vif_chanctx_swap(mvm, vifs);
3118 case CHANCTX_SWMODE_REASSIGN_VIF:
3119 ret = iwl_mvm_switch_vif_chanctx_reassign(mvm, vifs);
3129 static int iwl_mvm_set_tim(struct ieee80211_hw *hw,
3130 struct ieee80211_sta *sta,
3133 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3134 struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv;
3136 if (!mvm_sta || !mvm_sta->vif) {
3137 IWL_ERR(mvm, "Station is not associated to a vif\n");
3141 return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif);
3144 #ifdef CONFIG_NL80211_TESTMODE
3145 static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = {
3146 [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 },
3147 [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 },
3148 [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 },
3151 static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm,
3152 struct ieee80211_vif *vif,
3153 void *data, int len)
3155 struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1];
3159 err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy);
3163 if (!tb[IWL_MVM_TM_ATTR_CMD])
3166 switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) {
3167 case IWL_MVM_TM_CMD_SET_NOA:
3168 if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p ||
3169 !vif->bss_conf.enable_beacon ||
3170 !tb[IWL_MVM_TM_ATTR_NOA_DURATION])
3173 noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]);
3174 if (noa_duration >= vif->bss_conf.beacon_int)
3177 mvm->noa_duration = noa_duration;
3180 return iwl_mvm_update_quotas(mvm, NULL);
3181 case IWL_MVM_TM_CMD_SET_BEACON_FILTER:
3182 /* must be associated client vif - ignore authorized */
3183 if (!vif || vif->type != NL80211_IFTYPE_STATION ||
3184 !vif->bss_conf.assoc || !vif->bss_conf.dtim_period ||
3185 !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])
3188 if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]))
3189 return iwl_mvm_enable_beacon_filter(mvm, vif, 0);
3190 return iwl_mvm_disable_beacon_filter(mvm, vif, 0);
3196 static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw,
3197 struct ieee80211_vif *vif,
3198 void *data, int len)
3200 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3203 mutex_lock(&mvm->mutex);
3204 err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len);
3205 mutex_unlock(&mvm->mutex);
3211 static void iwl_mvm_channel_switch(struct ieee80211_hw *hw,
3212 struct ieee80211_vif *vif,
3213 struct ieee80211_channel_switch *chsw)
3215 /* By implementing this operation, we prevent mac80211 from
3216 * starting its own channel switch timer, so that we can call
3217 * ieee80211_chswitch_done() ourselves at the right time
3218 * (which is when the absence time event starts).
3221 IWL_DEBUG_MAC80211(IWL_MAC80211_GET_MVM(hw),
3222 "dummy channel switch op\n");
3225 static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw,
3226 struct ieee80211_vif *vif,
3227 struct ieee80211_channel_switch *chsw)
3229 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3230 struct ieee80211_vif *csa_vif;
3231 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
3235 mutex_lock(&mvm->mutex);
3237 IWL_DEBUG_MAC80211(mvm, "pre CSA to freq %d\n",
3238 chsw->chandef.center_freq1);
3240 switch (vif->type) {
3241 case NL80211_IFTYPE_AP:
3243 rcu_dereference_protected(mvm->csa_vif,
3244 lockdep_is_held(&mvm->mutex));
3245 if (WARN_ONCE(csa_vif && csa_vif->csa_active,
3246 "Another CSA is already in progress")) {
3251 rcu_assign_pointer(mvm->csa_vif, vif);
3253 if (WARN_ONCE(mvmvif->csa_countdown,
3254 "Previous CSA countdown didn't complete")) {
3260 case NL80211_IFTYPE_STATION:
3261 /* Schedule the time event to a bit before beacon 1,
3262 * to make sure we're in the new channel when the
3265 apply_time = chsw->device_timestamp +
3266 ((vif->bss_conf.beacon_int * (chsw->count - 1) -
3267 IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT) * 1024);
3270 iwl_mvm_csa_client_absent(mvm, vif);
3272 iwl_mvm_schedule_csa_period(mvm, vif, vif->bss_conf.beacon_int,
3274 if (mvmvif->bf_data.bf_enabled) {
3275 ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0);
3285 mvmvif->ps_disabled = true;
3287 ret = iwl_mvm_power_update_ps(mvm);
3291 /* we won't be on this channel any longer */
3292 iwl_mvm_teardown_tdls_peers(mvm);
3295 mutex_unlock(&mvm->mutex);
3300 static int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
3301 struct ieee80211_vif *vif)
3303 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
3304 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3307 mutex_lock(&mvm->mutex);
3309 if (vif->type == NL80211_IFTYPE_STATION) {
3310 struct iwl_mvm_sta *mvmsta;
3312 mvmsta = iwl_mvm_sta_from_staid_protected(mvm,
3315 if (WARN_ON(!mvmsta)) {
3320 iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false);
3322 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
3324 ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0);
3328 iwl_mvm_stop_session_protection(mvm, vif);
3331 mvmvif->ps_disabled = false;
3333 ret = iwl_mvm_power_update_ps(mvm);
3336 mutex_unlock(&mvm->mutex);
3341 static void iwl_mvm_mac_flush(struct ieee80211_hw *hw,
3342 struct ieee80211_vif *vif, u32 queues, bool drop)
3344 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3345 struct iwl_mvm_vif *mvmvif;
3346 struct iwl_mvm_sta *mvmsta;
3347 struct ieee80211_sta *sta;
3351 if (!vif || vif->type != NL80211_IFTYPE_STATION)
3354 mutex_lock(&mvm->mutex);
3355 mvmvif = iwl_mvm_vif_from_mac80211(vif);
3357 /* flush the AP-station and all TDLS peers */
3358 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
3359 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
3360 lockdep_is_held(&mvm->mutex));
3361 if (IS_ERR_OR_NULL(sta))
3364 mvmsta = iwl_mvm_sta_from_mac80211(sta);
3365 if (mvmsta->vif != vif)
3368 /* make sure only TDLS peers or the AP are flushed */
3369 WARN_ON(i != mvmvif->ap_sta_id && !sta->tdls);
3371 msk |= mvmsta->tfd_queue_msk;
3375 if (iwl_mvm_flush_tx_path(mvm, msk, true))
3376 IWL_ERR(mvm, "flush request fail\n");
3377 mutex_unlock(&mvm->mutex);
3379 mutex_unlock(&mvm->mutex);
3381 /* this can take a while, and we may need/want other operations
3382 * to succeed while doing this, so do it without the mutex held
3384 iwl_trans_wait_tx_queue_empty(mvm->trans, msk);
3388 const struct ieee80211_ops iwl_mvm_hw_ops = {
3389 .tx = iwl_mvm_mac_tx,
3390 .ampdu_action = iwl_mvm_mac_ampdu_action,
3391 .start = iwl_mvm_mac_start,
3392 .reconfig_complete = iwl_mvm_mac_reconfig_complete,
3393 .stop = iwl_mvm_mac_stop,
3394 .add_interface = iwl_mvm_mac_add_interface,
3395 .remove_interface = iwl_mvm_mac_remove_interface,
3396 .config = iwl_mvm_mac_config,
3397 .prepare_multicast = iwl_mvm_prepare_multicast,
3398 .configure_filter = iwl_mvm_configure_filter,
3399 .bss_info_changed = iwl_mvm_bss_info_changed,
3400 .hw_scan = iwl_mvm_mac_hw_scan,
3401 .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
3402 .sta_pre_rcu_remove = iwl_mvm_sta_pre_rcu_remove,
3403 .sta_state = iwl_mvm_mac_sta_state,
3404 .sta_notify = iwl_mvm_mac_sta_notify,
3405 .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames,
3406 .release_buffered_frames = iwl_mvm_mac_release_buffered_frames,
3407 .set_rts_threshold = iwl_mvm_mac_set_rts_threshold,
3408 .sta_rc_update = iwl_mvm_sta_rc_update,
3409 .conf_tx = iwl_mvm_mac_conf_tx,
3410 .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx,
3411 .mgd_protect_tdls_discover = iwl_mvm_mac_mgd_protect_tdls_discover,
3412 .flush = iwl_mvm_mac_flush,
3413 .sched_scan_start = iwl_mvm_mac_sched_scan_start,
3414 .sched_scan_stop = iwl_mvm_mac_sched_scan_stop,
3415 .set_key = iwl_mvm_mac_set_key,
3416 .update_tkip_key = iwl_mvm_mac_update_tkip_key,
3417 .remain_on_channel = iwl_mvm_roc,
3418 .cancel_remain_on_channel = iwl_mvm_cancel_roc,
3419 .add_chanctx = iwl_mvm_add_chanctx,
3420 .remove_chanctx = iwl_mvm_remove_chanctx,
3421 .change_chanctx = iwl_mvm_change_chanctx,
3422 .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx,
3423 .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx,
3424 .switch_vif_chanctx = iwl_mvm_switch_vif_chanctx,
3426 .start_ap = iwl_mvm_start_ap_ibss,
3427 .stop_ap = iwl_mvm_stop_ap_ibss,
3428 .join_ibss = iwl_mvm_start_ap_ibss,
3429 .leave_ibss = iwl_mvm_stop_ap_ibss,
3431 .set_tim = iwl_mvm_set_tim,
3433 .channel_switch = iwl_mvm_channel_switch,
3434 .pre_channel_switch = iwl_mvm_pre_channel_switch,
3435 .post_channel_switch = iwl_mvm_post_channel_switch,
3437 .tdls_channel_switch = iwl_mvm_tdls_channel_switch,
3438 .tdls_cancel_channel_switch = iwl_mvm_tdls_cancel_channel_switch,
3439 .tdls_recv_channel_switch = iwl_mvm_tdls_recv_channel_switch,
3441 CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd)
3443 #ifdef CONFIG_PM_SLEEP
3445 .suspend = iwl_mvm_suspend,
3446 .resume = iwl_mvm_resume,
3447 .set_wakeup = iwl_mvm_set_wakeup,
3448 .set_rekey_data = iwl_mvm_set_rekey_data,
3449 #if IS_ENABLED(CONFIG_IPV6)
3450 .ipv6_addr_change = iwl_mvm_ipv6_addr_change,
3452 .set_default_unicast_key = iwl_mvm_set_default_unicast_key,