Lines Matching refs:mvm
16 #include "mvm.h"
24 int iwl_mvm_send_cmd(struct iwl_mvm *mvm, struct iwl_host_cmd *cmd)
29 if (WARN_ON(mvm->d3_test_active))
39 lockdep_assert_held(&mvm->mutex);
41 ret = iwl_trans_send_cmd(mvm->trans, cmd);
60 int iwl_mvm_send_cmd_pdu(struct iwl_mvm *mvm, u32 id,
70 return iwl_mvm_send_cmd(mvm, &cmd);
76 int iwl_mvm_send_cmd_status(struct iwl_mvm *mvm, struct iwl_host_cmd *cmd,
83 lockdep_assert_held(&mvm->mutex);
86 if (WARN_ON(mvm->d3_test_active))
100 ret = iwl_trans_send_cmd(mvm->trans, cmd);
129 int iwl_mvm_send_cmd_pdu_status(struct iwl_mvm *mvm, u32 id, u16 len,
138 return iwl_mvm_send_cmd_status(mvm, &cmd, status);
198 void iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
203 IWL_ERR(mvm, "FW Error notification: type 0x%08X cmd_id 0x%02X\n",
205 IWL_ERR(mvm, "FW Error notification: seq 0x%04X service 0x%08X\n",
208 IWL_ERR(mvm, "FW Error notification: timestamp 0x%016llX\n",
231 u8 iwl_mvm_next_antenna(struct iwl_mvm *mvm, u8 valid, u8 last_idx)
248 * @mvm: Driver data.
258 int iwl_mvm_send_lq_cmd(struct iwl_mvm *mvm, struct iwl_lq_cmd *lq)
268 iwl_mvm_has_tlc_offload(mvm)))
271 return iwl_mvm_send_cmd(mvm, &cmd);
276 * @mvm: Driver data.
285 void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
294 lockdep_assert_held(&mvm->mutex);
297 if (num_of_ant(iwl_mvm_get_valid_rx_ant(mvm)) == 1)
327 void iwl_mvm_update_smps_on_active_links(struct iwl_mvm *mvm,
337 iwl_mvm_update_smps(mvm, vif, req_type, smps_request,
352 int iwl_mvm_request_periodic_system_statistics(struct iwl_mvm *mvm, bool enable)
364 return iwl_mvm_send_cmd_pdu(mvm,
370 static int iwl_mvm_request_system_statistics(struct iwl_mvm *mvm, bool clear,
393 IWL_FW_CHECK_FAILED(mvm,
399 iwl_init_notification_wait(&mvm->notif_wait, &stats_wait,
403 mvm->statistics_clear = clear;
404 ret = iwl_mvm_send_cmd(mvm, &cmd);
406 iwl_remove_notification(&mvm->notif_wait, &stats_wait);
414 ret = iwl_wait_notification(&mvm->notif_wait, &stats_wait, HZ / 2);
419 iwl_mvm_accu_radio_stats(mvm);
424 int iwl_mvm_request_statistics(struct iwl_mvm *mvm, bool clear)
435 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
445 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
449 return iwl_mvm_request_system_statistics(mvm, clear, cmd_ver);
455 if (iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP,
459 ret = iwl_mvm_send_cmd(mvm, &cmd);
463 iwl_mvm_handle_rx_statistics(mvm, cmd.resp_pkt);
471 iwl_init_notification_wait(&mvm->notif_wait, &stats_wait,
475 ret = iwl_mvm_send_cmd(mvm, &cmd);
477 iwl_remove_notification(&mvm->notif_wait, &stats_wait);
484 ret = iwl_wait_notification(&mvm->notif_wait, &stats_wait, HZ / 5);
490 iwl_mvm_accu_radio_stats(mvm);
495 void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm)
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;
531 bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm,
539 lockdep_assert_held(&mvm->mutex);
544 if (num_of_ant(iwl_mvm_get_valid_rx_ant(mvm)) == 1)
547 if (mvm->cfg->rx_with_siso_diversity)
551 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
557 void iwl_mvm_send_low_latency_cmd(struct iwl_mvm *mvm,
564 if (!fw_has_capa(&mvm->fw->ucode_capa,
574 if (iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(MAC_CONF_GROUP, LOW_LATENCY_CMD),
576 IWL_ERR(mvm, "Failed to send low latency command\n");
579 int iwl_mvm_update_low_latency(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
587 lockdep_assert_held(&mvm->mutex);
597 iwl_mvm_send_low_latency_cmd(mvm, low_latency, mvmvif->id);
599 res = iwl_mvm_update_quotas(mvm, false, NULL);
603 iwl_mvm_bt_coex_vif_change(mvm);
605 return iwl_mvm_power_update_mac(mvm);
630 bool iwl_mvm_low_latency(struct iwl_mvm *mvm)
635 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
641 bool iwl_mvm_low_latency_band(struct iwl_mvm *mvm, enum nl80211_band band)
646 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
673 struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm)
678 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
682 IWL_ERR(mvm, "More than one managed interface active!\n");
704 struct ieee80211_vif *iwl_mvm_get_vif_by_macid(struct iwl_mvm *mvm, u32 macid)
710 lockdep_assert_held(&mvm->mutex);
713 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
735 bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm)
741 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
748 unsigned int iwl_mvm_get_wd_timeout(struct iwl_mvm *mvm,
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,
770 trigger = iwl_fw_dbg_get_trigger(mvm->fw, FW_DBG_TRIGGER_TXQ_TIMERS);
799 return mvm->trans->trans_cfg->base_params->wd_timeout;
803 void iwl_mvm_connection_loss(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
809 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
820 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, "%s", errmsg);
826 void iwl_mvm_event_frame_timeout_callback(struct iwl_mvm *mvm,
834 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
844 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig,
858 iwl_mvm_tcm_load(struct iwl_mvm *mvm, u32 airtime, unsigned long elapsed)
872 struct iwl_mvm *mvm = _data;
879 low_latency = mvm->tcm.result.low_latency[mvmvif->id];
881 if (!mvm->tcm.result.change[mvmvif->id] &&
883 iwl_mvm_update_quotas(mvm, false, NULL);
889 iwl_mvm_update_low_latency(mvm, vif, low_latency,
892 iwl_mvm_update_quotas(mvm, false, NULL);
896 static void iwl_mvm_tcm_results(struct iwl_mvm *mvm)
898 guard(mvm)(mvm);
901 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
902 iwl_mvm_tcm_iter, mvm);
904 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN))
905 iwl_mvm_config_scan(mvm);
910 struct iwl_mvm *mvm;
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,
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;
929 iwl_mvm_connection_loss(mvm, vif,
933 static void iwl_mvm_uapsd_agg_disconnect(struct iwl_mvm *mvm,
950 if (mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected)
953 mvm->tcm.data[mvmvif->id].uapsd_nonagg_detect.detected = true;
954 IWL_INFO(mvm,
960 static void iwl_mvm_check_uapsd_agg_expected_tpt(struct iwl_mvm *mvm,
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)
975 if (iwl_mvm_has_new_rx_api(mvm)) {
997 vif = rcu_dereference(mvm->vif_id_to_mac[mac]);
999 iwl_mvm_uapsd_agg_disconnect(mvm, vif);
1015 static unsigned long iwl_mvm_calc_tcm_stats(struct iwl_mvm *mvm,
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];
1050 load = iwl_mvm_tcm_load(mvm, airtime, elapsed);
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;
1061 mvm->tcm.result.low_latency[mac] = true;
1063 mvm->tcm.result.low_latency[mac] = false;
1070 low_latency |= mvm->tcm.result.low_latency[mac];
1072 if (!mvm->tcm.result.low_latency[mac] && handle_uapsd)
1073 iwl_mvm_check_uapsd_agg_expected_tpt(mvm, uapsd_elapsed,
1082 load = iwl_mvm_tcm_load(mvm, total_airtime, elapsed);
1083 mvm->tcm.result.global_load = load;
1086 band_load = iwl_mvm_tcm_load(mvm, band_airtime[i], elapsed);
1087 mvm->tcm.result.band_load[i] = band_load;
1119 void iwl_mvm_recalc_tcm(struct iwl_mvm *mvm)
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);
1133 if (handle_uapsd && iwl_mvm_has_new_rx_api(mvm)) {
1134 guard(mvm)(mvm);
1135 if (iwl_mvm_request_statistics(mvm, true))
1139 spin_lock(&mvm->tcm.lock);
1141 if (!mvm->tcm.paused && time_after(ts, mvm->tcm.ts + MVM_TCM_PERIOD)) {
1143 unsigned long work_delay = iwl_mvm_calc_tcm_stats(mvm, ts,
1148 mvm->tcm.ts = ts;
1150 schedule_delayed_work(&mvm->tcm.work, work_delay);
1152 spin_unlock(&mvm->tcm.lock);
1154 iwl_mvm_tcm_results(mvm);
1160 struct iwl_mvm *mvm = container_of(delayed_work, struct iwl_mvm,
1163 iwl_mvm_recalc_tcm(mvm);
1166 void iwl_mvm_pause_tcm(struct iwl_mvm *mvm, bool with_cancel)
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);
1175 void iwl_mvm_resume_tcm(struct iwl_mvm *mvm)
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];
1191 if (mvm->tcm.result.low_latency[mac])
1196 mvm->tcm.paused = false;
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);
1210 void iwl_mvm_tcm_add_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1218 void iwl_mvm_tcm_rm_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1225 u32 iwl_mvm_get_systime(struct iwl_mvm *mvm)
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);
1236 void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type,
1241 lockdep_assert_held(&mvm->mutex);
1244 ps_disabled = mvm->ps_disabled;
1246 mvm->ps_disabled = true;
1247 iwl_mvm_power_update_device(mvm);
1250 *gp2 = iwl_mvm_get_systime(mvm);
1258 mvm->ps_disabled = ps_disabled;
1259 iwl_mvm_power_update_device(mvm);