Lines Matching +full:ac +full:- +full:link

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2024 Intel Corporation
4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5 * Copyright (C) 2015-2017 Intel Deutschland GmbH
9 #include "iwl-debug.h"
10 #include "iwl-io.h"
11 #include "iwl-prph.h"
12 #include "iwl-csr.h"
19 * CMD_WANT_SKB is set in cmd->flags.
26 if (WARN_ON(mvm->d3_test_active)) in iwl_mvm_send_cmd()
27 return -EIO; in iwl_mvm_send_cmd()
31 * Synchronous commands from this op-mode must hold in iwl_mvm_send_cmd()
35 if (!(cmd->flags & CMD_ASYNC)) in iwl_mvm_send_cmd()
36 lockdep_assert_held(&mvm->mutex); in iwl_mvm_send_cmd()
38 ret = iwl_trans_send_cmd(mvm->trans, cmd); in iwl_mvm_send_cmd()
45 if (cmd->flags & CMD_WANT_SKB) in iwl_mvm_send_cmd()
52 if (!ret || ret == -ERFKILL || ret == -EHOSTDOWN) in iwl_mvm_send_cmd()
80 lockdep_assert_held(&mvm->mutex); in iwl_mvm_send_cmd_status()
83 if (WARN_ON(mvm->d3_test_active)) in iwl_mvm_send_cmd_status()
84 return -EIO; in iwl_mvm_send_cmd_status()
91 if (WARN_ONCE(cmd->flags & (CMD_ASYNC | CMD_WANT_SKB), in iwl_mvm_send_cmd_status()
92 "cmd flags %x", cmd->flags)) in iwl_mvm_send_cmd_status()
93 return -EINVAL; in iwl_mvm_send_cmd_status()
95 cmd->flags |= CMD_WANT_SKB; in iwl_mvm_send_cmd_status()
97 ret = iwl_trans_send_cmd(mvm->trans, cmd); in iwl_mvm_send_cmd_status()
98 if (ret == -ERFKILL) { in iwl_mvm_send_cmd_status()
108 pkt = cmd->resp_pkt; in iwl_mvm_send_cmd_status()
112 ret = -EIO; in iwl_mvm_send_cmd_status()
116 resp = (void *)pkt->data; in iwl_mvm_send_cmd_status()
117 *status = le32_to_cpu(resp->status); in iwl_mvm_send_cmd_status()
150 return is_LB ? rate : -1; in iwl_mvm_legacy_hw_idx_to_mac80211_idx()
165 return idx - band_offset; in iwl_mvm_legacy_rate_to_mac80211_idx()
167 return -1; in iwl_mvm_legacy_rate_to_mac80211_idx()
174 * 0 - 3 for CCK and 0 - 7 for OFDM. in iwl_mvm_mac80211_idx_to_hwrate()
177 rate_idx - IWL_FIRST_OFDM_RATE : in iwl_mvm_mac80211_idx_to_hwrate()
183 u8 iwl_mvm_mac80211_ac_to_ucode_ac(enum ieee80211_ac_numbers ac) in iwl_mvm_mac80211_ac_to_ucode_ac() argument
192 return mac80211_ac_to_ucode_ac[ac]; in iwl_mvm_mac80211_ac_to_ucode_ac()
198 struct iwl_error_resp *err_resp = (void *)pkt->data; in iwl_mvm_rx_fw_error()
201 le32_to_cpu(err_resp->error_type), err_resp->cmd_id); in iwl_mvm_rx_fw_error()
203 le16_to_cpu(err_resp->bad_cmd_seq_num), in iwl_mvm_rx_fw_error()
204 le32_to_cpu(err_resp->error_service)); in iwl_mvm_rx_fw_error()
206 le64_to_cpu(err_resp->timestamp)); in iwl_mvm_rx_fw_error()
210 * Returns the first antenna as ANT_[ABC], as defined in iwl-config.h.
218 return BIT(ffs(mask) - 1); in first_antenna()
244 * iwl_mvm_send_lq_cmd() - Send link quality command
246 * @lq: Link quality command to send.
248 * The link quality command is sent as the last step of station creation.
264 if (WARN_ON(lq->sta_id == IWL_MVM_INVALID_STA || in iwl_mvm_send_lq_cmd()
266 return -EINVAL; in iwl_mvm_send_lq_cmd()
272 * iwl_mvm_update_smps - Get a request to change the SMPS mode
291 lockdep_assert_held(&mvm->mutex); in iwl_mvm_update_smps()
297 if (vif->type != NL80211_IFTYPE_STATION) in iwl_mvm_update_smps()
306 if (WARN_ON_ONCE(!mvmvif->link[link_id])) in iwl_mvm_update_smps()
309 mvmvif->link[link_id]->smps_requests[req_type] = smps_request; in iwl_mvm_update_smps()
311 if (mvmvif->link[link_id]->smps_requests[i] == in iwl_mvm_update_smps()
316 if (mvmvif->link[link_id]->smps_requests[i] == in iwl_mvm_update_smps()
322 if (mvmvif->esr_active) in iwl_mvm_update_smps()
346 WARN_ON(pkt->hdr.cmd != STATISTICS_NOTIFICATION); in iwl_wait_stats_complete()
397 return -EOPNOTSUPP; in iwl_mvm_request_system_statistics()
400 iwl_init_notification_wait(&mvm->notif_wait, &stats_wait, in iwl_mvm_request_system_statistics()
404 mvm->statistics_clear = clear; in iwl_mvm_request_system_statistics()
407 iwl_remove_notification(&mvm->notif_wait, &stats_wait); in iwl_mvm_request_system_statistics()
415 ret = iwl_wait_notification(&mvm->notif_wait, &stats_wait, HZ / 2); in iwl_mvm_request_system_statistics()
436 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_request_statistics()
446 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) in iwl_mvm_request_statistics()
452 /* From version 15 - STATISTICS_NOTIFICATION, the reply for in iwl_mvm_request_statistics()
456 if (iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP, in iwl_mvm_request_statistics()
472 iwl_init_notification_wait(&mvm->notif_wait, &stats_wait, in iwl_mvm_request_statistics()
478 iwl_remove_notification(&mvm->notif_wait, &stats_wait); in iwl_mvm_request_statistics()
485 ret = iwl_wait_notification(&mvm->notif_wait, &stats_wait, HZ / 5); in iwl_mvm_request_statistics()
498 mvm->accu_radio_stats.rx_time += mvm->radio_stats.rx_time; in iwl_mvm_accu_radio_stats()
499 mvm->accu_radio_stats.tx_time += mvm->radio_stats.tx_time; in iwl_mvm_accu_radio_stats()
500 mvm->accu_radio_stats.on_time_rf += mvm->radio_stats.on_time_rf; in iwl_mvm_accu_radio_stats()
501 mvm->accu_radio_stats.on_time_scan += mvm->radio_stats.on_time_scan; in iwl_mvm_accu_radio_stats()
517 struct iwl_mvm_vif_link_info *link_info = mvmvif->link[link_id]; in iwl_mvm_diversity_iter()
519 if (link_info->phy_ctxt != data->ctxt) in iwl_mvm_diversity_iter()
523 if (link_info->smps_requests[i] == IEEE80211_SMPS_STATIC || in iwl_mvm_diversity_iter()
524 link_info->smps_requests[i] == IEEE80211_SMPS_DYNAMIC) { in iwl_mvm_diversity_iter()
525 data->result = false; in iwl_mvm_diversity_iter()
540 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rx_diversity_allowed()
548 if (mvm->cfg->rx_with_siso_diversity) in iwl_mvm_rx_diversity_allowed()
552 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_rx_diversity_allowed()
565 if (!fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_send_low_latency_cmd()
588 lockdep_assert_held(&mvm->mutex); in iwl_mvm_update_low_latency()
598 iwl_mvm_send_low_latency_cmd(mvm, low_latency, mvmvif->id); in iwl_mvm_update_low_latency()
621 result->result = true; in iwl_mvm_ll_iter()
623 if (!mvmvif->deflink.phy_ctxt) in iwl_mvm_ll_iter()
626 band = mvmvif->deflink.phy_ctxt->channel->band; in iwl_mvm_ll_iter()
627 result->result_per_band[band] = true; in iwl_mvm_ll_iter()
636 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_low_latency()
647 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_low_latency_band()
663 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) in iwl_mvm_bss_iface_iterator()
666 if (data->vif) { in iwl_mvm_bss_iface_iterator()
667 data->error = true; in iwl_mvm_bss_iface_iterator()
671 data->vif = vif; in iwl_mvm_bss_iface_iterator()
679 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_get_bss_vif()
684 return ERR_PTR(-EINVAL); in iwl_mvm_get_bss_vif()
701 if (mvmvif->id == data->macid) in iwl_mvm_bss_find_iface_iterator()
702 data->vif = vif; in iwl_mvm_bss_find_iface_iterator()
711 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_vif_by_macid()
714 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_get_vif_by_macid()
729 if (vif->type != NL80211_IFTYPE_STATION) in iwl_mvm_sta_iface_iterator()
732 if (vif->cfg.assoc) in iwl_mvm_sta_iface_iterator()
733 data->assoc = true; in iwl_mvm_sta_iface_iterator()
742 ieee80211_iterate_active_interfaces_atomic(mvm->hw, in iwl_mvm_is_vif_assoc()
753 mvm->trans->trans_cfg->base_params->wd_timeout; in iwl_mvm_get_wd_timeout()
759 if (fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_get_wd_timeout()
761 vif->type == NL80211_IFTYPE_AP) in iwl_mvm_get_wd_timeout()
772 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), in iwl_mvm_connection_loss()
777 trig_mlme = (void *)trig->data; in iwl_mvm_connection_loss()
779 if (trig_mlme->stop_connection_loss && in iwl_mvm_connection_loss()
780 --trig_mlme->stop_connection_loss) in iwl_mvm_connection_loss()
783 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, "%s", errmsg); in iwl_mvm_connection_loss()
797 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), in iwl_mvm_event_frame_timeout_callback()
802 ba_trig = (void *)trig->data; in iwl_mvm_event_frame_timeout_callback()
804 if (!(le16_to_cpu(ba_trig->frame_timeout) & BIT(tid))) in iwl_mvm_event_frame_timeout_callback()
807 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, in iwl_mvm_event_frame_timeout_callback()
809 sta->addr, tid); in iwl_mvm_event_frame_timeout_callback()
837 bool low_latency, prev = mvmvif->low_latency & LOW_LATENCY_TRAFFIC; in iwl_mvm_tcm_iter()
839 if (mvmvif->id >= NUM_MAC_INDEX_DRIVER) in iwl_mvm_tcm_iter()
842 low_latency = mvm->tcm.result.low_latency[mvmvif->id]; in iwl_mvm_tcm_iter()
844 if (!mvm->tcm.result.change[mvmvif->id] && in iwl_mvm_tcm_iter()
864 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_tcm_results()
867 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) in iwl_mvm_tcm_results()
880 mvm = mvmvif->mvm; in iwl_mvm_tcm_uapsd_nonagg_detected_wk()
882 if (mvm->tcm.data[mvmvif->id].opened_rx_ba_sessions) in iwl_mvm_tcm_uapsd_nonagg_detected_wk()
886 memcpy(mvm->uapsd_noagg_bssids[mvm->uapsd_noagg_bssid_write_idx].addr, in iwl_mvm_tcm_uapsd_nonagg_detected_wk()
887 vif->bss_conf.bssid, ETH_ALEN); in iwl_mvm_tcm_uapsd_nonagg_detected_wk()
888 mvm->uapsd_noagg_bssid_write_idx++; in iwl_mvm_tcm_uapsd_nonagg_detected_wk()
889 if (mvm->uapsd_noagg_bssid_write_idx >= IWL_MVM_UAPSD_NOAGG_LIST_LEN) in iwl_mvm_tcm_uapsd_nonagg_detected_wk()
890 mvm->uapsd_noagg_bssid_write_idx = 0; in iwl_mvm_tcm_uapsd_nonagg_detected_wk()
901 if (vif->type != NL80211_IFTYPE_STATION) in iwl_mvm_uapsd_agg_disconnect()
904 if (!vif->cfg.assoc) in iwl_mvm_uapsd_agg_disconnect()
907 if (!mvmvif->deflink.queue_params[IEEE80211_AC_VO].uapsd && in iwl_mvm_uapsd_agg_disconnect()
908 !mvmvif->deflink.queue_params[IEEE80211_AC_VI].uapsd && in iwl_mvm_uapsd_agg_disconnect()
909 !mvmvif->deflink.queue_params[IEEE80211_AC_BE].uapsd && in iwl_mvm_uapsd_agg_disconnect()
910 !mvmvif->deflink.queue_params[IEEE80211_AC_BK].uapsd) in iwl_mvm_uapsd_agg_disconnect()
913 if (mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected) in iwl_mvm_uapsd_agg_disconnect()
916 mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected = true; in iwl_mvm_uapsd_agg_disconnect()
918 "detected AP should do aggregation but isn't, likely due to U-APSD\n"); in iwl_mvm_uapsd_agg_disconnect()
919 schedule_delayed_work(&mvmvif->uapsd_nonagg_detected_wk, in iwl_mvm_uapsd_agg_disconnect()
927 u64 bytes = mvm->tcm.data[mac].uapsd_nonagg_detect.rx_bytes; in iwl_mvm_check_uapsd_agg_expected_tpt()
932 rate = ewma_rate_read(&mvm->tcm.data[mac].uapsd_nonagg_detect.rate); in iwl_mvm_check_uapsd_agg_expected_tpt()
934 if (!rate || mvm->tcm.data[mac].opened_rx_ba_sessions || in iwl_mvm_check_uapsd_agg_expected_tpt()
935 mvm->tcm.data[mac].uapsd_nonagg_detect.detected) in iwl_mvm_check_uapsd_agg_expected_tpt()
960 vif = rcu_dereference(mvm->vif_id_to_mac[mac]); in iwl_mvm_check_uapsd_agg_expected_tpt()
972 if (!mvmvif->deflink.phy_ctxt) in iwl_mvm_tcm_iterator()
975 band[mvmvif->id] = mvmvif->deflink.phy_ctxt->channel->band; in iwl_mvm_tcm_iterator()
982 unsigned int elapsed = jiffies_to_msecs(ts - mvm->tcm.ts); in iwl_mvm_calc_tcm_stats()
984 jiffies_to_msecs(ts - mvm->tcm.uapsd_nonagg_ts); in iwl_mvm_calc_tcm_stats()
988 int ac, mac, i; in iwl_mvm_calc_tcm_stats() local
991 bool handle_ll = time_after(ts, mvm->tcm.ll_ts + MVM_LL_PERIOD); in iwl_mvm_calc_tcm_stats()
994 mvm->tcm.ll_ts = ts; in iwl_mvm_calc_tcm_stats()
996 mvm->tcm.uapsd_nonagg_ts = ts; in iwl_mvm_calc_tcm_stats()
998 mvm->tcm.result.elapsed = elapsed; in iwl_mvm_calc_tcm_stats()
1000 ieee80211_iterate_active_interfaces_atomic(mvm->hw, in iwl_mvm_calc_tcm_stats()
1006 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac]; in iwl_mvm_calc_tcm_stats()
1008 u32 airtime = mdata->rx.airtime + mdata->tx.airtime; in iwl_mvm_calc_tcm_stats()
1014 mvm->tcm.result.change[mac] = load != mvm->tcm.result.load[mac]; in iwl_mvm_calc_tcm_stats()
1015 mvm->tcm.result.load[mac] = load; in iwl_mvm_calc_tcm_stats()
1016 mvm->tcm.result.airtime[mac] = airtime; in iwl_mvm_calc_tcm_stats()
1018 for (ac = IEEE80211_AC_VO; ac <= IEEE80211_AC_VI; ac++) in iwl_mvm_calc_tcm_stats()
1019 vo_vi_pkts += mdata->rx.pkts[ac] + in iwl_mvm_calc_tcm_stats()
1020 mdata->tx.pkts[ac]; in iwl_mvm_calc_tcm_stats()
1024 mvm->tcm.result.low_latency[mac] = true; in iwl_mvm_calc_tcm_stats()
1026 mvm->tcm.result.low_latency[mac] = false; in iwl_mvm_calc_tcm_stats()
1030 memset(&mdata->rx.pkts, 0, sizeof(mdata->rx.pkts)); in iwl_mvm_calc_tcm_stats()
1031 memset(&mdata->tx.pkts, 0, sizeof(mdata->tx.pkts)); in iwl_mvm_calc_tcm_stats()
1033 low_latency |= mvm->tcm.result.low_latency[mac]; in iwl_mvm_calc_tcm_stats()
1035 if (!mvm->tcm.result.low_latency[mac] && handle_uapsd) in iwl_mvm_calc_tcm_stats()
1040 mdata->uapsd_nonagg_detect.rx_bytes = 0; in iwl_mvm_calc_tcm_stats()
1041 memset(&mdata->rx.airtime, 0, sizeof(mdata->rx.airtime)); in iwl_mvm_calc_tcm_stats()
1042 memset(&mdata->tx.airtime, 0, sizeof(mdata->tx.airtime)); in iwl_mvm_calc_tcm_stats()
1046 mvm->tcm.result.global_load = load; in iwl_mvm_calc_tcm_stats()
1050 mvm->tcm.result.band_load[i] = band_load; in iwl_mvm_calc_tcm_stats()
1054 * If the current load isn't low we need to force re-evaluation in iwl_mvm_calc_tcm_stats()
1062 * If low-latency is active we need to force re-evaluation after in iwl_mvm_calc_tcm_stats()
1063 * (the longer) MVM_LL_PERIOD, so that we can disable low-latency in iwl_mvm_calc_tcm_stats()
1070 * in the default "idle" state - traffic indication is low (which in iwl_mvm_calc_tcm_stats()
1071 * also covers the "no traffic" case) and low-latency is disabled in iwl_mvm_calc_tcm_stats()
1076 * updates triggered by traffic - those happen whenever one of the in iwl_mvm_calc_tcm_stats()
1086 time_after(ts, mvm->tcm.uapsd_nonagg_ts + in iwl_mvm_recalc_tcm()
1089 spin_lock(&mvm->tcm.lock); in iwl_mvm_recalc_tcm()
1090 if (mvm->tcm.paused || !time_after(ts, mvm->tcm.ts + MVM_TCM_PERIOD)) { in iwl_mvm_recalc_tcm()
1091 spin_unlock(&mvm->tcm.lock); in iwl_mvm_recalc_tcm()
1094 spin_unlock(&mvm->tcm.lock); in iwl_mvm_recalc_tcm()
1102 spin_lock(&mvm->tcm.lock); in iwl_mvm_recalc_tcm()
1103 /* re-check if somebody else won the recheck race */ in iwl_mvm_recalc_tcm()
1104 if (!mvm->tcm.paused && time_after(ts, mvm->tcm.ts + MVM_TCM_PERIOD)) { in iwl_mvm_recalc_tcm()
1111 mvm->tcm.ts = ts; in iwl_mvm_recalc_tcm()
1113 schedule_delayed_work(&mvm->tcm.work, work_delay); in iwl_mvm_recalc_tcm()
1115 spin_unlock(&mvm->tcm.lock); in iwl_mvm_recalc_tcm()
1131 spin_lock_bh(&mvm->tcm.lock); in iwl_mvm_pause_tcm()
1132 mvm->tcm.paused = true; in iwl_mvm_pause_tcm()
1133 spin_unlock_bh(&mvm->tcm.lock); in iwl_mvm_pause_tcm()
1135 cancel_delayed_work_sync(&mvm->tcm.work); in iwl_mvm_pause_tcm()
1143 spin_lock_bh(&mvm->tcm.lock); in iwl_mvm_resume_tcm()
1144 mvm->tcm.ts = jiffies; in iwl_mvm_resume_tcm()
1145 mvm->tcm.ll_ts = jiffies; in iwl_mvm_resume_tcm()
1147 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac]; in iwl_mvm_resume_tcm()
1149 memset(&mdata->rx.pkts, 0, sizeof(mdata->rx.pkts)); in iwl_mvm_resume_tcm()
1150 memset(&mdata->tx.pkts, 0, sizeof(mdata->tx.pkts)); in iwl_mvm_resume_tcm()
1151 memset(&mdata->rx.airtime, 0, sizeof(mdata->rx.airtime)); in iwl_mvm_resume_tcm()
1152 memset(&mdata->tx.airtime, 0, sizeof(mdata->tx.airtime)); in iwl_mvm_resume_tcm()
1154 if (mvm->tcm.result.low_latency[mac]) in iwl_mvm_resume_tcm()
1159 mvm->tcm.paused = false; in iwl_mvm_resume_tcm()
1163 * re-evaluation to cover the case of no traffic. in iwl_mvm_resume_tcm()
1165 if (mvm->tcm.result.global_load > IWL_MVM_TRAFFIC_LOW) in iwl_mvm_resume_tcm()
1166 schedule_delayed_work(&mvm->tcm.work, MVM_TCM_PERIOD); in iwl_mvm_resume_tcm()
1168 schedule_delayed_work(&mvm->tcm.work, MVM_LL_PERIOD); in iwl_mvm_resume_tcm()
1170 spin_unlock_bh(&mvm->tcm.lock); in iwl_mvm_resume_tcm()
1177 INIT_DELAYED_WORK(&mvmvif->uapsd_nonagg_detected_wk, in iwl_mvm_tcm_add_vif()
1185 cancel_delayed_work_sync(&mvmvif->uapsd_nonagg_detected_wk); in iwl_mvm_tcm_rm_vif()
1192 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000 && in iwl_mvm_get_systime()
1193 mvm->trans->cfg->gp2_reg_addr) in iwl_mvm_get_systime()
1194 reg_addr = mvm->trans->cfg->gp2_reg_addr; in iwl_mvm_get_systime()
1196 return iwl_read_prph(mvm->trans, reg_addr); in iwl_mvm_get_systime()
1204 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_sync_time()
1207 ps_disabled = mvm->ps_disabled; in iwl_mvm_get_sync_time()
1209 mvm->ps_disabled = true; in iwl_mvm_get_sync_time()
1221 mvm->ps_disabled = ps_disabled; in iwl_mvm_get_sync_time()
1237 if (vif1->link[i]->phy_ctxt == vif2->link[j]->phy_ctxt) in iwl_mvm_have_links_same_channel()
1251 if (mvmvif->link[i]->phy_ctxt && in iwl_mvm_vif_is_active()
1252 mvmvif->link[i]->phy_ctxt->id < NUM_PHY_CTX) in iwl_mvm_vif_is_active()