Lines Matching refs:mvm

43 int iwl_mvm_ftm_add_pasn_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,  in iwl_mvm_ftm_add_pasn_sta()  argument
51 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_add_pasn_sta()
88 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); in iwl_mvm_ftm_add_pasn_sta()
98 IWL_ERR(mvm, "Invalid key length: tk_len=%u hltk_len=%u\n", in iwl_mvm_ftm_add_pasn_sta()
104 IWL_ERR(mvm, "TK and HLTK not set\n"); in iwl_mvm_ftm_add_pasn_sta()
118 list_add_tail(&pasn->list, &mvm->ftm_initiator.pasn_list); in iwl_mvm_ftm_add_pasn_sta()
125 void iwl_mvm_ftm_remove_pasn_sta(struct iwl_mvm *mvm, u8 *addr) in iwl_mvm_ftm_remove_pasn_sta() argument
129 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_remove_pasn_sta()
131 list_for_each_entry_safe(entry, prev, &mvm->ftm_initiator.pasn_list, in iwl_mvm_ftm_remove_pasn_sta()
142 static void iwl_mvm_ftm_reset(struct iwl_mvm *mvm) in iwl_mvm_ftm_reset() argument
146 mvm->ftm_initiator.req = NULL; in iwl_mvm_ftm_reset()
147 mvm->ftm_initiator.req_wdev = NULL; in iwl_mvm_ftm_reset()
148 memset(mvm->ftm_initiator.responses, 0, in iwl_mvm_ftm_reset()
149 sizeof(mvm->ftm_initiator.responses)); in iwl_mvm_ftm_reset()
151 list_for_each_entry_safe(e, t, &mvm->ftm_initiator.loc_list, list) { in iwl_mvm_ftm_reset()
157 void iwl_mvm_ftm_restart(struct iwl_mvm *mvm) in iwl_mvm_ftm_restart() argument
167 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_restart()
169 if (!mvm->ftm_initiator.req) in iwl_mvm_ftm_restart()
172 for (i = 0; i < mvm->ftm_initiator.req->n_peers; i++) { in iwl_mvm_ftm_restart()
173 memcpy(result.addr, mvm->ftm_initiator.req->peers[i].addr, in iwl_mvm_ftm_restart()
175 result.ftm.burst_index = mvm->ftm_initiator.responses[i]; in iwl_mvm_ftm_restart()
177 cfg80211_pmsr_report(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_restart()
178 mvm->ftm_initiator.req, in iwl_mvm_ftm_restart()
182 cfg80211_pmsr_complete(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_restart()
183 mvm->ftm_initiator.req, GFP_KERNEL); in iwl_mvm_ftm_restart()
184 iwl_mvm_ftm_reset(mvm); in iwl_mvm_ftm_restart()
187 void iwl_mvm_ftm_initiator_smooth_config(struct iwl_mvm *mvm) in iwl_mvm_ftm_initiator_smooth_config() argument
189 INIT_LIST_HEAD(&mvm->ftm_initiator.smooth.resp); in iwl_mvm_ftm_initiator_smooth_config()
191 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_initiator_smooth_config()
200 void iwl_mvm_ftm_initiator_smooth_stop(struct iwl_mvm *mvm) in iwl_mvm_ftm_initiator_smooth_stop() argument
204 list_for_each_entry_safe(se, st, &mvm->ftm_initiator.smooth.resp, in iwl_mvm_ftm_initiator_smooth_stop()
225 static void iwl_mvm_ftm_cmd_v5(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_cmd_v5() argument
255 static void iwl_mvm_ftm_cmd_common(struct iwl_mvm *mvm, in iwl_mvm_ftm_cmd_common() argument
306 static void iwl_mvm_ftm_cmd_v8(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_cmd_v8() argument
310 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)cmd, req); in iwl_mvm_ftm_cmd_v8()
314 iwl_mvm_ftm_target_chandef_v1(struct iwl_mvm *mvm, in iwl_mvm_ftm_target_chandef_v1() argument
337 IWL_ERR(mvm, "Unsupported BW in FTM request (%d)\n", in iwl_mvm_ftm_target_chandef_v1()
349 iwl_mvm_ftm_target_chandef_v2(struct iwl_mvm *mvm, in iwl_mvm_ftm_target_chandef_v2() argument
377 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_ftm_target_chandef_v2()
388 IWL_ERR(mvm, "Unsupported BW in FTM request (%d)\n", in iwl_mvm_ftm_target_chandef_v2()
404 iwl_mvm_ftm_put_target_v2(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_v2() argument
410 ret = iwl_mvm_ftm_target_chandef_v1(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target_v2()
440 iwl_mvm_ftm_put_target_common(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_common() argument
480 iwl_mvm_ftm_put_target_v3(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_v3() argument
486 ret = iwl_mvm_ftm_target_chandef_v1(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target_v3()
496 iwl_mvm_ftm_put_target_common(mvm, peer, (void *)target); in iwl_mvm_ftm_put_target_v3()
502 iwl_mvm_ftm_put_target_v4(struct iwl_mvm *mvm, in iwl_mvm_ftm_put_target_v4() argument
508 ret = iwl_mvm_ftm_target_chandef_v2(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target_v4()
514 iwl_mvm_ftm_put_target_common(mvm, peer, (void *)target); in iwl_mvm_ftm_put_target_v4()
520 iwl_mvm_ftm_put_target(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_put_target() argument
526 ret = iwl_mvm_ftm_target_chandef_v2(mvm, peer, &target->channel_num, in iwl_mvm_ftm_put_target()
532 iwl_mvm_ftm_put_target_common(mvm, peer, target); in iwl_mvm_ftm_put_target()
546 sta = rcu_dereference(mvm->fw_id_to_mac_id[target->sta_id]); in iwl_mvm_ftm_put_target()
570 static int iwl_mvm_ftm_send_cmd(struct iwl_mvm *mvm, struct iwl_host_cmd *hcmd) in iwl_mvm_ftm_send_cmd() argument
573 int err = iwl_mvm_send_cmd_status(mvm, hcmd, &status); in iwl_mvm_ftm_send_cmd()
576 IWL_ERR(mvm, "FTM range request command failure, status: %u\n", in iwl_mvm_ftm_send_cmd()
584 static int iwl_mvm_ftm_start_v5(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v5() argument
597 iwl_mvm_ftm_cmd_v5(mvm, vif, &cmd_v5, req); in iwl_mvm_ftm_start_v5()
602 err = iwl_mvm_ftm_put_target_v2(mvm, peer, &cmd_v5.ap[i]); in iwl_mvm_ftm_start_v5()
607 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v5()
610 static int iwl_mvm_ftm_start_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v7() argument
627 iwl_mvm_ftm_cmd_v8(mvm, vif, (void *)&cmd_v7, req); in iwl_mvm_ftm_start_v7()
632 err = iwl_mvm_ftm_put_target_v3(mvm, peer, &cmd_v7.ap[i]); in iwl_mvm_ftm_start_v7()
637 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v7()
640 static int iwl_mvm_ftm_start_v8(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v8() argument
653 iwl_mvm_ftm_cmd_v8(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v8()
658 err = iwl_mvm_ftm_put_target_v4(mvm, peer, &cmd.ap[i]); in iwl_mvm_ftm_start_v8()
663 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v8()
666 static int iwl_mvm_ftm_start_v9(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start_v9() argument
679 iwl_mvm_ftm_cmd_common(mvm, vif, &cmd, req); in iwl_mvm_ftm_start_v9()
685 err = iwl_mvm_ftm_put_target(mvm, vif, peer, target); in iwl_mvm_ftm_start_v9()
690 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v9()
715 iwl_mvm_ftm_set_secured_ranging(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_set_secured_ranging() argument
725 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_set_secured_ranging()
727 list_for_each_entry(entry, &mvm->ftm_initiator.pasn_list, list) { in iwl_mvm_ftm_set_secured_ranging()
741 ieee80211_iter_keys(mvm->hw, vif, iter, target); in iwl_mvm_ftm_set_secured_ranging()
755 iwl_mvm_ftm_put_target_v7(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_put_target_v7() argument
759 int err = iwl_mvm_ftm_put_target(mvm, vif, peer, (void *)target); in iwl_mvm_ftm_put_target_v7()
763 iwl_mvm_ftm_set_secured_ranging(mvm, vif, target); in iwl_mvm_ftm_put_target_v7()
767 static int iwl_mvm_ftm_start_v11(struct iwl_mvm *mvm, in iwl_mvm_ftm_start_v11() argument
781 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v11()
787 err = iwl_mvm_ftm_put_target_v7(mvm, vif, peer, target); in iwl_mvm_ftm_start_v11()
792 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v11()
796 iwl_mvm_ftm_set_ndp_params(struct iwl_mvm *mvm, in iwl_mvm_ftm_set_ndp_params() argument
812 iwl_mvm_ftm_put_target_v8(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_put_target_v8() argument
817 int ret = iwl_mvm_ftm_put_target_v7(mvm, vif, peer, (void *)target); in iwl_mvm_ftm_put_target_v8()
822 iwl_mvm_ftm_set_ndp_params(mvm, target); in iwl_mvm_ftm_put_target_v8()
838 static int iwl_mvm_ftm_start_v12(struct iwl_mvm *mvm, in iwl_mvm_ftm_start_v12() argument
852 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v12()
858 err = iwl_mvm_ftm_put_target_v8(mvm, vif, peer, target); in iwl_mvm_ftm_start_v12()
863 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v12()
866 static int iwl_mvm_ftm_start_v13(struct iwl_mvm *mvm, in iwl_mvm_ftm_start_v13() argument
880 iwl_mvm_ftm_cmd_common(mvm, vif, (void *)&cmd, req); in iwl_mvm_ftm_start_v13()
886 err = iwl_mvm_ftm_put_target_v8(mvm, vif, peer, (void *)target); in iwl_mvm_ftm_start_v13()
906 return iwl_mvm_ftm_send_cmd(mvm, &hcmd); in iwl_mvm_ftm_start_v13()
909 int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, in iwl_mvm_ftm_start() argument
912 bool new_api = fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_start()
916 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_start()
918 if (mvm->ftm_initiator.req) in iwl_mvm_ftm_start()
922 u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_ftm_start()
928 err = iwl_mvm_ftm_start_v13(mvm, vif, req); in iwl_mvm_ftm_start()
931 err = iwl_mvm_ftm_start_v12(mvm, vif, req); in iwl_mvm_ftm_start()
934 err = iwl_mvm_ftm_start_v11(mvm, vif, req); in iwl_mvm_ftm_start()
938 err = iwl_mvm_ftm_start_v9(mvm, vif, req); in iwl_mvm_ftm_start()
941 err = iwl_mvm_ftm_start_v8(mvm, vif, req); in iwl_mvm_ftm_start()
944 err = iwl_mvm_ftm_start_v7(mvm, vif, req); in iwl_mvm_ftm_start()
948 err = iwl_mvm_ftm_start_v5(mvm, vif, req); in iwl_mvm_ftm_start()
952 mvm->ftm_initiator.req = req; in iwl_mvm_ftm_start()
953 mvm->ftm_initiator.req_wdev = ieee80211_vif_to_wdev(vif); in iwl_mvm_ftm_start()
959 void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req) in iwl_mvm_ftm_abort() argument
965 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_abort()
967 if (req != mvm->ftm_initiator.req) in iwl_mvm_ftm_abort()
970 iwl_mvm_ftm_reset(mvm); in iwl_mvm_ftm_abort()
972 if (iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(LOCATION_GROUP, TOF_RANGE_ABORT_CMD), in iwl_mvm_ftm_abort()
974 IWL_ERR(mvm, "failed to abort FTM process\n"); in iwl_mvm_ftm_abort()
992 static u64 iwl_mvm_ftm_get_host_time(struct iwl_mvm *mvm, __le32 fw_gp2_ts) in iwl_mvm_ftm_get_host_time() argument
998 iwl_mvm_get_sync_time(mvm, CLOCK_BOOTTIME, &curr_gp2, in iwl_mvm_ftm_get_host_time()
1009 static void iwl_mvm_ftm_get_lci_civic(struct iwl_mvm *mvm, in iwl_mvm_ftm_get_lci_civic() argument
1014 list_for_each_entry(entry, &mvm->ftm_initiator.loc_list, list) { in iwl_mvm_ftm_get_lci_civic()
1033 static int iwl_mvm_ftm_range_resp_valid(struct iwl_mvm *mvm, u8 request_id, in iwl_mvm_ftm_range_resp_valid() argument
1036 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_range_resp_valid()
1038 if (request_id != (u8)mvm->ftm_initiator.req->cookie) { in iwl_mvm_ftm_range_resp_valid()
1039 IWL_ERR(mvm, "Request ID mismatch, got %u, active %u\n", in iwl_mvm_ftm_range_resp_valid()
1040 request_id, (u8)mvm->ftm_initiator.req->cookie); in iwl_mvm_ftm_range_resp_valid()
1044 if (num_of_aps > mvm->ftm_initiator.req->n_peers) { in iwl_mvm_ftm_range_resp_valid()
1045 IWL_ERR(mvm, "FTM range response invalid\n"); in iwl_mvm_ftm_range_resp_valid()
1052 static void iwl_mvm_ftm_rtt_smoothing(struct iwl_mvm *mvm, in iwl_mvm_ftm_rtt_smoothing() argument
1066 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1072 list_for_each_entry(iter, &mvm->ftm_initiator.smooth.resp, list) { in iwl_mvm_ftm_rtt_smoothing()
1085 list_add_tail(&resp->list, &mvm->ftm_initiator.smooth.resp); in iwl_mvm_ftm_rtt_smoothing()
1089 IWL_DEBUG_INFO(mvm, "new: %pM: rtt_avg=%lld\n", in iwl_mvm_ftm_rtt_smoothing()
1098 IWL_DEBUG_INFO(mvm, "expired: %pM: rtt_avg=%lld\n", in iwl_mvm_ftm_rtt_smoothing()
1110 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1124 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1130 IWL_DEBUG_INFO(mvm, in iwl_mvm_ftm_rtt_smoothing()
1139 static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index, in iwl_mvm_debug_range_resp() argument
1144 IWL_DEBUG_INFO(mvm, "entry %d\n", index); in iwl_mvm_debug_range_resp()
1145 IWL_DEBUG_INFO(mvm, "\tstatus: %d\n", res->status); in iwl_mvm_debug_range_resp()
1146 IWL_DEBUG_INFO(mvm, "\tBSSID: %pM\n", res->addr); in iwl_mvm_debug_range_resp()
1147 IWL_DEBUG_INFO(mvm, "\thost time: %llu\n", res->host_time); in iwl_mvm_debug_range_resp()
1148 IWL_DEBUG_INFO(mvm, "\tburst index: %d\n", res->ftm.burst_index); in iwl_mvm_debug_range_resp()
1149 IWL_DEBUG_INFO(mvm, "\tsuccess num: %u\n", res->ftm.num_ftmr_successes); in iwl_mvm_debug_range_resp()
1150 IWL_DEBUG_INFO(mvm, "\trssi: %d\n", res->ftm.rssi_avg); in iwl_mvm_debug_range_resp()
1151 IWL_DEBUG_INFO(mvm, "\trssi spread: %d\n", res->ftm.rssi_spread); in iwl_mvm_debug_range_resp()
1152 IWL_DEBUG_INFO(mvm, "\trtt: %lld\n", res->ftm.rtt_avg); in iwl_mvm_debug_range_resp()
1153 IWL_DEBUG_INFO(mvm, "\trtt var: %llu\n", res->ftm.rtt_variance); in iwl_mvm_debug_range_resp()
1154 IWL_DEBUG_INFO(mvm, "\trtt spread: %llu\n", res->ftm.rtt_spread); in iwl_mvm_debug_range_resp()
1155 IWL_DEBUG_INFO(mvm, "\tdistance: %lld\n", rtt_avg); in iwl_mvm_debug_range_resp()
1159 iwl_mvm_ftm_pasn_update_pn(struct iwl_mvm *mvm, in iwl_mvm_ftm_pasn_update_pn() argument
1164 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_pasn_update_pn()
1166 list_for_each_entry(entry, &mvm->ftm_initiator.pasn_list, list) { in iwl_mvm_ftm_pasn_update_pn()
1176 static u8 iwl_mvm_ftm_get_range_resp_ver(struct iwl_mvm *mvm) in iwl_mvm_ftm_get_range_resp_ver() argument
1178 if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_get_range_resp_ver()
1183 if (mvm->cmd_ver.range_resp >= 8) in iwl_mvm_ftm_get_range_resp_ver()
1184 return mvm->cmd_ver.range_resp; in iwl_mvm_ftm_get_range_resp_ver()
1185 else if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_get_range_resp_ver()
1211 void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_ftm_range_resp() argument
1220 bool new_api = fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_range_resp()
1223 u8 notif_ver = iwl_mvm_ftm_get_range_resp_ver(mvm); in iwl_mvm_ftm_range_resp()
1225 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_range_resp()
1227 if (!mvm->ftm_initiator.req) { in iwl_mvm_ftm_range_resp()
1235 if (iwl_mvm_ftm_range_resp_valid(mvm, fw_resp_v8->request_id, in iwl_mvm_ftm_range_resp()
1242 if (iwl_mvm_ftm_range_resp_valid(mvm, fw_resp_v5->request_id, in iwl_mvm_ftm_range_resp()
1250 IWL_DEBUG_INFO(mvm, "Range response received\n"); in iwl_mvm_ftm_range_resp()
1251 IWL_DEBUG_INFO(mvm, "request id: %lld, num of entries: %u\n", in iwl_mvm_ftm_range_resp()
1252 mvm->ftm_initiator.req->cookie, num_of_aps); in iwl_mvm_ftm_range_resp()
1262 iwl_mvm_ftm_pasn_update_pn(mvm, fw_ap); in iwl_mvm_ftm_range_resp()
1283 peer_idx = iwl_mvm_ftm_find_peer(mvm->ftm_initiator.req, in iwl_mvm_ftm_range_resp()
1286 IWL_WARN(mvm, in iwl_mvm_ftm_range_resp()
1317 result.host_time = iwl_mvm_ftm_get_host_time(mvm, in iwl_mvm_ftm_range_resp()
1320 result.ftm.burst_index = mvm->ftm_initiator.responses[peer_idx]; in iwl_mvm_ftm_range_resp()
1321 mvm->ftm_initiator.responses[peer_idx]++; in iwl_mvm_ftm_range_resp()
1333 iwl_mvm_ftm_get_lci_civic(mvm, &result); in iwl_mvm_ftm_range_resp()
1335 iwl_mvm_ftm_rtt_smoothing(mvm, &result); in iwl_mvm_ftm_range_resp()
1337 cfg80211_pmsr_report(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_range_resp()
1338 mvm->ftm_initiator.req, in iwl_mvm_ftm_range_resp()
1341 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_ftm_range_resp()
1343 IWL_DEBUG_INFO(mvm, "RTT confidence: %u\n", in iwl_mvm_ftm_range_resp()
1346 iwl_mvm_debug_range_resp(mvm, i, &result); in iwl_mvm_ftm_range_resp()
1350 cfg80211_pmsr_complete(mvm->ftm_initiator.req_wdev, in iwl_mvm_ftm_range_resp()
1351 mvm->ftm_initiator.req, in iwl_mvm_ftm_range_resp()
1353 iwl_mvm_ftm_reset(mvm); in iwl_mvm_ftm_range_resp()
1357 void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_ftm_lc_notif() argument
1373 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ftm_lc_notif()
1406 list_add_tail(&entry->list, &mvm->ftm_initiator.loc_list); in iwl_mvm_ftm_lc_notif()