Lines Matching +full:tlv +full:- +full:layout
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
25 #include "iwl-drv.h"
26 #include "iwl-op-mode.h"
27 #include "iwl-io.h"
30 #include "time-event.h"
31 #include "iwl-nvm-utils.h"
32 #include "iwl-phy-db.h"
36 #include "fw/error-dump.h"
37 #include "iwl-prph.h"
38 #include "iwl-nvm-parse.h"
39 #include "time-sync.h"
93 .max_bursts_exponent = -1, /* all supported */
117 memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts));
119 mvm->phy_ctxts[i].id = i;
120 mvm->phy_ctxts[i].ref = 0;
137 lockdep_assert_held(&mvm->mutex);
148 u32 status = le32_to_cpu(resp->status);
153 resp_ver = iwl_fw_lookup_notif_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP,
157 regd = iwl_parse_nvm_mcc_info(mvm->trans->dev, mvm->cfg,
158 __le32_to_cpu(resp->n_channels),
159 resp->channels,
160 __le16_to_cpu(resp->mcc),
161 __le16_to_cpu(resp->geo_info),
162 le32_to_cpu(resp->cap), resp_ver);
164 src_id = resp->source_id;
172 regd->alpha2, regd->alpha2[0], regd->alpha2[1], src_id);
173 mvm->lar_regdom_set = true;
174 mvm->mcc_src = src_id;
180 if (resp->mcc == cpu_to_le16(IWL_MCC_US) ||
181 resp->mcc == cpu_to_le16(IWL_MCC_CANADA))
182 ieee80211_hw_set(mvm->hw, DISALLOW_PUNCTURING);
184 __clear_bit(IEEE80211_HW_DISALLOW_PUNCTURING, mvm->hw->flags);
186 iwl_mei_set_country_code(__le16_to_cpu(resp->mcc));
205 regulatory_set_wiphy_regd(mvm->hw->wiphy, regd);
214 return iwl_mvm_get_regdomain(mvm->hw->wiphy, "ZZ",
227 wiphy_dereference(mvm->hw->wiphy, mvm->hw->wiphy->regd);
230 return -ENOENT;
233 used_src = mvm->mcc_src;
242 regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, r->alpha2, used_src,
245 return -EIO;
251 ret = regulatory_set_wiphy_regd_sync(mvm->hw->wiphy, regd);
325 if (mvm->trans->trans_cfg->device_family != IWL_DEVICE_FAMILY_9000 &&
326 mvm->trans->trans_cfg->device_family != IWL_DEVICE_FAMILY_22000)
327 return -EOPNOTSUPP;
329 if (!mvm->nvm_data)
330 return -EBUSY;
336 mvm->set_tx_ant = tx_ant;
337 mvm->set_rx_ant = rx_ant;
339 iwl_reinit_cab(mvm->trans, mvm->nvm_data, tx_ant, rx_ant, mvm->fw);
346 struct ieee80211_hw *hw = mvm->hw;
355 bool unified = fw_has_capa(&mvm->fw->ucode_capa,
359 u8 sec_key_ver = iwl_fw_lookup_cmd_ver(mvm->fw, sec_key_id, 0);
380 if (mvm->mld_api_is_used && mvm->nvm_data->sku_cap_11be_enable &&
383 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_MLO;
391 if (!mvm->mld_api_is_used)
395 * On older devices, enabling TX A-MSDU occasionally leads to
401 * support A-MSDU until moving the mac80211 iTXQs, just leave it
405 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_9000)
416 mvm->trans->trans_cfg->device_family > IWL_DEVICE_FAMILY_9000)
419 if (fw_has_capa(&mvm->fw->ucode_capa,
428 return -EINVAL;
431 if (mvm->trans->num_rx_queues > 1)
434 if (mvm->trans->max_skb_frags)
435 hw->netdev_features = NETIF_F_HIGHDMA | NETIF_F_SG;
437 hw->queues = IEEE80211_NUM_ACS;
438 hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE;
439 hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC |
441 hw->radiotap_vht_details |= IEEE80211_RADIOTAP_VHT_KNOWN_STBC |
444 hw->radiotap_timestamp.units_pos =
448 hw->radiotap_timestamp.accuracy = 22;
451 hw->rate_control_algorithm = RS_NAME;
453 hw->uapsd_queues = IWL_MVM_UAPSD_QUEUES;
454 hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP;
455 hw->max_tx_fragments = mvm->trans->max_skb_frags;
457 BUILD_BUG_ON(ARRAY_SIZE(mvm->ciphers) < ARRAY_SIZE(mvm_ciphers) + 6);
458 memcpy(mvm->ciphers, mvm_ciphers, sizeof(mvm_ciphers));
459 hw->wiphy->n_cipher_suites = ARRAY_SIZE(mvm_ciphers);
460 hw->wiphy->cipher_suites = mvm->ciphers;
463 mvm->ciphers[hw->wiphy->n_cipher_suites] =
465 hw->wiphy->n_cipher_suites++;
466 mvm->ciphers[hw->wiphy->n_cipher_suites] =
468 hw->wiphy->n_cipher_suites++;
479 mvm->ciphers[hw->wiphy->n_cipher_suites] = WLAN_CIPHER_SUITE_AES_CMAC;
480 hw->wiphy->n_cipher_suites++;
482 mvm->ciphers[hw->wiphy->n_cipher_suites] =
484 hw->wiphy->n_cipher_suites++;
485 mvm->ciphers[hw->wiphy->n_cipher_suites] =
487 hw->wiphy->n_cipher_suites++;
490 wiphy_ext_feature_set(hw->wiphy,
492 wiphy_ext_feature_set(hw->wiphy,
495 if (fw_has_capa(&mvm->fw->ucode_capa,
497 wiphy_ext_feature_set(hw->wiphy,
499 hw->wiphy->pmsr_capa = &iwl_mvm_pmsr_capa;
503 fw_has_capa(&mvm->fw->ucode_capa,
505 wiphy_ext_feature_set(hw->wiphy,
507 else if (fw_has_capa(&mvm->fw->ucode_capa,
509 wiphy_ext_feature_set(hw->wiphy,
512 if (fw_has_capa(&mvm->fw->ucode_capa,
514 hw->wiphy->hw_timestamp_max_peers = 1;
516 if (fw_has_capa(&mvm->fw->ucode_capa,
518 wiphy_ext_feature_set(hw->wiphy,
522 hw->wiphy->features |=
527 hw->sta_data_size = sizeof(struct iwl_mvm_sta);
528 hw->vif_data_size = sizeof(struct iwl_mvm_vif);
529 hw->chanctx_data_size = sizeof(u16);
530 hw->txq_data_size = sizeof(struct iwl_mvm_txq);
532 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
539 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
540 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
547 wiphy_ext_feature_set(hw->wiphy,
549 hw->wiphy->features |= NL80211_FEATURE_HT_IBSS;
551 hw->wiphy->regulatory_flags |= REGULATORY_ENABLE_RELAX_NO_IR;
553 hw->wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;
555 hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG |
558 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
559 wiphy_ext_feature_set(hw->wiphy,
562 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
563 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
564 hw->wiphy->flags |= WIPHY_FLAG_SPLIT_SCAN_6GHZ;
566 hw->wiphy->iface_combinations = iwl_mvm_iface_combinations;
567 hw->wiphy->n_iface_combinations =
570 hw->wiphy->max_remain_on_channel_duration = 10000;
571 hw->max_listen_interval = IWL_MVM_CONN_LISTEN_INTERVAL;
574 memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN);
575 hw->wiphy->addresses = mvm->addresses;
576 hw->wiphy->n_addresses = 1;
579 num_mac = (mvm->nvm_data->n_hw_addrs > 1) ?
580 min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1;
583 memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr,
585 mvm->addresses[i].addr[5]++;
586 hw->wiphy->n_addresses++;
591 hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm);
593 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
599 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN))
600 mvm->max_scans = IWL_MAX_UMAC_SCANS;
602 mvm->max_scans = IWL_MAX_LMAC_SCANS;
604 if (mvm->nvm_data->bands[NL80211_BAND_2GHZ].n_channels)
605 hw->wiphy->bands[NL80211_BAND_2GHZ] =
606 &mvm->nvm_data->bands[NL80211_BAND_2GHZ];
607 if (mvm->nvm_data->bands[NL80211_BAND_5GHZ].n_channels) {
608 hw->wiphy->bands[NL80211_BAND_5GHZ] =
609 &mvm->nvm_data->bands[NL80211_BAND_5GHZ];
611 if (fw_has_capa(&mvm->fw->ucode_capa,
613 fw_has_api(&mvm->fw->ucode_capa,
615 hw->wiphy->bands[NL80211_BAND_5GHZ]->vht_cap.cap |=
618 if (fw_has_capa(&mvm->fw->ucode_capa,
620 mvm->nvm_data->bands[NL80211_BAND_6GHZ].n_channels)
621 hw->wiphy->bands[NL80211_BAND_6GHZ] =
622 &mvm->nvm_data->bands[NL80211_BAND_6GHZ];
624 hw->wiphy->hw_version = mvm->trans->hw_id;
627 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
629 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
631 hw->wiphy->max_sched_scan_reqs = 1;
632 hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX;
633 hw->wiphy->max_match_sets = iwl_umac_scan_get_max_profiles(mvm->fw);
635 hw->wiphy->max_sched_scan_ie_len =
636 SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2;
637 hw->wiphy->max_sched_scan_plans = IWL_MAX_SCHED_SCAN_PLANS;
638 hw->wiphy->max_sched_scan_plan_interval = U16_MAX;
644 hw->wiphy->max_sched_scan_plan_iterations = 254;
646 hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN |
654 if (fw_has_capa(&mvm->fw->ucode_capa,
656 hw->wiphy->features |= NL80211_FEATURE_TX_POWER_INSERTION;
657 if (fw_has_capa(&mvm->fw->ucode_capa,
659 hw->wiphy->features |= NL80211_FEATURE_QUIET;
661 if (fw_has_capa(&mvm->fw->ucode_capa,
663 hw->wiphy->features |=
666 if (fw_has_capa(&mvm->fw->ucode_capa,
668 hw->wiphy->features |= NL80211_FEATURE_WFA_TPC_IE_IN_PROBES;
670 if (iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_KEK_KCK_MATERIAL,
672 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK;
674 if (fw_has_api(&mvm->fw->ucode_capa,
676 wiphy_ext_feature_set(hw->wiphy,
678 wiphy_ext_feature_set(hw->wiphy,
683 u8 scan_ver = iwl_fw_lookup_cmd_ver(mvm->fw, SCAN_REQ_UMAC, 0);
685 wiphy_ext_feature_set(hw->wiphy,
687 wiphy_ext_feature_set(hw->wiphy,
689 wiphy_ext_feature_set(hw->wiphy,
694 wiphy_ext_feature_set(hw->wiphy,
698 hw->wiphy->iftype_ext_capab = NULL;
699 hw->wiphy->num_iftype_ext_capab = 0;
701 if (mvm->nvm_data->sku_cap_11ax_enable &&
703 hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa;
704 hw->wiphy->num_iftype_ext_capab =
705 ARRAY_SIZE(add_iftypes_ext_capa) - 1;
711 if (iwl_fw_lookup_cmd_ver(mvm->fw,
715 IWL_DEBUG_INFO(mvm->trans, "Timing measurement supported\n");
717 if (!hw->wiphy->iftype_ext_capab) {
718 hw->wiphy->num_iftype_ext_capab = 1;
719 hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa +
720 ARRAY_SIZE(add_iftypes_ext_capa) - 1;
722 hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa + 1;
726 if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(LOCATION_GROUP,
729 wiphy_ext_feature_set(hw->wiphy,
732 if (fw_has_capa(&mvm->fw->ucode_capa,
734 wiphy_ext_feature_set(hw->wiphy,
738 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
743 if ((unified || mvm->fw->img[IWL_UCODE_WOWLAN].num_sec) &&
744 device_can_wakeup(mvm->trans->dev)) {
745 mvm->wowlan.flags |= WIPHY_WOWLAN_MAGIC_PKT |
750 mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY |
754 mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS;
755 mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN;
756 mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN;
757 mvm->wowlan.max_nd_match_sets =
758 iwl_umac_scan_get_max_profiles(mvm->fw);
759 hw->wiphy->wowlan = &mvm->wowlan;
767 if (fw_has_capa(&mvm->fw->ucode_capa,
770 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS;
774 if (fw_has_capa(&mvm->fw->ucode_capa,
777 hw->wiphy->features |= NL80211_FEATURE_TDLS_CHANNEL_SWITCH;
780 hw->netdev_features |= mvm->cfg->features;
782 hw->netdev_features &= ~IWL_CSUM_NETIF_FLAGS_MASK;
784 if (mvm->cfg->vht_mu_mimo_supported)
785 wiphy_ext_feature_set(hw->wiphy,
788 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_PROTECTED_TWT))
789 wiphy_ext_feature_set(hw->wiphy,
794 hw->wiphy->available_antennas_tx = iwl_mvm_get_valid_tx_ant(mvm);
795 hw->wiphy->available_antennas_rx = iwl_mvm_get_valid_rx_ant(mvm);
797 ret = ieee80211_register_hw(mvm->hw);
816 ieee80211_free_txskb(mvm->hw, skb);
823 struct ieee80211_sta *sta = control->sta;
825 struct ieee80211_hdr *hdr = (void *)skb->data;
826 bool offchannel = IEEE80211_SKB_CB(skb)->flags &
828 u32 link_id = u32_get_bits(info->control.flags,
833 IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n");
838 !test_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status) &&
839 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status))
846 if (ieee80211_is_mgmt(hdr->frame_control))
849 /* If there is no sta, and it's not offchannel - send through AP */
850 if (!sta && info->control.vif->type == NL80211_IFTYPE_STATION &&
853 iwl_mvm_vif_from_mac80211(info->control.vif);
854 u8 ap_sta_id = READ_ONCE(mvmvif->deflink.ap_sta_id);
856 if (ap_sta_id < mvm->fw->ucode_capa.num_stations) {
858 sta = rcu_dereference(mvm->fw_id_to_mac_id[ap_sta_id]);
865 !ieee80211_is_probe_resp(hdr->frame_control)) {
868 rcu_dereference(tmp_sta->link[link_id]);
870 rcu_dereference(info->control.vif->link_conf[link_id]);
878 memcpy(mgmt->da, link_sta->addr, ETH_ALEN);
879 memcpy(mgmt->sa, link_conf->addr, ETH_ALEN);
880 memcpy(mgmt->bssid, link_conf->bssid, ETH_ALEN);
899 * mvmtxq->tx_request logic:
914 if (atomic_fetch_add_unless(&mvmtxq->tx_request, 1, 2))
920 &mvmtxq->state) &&
922 &mvmtxq->state) &&
924 &mvmtxq->state) &&
925 !test_bit(IWL_MVM_STATUS_IN_D3, &mvm->status))) {
929 if (txq->sta)
932 txq->sta->addr,
933 txq->tid);
937 iwl_mvm_tx_skb(mvm, skb, txq->sta);
939 } while (atomic_dec_return(&mvmtxq->tx_request));
949 if (likely(test_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state)) ||
950 !txq->sta) {
959 spin_lock_bh(&mvm->add_stream_lock);
961 if (list_empty(&mvmtxq->list) &&
963 !test_bit(IWL_MVM_TXQ_STATE_READY, &mvmtxq->state)) {
964 list_add_tail(&mvmtxq->list, &mvm->add_stream_txqs);
965 schedule_work(&mvm->add_stream_wk);
967 spin_unlock_bh(&mvm->add_stream_lock);
974 iwl_fw_dbg_collect_trig(&(_mvm)->fwrt, _trig, _fmt); \
985 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
990 ba_trig = (void *)trig->data;
995 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
997 CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_start, tid,
999 sta->addr, tid, tid_data->ssn);
1003 CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_stop, tid,
1005 sta->addr, tid);
1008 CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_start, tid,
1010 sta->addr, tid, rx_ba_ssn);
1013 CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_stop, tid,
1015 sta->addr, tid);
1028 struct ieee80211_sta *sta = params->sta;
1029 enum ieee80211_ampdu_mlme_action action = params->action;
1030 u16 tid = params->tid;
1031 u16 *ssn = ¶ms->ssn;
1032 u16 buf_size = params->buf_size;
1033 bool amsdu = params->amsdu;
1034 u16 timeout = params->timeout;
1036 IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n",
1037 sta->addr, tid, action);
1039 if (!(mvm->nvm_data->sku_cap_11n_enable))
1040 return -EACCES;
1042 mutex_lock(&mvm->mutex);
1046 if (iwl_mvm_vif_from_mac80211(vif)->deflink.ap_sta_id ==
1047 iwl_mvm_sta_from_mac80211(sta)->deflink.sta_id) {
1049 u16 macid = iwl_mvm_vif_from_mac80211(vif)->id;
1050 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[macid];
1052 mdata->opened_rx_ba_sessions = true;
1054 cancel_delayed_work(&mvmvif->uapsd_nonagg_detected_wk);
1057 ret = -EINVAL;
1069 ret = -EINVAL;
1087 ret = -EINVAL;
1100 mutex_unlock(&mvm->mutex);
1113 mvmvif->uploaded = false;
1115 spin_lock_bh(&mvm->time_event_lock);
1116 iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data);
1117 spin_unlock_bh(&mvm->time_event_lock);
1119 mvmvif->roc_activity = ROC_NUM_ACTIVITIES;
1121 mvmvif->bf_enabled = false;
1122 mvmvif->ba_enabled = false;
1123 mvmvif->ap_sta = NULL;
1125 mvmvif->esr_active = false;
1126 vif->driver_flags &= ~IEEE80211_VIF_EML_ACTIVE;
1129 mvmvif->link[link_id]->ap_sta_id = IWL_MVM_INVALID_STA;
1130 mvmvif->link[link_id]->fw_link_id = IWL_MVM_FW_LINK_ID_INVALID;
1131 mvmvif->link[link_id]->phy_ctxt = NULL;
1132 mvmvif->link[link_id]->active = 0;
1133 mvmvif->link[link_id]->igtk = NULL;
1134 memset(&mvmvif->link[link_id]->bf_data, 0,
1135 sizeof(mvmvif->link[link_id]->bf_data));
1138 probe_data = rcu_dereference_protected(mvmvif->deflink.probe_resp_data,
1139 lockdep_is_held(&mvm->mutex));
1142 RCU_INIT_POINTER(mvmvif->deflink.probe_resp_data, NULL);
1153 vif = mvm_sta->vif;
1155 if (!sta->valid_links)
1158 for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) {
1162 rcu_dereference_check(mvm_sta->link[link_id],
1163 lockdep_is_held(&mvm->mutex));
1164 if (mvm_link_sta && !(vif->active_links & BIT(link_id))) {
1182 mvm->cur_aid = 0;
1184 mvm->scan_status = 0;
1185 mvm->ps_disabled = false;
1186 mvm->rfkill_safe_init_done = false;
1190 ieee80211_remain_on_channel_expired(mvm->hw);
1198 ieee80211_iterate_interfaces(mvm->hw, 0, iwl_mvm_cleanup_iterator, mvm);
1201 ieee80211_iterate_stations_atomic(mvm->hw,
1204 mvm->p2p_device_vif = NULL;
1207 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
1208 memset(&mvm->last_bt_notif, 0, sizeof(mvm->last_bt_notif));
1209 memset(&mvm->last_bt_ci_cmd, 0, sizeof(mvm->last_bt_ci_cmd));
1211 ieee80211_wake_queues(mvm->hw);
1213 mvm->rx_ba_sessions = 0;
1214 mvm->fwrt.dump.conf = FW_DBG_INVALID;
1215 mvm->monitor_on = false;
1217 mvm->beacon_inject_active = false;
1229 lockdep_assert_held(&mvm->mutex);
1235 if (mvm->mei_nvm_data) {
1237 kfree(mvm->mei_nvm_data);
1238 mvm->mei_nvm_data = NULL;
1243 * allocated on mvm->nvm_data. Keep a pointer in temp_nvm_data
1248 mvm->temp_nvm_data = mvm->nvm_data;
1249 mvm->nvm_data = NULL;
1254 fast_resume = mvm->fast_resume;
1271 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
1276 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status)) {
1279 * so later code will - from now on - see that we're doing it.
1281 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1282 clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status);
1291 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_POST_INIT,
1293 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_PERIODIC,
1296 mvm->last_reset_or_resume_time_jiffies = jiffies;
1298 if (ret && test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
1299 /* Something went wrong - we need to finish some cleanup
1303 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1314 mutex_lock(&mvm->mutex);
1317 if (!test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status) &&
1323 set_bit(IWL_MVM_STATUS_STARTING, &mvm->status);
1327 clear_bit(IWL_MVM_STATUS_STARTING, &mvm->status);
1329 mutex_unlock(&mvm->mutex);
1342 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1374 lockdep_assert_held(&mvm->mutex);
1381 memset(&mvm->accu_radio_stats, 0, sizeof(mvm->accu_radio_stats));
1385 if (!iwl_mvm_has_new_station_api(mvm->fw))
1389 mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
1404 if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) ||
1406 &mvm->status))
1407 ieee80211_iterate_interfaces(mvm->hw, 0,
1413 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) {
1416 for (i = 0; i < mvm->max_scans; i++) {
1417 if (WARN_ONCE(mvm->scan_uid_status[i],
1420 mvm->scan_uid_status[i] = 0;
1430 mutex_lock(&mvm->mutex);
1432 mutex_unlock(&mvm->mutex);
1434 wiphy_work_cancel(mvm->hw->wiphy, &mvm->trig_link_selection_wk);
1435 wiphy_work_flush(mvm->hw->wiphy, &mvm->async_handlers_wiphy_wk);
1436 flush_work(&mvm->async_handlers_wk);
1437 flush_work(&mvm->add_stream_wk);
1447 clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
1449 cancel_delayed_work_sync(&mvm->cs_tx_unblock_dwork);
1450 cancel_delayed_work_sync(&mvm->scan_timeout_dwork);
1456 flush_work(&mvm->roc_done_wk);
1460 mutex_lock(&mvm->mutex);
1462 mutex_unlock(&mvm->mutex);
1468 cancel_work_sync(&mvm->async_handlers_wk);
1469 wiphy_work_cancel(hw->wiphy, &mvm->async_handlers_wiphy_wk);
1476 lockdep_assert_held(&mvm->mutex);
1479 if (!mvm->phy_ctxts[i].ref)
1480 return &mvm->phy_ctxts[i];
1494 cpu_to_le32(iwl_mvm_vif_from_mac80211(vif)->id),
1497 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
1509 else if (fw_has_api(&mvm->fw->ucode_capa,
1512 else if (fw_has_capa(&mvm->fw->ucode_capa,
1529 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) {
1531 iwl_mvm_txq_from_mac80211(sta->txq[i]);
1533 clear_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state);
1534 iwl_mvm_mac_itxq_xmit(hw, sta->txq[i]);
1546 mutex_lock(&mvm->mutex);
1548 if (vif->type == NL80211_IFTYPE_STATION) {
1550 unsigned int link_id = link_conf->link_id;
1551 u8 ap_sta_id = mvmvif->link[link_id]->ap_sta_id;
1553 mvmvif->csa_bcn_pending = false;
1554 mvmvif->csa_blocks_tx = false;
1558 ret = -EIO;
1563 if (mvm->mld_api_is_used)
1568 if (!fw_has_capa(&mvm->fw->ucode_capa,
1576 } else if (vif->type == NL80211_IFTYPE_AP && mvmvif->csa_blocks_tx) {
1578 iwl_mvm_txq_from_mac80211(vif->txq);
1580 clear_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state);
1583 iwl_mvm_mac_itxq_xmit(hw, vif->txq);
1587 mvmvif->csa_blocks_tx = false;
1590 mvmvif->ps_disabled = false;
1595 if (mvmvif->csa_failed)
1596 ret = -EIO;
1597 mutex_unlock(&mvm->mutex);
1609 .mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
1610 mvmvif->color)),
1619 if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP,
1623 IWL_DEBUG_MAC80211(mvm, "Abort CSA on mac %d\n", mvmvif->id);
1625 mutex_lock(&mvm->mutex);
1626 if (!fw_has_capa(&mvm->fw->ucode_capa,
1634 mvmvif->csa_failed = true;
1635 mutex_unlock(&mvm->mutex);
1638 iwl_mvm_post_channel_switch(hw, vif, &vif->bss_conf);
1660 if (chandef->width == NL80211_CHAN_WIDTH_320)
1662 else if (chandef->width == NL80211_CHAN_WIDTH_160)
1668 data_start = chandef->center_freq1 - bw / 2;
1670 control_start = chandef->chan->center_freq - 10;
1672 return (control_start - data_start) / 80;
1681 lockdep_assert_held(&mvm->mutex);
1692 return iwl_mvm_allocate_int_sta(mvm, &mvmvif->deflink.mcast_sta, 0,
1693 vif->type,
1702 struct iwl_mvm *mvm = mvmvif->mvm;
1717 guard(mvm)(mvmvif->mvm);
1718 iwl_mvm_int_mlo_scan(mvmvif->mvm, vif);
1725 struct iwl_mvm *mvm = mvmvif->mvm;
1735 lockdep_assert_held(&mvm->mutex);
1737 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1740 INIT_DELAYED_WORK(&mvmvif->csa_work,
1743 wiphy_delayed_work_init(&mvmvif->prevent_esr_done_wk,
1746 wiphy_delayed_work_init(&mvmvif->mlo_int_scan_wk,
1749 wiphy_work_init(&mvmvif->unblock_esr_tpt_wk,
1761 mutex_lock(&mvm->mutex);
1765 mvmvif->mvm = mvm;
1768 mvmvif->deflink.fw_link_id = IWL_MVM_FW_LINK_ID_INVALID;
1769 mvmvif->deflink.active = 0;
1770 mvmvif->link[0] = &mvmvif->deflink;
1772 ret = iwl_mvm_set_link_mapping(mvm, vif, &vif->bss_conf);
1783 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1785 mvmvif->link[i]->beacon_stats.accu_num_beacons +=
1786 mvmvif->link[i]->beacon_stats.num_beacons;
1793 rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif);
1796 if (vif->type == NL80211_IFTYPE_NAN) {
1812 if (vif->type == NL80211_IFTYPE_AP ||
1813 vif->type == NL80211_IFTYPE_ADHOC) {
1814 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1820 mvmvif->features |= hw->netdev_features;
1835 if (!mvm->bf_allowed_vif &&
1836 vif->type == NL80211_IFTYPE_STATION && !vif->p2p) {
1837 mvm->bf_allowed_vif = mvmvif;
1838 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
1842 if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
1843 mvm->p2p_device_vif = vif;
1847 if (vif->type == NL80211_IFTYPE_MONITOR) {
1848 mvm->monitor_on = true;
1849 mvm->monitor_p80 =
1850 iwl_mvm_chandef_get_primary_80(&vif->bss_conf.chanreq.oper);
1853 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1856 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
1857 vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
1858 !mvm->csme_vif && mvm->mei_registered) {
1859 iwl_mei_set_nic_info(vif->addr, mvm->nvm_data->hw_addr);
1860 iwl_mei_set_netdev(ieee80211_vif_to_wdev(vif)->netdev);
1861 mvm->csme_vif = vif;
1865 if (!ret && (vif->type == NL80211_IFTYPE_AP ||
1866 vif->type == NL80211_IFTYPE_ADHOC))
1872 mvmvif->deflink.phy_ctxt = NULL;
1875 mutex_unlock(&mvm->mutex);
1885 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1891 flush_work(&mvm->roc_done_wk);
1894 wiphy_delayed_work_cancel(mvm->hw->wiphy,
1895 &mvmvif->prevent_esr_done_wk);
1897 wiphy_delayed_work_cancel(mvm->hw->wiphy,
1898 &mvmvif->mlo_int_scan_wk);
1900 wiphy_work_cancel(mvm->hw->wiphy, &mvmvif->unblock_esr_tpt_wk);
1902 cancel_delayed_work_sync(&mvmvif->csa_work);
1914 if (!(vif->type == NL80211_IFTYPE_AP ||
1915 vif->type == NL80211_IFTYPE_ADHOC))
1918 mutex_lock(&mvm->mutex);
1920 if (vif == mvm->csme_vif) {
1922 mvm->csme_vif = NULL;
1925 probe_data = rcu_dereference_protected(mvmvif->deflink.probe_resp_data,
1926 lockdep_is_held(&mvm->mutex));
1927 RCU_INIT_POINTER(mvmvif->deflink.probe_resp_data, NULL);
1931 if (mvm->bf_allowed_vif == mvmvif) {
1932 mvm->bf_allowed_vif = NULL;
1933 vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER |
1937 if (vif->bss_conf.ftm_responder)
1938 memset(&mvm->ftm_resp_stats, 0, sizeof(mvm->ftm_resp_stats));
1946 if (vif->type == NL80211_IFTYPE_AP ||
1947 vif->type == NL80211_IFTYPE_ADHOC) {
1949 if (vif == mvm->noa_vif) {
1950 mvm->noa_vif = NULL;
1951 mvm->noa_duration = 0;
1964 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1965 if (mvmvif->deflink.phy_ctxt) {
1966 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt);
1967 mvmvif->deflink.phy_ctxt = NULL;
1969 mvm->p2p_device_vif = NULL;
1972 iwl_mvm_unset_link_mapping(mvm, vif, &vif->bss_conf);
1975 RCU_INIT_POINTER(mvm->vif_id_to_mac[mvmvif->id], NULL);
1977 if (vif->type == NL80211_IFTYPE_MONITOR)
1978 mvm->monitor_on = false;
1981 if (vif->type == NL80211_IFTYPE_AP ||
1982 vif->type == NL80211_IFTYPE_ADHOC) {
1983 iwl_mvm_dealloc_int_sta(mvm, &mvmvif->deflink.mcast_sta);
1987 mutex_unlock(&mvm->mutex);
1999 struct iwl_mvm *mvm = data->mvm;
2000 struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd;
2009 if (WARN_ON_ONCE(data->port_id >= MAX_PORT_ID_NUM))
2012 if (vif->type != NL80211_IFTYPE_STATION ||
2013 !vif->cfg.assoc)
2016 cmd->port_id = data->port_id++;
2017 memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN);
2018 len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4);
2035 lockdep_assert_held(&mvm->mutex);
2037 if (WARN_ON_ONCE(!mvm->mcast_filter_cmd))
2041 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
2051 * Note that the CPU is still faster - but with this we'll
2083 cmd->pass_all = 1;
2094 cmd->count, addr->addr);
2097 cmd->count, addr->addr, ":");
2099 memcpy(&cmd->addr_list[cmd->count * ETH_ALEN],
2100 addr->addr, ETH_ALEN);
2101 cmd->count++;
2125 kfree(mvm->mcast_filter_cmd);
2126 mvm->mcast_filter_cmd = cmd;
2132 cmd->pass_all = !!(*total_flags & FIF_ALLMULTI);
2134 if (cmd->pass_all)
2135 cmd->count = 0;
2154 if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc ||
2155 !vif->p2p)
2166 memcpy(cmd.membership_status, vif->bss_conf.mu_group.membership,
2168 memcpy(cmd.user_position, vif->bss_conf.mu_group.position,
2180 if (vif->bss_conf.mu_mimo_owner) {
2184 * MU-MIMO Group Id action frame is little endian. We treat
2189 (u8 *)¬if->membership_status,
2190 (u8 *)¬if->user_position);
2198 struct iwl_mu_group_mgmt_notif *notif = (void *)pkt->data;
2201 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
2214 (BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE) - 1);
2222 residue_bits = 8 - bit_num;
2225 (BIT(IEEE80211_PPE_THRES_INFO_PPET_SIZE - residue_bits) - 1)) <<
2227 res += (ppe[byte_num] >> bit_num) & (BIT(residue_bits) - 1);
2246 IWL_DEBUG_INFO(mvm, "Got NSS = %d - trimming to %d\n", nss,
2257 bw < ARRAY_SIZE(pkt_ext->pkt_ext_qam_th[i]);
2263 * isn't present - it should inherit the thresholds from the last
2265 * this inheritance - continue in this case
2280 pkt_ext->pkt_ext_qam_th[i][bw][0] = low_th;
2281 pkt_ext->pkt_ext_qam_th[i][bw][1] = high_th;
2291 u8 nss = (link_sta->he_cap.ppe_thres[0] &
2293 u8 *ppe = &link_sta->he_cap.ppe_thres[0];
2308 int low_th = -1;
2309 int high_th = -1;
2330 return -EINVAL;
2337 bw < ARRAY_SIZE(pkt_ext->pkt_ext_qam_th[i]);
2339 pkt_ext->pkt_ext_qam_th[i][bw][0] = low_th;
2340 pkt_ext->pkt_ext_qam_th[i][bw][1] = high_th;
2355 for (bw = 0; bw < ARRAY_SIZE(pkt_ext->pkt_ext_qam_th[i]);
2357 u8 *qam_th = &pkt_ext->pkt_ext_qam_th[i][bw][0];
2381 return -EINVAL;
2384 * 9-262ac of 80211.ax/D3.0.
2389 if (link_sta->eht_cap.has_eht) {
2391 u8_get_bits(link_sta->eht_cap.eht_cap_elem.phy_cap_info[5],
2394 /* If PPE Thresholds exists, parse them into a FW-familiar
2397 if (link_sta->eht_cap.eht_cap_elem.phy_cap_info[5] &
2399 u8 nss = (link_sta->eht_cap.eht_ppe_thres[0] &
2401 u8 *ppe = &link_sta->eht_cap.eht_ppe_thres[0];
2410 /* EHT PPE Thresholds doesn't exist - set the API according to
2413 } else if (link_sta->he_cap.he_cap_elem.phy_cap_info[6] &
2423 /* According to the requirements, for MCSs 12-13 the
2429 /* if PPE Thresholds doesn't present in both EHT IE and HE IE -
2436 } else if (link_sta->he_cap.has_he) {
2437 /* If PPE Thresholds exist, parse them into a FW-familiar format. */
2438 if (link_sta->he_cap.he_cap_elem.phy_cap_info[6] &
2442 /* PPE Thresholds doesn't exist - set the API PPE values
2447 u8_get_bits(link_sta->he_cap.he_cap_elem.phy_cap_info[9],
2459 bw < ARRAY_SIZE(*pkt_ext->pkt_ext_qam_th[i]);
2462 &pkt_ext->pkt_ext_qam_th[i][bw][0];
2486 &link_info->queue_params[i].mu_edca_param_rec;
2489 if (!link_info->queue_params[i].mu_edca) {
2495 cpu_to_le16(mu_edca->ecw_min_max & 0xf);
2497 cpu_to_le16((mu_edca->ecw_min_max & 0xf0) >> 4);
2499 cpu_to_le16(mu_edca->aifsn & 0xf);
2501 cpu_to_le16(mu_edca->mu_edca_timer);
2515 sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ];
2518 return (own_he_cap && (own_he_cap->he_cap_elem.mac_cap_info[2] &
2526 &link_sta->he_cap.he_cap_elem.mac_cap_info[0];
2562 .bss_color = vif->bss_conf.he_bss_color.color,
2563 .htc_trig_based_pkt_ext = vif->bss_conf.htc_trig_based_pkt_ext,
2565 cpu_to_le16(vif->bss_conf.frame_time_rts_th),
2569 u8 ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 2);
2576 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_MBSSID_HE))
2581 /* same layout as v2 except some data at the end */
2600 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_ctxt_cmd.sta_id]);
2607 if (!sta->deflink.he_cap.has_he) {
2614 /* Block 26-tone RU OFDMA transmissions */
2615 if (mvmvif->deflink.he_ru_2mhz_block)
2619 sta_ctxt_cmd.htc_flags = iwl_mvm_get_sta_htc_flags(sta, &sta->deflink);
2622 if (!iwl_mvm_set_sta_pkt_ext(mvm, &sta->deflink, &sta_ctxt_cmd.pkt_ext))
2625 if (sta->deflink.he_cap.he_cap_elem.mac_cap_info[2] &
2629 if (sta->deflink.he_cap.he_cap_elem.mac_cap_info[2] &
2635 if (iwl_mvm_set_fw_mu_edca_params(mvm, &mvmvif->deflink,
2639 if (vif->bss_conf.uora_exists) {
2643 vif->bss_conf.uora_ocw_range & 0x7;
2645 (vif->bss_conf.uora_ocw_range >> 3) & 0x7;
2651 if (vif->bss_conf.nontransmitted) {
2654 vif->bss_conf.transmitter_bssid);
2656 vif->bss_conf.bssid_indicator;
2657 sta_ctxt_cmd.bssid_index = vif->bss_conf.bssid_index;
2658 sta_ctxt_cmd.ema_ap = vif->bss_conf.ema_ap;
2660 vif->bss_conf.profile_periodicity;
2691 BUILD_BUG_ON(sizeof(sta_ctxt_cmd) -
2693 sizeof(sta_ctxt_cmd_v2) -
2699 sizeof(sta_ctxt_cmd) -
2726 if (fw_has_capa(&mvm->fw->ucode_capa,
2736 /* Handle association common part to MLD and non-MLD modes */
2745 /* The firmware tracks the MU-MIMO group on its own.
2748 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
2749 (changes & BSS_CHANGED_MU_GROUPS) && vif->bss_conf.mu_mimo_owner) {
2760 mvmvif->link[link_id]->bf_data.ave_beacon_signal = 0;
2765 if (fw_has_capa(&mvm->fw->ucode_capa,
2770 /* Execute the common part for MLD and non-MLD modes */
2802 mvmvif->link[link_conf->link_id];
2806 link_info->bf_data.last_cqm_event = 0;
2808 if (mvmvif->bf_enabled) {
2840 * Re-calculate the tsf id, as the leader-follower relations depend
2844 if (changes & BSS_CHANGED_ASSOC && vif->cfg.assoc) {
2845 if ((vif->bss_conf.he_support &&
2847 iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->deflink.ap_sta_id);
2853 if (changes & BSS_CHANGED_QOS && mvmvif->associated &&
2854 vif->cfg.assoc &&
2855 (vif->bss_conf.he_support && !iwlwifi_mod_params.disable_11ax))
2856 iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->deflink.ap_sta_id);
2864 if (changes & BSS_CHANGED_BSSID && !mvmvif->associated)
2865 memcpy(mvmvif->deflink.bssid, bss_conf->bssid, ETH_ALEN);
2867 ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, mvmvif->deflink.bssid);
2869 IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
2872 memcpy(mvmvif->deflink.bssid, bss_conf->bssid, ETH_ALEN);
2873 mvmvif->associated = vif->cfg.assoc;
2876 if (vif->cfg.assoc) {
2877 mvmvif->session_prot_connection_loss = false;
2882 memset(&mvmvif->link[i]->beacon_stats, 0,
2883 sizeof(mvmvif->link[i]->beacon_stats));
2893 &mvm->status) &&
2894 !fw_has_capa(&mvm->fw->ucode_capa,
2914 u32 dur = (11 * vif->bss_conf.beacon_int) / 10;
2918 &mvm->status) &&
2919 !vif->bss_conf.dtim_period) {
2935 if (vif->p2p) {
2940 } else if (mvmvif->deflink.ap_sta_id != IWL_MVM_INVALID_STA) {
2943 * If update fails - SF might be running in associated
2944 * mode while disassociated - which is forbidden.
2949 &mvm->status),
2955 * to associated), mac80211 will re-add the station and
2961 &mvm->status)) {
2964 &mvmvif->deflink, 0);
2971 mvmvif->deflink.ap_sta_id);
2976 mvmvif->deflink.ap_sta_id = IWL_MVM_INVALID_STA;
2989 vif->addr);
2995 iwl_mvm_bss_info_changed_station_common(mvm, vif, &vif->bss_conf,
3007 lockdep_assert_held(&mvm->mutex);
3009 mvmvif->ap_assoc_sta_count = 0;
3012 mvmvif->ap_ibss_active = true;
3015 for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) {
3016 struct ieee80211_key_conf *key = mvmvif->ap_early_keys[i];
3021 mvmvif->ap_early_keys[i] = NULL;
3028 if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) {
3031 iwl_mvm_send_low_latency_cmd(mvm, true, mvmvif->id);
3048 mutex_lock(&mvm->mutex);
3051 * Re-calculate the tsf id, as the leader-follower relations depend on
3055 if (vif->type == NL80211_IFTYPE_AP)
3062 if (mvm->trans->trans_cfg->device_family > IWL_DEVICE_FAMILY_22000) {
3094 * the TLV
3096 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) {
3132 if (vif->p2p && mvm->p2p_device_vif)
3133 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL);
3141 iwl_mvm_ftm_restart_responder(mvm, vif, &vif->bss_conf);
3147 mvmvif->ap_ibss_active = false;
3155 mutex_unlock(&mvm->mutex);
3169 return iwl_mvm_start_ap_ibss(hw, vif, &vif->bss_conf);
3172 /* Common part for MLD and non-MLD ops */
3178 lockdep_assert_held(&mvm->mutex);
3183 if (rcu_access_pointer(mvm->csa_vif) == vif) {
3185 &mvmvif->time_event_data);
3186 RCU_INIT_POINTER(mvm->csa_vif, NULL);
3187 mvmvif->csa_countdown = false;
3190 if (rcu_access_pointer(mvm->csa_tx_blocked_vif) == vif) {
3191 RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL);
3192 mvm->csa_tx_block_bcn_timeout = 0;
3195 mvmvif->ap_ibss_active = false;
3196 mvm->ap_last_beacon_gp2 = 0;
3198 if (vif->type == NL80211_IFTYPE_AP && !vif->p2p) {
3201 iwl_mvm_send_low_latency_cmd(mvm, false, mvmvif->id);
3218 if (vif->p2p && mvm->p2p_device_vif)
3219 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL);
3231 * So make the order of removal depend on the TLV
3233 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE))
3236 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE))
3255 iwl_mvm_stop_ap_ibss(hw, vif, &vif->bss_conf);
3267 if (!mvmvif->ap_ibss_active)
3273 IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
3277 iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, &vif->bss_conf))
3281 int ret = iwl_mvm_ftm_start_responder(mvm, vif, &vif->bss_conf);
3299 if (changes & BSS_CHANGED_IDLE && !vif->cfg.idle)
3302 switch (vif->type) {
3321 bss_conf->txpower);
3322 iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower);
3331 if (hw_req->req.n_channels == 0 ||
3332 hw_req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels)
3333 return -EINVAL;
3336 return iwl_mvm_reg_scan_start(mvm, vif, &hw_req->req, &hw_req->ies);
3353 if (mvm->scan_status & IWL_MVM_SCAN_REGULAR)
3397 * If we have TVQM then we get too high queue numbers - luckily
3404 spin_lock_bh(&mvmsta->lock);
3405 for (tid = 0; tid < ARRAY_SIZE(mvmsta->tid_data); tid++) {
3406 struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
3408 if (tid_data->txq_id == IWL_MVM_INVALID_QUEUE)
3411 __set_bit(tid_data->txq_id, &txqs);
3425 iwl_trans_freeze_txq_timer(mvm->trans, txqs, true);
3433 if (WARN_ON(mvmsta->deflink.sta_id == IWL_MVM_INVALID_STA))
3437 iwl_trans_freeze_txq_timer(mvm->trans, txqs, false);
3443 spin_unlock_bh(&mvmsta->lock);
3455 struct iwl_mvm_pm_state_notification *notif = (void *)pkt->data;
3458 bool sleeping = (notif->type != IWL_MVM_PM_EVENT_AWAKE);
3460 if (WARN_ON(notif->sta_id >= mvm->fw->ucode_capa.num_stations))
3464 sta = rcu_dereference(mvm->fw_id_to_mac_id[notif->sta_id]);
3472 if (!mvmsta->vif ||
3473 mvmsta->vif->type != NL80211_IFTYPE_AP) {
3478 if (mvmsta->sleeping != sleeping) {
3479 mvmsta->sleeping = sleeping;
3480 __iwl_mvm_mac_sta_notify(mvm->hw,
3487 switch (notif->type) {
3515 * so here we already invalidate our internal RCU-protected
3520 * Since there's mvm->mutex here, no need to have RCU lock for
3521 * mvm_sta->link access.
3524 for (link_id = 0; link_id < ARRAY_SIZE(mvm_sta->link); link_id++) {
3528 if (!mvm_sta->link[link_id])
3531 link_sta = rcu_dereference_protected(mvm_sta->link[link_id],
3532 lockdep_is_held(&mvm->mutex));
3533 sta_id = link_sta->sta_id;
3534 if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[sta_id])) {
3535 RCU_INIT_POINTER(mvm->fw_id_to_mac_id[sta_id],
3536 ERR_PTR(-ENOENT));
3537 RCU_INIT_POINTER(mvm->fw_id_to_link_sta[sta_id], NULL);
3547 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
3550 mdata = &mvm->tcm.data[iwl_mvm_vif_from_mac80211(vif)->id];
3551 ewma_rate_init(&mdata->uapsd_nonagg_detect.rate);
3552 mdata->opened_rx_ba_sessions = false;
3555 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT))
3558 if (vif->p2p && !iwl_mvm_is_p2p_scm_uapsd_supported(mvm)) {
3559 vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD;
3563 if (!vif->p2p &&
3565 vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD;
3570 if (ether_addr_equal(mvm->uapsd_noagg_bssids[i].addr, bssid)) {
3571 vif->driver_flags &= ~IEEE80211_VIF_SUPPORTS_UAPSD;
3576 vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD;
3587 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
3592 tdls_trig = (void *)trig->data;
3594 if (!(tdls_trig->action_bitmap & BIT(action)))
3597 if (tdls_trig->peer_mode &&
3598 memcmp(tdls_trig->peer, peer_addr, ETH_ALEN) != 0)
3601 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
3619 ies = rcu_dereference(bss->ies);
3620 elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY, ies->data,
3621 ies->len);
3623 if (!elem || elem->datalen < 10 ||
3624 !(elem->data[10] &
3626 data->tolerated = false;
3642 if (WARN_ON_ONCE(!link_conf->chanreq.oper.chan ||
3643 !mvmvif->link[link_id]))
3646 if (!(link_conf->chanreq.oper.chan->flags & IEEE80211_CHAN_RADAR)) {
3647 mvmvif->link[link_id]->he_ru_2mhz_block = false;
3651 cfg80211_bss_iter(hw->wiphy, &link_conf->chanreq.oper,
3657 * tolerate 26-tone RU UL OFDMA transmissions using HE TB PPDU.
3659 mvmvif->link[link_id]->he_ru_2mhz_block = !iter_data.tolerated;
3668 if (vif->type != NL80211_IFTYPE_STATION)
3671 if (!mvm->cca_40mhz_workaround)
3675 mvm->cca_40mhz_workaround--;
3676 if (mvm->cca_40mhz_workaround)
3679 sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ];
3681 sband->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
3689 he->he_cap_elem.phy_cap_info[0] |=
3701 .ssid_len = vif->cfg.ssid_len,
3704 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
3707 if (!mvm->mei_registered)
3711 if (!vif->bss_conf.chanreq.oper.chan)
3714 conn_info.channel = vif->bss_conf.chanreq.oper.chan->hw_value;
3716 switch (mvm_sta->pairwise_cipher) {
3737 switch (mvmvif->rekey_data.akm) {
3757 memcpy(conn_info.ssid, vif->cfg.ssid, vif->cfg.ssid_len);
3758 memcpy(conn_info.bssid, vif->bss_conf.bssid, ETH_ALEN);
3807 if (!conf || !link_sta || !mvmvif->link[link_id]->phy_ctxt)
3811 mvmvif->link[link_id]->phy_ctxt->channel->band);
3822 /* Beacon interval check - firmware will crash if the beacon
3836 if (link_conf->beacon_int < IWL_MVM_MIN_BEACON_INTERVAL_TU) {
3839 link_conf->beacon_int, link_sta->addr);
3843 link_conf->he_support = link_sta->he_cap.has_he;
3862 if (!link_conf || !mvmvif->link[link_id])
3865 link_conf->he_support = link_sta->he_cap.has_he;
3868 mvmvif->link[link_id]->he_ru_2mhz_block = false;
3869 if (link_sta->he_cap.has_he)
3888 lockdep_assert_held(&mvm->mutex);
3890 if (vif->type == NL80211_IFTYPE_STATION &&
3892 return -EINVAL;
3894 if (sta->tdls &&
3895 (vif->p2p ||
3899 return -EBUSY;
3902 ret = callbacks->add_sta(mvm, vif, sta);
3903 if (sta->tdls && ret == 0) {
3905 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
3913 link_sta->agg.max_rc_amsdu_len = 1;
3917 if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
3918 mvmvif->ap_sta = sta;
3921 * Initialize the rates here already - this really tells
3948 lockdep_assert_held(&mvm->mutex);
3950 if (vif->type == NL80211_IFTYPE_AP) {
3952 mvmvif->ap_assoc_sta_count++;
3953 callbacks->mac_ctxt_changed(mvm, vif, false);
3958 if (!mvm->mld_api_is_used &&
3959 (vif->bss_conf.he_support &&
3961 iwl_mvm_cfg_he_sta(mvm, vif, mvm_sta->deflink.sta_id);
3962 } else if (vif->type == NL80211_IFTYPE_STATION) {
3965 callbacks->mac_ctxt_changed(mvm, vif, false);
3967 if (!mvm->mld_api_is_used)
3975 return -EINVAL;
3976 if (!mvmvif->link[link_id])
3989 return callbacks->update_sta(mvm, vif, sta);
4001 lockdep_assert_held(&mvm->mutex);
4007 if (sta->tdls) {
4008 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
4014 mvmvif->authorized = 1;
4016 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
4017 mvmvif->link_selection_res = vif->active_links;
4018 mvmvif->link_selection_primary =
4019 vif->active_links ? __ffs(vif->active_links) : 0;
4022 callbacks->mac_ctxt_changed(mvm, vif, false);
4025 memset(&mvmvif->last_esr_exit, 0,
4026 sizeof(mvmvif->last_esr_exit));
4036 if (vif->type == NL80211_IFTYPE_STATION &&
4037 !test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
4041 mvm_sta->authorized = true;
4046 if (!sta->mfp) {
4047 int ret = callbacks->update_sta(mvm, vif, sta);
4067 lockdep_assert_held(&mvm->mutex);
4069 mvmsta->authorized = false;
4076 if (!sta->tdls) {
4081 mvmvif->authorized = 0;
4082 mvmvif->link_selection_res = 0;
4087 wiphy_delayed_work_cancel(mvm->hw->wiphy,
4088 &mvmvif->prevent_esr_done_wk);
4090 wiphy_delayed_work_cancel(mvm->hw->wiphy,
4091 &mvmvif->mlo_int_scan_wk);
4093 wiphy_work_cancel(mvm->hw->wiphy, &mvmvif->unblock_esr_tpt_wk);
4096 if (ieee80211_vif_is_mld(vif) && mvmvif->esr_active)
4103 /* Common part for MLD and non-MLD modes */
4118 IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n",
4119 sta->addr, old_state, new_state);
4131 * Drop any still-queued deferred-frame before removing the STA, and
4136 flush_work(&mvm->add_stream_wk);
4150 kfree(mvm_sta->dup_data);
4153 mutex_lock(&mvm->mutex);
4161 if (WARN_ON_ONCE(!mvmvif->link[link_id] ||
4162 !mvmvif->link[link_id]->phy_ctxt)) {
4163 mutex_unlock(&mvm->mutex);
4165 &mvm->status) ? 0 : -EINVAL;
4170 mvm_sta->sta_state = new_state;
4184 mvm->last_ebs_successful = true;
4185 iwl_mvm_check_uapsd(mvm, vif, sta->addr);
4201 if (vif->type == NL80211_IFTYPE_AP) {
4202 mvmvif->ap_assoc_sta_count--;
4203 callbacks->mac_ctxt_changed(mvm, vif, false);
4204 } else if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
4212 if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
4214 mvmvif->ap_sta = NULL;
4216 ret = callbacks->rm_sta(mvm, vif, sta);
4217 if (sta->tdls) {
4219 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
4225 &mvm->status)))
4228 ret = -EIO;
4231 mutex_unlock(&mvm->mutex);
4233 if (sta->tdls && ret == 0) {
4249 mvm->rts_threshold = value;
4264 if (vif->type == NL80211_IFTYPE_STATION &&
4277 mvmvif->deflink.queue_params[ac] = *params;
4283 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
4297 if (info->was_assoc && !mvmvif->session_prot_connection_loss)
4301 iwl_mvm_protect_assoc(mvm, vif, info->duration, info->link_id);
4311 if (info->success)
4327 if (!vif->cfg.idle)
4328 return -EBUSY;
4339 mutex_lock(&mvm->mutex);
4349 if (!(mvm->scan_status & IWL_MVM_SCAN_SCHED)) {
4350 mutex_unlock(&mvm->mutex);
4355 mutex_unlock(&mvm->mutex);
4371 int keyidx = key->keyidx;
4373 u8 sec_key_ver = iwl_fw_lookup_cmd_ver(mvm->fw, sec_key_id, 0);
4380 switch (key->cipher) {
4382 if (!mvm->trans->trans_cfg->gen2) {
4383 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
4384 key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE;
4385 } else if (vif->type == NL80211_IFTYPE_STATION) {
4386 key->flags |= IEEE80211_KEY_FLAG_PUT_MIC_SPACE;
4389 return -EOPNOTSUPP;
4396 key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE;
4405 if (vif->type == NL80211_IFTYPE_STATION)
4408 return -EOPNOTSUPP;
4412 return -EOPNOTSUPP;
4417 if (vif->type == NL80211_IFTYPE_STATION &&
4419 rcu_assign_pointer(mvmvif->bcn_prot.keys[keyidx - 6],
4422 if ((vif->type == NL80211_IFTYPE_ADHOC ||
4423 vif->type == NL80211_IFTYPE_AP) && !sta) {
4425 * GTK on AP interface is a TX-only key, return 0;
4426 * on IBSS they're per-station and because we're lazy
4431 * Except, of course, beacon protection - it must be
4436 * So just check for beacon protection - if we don't
4441 if (!wiphy_ext_feature_isset(hw->wiphy,
4443 (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
4444 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
4445 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256)) {
4446 ret = -EOPNOTSUPP;
4450 if (key->cipher != WLAN_CIPHER_SUITE_GCMP &&
4451 key->cipher != WLAN_CIPHER_SUITE_GCMP_256 &&
4453 key->hw_key_idx = STA_KEY_IDX_INVALID;
4458 if (!mvmvif->ap_ibss_active) {
4460 i < ARRAY_SIZE(mvmvif->ap_early_keys);
4462 if (!mvmvif->ap_early_keys[i]) {
4463 mvmvif->ap_early_keys[i] = key;
4468 if (i >= ARRAY_SIZE(mvmvif->ap_early_keys))
4469 ret = -ENOSPC;
4480 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
4481 key->hw_key_idx == STA_KEY_IDX_INVALID) {
4488 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
4490 key->flags & IEEE80211_KEY_FLAG_PAIRWISE &&
4491 (key->cipher == WLAN_CIPHER_SUITE_CCMP ||
4492 key->cipher == WLAN_CIPHER_SUITE_GCMP ||
4493 key->cipher == WLAN_CIPHER_SUITE_GCMP_256)) {
4497 WARN_ON(rcu_access_pointer(mvmsta->ptk_pn[keyidx]));
4499 mvm->trans->num_rx_queues),
4502 ret = -ENOMEM;
4508 for (q = 0; q < mvm->trans->num_rx_queues; q++)
4509 memcpy(ptk_pn->q[q].pn[tid],
4514 rcu_assign_pointer(mvmsta->ptk_pn[keyidx], ptk_pn);
4518 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
4519 key_offset = key->hw_key_idx;
4523 if (mvmsta && key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
4524 mvmsta->pairwise_cipher = key->cipher;
4527 sta ? sta->addr : NULL, key->keyidx);
4536 key->hw_key_idx = STA_KEY_IDX_INVALID;
4538 RCU_INIT_POINTER(mvmsta->ptk_pn[keyidx], NULL);
4548 ret = -EOPNOTSUPP;
4555 if (vif->type == NL80211_IFTYPE_STATION &&
4557 RCU_INIT_POINTER(mvmvif->bcn_prot.keys[keyidx - 6],
4560 ret = -ENOENT;
4561 for (i = 0; i < ARRAY_SIZE(mvmvif->ap_early_keys); i++) {
4562 if (mvmvif->ap_early_keys[i] == key) {
4563 mvmvif->ap_early_keys[i] = NULL;
4568 /* found in pending list - don't do anything else */
4572 if (key->hw_key_idx == STA_KEY_IDX_INVALID) {
4578 key->flags & IEEE80211_KEY_FLAG_PAIRWISE &&
4579 (key->cipher == WLAN_CIPHER_SUITE_CCMP ||
4580 key->cipher == WLAN_CIPHER_SUITE_GCMP ||
4581 key->cipher == WLAN_CIPHER_SUITE_GCMP_256)) {
4583 mvmsta->ptk_pn[keyidx],
4584 lockdep_is_held(&mvm->mutex));
4585 RCU_INIT_POINTER(mvmsta->ptk_pn[keyidx], NULL);
4597 ret = -EINVAL;
4621 if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID)
4637 if (WARN_ON(pkt->hdr.cmd != HOT_SPOT_CMD))
4645 resp = (void *)pkt->data;
4649 resp->status, resp->event_unique_id);
4651 te_data->uid = le32_to_cpu(resp->event_unique_id);
4652 IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n",
4653 te_data->uid);
4655 spin_lock_bh(&mvm->time_event_lock);
4656 list_add_tail(&te_data->list, &mvm->aux_roc_te_list);
4657 spin_unlock_bh(&mvm->time_event_lock);
4669 struct iwl_mvm_time_event_data *te_data = &mvmvif->hs_time_event_data;
4677 .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id),
4681 u16 len = sizeof(aux_roc_req) - iwl_mvm_chan_info_padding(mvm);
4684 iwl_mvm_set_chan_info(mvm, &aux_roc_req.channel_info, channel->hw_value,
4685 iwl_mvm_phy_band_from_nl80211(channel->band),
4690 tail->apply_time = cpu_to_le32(iwl_mvm_get_systime(mvm));
4693 tail->duration = cpu_to_le32(req_dur);
4694 tail->apply_time_max_delay = cpu_to_le32(delay);
4698 channel->hw_value, req_dur);
4704 memcpy(tail->node_addr, vif->addr, ETH_ALEN);
4706 lockdep_assert_held(&mvm->mutex);
4708 spin_lock_bh(&mvm->time_event_lock);
4710 if (WARN_ON(te_data->id == HOT_SPOT_CMD)) {
4711 spin_unlock_bh(&mvm->time_event_lock);
4712 return -EIO;
4715 te_data->vif = vif;
4716 te_data->duration = duration;
4717 te_data->id = HOT_SPOT_CMD;
4719 spin_unlock_bh(&mvm->time_event_lock);
4730 iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
4740 iwl_remove_notification(&mvm->notif_wait, &wait_time_event);
4745 res = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1);
4751 spin_lock_bh(&mvm->time_event_lock);
4753 spin_unlock_bh(&mvm->time_event_lock);
4763 lockdep_assert_held(&mvm->mutex);
4765 if (!fw_has_capa(&mvm->fw->ucode_capa,
4768 return -EINVAL;
4771 if (iwl_mvm_has_new_station_api(mvm->fw)) {
4783 lockdep_assert_held(&mvm->mutex);
4816 u8 fw_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
4825 ret = -EOPNOTSUPP;
4841 lockdep_assert_held(&mvm->mutex);
4852 return -EINVAL;
4856 iwl_mvm_get_lmac_id(mvm, channel->band));
4871 lockdep_assert_held(&mvm->mutex);
4873 if (mvmvif->deflink.phy_ctxt &&
4874 channel == mvmvif->deflink.phy_ctxt->channel)
4879 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[i];
4881 if (!phy_ctxt->ref || mvmvif->deflink.phy_ctxt == phy_ctxt)
4884 if (channel == phy_ctxt->channel) {
4885 if (mvmvif->deflink.phy_ctxt)
4887 mvmvif->deflink.phy_ctxt);
4889 mvmvif->deflink.phy_ctxt = phy_ctxt;
4890 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt);
4896 if (mvmvif->deflink.phy_ctxt)
4897 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt);
4899 mvmvif->deflink.phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
4900 if (!mvmvif->deflink.phy_ctxt)
4901 return -ENOSPC;
4905 return iwl_mvm_phy_ctxt_add(mvm, mvmvif->deflink.phy_ctxt,
4909 /* Execute the common part for MLD and non-MLD modes */
4920 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
4927 flush_work(&mvm->roc_done_wk);
4938 switch (vif->type) {
4940 lmac_id = iwl_mvm_get_lmac_id(mvm, channel->band);
4943 ret = ops->add_aux_sta_for_hs20(mvm, lmac_id);
4951 IWL_ERR(mvm, "ROC: Invalid vif type=%u\n", vif->type);
4952 return -EINVAL;
4964 ret = ops->link(mvm, vif);
4994 if (rcu_access_pointer(vif->bss_conf.chanctx_conf) == data->ctx &&
4995 vif->type == NL80211_IFTYPE_AP && vif->bss_conf.ftmr_params)
4996 data->responder = true;
5007 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
5017 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
5022 lockdep_assert_held(&mvm->mutex);
5028 ret = -ENOSPC;
5032 ret = iwl_mvm_phy_ctxt_add(mvm, phy_ctxt, def, &ctx->ap,
5033 ctx->rx_chains_static,
5034 ctx->rx_chains_dynamic);
5040 *phy_ctxt_id = phy_ctxt->id;
5057 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
5058 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
5060 lockdep_assert_held(&mvm->mutex);
5078 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
5079 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
5082 if (WARN_ONCE((phy_ctxt->ref > 1) &&
5088 phy_ctxt->ref, changed))
5095 if (phy_ctxt->width == def->width)
5099 if (phy_ctxt->width <= NL80211_CHAN_WIDTH_20 &&
5100 def->width <= NL80211_CHAN_WIDTH_20)
5105 iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, def, &ctx->ap,
5106 ctx->rx_chains_static,
5107 ctx->rx_chains_dynamic);
5111 * This function executes the common part for MLD and non-MLD modes.
5122 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
5123 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
5126 lockdep_assert_held(&mvm->mutex);
5128 mvmvif->deflink.phy_ctxt = phy_ctxt;
5130 switch (vif->type) {
5134 mvmvif->ap_ibss_active = true;
5149 mvmvif->ps_disabled = true;
5152 *ret = -EINVAL;
5168 return -EINVAL;
5188 if (vif->type == NL80211_IFTYPE_MONITOR) {
5189 mvmvif->monitor_active = true;
5201 if (vif->type == NL80211_IFTYPE_AP) {
5206 if (vif->type == NL80211_IFTYPE_STATION) {
5208 mvmvif->csa_bcn_pending = false;
5212 mvmvif->csa_bcn_pending = true;
5214 if (!fw_has_capa(&mvm->fw->ucode_capa,
5216 u32 duration = 5 * vif->bss_conf.beacon_int;
5222 vif->bss_conf.beacon_int / 2,
5240 mvmvif->deflink.phy_ctxt = NULL;
5256 * This function executes the common part for MLD and non-MLD modes.
5267 lockdep_assert_held(&mvm->mutex);
5269 &mvmvif->time_event_data);
5271 switch (vif->type) {
5275 mvmvif->monitor_active = false;
5276 mvmvif->ps_disabled = false;
5280 if (!switching_chanctx || !mvmvif->ap_ibss_active)
5283 mvmvif->csa_countdown = false;
5289 rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif);
5291 mvmvif->ap_ibss_active = false;
5311 if (vif->type == NL80211_IFTYPE_MONITOR)
5315 if (vif->type == NL80211_IFTYPE_STATION && switching_chanctx) {
5317 if (!fw_has_capa(&mvm->fw->ucode_capa,
5326 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD) &&
5329 mvmvif->deflink.phy_ctxt = NULL;
5352 ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5362 ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5370 /* we don't support TDLS during DCM - can be caused by channel switch */
5385 if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5407 ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5410 ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5421 if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5435 /* Execute the common part for both MLD and non-MLD modes */
5446 /* we only support a single-vif right now */
5448 return -EOPNOTSUPP;
5458 ret = -EOPNOTSUPP;
5482 return mvm->ibss_manager;
5491 if (!mvm_sta || !mvm_sta->vif) {
5493 return -EINVAL;
5496 return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif,
5497 &mvm_sta->vif->bss_conf);
5521 return -EINVAL;
5525 if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p ||
5526 !vif->bss_conf.enable_beacon ||
5528 return -EINVAL;
5531 if (noa_duration >= vif->bss_conf.beacon_int)
5532 return -EINVAL;
5534 mvm->noa_duration = noa_duration;
5535 mvm->noa_vif = vif;
5539 /* must be associated client vif - ignore authorized */
5540 if (!vif || vif->type != NL80211_IFTYPE_STATION ||
5541 !vif->cfg.assoc || !vif->bss_conf.dtim_period ||
5543 return -EINVAL;
5550 return -EOPNOTSUPP;
5583 .mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
5584 mvmvif->color)),
5586 .tsf = cpu_to_le32(chsw->timestamp),
5587 .cs_count = chsw->count,
5588 .cs_mode = chsw->block_tx,
5591 lockdep_assert_held(&mvm->mutex);
5593 if (chsw->delay)
5595 DIV_ROUND_UP(chsw->delay, vif->bss_conf.beacon_int);
5616 if (chsw->count <= 1)
5619 apply_time = chsw->device_timestamp +
5620 ((vif->bss_conf.beacon_int * (chsw->count - 1) -
5623 if (chsw->block_tx)
5626 if (mvmvif->bf_enabled) {
5633 iwl_mvm_schedule_csa_period(mvm, vif, vif->bss_conf.beacon_int,
5643 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) {
5645 iwl_mvm_txq_from_mac80211(sta->txq[i]);
5647 set_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state);
5661 lockdep_assert_held(&mvm->mutex);
5663 mvmvif->csa_failed = false;
5664 mvmvif->csa_blocks_tx = false;
5667 chsw->chandef.center_freq1);
5669 iwl_fw_dbg_trigger_simple_stop(&mvm->fwrt,
5673 switch (vif->type) {
5676 rcu_dereference_protected(mvm->csa_vif,
5677 lockdep_is_held(&mvm->mutex));
5678 if (WARN_ONCE(csa_vif && csa_vif->bss_conf.csa_active,
5680 return -EBUSY;
5683 if (rcu_dereference_protected(mvm->csa_tx_blocked_vif,
5684 lockdep_is_held(&mvm->mutex)))
5685 return -EBUSY;
5687 rcu_assign_pointer(mvm->csa_vif, vif);
5689 if (WARN_ONCE(mvmvif->csa_countdown,
5691 return -EBUSY;
5693 mvmvif->csa_target_freq = chsw->chandef.chan->center_freq;
5695 if (!chsw->block_tx)
5697 /* don't need blocking in driver otherwise - mac80211 will do */
5698 if (!ieee80211_hw_check(mvm->hw, HANDLES_QUIET_CSA))
5701 mvmvif->csa_blocks_tx = true;
5702 mvmtxq = iwl_mvm_txq_from_mac80211(vif->txq);
5703 set_bit(IWL_MVM_TXQ_STATE_STOP_AP_CSA, &mvmtxq->state);
5704 ieee80211_iterate_stations_atomic(mvm->hw,
5709 mvmvif->csa_blocks_tx = chsw->block_tx;
5715 if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP,
5725 if (!vif->cfg.assoc || !vif->bss_conf.dtim_period)
5726 return -EBUSY;
5728 if (chsw->delay > IWL_MAX_CSA_BLOCK_TX &&
5729 hweight16(vif->valid_links) <= 1)
5730 schedule_delayed_work(&mvmvif->csa_work, 0);
5732 if (chsw->block_tx) {
5737 if (!chsw->count ||
5738 chsw->count * vif->bss_conf.beacon_int >
5740 schedule_delayed_work(&mvmvif->csa_work,
5744 if (!fw_has_capa(&mvm->fw->ucode_capa,
5753 mvmvif->csa_count = chsw->count;
5754 mvmvif->csa_misbehave = false;
5760 mvmvif->ps_disabled = true;
5789 .mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
5790 mvmvif->color)),
5792 .tsf = cpu_to_le32(chsw->timestamp),
5793 .cs_count = chsw->count,
5794 .cs_mode = chsw->block_tx,
5801 if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP,
5805 if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_CS_MODIFY))
5809 mvmvif->id, chsw->count, mvmvif->csa_count, chsw->block_tx);
5811 if (chsw->count >= mvmvif->csa_count && chsw->block_tx) {
5812 if (mvmvif->csa_misbehave) {
5817 link_conf = wiphy_dereference(hw->wiphy,
5818 vif->link_conf[chsw->link_id]);
5824 mvmvif->csa_misbehave = false;
5827 mvmvif->csa_misbehave = true;
5829 mvmvif->csa_count = chsw->count;
5832 if (mvmvif->csa_failed)
5848 &mvm->status))
5855 iwl_trans_wait_tx_queues_empty(mvm->trans, queues);
5861 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
5864 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
5865 lockdep_is_held(&mvm->mutex));
5893 if (!drop && hweight16(vif->active_links) <= 1) {
5894 int link_id = vif->active_links ? __ffs(vif->active_links) : 0;
5897 link_conf = wiphy_dereference(hw->wiphy,
5898 vif->link_conf[link_id]);
5901 if (link_conf->csa_active && mvmvif->csa_blocks_tx)
5906 flush_work(&mvm->add_stream_wk);
5908 mutex_lock(&mvm->mutex);
5910 /* flush the AP-station and all TDLS peers */
5911 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
5912 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
5913 lockdep_is_held(&mvm->mutex));
5918 if (mvmsta->vif != vif)
5921 if (sta == mvmvif->ap_sta) {
5928 if (iwl_mvm_flush_sta(mvm, mvmsta->deflink.sta_id,
5929 mvmsta->tfd_queue_msk))
5935 msk |= mvmsta->tfd_queue_msk;
5939 mutex_unlock(&mvm->mutex);
5947 &mvm->status))
5948 iwl_trans_wait_tx_queues_empty(mvm->trans, msk);
5962 mvm_link_sta = rcu_dereference_protected(mvmsta->link[link_id],
5963 lockdep_is_held(&mvm->mutex));
5967 if (iwl_mvm_flush_sta(mvm, mvm_link_sta->sta_id,
5968 mvmsta->tfd_queue_msk))
5980 mutex_lock(&mvm->mutex);
5982 if (!mvm->acs_survey) {
5983 ret = -ENOENT;
5987 /* Find and return the next entry that has a non-zero active time */
5990 mvm->hw->wiphy->bands[band];
5995 for (chan_idx = 0; chan_idx < sband->n_channels; chan_idx++) {
5997 &mvm->acs_survey->bands[band][chan_idx];
5999 if (!info->time)
6003 survey->channel = &sband->channels[chan_idx];
6004 survey->filled = SURVEY_INFO_TIME |
6008 survey->time = info->time;
6009 survey->time_busy = info->time_busy;
6010 survey->time_rx = info->time_rx;
6011 survey->time_tx = info->time_tx;
6012 survey->noise = info->noise;
6013 if (survey->noise < 0)
6014 survey->filled |= SURVEY_INFO_NOISE_DBM;
6017 info->time = 0;
6024 ret = -ENOENT;
6027 mutex_unlock(&mvm->mutex);
6036 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
6043 if (!fw_has_capa(&mvm->fw->ucode_capa,
6045 return -ENOENT;
6053 return iwl_mvm_mac_get_acs_survey(mvm, idx - 1, survey);
6064 survey->filled = SURVEY_INFO_TIME_RX |
6067 survey->time_rx = mvm->accu_radio_stats.rx_time +
6068 mvm->radio_stats.rx_time;
6069 do_div(survey->time_rx, USEC_PER_MSEC);
6071 survey->time_tx = mvm->accu_radio_stats.tx_time +
6072 mvm->radio_stats.tx_time;
6073 do_div(survey->time_tx, USEC_PER_MSEC);
6079 survey->filled |= SURVEY_INFO_TIME |
6081 survey->time = mvm->accu_radio_stats.on_time_rf +
6082 mvm->radio_stats.on_time_rf;
6083 do_div(survey->time, USEC_PER_MSEC);
6085 survey->time_scan = mvm->accu_radio_stats.on_time_scan +
6086 mvm->radio_stats.on_time_scan;
6087 do_div(survey->time_scan, USEC_PER_MSEC);
6099 rinfo->bw = RATE_INFO_BW_20;
6102 rinfo->bw = RATE_INFO_BW_40;
6105 rinfo->bw = RATE_INFO_BW_80;
6108 rinfo->bw = RATE_INFO_BW_160;
6111 rinfo->bw = RATE_INFO_BW_320;
6125 rinfo->legacy = 10;
6128 rinfo->legacy = 20;
6131 rinfo->legacy = 55;
6134 rinfo->legacy = 110;
6137 rinfo->legacy = 60;
6140 rinfo->legacy = 90;
6143 rinfo->legacy = 120;
6146 rinfo->legacy = 180;
6149 rinfo->legacy = 240;
6152 rinfo->legacy = 360;
6155 rinfo->legacy = 480;
6158 rinfo->legacy = 540;
6163 rinfo->nss = u32_get_bits(rate_n_flags,
6165 rinfo->mcs = format == RATE_MCS_HT_MSK ?
6170 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
6175 rinfo->flags |= RATE_INFO_FLAGS_EHT_MCS;
6180 rinfo->flags |= RATE_INFO_FLAGS_HE_MCS;
6183 rinfo->bw = RATE_INFO_BW_HE_RU;
6184 rinfo->he_ru_alloc = NL80211_RATE_INFO_HE_RU_ALLOC_106;
6191 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_0_8;
6193 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_1_6;
6195 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_3_2;
6197 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_0_8;
6201 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_0_8;
6203 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_1_6;
6205 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_3_2;
6209 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_1_6;
6211 rinfo->he_gi = NL80211_RATE_INFO_HE_GI_3_2;
6216 rinfo->he_dcm = 1;
6219 rinfo->flags |= RATE_INFO_FLAGS_MCS;
6222 rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
6237 if (mvmsta->deflink.avg_energy) {
6238 sinfo->signal_avg = -(s8)mvmsta->deflink.avg_energy;
6239 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
6243 struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->deflink.lq_sta.rs_fw;
6245 iwl_mvm_set_sta_rate(lq_sta->last_rate_n_flags, &sinfo->txrate);
6246 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
6250 if (!(vif->driver_flags & IEEE80211_VIF_BEACON_FILTER))
6253 if (!vif->cfg.assoc)
6258 if (mvmvif->deflink.ap_sta_id != mvmsta->deflink.sta_id)
6264 sinfo->rx_beacon = 0;
6266 sinfo->rx_beacon += mvmvif->link[i]->beacon_stats.num_beacons +
6267 mvmvif->link[i]->beacon_stats.accu_num_beacons;
6269 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX);
6270 if (mvmvif->deflink.beacon_stats.avg_signal) {
6272 sinfo->rx_beacon_signal_avg =
6273 mvmvif->deflink.beacon_stats.avg_signal;
6274 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG);
6282 if ((mlme->data == ASSOC_EVENT || mlme->data == AUTH_EVENT) &&
6283 (mlme->status == MLME_DENIED || mlme->status == MLME_TIMEOUT)) {
6284 iwl_dbg_tlv_time_point(&mvm->fwrt,
6290 if (mlme->data == DEAUTH_RX_EVENT || mlme->data == DEAUTH_TX_EVENT) {
6291 iwl_dbg_tlv_time_point(&mvm->fwrt,
6304 if ((trig_mlme->_cnt) && --(trig_mlme->_cnt)) \
6306 iwl_fw_dbg_collect_trig(&(mvm)->fwrt, trig, _fmt); \
6312 if (iwl_trans_dbg_ini_valid(mvm->trans)) {
6313 iwl_mvm_event_mlme_callback_ini(mvm, vif, &event->u.mlme);
6317 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
6322 trig_mlme = (void *)trig->data;
6324 if (event->u.mlme.data == ASSOC_EVENT) {
6325 if (event->u.mlme.status == MLME_DENIED)
6328 event->u.mlme.reason);
6329 else if (event->u.mlme.status == MLME_TIMEOUT)
6332 } else if (event->u.mlme.data == AUTH_EVENT) {
6333 if (event->u.mlme.status == MLME_DENIED)
6336 event->u.mlme.reason);
6337 else if (event->u.mlme.status == MLME_TIMEOUT)
6340 } else if (event->u.mlme.data == DEAUTH_RX_EVENT) {
6342 "DEAUTH RX %d", event->u.mlme.reason);
6343 } else if (event->u.mlme.data == DEAUTH_TX_EVENT) {
6345 "DEAUTH TX %d", event->u.mlme.reason);
6357 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
6362 ba_trig = (void *)trig->data;
6364 if (!(le16_to_cpu(ba_trig->rx_bar) & BIT(event->u.ba.tid)))
6367 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
6369 event->u.ba.sta->addr, event->u.ba.tid,
6370 event->u.ba.ssn);
6379 switch (event->type) {
6387 iwl_mvm_event_frame_timeout_callback(mvm, vif, event->u.ba.sta,
6388 event->u.ba.tid);
6405 .cmd.rxq_mask = cpu_to_le32(BIT(mvm->trans->num_rx_queues) - 1),
6430 cmd.notif.cookie = mvm->queue_sync_cookie;
6431 mvm->queue_sync_state = (1 << mvm->trans->num_rx_queues) - 1;
6441 lockdep_assert_held(&mvm->mutex);
6442 ret = wait_event_timeout(mvm->rx_sync_waitq,
6443 READ_ONCE(mvm->queue_sync_state) == 0,
6446 mvm->queue_sync_state,
6447 mvm->queue_sync_cookie);
6452 mvm->queue_sync_state = 0;
6453 mvm->queue_sync_cookie++;
6473 if (vif->p2p || vif->type != NL80211_IFTYPE_AP ||
6474 !mvmvif->ap_ibss_active || !vif->bss_conf.ftm_responder)
6475 return -EINVAL;
6477 mutex_lock(&mvm->mutex);
6478 *stats = mvm->ftm_resp_stats;
6479 mutex_unlock(&mvm->mutex);
6481 stats->filled = BIT(NL80211_FTM_STATS_SUCCESS_NUM) |
6514 u8 protocol = ip_hdr(skb)->protocol;
6529 if (skb->protocol != htons(ETH_P_IP))
6546 if (!hwts->macaddr)
6547 return -EOPNOTSUPP;
6549 if (hwts->enable)
6554 return iwl_mvm_time_sync_config(mvm, hwts->macaddr, protocols);