mac80211: ath11k: sync with ath-next
[openwrt/staging/pepe2k.git] / package / kernel / mac80211 / patches / ath11k / 0084-wifi-ath11k-Add-HTT-stats-for-PHY-reset-case.patch
1 From 2d4f9093e2d8531ad0a2bb98fe5b36dc8addf2a2 Mon Sep 17 00:00:00 2001
2 From: Nidhi Jain <quic_nidhjain@quicinc.com>
3 Date: Fri, 26 May 2023 12:41:07 +0300
4 Subject: [PATCH] wifi: ath11k: Add HTT stats for PHY reset case
5
6 New HTT stats are added with stats type 37 to
7 provide PHY reset stats and PHY reset counter stats.
8
9 PHY reset stats are used to display the current
10 PHY-related operation information such as band, CCA
11 threshold, current operating channel etc.,
12
13 PHY reset counter stats are used to display the
14 PHY reset counter values like calibration counts,
15 temperature based recalibration counts etc.,
16
17 Usage:
18 echo 37 > /sys/kernel/debug/ieee80211/phyX/ath11k/htt_stats_type
19 cat /sys/kernel/debug/ieee80211/phyx/ath11k/htt_stats
20
21 Output:
22
23 HTT_PHY_RESET_STATS_TLV:
24 pdev_id = 0
25 chan_mhz = 5180
26 chan_band_center_freq1 = 5210
27 chan_band_center_freq2 = 0
28 chan_phy_mode = 18
29 chan_flags = 0x8
30 chan_num = 36
31 reset_cause = 0x50000
32 prev_reset_cause = 0x50000
33 phy_warm_reset_src = 0x0
34 rx_gain_tbl_mode = 0
35 xbar_val = 0xfac688
36 force_calibration = 0
37 phyrf_mode = 0
38 phy_homechan = 0
39 phy_tx_ch_mask = 0x3
40 phy_rx_ch_mask = 0x3
41 phybb_ini_mask = 0x5
42 phyrf_ini_mask = 0x0
43 phy_dfs_en_mask = 0x0
44 phy_sscan_en_mask = 0x0
45 phy_synth_sel_mask = 0x0
46 phy_adfs_freq = 0
47 cck_fir_settings = 0x0
48 phy_dyn_pri_chan = 6
49 cca_thresh = 0x26232020
50 dyn_cca_status = 0
51 rxdesense_thresh_hw = 0xcfe0afe
52 rxdesense_thresh_sw = 0xcfe0afe
53
54 HTT_PHY_RESET_COUNTERS_TLV:
55 pdev_id = 0
56 cf_active_low_fail_cnt = 0
57 cf_active_low_pass_cnt = 0
58 phy_off_through_vreg_cnt = 0
59 force_calibration_cnt = 0
60 rf_mode_switch_phy_off_cnt = 0
61
62 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
63
64 Signed-off-by: Nidhi Jain <quic_nidhjain@quicinc.com>
65 Signed-off-by: Maharaja Kennadyrajan <quic_mkenna@quicinc.com>
66 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
67 Link: https://lore.kernel.org/r/20230517141242.2754293-1-quic_mkenna@quicinc.com
68 ---
69 .../wireless/ath/ath11k/debugfs_htt_stats.c | 114 ++++++++++++++++++
70 .../wireless/ath/ath11k/debugfs_htt_stats.h | 43 +++++++
71 2 files changed, 157 insertions(+)
72
73 --- a/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c
74 +++ b/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c
75 @@ -4011,6 +4011,114 @@ void htt_print_phy_stats_tlv(const void
76 stats_req->buf_len = len;
77 }
78
79 +static inline void
80 +htt_print_phy_reset_counters_tlv(const void *tag_buf,
81 + u16 tag_len,
82 + struct debug_htt_stats_req *stats_req)
83 +{
84 + const struct htt_phy_reset_counters_tlv *htt_stats_buf = tag_buf;
85 + u8 *buf = stats_req->buf;
86 + u32 len = stats_req->buf_len;
87 + u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
88 +
89 + if (tag_len < sizeof(*htt_stats_buf))
90 + return;
91 +
92 + len += scnprintf(buf + len, buf_len - len, "HTT_PHY_RESET_COUNTERS_TLV:\n");
93 +
94 + len += scnprintf(buf + len, buf_len - len, "pdev_id = %u\n",
95 + htt_stats_buf->pdev_id);
96 + len += scnprintf(buf + len, buf_len - len, "cf_active_low_fail_cnt = %u\n",
97 + htt_stats_buf->cf_active_low_fail_cnt);
98 + len += scnprintf(buf + len, buf_len - len, "cf_active_low_pass_cnt = %u\n",
99 + htt_stats_buf->cf_active_low_pass_cnt);
100 + len += scnprintf(buf + len, buf_len - len, "phy_off_through_vreg_cnt = %u\n",
101 + htt_stats_buf->phy_off_through_vreg_cnt);
102 + len += scnprintf(buf + len, buf_len - len, "force_calibration_cnt = %u\n",
103 + htt_stats_buf->force_calibration_cnt);
104 + len += scnprintf(buf + len, buf_len - len, "rf_mode_switch_phy_off_cnt = %u\n",
105 + htt_stats_buf->rf_mode_switch_phy_off_cnt);
106 +
107 + stats_req->buf_len = len;
108 +}
109 +
110 +static inline void
111 +htt_print_phy_reset_stats_tlv(const void *tag_buf,
112 + u16 tag_len,
113 + struct debug_htt_stats_req *stats_req)
114 +{
115 + const struct htt_phy_reset_stats_tlv *htt_stats_buf = tag_buf;
116 + u8 *buf = stats_req->buf;
117 + u32 len = stats_req->buf_len;
118 + u32 buf_len = ATH11K_HTT_STATS_BUF_SIZE;
119 +
120 + if (tag_len < sizeof(*htt_stats_buf))
121 + return;
122 +
123 + len += scnprintf(buf + len, buf_len - len, "HTT_PHY_RESET_STATS_TLV:\n");
124 +
125 + len += scnprintf(buf + len, buf_len - len, "pdev_id = %u\n",
126 + htt_stats_buf->pdev_id);
127 + len += scnprintf(buf + len, buf_len - len, "chan_mhz = %u\n",
128 + htt_stats_buf->chan_mhz);
129 + len += scnprintf(buf + len, buf_len - len, "chan_band_center_freq1 = %u\n",
130 + htt_stats_buf->chan_band_center_freq1);
131 + len += scnprintf(buf + len, buf_len - len, "chan_band_center_freq2 = %u\n",
132 + htt_stats_buf->chan_band_center_freq2);
133 + len += scnprintf(buf + len, buf_len - len, "chan_phy_mode = %u\n",
134 + htt_stats_buf->chan_phy_mode);
135 + len += scnprintf(buf + len, buf_len - len, "chan_flags = 0x%0x\n",
136 + htt_stats_buf->chan_flags);
137 + len += scnprintf(buf + len, buf_len - len, "chan_num = %u\n",
138 + htt_stats_buf->chan_num);
139 + len += scnprintf(buf + len, buf_len - len, "reset_cause = 0x%0x\n",
140 + htt_stats_buf->reset_cause);
141 + len += scnprintf(buf + len, buf_len - len, "prev_reset_cause = 0x%0x\n",
142 + htt_stats_buf->prev_reset_cause);
143 + len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_src = 0x%0x\n",
144 + htt_stats_buf->phy_warm_reset_src);
145 + len += scnprintf(buf + len, buf_len - len, "rx_gain_tbl_mode = %d\n",
146 + htt_stats_buf->rx_gain_tbl_mode);
147 + len += scnprintf(buf + len, buf_len - len, "xbar_val = 0x%0x\n",
148 + htt_stats_buf->xbar_val);
149 + len += scnprintf(buf + len, buf_len - len, "force_calibration = %u\n",
150 + htt_stats_buf->force_calibration);
151 + len += scnprintf(buf + len, buf_len - len, "phyrf_mode = %u\n",
152 + htt_stats_buf->phyrf_mode);
153 + len += scnprintf(buf + len, buf_len - len, "phy_homechan = %u\n",
154 + htt_stats_buf->phy_homechan);
155 + len += scnprintf(buf + len, buf_len - len, "phy_tx_ch_mask = 0x%0x\n",
156 + htt_stats_buf->phy_tx_ch_mask);
157 + len += scnprintf(buf + len, buf_len - len, "phy_rx_ch_mask = 0x%0x\n",
158 + htt_stats_buf->phy_rx_ch_mask);
159 + len += scnprintf(buf + len, buf_len - len, "phybb_ini_mask = 0x%0x\n",
160 + htt_stats_buf->phybb_ini_mask);
161 + len += scnprintf(buf + len, buf_len - len, "phyrf_ini_mask = 0x%0x\n",
162 + htt_stats_buf->phyrf_ini_mask);
163 + len += scnprintf(buf + len, buf_len - len, "phy_dfs_en_mask = 0x%0x\n",
164 + htt_stats_buf->phy_dfs_en_mask);
165 + len += scnprintf(buf + len, buf_len - len, "phy_sscan_en_mask = 0x%0x\n",
166 + htt_stats_buf->phy_sscan_en_mask);
167 + len += scnprintf(buf + len, buf_len - len, "phy_synth_sel_mask = 0x%0x\n",
168 + htt_stats_buf->phy_synth_sel_mask);
169 + len += scnprintf(buf + len, buf_len - len, "phy_adfs_freq = %u\n",
170 + htt_stats_buf->phy_adfs_freq);
171 + len += scnprintf(buf + len, buf_len - len, "cck_fir_settings = 0x%0x\n",
172 + htt_stats_buf->cck_fir_settings);
173 + len += scnprintf(buf + len, buf_len - len, "phy_dyn_pri_chan = %u\n",
174 + htt_stats_buf->phy_dyn_pri_chan);
175 + len += scnprintf(buf + len, buf_len - len, "cca_thresh = 0x%0x\n",
176 + htt_stats_buf->cca_thresh);
177 + len += scnprintf(buf + len, buf_len - len, "dyn_cca_status = %u\n",
178 + htt_stats_buf->dyn_cca_status);
179 + len += scnprintf(buf + len, buf_len - len, "rxdesense_thresh_hw = 0x%x\n",
180 + htt_stats_buf->rxdesense_thresh_hw);
181 + len += scnprintf(buf + len, buf_len - len, "rxdesense_thresh_sw = 0x%x\n",
182 + htt_stats_buf->rxdesense_thresh_sw);
183 +
184 + stats_req->buf_len = len;
185 +}
186 +
187 static inline
188 void htt_print_peer_ctrl_path_txrx_stats_tlv(const void *tag_buf,
189 struct debug_htt_stats_req *stats_req)
190 @@ -4425,6 +4533,12 @@ static int ath11k_dbg_htt_ext_stats_pars
191 case HTT_STATS_PHY_STATS_TAG:
192 htt_print_phy_stats_tlv(tag_buf, stats_req);
193 break;
194 + case HTT_STATS_PHY_RESET_COUNTERS_TAG:
195 + htt_print_phy_reset_counters_tlv(tag_buf, len, stats_req);
196 + break;
197 + case HTT_STATS_PHY_RESET_STATS_TAG:
198 + htt_print_phy_reset_stats_tlv(tag_buf, len, stats_req);
199 + break;
200 case HTT_STATS_PEER_CTRL_PATH_TXRX_STATS_TAG:
201 htt_print_peer_ctrl_path_txrx_stats_tlv(tag_buf, stats_req);
202 break;
203 --- a/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.h
204 +++ b/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.h
205 @@ -111,6 +111,8 @@ enum htt_tlv_tag_t {
206 HTT_STATS_TXBF_OFDMA_STEER_STATS_TAG = 116,
207 HTT_STATS_PHY_COUNTERS_TAG = 121,
208 HTT_STATS_PHY_STATS_TAG = 122,
209 + HTT_STATS_PHY_RESET_COUNTERS_TAG = 123,
210 + HTT_STATS_PHY_RESET_STATS_TAG = 124,
211
212 HTT_STATS_MAX_TAG,
213 };
214 @@ -1964,6 +1966,47 @@ struct htt_phy_stats_tlv {
215 u32 fw_run_time;
216 };
217
218 +struct htt_phy_reset_counters_tlv {
219 + u32 pdev_id;
220 + u32 cf_active_low_fail_cnt;
221 + u32 cf_active_low_pass_cnt;
222 + u32 phy_off_through_vreg_cnt;
223 + u32 force_calibration_cnt;
224 + u32 rf_mode_switch_phy_off_cnt;
225 +};
226 +
227 +struct htt_phy_reset_stats_tlv {
228 + u32 pdev_id;
229 + u32 chan_mhz;
230 + u32 chan_band_center_freq1;
231 + u32 chan_band_center_freq2;
232 + u32 chan_phy_mode;
233 + u32 chan_flags;
234 + u32 chan_num;
235 + u32 reset_cause;
236 + u32 prev_reset_cause;
237 + u32 phy_warm_reset_src;
238 + u32 rx_gain_tbl_mode;
239 + u32 xbar_val;
240 + u32 force_calibration;
241 + u32 phyrf_mode;
242 + u32 phy_homechan;
243 + u32 phy_tx_ch_mask;
244 + u32 phy_rx_ch_mask;
245 + u32 phybb_ini_mask;
246 + u32 phyrf_ini_mask;
247 + u32 phy_dfs_en_mask;
248 + u32 phy_sscan_en_mask;
249 + u32 phy_synth_sel_mask;
250 + u32 phy_adfs_freq;
251 + u32 cck_fir_settings;
252 + u32 phy_dyn_pri_chan;
253 + u32 cca_thresh;
254 + u32 dyn_cca_status;
255 + u32 rxdesense_thresh_hw;
256 + u32 rxdesense_thresh_sw;
257 +};
258 +
259 struct htt_peer_ctrl_path_txrx_stats_tlv {
260 /* peer mac address */
261 u8 peer_mac_addr[ETH_ALEN];