Lines Matching refs:mvm
146 static inline void *iwl_mvm_get_scan_req_umac_data(struct iwl_mvm *mvm) in iwl_mvm_get_scan_req_umac_data() argument
148 struct iwl_scan_req_umac *cmd = mvm->scan_cmd; in iwl_mvm_get_scan_req_umac_data()
150 if (iwl_mvm_is_adaptive_dwell_v2_supported(mvm)) in iwl_mvm_get_scan_req_umac_data()
153 if (iwl_mvm_is_adaptive_dwell_supported(mvm)) in iwl_mvm_get_scan_req_umac_data()
156 if (iwl_mvm_cdb_scan_api(mvm)) in iwl_mvm_get_scan_req_umac_data()
163 iwl_mvm_get_scan_req_umac_channel(struct iwl_mvm *mvm) in iwl_mvm_get_scan_req_umac_channel() argument
165 struct iwl_scan_req_umac *cmd = mvm->scan_cmd; in iwl_mvm_get_scan_req_umac_channel()
167 if (iwl_mvm_is_adaptive_dwell_v2_supported(mvm)) in iwl_mvm_get_scan_req_umac_channel()
170 if (iwl_mvm_is_adaptive_dwell_supported(mvm)) in iwl_mvm_get_scan_req_umac_channel()
173 if (iwl_mvm_cdb_scan_api(mvm)) in iwl_mvm_get_scan_req_umac_channel()
179 static u8 iwl_mvm_scan_rx_ant(struct iwl_mvm *mvm) in iwl_mvm_scan_rx_ant() argument
181 if (mvm->scan_rx_ant != ANT_NONE) in iwl_mvm_scan_rx_ant()
182 return mvm->scan_rx_ant; in iwl_mvm_scan_rx_ant()
183 return iwl_mvm_get_valid_rx_ant(mvm); in iwl_mvm_scan_rx_ant()
186 static inline __le16 iwl_mvm_scan_rx_chain(struct iwl_mvm *mvm) in iwl_mvm_scan_rx_chain() argument
191 rx_ant = iwl_mvm_scan_rx_ant(mvm); in iwl_mvm_scan_rx_chain()
208 iwl_mvm_scan_rate_n_flags(struct iwl_mvm *mvm, enum nl80211_band band, in iwl_mvm_scan_rate_n_flags() argument
213 iwl_mvm_toggle_tx_ant(mvm, &mvm->scan_last_antenna_idx); in iwl_mvm_scan_rate_n_flags()
214 tx_ant = BIT(mvm->scan_last_antenna_idx) << RATE_MCS_ANT_POS; in iwl_mvm_scan_rate_n_flags()
234 static enum iwl_mvm_traffic_load iwl_mvm_get_traffic_load(struct iwl_mvm *mvm) in iwl_mvm_get_traffic_load() argument
236 return mvm->tcm.result.global_load; in iwl_mvm_get_traffic_load()
240 iwl_mvm_get_traffic_load_band(struct iwl_mvm *mvm, enum nl80211_band band) in iwl_mvm_get_traffic_load_band() argument
242 return mvm->tcm.result.band_load[band]; in iwl_mvm_get_traffic_load_band()
269 iwl_mvm_scan_type _iwl_mvm_get_scan_type(struct iwl_mvm *mvm, in _iwl_mvm_get_scan_type() argument
276 ieee80211_iterate_active_interfaces_atomic(mvm->hw, in _iwl_mvm_get_scan_type()
283 if (fw_has_api(&mvm->fw->ucode_capa, in _iwl_mvm_get_scan_type()
299 ieee80211_iterate_active_interfaces_atomic(mvm->hw, in _iwl_mvm_get_scan_type()
315 iwl_mvm_scan_type iwl_mvm_get_scan_type(struct iwl_mvm *mvm, in iwl_mvm_get_scan_type() argument
321 load = iwl_mvm_get_traffic_load(mvm); in iwl_mvm_get_scan_type()
322 low_latency = iwl_mvm_low_latency(mvm); in iwl_mvm_get_scan_type()
324 return _iwl_mvm_get_scan_type(mvm, vif, load, low_latency); in iwl_mvm_get_scan_type()
328 iwl_mvm_scan_type iwl_mvm_get_scan_type_band(struct iwl_mvm *mvm, in iwl_mvm_get_scan_type_band() argument
335 load = iwl_mvm_get_traffic_load_band(mvm, band); in iwl_mvm_get_scan_type_band()
336 low_latency = iwl_mvm_low_latency_band(mvm, band); in iwl_mvm_get_scan_type_band()
338 return _iwl_mvm_get_scan_type(mvm, vif, load, low_latency); in iwl_mvm_get_scan_type_band()
342 iwl_mvm_get_measurement_dwell(struct iwl_mvm *mvm, in iwl_mvm_get_measurement_dwell() argument
351 if (iwl_mvm_is_cdb_supported(mvm)) { in iwl_mvm_get_measurement_dwell()
358 IWL_DEBUG_SCAN(mvm, in iwl_mvm_get_measurement_dwell()
368 static inline bool iwl_mvm_rrm_scan_needed(struct iwl_mvm *mvm) in iwl_mvm_rrm_scan_needed() argument
371 return fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_rrm_scan_needed()
375 static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm) in iwl_mvm_max_scan_ie_fw_cmd_room() argument
385 if (iwl_mvm_rrm_scan_needed(mvm)) in iwl_mvm_max_scan_ie_fw_cmd_room()
391 int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm) in iwl_mvm_max_scan_ie_len() argument
393 int max_ie_len = iwl_mvm_max_scan_ie_fw_cmd_room(mvm); in iwl_mvm_max_scan_ie_len()
408 void iwl_mvm_rx_lmac_scan_iter_complete_notif(struct iwl_mvm *mvm, in iwl_mvm_rx_lmac_scan_iter_complete_notif() argument
414 IWL_DEBUG_SCAN(mvm, in iwl_mvm_rx_lmac_scan_iter_complete_notif()
418 if (mvm->sched_scan_pass_all == SCHED_SCAN_PASS_ALL_FOUND) { in iwl_mvm_rx_lmac_scan_iter_complete_notif()
419 IWL_DEBUG_SCAN(mvm, "Pass all scheduled scan results found\n"); in iwl_mvm_rx_lmac_scan_iter_complete_notif()
420 ieee80211_sched_scan_results(mvm->hw); in iwl_mvm_rx_lmac_scan_iter_complete_notif()
421 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_ENABLED; in iwl_mvm_rx_lmac_scan_iter_complete_notif()
425 void iwl_mvm_rx_scan_match_found(struct iwl_mvm *mvm, in iwl_mvm_rx_scan_match_found() argument
428 IWL_DEBUG_SCAN(mvm, "Scheduled scan results\n"); in iwl_mvm_rx_scan_match_found()
429 ieee80211_sched_scan_results(mvm->hw); in iwl_mvm_rx_scan_match_found()
446 void iwl_mvm_rx_lmac_scan_complete_notif(struct iwl_mvm *mvm, in iwl_mvm_rx_lmac_scan_complete_notif() argument
456 if (WARN_ON_ONCE(fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_rx_lmac_scan_complete_notif()
461 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rx_lmac_scan_complete_notif()
473 if (mvm->scan_status & IWL_MVM_SCAN_STOPPING_SCHED) { in iwl_mvm_rx_lmac_scan_complete_notif()
474 WARN_ON_ONCE(mvm->scan_status & IWL_MVM_SCAN_STOPPING_REGULAR); in iwl_mvm_rx_lmac_scan_complete_notif()
476 IWL_DEBUG_SCAN(mvm, "Scheduled scan %s, EBS status %s\n", in iwl_mvm_rx_lmac_scan_complete_notif()
479 IWL_DEBUG_SCAN(mvm, in iwl_mvm_rx_lmac_scan_complete_notif()
485 mvm->scan_status &= ~IWL_MVM_SCAN_STOPPING_SCHED; in iwl_mvm_rx_lmac_scan_complete_notif()
486 } else if (mvm->scan_status & IWL_MVM_SCAN_STOPPING_REGULAR) { in iwl_mvm_rx_lmac_scan_complete_notif()
487 IWL_DEBUG_SCAN(mvm, "Regular scan %s, EBS status %s\n", in iwl_mvm_rx_lmac_scan_complete_notif()
491 mvm->scan_status &= ~IWL_MVM_SCAN_STOPPING_REGULAR; in iwl_mvm_rx_lmac_scan_complete_notif()
492 } else if (mvm->scan_status & IWL_MVM_SCAN_SCHED) { in iwl_mvm_rx_lmac_scan_complete_notif()
493 WARN_ON_ONCE(mvm->scan_status & IWL_MVM_SCAN_REGULAR); in iwl_mvm_rx_lmac_scan_complete_notif()
495 IWL_DEBUG_SCAN(mvm, "Scheduled scan %s, EBS status %s\n", in iwl_mvm_rx_lmac_scan_complete_notif()
498 IWL_DEBUG_SCAN(mvm, in iwl_mvm_rx_lmac_scan_complete_notif()
504 mvm->scan_status &= ~IWL_MVM_SCAN_SCHED; in iwl_mvm_rx_lmac_scan_complete_notif()
505 ieee80211_sched_scan_stopped(mvm->hw); in iwl_mvm_rx_lmac_scan_complete_notif()
506 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_DISABLED; in iwl_mvm_rx_lmac_scan_complete_notif()
507 } else if (mvm->scan_status & IWL_MVM_SCAN_REGULAR) { in iwl_mvm_rx_lmac_scan_complete_notif()
512 IWL_DEBUG_SCAN(mvm, "Regular scan %s, EBS status %s (FW)\n", in iwl_mvm_rx_lmac_scan_complete_notif()
516 mvm->scan_status &= ~IWL_MVM_SCAN_REGULAR; in iwl_mvm_rx_lmac_scan_complete_notif()
517 ieee80211_scan_completed(mvm->hw, &info); in iwl_mvm_rx_lmac_scan_complete_notif()
518 cancel_delayed_work(&mvm->scan_timeout_dwork); in iwl_mvm_rx_lmac_scan_complete_notif()
519 iwl_mvm_resume_tcm(mvm); in iwl_mvm_rx_lmac_scan_complete_notif()
521 IWL_ERR(mvm, in iwl_mvm_rx_lmac_scan_complete_notif()
525 mvm->last_ebs_successful = in iwl_mvm_rx_lmac_scan_complete_notif()
592 iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm, in iwl_mvm_config_sched_scan_profiles() argument
611 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SHORT_BL) in iwl_mvm_config_sched_scan_profiles()
650 IWL_DEBUG_SCAN(mvm, "Sending scheduled scan profile config\n"); in iwl_mvm_config_sched_scan_profiles()
652 ret = iwl_mvm_send_cmd(mvm, &cmd); in iwl_mvm_config_sched_scan_profiles()
660 static bool iwl_mvm_scan_pass_all(struct iwl_mvm *mvm, in iwl_mvm_scan_pass_all() argument
664 IWL_DEBUG_SCAN(mvm, in iwl_mvm_scan_pass_all()
667 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_DISABLED; in iwl_mvm_scan_pass_all()
671 IWL_DEBUG_SCAN(mvm, "Sending Scheduled scan without filtering\n"); in iwl_mvm_scan_pass_all()
673 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_ENABLED; in iwl_mvm_scan_pass_all()
677 static int iwl_mvm_lmac_scan_abort(struct iwl_mvm *mvm) in iwl_mvm_lmac_scan_abort() argument
685 ret = iwl_mvm_send_cmd_status(mvm, &cmd, &status); in iwl_mvm_lmac_scan_abort()
697 IWL_DEBUG_SCAN(mvm, "SCAN OFFLOAD ABORT ret %d.\n", status); in iwl_mvm_lmac_scan_abort()
704 static void iwl_mvm_scan_fill_tx_cmd(struct iwl_mvm *mvm, in iwl_mvm_scan_fill_tx_cmd() argument
710 tx_cmd[0].rate_n_flags = iwl_mvm_scan_rate_n_flags(mvm, in iwl_mvm_scan_fill_tx_cmd()
713 tx_cmd[0].sta_id = mvm->aux_sta.sta_id; in iwl_mvm_scan_fill_tx_cmd()
717 tx_cmd[1].rate_n_flags = iwl_mvm_scan_rate_n_flags(mvm, in iwl_mvm_scan_fill_tx_cmd()
720 tx_cmd[1].sta_id = mvm->aux_sta.sta_id; in iwl_mvm_scan_fill_tx_cmd()
724 iwl_mvm_lmac_scan_cfg_channels(struct iwl_mvm *mvm, in iwl_mvm_lmac_scan_cfg_channels() argument
743 static u8 *iwl_mvm_copy_and_insert_ds_elem(struct iwl_mvm *mvm, const u8 *ies, in iwl_mvm_copy_and_insert_ds_elem() argument
755 if (!iwl_mvm_rrm_scan_needed(mvm)) { in iwl_mvm_copy_and_insert_ds_elem()
796 iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_build_scan_probe() argument
830 newpos = iwl_mvm_copy_and_insert_ds_elem(mvm, in iwl_mvm_build_scan_probe()
848 if (iwl_mvm_rrm_scan_needed(mvm) && in iwl_mvm_build_scan_probe()
849 !fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_build_scan_probe()
859 static void iwl_mvm_scan_lmac_dwell(struct iwl_mvm *mvm, in iwl_mvm_scan_lmac_dwell() argument
872 static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids, in iwl_mvm_scan_fits() argument
877 (n_channels <= mvm->fw->ucode_capa.n_scan_channels) & in iwl_mvm_scan_fits()
881 iwl_mvm_max_scan_ie_fw_cmd_room(mvm))); in iwl_mvm_scan_fits()
884 static inline bool iwl_mvm_scan_use_ebs(struct iwl_mvm *mvm, in iwl_mvm_scan_use_ebs() argument
887 const struct iwl_ucode_capabilities *capa = &mvm->fw->ucode_capa; in iwl_mvm_scan_use_ebs()
890 if (iwl_mvm_is_cdb_supported(mvm)) in iwl_mvm_scan_use_ebs()
891 low_latency = iwl_mvm_low_latency_band(mvm, NL80211_BAND_5GHZ); in iwl_mvm_scan_use_ebs()
893 low_latency = iwl_mvm_low_latency(mvm); in iwl_mvm_scan_use_ebs()
904 mvm->last_ebs_successful && IWL_MVM_ENABLE_EBS && in iwl_mvm_scan_use_ebs()
906 (!low_latency || iwl_mvm_is_frag_ebs_supported(mvm))); in iwl_mvm_scan_use_ebs()
921 static int iwl_mvm_scan_lmac_flags(struct iwl_mvm *mvm, in iwl_mvm_scan_lmac_flags() argument
936 if (iwl_mvm_rrm_scan_needed(mvm) && in iwl_mvm_scan_lmac_flags()
937 fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_scan_lmac_flags()
947 if (mvm->scan_iter_notif_enabled) in iwl_mvm_scan_lmac_flags()
951 if (mvm->sched_scan_pass_all == SCHED_SCAN_PASS_ALL_ENABLED) in iwl_mvm_scan_lmac_flags()
975 static int iwl_mvm_scan_lmac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_scan_lmac() argument
978 struct iwl_scan_req_lmac *cmd = mvm->scan_cmd; in iwl_mvm_scan_lmac()
981 mvm->fw->ucode_capa.n_scan_channels); in iwl_mvm_scan_lmac()
985 lockdep_assert_held(&mvm->mutex); in iwl_mvm_scan_lmac()
992 iwl_mvm_scan_lmac_dwell(mvm, cmd, params); in iwl_mvm_scan_lmac()
994 cmd->rx_chain_select = iwl_mvm_scan_rx_chain(mvm); in iwl_mvm_scan_lmac()
1000 cmd->scan_flags = cpu_to_le32(iwl_mvm_scan_lmac_flags(mvm, params, in iwl_mvm_scan_lmac()
1006 iwl_mvm_scan_fill_tx_cmd(mvm, cmd->tx_cmd, params->no_cck); in iwl_mvm_scan_lmac()
1031 if (iwl_mvm_scan_use_ebs(mvm, vif)) { in iwl_mvm_scan_lmac()
1046 iwl_mvm_lmac_scan_cfg_channels(mvm, params->channels, in iwl_mvm_scan_lmac()
1074 static __le32 iwl_mvm_scan_config_rates(struct iwl_mvm *mvm) in iwl_mvm_scan_config_rates() argument
1080 band = &mvm->nvm_data->bands[NL80211_BAND_2GHZ]; in iwl_mvm_scan_config_rates()
1083 band = &mvm->nvm_data->bands[NL80211_BAND_5GHZ]; in iwl_mvm_scan_config_rates()
1093 static void iwl_mvm_fill_scan_dwell(struct iwl_mvm *mvm, in iwl_mvm_fill_scan_dwell() argument
1102 static void iwl_mvm_fill_channels(struct iwl_mvm *mvm, u8 *channels, in iwl_mvm_fill_channels() argument
1108 band = &mvm->nvm_data->bands[NL80211_BAND_2GHZ]; in iwl_mvm_fill_channels()
1111 band = &mvm->nvm_data->bands[NL80211_BAND_5GHZ]; in iwl_mvm_fill_channels()
1116 static void iwl_mvm_fill_scan_config_v1(struct iwl_mvm *mvm, void *config, in iwl_mvm_fill_scan_config_v1() argument
1120 enum iwl_mvm_scan_type type = iwl_mvm_get_scan_type(mvm, NULL); in iwl_mvm_fill_scan_config_v1()
1124 cfg->tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); in iwl_mvm_fill_scan_config_v1()
1125 cfg->rx_chains = cpu_to_le32(iwl_mvm_scan_rx_ant(mvm)); in iwl_mvm_fill_scan_config_v1()
1126 cfg->legacy_rates = iwl_mvm_scan_config_rates(mvm); in iwl_mvm_fill_scan_config_v1()
1130 iwl_mvm_fill_scan_dwell(mvm, &cfg->dwell); in iwl_mvm_fill_scan_config_v1()
1132 memcpy(&cfg->mac_addr, &mvm->addresses[0].addr, ETH_ALEN); in iwl_mvm_fill_scan_config_v1()
1134 cfg->bcast_sta_id = mvm->aux_sta.sta_id; in iwl_mvm_fill_scan_config_v1()
1137 iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels); in iwl_mvm_fill_scan_config_v1()
1140 static void iwl_mvm_fill_scan_config_v2(struct iwl_mvm *mvm, void *config, in iwl_mvm_fill_scan_config_v2() argument
1147 cfg->tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); in iwl_mvm_fill_scan_config_v2()
1148 cfg->rx_chains = cpu_to_le32(iwl_mvm_scan_rx_ant(mvm)); in iwl_mvm_fill_scan_config_v2()
1149 cfg->legacy_rates = iwl_mvm_scan_config_rates(mvm); in iwl_mvm_fill_scan_config_v2()
1151 if (iwl_mvm_is_cdb_supported(mvm)) { in iwl_mvm_fill_scan_config_v2()
1154 lb_type = iwl_mvm_get_scan_type_band(mvm, NULL, in iwl_mvm_fill_scan_config_v2()
1156 hb_type = iwl_mvm_get_scan_type_band(mvm, NULL, in iwl_mvm_fill_scan_config_v2()
1170 iwl_mvm_get_scan_type(mvm, NULL); in iwl_mvm_fill_scan_config_v2()
1178 iwl_mvm_fill_scan_dwell(mvm, &cfg->dwell); in iwl_mvm_fill_scan_config_v2()
1180 memcpy(&cfg->mac_addr, &mvm->addresses[0].addr, ETH_ALEN); in iwl_mvm_fill_scan_config_v2()
1182 cfg->bcast_sta_id = mvm->aux_sta.sta_id; in iwl_mvm_fill_scan_config_v2()
1185 iwl_mvm_fill_channels(mvm, cfg->channel_array, max_channels); in iwl_mvm_fill_scan_config_v2()
1188 static int iwl_mvm_legacy_config_scan(struct iwl_mvm *mvm) in iwl_mvm_legacy_config_scan() argument
1198 mvm->nvm_data->bands[NL80211_BAND_2GHZ].n_channels + in iwl_mvm_legacy_config_scan()
1199 mvm->nvm_data->bands[NL80211_BAND_5GHZ].n_channels; in iwl_mvm_legacy_config_scan()
1203 if (WARN_ON(num_channels > mvm->fw->ucode_capa.n_scan_channels)) in iwl_mvm_legacy_config_scan()
1204 num_channels = mvm->fw->ucode_capa.n_scan_channels; in iwl_mvm_legacy_config_scan()
1206 if (iwl_mvm_is_cdb_supported(mvm)) { in iwl_mvm_legacy_config_scan()
1207 type = iwl_mvm_get_scan_type_band(mvm, NULL, in iwl_mvm_legacy_config_scan()
1209 hb_type = iwl_mvm_get_scan_type_band(mvm, NULL, in iwl_mvm_legacy_config_scan()
1211 if (type == mvm->scan_type && hb_type == mvm->hb_scan_type) in iwl_mvm_legacy_config_scan()
1214 type = iwl_mvm_get_scan_type(mvm, NULL); in iwl_mvm_legacy_config_scan()
1215 if (type == mvm->scan_type) in iwl_mvm_legacy_config_scan()
1219 if (iwl_mvm_cdb_scan_api(mvm)) in iwl_mvm_legacy_config_scan()
1252 if (iwl_mvm_cdb_scan_api(mvm)) { in iwl_mvm_legacy_config_scan()
1253 if (iwl_mvm_is_cdb_supported(mvm)) in iwl_mvm_legacy_config_scan()
1257 iwl_mvm_fill_scan_config_v2(mvm, cfg, flags, channel_flags, in iwl_mvm_legacy_config_scan()
1260 iwl_mvm_fill_scan_config_v1(mvm, cfg, flags, channel_flags, in iwl_mvm_legacy_config_scan()
1268 IWL_DEBUG_SCAN(mvm, "Sending UMAC scan config\n"); in iwl_mvm_legacy_config_scan()
1270 ret = iwl_mvm_send_cmd(mvm, &cmd); in iwl_mvm_legacy_config_scan()
1272 mvm->scan_type = type; in iwl_mvm_legacy_config_scan()
1273 mvm->hb_scan_type = hb_type; in iwl_mvm_legacy_config_scan()
1280 int iwl_mvm_config_scan(struct iwl_mvm *mvm) in iwl_mvm_config_scan() argument
1290 if (!iwl_mvm_is_reduced_config_scan_supported(mvm)) in iwl_mvm_config_scan()
1291 return iwl_mvm_legacy_config_scan(mvm); in iwl_mvm_config_scan()
1295 cfg.bcast_sta_id = mvm->aux_sta.sta_id; in iwl_mvm_config_scan()
1296 cfg.tx_chains = cpu_to_le32(iwl_mvm_get_valid_tx_ant(mvm)); in iwl_mvm_config_scan()
1297 cfg.rx_chains = cpu_to_le32(iwl_mvm_scan_rx_ant(mvm)); in iwl_mvm_config_scan()
1299 IWL_DEBUG_SCAN(mvm, "Sending UMAC scan config\n"); in iwl_mvm_config_scan()
1301 return iwl_mvm_send_cmd(mvm, &cmd); in iwl_mvm_config_scan()
1304 static int iwl_mvm_scan_uid_by_status(struct iwl_mvm *mvm, int status) in iwl_mvm_scan_uid_by_status() argument
1308 for (i = 0; i < mvm->max_scans; i++) in iwl_mvm_scan_uid_by_status()
1309 if (mvm->scan_uid_status[i] == status) in iwl_mvm_scan_uid_by_status()
1315 static void iwl_mvm_scan_umac_dwell(struct iwl_mvm *mvm, in iwl_mvm_scan_umac_dwell() argument
1328 if (iwl_mvm_is_adaptive_dwell_supported(mvm)) { in iwl_mvm_scan_umac_dwell()
1334 if (iwl_mvm_is_adwell_hb_ap_num_supported(mvm)) in iwl_mvm_scan_umac_dwell()
1355 if (iwl_mvm_is_cdb_supported(mvm)) { in iwl_mvm_scan_umac_dwell()
1364 if (!iwl_mvm_is_adaptive_dwell_v2_supported(mvm)) { in iwl_mvm_scan_umac_dwell()
1371 if (iwl_mvm_is_cdb_supported(mvm)) { in iwl_mvm_scan_umac_dwell()
1385 if (iwl_mvm_is_cdb_supported(mvm)) { in iwl_mvm_scan_umac_dwell()
1394 if (iwl_mvm_cdb_scan_api(mvm)) { in iwl_mvm_scan_umac_dwell()
1418 iwl_mvm_umac_scan_cfg_channels(struct iwl_mvm *mvm, in iwl_mvm_umac_scan_cfg_channels() argument
1428 if (iwl_mvm_is_scan_ext_chan_supported(mvm)) { in iwl_mvm_umac_scan_cfg_channels()
1441 static u16 iwl_mvm_scan_umac_flags(struct iwl_mvm *mvm, in iwl_mvm_scan_umac_flags() argument
1456 if (iwl_mvm_is_cdb_supported(mvm) && in iwl_mvm_scan_umac_flags()
1460 if (iwl_mvm_rrm_scan_needed(mvm) && in iwl_mvm_scan_umac_flags()
1461 fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_scan_umac_flags()
1477 if (mvm->scan_iter_notif_enabled) in iwl_mvm_scan_umac_flags()
1481 if (mvm->sched_scan_pass_all == SCHED_SCAN_PASS_ALL_ENABLED) in iwl_mvm_scan_umac_flags()
1484 if (iwl_mvm_is_adaptive_dwell_supported(mvm) && IWL_MVM_ADWELL_ENABLE && in iwl_mvm_scan_umac_flags()
1496 !iwl_mvm_is_adaptive_dwell_supported(mvm) && in iwl_mvm_scan_umac_flags()
1497 !iwl_mvm_is_oce_supported(mvm)) in iwl_mvm_scan_umac_flags()
1500 if (iwl_mvm_is_oce_supported(mvm)) { in iwl_mvm_scan_umac_flags()
1511 !WARN_ON_ONCE(!iwl_mvm_is_adaptive_dwell_supported(mvm))) in iwl_mvm_scan_umac_flags()
1520 static int iwl_mvm_scan_umac(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_scan_umac() argument
1524 struct iwl_scan_req_umac *cmd = mvm->scan_cmd; in iwl_mvm_scan_umac()
1526 void *cmd_data = iwl_mvm_get_scan_req_umac_data(mvm); in iwl_mvm_scan_umac()
1528 mvm->fw->ucode_capa.n_scan_channels; in iwl_mvm_scan_umac()
1539 chan_param = iwl_mvm_get_scan_req_umac_channel(mvm); in iwl_mvm_scan_umac()
1541 lockdep_assert_held(&mvm->mutex); in iwl_mvm_scan_umac()
1546 uid = iwl_mvm_scan_uid_by_status(mvm, 0); in iwl_mvm_scan_umac()
1552 iwl_mvm_scan_umac_dwell(mvm, cmd, params); in iwl_mvm_scan_umac()
1554 mvm->scan_uid_status[uid] = type; in iwl_mvm_scan_umac()
1557 gen_flags = iwl_mvm_scan_umac_flags(mvm, params, vif); in iwl_mvm_scan_umac()
1559 if (iwl_mvm_is_adaptive_dwell_v2_supported(mvm)) { in iwl_mvm_scan_umac()
1576 if (iwl_mvm_scan_use_ebs(mvm, vif)) { in iwl_mvm_scan_umac()
1582 if (iwl_mvm_is_frag_ebs_supported(mvm)) { in iwl_mvm_scan_umac()
1585 (!iwl_mvm_is_cdb_supported(mvm) && in iwl_mvm_scan_umac()
1614 if (iwl_mvm_is_scan_ext_chan_supported(mvm)) { in iwl_mvm_scan_umac()
1624 iwl_mvm_umac_scan_cfg_channels(mvm, params->channels, in iwl_mvm_scan_umac()
1630 static int iwl_mvm_num_scans(struct iwl_mvm *mvm) in iwl_mvm_num_scans() argument
1632 return hweight32(mvm->scan_status & IWL_MVM_SCAN_MASK); in iwl_mvm_num_scans()
1635 static int iwl_mvm_check_running_scans(struct iwl_mvm *mvm, int type) in iwl_mvm_check_running_scans() argument
1637 bool unified_image = fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_check_running_scans()
1652 mvm->scan_status & (IWL_MVM_SCAN_SCHED | IWL_MVM_SCAN_NETDETECT)) in iwl_mvm_check_running_scans()
1655 if (iwl_mvm_num_scans(mvm) < mvm->max_scans) in iwl_mvm_check_running_scans()
1663 if (mvm->scan_status & IWL_MVM_SCAN_REGULAR_MASK) in iwl_mvm_check_running_scans()
1665 return iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, true); in iwl_mvm_check_running_scans()
1667 if (mvm->scan_status & IWL_MVM_SCAN_SCHED_MASK) in iwl_mvm_check_running_scans()
1669 return iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, true); in iwl_mvm_check_running_scans()
1685 if (mvm->scan_status & IWL_MVM_SCAN_REGULAR_MASK) in iwl_mvm_check_running_scans()
1686 return iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, in iwl_mvm_check_running_scans()
1688 if (mvm->scan_status & IWL_MVM_SCAN_SCHED_MASK) in iwl_mvm_check_running_scans()
1689 return iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, in iwl_mvm_check_running_scans()
1708 struct iwl_mvm *mvm = container_of(delayed_work, struct iwl_mvm, in iwl_mvm_scan_timeout_wk() local
1711 IWL_ERR(mvm, "regular scan timed out\n"); in iwl_mvm_scan_timeout_wk()
1713 iwl_force_nmi(mvm->trans); in iwl_mvm_scan_timeout_wk()
1716 static void iwl_mvm_fill_scan_type(struct iwl_mvm *mvm, in iwl_mvm_fill_scan_type() argument
1720 if (iwl_mvm_is_cdb_supported(mvm)) { in iwl_mvm_fill_scan_type()
1722 iwl_mvm_get_scan_type_band(mvm, vif, in iwl_mvm_fill_scan_type()
1725 iwl_mvm_get_scan_type_band(mvm, vif, in iwl_mvm_fill_scan_type()
1728 params->type = iwl_mvm_get_scan_type(mvm, vif); in iwl_mvm_fill_scan_type()
1732 int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_reg_scan_start() argument
1737 .len = { iwl_mvm_scan_size(mvm), }, in iwl_mvm_reg_scan_start()
1738 .data = { mvm->scan_cmd, }, in iwl_mvm_reg_scan_start()
1745 lockdep_assert_held(&mvm->mutex); in iwl_mvm_reg_scan_start()
1747 if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) { in iwl_mvm_reg_scan_start()
1748 IWL_ERR(mvm, "scan while LAR regdomain is not set\n"); in iwl_mvm_reg_scan_start()
1752 ret = iwl_mvm_check_running_scans(mvm, IWL_MVM_SCAN_REGULAR); in iwl_mvm_reg_scan_start()
1757 if (WARN_ON(!mvm->scan_cmd)) in iwl_mvm_reg_scan_start()
1760 if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels)) in iwl_mvm_reg_scan_start()
1779 iwl_mvm_fill_scan_type(mvm, ¶ms, vif); in iwl_mvm_reg_scan_start()
1781 ret = iwl_mvm_get_measurement_dwell(mvm, req, ¶ms); in iwl_mvm_reg_scan_start()
1787 iwl_mvm_build_scan_probe(mvm, vif, ies, ¶ms); in iwl_mvm_reg_scan_start()
1789 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { in iwl_mvm_reg_scan_start()
1791 ret = iwl_mvm_scan_umac(mvm, vif, ¶ms, in iwl_mvm_reg_scan_start()
1795 ret = iwl_mvm_scan_lmac(mvm, vif, ¶ms); in iwl_mvm_reg_scan_start()
1801 iwl_mvm_pause_tcm(mvm, false); in iwl_mvm_reg_scan_start()
1803 ret = iwl_mvm_send_cmd(mvm, &hcmd); in iwl_mvm_reg_scan_start()
1809 IWL_ERR(mvm, "Scan failed! ret %d\n", ret); in iwl_mvm_reg_scan_start()
1810 iwl_mvm_resume_tcm(mvm); in iwl_mvm_reg_scan_start()
1814 IWL_DEBUG_SCAN(mvm, "Scan request was sent successfully\n"); in iwl_mvm_reg_scan_start()
1815 mvm->scan_status |= IWL_MVM_SCAN_REGULAR; in iwl_mvm_reg_scan_start()
1816 mvm->scan_vif = iwl_mvm_vif_from_mac80211(vif); in iwl_mvm_reg_scan_start()
1818 schedule_delayed_work(&mvm->scan_timeout_dwork, in iwl_mvm_reg_scan_start()
1824 int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm, in iwl_mvm_sched_scan_start() argument
1831 .len = { iwl_mvm_scan_size(mvm), }, in iwl_mvm_sched_scan_start()
1832 .data = { mvm->scan_cmd, }, in iwl_mvm_sched_scan_start()
1838 lockdep_assert_held(&mvm->mutex); in iwl_mvm_sched_scan_start()
1840 if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) { in iwl_mvm_sched_scan_start()
1841 IWL_ERR(mvm, "sched-scan while LAR regdomain is not set\n"); in iwl_mvm_sched_scan_start()
1845 ret = iwl_mvm_check_running_scans(mvm, type); in iwl_mvm_sched_scan_start()
1850 if (WARN_ON(!mvm->scan_cmd)) in iwl_mvm_sched_scan_start()
1853 if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels)) in iwl_mvm_sched_scan_start()
1864 params.pass_all = iwl_mvm_scan_pass_all(mvm, req); in iwl_mvm_sched_scan_start()
1873 iwl_mvm_fill_scan_type(mvm, ¶ms, vif); in iwl_mvm_sched_scan_start()
1881 IWL_DEBUG_SCAN(mvm, in iwl_mvm_sched_scan_start()
1888 ret = iwl_mvm_config_sched_scan_profiles(mvm, req); in iwl_mvm_sched_scan_start()
1892 iwl_mvm_build_scan_probe(mvm, vif, ies, ¶ms); in iwl_mvm_sched_scan_start()
1894 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { in iwl_mvm_sched_scan_start()
1896 ret = iwl_mvm_scan_umac(mvm, vif, ¶ms, type); in iwl_mvm_sched_scan_start()
1899 ret = iwl_mvm_scan_lmac(mvm, vif, ¶ms); in iwl_mvm_sched_scan_start()
1905 ret = iwl_mvm_send_cmd(mvm, &hcmd); in iwl_mvm_sched_scan_start()
1907 IWL_DEBUG_SCAN(mvm, in iwl_mvm_sched_scan_start()
1909 mvm->scan_status |= type; in iwl_mvm_sched_scan_start()
1915 IWL_ERR(mvm, "Sched scan failed! ret %d\n", ret); in iwl_mvm_sched_scan_start()
1921 void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm, in iwl_mvm_rx_umac_scan_complete_notif() argument
1929 if (WARN_ON(!(mvm->scan_uid_status[uid] & mvm->scan_status))) in iwl_mvm_rx_umac_scan_complete_notif()
1933 if (mvm->scan_uid_status[uid] == IWL_MVM_SCAN_REGULAR) { in iwl_mvm_rx_umac_scan_complete_notif()
1936 .scan_start_tsf = mvm->scan_start, in iwl_mvm_rx_umac_scan_complete_notif()
1939 memcpy(info.tsf_bssid, mvm->scan_vif->bssid, ETH_ALEN); in iwl_mvm_rx_umac_scan_complete_notif()
1940 ieee80211_scan_completed(mvm->hw, &info); in iwl_mvm_rx_umac_scan_complete_notif()
1941 mvm->scan_vif = NULL; in iwl_mvm_rx_umac_scan_complete_notif()
1942 cancel_delayed_work(&mvm->scan_timeout_dwork); in iwl_mvm_rx_umac_scan_complete_notif()
1943 iwl_mvm_resume_tcm(mvm); in iwl_mvm_rx_umac_scan_complete_notif()
1944 } else if (mvm->scan_uid_status[uid] == IWL_MVM_SCAN_SCHED) { in iwl_mvm_rx_umac_scan_complete_notif()
1945 ieee80211_sched_scan_stopped(mvm->hw); in iwl_mvm_rx_umac_scan_complete_notif()
1946 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_DISABLED; in iwl_mvm_rx_umac_scan_complete_notif()
1949 mvm->scan_status &= ~mvm->scan_uid_status[uid]; in iwl_mvm_rx_umac_scan_complete_notif()
1950 IWL_DEBUG_SCAN(mvm, in iwl_mvm_rx_umac_scan_complete_notif()
1952 uid, mvm->scan_uid_status[uid], in iwl_mvm_rx_umac_scan_complete_notif()
1956 IWL_DEBUG_SCAN(mvm, in iwl_mvm_rx_umac_scan_complete_notif()
1963 mvm->last_ebs_successful = false; in iwl_mvm_rx_umac_scan_complete_notif()
1965 mvm->scan_uid_status[uid] = 0; in iwl_mvm_rx_umac_scan_complete_notif()
1968 void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm, in iwl_mvm_rx_umac_scan_iter_complete_notif() argument
1974 mvm->scan_start = le64_to_cpu(notif->start_tsf); in iwl_mvm_rx_umac_scan_iter_complete_notif()
1976 IWL_DEBUG_SCAN(mvm, in iwl_mvm_rx_umac_scan_iter_complete_notif()
1980 if (mvm->sched_scan_pass_all == SCHED_SCAN_PASS_ALL_FOUND) { in iwl_mvm_rx_umac_scan_iter_complete_notif()
1981 IWL_DEBUG_SCAN(mvm, "Pass all scheduled scan results found\n"); in iwl_mvm_rx_umac_scan_iter_complete_notif()
1982 ieee80211_sched_scan_results(mvm->hw); in iwl_mvm_rx_umac_scan_iter_complete_notif()
1983 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_ENABLED; in iwl_mvm_rx_umac_scan_iter_complete_notif()
1986 IWL_DEBUG_SCAN(mvm, in iwl_mvm_rx_umac_scan_iter_complete_notif()
1988 mvm->scan_start); in iwl_mvm_rx_umac_scan_iter_complete_notif()
1991 static int iwl_mvm_umac_scan_abort(struct iwl_mvm *mvm, int type) in iwl_mvm_umac_scan_abort() argument
1996 lockdep_assert_held(&mvm->mutex); in iwl_mvm_umac_scan_abort()
2002 uid = iwl_mvm_scan_uid_by_status(mvm, type); in iwl_mvm_umac_scan_abort()
2008 IWL_DEBUG_SCAN(mvm, "Sending scan abort, uid %u\n", uid); in iwl_mvm_umac_scan_abort()
2010 ret = iwl_mvm_send_cmd_pdu(mvm, in iwl_mvm_umac_scan_abort()
2015 mvm->scan_uid_status[uid] = type << IWL_MVM_SCAN_STOPPING_SHIFT; in iwl_mvm_umac_scan_abort()
2020 static int iwl_mvm_scan_stop_wait(struct iwl_mvm *mvm, int type) in iwl_mvm_scan_stop_wait() argument
2027 lockdep_assert_held(&mvm->mutex); in iwl_mvm_scan_stop_wait()
2029 iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_done, in iwl_mvm_scan_stop_wait()
2034 IWL_DEBUG_SCAN(mvm, "Preparing to stop scan, type %x\n", type); in iwl_mvm_scan_stop_wait()
2036 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) in iwl_mvm_scan_stop_wait()
2037 ret = iwl_mvm_umac_scan_abort(mvm, type); in iwl_mvm_scan_stop_wait()
2039 ret = iwl_mvm_lmac_scan_abort(mvm); in iwl_mvm_scan_stop_wait()
2042 IWL_DEBUG_SCAN(mvm, "couldn't stop scan type %d\n", type); in iwl_mvm_scan_stop_wait()
2043 iwl_remove_notification(&mvm->notif_wait, &wait_scan_done); in iwl_mvm_scan_stop_wait()
2047 return iwl_wait_notification(&mvm->notif_wait, &wait_scan_done, in iwl_mvm_scan_stop_wait()
2051 int iwl_mvm_scan_size(struct iwl_mvm *mvm) in iwl_mvm_scan_size() argument
2056 if (iwl_mvm_is_adaptive_dwell_v2_supported(mvm)) in iwl_mvm_scan_size()
2058 else if (iwl_mvm_is_adaptive_dwell_supported(mvm)) in iwl_mvm_scan_size()
2060 else if (iwl_mvm_cdb_scan_api(mvm)) in iwl_mvm_scan_size()
2063 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { in iwl_mvm_scan_size()
2064 if (iwl_mvm_is_scan_ext_chan_supported(mvm)) in iwl_mvm_scan_size()
2071 mvm->fw->ucode_capa.n_scan_channels + in iwl_mvm_scan_size()
2076 mvm->fw->ucode_capa.n_scan_channels + in iwl_mvm_scan_size()
2084 void iwl_mvm_report_scan_aborted(struct iwl_mvm *mvm) in iwl_mvm_report_scan_aborted() argument
2086 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) { in iwl_mvm_report_scan_aborted()
2089 uid = iwl_mvm_scan_uid_by_status(mvm, IWL_MVM_SCAN_REGULAR); in iwl_mvm_report_scan_aborted()
2095 ieee80211_scan_completed(mvm->hw, &info); in iwl_mvm_report_scan_aborted()
2096 mvm->scan_uid_status[uid] = 0; in iwl_mvm_report_scan_aborted()
2098 uid = iwl_mvm_scan_uid_by_status(mvm, IWL_MVM_SCAN_SCHED); in iwl_mvm_report_scan_aborted()
2099 if (uid >= 0 && !mvm->fw_restart) { in iwl_mvm_report_scan_aborted()
2100 ieee80211_sched_scan_stopped(mvm->hw); in iwl_mvm_report_scan_aborted()
2101 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_DISABLED; in iwl_mvm_report_scan_aborted()
2102 mvm->scan_uid_status[uid] = 0; in iwl_mvm_report_scan_aborted()
2109 for (i = 0; i < mvm->max_scans; i++) { in iwl_mvm_report_scan_aborted()
2110 if (WARN_ONCE(mvm->scan_uid_status[i], in iwl_mvm_report_scan_aborted()
2113 mvm->scan_uid_status[i] = 0; in iwl_mvm_report_scan_aborted()
2116 if (mvm->scan_status & IWL_MVM_SCAN_REGULAR) { in iwl_mvm_report_scan_aborted()
2121 ieee80211_scan_completed(mvm->hw, &info); in iwl_mvm_report_scan_aborted()
2128 if ((mvm->scan_status & IWL_MVM_SCAN_SCHED) && in iwl_mvm_report_scan_aborted()
2129 !mvm->fw_restart) { in iwl_mvm_report_scan_aborted()
2130 ieee80211_sched_scan_stopped(mvm->hw); in iwl_mvm_report_scan_aborted()
2131 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_DISABLED; in iwl_mvm_report_scan_aborted()
2136 int iwl_mvm_scan_stop(struct iwl_mvm *mvm, int type, bool notify) in iwl_mvm_scan_stop() argument
2140 if (!(mvm->scan_status & type)) in iwl_mvm_scan_stop()
2143 if (iwl_mvm_is_radio_killed(mvm)) { in iwl_mvm_scan_stop()
2148 ret = iwl_mvm_scan_stop_wait(mvm, type); in iwl_mvm_scan_stop()
2150 mvm->scan_status |= type << IWL_MVM_SCAN_STOPPING_SHIFT; in iwl_mvm_scan_stop()
2157 mvm->scan_status &= ~type; in iwl_mvm_scan_stop()
2160 cancel_delayed_work(&mvm->scan_timeout_dwork); in iwl_mvm_scan_stop()
2166 ieee80211_scan_completed(mvm->hw, &info); in iwl_mvm_scan_stop()
2169 ieee80211_sched_scan_stopped(mvm->hw); in iwl_mvm_scan_stop()
2170 mvm->sched_scan_pass_all = SCHED_SCAN_PASS_ALL_DISABLED; in iwl_mvm_scan_stop()