Lines Matching +full:tcm +full:- +full:mode

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
12 #include "iwl-debug.h"
13 #include "iwl-io.h"
14 #include "iwl-prph.h"
15 #include "iwl-csr.h"
22 * CMD_WANT_SKB is set in cmd->flags.
29 if (WARN_ON(mvm->d3_test_active))
30 return -EIO;
34 * Synchronous commands from this op-mode must hold
38 if (!(cmd->flags & CMD_ASYNC))
39 lockdep_assert_held(&mvm->mutex);
41 ret = iwl_trans_send_cmd(mvm->trans, cmd);
48 if (cmd->flags & CMD_WANT_SKB)
55 if (!ret || ret == -ERFKILL || ret == -EHOSTDOWN)
83 lockdep_assert_held(&mvm->mutex);
86 if (WARN_ON(mvm->d3_test_active))
87 return -EIO;
94 if (WARN_ONCE(cmd->flags & (CMD_ASYNC | CMD_WANT_SKB),
95 "cmd flags %x", cmd->flags))
96 return -EINVAL;
98 cmd->flags |= CMD_WANT_SKB;
100 ret = iwl_trans_send_cmd(mvm->trans, cmd);
101 if (ret == -ERFKILL) {
111 pkt = cmd->resp_pkt;
115 ret = -EIO;
119 resp = (void *)pkt->data;
120 *status = le32_to_cpu(resp->status);
153 return is_LB ? rate : -1;
168 return idx - band_offset;
170 return -1;
177 * 0 - 3 for CCK and 0 - 7 for OFDM.
180 rate_idx - IWL_FIRST_OFDM_RATE :
201 struct iwl_error_resp *err_resp = (void *)pkt->data;
204 le32_to_cpu(err_resp->error_type), err_resp->cmd_id);
206 le16_to_cpu(err_resp->bad_cmd_seq_num),
207 le32_to_cpu(err_resp->error_service));
209 le64_to_cpu(err_resp->timestamp));
213 * Returns the first antenna as ANT_[ABC], as defined in iwl-config.h.
221 return BIT(ffs(mask) - 1);
247 * iwl_mvm_send_lq_cmd() - Send link quality command
267 if (WARN_ON(lq->sta_id == IWL_MVM_INVALID_STA ||
269 return -EINVAL;
275 * iwl_mvm_update_smps - Get a request to change the SMPS mode
279 * @smps_request: The request to change the SMPS mode.
282 * Get a requst to change the SMPS mode,
294 lockdep_assert_held(&mvm->mutex);
300 if (vif->type != NL80211_IFTYPE_STATION)
305 if (WARN_ON_ONCE(!mvmvif->link[link_id]))
308 mvmvif->link[link_id]->smps_requests[req_type] = smps_request;
310 if (mvmvif->link[link_id]->smps_requests[i] ==
315 if (mvmvif->link[link_id]->smps_requests[i] ==
321 if (mvmvif->esr_active)
345 WARN_ON(pkt->hdr.cmd != STATISTICS_NOTIFICATION);
396 return -EOPNOTSUPP;
399 iwl_init_notification_wait(&mvm->notif_wait, &stats_wait,
403 mvm->statistics_clear = clear;
406 iwl_remove_notification(&mvm->notif_wait, &stats_wait);
414 ret = iwl_wait_notification(&mvm->notif_wait, &stats_wait, HZ / 2);
435 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
445 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
451 /* From version 15 - STATISTICS_NOTIFICATION, the reply for
455 if (iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP,
471 iwl_init_notification_wait(&mvm->notif_wait, &stats_wait,
477 iwl_remove_notification(&mvm->notif_wait, &stats_wait);
484 ret = iwl_wait_notification(&mvm->notif_wait, &stats_wait, HZ / 5);
497 mvm->accu_radio_stats.rx_time += mvm->radio_stats.rx_time;
498 mvm->accu_radio_stats.tx_time += mvm->radio_stats.tx_time;
499 mvm->accu_radio_stats.on_time_rf += mvm->radio_stats.on_time_rf;
500 mvm->accu_radio_stats.on_time_scan += mvm->radio_stats.on_time_scan;
516 struct iwl_mvm_vif_link_info *link_info = mvmvif->link[link_id];
518 if (link_info->phy_ctxt != data->ctxt)
522 if (link_info->smps_requests[i] == IEEE80211_SMPS_STATIC ||
523 link_info->smps_requests[i] == IEEE80211_SMPS_DYNAMIC) {
524 data->result = false;
539 lockdep_assert_held(&mvm->mutex);
547 if (mvm->cfg->rx_with_siso_diversity)
551 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
564 if (!fw_has_capa(&mvm->fw->ucode_capa,
587 lockdep_assert_held(&mvm->mutex);
597 iwl_mvm_send_low_latency_cmd(mvm, low_latency, mvmvif->id);
620 result->result = true;
622 if (!mvmvif->deflink.phy_ctxt)
625 band = mvmvif->deflink.phy_ctxt->channel->band;
626 result->result_per_band[band] = true;
635 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
646 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
662 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
665 if (data->vif) {
666 data->error = true;
670 data->vif = vif;
678 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
683 return ERR_PTR(-EINVAL);
700 if (mvmvif->id == data->macid)
701 data->vif = vif;
710 lockdep_assert_held(&mvm->mutex);
713 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
728 if (vif->type != NL80211_IFTYPE_STATION)
731 if (vif->cfg.assoc)
732 data->assoc = true;
741 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
756 mvm->trans->trans_cfg->base_params->wd_timeout;
758 if (!iwl_fw_dbg_trigger_enabled(mvm->fw, FW_DBG_TRIGGER_TXQ_TIMERS)) {
763 if (fw_has_capa(&mvm->fw->ucode_capa,
765 vif && vif->type == NL80211_IFTYPE_AP)
770 trigger = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_TXQ_TIMERS);
771 txq_timer = (void *)trigger->data;
774 return le32_to_cpu(txq_timer->tdls);
777 return le32_to_cpu(txq_timer->command_queue);
784 return le32_to_cpu(txq_timer->ibss);
786 return le32_to_cpu(txq_timer->bss);
788 return le32_to_cpu(txq_timer->softap);
790 return le32_to_cpu(txq_timer->p2p_client);
792 return le32_to_cpu(txq_timer->p2p_go);
794 return le32_to_cpu(txq_timer->p2p_device);
799 return mvm->trans->trans_cfg->base_params->wd_timeout;
809 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
814 trig_mlme = (void *)trig->data;
816 if (trig_mlme->stop_connection_loss &&
817 --trig_mlme->stop_connection_loss)
820 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, "%s", errmsg);
834 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
839 ba_trig = (void *)trig->data;
841 if (!(le16_to_cpu(ba_trig->frame_timeout) & BIT(tid)))
844 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
846 sta->addr, tid);
874 bool low_latency, prev = mvmvif->low_latency & LOW_LATENCY_TRAFFIC;
876 if (mvmvif->id >= NUM_MAC_INDEX_DRIVER)
879 low_latency = mvm->tcm.result.low_latency[mvmvif->id];
881 if (!mvm->tcm.result.change[mvmvif->id] &&
901 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
904 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN))
917 mvm = mvmvif->mvm;
919 if (mvm->tcm.data[mvmvif->id].opened_rx_ba_sessions)
923 memcpy(mvm->uapsd_noagg_bssids[mvm->uapsd_noagg_bssid_write_idx].addr,
924 vif->bss_conf.bssid, ETH_ALEN);
925 mvm->uapsd_noagg_bssid_write_idx++;
926 if (mvm->uapsd_noagg_bssid_write_idx >= IWL_MVM_UAPSD_NOAGG_LIST_LEN)
927 mvm->uapsd_noagg_bssid_write_idx = 0;
938 if (vif->type != NL80211_IFTYPE_STATION)
941 if (!vif->cfg.assoc)
944 if (!mvmvif->deflink.queue_params[IEEE80211_AC_VO].uapsd &&
945 !mvmvif->deflink.queue_params[IEEE80211_AC_VI].uapsd &&
946 !mvmvif->deflink.queue_params[IEEE80211_AC_BE].uapsd &&
947 !mvmvif->deflink.queue_params[IEEE80211_AC_BK].uapsd)
950 if (mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected)
953 mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected = true;
955 "detected AP should do aggregation but isn't, likely due to U-APSD\n");
956 schedule_delayed_work(&mvmvif->uapsd_nonagg_detected_wk,
964 u64 bytes = mvm->tcm.data[mac].uapsd_nonagg_detect.rx_bytes;
969 rate = ewma_rate_read(&mvm->tcm.data[mac].uapsd_nonagg_detect.rate);
971 if (!rate || mvm->tcm.data[mac].opened_rx_ba_sessions ||
972 mvm->tcm.data[mac].uapsd_nonagg_detect.detected)
997 vif = rcu_dereference(mvm->vif_id_to_mac[mac]);
1009 if (!mvmvif->deflink.phy_ctxt)
1012 band[mvmvif->id] = mvmvif->deflink.phy_ctxt->channel->band;
1019 unsigned int elapsed = jiffies_to_msecs(ts - mvm->tcm.ts);
1021 jiffies_to_msecs(ts - mvm->tcm.uapsd_nonagg_ts);
1028 bool handle_ll = time_after(ts, mvm->tcm.ll_ts + MVM_LL_PERIOD);
1031 mvm->tcm.ll_ts = ts;
1033 mvm->tcm.uapsd_nonagg_ts = ts;
1035 mvm->tcm.result.elapsed = elapsed;
1037 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
1043 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac];
1045 u32 airtime = mdata->rx.airtime + mdata->tx.airtime;
1051 mvm->tcm.result.change[mac] = load != mvm->tcm.result.load[mac];
1052 mvm->tcm.result.load[mac] = load;
1053 mvm->tcm.result.airtime[mac] = airtime;
1056 vo_vi_pkts += mdata->rx.pkts[ac] +
1057 mdata->tx.pkts[ac];
1061 mvm->tcm.result.low_latency[mac] = true;
1063 mvm->tcm.result.low_latency[mac] = false;
1067 memset(&mdata->rx.pkts, 0, sizeof(mdata->rx.pkts));
1068 memset(&mdata->tx.pkts, 0, sizeof(mdata->tx.pkts));
1070 low_latency |= mvm->tcm.result.low_latency[mac];
1072 if (!mvm->tcm.result.low_latency[mac] && handle_uapsd)
1077 mdata->uapsd_nonagg_detect.rx_bytes = 0;
1078 memset(&mdata->rx.airtime, 0, sizeof(mdata->rx.airtime));
1079 memset(&mdata->tx.airtime, 0, sizeof(mdata->tx.airtime));
1083 mvm->tcm.result.global_load = load;
1087 mvm->tcm.result.band_load[i] = band_load;
1091 * If the current load isn't low we need to force re-evaluation
1092 * in the TCM period, so that we can return to low load if there
1099 * If low-latency is active we need to force re-evaluation after
1100 * (the longer) MVM_LL_PERIOD, so that we can disable low-latency
1107 * in the default "idle" state - traffic indication is low (which
1108 * also covers the "no traffic" case) and low-latency is disabled
1113 * updates triggered by traffic - those happen whenever one of the
1123 time_after(ts, mvm->tcm.uapsd_nonagg_ts +
1126 spin_lock(&mvm->tcm.lock);
1127 if (mvm->tcm.paused || !time_after(ts, mvm->tcm.ts + MVM_TCM_PERIOD)) {
1128 spin_unlock(&mvm->tcm.lock);
1131 spin_unlock(&mvm->tcm.lock);
1139 spin_lock(&mvm->tcm.lock);
1140 /* re-check if somebody else won the recheck race */
1141 if (!mvm->tcm.paused && time_after(ts, mvm->tcm.ts + MVM_TCM_PERIOD)) {
1148 mvm->tcm.ts = ts;
1150 schedule_delayed_work(&mvm->tcm.work, work_delay);
1152 spin_unlock(&mvm->tcm.lock);
1161 tcm.work);
1168 spin_lock_bh(&mvm->tcm.lock);
1169 mvm->tcm.paused = true;
1170 spin_unlock_bh(&mvm->tcm.lock);
1172 cancel_delayed_work_sync(&mvm->tcm.work);
1180 spin_lock_bh(&mvm->tcm.lock);
1181 mvm->tcm.ts = jiffies;
1182 mvm->tcm.ll_ts = jiffies;
1184 struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac];
1186 memset(&mdata->rx.pkts, 0, sizeof(mdata->rx.pkts));
1187 memset(&mdata->tx.pkts, 0, sizeof(mdata->tx.pkts));
1188 memset(&mdata->rx.airtime, 0, sizeof(mdata->rx.airtime));
1189 memset(&mdata->tx.airtime, 0, sizeof(mdata->tx.airtime));
1191 if (mvm->tcm.result.low_latency[mac])
1194 /* The TCM data needs to be reset before "paused" flag changes */
1196 mvm->tcm.paused = false;
1200 * re-evaluation to cover the case of no traffic.
1202 if (mvm->tcm.result.global_load > IWL_MVM_TRAFFIC_LOW)
1203 schedule_delayed_work(&mvm->tcm.work, MVM_TCM_PERIOD);
1205 schedule_delayed_work(&mvm->tcm.work, MVM_LL_PERIOD);
1207 spin_unlock_bh(&mvm->tcm.lock);
1214 INIT_DELAYED_WORK(&mvmvif->uapsd_nonagg_detected_wk,
1222 cancel_delayed_work_sync(&mvmvif->uapsd_nonagg_detected_wk);
1229 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_22000 &&
1230 mvm->trans->cfg->gp2_reg_addr)
1231 reg_addr = mvm->trans->cfg->gp2_reg_addr;
1233 return iwl_read_prph(mvm->trans, reg_addr);
1241 lockdep_assert_held(&mvm->mutex);
1244 ps_disabled = mvm->ps_disabled;
1246 mvm->ps_disabled = true;
1258 mvm->ps_disabled = ps_disabled;
1274 if (vif1->link[i]->phy_ctxt == vif2->link[j]->phy_ctxt)
1288 if (mvmvif->link[i]->phy_ctxt &&
1289 mvmvif->link[i]->phy_ctxt->id < NUM_PHY_CTX)