1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2024 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
7 #include <linux/kernel.h>
8 #include <linux/slab.h>
9 #include <linux/skbuff.h>
10 #include <linux/netdevice.h>
11 #include <linux/etherdevice.h>
13 #include <linux/if_arp.h>
14 #include <linux/time.h>
15 #include <net/mac80211.h>
16 #include <net/ieee80211_radiotap.h>
20 #include "iwl-op-mode.h"
24 #include "time-event.h"
25 #include "iwl-nvm-utils.h"
26 #include "iwl-phy-db.h"
28 #include "fw/error-dump.h"
30 #include "iwl-nvm-parse.h"
31 #include "time-sync.h"
33 #define IWL_MVM_LIMITS(ap) \
36 .types = BIT(NL80211_IFTYPE_STATION), \
41 BIT(NL80211_IFTYPE_P2P_CLIENT) | \
42 BIT(NL80211_IFTYPE_P2P_GO), \
46 .types = BIT(NL80211_IFTYPE_P2P_DEVICE), \
49 static const struct ieee80211_iface_limit iwl_mvm_limits
[] = {
53 static const struct ieee80211_iface_limit iwl_mvm_limits_ap
[] = {
54 IWL_MVM_LIMITS(BIT(NL80211_IFTYPE_AP
))
57 static const struct ieee80211_iface_combination iwl_mvm_iface_combinations
[] = {
59 .num_different_channels
= 2,
61 .limits
= iwl_mvm_limits
,
62 .n_limits
= ARRAY_SIZE(iwl_mvm_limits
),
65 .num_different_channels
= 1,
67 .limits
= iwl_mvm_limits_ap
,
68 .n_limits
= ARRAY_SIZE(iwl_mvm_limits_ap
),
72 static const struct cfg80211_pmsr_capabilities iwl_mvm_pmsr_capa
= {
73 .max_peers
= IWL_MVM_TOF_MAX_APS
,
75 .randomize_mac_addr
= 1,
82 .request_civicloc
= 1,
84 .non_trigger_based
= 1,
85 .max_bursts_exponent
= -1, /* all supported */
86 .max_ftms_per_burst
= 0, /* no limits */
87 .bandwidths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
88 BIT(NL80211_CHAN_WIDTH_20
) |
89 BIT(NL80211_CHAN_WIDTH_40
) |
90 BIT(NL80211_CHAN_WIDTH_80
) |
91 BIT(NL80211_CHAN_WIDTH_160
),
92 .preambles
= BIT(NL80211_PREAMBLE_LEGACY
) |
93 BIT(NL80211_PREAMBLE_HT
) |
94 BIT(NL80211_PREAMBLE_VHT
) |
95 BIT(NL80211_PREAMBLE_HE
),
99 static int __iwl_mvm_mac_set_key(struct ieee80211_hw
*hw
,
100 enum set_key_cmd cmd
,
101 struct ieee80211_vif
*vif
,
102 struct ieee80211_sta
*sta
,
103 struct ieee80211_key_conf
*key
);
105 static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm
*mvm
)
109 memset(mvm
->phy_ctxts
, 0, sizeof(mvm
->phy_ctxts
));
110 for (i
= 0; i
< NUM_PHY_CTX
; i
++) {
111 mvm
->phy_ctxts
[i
].id
= i
;
112 mvm
->phy_ctxts
[i
].ref
= 0;
116 struct ieee80211_regdomain
*iwl_mvm_get_regdomain(struct wiphy
*wiphy
,
118 enum iwl_mcc_source src_id
,
121 struct ieee80211_regdomain
*regd
= NULL
;
122 struct ieee80211_hw
*hw
= wiphy_to_ieee80211_hw(wiphy
);
123 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
124 struct iwl_mcc_update_resp_v8
*resp
;
127 IWL_DEBUG_LAR(mvm
, "Getting regdomain data for %s from FW\n", alpha2
);
129 lockdep_assert_held(&mvm
->mutex
);
131 resp
= iwl_mvm_update_mcc(mvm
, alpha2
, src_id
);
132 if (IS_ERR_OR_NULL(resp
)) {
133 IWL_DEBUG_LAR(mvm
, "Could not get update from FW %d\n",
134 PTR_ERR_OR_ZERO(resp
));
140 u32 status
= le32_to_cpu(resp
->status
);
142 *changed
= (status
== MCC_RESP_NEW_CHAN_PROFILE
||
143 status
== MCC_RESP_ILLEGAL
);
145 resp_ver
= iwl_fw_lookup_notif_ver(mvm
->fw
, IWL_ALWAYS_LONG_GROUP
,
147 IWL_DEBUG_LAR(mvm
, "MCC update response version: %d\n", resp_ver
);
149 regd
= iwl_parse_nvm_mcc_info(mvm
->trans
->dev
, mvm
->cfg
,
150 __le32_to_cpu(resp
->n_channels
),
152 __le16_to_cpu(resp
->mcc
),
153 __le16_to_cpu(resp
->geo_info
),
154 le32_to_cpu(resp
->cap
), resp_ver
);
155 /* Store the return source id */
156 src_id
= resp
->source_id
;
157 if (IS_ERR_OR_NULL(regd
)) {
158 IWL_DEBUG_LAR(mvm
, "Could not get parse update from FW %d\n",
159 PTR_ERR_OR_ZERO(regd
));
163 IWL_DEBUG_LAR(mvm
, "setting alpha2 from FW to %s (0x%x, 0x%x) src=%d\n",
164 regd
->alpha2
, regd
->alpha2
[0], regd
->alpha2
[1], src_id
);
165 mvm
->lar_regdom_set
= true;
166 mvm
->mcc_src
= src_id
;
168 if (!iwl_puncturing_is_allowed_in_bios(mvm
->bios_enable_puncturing
,
169 le16_to_cpu(resp
->mcc
)))
170 ieee80211_hw_set(mvm
->hw
, DISALLOW_PUNCTURING
);
172 __clear_bit(IEEE80211_HW_DISALLOW_PUNCTURING
, mvm
->hw
->flags
);
174 iwl_mei_set_country_code(__le16_to_cpu(resp
->mcc
));
181 void iwl_mvm_update_changed_regdom(struct iwl_mvm
*mvm
)
184 struct ieee80211_regdomain
*regd
;
186 if (!iwl_mvm_is_lar_supported(mvm
))
189 regd
= iwl_mvm_get_current_regdomain(mvm
, &changed
);
190 if (!IS_ERR_OR_NULL(regd
)) {
191 /* only update the regulatory core if changed */
193 regulatory_set_wiphy_regd(mvm
->hw
->wiphy
, regd
);
199 struct ieee80211_regdomain
*iwl_mvm_get_current_regdomain(struct iwl_mvm
*mvm
,
202 return iwl_mvm_get_regdomain(mvm
->hw
->wiphy
, "ZZ",
203 iwl_mvm_is_wifi_mcc_supported(mvm
) ?
204 MCC_SOURCE_GET_CURRENT
:
205 MCC_SOURCE_OLD_FW
, changed
);
208 int iwl_mvm_init_fw_regd(struct iwl_mvm
*mvm
, bool force_regd_sync
)
210 enum iwl_mcc_source used_src
;
211 struct ieee80211_regdomain
*regd
;
214 const struct ieee80211_regdomain
*r
=
215 wiphy_dereference(mvm
->hw
->wiphy
, mvm
->hw
->wiphy
->regd
);
220 /* save the last source in case we overwrite it below */
221 used_src
= mvm
->mcc_src
;
222 if (iwl_mvm_is_wifi_mcc_supported(mvm
)) {
223 /* Notify the firmware we support wifi location updates */
224 regd
= iwl_mvm_get_current_regdomain(mvm
, NULL
);
225 if (!IS_ERR_OR_NULL(regd
))
229 /* Now set our last stored MCC and source */
230 regd
= iwl_mvm_get_regdomain(mvm
->hw
->wiphy
, r
->alpha2
, used_src
,
232 if (IS_ERR_OR_NULL(regd
))
235 /* update cfg80211 if the regdomain was changed or the caller explicitly
236 * asked to update regdomain
238 if (changed
|| force_regd_sync
)
239 ret
= regulatory_set_wiphy_regd_sync(mvm
->hw
->wiphy
, regd
);
247 /* Each capability added here should also be add to tm_if_types_ext_capa_sta */
248 static const u8 he_if_types_ext_capa_sta
[] = {
249 [0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING
,
250 [2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT
,
251 [7] = WLAN_EXT_CAPA8_OPMODE_NOTIF
|
252 WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB
,
253 [8] = WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB
,
256 static const u8 tm_if_types_ext_capa_sta
[] = {
257 [0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING
,
258 [2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT
|
259 WLAN_EXT_CAPA3_TIMING_MEASUREMENT_SUPPORT
,
260 [7] = WLAN_EXT_CAPA8_OPMODE_NOTIF
|
261 WLAN_EXT_CAPA8_MAX_MSDU_IN_AMSDU_LSB
,
262 [8] = WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB
,
263 [9] = WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT
,
266 /* Additional interface types for which extended capabilities are
267 * specified separately
270 #define IWL_MVM_EMLSR_CAPA (IEEE80211_EML_CAP_EMLSR_SUPP | \
271 IEEE80211_EML_CAP_EMLSR_PADDING_DELAY_32US << \
272 __bf_shf(IEEE80211_EML_CAP_EMLSR_PADDING_DELAY) | \
273 IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_64US << \
274 __bf_shf(IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY))
275 #define IWL_MVM_MLD_CAPA_OPS FIELD_PREP_CONST( \
276 IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP, \
277 IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP_SAME)
279 static const struct wiphy_iftype_ext_capab add_iftypes_ext_capa
[] = {
281 .iftype
= NL80211_IFTYPE_STATION
,
282 .extended_capabilities
= he_if_types_ext_capa_sta
,
283 .extended_capabilities_mask
= he_if_types_ext_capa_sta
,
284 .extended_capabilities_len
= sizeof(he_if_types_ext_capa_sta
),
285 /* relevant only if EHT is supported */
286 .eml_capabilities
= IWL_MVM_EMLSR_CAPA
,
287 .mld_capa_and_ops
= IWL_MVM_MLD_CAPA_OPS
,
290 .iftype
= NL80211_IFTYPE_STATION
,
291 .extended_capabilities
= tm_if_types_ext_capa_sta
,
292 .extended_capabilities_mask
= tm_if_types_ext_capa_sta
,
293 .extended_capabilities_len
= sizeof(tm_if_types_ext_capa_sta
),
294 /* relevant only if EHT is supported */
295 .eml_capabilities
= IWL_MVM_EMLSR_CAPA
,
296 .mld_capa_and_ops
= IWL_MVM_MLD_CAPA_OPS
,
300 int iwl_mvm_op_get_antenna(struct ieee80211_hw
*hw
, u32
*tx_ant
, u32
*rx_ant
)
302 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
303 *tx_ant
= iwl_mvm_get_valid_tx_ant(mvm
);
304 *rx_ant
= iwl_mvm_get_valid_rx_ant(mvm
);
308 int iwl_mvm_op_set_antenna(struct ieee80211_hw
*hw
, u32 tx_ant
, u32 rx_ant
)
310 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
312 /* This has been tested on those devices only */
313 if (mvm
->trans
->trans_cfg
->device_family
!= IWL_DEVICE_FAMILY_9000
&&
314 mvm
->trans
->trans_cfg
->device_family
!= IWL_DEVICE_FAMILY_22000
)
320 /* mac80211 ensures the device is not started,
321 * so the firmware cannot be running
324 mvm
->set_tx_ant
= tx_ant
;
325 mvm
->set_rx_ant
= rx_ant
;
327 iwl_reinit_cab(mvm
->trans
, mvm
->nvm_data
, tx_ant
, rx_ant
, mvm
->fw
);
332 int iwl_mvm_mac_setup_register(struct iwl_mvm
*mvm
)
334 struct ieee80211_hw
*hw
= mvm
->hw
;
336 static const u32 mvm_ciphers
[] = {
337 WLAN_CIPHER_SUITE_WEP40
,
338 WLAN_CIPHER_SUITE_WEP104
,
339 WLAN_CIPHER_SUITE_TKIP
,
340 WLAN_CIPHER_SUITE_CCMP
,
342 #ifdef CONFIG_PM_SLEEP
343 bool unified
= fw_has_capa(&mvm
->fw
->ucode_capa
,
344 IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG
);
346 u32 sec_key_id
= WIDE_ID(DATA_PATH_GROUP
, SEC_KEY_CMD
);
347 u8 sec_key_ver
= iwl_fw_lookup_cmd_ver(mvm
->fw
, sec_key_id
, 0);
349 /* Tell mac80211 our characteristics */
350 ieee80211_hw_set(hw
, SIGNAL_DBM
);
351 ieee80211_hw_set(hw
, SPECTRUM_MGMT
);
352 ieee80211_hw_set(hw
, REPORTS_TX_ACK_STATUS
);
353 ieee80211_hw_set(hw
, WANT_MONITOR_VIF
);
354 ieee80211_hw_set(hw
, SUPPORTS_PS
);
355 ieee80211_hw_set(hw
, SUPPORTS_DYNAMIC_PS
);
356 ieee80211_hw_set(hw
, AMPDU_AGGREGATION
);
357 ieee80211_hw_set(hw
, CONNECTION_MONITOR
);
358 ieee80211_hw_set(hw
, CHANCTX_STA_CSA
);
359 ieee80211_hw_set(hw
, SUPPORT_FAST_XMIT
);
360 ieee80211_hw_set(hw
, SUPPORTS_CLONED_SKBS
);
361 ieee80211_hw_set(hw
, SUPPORTS_AMSDU_IN_AMPDU
);
362 ieee80211_hw_set(hw
, NEEDS_UNIQUE_STA_ADDR
);
363 ieee80211_hw_set(hw
, SUPPORTS_VHT_EXT_NSS_BW
);
364 ieee80211_hw_set(hw
, BUFF_MMPDU_TXQ
);
365 ieee80211_hw_set(hw
, STA_MMPDU_TXQ
);
367 /* Set this early since we need to have it for the check below */
368 if (mvm
->mld_api_is_used
&& mvm
->nvm_data
->sku_cap_11be_enable
&&
369 !iwlwifi_mod_params
.disable_11ax
&&
370 !iwlwifi_mod_params
.disable_11be
) {
371 hw
->wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_MLO
;
372 /* we handle this already earlier, but need it for MLO */
373 ieee80211_hw_set(hw
, HANDLES_QUIET_CSA
);
376 /* With MLD FW API, it tracks timing by itself,
377 * no need for any timing from the host
379 if (!mvm
->mld_api_is_used
)
380 ieee80211_hw_set(hw
, TIMING_BEACON_ONLY
);
383 * On older devices, enabling TX A-MSDU occasionally leads to
384 * something getting messed up, the command read from the FIFO
385 * gets out of sync and isn't a TX command, so that we have an
388 * It's not clear where the bug is, but since we didn't used to
389 * support A-MSDU until moving the mac80211 iTXQs, just leave it
390 * for older devices. We also don't see this issue on any newer
393 if (mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_9000
)
394 ieee80211_hw_set(hw
, TX_AMSDU
);
395 ieee80211_hw_set(hw
, TX_FRAG_LIST
);
397 if (iwl_mvm_has_tlc_offload(mvm
)) {
398 ieee80211_hw_set(hw
, TX_AMPDU_SETUP_IN_HW
);
399 ieee80211_hw_set(hw
, HAS_RATE_CONTROL
);
402 /* We want to use the mac80211's reorder buffer for 9000 */
403 if (iwl_mvm_has_new_rx_api(mvm
) &&
404 mvm
->trans
->trans_cfg
->device_family
> IWL_DEVICE_FAMILY_9000
)
405 ieee80211_hw_set(hw
, SUPPORTS_REORDERING_BUFFER
);
407 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
408 IWL_UCODE_TLV_CAPA_STA_PM_NOTIF
)) {
409 ieee80211_hw_set(hw
, AP_LINK_PS
);
410 } else if (WARN_ON(iwl_mvm_has_new_tx_api(mvm
))) {
412 * we absolutely need this for the new TX API since that comes
413 * with many more queues than the current code can deal with
414 * for station powersave
419 if (mvm
->trans
->num_rx_queues
> 1)
420 ieee80211_hw_set(hw
, USES_RSS
);
422 if (mvm
->trans
->max_skb_frags
)
423 hw
->netdev_features
= NETIF_F_HIGHDMA
| NETIF_F_SG
;
425 hw
->queues
= IEEE80211_NUM_ACS
;
426 hw
->offchannel_tx_hw_queue
= IWL_MVM_OFFCHANNEL_QUEUE
;
427 hw
->radiotap_mcs_details
|= IEEE80211_RADIOTAP_MCS_HAVE_FEC
|
428 IEEE80211_RADIOTAP_MCS_HAVE_STBC
;
429 hw
->radiotap_vht_details
|= IEEE80211_RADIOTAP_VHT_KNOWN_STBC
|
430 IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED
;
432 hw
->radiotap_timestamp
.units_pos
=
433 IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US
|
434 IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ
;
435 /* this is the case for CCK frames, it's better (only 8) for OFDM */
436 hw
->radiotap_timestamp
.accuracy
= 22;
438 if (!iwl_mvm_has_tlc_offload(mvm
))
439 hw
->rate_control_algorithm
= RS_NAME
;
441 hw
->uapsd_queues
= IWL_MVM_UAPSD_QUEUES
;
442 hw
->uapsd_max_sp_len
= IWL_UAPSD_MAX_SP
;
443 hw
->max_tx_fragments
= mvm
->trans
->max_skb_frags
;
445 BUILD_BUG_ON(ARRAY_SIZE(mvm
->ciphers
) < ARRAY_SIZE(mvm_ciphers
) + 6);
446 memcpy(mvm
->ciphers
, mvm_ciphers
, sizeof(mvm_ciphers
));
447 hw
->wiphy
->n_cipher_suites
= ARRAY_SIZE(mvm_ciphers
);
448 hw
->wiphy
->cipher_suites
= mvm
->ciphers
;
450 if (iwl_mvm_has_new_rx_api(mvm
)) {
451 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
452 WLAN_CIPHER_SUITE_GCMP
;
453 hw
->wiphy
->n_cipher_suites
++;
454 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
455 WLAN_CIPHER_SUITE_GCMP_256
;
456 hw
->wiphy
->n_cipher_suites
++;
459 if (iwlwifi_mod_params
.swcrypto
)
461 "iwlmvm doesn't allow to disable HW crypto, check swcrypto module parameter\n");
462 if (!iwlwifi_mod_params
.bt_coex_active
)
464 "iwlmvm doesn't allow to disable BT Coex, check bt_coex_active module parameter\n");
466 ieee80211_hw_set(hw
, MFP_CAPABLE
);
467 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] = WLAN_CIPHER_SUITE_AES_CMAC
;
468 hw
->wiphy
->n_cipher_suites
++;
469 if (iwl_mvm_has_new_rx_api(mvm
)) {
470 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
471 WLAN_CIPHER_SUITE_BIP_GMAC_128
;
472 hw
->wiphy
->n_cipher_suites
++;
473 mvm
->ciphers
[hw
->wiphy
->n_cipher_suites
] =
474 WLAN_CIPHER_SUITE_BIP_GMAC_256
;
475 hw
->wiphy
->n_cipher_suites
++;
478 wiphy_ext_feature_set(hw
->wiphy
,
479 NL80211_EXT_FEATURE_BEACON_RATE_LEGACY
);
480 wiphy_ext_feature_set(hw
->wiphy
,
481 NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT
);
483 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
484 IWL_UCODE_TLV_CAPA_FTM_CALIBRATED
)) {
485 wiphy_ext_feature_set(hw
->wiphy
,
486 NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER
);
487 hw
->wiphy
->pmsr_capa
= &iwl_mvm_pmsr_capa
;
491 fw_has_capa(&mvm
->fw
->ucode_capa
,
492 IWL_UCODE_TLV_CAPA_BIGTK_TX_SUPPORT
))
493 wiphy_ext_feature_set(hw
->wiphy
,
494 NL80211_EXT_FEATURE_BEACON_PROTECTION
);
495 else if (fw_has_capa(&mvm
->fw
->ucode_capa
,
496 IWL_UCODE_TLV_CAPA_BIGTK_SUPPORT
))
497 wiphy_ext_feature_set(hw
->wiphy
,
498 NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT
);
500 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
501 IWL_UCODE_TLV_CAPA_TIME_SYNC_BOTH_FTM_TM
))
502 hw
->wiphy
->hw_timestamp_max_peers
= 1;
504 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
505 IWL_UCODE_TLV_CAPA_SPP_AMSDU_SUPPORT
))
506 wiphy_ext_feature_set(hw
->wiphy
,
507 NL80211_EXT_FEATURE_SPP_AMSDU_SUPPORT
);
509 ieee80211_hw_set(hw
, SINGLE_SCAN_ON_ALL_BANDS
);
510 hw
->wiphy
->features
|=
511 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
|
512 NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR
|
513 NL80211_FEATURE_ND_RANDOM_MAC_ADDR
;
515 hw
->sta_data_size
= sizeof(struct iwl_mvm_sta
);
516 hw
->vif_data_size
= sizeof(struct iwl_mvm_vif
);
517 hw
->chanctx_data_size
= sizeof(u16
);
518 hw
->txq_data_size
= sizeof(struct iwl_mvm_txq
);
520 hw
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
521 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
522 BIT(NL80211_IFTYPE_AP
) |
523 BIT(NL80211_IFTYPE_P2P_GO
) |
524 BIT(NL80211_IFTYPE_P2P_DEVICE
) |
525 BIT(NL80211_IFTYPE_ADHOC
);
527 hw
->wiphy
->flags
|= WIPHY_FLAG_IBSS_RSN
;
528 wiphy_ext_feature_set(hw
->wiphy
, NL80211_EXT_FEATURE_VHT_IBSS
);
530 /* The new Tx API does not allow to pass the key or keyid of a MPDU to
531 * the hw, preventing us to control which key(id) to use per MPDU.
532 * Till that's fixed we can't use Extended Key ID for the newer cards.
534 if (!iwl_mvm_has_new_tx_api(mvm
))
535 wiphy_ext_feature_set(hw
->wiphy
,
536 NL80211_EXT_FEATURE_EXT_KEY_ID
);
537 hw
->wiphy
->features
|= NL80211_FEATURE_HT_IBSS
;
539 hw
->wiphy
->regulatory_flags
|= REGULATORY_ENABLE_RELAX_NO_IR
;
540 if (iwl_mvm_is_lar_supported(mvm
))
541 hw
->wiphy
->regulatory_flags
|= REGULATORY_WIPHY_SELF_MANAGED
;
543 hw
->wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
544 REGULATORY_DISABLE_BEACON_HINTS
;
546 if (mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_AX210
)
547 wiphy_ext_feature_set(hw
->wiphy
,
548 NL80211_EXT_FEATURE_DFS_CONCURRENT
);
550 hw
->wiphy
->flags
|= WIPHY_FLAG_AP_UAPSD
;
551 hw
->wiphy
->flags
|= WIPHY_FLAG_HAS_CHANNEL_SWITCH
;
552 hw
->wiphy
->flags
|= WIPHY_FLAG_SPLIT_SCAN_6GHZ
;
554 hw
->wiphy
->iface_combinations
= iwl_mvm_iface_combinations
;
555 hw
->wiphy
->n_iface_combinations
=
556 ARRAY_SIZE(iwl_mvm_iface_combinations
);
558 hw
->wiphy
->max_remain_on_channel_duration
= 10000;
559 hw
->max_listen_interval
= IWL_MVM_CONN_LISTEN_INTERVAL
;
561 /* Extract MAC address */
562 memcpy(mvm
->addresses
[0].addr
, mvm
->nvm_data
->hw_addr
, ETH_ALEN
);
563 hw
->wiphy
->addresses
= mvm
->addresses
;
564 hw
->wiphy
->n_addresses
= 1;
566 /* Extract additional MAC addresses if available */
567 num_mac
= (mvm
->nvm_data
->n_hw_addrs
> 1) ?
568 min(IWL_MVM_MAX_ADDRESSES
, mvm
->nvm_data
->n_hw_addrs
) : 1;
570 for (i
= 1; i
< num_mac
; i
++) {
571 memcpy(mvm
->addresses
[i
].addr
, mvm
->addresses
[i
-1].addr
,
573 mvm
->addresses
[i
].addr
[5]++;
574 hw
->wiphy
->n_addresses
++;
577 iwl_mvm_reset_phy_ctxts(mvm
);
579 hw
->wiphy
->max_scan_ie_len
= iwl_mvm_max_scan_ie_len(mvm
);
581 hw
->wiphy
->max_scan_ssids
= PROBE_OPTION_MAX
;
583 BUILD_BUG_ON(IWL_MVM_SCAN_STOPPING_MASK
& IWL_MVM_SCAN_MASK
);
584 BUILD_BUG_ON(IWL_MAX_UMAC_SCANS
> HWEIGHT32(IWL_MVM_SCAN_MASK
) ||
585 IWL_MAX_LMAC_SCANS
> HWEIGHT32(IWL_MVM_SCAN_MASK
));
587 if (fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_UMAC_SCAN
))
588 mvm
->max_scans
= IWL_MAX_UMAC_SCANS
;
590 mvm
->max_scans
= IWL_MAX_LMAC_SCANS
;
592 if (mvm
->nvm_data
->bands
[NL80211_BAND_2GHZ
].n_channels
)
593 hw
->wiphy
->bands
[NL80211_BAND_2GHZ
] =
594 &mvm
->nvm_data
->bands
[NL80211_BAND_2GHZ
];
595 if (mvm
->nvm_data
->bands
[NL80211_BAND_5GHZ
].n_channels
) {
596 hw
->wiphy
->bands
[NL80211_BAND_5GHZ
] =
597 &mvm
->nvm_data
->bands
[NL80211_BAND_5GHZ
];
599 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
600 IWL_UCODE_TLV_CAPA_BEAMFORMER
) &&
601 fw_has_api(&mvm
->fw
->ucode_capa
,
602 IWL_UCODE_TLV_API_LQ_SS_PARAMS
))
603 hw
->wiphy
->bands
[NL80211_BAND_5GHZ
]->vht_cap
.cap
|=
604 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE
;
606 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
607 IWL_UCODE_TLV_CAPA_PSC_CHAN_SUPPORT
) &&
608 mvm
->nvm_data
->bands
[NL80211_BAND_6GHZ
].n_channels
)
609 hw
->wiphy
->bands
[NL80211_BAND_6GHZ
] =
610 &mvm
->nvm_data
->bands
[NL80211_BAND_6GHZ
];
612 hw
->wiphy
->hw_version
= mvm
->trans
->hw_id
;
614 if (iwlmvm_mod_params
.power_scheme
!= IWL_POWER_SCHEME_CAM
)
615 hw
->wiphy
->flags
|= WIPHY_FLAG_PS_ON_BY_DEFAULT
;
617 hw
->wiphy
->flags
&= ~WIPHY_FLAG_PS_ON_BY_DEFAULT
;
619 hw
->wiphy
->max_sched_scan_reqs
= 1;
620 hw
->wiphy
->max_sched_scan_ssids
= PROBE_OPTION_MAX
;
621 hw
->wiphy
->max_match_sets
= iwl_umac_scan_get_max_profiles(mvm
->fw
);
622 /* we create the 802.11 header and zero length SSID IE. */
623 hw
->wiphy
->max_sched_scan_ie_len
=
624 SCAN_OFFLOAD_PROBE_REQ_SIZE
- 24 - 2;
625 hw
->wiphy
->max_sched_scan_plans
= IWL_MAX_SCHED_SCAN_PLANS
;
626 hw
->wiphy
->max_sched_scan_plan_interval
= U16_MAX
;
629 * the firmware uses u8 for num of iterations, but 0xff is saved for
630 * infinite loop, so the maximum number of iterations is actually 254.
632 hw
->wiphy
->max_sched_scan_plan_iterations
= 254;
634 hw
->wiphy
->features
|= NL80211_FEATURE_P2P_GO_CTWIN
|
635 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
636 NL80211_FEATURE_P2P_GO_OPPPS
|
637 NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE
|
638 NL80211_FEATURE_SUPPORTS_WMM_ADMISSION
;
640 /* when firmware supports RLC/SMPS offload, do not set these
641 * driver features, since it's no longer supported by driver.
643 if (!iwl_mvm_has_rlc_offload(mvm
))
644 hw
->wiphy
->features
|= NL80211_FEATURE_STATIC_SMPS
|
645 NL80211_FEATURE_DYNAMIC_SMPS
;
647 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
648 IWL_UCODE_TLV_CAPA_TXPOWER_INSERTION_SUPPORT
))
649 hw
->wiphy
->features
|= NL80211_FEATURE_TX_POWER_INSERTION
;
650 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
651 IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT
))
652 hw
->wiphy
->features
|= NL80211_FEATURE_QUIET
;
654 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
655 IWL_UCODE_TLV_CAPA_DS_PARAM_SET_IE_SUPPORT
))
656 hw
->wiphy
->features
|=
657 NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES
;
659 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
660 IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT
))
661 hw
->wiphy
->features
|= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES
;
663 if (iwl_fw_lookup_cmd_ver(mvm
->fw
, WOWLAN_KEK_KCK_MATERIAL
,
664 IWL_FW_CMD_VER_UNKNOWN
) >= 3)
665 hw
->wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK
;
667 if (fw_has_api(&mvm
->fw
->ucode_capa
,
668 IWL_UCODE_TLV_API_SCAN_TSF_REPORT
)) {
669 wiphy_ext_feature_set(hw
->wiphy
,
670 NL80211_EXT_FEATURE_SCAN_START_TIME
);
671 wiphy_ext_feature_set(hw
->wiphy
,
672 NL80211_EXT_FEATURE_BSS_PARENT_TSF
);
675 if (iwl_mvm_is_oce_supported(mvm
)) {
676 u8 scan_ver
= iwl_fw_lookup_cmd_ver(mvm
->fw
, SCAN_REQ_UMAC
, 0);
678 wiphy_ext_feature_set(hw
->wiphy
,
679 NL80211_EXT_FEATURE_ACCEPT_BCAST_PROBE_RESP
);
680 wiphy_ext_feature_set(hw
->wiphy
,
681 NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME
);
682 wiphy_ext_feature_set(hw
->wiphy
,
683 NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE
);
685 /* Old firmware also supports probe deferral and suppression */
687 wiphy_ext_feature_set(hw
->wiphy
,
688 NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION
);
691 hw
->wiphy
->iftype_ext_capab
= NULL
;
692 hw
->wiphy
->num_iftype_ext_capab
= 0;
694 if (mvm
->nvm_data
->sku_cap_11ax_enable
&&
695 !iwlwifi_mod_params
.disable_11ax
) {
696 hw
->wiphy
->iftype_ext_capab
= add_iftypes_ext_capa
;
697 hw
->wiphy
->num_iftype_ext_capab
=
698 ARRAY_SIZE(add_iftypes_ext_capa
) - 1;
700 ieee80211_hw_set(hw
, SUPPORTS_MULTI_BSSID
);
701 ieee80211_hw_set(hw
, SUPPORTS_ONLY_HE_MULTI_BSSID
);
704 if (iwl_fw_lookup_cmd_ver(mvm
->fw
,
705 WIDE_ID(DATA_PATH_GROUP
,
706 WNM_80211V_TIMING_MEASUREMENT_CONFIG_CMD
),
707 IWL_FW_CMD_VER_UNKNOWN
) >= 1) {
708 IWL_DEBUG_INFO(mvm
->trans
, "Timing measurement supported\n");
710 if (!hw
->wiphy
->iftype_ext_capab
) {
711 hw
->wiphy
->num_iftype_ext_capab
= 1;
712 hw
->wiphy
->iftype_ext_capab
= add_iftypes_ext_capa
+
713 ARRAY_SIZE(add_iftypes_ext_capa
) - 1;
715 hw
->wiphy
->iftype_ext_capab
= add_iftypes_ext_capa
+ 1;
719 if (iwl_fw_lookup_cmd_ver(mvm
->fw
, WIDE_ID(LOCATION_GROUP
,
721 IWL_FW_CMD_VER_UNKNOWN
) >= 11) {
722 wiphy_ext_feature_set(hw
->wiphy
,
723 NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE
);
725 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
726 IWL_UCODE_TLV_CAPA_SECURE_LTF_SUPPORT
))
727 wiphy_ext_feature_set(hw
->wiphy
,
728 NL80211_EXT_FEATURE_SECURE_LTF
);
731 mvm
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
733 ieee80211_hw_set(hw
, DISALLOW_PUNCTURING_5GHZ
);
735 #ifdef CONFIG_PM_SLEEP
736 if ((unified
|| mvm
->fw
->img
[IWL_UCODE_WOWLAN
].num_sec
) &&
737 device_can_wakeup(mvm
->trans
->dev
)) {
738 mvm
->wowlan
.flags
|= WIPHY_WOWLAN_MAGIC_PKT
|
739 WIPHY_WOWLAN_DISCONNECT
|
740 WIPHY_WOWLAN_EAP_IDENTITY_REQ
|
741 WIPHY_WOWLAN_RFKILL_RELEASE
|
742 WIPHY_WOWLAN_NET_DETECT
;
743 mvm
->wowlan
.flags
|= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
744 WIPHY_WOWLAN_GTK_REKEY_FAILURE
|
745 WIPHY_WOWLAN_4WAY_HANDSHAKE
;
747 mvm
->wowlan
.n_patterns
= IWL_WOWLAN_MAX_PATTERNS
;
748 mvm
->wowlan
.pattern_min_len
= IWL_WOWLAN_MIN_PATTERN_LEN
;
749 mvm
->wowlan
.pattern_max_len
= IWL_WOWLAN_MAX_PATTERN_LEN
;
750 mvm
->wowlan
.max_nd_match_sets
=
751 iwl_umac_scan_get_max_profiles(mvm
->fw
);
752 hw
->wiphy
->wowlan
= &mvm
->wowlan
;
756 ret
= iwl_mvm_leds_init(mvm
);
760 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
761 IWL_UCODE_TLV_CAPA_TDLS_SUPPORT
)) {
762 IWL_DEBUG_TDLS(mvm
, "TDLS supported\n");
763 hw
->wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
;
764 ieee80211_hw_set(hw
, TDLS_WIDER_BW
);
767 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
768 IWL_UCODE_TLV_CAPA_TDLS_CHANNEL_SWITCH
)) {
769 IWL_DEBUG_TDLS(mvm
, "TDLS channel switch supported\n");
770 hw
->wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
773 hw
->netdev_features
|= mvm
->cfg
->features
;
774 if (!iwl_mvm_is_csum_supported(mvm
))
775 hw
->netdev_features
&= ~IWL_CSUM_NETIF_FLAGS_MASK
;
777 if (mvm
->cfg
->vht_mu_mimo_supported
)
778 wiphy_ext_feature_set(hw
->wiphy
,
779 NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER
);
781 if (fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_PROTECTED_TWT
))
782 wiphy_ext_feature_set(hw
->wiphy
,
783 NL80211_EXT_FEATURE_PROTECTED_TWT
);
785 iwl_mvm_vendor_cmds_register(mvm
);
787 hw
->wiphy
->available_antennas_tx
= iwl_mvm_get_valid_tx_ant(mvm
);
788 hw
->wiphy
->available_antennas_rx
= iwl_mvm_get_valid_rx_ant(mvm
);
790 ret
= ieee80211_register_hw(mvm
->hw
);
792 iwl_mvm_leds_exit(mvm
);
798 static void iwl_mvm_tx_skb(struct iwl_mvm
*mvm
, struct sk_buff
*skb
,
799 struct ieee80211_sta
*sta
)
802 if (likely(iwl_mvm_tx_skb_sta(mvm
, skb
, sta
) == 0))
805 if (likely(iwl_mvm_tx_skb_non_sta(mvm
, skb
) == 0))
809 ieee80211_free_txskb(mvm
->hw
, skb
);
812 void iwl_mvm_mac_tx(struct ieee80211_hw
*hw
,
813 struct ieee80211_tx_control
*control
, struct sk_buff
*skb
)
815 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
816 struct ieee80211_sta
*sta
= control
->sta
;
817 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
818 struct ieee80211_hdr
*hdr
= (void *)skb
->data
;
819 bool offchannel
= IEEE80211_SKB_CB(skb
)->flags
&
820 IEEE80211_TX_CTL_TX_OFFCHAN
;
821 u32 link_id
= u32_get_bits(info
->control
.flags
,
822 IEEE80211_TX_CTRL_MLO_LINK
);
823 struct ieee80211_sta
*tmp_sta
= sta
;
825 if (iwl_mvm_is_radio_killed(mvm
)) {
826 IWL_DEBUG_DROP(mvm
, "Dropping - RF/CT KILL\n");
831 !test_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING
, &mvm
->status
) &&
832 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING
, &mvm
->status
))
836 * bufferable MMPDUs or MMPDUs on STA interfaces come via TXQs
837 * so we treat the others as broadcast
839 if (ieee80211_is_mgmt(hdr
->frame_control
))
842 /* this shouldn't even happen: just drop */
843 if (!sta
&& info
->control
.vif
->type
== NL80211_IFTYPE_STATION
&&
847 if (tmp_sta
&& !sta
&& link_id
!= IEEE80211_LINK_UNSPECIFIED
&&
848 !ieee80211_is_probe_resp(hdr
->frame_control
)) {
849 /* translate MLD addresses to LINK addresses */
850 struct ieee80211_link_sta
*link_sta
=
851 rcu_dereference(tmp_sta
->link
[link_id
]);
852 struct ieee80211_bss_conf
*link_conf
=
853 rcu_dereference(info
->control
.vif
->link_conf
[link_id
]);
854 struct ieee80211_mgmt
*mgmt
;
856 if (WARN_ON(!link_sta
|| !link_conf
))
859 /* if sta is NULL, the frame is a management frame */
861 memcpy(mgmt
->da
, link_sta
->addr
, ETH_ALEN
);
862 memcpy(mgmt
->sa
, link_conf
->addr
, ETH_ALEN
);
863 memcpy(mgmt
->bssid
, link_conf
->bssid
, ETH_ALEN
);
866 iwl_mvm_tx_skb(mvm
, skb
, sta
);
869 ieee80211_free_txskb(hw
, skb
);
872 void iwl_mvm_mac_itxq_xmit(struct ieee80211_hw
*hw
, struct ieee80211_txq
*txq
)
874 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
875 struct iwl_mvm_txq
*mvmtxq
= iwl_mvm_txq_from_mac80211(txq
);
876 struct sk_buff
*skb
= NULL
;
879 * No need for threads to be pending here, they can leave the first
880 * taker all the work.
882 * mvmtxq->tx_request logic:
884 * If 0, no one is currently TXing, set to 1 to indicate current thread
885 * will now start TX and other threads should quit.
887 * If 1, another thread is currently TXing, set to 2 to indicate to
888 * that thread that there was another request. Since that request may
889 * have raced with the check whether the queue is empty, the TXing
890 * thread should check the queue's status one more time before leaving.
891 * This check is done in order to not leave any TX hanging in the queue
892 * until the next TX invocation (which may not even happen).
894 * If 2, another thread is currently TXing, and it will already double
895 * check the queue, so do nothing.
897 if (atomic_fetch_add_unless(&mvmtxq
->tx_request
, 1, 2))
902 while (likely(!test_bit(IWL_MVM_TXQ_STATE_STOP_FULL
,
904 !test_bit(IWL_MVM_TXQ_STATE_STOP_REDIRECT
,
906 !test_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA
,
908 !test_bit(IWL_MVM_STATUS_IN_D3
, &mvm
->status
))) {
909 skb
= ieee80211_tx_dequeue(hw
, txq
);
914 "TXQ of sta %pM tid %d is now empty\n",
920 iwl_mvm_tx_skb(mvm
, skb
, txq
->sta
);
922 } while (atomic_dec_return(&mvmtxq
->tx_request
));
926 void iwl_mvm_mac_wake_tx_queue(struct ieee80211_hw
*hw
,
927 struct ieee80211_txq
*txq
)
929 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
930 struct iwl_mvm_txq
*mvmtxq
= iwl_mvm_txq_from_mac80211(txq
);
932 if (likely(test_bit(IWL_MVM_TXQ_STATE_READY
, &mvmtxq
->state
)) ||
934 iwl_mvm_mac_itxq_xmit(hw
, txq
);
938 /* iwl_mvm_mac_itxq_xmit() will later be called by the worker
939 * to handle any packets we leave on the txq now
942 spin_lock_bh(&mvm
->add_stream_lock
);
943 /* The list is being deleted only after the queue is fully allocated. */
944 if (list_empty(&mvmtxq
->list
) &&
945 /* recheck under lock */
946 !test_bit(IWL_MVM_TXQ_STATE_READY
, &mvmtxq
->state
)) {
947 list_add_tail(&mvmtxq
->list
, &mvm
->add_stream_txqs
);
948 schedule_work(&mvm
->add_stream_wk
);
950 spin_unlock_bh(&mvm
->add_stream_lock
);
953 #define CHECK_BA_TRIGGER(_mvm, _trig, _tid_bm, _tid, _fmt...) \
955 if (!(le16_to_cpu(_tid_bm) & BIT(_tid))) \
957 iwl_fw_dbg_collect_trig(&(_mvm)->fwrt, _trig, _fmt); \
961 iwl_mvm_ampdu_check_trigger(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
962 struct ieee80211_sta
*sta
, u16 tid
, u16 rx_ba_ssn
,
963 enum ieee80211_ampdu_mlme_action action
)
965 struct iwl_fw_dbg_trigger_tlv
*trig
;
966 struct iwl_fw_dbg_trigger_ba
*ba_trig
;
968 trig
= iwl_fw_dbg_trigger_on(&mvm
->fwrt
, ieee80211_vif_to_wdev(vif
),
973 ba_trig
= (void *)trig
->data
;
976 case IEEE80211_AMPDU_TX_OPERATIONAL
: {
977 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
978 struct iwl_mvm_tid_data
*tid_data
= &mvmsta
->tid_data
[tid
];
980 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->tx_ba_start
, tid
,
981 "TX AGG START: MAC %pM tid %d ssn %d\n",
982 sta
->addr
, tid
, tid_data
->ssn
);
985 case IEEE80211_AMPDU_TX_STOP_CONT
:
986 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->tx_ba_stop
, tid
,
987 "TX AGG STOP: MAC %pM tid %d\n",
990 case IEEE80211_AMPDU_RX_START
:
991 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->rx_ba_start
, tid
,
992 "RX AGG START: MAC %pM tid %d ssn %d\n",
993 sta
->addr
, tid
, rx_ba_ssn
);
995 case IEEE80211_AMPDU_RX_STOP
:
996 CHECK_BA_TRIGGER(mvm
, trig
, ba_trig
->rx_ba_stop
, tid
,
997 "RX AGG STOP: MAC %pM tid %d\n",
1005 int iwl_mvm_mac_ampdu_action(struct ieee80211_hw
*hw
,
1006 struct ieee80211_vif
*vif
,
1007 struct ieee80211_ampdu_params
*params
)
1009 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1011 struct ieee80211_sta
*sta
= params
->sta
;
1012 enum ieee80211_ampdu_mlme_action action
= params
->action
;
1013 u16 tid
= params
->tid
;
1014 u16
*ssn
= ¶ms
->ssn
;
1015 u16 buf_size
= params
->buf_size
;
1016 bool amsdu
= params
->amsdu
;
1017 u16 timeout
= params
->timeout
;
1019 IWL_DEBUG_HT(mvm
, "A-MPDU action on addr %pM tid %d: action %d\n",
1020 sta
->addr
, tid
, action
);
1022 if (!(mvm
->nvm_data
->sku_cap_11n_enable
))
1025 mutex_lock(&mvm
->mutex
);
1028 case IEEE80211_AMPDU_RX_START
:
1029 if (iwl_mvm_vif_from_mac80211(vif
)->deflink
.ap_sta_id
==
1030 iwl_mvm_sta_from_mac80211(sta
)->deflink
.sta_id
) {
1031 struct iwl_mvm_vif
*mvmvif
;
1032 u16 macid
= iwl_mvm_vif_from_mac80211(vif
)->id
;
1033 struct iwl_mvm_tcm_mac
*mdata
= &mvm
->tcm
.data
[macid
];
1035 mdata
->opened_rx_ba_sessions
= true;
1036 mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1037 cancel_delayed_work(&mvmvif
->uapsd_nonagg_detected_wk
);
1039 if (!iwl_enable_rx_ampdu()) {
1043 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, *ssn
, true, buf_size
,
1046 case IEEE80211_AMPDU_RX_STOP
:
1047 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, 0, false, buf_size
,
1050 case IEEE80211_AMPDU_TX_START
:
1051 if (!iwl_enable_tx_ampdu()) {
1055 ret
= iwl_mvm_sta_tx_agg_start(mvm
, vif
, sta
, tid
, ssn
);
1057 case IEEE80211_AMPDU_TX_STOP_CONT
:
1058 ret
= iwl_mvm_sta_tx_agg_stop(mvm
, vif
, sta
, tid
);
1060 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
1061 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
1062 ret
= iwl_mvm_sta_tx_agg_flush(mvm
, vif
, sta
, tid
);
1064 case IEEE80211_AMPDU_TX_OPERATIONAL
:
1065 ret
= iwl_mvm_sta_tx_agg_oper(mvm
, vif
, sta
, tid
,
1077 if (action
== IEEE80211_AMPDU_RX_START
)
1080 iwl_mvm_ampdu_check_trigger(mvm
, vif
, sta
, tid
,
1083 mutex_unlock(&mvm
->mutex
);
1088 static void iwl_mvm_cleanup_iterator(void *data
, u8
*mac
,
1089 struct ieee80211_vif
*vif
)
1091 struct iwl_mvm
*mvm
= data
;
1092 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1093 struct iwl_probe_resp_data
*probe_data
;
1094 unsigned int link_id
;
1096 mvmvif
->uploaded
= false;
1098 spin_lock_bh(&mvm
->time_event_lock
);
1099 iwl_mvm_te_clear_data(mvm
, &mvmvif
->time_event_data
);
1100 spin_unlock_bh(&mvm
->time_event_lock
);
1102 mvmvif
->roc_activity
= ROC_NUM_ACTIVITIES
;
1104 mvmvif
->bf_enabled
= false;
1105 mvmvif
->ba_enabled
= false;
1106 mvmvif
->ap_sta
= NULL
;
1108 mvmvif
->esr_active
= false;
1109 vif
->driver_flags
&= ~IEEE80211_VIF_EML_ACTIVE
;
1111 for_each_mvm_vif_valid_link(mvmvif
, link_id
) {
1112 mvmvif
->link
[link_id
]->ap_sta_id
= IWL_INVALID_STA
;
1113 mvmvif
->link
[link_id
]->fw_link_id
= IWL_MVM_FW_LINK_ID_INVALID
;
1114 mvmvif
->link
[link_id
]->phy_ctxt
= NULL
;
1115 mvmvif
->link
[link_id
]->active
= 0;
1116 mvmvif
->link
[link_id
]->igtk
= NULL
;
1117 memset(&mvmvif
->link
[link_id
]->bf_data
, 0,
1118 sizeof(mvmvif
->link
[link_id
]->bf_data
));
1121 probe_data
= rcu_dereference_protected(mvmvif
->deflink
.probe_resp_data
,
1122 lockdep_is_held(&mvm
->mutex
));
1124 kfree_rcu(probe_data
, rcu_head
);
1125 RCU_INIT_POINTER(mvmvif
->deflink
.probe_resp_data
, NULL
);
1128 static void iwl_mvm_cleanup_sta_iterator(void *data
, struct ieee80211_sta
*sta
)
1130 struct iwl_mvm
*mvm
= data
;
1131 struct iwl_mvm_sta
*mvm_sta
;
1132 struct ieee80211_vif
*vif
;
1135 mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
1138 if (!sta
->valid_links
)
1141 for (link_id
= 0; link_id
< ARRAY_SIZE((sta
)->link
); link_id
++) {
1142 struct iwl_mvm_link_sta
*mvm_link_sta
;
1145 rcu_dereference_check(mvm_sta
->link
[link_id
],
1146 lockdep_is_held(&mvm
->mutex
));
1147 if (mvm_link_sta
&& !(vif
->active_links
& BIT(link_id
))) {
1149 * We have a link STA but the link is inactive in
1150 * mac80211. This will happen if we failed to
1151 * deactivate the link but mac80211 roll back the
1152 * deactivation of the link.
1153 * Delete the stale data to avoid issues later on.
1155 iwl_mvm_mld_free_sta_link(mvm
, mvm_sta
, mvm_link_sta
,
1161 static void iwl_mvm_restart_cleanup(struct iwl_mvm
*mvm
)
1163 iwl_mvm_stop_device(mvm
);
1167 mvm
->scan_status
= 0;
1168 mvm
->ps_disabled
= false;
1169 mvm
->rfkill_safe_init_done
= false;
1171 /* just in case one was running */
1172 iwl_mvm_cleanup_roc_te(mvm
);
1173 ieee80211_remain_on_channel_expired(mvm
->hw
);
1175 iwl_mvm_ftm_restart(mvm
);
1178 * cleanup all interfaces, even inactive ones, as some might have
1179 * gone down during the HW restart
1181 ieee80211_iterate_interfaces(mvm
->hw
, 0, iwl_mvm_cleanup_iterator
, mvm
);
1183 /* cleanup stations as links may be gone after restart */
1184 ieee80211_iterate_stations_atomic(mvm
->hw
,
1185 iwl_mvm_cleanup_sta_iterator
, mvm
);
1187 mvm
->p2p_device_vif
= NULL
;
1189 iwl_mvm_reset_phy_ctxts(mvm
);
1190 memset(mvm
->fw_key_table
, 0, sizeof(mvm
->fw_key_table
));
1191 memset(&mvm
->last_bt_notif
, 0, sizeof(mvm
->last_bt_notif
));
1192 memset(&mvm
->last_bt_ci_cmd
, 0, sizeof(mvm
->last_bt_ci_cmd
));
1194 ieee80211_wake_queues(mvm
->hw
);
1196 mvm
->rx_ba_sessions
= 0;
1197 mvm
->fwrt
.dump
.conf
= FW_DBG_INVALID
;
1198 mvm
->monitor_on
= false;
1199 #ifdef CONFIG_IWLWIFI_DEBUGFS
1200 mvm
->beacon_inject_active
= false;
1203 /* keep statistics ticking */
1204 iwl_mvm_accu_radio_stats(mvm
);
1207 int __iwl_mvm_mac_start(struct iwl_mvm
*mvm
)
1209 bool fast_resume
= false;
1212 lockdep_assert_held(&mvm
->mutex
);
1214 ret
= iwl_mvm_mei_get_ownership(mvm
);
1218 if (mvm
->mei_nvm_data
) {
1219 /* We got the NIC, we can now free the MEI NVM data */
1220 kfree(mvm
->mei_nvm_data
);
1221 mvm
->mei_nvm_data
= NULL
;
1224 * We can't free the nvm_data we allocated based on the SAP
1225 * data because we registered to cfg80211 with the channels
1226 * allocated on mvm->nvm_data. Keep a pointer in temp_nvm_data
1227 * just in order to be able free it later.
1228 * NULLify nvm_data so that we will read the NVM from the
1229 * firmware this time.
1231 mvm
->temp_nvm_data
= mvm
->nvm_data
;
1232 mvm
->nvm_data
= NULL
;
1235 #ifdef CONFIG_PM_SLEEP
1236 /* fast_resume will be cleared by iwl_mvm_fast_resume */
1237 fast_resume
= mvm
->fast_resume
;
1240 iwl_mvm_mei_device_state(mvm
, true);
1241 ret
= iwl_mvm_fast_resume(mvm
);
1243 iwl_mvm_stop_device(mvm
);
1244 /* iwl_mvm_up() will be called further down */
1247 * We clear IWL_MVM_STATUS_FIRMWARE_RUNNING upon
1248 * mac_down() so that debugfs will stop honoring
1249 * requests after we flush all the workers.
1250 * Set the IWL_MVM_STATUS_FIRMWARE_RUNNING bit again
1251 * now that we are back. This is a bit abusing the
1252 * flag since the firmware wasn't really ever stopped,
1253 * but this still serves the purpose.
1255 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING
, &mvm
->status
);
1258 #endif /* CONFIG_PM_SLEEP */
1260 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
, &mvm
->status
)) {
1262 * Now convert the HW_RESTART_REQUESTED flag to IN_HW_RESTART
1263 * so later code will - from now on - see that we're doing it.
1265 set_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
1266 clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
, &mvm
->status
);
1267 /* Clean up some internal and mac80211 state on restart */
1268 iwl_mvm_restart_cleanup(mvm
);
1271 /* we also want to load the firmware if fast_resume failed */
1272 if (!fast_resume
|| ret
)
1273 ret
= iwl_mvm_up(mvm
);
1275 iwl_dbg_tlv_time_point(&mvm
->fwrt
, IWL_FW_INI_TIME_POINT_POST_INIT
,
1277 iwl_dbg_tlv_time_point(&mvm
->fwrt
, IWL_FW_INI_TIME_POINT_PERIODIC
,
1280 mvm
->last_reset_or_resume_time_jiffies
= jiffies
;
1282 if (ret
&& test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)) {
1283 /* Something went wrong - we need to finish some cleanup
1284 * that normally iwl_mvm_mac_restart_complete() below
1287 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
1293 int iwl_mvm_mac_start(struct ieee80211_hw
*hw
)
1295 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1297 int retry
, max_retry
= 0;
1299 mutex_lock(&mvm
->mutex
);
1301 /* we are starting the mac not in error flow, and restart is enabled */
1302 if (!test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
, &mvm
->status
) &&
1303 iwlwifi_mod_params
.fw_restart
) {
1304 max_retry
= IWL_MAX_INIT_RETRY
;
1306 * This will prevent mac80211 recovery flows to trigger during
1309 set_bit(IWL_MVM_STATUS_STARTING
, &mvm
->status
);
1312 for (retry
= 0; retry
<= max_retry
; retry
++) {
1313 ret
= __iwl_mvm_mac_start(mvm
);
1317 IWL_ERR(mvm
, "mac start retry %d\n", retry
);
1319 clear_bit(IWL_MVM_STATUS_STARTING
, &mvm
->status
);
1321 mutex_unlock(&mvm
->mutex
);
1323 iwl_mvm_mei_set_sw_rfkill_state(mvm
);
1328 static void iwl_mvm_restart_complete(struct iwl_mvm
*mvm
)
1334 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
1336 ret
= iwl_mvm_update_quotas(mvm
, true, NULL
);
1338 IWL_ERR(mvm
, "Failed to update quotas after restart (%d)\n",
1341 iwl_mvm_send_recovery_cmd(mvm
, ERROR_RECOVERY_END_OF_RECOVERY
);
1344 * If we have TDLS peers, remove them. We don't know the last seqno/PN
1345 * of packets the FW sent out, so we must reconnect.
1347 iwl_mvm_teardown_tdls_peers(mvm
);
1349 IWL_INFO(mvm
, "restart completed\n");
1352 void iwl_mvm_mac_reconfig_complete(struct ieee80211_hw
*hw
,
1353 enum ieee80211_reconfig_type reconfig_type
)
1355 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1357 switch (reconfig_type
) {
1358 case IEEE80211_RECONFIG_TYPE_RESTART
:
1359 iwl_mvm_restart_complete(mvm
);
1361 case IEEE80211_RECONFIG_TYPE_SUSPEND
:
1366 void __iwl_mvm_mac_stop(struct iwl_mvm
*mvm
, bool suspend
)
1368 lockdep_assert_held(&mvm
->mutex
);
1370 iwl_mvm_ftm_initiator_smooth_stop(mvm
);
1372 /* firmware counters are obviously reset now, but we shouldn't
1373 * partially track so also clear the fw_reset_accu counters.
1375 memset(&mvm
->accu_radio_stats
, 0, sizeof(mvm
->accu_radio_stats
));
1377 /* async_handlers_wk is now blocked */
1379 if (!iwl_mvm_has_new_station_api(mvm
->fw
))
1380 iwl_mvm_rm_aux_sta(mvm
);
1383 mvm
->trans
->trans_cfg
->device_family
>= IWL_DEVICE_FAMILY_22000
) {
1384 iwl_mvm_fast_suspend(mvm
);
1385 /* From this point on, we won't touch the device */
1386 iwl_mvm_mei_device_state(mvm
, false);
1388 iwl_mvm_stop_device(mvm
);
1391 iwl_mvm_async_handlers_purge(mvm
);
1392 /* async_handlers_list is empty and will stay empty: HW is stopped */
1395 * Clear IN_HW_RESTART and HW_RESTART_REQUESTED flag when stopping the
1396 * hw (as restart_complete() won't be called in this case) and mac80211
1397 * won't execute the restart.
1398 * But make sure to cleanup interfaces that have gone down before/during
1399 * HW restart was requested.
1401 if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) ||
1402 test_and_clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
,
1404 ieee80211_iterate_interfaces(mvm
->hw
, 0,
1405 iwl_mvm_cleanup_iterator
, mvm
);
1407 /* We shouldn't have any UIDs still set. Loop over all the UIDs to
1408 * make sure there's nothing left there and warn if any is found.
1410 if (fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_UMAC_SCAN
)) {
1413 for (i
= 0; i
< mvm
->max_scans
; i
++) {
1414 if (WARN_ONCE(mvm
->scan_uid_status
[i
],
1415 "UMAC scan UID %d status was not cleaned\n",
1417 mvm
->scan_uid_status
[i
] = 0;
1422 void iwl_mvm_mac_stop(struct ieee80211_hw
*hw
, bool suspend
)
1424 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1426 /* Stop internal MLO scan, if running */
1427 mutex_lock(&mvm
->mutex
);
1428 iwl_mvm_scan_stop(mvm
, IWL_MVM_SCAN_INT_MLO
, false);
1429 mutex_unlock(&mvm
->mutex
);
1431 wiphy_work_cancel(mvm
->hw
->wiphy
, &mvm
->trig_link_selection_wk
);
1432 wiphy_work_flush(mvm
->hw
->wiphy
, &mvm
->async_handlers_wiphy_wk
);
1433 flush_work(&mvm
->async_handlers_wk
);
1434 flush_work(&mvm
->add_stream_wk
);
1437 * Lock and clear the firmware running bit here already, so that
1438 * new commands coming in elsewhere, e.g. from debugfs, will not
1439 * be able to proceed. This is important here because one of those
1440 * debugfs files causes the firmware dump to be triggered, and if we
1441 * don't stop debugfs accesses before canceling that it could be
1442 * retriggered after we flush it but before we've cleared the bit.
1444 clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING
, &mvm
->status
);
1446 cancel_delayed_work_sync(&mvm
->cs_tx_unblock_dwork
);
1447 cancel_delayed_work_sync(&mvm
->scan_timeout_dwork
);
1450 * The work item could be running or queued if the
1451 * ROC time event stops just as we get here.
1453 flush_work(&mvm
->roc_done_wk
);
1455 iwl_mvm_mei_set_sw_rfkill_state(mvm
);
1457 mutex_lock(&mvm
->mutex
);
1458 __iwl_mvm_mac_stop(mvm
, suspend
);
1459 mutex_unlock(&mvm
->mutex
);
1462 * The worker might have been waiting for the mutex, let it run and
1463 * discover that its list is now empty.
1465 cancel_work_sync(&mvm
->async_handlers_wk
);
1466 wiphy_work_cancel(hw
->wiphy
, &mvm
->async_handlers_wiphy_wk
);
1469 struct iwl_mvm_phy_ctxt
*iwl_mvm_get_free_phy_ctxt(struct iwl_mvm
*mvm
)
1473 lockdep_assert_held(&mvm
->mutex
);
1475 for (i
= 0; i
< NUM_PHY_CTX
; i
++)
1476 if (!mvm
->phy_ctxts
[i
].ref
)
1477 return &mvm
->phy_ctxts
[i
];
1479 IWL_ERR(mvm
, "No available PHY context\n");
1483 int iwl_mvm_set_tx_power(struct iwl_mvm
*mvm
,
1484 struct ieee80211_bss_conf
*link_conf
,
1487 u32 cmd_id
= REDUCE_TX_POWER_CMD
;
1488 u32 mac_id
= iwl_mvm_vif_from_mac80211(link_conf
->vif
)->id
;
1490 struct iwl_dev_tx_power_cmd_v3_v8 cmd
= {
1491 .common
.set_mode
= cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC
),
1492 .common
.mac_context_id
= cpu_to_le32(mac_id
),
1494 struct iwl_dev_tx_power_cmd cmd_v9_v10
;
1495 u8 cmd_ver
= iwl_fw_lookup_cmd_ver(mvm
->fw
, cmd_id
, 3);
1496 u16 u_tx_power
= tx_power
== IWL_DEFAULT_MAX_TX_POWER
?
1497 IWL_DEV_MAX_TX_POWER
: 8 * tx_power
;
1498 void *cmd_data
= &cmd
;
1500 cmd
.common
.pwr_restriction
= cpu_to_le16(u_tx_power
);
1503 /* Those fields sit on the same place for v9 and v10 */
1504 cmd_v9_v10
.common
.set_mode
= cpu_to_le32(IWL_TX_POWER_MODE_SET_MAC
);
1505 cmd_v9_v10
.common
.mac_context_id
= cpu_to_le32(mac_id
);
1506 cmd_v9_v10
.common
.pwr_restriction
= cpu_to_le16(u_tx_power
);
1507 cmd_data
= &cmd_v9_v10
;
1511 len
= sizeof(cmd_v9_v10
.v10
);
1512 else if (cmd_ver
== 9)
1513 len
= sizeof(cmd_v9_v10
.v9
);
1514 else if (cmd_ver
== 8)
1515 len
= sizeof(cmd
.v8
);
1516 else if (cmd_ver
== 7)
1517 len
= sizeof(cmd
.v7
);
1518 else if (cmd_ver
== 6)
1519 len
= sizeof(cmd
.v6
);
1520 else if (fw_has_api(&mvm
->fw
->ucode_capa
,
1521 IWL_UCODE_TLV_API_REDUCE_TX_POWER
))
1522 len
= sizeof(cmd
.v5
);
1523 else if (fw_has_capa(&mvm
->fw
->ucode_capa
,
1524 IWL_UCODE_TLV_CAPA_TX_POWER_ACK
))
1525 len
= sizeof(cmd
.v4
);
1527 len
= sizeof(cmd
.v3
);
1529 /* all structs have the same common part, add its length */
1530 len
+= sizeof(cmd
.common
);
1533 len
+= sizeof(cmd
.per_band
);
1535 return iwl_mvm_send_cmd_pdu(mvm
, cmd_id
, 0, len
, cmd_data
);
1539 static void iwl_mvm_post_csa_tx(void *data
, struct ieee80211_sta
*sta
)
1541 struct ieee80211_hw
*hw
= data
;
1544 for (i
= 0; i
< ARRAY_SIZE(sta
->txq
); i
++) {
1545 struct iwl_mvm_txq
*mvmtxq
=
1546 iwl_mvm_txq_from_mac80211(sta
->txq
[i
]);
1548 clear_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA
, &mvmtxq
->state
);
1549 iwl_mvm_mac_itxq_xmit(hw
, sta
->txq
[i
]);
1553 int iwl_mvm_post_channel_switch(struct ieee80211_hw
*hw
,
1554 struct ieee80211_vif
*vif
,
1555 struct ieee80211_bss_conf
*link_conf
)
1557 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1558 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1561 mutex_lock(&mvm
->mutex
);
1563 if (vif
->type
== NL80211_IFTYPE_STATION
) {
1564 struct iwl_mvm_sta
*mvmsta
;
1565 unsigned int link_id
= link_conf
->link_id
;
1566 u8 ap_sta_id
= mvmvif
->link
[link_id
]->ap_sta_id
;
1568 mvmvif
->csa_bcn_pending
= false;
1569 mvmvif
->csa_blocks_tx
= false;
1570 mvmsta
= iwl_mvm_sta_from_staid_protected(mvm
, ap_sta_id
);
1572 if (WARN_ON(!mvmsta
)) {
1577 iwl_mvm_sta_modify_disable_tx(mvm
, mvmsta
, false);
1578 if (mvm
->mld_api_is_used
)
1579 iwl_mvm_mld_mac_ctxt_changed(mvm
, vif
, false);
1581 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
1583 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
1584 IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD
)) {
1585 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
);
1589 iwl_mvm_stop_session_protection(mvm
, vif
);
1591 } else if (vif
->type
== NL80211_IFTYPE_AP
&& mvmvif
->csa_blocks_tx
) {
1592 struct iwl_mvm_txq
*mvmtxq
=
1593 iwl_mvm_txq_from_mac80211(vif
->txq
);
1595 clear_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA
, &mvmtxq
->state
);
1598 iwl_mvm_mac_itxq_xmit(hw
, vif
->txq
);
1599 ieee80211_iterate_stations_atomic(hw
, iwl_mvm_post_csa_tx
, hw
);
1602 mvmvif
->csa_blocks_tx
= false;
1605 mvmvif
->ps_disabled
= false;
1607 ret
= iwl_mvm_power_update_ps(mvm
);
1610 if (mvmvif
->csa_failed
)
1612 mutex_unlock(&mvm
->mutex
);
1617 void iwl_mvm_abort_channel_switch(struct ieee80211_hw
*hw
,
1618 struct ieee80211_vif
*vif
,
1619 struct ieee80211_bss_conf
*link_conf
)
1621 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1622 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1623 struct iwl_chan_switch_te_cmd cmd
= {
1624 .mac_id
= cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif
->id
,
1626 .action
= cpu_to_le32(FW_CTXT_ACTION_REMOVE
),
1630 * In the new flow since FW is in charge of the timing,
1631 * if driver has canceled the channel switch he will receive the
1632 * CHANNEL_SWITCH_START_NOTIF notification from FW and then cancel it
1634 if (iwl_fw_lookup_notif_ver(mvm
->fw
, MAC_CONF_GROUP
,
1635 CHANNEL_SWITCH_ERROR_NOTIF
, 0))
1638 IWL_DEBUG_MAC80211(mvm
, "Abort CSA on mac %d\n", mvmvif
->id
);
1640 mutex_lock(&mvm
->mutex
);
1641 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
1642 IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD
))
1643 iwl_mvm_remove_csa_period(mvm
, vif
);
1645 WARN_ON(iwl_mvm_send_cmd_pdu(mvm
,
1646 WIDE_ID(MAC_CONF_GROUP
,
1647 CHANNEL_SWITCH_TIME_EVENT_CMD
),
1648 0, sizeof(cmd
), &cmd
));
1649 mvmvif
->csa_failed
= true;
1650 mutex_unlock(&mvm
->mutex
);
1652 /* If we're here, we can't support MLD */
1653 iwl_mvm_post_channel_switch(hw
, vif
, &vif
->bss_conf
);
1656 void iwl_mvm_channel_switch_disconnect_wk(struct work_struct
*wk
)
1658 struct iwl_mvm_vif
*mvmvif
;
1659 struct ieee80211_vif
*vif
;
1661 mvmvif
= container_of(wk
, struct iwl_mvm_vif
, csa_work
.work
);
1662 vif
= container_of((void *)mvmvif
, struct ieee80211_vif
, drv_priv
);
1664 /* Trigger disconnect (should clear the CSA state) */
1665 ieee80211_chswitch_done(vif
, false, 0);
1669 iwl_mvm_chandef_get_primary_80(struct cfg80211_chan_def
*chandef
)
1675 if (chandef
->width
== NL80211_CHAN_WIDTH_320
)
1677 else if (chandef
->width
== NL80211_CHAN_WIDTH_160
)
1682 /* data is bw wide so the start is half the width */
1683 data_start
= chandef
->center_freq1
- bw
/ 2;
1684 /* control is 20Mhz width */
1685 control_start
= chandef
->chan
->center_freq
- 10;
1687 return (control_start
- data_start
) / 80;
1690 static int iwl_mvm_alloc_bcast_mcast_sta(struct iwl_mvm
*mvm
,
1691 struct ieee80211_vif
*vif
)
1693 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1696 lockdep_assert_held(&mvm
->mutex
);
1698 ret
= iwl_mvm_alloc_bcast_sta(mvm
, vif
);
1700 IWL_ERR(mvm
, "Failed to allocate bcast sta\n");
1704 /* Only queue for this station is the mcast queue,
1705 * which shouldn't be in TFD mask anyway
1707 return iwl_mvm_allocate_int_sta(mvm
, &mvmvif
->deflink
.mcast_sta
, 0,
1712 static void iwl_mvm_prevent_esr_done_wk(struct wiphy
*wiphy
,
1713 struct wiphy_work
*wk
)
1715 struct iwl_mvm_vif
*mvmvif
=
1716 container_of(wk
, struct iwl_mvm_vif
, prevent_esr_done_wk
.work
);
1717 struct iwl_mvm
*mvm
= mvmvif
->mvm
;
1718 struct ieee80211_vif
*vif
=
1719 container_of((void *)mvmvif
, struct ieee80211_vif
, drv_priv
);
1722 iwl_mvm_unblock_esr(mvm
, vif
, IWL_MVM_ESR_BLOCKED_PREVENTION
);
1725 static void iwl_mvm_mlo_int_scan_wk(struct wiphy
*wiphy
, struct wiphy_work
*wk
)
1727 struct iwl_mvm_vif
*mvmvif
= container_of(wk
, struct iwl_mvm_vif
,
1728 mlo_int_scan_wk
.work
);
1729 struct ieee80211_vif
*vif
=
1730 container_of((void *)mvmvif
, struct ieee80211_vif
, drv_priv
);
1732 guard(mvm
)(mvmvif
->mvm
);
1733 iwl_mvm_int_mlo_scan(mvmvif
->mvm
, vif
);
1736 static void iwl_mvm_unblock_esr_tpt(struct wiphy
*wiphy
, struct wiphy_work
*wk
)
1738 struct iwl_mvm_vif
*mvmvif
=
1739 container_of(wk
, struct iwl_mvm_vif
, unblock_esr_tpt_wk
);
1740 struct iwl_mvm
*mvm
= mvmvif
->mvm
;
1741 struct ieee80211_vif
*vif
=
1742 container_of((void *)mvmvif
, struct ieee80211_vif
, drv_priv
);
1745 iwl_mvm_unblock_esr(mvm
, vif
, IWL_MVM_ESR_BLOCKED_TPT
);
1748 static void iwl_mvm_unblock_esr_tmp_non_bss(struct wiphy
*wiphy
,
1749 struct wiphy_work
*wk
)
1751 struct iwl_mvm_vif
*mvmvif
=
1752 container_of(wk
, struct iwl_mvm_vif
,
1753 unblock_esr_tmp_non_bss_wk
.work
);
1754 struct iwl_mvm
*mvm
= mvmvif
->mvm
;
1755 struct ieee80211_vif
*vif
=
1756 container_of((void *)mvmvif
, struct ieee80211_vif
, drv_priv
);
1758 mutex_lock(&mvm
->mutex
);
1759 iwl_mvm_unblock_esr(mvm
, vif
, IWL_MVM_ESR_BLOCKED_TMP_NON_BSS
);
1760 mutex_unlock(&mvm
->mutex
);
1763 void iwl_mvm_mac_init_mvmvif(struct iwl_mvm
*mvm
, struct iwl_mvm_vif
*mvmvif
)
1765 lockdep_assert_held(&mvm
->mutex
);
1767 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
1770 INIT_DELAYED_WORK(&mvmvif
->csa_work
,
1771 iwl_mvm_channel_switch_disconnect_wk
);
1773 wiphy_delayed_work_init(&mvmvif
->prevent_esr_done_wk
,
1774 iwl_mvm_prevent_esr_done_wk
);
1776 wiphy_delayed_work_init(&mvmvif
->mlo_int_scan_wk
,
1777 iwl_mvm_mlo_int_scan_wk
);
1779 wiphy_work_init(&mvmvif
->unblock_esr_tpt_wk
,
1780 iwl_mvm_unblock_esr_tpt
);
1782 wiphy_delayed_work_init(&mvmvif
->unblock_esr_tmp_non_bss_wk
,
1783 iwl_mvm_unblock_esr_tmp_non_bss
);
1786 static int iwl_mvm_mac_add_interface(struct ieee80211_hw
*hw
,
1787 struct ieee80211_vif
*vif
)
1789 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1790 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1794 mutex_lock(&mvm
->mutex
);
1796 iwl_mvm_mac_init_mvmvif(mvm
, mvmvif
);
1800 /* the first link always points to the default one */
1801 mvmvif
->deflink
.fw_link_id
= IWL_MVM_FW_LINK_ID_INVALID
;
1802 mvmvif
->deflink
.active
= 0;
1803 mvmvif
->link
[0] = &mvmvif
->deflink
;
1805 ret
= iwl_mvm_set_link_mapping(mvm
, vif
, &vif
->bss_conf
);
1810 * Not much to do here. The stack will not allow interface
1811 * types or combinations that we didn't advertise, so we
1812 * don't really have to check the types.
1815 /* make sure that beacon statistics don't go backwards with FW reset */
1816 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
1817 for_each_mvm_vif_valid_link(mvmvif
, i
)
1818 mvmvif
->link
[i
]->beacon_stats
.accu_num_beacons
+=
1819 mvmvif
->link
[i
]->beacon_stats
.num_beacons
;
1821 /* Allocate resources for the MAC context, and add it to the fw */
1822 ret
= iwl_mvm_mac_ctxt_init(mvm
, vif
);
1826 rcu_assign_pointer(mvm
->vif_id_to_mac
[mvmvif
->id
], vif
);
1828 /* Currently not much to do for NAN */
1829 if (vif
->type
== NL80211_IFTYPE_NAN
) {
1835 * The AP binding flow can be done only after the beacon
1836 * template is configured (which happens only in the mac80211
1837 * start_ap() flow), and adding the broadcast station can happen
1838 * only after the binding.
1839 * In addition, since modifying the MAC before adding a bcast
1840 * station is not allowed by the FW, delay the adding of MAC context to
1841 * the point where we can also add the bcast station.
1842 * In short: there's not much we can do at this point, other than
1843 * allocating resources :)
1845 if (vif
->type
== NL80211_IFTYPE_AP
||
1846 vif
->type
== NL80211_IFTYPE_ADHOC
) {
1847 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
1848 iwl_mvm_vif_dbgfs_add_link(mvm
, vif
);
1853 mvmvif
->features
|= hw
->netdev_features
;
1855 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
1859 ret
= iwl_mvm_power_update_mac(mvm
);
1861 goto out_remove_mac
;
1863 /* beacon filtering */
1864 ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
);
1866 goto out_remove_mac
;
1868 if (!mvm
->bf_allowed_vif
&&
1869 vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
) {
1870 mvm
->bf_allowed_vif
= mvmvif
;
1871 vif
->driver_flags
|= IEEE80211_VIF_BEACON_FILTER
|
1872 IEEE80211_VIF_SUPPORTS_CQM_RSSI
;
1875 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
)
1876 mvm
->p2p_device_vif
= vif
;
1878 iwl_mvm_tcm_add_vif(mvm
, vif
);
1880 if (vif
->type
== NL80211_IFTYPE_MONITOR
) {
1881 mvm
->monitor_on
= true;
1883 iwl_mvm_chandef_get_primary_80(&vif
->bss_conf
.chanreq
.oper
);
1886 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
1887 iwl_mvm_vif_dbgfs_add_link(mvm
, vif
);
1889 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) &&
1890 vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
&&
1891 !mvm
->csme_vif
&& mvm
->mei_registered
) {
1892 iwl_mei_set_nic_info(vif
->addr
, mvm
->nvm_data
->hw_addr
);
1893 iwl_mei_set_netdev(ieee80211_vif_to_wdev(vif
)->netdev
);
1894 mvm
->csme_vif
= vif
;
1898 if (!ret
&& (vif
->type
== NL80211_IFTYPE_AP
||
1899 vif
->type
== NL80211_IFTYPE_ADHOC
))
1900 ret
= iwl_mvm_alloc_bcast_mcast_sta(mvm
, vif
);
1905 mvmvif
->deflink
.phy_ctxt
= NULL
;
1906 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1908 mutex_unlock(&mvm
->mutex
);
1913 void iwl_mvm_prepare_mac_removal(struct iwl_mvm
*mvm
,
1914 struct ieee80211_vif
*vif
)
1916 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1918 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1920 * Flush the ROC worker which will flush the OFFCHANNEL queue.
1921 * We assume here that all the packets sent to the OFFCHANNEL
1922 * queue are sent in ROC session.
1924 flush_work(&mvm
->roc_done_wk
);
1927 wiphy_delayed_work_cancel(mvm
->hw
->wiphy
,
1928 &mvmvif
->prevent_esr_done_wk
);
1930 wiphy_delayed_work_cancel(mvm
->hw
->wiphy
,
1931 &mvmvif
->mlo_int_scan_wk
);
1933 wiphy_work_cancel(mvm
->hw
->wiphy
, &mvmvif
->unblock_esr_tpt_wk
);
1934 wiphy_delayed_work_cancel(mvm
->hw
->wiphy
,
1935 &mvmvif
->unblock_esr_tmp_non_bss_wk
);
1937 cancel_delayed_work_sync(&mvmvif
->csa_work
);
1940 static void iwl_mvm_mac_remove_interface(struct ieee80211_hw
*hw
,
1941 struct ieee80211_vif
*vif
)
1943 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1944 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1945 struct iwl_probe_resp_data
*probe_data
;
1947 iwl_mvm_prepare_mac_removal(mvm
, vif
);
1949 if (!(vif
->type
== NL80211_IFTYPE_AP
||
1950 vif
->type
== NL80211_IFTYPE_ADHOC
))
1951 iwl_mvm_tcm_rm_vif(mvm
, vif
);
1953 mutex_lock(&mvm
->mutex
);
1955 if (vif
== mvm
->csme_vif
) {
1956 iwl_mei_set_netdev(NULL
);
1957 mvm
->csme_vif
= NULL
;
1960 probe_data
= rcu_dereference_protected(mvmvif
->deflink
.probe_resp_data
,
1961 lockdep_is_held(&mvm
->mutex
));
1962 RCU_INIT_POINTER(mvmvif
->deflink
.probe_resp_data
, NULL
);
1964 kfree_rcu(probe_data
, rcu_head
);
1966 if (mvm
->bf_allowed_vif
== mvmvif
) {
1967 mvm
->bf_allowed_vif
= NULL
;
1968 vif
->driver_flags
&= ~(IEEE80211_VIF_BEACON_FILTER
|
1969 IEEE80211_VIF_SUPPORTS_CQM_RSSI
);
1972 if (vif
->bss_conf
.ftm_responder
)
1973 memset(&mvm
->ftm_resp_stats
, 0, sizeof(mvm
->ftm_resp_stats
));
1975 iwl_mvm_vif_dbgfs_rm_link(mvm
, vif
);
1978 * For AP/GO interface, the tear down of the resources allocated to the
1979 * interface is be handled as part of the stop_ap flow.
1981 if (vif
->type
== NL80211_IFTYPE_AP
||
1982 vif
->type
== NL80211_IFTYPE_ADHOC
) {
1983 #ifdef CONFIG_NL80211_TESTMODE
1984 if (vif
== mvm
->noa_vif
) {
1985 mvm
->noa_vif
= NULL
;
1986 mvm
->noa_duration
= 0;
1992 iwl_mvm_power_update_mac(mvm
);
1994 /* Before the interface removal, mac80211 would cancel the ROC, and the
1995 * ROC worker would be scheduled if needed. The worker would be flushed
1996 * in iwl_mvm_prepare_mac_removal() and thus at this point there is no
1997 * binding etc. so nothing needs to be done here.
1999 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
2000 if (mvmvif
->deflink
.phy_ctxt
) {
2001 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->deflink
.phy_ctxt
);
2002 mvmvif
->deflink
.phy_ctxt
= NULL
;
2004 mvm
->p2p_device_vif
= NULL
;
2007 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
2009 RCU_INIT_POINTER(mvm
->vif_id_to_mac
[mvmvif
->id
], NULL
);
2011 if (vif
->type
== NL80211_IFTYPE_MONITOR
)
2012 mvm
->monitor_on
= false;
2015 iwl_mvm_unset_link_mapping(mvm
, vif
, &vif
->bss_conf
);
2016 if (vif
->type
== NL80211_IFTYPE_AP
||
2017 vif
->type
== NL80211_IFTYPE_ADHOC
) {
2018 iwl_mvm_dealloc_int_sta(mvm
, &mvmvif
->deflink
.mcast_sta
);
2019 iwl_mvm_dealloc_bcast_sta(mvm
, vif
);
2022 mutex_unlock(&mvm
->mutex
);
2025 struct iwl_mvm_mc_iter_data
{
2026 struct iwl_mvm
*mvm
;
2030 static void iwl_mvm_mc_iface_iterator(void *_data
, u8
*mac
,
2031 struct ieee80211_vif
*vif
)
2033 struct iwl_mvm_mc_iter_data
*data
= _data
;
2034 struct iwl_mvm
*mvm
= data
->mvm
;
2035 struct iwl_mcast_filter_cmd
*cmd
= mvm
->mcast_filter_cmd
;
2036 struct iwl_host_cmd hcmd
= {
2037 .id
= MCAST_FILTER_CMD
,
2039 .dataflags
[0] = IWL_HCMD_DFL_NOCOPY
,
2043 /* if we don't have free ports, mcast frames will be dropped */
2044 if (WARN_ON_ONCE(data
->port_id
>= MAX_PORT_ID_NUM
))
2047 if (vif
->type
!= NL80211_IFTYPE_STATION
||
2051 cmd
->port_id
= data
->port_id
++;
2052 memcpy(cmd
->bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
2053 len
= roundup(sizeof(*cmd
) + cmd
->count
* ETH_ALEN
, 4);
2058 ret
= iwl_mvm_send_cmd(mvm
, &hcmd
);
2060 IWL_ERR(mvm
, "mcast filter cmd error. ret=%d\n", ret
);
2063 static void iwl_mvm_recalc_multicast(struct iwl_mvm
*mvm
)
2065 struct iwl_mvm_mc_iter_data iter_data
= {
2070 lockdep_assert_held(&mvm
->mutex
);
2072 if (WARN_ON_ONCE(!mvm
->mcast_filter_cmd
))
2075 ieee80211_iterate_active_interfaces_atomic(
2076 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
2077 iwl_mvm_mc_iface_iterator
, &iter_data
);
2080 * Send a (synchronous) ech command so that we wait for the
2081 * multiple asynchronous MCAST_FILTER_CMD commands sent by
2082 * the interface iterator. Otherwise, we might get here over
2083 * and over again (by userspace just sending a lot of these)
2084 * and the CPU can send them faster than the firmware can
2086 * Note that the CPU is still faster - but with this we'll
2087 * actually send fewer commands overall because the CPU will
2088 * not schedule the work in mac80211 as frequently if it's
2089 * still running when rescheduled (possibly multiple times).
2091 ret
= iwl_mvm_send_cmd_pdu(mvm
, ECHO_CMD
, 0, 0, NULL
);
2093 IWL_ERR(mvm
, "Failed to synchronize multicast groups update\n");
2096 u64
iwl_mvm_prepare_multicast(struct ieee80211_hw
*hw
,
2097 struct netdev_hw_addr_list
*mc_list
)
2099 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2100 struct iwl_mcast_filter_cmd
*cmd
;
2101 struct netdev_hw_addr
*addr
;
2106 addr_count
= netdev_hw_addr_list_count(mc_list
);
2107 pass_all
= addr_count
> MAX_MCAST_FILTERING_ADDRESSES
||
2108 IWL_MVM_FW_MCAST_FILTER_PASS_ALL
;
2112 len
= roundup(sizeof(*cmd
) + addr_count
* ETH_ALEN
, 4);
2113 cmd
= kzalloc(len
, GFP_ATOMIC
);
2119 return (u64
)(unsigned long)cmd
;
2122 netdev_hw_addr_list_for_each(addr
, mc_list
) {
2123 IWL_DEBUG_MAC80211(mvm
, "mcast addr (%d): %pM\n",
2124 cmd
->count
, addr
->addr
);
2125 memcpy(&cmd
->addr_list
[cmd
->count
* ETH_ALEN
],
2126 addr
->addr
, ETH_ALEN
);
2130 return (u64
)(unsigned long)cmd
;
2133 void iwl_mvm_configure_filter(struct ieee80211_hw
*hw
,
2134 unsigned int changed_flags
,
2135 unsigned int *total_flags
, u64 multicast
)
2137 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2138 struct iwl_mcast_filter_cmd
*cmd
= (void *)(unsigned long)multicast
;
2142 /* replace previous configuration */
2143 kfree(mvm
->mcast_filter_cmd
);
2144 mvm
->mcast_filter_cmd
= cmd
;
2149 if (changed_flags
& FIF_ALLMULTI
)
2150 cmd
->pass_all
= !!(*total_flags
& FIF_ALLMULTI
);
2155 iwl_mvm_recalc_multicast(mvm
);
2160 static void iwl_mvm_config_iface_filter(struct ieee80211_hw
*hw
,
2161 struct ieee80211_vif
*vif
,
2162 unsigned int filter_flags
,
2163 unsigned int changed_flags
)
2165 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2167 /* We support only filter for probe requests */
2168 if (!(changed_flags
& FIF_PROBE_REQ
))
2171 /* Supported only for p2p client interfaces */
2172 if (vif
->type
!= NL80211_IFTYPE_STATION
|| !vif
->cfg
.assoc
||
2177 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
2180 int iwl_mvm_update_mu_groups(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
2182 struct iwl_mu_group_mgmt_cmd cmd
= {};
2184 memcpy(cmd
.membership_status
, vif
->bss_conf
.mu_group
.membership
,
2185 WLAN_MEMBERSHIP_LEN
);
2186 memcpy(cmd
.user_position
, vif
->bss_conf
.mu_group
.position
,
2187 WLAN_USER_POSITION_LEN
);
2189 return iwl_mvm_send_cmd_pdu(mvm
,
2190 WIDE_ID(DATA_PATH_GROUP
,
2191 UPDATE_MU_GROUPS_CMD
),
2192 0, sizeof(cmd
), &cmd
);
2195 static void iwl_mvm_mu_mimo_iface_iterator(void *_data
, u8
*mac
,
2196 struct ieee80211_vif
*vif
)
2198 if (vif
->bss_conf
.mu_mimo_owner
) {
2199 struct iwl_mu_group_mgmt_notif
*notif
= _data
;
2202 * MU-MIMO Group Id action frame is little endian. We treat
2203 * the data received from firmware as if it came from the
2204 * action frame, so no conversion is needed.
2206 ieee80211_update_mu_groups(vif
, 0,
2207 (u8
*)¬if
->membership_status
,
2208 (u8
*)¬if
->user_position
);
2212 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm
*mvm
,
2213 struct iwl_rx_cmd_buffer
*rxb
)
2215 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
2216 struct iwl_mu_group_mgmt_notif
*notif
= (void *)pkt
->data
;
2218 ieee80211_iterate_active_interfaces_atomic(
2219 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
2220 iwl_mvm_mu_mimo_iface_iterator
, notif
);
2223 static u8
iwl_mvm_he_get_ppe_val(u8
*ppe
, u8 ppe_pos_bit
)
2225 u8 byte_num
= ppe_pos_bit
/ 8;
2226 u8 bit_num
= ppe_pos_bit
% 8;
2231 return (ppe
[byte_num
] >> bit_num
) &
2232 (BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE
) - 1);
2235 * If bit_num > 5, we have to combine bits with next byte.
2236 * Calculate how many bits we need to take from current byte (called
2237 * here "residue_bits"), and add them to bits from next byte.
2240 residue_bits
= 8 - bit_num
;
2242 res
= (ppe
[byte_num
+ 1] &
2243 (BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE
- residue_bits
) - 1)) <<
2245 res
+= (ppe
[byte_num
] >> bit_num
) & (BIT(residue_bits
) - 1);
2250 static void iwl_mvm_parse_ppe(struct iwl_mvm
*mvm
,
2251 struct iwl_he_pkt_ext_v2
*pkt_ext
, u8 nss
,
2252 u8 ru_index_bitmap
, u8
*ppe
, u8 ppe_pos_bit
,
2258 * FW currently supports only nss == MAX_HE_SUPP_NSS
2260 * If nss > MAX: we can ignore values we don't support
2261 * If nss < MAX: we can set zeros in other streams
2263 if (nss
> MAX_HE_SUPP_NSS
) {
2264 IWL_DEBUG_INFO(mvm
, "Got NSS = %d - trimming to %d\n", nss
,
2266 nss
= MAX_HE_SUPP_NSS
;
2269 for (i
= 0; i
< nss
; i
++) {
2270 u8 ru_index_tmp
= ru_index_bitmap
<< 1;
2271 u8 low_th
= IWL_HE_PKT_EXT_NONE
, high_th
= IWL_HE_PKT_EXT_NONE
;
2275 bw
< ARRAY_SIZE(pkt_ext
->pkt_ext_qam_th
[i
]);
2280 * According to the 11be spec, if for a specific BW the PPE Thresholds
2281 * isn't present - it should inherit the thresholds from the last
2282 * BW for which we had PPE Thresholds. In 11ax though, we don't have
2283 * this inheritance - continue in this case
2285 if (!(ru_index_tmp
& 1)) {
2287 goto set_thresholds
;
2292 high_th
= iwl_mvm_he_get_ppe_val(ppe
, ppe_pos_bit
);
2293 ppe_pos_bit
+= IEEE80211_PPE_THRES_INFO_PPET_SIZE
;
2294 low_th
= iwl_mvm_he_get_ppe_val(ppe
, ppe_pos_bit
);
2295 ppe_pos_bit
+= IEEE80211_PPE_THRES_INFO_PPET_SIZE
;
2298 pkt_ext
->pkt_ext_qam_th
[i
][bw
][0] = low_th
;
2299 pkt_ext
->pkt_ext_qam_th
[i
][bw
][1] = high_th
;
2304 static void iwl_mvm_set_pkt_ext_from_he_ppe(struct iwl_mvm
*mvm
,
2305 struct ieee80211_link_sta
*link_sta
,
2306 struct iwl_he_pkt_ext_v2
*pkt_ext
,
2309 u8 nss
= (link_sta
->he_cap
.ppe_thres
[0] &
2310 IEEE80211_PPE_THRES_NSS_MASK
) + 1;
2311 u8
*ppe
= &link_sta
->he_cap
.ppe_thres
[0];
2312 u8 ru_index_bitmap
=
2314 IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK
);
2315 /* Starting after PPE header */
2316 u8 ppe_pos_bit
= IEEE80211_HE_PPE_THRES_INFO_HEADER_SIZE
;
2318 iwl_mvm_parse_ppe(mvm
, pkt_ext
, nss
, ru_index_bitmap
, ppe
, ppe_pos_bit
,
2323 iwl_mvm_set_pkt_ext_from_nominal_padding(struct iwl_he_pkt_ext_v2
*pkt_ext
,
2330 /* all the macros are the same for EHT and HE */
2331 switch (nominal_padding
) {
2332 case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_0US
:
2333 low_th
= IWL_HE_PKT_EXT_NONE
;
2334 high_th
= IWL_HE_PKT_EXT_NONE
;
2336 case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US
:
2337 low_th
= IWL_HE_PKT_EXT_BPSK
;
2338 high_th
= IWL_HE_PKT_EXT_NONE
;
2340 case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_16US
:
2341 case IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_20US
:
2342 low_th
= IWL_HE_PKT_EXT_NONE
;
2343 high_th
= IWL_HE_PKT_EXT_BPSK
;
2347 if (low_th
< 0 || high_th
< 0)
2350 /* Set the PPE thresholds accordingly */
2351 for (i
= 0; i
< MAX_HE_SUPP_NSS
; i
++) {
2355 bw
< ARRAY_SIZE(pkt_ext
->pkt_ext_qam_th
[i
]);
2357 pkt_ext
->pkt_ext_qam_th
[i
][bw
][0] = low_th
;
2358 pkt_ext
->pkt_ext_qam_th
[i
][bw
][1] = high_th
;
2365 static void iwl_mvm_get_optimal_ppe_info(struct iwl_he_pkt_ext_v2
*pkt_ext
,
2370 for (i
= 0; i
< MAX_HE_SUPP_NSS
; i
++) {
2373 for (bw
= 0; bw
< ARRAY_SIZE(pkt_ext
->pkt_ext_qam_th
[i
]);
2375 u8
*qam_th
= &pkt_ext
->pkt_ext_qam_th
[i
][bw
][0];
2377 if (nominal_padding
>
2378 IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US
&&
2379 qam_th
[1] == IWL_HE_PKT_EXT_NONE
)
2380 qam_th
[1] = IWL_HE_PKT_EXT_4096QAM
;
2381 else if (nominal_padding
==
2382 IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_8US
&&
2383 qam_th
[0] == IWL_HE_PKT_EXT_NONE
&&
2384 qam_th
[1] == IWL_HE_PKT_EXT_NONE
)
2385 qam_th
[0] = IWL_HE_PKT_EXT_4096QAM
;
2390 /* Set the pkt_ext field according to PPE Thresholds element */
2391 int iwl_mvm_set_sta_pkt_ext(struct iwl_mvm
*mvm
,
2392 struct ieee80211_link_sta
*link_sta
,
2393 struct iwl_he_pkt_ext_v2
*pkt_ext
)
2398 if (WARN_ON(!link_sta
))
2401 /* Initialize the PPE thresholds to "None" (7), as described in Table
2402 * 9-262ac of 80211.ax/D3.0.
2404 memset(pkt_ext
, IWL_HE_PKT_EXT_NONE
,
2405 sizeof(struct iwl_he_pkt_ext_v2
));
2407 if (link_sta
->eht_cap
.has_eht
) {
2409 u8_get_bits(link_sta
->eht_cap
.eht_cap_elem
.phy_cap_info
[5],
2410 IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK
);
2412 /* If PPE Thresholds exists, parse them into a FW-familiar
2415 if (link_sta
->eht_cap
.eht_cap_elem
.phy_cap_info
[5] &
2416 IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT
) {
2417 u8 nss
= (link_sta
->eht_cap
.eht_ppe_thres
[0] &
2418 IEEE80211_EHT_PPE_THRES_NSS_MASK
) + 1;
2419 u8
*ppe
= &link_sta
->eht_cap
.eht_ppe_thres
[0];
2420 u8 ru_index_bitmap
=
2422 IEEE80211_EHT_PPE_THRES_RU_INDEX_BITMASK_MASK
);
2423 /* Starting after PPE header */
2424 u8 ppe_pos_bit
= IEEE80211_EHT_PPE_THRES_INFO_HEADER_SIZE
;
2426 iwl_mvm_parse_ppe(mvm
, pkt_ext
, nss
, ru_index_bitmap
,
2427 ppe
, ppe_pos_bit
, true);
2428 /* EHT PPE Thresholds doesn't exist - set the API according to
2431 } else if (link_sta
->he_cap
.he_cap_elem
.phy_cap_info
[6] &
2432 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT
) {
2433 /* Even though HE Capabilities IE doesn't contain PPE
2434 * Thresholds for BW 320Mhz, thresholds for this BW will
2435 * be filled in with the same values as 160Mhz, due to
2436 * the inheritance, as required.
2438 iwl_mvm_set_pkt_ext_from_he_ppe(mvm
, link_sta
, pkt_ext
,
2441 /* According to the requirements, for MCSs 12-13 the
2442 * maximum value between HE PPE Threshold and Common
2443 * Nominal Packet Padding needs to be taken
2445 iwl_mvm_get_optimal_ppe_info(pkt_ext
, nominal_padding
);
2447 /* if PPE Thresholds doesn't present in both EHT IE and HE IE -
2448 * take the Thresholds from Common Nominal Packet Padding field
2451 ret
= iwl_mvm_set_pkt_ext_from_nominal_padding(pkt_ext
,
2454 } else if (link_sta
->he_cap
.has_he
) {
2455 /* If PPE Thresholds exist, parse them into a FW-familiar format. */
2456 if (link_sta
->he_cap
.he_cap_elem
.phy_cap_info
[6] &
2457 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT
) {
2458 iwl_mvm_set_pkt_ext_from_he_ppe(mvm
, link_sta
, pkt_ext
,
2460 /* PPE Thresholds doesn't exist - set the API PPE values
2461 * according to Common Nominal Packet Padding field.
2465 u8_get_bits(link_sta
->he_cap
.he_cap_elem
.phy_cap_info
[9],
2466 IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_MASK
);
2467 if (nominal_padding
!= IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_RESERVED
)
2468 ret
= iwl_mvm_set_pkt_ext_from_nominal_padding(pkt_ext
,
2473 for (i
= 0; i
< MAX_HE_SUPP_NSS
; i
++) {
2477 bw
< ARRAY_SIZE(*pkt_ext
->pkt_ext_qam_th
[i
]);
2480 &pkt_ext
->pkt_ext_qam_th
[i
][bw
][0];
2483 "PPE table: nss[%d] bw[%d] PPET8 = %d, PPET16 = %d\n",
2484 i
, bw
, qam_th
[0], qam_th
[1]);
2491 * This function sets the MU EDCA parameters ans returns whether MU EDCA
2494 bool iwl_mvm_set_fw_mu_edca_params(struct iwl_mvm
*mvm
,
2495 const struct iwl_mvm_vif_link_info
*link_info
,
2496 struct iwl_he_backoff_conf
*trig_based_txf
)
2499 /* Mark MU EDCA as enabled, unless none detected on some AC */
2500 bool mu_edca_enabled
= true;
2502 for (i
= 0; i
< IEEE80211_NUM_ACS
; i
++) {
2503 const struct ieee80211_he_mu_edca_param_ac_rec
*mu_edca
=
2504 &link_info
->queue_params
[i
].mu_edca_param_rec
;
2505 u8 ac
= iwl_mvm_mac80211_ac_to_ucode_ac(i
);
2507 if (!link_info
->queue_params
[i
].mu_edca
) {
2508 mu_edca_enabled
= false;
2512 trig_based_txf
[ac
].cwmin
=
2513 cpu_to_le16(mu_edca
->ecw_min_max
& 0xf);
2514 trig_based_txf
[ac
].cwmax
=
2515 cpu_to_le16((mu_edca
->ecw_min_max
& 0xf0) >> 4);
2516 trig_based_txf
[ac
].aifsn
=
2517 cpu_to_le16(mu_edca
->aifsn
& 0xf);
2518 trig_based_txf
[ac
].mu_time
=
2519 cpu_to_le16(mu_edca
->mu_edca_timer
);
2522 return mu_edca_enabled
;
2525 bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
2527 const struct ieee80211_supported_band
*sband
;
2528 const struct ieee80211_sta_he_cap
*own_he_cap
= NULL
;
2530 /* This capability is the same for all bands,
2531 * so take it from one of them.
2533 sband
= mvm
->hw
->wiphy
->bands
[NL80211_BAND_2GHZ
];
2534 own_he_cap
= ieee80211_get_he_iftype_cap_vif(sband
, vif
);
2536 return (own_he_cap
&& (own_he_cap
->he_cap_elem
.mac_cap_info
[2] &
2537 IEEE80211_HE_MAC_CAP2_ACK_EN
));
2540 __le32
iwl_mvm_get_sta_htc_flags(struct ieee80211_sta
*sta
,
2541 struct ieee80211_link_sta
*link_sta
)
2544 &link_sta
->he_cap
.he_cap_elem
.mac_cap_info
[0];
2545 __le32 htc_flags
= 0;
2547 if (mac_cap_info
[0] & IEEE80211_HE_MAC_CAP0_HTC_HE
)
2548 htc_flags
|= cpu_to_le32(IWL_HE_HTC_SUPPORT
);
2549 if ((mac_cap_info
[1] & IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION
) ||
2550 (mac_cap_info
[2] & IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION
)) {
2553 IEEE80211_HE_MAC_CAP2_LINK_ADAPTATION
) << 1) +
2555 IEEE80211_HE_MAC_CAP1_LINK_ADAPTATION
);
2559 cpu_to_le32(IWL_HE_HTC_LINK_ADAP_UNSOLICITED
);
2560 else if (link_adap
== 3)
2561 htc_flags
|= cpu_to_le32(IWL_HE_HTC_LINK_ADAP_BOTH
);
2563 if (mac_cap_info
[2] & IEEE80211_HE_MAC_CAP2_BSR
)
2564 htc_flags
|= cpu_to_le32(IWL_HE_HTC_BSR_SUPP
);
2565 if (mac_cap_info
[3] & IEEE80211_HE_MAC_CAP3_OMI_CONTROL
)
2566 htc_flags
|= cpu_to_le32(IWL_HE_HTC_OMI_SUPP
);
2567 if (mac_cap_info
[4] & IEEE80211_HE_MAC_CAP4_BQR
)
2568 htc_flags
|= cpu_to_le32(IWL_HE_HTC_BQR_SUPP
);
2573 static void iwl_mvm_cfg_he_sta(struct iwl_mvm
*mvm
,
2574 struct ieee80211_vif
*vif
, u8 sta_id
)
2576 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2577 struct iwl_he_sta_context_cmd_v3 sta_ctxt_cmd
= {
2579 .tid_limit
= IWL_MAX_TID_COUNT
,
2580 .bss_color
= vif
->bss_conf
.he_bss_color
.color
,
2581 .htc_trig_based_pkt_ext
= vif
->bss_conf
.htc_trig_based_pkt_ext
,
2582 .frame_time_rts_th
=
2583 cpu_to_le16(vif
->bss_conf
.frame_time_rts_th
),
2585 struct iwl_he_sta_context_cmd_v2 sta_ctxt_cmd_v2
= {};
2586 u32 cmd_id
= WIDE_ID(DATA_PATH_GROUP
, STA_HE_CTXT_CMD
);
2587 u8 ver
= iwl_fw_lookup_cmd_ver(mvm
->fw
, cmd_id
, 2);
2589 struct ieee80211_sta
*sta
;
2594 if (!fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_MBSSID_HE
))
2599 /* same layout as v2 except some data at the end */
2600 cmd
= &sta_ctxt_cmd_v2
;
2601 size
= sizeof(struct iwl_he_sta_context_cmd_v1
);
2604 cmd
= &sta_ctxt_cmd_v2
;
2605 size
= sizeof(struct iwl_he_sta_context_cmd_v2
);
2608 cmd
= &sta_ctxt_cmd
;
2609 size
= sizeof(struct iwl_he_sta_context_cmd_v3
);
2612 IWL_ERR(mvm
, "bad STA_HE_CTXT_CMD version %d\n", ver
);
2618 sta
= rcu_dereference(mvm
->fw_id_to_mac_id
[sta_ctxt_cmd
.sta_id
]);
2619 if (IS_ERR_OR_NULL(sta
)) {
2621 WARN(1, "Can't find STA to configure HE\n");
2625 if (!sta
->deflink
.he_cap
.has_he
) {
2632 /* Block 26-tone RU OFDMA transmissions */
2633 if (mvmvif
->deflink
.he_ru_2mhz_block
)
2634 flags
|= STA_CTXT_HE_RU_2MHZ_BLOCK
;
2637 sta_ctxt_cmd
.htc_flags
= iwl_mvm_get_sta_htc_flags(sta
, &sta
->deflink
);
2639 /* PPE Thresholds */
2640 if (!iwl_mvm_set_sta_pkt_ext(mvm
, &sta
->deflink
, &sta_ctxt_cmd
.pkt_ext
))
2641 flags
|= STA_CTXT_HE_PACKET_EXT
;
2643 if (sta
->deflink
.he_cap
.he_cap_elem
.mac_cap_info
[2] &
2644 IEEE80211_HE_MAC_CAP2_32BIT_BA_BITMAP
)
2645 flags
|= STA_CTXT_HE_32BIT_BA_BITMAP
;
2647 if (sta
->deflink
.he_cap
.he_cap_elem
.mac_cap_info
[2] &
2648 IEEE80211_HE_MAC_CAP2_ACK_EN
)
2649 flags
|= STA_CTXT_HE_ACK_ENABLED
;
2653 if (iwl_mvm_set_fw_mu_edca_params(mvm
, &mvmvif
->deflink
,
2654 &sta_ctxt_cmd
.trig_based_txf
[0]))
2655 flags
|= STA_CTXT_HE_MU_EDCA_CW
;
2657 if (vif
->bss_conf
.uora_exists
) {
2658 flags
|= STA_CTXT_HE_TRIG_RND_ALLOC
;
2660 sta_ctxt_cmd
.rand_alloc_ecwmin
=
2661 vif
->bss_conf
.uora_ocw_range
& 0x7;
2662 sta_ctxt_cmd
.rand_alloc_ecwmax
=
2663 (vif
->bss_conf
.uora_ocw_range
>> 3) & 0x7;
2666 if (!iwl_mvm_is_nic_ack_enabled(mvm
, vif
))
2667 flags
|= STA_CTXT_HE_NIC_NOT_ACK_ENABLED
;
2669 if (vif
->bss_conf
.nontransmitted
) {
2670 flags
|= STA_CTXT_HE_REF_BSSID_VALID
;
2671 ether_addr_copy(sta_ctxt_cmd
.ref_bssid_addr
,
2672 vif
->bss_conf
.transmitter_bssid
);
2673 sta_ctxt_cmd
.max_bssid_indicator
=
2674 vif
->bss_conf
.bssid_indicator
;
2675 sta_ctxt_cmd
.bssid_index
= vif
->bss_conf
.bssid_index
;
2676 sta_ctxt_cmd
.ema_ap
= vif
->bss_conf
.ema_ap
;
2677 sta_ctxt_cmd
.profile_periodicity
=
2678 vif
->bss_conf
.profile_periodicity
;
2681 sta_ctxt_cmd
.flags
= cpu_to_le32(flags
);
2684 /* fields before pkt_ext */
2685 BUILD_BUG_ON(offsetof(typeof(sta_ctxt_cmd
), pkt_ext
) !=
2686 offsetof(typeof(sta_ctxt_cmd_v2
), pkt_ext
));
2687 memcpy(&sta_ctxt_cmd_v2
, &sta_ctxt_cmd
,
2688 offsetof(typeof(sta_ctxt_cmd
), pkt_ext
));
2692 i
< ARRAY_SIZE(sta_ctxt_cmd_v2
.pkt_ext
.pkt_ext_qam_th
);
2697 bw
< ARRAY_SIZE(sta_ctxt_cmd_v2
.pkt_ext
.pkt_ext_qam_th
[i
]);
2699 BUILD_BUG_ON(sizeof(sta_ctxt_cmd
.pkt_ext
.pkt_ext_qam_th
[i
][bw
]) !=
2700 sizeof(sta_ctxt_cmd_v2
.pkt_ext
.pkt_ext_qam_th
[i
][bw
]));
2702 memcpy(&sta_ctxt_cmd_v2
.pkt_ext
.pkt_ext_qam_th
[i
][bw
],
2703 &sta_ctxt_cmd
.pkt_ext
.pkt_ext_qam_th
[i
][bw
],
2704 sizeof(sta_ctxt_cmd
.pkt_ext
.pkt_ext_qam_th
[i
][bw
]));
2708 /* fields after pkt_ext */
2709 BUILD_BUG_ON(sizeof(sta_ctxt_cmd
) -
2710 offsetofend(typeof(sta_ctxt_cmd
), pkt_ext
) !=
2711 sizeof(sta_ctxt_cmd_v2
) -
2712 offsetofend(typeof(sta_ctxt_cmd_v2
), pkt_ext
));
2713 memcpy((u8
*)&sta_ctxt_cmd_v2
+
2714 offsetofend(typeof(sta_ctxt_cmd_v2
), pkt_ext
),
2715 (u8
*)&sta_ctxt_cmd
+
2716 offsetofend(typeof(sta_ctxt_cmd
), pkt_ext
),
2717 sizeof(sta_ctxt_cmd
) -
2718 offsetofend(typeof(sta_ctxt_cmd
), pkt_ext
));
2719 sta_ctxt_cmd_v2
.reserved3
= 0;
2722 if (iwl_mvm_send_cmd_pdu(mvm
, cmd_id
, 0, size
, cmd
))
2723 IWL_ERR(mvm
, "Failed to config FW to work HE!\n");
2726 void iwl_mvm_protect_assoc(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
2727 u32 duration_override
, unsigned int link_id
)
2729 u32 duration
= IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS
;
2730 u32 min_duration
= IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS
;
2732 if (duration_override
> duration
)
2733 duration
= duration_override
;
2735 /* Try really hard to protect the session and hear a beacon
2736 * The new session protection command allows us to protect the
2737 * session for a much longer time since the firmware will internally
2738 * create two events: a 300TU one with a very high priority that
2739 * won't be fragmented which should be enough for 99% of the cases,
2740 * and another one (which we configure here to be 900TU long) which
2741 * will have a slightly lower priority, but more importantly, can be
2742 * fragmented so that it'll allow other activities to run.
2744 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
2745 IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD
))
2746 iwl_mvm_schedule_session_protection(mvm
, vif
, 900,
2747 min_duration
, false,
2750 iwl_mvm_protect_session(mvm
, vif
, duration
,
2751 min_duration
, 500, false);
2754 /* Handle association common part to MLD and non-MLD modes */
2755 void iwl_mvm_bss_info_changed_station_assoc(struct iwl_mvm
*mvm
,
2756 struct ieee80211_vif
*vif
,
2759 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2763 /* The firmware tracks the MU-MIMO group on its own.
2764 * However, on HW restart we should restore this data.
2766 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) &&
2767 (changes
& BSS_CHANGED_MU_GROUPS
) && vif
->bss_conf
.mu_mimo_owner
) {
2768 ret
= iwl_mvm_update_mu_groups(mvm
, vif
);
2771 "failed to update VHT MU_MIMO groups\n");
2774 iwl_mvm_recalc_multicast(mvm
);
2776 /* reset rssi values */
2777 for_each_mvm_vif_valid_link(mvmvif
, link_id
)
2778 mvmvif
->link
[link_id
]->bf_data
.ave_beacon_signal
= 0;
2780 iwl_mvm_bt_coex_vif_change(mvm
);
2781 iwl_mvm_update_smps_on_active_links(mvm
, vif
, IWL_MVM_SMPS_REQ_TT
,
2782 IEEE80211_SMPS_AUTOMATIC
);
2783 if (fw_has_capa(&mvm
->fw
->ucode_capa
,
2784 IWL_UCODE_TLV_CAPA_UMAC_SCAN
))
2785 iwl_mvm_config_scan(mvm
);
2788 /* Execute the common part for MLD and non-MLD modes */
2790 iwl_mvm_bss_info_changed_station_common(struct iwl_mvm
*mvm
,
2791 struct ieee80211_vif
*vif
,
2792 struct ieee80211_bss_conf
*link_conf
,
2795 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2798 if (changes
& BSS_CHANGED_BEACON_INFO
) {
2799 /* We received a beacon from the associated AP so
2800 * remove the session protection.
2802 iwl_mvm_stop_session_protection(mvm
, vif
);
2804 iwl_mvm_sf_update(mvm
, vif
, false);
2805 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
));
2808 if (changes
& (BSS_CHANGED_PS
| BSS_CHANGED_P2P_PS
| BSS_CHANGED_QOS
|
2809 /* Send power command on every beacon change,
2810 * because we may have not enabled beacon abort yet.
2812 BSS_CHANGED_BEACON_INFO
)) {
2813 ret
= iwl_mvm_power_update_mac(mvm
);
2815 IWL_ERR(mvm
, "failed to update power mode\n");
2818 if (changes
& BSS_CHANGED_CQM
) {
2819 struct iwl_mvm_vif_link_info
*link_info
=
2820 mvmvif
->link
[link_conf
->link_id
];
2822 IWL_DEBUG_MAC80211(mvm
, "CQM info_changed\n");
2824 link_info
->bf_data
.last_cqm_event
= 0;
2826 if (mvmvif
->bf_enabled
) {
2827 /* FIXME: need to update per link when FW API will
2830 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
);
2833 "failed to update CQM thresholds\n");
2837 if (changes
& BSS_CHANGED_BANDWIDTH
)
2838 iwl_mvm_update_link_smps(vif
, link_conf
);
2840 if (changes
& BSS_CHANGED_TPE
) {
2841 IWL_DEBUG_CALIB(mvm
, "Changing TPE\n");
2842 iwl_mvm_send_ap_tx_power_constraint_cmd(mvm
, vif
,
2848 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm
*mvm
,
2849 struct ieee80211_vif
*vif
,
2850 struct ieee80211_bss_conf
*bss_conf
,
2853 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2858 * Re-calculate the tsf id, as the leader-follower relations depend
2859 * on the beacon interval, which was not known when the station
2860 * interface was added.
2862 if (changes
& BSS_CHANGED_ASSOC
&& vif
->cfg
.assoc
) {
2863 if ((vif
->bss_conf
.he_support
&&
2864 !iwlwifi_mod_params
.disable_11ax
))
2865 iwl_mvm_cfg_he_sta(mvm
, vif
, mvmvif
->deflink
.ap_sta_id
);
2867 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
2870 /* Update MU EDCA params */
2871 if (changes
& BSS_CHANGED_QOS
&& mvmvif
->associated
&&
2873 (vif
->bss_conf
.he_support
&& !iwlwifi_mod_params
.disable_11ax
))
2874 iwl_mvm_cfg_he_sta(mvm
, vif
, mvmvif
->deflink
.ap_sta_id
);
2877 * If we're not associated yet, take the (new) BSSID before associating
2878 * so the firmware knows. If we're already associated, then use the old
2879 * BSSID here, and we'll send a cleared one later in the CHANGED_ASSOC
2880 * branch for disassociation below.
2882 if (changes
& BSS_CHANGED_BSSID
&& !mvmvif
->associated
)
2883 memcpy(mvmvif
->deflink
.bssid
, bss_conf
->bssid
, ETH_ALEN
);
2885 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, mvmvif
->deflink
.bssid
);
2887 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
2889 /* after sending it once, adopt mac80211 data */
2890 memcpy(mvmvif
->deflink
.bssid
, bss_conf
->bssid
, ETH_ALEN
);
2891 mvmvif
->associated
= vif
->cfg
.assoc
;
2893 if (changes
& BSS_CHANGED_ASSOC
) {
2894 if (vif
->cfg
.assoc
) {
2895 mvmvif
->session_prot_connection_loss
= false;
2897 /* clear statistics to get clean beacon counter */
2898 iwl_mvm_request_statistics(mvm
, true);
2899 for_each_mvm_vif_valid_link(mvmvif
, i
)
2900 memset(&mvmvif
->link
[i
]->beacon_stats
, 0,
2901 sizeof(mvmvif
->link
[i
]->beacon_stats
));
2903 /* add quota for this interface */
2904 ret
= iwl_mvm_update_quotas(mvm
, true, NULL
);
2906 IWL_ERR(mvm
, "failed to update quotas\n");
2910 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
,
2912 !fw_has_capa(&mvm
->fw
->ucode_capa
,
2913 IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD
)) {
2915 * If we're restarting then the firmware will
2916 * obviously have lost synchronisation with
2917 * the AP. It will attempt to synchronise by
2918 * itself, but we can make it more reliable by
2919 * scheduling a session protection time event.
2921 * The firmware needs to receive a beacon to
2922 * catch up with synchronisation, use 110% of
2923 * the beacon interval.
2925 * Set a large maximum delay to allow for more
2926 * than a single interface.
2928 * For new firmware versions, rely on the
2929 * firmware. This is relevant for DCM scenarios
2932 u32 dur
= (11 * vif
->bss_conf
.beacon_int
) / 10;
2933 iwl_mvm_protect_session(mvm
, vif
, dur
, dur
,
2935 } else if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
,
2937 !vif
->bss_conf
.dtim_period
) {
2939 * If we're not restarting and still haven't
2940 * heard a beacon (dtim period unknown) then
2941 * make sure we still have enough minimum time
2942 * remaining in the time event, since the auth
2943 * might actually have taken quite a while
2944 * (especially for SAE) and so the remaining
2945 * time could be small without us having heard
2948 iwl_mvm_protect_assoc(mvm
, vif
, 0, 0);
2951 iwl_mvm_sf_update(mvm
, vif
, false);
2952 iwl_mvm_power_vif_assoc(mvm
, vif
);
2954 iwl_mvm_update_smps(mvm
, vif
,
2955 IWL_MVM_SMPS_REQ_PROT
,
2956 IEEE80211_SMPS_DYNAMIC
, 0);
2958 } else if (mvmvif
->deflink
.ap_sta_id
!= IWL_INVALID_STA
) {
2959 iwl_mvm_mei_host_disassociated(mvm
);
2961 * If update fails - SF might be running in associated
2962 * mode while disassociated - which is forbidden.
2964 ret
= iwl_mvm_sf_update(mvm
, vif
, false);
2966 !test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
,
2968 "Failed to update SF upon disassociation\n");
2971 * If we get an assert during the connection (after the
2972 * station has been added, but before the vif is set
2973 * to associated), mac80211 will re-add the station and
2974 * then configure the vif. Since the vif is not
2975 * associated, we would remove the station here and
2976 * this would fail the recovery.
2978 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
,
2980 /* first remove remaining keys */
2981 iwl_mvm_sec_key_remove_ap(mvm
, vif
,
2982 &mvmvif
->deflink
, 0);
2985 * Remove AP station now that
2986 * the MAC is unassoc
2988 ret
= iwl_mvm_rm_sta_id(mvm
, vif
,
2989 mvmvif
->deflink
.ap_sta_id
);
2992 "failed to remove AP station\n");
2994 mvmvif
->deflink
.ap_sta_id
= IWL_INVALID_STA
;
2997 /* remove quota for this interface */
2998 ret
= iwl_mvm_update_quotas(mvm
, false, NULL
);
3000 IWL_ERR(mvm
, "failed to update quotas\n");
3002 /* this will take the cleared BSSID from bss_conf */
3003 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
3006 "failed to update MAC %pM (clear after unassoc)\n",
3010 iwl_mvm_bss_info_changed_station_assoc(mvm
, vif
, changes
);
3013 iwl_mvm_bss_info_changed_station_common(mvm
, vif
, &vif
->bss_conf
,
3017 bool iwl_mvm_start_ap_ibss_common(struct ieee80211_hw
*hw
,
3018 struct ieee80211_vif
*vif
,
3021 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3022 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3025 lockdep_assert_held(&mvm
->mutex
);
3027 mvmvif
->ap_assoc_sta_count
= 0;
3029 /* must be set before quota calculations */
3030 mvmvif
->ap_ibss_active
= true;
3032 /* send all the early keys to the device now */
3033 for (i
= 0; i
< ARRAY_SIZE(mvmvif
->ap_early_keys
); i
++) {
3034 struct ieee80211_key_conf
*key
= mvmvif
->ap_early_keys
[i
];
3039 mvmvif
->ap_early_keys
[i
] = NULL
;
3041 *ret
= __iwl_mvm_mac_set_key(hw
, SET_KEY
, vif
, NULL
, key
);
3046 if (vif
->type
== NL80211_IFTYPE_AP
&& !vif
->p2p
) {
3047 iwl_mvm_vif_set_low_latency(mvmvif
, true,
3048 LOW_LATENCY_VIF_TYPE
);
3049 iwl_mvm_send_low_latency_cmd(mvm
, true, mvmvif
->id
);
3052 /* power updated needs to be done before quotas */
3053 iwl_mvm_power_update_mac(mvm
);
3058 static int iwl_mvm_start_ap_ibss(struct ieee80211_hw
*hw
,
3059 struct ieee80211_vif
*vif
,
3060 struct ieee80211_bss_conf
*link_conf
)
3062 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3063 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3066 mutex_lock(&mvm
->mutex
);
3069 * Re-calculate the tsf id, as the leader-follower relations depend on
3070 * the beacon interval, which was not known when the AP interface
3073 if (vif
->type
== NL80211_IFTYPE_AP
)
3074 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
3076 /* For older devices need to send beacon template before adding mac
3077 * context. For the newer, the beacon is a resource that belongs to a
3078 * MAC, so need to send beacon template after adding the mac.
3080 if (mvm
->trans
->trans_cfg
->device_family
> IWL_DEVICE_FAMILY_22000
) {
3081 /* Add the mac context */
3082 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
3086 /* Send the beacon template */
3087 ret
= iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
, link_conf
);
3091 /* Send the beacon template */
3092 ret
= iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
, link_conf
);
3096 /* Add the mac context */
3097 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
3102 /* Perform the binding */
3103 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
3108 * This is not very nice, but the simplest:
3109 * For older FWs adding the mcast sta before the bcast station may
3110 * cause assert 0x2b00.
3111 * This is fixed in later FW so make the order of removal depend on
3114 if (fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_STA_TYPE
)) {
3115 ret
= iwl_mvm_add_mcast_sta(mvm
, vif
);
3119 * Send the bcast station. At this stage the TBTT and DTIM time
3120 * events are added and applied to the scheduler
3122 ret
= iwl_mvm_send_add_bcast_sta(mvm
, vif
);
3124 iwl_mvm_rm_mcast_sta(mvm
, vif
);
3129 * Send the bcast station. At this stage the TBTT and DTIM time
3130 * events are added and applied to the scheduler
3132 ret
= iwl_mvm_send_add_bcast_sta(mvm
, vif
);
3135 ret
= iwl_mvm_add_mcast_sta(mvm
, vif
);
3137 iwl_mvm_send_rm_bcast_sta(mvm
, vif
);
3142 if (iwl_mvm_start_ap_ibss_common(hw
, vif
, &ret
))
3145 ret
= iwl_mvm_update_quotas(mvm
, false, NULL
);
3149 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
3150 if (vif
->p2p
&& mvm
->p2p_device_vif
)
3151 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false, NULL
);
3153 iwl_mvm_bt_coex_vif_change(mvm
);
3155 /* we don't support TDLS during DCM */
3156 if (iwl_mvm_phy_ctx_count(mvm
) > 1)
3157 iwl_mvm_teardown_tdls_peers(mvm
);
3159 iwl_mvm_ftm_restart_responder(mvm
, vif
, &vif
->bss_conf
);
3164 iwl_mvm_power_update_mac(mvm
);
3165 mvmvif
->ap_ibss_active
= false;
3166 iwl_mvm_send_rm_bcast_sta(mvm
, vif
);
3167 iwl_mvm_rm_mcast_sta(mvm
, vif
);
3169 iwl_mvm_binding_remove_vif(mvm
, vif
);
3171 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
3173 mutex_unlock(&mvm
->mutex
);
3177 static int iwl_mvm_start_ap(struct ieee80211_hw
*hw
,
3178 struct ieee80211_vif
*vif
,
3179 struct ieee80211_bss_conf
*link_conf
)
3181 return iwl_mvm_start_ap_ibss(hw
, vif
, link_conf
);
3184 static int iwl_mvm_start_ibss(struct ieee80211_hw
*hw
,
3185 struct ieee80211_vif
*vif
)
3187 return iwl_mvm_start_ap_ibss(hw
, vif
, &vif
->bss_conf
);
3190 /* Common part for MLD and non-MLD ops */
3191 void iwl_mvm_stop_ap_ibss_common(struct iwl_mvm
*mvm
,
3192 struct ieee80211_vif
*vif
)
3194 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3196 lockdep_assert_held(&mvm
->mutex
);
3198 iwl_mvm_prepare_mac_removal(mvm
, vif
);
3200 /* Handle AP stop while in CSA */
3201 if (rcu_access_pointer(mvm
->csa_vif
) == vif
) {
3202 iwl_mvm_remove_time_event(mvm
, mvmvif
,
3203 &mvmvif
->time_event_data
);
3204 RCU_INIT_POINTER(mvm
->csa_vif
, NULL
);
3205 mvmvif
->csa_countdown
= false;
3208 if (rcu_access_pointer(mvm
->csa_tx_blocked_vif
) == vif
) {
3209 RCU_INIT_POINTER(mvm
->csa_tx_blocked_vif
, NULL
);
3210 mvm
->csa_tx_block_bcn_timeout
= 0;
3213 mvmvif
->ap_ibss_active
= false;
3214 mvm
->ap_last_beacon_gp2
= 0;
3216 if (vif
->type
== NL80211_IFTYPE_AP
&& !vif
->p2p
) {
3217 iwl_mvm_vif_set_low_latency(mvmvif
, false,
3218 LOW_LATENCY_VIF_TYPE
);
3219 iwl_mvm_send_low_latency_cmd(mvm
, false, mvmvif
->id
);
3222 iwl_mvm_bt_coex_vif_change(mvm
);
3225 static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw
*hw
,
3226 struct ieee80211_vif
*vif
,
3227 struct ieee80211_bss_conf
*link_conf
)
3229 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3233 iwl_mvm_stop_ap_ibss_common(mvm
, vif
);
3235 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
3236 if (vif
->p2p
&& mvm
->p2p_device_vif
)
3237 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false, NULL
);
3239 iwl_mvm_update_quotas(mvm
, false, NULL
);
3241 iwl_mvm_ftm_responder_clear(mvm
, vif
);
3244 * This is not very nice, but the simplest:
3245 * For older FWs removing the mcast sta before the bcast station may
3246 * cause assert 0x2b00.
3247 * This is fixed in later FW (which will stop beaconing when removing
3249 * So make the order of removal depend on the TLV
3251 if (!fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_STA_TYPE
))
3252 iwl_mvm_rm_mcast_sta(mvm
, vif
);
3253 iwl_mvm_send_rm_bcast_sta(mvm
, vif
);
3254 if (fw_has_api(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_API_STA_TYPE
))
3255 iwl_mvm_rm_mcast_sta(mvm
, vif
);
3256 iwl_mvm_binding_remove_vif(mvm
, vif
);
3258 iwl_mvm_power_update_mac(mvm
);
3260 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
3263 static void iwl_mvm_stop_ap(struct ieee80211_hw
*hw
,
3264 struct ieee80211_vif
*vif
,
3265 struct ieee80211_bss_conf
*link_conf
)
3267 iwl_mvm_stop_ap_ibss(hw
, vif
, link_conf
);
3270 static void iwl_mvm_stop_ibss(struct ieee80211_hw
*hw
,
3271 struct ieee80211_vif
*vif
)
3273 iwl_mvm_stop_ap_ibss(hw
, vif
, &vif
->bss_conf
);
3277 iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm
*mvm
,
3278 struct ieee80211_vif
*vif
,
3279 struct ieee80211_bss_conf
*bss_conf
,
3282 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3284 /* Changes will be applied when the AP/IBSS is started */
3285 if (!mvmvif
->ap_ibss_active
)
3288 if (changes
& (BSS_CHANGED_ERP_CTS_PROT
| BSS_CHANGED_HT
|
3289 BSS_CHANGED_BANDWIDTH
| BSS_CHANGED_QOS
) &&
3290 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
))
3291 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
3293 /* Need to send a new beacon template to the FW */
3294 if (changes
& BSS_CHANGED_BEACON
&&
3295 iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
, &vif
->bss_conf
))
3296 IWL_WARN(mvm
, "Failed updating beacon data\n");
3298 if (changes
& BSS_CHANGED_FTM_RESPONDER
) {
3299 int ret
= iwl_mvm_ftm_start_responder(mvm
, vif
, &vif
->bss_conf
);
3302 IWL_WARN(mvm
, "Failed to enable FTM responder (%d)\n",
3308 static void iwl_mvm_bss_info_changed(struct ieee80211_hw
*hw
,
3309 struct ieee80211_vif
*vif
,
3310 struct ieee80211_bss_conf
*bss_conf
,
3313 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3317 if (changes
& BSS_CHANGED_IDLE
&& !vif
->cfg
.idle
)
3318 iwl_mvm_scan_stop(mvm
, IWL_MVM_SCAN_SCHED
, true);
3320 switch (vif
->type
) {
3321 case NL80211_IFTYPE_STATION
:
3322 iwl_mvm_bss_info_changed_station(mvm
, vif
, bss_conf
, changes
);
3324 case NL80211_IFTYPE_AP
:
3325 case NL80211_IFTYPE_ADHOC
:
3326 iwl_mvm_bss_info_changed_ap_ibss(mvm
, vif
, bss_conf
, changes
);
3328 case NL80211_IFTYPE_MONITOR
:
3329 if (changes
& BSS_CHANGED_MU_GROUPS
)
3330 iwl_mvm_update_mu_groups(mvm
, vif
);
3333 /* shouldn't happen */
3337 if (changes
& BSS_CHANGED_TXPOWER
) {
3338 IWL_DEBUG_CALIB(mvm
, "Changing TX Power to %d dBm\n",
3340 iwl_mvm_set_tx_power(mvm
, bss_conf
, bss_conf
->txpower
);
3344 int iwl_mvm_mac_hw_scan(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
3345 struct ieee80211_scan_request
*hw_req
)
3347 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3349 if (hw_req
->req
.n_channels
== 0 ||
3350 hw_req
->req
.n_channels
> mvm
->fw
->ucode_capa
.n_scan_channels
)
3354 return iwl_mvm_reg_scan_start(mvm
, vif
, &hw_req
->req
, &hw_req
->ies
);
3357 void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw
*hw
,
3358 struct ieee80211_vif
*vif
)
3360 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3364 /* Due to a race condition, it's possible that mac80211 asks
3365 * us to stop a hw_scan when it's already stopped. This can
3366 * happen, for instance, if we stopped the scan ourselves,
3367 * called ieee80211_scan_completed() and the userspace called
3368 * cancel scan scan before ieee80211_scan_work() could run.
3369 * To handle that, simply return if the scan is not running.
3371 if (mvm
->scan_status
& IWL_MVM_SCAN_REGULAR
)
3372 iwl_mvm_scan_stop(mvm
, IWL_MVM_SCAN_REGULAR
, true);
3376 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw
*hw
,
3377 struct ieee80211_sta
*sta
, u16 tids
,
3379 enum ieee80211_frame_release_type reason
,
3382 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3384 /* Called when we need to transmit (a) frame(s) from mac80211 */
3386 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
3387 tids
, more_data
, false);
3391 iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw
*hw
,
3392 struct ieee80211_sta
*sta
, u16 tids
,
3394 enum ieee80211_frame_release_type reason
,
3397 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3399 /* Called when we need to transmit (a) frame(s) from agg or dqa queue */
3401 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
3402 tids
, more_data
, true);
3405 static void __iwl_mvm_mac_sta_notify(struct ieee80211_hw
*hw
,
3406 enum sta_notify_cmd cmd
,
3407 struct ieee80211_sta
*sta
)
3409 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3410 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
3411 unsigned long txqs
= 0, tids
= 0;
3415 * If we have TVQM then we get too high queue numbers - luckily
3416 * we really shouldn't get here with that because such hardware
3417 * should have firmware supporting buffer station offload.
3419 if (WARN_ON(iwl_mvm_has_new_tx_api(mvm
)))
3422 spin_lock_bh(&mvmsta
->lock
);
3423 for (tid
= 0; tid
< ARRAY_SIZE(mvmsta
->tid_data
); tid
++) {
3424 struct iwl_mvm_tid_data
*tid_data
= &mvmsta
->tid_data
[tid
];
3426 if (tid_data
->txq_id
== IWL_MVM_INVALID_QUEUE
)
3429 __set_bit(tid_data
->txq_id
, &txqs
);
3431 if (iwl_mvm_tid_queued(mvm
, tid_data
) == 0)
3434 __set_bit(tid
, &tids
);
3438 case STA_NOTIFY_SLEEP
:
3439 for_each_set_bit(tid
, &tids
, IWL_MAX_TID_COUNT
)
3440 ieee80211_sta_set_buffered(sta
, tid
, true);
3443 iwl_trans_freeze_txq_timer(mvm
->trans
, txqs
, true);
3445 * The fw updates the STA to be asleep. Tx packets on the Tx
3446 * queues to this station will not be transmitted. The fw will
3447 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
3450 case STA_NOTIFY_AWAKE
:
3451 if (WARN_ON(mvmsta
->deflink
.sta_id
== IWL_INVALID_STA
))
3455 iwl_trans_freeze_txq_timer(mvm
->trans
, txqs
, false);
3456 iwl_mvm_sta_modify_ps_wake(mvm
, sta
);
3461 spin_unlock_bh(&mvmsta
->lock
);
3464 void iwl_mvm_mac_sta_notify(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
3465 enum sta_notify_cmd cmd
, struct ieee80211_sta
*sta
)
3467 __iwl_mvm_mac_sta_notify(hw
, cmd
, sta
);
3470 void iwl_mvm_sta_pm_notif(struct iwl_mvm
*mvm
, struct iwl_rx_cmd_buffer
*rxb
)
3472 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
3473 struct iwl_mvm_pm_state_notification
*notif
= (void *)pkt
->data
;
3474 struct ieee80211_sta
*sta
;
3475 struct iwl_mvm_sta
*mvmsta
;
3476 bool sleeping
= (notif
->type
!= IWL_MVM_PM_EVENT_AWAKE
);
3478 if (WARN_ON(notif
->sta_id
>= mvm
->fw
->ucode_capa
.num_stations
))
3482 sta
= rcu_dereference(mvm
->fw_id_to_mac_id
[notif
->sta_id
]);
3483 if (WARN_ON(IS_ERR_OR_NULL(sta
))) {
3488 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
3491 mvmsta
->vif
->type
!= NL80211_IFTYPE_AP
) {
3496 if (mvmsta
->sleeping
!= sleeping
) {
3497 mvmsta
->sleeping
= sleeping
;
3498 __iwl_mvm_mac_sta_notify(mvm
->hw
,
3499 sleeping
? STA_NOTIFY_SLEEP
: STA_NOTIFY_AWAKE
,
3501 ieee80211_sta_ps_transition(sta
, sleeping
);
3505 switch (notif
->type
) {
3506 case IWL_MVM_PM_EVENT_AWAKE
:
3507 case IWL_MVM_PM_EVENT_ASLEEP
:
3509 case IWL_MVM_PM_EVENT_UAPSD
:
3510 ieee80211_sta_uapsd_trigger(sta
, IEEE80211_NUM_TIDS
);
3512 case IWL_MVM_PM_EVENT_PS_POLL
:
3513 ieee80211_sta_pspoll(sta
);
3523 void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw
*hw
,
3524 struct ieee80211_vif
*vif
,
3525 struct ieee80211_sta
*sta
)
3527 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
3528 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
3529 unsigned int link_id
;
3531 lockdep_assert_wiphy(mvm
->hw
->wiphy
);
3534 * This is called before mac80211 does RCU synchronisation,
3535 * so here we already invalidate our internal RCU-protected
3536 * station pointer. The rest of the code will thus no longer
3537 * be able to find the station this way, and we don't rely
3538 * on further RCU synchronisation after the sta_state()
3539 * callback deleted the station.
3540 * Since there's mvm->mutex here, no need to have RCU lock for
3541 * mvm_sta->link access.
3544 for (link_id
= 0; link_id
< ARRAY_SIZE(mvm_sta
->link
); link_id
++) {
3545 struct iwl_mvm_link_sta
*link_sta
;
3548 if (!mvm_sta
->link
[link_id
])
3551 link_sta
= rcu_dereference_protected(mvm_sta
->link
[link_id
],
3552 lockdep_is_held(&mvm
->mutex
));
3553 sta_id
= link_sta
->sta_id
;
3554 if (sta
== rcu_access_pointer(mvm
->fw_id_to_mac_id
[sta_id
])) {
3555 RCU_INIT_POINTER(mvm
->fw_id_to_mac_id
[sta_id
],
3557 RCU_INIT_POINTER(mvm
->fw_id_to_link_sta
[sta_id
], NULL
);
3562 static void iwl_mvm_check_uapsd(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
3567 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)) {
3568 struct iwl_mvm_tcm_mac
*mdata
;
3570 mdata
= &mvm
->tcm
.data
[iwl_mvm_vif_from_mac80211(vif
)->id
];
3571 ewma_rate_init(&mdata
->uapsd_nonagg_detect
.rate
);
3572 mdata
->opened_rx_ba_sessions
= false;
3575 if (!(mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT
))
3578 if (vif
->p2p
&& !iwl_mvm_is_p2p_scm_uapsd_supported(mvm
)) {
3579 vif
->driver_flags
&= ~IEEE80211_VIF_SUPPORTS_UAPSD
;
3584 (iwlwifi_mod_params
.uapsd_disable
& IWL_DISABLE_UAPSD_BSS
)) {
3585 vif
->driver_flags
&= ~IEEE80211_VIF_SUPPORTS_UAPSD
;
3589 for (i
= 0; i
< IWL_MVM_UAPSD_NOAGG_LIST_LEN
; i
++) {
3590 if (ether_addr_equal(mvm
->uapsd_noagg_bssids
[i
].addr
, bssid
)) {
3591 vif
->driver_flags
&= ~IEEE80211_VIF_SUPPORTS_UAPSD
;
3596 vif
->driver_flags
|= IEEE80211_VIF_SUPPORTS_UAPSD
;
3600 iwl_mvm_tdls_check_trigger(struct iwl_mvm
*mvm
,
3601 struct ieee80211_vif
*vif
, u8
*peer_addr
,
3602 enum nl80211_tdls_operation action
)
3604 struct iwl_fw_dbg_trigger_tlv
*trig
;
3605 struct iwl_fw_dbg_trigger_tdls
*tdls_trig
;
3607 trig
= iwl_fw_dbg_trigger_on(&mvm
->fwrt
, ieee80211_vif_to_wdev(vif
),
3608 FW_DBG_TRIGGER_TDLS
);
3612 tdls_trig
= (void *)trig
->data
;
3614 if (!(tdls_trig
->action_bitmap
& BIT(action
)))
3617 if (tdls_trig
->peer_mode
&&
3618 memcmp(tdls_trig
->peer
, peer_addr
, ETH_ALEN
) != 0)
3621 iwl_fw_dbg_collect_trig(&mvm
->fwrt
, trig
,
3622 "TDLS event occurred, peer %pM, action %d",
3626 struct iwl_mvm_he_obss_narrow_bw_ru_data
{
3630 static void iwl_mvm_check_he_obss_narrow_bw_ru_iter(struct wiphy
*wiphy
,
3631 struct cfg80211_bss
*bss
,
3634 struct iwl_mvm_he_obss_narrow_bw_ru_data
*data
= _data
;
3635 const struct cfg80211_bss_ies
*ies
;
3636 const struct element
*elem
;
3639 ies
= rcu_dereference(bss
->ies
);
3640 elem
= cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY
, ies
->data
,
3643 if (!elem
|| elem
->datalen
< 10 ||
3645 WLAN_EXT_CAPA10_OBSS_NARROW_BW_RU_TOLERANCE_SUPPORT
)) {
3646 data
->tolerated
= false;
3652 iwl_mvm_check_he_obss_narrow_bw_ru(struct ieee80211_hw
*hw
,
3653 struct ieee80211_vif
*vif
,
3654 unsigned int link_id
,
3655 struct ieee80211_bss_conf
*link_conf
)
3657 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3658 struct iwl_mvm_he_obss_narrow_bw_ru_data iter_data
= {
3662 if (WARN_ON_ONCE(!link_conf
->chanreq
.oper
.chan
||
3663 !mvmvif
->link
[link_id
]))
3666 if (!(link_conf
->chanreq
.oper
.chan
->flags
& IEEE80211_CHAN_RADAR
)) {
3667 mvmvif
->link
[link_id
]->he_ru_2mhz_block
= false;
3671 cfg80211_bss_iter(hw
->wiphy
, &link_conf
->chanreq
.oper
,
3672 iwl_mvm_check_he_obss_narrow_bw_ru_iter
,
3676 * If there is at least one AP on radar channel that cannot
3677 * tolerate 26-tone RU UL OFDMA transmissions using HE TB PPDU.
3679 mvmvif
->link
[link_id
]->he_ru_2mhz_block
= !iter_data
.tolerated
;
3682 static void iwl_mvm_reset_cca_40mhz_workaround(struct iwl_mvm
*mvm
,
3683 struct ieee80211_vif
*vif
)
3685 struct ieee80211_supported_band
*sband
;
3686 const struct ieee80211_sta_he_cap
*he_cap
;
3688 if (vif
->type
!= NL80211_IFTYPE_STATION
)
3691 if (!mvm
->cca_40mhz_workaround
)
3694 /* decrement and check that we reached zero */
3695 mvm
->cca_40mhz_workaround
--;
3696 if (mvm
->cca_40mhz_workaround
)
3699 sband
= mvm
->hw
->wiphy
->bands
[NL80211_BAND_2GHZ
];
3701 sband
->ht_cap
.cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
3703 he_cap
= ieee80211_get_he_iftype_cap_vif(sband
, vif
);
3706 /* we know that ours is writable */
3707 struct ieee80211_sta_he_cap
*he
= (void *)(uintptr_t)he_cap
;
3709 he
->he_cap_elem
.phy_cap_info
[0] |=
3710 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G
;
3714 static void iwl_mvm_mei_host_associated(struct iwl_mvm
*mvm
,
3715 struct ieee80211_vif
*vif
,
3716 struct iwl_mvm_sta
*mvm_sta
)
3718 #if IS_ENABLED(CONFIG_IWLMEI)
3719 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3720 struct iwl_mei_conn_info conn_info
= {
3721 .ssid_len
= vif
->cfg
.ssid_len
,
3724 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
3727 if (!mvm
->mei_registered
)
3730 /* FIXME: MEI needs to be updated for MLO */
3731 if (!vif
->bss_conf
.chanreq
.oper
.chan
)
3734 conn_info
.channel
= vif
->bss_conf
.chanreq
.oper
.chan
->hw_value
;
3736 switch (mvm_sta
->pairwise_cipher
) {
3737 case WLAN_CIPHER_SUITE_TKIP
:
3738 conn_info
.pairwise_cipher
= IWL_MEI_CIPHER_TKIP
;
3740 case WLAN_CIPHER_SUITE_CCMP
:
3741 conn_info
.pairwise_cipher
= IWL_MEI_CIPHER_CCMP
;
3743 case WLAN_CIPHER_SUITE_GCMP
:
3744 conn_info
.pairwise_cipher
= IWL_MEI_CIPHER_GCMP
;
3746 case WLAN_CIPHER_SUITE_GCMP_256
:
3747 conn_info
.pairwise_cipher
= IWL_MEI_CIPHER_GCMP_256
;
3753 /* cipher not supported, don't send anything to iwlmei */
3757 switch (mvmvif
->rekey_data
.akm
) {
3758 case WLAN_AKM_SUITE_SAE
& 0xff:
3759 conn_info
.auth_mode
= IWL_MEI_AKM_AUTH_SAE
;
3761 case WLAN_AKM_SUITE_PSK
& 0xff:
3762 conn_info
.auth_mode
= IWL_MEI_AKM_AUTH_RSNA_PSK
;
3764 case WLAN_AKM_SUITE_8021X
& 0xff:
3765 conn_info
.auth_mode
= IWL_MEI_AKM_AUTH_RSNA
;
3769 conn_info
.auth_mode
= IWL_MEI_AKM_AUTH_OPEN
;
3772 /* auth method / AKM not supported */
3773 /* TODO: All the FT vesions of these? */
3777 memcpy(conn_info
.ssid
, vif
->cfg
.ssid
, vif
->cfg
.ssid_len
);
3778 memcpy(conn_info
.bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
3780 /* TODO: add support for collocated AP data */
3781 iwl_mei_host_associated(&conn_info
, NULL
);
3785 static int iwl_mvm_mac_ctxt_changed_wrapper(struct iwl_mvm
*mvm
,
3786 struct ieee80211_vif
*vif
,
3787 bool force_assoc_off
)
3789 return iwl_mvm_mac_ctxt_changed(mvm
, vif
, force_assoc_off
, NULL
);
3792 static int iwl_mvm_mac_sta_state(struct ieee80211_hw
*hw
,
3793 struct ieee80211_vif
*vif
,
3794 struct ieee80211_sta
*sta
,
3795 enum ieee80211_sta_state old_state
,
3796 enum ieee80211_sta_state new_state
)
3798 static const struct iwl_mvm_sta_state_ops callbacks
= {
3799 .add_sta
= iwl_mvm_add_sta
,
3800 .update_sta
= iwl_mvm_update_sta
,
3801 .rm_sta
= iwl_mvm_rm_sta
,
3802 .mac_ctxt_changed
= iwl_mvm_mac_ctxt_changed_wrapper
,
3805 return iwl_mvm_mac_sta_state_common(hw
, vif
, sta
, old_state
, new_state
,
3809 /* FIXME: temporary making two assumptions in all sta handling functions:
3810 * (1) when setting sta state, the link exists and protected
3811 * (2) if a link is valid in sta then it's valid in vif (can
3812 * use same index in the link array)
3814 static void iwl_mvm_rs_rate_init_all_links(struct iwl_mvm
*mvm
,
3815 struct ieee80211_vif
*vif
,
3816 struct ieee80211_sta
*sta
)
3818 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3819 unsigned int link_id
;
3821 for_each_mvm_vif_valid_link(mvmvif
, link_id
) {
3822 struct ieee80211_bss_conf
*conf
=
3823 link_conf_dereference_check(vif
, link_id
);
3824 struct ieee80211_link_sta
*link_sta
=
3825 link_sta_dereference_check(sta
, link_id
);
3827 if (!conf
|| !link_sta
|| !mvmvif
->link
[link_id
]->phy_ctxt
)
3830 iwl_mvm_rs_rate_init(mvm
, vif
, sta
, conf
, link_sta
,
3831 mvmvif
->link
[link_id
]->phy_ctxt
->channel
->band
);
3835 static bool iwl_mvm_vif_conf_from_sta(struct iwl_mvm
*mvm
,
3836 struct ieee80211_vif
*vif
,
3837 struct ieee80211_sta
*sta
)
3839 struct ieee80211_link_sta
*link_sta
;
3840 unsigned int link_id
;
3842 /* Beacon interval check - firmware will crash if the beacon
3843 * interval is less than 16. We can't avoid connecting at all,
3844 * so refuse the station state change, this will cause mac80211
3845 * to abandon attempts to connect to this AP, and eventually
3846 * wpa_s will blocklist the AP...
3849 for_each_sta_active_link(vif
, sta
, link_sta
, link_id
) {
3850 struct ieee80211_bss_conf
*link_conf
=
3851 link_conf_dereference_protected(vif
, link_id
);
3856 if (link_conf
->beacon_int
< IWL_MVM_MIN_BEACON_INTERVAL_TU
) {
3858 "Beacon interval %d for AP %pM is too small\n",
3859 link_conf
->beacon_int
, link_sta
->addr
);
3863 link_conf
->he_support
= link_sta
->he_cap
.has_he
;
3869 static void iwl_mvm_vif_set_he_support(struct ieee80211_hw
*hw
,
3870 struct ieee80211_vif
*vif
,
3871 struct ieee80211_sta
*sta
,
3874 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3875 struct ieee80211_link_sta
*link_sta
;
3876 unsigned int link_id
;
3878 for_each_sta_active_link(vif
, sta
, link_sta
, link_id
) {
3879 struct ieee80211_bss_conf
*link_conf
=
3880 link_conf_dereference_protected(vif
, link_id
);
3882 if (!link_conf
|| !mvmvif
->link
[link_id
])
3885 link_conf
->he_support
= link_sta
->he_cap
.has_he
;
3888 mvmvif
->link
[link_id
]->he_ru_2mhz_block
= false;
3889 if (link_sta
->he_cap
.has_he
)
3890 iwl_mvm_check_he_obss_narrow_bw_ru(hw
, vif
,
3898 iwl_mvm_sta_state_notexist_to_none(struct iwl_mvm
*mvm
,
3899 struct ieee80211_vif
*vif
,
3900 struct ieee80211_sta
*sta
,
3901 const struct iwl_mvm_sta_state_ops
*callbacks
)
3903 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3904 struct ieee80211_link_sta
*link_sta
;
3908 lockdep_assert_held(&mvm
->mutex
);
3910 if (vif
->type
== NL80211_IFTYPE_STATION
&&
3911 !iwl_mvm_vif_conf_from_sta(mvm
, vif
, sta
))
3916 iwl_mvm_tdls_sta_count(mvm
, NULL
) == IWL_MVM_TDLS_STA_COUNT
||
3917 iwl_mvm_phy_ctx_count(mvm
) > 1)) {
3918 IWL_DEBUG_MAC80211(mvm
, "refusing TDLS sta\n");
3922 ret
= callbacks
->add_sta(mvm
, vif
, sta
);
3923 if (sta
->tdls
&& ret
== 0) {
3924 iwl_mvm_recalc_tdls_state(mvm
, vif
, true);
3925 iwl_mvm_tdls_check_trigger(mvm
, vif
, sta
->addr
,
3926 NL80211_TDLS_SETUP
);
3932 for_each_sta_active_link(vif
, sta
, link_sta
, i
)
3933 link_sta
->agg
.max_rc_amsdu_len
= 1;
3935 ieee80211_sta_recalc_aggregates(sta
);
3937 if (vif
->type
== NL80211_IFTYPE_STATION
&& !sta
->tdls
)
3938 mvmvif
->ap_sta
= sta
;
3941 * Initialize the rates here already - this really tells
3942 * the firmware only what the supported legacy rates are
3943 * (may be) since it's initialized already from what the
3944 * AP advertised in the beacon/probe response. This will
3945 * allow the firmware to send auth/assoc frames with one
3946 * of the supported rates already, rather than having to
3947 * use a mandatory rate.
3948 * If we're the AP, we'll just assume mandatory rates at
3949 * this point, but we know nothing about the STA anyway.
3951 iwl_mvm_rs_rate_init_all_links(mvm
, vif
, sta
);
3957 iwl_mvm_sta_state_auth_to_assoc(struct ieee80211_hw
*hw
,
3958 struct iwl_mvm
*mvm
,
3959 struct ieee80211_vif
*vif
,
3960 struct ieee80211_sta
*sta
,
3961 const struct iwl_mvm_sta_state_ops
*callbacks
)
3963 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
3964 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
3965 struct ieee80211_link_sta
*link_sta
;
3966 unsigned int link_id
;
3968 lockdep_assert_held(&mvm
->mutex
);
3970 if (vif
->type
== NL80211_IFTYPE_AP
) {
3971 iwl_mvm_vif_set_he_support(hw
, vif
, sta
, false);
3972 mvmvif
->ap_assoc_sta_count
++;
3973 callbacks
->mac_ctxt_changed(mvm
, vif
, false);
3975 /* since the below is not for MLD API, it's ok to use
3976 * the default bss_conf
3978 if (!mvm
->mld_api_is_used
&&
3979 (vif
->bss_conf
.he_support
&&
3980 !iwlwifi_mod_params
.disable_11ax
))
3981 iwl_mvm_cfg_he_sta(mvm
, vif
, mvm_sta
->deflink
.sta_id
);
3982 } else if (vif
->type
== NL80211_IFTYPE_STATION
) {
3983 iwl_mvm_vif_set_he_support(hw
, vif
, sta
, true);
3985 callbacks
->mac_ctxt_changed(mvm
, vif
, false);
3987 if (!mvm
->mld_api_is_used
)
3990 for_each_sta_active_link(vif
, sta
, link_sta
, link_id
) {
3991 struct ieee80211_bss_conf
*link_conf
=
3992 link_conf_dereference_protected(vif
, link_id
);
3994 if (WARN_ON(!link_conf
))
3996 if (!mvmvif
->link
[link_id
])
3999 iwl_mvm_link_changed(mvm
, vif
, link_conf
,
4000 LINK_CONTEXT_MODIFY_ALL
&
4001 ~LINK_CONTEXT_MODIFY_ACTIVE
,
4007 iwl_mvm_rs_rate_init_all_links(mvm
, vif
, sta
);
4009 return callbacks
->update_sta(mvm
, vif
, sta
);
4013 iwl_mvm_sta_state_assoc_to_authorized(struct iwl_mvm
*mvm
,
4014 struct ieee80211_vif
*vif
,
4015 struct ieee80211_sta
*sta
,
4016 const struct iwl_mvm_sta_state_ops
*callbacks
)
4018 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4019 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
4021 lockdep_assert_held(&mvm
->mutex
);
4023 /* we don't support TDLS during DCM */
4024 if (iwl_mvm_phy_ctx_count(mvm
) > 1)
4025 iwl_mvm_teardown_tdls_peers(mvm
);
4028 iwl_mvm_tdls_check_trigger(mvm
, vif
, sta
->addr
,
4029 NL80211_TDLS_ENABLE_LINK
);
4031 /* enable beacon filtering */
4032 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
));
4034 mvmvif
->authorized
= 1;
4036 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)) {
4037 mvmvif
->link_selection_res
= vif
->active_links
;
4038 mvmvif
->link_selection_primary
=
4039 vif
->active_links
? __ffs(vif
->active_links
) : 0;
4042 callbacks
->mac_ctxt_changed(mvm
, vif
, false);
4043 iwl_mvm_mei_host_associated(mvm
, vif
, mvm_sta
);
4045 memset(&mvmvif
->last_esr_exit
, 0,
4046 sizeof(mvmvif
->last_esr_exit
));
4048 iwl_mvm_block_esr(mvm
, vif
, IWL_MVM_ESR_BLOCKED_TPT
, 0);
4050 /* Block until FW notif will arrive */
4051 iwl_mvm_block_esr(mvm
, vif
, IWL_MVM_ESR_BLOCKED_FW
, 0);
4053 /* when client is authorized (AP station marked as such),
4054 * try to enable the best link(s).
4056 if (vif
->type
== NL80211_IFTYPE_STATION
&&
4057 !test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
4058 iwl_mvm_select_links(mvm
, vif
);
4061 mvm_sta
->authorized
= true;
4063 /* MFP is set by default before the station is authorized.
4064 * Clear it here in case it's not used.
4067 int ret
= callbacks
->update_sta(mvm
, vif
, sta
);
4073 iwl_mvm_rs_rate_init_all_links(mvm
, vif
, sta
);
4079 iwl_mvm_sta_state_authorized_to_assoc(struct iwl_mvm
*mvm
,
4080 struct ieee80211_vif
*vif
,
4081 struct ieee80211_sta
*sta
,
4082 const struct iwl_mvm_sta_state_ops
*callbacks
)
4084 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4085 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
4087 lockdep_assert_held(&mvm
->mutex
);
4089 mvmsta
->authorized
= false;
4091 /* once we move into assoc state, need to update rate scale to
4092 * disable using wide bandwidth
4094 iwl_mvm_rs_rate_init_all_links(mvm
, vif
, sta
);
4097 /* Set this but don't call iwl_mvm_mac_ctxt_changed()
4098 * yet to avoid sending high prio again for a little
4101 mvmvif
->authorized
= 0;
4102 mvmvif
->link_selection_res
= 0;
4104 /* disable beacon filtering */
4105 iwl_mvm_disable_beacon_filter(mvm
, vif
);
4107 wiphy_delayed_work_cancel(mvm
->hw
->wiphy
,
4108 &mvmvif
->prevent_esr_done_wk
);
4110 wiphy_delayed_work_cancel(mvm
->hw
->wiphy
,
4111 &mvmvif
->mlo_int_scan_wk
);
4113 wiphy_work_cancel(mvm
->hw
->wiphy
, &mvmvif
->unblock_esr_tpt_wk
);
4114 wiphy_delayed_work_cancel(mvm
->hw
->wiphy
,
4115 &mvmvif
->unblock_esr_tmp_non_bss_wk
);
4117 /* No need for the periodic statistics anymore */
4118 if (ieee80211_vif_is_mld(vif
) && mvmvif
->esr_active
)
4119 iwl_mvm_request_periodic_system_statistics(mvm
, false);
4125 /* Common part for MLD and non-MLD modes */
4126 int iwl_mvm_mac_sta_state_common(struct ieee80211_hw
*hw
,
4127 struct ieee80211_vif
*vif
,
4128 struct ieee80211_sta
*sta
,
4129 enum ieee80211_sta_state old_state
,
4130 enum ieee80211_sta_state new_state
,
4131 const struct iwl_mvm_sta_state_ops
*callbacks
)
4133 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4134 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4135 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
4136 struct ieee80211_link_sta
*link_sta
;
4137 unsigned int link_id
;
4140 IWL_DEBUG_MAC80211(mvm
, "station %pM state change %d->%d\n",
4141 sta
->addr
, old_state
, new_state
);
4144 * If we are in a STA removal flow and in DQA mode:
4146 * This is after the sync_rcu part, so the queues have already been
4147 * flushed. No more TXs on their way in mac80211's path, and no more in
4149 * Also, we won't be getting any new TX frames for this station.
4150 * What we might have are deferred TX frames that need to be taken care
4153 * Drop any still-queued deferred-frame before removing the STA, and
4154 * make sure the worker is no longer handling frames for this STA.
4156 if (old_state
== IEEE80211_STA_NONE
&&
4157 new_state
== IEEE80211_STA_NOTEXIST
) {
4158 flush_work(&mvm
->add_stream_wk
);
4161 * No need to make sure deferred TX indication is off since the
4162 * worker will already remove it if it was on
4166 * Additionally, reset the 40 MHz capability if we disconnected
4169 iwl_mvm_reset_cca_40mhz_workaround(mvm
, vif
);
4171 /* Also free dup data just in case any assertions below fail */
4172 kfree(mvm_sta
->dup_data
);
4175 mutex_lock(&mvm
->mutex
);
4177 /* this would be a mac80211 bug ... but don't crash, unless we had a
4178 * firmware crash while we were activating a link, in which case it is
4179 * legit to have phy_ctxt = NULL. Don't bother not to WARN if we are in
4180 * recovery flow since we spit tons of error messages anyway.
4182 for_each_sta_active_link(vif
, sta
, link_sta
, link_id
) {
4183 if (WARN_ON_ONCE(!mvmvif
->link
[link_id
] ||
4184 !mvmvif
->link
[link_id
]->phy_ctxt
)) {
4185 mutex_unlock(&mvm
->mutex
);
4186 return test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
,
4187 &mvm
->status
) ? 0 : -EINVAL
;
4191 /* track whether or not the station is associated */
4192 mvm_sta
->sta_state
= new_state
;
4194 if (old_state
== IEEE80211_STA_NOTEXIST
&&
4195 new_state
== IEEE80211_STA_NONE
) {
4196 ret
= iwl_mvm_sta_state_notexist_to_none(mvm
, vif
, sta
,
4200 } else if (old_state
== IEEE80211_STA_NONE
&&
4201 new_state
== IEEE80211_STA_AUTH
) {
4203 * EBS may be disabled due to previous failures reported by FW.
4204 * Reset EBS status here assuming environment has been changed.
4206 mvm
->last_ebs_successful
= true;
4207 iwl_mvm_check_uapsd(mvm
, vif
, sta
->addr
);
4209 } else if (old_state
== IEEE80211_STA_AUTH
&&
4210 new_state
== IEEE80211_STA_ASSOC
) {
4211 ret
= iwl_mvm_sta_state_auth_to_assoc(hw
, mvm
, vif
, sta
,
4213 } else if (old_state
== IEEE80211_STA_ASSOC
&&
4214 new_state
== IEEE80211_STA_AUTHORIZED
) {
4215 ret
= iwl_mvm_sta_state_assoc_to_authorized(mvm
, vif
, sta
,
4217 } else if (old_state
== IEEE80211_STA_AUTHORIZED
&&
4218 new_state
== IEEE80211_STA_ASSOC
) {
4219 ret
= iwl_mvm_sta_state_authorized_to_assoc(mvm
, vif
, sta
,
4221 } else if (old_state
== IEEE80211_STA_ASSOC
&&
4222 new_state
== IEEE80211_STA_AUTH
) {
4223 if (vif
->type
== NL80211_IFTYPE_AP
) {
4224 mvmvif
->ap_assoc_sta_count
--;
4225 callbacks
->mac_ctxt_changed(mvm
, vif
, false);
4226 } else if (vif
->type
== NL80211_IFTYPE_STATION
&& !sta
->tdls
)
4227 iwl_mvm_stop_session_protection(mvm
, vif
);
4229 } else if (old_state
== IEEE80211_STA_AUTH
&&
4230 new_state
== IEEE80211_STA_NONE
) {
4232 } else if (old_state
== IEEE80211_STA_NONE
&&
4233 new_state
== IEEE80211_STA_NOTEXIST
) {
4234 if (vif
->type
== NL80211_IFTYPE_STATION
&& !sta
->tdls
) {
4235 iwl_mvm_stop_session_protection(mvm
, vif
);
4236 mvmvif
->ap_sta
= NULL
;
4238 ret
= callbacks
->rm_sta(mvm
, vif
, sta
);
4240 iwl_mvm_recalc_tdls_state(mvm
, vif
, false);
4241 iwl_mvm_tdls_check_trigger(mvm
, vif
, sta
->addr
,
4242 NL80211_TDLS_DISABLE_LINK
);
4246 test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
,
4253 mutex_unlock(&mvm
->mutex
);
4255 if (sta
->tdls
&& ret
== 0) {
4256 if (old_state
== IEEE80211_STA_NOTEXIST
&&
4257 new_state
== IEEE80211_STA_NONE
)
4258 ieee80211_reserve_tid(sta
, IWL_MVM_TDLS_FW_TID
);
4259 else if (old_state
== IEEE80211_STA_NONE
&&
4260 new_state
== IEEE80211_STA_NOTEXIST
)
4261 ieee80211_unreserve_tid(sta
, IWL_MVM_TDLS_FW_TID
);
4267 int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
)
4269 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4271 mvm
->rts_threshold
= value
;
4276 void iwl_mvm_sta_rc_update(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
4277 struct ieee80211_link_sta
*link_sta
, u32 changed
)
4279 struct ieee80211_sta
*sta
= link_sta
->sta
;
4280 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4282 if (changed
& (IEEE80211_RC_BW_CHANGED
|
4283 IEEE80211_RC_SUPP_RATES_CHANGED
|
4284 IEEE80211_RC_NSS_CHANGED
))
4285 iwl_mvm_rs_rate_init_all_links(mvm
, vif
, sta
);
4287 if (vif
->type
== NL80211_IFTYPE_STATION
&&
4288 changed
& IEEE80211_RC_NSS_CHANGED
)
4289 iwl_mvm_sf_update(mvm
, vif
, false);
4292 static int iwl_mvm_mac_conf_tx(struct ieee80211_hw
*hw
,
4293 struct ieee80211_vif
*vif
,
4294 unsigned int link_id
, u16 ac
,
4295 const struct ieee80211_tx_queue_params
*params
)
4297 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4298 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4300 mvmvif
->deflink
.queue_params
[ac
] = *params
;
4303 * No need to update right away, we'll get BSS_CHANGED_QOS
4304 * The exception is P2P_DEVICE interface which needs immediate update.
4306 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
4308 return iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
4313 void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw
*hw
,
4314 struct ieee80211_vif
*vif
,
4315 struct ieee80211_prep_tx_info
*info
)
4317 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4318 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4320 if (info
->was_assoc
&& !mvmvif
->session_prot_connection_loss
)
4324 iwl_mvm_protect_assoc(mvm
, vif
, info
->duration
, info
->link_id
);
4327 void iwl_mvm_mac_mgd_complete_tx(struct ieee80211_hw
*hw
,
4328 struct ieee80211_vif
*vif
,
4329 struct ieee80211_prep_tx_info
*info
)
4331 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4333 /* for successful cases (auth/assoc), don't cancel session protection */
4338 iwl_mvm_stop_session_protection(mvm
, vif
);
4341 int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw
*hw
,
4342 struct ieee80211_vif
*vif
,
4343 struct cfg80211_sched_scan_request
*req
,
4344 struct ieee80211_scan_ies
*ies
)
4346 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4353 return iwl_mvm_sched_scan_start(mvm
, vif
, req
, ies
, IWL_MVM_SCAN_SCHED
);
4356 int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw
*hw
,
4357 struct ieee80211_vif
*vif
)
4359 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4362 mutex_lock(&mvm
->mutex
);
4364 /* Due to a race condition, it's possible that mac80211 asks
4365 * us to stop a sched_scan when it's already stopped. This
4366 * can happen, for instance, if we stopped the scan ourselves,
4367 * called ieee80211_sched_scan_stopped() and the userspace called
4368 * stop sched scan scan before ieee80211_sched_scan_stopped_work()
4369 * could run. To handle this, simply return if the scan is
4372 if (!(mvm
->scan_status
& IWL_MVM_SCAN_SCHED
)) {
4373 mutex_unlock(&mvm
->mutex
);
4377 ret
= iwl_mvm_scan_stop(mvm
, IWL_MVM_SCAN_SCHED
, false);
4378 mutex_unlock(&mvm
->mutex
);
4379 iwl_mvm_wait_for_async_handlers(mvm
);
4384 static int __iwl_mvm_mac_set_key(struct ieee80211_hw
*hw
,
4385 enum set_key_cmd cmd
,
4386 struct ieee80211_vif
*vif
,
4387 struct ieee80211_sta
*sta
,
4388 struct ieee80211_key_conf
*key
)
4390 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4391 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4392 struct iwl_mvm_sta
*mvmsta
= NULL
;
4393 struct iwl_mvm_key_pn
*ptk_pn
= NULL
;
4394 int keyidx
= key
->keyidx
;
4395 u32 sec_key_id
= WIDE_ID(DATA_PATH_GROUP
, SEC_KEY_CMD
);
4396 u8 sec_key_ver
= iwl_fw_lookup_cmd_ver(mvm
->fw
, sec_key_id
, 0);
4401 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
4403 switch (key
->cipher
) {
4404 case WLAN_CIPHER_SUITE_TKIP
:
4405 if (!mvm
->trans
->trans_cfg
->gen2
) {
4406 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_MMIC
;
4407 key
->flags
|= IEEE80211_KEY_FLAG_PUT_IV_SPACE
;
4408 } else if (vif
->type
== NL80211_IFTYPE_STATION
) {
4409 key
->flags
|= IEEE80211_KEY_FLAG_PUT_MIC_SPACE
;
4411 IWL_DEBUG_MAC80211(mvm
, "Use SW encryption for TKIP\n");
4415 case WLAN_CIPHER_SUITE_CCMP
:
4416 case WLAN_CIPHER_SUITE_GCMP
:
4417 case WLAN_CIPHER_SUITE_GCMP_256
:
4418 if (!iwl_mvm_has_new_tx_api(mvm
))
4419 key
->flags
|= IEEE80211_KEY_FLAG_PUT_IV_SPACE
;
4421 case WLAN_CIPHER_SUITE_AES_CMAC
:
4422 case WLAN_CIPHER_SUITE_BIP_GMAC_128
:
4423 case WLAN_CIPHER_SUITE_BIP_GMAC_256
:
4424 WARN_ON_ONCE(!ieee80211_hw_check(hw
, MFP_CAPABLE
));
4426 case WLAN_CIPHER_SUITE_WEP40
:
4427 case WLAN_CIPHER_SUITE_WEP104
:
4428 if (vif
->type
== NL80211_IFTYPE_STATION
)
4430 if (iwl_mvm_has_new_tx_api(mvm
))
4432 /* support HW crypto on TX */
4440 if (vif
->type
== NL80211_IFTYPE_STATION
&&
4441 (keyidx
== 6 || keyidx
== 7))
4442 rcu_assign_pointer(mvmvif
->bcn_prot
.keys
[keyidx
- 6],
4445 if ((vif
->type
== NL80211_IFTYPE_ADHOC
||
4446 vif
->type
== NL80211_IFTYPE_AP
) && !sta
) {
4448 * GTK on AP interface is a TX-only key, return 0;
4449 * on IBSS they're per-station and because we're lazy
4450 * we don't support them for RX, so do the same.
4451 * CMAC/GMAC in AP/IBSS modes must be done in software
4454 * Except, of course, beacon protection - it must be
4455 * offloaded since we just set a beacon template, and
4456 * then we must also offload the IGTK (not just BIGTK)
4457 * for firmware reasons.
4459 * So just check for beacon protection - if we don't
4460 * have it we cannot get here with keyidx >= 6, and
4461 * if we do have it we need to send the key to FW in
4462 * all cases (CMAC/GMAC).
4464 if (!wiphy_ext_feature_isset(hw
->wiphy
,
4465 NL80211_EXT_FEATURE_BEACON_PROTECTION
) &&
4466 (key
->cipher
== WLAN_CIPHER_SUITE_AES_CMAC
||
4467 key
->cipher
== WLAN_CIPHER_SUITE_BIP_GMAC_128
||
4468 key
->cipher
== WLAN_CIPHER_SUITE_BIP_GMAC_256
)) {
4473 if (key
->cipher
!= WLAN_CIPHER_SUITE_GCMP
&&
4474 key
->cipher
!= WLAN_CIPHER_SUITE_GCMP_256
&&
4475 !iwl_mvm_has_new_tx_api(mvm
)) {
4476 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
4481 if (!mvmvif
->ap_ibss_active
) {
4483 i
< ARRAY_SIZE(mvmvif
->ap_early_keys
);
4485 if (!mvmvif
->ap_early_keys
[i
]) {
4486 mvmvif
->ap_early_keys
[i
] = key
;
4491 if (i
>= ARRAY_SIZE(mvmvif
->ap_early_keys
))
4500 /* During FW restart, in order to restore the state as it was,
4501 * don't try to reprogram keys we previously failed for.
4503 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) &&
4504 key
->hw_key_idx
== STA_KEY_IDX_INVALID
) {
4505 IWL_DEBUG_MAC80211(mvm
,
4506 "skip invalid idx key programming during restart\n");
4511 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
) &&
4512 mvmsta
&& iwl_mvm_has_new_rx_api(mvm
) &&
4513 key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
&&
4514 (key
->cipher
== WLAN_CIPHER_SUITE_CCMP
||
4515 key
->cipher
== WLAN_CIPHER_SUITE_GCMP
||
4516 key
->cipher
== WLAN_CIPHER_SUITE_GCMP_256
)) {
4517 struct ieee80211_key_seq seq
;
4520 WARN_ON(rcu_access_pointer(mvmsta
->ptk_pn
[keyidx
]));
4521 ptk_pn
= kzalloc(struct_size(ptk_pn
, q
,
4522 mvm
->trans
->num_rx_queues
),
4529 for (tid
= 0; tid
< IWL_MAX_TID_COUNT
; tid
++) {
4530 ieee80211_get_key_rx_seq(key
, tid
, &seq
);
4531 for (q
= 0; q
< mvm
->trans
->num_rx_queues
; q
++)
4532 memcpy(ptk_pn
->q
[q
].pn
[tid
],
4534 IEEE80211_CCMP_PN_LEN
);
4537 rcu_assign_pointer(mvmsta
->ptk_pn
[keyidx
], ptk_pn
);
4540 /* in HW restart reuse the index, otherwise request a new one */
4541 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
4542 key_offset
= key
->hw_key_idx
;
4544 key_offset
= STA_KEY_IDX_INVALID
;
4546 if (mvmsta
&& key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
)
4547 mvmsta
->pairwise_cipher
= key
->cipher
;
4549 IWL_DEBUG_MAC80211(mvm
, "set hwcrypto key (sta:%pM, id:%d)\n",
4550 sta
? sta
->addr
: NULL
, key
->keyidx
);
4553 ret
= iwl_mvm_sec_key_add(mvm
, vif
, sta
, key
);
4555 ret
= iwl_mvm_set_sta_key(mvm
, vif
, sta
, key
, key_offset
);
4558 IWL_WARN(mvm
, "set key failed\n");
4559 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
4561 RCU_INIT_POINTER(mvmsta
->ptk_pn
[keyidx
], NULL
);
4565 * can't add key for RX, but we don't need it
4566 * in the device for TX so still return 0,
4567 * unless we have new TX API where we cannot
4568 * put key material into the TX_CMD
4570 if (iwl_mvm_has_new_tx_api(mvm
))
4578 if (vif
->type
== NL80211_IFTYPE_STATION
&&
4579 (keyidx
== 6 || keyidx
== 7))
4580 RCU_INIT_POINTER(mvmvif
->bcn_prot
.keys
[keyidx
- 6],
4584 for (i
= 0; i
< ARRAY_SIZE(mvmvif
->ap_early_keys
); i
++) {
4585 if (mvmvif
->ap_early_keys
[i
] == key
) {
4586 mvmvif
->ap_early_keys
[i
] = NULL
;
4591 /* found in pending list - don't do anything else */
4595 if (key
->hw_key_idx
== STA_KEY_IDX_INVALID
) {
4600 if (mvmsta
&& iwl_mvm_has_new_rx_api(mvm
) &&
4601 key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
&&
4602 (key
->cipher
== WLAN_CIPHER_SUITE_CCMP
||
4603 key
->cipher
== WLAN_CIPHER_SUITE_GCMP
||
4604 key
->cipher
== WLAN_CIPHER_SUITE_GCMP_256
)) {
4605 ptk_pn
= rcu_dereference_protected(
4606 mvmsta
->ptk_pn
[keyidx
],
4607 lockdep_is_held(&mvm
->mutex
));
4608 RCU_INIT_POINTER(mvmsta
->ptk_pn
[keyidx
], NULL
);
4610 kfree_rcu(ptk_pn
, rcu_head
);
4613 IWL_DEBUG_MAC80211(mvm
, "disable hwcrypto key\n");
4615 ret
= iwl_mvm_sec_key_del(mvm
, vif
, sta
, key
);
4617 ret
= iwl_mvm_remove_sta_key(mvm
, vif
, sta
, key
);
4626 int iwl_mvm_mac_set_key(struct ieee80211_hw
*hw
, enum set_key_cmd cmd
,
4627 struct ieee80211_vif
*vif
, struct ieee80211_sta
*sta
,
4628 struct ieee80211_key_conf
*key
)
4630 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4633 return __iwl_mvm_mac_set_key(hw
, cmd
, vif
, sta
, key
);
4636 void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw
*hw
,
4637 struct ieee80211_vif
*vif
,
4638 struct ieee80211_key_conf
*keyconf
,
4639 struct ieee80211_sta
*sta
,
4640 u32 iv32
, u16
*phase1key
)
4642 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4644 if (keyconf
->hw_key_idx
== STA_KEY_IDX_INVALID
)
4647 iwl_mvm_update_tkip_key(mvm
, vif
, keyconf
, sta
, iv32
, phase1key
);
4651 static bool iwl_mvm_rx_aux_roc(struct iwl_notif_wait_data
*notif_wait
,
4652 struct iwl_rx_packet
*pkt
, void *data
)
4654 struct iwl_mvm
*mvm
=
4655 container_of(notif_wait
, struct iwl_mvm
, notif_wait
);
4656 struct iwl_hs20_roc_res
*resp
;
4657 int resp_len
= iwl_rx_packet_payload_len(pkt
);
4658 struct iwl_mvm_time_event_data
*te_data
= data
;
4660 if (WARN_ON(pkt
->hdr
.cmd
!= HOT_SPOT_CMD
))
4663 if (WARN_ON_ONCE(resp_len
!= sizeof(*resp
))) {
4664 IWL_ERR(mvm
, "Invalid HOT_SPOT_CMD response\n");
4668 resp
= (void *)pkt
->data
;
4671 "Aux ROC: Received response from ucode: status=%d uid=%d\n",
4672 resp
->status
, resp
->event_unique_id
);
4674 te_data
->uid
= le32_to_cpu(resp
->event_unique_id
);
4675 IWL_DEBUG_TE(mvm
, "TIME_EVENT_CMD response - UID = 0x%x\n",
4678 spin_lock_bh(&mvm
->time_event_lock
);
4679 list_add_tail(&te_data
->list
, &mvm
->aux_roc_te_list
);
4680 spin_unlock_bh(&mvm
->time_event_lock
);
4685 static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm
*mvm
,
4686 struct ieee80211_channel
*channel
,
4687 struct ieee80211_vif
*vif
,
4691 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4692 struct iwl_mvm_time_event_data
*te_data
= &mvmvif
->hs_time_event_data
;
4693 static const u16 time_event_response
[] = { HOT_SPOT_CMD
};
4694 struct iwl_notification_wait wait_time_event
;
4696 struct iwl_hs20_roc_req aux_roc_req
= {
4697 .action
= cpu_to_le32(FW_CTXT_ACTION_ADD
),
4699 cpu_to_le32(FW_CMD_ID_AND_COLOR(MAC_INDEX_AUX
, 0)),
4700 .sta_id_and_color
= cpu_to_le32(mvm
->aux_sta
.sta_id
),
4702 struct iwl_hs20_roc_req_tail
*tail
= iwl_mvm_chan_info_cmd_tail(mvm
,
4703 &aux_roc_req
.channel_info
);
4704 u16 len
= sizeof(aux_roc_req
) - iwl_mvm_chan_info_padding(mvm
);
4706 /* Set the channel info data */
4707 iwl_mvm_set_chan_info(mvm
, &aux_roc_req
.channel_info
, channel
->hw_value
,
4708 iwl_mvm_phy_band_from_nl80211(channel
->band
),
4709 IWL_PHY_CHANNEL_MODE20
,
4712 /* Set the time and duration */
4713 tail
->apply_time
= cpu_to_le32(iwl_mvm_get_systime(mvm
));
4715 iwl_mvm_roc_duration_and_delay(vif
, duration
, &req_dur
, &delay
);
4716 tail
->duration
= cpu_to_le32(req_dur
);
4717 tail
->apply_time_max_delay
= cpu_to_le32(delay
);
4720 "ROC: Requesting to remain on channel %u for %ums\n",
4721 channel
->hw_value
, req_dur
);
4723 "\t(requested = %ums, max_delay = %ums)\n",
4726 /* Set the node address */
4727 memcpy(tail
->node_addr
, vif
->addr
, ETH_ALEN
);
4729 lockdep_assert_held(&mvm
->mutex
);
4731 spin_lock_bh(&mvm
->time_event_lock
);
4733 if (WARN_ON(te_data
->id
== HOT_SPOT_CMD
)) {
4734 spin_unlock_bh(&mvm
->time_event_lock
);
4739 te_data
->duration
= duration
;
4740 te_data
->id
= HOT_SPOT_CMD
;
4742 spin_unlock_bh(&mvm
->time_event_lock
);
4745 * Use a notification wait, which really just processes the
4746 * command response and doesn't wait for anything, in order
4747 * to be able to process the response and get the UID inside
4748 * the RX path. Using CMD_WANT_SKB doesn't work because it
4749 * stores the buffer and then wakes up this thread, by which
4750 * time another notification (that the time event started)
4751 * might already be processed unsuccessfully.
4753 iwl_init_notification_wait(&mvm
->notif_wait
, &wait_time_event
,
4754 time_event_response
,
4755 ARRAY_SIZE(time_event_response
),
4756 iwl_mvm_rx_aux_roc
, te_data
);
4758 res
= iwl_mvm_send_cmd_pdu(mvm
, HOT_SPOT_CMD
, 0, len
,
4762 IWL_ERR(mvm
, "Couldn't send HOT_SPOT_CMD: %d\n", res
);
4763 iwl_remove_notification(&mvm
->notif_wait
, &wait_time_event
);
4767 /* No need to wait for anything, so just pass 1 (0 isn't valid) */
4768 res
= iwl_wait_notification(&mvm
->notif_wait
, &wait_time_event
, 1);
4769 /* should never fail */
4774 spin_lock_bh(&mvm
->time_event_lock
);
4775 iwl_mvm_te_clear_data(mvm
, te_data
);
4776 spin_unlock_bh(&mvm
->time_event_lock
);
4782 static int iwl_mvm_add_aux_sta_for_hs20(struct iwl_mvm
*mvm
, u32 lmac_id
)
4786 lockdep_assert_held(&mvm
->mutex
);
4788 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
4789 IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT
)) {
4790 IWL_ERR(mvm
, "hotspot not supported\n");
4794 if (iwl_mvm_has_new_station_api(mvm
->fw
)) {
4795 ret
= iwl_mvm_add_aux_sta(mvm
, lmac_id
);
4796 WARN(ret
, "Failed to allocate aux station");
4802 static int iwl_mvm_roc_link(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
)
4806 lockdep_assert_held(&mvm
->mutex
);
4808 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
4809 if (WARN(ret
, "Failed binding P2P_DEVICE\n"))
4812 /* The station and queue allocation must be done only after the binding
4813 * is done, as otherwise the FW might incorrectly configure its state.
4815 return iwl_mvm_add_p2p_bcast_sta(mvm
, vif
);
4818 static int iwl_mvm_roc(struct ieee80211_hw
*hw
,
4819 struct ieee80211_vif
*vif
,
4820 struct ieee80211_channel
*channel
,
4822 enum ieee80211_roc_type type
)
4824 static const struct iwl_mvm_roc_ops ops
= {
4825 .add_aux_sta_for_hs20
= iwl_mvm_add_aux_sta_for_hs20
,
4826 .link
= iwl_mvm_roc_link
,
4829 return iwl_mvm_roc_common(hw
, vif
, channel
, duration
, type
, &ops
);
4832 static int iwl_mvm_roc_station(struct iwl_mvm
*mvm
,
4833 struct ieee80211_channel
*channel
,
4834 struct ieee80211_vif
*vif
,
4838 u32 cmd_id
= WIDE_ID(MAC_CONF_GROUP
, ROC_CMD
);
4839 u8 fw_ver
= iwl_fw_lookup_cmd_ver(mvm
->fw
, cmd_id
,
4840 IWL_FW_CMD_VER_UNKNOWN
);
4842 if (fw_ver
== IWL_FW_CMD_VER_UNKNOWN
) {
4843 ret
= iwl_mvm_send_aux_roc_cmd(mvm
, channel
, vif
, duration
);
4844 } else if (fw_ver
>= 3) {
4845 ret
= iwl_mvm_roc_add_cmd(mvm
, channel
, vif
, duration
,
4846 ROC_ACTIVITY_HOTSPOT
);
4849 IWL_ERR(mvm
, "ROC command version %d mismatch!\n", fw_ver
);
4855 static int iwl_mvm_roc_p2p(struct iwl_mvm
*mvm
,
4856 struct ieee80211_channel
*channel
,
4857 struct ieee80211_vif
*vif
,
4859 enum ieee80211_roc_type type
)
4861 enum iwl_roc_activity activity
;
4864 lockdep_assert_held(&mvm
->mutex
);
4867 case IEEE80211_ROC_TYPE_NORMAL
:
4868 activity
= ROC_ACTIVITY_P2P_DISC
;
4870 case IEEE80211_ROC_TYPE_MGMT_TX
:
4871 activity
= ROC_ACTIVITY_P2P_NEG
;
4874 WARN_ONCE(1, "Got an invalid P2P ROC type\n");
4878 ret
= iwl_mvm_mld_add_aux_sta(mvm
,
4879 iwl_mvm_get_lmac_id(mvm
, channel
->band
));
4883 return iwl_mvm_roc_add_cmd(mvm
, channel
, vif
, duration
, activity
);
4886 static int iwl_mvm_p2p_find_phy_ctxt(struct iwl_mvm
*mvm
,
4887 struct ieee80211_vif
*vif
,
4888 struct ieee80211_channel
*channel
)
4890 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
4891 struct cfg80211_chan_def chandef
;
4894 lockdep_assert_held(&mvm
->mutex
);
4896 if (mvmvif
->deflink
.phy_ctxt
&&
4897 channel
== mvmvif
->deflink
.phy_ctxt
->channel
)
4900 /* Try using a PHY context that is already in use */
4901 for (i
= 0; i
< NUM_PHY_CTX
; i
++) {
4902 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[i
];
4904 if (!phy_ctxt
->ref
|| mvmvif
->deflink
.phy_ctxt
== phy_ctxt
)
4907 if (channel
== phy_ctxt
->channel
) {
4908 if (mvmvif
->deflink
.phy_ctxt
)
4909 iwl_mvm_phy_ctxt_unref(mvm
,
4910 mvmvif
->deflink
.phy_ctxt
);
4912 mvmvif
->deflink
.phy_ctxt
= phy_ctxt
;
4913 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->deflink
.phy_ctxt
);
4918 /* We already have a phy_ctxt, but it's not on the right channel */
4919 if (mvmvif
->deflink
.phy_ctxt
)
4920 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->deflink
.phy_ctxt
);
4922 mvmvif
->deflink
.phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
4923 if (!mvmvif
->deflink
.phy_ctxt
)
4926 cfg80211_chandef_create(&chandef
, channel
, NL80211_CHAN_NO_HT
);
4928 return iwl_mvm_phy_ctxt_add(mvm
, mvmvif
->deflink
.phy_ctxt
,
4929 &chandef
, NULL
, 1, 1);
4932 /* Execute the common part for MLD and non-MLD modes */
4933 int iwl_mvm_roc_common(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
4934 struct ieee80211_channel
*channel
, int duration
,
4935 enum ieee80211_roc_type type
,
4936 const struct iwl_mvm_roc_ops
*ops
)
4938 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4939 struct ieee80211_vif
*bss_vif
= iwl_mvm_get_bss_vif(mvm
);
4943 IWL_DEBUG_MAC80211(mvm
, "enter (%d, %d, %d)\n", channel
->hw_value
,
4947 * Flush the done work, just in case it's still pending, so that
4948 * the work it does can complete and we can accept new frames.
4950 flush_work(&mvm
->roc_done_wk
);
4952 if (!IS_ERR_OR_NULL(bss_vif
)) {
4953 ret
= iwl_mvm_block_esr_sync(mvm
, bss_vif
,
4954 IWL_MVM_ESR_BLOCKED_ROC
);
4961 switch (vif
->type
) {
4962 case NL80211_IFTYPE_STATION
:
4963 lmac_id
= iwl_mvm_get_lmac_id(mvm
, channel
->band
);
4965 /* Use aux roc framework (HS20) */
4966 ret
= ops
->add_aux_sta_for_hs20(mvm
, lmac_id
);
4968 ret
= iwl_mvm_roc_station(mvm
, channel
, vif
, duration
);
4970 case NL80211_IFTYPE_P2P_DEVICE
:
4974 IWL_ERR(mvm
, "ROC: Invalid vif type=%u\n", vif
->type
);
4978 if (iwl_mvm_has_p2p_over_aux(mvm
)) {
4979 ret
= iwl_mvm_roc_p2p(mvm
, channel
, vif
, duration
, type
);
4983 ret
= iwl_mvm_p2p_find_phy_ctxt(mvm
, vif
, channel
);
4987 ret
= ops
->link(mvm
, vif
);
4991 return iwl_mvm_start_p2p_roc(mvm
, vif
, duration
, type
);
4994 int iwl_mvm_cancel_roc(struct ieee80211_hw
*hw
,
4995 struct ieee80211_vif
*vif
)
4997 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
4999 IWL_DEBUG_MAC80211(mvm
, "enter\n");
5001 iwl_mvm_stop_roc(mvm
, vif
);
5003 IWL_DEBUG_MAC80211(mvm
, "leave\n");
5007 struct iwl_mvm_ftm_responder_iter_data
{
5009 struct ieee80211_chanctx_conf
*ctx
;
5012 static void iwl_mvm_ftm_responder_chanctx_iter(void *_data
, u8
*mac
,
5013 struct ieee80211_vif
*vif
)
5015 struct iwl_mvm_ftm_responder_iter_data
*data
= _data
;
5017 if (rcu_access_pointer(vif
->bss_conf
.chanctx_conf
) == data
->ctx
&&
5018 vif
->type
== NL80211_IFTYPE_AP
&& vif
->bss_conf
.ftmr_params
)
5019 data
->responder
= true;
5022 bool iwl_mvm_is_ftm_responder_chanctx(struct iwl_mvm
*mvm
,
5023 struct ieee80211_chanctx_conf
*ctx
)
5025 struct iwl_mvm_ftm_responder_iter_data data
= {
5030 ieee80211_iterate_active_interfaces_atomic(mvm
->hw
,
5031 IEEE80211_IFACE_ITER_NORMAL
,
5032 iwl_mvm_ftm_responder_chanctx_iter
,
5034 return data
.responder
;
5037 static int __iwl_mvm_add_chanctx(struct iwl_mvm
*mvm
,
5038 struct ieee80211_chanctx_conf
*ctx
)
5040 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
5041 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
5042 struct cfg80211_chan_def
*def
= iwl_mvm_chanctx_def(mvm
, ctx
);
5045 lockdep_assert_held(&mvm
->mutex
);
5047 IWL_DEBUG_MAC80211(mvm
, "Add channel context\n");
5049 phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
5055 ret
= iwl_mvm_phy_ctxt_add(mvm
, phy_ctxt
, def
, &ctx
->ap
,
5056 ctx
->rx_chains_static
,
5057 ctx
->rx_chains_dynamic
);
5059 IWL_ERR(mvm
, "Failed to add PHY context\n");
5063 *phy_ctxt_id
= phy_ctxt
->id
;
5068 int iwl_mvm_add_chanctx(struct ieee80211_hw
*hw
,
5069 struct ieee80211_chanctx_conf
*ctx
)
5071 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5074 return __iwl_mvm_add_chanctx(mvm
, ctx
);
5077 static void __iwl_mvm_remove_chanctx(struct iwl_mvm
*mvm
,
5078 struct ieee80211_chanctx_conf
*ctx
)
5080 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
5081 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
5083 lockdep_assert_held(&mvm
->mutex
);
5085 iwl_mvm_phy_ctxt_unref(mvm
, phy_ctxt
);
5088 void iwl_mvm_remove_chanctx(struct ieee80211_hw
*hw
,
5089 struct ieee80211_chanctx_conf
*ctx
)
5091 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5094 __iwl_mvm_remove_chanctx(mvm
, ctx
);
5097 void iwl_mvm_change_chanctx(struct ieee80211_hw
*hw
,
5098 struct ieee80211_chanctx_conf
*ctx
, u32 changed
)
5100 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5101 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
5102 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
5103 struct cfg80211_chan_def
*def
= iwl_mvm_chanctx_def(mvm
, ctx
);
5105 if (WARN_ONCE((phy_ctxt
->ref
> 1) &&
5106 (changed
& ~(IEEE80211_CHANCTX_CHANGE_WIDTH
|
5107 IEEE80211_CHANCTX_CHANGE_RX_CHAINS
|
5108 IEEE80211_CHANCTX_CHANGE_RADAR
|
5109 IEEE80211_CHANCTX_CHANGE_MIN_DEF
)),
5110 "Cannot change PHY. Ref=%d, changed=0x%X\n",
5111 phy_ctxt
->ref
, changed
))
5116 /* we are only changing the min_width, may be a noop */
5117 if (changed
== IEEE80211_CHANCTX_CHANGE_MIN_DEF
) {
5118 if (phy_ctxt
->width
== def
->width
)
5121 /* we are just toggling between 20_NOHT and 20 */
5122 if (phy_ctxt
->width
<= NL80211_CHAN_WIDTH_20
&&
5123 def
->width
<= NL80211_CHAN_WIDTH_20
)
5127 iwl_mvm_bt_coex_vif_change(mvm
);
5128 iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, def
, &ctx
->ap
,
5129 ctx
->rx_chains_static
,
5130 ctx
->rx_chains_dynamic
);
5134 * This function executes the common part for MLD and non-MLD modes.
5136 * Returns true if we're done assigning the chanctx
5137 * (either on failure or success)
5140 __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm
*mvm
,
5141 struct ieee80211_vif
*vif
,
5142 struct ieee80211_chanctx_conf
*ctx
,
5143 bool switching_chanctx
, int *ret
)
5145 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
5146 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
5147 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5149 lockdep_assert_held(&mvm
->mutex
);
5151 mvmvif
->deflink
.phy_ctxt
= phy_ctxt
;
5153 switch (vif
->type
) {
5154 case NL80211_IFTYPE_AP
:
5155 /* only needed if we're switching chanctx (i.e. during CSA) */
5156 if (switching_chanctx
) {
5157 mvmvif
->ap_ibss_active
= true;
5161 case NL80211_IFTYPE_ADHOC
:
5163 * The AP binding flow is handled as part of the start_ap flow
5164 * (in bss_info_changed), similarly for IBSS.
5168 case NL80211_IFTYPE_STATION
:
5170 case NL80211_IFTYPE_MONITOR
:
5171 /* always disable PS when a monitor interface is active */
5172 mvmvif
->ps_disabled
= true;
5181 static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm
*mvm
,
5182 struct ieee80211_vif
*vif
,
5183 struct ieee80211_bss_conf
*link_conf
,
5184 struct ieee80211_chanctx_conf
*ctx
,
5185 bool switching_chanctx
)
5187 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5190 if (WARN_ON(!link_conf
))
5193 if (__iwl_mvm_assign_vif_chanctx_common(mvm
, vif
, ctx
,
5194 switching_chanctx
, &ret
))
5197 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
5202 * Power state must be updated before quotas,
5203 * otherwise fw will complain.
5205 iwl_mvm_power_update_mac(mvm
);
5207 /* Setting the quota at this stage is only required for monitor
5208 * interfaces. For the other types, the bss_info changed flow
5209 * will handle quota settings.
5211 if (vif
->type
== NL80211_IFTYPE_MONITOR
) {
5212 mvmvif
->monitor_active
= true;
5213 ret
= iwl_mvm_update_quotas(mvm
, false, NULL
);
5215 goto out_remove_binding
;
5217 ret
= iwl_mvm_add_snif_sta(mvm
, vif
);
5219 goto out_remove_binding
;
5223 /* Handle binding during CSA */
5224 if (vif
->type
== NL80211_IFTYPE_AP
) {
5225 iwl_mvm_update_quotas(mvm
, false, NULL
);
5226 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false, NULL
);
5229 if (vif
->type
== NL80211_IFTYPE_STATION
) {
5230 if (!switching_chanctx
) {
5231 mvmvif
->csa_bcn_pending
= false;
5235 mvmvif
->csa_bcn_pending
= true;
5237 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
5238 IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD
)) {
5239 u32 duration
= 5 * vif
->bss_conf
.beacon_int
;
5241 /* Protect the session to make sure we hear the first
5242 * beacon on the new channel.
5244 iwl_mvm_protect_session(mvm
, vif
, duration
, duration
,
5245 vif
->bss_conf
.beacon_int
/ 2,
5249 iwl_mvm_update_quotas(mvm
, false, NULL
);
5251 iwl_mvm_send_ap_tx_power_constraint_cmd(mvm
, vif
,
5259 iwl_mvm_binding_remove_vif(mvm
, vif
);
5260 iwl_mvm_power_update_mac(mvm
);
5263 mvmvif
->deflink
.phy_ctxt
= NULL
;
5267 static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw
*hw
,
5268 struct ieee80211_vif
*vif
,
5269 struct ieee80211_bss_conf
*link_conf
,
5270 struct ieee80211_chanctx_conf
*ctx
)
5272 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5275 return __iwl_mvm_assign_vif_chanctx(mvm
, vif
, link_conf
, ctx
, false);
5279 * This function executes the common part for MLD and non-MLD modes.
5281 * Returns if chanctx unassign chanctx is done
5282 * (either on failure or success)
5284 static bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm
*mvm
,
5285 struct ieee80211_vif
*vif
,
5286 bool switching_chanctx
)
5288 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5290 lockdep_assert_held(&mvm
->mutex
);
5291 iwl_mvm_remove_time_event(mvm
, mvmvif
,
5292 &mvmvif
->time_event_data
);
5294 switch (vif
->type
) {
5295 case NL80211_IFTYPE_ADHOC
:
5297 case NL80211_IFTYPE_MONITOR
:
5298 mvmvif
->monitor_active
= false;
5299 mvmvif
->ps_disabled
= false;
5301 case NL80211_IFTYPE_AP
:
5302 /* This part is triggered only during CSA */
5303 if (!switching_chanctx
|| !mvmvif
->ap_ibss_active
)
5306 mvmvif
->csa_countdown
= false;
5308 /* Set CS bit on all the stations */
5309 iwl_mvm_modify_all_sta_disable_tx(mvm
, mvmvif
, true);
5311 /* Save blocked iface, the timeout is set on the next beacon */
5312 rcu_assign_pointer(mvm
->csa_tx_blocked_vif
, vif
);
5314 mvmvif
->ap_ibss_active
= false;
5322 static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm
*mvm
,
5323 struct ieee80211_vif
*vif
,
5324 struct ieee80211_bss_conf
*link_conf
,
5325 struct ieee80211_chanctx_conf
*ctx
,
5326 bool switching_chanctx
)
5328 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5329 struct ieee80211_vif
*disabled_vif
= NULL
;
5331 if (__iwl_mvm_unassign_vif_chanctx_common(mvm
, vif
, switching_chanctx
))
5334 if (vif
->type
== NL80211_IFTYPE_MONITOR
)
5335 iwl_mvm_rm_snif_sta(mvm
, vif
);
5338 if (vif
->type
== NL80211_IFTYPE_STATION
&& switching_chanctx
) {
5340 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
5341 IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD
))
5342 iwl_mvm_mac_ctxt_changed(mvm
, vif
, true, NULL
);
5345 iwl_mvm_update_quotas(mvm
, false, disabled_vif
);
5346 iwl_mvm_binding_remove_vif(mvm
, vif
);
5349 if (fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD
) &&
5352 mvmvif
->deflink
.phy_ctxt
= NULL
;
5353 iwl_mvm_power_update_mac(mvm
);
5356 static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw
*hw
,
5357 struct ieee80211_vif
*vif
,
5358 struct ieee80211_bss_conf
*link_conf
,
5359 struct ieee80211_chanctx_conf
*ctx
)
5361 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5364 __iwl_mvm_unassign_vif_chanctx(mvm
, vif
, link_conf
, ctx
, false);
5368 iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm
*mvm
,
5369 struct ieee80211_vif_chanctx_switch
*vifs
,
5370 const struct iwl_mvm_switch_vif_chanctx_ops
*ops
)
5375 ops
->__unassign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].link_conf
,
5376 vifs
[0].old_ctx
, true);
5377 __iwl_mvm_remove_chanctx(mvm
, vifs
[0].old_ctx
);
5379 ret
= __iwl_mvm_add_chanctx(mvm
, vifs
[0].new_ctx
);
5381 IWL_ERR(mvm
, "failed to add new_ctx during channel switch\n");
5385 ret
= ops
->__assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].link_conf
,
5386 vifs
[0].new_ctx
, true);
5389 "failed to assign new_ctx during channel switch\n");
5393 /* we don't support TDLS during DCM - can be caused by channel switch */
5394 if (iwl_mvm_phy_ctx_count(mvm
) > 1)
5395 iwl_mvm_teardown_tdls_peers(mvm
);
5400 __iwl_mvm_remove_chanctx(mvm
, vifs
[0].new_ctx
);
5403 if (__iwl_mvm_add_chanctx(mvm
, vifs
[0].old_ctx
)) {
5404 IWL_ERR(mvm
, "failed to add old_ctx back after failure.\n");
5408 if (ops
->__assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].link_conf
,
5409 vifs
[0].old_ctx
, true)) {
5410 IWL_ERR(mvm
, "failed to reassign old_ctx after failure.\n");
5417 /* things keep failing, better restart the hw */
5418 iwl_mvm_nic_restart(mvm
, false);
5423 iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm
*mvm
,
5424 struct ieee80211_vif_chanctx_switch
*vifs
,
5425 const struct iwl_mvm_switch_vif_chanctx_ops
*ops
)
5430 ops
->__unassign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].link_conf
,
5431 vifs
[0].old_ctx
, true);
5433 ret
= ops
->__assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].link_conf
,
5434 vifs
[0].new_ctx
, true);
5437 "failed to assign new_ctx during channel switch\n");
5444 if (ops
->__assign_vif_chanctx(mvm
, vifs
[0].vif
, vifs
[0].link_conf
,
5445 vifs
[0].old_ctx
, true)) {
5446 IWL_ERR(mvm
, "failed to reassign old_ctx after failure.\n");
5453 /* things keep failing, better restart the hw */
5454 iwl_mvm_nic_restart(mvm
, false);
5458 /* Execute the common part for both MLD and non-MLD modes */
5460 iwl_mvm_switch_vif_chanctx_common(struct ieee80211_hw
*hw
,
5461 struct ieee80211_vif_chanctx_switch
*vifs
,
5463 enum ieee80211_chanctx_switch_mode mode
,
5464 const struct iwl_mvm_switch_vif_chanctx_ops
*ops
)
5466 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5469 /* we only support a single-vif right now */
5474 case CHANCTX_SWMODE_SWAP_CONTEXTS
:
5475 ret
= iwl_mvm_switch_vif_chanctx_swap(mvm
, vifs
, ops
);
5477 case CHANCTX_SWMODE_REASSIGN_VIF
:
5478 ret
= iwl_mvm_switch_vif_chanctx_reassign(mvm
, vifs
, ops
);
5488 static int iwl_mvm_switch_vif_chanctx(struct ieee80211_hw
*hw
,
5489 struct ieee80211_vif_chanctx_switch
*vifs
,
5491 enum ieee80211_chanctx_switch_mode mode
)
5493 static const struct iwl_mvm_switch_vif_chanctx_ops ops
= {
5494 .__assign_vif_chanctx
= __iwl_mvm_assign_vif_chanctx
,
5495 .__unassign_vif_chanctx
= __iwl_mvm_unassign_vif_chanctx
,
5498 return iwl_mvm_switch_vif_chanctx_common(hw
, vifs
, n_vifs
, mode
, &ops
);
5501 int iwl_mvm_tx_last_beacon(struct ieee80211_hw
*hw
)
5503 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5505 return mvm
->ibss_manager
;
5508 static int iwl_mvm_set_tim(struct ieee80211_hw
*hw
, struct ieee80211_sta
*sta
,
5511 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5512 struct iwl_mvm_sta
*mvm_sta
= iwl_mvm_sta_from_mac80211(sta
);
5514 if (!mvm_sta
|| !mvm_sta
->vif
) {
5515 IWL_ERR(mvm
, "Station is not associated to a vif\n");
5519 return iwl_mvm_mac_ctxt_beacon_changed(mvm
, mvm_sta
->vif
,
5520 &mvm_sta
->vif
->bss_conf
);
5523 #ifdef CONFIG_NL80211_TESTMODE
5524 static const struct nla_policy iwl_mvm_tm_policy
[IWL_MVM_TM_ATTR_MAX
+ 1] = {
5525 [IWL_MVM_TM_ATTR_CMD
] = { .type
= NLA_U32
},
5526 [IWL_MVM_TM_ATTR_NOA_DURATION
] = { .type
= NLA_U32
},
5527 [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
] = { .type
= NLA_U32
},
5530 static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm
*mvm
,
5531 struct ieee80211_vif
*vif
,
5532 void *data
, int len
)
5534 struct nlattr
*tb
[IWL_MVM_TM_ATTR_MAX
+ 1];
5538 err
= nla_parse_deprecated(tb
, IWL_MVM_TM_ATTR_MAX
, data
, len
,
5539 iwl_mvm_tm_policy
, NULL
);
5543 if (!tb
[IWL_MVM_TM_ATTR_CMD
])
5546 switch (nla_get_u32(tb
[IWL_MVM_TM_ATTR_CMD
])) {
5547 case IWL_MVM_TM_CMD_SET_NOA
:
5548 if (!vif
|| vif
->type
!= NL80211_IFTYPE_AP
|| !vif
->p2p
||
5549 !vif
->bss_conf
.enable_beacon
||
5550 !tb
[IWL_MVM_TM_ATTR_NOA_DURATION
])
5553 noa_duration
= nla_get_u32(tb
[IWL_MVM_TM_ATTR_NOA_DURATION
]);
5554 if (noa_duration
>= vif
->bss_conf
.beacon_int
)
5557 mvm
->noa_duration
= noa_duration
;
5560 return iwl_mvm_update_quotas(mvm
, true, NULL
);
5561 case IWL_MVM_TM_CMD_SET_BEACON_FILTER
:
5562 /* must be associated client vif - ignore authorized */
5563 if (!vif
|| vif
->type
!= NL80211_IFTYPE_STATION
||
5564 !vif
->cfg
.assoc
|| !vif
->bss_conf
.dtim_period
||
5565 !tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
])
5568 if (nla_get_u32(tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
]))
5569 return iwl_mvm_enable_beacon_filter(mvm
, vif
);
5570 return iwl_mvm_disable_beacon_filter(mvm
, vif
);
5576 int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw
*hw
,
5577 struct ieee80211_vif
*vif
,
5578 void *data
, int len
)
5580 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5583 return __iwl_mvm_mac_testmode_cmd(mvm
, vif
, data
, len
);
5587 void iwl_mvm_channel_switch(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
5588 struct ieee80211_channel_switch
*chsw
)
5590 /* By implementing this operation, we prevent mac80211 from
5591 * starting its own channel switch timer, so that we can call
5592 * ieee80211_chswitch_done() ourselves at the right time
5593 * (which is when the absence time event starts).
5596 IWL_DEBUG_MAC80211(IWL_MAC80211_GET_MVM(hw
),
5597 "dummy channel switch op\n");
5600 static int iwl_mvm_schedule_client_csa(struct iwl_mvm
*mvm
,
5601 struct ieee80211_vif
*vif
,
5602 struct ieee80211_channel_switch
*chsw
)
5604 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5605 struct iwl_chan_switch_te_cmd cmd
= {
5606 .mac_id
= cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif
->id
,
5608 .action
= cpu_to_le32(FW_CTXT_ACTION_ADD
),
5609 .tsf
= cpu_to_le32(chsw
->timestamp
),
5610 .cs_count
= chsw
->count
,
5611 .cs_mode
= chsw
->block_tx
,
5614 lockdep_assert_held(&mvm
->mutex
);
5617 cmd
.cs_delayed_bcn_count
=
5618 DIV_ROUND_UP(chsw
->delay
, vif
->bss_conf
.beacon_int
);
5620 return iwl_mvm_send_cmd_pdu(mvm
,
5621 WIDE_ID(MAC_CONF_GROUP
,
5622 CHANNEL_SWITCH_TIME_EVENT_CMD
),
5623 0, sizeof(cmd
), &cmd
);
5626 static int iwl_mvm_old_pre_chan_sw_sta(struct iwl_mvm
*mvm
,
5627 struct ieee80211_vif
*vif
,
5628 struct ieee80211_channel_switch
*chsw
)
5630 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5633 /* Schedule the time event to a bit before beacon 1,
5634 * to make sure we're in the new channel when the
5635 * GO/AP arrives. In case count <= 1 immediately schedule the
5636 * TE (this might result with some packet loss or connection
5639 if (chsw
->count
<= 1)
5642 apply_time
= chsw
->device_timestamp
+
5643 ((vif
->bss_conf
.beacon_int
* (chsw
->count
- 1) -
5644 IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT
) * 1024);
5647 iwl_mvm_csa_client_absent(mvm
, vif
);
5649 if (mvmvif
->bf_enabled
) {
5650 int ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
);
5656 iwl_mvm_schedule_csa_period(mvm
, vif
, vif
->bss_conf
.beacon_int
,
5662 static void iwl_mvm_csa_block_txqs(void *data
, struct ieee80211_sta
*sta
)
5666 for (i
= 0; i
< ARRAY_SIZE(sta
->txq
); i
++) {
5667 struct iwl_mvm_txq
*mvmtxq
=
5668 iwl_mvm_txq_from_mac80211(sta
->txq
[i
]);
5670 set_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA
, &mvmtxq
->state
);
5674 #define IWL_MAX_CSA_BLOCK_TX 1500
5675 int iwl_mvm_pre_channel_switch(struct iwl_mvm
*mvm
,
5676 struct ieee80211_vif
*vif
,
5677 struct ieee80211_channel_switch
*chsw
)
5679 struct ieee80211_vif
*csa_vif
;
5680 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5681 struct iwl_mvm_txq
*mvmtxq
;
5684 lockdep_assert_held(&mvm
->mutex
);
5686 mvmvif
->csa_failed
= false;
5687 mvmvif
->csa_blocks_tx
= false;
5689 IWL_DEBUG_MAC80211(mvm
, "pre CSA to freq %d\n",
5690 chsw
->chandef
.center_freq1
);
5692 iwl_fw_dbg_trigger_simple_stop(&mvm
->fwrt
,
5693 ieee80211_vif_to_wdev(vif
),
5694 FW_DBG_TRIGGER_CHANNEL_SWITCH
);
5696 switch (vif
->type
) {
5697 case NL80211_IFTYPE_AP
:
5699 rcu_dereference_protected(mvm
->csa_vif
,
5700 lockdep_is_held(&mvm
->mutex
));
5701 if (WARN_ONCE(csa_vif
&& csa_vif
->bss_conf
.csa_active
,
5702 "Another CSA is already in progress"))
5705 /* we still didn't unblock tx. prevent new CS meanwhile */
5706 if (rcu_dereference_protected(mvm
->csa_tx_blocked_vif
,
5707 lockdep_is_held(&mvm
->mutex
)))
5710 rcu_assign_pointer(mvm
->csa_vif
, vif
);
5712 if (WARN_ONCE(mvmvif
->csa_countdown
,
5713 "Previous CSA countdown didn't complete"))
5716 mvmvif
->csa_target_freq
= chsw
->chandef
.chan
->center_freq
;
5718 if (!chsw
->block_tx
)
5720 /* don't need blocking in driver otherwise - mac80211 will do */
5721 if (!ieee80211_hw_check(mvm
->hw
, HANDLES_QUIET_CSA
))
5724 mvmvif
->csa_blocks_tx
= true;
5725 mvmtxq
= iwl_mvm_txq_from_mac80211(vif
->txq
);
5726 set_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA
, &mvmtxq
->state
);
5727 ieee80211_iterate_stations_atomic(mvm
->hw
,
5728 iwl_mvm_csa_block_txqs
,
5731 case NL80211_IFTYPE_STATION
:
5732 mvmvif
->csa_blocks_tx
= chsw
->block_tx
;
5735 * In the new flow FW is in charge of timing the switch so there
5736 * is no need for all of this
5738 if (iwl_fw_lookup_notif_ver(mvm
->fw
, MAC_CONF_GROUP
,
5739 CHANNEL_SWITCH_ERROR_NOTIF
,
5744 * We haven't configured the firmware to be associated yet since
5745 * we don't know the dtim period. In this case, the firmware can't
5746 * track the beacons.
5748 if (!vif
->cfg
.assoc
|| !vif
->bss_conf
.dtim_period
)
5751 if (chsw
->delay
> IWL_MAX_CSA_BLOCK_TX
&&
5752 hweight16(vif
->valid_links
) <= 1)
5753 schedule_delayed_work(&mvmvif
->csa_work
, 0);
5755 if (chsw
->block_tx
) {
5757 * In case of undetermined / long time with immediate
5758 * quiet monitor status to gracefully disconnect
5761 chsw
->count
* vif
->bss_conf
.beacon_int
>
5762 IWL_MAX_CSA_BLOCK_TX
)
5763 schedule_delayed_work(&mvmvif
->csa_work
,
5764 msecs_to_jiffies(IWL_MAX_CSA_BLOCK_TX
));
5767 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
5768 IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD
)) {
5769 ret
= iwl_mvm_old_pre_chan_sw_sta(mvm
, vif
, chsw
);
5773 iwl_mvm_schedule_client_csa(mvm
, vif
, chsw
);
5776 mvmvif
->csa_count
= chsw
->count
;
5777 mvmvif
->csa_misbehave
= false;
5783 mvmvif
->ps_disabled
= true;
5785 ret
= iwl_mvm_power_update_ps(mvm
);
5789 /* we won't be on this channel any longer */
5790 iwl_mvm_teardown_tdls_peers(mvm
);
5795 static int iwl_mvm_mac_pre_channel_switch(struct ieee80211_hw
*hw
,
5796 struct ieee80211_vif
*vif
,
5797 struct ieee80211_channel_switch
*chsw
)
5799 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5802 return iwl_mvm_pre_channel_switch(mvm
, vif
, chsw
);
5805 void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw
*hw
,
5806 struct ieee80211_vif
*vif
,
5807 struct ieee80211_channel_switch
*chsw
)
5809 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5810 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5811 struct iwl_chan_switch_te_cmd cmd
= {
5812 .mac_id
= cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif
->id
,
5814 .action
= cpu_to_le32(FW_CTXT_ACTION_MODIFY
),
5815 .tsf
= cpu_to_le32(chsw
->timestamp
),
5816 .cs_count
= chsw
->count
,
5817 .cs_mode
= chsw
->block_tx
,
5821 * In the new flow FW is in charge of timing the switch so there is no
5822 * need for all of this
5824 if (iwl_fw_lookup_notif_ver(mvm
->fw
, MAC_CONF_GROUP
,
5825 CHANNEL_SWITCH_ERROR_NOTIF
, 0))
5828 if (!fw_has_capa(&mvm
->fw
->ucode_capa
, IWL_UCODE_TLV_CAPA_CS_MODIFY
))
5831 IWL_DEBUG_MAC80211(mvm
, "Modify CSA on mac %d count = %d (old %d) mode = %d\n",
5832 mvmvif
->id
, chsw
->count
, mvmvif
->csa_count
, chsw
->block_tx
);
5834 if (chsw
->count
>= mvmvif
->csa_count
&& chsw
->block_tx
) {
5835 if (mvmvif
->csa_misbehave
) {
5836 struct ieee80211_bss_conf
*link_conf
;
5838 /* Second time, give up on this AP*/
5840 link_conf
= wiphy_dereference(hw
->wiphy
,
5841 vif
->link_conf
[chsw
->link_id
]);
5842 if (WARN_ON(!link_conf
))
5845 iwl_mvm_abort_channel_switch(hw
, vif
, link_conf
);
5846 ieee80211_chswitch_done(vif
, false, 0);
5847 mvmvif
->csa_misbehave
= false;
5850 mvmvif
->csa_misbehave
= true;
5852 mvmvif
->csa_count
= chsw
->count
;
5855 if (mvmvif
->csa_failed
)
5858 WARN_ON(iwl_mvm_send_cmd_pdu(mvm
,
5859 WIDE_ID(MAC_CONF_GROUP
,
5860 CHANNEL_SWITCH_TIME_EVENT_CMD
),
5861 0, sizeof(cmd
), &cmd
));
5864 static void iwl_mvm_flush_no_vif(struct iwl_mvm
*mvm
, u32 queues
, bool drop
)
5868 if (!iwl_mvm_has_new_tx_api(mvm
)) {
5869 /* we can't ask the firmware anything if it is dead */
5870 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
,
5875 iwl_mvm_flush_tx_path(mvm
,
5876 iwl_mvm_flushable_queues(mvm
) & queues
);
5878 iwl_trans_wait_tx_queues_empty(mvm
->trans
, queues
);
5884 for (i
= 0; i
< mvm
->fw
->ucode_capa
.num_stations
; i
++) {
5885 struct ieee80211_sta
*sta
;
5887 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[i
],
5888 lockdep_is_held(&mvm
->mutex
));
5889 if (IS_ERR_OR_NULL(sta
))
5893 iwl_mvm_flush_sta_tids(mvm
, i
, 0xFFFF);
5895 iwl_mvm_wait_sta_queues_empty(mvm
,
5896 iwl_mvm_sta_from_mac80211(sta
));
5900 void iwl_mvm_mac_flush(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
5901 u32 queues
, bool drop
)
5903 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
5904 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5905 struct iwl_mvm_sta
*mvmsta
;
5906 struct ieee80211_sta
*sta
;
5907 bool ap_sta_done
= false;
5912 iwl_mvm_flush_no_vif(mvm
, queues
, drop
);
5916 if (!drop
&& hweight16(vif
->active_links
) <= 1) {
5917 int link_id
= vif
->active_links
? __ffs(vif
->active_links
) : 0;
5918 struct ieee80211_bss_conf
*link_conf
;
5920 link_conf
= wiphy_dereference(hw
->wiphy
,
5921 vif
->link_conf
[link_id
]);
5922 if (WARN_ON(!link_conf
))
5924 if (link_conf
->csa_active
&& mvmvif
->csa_blocks_tx
)
5928 /* Make sure we're done with the deferred traffic before flushing */
5929 flush_work(&mvm
->add_stream_wk
);
5931 mutex_lock(&mvm
->mutex
);
5933 /* flush the AP-station and all TDLS peers */
5934 for (i
= 0; i
< mvm
->fw
->ucode_capa
.num_stations
; i
++) {
5935 sta
= rcu_dereference_protected(mvm
->fw_id_to_mac_id
[i
],
5936 lockdep_is_held(&mvm
->mutex
));
5937 if (IS_ERR_OR_NULL(sta
))
5940 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
5941 if (mvmsta
->vif
!= vif
)
5944 if (sta
== mvmvif
->ap_sta
) {
5951 if (iwl_mvm_flush_sta(mvm
, mvmsta
->deflink
.sta_id
,
5952 mvmsta
->tfd_queue_msk
))
5953 IWL_ERR(mvm
, "flush request fail\n");
5955 if (iwl_mvm_has_new_tx_api(mvm
))
5956 iwl_mvm_wait_sta_queues_empty(mvm
, mvmsta
);
5957 else /* only used for !iwl_mvm_has_new_tx_api() below */
5958 msk
|= mvmsta
->tfd_queue_msk
;
5962 mutex_unlock(&mvm
->mutex
);
5964 /* this can take a while, and we may need/want other operations
5965 * to succeed while doing this, so do it without the mutex held
5966 * If the firmware is dead, this can't work...
5968 if (!drop
&& !iwl_mvm_has_new_tx_api(mvm
) &&
5969 !test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED
,
5971 iwl_trans_wait_tx_queues_empty(mvm
->trans
, msk
);
5974 void iwl_mvm_mac_flush_sta(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
5975 struct ieee80211_sta
*sta
)
5977 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
5978 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
5979 struct iwl_mvm_link_sta
*mvm_link_sta
;
5980 struct ieee80211_link_sta
*link_sta
;
5984 for_each_sta_active_link(vif
, sta
, link_sta
, link_id
) {
5985 mvm_link_sta
= rcu_dereference_protected(mvmsta
->link
[link_id
],
5986 lockdep_is_held(&mvm
->mutex
));
5990 if (iwl_mvm_flush_sta(mvm
, mvm_link_sta
->sta_id
,
5991 mvmsta
->tfd_queue_msk
))
5992 IWL_ERR(mvm
, "flush request fail\n");
5996 static int iwl_mvm_mac_get_acs_survey(struct iwl_mvm
*mvm
, int idx
,
5997 struct survey_info
*survey
)
6000 enum nl80211_band band
;
6003 mutex_lock(&mvm
->mutex
);
6005 if (!mvm
->acs_survey
) {
6010 /* Find and return the next entry that has a non-zero active time */
6011 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
6012 struct ieee80211_supported_band
*sband
=
6013 mvm
->hw
->wiphy
->bands
[band
];
6018 for (chan_idx
= 0; chan_idx
< sband
->n_channels
; chan_idx
++) {
6019 struct iwl_mvm_acs_survey_channel
*info
=
6020 &mvm
->acs_survey
->bands
[band
][chan_idx
];
6025 /* Found (the next) channel to report */
6026 survey
->channel
= &sband
->channels
[chan_idx
];
6027 survey
->filled
= SURVEY_INFO_TIME
|
6028 SURVEY_INFO_TIME_BUSY
|
6029 SURVEY_INFO_TIME_RX
|
6030 SURVEY_INFO_TIME_TX
;
6031 survey
->time
= info
->time
;
6032 survey
->time_busy
= info
->time_busy
;
6033 survey
->time_rx
= info
->time_rx
;
6034 survey
->time_tx
= info
->time_tx
;
6035 survey
->noise
= info
->noise
;
6036 if (survey
->noise
< 0)
6037 survey
->filled
|= SURVEY_INFO_NOISE_DBM
;
6039 /* Clear time so that channel is only reported once */
6050 mutex_unlock(&mvm
->mutex
);
6055 int iwl_mvm_mac_get_survey(struct ieee80211_hw
*hw
, int idx
,
6056 struct survey_info
*survey
)
6058 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6059 u8 cmd_ver
= iwl_fw_lookup_cmd_ver(mvm
->fw
,
6060 WIDE_ID(SYSTEM_GROUP
,
6061 SYSTEM_STATISTICS_CMD
),
6062 IWL_FW_CMD_VER_UNKNOWN
);
6064 memset(survey
, 0, sizeof(*survey
));
6066 if (!fw_has_capa(&mvm
->fw
->ucode_capa
,
6067 IWL_UCODE_TLV_CAPA_RADIO_BEACON_STATS
))
6071 * Return the beacon stats at index zero and pass on following indices
6072 * to the function returning the full survey, most likely for ACS
6073 * (Automatic Channel Selection).
6076 return iwl_mvm_mac_get_acs_survey(mvm
, idx
- 1, survey
);
6080 if (iwl_mvm_firmware_running(mvm
)) {
6081 int ret
= iwl_mvm_request_statistics(mvm
, false);
6087 survey
->filled
= SURVEY_INFO_TIME_RX
|
6088 SURVEY_INFO_TIME_TX
;
6090 survey
->time_rx
= mvm
->accu_radio_stats
.rx_time
+
6091 mvm
->radio_stats
.rx_time
;
6092 do_div(survey
->time_rx
, USEC_PER_MSEC
);
6094 survey
->time_tx
= mvm
->accu_radio_stats
.tx_time
+
6095 mvm
->radio_stats
.tx_time
;
6096 do_div(survey
->time_tx
, USEC_PER_MSEC
);
6098 /* the new fw api doesn't support the following fields */
6099 if (cmd_ver
!= IWL_FW_CMD_VER_UNKNOWN
)
6102 survey
->filled
|= SURVEY_INFO_TIME
|
6103 SURVEY_INFO_TIME_SCAN
;
6104 survey
->time
= mvm
->accu_radio_stats
.on_time_rf
+
6105 mvm
->radio_stats
.on_time_rf
;
6106 do_div(survey
->time
, USEC_PER_MSEC
);
6108 survey
->time_scan
= mvm
->accu_radio_stats
.on_time_scan
+
6109 mvm
->radio_stats
.on_time_scan
;
6110 do_div(survey
->time_scan
, USEC_PER_MSEC
);
6115 static void iwl_mvm_set_sta_rate(u32 rate_n_flags
, struct rate_info
*rinfo
)
6117 u32 format
= rate_n_flags
& RATE_MCS_MOD_TYPE_MSK
;
6120 switch (rate_n_flags
& RATE_MCS_CHAN_WIDTH_MSK
) {
6121 case RATE_MCS_CHAN_WIDTH_20
:
6122 rinfo
->bw
= RATE_INFO_BW_20
;
6124 case RATE_MCS_CHAN_WIDTH_40
:
6125 rinfo
->bw
= RATE_INFO_BW_40
;
6127 case RATE_MCS_CHAN_WIDTH_80
:
6128 rinfo
->bw
= RATE_INFO_BW_80
;
6130 case RATE_MCS_CHAN_WIDTH_160
:
6131 rinfo
->bw
= RATE_INFO_BW_160
;
6133 case RATE_MCS_CHAN_WIDTH_320
:
6134 rinfo
->bw
= RATE_INFO_BW_320
;
6138 if (format
== RATE_MCS_CCK_MSK
||
6139 format
== RATE_MCS_LEGACY_OFDM_MSK
) {
6140 int rate
= u32_get_bits(rate_n_flags
, RATE_LEGACY_RATE_MSK
);
6142 /* add the offset needed to get to the legacy ofdm indices */
6143 if (format
== RATE_MCS_LEGACY_OFDM_MSK
)
6144 rate
+= IWL_FIRST_OFDM_RATE
;
6147 case IWL_RATE_1M_INDEX
:
6150 case IWL_RATE_2M_INDEX
:
6153 case IWL_RATE_5M_INDEX
:
6156 case IWL_RATE_11M_INDEX
:
6157 rinfo
->legacy
= 110;
6159 case IWL_RATE_6M_INDEX
:
6162 case IWL_RATE_9M_INDEX
:
6165 case IWL_RATE_12M_INDEX
:
6166 rinfo
->legacy
= 120;
6168 case IWL_RATE_18M_INDEX
:
6169 rinfo
->legacy
= 180;
6171 case IWL_RATE_24M_INDEX
:
6172 rinfo
->legacy
= 240;
6174 case IWL_RATE_36M_INDEX
:
6175 rinfo
->legacy
= 360;
6177 case IWL_RATE_48M_INDEX
:
6178 rinfo
->legacy
= 480;
6180 case IWL_RATE_54M_INDEX
:
6181 rinfo
->legacy
= 540;
6186 rinfo
->nss
= u32_get_bits(rate_n_flags
,
6187 RATE_MCS_NSS_MSK
) + 1;
6188 rinfo
->mcs
= format
== RATE_MCS_HT_MSK
?
6189 RATE_HT_MCS_INDEX(rate_n_flags
) :
6190 u32_get_bits(rate_n_flags
, RATE_MCS_CODE_MSK
);
6192 if (rate_n_flags
& RATE_MCS_SGI_MSK
)
6193 rinfo
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
6196 case RATE_MCS_EHT_MSK
:
6197 /* TODO: GI/LTF/RU. How does the firmware encode them? */
6198 rinfo
->flags
|= RATE_INFO_FLAGS_EHT_MCS
;
6200 case RATE_MCS_HE_MSK
:
6201 gi_ltf
= u32_get_bits(rate_n_flags
, RATE_MCS_HE_GI_LTF_MSK
);
6203 rinfo
->flags
|= RATE_INFO_FLAGS_HE_MCS
;
6205 if (rate_n_flags
& RATE_MCS_HE_106T_MSK
) {
6206 rinfo
->bw
= RATE_INFO_BW_HE_RU
;
6207 rinfo
->he_ru_alloc
= NL80211_RATE_INFO_HE_RU_ALLOC_106
;
6210 switch (rate_n_flags
& RATE_MCS_HE_TYPE_MSK
) {
6211 case RATE_MCS_HE_TYPE_SU
:
6212 case RATE_MCS_HE_TYPE_EXT_SU
:
6213 if (gi_ltf
== 0 || gi_ltf
== 1)
6214 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_0_8
;
6215 else if (gi_ltf
== 2)
6216 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_1_6
;
6217 else if (gi_ltf
== 3)
6218 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_3_2
;
6220 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_0_8
;
6222 case RATE_MCS_HE_TYPE_MU
:
6223 if (gi_ltf
== 0 || gi_ltf
== 1)
6224 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_0_8
;
6225 else if (gi_ltf
== 2)
6226 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_1_6
;
6228 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_3_2
;
6230 case RATE_MCS_HE_TYPE_TRIG
:
6231 if (gi_ltf
== 0 || gi_ltf
== 1)
6232 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_1_6
;
6234 rinfo
->he_gi
= NL80211_RATE_INFO_HE_GI_3_2
;
6238 if (rate_n_flags
& RATE_HE_DUAL_CARRIER_MODE_MSK
)
6241 case RATE_MCS_HT_MSK
:
6242 rinfo
->flags
|= RATE_INFO_FLAGS_MCS
;
6244 case RATE_MCS_VHT_MSK
:
6245 rinfo
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
6250 void iwl_mvm_mac_sta_statistics(struct ieee80211_hw
*hw
,
6251 struct ieee80211_vif
*vif
,
6252 struct ieee80211_sta
*sta
,
6253 struct station_info
*sinfo
)
6255 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6256 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
6257 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
6260 if (mvmsta
->deflink
.avg_energy
) {
6261 sinfo
->signal_avg
= -(s8
)mvmsta
->deflink
.avg_energy
;
6262 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG
);
6265 if (iwl_mvm_has_tlc_offload(mvm
)) {
6266 struct iwl_lq_sta_rs_fw
*lq_sta
= &mvmsta
->deflink
.lq_sta
.rs_fw
;
6268 iwl_mvm_set_sta_rate(lq_sta
->last_rate_n_flags
, &sinfo
->txrate
);
6269 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_TX_BITRATE
);
6272 /* if beacon filtering isn't on mac80211 does it anyway */
6273 if (!(vif
->driver_flags
& IEEE80211_VIF_BEACON_FILTER
))
6276 if (!vif
->cfg
.assoc
)
6281 if (mvmvif
->deflink
.ap_sta_id
!= mvmsta
->deflink
.sta_id
)
6284 if (iwl_mvm_request_statistics(mvm
, false))
6287 sinfo
->rx_beacon
= 0;
6288 for_each_mvm_vif_valid_link(mvmvif
, i
)
6289 sinfo
->rx_beacon
+= mvmvif
->link
[i
]->beacon_stats
.num_beacons
+
6290 mvmvif
->link
[i
]->beacon_stats
.accu_num_beacons
;
6292 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_BEACON_RX
);
6293 if (mvmvif
->deflink
.beacon_stats
.avg_signal
) {
6294 /* firmware only reports a value after RXing a few beacons */
6295 sinfo
->rx_beacon_signal_avg
=
6296 mvmvif
->deflink
.beacon_stats
.avg_signal
;
6297 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG
);
6301 static void iwl_mvm_event_mlme_callback_ini(struct iwl_mvm
*mvm
,
6302 struct ieee80211_vif
*vif
,
6303 const struct ieee80211_mlme_event
*mlme
)
6305 if ((mlme
->data
== ASSOC_EVENT
|| mlme
->data
== AUTH_EVENT
) &&
6306 (mlme
->status
== MLME_DENIED
|| mlme
->status
== MLME_TIMEOUT
)) {
6307 iwl_dbg_tlv_time_point(&mvm
->fwrt
,
6308 IWL_FW_INI_TIME_POINT_ASSOC_FAILED
,
6313 if (mlme
->data
== DEAUTH_RX_EVENT
|| mlme
->data
== DEAUTH_TX_EVENT
) {
6314 iwl_dbg_tlv_time_point(&mvm
->fwrt
,
6315 IWL_FW_INI_TIME_POINT_DEASSOC
,
6321 static void iwl_mvm_event_mlme_callback(struct iwl_mvm
*mvm
,
6322 struct ieee80211_vif
*vif
,
6323 const struct ieee80211_event
*event
)
6325 #define CHECK_MLME_TRIGGER(_cnt, _fmt...) \
6327 if ((trig_mlme->_cnt) && --(trig_mlme->_cnt)) \
6329 iwl_fw_dbg_collect_trig(&(mvm)->fwrt, trig, _fmt); \
6332 struct iwl_fw_dbg_trigger_tlv
*trig
;
6333 struct iwl_fw_dbg_trigger_mlme
*trig_mlme
;
6335 if (iwl_trans_dbg_ini_valid(mvm
->trans
)) {
6336 iwl_mvm_event_mlme_callback_ini(mvm
, vif
, &event
->u
.mlme
);
6340 trig
= iwl_fw_dbg_trigger_on(&mvm
->fwrt
, ieee80211_vif_to_wdev(vif
),
6341 FW_DBG_TRIGGER_MLME
);
6345 trig_mlme
= (void *)trig
->data
;
6347 if (event
->u
.mlme
.data
== ASSOC_EVENT
) {
6348 if (event
->u
.mlme
.status
== MLME_DENIED
)
6349 CHECK_MLME_TRIGGER(stop_assoc_denied
,
6350 "DENIED ASSOC: reason %d",
6351 event
->u
.mlme
.reason
);
6352 else if (event
->u
.mlme
.status
== MLME_TIMEOUT
)
6353 CHECK_MLME_TRIGGER(stop_assoc_timeout
,
6355 } else if (event
->u
.mlme
.data
== AUTH_EVENT
) {
6356 if (event
->u
.mlme
.status
== MLME_DENIED
)
6357 CHECK_MLME_TRIGGER(stop_auth_denied
,
6358 "DENIED AUTH: reason %d",
6359 event
->u
.mlme
.reason
);
6360 else if (event
->u
.mlme
.status
== MLME_TIMEOUT
)
6361 CHECK_MLME_TRIGGER(stop_auth_timeout
,
6363 } else if (event
->u
.mlme
.data
== DEAUTH_RX_EVENT
) {
6364 CHECK_MLME_TRIGGER(stop_rx_deauth
,
6365 "DEAUTH RX %d", event
->u
.mlme
.reason
);
6366 } else if (event
->u
.mlme
.data
== DEAUTH_TX_EVENT
) {
6367 CHECK_MLME_TRIGGER(stop_tx_deauth
,
6368 "DEAUTH TX %d", event
->u
.mlme
.reason
);
6370 #undef CHECK_MLME_TRIGGER
6373 static void iwl_mvm_event_bar_rx_callback(struct iwl_mvm
*mvm
,
6374 struct ieee80211_vif
*vif
,
6375 const struct ieee80211_event
*event
)
6377 struct iwl_fw_dbg_trigger_tlv
*trig
;
6378 struct iwl_fw_dbg_trigger_ba
*ba_trig
;
6380 trig
= iwl_fw_dbg_trigger_on(&mvm
->fwrt
, ieee80211_vif_to_wdev(vif
),
6385 ba_trig
= (void *)trig
->data
;
6387 if (!(le16_to_cpu(ba_trig
->rx_bar
) & BIT(event
->u
.ba
.tid
)))
6390 iwl_fw_dbg_collect_trig(&mvm
->fwrt
, trig
,
6391 "BAR received from %pM, tid %d, ssn %d",
6392 event
->u
.ba
.sta
->addr
, event
->u
.ba
.tid
,
6396 void iwl_mvm_mac_event_callback(struct ieee80211_hw
*hw
,
6397 struct ieee80211_vif
*vif
,
6398 const struct ieee80211_event
*event
)
6400 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6402 switch (event
->type
) {
6404 iwl_mvm_event_mlme_callback(mvm
, vif
, event
);
6407 iwl_mvm_event_bar_rx_callback(mvm
, vif
, event
);
6409 case BA_FRAME_TIMEOUT
:
6410 iwl_mvm_event_frame_timeout_callback(mvm
, vif
, event
->u
.ba
.sta
,
6418 #define SYNC_RX_QUEUE_TIMEOUT (HZ)
6419 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm
*mvm
,
6420 enum iwl_mvm_rxq_notif_type type
,
6422 const void *data
, u32 size
)
6425 struct iwl_rxq_sync_cmd cmd
;
6426 struct iwl_mvm_internal_rxq_notif notif
;
6428 .cmd
.rxq_mask
= cpu_to_le32(BIT(mvm
->trans
->num_rx_queues
) - 1),
6430 cpu_to_le32(sizeof(struct iwl_mvm_internal_rxq_notif
) +
6435 struct iwl_host_cmd hcmd
= {
6436 .id
= WIDE_ID(DATA_PATH_GROUP
, TRIGGER_RX_QUEUES_NOTIF_CMD
),
6438 .len
[0] = sizeof(cmd
),
6441 .flags
= CMD_SEND_IN_RFKILL
| (sync
? 0 : CMD_ASYNC
),
6445 /* size must be a multiple of DWORD */
6446 if (WARN_ON(cmd
.cmd
.count
& cpu_to_le32(3)))
6449 if (!iwl_mvm_has_new_rx_api(mvm
))
6453 cmd
.notif
.cookie
= mvm
->queue_sync_cookie
;
6454 mvm
->queue_sync_state
= (1 << mvm
->trans
->num_rx_queues
) - 1;
6457 ret
= iwl_mvm_send_cmd(mvm
, &hcmd
);
6459 IWL_ERR(mvm
, "Failed to trigger RX queues sync (%d)\n", ret
);
6464 lockdep_assert_held(&mvm
->mutex
);
6465 ret
= wait_event_timeout(mvm
->rx_sync_waitq
,
6466 READ_ONCE(mvm
->queue_sync_state
) == 0,
6467 SYNC_RX_QUEUE_TIMEOUT
);
6468 WARN_ONCE(!ret
, "queue sync: failed to sync, state is 0x%lx, cookie %d\n",
6469 mvm
->queue_sync_state
,
6470 mvm
->queue_sync_cookie
);
6475 mvm
->queue_sync_state
= 0;
6476 mvm
->queue_sync_cookie
++;
6480 void iwl_mvm_sync_rx_queues(struct ieee80211_hw
*hw
)
6482 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6485 iwl_mvm_sync_rx_queues_internal(mvm
, IWL_MVM_RXQ_EMPTY
, true, NULL
, 0);
6489 iwl_mvm_mac_get_ftm_responder_stats(struct ieee80211_hw
*hw
,
6490 struct ieee80211_vif
*vif
,
6491 struct cfg80211_ftm_responder_stats
*stats
)
6493 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6494 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
6496 if (vif
->p2p
|| vif
->type
!= NL80211_IFTYPE_AP
||
6497 !mvmvif
->ap_ibss_active
|| !vif
->bss_conf
.ftm_responder
)
6500 mutex_lock(&mvm
->mutex
);
6501 *stats
= mvm
->ftm_resp_stats
;
6502 mutex_unlock(&mvm
->mutex
);
6504 stats
->filled
= BIT(NL80211_FTM_STATS_SUCCESS_NUM
) |
6505 BIT(NL80211_FTM_STATS_PARTIAL_NUM
) |
6506 BIT(NL80211_FTM_STATS_FAILED_NUM
) |
6507 BIT(NL80211_FTM_STATS_ASAP_NUM
) |
6508 BIT(NL80211_FTM_STATS_NON_ASAP_NUM
) |
6509 BIT(NL80211_FTM_STATS_TOTAL_DURATION_MSEC
) |
6510 BIT(NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM
) |
6511 BIT(NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM
) |
6512 BIT(NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM
);
6517 int iwl_mvm_start_pmsr(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
6518 struct cfg80211_pmsr_request
*request
)
6520 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6523 return iwl_mvm_ftm_start(mvm
, vif
, request
);
6526 void iwl_mvm_abort_pmsr(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
6527 struct cfg80211_pmsr_request
*request
)
6529 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6532 iwl_mvm_ftm_abort(mvm
, request
);
6535 static bool iwl_mvm_can_hw_csum(struct sk_buff
*skb
)
6537 u8 protocol
= ip_hdr(skb
)->protocol
;
6539 if (!IS_ENABLED(CONFIG_INET
))
6542 return protocol
== IPPROTO_TCP
|| protocol
== IPPROTO_UDP
;
6545 static bool iwl_mvm_mac_can_aggregate(struct ieee80211_hw
*hw
,
6546 struct sk_buff
*head
,
6547 struct sk_buff
*skb
)
6549 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6551 /* For now don't aggregate IPv6 in AMSDU */
6552 if (skb
->protocol
!= htons(ETH_P_IP
))
6555 if (!iwl_mvm_is_csum_supported(mvm
))
6558 return iwl_mvm_can_hw_csum(skb
) == iwl_mvm_can_hw_csum(head
);
6561 int iwl_mvm_set_hw_timestamp(struct ieee80211_hw
*hw
,
6562 struct ieee80211_vif
*vif
,
6563 struct cfg80211_set_hw_timestamp
*hwts
)
6565 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
6568 /* HW timestamping is only supported for a specific station */
6574 IWL_TIME_SYNC_PROTOCOL_TM
| IWL_TIME_SYNC_PROTOCOL_FTM
;
6577 return iwl_mvm_time_sync_config(mvm
, hwts
->macaddr
, protocols
);
6580 const struct ieee80211_ops iwl_mvm_hw_ops
= {
6581 .tx
= iwl_mvm_mac_tx
,
6582 .wake_tx_queue
= iwl_mvm_mac_wake_tx_queue
,
6583 .ampdu_action
= iwl_mvm_mac_ampdu_action
,
6584 .get_antenna
= iwl_mvm_op_get_antenna
,
6585 .set_antenna
= iwl_mvm_op_set_antenna
,
6586 .start
= iwl_mvm_mac_start
,
6587 .reconfig_complete
= iwl_mvm_mac_reconfig_complete
,
6588 .stop
= iwl_mvm_mac_stop
,
6589 .add_interface
= iwl_mvm_mac_add_interface
,
6590 .remove_interface
= iwl_mvm_mac_remove_interface
,
6591 .config
= iwl_mvm_mac_config
,
6592 .prepare_multicast
= iwl_mvm_prepare_multicast
,
6593 .configure_filter
= iwl_mvm_configure_filter
,
6594 .config_iface_filter
= iwl_mvm_config_iface_filter
,
6595 .bss_info_changed
= iwl_mvm_bss_info_changed
,
6596 .hw_scan
= iwl_mvm_mac_hw_scan
,
6597 .cancel_hw_scan
= iwl_mvm_mac_cancel_hw_scan
,
6598 .sta_pre_rcu_remove
= iwl_mvm_sta_pre_rcu_remove
,
6599 .sta_state
= iwl_mvm_mac_sta_state
,
6600 .sta_notify
= iwl_mvm_mac_sta_notify
,
6601 .allow_buffered_frames
= iwl_mvm_mac_allow_buffered_frames
,
6602 .release_buffered_frames
= iwl_mvm_mac_release_buffered_frames
,
6603 .set_rts_threshold
= iwl_mvm_mac_set_rts_threshold
,
6604 .link_sta_rc_update
= iwl_mvm_sta_rc_update
,
6605 .conf_tx
= iwl_mvm_mac_conf_tx
,
6606 .mgd_prepare_tx
= iwl_mvm_mac_mgd_prepare_tx
,
6607 .mgd_complete_tx
= iwl_mvm_mac_mgd_complete_tx
,
6608 .mgd_protect_tdls_discover
= iwl_mvm_mac_mgd_protect_tdls_discover
,
6609 .flush
= iwl_mvm_mac_flush
,
6610 .flush_sta
= iwl_mvm_mac_flush_sta
,
6611 .sched_scan_start
= iwl_mvm_mac_sched_scan_start
,
6612 .sched_scan_stop
= iwl_mvm_mac_sched_scan_stop
,
6613 .set_key
= iwl_mvm_mac_set_key
,
6614 .update_tkip_key
= iwl_mvm_mac_update_tkip_key
,
6615 .remain_on_channel
= iwl_mvm_roc
,
6616 .cancel_remain_on_channel
= iwl_mvm_cancel_roc
,
6617 .add_chanctx
= iwl_mvm_add_chanctx
,
6618 .remove_chanctx
= iwl_mvm_remove_chanctx
,
6619 .change_chanctx
= iwl_mvm_change_chanctx
,
6620 .assign_vif_chanctx
= iwl_mvm_assign_vif_chanctx
,
6621 .unassign_vif_chanctx
= iwl_mvm_unassign_vif_chanctx
,
6622 .switch_vif_chanctx
= iwl_mvm_switch_vif_chanctx
,
6624 .start_ap
= iwl_mvm_start_ap
,
6625 .stop_ap
= iwl_mvm_stop_ap
,
6626 .join_ibss
= iwl_mvm_start_ibss
,
6627 .leave_ibss
= iwl_mvm_stop_ibss
,
6629 .tx_last_beacon
= iwl_mvm_tx_last_beacon
,
6631 .set_tim
= iwl_mvm_set_tim
,
6633 .channel_switch
= iwl_mvm_channel_switch
,
6634 .pre_channel_switch
= iwl_mvm_mac_pre_channel_switch
,
6635 .post_channel_switch
= iwl_mvm_post_channel_switch
,
6636 .abort_channel_switch
= iwl_mvm_abort_channel_switch
,
6637 .channel_switch_rx_beacon
= iwl_mvm_channel_switch_rx_beacon
,
6639 .tdls_channel_switch
= iwl_mvm_tdls_channel_switch
,
6640 .tdls_cancel_channel_switch
= iwl_mvm_tdls_cancel_channel_switch
,
6641 .tdls_recv_channel_switch
= iwl_mvm_tdls_recv_channel_switch
,
6643 .event_callback
= iwl_mvm_mac_event_callback
,
6645 .sync_rx_queues
= iwl_mvm_sync_rx_queues
,
6647 CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd
)
6649 #ifdef CONFIG_PM_SLEEP
6651 .suspend
= iwl_mvm_suspend
,
6652 .resume
= iwl_mvm_resume
,
6653 .set_wakeup
= iwl_mvm_set_wakeup
,
6654 .set_rekey_data
= iwl_mvm_set_rekey_data
,
6655 #if IS_ENABLED(CONFIG_IPV6)
6656 .ipv6_addr_change
= iwl_mvm_ipv6_addr_change
,
6658 .set_default_unicast_key
= iwl_mvm_set_default_unicast_key
,
6660 .get_survey
= iwl_mvm_mac_get_survey
,
6661 .sta_statistics
= iwl_mvm_mac_sta_statistics
,
6662 .get_ftm_responder_stats
= iwl_mvm_mac_get_ftm_responder_stats
,
6663 .start_pmsr
= iwl_mvm_start_pmsr
,
6664 .abort_pmsr
= iwl_mvm_abort_pmsr
,
6666 .can_aggregate_in_amsdu
= iwl_mvm_mac_can_aggregate
,
6667 #ifdef CONFIG_IWLWIFI_DEBUGFS
6668 .vif_add_debugfs
= iwl_mvm_vif_add_debugfs
,
6669 .link_sta_add_debugfs
= iwl_mvm_link_sta_add_debugfs
,
6671 .set_hw_timestamp
= iwl_mvm_set_hw_timestamp
,