Lines Matching refs:mvm

28 #include "mvm.h"
113 static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm)
117 memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts));
119 mvm->phy_ctxts[i].id = i;
120 mvm->phy_ctxts[i].ref = 0;
131 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
135 IWL_DEBUG_LAR(mvm, "Getting regdomain data for %s from FW\n", alpha2);
137 lockdep_assert_held(&mvm->mutex);
139 resp = iwl_mvm_update_mcc(mvm, alpha2, src_id);
141 IWL_DEBUG_LAR(mvm, "Could not get update from FW %d\n",
153 resp_ver = iwl_fw_lookup_notif_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP,
155 IWL_DEBUG_LAR(mvm, "MCC update response version: %d\n", resp_ver);
157 regd = iwl_parse_nvm_mcc_info(mvm->trans->dev, mvm->cfg,
166 IWL_DEBUG_LAR(mvm, "Could not get parse update from FW %d\n",
171 IWL_DEBUG_LAR(mvm, "setting alpha2 from FW to %s (0x%x, 0x%x) src=%d\n",
173 mvm->lar_regdom_set = true;
174 mvm->mcc_src = src_id;
182 ieee80211_hw_set(mvm->hw, DISALLOW_PUNCTURING);
184 __clear_bit(IEEE80211_HW_DISALLOW_PUNCTURING, mvm->hw->flags);
193 void iwl_mvm_update_changed_regdom(struct iwl_mvm *mvm)
198 if (!iwl_mvm_is_lar_supported(mvm))
201 regd = iwl_mvm_get_current_regdomain(mvm, &changed);
205 regulatory_set_wiphy_regd(mvm->hw->wiphy, regd);
211 struct ieee80211_regdomain *iwl_mvm_get_current_regdomain(struct iwl_mvm *mvm,
214 return iwl_mvm_get_regdomain(mvm->hw->wiphy, "ZZ",
215 iwl_mvm_is_wifi_mcc_supported(mvm) ?
220 int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm, bool force_regd_sync)
227 wiphy_dereference(mvm->hw->wiphy, mvm->hw->wiphy->regd);
233 used_src = mvm->mcc_src;
234 if (iwl_mvm_is_wifi_mcc_supported(mvm)) {
236 regd = iwl_mvm_get_current_regdomain(mvm, NULL);
242 regd = iwl_mvm_get_regdomain(mvm->hw->wiphy, r->alpha2, used_src,
251 ret = regulatory_set_wiphy_regd_sync(mvm->hw->wiphy, regd);
314 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
315 *tx_ant = iwl_mvm_get_valid_tx_ant(mvm);
316 *rx_ant = iwl_mvm_get_valid_rx_ant(mvm);
322 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
325 if (mvm->trans->trans_cfg->device_family != IWL_DEVICE_FAMILY_9000 &&
326 mvm->trans->trans_cfg->device_family != IWL_DEVICE_FAMILY_22000)
329 if (!mvm->nvm_data)
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);
344 int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
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 &&
391 if (!mvm->mld_api_is_used)
405 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_9000)
409 if (iwl_mvm_has_tlc_offload(mvm)) {
415 if (iwl_mvm_has_new_rx_api(mvm) &&
416 mvm->trans->trans_cfg->device_family > IWL_DEVICE_FAMILY_9000)
419 if (fw_has_capa(&mvm->fw->ucode_capa,
422 } else if (WARN_ON(iwl_mvm_has_new_tx_api(mvm))) {
431 if (mvm->trans->num_rx_queues > 1)
434 if (mvm->trans->max_skb_frags)
450 if (!iwl_mvm_has_tlc_offload(mvm))
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));
460 hw->wiphy->cipher_suites = mvm->ciphers;
462 if (iwl_mvm_has_new_rx_api(mvm)) {
463 mvm->ciphers[hw->wiphy->n_cipher_suites] =
466 mvm->ciphers[hw->wiphy->n_cipher_suites] =
472 IWL_ERR(mvm,
475 IWL_ERR(mvm,
479 mvm->ciphers[hw->wiphy->n_cipher_suites] = WLAN_CIPHER_SUITE_AES_CMAC;
481 if (iwl_mvm_has_new_rx_api(mvm)) {
482 mvm->ciphers[hw->wiphy->n_cipher_suites] =
485 mvm->ciphers[hw->wiphy->n_cipher_suites] =
495 if (fw_has_capa(&mvm->fw->ucode_capa,
503 fw_has_capa(&mvm->fw->ucode_capa,
507 else if (fw_has_capa(&mvm->fw->ucode_capa,
512 if (fw_has_capa(&mvm->fw->ucode_capa,
516 if (fw_has_capa(&mvm->fw->ucode_capa,
546 if (!iwl_mvm_has_new_tx_api(mvm))
552 if (iwl_mvm_is_lar_supported(mvm))
558 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
574 memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN);
575 hw->wiphy->addresses = mvm->addresses;
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]++;
589 iwl_mvm_reset_phy_ctxts(mvm);
591 hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm);
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)
606 &mvm->nvm_data->bands[NL80211_BAND_2GHZ];
607 if (mvm->nvm_data->bands[NL80211_BAND_5GHZ].n_channels) {
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,
618 if (fw_has_capa(&mvm->fw->ucode_capa,
620 mvm->nvm_data->bands[NL80211_BAND_6GHZ].n_channels)
622 &mvm->nvm_data->bands[NL80211_BAND_6GHZ];
624 hw->wiphy->hw_version = mvm->trans->hw_id;
633 hw->wiphy->max_match_sets = iwl_umac_scan_get_max_profiles(mvm->fw);
654 if (fw_has_capa(&mvm->fw->ucode_capa,
657 if (fw_has_capa(&mvm->fw->ucode_capa,
661 if (fw_has_capa(&mvm->fw->ucode_capa,
666 if (fw_has_capa(&mvm->fw->ucode_capa,
670 if (iwl_fw_lookup_cmd_ver(mvm->fw, WOWLAN_KEK_KCK_MATERIAL,
674 if (fw_has_api(&mvm->fw->ucode_capa,
682 if (iwl_mvm_is_oce_supported(mvm)) {
683 u8 scan_ver = iwl_fw_lookup_cmd_ver(mvm->fw, SCAN_REQ_UMAC, 0);
701 if (mvm->nvm_data->sku_cap_11ax_enable &&
711 if (iwl_fw_lookup_cmd_ver(mvm->fw,
715 IWL_DEBUG_INFO(mvm->trans, "Timing measurement supported\n");
726 if (iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(LOCATION_GROUP,
732 if (fw_has_capa(&mvm->fw->ucode_capa,
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;
763 ret = iwl_mvm_leds_init(mvm);
767 if (fw_has_capa(&mvm->fw->ucode_capa,
769 IWL_DEBUG_TDLS(mvm, "TDLS supported\n");
774 if (fw_has_capa(&mvm->fw->ucode_capa,
776 IWL_DEBUG_TDLS(mvm, "TDLS channel switch supported\n");
780 hw->netdev_features |= mvm->cfg->features;
781 if (!iwl_mvm_is_csum_supported(mvm))
784 if (mvm->cfg->vht_mu_mimo_supported)
788 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_PROTECTED_TWT))
792 iwl_mvm_vendor_cmds_register(mvm);
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);
799 iwl_mvm_leds_exit(mvm);
805 static void iwl_mvm_tx_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
809 if (likely(iwl_mvm_tx_skb_sta(mvm, skb, sta) == 0))
812 if (likely(iwl_mvm_tx_skb_non_sta(mvm, skb) == 0))
816 ieee80211_free_txskb(mvm->hw, skb);
822 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
832 if (iwl_mvm_is_radio_killed(mvm)) {
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))
856 if (ap_sta_id < mvm->fw->ucode_capa.num_stations) {
858 sta = rcu_dereference(mvm->fw_id_to_mac_id[ap_sta_id]);
883 iwl_mvm_tx_skb(mvm, skb, sta);
891 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
925 !test_bit(IWL_MVM_STATUS_IN_D3, &mvm->status))) {
930 IWL_DEBUG_TX(mvm,
937 iwl_mvm_tx_skb(mvm, skb, txq->sta);
946 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
959 spin_lock_bh(&mvm->add_stream_lock);
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);
978 iwl_mvm_ampdu_check_trigger(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
985 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
997 CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_start, tid,
1003 CHECK_BA_TRIGGER(mvm, trig, ba_trig->tx_ba_stop, tid,
1008 CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_start, tid,
1013 CHECK_BA_TRIGGER(mvm, trig, ba_trig->rx_ba_stop, tid,
1026 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1036 IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n",
1039 if (!(mvm->nvm_data->sku_cap_11n_enable))
1042 mutex_lock(&mvm->mutex);
1050 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[macid];
1060 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true, buf_size,
1064 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false, buf_size,
1072 ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn);
1075 ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid);
1079 ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid);
1082 ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid,
1097 iwl_mvm_ampdu_check_trigger(mvm, vif, sta, tid,
1100 mutex_unlock(&mvm->mutex);
1108 struct iwl_mvm *mvm = data;
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);
1139 lockdep_is_held(&mvm->mutex));
1147 struct iwl_mvm *mvm = data;
1163 lockdep_is_held(&mvm->mutex));
1172 iwl_mvm_mld_free_sta_link(mvm, mvm_sta, mvm_link_sta,
1178 static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
1180 iwl_mvm_stop_device(mvm);
1182 mvm->cur_aid = 0;
1184 mvm->scan_status = 0;
1185 mvm->ps_disabled = false;
1186 mvm->rfkill_safe_init_done = false;
1189 iwl_mvm_cleanup_roc_te(mvm);
1190 ieee80211_remain_on_channel_expired(mvm->hw);
1192 iwl_mvm_ftm_restart(mvm);
1198 ieee80211_iterate_interfaces(mvm->hw, 0, iwl_mvm_cleanup_iterator, mvm);
1201 ieee80211_iterate_stations_atomic(mvm->hw,
1202 iwl_mvm_cleanup_sta_iterator, mvm);
1204 mvm->p2p_device_vif = NULL;
1206 iwl_mvm_reset_phy_ctxts(mvm);
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;
1221 iwl_mvm_accu_radio_stats(mvm);
1224 int __iwl_mvm_mac_start(struct iwl_mvm *mvm)
1229 lockdep_assert_held(&mvm->mutex);
1231 ret = iwl_mvm_mei_get_ownership(mvm);
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;
1257 ret = iwl_mvm_fast_resume(mvm);
1259 iwl_mvm_stop_device(mvm);
1271 set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status);
1276 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status)) {
1281 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1282 clear_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status);
1284 iwl_mvm_restart_cleanup(mvm);
1289 ret = iwl_mvm_up(mvm);
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)) {
1303 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1311 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
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);
1326 ret = __iwl_mvm_mac_start(mvm);
1327 clear_bit(IWL_MVM_STATUS_STARTING, &mvm->status);
1329 mutex_unlock(&mvm->mutex);
1331 iwl_mvm_mei_set_sw_rfkill_state(mvm);
1336 static void iwl_mvm_restart_complete(struct iwl_mvm *mvm)
1340 guard(mvm)(mvm);
1342 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1344 ret = iwl_mvm_update_quotas(mvm, true, NULL);
1346 IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n",
1349 iwl_mvm_send_recovery_cmd(mvm, ERROR_RECOVERY_END_OF_RECOVERY);
1355 iwl_mvm_teardown_tdls_peers(mvm);
1361 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1365 iwl_mvm_restart_complete(mvm);
1372 void __iwl_mvm_mac_stop(struct iwl_mvm *mvm, bool suspend)
1374 lockdep_assert_held(&mvm->mutex);
1376 iwl_mvm_ftm_initiator_smooth_stop(mvm);
1381 memset(&mvm->accu_radio_stats, 0, sizeof(mvm->accu_radio_stats));
1385 if (!iwl_mvm_has_new_station_api(mvm->fw))
1386 iwl_mvm_rm_aux_sta(mvm);
1389 mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
1390 iwl_mvm_fast_suspend(mvm);
1392 iwl_mvm_stop_device(mvm);
1394 iwl_mvm_async_handlers_purge(mvm);
1404 if (test_and_clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) ||
1406 &mvm->status))
1407 ieee80211_iterate_interfaces(mvm->hw, 0,
1408 iwl_mvm_cleanup_iterator, mvm);
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;
1427 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1430 mutex_lock(&mvm->mutex);
1431 iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_INT_MLO, false);
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);
1458 iwl_mvm_mei_set_sw_rfkill_state(mvm);
1460 mutex_lock(&mvm->mutex);
1461 __iwl_mvm_mac_stop(mvm, suspend);
1462 mutex_unlock(&mvm->mutex);
1468 cancel_work_sync(&mvm->async_handlers_wk);
1469 wiphy_work_cancel(hw->wiphy, &mvm->async_handlers_wiphy_wk);
1472 struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
1476 lockdep_assert_held(&mvm->mutex);
1479 if (!mvm->phy_ctxts[i].ref)
1480 return &mvm->phy_ctxts[i];
1482 IWL_ERR(mvm, "No available PHY context\n");
1486 int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
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,
1521 return iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, len, &cmd);
1543 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1546 mutex_lock(&mvm->mutex);
1555 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, ap_sta_id);
1562 iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false);
1563 if (mvm->mld_api_is_used)
1564 iwl_mvm_mld_mac_ctxt_changed(mvm, vif, false);
1566 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
1568 if (!fw_has_capa(&mvm->fw->ucode_capa,
1570 ret = iwl_mvm_enable_beacon_filter(mvm, vif);
1574 iwl_mvm_stop_session_protection(mvm, vif);
1592 ret = iwl_mvm_power_update_ps(mvm);
1597 mutex_unlock(&mvm->mutex);
1606 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
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,
1628 iwl_mvm_remove_csa_period(mvm, vif);
1630 WARN_ON(iwl_mvm_send_cmd_pdu(mvm,
1635 mutex_unlock(&mvm->mutex);
1675 static int iwl_mvm_alloc_bcast_mcast_sta(struct iwl_mvm *mvm,
1681 lockdep_assert_held(&mvm->mutex);
1683 ret = iwl_mvm_alloc_bcast_sta(mvm, vif);
1685 IWL_ERR(mvm, "Failed to allocate bcast sta\n");
1692 return iwl_mvm_allocate_int_sta(mvm, &mvmvif->deflink.mcast_sta, 0,
1702 struct iwl_mvm *mvm = mvmvif->mvm;
1706 guard(mvm)(mvm);
1707 iwl_mvm_unblock_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_PREVENTION);
1717 guard(mvm)(mvmvif->mvm);
1718 iwl_mvm_int_mlo_scan(mvmvif->mvm, vif);
1725 struct iwl_mvm *mvm = mvmvif->mvm;
1729 guard(mvm)(mvm);
1730 iwl_mvm_unblock_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_TPT);
1733 void iwl_mvm_mac_init_mvmvif(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif)
1735 lockdep_assert_held(&mvm->mutex);
1737 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1756 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1761 mutex_lock(&mvm->mutex);
1763 iwl_mvm_mac_init_mvmvif(mvm, mvmvif);
1765 mvmvif->mvm = mvm;
1772 ret = iwl_mvm_set_link_mapping(mvm, vif, &vif->bss_conf);
1783 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1789 ret = iwl_mvm_mac_ctxt_init(mvm, vif);
1793 rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif);
1814 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1815 iwl_mvm_vif_dbgfs_add_link(mvm, vif);
1822 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
1826 ret = iwl_mvm_power_update_mac(mvm);
1831 ret = iwl_mvm_disable_beacon_filter(mvm, vif);
1835 if (!mvm->bf_allowed_vif &&
1837 mvm->bf_allowed_vif = mvmvif;
1843 mvm->p2p_device_vif = vif;
1845 iwl_mvm_tcm_add_vif(mvm, vif);
1848 mvm->monitor_on = true;
1849 mvm->monitor_p80 =
1853 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1854 iwl_mvm_vif_dbgfs_add_link(mvm, vif);
1856 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
1858 !mvm->csme_vif && mvm->mei_registered) {
1859 iwl_mei_set_nic_info(vif->addr, mvm->nvm_data->hw_addr);
1861 mvm->csme_vif = vif;
1867 ret = iwl_mvm_alloc_bcast_mcast_sta(mvm, vif);
1873 iwl_mvm_mac_ctxt_remove(mvm, vif);
1875 mutex_unlock(&mvm->mutex);
1880 void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
1891 flush_work(&mvm->roc_done_wk);
1894 wiphy_delayed_work_cancel(mvm->hw->wiphy,
1897 wiphy_delayed_work_cancel(mvm->hw->wiphy,
1900 wiphy_work_cancel(mvm->hw->wiphy, &mvmvif->unblock_esr_tpt_wk);
1908 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1912 iwl_mvm_prepare_mac_removal(mvm, vif);
1916 iwl_mvm_tcm_rm_vif(mvm, vif);
1918 mutex_lock(&mvm->mutex);
1920 if (vif == mvm->csme_vif) {
1922 mvm->csme_vif = NULL;
1926 lockdep_is_held(&mvm->mutex));
1931 if (mvm->bf_allowed_vif == mvmvif) {
1932 mvm->bf_allowed_vif = NULL;
1938 memset(&mvm->ftm_resp_stats, 0, sizeof(mvm->ftm_resp_stats));
1940 iwl_mvm_vif_dbgfs_rm_link(mvm, vif);
1949 if (vif == mvm->noa_vif) {
1950 mvm->noa_vif = NULL;
1951 mvm->noa_duration = 0;
1957 iwl_mvm_power_update_mac(mvm);
1966 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt);
1969 mvm->p2p_device_vif = NULL;
1972 iwl_mvm_unset_link_mapping(mvm, vif, &vif->bss_conf);
1973 iwl_mvm_mac_ctxt_remove(mvm, vif);
1975 RCU_INIT_POINTER(mvm->vif_id_to_mac[mvmvif->id], NULL);
1978 mvm->monitor_on = false;
1983 iwl_mvm_dealloc_int_sta(mvm, &mvmvif->deflink.mcast_sta);
1984 iwl_mvm_dealloc_bcast_sta(mvm, vif);
1987 mutex_unlock(&mvm->mutex);
1991 struct iwl_mvm *mvm;
1999 struct iwl_mvm *mvm = data->mvm;
2000 struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd;
2023 ret = iwl_mvm_send_cmd(mvm, &hcmd);
2025 IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret);
2028 static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm)
2031 .mvm = mvm,
2035 lockdep_assert_held(&mvm->mutex);
2037 if (WARN_ON_ONCE(!mvm->mcast_filter_cmd))
2041 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
2056 ret = iwl_mvm_send_cmd_pdu(mvm, ECHO_CMD, 0, 0, NULL);
2058 IWL_ERR(mvm, "Failed to synchronize multicast groups update\n");
2064 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2093 IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %pM\n",
2096 IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %6D\n",
2115 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2122 guard(mvm)(mvm);
2125 kfree(mvm->mcast_filter_cmd);
2126 mvm->mcast_filter_cmd = cmd;
2137 iwl_mvm_recalc_multicast(mvm);
2147 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
2158 guard(mvm)(mvm);
2159 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
2162 int iwl_mvm_update_mu_groups(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2171 return iwl_mvm_send_cmd_pdu(mvm,
2194 void iwl_mvm_mu_mimo_grp_notif(struct iwl_mvm *mvm,
2201 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
2232 static void iwl_mvm_parse_ppe(struct iwl_mvm *mvm,
2246 IWL_DEBUG_INFO(mvm, "Got NSS = %d - trimming to %d\n", nss,
2286 static void iwl_mvm_set_pkt_ext_from_he_ppe(struct iwl_mvm *mvm,
2300 iwl_mvm_parse_ppe(mvm, pkt_ext, nss, ru_index_bitmap, ppe, ppe_pos_bit,
2373 int iwl_mvm_set_sta_pkt_ext(struct iwl_mvm *mvm,
2408 iwl_mvm_parse_ppe(mvm, pkt_ext, nss, ru_index_bitmap,
2420 iwl_mvm_set_pkt_ext_from_he_ppe(mvm, link_sta, pkt_ext,
2440 iwl_mvm_set_pkt_ext_from_he_ppe(mvm, link_sta, pkt_ext,
2464 IWL_DEBUG_HT(mvm,
2476 bool iwl_mvm_set_fw_mu_edca_params(struct iwl_mvm *mvm,
2507 bool iwl_mvm_is_nic_ack_enabled(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
2515 sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ];
2555 static void iwl_mvm_cfg_he_sta(struct iwl_mvm *mvm,
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))
2594 IWL_ERR(mvm, "bad STA_HE_CTXT_CMD version %d\n", ver);
2600 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_ctxt_cmd.sta_id]);
2622 if (!iwl_mvm_set_sta_pkt_ext(mvm, &sta->deflink, &sta_ctxt_cmd.pkt_ext))
2635 if (iwl_mvm_set_fw_mu_edca_params(mvm, &mvmvif->deflink,
2648 if (!iwl_mvm_is_nic_ack_enabled(mvm, vif))
2704 if (iwl_mvm_send_cmd_pdu(mvm, cmd_id, 0, size, cmd))
2705 IWL_ERR(mvm, "Failed to config FW to work HE!\n");
2708 void iwl_mvm_protect_assoc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2726 if (fw_has_capa(&mvm->fw->ucode_capa,
2728 iwl_mvm_schedule_session_protection(mvm, vif, 900,
2732 iwl_mvm_protect_session(mvm, vif, duration,
2737 void iwl_mvm_bss_info_changed_station_assoc(struct iwl_mvm *mvm,
2748 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
2750 ret = iwl_mvm_update_mu_groups(mvm, vif);
2752 IWL_ERR(mvm,
2756 iwl_mvm_recalc_multicast(mvm);
2762 iwl_mvm_bt_coex_vif_change(mvm);
2763 iwl_mvm_update_smps_on_active_links(mvm, vif, IWL_MVM_SMPS_REQ_TT,
2765 if (fw_has_capa(&mvm->fw->ucode_capa,
2767 iwl_mvm_config_scan(mvm);
2772 iwl_mvm_bss_info_changed_station_common(struct iwl_mvm *mvm,
2784 iwl_mvm_stop_session_protection(mvm, vif);
2786 iwl_mvm_sf_update(mvm, vif, false);
2787 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif));
2795 ret = iwl_mvm_power_update_mac(mvm);
2797 IWL_ERR(mvm, "failed to update power mode\n");
2804 IWL_DEBUG_MAC80211(mvm, "CQM info_changed\n");
2812 ret = iwl_mvm_enable_beacon_filter(mvm, vif);
2814 IWL_ERR(mvm,
2823 IWL_DEBUG_CALIB(mvm, "Changing TPE\n");
2824 iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif,
2830 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,
2847 iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->deflink.ap_sta_id);
2849 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif);
2856 iwl_mvm_cfg_he_sta(mvm, vif, mvmvif->deflink.ap_sta_id);
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);
2880 iwl_mvm_request_statistics(mvm, true);
2886 ret = iwl_mvm_update_quotas(mvm, true, NULL);
2888 IWL_ERR(mvm, "failed to update quotas\n");
2893 &mvm->status) &&
2894 !fw_has_capa(&mvm->fw->ucode_capa,
2915 iwl_mvm_protect_session(mvm, vif, dur, dur,
2918 &mvm->status) &&
2930 iwl_mvm_protect_assoc(mvm, vif, 0, 0);
2933 iwl_mvm_sf_update(mvm, vif, false);
2934 iwl_mvm_power_vif_assoc(mvm, vif);
2936 iwl_mvm_update_smps(mvm, vif,
2941 iwl_mvm_mei_host_disassociated(mvm);
2946 ret = iwl_mvm_sf_update(mvm, vif, false);
2949 &mvm->status),
2961 &mvm->status)) {
2963 iwl_mvm_sec_key_remove_ap(mvm, vif,
2970 ret = iwl_mvm_rm_sta_id(mvm, vif,
2973 IWL_ERR(mvm,
2980 ret = iwl_mvm_update_quotas(mvm, false, NULL);
2982 IWL_ERR(mvm, "failed to update quotas\n");
2985 ret = iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
2987 IWL_ERR(mvm,
2992 iwl_mvm_bss_info_changed_station_assoc(mvm, vif, changes);
2995 iwl_mvm_bss_info_changed_station_common(mvm, vif, &vif->bss_conf,
3003 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3007 lockdep_assert_held(&mvm->mutex);
3031 iwl_mvm_send_low_latency_cmd(mvm, true, mvmvif->id);
3035 iwl_mvm_power_update_mac(mvm);
3044 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3048 mutex_lock(&mvm->mutex);
3056 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif);
3062 if (mvm->trans->trans_cfg->device_family > IWL_DEVICE_FAMILY_22000) {
3064 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
3069 ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf);
3074 ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf);
3079 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
3085 ret = iwl_mvm_binding_add_vif(mvm, vif);
3096 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) {
3097 ret = iwl_mvm_add_mcast_sta(mvm, vif);
3104 ret = iwl_mvm_send_add_bcast_sta(mvm, vif);
3106 iwl_mvm_rm_mcast_sta(mvm, vif);
3114 ret = iwl_mvm_send_add_bcast_sta(mvm, vif);
3117 ret = iwl_mvm_add_mcast_sta(mvm, vif);
3119 iwl_mvm_send_rm_bcast_sta(mvm, vif);
3127 ret = iwl_mvm_update_quotas(mvm, false, NULL);
3132 if (vif->p2p && mvm->p2p_device_vif)
3133 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL);
3135 iwl_mvm_bt_coex_vif_change(mvm);
3138 if (iwl_mvm_phy_ctx_count(mvm) > 1)
3139 iwl_mvm_teardown_tdls_peers(mvm);
3141 iwl_mvm_ftm_restart_responder(mvm, vif, &vif->bss_conf);
3146 iwl_mvm_power_update_mac(mvm);
3148 iwl_mvm_send_rm_bcast_sta(mvm, vif);
3149 iwl_mvm_rm_mcast_sta(mvm, vif);
3151 iwl_mvm_binding_remove_vif(mvm, vif);
3153 iwl_mvm_mac_ctxt_remove(mvm, vif);
3155 mutex_unlock(&mvm->mutex);
3173 void iwl_mvm_stop_ap_ibss_common(struct iwl_mvm *mvm,
3178 lockdep_assert_held(&mvm->mutex);
3180 iwl_mvm_prepare_mac_removal(mvm, vif);
3183 if (rcu_access_pointer(mvm->csa_vif) == vif) {
3184 iwl_mvm_remove_time_event(mvm, mvmvif,
3186 RCU_INIT_POINTER(mvm->csa_vif, NULL);
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;
3196 mvm->ap_last_beacon_gp2 = 0;
3201 iwl_mvm_send_low_latency_cmd(mvm, false, mvmvif->id);
3204 iwl_mvm_bt_coex_vif_change(mvm);
3211 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3213 guard(mvm)(mvm);
3215 iwl_mvm_stop_ap_ibss_common(mvm, vif);
3218 if (vif->p2p && mvm->p2p_device_vif)
3219 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif, false, NULL);
3221 iwl_mvm_update_quotas(mvm, false, NULL);
3223 iwl_mvm_ftm_responder_clear(mvm, vif);
3233 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE))
3234 iwl_mvm_rm_mcast_sta(mvm, vif);
3235 iwl_mvm_send_rm_bcast_sta(mvm, vif);
3236 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE))
3237 iwl_mvm_rm_mcast_sta(mvm, vif);
3238 iwl_mvm_binding_remove_vif(mvm, vif);
3240 iwl_mvm_power_update_mac(mvm);
3242 iwl_mvm_mac_ctxt_remove(mvm, vif);
3259 iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm,
3272 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL))
3273 IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
3277 iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, &vif->bss_conf))
3278 IWL_WARN(mvm, "Failed updating beacon data\n");
3281 int ret = iwl_mvm_ftm_start_responder(mvm, vif, &vif->bss_conf);
3284 IWL_WARN(mvm, "Failed to enable FTM responder (%d)\n",
3295 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3297 guard(mvm)(mvm);
3300 iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, true);
3304 iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes);
3308 iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes);
3312 iwl_mvm_update_mu_groups(mvm, vif);
3320 IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d dBm\n",
3322 iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower);
3329 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3332 hw_req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels)
3335 guard(mvm)(mvm);
3336 return iwl_mvm_reg_scan_start(mvm, vif, &hw_req->req, &hw_req->ies);
3342 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3344 guard(mvm)(mvm);
3353 if (mvm->scan_status & IWL_MVM_SCAN_REGULAR)
3354 iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, true);
3364 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3368 iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames,
3379 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3383 iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames,
3391 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3401 if (WARN_ON(iwl_mvm_has_new_tx_api(mvm)))
3413 if (iwl_mvm_tid_queued(mvm, tid_data) == 0)
3425 iwl_trans_freeze_txq_timer(mvm->trans, txqs, true);
3437 iwl_trans_freeze_txq_timer(mvm->trans, txqs, false);
3438 iwl_mvm_sta_modify_ps_wake(mvm, sta);
3452 void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
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]);
3480 __iwl_mvm_mac_sta_notify(mvm->hw,
3509 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3520 * Since there's mvm->mutex here, no need to have RCU lock for
3523 guard(mvm)(mvm);
3532 lockdep_is_held(&mvm->mutex));
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],
3537 RCU_INIT_POINTER(mvm->fw_id_to_link_sta[sta_id], NULL);
3542 static void iwl_mvm_check_uapsd(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
3547 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
3550 mdata = &mvm->tcm.data[iwl_mvm_vif_from_mac80211(vif)->id];
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)) {
3570 if (ether_addr_equal(mvm->uapsd_noagg_bssids[i].addr, bssid)) {
3580 iwl_mvm_tdls_check_trigger(struct iwl_mvm *mvm,
3587 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
3601 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
3662 static void iwl_mvm_reset_cca_40mhz_workaround(struct iwl_mvm *mvm,
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];
3694 static void iwl_mvm_mei_host_associated(struct iwl_mvm *mvm,
3704 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
3707 if (!mvm->mei_registered)
3765 static int iwl_mvm_mac_ctxt_changed_wrapper(struct iwl_mvm *mvm,
3769 return iwl_mvm_mac_ctxt_changed(mvm, vif, force_assoc_off, NULL);
3794 static void iwl_mvm_rs_rate_init_all_links(struct iwl_mvm *mvm,
3810 iwl_mvm_rs_rate_init(mvm, vif, sta, conf, link_sta,
3815 static bool iwl_mvm_vif_conf_from_sta(struct iwl_mvm *mvm,
3837 IWL_ERR(mvm,
3878 iwl_mvm_sta_state_notexist_to_none(struct iwl_mvm *mvm,
3888 lockdep_assert_held(&mvm->mutex);
3891 !iwl_mvm_vif_conf_from_sta(mvm, vif, sta))
3896 iwl_mvm_tdls_sta_count(mvm, NULL) == IWL_MVM_TDLS_STA_COUNT ||
3897 iwl_mvm_phy_ctx_count(mvm) > 1)) {
3898 IWL_DEBUG_MAC80211(mvm, "refusing TDLS sta\n");
3902 ret = callbacks->add_sta(mvm, vif, sta);
3904 iwl_mvm_recalc_tdls_state(mvm, vif, true);
3905 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
3931 iwl_mvm_rs_rate_init_all_links(mvm, vif, sta);
3938 struct iwl_mvm *mvm,
3948 lockdep_assert_held(&mvm->mutex);
3953 callbacks->mac_ctxt_changed(mvm, vif, false);
3958 if (!mvm->mld_api_is_used &&
3961 iwl_mvm_cfg_he_sta(mvm, vif, mvm_sta->deflink.sta_id);
3965 callbacks->mac_ctxt_changed(mvm, vif, false);
3967 if (!mvm->mld_api_is_used)
3979 iwl_mvm_link_changed(mvm, vif, link_conf,
3987 iwl_mvm_rs_rate_init_all_links(mvm, vif, sta);
3989 return callbacks->update_sta(mvm, vif, sta);
3993 iwl_mvm_sta_state_assoc_to_authorized(struct iwl_mvm *mvm,
4001 lockdep_assert_held(&mvm->mutex);
4004 if (iwl_mvm_phy_ctx_count(mvm) > 1)
4005 iwl_mvm_teardown_tdls_peers(mvm);
4008 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
4012 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif));
4016 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) {
4022 callbacks->mac_ctxt_changed(mvm, vif, false);
4023 iwl_mvm_mei_host_associated(mvm, vif, mvm_sta);
4028 iwl_mvm_block_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_TPT, 0);
4031 iwl_mvm_block_esr(mvm, vif, IWL_MVM_ESR_BLOCKED_FW, 0);
4037 !test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
4038 iwl_mvm_select_links(mvm, vif);
4047 int ret = callbacks->update_sta(mvm, vif, sta);
4053 iwl_mvm_rs_rate_init_all_links(mvm, vif, sta);
4059 iwl_mvm_sta_state_authorized_to_assoc(struct iwl_mvm *mvm,
4067 lockdep_assert_held(&mvm->mutex);
4074 iwl_mvm_rs_rate_init_all_links(mvm, vif, sta);
4085 iwl_mvm_disable_beacon_filter(mvm, vif);
4087 wiphy_delayed_work_cancel(mvm->hw->wiphy,
4090 wiphy_delayed_work_cancel(mvm->hw->wiphy,
4093 wiphy_work_cancel(mvm->hw->wiphy, &mvmvif->unblock_esr_tpt_wk);
4097 iwl_mvm_request_periodic_system_statistics(mvm, false);
4111 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4118 IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n",
4136 flush_work(&mvm->add_stream_wk);
4147 iwl_mvm_reset_cca_40mhz_workaround(mvm, vif);
4153 mutex_lock(&mvm->mutex);
4163 mutex_unlock(&mvm->mutex);
4165 &mvm->status) ? 0 : -EINVAL;
4174 ret = iwl_mvm_sta_state_notexist_to_none(mvm, vif, sta,
4184 mvm->last_ebs_successful = true;
4185 iwl_mvm_check_uapsd(mvm, vif, sta->addr);
4189 ret = iwl_mvm_sta_state_auth_to_assoc(hw, mvm, vif, sta,
4193 ret = iwl_mvm_sta_state_assoc_to_authorized(mvm, vif, sta,
4197 ret = iwl_mvm_sta_state_authorized_to_assoc(mvm, vif, sta,
4203 callbacks->mac_ctxt_changed(mvm, vif, false);
4205 iwl_mvm_stop_session_protection(mvm, vif);
4213 iwl_mvm_stop_session_protection(mvm, vif);
4216 ret = callbacks->rm_sta(mvm, vif, sta);
4218 iwl_mvm_recalc_tdls_state(mvm, vif, false);
4219 iwl_mvm_tdls_check_trigger(mvm, vif, sta->addr,
4225 &mvm->status)))
4231 mutex_unlock(&mvm->mutex);
4247 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4249 mvm->rts_threshold = value;
4257 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4262 iwl_mvm_rs_rate_init_all_links(mvm, vif, sta);
4266 iwl_mvm_sf_update(mvm, vif, false);
4274 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4284 guard(mvm)(mvm);
4285 return iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
4295 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4300 guard(mvm)(mvm);
4301 iwl_mvm_protect_assoc(mvm, vif, info->duration, info->link_id);
4308 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4314 guard(mvm)(mvm);
4315 iwl_mvm_stop_session_protection(mvm, vif);
4323 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4325 guard(mvm)(mvm);
4330 return iwl_mvm_sched_scan_start(mvm, vif, req, ies, IWL_MVM_SCAN_SCHED);
4336 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4339 mutex_lock(&mvm->mutex);
4349 if (!(mvm->scan_status & IWL_MVM_SCAN_SCHED)) {
4350 mutex_unlock(&mvm->mutex);
4354 ret = iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, false);
4355 mutex_unlock(&mvm->mutex);
4356 iwl_mvm_wait_for_async_handlers(mvm);
4368 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4373 u8 sec_key_ver = iwl_fw_lookup_cmd_ver(mvm->fw, sec_key_id, 0);
4382 if (!mvm->trans->trans_cfg->gen2) {
4388 IWL_DEBUG_MAC80211(mvm, "Use SW encryption for TKIP\n");
4395 if (!iwl_mvm_has_new_tx_api(mvm))
4407 if (iwl_mvm_has_new_tx_api(mvm))
4452 !iwl_mvm_has_new_tx_api(mvm)) {
4480 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
4482 IWL_DEBUG_MAC80211(mvm,
4488 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
4489 mvmsta && iwl_mvm_has_new_rx_api(mvm) &&
4499 mvm->trans->num_rx_queues),
4508 for (q = 0; q < mvm->trans->num_rx_queues; q++)
4518 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
4526 IWL_DEBUG_MAC80211(mvm, "set hwcrypto key (sta:%pM, id:%d)\n",
4530 ret = iwl_mvm_sec_key_add(mvm, vif, sta, key);
4532 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, key_offset);
4535 IWL_WARN(mvm, "set key failed\n");
4547 if (iwl_mvm_has_new_tx_api(mvm))
4577 if (mvmsta && iwl_mvm_has_new_rx_api(mvm) &&
4584 lockdep_is_held(&mvm->mutex));
4590 IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n");
4592 ret = iwl_mvm_sec_key_del(mvm, vif, sta, key);
4594 ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key);
4607 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4609 guard(mvm)(mvm);
4619 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4624 iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key);
4631 struct iwl_mvm *mvm =
4641 IWL_ERR(mvm, "Invalid HOT_SPOT_CMD response\n");
4647 IWL_DEBUG_TE(mvm,
4652 IWL_DEBUG_TE(mvm, "TIME_EVENT_CMD response - UID = 0x%x\n",
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);
4662 static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
4677 .sta_id_and_color = cpu_to_le32(mvm->aux_sta.sta_id),
4679 struct iwl_hs20_roc_req_tail *tail = iwl_mvm_chan_info_cmd_tail(mvm,
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,
4690 tail->apply_time = cpu_to_le32(iwl_mvm_get_systime(mvm));
4696 IWL_DEBUG_TE(mvm,
4699 IWL_DEBUG_TE(mvm,
4706 lockdep_assert_held(&mvm->mutex);
4708 spin_lock_bh(&mvm->time_event_lock);
4711 spin_unlock_bh(&mvm->time_event_lock);
4719 spin_unlock_bh(&mvm->time_event_lock);
4730 iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
4735 res = iwl_mvm_send_cmd_pdu(mvm, HOT_SPOT_CMD, 0, len,
4739 IWL_ERR(mvm, "Couldn't send HOT_SPOT_CMD: %d\n", res);
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);
4752 iwl_mvm_te_clear_data(mvm, te_data);
4753 spin_unlock_bh(&mvm->time_event_lock);
4759 static int iwl_mvm_add_aux_sta_for_hs20(struct iwl_mvm *mvm, u32 lmac_id)
4763 lockdep_assert_held(&mvm->mutex);
4765 if (!fw_has_capa(&mvm->fw->ucode_capa,
4767 IWL_ERR(mvm, "hotspot not supported\n");
4771 if (iwl_mvm_has_new_station_api(mvm->fw)) {
4772 ret = iwl_mvm_add_aux_sta(mvm, lmac_id);
4779 static int iwl_mvm_roc_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
4783 lockdep_assert_held(&mvm->mutex);
4785 ret = iwl_mvm_binding_add_vif(mvm, vif);
4792 return iwl_mvm_add_p2p_bcast_sta(mvm, vif);
4809 static int iwl_mvm_roc_station(struct iwl_mvm *mvm,
4816 u8 fw_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id,
4820 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, vif, duration);
4822 ret = iwl_mvm_roc_add_cmd(mvm, channel, vif, duration,
4826 IWL_ERR(mvm, "ROC command version %d mismatch!\n", fw_ver);
4832 static int iwl_mvm_roc_p2p(struct iwl_mvm *mvm,
4841 lockdep_assert_held(&mvm->mutex);
4855 ret = iwl_mvm_mld_add_aux_sta(mvm,
4856 iwl_mvm_get_lmac_id(mvm, channel->band));
4860 return iwl_mvm_roc_add_cmd(mvm, channel, vif, duration, activity);
4863 static int iwl_mvm_p2p_find_phy_ctxt(struct iwl_mvm *mvm,
4871 lockdep_assert_held(&mvm->mutex);
4879 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[i];
4886 iwl_mvm_phy_ctxt_unref(mvm,
4890 iwl_mvm_phy_ctxt_ref(mvm, 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);
4905 return iwl_mvm_phy_ctxt_add(mvm, mvmvif->deflink.phy_ctxt,
4915 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4916 struct ieee80211_vif *bss_vif = iwl_mvm_get_bss_vif(mvm);
4920 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
4927 flush_work(&mvm->roc_done_wk);
4930 ret = iwl_mvm_block_esr_sync(mvm, bss_vif,
4936 guard(mvm)(mvm);
4940 lmac_id = iwl_mvm_get_lmac_id(mvm, channel->band);
4943 ret = ops->add_aux_sta_for_hs20(mvm, lmac_id);
4945 ret = iwl_mvm_roc_station(mvm, channel, vif, duration);
4951 IWL_ERR(mvm, "ROC: Invalid vif type=%u\n", vif->type);
4955 if (iwl_mvm_has_p2p_over_aux(mvm)) {
4956 ret = iwl_mvm_roc_p2p(mvm, channel, vif, duration, type);
4960 ret = iwl_mvm_p2p_find_phy_ctxt(mvm, vif, channel);
4964 ret = ops->link(mvm, vif);
4968 return iwl_mvm_start_p2p_roc(mvm, vif, duration, type);
4974 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4976 IWL_DEBUG_MAC80211(mvm, "enter\n");
4978 iwl_mvm_stop_roc(mvm, vif);
4980 IWL_DEBUG_MAC80211(mvm, "leave\n");
4999 bool iwl_mvm_is_ftm_responder_chanctx(struct iwl_mvm *mvm,
5007 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
5014 static int __iwl_mvm_add_chanctx(struct iwl_mvm *mvm,
5019 struct cfg80211_chan_def *def = iwl_mvm_chanctx_def(mvm, ctx);
5022 lockdep_assert_held(&mvm->mutex);
5024 IWL_DEBUG_MAC80211(mvm, "Add channel context\n");
5026 phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
5032 ret = iwl_mvm_phy_ctxt_add(mvm, phy_ctxt, def, &ctx->ap,
5036 IWL_ERR(mvm, "Failed to add PHY context\n");
5048 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5050 guard(mvm)(mvm);
5051 return __iwl_mvm_add_chanctx(mvm, ctx);
5054 static void __iwl_mvm_remove_chanctx(struct iwl_mvm *mvm,
5058 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
5060 lockdep_assert_held(&mvm->mutex);
5062 iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt);
5068 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5070 guard(mvm)(mvm);
5071 __iwl_mvm_remove_chanctx(mvm, ctx);
5077 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5079 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
5080 struct cfg80211_chan_def *def = iwl_mvm_chanctx_def(mvm, ctx);
5091 guard(mvm)(mvm);
5104 iwl_mvm_bt_coex_vif_change(mvm);
5105 iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, def, &ctx->ap,
5117 __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
5123 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
5126 lockdep_assert_held(&mvm->mutex);
5158 static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
5170 if (__iwl_mvm_assign_vif_chanctx_common(mvm, vif, ctx,
5174 ret = iwl_mvm_binding_add_vif(mvm, vif);
5182 iwl_mvm_power_update_mac(mvm);
5190 ret = iwl_mvm_update_quotas(mvm, false, NULL);
5194 ret = iwl_mvm_add_snif_sta(mvm, vif);
5202 iwl_mvm_update_quotas(mvm, false, NULL);
5203 iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
5214 if (!fw_has_capa(&mvm->fw->ucode_capa,
5221 iwl_mvm_protect_session(mvm, vif, duration, duration,
5226 iwl_mvm_update_quotas(mvm, false, NULL);
5228 iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif,
5236 iwl_mvm_binding_remove_vif(mvm, vif);
5237 iwl_mvm_power_update_mac(mvm);
5249 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5251 guard(mvm)(mvm);
5252 return __iwl_mvm_assign_vif_chanctx(mvm, vif, link_conf, ctx, false);
5261 static bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm *mvm,
5267 lockdep_assert_held(&mvm->mutex);
5268 iwl_mvm_remove_time_event(mvm, mvmvif,
5286 iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true);
5289 rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif);
5299 static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
5308 if (__iwl_mvm_unassign_vif_chanctx_common(mvm, vif, switching_chanctx))
5312 iwl_mvm_rm_snif_sta(mvm, vif);
5317 if (!fw_has_capa(&mvm->fw->ucode_capa,
5319 iwl_mvm_mac_ctxt_changed(mvm, vif, true, NULL);
5322 iwl_mvm_update_quotas(mvm, false, disabled_vif);
5323 iwl_mvm_binding_remove_vif(mvm, vif);
5326 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD) &&
5330 iwl_mvm_power_update_mac(mvm);
5338 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5340 guard(mvm)(mvm);
5341 __iwl_mvm_unassign_vif_chanctx(mvm, vif, link_conf, ctx, false);
5345 iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm *mvm,
5351 guard(mvm)(mvm);
5352 ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5354 __iwl_mvm_remove_chanctx(mvm, vifs[0].old_ctx);
5356 ret = __iwl_mvm_add_chanctx(mvm, vifs[0].new_ctx);
5358 IWL_ERR(mvm, "failed to add new_ctx during channel switch\n");
5362 ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5365 IWL_ERR(mvm,
5371 if (iwl_mvm_phy_ctx_count(mvm) > 1)
5372 iwl_mvm_teardown_tdls_peers(mvm);
5377 __iwl_mvm_remove_chanctx(mvm, vifs[0].new_ctx);
5380 if (__iwl_mvm_add_chanctx(mvm, vifs[0].old_ctx)) {
5381 IWL_ERR(mvm, "failed to add old_ctx back after failure.\n");
5385 if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5387 IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n");
5395 iwl_mvm_nic_restart(mvm, false);
5400 iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm *mvm,
5406 guard(mvm)(mvm);
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,
5413 IWL_ERR(mvm,
5421 if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
5423 IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n");
5431 iwl_mvm_nic_restart(mvm, false);
5443 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5452 ret = iwl_mvm_switch_vif_chanctx_swap(mvm, vifs, ops);
5455 ret = iwl_mvm_switch_vif_chanctx_reassign(mvm, vifs, ops);
5480 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5482 return mvm->ibss_manager;
5488 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5492 IWL_ERR(mvm, "Station is not associated to a vif\n");
5496 return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif,
5507 static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm,
5534 mvm->noa_duration = noa_duration;
5535 mvm->noa_vif = vif;
5537 return iwl_mvm_update_quotas(mvm, true, NULL);
5546 return iwl_mvm_enable_beacon_filter(mvm, vif);
5547 return iwl_mvm_disable_beacon_filter(mvm, vif);
5557 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5559 guard(mvm)(mvm);
5560 return __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len);
5577 static int iwl_mvm_schedule_client_csa(struct iwl_mvm *mvm,
5591 lockdep_assert_held(&mvm->mutex);
5597 return iwl_mvm_send_cmd_pdu(mvm,
5603 static int iwl_mvm_old_pre_chan_sw_sta(struct iwl_mvm *mvm,
5624 iwl_mvm_csa_client_absent(mvm, vif);
5627 int ret = iwl_mvm_disable_beacon_filter(mvm, vif);
5633 iwl_mvm_schedule_csa_period(mvm, vif, vif->bss_conf.beacon_int,
5652 int iwl_mvm_pre_channel_switch(struct iwl_mvm *mvm,
5661 lockdep_assert_held(&mvm->mutex);
5666 IWL_DEBUG_MAC80211(mvm, "pre CSA to freq %d\n",
5669 iwl_fw_dbg_trigger_simple_stop(&mvm->fwrt,
5676 rcu_dereference_protected(mvm->csa_vif,
5677 lockdep_is_held(&mvm->mutex));
5683 if (rcu_dereference_protected(mvm->csa_tx_blocked_vif,
5684 lockdep_is_held(&mvm->mutex)))
5687 rcu_assign_pointer(mvm->csa_vif, vif);
5698 if (!ieee80211_hw_check(mvm->hw, HANDLES_QUIET_CSA))
5704 ieee80211_iterate_stations_atomic(mvm->hw,
5715 if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP,
5744 if (!fw_has_capa(&mvm->fw->ucode_capa,
5746 ret = iwl_mvm_old_pre_chan_sw_sta(mvm, vif, chsw);
5750 iwl_mvm_schedule_client_csa(mvm, vif, chsw);
5762 ret = iwl_mvm_power_update_ps(mvm);
5767 iwl_mvm_teardown_tdls_peers(mvm);
5776 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5778 guard(mvm)(mvm);
5779 return iwl_mvm_pre_channel_switch(mvm, vif, chsw);
5786 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
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))
5808 IWL_DEBUG_MAC80211(mvm, "Modify CSA on mac %d count = %d (old %d) mode = %d\n",
5831 guard(mvm)(mvm);
5835 WARN_ON(iwl_mvm_send_cmd_pdu(mvm,
5841 static void iwl_mvm_flush_no_vif(struct iwl_mvm *mvm, u32 queues, bool drop)
5845 if (!iwl_mvm_has_new_tx_api(mvm)) {
5848 &mvm->status))
5851 guard(mvm)(mvm);
5852 iwl_mvm_flush_tx_path(mvm,
5853 iwl_mvm_flushable_queues(mvm) & queues);
5855 iwl_trans_wait_tx_queues_empty(mvm->trans, queues);
5860 guard(mvm)(mvm);
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));
5870 iwl_mvm_flush_sta_tids(mvm, i, 0xFFFF);
5872 iwl_mvm_wait_sta_queues_empty(mvm,
5881 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5889 iwl_mvm_flush_no_vif(mvm, queues, drop);
5906 flush_work(&mvm->add_stream_wk);
5908 mutex_lock(&mvm->mutex);
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));
5928 if (iwl_mvm_flush_sta(mvm, mvmsta->deflink.sta_id,
5930 IWL_ERR(mvm, "flush request fail\n");
5932 if (iwl_mvm_has_new_tx_api(mvm))
5933 iwl_mvm_wait_sta_queues_empty(mvm, mvmsta);
5939 mutex_unlock(&mvm->mutex);
5945 if (!drop && !iwl_mvm_has_new_tx_api(mvm) &&
5947 &mvm->status))
5948 iwl_trans_wait_tx_queues_empty(mvm->trans, msk);
5955 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
5960 guard(mvm)(mvm);
5963 lockdep_is_held(&mvm->mutex));
5967 if (iwl_mvm_flush_sta(mvm, mvm_link_sta->sta_id,
5969 IWL_ERR(mvm, "flush request fail\n");
5973 static int iwl_mvm_mac_get_acs_survey(struct iwl_mvm *mvm, int idx,
5980 mutex_lock(&mvm->mutex);
5982 if (!mvm->acs_survey) {
5990 mvm->hw->wiphy->bands[band];
5997 &mvm->acs_survey->bands[band][chan_idx];
6027 mutex_unlock(&mvm->mutex);
6035 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6036 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
6043 if (!fw_has_capa(&mvm->fw->ucode_capa,
6053 return iwl_mvm_mac_get_acs_survey(mvm, idx - 1, survey);
6055 guard(mvm)(mvm);
6057 if (iwl_mvm_firmware_running(mvm)) {
6058 int ret = iwl_mvm_request_statistics(mvm, false);
6067 survey->time_rx = mvm->accu_radio_stats.rx_time +
6068 mvm->radio_stats.rx_time;
6071 survey->time_tx = mvm->accu_radio_stats.tx_time +
6072 mvm->radio_stats.tx_time;
6081 survey->time = mvm->accu_radio_stats.on_time_rf +
6082 mvm->radio_stats.on_time_rf;
6085 survey->time_scan = mvm->accu_radio_stats.on_time_scan +
6086 mvm->radio_stats.on_time_scan;
6232 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6242 if (iwl_mvm_has_tlc_offload(mvm)) {
6256 guard(mvm)(mvm);
6261 if (iwl_mvm_request_statistics(mvm, false))
6278 static void iwl_mvm_event_mlme_callback_ini(struct iwl_mvm *mvm,
6284 iwl_dbg_tlv_time_point(&mvm->fwrt,
6291 iwl_dbg_tlv_time_point(&mvm->fwrt,
6298 static void iwl_mvm_event_mlme_callback(struct iwl_mvm *mvm,
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),
6350 static void iwl_mvm_event_bar_rx_callback(struct iwl_mvm *mvm,
6357 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
6367 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
6377 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6381 iwl_mvm_event_mlme_callback(mvm, vif, event);
6384 iwl_mvm_event_bar_rx_callback(mvm, vif, event);
6387 iwl_mvm_event_frame_timeout_callback(mvm, vif, event->u.ba.sta,
6396 void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
6405 .cmd.rxq_mask = cpu_to_le32(BIT(mvm->trans->num_rx_queues) - 1),
6426 if (!iwl_mvm_has_new_rx_api(mvm))
6430 cmd.notif.cookie = mvm->queue_sync_cookie;
6431 mvm->queue_sync_state = (1 << mvm->trans->num_rx_queues) - 1;
6434 ret = iwl_mvm_send_cmd(mvm, &hcmd);
6436 IWL_ERR(mvm, "Failed to trigger RX queues sync (%d)\n", ret);
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++;
6459 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6461 guard(mvm)(mvm);
6462 iwl_mvm_sync_rx_queues_internal(mvm, IWL_MVM_RXQ_EMPTY, true, NULL, 0);
6470 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6477 mutex_lock(&mvm->mutex);
6478 *stats = mvm->ftm_resp_stats;
6479 mutex_unlock(&mvm->mutex);
6497 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6499 guard(mvm)(mvm);
6500 return iwl_mvm_ftm_start(mvm, vif, request);
6506 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6508 guard(mvm)(mvm);
6509 iwl_mvm_ftm_abort(mvm, request);
6526 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6532 if (!iwl_mvm_is_csum_supported(mvm))
6542 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
6553 guard(mvm)(mvm);
6554 return iwl_mvm_time_sync_config(mvm, hwts->macaddr, protocols);