mac80211: ath11k: sync with ath-next
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / ath11k / 0029-wifi-ath11k-Add-support-to-configure-FTM-responder-r.patch
1 From a27c6a5853eb9d4f293b99be73a6891fe88263c7 Mon Sep 17 00:00:00 2001
2 From: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
3 Date: Tue, 10 Jan 2023 15:30:57 +0200
4 Subject: [PATCH] wifi: ath11k: Add support to configure FTM responder role
5
6 Fine Timing Measurement(FTM) support is used to measure round trip
7 time between two nodes.
8
9 Enable FTM responder feature using hw_params on supported device.
10 Since FTM functionality is offloaded to firmware, adding the
11 interface allows user space to enable or disable FTM responder.
12 Also add support for advertising the same in extended capabilities.
13
14 QCA6390, WCN6855 and WCN6750 do not support this feature.
15
16 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
17 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
18
19 Signed-off-by: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
20 Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
21 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
22 Link: https://lore.kernel.org/r/20221220044435.10506-1-quic_rajkbhag@quicinc.com
23 ---
24 drivers/net/wireless/ath/ath11k/core.c | 8 ++++++++
25 drivers/net/wireless/ath/ath11k/core.h | 1 +
26 drivers/net/wireless/ath/ath11k/hw.h | 1 +
27 drivers/net/wireless/ath/ath11k/mac.c | 20 +++++++++++++++++++-
28 drivers/net/wireless/ath/ath11k/wmi.h | 1 +
29 5 files changed, 30 insertions(+), 1 deletion(-)
30
31 --- a/drivers/net/wireless/ath/ath11k/core.c
32 +++ b/drivers/net/wireless/ath/ath11k/core.c
33 @@ -116,6 +116,7 @@ static const struct ath11k_hw_params ath
34 .tcl_ring_retry = true,
35 .tx_ring_size = DP_TCL_DATA_RING_SIZE,
36 .smp2p_wow_exit = false,
37 + .ftm_responder = true,
38 },
39 {
40 .hw_rev = ATH11K_HW_IPQ6018_HW10,
41 @@ -198,6 +199,7 @@ static const struct ath11k_hw_params ath
42 .tx_ring_size = DP_TCL_DATA_RING_SIZE,
43 .smp2p_wow_exit = false,
44 .support_fw_mac_sequence = false,
45 + .ftm_responder = true,
46 },
47 {
48 .name = "qca6390 hw2.0",
49 @@ -282,6 +284,7 @@ static const struct ath11k_hw_params ath
50 .tx_ring_size = DP_TCL_DATA_RING_SIZE,
51 .smp2p_wow_exit = false,
52 .support_fw_mac_sequence = true,
53 + .ftm_responder = false,
54 },
55 {
56 .name = "qcn9074 hw1.0",
57 @@ -363,6 +366,7 @@ static const struct ath11k_hw_params ath
58 .tx_ring_size = DP_TCL_DATA_RING_SIZE,
59 .smp2p_wow_exit = false,
60 .support_fw_mac_sequence = false,
61 + .ftm_responder = true,
62 },
63 {
64 .name = "wcn6855 hw2.0",
65 @@ -447,6 +451,7 @@ static const struct ath11k_hw_params ath
66 .tx_ring_size = DP_TCL_DATA_RING_SIZE,
67 .smp2p_wow_exit = false,
68 .support_fw_mac_sequence = true,
69 + .ftm_responder = false,
70 },
71 {
72 .name = "wcn6855 hw2.1",
73 @@ -529,6 +534,7 @@ static const struct ath11k_hw_params ath
74 .tx_ring_size = DP_TCL_DATA_RING_SIZE,
75 .smp2p_wow_exit = false,
76 .support_fw_mac_sequence = true,
77 + .ftm_responder = false,
78 },
79 {
80 .name = "wcn6750 hw1.0",
81 @@ -609,6 +615,7 @@ static const struct ath11k_hw_params ath
82 .tx_ring_size = DP_TCL_DATA_RING_SIZE_WCN6750,
83 .smp2p_wow_exit = true,
84 .support_fw_mac_sequence = true,
85 + .ftm_responder = false,
86 },
87 {
88 .hw_rev = ATH11K_HW_IPQ5018_HW10,
89 @@ -688,6 +695,7 @@ static const struct ath11k_hw_params ath
90 .tx_ring_size = DP_TCL_DATA_RING_SIZE,
91 .smp2p_wow_exit = false,
92 .support_fw_mac_sequence = false,
93 + .ftm_responder = true,
94 },
95 };
96
97 --- a/drivers/net/wireless/ath/ath11k/core.h
98 +++ b/drivers/net/wireless/ath/ath11k/core.h
99 @@ -346,6 +346,7 @@ struct ath11k_vif {
100
101 bool is_started;
102 bool is_up;
103 + bool ftm_responder;
104 bool spectral_enabled;
105 bool ps;
106 u32 aid;
107 --- a/drivers/net/wireless/ath/ath11k/hw.h
108 +++ b/drivers/net/wireless/ath/ath11k/hw.h
109 @@ -224,6 +224,7 @@ struct ath11k_hw_params {
110 u32 tx_ring_size;
111 bool smp2p_wow_exit;
112 bool support_fw_mac_sequence;
113 + bool ftm_responder;
114 };
115
116 struct ath11k_hw_ops {
117 --- a/drivers/net/wireless/ath/ath11k/mac.c
118 +++ b/drivers/net/wireless/ath/ath11k/mac.c
119 @@ -3110,7 +3110,7 @@ static void ath11k_mac_op_bss_info_chang
120 u16 bitrate;
121 int ret = 0;
122 u8 rateidx;
123 - u32 rate;
124 + u32 rate, param;
125 u32 ipv4_cnt;
126
127 mutex_lock(&ar->conf_mutex);
128 @@ -3412,6 +3412,20 @@ static void ath11k_mac_op_bss_info_chang
129 }
130 }
131
132 + if (changed & BSS_CHANGED_FTM_RESPONDER &&
133 + arvif->ftm_responder != info->ftm_responder &&
134 + ar->ab->hw_params.ftm_responder &&
135 + (vif->type == NL80211_IFTYPE_AP ||
136 + vif->type == NL80211_IFTYPE_MESH_POINT)) {
137 + arvif->ftm_responder = info->ftm_responder;
138 + param = WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE;
139 + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param,
140 + arvif->ftm_responder);
141 + if (ret)
142 + ath11k_warn(ar->ab, "Failed to set ftm responder %i: %d\n",
143 + arvif->vdev_id, ret);
144 + }
145 +
146 if (changed & BSS_CHANGED_FILS_DISCOVERY ||
147 changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP)
148 ath11k_mac_fils_discovery(arvif, info);
149 @@ -9113,6 +9127,10 @@ static int __ath11k_mac_register(struct
150 wiphy_ext_feature_set(ar->hw->wiphy,
151 NL80211_EXT_FEATURE_SET_SCAN_DWELL);
152
153 + if (ab->hw_params.ftm_responder)
154 + wiphy_ext_feature_set(ar->hw->wiphy,
155 + NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER);
156 +
157 ath11k_reg_init(ar);
158
159 if (!test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) {
160 --- a/drivers/net/wireless/ath/ath11k/wmi.h
161 +++ b/drivers/net/wireless/ath/ath11k/wmi.h
162 @@ -1073,6 +1073,7 @@ enum wmi_tlv_vdev_param {
163 WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
164 WMI_VDEV_PARAM_FILS_MAX_CHANNEL_GUARD_TIME,
165 WMI_VDEV_PARAM_HE_LTF = 0x74,
166 + WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE = 0x7d,
167 WMI_VDEV_PARAM_BA_MODE = 0x7e,
168 WMI_VDEV_PARAM_AUTORATE_MISC_CFG = 0x80,
169 WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE = 0x87,