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 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
26 * The full GNU General Public License is included in this distribution
27 * in the file called COPYING.
29 * Contact Information:
30 * Intel Linux Wireless <linuxwifi@intel.com>
31 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
35 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
36 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
37 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
38 * All rights reserved.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
44 * * Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * * Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in
48 * the documentation and/or other materials provided with the
50 * * Neither the name Intel Corporation nor the names of its
51 * contributors may be used to endorse or promote products derived
52 * from this software without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
60 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
61 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
62 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 *****************************************************************************/
67 #include <linux/kernel.h>
68 #include <linux/slab.h>
69 #include <linux/skbuff.h>
70 #include <linux/netdevice.h>
71 #include <linux/etherdevice.h>
73 #include <linux/if_arp.h>
74 #include <linux/time.h>
75 #include <net/mac80211.h>
76 #include <net/ieee80211_radiotap.h>
79 #include "iwl-op-mode.h"
83 #include "time-event.h"
84 #include "iwl-eeprom-parse.h"
85 #include "iwl-phy-db.h"
87 #include "fw/error-dump.h"
89 #include "iwl-nvm-parse.h"
91 static const struct ieee80211_iface_limit iwl_mvm_limits
[] = {
94 .types
= BIT(NL80211_IFTYPE_STATION
),
98 .types
= BIT(NL80211_IFTYPE_AP
) |
99 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
100 BIT(NL80211_IFTYPE_P2P_GO
),
104 .types
= BIT(NL80211_IFTYPE_P2P_DEVICE
),
108 static const struct ieee80211_iface_combination iwl_mvm_iface_combinations
[] = {
110 .num_different_channels
= 2,
112 .limits
= iwl_mvm_limits
,
113 .n_limits
= ARRAY_SIZE(iwl_mvm_limits
),
117 #ifdef CONFIG_PM_SLEEP
118 static const struct nl80211_wowlan_tcp_data_token_feature
119 iwl_mvm_wowlan_tcp_token_feature
= {
122 .bufsize
= IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS
,
125 static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support
= {
126 .tok
= &iwl_mvm_wowlan_tcp_token_feature
,
127 .data_payload_max
= IWL_WOWLAN_TCP_MAX_PACKET_LEN
-
128 sizeof(struct ethhdr
) -
129 sizeof(struct iphdr
) -
130 sizeof(struct tcphdr
),
131 .data_interval_max
= 65535, /* __le16 in API */
132 .wake_payload_max
= IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN
-
133 sizeof(struct ethhdr
) -
134 sizeof(struct iphdr
) -
135 sizeof(struct tcphdr
),
140 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
142 * Use the reserved field to indicate magic values.
143 * these values will only be used internally by the driver,
144 * and won't make it to the fw (reserved will be 0).
145 * BC_FILTER_MAGIC_IP - configure the val of this attribute to
146 * be the vif's ip address. in case there is not a single
147 * ip address (0, or more than 1), this attribute will
149 * BC_FILTER_MAGIC_MAC - set the val of this attribute to
150 * the LSB bytes of the vif's mac address
153 BC_FILTER_MAGIC_NONE
= 0,
158 static const struct iwl_fw_bcast_filter iwl_mvm_default_bcast_filters
[] = {
162 .frame_type
= BCAST_FILTER_FRAME_TYPE_ALL
,
165 /* frame type - arp, hw type - ethernet */
167 BCAST_FILTER_OFFSET_PAYLOAD_START
,
168 .offset
= sizeof(rfc1042_header
),
169 .val
= cpu_to_be32(0x08060001),
170 .mask
= cpu_to_be32(0xffffffff),
175 BCAST_FILTER_OFFSET_PAYLOAD_START
,
176 .offset
= sizeof(rfc1042_header
) + 2 +
177 sizeof(struct arphdr
) +
178 ETH_ALEN
+ sizeof(__be32
) +
180 .mask
= cpu_to_be32(0xffffffff),
181 /* mark it as special field */
182 .reserved1
= cpu_to_le16(BC_FILTER_MAGIC_IP
),
187 /* dhcp offer bcast */
189 .frame_type
= BCAST_FILTER_FRAME_TYPE_IPV4
,
192 /* udp dest port - 68 (bootp client)*/
193 .offset_type
= BCAST_FILTER_OFFSET_IP_END
,
194 .offset
= offsetof(struct udphdr
, dest
),
195 .val
= cpu_to_be32(0x00440000),
196 .mask
= cpu_to_be32(0xffff0000),
199 /* dhcp - lsb bytes of client hw address */
200 .offset_type
= BCAST_FILTER_OFFSET_IP_END
,
202 .mask
= cpu_to_be32(0xffffffff),
203 /* mark it as special field */
204 .reserved1
= cpu_to_le16(BC_FILTER_MAGIC_MAC
),
208 /* last filter must be empty */
213 void iwl_mvm_ref(struct iwl_mvm
*mvm
, enum iwl_mvm_ref_type ref_type
)
215 if (!iwl_mvm_is_d0i3_supported(mvm
))
218 IWL_DEBUG_RPM(mvm
, "Take mvm reference - type %d\n", ref_type
);
219 spin_lock_bh(&mvm
->refs_lock
);
220 mvm
->refs
[ref_type
]++;
221 spin_unlock_bh(&mvm
->refs_lock
);
222 iwl_trans_ref(mvm
->trans
);
225 void iwl_mvm_unref(struct iwl_mvm
*mvm
, enum iwl_mvm_ref_type ref_type
)
227 if (!iwl_mvm_is_d0i3_supported(mvm
))
230 IWL_DEBUG_RPM(mvm
, "Leave mvm reference - type %d\n", ref_type
);
231 spin_lock_bh(&mvm
->refs_lock
);
232 if (WARN_ON(!mvm
->refs
[ref_type
])) {
233 spin_unlock_bh(&mvm
->refs_lock
);
236 mvm
->refs
[ref_type
]--;
237 spin_unlock_bh(&mvm
->refs_lock
);
238 iwl_trans_unref(mvm
->trans
);
241 static void iwl_mvm_unref_all_except(struct iwl_mvm
*mvm
,
242 enum iwl_mvm_ref_type except_ref
)
246 if (!iwl_mvm_is_d0i3_supported(mvm
))
249 spin_lock_bh(&mvm
->refs_lock
);
250 for (i
= 0; i
< IWL_MVM_REF_COUNT
; i
++) {
251 if (except_ref
== i
|| !mvm
->refs
[i
])
254 IWL_DEBUG_RPM(mvm
, "Cleanup: remove mvm ref type %d (%d)\n",
256 for (j
= 0; j
< mvm
->refs
[i
]; j
++)
257 iwl_trans_unref(mvm
->trans
);
260 spin_unlock_bh(&mvm
->refs_lock
);
263 bool iwl_mvm_ref_taken(struct iwl_mvm
*mvm
)
268 if (!iwl_mvm_is_d0i3_supported(mvm
))
271 spin_lock_bh(&mvm
->refs_lock
);
272 for (i
= 0; i
< IWL_MVM_REF_COUNT
; i
++) {
278 spin_unlock_bh(&mvm
->refs_lock
);
283 int iwl_mvm_ref_sync(struct iwl_mvm
*mvm
, enum iwl_mvm_ref_type ref_type
)
285 iwl_mvm_ref(mvm
, ref_type
);
287 if (!wait_event_timeout(mvm
->d0i3_exit_waitq
,
288 !test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
),
291 iwl_mvm_unref(mvm
, ref_type
);
298 static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm
*mvm
)
302 memset(mvm
->phy_ctxts
, 0, sizeof(mvm
->phy_ctxts
));
303 for (i
= 0; i
< NUM_PHY_CTX
; i
++) {
304 mvm
->phy_ctxts
[i
].id
= i
;
305 mvm
->phy_ctxts
[i
].ref
= 0;
309 struct ieee80211_regdomain
*iwl_mvm_get_regdomain(struct wiphy
*wiphy
,
311 enum iwl_mcc_source src_id
,
314 struct ieee80211_regdomain
*regd
= NULL
;
315 struct ieee80211_hw
*hw
= wiphy_to_ieee80211_hw(wiphy
);
316 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
317 struct iwl_mcc_update_resp
*resp
;
319 IWL_DEBUG_LAR(mvm
, "Getting regdomain data for %s from FW\n", alpha2
);
321 lockdep_assert_held(&mvm
->mutex
);
323 resp
= iwl_mvm_update_mcc(mvm
, alpha2
, src_id
);
324 if (IS_ERR_OR_NULL(resp
)) {
325 IWL_DEBUG_LAR(mvm
, "Could not get update from FW %d\n",
326 PTR_ERR_OR_ZERO(resp
));
331 *changed
= (resp
->status
== MCC_RESP_NEW_CHAN_PROFILE
);
333 regd
= iwl_parse_nvm_mcc_info(mvm
->trans
->dev
, mvm
->cfg
,
334 __le32_to_cpu(resp
->n_channels
),
336 __le16_to_cpu(resp
->mcc
));
337 /* Store the return source id */
338 src_id
= resp
->source_id
;
340 if (IS_ERR_OR_NULL(regd
)) {
341 IWL_DEBUG_LAR(mvm
, "Could not get parse update from FW %d\n",
342 PTR_ERR_OR_ZERO(regd
));
346 IWL_DEBUG_LAR(mvm
, "setting alpha2 from FW to %s (0x%x, 0x%x) src=%d\n",
347 regd
->alpha2
, regd
->alpha2
[0], regd
->alpha2
[1], src_id
);
348 mvm
->lar_regdom_set
= true;
349 mvm
->mcc_src
= src_id
;
355 void iwl_mvm_update_changed_regdom(struct iwl_mvm
*mvm
)
358 struct ieee80211_regdomain
*regd
;
360 if (!iwl_mvm_is_lar_supported(mvm
))
363 regd
= iwl_mvm_get_current_regdomain(mvm
, &changed
);
364 if (!IS_ERR_OR_NULL(regd
)) {
365 /* only update the regulatory core if changed */
367 regulatory_set_wiphy_regd(mvm
->hw
->wiphy
, regd
);
373 struct ieee80211_regdomain
*iwl_mvm_get_current_regdomain(struct iwl_mvm
*mvm
,
376 return iwl_mvm_get_regdomain(mvm
->hw
->wiphy
, "ZZ",
377 iwl_mvm_is_wifi_mcc_supported(mvm
) ?
378 MCC_SOURCE_GET_CURRENT
:
379 MCC_SOURCE_OLD_FW
, changed
);
382 int iwl_mvm_init_fw_regd(struct iwl_mvm
*mvm
)
384 enum iwl_mcc_source used_src
;
385 struct ieee80211_regdomain
*regd
;
388 const struct ieee80211_regdomain
*r
=
389 rtnl_dereference(mvm
->hw
->wiphy
->regd
);
394 /* save the last source in case we overwrite it below */
395 used_src
= mvm
->mcc_src
;
396 if (iwl_mvm_is_wifi_mcc_supported(mvm
)) {
397 /* Notify the firmware we support wifi location updates */
398 regd
= iwl_mvm_get_current_regdomain(mvm
, NULL
);
399 if (!IS_ERR_OR_NULL(regd
))
403 /* Now set our last stored MCC and source */
404 regd
= iwl_mvm_get_regdomain(mvm
->hw
->wiphy
, r
->alpha2
, used_src
,
406 if (IS_ERR_OR_NULL(regd
))
409 /* update cfg80211 if the regdomain was changed */
411 ret
= regulatory_set_wiphy_regd_sync_rtnl(mvm
->hw
->wiphy
, regd
);
419 int iwl_mvm_mac_setup_register(struct iwl_mvm
*mvm
)
421 struct ieee80211_hw
*hw
= mvm
->hw
;
423 static const u32 mvm_ciphers
[] = {
424 WLAN_CIPHER_SUITE_WEP40
,
425 WLAN_CIPHER_SUITE_WEP104
,
426 WLAN_CIPHER_SUITE_TKIP
,
427 WLAN_CIPHER_SUITE_CCMP
,
430 /* Tell mac80211 our characteristics */
431 ieee80211_hw_set(hw
, SIGNAL_DBM
);
432 ieee80211_hw_set(hw
, SPECTRUM_MGMT
);
433 ieee80211_hw_set(hw
, REPORTS_TX_ACK_STATUS
);
434 ieee80211_hw_set(hw
, QUEUE_CONTROL
);
435 ieee80211_hw_set(hw
, WANT_MONITOR_VIF
);
436 ieee80211_hw_set(hw
, SUPPORTS_PS
);
437 ieee80211_hw_set(hw
, SUPPORTS_DYNAMIC_PS
);
438 ieee80211_hw_set(hw
, AMPDU_AGGREGATION
);
439 ieee80211_hw_set(hw
, TIMING_BEACON_ONLY
);
440 ieee80211_hw_set(hw
, CONNECTION_MONITOR
);
441 ieee80211_hw_set(hw
, CHANCTX_STA_CSA
);
442 ieee80211_hw_set(hw
, SUPPORT_FAST_XMIT
);
443 ieee80211_hw_set(hw
, SUPPORTS_CLONED_SKBS
);
444 ieee80211_hw_set(hw
, SUPPORTS_AMSDU_IN_AMPDU
);
445 ieee80211_hw_set(hw
, NEEDS_UNIQUE_STA_ADDR
);
446 if (iwl_mvm_has_new_rx_api(mvm
))
447 ieee80211_hw_set(hw
, SUPPORTS_REORDERING_BUFFER
);
449 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
450 IWL_UCODE_TLV_CAPA_STA_PM_NOTIF
)) {
451 ieee80211_hw_set(hw
, AP_LINK_PS
);
452 } else if (WARN_ON(iwl_mvm_has_new_tx_api(mvm
))) {
454 * we absolutely need this for the new TX API since that comes
455 * with many more queues than the current code can deal with
456 * for station powersave
461 if (mvm
->trans
->num_rx_queues
> 1)
462 ieee80211_hw_set(hw
, USES_RSS
);
464 if (mvm
->trans
->max_skb_frags
)
465 hw
->netdev_features
= NETIF_F_HIGHDMA
| NETIF_F_SG
;
467 hw
->queues
= IEEE80211_MAX_QUEUES
;
468 hw
->offchannel_tx_hw_queue
= IWL_MVM_OFFCHANNEL_QUEUE
;
469 hw
->radiotap_mcs_details
|= IEEE80211_RADIOTAP_MCS_HAVE_FEC
|
470 IEEE80211_RADIOTAP_MCS_HAVE_STBC
;
471 hw
->radiotap_vht_details
|= IEEE80211_RADIOTAP_VHT_KNOWN_STBC
|
472 IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED
;
474 hw
->radiotap_timestamp
.units_pos
=
475 IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US
|
476 IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ
;
477 /* this is the case for CCK frames, it's better (only 8) for OFDM */
478 hw
->radiotap_timestamp
.accuracy
= 22;
480 hw
->rate_control_algorithm
= "iwl-mvm-rs";
481 hw
->uapsd_queues
= IWL_MVM_UAPSD_QUEUES
;
482 hw
->uapsd_max_sp_len
= IWL_UAPSD_MAX_SP
;
484 BUILD_BUG_ON(ARRAY_SIZE(mvm
->ciphers
) < ARRAY_SIZE(mvm_ciphers
) + 6);
485 memcpy(mvm
->ciphers
, mvm_ciphers
, sizeof(mvm_ciphers
));
486 hw
->wiphy
->n_cipher_suites
= ARRAY_SIZE(mvm_ciphers
);
487 hw
->wiphy
->cipher_suites
= mvm
->ciphers
;
489 if (iwl_mvm_has_new_rx_api(mvm
)) {
490 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
491 WLAN_CIPHER_SUITE_GCMP
;
492 hw
->wiphy
->n_cipher_suites
++;
493 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
494 WLAN_CIPHER_SUITE_GCMP_256
;
495 hw
->wiphy
->n_cipher_suites
++;
498 /* Enable 11w if software crypto is not enabled (as the
499 * firmware will interpret some mgmt packets, so enabling it
500 * with software crypto isn't safe).
502 if (!iwlwifi_mod_params
.swcrypto
) {
503 ieee80211_hw_set(hw
, MFP_CAPABLE
);
504 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
505 WLAN_CIPHER_SUITE_AES_CMAC
;
506 hw
->wiphy
->n_cipher_suites
++;
507 if (iwl_mvm_has_new_rx_api(mvm
)) {
508 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
509 WLAN_CIPHER_SUITE_BIP_GMAC_128
;
510 hw
->wiphy
->n_cipher_suites
++;
511 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
512 WLAN_CIPHER_SUITE_BIP_GMAC_256
;
513 hw
->wiphy
->n_cipher_suites
++;
517 /* currently FW API supports only one optional cipher scheme */
518 if (mvm
->fw
->cs
[0].cipher
) {
519 const struct iwl_fw_cipher_scheme
*fwcs
= &mvm
->fw
->cs
[0];
520 struct ieee80211_cipher_scheme
*cs
= &mvm
->cs
[0];
522 mvm
->hw
->n_cipher_schemes
= 1;
524 cs
->cipher
= le32_to_cpu(fwcs
->cipher
);
525 cs
->iftype
= BIT(NL80211_IFTYPE_STATION
);
526 cs
->hdr_len
= fwcs
->hdr_len
;
527 cs
->pn_len
= fwcs
->pn_len
;
528 cs
->pn_off
= fwcs
->pn_off
;
529 cs
->key_idx_off
= fwcs
->key_idx_off
;
530 cs
->key_idx_mask
= fwcs
->key_idx_mask
;
531 cs
->key_idx_shift
= fwcs
->key_idx_shift
;
532 cs
->mic_len
= fwcs
->mic_len
;
534 mvm
->hw
->cipher_schemes
= mvm
->cs
;
535 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] = cs
->cipher
;
536 hw
->wiphy
->n_cipher_suites
++;
539 ieee80211_hw_set(hw
, SINGLE_SCAN_ON_ALL_BANDS
);
540 hw
->wiphy
->features
|=
541 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
|
542 NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR
|
543 NL80211_FEATURE_ND_RANDOM_MAC_ADDR
;
545 hw
->sta_data_size
= sizeof(struct iwl_mvm_sta
);
546 hw
->vif_data_size
= sizeof(struct iwl_mvm_vif
);
547 hw
->chanctx_data_size
= sizeof(u16
);
549 hw
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
550 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
551 BIT(NL80211_IFTYPE_AP
) |
552 BIT(NL80211_IFTYPE_P2P_GO
) |
553 BIT(NL80211_IFTYPE_P2P_DEVICE
) |
554 BIT(NL80211_IFTYPE_ADHOC
);
556 hw
->wiphy
->flags
|= WIPHY_FLAG_IBSS_RSN
;
557 hw
->wiphy
->regulatory_flags
|= REGULATORY_ENABLE_RELAX_NO_IR
;
558 if (iwl_mvm_is_lar_supported(mvm
))
559 hw
->wiphy
->regulatory_flags
|= REGULATORY_WIPHY_SELF_MANAGED
;
561 hw
->wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
562 REGULATORY_DISABLE_BEACON_HINTS
;
564 hw
->wiphy
->flags
|= WIPHY_FLAG_AP_UAPSD
;
565 hw
->wiphy
->flags
|= WIPHY_FLAG_HAS_CHANNEL_SWITCH
;
567 hw
->wiphy
->iface_combinations
= iwl_mvm_iface_combinations
;
568 hw
->wiphy
->n_iface_combinations
=
569 ARRAY_SIZE(iwl_mvm_iface_combinations
);
571 hw
->wiphy
->max_remain_on_channel_duration
= 10000;
572 hw
->max_listen_interval
= IWL_CONN_MAX_LISTEN_INTERVAL
;
573 /* we can compensate an offset of up to 3 channels = 15 MHz */
574 hw
->wiphy
->max_adj_channel_rssi_comp
= 3 * 5;
576 /* Extract MAC address */
577 memcpy(mvm
->addresses
[0].addr
, mvm
->nvm_data
->hw_addr
, ETH_ALEN
);
578 hw
->wiphy
->addresses
= mvm
->addresses
;
579 hw
->wiphy
->n_addresses
= 1;
581 /* Extract additional MAC addresses if available */
582 num_mac
= (mvm
->nvm_data
->n_hw_addrs
> 1) ?
583 min(IWL_MVM_MAX_ADDRESSES
, mvm
->nvm_data
->n_hw_addrs
) : 1;
585 for (i
= 1; i
< num_mac
; i
++) {
586 memcpy(mvm
->addresses
[i
].addr
, mvm
->addresses
[i
-1].addr
,
588 mvm
->addresses
[i
].addr
[5]++;
589 hw
->wiphy
->n_addresses
++;
592 iwl_mvm_reset_phy_ctxts(mvm
);
594 hw
->wiphy
->max_scan_ie_len
= iwl_mvm_max_scan_ie_len(mvm
);
596 hw
->wiphy
->max_scan_ssids
= PROBE_OPTION_MAX
;
598 BUILD_BUG_ON(IWL_MVM_SCAN_STOPPING_MASK
& IWL_MVM_SCAN_MASK
);
599 BUILD_BUG_ON(IWL_MVM_MAX_UMAC_SCANS
> HWEIGHT32(IWL_MVM_SCAN_MASK
) ||
600 IWL_MVM_MAX_LMAC_SCANS
> HWEIGHT32(IWL_MVM_SCAN_MASK
));
602 if (fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_UMAC_SCAN
))
603 mvm
->max_scans
= IWL_MVM_MAX_UMAC_SCANS
;
605 mvm
->max_scans
= IWL_MVM_MAX_LMAC_SCANS
;
607 if (mvm
->nvm_data
->bands
[NL80211_BAND_2GHZ
].n_channels
)
608 hw
->wiphy
->bands
[NL80211_BAND_2GHZ
] =
609 &mvm
->nvm_data
->bands
[NL80211_BAND_2GHZ
];
610 if (mvm
->nvm_data
->bands
[NL80211_BAND_5GHZ
].n_channels
) {
611 hw
->wiphy
->bands
[NL80211_BAND_5GHZ
] =
612 &mvm
->nvm_data
->bands
[NL80211_BAND_5GHZ
];
614 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
615 IWL_UCODE_TLV_CAPA_BEAMFORMER
) &&
616 fw_has_api(&mvm
->fw
->ucode_capa
,
617 IWL_UCODE_TLV_API_LQ_SS_PARAMS
))
618 hw
->wiphy
->bands
[NL80211_BAND_5GHZ
]->vht_cap
.cap
|=
619 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE
;
622 hw
->wiphy
->hw_version
= mvm
->trans
->hw_id
;
624 if (iwlmvm_mod_params
.power_scheme
!= IWL_POWER_SCHEME_CAM
)
625 hw
->wiphy
->flags
|= WIPHY_FLAG_PS_ON_BY_DEFAULT
;
627 hw
->wiphy
->flags
&= ~WIPHY_FLAG_PS_ON_BY_DEFAULT
;
629 hw
->wiphy
->max_sched_scan_reqs
= 1;
630 hw
->wiphy
->max_sched_scan_ssids
= PROBE_OPTION_MAX
;
631 hw
->wiphy
->max_match_sets
= IWL_SCAN_MAX_PROFILES
;
632 /* we create the 802.11 header and zero length SSID IE. */
633 hw
->wiphy
->max_sched_scan_ie_len
=
634 SCAN_OFFLOAD_PROBE_REQ_SIZE
- 24 - 2;
635 hw
->wiphy
->max_sched_scan_plans
= IWL_MAX_SCHED_SCAN_PLANS
;
636 hw
->wiphy
->max_sched_scan_plan_interval
= U16_MAX
;
639 * the firmware uses u8 for num of iterations, but 0xff is saved for
640 * infinite loop, so the maximum number of iterations is actually 254.
642 hw
->wiphy
->max_sched_scan_plan_iterations
= 254;
644 hw
->wiphy
->features
|= NL80211_FEATURE_P2P_GO_CTWIN
|
645 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
646 NL80211_FEATURE_P2P_GO_OPPPS
|
647 NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE
|
648 NL80211_FEATURE_DYNAMIC_SMPS
|
649 NL80211_FEATURE_STATIC_SMPS
|
650 NL80211_FEATURE_SUPPORTS_WMM_ADMISSION
;
652 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
653 IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT
))
654 hw
->wiphy
->features
|= NL80211_FEATURE_TX_POWER_INSERTION
;
655 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
656 IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT
))
657 hw
->wiphy
->features
|= NL80211_FEATURE_QUIET
;
659 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
660 IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT
))
661 hw
->wiphy
->features
|=
662 NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES
;
664 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
665 IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT
))
666 hw
->wiphy
->features
|= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES
;
668 if (fw_has_api(&mvm
->fw
->ucode_capa
,
669 IWL_UCODE_TLV_API_SCAN_TSF_REPORT
)) {
670 wiphy_ext_feature_set(hw
->wiphy
,
671 NL80211_EXT_FEATURE_SCAN_START_TIME
);
672 wiphy_ext_feature_set(hw
->wiphy
,
673 NL80211_EXT_FEATURE_BSS_PARENT_TSF
);
674 wiphy_ext_feature_set(hw
->wiphy
,
675 NL80211_EXT_FEATURE_SET_SCAN_DWELL
);
678 mvm
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
680 #ifdef CONFIG_PM_SLEEP
681 if (iwl_mvm_is_d0i3_supported(mvm
) &&
682 device_can_wakeup(mvm
->trans
->dev
)) {
683 mvm
->wowlan
.flags
= WIPHY_WOWLAN_ANY
;
684 hw
->wiphy
->wowlan
= &mvm
->wowlan
;
687 if (mvm
->fw
->img
[IWL_UCODE_WOWLAN
].num_sec
&&
688 mvm
->trans
->ops
->d3_suspend
&&
689 mvm
->trans
->ops
->d3_resume
&&
690 device_can_wakeup(mvm
->trans
->dev
)) {
691 mvm
->wowlan
.flags
|= WIPHY_WOWLAN_MAGIC_PKT
|
692 WIPHY_WOWLAN_DISCONNECT
|
693 WIPHY_WOWLAN_EAP_IDENTITY_REQ
|
694 WIPHY_WOWLAN_RFKILL_RELEASE
|
695 WIPHY_WOWLAN_NET_DETECT
;
696 if (!iwlwifi_mod_params
.swcrypto
)
697 mvm
->wowlan
.flags
|= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
698 WIPHY_WOWLAN_GTK_REKEY_FAILURE
|
699 WIPHY_WOWLAN_4WAY_HANDSHAKE
;
701 mvm
->wowlan
.n_patterns
= IWL_WOWLAN_MAX_PATTERNS
;
702 mvm
->wowlan
.pattern_min_len
= IWL_WOWLAN_MIN_PATTERN_LEN
;
703 mvm
->wowlan
.pattern_max_len
= IWL_WOWLAN_MAX_PATTERN_LEN
;
704 mvm
->wowlan
.max_nd_match_sets
= IWL_SCAN_MAX_PROFILES
;
705 mvm
->wowlan
.tcp
= &iwl_mvm_wowlan_tcp_support
;
706 hw
->wiphy
->wowlan
= &mvm
->wowlan
;
710 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
711 /* assign default bcast filtering configuration */
712 mvm
->bcast_filters
= iwl_mvm_default_bcast_filters
;
715 ret
= iwl_mvm_leds_init(mvm
);
719 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
720 IWL_UCODE_TLV_CAPA_TDLS_SUPPORT
)) {
721 IWL_DEBUG_TDLS(mvm
, "TDLS supported\n");
722 hw
->wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
;
723 ieee80211_hw_set(hw
, TDLS_WIDER_BW
);
726 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
727 IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH
)) {
728 IWL_DEBUG_TDLS(mvm
, "TDLS channel switch supported\n");
729 hw
->wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
732 hw
->netdev_features
|= mvm
->cfg
->features
;
733 if (!iwl_mvm_is_csum_supported(mvm
)) {
734 hw
->netdev_features
&= ~(IWL_TX_CSUM_NETIF_FLAGS
|
736 /* We may support SW TX CSUM */
737 if (IWL_MVM_SW_TX_CSUM_OFFLOAD
)
738 hw
->netdev_features
|= IWL_TX_CSUM_NETIF_FLAGS
;
741 ret
= ieee80211_register_hw(mvm
->hw
);
743 iwl_mvm_leds_exit(mvm
);
744 mvm
->init_status
|= IWL_MVM_INIT_STATUS_REG_HW_INIT_COMPLETE
;
746 if (mvm
->cfg
->vht_mu_mimo_supported
)
747 wiphy_ext_feature_set(hw
->wiphy
,
748 NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER
);
753 static bool iwl_mvm_defer_tx(struct iwl_mvm
*mvm
,
754 struct ieee80211_sta
*sta
,
757 struct iwl_mvm_sta
*mvmsta
;
761 * double check the IN_D0I3 flag both before and after
762 * taking the spinlock, in order to prevent taking
763 * the spinlock when not needed.
765 if (likely(!test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
)))
768 spin_lock(&mvm
->d0i3_tx_lock
);
770 * testing the flag again ensures the skb dequeue
771 * loop (on d0i3 exit) hasn't run yet.
773 if (!test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
))
776 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
777 if (mvmsta
->sta_id
== IWL_MVM_INVALID_STA
||
778 mvmsta
->sta_id
!= mvm
->d0i3_ap_sta_id
)
781 __skb_queue_tail(&mvm
->d0i3_tx
, skb
);
782 ieee80211_stop_queues(mvm
->hw
);
785 iwl_mvm_ref(mvm
, IWL_MVM_REF_TX
);
786 iwl_mvm_unref(mvm
, IWL_MVM_REF_TX
);
790 spin_unlock(&mvm
->d0i3_tx_lock
);
794 static void iwl_mvm_mac_tx(struct ieee80211_hw
*hw
,
795 struct ieee80211_tx_control
*control
,
798 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
799 struct ieee80211_sta
*sta
= control
->sta
;
800 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
801 struct ieee80211_hdr
*hdr
= (void *)skb
->data
;
803 if (iwl_mvm_is_radio_killed(mvm
)) {
804 IWL_DEBUG_DROP(mvm
, "Dropping - RF/CT KILL\n");
808 if (info
->hw_queue
== IWL_MVM_OFFCHANNEL_QUEUE
&&
809 !test_bit(IWL_MVM_STATUS_ROC_RUNNING
, &mvm
->status
) &&
810 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING
, &mvm
->status
))
813 /* treat non-bufferable MMPDUs on AP interfaces as broadcast */
814 if ((info
->control
.vif
->type
== NL80211_IFTYPE_AP
||
815 info
->control
.vif
->type
== NL80211_IFTYPE_ADHOC
) &&
816 ieee80211_is_mgmt(hdr
->frame_control
) &&
817 !ieee80211_is_bufferable_mmpdu(hdr
->frame_control
))
821 if (iwl_mvm_defer_tx(mvm
, sta
, skb
))
823 if (iwl_mvm_tx_skb(mvm
, skb
, sta
))
828 if (iwl_mvm_tx_skb_non_sta(mvm
, skb
))
832 ieee80211_free_txskb(hw
, skb
);
835 static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg
*cfg
)
837 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_RXAGG
)
842 static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg
*cfg
)
844 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_TXAGG
)
846 if (iwlwifi_mod_params
.disable_11n
& IWL_ENABLE_HT_TXAGG
)
849 /* enabled by default */
853 #define CHECK_BA_TRIGGER(_mvm, _trig, _tid_bm, _tid, _fmt...) \
855 if (!(le16_to_cpu(_tid_bm) & BIT(_tid))) \
857 iwl_fw_dbg_collect_trig(&(_mvm)->fwrt, _trig, _fmt); \
861 iwl_mvm_ampdu_check_trigger(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
862 struct ieee80211_sta
*sta
, u16 tid
, u16 rx_ba_ssn
,
863 enum ieee80211_ampdu_mlme_action action
)
865 struct iwl_fw_dbg_trigger_tlv
*trig
;
866 struct iwl_fw_dbg_trigger_ba
*ba_trig
;
868 if (!iwl_fw_dbg_trigger_enabled(mvm
->fw
, FW_DBG_TRIGGER_BA
))
871 trig
= iwl_fw_dbg_get_trigger(mvm
->fw
, FW_DBG_TRIGGER_BA
);
872 ba_trig
= (void *)trig
->data
;
874 if (!iwl_fw_dbg_trigger_check_stop(&mvm
->fwrt
,
875 ieee80211_vif_to_wdev(vif
), trig
))
879 case IEEE80211_AMPDU_TX_OPERATIONAL
: {
880 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
881 struct iwl_mvm_tid_data
*tid_data
= &mvmsta
->tid_data
[tid
];
883 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->tx_ba_start
, tid
,
884 "TX AGG START: MAC %pM tid %d ssn %d\n",
885 sta
->addr
, tid
, tid_data
->ssn
);
888 case IEEE80211_AMPDU_TX_STOP_CONT
:
889 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->tx_ba_stop
, tid
,
890 "TX AGG STOP: MAC %pM tid %d\n",
893 case IEEE80211_AMPDU_RX_START
:
894 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->rx_ba_start
, tid
,
895 "RX AGG START: MAC %pM tid %d ssn %d\n",
896 sta
->addr
, tid
, rx_ba_ssn
);
898 case IEEE80211_AMPDU_RX_STOP
:
899 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->rx_ba_stop
, tid
,
900 "RX AGG STOP: MAC %pM tid %d\n",
908 static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw
*hw
,
909 struct ieee80211_vif
*vif
,
910 struct ieee80211_ampdu_params
*params
)
912 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
914 bool tx_agg_ref
= false;
915 struct ieee80211_sta
*sta
= params
->sta
;
916 enum ieee80211_ampdu_mlme_action action
= params
->action
;
917 u16 tid
= params
->tid
;
918 u16
*ssn
= ¶ms
->ssn
;
919 u8 buf_size
= params
->buf_size
;
920 bool amsdu
= params
->amsdu
;
921 u16 timeout
= params
->timeout
;
923 IWL_DEBUG_HT(mvm
, "A-MPDU action on addr %pM tid %d: action %d\n",
924 sta
->addr
, tid
, action
);
926 if (!(mvm
->nvm_data
->sku_cap_11n_enable
))
929 /* return from D0i3 before starting a new Tx aggregation */
931 case IEEE80211_AMPDU_TX_START
:
932 case IEEE80211_AMPDU_TX_STOP_CONT
:
933 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
934 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
935 case IEEE80211_AMPDU_TX_OPERATIONAL
:
937 * for tx start, wait synchronously until D0i3 exit to
938 * get the correct sequence number for the tid.
939 * additionally, some other ampdu actions use direct
940 * target access, which is not handled automatically
941 * by the trans layer (unlike commands), so wait for
942 * d0i3 exit in these cases as well.
944 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_TX_AGG
);
954 mutex_lock(&mvm
->mutex
);
957 case IEEE80211_AMPDU_RX_START
:
958 if (!iwl_enable_rx_ampdu(mvm
->cfg
)) {
962 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, *ssn
, true, buf_size
,
965 case IEEE80211_AMPDU_RX_STOP
:
966 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, 0, false, buf_size
,
969 case IEEE80211_AMPDU_TX_START
:
970 if (!iwl_enable_tx_ampdu(mvm
->cfg
)) {
974 ret
= iwl_mvm_sta_tx_agg_start(mvm
, vif
, sta
, tid
, ssn
);
976 case IEEE80211_AMPDU_TX_STOP_CONT
:
977 ret
= iwl_mvm_sta_tx_agg_stop(mvm
, vif
, sta
, tid
);
979 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
980 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
981 ret
= iwl_mvm_sta_tx_agg_flush(mvm
, vif
, sta
, tid
);
983 case IEEE80211_AMPDU_TX_OPERATIONAL
:
984 ret
= iwl_mvm_sta_tx_agg_oper(mvm
, vif
, sta
, tid
,
996 if (action
== IEEE80211_AMPDU_RX_START
)
999 iwl_mvm_ampdu_check_trigger(mvm
, vif
, sta
, tid
,
1002 mutex_unlock(&mvm
->mutex
);
1005 * If the tid is marked as started, we won't use it for offloaded
1006 * traffic on the next D0i3 entry. It's safe to unref.
1009 iwl_mvm_unref(mvm
, IWL_MVM_REF_TX_AGG
);
1014 static void iwl_mvm_cleanup_iterator(void *data
, u8
*mac
,
1015 struct ieee80211_vif
*vif
)
1017 struct iwl_mvm
*mvm
= data
;
1018 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1020 mvmvif
->uploaded
= false;
1021 mvmvif
->ap_sta_id
= IWL_MVM_INVALID_STA
;
1023 spin_lock_bh(&mvm
->time_event_lock
);
1024 iwl_mvm_te_clear_data(mvm
, &mvmvif
->time_event_data
);
1025 spin_unlock_bh(&mvm
->time_event_lock
);
1027 mvmvif
->phy_ctxt
= NULL
;
1028 memset(&mvmvif
->bf_data
, 0, sizeof(mvmvif
->bf_data
));
1031 static void iwl_mvm_restart_cleanup(struct iwl_mvm
*mvm
)
1033 /* clear the D3 reconfig, we only need it to avoid dumping a
1034 * firmware coredump on reconfiguration, we shouldn't do that
1035 * on D3->D0 transition
1037 if (!test_and_clear_bit(IWL_MVM_STATUS_D3_RECONFIG
, &mvm
->status
)) {
1038 mvm
->fwrt
.dump
.desc
= &iwl_dump_desc_assert
;
1039 iwl_fw_error_dump(&mvm
->fwrt
);
1042 /* cleanup all stale references (scan, roc), but keep the
1043 * ucode_down ref until reconfig is complete
1045 iwl_mvm_unref_all_except(mvm
, IWL_MVM_REF_UCODE_DOWN
);
1047 iwl_mvm_stop_device(mvm
);
1049 mvm
->scan_status
= 0;
1050 mvm
->ps_disabled
= false;
1051 mvm
->calibrating
= false;
1053 /* just in case one was running */
1054 iwl_mvm_cleanup_roc_te(mvm
);
1055 ieee80211_remain_on_channel_expired(mvm
->hw
);
1058 * cleanup all interfaces, even inactive ones, as some might have
1059 * gone down during the HW restart
1061 ieee80211_iterate_interfaces(mvm
->hw
, 0, iwl_mvm_cleanup_iterator
, mvm
);
1063 mvm
->p2p_device_vif
= NULL
;
1064 mvm
->d0i3_ap_sta_id
= IWL_MVM_INVALID_STA
;
1066 iwl_mvm_reset_phy_ctxts(mvm
);
1067 memset(mvm
->fw_key_table
, 0, sizeof(mvm
->fw_key_table
));
1068 memset(mvm
->sta_deferred_frames
, 0, sizeof(mvm
->sta_deferred_frames
));
1069 memset(&mvm
->last_bt_notif
, 0, sizeof(mvm
->last_bt_notif
));
1070 memset(&mvm
->last_bt_ci_cmd
, 0, sizeof(mvm
->last_bt_ci_cmd
));
1072 ieee80211_wake_queues(mvm
->hw
);
1074 /* clear any stale d0i3 state */
1075 clear_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
);
1078 mvm
->rx_ba_sessions
= 0;
1079 mvm
->fwrt
.dump
.conf
= FW_DBG_INVALID
;
1080 mvm
->monitor_on
= false;
1082 /* keep statistics ticking */
1083 iwl_mvm_accu_radio_stats(mvm
);
1086 int __iwl_mvm_mac_start(struct iwl_mvm
*mvm
)
1090 lockdep_assert_held(&mvm
->mutex
);
1092 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
, &mvm
->status
)) {
1094 * Now convert the HW_RESTART_REQUESTED flag to IN_HW_RESTART
1095 * so later code will - from now on - see that we're doing it.
1097 set_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
1098 clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
, &mvm
->status
);
1099 /* Clean up some internal and mac80211 state on restart */
1100 iwl_mvm_restart_cleanup(mvm
);
1102 /* Hold the reference to prevent runtime suspend while
1103 * the start procedure runs. It's a bit confusing
1104 * that the UCODE_DOWN reference is taken, but it just
1105 * means "UCODE is not UP yet". ( TODO: rename this
1108 iwl_mvm_ref(mvm
, IWL_MVM_REF_UCODE_DOWN
);
1110 ret
= iwl_mvm_up(mvm
);
1112 if (ret
&& test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)) {
1113 /* Something went wrong - we need to finish some cleanup
1114 * that normally iwl_mvm_mac_restart_complete() below
1117 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
1118 iwl_mvm_d0i3_enable_tx(mvm
, NULL
);
1124 static int iwl_mvm_mac_start(struct ieee80211_hw
*hw
)
1126 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1129 /* Some hw restart cleanups must not hold the mutex */
1130 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)) {
1132 * Make sure we are out of d0i3. This is needed
1133 * to make sure the reference accounting is correct
1134 * (and there is no stale d0i3_exit_work).
1136 wait_event_timeout(mvm
->d0i3_exit_waitq
,
1137 !test_bit(IWL_MVM_STATUS_IN_D0I3
,
1142 mutex_lock(&mvm
->mutex
);
1143 ret
= __iwl_mvm_mac_start(mvm
);
1144 mutex_unlock(&mvm
->mutex
);
1149 static void iwl_mvm_restart_complete(struct iwl_mvm
*mvm
)
1153 mutex_lock(&mvm
->mutex
);
1155 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
1156 iwl_mvm_d0i3_enable_tx(mvm
, NULL
);
1157 ret
= iwl_mvm_update_quotas(mvm
, true, NULL
);
1159 IWL_ERR(mvm
, "Failed to update quotas after restart (%d)\n",
1162 /* allow transport/FW low power modes */
1163 iwl_mvm_unref(mvm
, IWL_MVM_REF_UCODE_DOWN
);
1166 * If we have TDLS peers, remove them. We don't know the last seqno/PN
1167 * of packets the FW sent out, so we must reconnect.
1169 iwl_mvm_teardown_tdls_peers(mvm
);
1171 mutex_unlock(&mvm
->mutex
);
1174 static void iwl_mvm_resume_complete(struct iwl_mvm
*mvm
)
1176 if (iwl_mvm_is_d0i3_supported(mvm
) &&
1177 iwl_mvm_enter_d0i3_on_suspend(mvm
))
1178 WARN_ONCE(!wait_event_timeout(mvm
->d0i3_exit_waitq
,
1179 !test_bit(IWL_MVM_STATUS_IN_D0I3
,
1182 "D0i3 exit on resume timed out\n");
1186 iwl_mvm_mac_reconfig_complete(struct ieee80211_hw
*hw
,
1187 enum ieee80211_reconfig_type reconfig_type
)
1189 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1191 switch (reconfig_type
) {
1192 case IEEE80211_RECONFIG_TYPE_RESTART
:
1193 iwl_mvm_restart_complete(mvm
);
1195 case IEEE80211_RECONFIG_TYPE_SUSPEND
:
1196 iwl_mvm_resume_complete(mvm
);
1201 void __iwl_mvm_mac_stop(struct iwl_mvm
*mvm
)
1203 lockdep_assert_held(&mvm
->mutex
);
1205 /* firmware counters are obviously reset now, but we shouldn't
1206 * partially track so also clear the fw_reset_accu counters.
1208 memset(&mvm
->accu_radio_stats
, 0, sizeof(mvm
->accu_radio_stats
));
1210 /* async_handlers_wk is now blocked */
1213 * The work item could be running or queued if the
1214 * ROC time event stops just as we get here.
1216 flush_work(&mvm
->roc_done_wk
);
1218 iwl_mvm_stop_device(mvm
);
1220 iwl_mvm_async_handlers_purge(mvm
);
1221 /* async_handlers_list is empty and will stay empty: HW is stopped */
1223 /* the fw is stopped, the aux sta is dead: clean up driver state */
1224 iwl_mvm_del_aux_sta(mvm
);
1227 * Clear IN_HW_RESTART flag when stopping the hw (as restart_complete()
1228 * won't be called in this case).
1229 * But make sure to cleanup interfaces that have gone down before/during
1230 * HW restart was requested.
1232 if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
1233 ieee80211_iterate_interfaces(mvm
->hw
, 0,
1234 iwl_mvm_cleanup_iterator
, mvm
);
1236 /* We shouldn't have any UIDs still set. Loop over all the UIDs to
1237 * make sure there's nothing left there and warn if any is found.
1239 if (fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_UMAC_SCAN
)) {
1242 for (i
= 0; i
< mvm
->max_scans
; i
++) {
1243 if (WARN_ONCE(mvm
->scan_uid_status
[i
],
1244 "UMAC scan UID %d status was not cleaned\n",
1246 mvm
->scan_uid_status
[i
] = 0;
1251 static void iwl_mvm_mac_stop(struct ieee80211_hw
*hw
)
1253 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1255 flush_work(&mvm
->d0i3_exit_work
);
1256 flush_work(&mvm
->async_handlers_wk
);
1257 flush_work(&mvm
->add_stream_wk
);
1260 * Lock and clear the firmware running bit here already, so that
1261 * new commands coming in elsewhere, e.g. from debugfs, will not
1262 * be able to proceed. This is important here because one of those
1263 * debugfs files causes the firmware dump to be triggered, and if we
1264 * don't stop debugfs accesses before canceling that it could be
1265 * retriggered after we flush it but before we've cleared the bit.
1267 clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING
, &mvm
->status
);
1269 iwl_fw_cancel_dump(&mvm
->fwrt
);
1270 cancel_delayed_work_sync(&mvm
->cs_tx_unblock_dwork
);
1271 cancel_delayed_work_sync(&mvm
->scan_timeout_dwork
);
1272 iwl_fw_free_dump_desc(&mvm
->fwrt
);
1274 mutex_lock(&mvm
->mutex
);
1275 __iwl_mvm_mac_stop(mvm
);
1276 mutex_unlock(&mvm
->mutex
);
1279 * The worker might have been waiting for the mutex, let it run and
1280 * discover that its list is now empty.
1282 cancel_work_sync(&mvm
->async_handlers_wk
);
1285 static struct iwl_mvm_phy_ctxt
*iwl_mvm_get_free_phy_ctxt(struct iwl_mvm
*mvm
)
1289 lockdep_assert_held(&mvm
->mutex
);
1291 for (i
= 0; i
< NUM_PHY_CTX
; i
++)
1292 if (!mvm
->phy_ctxts
[i
].ref
)
1293 return &mvm
->phy_ctxts
[i
];
1295 IWL_ERR(mvm
, "No available PHY context\n");
1299 static int iwl_mvm_set_tx_power(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
1302 struct iwl_dev_tx_power_cmd cmd
= {
1303 .v3
.set_mode
= cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC
),
1304 .v3
.mac_context_id
=
1305 cpu_to_le32(iwl_mvm_vif_from_mac80211(vif
)->id
),
1306 .v3
.pwr_restriction
= cpu_to_le16(8 * tx_power
),
1308 int len
= sizeof(cmd
);
1310 if (tx_power
== IWL_DEFAULT_MAX_TX_POWER
)
1311 cmd
.v3
.pwr_restriction
= cpu_to_le16(IWL_DEV_MAX_TX_POWER
);
1313 if (!fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_TX_POWER_ACK
))
1314 len
= sizeof(cmd
.v3
);
1316 return iwl_mvm_send_cmd_pdu(mvm
, REDUCE_TX_POWER_CMD
, 0, len
, &cmd
);
1319 static int iwl_mvm_mac_add_interface(struct ieee80211_hw
*hw
,
1320 struct ieee80211_vif
*vif
)
1322 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1323 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1329 * make sure D0i3 exit is completed, otherwise a target access
1330 * during tx queue configuration could be done when still in
1333 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_ADD_IF
);
1338 * Not much to do here. The stack will not allow interface
1339 * types or combinations that we didn't advertise, so we
1340 * don't really have to check the types.
1343 mutex_lock(&mvm
->mutex
);
1345 /* make sure that beacon statistics don't go backwards with FW reset */
1346 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
1347 mvmvif
->beacon_stats
.accu_num_beacons
+=
1348 mvmvif
->beacon_stats
.num_beacons
;
1350 /* Allocate resources for the MAC context, and add it to the fw */
1351 ret
= iwl_mvm_mac_ctxt_init(mvm
, vif
);
1355 /* Counting number of interfaces is needed for legacy PM */
1356 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
1360 * The AP binding flow can be done only after the beacon
1361 * template is configured (which happens only in the mac80211
1362 * start_ap() flow), and adding the broadcast station can happen
1363 * only after the binding.
1364 * In addition, since modifying the MAC before adding a bcast
1365 * station is not allowed by the FW, delay the adding of MAC context to
1366 * the point where we can also add the bcast station.
1367 * In short: there's not much we can do at this point, other than
1368 * allocating resources :)
1370 if (vif
->type
== NL80211_IFTYPE_AP
||
1371 vif
->type
== NL80211_IFTYPE_ADHOC
) {
1372 ret
= iwl_mvm_alloc_bcast_sta(mvm
, vif
);
1374 IWL_ERR(mvm
, "Failed to allocate bcast sta\n");
1379 * Only queue for this station is the mcast queue,
1380 * which shouldn't be in TFD mask anyway
1382 ret
= iwl_mvm_allocate_int_sta(mvm
, &mvmvif
->mcast_sta
,
1388 iwl_mvm_vif_dbgfs_register(mvm
, vif
);
1392 mvmvif
->features
|= hw
->netdev_features
;
1394 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
1398 ret
= iwl_mvm_power_update_mac(mvm
);
1400 goto out_remove_mac
;
1402 /* beacon filtering */
1403 ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
, 0);
1405 goto out_remove_mac
;
1407 if (!mvm
->bf_allowed_vif
&&
1408 vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
) {
1409 mvm
->bf_allowed_vif
= mvmvif
;
1410 vif
->driver_flags
|= IEEE80211_VIF_BEACON_FILTER
|
1411 IEEE80211_VIF_SUPPORTS_CQM_RSSI
;
1415 * P2P_DEVICE interface does not have a channel context assigned to it,
1416 * so a dedicated PHY context is allocated to it and the corresponding
1417 * MAC context is bound to it at this stage.
1419 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1421 mvmvif
->phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
1422 if (!mvmvif
->phy_ctxt
) {
1427 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
1428 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
1432 ret
= iwl_mvm_add_p2p_bcast_sta(mvm
, vif
);
1436 /* Save a pointer to p2p device vif, so it can later be used to
1437 * update the p2p device MAC when a GO is started/stopped */
1438 mvm
->p2p_device_vif
= vif
;
1441 if (vif
->type
== NL80211_IFTYPE_MONITOR
)
1442 mvm
->monitor_on
= true;
1444 iwl_mvm_vif_dbgfs_register(mvm
, vif
);
1448 iwl_mvm_binding_remove_vif(mvm
, vif
);
1450 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
1452 if (mvm
->bf_allowed_vif
== mvmvif
) {
1453 mvm
->bf_allowed_vif
= NULL
;
1454 vif
->driver_flags
&= ~(IEEE80211_VIF_BEACON_FILTER
|
1455 IEEE80211_VIF_SUPPORTS_CQM_RSSI
);
1458 mvmvif
->phy_ctxt
= NULL
;
1459 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1461 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
1464 mutex_unlock(&mvm
->mutex
);
1466 iwl_mvm_unref(mvm
, IWL_MVM_REF_ADD_IF
);
1471 static void iwl_mvm_prepare_mac_removal(struct iwl_mvm
*mvm
,
1472 struct ieee80211_vif
*vif
)
1474 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1476 * Flush the ROC worker which will flush the OFFCHANNEL queue.
1477 * We assume here that all the packets sent to the OFFCHANNEL
1478 * queue are sent in ROC session.
1480 flush_work(&mvm
->roc_done_wk
);
1484 static void iwl_mvm_mac_remove_interface(struct ieee80211_hw
*hw
,
1485 struct ieee80211_vif
*vif
)
1487 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1488 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1490 iwl_mvm_prepare_mac_removal(mvm
, vif
);
1492 mutex_lock(&mvm
->mutex
);
1494 if (mvm
->bf_allowed_vif
== mvmvif
) {
1495 mvm
->bf_allowed_vif
= NULL
;
1496 vif
->driver_flags
&= ~(IEEE80211_VIF_BEACON_FILTER
|
1497 IEEE80211_VIF_SUPPORTS_CQM_RSSI
);
1500 iwl_mvm_vif_dbgfs_clean(mvm
, vif
);
1503 * For AP/GO interface, the tear down of the resources allocated to the
1504 * interface is be handled as part of the stop_ap flow.
1506 if (vif
->type
== NL80211_IFTYPE_AP
||
1507 vif
->type
== NL80211_IFTYPE_ADHOC
) {
1508 #ifdef CONFIG_NL80211_TESTMODE
1509 if (vif
== mvm
->noa_vif
) {
1510 mvm
->noa_vif
= NULL
;
1511 mvm
->noa_duration
= 0;
1514 iwl_mvm_dealloc_int_sta(mvm
, &mvmvif
->mcast_sta
);
1515 iwl_mvm_dealloc_bcast_sta(mvm
, vif
);
1519 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1520 mvm
->p2p_device_vif
= NULL
;
1521 iwl_mvm_rm_p2p_bcast_sta(mvm
, vif
);
1522 iwl_mvm_binding_remove_vif(mvm
, vif
);
1523 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
1524 mvmvif
->phy_ctxt
= NULL
;
1527 if (mvm
->vif_count
&& vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
1530 iwl_mvm_power_update_mac(mvm
);
1531 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1533 if (vif
->type
== NL80211_IFTYPE_MONITOR
)
1534 mvm
->monitor_on
= false;
1537 mutex_unlock(&mvm
->mutex
);
1540 static int iwl_mvm_mac_config(struct ieee80211_hw
*hw
, u32 changed
)
1545 struct iwl_mvm_mc_iter_data
{
1546 struct iwl_mvm
*mvm
;
1550 static void iwl_mvm_mc_iface_iterator(void *_data
, u8
*mac
,
1551 struct ieee80211_vif
*vif
)
1553 struct iwl_mvm_mc_iter_data
*data
= _data
;
1554 struct iwl_mvm
*mvm
= data
->mvm
;
1555 struct iwl_mcast_filter_cmd
*cmd
= mvm
->mcast_filter_cmd
;
1556 struct iwl_host_cmd hcmd
= {
1557 .id
= MCAST_FILTER_CMD
,
1559 .dataflags
[0] = IWL_HCMD_DFL_NOCOPY
,
1563 /* if we don't have free ports, mcast frames will be dropped */
1564 if (WARN_ON_ONCE(data
->port_id
>= MAX_PORT_ID_NUM
))
1567 if (vif
->type
!= NL80211_IFTYPE_STATION
||
1568 !vif
->bss_conf
.assoc
)
1571 cmd
->port_id
= data
->port_id
++;
1572 memcpy(cmd
->bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
1573 len
= roundup(sizeof(*cmd
) + cmd
->count
* ETH_ALEN
, 4);
1578 ret
= iwl_mvm_send_cmd(mvm
, &hcmd
);
1580 IWL_ERR(mvm
, "mcast filter cmd error. ret=%d\n", ret
);
1583 static void iwl_mvm_recalc_multicast(struct iwl_mvm
*mvm
)
1585 struct iwl_mvm_mc_iter_data iter_data
= {
1589 lockdep_assert_held(&mvm
->mutex
);
1591 if (WARN_ON_ONCE(!mvm
->mcast_filter_cmd
))
1594 ieee80211_iterate_active_interfaces_atomic(
1595 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
1596 iwl_mvm_mc_iface_iterator
, &iter_data
);
1599 static u64
iwl_mvm_prepare_multicast(struct ieee80211_hw
*hw
,
1600 struct netdev_hw_addr_list
*mc_list
)
1602 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1603 struct iwl_mcast_filter_cmd
*cmd
;
1604 struct netdev_hw_addr
*addr
;
1609 addr_count
= netdev_hw_addr_list_count(mc_list
);
1610 pass_all
= addr_count
> MAX_MCAST_FILTERING_ADDRESSES
||
1611 IWL_MVM_FW_MCAST_FILTER_PASS_ALL
;
1615 len
= roundup(sizeof(*cmd
) + addr_count
* ETH_ALEN
, 4);
1616 cmd
= kzalloc(len
, GFP_ATOMIC
);
1622 return (u64
)(unsigned long)cmd
;
1625 netdev_hw_addr_list_for_each(addr
, mc_list
) {
1626 IWL_DEBUG_MAC80211(mvm
, "mcast addr (%d): %pM\n",
1627 cmd
->count
, addr
->addr
);
1628 memcpy(&cmd
->addr_list
[cmd
->count
* ETH_ALEN
],
1629 addr
->addr
, ETH_ALEN
);
1633 return (u64
)(unsigned long)cmd
;
1636 static void iwl_mvm_configure_filter(struct ieee80211_hw
*hw
,
1637 unsigned int changed_flags
,
1638 unsigned int *total_flags
,
1641 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1642 struct iwl_mcast_filter_cmd
*cmd
= (void *)(unsigned long)multicast
;
1644 mutex_lock(&mvm
->mutex
);
1646 /* replace previous configuration */
1647 kfree(mvm
->mcast_filter_cmd
);
1648 mvm
->mcast_filter_cmd
= cmd
;
1653 if (changed_flags
& FIF_ALLMULTI
)
1654 cmd
->pass_all
= !!(*total_flags
& FIF_ALLMULTI
);
1659 iwl_mvm_recalc_multicast(mvm
);
1661 mutex_unlock(&mvm
->mutex
);
1665 static void iwl_mvm_config_iface_filter(struct ieee80211_hw
*hw
,
1666 struct ieee80211_vif
*vif
,
1667 unsigned int filter_flags
,
1668 unsigned int changed_flags
)
1670 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1672 /* We support only filter for probe requests */
1673 if (!(changed_flags
& FIF_PROBE_REQ
))
1676 /* Supported only for p2p client interfaces */
1677 if (vif
->type
!= NL80211_IFTYPE_STATION
|| !vif
->bss_conf
.assoc
||
1681 mutex_lock(&mvm
->mutex
);
1682 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
1683 mutex_unlock(&mvm
->mutex
);
1686 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1687 struct iwl_bcast_iter_data
{
1688 struct iwl_mvm
*mvm
;
1689 struct iwl_bcast_filter_cmd
*cmd
;
1694 iwl_mvm_set_bcast_filter(struct ieee80211_vif
*vif
,
1695 const struct iwl_fw_bcast_filter
*in_filter
,
1696 struct iwl_fw_bcast_filter
*out_filter
)
1698 struct iwl_fw_bcast_filter_attr
*attr
;
1701 memcpy(out_filter
, in_filter
, sizeof(*out_filter
));
1703 for (i
= 0; i
< ARRAY_SIZE(out_filter
->attrs
); i
++) {
1704 attr
= &out_filter
->attrs
[i
];
1709 switch (attr
->reserved1
) {
1710 case cpu_to_le16(BC_FILTER_MAGIC_IP
):
1711 if (vif
->bss_conf
.arp_addr_cnt
!= 1) {
1716 attr
->val
= vif
->bss_conf
.arp_addr_list
[0];
1718 case cpu_to_le16(BC_FILTER_MAGIC_MAC
):
1719 attr
->val
= *(__be32
*)&vif
->addr
[2];
1724 attr
->reserved1
= 0;
1725 out_filter
->num_attrs
++;
1729 static void iwl_mvm_bcast_filter_iterator(void *_data
, u8
*mac
,
1730 struct ieee80211_vif
*vif
)
1732 struct iwl_bcast_iter_data
*data
= _data
;
1733 struct iwl_mvm
*mvm
= data
->mvm
;
1734 struct iwl_bcast_filter_cmd
*cmd
= data
->cmd
;
1735 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1736 struct iwl_fw_bcast_mac
*bcast_mac
;
1739 if (WARN_ON(mvmvif
->id
>= ARRAY_SIZE(cmd
->macs
)))
1742 bcast_mac
= &cmd
->macs
[mvmvif
->id
];
1745 * enable filtering only for associated stations, but not for P2P
1748 if (vif
->type
!= NL80211_IFTYPE_STATION
|| vif
->p2p
||
1749 !vif
->bss_conf
.assoc
)
1752 bcast_mac
->default_discard
= 1;
1754 /* copy all configured filters */
1755 for (i
= 0; mvm
->bcast_filters
[i
].attrs
[0].mask
; i
++) {
1757 * Make sure we don't exceed our filters limit.
1758 * if there is still a valid filter to be configured,
1759 * be on the safe side and just allow bcast for this mac.
1761 if (WARN_ON_ONCE(data
->current_filter
>=
1762 ARRAY_SIZE(cmd
->filters
))) {
1763 bcast_mac
->default_discard
= 0;
1764 bcast_mac
->attached_filters
= 0;
1768 iwl_mvm_set_bcast_filter(vif
,
1769 &mvm
->bcast_filters
[i
],
1770 &cmd
->filters
[data
->current_filter
]);
1772 /* skip current filter if it contains no attributes */
1773 if (!cmd
->filters
[data
->current_filter
].num_attrs
)
1776 /* attach the filter to current mac */
1777 bcast_mac
->attached_filters
|=
1778 cpu_to_le16(BIT(data
->current_filter
));
1780 data
->current_filter
++;
1784 bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm
*mvm
,
1785 struct iwl_bcast_filter_cmd
*cmd
)
1787 struct iwl_bcast_iter_data iter_data
= {
1792 if (IWL_MVM_FW_BCAST_FILTER_PASS_ALL
)
1795 memset(cmd
, 0, sizeof(*cmd
));
1796 cmd
->max_bcast_filters
= ARRAY_SIZE(cmd
->filters
);
1797 cmd
->max_macs
= ARRAY_SIZE(cmd
->macs
);
1799 #ifdef CONFIG_IWLWIFI_DEBUGFS
1800 /* use debugfs filters/macs if override is configured */
1801 if (mvm
->dbgfs_bcast_filtering
.override
) {
1802 memcpy(cmd
->filters
, &mvm
->dbgfs_bcast_filtering
.cmd
.filters
,
1803 sizeof(cmd
->filters
));
1804 memcpy(cmd
->macs
, &mvm
->dbgfs_bcast_filtering
.cmd
.macs
,
1810 /* if no filters are configured, do nothing */
1811 if (!mvm
->bcast_filters
)
1814 /* configure and attach these filters for each associated sta vif */
1815 ieee80211_iterate_active_interfaces(
1816 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
1817 iwl_mvm_bcast_filter_iterator
, &iter_data
);
1822 static int iwl_mvm_configure_bcast_filter(struct iwl_mvm
*mvm
)
1824 struct iwl_bcast_filter_cmd cmd
;
1826 if (!(mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_BCAST_FILTERING
))
1829 if (!iwl_mvm_bcast_filter_build_cmd(mvm
, &cmd
))
1832 return iwl_mvm_send_cmd_pdu(mvm
, BCAST_FILTER_CMD
, 0,
1836 static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm
*mvm
)
1842 static int iwl_mvm_update_mu_groups(struct iwl_mvm
*mvm
,
1843 struct ieee80211_vif
*vif
)
1845 struct iwl_mu_group_mgmt_cmd cmd
= {};
1847 memcpy(cmd
.membership_status
, vif
->bss_conf
.mu_group
.membership
,
1848 WLAN_MEMBERSHIP_LEN
);
1849 memcpy(cmd
.user_position
, vif
->bss_conf
.mu_group
.position
,
1850 WLAN_USER_POSITION_LEN
);
1852 return iwl_mvm_send_cmd_pdu(mvm
,
1853 WIDE_ID(DATA_PATH_GROUP
,
1854 UPDATE_MU_GROUPS_CMD
),
1855 0, sizeof(cmd
), &cmd
);
1858 static void iwl_mvm_mu_mimo_iface_iterator(void *_data
, u8
*mac
,
1859 struct ieee80211_vif
*vif
)
1861 if (vif
->mu_mimo_owner
) {
1862 struct iwl_mu_group_mgmt_notif
*notif
= _data
;
1865 * MU-MIMO Group Id action frame is little endian. We treat
1866 * the data received from firmware as if it came from the
1867 * action frame, so no conversion is needed.
1869 ieee80211_update_mu_groups(vif
,
1870 (u8
*)¬if
->membership_status
,
1871 (u8
*)¬if
->user_position
);
1875 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm
*mvm
,
1876 struct iwl_rx_cmd_buffer
*rxb
)
1878 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
1879 struct iwl_mu_group_mgmt_notif
*notif
= (void *)pkt
->data
;
1881 ieee80211_iterate_active_interfaces_atomic(
1882 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
1883 iwl_mvm_mu_mimo_iface_iterator
, notif
);
1886 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm
*mvm
,
1887 struct ieee80211_vif
*vif
,
1888 struct ieee80211_bss_conf
*bss_conf
,
1891 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1895 * Re-calculate the tsf id, as the master-slave relations depend on the
1896 * beacon interval, which was not known when the station interface was
1899 if (changes
& BSS_CHANGED_ASSOC
&& bss_conf
->assoc
)
1900 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
1902 if (changes
& BSS_CHANGED_ASSOC
&& !bss_conf
->assoc
&&
1904 iwl_mvm_send_lqm_cmd(vif
, LQM_CMD_OPERATION_STOP_MEASUREMENT
,
1908 * If we're not associated yet, take the (new) BSSID before associating
1909 * so the firmware knows. If we're already associated, then use the old
1910 * BSSID here, and we'll send a cleared one later in the CHANGED_ASSOC
1911 * branch for disassociation below.
1913 if (changes
& BSS_CHANGED_BSSID
&& !mvmvif
->associated
)
1914 memcpy(mvmvif
->bssid
, bss_conf
->bssid
, ETH_ALEN
);
1916 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, mvmvif
->bssid
);
1918 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
1920 /* after sending it once, adopt mac80211 data */
1921 memcpy(mvmvif
->bssid
, bss_conf
->bssid
, ETH_ALEN
);
1922 mvmvif
->associated
= bss_conf
->assoc
;
1924 if (changes
& BSS_CHANGED_ASSOC
) {
1925 if (bss_conf
->assoc
) {
1926 /* clear statistics to get clean beacon counter */
1927 iwl_mvm_request_statistics(mvm
, true);
1928 memset(&mvmvif
->beacon_stats
, 0,
1929 sizeof(mvmvif
->beacon_stats
));
1931 /* add quota for this interface */
1932 ret
= iwl_mvm_update_quotas(mvm
, true, NULL
);
1934 IWL_ERR(mvm
, "failed to update quotas\n");
1938 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
,
1941 * If we're restarting then the firmware will
1942 * obviously have lost synchronisation with
1943 * the AP. It will attempt to synchronise by
1944 * itself, but we can make it more reliable by
1945 * scheduling a session protection time event.
1947 * The firmware needs to receive a beacon to
1948 * catch up with synchronisation, use 110% of
1949 * the beacon interval.
1951 * Set a large maximum delay to allow for more
1952 * than a single interface.
1954 u32 dur
= (11 * vif
->bss_conf
.beacon_int
) / 10;
1955 iwl_mvm_protect_session(mvm
, vif
, dur
, dur
,
1959 iwl_mvm_sf_update(mvm
, vif
, false);
1960 iwl_mvm_power_vif_assoc(mvm
, vif
);
1962 iwl_mvm_ref(mvm
, IWL_MVM_REF_P2P_CLIENT
);
1963 iwl_mvm_update_smps(mvm
, vif
,
1964 IWL_MVM_SMPS_REQ_PROT
,
1965 IEEE80211_SMPS_DYNAMIC
);
1967 } else if (mvmvif
->ap_sta_id
!= IWL_MVM_INVALID_STA
) {
1969 * If update fails - SF might be running in associated
1970 * mode while disassociated - which is forbidden.
1972 WARN_ONCE(iwl_mvm_sf_update(mvm
, vif
, false),
1973 "Failed to update SF upon disassociation\n");
1976 * If we get an assert during the connection (after the
1977 * station has been added, but before the vif is set
1978 * to associated), mac80211 will re-add the station and
1979 * then configure the vif. Since the vif is not
1980 * associated, we would remove the station here and
1981 * this would fail the recovery.
1983 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
,
1986 * Remove AP station now that
1987 * the MAC is unassoc
1989 ret
= iwl_mvm_rm_sta_id(mvm
, vif
,
1993 "failed to remove AP station\n");
1995 if (mvm
->d0i3_ap_sta_id
== mvmvif
->ap_sta_id
)
1996 mvm
->d0i3_ap_sta_id
=
1997 IWL_MVM_INVALID_STA
;
1998 mvmvif
->ap_sta_id
= IWL_MVM_INVALID_STA
;
2001 /* remove quota for this interface */
2002 ret
= iwl_mvm_update_quotas(mvm
, false, NULL
);
2004 IWL_ERR(mvm
, "failed to update quotas\n");
2007 iwl_mvm_unref(mvm
, IWL_MVM_REF_P2P_CLIENT
);
2009 /* this will take the cleared BSSID from bss_conf */
2010 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
2013 "failed to update MAC %pM (clear after unassoc)\n",
2018 * The firmware tracks the MU-MIMO group on its own.
2019 * However, on HW restart we should restore this data.
2021 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) &&
2022 (changes
& BSS_CHANGED_MU_GROUPS
) && vif
->mu_mimo_owner
) {
2023 ret
= iwl_mvm_update_mu_groups(mvm
, vif
);
2026 "failed to update VHT MU_MIMO groups\n");
2029 iwl_mvm_recalc_multicast(mvm
);
2030 iwl_mvm_configure_bcast_filter(mvm
);
2032 /* reset rssi values */
2033 mvmvif
->bf_data
.ave_beacon_signal
= 0;
2035 iwl_mvm_bt_coex_vif_change(mvm
);
2036 iwl_mvm_update_smps(mvm
, vif
, IWL_MVM_SMPS_REQ_TT
,
2037 IEEE80211_SMPS_AUTOMATIC
);
2038 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
2039 IWL_UCODE_TLV_CAPA_UMAC_SCAN
))
2040 iwl_mvm_config_scan(mvm
);
2043 if (changes
& BSS_CHANGED_BEACON_INFO
) {
2045 * We received a beacon from the associated AP so
2046 * remove the session protection.
2048 iwl_mvm_stop_session_protection(mvm
, vif
);
2050 iwl_mvm_sf_update(mvm
, vif
, false);
2051 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
, 0));
2054 if (changes
& (BSS_CHANGED_PS
| BSS_CHANGED_P2P_PS
| BSS_CHANGED_QOS
|
2056 * Send power command on every beacon change,
2057 * because we may have not enabled beacon abort yet.
2059 BSS_CHANGED_BEACON_INFO
)) {
2060 ret
= iwl_mvm_power_update_mac(mvm
);
2062 IWL_ERR(mvm
, "failed to update power mode\n");
2065 if (changes
& BSS_CHANGED_TXPOWER
) {
2066 IWL_DEBUG_CALIB(mvm
, "Changing TX Power to %d\n",
2068 iwl_mvm_set_tx_power(mvm
, vif
, bss_conf
->txpower
);
2071 if (changes
& BSS_CHANGED_CQM
) {
2072 IWL_DEBUG_MAC80211(mvm
, "cqm info_changed\n");
2073 /* reset cqm events tracking */
2074 mvmvif
->bf_data
.last_cqm_event
= 0;
2075 if (mvmvif
->bf_data
.bf_enabled
) {
2076 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
, 0);
2079 "failed to update CQM thresholds\n");
2083 if (changes
& BSS_CHANGED_ARP_FILTER
) {
2084 IWL_DEBUG_MAC80211(mvm
, "arp filter changed\n");
2085 iwl_mvm_configure_bcast_filter(mvm
);
2089 static int iwl_mvm_start_ap_ibss(struct ieee80211_hw
*hw
,
2090 struct ieee80211_vif
*vif
)
2092 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2093 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2097 * iwl_mvm_mac_ctxt_add() might read directly from the device
2098 * (the system time), so make sure it is available.
2100 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_START_AP
);
2104 mutex_lock(&mvm
->mutex
);
2106 /* Send the beacon template */
2107 ret
= iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
);
2112 * Re-calculate the tsf id, as the master-slave relations depend on the
2113 * beacon interval, which was not known when the AP interface was added.
2115 if (vif
->type
== NL80211_IFTYPE_AP
)
2116 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
2118 mvmvif
->ap_assoc_sta_count
= 0;
2120 /* Add the mac context */
2121 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
2125 /* Perform the binding */
2126 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
2130 ret
= iwl_mvm_add_mcast_sta(mvm
, vif
);
2134 /* Send the bcast station. At this stage the TBTT and DTIM time events
2135 * are added and applied to the scheduler */
2136 ret
= iwl_mvm_send_add_bcast_sta(mvm
, vif
);
2140 /* must be set before quota calculations */
2141 mvmvif
->ap_ibss_active
= true;
2143 /* power updated needs to be done before quotas */
2144 iwl_mvm_power_update_mac(mvm
);
2146 ret
= iwl_mvm_update_quotas(mvm
, false, NULL
);
2148 goto out_quota_failed
;
2150 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
2151 if (vif
->p2p
&& mvm
->p2p_device_vif
)
2152 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false, NULL
);
2154 iwl_mvm_ref(mvm
, IWL_MVM_REF_AP_IBSS
);
2156 iwl_mvm_bt_coex_vif_change(mvm
);
2158 /* we don't support TDLS during DCM */
2159 if (iwl_mvm_phy_ctx_count(mvm
) > 1)
2160 iwl_mvm_teardown_tdls_peers(mvm
);
2165 iwl_mvm_power_update_mac(mvm
);
2166 mvmvif
->ap_ibss_active
= false;
2167 iwl_mvm_send_rm_bcast_sta(mvm
, vif
);
2169 iwl_mvm_rm_mcast_sta(mvm
, vif
);
2171 iwl_mvm_binding_remove_vif(mvm
, vif
);
2173 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
2175 mutex_unlock(&mvm
->mutex
);
2176 iwl_mvm_unref(mvm
, IWL_MVM_REF_START_AP
);
2180 static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw
*hw
,
2181 struct ieee80211_vif
*vif
)
2183 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2184 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2186 iwl_mvm_prepare_mac_removal(mvm
, vif
);
2188 mutex_lock(&mvm
->mutex
);
2190 /* Handle AP stop while in CSA */
2191 if (rcu_access_pointer(mvm
->csa_vif
) == vif
) {
2192 iwl_mvm_remove_time_event(mvm
, mvmvif
,
2193 &mvmvif
->time_event_data
);
2194 RCU_INIT_POINTER(mvm
->csa_vif
, NULL
);
2195 mvmvif
->csa_countdown
= false;
2198 if (rcu_access_pointer(mvm
->csa_tx_blocked_vif
) == vif
) {
2199 RCU_INIT_POINTER(mvm
->csa_tx_blocked_vif
, NULL
);
2200 mvm
->csa_tx_block_bcn_timeout
= 0;
2203 mvmvif
->ap_ibss_active
= false;
2204 mvm
->ap_last_beacon_gp2
= 0;
2206 iwl_mvm_bt_coex_vif_change(mvm
);
2208 iwl_mvm_unref(mvm
, IWL_MVM_REF_AP_IBSS
);
2210 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
2211 if (vif
->p2p
&& mvm
->p2p_device_vif
)
2212 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false, NULL
);
2214 iwl_mvm_update_quotas(mvm
, false, NULL
);
2217 * This is not very nice, but the simplest:
2218 * For older FWs removing the mcast sta before the bcast station may
2219 * cause assert 0x2b00.
2220 * This is fixed in later FW (which will stop beaconing when removing
2222 * So make the order of removal depend on the TLV
2224 if (!fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_STA_TYPE
))
2225 iwl_mvm_rm_mcast_sta(mvm
, vif
);
2226 iwl_mvm_send_rm_bcast_sta(mvm
, vif
);
2227 if (fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_STA_TYPE
))
2228 iwl_mvm_rm_mcast_sta(mvm
, vif
);
2229 iwl_mvm_binding_remove_vif(mvm
, vif
);
2231 iwl_mvm_power_update_mac(mvm
);
2233 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
2235 mutex_unlock(&mvm
->mutex
);
2239 iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm
*mvm
,
2240 struct ieee80211_vif
*vif
,
2241 struct ieee80211_bss_conf
*bss_conf
,
2244 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2246 /* Changes will be applied when the AP/IBSS is started */
2247 if (!mvmvif
->ap_ibss_active
)
2250 if (changes
& (BSS_CHANGED_ERP_CTS_PROT
| BSS_CHANGED_HT
|
2251 BSS_CHANGED_BANDWIDTH
| BSS_CHANGED_QOS
) &&
2252 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
))
2253 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
2255 /* Need to send a new beacon template to the FW */
2256 if (changes
& BSS_CHANGED_BEACON
&&
2257 iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
))
2258 IWL_WARN(mvm
, "Failed updating beacon data\n");
2260 if (changes
& BSS_CHANGED_TXPOWER
) {
2261 IWL_DEBUG_CALIB(mvm
, "Changing TX Power to %d\n",
2263 iwl_mvm_set_tx_power(mvm
, vif
, bss_conf
->txpower
);
2267 static void iwl_mvm_bss_info_changed(struct ieee80211_hw
*hw
,
2268 struct ieee80211_vif
*vif
,
2269 struct ieee80211_bss_conf
*bss_conf
,
2272 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2275 * iwl_mvm_bss_info_changed_station() might call
2276 * iwl_mvm_protect_session(), which reads directly from
2277 * the device (the system time), so make sure it is available.
2279 if (iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_BSS_CHANGED
))
2282 mutex_lock(&mvm
->mutex
);
2284 if (changes
& BSS_CHANGED_IDLE
&& !bss_conf
->idle
)
2285 iwl_mvm_scan_stop(mvm
, IWL_MVM_SCAN_SCHED
, true);
2287 switch (vif
->type
) {
2288 case NL80211_IFTYPE_STATION
:
2289 iwl_mvm_bss_info_changed_station(mvm
, vif
, bss_conf
, changes
);
2291 case NL80211_IFTYPE_AP
:
2292 case NL80211_IFTYPE_ADHOC
:
2293 iwl_mvm_bss_info_changed_ap_ibss(mvm
, vif
, bss_conf
, changes
);
2295 case NL80211_IFTYPE_MONITOR
:
2296 if (changes
& BSS_CHANGED_MU_GROUPS
)
2297 iwl_mvm_update_mu_groups(mvm
, vif
);
2300 /* shouldn't happen */
2304 mutex_unlock(&mvm
->mutex
);
2305 iwl_mvm_unref(mvm
, IWL_MVM_REF_BSS_CHANGED
);
2308 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw
*hw
,
2309 struct ieee80211_vif
*vif
,
2310 struct ieee80211_scan_request
*hw_req
)
2312 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2315 if (hw_req
->req
.n_channels
== 0 ||
2316 hw_req
->req
.n_channels
> mvm
->fw
->ucode_capa
.n_scan_channels
)
2319 mutex_lock(&mvm
->mutex
);
2320 ret
= iwl_mvm_reg_scan_start(mvm
, vif
, &hw_req
->req
, &hw_req
->ies
);
2321 mutex_unlock(&mvm
->mutex
);
2326 static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw
*hw
,
2327 struct ieee80211_vif
*vif
)
2329 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2331 mutex_lock(&mvm
->mutex
);
2333 /* Due to a race condition, it's possible that mac80211 asks
2334 * us to stop a hw_scan when it's already stopped. This can
2335 * happen, for instance, if we stopped the scan ourselves,
2336 * called ieee80211_scan_completed() and the userspace called
2337 * cancel scan scan before ieee80211_scan_work() could run.
2338 * To handle that, simply return if the scan is not running.
2340 if (mvm
->scan_status
& IWL_MVM_SCAN_REGULAR
)
2341 iwl_mvm_scan_stop(mvm
, IWL_MVM_SCAN_REGULAR
, true);
2343 mutex_unlock(&mvm
->mutex
);
2347 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw
*hw
,
2348 struct ieee80211_sta
*sta
, u16 tids
,
2350 enum ieee80211_frame_release_type reason
,
2353 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2355 /* Called when we need to transmit (a) frame(s) from mac80211 */
2357 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
2358 tids
, more_data
, false);
2362 iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw
*hw
,
2363 struct ieee80211_sta
*sta
, u16 tids
,
2365 enum ieee80211_frame_release_type reason
,
2368 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2370 /* Called when we need to transmit (a) frame(s) from agg or dqa queue */
2372 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
2373 tids
, more_data
, true);
2376 static void __iwl_mvm_mac_sta_notify(struct ieee80211_hw
*hw
,
2377 enum sta_notify_cmd cmd
,
2378 struct ieee80211_sta
*sta
)
2380 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2381 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
2382 unsigned long txqs
= 0, tids
= 0;
2386 * If we have TVQM then we get too high queue numbers - luckily
2387 * we really shouldn't get here with that because such hardware
2388 * should have firmware supporting buffer station offload.
2390 if (WARN_ON(iwl_mvm_has_new_tx_api(mvm
)))
2393 spin_lock_bh(&mvmsta
->lock
);
2394 for (tid
= 0; tid
< IWL_MAX_TID_COUNT
; tid
++) {
2395 struct iwl_mvm_tid_data
*tid_data
= &mvmsta
->tid_data
[tid
];
2397 if (tid_data
->txq_id
== IWL_MVM_INVALID_QUEUE
)
2400 __set_bit(tid_data
->txq_id
, &txqs
);
2402 if (iwl_mvm_tid_queued(mvm
, tid_data
) == 0)
2405 __set_bit(tid
, &tids
);
2409 case STA_NOTIFY_SLEEP
:
2410 for_each_set_bit(tid
, &tids
, IWL_MAX_TID_COUNT
)
2411 ieee80211_sta_set_buffered(sta
, tid
, true);
2414 iwl_trans_freeze_txq_timer(mvm
->trans
, txqs
, true);
2416 * The fw updates the STA to be asleep. Tx packets on the Tx
2417 * queues to this station will not be transmitted. The fw will
2418 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
2421 case STA_NOTIFY_AWAKE
:
2422 if (WARN_ON(mvmsta
->sta_id
== IWL_MVM_INVALID_STA
))
2426 iwl_trans_freeze_txq_timer(mvm
->trans
, txqs
, false);
2427 iwl_mvm_sta_modify_ps_wake(mvm
, sta
);
2432 spin_unlock_bh(&mvmsta
->lock
);
2435 static void iwl_mvm_mac_sta_notify(struct ieee80211_hw
*hw
,
2436 struct ieee80211_vif
*vif
,
2437 enum sta_notify_cmd cmd
,
2438 struct ieee80211_sta
*sta
)
2440 __iwl_mvm_mac_sta_notify(hw
, cmd
, sta
);
2443 void iwl_mvm_sta_pm_notif(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
)
2445 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
2446 struct iwl_mvm_pm_state_notification
*notif
= (void *)pkt
->data
;
2447 struct ieee80211_sta
*sta
;
2448 struct iwl_mvm_sta
*mvmsta
;
2449 bool sleeping
= (notif
->type
!= IWL_MVM_PM_EVENT_AWAKE
);
2451 if (WARN_ON(notif
->sta_id
>= ARRAY_SIZE(mvm
->fw_id_to_mac_id
)))
2455 sta
= rcu_dereference(mvm
->fw_id_to_mac_id
[notif
->sta_id
]);
2456 if (WARN_ON(IS_ERR_OR_NULL(sta
))) {
2461 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
2464 mvmsta
->vif
->type
!= NL80211_IFTYPE_AP
) {
2469 if (mvmsta
->sleeping
!= sleeping
) {
2470 mvmsta
->sleeping
= sleeping
;
2471 __iwl_mvm_mac_sta_notify(mvm
->hw
,
2472 sleeping
? STA_NOTIFY_SLEEP
: STA_NOTIFY_AWAKE
,
2474 ieee80211_sta_ps_transition(sta
, sleeping
);
2478 switch (notif
->type
) {
2479 case IWL_MVM_PM_EVENT_AWAKE
:
2480 case IWL_MVM_PM_EVENT_ASLEEP
:
2482 case IWL_MVM_PM_EVENT_UAPSD
:
2483 ieee80211_sta_uapsd_trigger(sta
, IEEE80211_NUM_TIDS
);
2485 case IWL_MVM_PM_EVENT_PS_POLL
:
2486 ieee80211_sta_pspoll(sta
);
2496 static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw
*hw
,
2497 struct ieee80211_vif
*vif
,
2498 struct ieee80211_sta
*sta
)
2500 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2501 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
2504 * This is called before mac80211 does RCU synchronisation,
2505 * so here we already invalidate our internal RCU-protected
2506 * station pointer. The rest of the code will thus no longer
2507 * be able to find the station this way, and we don't rely
2508 * on further RCU synchronisation after the sta_state()
2509 * callback deleted the station.
2511 mutex_lock(&mvm
->mutex
);
2512 if (sta
== rcu_access_pointer(mvm
->fw_id_to_mac_id
[mvm_sta
->sta_id
]))
2513 rcu_assign_pointer(mvm
->fw_id_to_mac_id
[mvm_sta
->sta_id
],
2516 mutex_unlock(&mvm
->mutex
);
2519 static void iwl_mvm_check_uapsd(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
2522 if (!(mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT
))
2525 if (vif
->p2p
&& !iwl_mvm_is_p2p_scm_uapsd_supported(mvm
)) {
2526 vif
->driver_flags
&= ~IEEE80211_VIF_SUPPORTS_UAPSD
;
2531 (iwlwifi_mod_params
.uapsd_disable
& IWL_DISABLE_UAPSD_BSS
)) {
2532 vif
->driver_flags
&= ~IEEE80211_VIF_SUPPORTS_UAPSD
;
2536 vif
->driver_flags
|= IEEE80211_VIF_SUPPORTS_UAPSD
;
2540 iwl_mvm_tdls_check_trigger(struct iwl_mvm
*mvm
,
2541 struct ieee80211_vif
*vif
, u8
*peer_addr
,
2542 enum nl80211_tdls_operation action
)
2544 struct iwl_fw_dbg_trigger_tlv
*trig
;
2545 struct iwl_fw_dbg_trigger_tdls
*tdls_trig
;
2547 if (!iwl_fw_dbg_trigger_enabled(mvm
->fw
, FW_DBG_TRIGGER_TDLS
))
2550 trig
= iwl_fw_dbg_get_trigger(mvm
->fw
, FW_DBG_TRIGGER_TDLS
);
2551 tdls_trig
= (void *)trig
->data
;
2552 if (!iwl_fw_dbg_trigger_check_stop(&mvm
->fwrt
,
2553 ieee80211_vif_to_wdev(vif
), trig
))
2556 if (!(tdls_trig
->action_bitmap
& BIT(action
)))
2559 if (tdls_trig
->peer_mode
&&
2560 memcmp(tdls_trig
->peer
, peer_addr
, ETH_ALEN
) != 0)
2563 iwl_fw_dbg_collect_trig(&mvm
->fwrt
, trig
,
2564 "TDLS event occurred, peer %pM, action %d",
2568 static void iwl_mvm_purge_deferred_tx_frames(struct iwl_mvm
*mvm
,
2569 struct iwl_mvm_sta
*mvm_sta
)
2571 struct iwl_mvm_tid_data
*tid_data
;
2572 struct sk_buff
*skb
;
2575 spin_lock_bh(&mvm_sta
->lock
);
2576 for (i
= 0; i
<= IWL_MAX_TID_COUNT
; i
++) {
2577 tid_data
= &mvm_sta
->tid_data
[i
];
2579 while ((skb
= __skb_dequeue(&tid_data
->deferred_tx_frames
))) {
2580 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
2583 * The first deferred frame should've stopped the MAC
2584 * queues, so we should never get a second deferred
2585 * frame for the RA/TID.
2587 iwl_mvm_start_mac_queues(mvm
, BIT(info
->hw_queue
));
2588 ieee80211_free_txskb(mvm
->hw
, skb
);
2591 spin_unlock_bh(&mvm_sta
->lock
);
2594 static int iwl_mvm_mac_sta_state(struct ieee80211_hw
*hw
,
2595 struct ieee80211_vif
*vif
,
2596 struct ieee80211_sta
*sta
,
2597 enum ieee80211_sta_state old_state
,
2598 enum ieee80211_sta_state new_state
)
2600 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2601 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2602 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
2605 IWL_DEBUG_MAC80211(mvm
, "station %pM state change %d->%d\n",
2606 sta
->addr
, old_state
, new_state
);
2608 /* this would be a mac80211 bug ... but don't crash */
2609 if (WARN_ON_ONCE(!mvmvif
->phy_ctxt
))
2613 * If we are in a STA removal flow and in DQA mode:
2615 * This is after the sync_rcu part, so the queues have already been
2616 * flushed. No more TXs on their way in mac80211's path, and no more in
2618 * Also, we won't be getting any new TX frames for this station.
2619 * What we might have are deferred TX frames that need to be taken care
2622 * Drop any still-queued deferred-frame before removing the STA, and
2623 * make sure the worker is no longer handling frames for this STA.
2625 if (old_state
== IEEE80211_STA_NONE
&&
2626 new_state
== IEEE80211_STA_NOTEXIST
) {
2627 iwl_mvm_purge_deferred_tx_frames(mvm
, mvm_sta
);
2628 flush_work(&mvm
->add_stream_wk
);
2631 * No need to make sure deferred TX indication is off since the
2632 * worker will already remove it if it was on
2636 mutex_lock(&mvm
->mutex
);
2637 /* track whether or not the station is associated */
2638 mvm_sta
->associated
= new_state
>= IEEE80211_STA_ASSOC
;
2640 if (old_state
== IEEE80211_STA_NOTEXIST
&&
2641 new_state
== IEEE80211_STA_NONE
) {
2643 * Firmware bug - it'll crash if the beacon interval is less
2644 * than 16. We can't avoid connecting at all, so refuse the
2645 * station state change, this will cause mac80211 to abandon
2646 * attempts to connect to this AP, and eventually wpa_s will
2647 * blacklist the AP...
2649 if (vif
->type
== NL80211_IFTYPE_STATION
&&
2650 vif
->bss_conf
.beacon_int
< 16) {
2652 "AP %pM beacon interval is %d, refusing due to firmware bug!\n",
2653 sta
->addr
, vif
->bss_conf
.beacon_int
);
2660 iwl_mvm_tdls_sta_count(mvm
, NULL
) ==
2661 IWL_MVM_TDLS_STA_COUNT
||
2662 iwl_mvm_phy_ctx_count(mvm
) > 1)) {
2663 IWL_DEBUG_MAC80211(mvm
, "refusing TDLS sta\n");
2668 ret
= iwl_mvm_add_sta(mvm
, vif
, sta
);
2669 if (sta
->tdls
&& ret
== 0) {
2670 iwl_mvm_recalc_tdls_state(mvm
, vif
, true);
2671 iwl_mvm_tdls_check_trigger(mvm
, vif
, sta
->addr
,
2672 NL80211_TDLS_SETUP
);
2674 } else if (old_state
== IEEE80211_STA_NONE
&&
2675 new_state
== IEEE80211_STA_AUTH
) {
2677 * EBS may be disabled due to previous failures reported by FW.
2678 * Reset EBS status here assuming environment has been changed.
2680 mvm
->last_ebs_successful
= true;
2681 iwl_mvm_check_uapsd(mvm
, vif
, sta
->addr
);
2683 } else if (old_state
== IEEE80211_STA_AUTH
&&
2684 new_state
== IEEE80211_STA_ASSOC
) {
2685 if (vif
->type
== NL80211_IFTYPE_AP
) {
2686 mvmvif
->ap_assoc_sta_count
++;
2687 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
2690 iwl_mvm_rs_rate_init(mvm
, sta
, mvmvif
->phy_ctxt
->channel
->band
,
2692 ret
= iwl_mvm_update_sta(mvm
, vif
, sta
);
2693 } else if (old_state
== IEEE80211_STA_ASSOC
&&
2694 new_state
== IEEE80211_STA_AUTHORIZED
) {
2696 /* we don't support TDLS during DCM */
2697 if (iwl_mvm_phy_ctx_count(mvm
) > 1)
2698 iwl_mvm_teardown_tdls_peers(mvm
);
2701 iwl_mvm_tdls_check_trigger(mvm
, vif
, sta
->addr
,
2702 NL80211_TDLS_ENABLE_LINK
);
2704 /* enable beacon filtering */
2705 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
, 0));
2707 } else if (old_state
== IEEE80211_STA_AUTHORIZED
&&
2708 new_state
== IEEE80211_STA_ASSOC
) {
2709 /* disable beacon filtering */
2710 WARN_ON(iwl_mvm_disable_beacon_filter(mvm
, vif
, 0));
2712 } else if (old_state
== IEEE80211_STA_ASSOC
&&
2713 new_state
== IEEE80211_STA_AUTH
) {
2714 if (vif
->type
== NL80211_IFTYPE_AP
) {
2715 mvmvif
->ap_assoc_sta_count
--;
2716 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
2719 } else if (old_state
== IEEE80211_STA_AUTH
&&
2720 new_state
== IEEE80211_STA_NONE
) {
2722 } else if (old_state
== IEEE80211_STA_NONE
&&
2723 new_state
== IEEE80211_STA_NOTEXIST
) {
2724 ret
= iwl_mvm_rm_sta(mvm
, vif
, sta
);
2726 iwl_mvm_recalc_tdls_state(mvm
, vif
, false);
2727 iwl_mvm_tdls_check_trigger(mvm
, vif
, sta
->addr
,
2728 NL80211_TDLS_DISABLE_LINK
);
2734 mutex_unlock(&mvm
->mutex
);
2736 if (sta
->tdls
&& ret
== 0) {
2737 if (old_state
== IEEE80211_STA_NOTEXIST
&&
2738 new_state
== IEEE80211_STA_NONE
)
2739 ieee80211_reserve_tid(sta
, IWL_MVM_TDLS_FW_TID
);
2740 else if (old_state
== IEEE80211_STA_NONE
&&
2741 new_state
== IEEE80211_STA_NOTEXIST
)
2742 ieee80211_unreserve_tid(sta
, IWL_MVM_TDLS_FW_TID
);
2748 static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
)
2750 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2752 mvm
->rts_threshold
= value
;
2757 static void iwl_mvm_sta_rc_update(struct ieee80211_hw
*hw
,
2758 struct ieee80211_vif
*vif
,
2759 struct ieee80211_sta
*sta
, u32 changed
)
2761 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2763 if (vif
->type
== NL80211_IFTYPE_STATION
&&
2764 changed
& IEEE80211_RC_NSS_CHANGED
)
2765 iwl_mvm_sf_update(mvm
, vif
, false);
2768 static int iwl_mvm_mac_conf_tx(struct ieee80211_hw
*hw
,
2769 struct ieee80211_vif
*vif
, u16 ac
,
2770 const struct ieee80211_tx_queue_params
*params
)
2772 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2773 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2775 mvmvif
->queue_params
[ac
] = *params
;
2778 * No need to update right away, we'll get BSS_CHANGED_QOS
2779 * The exception is P2P_DEVICE interface which needs immediate update.
2781 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
2784 mutex_lock(&mvm
->mutex
);
2785 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
2786 mutex_unlock(&mvm
->mutex
);
2792 static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw
*hw
,
2793 struct ieee80211_vif
*vif
)
2795 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2796 u32 duration
= IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS
;
2797 u32 min_duration
= IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS
;
2799 if (WARN_ON_ONCE(vif
->bss_conf
.assoc
))
2803 * iwl_mvm_protect_session() reads directly from the device
2804 * (the system time), so make sure it is available.
2806 if (iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_PREPARE_TX
))
2809 mutex_lock(&mvm
->mutex
);
2810 /* Try really hard to protect the session and hear a beacon */
2811 iwl_mvm_protect_session(mvm
, vif
, duration
, min_duration
, 500, false);
2812 mutex_unlock(&mvm
->mutex
);
2814 iwl_mvm_unref(mvm
, IWL_MVM_REF_PREPARE_TX
);
2817 static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw
*hw
,
2818 struct ieee80211_vif
*vif
,
2819 struct cfg80211_sched_scan_request
*req
,
2820 struct ieee80211_scan_ies
*ies
)
2822 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2826 mutex_lock(&mvm
->mutex
);
2828 if (!vif
->bss_conf
.idle
) {
2833 ret
= iwl_mvm_sched_scan_start(mvm
, vif
, req
, ies
, IWL_MVM_SCAN_SCHED
);
2836 mutex_unlock(&mvm
->mutex
);
2840 static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw
*hw
,
2841 struct ieee80211_vif
*vif
)
2843 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2846 mutex_lock(&mvm
->mutex
);
2848 /* Due to a race condition, it's possible that mac80211 asks
2849 * us to stop a sched_scan when it's already stopped. This
2850 * can happen, for instance, if we stopped the scan ourselves,
2851 * called ieee80211_sched_scan_stopped() and the userspace called
2852 * stop sched scan scan before ieee80211_sched_scan_stopped_work()
2853 * could run. To handle this, simply return if the scan is
2856 if (!(mvm
->scan_status
& IWL_MVM_SCAN_SCHED
)) {
2857 mutex_unlock(&mvm
->mutex
);
2861 ret
= iwl_mvm_scan_stop(mvm
, IWL_MVM_SCAN_SCHED
, false);
2862 mutex_unlock(&mvm
->mutex
);
2863 iwl_mvm_wait_for_async_handlers(mvm
);
2868 static int iwl_mvm_mac_set_key(struct ieee80211_hw
*hw
,
2869 enum set_key_cmd cmd
,
2870 struct ieee80211_vif
*vif
,
2871 struct ieee80211_sta
*sta
,
2872 struct ieee80211_key_conf
*key
)
2874 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2875 struct iwl_mvm_sta
*mvmsta
;
2876 struct iwl_mvm_key_pn
*ptk_pn
;
2877 int keyidx
= key
->keyidx
;
2881 if (iwlwifi_mod_params
.swcrypto
) {
2882 IWL_DEBUG_MAC80211(mvm
, "leave - hwcrypto disabled\n");
2886 switch (key
->cipher
) {
2887 case WLAN_CIPHER_SUITE_TKIP
:
2888 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_MMIC
;
2889 key
->flags
|= IEEE80211_KEY_FLAG_PUT_IV_SPACE
;
2891 case WLAN_CIPHER_SUITE_CCMP
:
2892 case WLAN_CIPHER_SUITE_GCMP
:
2893 case WLAN_CIPHER_SUITE_GCMP_256
:
2894 if (!iwl_mvm_has_new_tx_api(mvm
))
2895 key
->flags
|= IEEE80211_KEY_FLAG_PUT_IV_SPACE
;
2897 case WLAN_CIPHER_SUITE_AES_CMAC
:
2898 case WLAN_CIPHER_SUITE_BIP_GMAC_128
:
2899 case WLAN_CIPHER_SUITE_BIP_GMAC_256
:
2900 WARN_ON_ONCE(!ieee80211_hw_check(hw
, MFP_CAPABLE
));
2902 case WLAN_CIPHER_SUITE_WEP40
:
2903 case WLAN_CIPHER_SUITE_WEP104
:
2904 /* For non-client mode, only use WEP keys for TX as we probably
2905 * don't have a station yet anyway and would then have to keep
2906 * track of the keys, linking them to each of the clients/peers
2907 * as they appear. For now, don't do that, for performance WEP
2908 * offload doesn't really matter much, but we need it for some
2909 * other offload features in client mode.
2911 if (vif
->type
!= NL80211_IFTYPE_STATION
)
2915 /* currently FW supports only one optional cipher scheme */
2916 if (hw
->n_cipher_schemes
&&
2917 hw
->cipher_schemes
->cipher
== key
->cipher
)
2918 key
->flags
|= IEEE80211_KEY_FLAG_PUT_IV_SPACE
;
2923 mutex_lock(&mvm
->mutex
);
2927 if ((vif
->type
== NL80211_IFTYPE_ADHOC
||
2928 vif
->type
== NL80211_IFTYPE_AP
) && !sta
) {
2930 * GTK on AP interface is a TX-only key, return 0;
2931 * on IBSS they're per-station and because we're lazy
2932 * we don't support them for RX, so do the same.
2933 * CMAC/GMAC in AP/IBSS modes must be done in software.
2935 if (key
->cipher
== WLAN_CIPHER_SUITE_AES_CMAC
||
2936 key
->cipher
== WLAN_CIPHER_SUITE_BIP_GMAC_128
||
2937 key
->cipher
== WLAN_CIPHER_SUITE_BIP_GMAC_256
)
2942 if (key
->cipher
!= WLAN_CIPHER_SUITE_GCMP
&&
2943 key
->cipher
!= WLAN_CIPHER_SUITE_GCMP_256
&&
2944 !iwl_mvm_has_new_tx_api(mvm
)) {
2945 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
2950 /* During FW restart, in order to restore the state as it was,
2951 * don't try to reprogram keys we previously failed for.
2953 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) &&
2954 key
->hw_key_idx
== STA_KEY_IDX_INVALID
) {
2955 IWL_DEBUG_MAC80211(mvm
,
2956 "skip invalid idx key programming during restart\n");
2961 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) &&
2962 sta
&& iwl_mvm_has_new_rx_api(mvm
) &&
2963 key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
&&
2964 (key
->cipher
== WLAN_CIPHER_SUITE_CCMP
||
2965 key
->cipher
== WLAN_CIPHER_SUITE_GCMP
||
2966 key
->cipher
== WLAN_CIPHER_SUITE_GCMP_256
)) {
2967 struct ieee80211_key_seq seq
;
2970 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
2971 WARN_ON(rcu_access_pointer(mvmsta
->ptk_pn
[keyidx
]));
2972 ptk_pn
= kzalloc(sizeof(*ptk_pn
) +
2973 mvm
->trans
->num_rx_queues
*
2974 sizeof(ptk_pn
->q
[0]),
2981 for (tid
= 0; tid
< IWL_MAX_TID_COUNT
; tid
++) {
2982 ieee80211_get_key_rx_seq(key
, tid
, &seq
);
2983 for (q
= 0; q
< mvm
->trans
->num_rx_queues
; q
++)
2984 memcpy(ptk_pn
->q
[q
].pn
[tid
],
2986 IEEE80211_CCMP_PN_LEN
);
2989 rcu_assign_pointer(mvmsta
->ptk_pn
[keyidx
], ptk_pn
);
2992 /* in HW restart reuse the index, otherwise request a new one */
2993 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
2994 key_offset
= key
->hw_key_idx
;
2996 key_offset
= STA_KEY_IDX_INVALID
;
2998 IWL_DEBUG_MAC80211(mvm
, "set hwcrypto key\n");
2999 ret
= iwl_mvm_set_sta_key(mvm
, vif
, sta
, key
, key_offset
);
3001 IWL_WARN(mvm
, "set key failed\n");
3003 * can't add key for RX, but we don't need it
3004 * in the device for TX so still return 0
3006 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
3012 if (key
->hw_key_idx
== STA_KEY_IDX_INVALID
) {
3017 if (sta
&& iwl_mvm_has_new_rx_api(mvm
) &&
3018 key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
&&
3019 (key
->cipher
== WLAN_CIPHER_SUITE_CCMP
||
3020 key
->cipher
== WLAN_CIPHER_SUITE_GCMP
||
3021 key
->cipher
== WLAN_CIPHER_SUITE_GCMP_256
)) {
3022 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
3023 ptk_pn
= rcu_dereference_protected(
3024 mvmsta
->ptk_pn
[keyidx
],
3025 lockdep_is_held(&mvm
->mutex
));
3026 RCU_INIT_POINTER(mvmsta
->ptk_pn
[keyidx
], NULL
);
3028 kfree_rcu(ptk_pn
, rcu_head
);
3031 IWL_DEBUG_MAC80211(mvm
, "disable hwcrypto key\n");
3032 ret
= iwl_mvm_remove_sta_key(mvm
, vif
, sta
, key
);
3038 mutex_unlock(&mvm
->mutex
);
3042 static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw
*hw
,
3043 struct ieee80211_vif
*vif
,
3044 struct ieee80211_key_conf
*keyconf
,
3045 struct ieee80211_sta
*sta
,
3046 u32 iv32
, u16
*phase1key
)
3048 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3050 if (keyconf
->hw_key_idx
== STA_KEY_IDX_INVALID
)
3053 iwl_mvm_update_tkip_key(mvm
, vif
, keyconf
, sta
, iv32
, phase1key
);
3057 static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data
*notif_wait
,
3058 struct iwl_rx_packet
*pkt
, void *data
)
3060 struct iwl_mvm
*mvm
=
3061 container_of(notif_wait
, struct iwl_mvm
, notif_wait
);
3062 struct iwl_hs20_roc_res
*resp
;
3063 int resp_len
= iwl_rx_packet_payload_len(pkt
);
3064 struct iwl_mvm_time_event_data
*te_data
= data
;
3066 if (WARN_ON(pkt
->hdr
.cmd
!= HOT_SPOT_CMD
))
3069 if (WARN_ON_ONCE(resp_len
!= sizeof(*resp
))) {
3070 IWL_ERR(mvm
, "Invalid HOT_SPOT_CMD response\n");
3074 resp
= (void *)pkt
->data
;
3077 "Aux ROC: Recieved response from ucode: status=%d uid=%d\n",
3078 resp
->status
, resp
->event_unique_id
);
3080 te_data
->uid
= le32_to_cpu(resp
->event_unique_id
);
3081 IWL_DEBUG_TE(mvm
, "TIME_EVENT_CMD response - UID = 0x%x\n",
3084 spin_lock_bh(&mvm
->time_event_lock
);
3085 list_add_tail(&te_data
->list
, &mvm
->aux_roc_te_list
);
3086 spin_unlock_bh(&mvm
->time_event_lock
);
3091 #define AUX_ROC_MIN_DURATION MSEC_TO_TU(100)
3092 #define AUX_ROC_MIN_DELAY MSEC_TO_TU(200)
3093 #define AUX_ROC_MAX_DELAY MSEC_TO_TU(600)
3094 #define AUX_ROC_SAFETY_BUFFER MSEC_TO_TU(20)
3095 #define AUX_ROC_MIN_SAFETY_BUFFER MSEC_TO_TU(10)
3096 static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm
*mvm
,
3097 struct ieee80211_channel
*channel
,
3098 struct ieee80211_vif
*vif
,
3101 int res
, time_reg
= DEVICE_SYSTEM_TIME_REG
;
3102 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3103 struct iwl_mvm_time_event_data
*te_data
= &mvmvif
->hs_time_event_data
;
3104 static const u16 time_event_response
[] = { HOT_SPOT_CMD
};
3105 struct iwl_notification_wait wait_time_event
;
3106 u32 dtim_interval
= vif
->bss_conf
.dtim_period
*
3107 vif
->bss_conf
.beacon_int
;
3109 struct iwl_hs20_roc_req aux_roc_req
= {
3110 .action
= cpu_to_le32(FW_CTXT_ACTION_ADD
),
3112 cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX
, 0)),
3113 .sta_id_and_color
= cpu_to_le32(mvm
->aux_sta
.sta_id
),
3114 /* Set the channel info data */
3115 .channel_info
.band
= (channel
->band
== NL80211_BAND_2GHZ
) ?
3116 PHY_BAND_24
: PHY_BAND_5
,
3117 .channel_info
.channel
= channel
->hw_value
,
3118 .channel_info
.width
= PHY_VHT_CHANNEL_MODE20
,
3119 /* Set the time and duration */
3120 .apply_time
= cpu_to_le32(iwl_read_prph(mvm
->trans
, time_reg
)),
3123 delay
= AUX_ROC_MIN_DELAY
;
3124 req_dur
= MSEC_TO_TU(duration
);
3127 * If we are associated we want the delay time to be at least one
3128 * dtim interval so that the FW can wait until after the DTIM and
3129 * then start the time event, this will potentially allow us to
3130 * remain off-channel for the max duration.
3131 * Since we want to use almost a whole dtim interval we would also
3132 * like the delay to be for 2-3 dtim intervals, in case there are
3133 * other time events with higher priority.
3135 if (vif
->bss_conf
.assoc
) {
3136 delay
= min_t(u32
, dtim_interval
* 3, AUX_ROC_MAX_DELAY
);
3137 /* We cannot remain off-channel longer than the DTIM interval */
3138 if (dtim_interval
<= req_dur
) {
3139 req_dur
= dtim_interval
- AUX_ROC_SAFETY_BUFFER
;
3140 if (req_dur
<= AUX_ROC_MIN_DURATION
)
3141 req_dur
= dtim_interval
-
3142 AUX_ROC_MIN_SAFETY_BUFFER
;
3146 aux_roc_req
.duration
= cpu_to_le32(req_dur
);
3147 aux_roc_req
.apply_time_max_delay
= cpu_to_le32(delay
);
3150 "ROC: Requesting to remain on channel %u for %ums (requested = %ums, max_delay = %ums, dtim_interval = %ums)\n",
3151 channel
->hw_value
, req_dur
, duration
, delay
,
3153 /* Set the node address */
3154 memcpy(aux_roc_req
.node_addr
, vif
->addr
, ETH_ALEN
);
3156 lockdep_assert_held(&mvm
->mutex
);
3158 spin_lock_bh(&mvm
->time_event_lock
);
3160 if (WARN_ON(te_data
->id
== HOT_SPOT_CMD
)) {
3161 spin_unlock_bh(&mvm
->time_event_lock
);
3166 te_data
->duration
= duration
;
3167 te_data
->id
= HOT_SPOT_CMD
;
3169 spin_unlock_bh(&mvm
->time_event_lock
);
3172 * Use a notification wait, which really just processes the
3173 * command response and doesn't wait for anything, in order
3174 * to be able to process the response and get the UID inside
3175 * the RX path. Using CMD_WANT_SKB doesn't work because it
3176 * stores the buffer and then wakes up this thread, by which
3177 * time another notification (that the time event started)
3178 * might already be processed unsuccessfully.
3180 iwl_init_notification_wait(&mvm
->notif_wait
, &wait_time_event
,
3181 time_event_response
,
3182 ARRAY_SIZE(time_event_response
),
3183 iwl_mvm_rx_aux_roc
, te_data
);
3185 res
= iwl_mvm_send_cmd_pdu(mvm
, HOT_SPOT_CMD
, 0, sizeof(aux_roc_req
),
3189 IWL_ERR(mvm
, "Couldn't send HOT_SPOT_CMD: %d\n", res
);
3190 iwl_remove_notification(&mvm
->notif_wait
, &wait_time_event
);
3194 /* No need to wait for anything, so just pass 1 (0 isn't valid) */
3195 res
= iwl_wait_notification(&mvm
->notif_wait
, &wait_time_event
, 1);
3196 /* should never fail */
3201 spin_lock_bh(&mvm
->time_event_lock
);
3202 iwl_mvm_te_clear_data(mvm
, te_data
);
3203 spin_unlock_bh(&mvm
->time_event_lock
);
3209 static int iwl_mvm_roc(struct ieee80211_hw
*hw
,
3210 struct ieee80211_vif
*vif
,
3211 struct ieee80211_channel
*channel
,
3213 enum ieee80211_roc_type type
)
3215 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3216 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3217 struct cfg80211_chan_def chandef
;
3218 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
3221 IWL_DEBUG_MAC80211(mvm
, "enter (%d, %d, %d)\n", channel
->hw_value
,
3224 flush_work(&mvm
->roc_done_wk
);
3226 mutex_lock(&mvm
->mutex
);
3228 switch (vif
->type
) {
3229 case NL80211_IFTYPE_STATION
:
3230 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
3231 IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT
)) {
3232 /* Use aux roc framework (HS20) */
3233 ret
= iwl_mvm_send_aux_roc_cmd(mvm
, channel
,
3237 IWL_ERR(mvm
, "hotspot not supported\n");
3240 case NL80211_IFTYPE_P2P_DEVICE
:
3244 IWL_ERR(mvm
, "vif isn't P2P_DEVICE: %d\n", vif
->type
);
3249 for (i
= 0; i
< NUM_PHY_CTX
; i
++) {
3250 phy_ctxt
= &mvm
->phy_ctxts
[i
];
3251 if (phy_ctxt
->ref
== 0 || mvmvif
->phy_ctxt
== phy_ctxt
)
3254 if (phy_ctxt
->ref
&& channel
== phy_ctxt
->channel
) {
3256 * Unbind the P2P_DEVICE from the current PHY context,
3257 * and if the PHY context is not used remove it.
3259 ret
= iwl_mvm_binding_remove_vif(mvm
, vif
);
3260 if (WARN(ret
, "Failed unbinding P2P_DEVICE\n"))
3263 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
3265 /* Bind the P2P_DEVICE to the current PHY Context */
3266 mvmvif
->phy_ctxt
= phy_ctxt
;
3268 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
3269 if (WARN(ret
, "Failed binding P2P_DEVICE\n"))
3272 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
3273 goto schedule_time_event
;
3277 /* Need to update the PHY context only if the ROC channel changed */
3278 if (channel
== mvmvif
->phy_ctxt
->channel
)
3279 goto schedule_time_event
;
3281 cfg80211_chandef_create(&chandef
, channel
, NL80211_CHAN_NO_HT
);
3284 * Change the PHY context configuration as it is currently referenced
3285 * only by the P2P Device MAC
3287 if (mvmvif
->phy_ctxt
->ref
== 1) {
3288 ret
= iwl_mvm_phy_ctxt_changed(mvm
, mvmvif
->phy_ctxt
,
3294 * The PHY context is shared with other MACs. Need to remove the
3295 * P2P Device from the binding, allocate an new PHY context and
3296 * create a new binding
3298 phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
3304 ret
= iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &chandef
,
3307 IWL_ERR(mvm
, "Failed to change PHY context\n");
3311 /* Unbind the P2P_DEVICE from the current PHY context */
3312 ret
= iwl_mvm_binding_remove_vif(mvm
, vif
);
3313 if (WARN(ret
, "Failed unbinding P2P_DEVICE\n"))
3316 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
3318 /* Bind the P2P_DEVICE to the new allocated PHY context */
3319 mvmvif
->phy_ctxt
= phy_ctxt
;
3321 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
3322 if (WARN(ret
, "Failed binding P2P_DEVICE\n"))
3325 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
3328 schedule_time_event
:
3329 /* Schedule the time events */
3330 ret
= iwl_mvm_start_p2p_roc(mvm
, vif
, duration
, type
);
3333 mutex_unlock(&mvm
->mutex
);
3334 IWL_DEBUG_MAC80211(mvm
, "leave\n");
3338 static int iwl_mvm_cancel_roc(struct ieee80211_hw
*hw
)
3340 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3342 IWL_DEBUG_MAC80211(mvm
, "enter\n");
3344 mutex_lock(&mvm
->mutex
);
3345 iwl_mvm_stop_roc(mvm
);
3346 mutex_unlock(&mvm
->mutex
);
3348 IWL_DEBUG_MAC80211(mvm
, "leave\n");
3352 static int __iwl_mvm_add_chanctx(struct iwl_mvm
*mvm
,
3353 struct ieee80211_chanctx_conf
*ctx
)
3355 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
3356 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
3359 lockdep_assert_held(&mvm
->mutex
);
3361 IWL_DEBUG_MAC80211(mvm
, "Add channel context\n");
3363 phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
3369 ret
= iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &ctx
->min_def
,
3370 ctx
->rx_chains_static
,
3371 ctx
->rx_chains_dynamic
);
3373 IWL_ERR(mvm
, "Failed to add PHY context\n");
3377 iwl_mvm_phy_ctxt_ref(mvm
, phy_ctxt
);
3378 *phy_ctxt_id
= phy_ctxt
->id
;
3383 static int iwl_mvm_add_chanctx(struct ieee80211_hw
*hw
,
3384 struct ieee80211_chanctx_conf
*ctx
)
3386 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3389 mutex_lock(&mvm
->mutex
);
3390 ret
= __iwl_mvm_add_chanctx(mvm
, ctx
);
3391 mutex_unlock(&mvm
->mutex
);
3396 static void __iwl_mvm_remove_chanctx(struct iwl_mvm
*mvm
,
3397 struct ieee80211_chanctx_conf
*ctx
)
3399 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
3400 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
3402 lockdep_assert_held(&mvm
->mutex
);
3404 iwl_mvm_phy_ctxt_unref(mvm
, phy_ctxt
);
3407 static void iwl_mvm_remove_chanctx(struct ieee80211_hw
*hw
,
3408 struct ieee80211_chanctx_conf
*ctx
)
3410 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3412 mutex_lock(&mvm
->mutex
);
3413 __iwl_mvm_remove_chanctx(mvm
, ctx
);
3414 mutex_unlock(&mvm
->mutex
);
3417 static void iwl_mvm_change_chanctx(struct ieee80211_hw
*hw
,
3418 struct ieee80211_chanctx_conf
*ctx
,
3421 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3422 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
3423 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
3425 if (WARN_ONCE((phy_ctxt
->ref
> 1) &&
3426 (changed
& ~(IEEE80211_CHANCTX_CHANGE_WIDTH
|
3427 IEEE80211_CHANCTX_CHANGE_RX_CHAINS
|
3428 IEEE80211_CHANCTX_CHANGE_RADAR
|
3429 IEEE80211_CHANCTX_CHANGE_MIN_WIDTH
)),
3430 "Cannot change PHY. Ref=%d, changed=0x%X\n",
3431 phy_ctxt
->ref
, changed
))
3434 mutex_lock(&mvm
->mutex
);
3435 iwl_mvm_bt_coex_vif_change(mvm
);
3436 iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &ctx
->min_def
,
3437 ctx
->rx_chains_static
,
3438 ctx
->rx_chains_dynamic
);
3439 mutex_unlock(&mvm
->mutex
);
3442 static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm
*mvm
,
3443 struct ieee80211_vif
*vif
,
3444 struct ieee80211_chanctx_conf
*ctx
,
3445 bool switching_chanctx
)
3447 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
3448 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
3449 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3452 lockdep_assert_held(&mvm
->mutex
);
3454 mvmvif
->phy_ctxt
= phy_ctxt
;
3456 switch (vif
->type
) {
3457 case NL80211_IFTYPE_AP
:
3458 /* only needed if we're switching chanctx (i.e. during CSA) */
3459 if (switching_chanctx
) {
3460 mvmvif
->ap_ibss_active
= true;
3463 case NL80211_IFTYPE_ADHOC
:
3465 * The AP binding flow is handled as part of the start_ap flow
3466 * (in bss_info_changed), similarly for IBSS.
3470 case NL80211_IFTYPE_STATION
:
3472 case NL80211_IFTYPE_MONITOR
:
3473 /* always disable PS when a monitor interface is active */
3474 mvmvif
->ps_disabled
= true;
3481 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
3486 * Power state must be updated before quotas,
3487 * otherwise fw will complain.
3489 iwl_mvm_power_update_mac(mvm
);
3491 /* Setting the quota at this stage is only required for monitor
3492 * interfaces. For the other types, the bss_info changed flow
3493 * will handle quota settings.
3495 if (vif
->type
== NL80211_IFTYPE_MONITOR
) {
3496 mvmvif
->monitor_active
= true;
3497 ret
= iwl_mvm_update_quotas(mvm
, false, NULL
);
3499 goto out_remove_binding
;
3501 ret
= iwl_mvm_add_snif_sta(mvm
, vif
);
3503 goto out_remove_binding
;
3507 /* Handle binding during CSA */
3508 if (vif
->type
== NL80211_IFTYPE_AP
) {
3509 iwl_mvm_update_quotas(mvm
, false, NULL
);
3510 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
3513 if (switching_chanctx
&& vif
->type
== NL80211_IFTYPE_STATION
) {
3514 u32 duration
= 2 * vif
->bss_conf
.beacon_int
;
3516 /* iwl_mvm_protect_session() reads directly from the
3517 * device (the system time), so make sure it is
3520 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_PROTECT_CSA
);
3522 goto out_remove_binding
;
3524 /* Protect the session to make sure we hear the first
3525 * beacon on the new channel.
3527 iwl_mvm_protect_session(mvm
, vif
, duration
, duration
,
3528 vif
->bss_conf
.beacon_int
/ 2,
3531 iwl_mvm_unref(mvm
, IWL_MVM_REF_PROTECT_CSA
);
3533 iwl_mvm_update_quotas(mvm
, false, NULL
);
3539 iwl_mvm_binding_remove_vif(mvm
, vif
);
3540 iwl_mvm_power_update_mac(mvm
);
3543 mvmvif
->phy_ctxt
= NULL
;
3546 static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw
*hw
,
3547 struct ieee80211_vif
*vif
,
3548 struct ieee80211_chanctx_conf
*ctx
)
3550 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3553 mutex_lock(&mvm
->mutex
);
3554 ret
= __iwl_mvm_assign_vif_chanctx(mvm
, vif
, ctx
, false);
3555 mutex_unlock(&mvm
->mutex
);
3560 static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm
*mvm
,
3561 struct ieee80211_vif
*vif
,
3562 struct ieee80211_chanctx_conf
*ctx
,
3563 bool switching_chanctx
)
3565 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3566 struct ieee80211_vif
*disabled_vif
= NULL
;
3568 lockdep_assert_held(&mvm
->mutex
);
3570 iwl_mvm_remove_time_event(mvm
, mvmvif
, &mvmvif
->time_event_data
);
3572 switch (vif
->type
) {
3573 case NL80211_IFTYPE_ADHOC
:
3575 case NL80211_IFTYPE_MONITOR
:
3576 mvmvif
->monitor_active
= false;
3577 mvmvif
->ps_disabled
= false;
3578 iwl_mvm_rm_snif_sta(mvm
, vif
);
3580 case NL80211_IFTYPE_AP
:
3581 /* This part is triggered only during CSA */
3582 if (!switching_chanctx
|| !mvmvif
->ap_ibss_active
)
3585 mvmvif
->csa_countdown
= false;
3587 /* Set CS bit on all the stations */
3588 iwl_mvm_modify_all_sta_disable_tx(mvm
, mvmvif
, true);
3590 /* Save blocked iface, the timeout is set on the next beacon */
3591 rcu_assign_pointer(mvm
->csa_tx_blocked_vif
, vif
);
3593 mvmvif
->ap_ibss_active
= false;
3595 case NL80211_IFTYPE_STATION
:
3596 if (!switching_chanctx
)
3601 iwl_mvm_mac_ctxt_changed(mvm
, vif
, true, NULL
);
3607 iwl_mvm_update_quotas(mvm
, false, disabled_vif
);
3608 iwl_mvm_binding_remove_vif(mvm
, vif
);
3611 mvmvif
->phy_ctxt
= NULL
;
3612 iwl_mvm_power_update_mac(mvm
);
3615 static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw
*hw
,
3616 struct ieee80211_vif
*vif
,
3617 struct ieee80211_chanctx_conf
*ctx
)
3619 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3621 mutex_lock(&mvm
->mutex
);
3622 __iwl_mvm_unassign_vif_chanctx(mvm
, vif
, ctx
, false);
3623 mutex_unlock(&mvm
->mutex
);
3627 iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm
*mvm
,
3628 struct ieee80211_vif_chanctx_switch
*vifs
)
3632 mutex_lock(&mvm
->mutex
);
3633 __iwl_mvm_unassign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].old_ctx
, true);
3634 __iwl_mvm_remove_chanctx(mvm
, vifs
[0].old_ctx
);
3636 ret
= __iwl_mvm_add_chanctx(mvm
, vifs
[0].new_ctx
);
3638 IWL_ERR(mvm
, "failed to add new_ctx during channel switch\n");
3642 ret
= __iwl_mvm_assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].new_ctx
,
3646 "failed to assign new_ctx during channel switch\n");
3650 /* we don't support TDLS during DCM - can be caused by channel switch */
3651 if (iwl_mvm_phy_ctx_count(mvm
) > 1)
3652 iwl_mvm_teardown_tdls_peers(mvm
);
3657 __iwl_mvm_remove_chanctx(mvm
, vifs
[0].new_ctx
);
3660 if (__iwl_mvm_add_chanctx(mvm
, vifs
[0].old_ctx
)) {
3661 IWL_ERR(mvm
, "failed to add old_ctx back after failure.\n");
3665 if (__iwl_mvm_assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].old_ctx
,
3667 IWL_ERR(mvm
, "failed to reassign old_ctx after failure.\n");
3674 /* things keep failing, better restart the hw */
3675 iwl_mvm_nic_restart(mvm
, false);
3678 mutex_unlock(&mvm
->mutex
);
3684 iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm
*mvm
,
3685 struct ieee80211_vif_chanctx_switch
*vifs
)
3689 mutex_lock(&mvm
->mutex
);
3690 __iwl_mvm_unassign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].old_ctx
, true);
3692 ret
= __iwl_mvm_assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].new_ctx
,
3696 "failed to assign new_ctx during channel switch\n");
3703 if (__iwl_mvm_assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].old_ctx
,
3705 IWL_ERR(mvm
, "failed to reassign old_ctx after failure.\n");
3712 /* things keep failing, better restart the hw */
3713 iwl_mvm_nic_restart(mvm
, false);
3716 mutex_unlock(&mvm
->mutex
);
3721 static int iwl_mvm_switch_vif_chanctx(struct ieee80211_hw
*hw
,
3722 struct ieee80211_vif_chanctx_switch
*vifs
,
3724 enum ieee80211_chanctx_switch_mode mode
)
3726 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3729 /* we only support a single-vif right now */
3734 case CHANCTX_SWMODE_SWAP_CONTEXTS
:
3735 ret
= iwl_mvm_switch_vif_chanctx_swap(mvm
, vifs
);
3737 case CHANCTX_SWMODE_REASSIGN_VIF
:
3738 ret
= iwl_mvm_switch_vif_chanctx_reassign(mvm
, vifs
);
3748 static int iwl_mvm_tx_last_beacon(struct ieee80211_hw
*hw
)
3750 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3752 return mvm
->ibss_manager
;
3755 static int iwl_mvm_set_tim(struct ieee80211_hw
*hw
,
3756 struct ieee80211_sta
*sta
,
3759 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3760 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
3762 if (!mvm_sta
|| !mvm_sta
->vif
) {
3763 IWL_ERR(mvm
, "Station is not associated to a vif\n");
3767 return iwl_mvm_mac_ctxt_beacon_changed(mvm
, mvm_sta
->vif
);
3770 #ifdef CONFIG_NL80211_TESTMODE
3771 static const struct nla_policy iwl_mvm_tm_policy
[IWL_MVM_TM_ATTR_MAX
+ 1] = {
3772 [IWL_MVM_TM_ATTR_CMD
] = { .type
= NLA_U32
},
3773 [IWL_MVM_TM_ATTR_NOA_DURATION
] = { .type
= NLA_U32
},
3774 [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
] = { .type
= NLA_U32
},
3777 static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm
*mvm
,
3778 struct ieee80211_vif
*vif
,
3779 void *data
, int len
)
3781 struct nlattr
*tb
[IWL_MVM_TM_ATTR_MAX
+ 1];
3785 err
= nla_parse(tb
, IWL_MVM_TM_ATTR_MAX
, data
, len
, iwl_mvm_tm_policy
,
3790 if (!tb
[IWL_MVM_TM_ATTR_CMD
])
3793 switch (nla_get_u32(tb
[IWL_MVM_TM_ATTR_CMD
])) {
3794 case IWL_MVM_TM_CMD_SET_NOA
:
3795 if (!vif
|| vif
->type
!= NL80211_IFTYPE_AP
|| !vif
->p2p
||
3796 !vif
->bss_conf
.enable_beacon
||
3797 !tb
[IWL_MVM_TM_ATTR_NOA_DURATION
])
3800 noa_duration
= nla_get_u32(tb
[IWL_MVM_TM_ATTR_NOA_DURATION
]);
3801 if (noa_duration
>= vif
->bss_conf
.beacon_int
)
3804 mvm
->noa_duration
= noa_duration
;
3807 return iwl_mvm_update_quotas(mvm
, false, NULL
);
3808 case IWL_MVM_TM_CMD_SET_BEACON_FILTER
:
3809 /* must be associated client vif - ignore authorized */
3810 if (!vif
|| vif
->type
!= NL80211_IFTYPE_STATION
||
3811 !vif
->bss_conf
.assoc
|| !vif
->bss_conf
.dtim_period
||
3812 !tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
])
3815 if (nla_get_u32(tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
]))
3816 return iwl_mvm_enable_beacon_filter(mvm
, vif
, 0);
3817 return iwl_mvm_disable_beacon_filter(mvm
, vif
, 0);
3823 static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw
*hw
,
3824 struct ieee80211_vif
*vif
,
3825 void *data
, int len
)
3827 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3830 mutex_lock(&mvm
->mutex
);
3831 err
= __iwl_mvm_mac_testmode_cmd(mvm
, vif
, data
, len
);
3832 mutex_unlock(&mvm
->mutex
);
3838 static void iwl_mvm_channel_switch(struct ieee80211_hw
*hw
,
3839 struct ieee80211_vif
*vif
,
3840 struct ieee80211_channel_switch
*chsw
)
3842 /* By implementing this operation, we prevent mac80211 from
3843 * starting its own channel switch timer, so that we can call
3844 * ieee80211_chswitch_done() ourselves at the right time
3845 * (which is when the absence time event starts).
3848 IWL_DEBUG_MAC80211(IWL_MAC80211_GET_MVM(hw
),
3849 "dummy channel switch op\n");
3852 static int iwl_mvm_pre_channel_switch(struct ieee80211_hw
*hw
,
3853 struct ieee80211_vif
*vif
,
3854 struct ieee80211_channel_switch
*chsw
)
3856 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3857 struct ieee80211_vif
*csa_vif
;
3858 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3862 mutex_lock(&mvm
->mutex
);
3864 mvmvif
->csa_failed
= false;
3866 IWL_DEBUG_MAC80211(mvm
, "pre CSA to freq %d\n",
3867 chsw
->chandef
.center_freq1
);
3869 iwl_fw_dbg_trigger_simple_stop(&mvm
->fwrt
,
3870 ieee80211_vif_to_wdev(vif
),
3871 FW_DBG_TRIGGER_CHANNEL_SWITCH
);
3873 switch (vif
->type
) {
3874 case NL80211_IFTYPE_AP
:
3876 rcu_dereference_protected(mvm
->csa_vif
,
3877 lockdep_is_held(&mvm
->mutex
));
3878 if (WARN_ONCE(csa_vif
&& csa_vif
->csa_active
,
3879 "Another CSA is already in progress")) {
3884 /* we still didn't unblock tx. prevent new CS meanwhile */
3885 if (rcu_dereference_protected(mvm
->csa_tx_blocked_vif
,
3886 lockdep_is_held(&mvm
->mutex
))) {
3891 rcu_assign_pointer(mvm
->csa_vif
, vif
);
3893 if (WARN_ONCE(mvmvif
->csa_countdown
,
3894 "Previous CSA countdown didn't complete")) {
3899 mvmvif
->csa_target_freq
= chsw
->chandef
.chan
->center_freq
;
3902 case NL80211_IFTYPE_STATION
:
3903 if (mvmvif
->lqm_active
)
3904 iwl_mvm_send_lqm_cmd(vif
,
3905 LQM_CMD_OPERATION_STOP_MEASUREMENT
,
3908 /* Schedule the time event to a bit before beacon 1,
3909 * to make sure we're in the new channel when the
3910 * GO/AP arrives. In case count <= 1 immediately schedule the
3911 * TE (this might result with some packet loss or connection
3914 if (chsw
->count
<= 1)
3917 apply_time
= chsw
->device_timestamp
+
3918 ((vif
->bss_conf
.beacon_int
* (chsw
->count
- 1) -
3919 IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT
) * 1024);
3922 iwl_mvm_csa_client_absent(mvm
, vif
);
3924 iwl_mvm_schedule_csa_period(mvm
, vif
, vif
->bss_conf
.beacon_int
,
3926 if (mvmvif
->bf_data
.bf_enabled
) {
3927 ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
, 0);
3937 mvmvif
->ps_disabled
= true;
3939 ret
= iwl_mvm_power_update_ps(mvm
);
3943 /* we won't be on this channel any longer */
3944 iwl_mvm_teardown_tdls_peers(mvm
);
3947 mutex_unlock(&mvm
->mutex
);
3952 static int iwl_mvm_post_channel_switch(struct ieee80211_hw
*hw
,
3953 struct ieee80211_vif
*vif
)
3955 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3956 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3959 mutex_lock(&mvm
->mutex
);
3961 if (mvmvif
->csa_failed
) {
3962 mvmvif
->csa_failed
= false;
3967 if (vif
->type
== NL80211_IFTYPE_STATION
) {
3968 struct iwl_mvm_sta
*mvmsta
;
3970 mvmsta
= iwl_mvm_sta_from_staid_protected(mvm
,
3973 if (WARN_ON(!mvmsta
)) {
3978 iwl_mvm_sta_modify_disable_tx(mvm
, mvmsta
, false);
3980 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
3982 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
, 0);
3986 iwl_mvm_stop_session_protection(mvm
, vif
);
3989 mvmvif
->ps_disabled
= false;
3991 ret
= iwl_mvm_power_update_ps(mvm
);
3994 mutex_unlock(&mvm
->mutex
);
3999 static void iwl_mvm_flush_no_vif(struct iwl_mvm
*mvm
, u32 queues
, bool drop
)
4002 if (iwl_mvm_has_new_tx_api(mvm
))
4003 /* TODO new tx api */
4005 "Need to implement flush TX queue\n");
4007 iwl_mvm_flush_tx_path(mvm
,
4008 iwl_mvm_flushable_queues(mvm
) & queues
,
4011 if (iwl_mvm_has_new_tx_api(mvm
)) {
4012 struct ieee80211_sta
*sta
;
4015 mutex_lock(&mvm
->mutex
);
4017 for (i
= 0; i
< ARRAY_SIZE(mvm
->fw_id_to_mac_id
); i
++) {
4018 sta
= rcu_dereference_protected(
4019 mvm
->fw_id_to_mac_id
[i
],
4020 lockdep_is_held(&mvm
->mutex
));
4021 if (IS_ERR_OR_NULL(sta
))
4024 iwl_mvm_wait_sta_queues_empty(mvm
,
4025 iwl_mvm_sta_from_mac80211(sta
));
4028 mutex_unlock(&mvm
->mutex
);
4030 iwl_trans_wait_tx_queues_empty(mvm
->trans
,
4036 static void iwl_mvm_mac_flush(struct ieee80211_hw
*hw
,
4037 struct ieee80211_vif
*vif
, u32 queues
, bool drop
)
4039 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4040 struct iwl_mvm_vif
*mvmvif
;
4041 struct iwl_mvm_sta
*mvmsta
;
4042 struct ieee80211_sta
*sta
;
4047 iwl_mvm_flush_no_vif(mvm
, queues
, drop
);
4051 if (vif
->type
!= NL80211_IFTYPE_STATION
)
4054 /* Make sure we're done with the deferred traffic before flushing */
4055 flush_work(&mvm
->add_stream_wk
);
4057 mutex_lock(&mvm
->mutex
);
4058 mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4060 /* flush the AP-station and all TDLS peers */
4061 for (i
= 0; i
< ARRAY_SIZE(mvm
->fw_id_to_mac_id
); i
++) {
4062 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[i
],
4063 lockdep_is_held(&mvm
->mutex
));
4064 if (IS_ERR_OR_NULL(sta
))
4067 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
4068 if (mvmsta
->vif
!= vif
)
4071 /* make sure only TDLS peers or the AP are flushed */
4072 WARN_ON(i
!= mvmvif
->ap_sta_id
&& !sta
->tdls
);
4075 if (iwl_mvm_flush_sta(mvm
, mvmsta
, false, 0))
4076 IWL_ERR(mvm
, "flush request fail\n");
4078 msk
|= mvmsta
->tfd_queue_msk
;
4079 if (iwl_mvm_has_new_tx_api(mvm
))
4080 iwl_mvm_wait_sta_queues_empty(mvm
, mvmsta
);
4084 mutex_unlock(&mvm
->mutex
);
4086 /* this can take a while, and we may need/want other operations
4087 * to succeed while doing this, so do it without the mutex held
4089 if (!drop
&& !iwl_mvm_has_new_tx_api(mvm
))
4090 iwl_trans_wait_tx_queues_empty(mvm
->trans
, msk
);
4093 static int iwl_mvm_mac_get_survey(struct ieee80211_hw
*hw
, int idx
,
4094 struct survey_info
*survey
)
4096 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4099 memset(survey
, 0, sizeof(*survey
));
4101 /* only support global statistics right now */
4105 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
4106 IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS
))
4109 mutex_lock(&mvm
->mutex
);
4111 if (iwl_mvm_firmware_running(mvm
)) {
4112 ret
= iwl_mvm_request_statistics(mvm
, false);
4117 survey
->filled
= SURVEY_INFO_TIME
|
4118 SURVEY_INFO_TIME_RX
|
4119 SURVEY_INFO_TIME_TX
|
4120 SURVEY_INFO_TIME_SCAN
;
4121 survey
->time
= mvm
->accu_radio_stats
.on_time_rf
+
4122 mvm
->radio_stats
.on_time_rf
;
4123 do_div(survey
->time
, USEC_PER_MSEC
);
4125 survey
->time_rx
= mvm
->accu_radio_stats
.rx_time
+
4126 mvm
->radio_stats
.rx_time
;
4127 do_div(survey
->time_rx
, USEC_PER_MSEC
);
4129 survey
->time_tx
= mvm
->accu_radio_stats
.tx_time
+
4130 mvm
->radio_stats
.tx_time
;
4131 do_div(survey
->time_tx
, USEC_PER_MSEC
);
4133 survey
->time_scan
= mvm
->accu_radio_stats
.on_time_scan
+
4134 mvm
->radio_stats
.on_time_scan
;
4135 do_div(survey
->time_scan
, USEC_PER_MSEC
);
4139 mutex_unlock(&mvm
->mutex
);
4143 static void iwl_mvm_mac_sta_statistics(struct ieee80211_hw
*hw
,
4144 struct ieee80211_vif
*vif
,
4145 struct ieee80211_sta
*sta
,
4146 struct station_info
*sinfo
)
4148 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4149 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4150 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
4152 if (mvmsta
->avg_energy
) {
4153 sinfo
->signal_avg
= mvmsta
->avg_energy
;
4154 sinfo
->filled
|= BIT(NL80211_STA_INFO_SIGNAL_AVG
);
4157 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
4158 IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS
))
4161 /* if beacon filtering isn't on mac80211 does it anyway */
4162 if (!(vif
->driver_flags
& IEEE80211_VIF_BEACON_FILTER
))
4165 if (!vif
->bss_conf
.assoc
)
4168 mutex_lock(&mvm
->mutex
);
4170 if (mvmvif
->ap_sta_id
!= mvmsta
->sta_id
)
4173 if (iwl_mvm_request_statistics(mvm
, false))
4176 sinfo
->rx_beacon
= mvmvif
->beacon_stats
.num_beacons
+
4177 mvmvif
->beacon_stats
.accu_num_beacons
;
4178 sinfo
->filled
|= BIT(NL80211_STA_INFO_BEACON_RX
);
4179 if (mvmvif
->beacon_stats
.avg_signal
) {
4180 /* firmware only reports a value after RXing a few beacons */
4181 sinfo
->rx_beacon_signal_avg
= mvmvif
->beacon_stats
.avg_signal
;
4182 sinfo
->filled
|= BIT(NL80211_STA_INFO_BEACON_SIGNAL_AVG
);
4185 mutex_unlock(&mvm
->mutex
);
4188 static void iwl_mvm_event_mlme_callback(struct iwl_mvm
*mvm
,
4189 struct ieee80211_vif
*vif
,
4190 const struct ieee80211_event
*event
)
4192 #define CHECK_MLME_TRIGGER(_cnt, _fmt...) \
4194 if ((trig_mlme->_cnt) && --(trig_mlme->_cnt)) \
4196 iwl_fw_dbg_collect_trig(&(mvm)->fwrt, trig, _fmt); \
4199 struct iwl_fw_dbg_trigger_tlv
*trig
;
4200 struct iwl_fw_dbg_trigger_mlme
*trig_mlme
;
4202 if (!iwl_fw_dbg_trigger_enabled(mvm
->fw
, FW_DBG_TRIGGER_MLME
))
4205 trig
= iwl_fw_dbg_get_trigger(mvm
->fw
, FW_DBG_TRIGGER_MLME
);
4206 trig_mlme
= (void *)trig
->data
;
4207 if (!iwl_fw_dbg_trigger_check_stop(&mvm
->fwrt
,
4208 ieee80211_vif_to_wdev(vif
), trig
))
4211 if (event
->u
.mlme
.data
== ASSOC_EVENT
) {
4212 if (event
->u
.mlme
.status
== MLME_DENIED
)
4213 CHECK_MLME_TRIGGER(stop_assoc_denied
,
4214 "DENIED ASSOC: reason %d",
4215 event
->u
.mlme
.reason
);
4216 else if (event
->u
.mlme
.status
== MLME_TIMEOUT
)
4217 CHECK_MLME_TRIGGER(stop_assoc_timeout
,
4219 } else if (event
->u
.mlme
.data
== AUTH_EVENT
) {
4220 if (event
->u
.mlme
.status
== MLME_DENIED
)
4221 CHECK_MLME_TRIGGER(stop_auth_denied
,
4222 "DENIED AUTH: reason %d",
4223 event
->u
.mlme
.reason
);
4224 else if (event
->u
.mlme
.status
== MLME_TIMEOUT
)
4225 CHECK_MLME_TRIGGER(stop_auth_timeout
,
4227 } else if (event
->u
.mlme
.data
== DEAUTH_RX_EVENT
) {
4228 CHECK_MLME_TRIGGER(stop_rx_deauth
,
4229 "DEAUTH RX %d", event
->u
.mlme
.reason
);
4230 } else if (event
->u
.mlme
.data
== DEAUTH_TX_EVENT
) {
4231 CHECK_MLME_TRIGGER(stop_tx_deauth
,
4232 "DEAUTH TX %d", event
->u
.mlme
.reason
);
4234 #undef CHECK_MLME_TRIGGER
4237 static void iwl_mvm_event_bar_rx_callback(struct iwl_mvm
*mvm
,
4238 struct ieee80211_vif
*vif
,
4239 const struct ieee80211_event
*event
)
4241 struct iwl_fw_dbg_trigger_tlv
*trig
;
4242 struct iwl_fw_dbg_trigger_ba
*ba_trig
;
4244 if (!iwl_fw_dbg_trigger_enabled(mvm
->fw
, FW_DBG_TRIGGER_BA
))
4247 trig
= iwl_fw_dbg_get_trigger(mvm
->fw
, FW_DBG_TRIGGER_BA
);
4248 ba_trig
= (void *)trig
->data
;
4249 if (!iwl_fw_dbg_trigger_check_stop(&mvm
->fwrt
,
4250 ieee80211_vif_to_wdev(vif
), trig
))
4253 if (!(le16_to_cpu(ba_trig
->rx_bar
) & BIT(event
->u
.ba
.tid
)))
4256 iwl_fw_dbg_collect_trig(&mvm
->fwrt
, trig
,
4257 "BAR received from %pM, tid %d, ssn %d",
4258 event
->u
.ba
.sta
->addr
, event
->u
.ba
.tid
,
4263 iwl_mvm_event_frame_timeout_callback(struct iwl_mvm
*mvm
,
4264 struct ieee80211_vif
*vif
,
4265 const struct ieee80211_event
*event
)
4267 struct iwl_fw_dbg_trigger_tlv
*trig
;
4268 struct iwl_fw_dbg_trigger_ba
*ba_trig
;
4270 if (!iwl_fw_dbg_trigger_enabled(mvm
->fw
, FW_DBG_TRIGGER_BA
))
4273 trig
= iwl_fw_dbg_get_trigger(mvm
->fw
, FW_DBG_TRIGGER_BA
);
4274 ba_trig
= (void *)trig
->data
;
4275 if (!iwl_fw_dbg_trigger_check_stop(&mvm
->fwrt
,
4276 ieee80211_vif_to_wdev(vif
), trig
))
4279 if (!(le16_to_cpu(ba_trig
->frame_timeout
) & BIT(event
->u
.ba
.tid
)))
4282 iwl_fw_dbg_collect_trig(&mvm
->fwrt
, trig
,
4283 "Frame from %pM timed out, tid %d",
4284 event
->u
.ba
.sta
->addr
, event
->u
.ba
.tid
);
4287 static void iwl_mvm_mac_event_callback(struct ieee80211_hw
*hw
,
4288 struct ieee80211_vif
*vif
,
4289 const struct ieee80211_event
*event
)
4291 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4293 switch (event
->type
) {
4295 iwl_mvm_event_mlme_callback(mvm
, vif
, event
);
4298 iwl_mvm_event_bar_rx_callback(mvm
, vif
, event
);
4300 case BA_FRAME_TIMEOUT
:
4301 iwl_mvm_event_frame_timeout_callback(mvm
, vif
, event
);
4308 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm
*mvm
,
4309 struct iwl_mvm_internal_rxq_notif
*notif
,
4312 u32 qmask
= BIT(mvm
->trans
->num_rx_queues
) - 1;
4315 lockdep_assert_held(&mvm
->mutex
);
4317 /* TODO - remove a000 disablement when we have RXQ config API */
4318 if (!iwl_mvm_has_new_rx_api(mvm
) ||
4319 mvm
->trans
->cfg
->device_family
== IWL_DEVICE_FAMILY_A000
)
4322 notif
->cookie
= mvm
->queue_sync_cookie
;
4325 atomic_set(&mvm
->queue_sync_counter
,
4326 mvm
->trans
->num_rx_queues
);
4328 ret
= iwl_mvm_notify_rx_queue(mvm
, qmask
, (u8
*)notif
, size
);
4330 IWL_ERR(mvm
, "Failed to trigger RX queues sync (%d)\n", ret
);
4335 ret
= wait_event_timeout(mvm
->rx_sync_waitq
,
4336 atomic_read(&mvm
->queue_sync_counter
) == 0 ||
4337 iwl_mvm_is_radio_killed(mvm
),
4339 WARN_ON_ONCE(!ret
&& !iwl_mvm_is_radio_killed(mvm
));
4343 atomic_set(&mvm
->queue_sync_counter
, 0);
4344 mvm
->queue_sync_cookie
++;
4347 static void iwl_mvm_sync_rx_queues(struct ieee80211_hw
*hw
)
4349 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4350 struct iwl_mvm_internal_rxq_notif data
= {
4351 .type
= IWL_MVM_RXQ_EMPTY
,
4355 mutex_lock(&mvm
->mutex
);
4356 iwl_mvm_sync_rx_queues_internal(mvm
, &data
, sizeof(data
));
4357 mutex_unlock(&mvm
->mutex
);
4360 const struct ieee80211_ops iwl_mvm_hw_ops
= {
4361 .tx
= iwl_mvm_mac_tx
,
4362 .ampdu_action
= iwl_mvm_mac_ampdu_action
,
4363 .start
= iwl_mvm_mac_start
,
4364 .reconfig_complete
= iwl_mvm_mac_reconfig_complete
,
4365 .stop
= iwl_mvm_mac_stop
,
4366 .add_interface
= iwl_mvm_mac_add_interface
,
4367 .remove_interface
= iwl_mvm_mac_remove_interface
,
4368 .config
= iwl_mvm_mac_config
,
4369 .prepare_multicast
= iwl_mvm_prepare_multicast
,
4370 .configure_filter
= iwl_mvm_configure_filter
,
4371 .config_iface_filter
= iwl_mvm_config_iface_filter
,
4372 .bss_info_changed
= iwl_mvm_bss_info_changed
,
4373 .hw_scan
= iwl_mvm_mac_hw_scan
,
4374 .cancel_hw_scan
= iwl_mvm_mac_cancel_hw_scan
,
4375 .sta_pre_rcu_remove
= iwl_mvm_sta_pre_rcu_remove
,
4376 .sta_state
= iwl_mvm_mac_sta_state
,
4377 .sta_notify
= iwl_mvm_mac_sta_notify
,
4378 .allow_buffered_frames
= iwl_mvm_mac_allow_buffered_frames
,
4379 .release_buffered_frames
= iwl_mvm_mac_release_buffered_frames
,
4380 .set_rts_threshold
= iwl_mvm_mac_set_rts_threshold
,
4381 .sta_rc_update
= iwl_mvm_sta_rc_update
,
4382 .conf_tx
= iwl_mvm_mac_conf_tx
,
4383 .mgd_prepare_tx
= iwl_mvm_mac_mgd_prepare_tx
,
4384 .mgd_protect_tdls_discover
= iwl_mvm_mac_mgd_protect_tdls_discover
,
4385 .flush
= iwl_mvm_mac_flush
,
4386 .sched_scan_start
= iwl_mvm_mac_sched_scan_start
,
4387 .sched_scan_stop
= iwl_mvm_mac_sched_scan_stop
,
4388 .set_key
= iwl_mvm_mac_set_key
,
4389 .update_tkip_key
= iwl_mvm_mac_update_tkip_key
,
4390 .remain_on_channel
= iwl_mvm_roc
,
4391 .cancel_remain_on_channel
= iwl_mvm_cancel_roc
,
4392 .add_chanctx
= iwl_mvm_add_chanctx
,
4393 .remove_chanctx
= iwl_mvm_remove_chanctx
,
4394 .change_chanctx
= iwl_mvm_change_chanctx
,
4395 .assign_vif_chanctx
= iwl_mvm_assign_vif_chanctx
,
4396 .unassign_vif_chanctx
= iwl_mvm_unassign_vif_chanctx
,
4397 .switch_vif_chanctx
= iwl_mvm_switch_vif_chanctx
,
4399 .start_ap
= iwl_mvm_start_ap_ibss
,
4400 .stop_ap
= iwl_mvm_stop_ap_ibss
,
4401 .join_ibss
= iwl_mvm_start_ap_ibss
,
4402 .leave_ibss
= iwl_mvm_stop_ap_ibss
,
4404 .tx_last_beacon
= iwl_mvm_tx_last_beacon
,
4406 .set_tim
= iwl_mvm_set_tim
,
4408 .channel_switch
= iwl_mvm_channel_switch
,
4409 .pre_channel_switch
= iwl_mvm_pre_channel_switch
,
4410 .post_channel_switch
= iwl_mvm_post_channel_switch
,
4412 .tdls_channel_switch
= iwl_mvm_tdls_channel_switch
,
4413 .tdls_cancel_channel_switch
= iwl_mvm_tdls_cancel_channel_switch
,
4414 .tdls_recv_channel_switch
= iwl_mvm_tdls_recv_channel_switch
,
4416 .event_callback
= iwl_mvm_mac_event_callback
,
4418 .sync_rx_queues
= iwl_mvm_sync_rx_queues
,
4420 CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd
)
4422 #ifdef CONFIG_PM_SLEEP
4424 .suspend
= iwl_mvm_suspend
,
4425 .resume
= iwl_mvm_resume
,
4426 .set_wakeup
= iwl_mvm_set_wakeup
,
4427 .set_rekey_data
= iwl_mvm_set_rekey_data
,
4428 #if IS_ENABLED(CONFIG_IPV6)
4429 .ipv6_addr_change
= iwl_mvm_ipv6_addr_change
,
4431 .set_default_unicast_key
= iwl_mvm_set_default_unicast_key
,
4433 .get_survey
= iwl_mvm_mac_get_survey
,
4434 .sta_statistics
= iwl_mvm_mac_sta_statistics
,