aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2018-10-30 09:47:52 -0400
committerLuca Coelho <luciano.coelho@intel.com>2019-01-29 09:10:31 -0500
commit3a894a9f319f0b4a36857683c4caacc371a40d25 (patch)
treeefd6708298400d2889e060a1bc8110fd2ce4edc2 /drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
parentfba8248e7e67b7e1098e69284aeccbcb2110fa86 (diff)
iwlwifi: remove TOF implementation
This is an ancient (~2015) implementation that no longer matches the firmware in any way, and most likely never worked. Remove all of it so it can be reintroduced properly. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c')
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c770
1 files changed, 0 insertions, 770 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index 33b0af24a537..1c0f84049573 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -60,7 +60,6 @@
60 * 60 *
61 *****************************************************************************/ 61 *****************************************************************************/
62#include "mvm.h" 62#include "mvm.h"
63#include "fw/api/tof.h"
64#include "debugfs.h" 63#include "debugfs.h"
65 64
66static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm, 65static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm,
@@ -523,751 +522,6 @@ static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
523 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 522 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
524} 523}
525 524
526static ssize_t iwl_dbgfs_tof_enable_write(struct ieee80211_vif *vif,
527 char *buf,
528 size_t count, loff_t *ppos)
529{
530 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
531 struct iwl_mvm *mvm = mvmvif->mvm;
532 u32 value;
533 int ret = -EINVAL;
534 char *data;
535
536 mutex_lock(&mvm->mutex);
537
538 data = iwl_dbgfs_is_match("tof_disabled=", buf);
539 if (data) {
540 ret = kstrtou32(data, 10, &value);
541 if (ret == 0)
542 mvm->tof_data.tof_cfg.tof_disabled = value;
543 goto out;
544 }
545
546 data = iwl_dbgfs_is_match("one_sided_disabled=", buf);
547 if (data) {
548 ret = kstrtou32(data, 10, &value);
549 if (ret == 0)
550 mvm->tof_data.tof_cfg.one_sided_disabled = value;
551 goto out;
552 }
553
554 data = iwl_dbgfs_is_match("is_debug_mode=", buf);
555 if (data) {
556 ret = kstrtou32(data, 10, &value);
557 if (ret == 0)
558 mvm->tof_data.tof_cfg.is_debug_mode = value;
559 goto out;
560 }
561
562 data = iwl_dbgfs_is_match("is_buf=", buf);
563 if (data) {
564 ret = kstrtou32(data, 10, &value);
565 if (ret == 0)
566 mvm->tof_data.tof_cfg.is_buf_required = value;
567 goto out;
568 }
569
570 data = iwl_dbgfs_is_match("send_tof_cfg=", buf);
571 if (data) {
572 ret = kstrtou32(data, 10, &value);
573 if (ret == 0 && value) {
574 ret = iwl_mvm_tof_config_cmd(mvm);
575 goto out;
576 }
577 }
578
579out:
580 mutex_unlock(&mvm->mutex);
581
582 return ret ?: count;
583}
584
585static ssize_t iwl_dbgfs_tof_enable_read(struct file *file,
586 char __user *user_buf,
587 size_t count, loff_t *ppos)
588{
589 struct ieee80211_vif *vif = file->private_data;
590 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
591 struct iwl_mvm *mvm = mvmvif->mvm;
592 char buf[256];
593 int pos = 0;
594 const size_t bufsz = sizeof(buf);
595 struct iwl_tof_config_cmd *cmd;
596
597 cmd = &mvm->tof_data.tof_cfg;
598
599 mutex_lock(&mvm->mutex);
600
601 pos += scnprintf(buf + pos, bufsz - pos, "tof_disabled = %d\n",
602 cmd->tof_disabled);
603 pos += scnprintf(buf + pos, bufsz - pos, "one_sided_disabled = %d\n",
604 cmd->one_sided_disabled);
605 pos += scnprintf(buf + pos, bufsz - pos, "is_debug_mode = %d\n",
606 cmd->is_debug_mode);
607 pos += scnprintf(buf + pos, bufsz - pos, "is_buf_required = %d\n",
608 cmd->is_buf_required);
609
610 mutex_unlock(&mvm->mutex);
611
612 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
613}
614
615static ssize_t iwl_dbgfs_tof_responder_params_write(struct ieee80211_vif *vif,
616 char *buf,
617 size_t count, loff_t *ppos)
618{
619 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
620 struct iwl_mvm *mvm = mvmvif->mvm;
621 u32 value;
622 int ret = 0;
623 char *data;
624
625 mutex_lock(&mvm->mutex);
626
627 data = iwl_dbgfs_is_match("burst_period=", buf);
628 if (data) {
629 ret = kstrtou32(data, 10, &value);
630 if (!ret)
631 mvm->tof_data.responder_cfg.burst_period =
632 cpu_to_le16(value);
633 goto out;
634 }
635
636 data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
637 if (data) {
638 ret = kstrtou32(data, 10, &value);
639 if (ret == 0)
640 mvm->tof_data.responder_cfg.min_delta_ftm = value;
641 goto out;
642 }
643
644 data = iwl_dbgfs_is_match("burst_duration=", buf);
645 if (data) {
646 ret = kstrtou32(data, 10, &value);
647 if (ret == 0)
648 mvm->tof_data.responder_cfg.burst_duration = value;
649 goto out;
650 }
651
652 data = iwl_dbgfs_is_match("num_of_burst_exp=", buf);
653 if (data) {
654 ret = kstrtou32(data, 10, &value);
655 if (ret == 0)
656 mvm->tof_data.responder_cfg.num_of_burst_exp = value;
657 goto out;
658 }
659
660 data = iwl_dbgfs_is_match("abort_responder=", buf);
661 if (data) {
662 ret = kstrtou32(data, 10, &value);
663 if (ret == 0)
664 mvm->tof_data.responder_cfg.abort_responder = value;
665 goto out;
666 }
667
668 data = iwl_dbgfs_is_match("get_ch_est=", buf);
669 if (data) {
670 ret = kstrtou32(data, 10, &value);
671 if (ret == 0)
672 mvm->tof_data.responder_cfg.get_ch_est = value;
673 goto out;
674 }
675
676 data = iwl_dbgfs_is_match("recv_sta_req_params=", buf);
677 if (data) {
678 ret = kstrtou32(data, 10, &value);
679 if (ret == 0)
680 mvm->tof_data.responder_cfg.recv_sta_req_params = value;
681 goto out;
682 }
683
684 data = iwl_dbgfs_is_match("channel_num=", buf);
685 if (data) {
686 ret = kstrtou32(data, 10, &value);
687 if (ret == 0)
688 mvm->tof_data.responder_cfg.channel_num = value;
689 goto out;
690 }
691
692 data = iwl_dbgfs_is_match("bandwidth=", buf);
693 if (data) {
694 ret = kstrtou32(data, 10, &value);
695 if (ret == 0)
696 mvm->tof_data.responder_cfg.bandwidth = value;
697 goto out;
698 }
699
700 data = iwl_dbgfs_is_match("rate=", buf);
701 if (data) {
702 ret = kstrtou32(data, 10, &value);
703 if (ret == 0)
704 mvm->tof_data.responder_cfg.rate = value;
705 goto out;
706 }
707
708 data = iwl_dbgfs_is_match("bssid=", buf);
709 if (data) {
710 u8 *mac = mvm->tof_data.responder_cfg.bssid;
711
712 if (!mac_pton(data, mac)) {
713 ret = -EINVAL;
714 goto out;
715 }
716 }
717
718 data = iwl_dbgfs_is_match("tsf_timer_offset_msecs=", buf);
719 if (data) {
720 ret = kstrtou32(data, 10, &value);
721 if (ret == 0)
722 mvm->tof_data.responder_cfg.tsf_timer_offset_msecs =
723 cpu_to_le16(value);
724 goto out;
725 }
726
727 data = iwl_dbgfs_is_match("toa_offset=", buf);
728 if (data) {
729 ret = kstrtou32(data, 10, &value);
730 if (ret == 0)
731 mvm->tof_data.responder_cfg.toa_offset =
732 cpu_to_le16(value);
733 goto out;
734 }
735
736 data = iwl_dbgfs_is_match("center_freq=", buf);
737 if (data) {
738 struct iwl_tof_responder_config_cmd *cmd =
739 &mvm->tof_data.responder_cfg;
740
741 ret = kstrtou32(data, 10, &value);
742 if (ret == 0 && value) {
743 enum nl80211_band band = (cmd->channel_num <= 14) ?
744 NL80211_BAND_2GHZ :
745 NL80211_BAND_5GHZ;
746 struct ieee80211_channel chn = {
747 .band = band,
748 .center_freq = ieee80211_channel_to_frequency(
749 cmd->channel_num, band),
750 };
751 struct cfg80211_chan_def chandef = {
752 .chan = &chn,
753 .center_freq1 =
754 ieee80211_channel_to_frequency(value,
755 band),
756 };
757
758 cmd->ctrl_ch_position = iwl_mvm_get_ctrl_pos(&chandef);
759 }
760 goto out;
761 }
762
763 data = iwl_dbgfs_is_match("ftm_per_burst=", buf);
764 if (data) {
765 ret = kstrtou32(data, 10, &value);
766 if (ret == 0)
767 mvm->tof_data.responder_cfg.ftm_per_burst = value;
768 goto out;
769 }
770
771 data = iwl_dbgfs_is_match("ftm_resp_ts_avail=", buf);
772 if (data) {
773 ret = kstrtou32(data, 10, &value);
774 if (ret == 0)
775 mvm->tof_data.responder_cfg.ftm_resp_ts_avail = value;
776 goto out;
777 }
778
779 data = iwl_dbgfs_is_match("asap_mode=", buf);
780 if (data) {
781 ret = kstrtou32(data, 10, &value);
782 if (ret == 0)
783 mvm->tof_data.responder_cfg.asap_mode = value;
784 goto out;
785 }
786
787 data = iwl_dbgfs_is_match("send_responder_cfg=", buf);
788 if (data) {
789 ret = kstrtou32(data, 10, &value);
790 if (ret == 0 && value) {
791 ret = iwl_mvm_tof_responder_cmd(mvm, vif);
792 goto out;
793 }
794 }
795
796out:
797 mutex_unlock(&mvm->mutex);
798
799 return ret ?: count;
800}
801
802static ssize_t iwl_dbgfs_tof_responder_params_read(struct file *file,
803 char __user *user_buf,
804 size_t count, loff_t *ppos)
805{
806 struct ieee80211_vif *vif = file->private_data;
807 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
808 struct iwl_mvm *mvm = mvmvif->mvm;
809 char buf[256];
810 int pos = 0;
811 const size_t bufsz = sizeof(buf);
812 struct iwl_tof_responder_config_cmd *cmd;
813
814 cmd = &mvm->tof_data.responder_cfg;
815
816 mutex_lock(&mvm->mutex);
817
818 pos += scnprintf(buf + pos, bufsz - pos, "burst_period = %d\n",
819 le16_to_cpu(cmd->burst_period));
820 pos += scnprintf(buf + pos, bufsz - pos, "burst_duration = %d\n",
821 cmd->burst_duration);
822 pos += scnprintf(buf + pos, bufsz - pos, "bandwidth = %d\n",
823 cmd->bandwidth);
824 pos += scnprintf(buf + pos, bufsz - pos, "channel_num = %d\n",
825 cmd->channel_num);
826 pos += scnprintf(buf + pos, bufsz - pos, "ctrl_ch_position = 0x%x\n",
827 cmd->ctrl_ch_position);
828 pos += scnprintf(buf + pos, bufsz - pos, "bssid = %pM\n",
829 cmd->bssid);
830 pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %d\n",
831 cmd->min_delta_ftm);
832 pos += scnprintf(buf + pos, bufsz - pos, "num_of_burst_exp = %d\n",
833 cmd->num_of_burst_exp);
834 pos += scnprintf(buf + pos, bufsz - pos, "rate = %d\n", cmd->rate);
835 pos += scnprintf(buf + pos, bufsz - pos, "abort_responder = %d\n",
836 cmd->abort_responder);
837 pos += scnprintf(buf + pos, bufsz - pos, "get_ch_est = %d\n",
838 cmd->get_ch_est);
839 pos += scnprintf(buf + pos, bufsz - pos, "recv_sta_req_params = %d\n",
840 cmd->recv_sta_req_params);
841 pos += scnprintf(buf + pos, bufsz - pos, "ftm_per_burst = %d\n",
842 cmd->ftm_per_burst);
843 pos += scnprintf(buf + pos, bufsz - pos, "ftm_resp_ts_avail = %d\n",
844 cmd->ftm_resp_ts_avail);
845 pos += scnprintf(buf + pos, bufsz - pos, "asap_mode = %d\n",
846 cmd->asap_mode);
847 pos += scnprintf(buf + pos, bufsz - pos,
848 "tsf_timer_offset_msecs = %d\n",
849 le16_to_cpu(cmd->tsf_timer_offset_msecs));
850 pos += scnprintf(buf + pos, bufsz - pos, "toa_offset = %d\n",
851 le16_to_cpu(cmd->toa_offset));
852
853 mutex_unlock(&mvm->mutex);
854
855 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
856}
857
858static ssize_t iwl_dbgfs_tof_range_request_write(struct ieee80211_vif *vif,
859 char *buf, size_t count,
860 loff_t *ppos)
861{
862 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
863 struct iwl_mvm *mvm = mvmvif->mvm;
864 u32 value;
865 int ret = 0;
866 char *data;
867
868 mutex_lock(&mvm->mutex);
869
870 data = iwl_dbgfs_is_match("request_id=", buf);
871 if (data) {
872 ret = kstrtou32(data, 10, &value);
873 if (ret == 0)
874 mvm->tof_data.range_req.request_id = value;
875 goto out;
876 }
877
878 data = iwl_dbgfs_is_match("initiator=", buf);
879 if (data) {
880 ret = kstrtou32(data, 10, &value);
881 if (ret == 0)
882 mvm->tof_data.range_req.initiator = value;
883 goto out;
884 }
885
886 data = iwl_dbgfs_is_match("one_sided_los_disable=", buf);
887 if (data) {
888 ret = kstrtou32(data, 10, &value);
889 if (ret == 0)
890 mvm->tof_data.range_req.one_sided_los_disable = value;
891 goto out;
892 }
893
894 data = iwl_dbgfs_is_match("req_timeout=", buf);
895 if (data) {
896 ret = kstrtou32(data, 10, &value);
897 if (ret == 0)
898 mvm->tof_data.range_req.req_timeout = value;
899 goto out;
900 }
901
902 data = iwl_dbgfs_is_match("report_policy=", buf);
903 if (data) {
904 ret = kstrtou32(data, 10, &value);
905 if (ret == 0)
906 mvm->tof_data.range_req.report_policy = value;
907 goto out;
908 }
909
910 data = iwl_dbgfs_is_match("macaddr_random=", buf);
911 if (data) {
912 ret = kstrtou32(data, 10, &value);
913 if (ret == 0)
914 mvm->tof_data.range_req.macaddr_random = value;
915 goto out;
916 }
917
918 data = iwl_dbgfs_is_match("num_of_ap=", buf);
919 if (data) {
920 ret = kstrtou32(data, 10, &value);
921 if (ret == 0)
922 mvm->tof_data.range_req.num_of_ap = value;
923 goto out;
924 }
925
926 data = iwl_dbgfs_is_match("macaddr_template=", buf);
927 if (data) {
928 u8 mac[ETH_ALEN];
929
930 if (!mac_pton(data, mac)) {
931 ret = -EINVAL;
932 goto out;
933 }
934 memcpy(mvm->tof_data.range_req.macaddr_template, mac, ETH_ALEN);
935 goto out;
936 }
937
938 data = iwl_dbgfs_is_match("macaddr_mask=", buf);
939 if (data) {
940 u8 mac[ETH_ALEN];
941
942 if (!mac_pton(data, mac)) {
943 ret = -EINVAL;
944 goto out;
945 }
946 memcpy(mvm->tof_data.range_req.macaddr_mask, mac, ETH_ALEN);
947 goto out;
948 }
949
950 data = iwl_dbgfs_is_match("ap=", buf);
951 if (data) {
952 struct iwl_tof_range_req_ap_entry ap = {};
953 int size = sizeof(struct iwl_tof_range_req_ap_entry);
954 u16 burst_period;
955 u8 *mac = ap.bssid;
956 unsigned int i;
957
958 if (sscanf(data, "%u %hhd %hhd %hhd"
959 "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx"
960 "%hhd %hhd %hd"
961 "%hhd %hhd %d"
962 "%hhx %hhd %hhd %hhd",
963 &i, &ap.channel_num, &ap.bandwidth,
964 &ap.ctrl_ch_position,
965 mac, mac + 1, mac + 2, mac + 3, mac + 4, mac + 5,
966 &ap.measure_type, &ap.num_of_bursts,
967 &burst_period,
968 &ap.samples_per_burst, &ap.retries_per_sample,
969 &ap.tsf_delta, &ap.location_req, &ap.asap_mode,
970 &ap.enable_dyn_ack, &ap.rssi) != 20) {
971 ret = -EINVAL;
972 goto out;
973 }
974 if (i >= IWL_MVM_TOF_MAX_APS) {
975 IWL_ERR(mvm, "Invalid AP index %d\n", i);
976 ret = -EINVAL;
977 goto out;
978 }
979
980 ap.burst_period = cpu_to_le16(burst_period);
981
982 memcpy(&mvm->tof_data.range_req.ap[i], &ap, size);
983 goto out;
984 }
985
986 data = iwl_dbgfs_is_match("send_range_request=", buf);
987 if (data) {
988 ret = kstrtou32(data, 10, &value);
989 if (ret == 0 && value)
990 ret = iwl_mvm_tof_range_request_cmd(mvm, vif);
991 goto out;
992 }
993
994 ret = -EINVAL;
995out:
996 mutex_unlock(&mvm->mutex);
997 return ret ?: count;
998}
999
1000static ssize_t iwl_dbgfs_tof_range_request_read(struct file *file,
1001 char __user *user_buf,
1002 size_t count, loff_t *ppos)
1003{
1004 struct ieee80211_vif *vif = file->private_data;
1005 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1006 struct iwl_mvm *mvm = mvmvif->mvm;
1007 char buf[512];
1008 int pos = 0;
1009 const size_t bufsz = sizeof(buf);
1010 struct iwl_tof_range_req_cmd *cmd;
1011 int i;
1012
1013 cmd = &mvm->tof_data.range_req;
1014
1015 mutex_lock(&mvm->mutex);
1016
1017 pos += scnprintf(buf + pos, bufsz - pos, "request_id= %d\n",
1018 cmd->request_id);
1019 pos += scnprintf(buf + pos, bufsz - pos, "initiator= %d\n",
1020 cmd->initiator);
1021 pos += scnprintf(buf + pos, bufsz - pos, "one_sided_los_disable = %d\n",
1022 cmd->one_sided_los_disable);
1023 pos += scnprintf(buf + pos, bufsz - pos, "req_timeout= %d\n",
1024 cmd->req_timeout);
1025 pos += scnprintf(buf + pos, bufsz - pos, "report_policy= %d\n",
1026 cmd->report_policy);
1027 pos += scnprintf(buf + pos, bufsz - pos, "macaddr_random= %d\n",
1028 cmd->macaddr_random);
1029 pos += scnprintf(buf + pos, bufsz - pos, "macaddr_template= %pM\n",
1030 cmd->macaddr_template);
1031 pos += scnprintf(buf + pos, bufsz - pos, "macaddr_mask= %pM\n",
1032 cmd->macaddr_mask);
1033 pos += scnprintf(buf + pos, bufsz - pos, "num_of_ap= %d\n",
1034 cmd->num_of_ap);
1035 for (i = 0; i < cmd->num_of_ap; i++) {
1036 struct iwl_tof_range_req_ap_entry *ap = &cmd->ap[i];
1037
1038 pos += scnprintf(buf + pos, bufsz - pos,
1039 "ap %.2d: channel_num=%hhd bw=%hhd"
1040 " control=%hhd bssid=%pM type=%hhd"
1041 " num_of_bursts=%hhd burst_period=%hd ftm=%hhd"
1042 " retries=%hhd tsf_delta=%d"
1043 " tsf_delta_direction=%hhd location_req=0x%hhx "
1044 " asap=%hhd enable=%hhd rssi=%hhd\n",
1045 i, ap->channel_num, ap->bandwidth,
1046 ap->ctrl_ch_position, ap->bssid,
1047 ap->measure_type, ap->num_of_bursts,
1048 ap->burst_period, ap->samples_per_burst,
1049 ap->retries_per_sample, ap->tsf_delta,
1050 ap->tsf_delta_direction,
1051 ap->location_req, ap->asap_mode,
1052 ap->enable_dyn_ack, ap->rssi);
1053 }
1054
1055 mutex_unlock(&mvm->mutex);
1056
1057 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1058}
1059
1060static ssize_t iwl_dbgfs_tof_range_req_ext_write(struct ieee80211_vif *vif,
1061 char *buf,
1062 size_t count, loff_t *ppos)
1063{
1064 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1065 struct iwl_mvm *mvm = mvmvif->mvm;
1066 u32 value;
1067 int ret = 0;
1068 char *data;
1069
1070 mutex_lock(&mvm->mutex);
1071
1072 data = iwl_dbgfs_is_match("tsf_timer_offset_msec=", buf);
1073 if (data) {
1074 ret = kstrtou32(data, 10, &value);
1075 if (ret == 0)
1076 mvm->tof_data.range_req_ext.tsf_timer_offset_msec =
1077 cpu_to_le16(value);
1078 goto out;
1079 }
1080
1081 data = iwl_dbgfs_is_match("min_delta_ftm=", buf);
1082 if (data) {
1083 ret = kstrtou32(data, 10, &value);
1084 if (ret == 0)
1085 mvm->tof_data.range_req_ext.min_delta_ftm = value;
1086 goto out;
1087 }
1088
1089 data = iwl_dbgfs_is_match("ftm_format_and_bw20M=", buf);
1090 if (data) {
1091 ret = kstrtou32(data, 10, &value);
1092 if (ret == 0)
1093 mvm->tof_data.range_req_ext.ftm_format_and_bw20M =
1094 value;
1095 goto out;
1096 }
1097
1098 data = iwl_dbgfs_is_match("ftm_format_and_bw40M=", buf);
1099 if (data) {
1100 ret = kstrtou32(data, 10, &value);
1101 if (ret == 0)
1102 mvm->tof_data.range_req_ext.ftm_format_and_bw40M =
1103 value;
1104 goto out;
1105 }
1106
1107 data = iwl_dbgfs_is_match("ftm_format_and_bw80M=", buf);
1108 if (data) {
1109 ret = kstrtou32(data, 10, &value);
1110 if (ret == 0)
1111 mvm->tof_data.range_req_ext.ftm_format_and_bw80M =
1112 value;
1113 goto out;
1114 }
1115
1116 data = iwl_dbgfs_is_match("send_range_req_ext=", buf);
1117 if (data) {
1118 ret = kstrtou32(data, 10, &value);
1119 if (ret == 0 && value)
1120 ret = iwl_mvm_tof_range_request_ext_cmd(mvm, vif);
1121 goto out;
1122 }
1123
1124 ret = -EINVAL;
1125out:
1126 mutex_unlock(&mvm->mutex);
1127 return ret ?: count;
1128}
1129
1130static ssize_t iwl_dbgfs_tof_range_req_ext_read(struct file *file,
1131 char __user *user_buf,
1132 size_t count, loff_t *ppos)
1133{
1134 struct ieee80211_vif *vif = file->private_data;
1135 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1136 struct iwl_mvm *mvm = mvmvif->mvm;
1137 char buf[256];
1138 int pos = 0;
1139 const size_t bufsz = sizeof(buf);
1140 struct iwl_tof_range_req_ext_cmd *cmd;
1141
1142 cmd = &mvm->tof_data.range_req_ext;
1143
1144 mutex_lock(&mvm->mutex);
1145
1146 pos += scnprintf(buf + pos, bufsz - pos,
1147 "tsf_timer_offset_msec = %hd\n",
1148 cmd->tsf_timer_offset_msec);
1149 pos += scnprintf(buf + pos, bufsz - pos, "min_delta_ftm = %hhd\n",
1150 cmd->min_delta_ftm);
1151 pos += scnprintf(buf + pos, bufsz - pos,
1152 "ftm_format_and_bw20M = %hhd\n",
1153 cmd->ftm_format_and_bw20M);
1154 pos += scnprintf(buf + pos, bufsz - pos,
1155 "ftm_format_and_bw40M = %hhd\n",
1156 cmd->ftm_format_and_bw40M);
1157 pos += scnprintf(buf + pos, bufsz - pos,
1158 "ftm_format_and_bw80M = %hhd\n",
1159 cmd->ftm_format_and_bw80M);
1160
1161 mutex_unlock(&mvm->mutex);
1162 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1163}
1164
1165static ssize_t iwl_dbgfs_tof_range_abort_write(struct ieee80211_vif *vif,
1166 char *buf,
1167 size_t count, loff_t *ppos)
1168{
1169 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1170 struct iwl_mvm *mvm = mvmvif->mvm;
1171 u32 value;
1172 int abort_id, ret = 0;
1173 char *data;
1174
1175 mutex_lock(&mvm->mutex);
1176
1177 data = iwl_dbgfs_is_match("abort_id=", buf);
1178 if (data) {
1179 ret = kstrtou32(data, 10, &value);
1180 if (ret == 0)
1181 mvm->tof_data.last_abort_id = value;
1182 goto out;
1183 }
1184
1185 data = iwl_dbgfs_is_match("send_range_abort=", buf);
1186 if (data) {
1187 ret = kstrtou32(data, 10, &value);
1188 if (ret == 0 && value) {
1189 abort_id = mvm->tof_data.last_abort_id;
1190 ret = iwl_mvm_tof_range_abort_cmd(mvm, abort_id);
1191 goto out;
1192 }
1193 }
1194
1195out:
1196 mutex_unlock(&mvm->mutex);
1197 return ret ?: count;
1198}
1199
1200static ssize_t iwl_dbgfs_tof_range_abort_read(struct file *file,
1201 char __user *user_buf,
1202 size_t count, loff_t *ppos)
1203{
1204 struct ieee80211_vif *vif = file->private_data;
1205 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1206 struct iwl_mvm *mvm = mvmvif->mvm;
1207 char buf[32];
1208 int pos = 0;
1209 const size_t bufsz = sizeof(buf);
1210 int last_abort_id;
1211
1212 mutex_lock(&mvm->mutex);
1213 last_abort_id = mvm->tof_data.last_abort_id;
1214 mutex_unlock(&mvm->mutex);
1215
1216 pos += scnprintf(buf + pos, bufsz - pos, "last_abort_id = %d\n",
1217 last_abort_id);
1218 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1219}
1220
1221static ssize_t iwl_dbgfs_tof_range_response_read(struct file *file,
1222 char __user *user_buf,
1223 size_t count, loff_t *ppos)
1224{
1225 struct ieee80211_vif *vif = file->private_data;
1226 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1227 struct iwl_mvm *mvm = mvmvif->mvm;
1228 char *buf;
1229 int pos = 0;
1230 const size_t bufsz = sizeof(struct iwl_tof_range_rsp_ntfy) + 256;
1231 struct iwl_tof_range_rsp_ntfy *cmd;
1232 int i, ret;
1233
1234 buf = kzalloc(bufsz, GFP_KERNEL);
1235 if (!buf)
1236 return -ENOMEM;
1237
1238 mutex_lock(&mvm->mutex);
1239 cmd = &mvm->tof_data.range_resp;
1240
1241 pos += scnprintf(buf + pos, bufsz - pos, "request_id = %d\n",
1242 cmd->request_id);
1243 pos += scnprintf(buf + pos, bufsz - pos, "status = %d\n",
1244 cmd->request_status);
1245 pos += scnprintf(buf + pos, bufsz - pos, "last_in_batch = %d\n",
1246 cmd->last_in_batch);
1247 pos += scnprintf(buf + pos, bufsz - pos, "num_of_aps = %d\n",
1248 cmd->num_of_aps);
1249 for (i = 0; i < cmd->num_of_aps; i++) {
1250 struct iwl_tof_range_rsp_ap_entry_ntfy *ap = &cmd->ap[i];
1251
1252 pos += scnprintf(buf + pos, bufsz - pos,
1253 "ap %.2d: bssid=%pM status=%hhd bw=%hhd"
1254 " rtt=%d rtt_var=%d rtt_spread=%d"
1255 " rssi=%hhd rssi_spread=%hhd"
1256 " range=%d range_var=%d"
1257 " time_stamp=%d\n",
1258 i, ap->bssid, ap->measure_status,
1259 ap->measure_bw,
1260 ap->rtt, ap->rtt_variance, ap->rtt_spread,
1261 ap->rssi, ap->rssi_spread, ap->range,
1262 ap->range_variance, ap->timestamp);
1263 }
1264 mutex_unlock(&mvm->mutex);
1265
1266 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1267 kfree(buf);
1268 return ret;
1269}
1270
1271static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf, 525static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf,
1272 size_t count, loff_t *ppos) 526 size_t count, loff_t *ppos)
1273{ 527{
@@ -1458,12 +712,6 @@ MVM_DEBUGFS_READ_WRITE_FILE_OPS(bf_params, 256);
1458MVM_DEBUGFS_READ_WRITE_FILE_OPS(low_latency, 10); 712MVM_DEBUGFS_READ_WRITE_FILE_OPS(low_latency, 10);
1459MVM_DEBUGFS_READ_WRITE_FILE_OPS(uapsd_misbehaving, 20); 713MVM_DEBUGFS_READ_WRITE_FILE_OPS(uapsd_misbehaving, 20);
1460MVM_DEBUGFS_READ_WRITE_FILE_OPS(rx_phyinfo, 10); 714MVM_DEBUGFS_READ_WRITE_FILE_OPS(rx_phyinfo, 10);
1461MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_enable, 32);
1462MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_request, 512);
1463MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_req_ext, 32);
1464MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_range_abort, 32);
1465MVM_DEBUGFS_READ_FILE_OPS(tof_range_response);
1466MVM_DEBUGFS_READ_WRITE_FILE_OPS(tof_responder_params, 32);
1467MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32); 715MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
1468MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff); 716MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
1469 717
@@ -1506,24 +754,6 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1506 mvmvif == mvm->bf_allowed_vif) 754 mvmvif == mvm->bf_allowed_vif)
1507 MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir, 0600); 755 MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir, 0600);
1508 756
1509 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT) &&
1510 !vif->p2p && (vif->type != NL80211_IFTYPE_P2P_DEVICE)) {
1511 if (IWL_MVM_TOF_IS_RESPONDER && vif->type == NL80211_IFTYPE_AP)
1512 MVM_DEBUGFS_ADD_FILE_VIF(tof_responder_params,
1513 mvmvif->dbgfs_dir, 0600);
1514
1515 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_request, mvmvif->dbgfs_dir,
1516 0600);
1517 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_req_ext, mvmvif->dbgfs_dir,
1518 0600);
1519 MVM_DEBUGFS_ADD_FILE_VIF(tof_enable, mvmvif->dbgfs_dir,
1520 0600);
1521 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_abort, mvmvif->dbgfs_dir,
1522 0600);
1523 MVM_DEBUGFS_ADD_FILE_VIF(tof_range_response, mvmvif->dbgfs_dir,
1524 0400);
1525 }
1526
1527 /* 757 /*
1528 * Create symlink for convenience pointing to interface specific 758 * Create symlink for convenience pointing to interface specific
1529 * debugfs entries for the driver. For example, under 759 * debugfs entries for the driver. For example, under