Lines Matching refs:mvm
38 int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_add_pasn_sta() argument
46 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_add_pasn_sta()
76 sta = rcu_dereference(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id]); in iwl_mvm_ftm_add_pasn_sta()
83 IWL_ERR(mvm, "Invalid key length: tk_len=%u hltk_len=%u\n", in iwl_mvm_ftm_add_pasn_sta()
94 list_add_tail(&pasn->list, &mvm->ftm_initiator.pasn_list); in iwl_mvm_ftm_add_pasn_sta()
101 void iwl_mvm_ftm_remove_pasn_sta(struct iwl_mvm *mvm, u8 *addr) in iwl_mvm_ftm_remove_pasn_sta() argument
105 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_remove_pasn_sta()
107 list_for_each_entry_safe(entry, prev, &mvm->ftm_initiator.pasn_list, in iwl_mvm_ftm_remove_pasn_sta()
118 static void iwl_mvm_ftm_reset(struct iwl_mvm *mvm) in iwl_mvm_ftm_reset() argument
122 mvm->ftm_initiator.req = NULL; in iwl_mvm_ftm_reset()
123 mvm->ftm_initiator.req_wdev = NULL; in iwl_mvm_ftm_reset()
124 memset(mvm->ftm_initiator.responses, 0, in iwl_mvm_ftm_reset()
125 sizeof(mvm->ftm_initiator.responses)); in iwl_mvm_ftm_reset()
127 list_for_each_entry_safe(e, t, &mvm->ftm_initiator.loc_list, list) { in iwl_mvm_ftm_reset()
133 void iwl_mvm_ftm_restart(struct iwl_mvm *mvm) in iwl_mvm_ftm_restart() argument
143 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_restart()
145 if (!mvm->ftm_initiator.req) in iwl_mvm_ftm_restart()
148 for (i = 0; i < mvm->ftm_initiator.req->n_peers; i++) { in iwl_mvm_ftm_restart()
149 memcpy(result.addr, mvm->ftm_initiator.req->peers[i].addr, in iwl_mvm_ftm_restart()
151 result.ftm.burst_index = mvm->ftm_initiator.responses[i]; in iwl_mvm_ftm_restart()
153 cfg80211_pmsr_report(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_restart()
154 mvm->ftm_initiator.req, in iwl_mvm_ftm_restart()
158 cfg80211_pmsr_complete(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_restart()
159 mvm->ftm_initiator.req, GFP_KERNEL); in iwl_mvm_ftm_restart()
160 iwl_mvm_ftm_reset(mvm); in iwl_mvm_ftm_restart()
163 void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm *mvm) in iwl_mvm_ftm_initiator_smooth_config() argument
165 INIT_LIST_HEAD(&mvm->ftm_initiator.smooth.resp); in iwl_mvm_ftm_initiator_smooth_config()
167 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_initiator_smooth_config()
176 void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm *mvm) in iwl_mvm_ftm_initiator_smooth_stop() argument
180 list_for_each_entry_safe(se, st, &mvm->ftm_initiator.smooth.resp, in iwl_mvm_ftm_initiator_smooth_stop()
201 static void iwl_mvm_ftm_cmd_v5(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_cmd_v5() argument
231 static void iwl_mvm_ftm_cmd_common(struct iwl_mvm *mvm, in iwl_mvm_ftm_cmd_common() argument
278 static void iwl_mvm_ftm_cmd_v8(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_cmd_v8() argument
282 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)cmd, req); in iwl_mvm_ftm_cmd_v8()
286 iwl_mvm_ftm_target_chandef_v1(struct iwl_mvm *mvm, in iwl_mvm_ftm_target_chandef_v1() argument
309 IWL_ERR(mvm, "Unsupported BW in FTM request (%d)\n", in iwl_mvm_ftm_target_chandef_v1()
321 iwl_mvm_ftm_target_chandef_v2(struct iwl_mvm *mvm, in iwl_mvm_ftm_target_chandef_v2() argument
349 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_ftm_target_chandef_v2()
360 IWL_ERR(mvm, "Unsupported BW in FTM request (%d)\n", in iwl_mvm_ftm_target_chandef_v2()
376 iwl_mvm_ftm_put_target_v2(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_v2() argument
382 ret = iwl_mvm_ftm_target_chandef_v1(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target_v2()
412 iwl_mvm_ftm_put_target_common(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_common() argument
452 iwl_mvm_ftm_put_target_v3(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_v3() argument
458 ret = iwl_mvm_ftm_target_chandef_v1(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target_v3()
468 iwl_mvm_ftm_put_target_common(mvm, peer, (void *)target); in iwl_mvm_ftm_put_target_v3()
474 iwl_mvm_ftm_put_target_v4(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_v4() argument
480 ret = iwl_mvm_ftm_target_chandef_v2(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target_v4()
486 iwl_mvm_ftm_put_target_common(mvm, peer, (void *)target); in iwl_mvm_ftm_put_target_v4()
492 iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_put_target() argument
498 ret = iwl_mvm_ftm_target_chandef_v2(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target()
504 iwl_mvm_ftm_put_target_common(mvm, peer, target); in iwl_mvm_ftm_put_target()
513 sta = rcu_dereference(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id]); in iwl_mvm_ftm_put_target()
532 static int iwl_mvm_ftm_send_cmd(struct iwl_mvm *mvm, struct iwl_host_cmd *hcmd) in iwl_mvm_ftm_send_cmd() argument
535 int err = iwl_mvm_send_cmd_status(mvm, hcmd, &status); in iwl_mvm_ftm_send_cmd()
538 IWL_ERR(mvm, "FTM range request command failure, status: %u\n", in iwl_mvm_ftm_send_cmd()
546 static int iwl_mvm_ftm_start_v5(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v5() argument
559 iwl_mvm_ftm_cmd_v5(mvm, vif, &cmd_v5, req); in iwl_mvm_ftm_start_v5()
564 err = iwl_mvm_ftm_put_target_v2(mvm, peer, &cmd_v5.ap[i]); in iwl_mvm_ftm_start_v5()
569 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v5()
572 static int iwl_mvm_ftm_start_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v7() argument
589 iwl_mvm_ftm_cmd_v8(mvm, vif, (void *)&cmd_v7, req); in iwl_mvm_ftm_start_v7()
594 err = iwl_mvm_ftm_put_target_v3(mvm, peer, &cmd_v7.ap[i]); in iwl_mvm_ftm_start_v7()
599 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v7()
602 static int iwl_mvm_ftm_start_v8(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v8() argument
615 iwl_mvm_ftm_cmd_v8(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v8()
620 err = iwl_mvm_ftm_put_target_v4(mvm, peer, &cmd.ap[i]); in iwl_mvm_ftm_start_v8()
625 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v8()
628 static int iwl_mvm_ftm_start_v9(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v9() argument
641 iwl_mvm_ftm_cmd_common(mvm, vif, &cmd, req); in iwl_mvm_ftm_start_v9()
647 err = iwl_mvm_ftm_put_target(mvm, vif, peer, target); in iwl_mvm_ftm_start_v9()
652 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v9()
677 iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_set_secured_ranging() argument
687 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_set_secured_ranging()
689 list_for_each_entry(entry, &mvm->ftm_initiator.pasn_list, list) { in iwl_mvm_ftm_set_secured_ranging()
699 ieee80211_iter_keys(mvm->hw, vif, iter, target); in iwl_mvm_ftm_set_secured_ranging()
713 iwl_mvm_ftm_put_target_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_put_target_v7() argument
717 int err = iwl_mvm_ftm_put_target(mvm, vif, peer, (void *)target); in iwl_mvm_ftm_put_target_v7()
721 iwl_mvm_ftm_set_secured_ranging(mvm, vif, target); in iwl_mvm_ftm_put_target_v7()
725 static int iwl_mvm_ftm_start_v11(struct iwl_mvm *mvm, in iwl_mvm_ftm_start_v11() argument
739 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v11()
745 err = iwl_mvm_ftm_put_target_v7(mvm, vif, peer, target); in iwl_mvm_ftm_start_v11()
750 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v11()
754 iwl_mvm_ftm_set_ndp_params(struct iwl_mvm *mvm, in iwl_mvm_ftm_set_ndp_params() argument
770 iwl_mvm_ftm_put_target_v8(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_put_target_v8() argument
775 int ret = iwl_mvm_ftm_put_target_v7(mvm, vif, peer, (void *)target); in iwl_mvm_ftm_put_target_v8()
780 iwl_mvm_ftm_set_ndp_params(mvm, target); in iwl_mvm_ftm_put_target_v8()
796 static int iwl_mvm_ftm_start_v12(struct iwl_mvm *mvm, in iwl_mvm_ftm_start_v12() argument
810 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v12()
816 err = iwl_mvm_ftm_put_target_v8(mvm, vif, peer, target); in iwl_mvm_ftm_start_v12()
821 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v12()
824 static int iwl_mvm_ftm_start_v13(struct iwl_mvm *mvm, in iwl_mvm_ftm_start_v13() argument
838 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v13()
844 err = iwl_mvm_ftm_put_target_v8(mvm, vif, peer, (void *)target); in iwl_mvm_ftm_start_v13()
864 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v13()
867 int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start() argument
870 bool new_api = fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_start()
874 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_start()
876 if (mvm->ftm_initiator.req) in iwl_mvm_ftm_start()
880 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_ftm_start()
886 err = iwl_mvm_ftm_start_v13(mvm, vif, req); in iwl_mvm_ftm_start()
889 err = iwl_mvm_ftm_start_v12(mvm, vif, req); in iwl_mvm_ftm_start()
892 err = iwl_mvm_ftm_start_v11(mvm, vif, req); in iwl_mvm_ftm_start()
896 err = iwl_mvm_ftm_start_v9(mvm, vif, req); in iwl_mvm_ftm_start()
899 err = iwl_mvm_ftm_start_v8(mvm, vif, req); in iwl_mvm_ftm_start()
902 err = iwl_mvm_ftm_start_v7(mvm, vif, req); in iwl_mvm_ftm_start()
906 err = iwl_mvm_ftm_start_v5(mvm, vif, req); in iwl_mvm_ftm_start()
910 mvm->ftm_initiator.req = req; in iwl_mvm_ftm_start()
911 mvm->ftm_initiator.req_wdev = ieee80211_vif_to_wdev(vif); in iwl_mvm_ftm_start()
917 void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req) in iwl_mvm_ftm_abort() argument
923 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_abort()
925 if (req != mvm->ftm_initiator.req) in iwl_mvm_ftm_abort()
928 iwl_mvm_ftm_reset(mvm); in iwl_mvm_ftm_abort()
930 if (iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(LOCATION_GROUP, TOF_RANGE_ABORT_CMD), in iwl_mvm_ftm_abort()
932 IWL_ERR(mvm, "failed to abort FTM process\n"); in iwl_mvm_ftm_abort()
950 static u64 iwl_mvm_ftm_get_host_time(struct iwl_mvm *mvm, __le32 fw_gp2_ts) in iwl_mvm_ftm_get_host_time() argument
956 iwl_mvm_get_sync_time(mvm, CLOCK_BOOTTIME, &curr_gp2, in iwl_mvm_ftm_get_host_time()
967 static void iwl_mvm_ftm_get_lci_civic(struct iwl_mvm *mvm, in iwl_mvm_ftm_get_lci_civic() argument
972 list_for_each_entry(entry, &mvm->ftm_initiator.loc_list, list) { in iwl_mvm_ftm_get_lci_civic()
991 static int iwl_mvm_ftm_range_resp_valid(struct iwl_mvm *mvm, u8 request_id, in iwl_mvm_ftm_range_resp_valid() argument
994 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_range_resp_valid()
996 if (request_id != (u8)mvm->ftm_initiator.req->cookie) { in iwl_mvm_ftm_range_resp_valid()
997 IWL_ERR(mvm, "Request ID mismatch, got %u, active %u\n", in iwl_mvm_ftm_range_resp_valid()
998 request_id, (u8)mvm->ftm_initiator.req->cookie); in iwl_mvm_ftm_range_resp_valid()
1002 if (num_of_aps > mvm->ftm_initiator.req->n_peers) { in iwl_mvm_ftm_range_resp_valid()
1003 IWL_ERR(mvm, "FTM range response invalid\n"); in iwl_mvm_ftm_range_resp_valid()
1010 static void iwl_mvm_ftm_rtt_smoothing(struct iwl_mvm *mvm, in iwl_mvm_ftm_rtt_smoothing() argument
1025 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1032 list_for_each_entry(resp, &mvm->ftm_initiator.smooth.resp, list) { in iwl_mvm_ftm_rtt_smoothing()
1045 list_add_tail(&resp->list, &mvm->ftm_initiator.smooth.resp); in iwl_mvm_ftm_rtt_smoothing()
1049 IWL_DEBUG_INFO(mvm, "new: %pM: rtt_avg=%lld\n", in iwl_mvm_ftm_rtt_smoothing()
1058 IWL_DEBUG_INFO(mvm, "expired: %pM: rtt_avg=%lld\n", in iwl_mvm_ftm_rtt_smoothing()
1070 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1084 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1090 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1099 static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index, in iwl_mvm_debug_range_resp() argument
1104 IWL_DEBUG_INFO(mvm, "entry %d\n", index); in iwl_mvm_debug_range_resp()
1105 IWL_DEBUG_INFO(mvm, "\tstatus: %d\n", res->status); in iwl_mvm_debug_range_resp()
1106 IWL_DEBUG_INFO(mvm, "\tBSSID: %pM\n", res->addr); in iwl_mvm_debug_range_resp()
1107 IWL_DEBUG_INFO(mvm, "\thost time: %llu\n", res->host_time); in iwl_mvm_debug_range_resp()
1108 IWL_DEBUG_INFO(mvm, "\tburst index: %d\n", res->ftm.burst_index); in iwl_mvm_debug_range_resp()
1109 IWL_DEBUG_INFO(mvm, "\tsuccess num: %u\n", res->ftm.num_ftmr_successes); in iwl_mvm_debug_range_resp()
1110 IWL_DEBUG_INFO(mvm, "\trssi: %d\n", res->ftm.rssi_avg); in iwl_mvm_debug_range_resp()
1111 IWL_DEBUG_INFO(mvm, "\trssi spread: %d\n", res->ftm.rssi_spread); in iwl_mvm_debug_range_resp()
1112 IWL_DEBUG_INFO(mvm, "\trtt: %lld\n", res->ftm.rtt_avg); in iwl_mvm_debug_range_resp()
1113 IWL_DEBUG_INFO(mvm, "\trtt var: %llu\n", res->ftm.rtt_variance); in iwl_mvm_debug_range_resp()
1114 IWL_DEBUG_INFO(mvm, "\trtt spread: %llu\n", res->ftm.rtt_spread); in iwl_mvm_debug_range_resp()
1115 IWL_DEBUG_INFO(mvm, "\tdistance: %lld\n", rtt_avg); in iwl_mvm_debug_range_resp()
1119 iwl_mvm_ftm_pasn_update_pn(struct iwl_mvm *mvm, in iwl_mvm_ftm_pasn_update_pn() argument
1124 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_pasn_update_pn()
1126 list_for_each_entry(entry, &mvm->ftm_initiator.pasn_list, list) { in iwl_mvm_ftm_pasn_update_pn()
1136 static u8 iwl_mvm_ftm_get_range_resp_ver(struct iwl_mvm *mvm) in iwl_mvm_ftm_get_range_resp_ver() argument
1138 if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_get_range_resp_ver()
1143 if (mvm->cmd_ver.range_resp >= 8) in iwl_mvm_ftm_get_range_resp_ver()
1144 return mvm->cmd_ver.range_resp; in iwl_mvm_ftm_get_range_resp_ver()
1145 else if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_get_range_resp_ver()
1171 void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_ftm_range_resp() argument
1180 bool new_api = fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_range_resp()
1183 u8 notif_ver = iwl_mvm_ftm_get_range_resp_ver(mvm); in iwl_mvm_ftm_range_resp()
1185 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_range_resp()
1187 if (!mvm->ftm_initiator.req) { in iwl_mvm_ftm_range_resp()
1195 if (iwl_mvm_ftm_range_resp_valid(mvm, fw_resp_v8->request_id, in iwl_mvm_ftm_range_resp()
1202 if (iwl_mvm_ftm_range_resp_valid(mvm, fw_resp_v5->request_id, in iwl_mvm_ftm_range_resp()
1210 IWL_DEBUG_INFO(mvm, "Range response received\n"); in iwl_mvm_ftm_range_resp()
1211 IWL_DEBUG_INFO(mvm, "request id: %lld, num of entries: %hhu\n", in iwl_mvm_ftm_range_resp()
1212 mvm->ftm_initiator.req->cookie, num_of_aps); in iwl_mvm_ftm_range_resp()
1222 iwl_mvm_ftm_pasn_update_pn(mvm, fw_ap); in iwl_mvm_ftm_range_resp()
1243 peer_idx = iwl_mvm_ftm_find_peer(mvm->ftm_initiator.req, in iwl_mvm_ftm_range_resp()
1246 IWL_WARN(mvm, in iwl_mvm_ftm_range_resp()
1277 result.host_time = iwl_mvm_ftm_get_host_time(mvm, in iwl_mvm_ftm_range_resp()
1280 result.ftm.burst_index = mvm->ftm_initiator.responses[peer_idx]; in iwl_mvm_ftm_range_resp()
1281 mvm->ftm_initiator.responses[peer_idx]++; in iwl_mvm_ftm_range_resp()
1293 iwl_mvm_ftm_get_lci_civic(mvm, &result); in iwl_mvm_ftm_range_resp()
1295 iwl_mvm_ftm_rtt_smoothing(mvm, &result); in iwl_mvm_ftm_range_resp()
1297 cfg80211_pmsr_report(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_range_resp()
1298 mvm->ftm_initiator.req, in iwl_mvm_ftm_range_resp()
1301 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_range_resp()
1303 IWL_DEBUG_INFO(mvm, "RTT confidence: %hhu\n", in iwl_mvm_ftm_range_resp()
1306 iwl_mvm_debug_range_resp(mvm, i, &result); in iwl_mvm_ftm_range_resp()
1310 cfg80211_pmsr_complete(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_range_resp()
1311 mvm->ftm_initiator.req, in iwl_mvm_ftm_range_resp()
1313 iwl_mvm_ftm_reset(mvm); in iwl_mvm_ftm_range_resp()
1317 void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_ftm_lc_notif() argument
1333 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_lc_notif()
1366 list_add_tail(&entry->list, &mvm->ftm_initiator.loc_list); in iwl_mvm_ftm_lc_notif()