1 // SPDX-License-Identifier: BSD-3-Clause-Clear
2 /*
3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
5 */
6
7 #include <linux/vmalloc.h>
8 #include "core.h"
9 #include "debug.h"
10 #include "debugfs_htt_stats.h"
11 #include "dp_tx.h"
12 #include "dp_rx.h"
13
14 static u32
print_array_to_buf_index(u8 * buf,u32 offset,const char * header,u32 stats_index,const __le32 * array,u32 array_len,const char * footer)15 print_array_to_buf_index(u8 *buf, u32 offset, const char *header, u32 stats_index,
16 const __le32 *array, u32 array_len, const char *footer)
17 {
18 int index = 0;
19 u8 i;
20
21 if (header) {
22 index += scnprintf(buf + offset,
23 ATH12K_HTT_STATS_BUF_SIZE - offset,
24 "%s = ", header);
25 }
26 for (i = 0; i < array_len; i++) {
27 index += scnprintf(buf + offset + index,
28 (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
29 " %u:%u,", stats_index++, le32_to_cpu(array[i]));
30 }
31 /* To overwrite the last trailing comma */
32 index--;
33 *(buf + offset + index) = '\0';
34
35 if (footer) {
36 index += scnprintf(buf + offset + index,
37 (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
38 "%s", footer);
39 }
40 return index;
41 }
42
43 static u32
print_array_to_buf(u8 * buf,u32 offset,const char * header,const __le32 * array,u32 array_len,const char * footer)44 print_array_to_buf(u8 *buf, u32 offset, const char *header,
45 const __le32 *array, u32 array_len, const char *footer)
46 {
47 return print_array_to_buf_index(buf, offset, header, 0, array, array_len,
48 footer);
49 }
50
51 static u32
print_array_to_buf_s8(u8 * buf,u32 offset,const char * header,u32 stats_index,const s8 * array,u32 array_len,const char * footer)52 print_array_to_buf_s8(u8 *buf, u32 offset, const char *header, u32 stats_index,
53 const s8 *array, u32 array_len, const char *footer)
54 {
55 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
56 int index = 0;
57 u8 i;
58
59 if (header)
60 index += scnprintf(buf + offset, buf_len - offset, "%s = ", header);
61
62 for (i = 0; i < array_len; i++) {
63 index += scnprintf(buf + offset + index, (buf_len - offset) - index,
64 " %u:%d,", stats_index++, array[i]);
65 }
66
67 index--;
68 if ((offset + index) < buf_len)
69 buf[offset + index] = '\0';
70
71 if (footer) {
72 index += scnprintf(buf + offset + index, (buf_len - offset) - index,
73 "%s", footer);
74 }
75
76 return index;
77 }
78
ath12k_htt_ax_tx_rx_ru_size_to_str(u8 ru_size)79 static const char *ath12k_htt_ax_tx_rx_ru_size_to_str(u8 ru_size)
80 {
81 switch (ru_size) {
82 case ATH12K_HTT_TX_RX_PDEV_STATS_AX_RU_SIZE_26:
83 return "26";
84 case ATH12K_HTT_TX_RX_PDEV_STATS_AX_RU_SIZE_52:
85 return "52";
86 case ATH12K_HTT_TX_RX_PDEV_STATS_AX_RU_SIZE_106:
87 return "106";
88 case ATH12K_HTT_TX_RX_PDEV_STATS_AX_RU_SIZE_242:
89 return "242";
90 case ATH12K_HTT_TX_RX_PDEV_STATS_AX_RU_SIZE_484:
91 return "484";
92 case ATH12K_HTT_TX_RX_PDEV_STATS_AX_RU_SIZE_996:
93 return "996";
94 case ATH12K_HTT_TX_RX_PDEV_STATS_AX_RU_SIZE_996x2:
95 return "996x2";
96 default:
97 return "unknown";
98 }
99 }
100
ath12k_htt_be_tx_rx_ru_size_to_str(u8 ru_size)101 static const char *ath12k_htt_be_tx_rx_ru_size_to_str(u8 ru_size)
102 {
103 switch (ru_size) {
104 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_26:
105 return "26";
106 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_52:
107 return "52";
108 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_52_26:
109 return "52+26";
110 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_106:
111 return "106";
112 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_106_26:
113 return "106+26";
114 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_242:
115 return "242";
116 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_484:
117 return "484";
118 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_484_242:
119 return "484+242";
120 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996:
121 return "996";
122 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996_484:
123 return "996+484";
124 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996_484_242:
125 return "996+484+242";
126 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996x2:
127 return "996x2";
128 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996x2_484:
129 return "996x2+484";
130 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996x3:
131 return "996x3";
132 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996x3_484:
133 return "996x3+484";
134 case ATH12K_HTT_TX_RX_PDEV_STATS_BE_RU_SIZE_996x4:
135 return "996x4";
136 default:
137 return "unknown";
138 }
139 }
140
141 static const char*
ath12k_tx_ru_size_to_str(enum ath12k_htt_stats_ru_type ru_type,u8 ru_size)142 ath12k_tx_ru_size_to_str(enum ath12k_htt_stats_ru_type ru_type, u8 ru_size)
143 {
144 if (ru_type == ATH12K_HTT_STATS_RU_TYPE_SINGLE_RU_ONLY)
145 return ath12k_htt_ax_tx_rx_ru_size_to_str(ru_size);
146 else if (ru_type == ATH12K_HTT_STATS_RU_TYPE_SINGLE_AND_MULTI_RU)
147 return ath12k_htt_be_tx_rx_ru_size_to_str(ru_size);
148 else
149 return "unknown";
150 }
151
152 static void
htt_print_tx_pdev_stats_cmn_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)153 htt_print_tx_pdev_stats_cmn_tlv(const void *tag_buf, u16 tag_len,
154 struct debug_htt_stats_req *stats_req)
155 {
156 const struct ath12k_htt_tx_pdev_stats_cmn_tlv *htt_stats_buf = tag_buf;
157 u8 *buf = stats_req->buf;
158 u32 len = stats_req->buf_len;
159 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
160 u32 mac_id_word;
161
162 if (tag_len < sizeof(*htt_stats_buf))
163 return;
164
165 mac_id_word = le32_to_cpu(htt_stats_buf->mac_id__word);
166
167 len += scnprintf(buf + len, buf_len - len, "HTT_TX_PDEV_STATS_CMN_TLV:\n");
168 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
169 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
170 len += scnprintf(buf + len, buf_len - len, "comp_delivered = %u\n",
171 le32_to_cpu(htt_stats_buf->comp_delivered));
172 len += scnprintf(buf + len, buf_len - len, "self_triggers = %u\n",
173 le32_to_cpu(htt_stats_buf->self_triggers));
174 len += scnprintf(buf + len, buf_len - len, "hw_queued = %u\n",
175 le32_to_cpu(htt_stats_buf->hw_queued));
176 len += scnprintf(buf + len, buf_len - len, "hw_reaped = %u\n",
177 le32_to_cpu(htt_stats_buf->hw_reaped));
178 len += scnprintf(buf + len, buf_len - len, "underrun = %u\n",
179 le32_to_cpu(htt_stats_buf->underrun));
180 len += scnprintf(buf + len, buf_len - len, "hw_paused = %u\n",
181 le32_to_cpu(htt_stats_buf->hw_paused));
182 len += scnprintf(buf + len, buf_len - len, "hw_flush = %u\n",
183 le32_to_cpu(htt_stats_buf->hw_flush));
184 len += scnprintf(buf + len, buf_len - len, "hw_filt = %u\n",
185 le32_to_cpu(htt_stats_buf->hw_filt));
186 len += scnprintf(buf + len, buf_len - len, "tx_abort = %u\n",
187 le32_to_cpu(htt_stats_buf->tx_abort));
188 len += scnprintf(buf + len, buf_len - len, "ppdu_ok = %u\n",
189 le32_to_cpu(htt_stats_buf->ppdu_ok));
190 len += scnprintf(buf + len, buf_len - len, "mpdu_requeued = %u\n",
191 le32_to_cpu(htt_stats_buf->mpdu_requed));
192 len += scnprintf(buf + len, buf_len - len, "tx_xretry = %u\n",
193 le32_to_cpu(htt_stats_buf->tx_xretry));
194 len += scnprintf(buf + len, buf_len - len, "data_rc = %u\n",
195 le32_to_cpu(htt_stats_buf->data_rc));
196 len += scnprintf(buf + len, buf_len - len, "mpdu_dropped_xretry = %u\n",
197 le32_to_cpu(htt_stats_buf->mpdu_dropped_xretry));
198 len += scnprintf(buf + len, buf_len - len, "illegal_rate_phy_err = %u\n",
199 le32_to_cpu(htt_stats_buf->illgl_rate_phy_err));
200 len += scnprintf(buf + len, buf_len - len, "cont_xretry = %u\n",
201 le32_to_cpu(htt_stats_buf->cont_xretry));
202 len += scnprintf(buf + len, buf_len - len, "tx_timeout = %u\n",
203 le32_to_cpu(htt_stats_buf->tx_timeout));
204 len += scnprintf(buf + len, buf_len - len, "tx_time_dur_data = %u\n",
205 le32_to_cpu(htt_stats_buf->tx_time_dur_data));
206 len += scnprintf(buf + len, buf_len - len, "pdev_resets = %u\n",
207 le32_to_cpu(htt_stats_buf->pdev_resets));
208 len += scnprintf(buf + len, buf_len - len, "phy_underrun = %u\n",
209 le32_to_cpu(htt_stats_buf->phy_underrun));
210 len += scnprintf(buf + len, buf_len - len, "txop_ovf = %u\n",
211 le32_to_cpu(htt_stats_buf->txop_ovf));
212 len += scnprintf(buf + len, buf_len - len, "seq_posted = %u\n",
213 le32_to_cpu(htt_stats_buf->seq_posted));
214 len += scnprintf(buf + len, buf_len - len, "seq_failed_queueing = %u\n",
215 le32_to_cpu(htt_stats_buf->seq_failed_queueing));
216 len += scnprintf(buf + len, buf_len - len, "seq_completed = %u\n",
217 le32_to_cpu(htt_stats_buf->seq_completed));
218 len += scnprintf(buf + len, buf_len - len, "seq_restarted = %u\n",
219 le32_to_cpu(htt_stats_buf->seq_restarted));
220 len += scnprintf(buf + len, buf_len - len, "seq_txop_repost_stop = %u\n",
221 le32_to_cpu(htt_stats_buf->seq_txop_repost_stop));
222 len += scnprintf(buf + len, buf_len - len, "next_seq_cancel = %u\n",
223 le32_to_cpu(htt_stats_buf->next_seq_cancel));
224 len += scnprintf(buf + len, buf_len - len, "dl_mu_mimo_seq_posted = %u\n",
225 le32_to_cpu(htt_stats_buf->mu_seq_posted));
226 len += scnprintf(buf + len, buf_len - len, "dl_mu_ofdma_seq_posted = %u\n",
227 le32_to_cpu(htt_stats_buf->mu_ofdma_seq_posted));
228 len += scnprintf(buf + len, buf_len - len, "ul_mu_mimo_seq_posted = %u\n",
229 le32_to_cpu(htt_stats_buf->ul_mumimo_seq_posted));
230 len += scnprintf(buf + len, buf_len - len, "ul_mu_ofdma_seq_posted = %u\n",
231 le32_to_cpu(htt_stats_buf->ul_ofdma_seq_posted));
232 len += scnprintf(buf + len, buf_len - len, "mu_mimo_peer_blacklisted = %u\n",
233 le32_to_cpu(htt_stats_buf->num_mu_peer_blacklisted));
234 len += scnprintf(buf + len, buf_len - len, "seq_qdepth_repost_stop = %u\n",
235 le32_to_cpu(htt_stats_buf->seq_qdepth_repost_stop));
236 len += scnprintf(buf + len, buf_len - len, "seq_min_msdu_repost_stop = %u\n",
237 le32_to_cpu(htt_stats_buf->seq_min_msdu_repost_stop));
238 len += scnprintf(buf + len, buf_len - len, "mu_seq_min_msdu_repost_stop = %u\n",
239 le32_to_cpu(htt_stats_buf->mu_seq_min_msdu_repost_stop));
240 len += scnprintf(buf + len, buf_len - len, "seq_switch_hw_paused = %u\n",
241 le32_to_cpu(htt_stats_buf->seq_switch_hw_paused));
242 len += scnprintf(buf + len, buf_len - len, "next_seq_posted_dsr = %u\n",
243 le32_to_cpu(htt_stats_buf->next_seq_posted_dsr));
244 len += scnprintf(buf + len, buf_len - len, "seq_posted_isr = %u\n",
245 le32_to_cpu(htt_stats_buf->seq_posted_isr));
246 len += scnprintf(buf + len, buf_len - len, "seq_ctrl_cached = %u\n",
247 le32_to_cpu(htt_stats_buf->seq_ctrl_cached));
248 len += scnprintf(buf + len, buf_len - len, "mpdu_count_tqm = %u\n",
249 le32_to_cpu(htt_stats_buf->mpdu_count_tqm));
250 len += scnprintf(buf + len, buf_len - len, "msdu_count_tqm = %u\n",
251 le32_to_cpu(htt_stats_buf->msdu_count_tqm));
252 len += scnprintf(buf + len, buf_len - len, "mpdu_removed_tqm = %u\n",
253 le32_to_cpu(htt_stats_buf->mpdu_removed_tqm));
254 len += scnprintf(buf + len, buf_len - len, "msdu_removed_tqm = %u\n",
255 le32_to_cpu(htt_stats_buf->msdu_removed_tqm));
256 len += scnprintf(buf + len, buf_len - len, "remove_mpdus_max_retries = %u\n",
257 le32_to_cpu(htt_stats_buf->remove_mpdus_max_retries));
258 len += scnprintf(buf + len, buf_len - len, "mpdus_sw_flush = %u\n",
259 le32_to_cpu(htt_stats_buf->mpdus_sw_flush));
260 len += scnprintf(buf + len, buf_len - len, "mpdus_hw_filter = %u\n",
261 le32_to_cpu(htt_stats_buf->mpdus_hw_filter));
262 len += scnprintf(buf + len, buf_len - len, "mpdus_truncated = %u\n",
263 le32_to_cpu(htt_stats_buf->mpdus_truncated));
264 len += scnprintf(buf + len, buf_len - len, "mpdus_ack_failed = %u\n",
265 le32_to_cpu(htt_stats_buf->mpdus_ack_failed));
266 len += scnprintf(buf + len, buf_len - len, "mpdus_expired = %u\n",
267 le32_to_cpu(htt_stats_buf->mpdus_expired));
268 len += scnprintf(buf + len, buf_len - len, "mpdus_seq_hw_retry = %u\n",
269 le32_to_cpu(htt_stats_buf->mpdus_seq_hw_retry));
270 len += scnprintf(buf + len, buf_len - len, "ack_tlv_proc = %u\n",
271 le32_to_cpu(htt_stats_buf->ack_tlv_proc));
272 len += scnprintf(buf + len, buf_len - len, "coex_abort_mpdu_cnt_valid = %u\n",
273 le32_to_cpu(htt_stats_buf->coex_abort_mpdu_cnt_valid));
274 len += scnprintf(buf + len, buf_len - len, "coex_abort_mpdu_cnt = %u\n",
275 le32_to_cpu(htt_stats_buf->coex_abort_mpdu_cnt));
276 len += scnprintf(buf + len, buf_len - len, "num_total_ppdus_tried_ota = %u\n",
277 le32_to_cpu(htt_stats_buf->num_total_ppdus_tried_ota));
278 len += scnprintf(buf + len, buf_len - len, "num_data_ppdus_tried_ota = %u\n",
279 le32_to_cpu(htt_stats_buf->num_data_ppdus_tried_ota));
280 len += scnprintf(buf + len, buf_len - len, "local_ctrl_mgmt_enqued = %u\n",
281 le32_to_cpu(htt_stats_buf->local_ctrl_mgmt_enqued));
282 len += scnprintf(buf + len, buf_len - len, "local_ctrl_mgmt_freed = %u\n",
283 le32_to_cpu(htt_stats_buf->local_ctrl_mgmt_freed));
284 len += scnprintf(buf + len, buf_len - len, "local_data_enqued = %u\n",
285 le32_to_cpu(htt_stats_buf->local_data_enqued));
286 len += scnprintf(buf + len, buf_len - len, "local_data_freed = %u\n",
287 le32_to_cpu(htt_stats_buf->local_data_freed));
288 len += scnprintf(buf + len, buf_len - len, "mpdu_tried = %u\n",
289 le32_to_cpu(htt_stats_buf->mpdu_tried));
290 len += scnprintf(buf + len, buf_len - len, "isr_wait_seq_posted = %u\n",
291 le32_to_cpu(htt_stats_buf->isr_wait_seq_posted));
292 len += scnprintf(buf + len, buf_len - len, "tx_active_dur_us_low = %u\n",
293 le32_to_cpu(htt_stats_buf->tx_active_dur_us_low));
294 len += scnprintf(buf + len, buf_len - len, "tx_active_dur_us_high = %u\n",
295 le32_to_cpu(htt_stats_buf->tx_active_dur_us_high));
296 len += scnprintf(buf + len, buf_len - len, "fes_offsets_err_cnt = %u\n\n",
297 le32_to_cpu(htt_stats_buf->fes_offsets_err_cnt));
298
299 stats_req->buf_len = len;
300 }
301
302 static void
htt_print_tx_pdev_stats_urrn_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)303 htt_print_tx_pdev_stats_urrn_tlv(const void *tag_buf,
304 u16 tag_len,
305 struct debug_htt_stats_req *stats_req)
306 {
307 const struct ath12k_htt_tx_pdev_stats_urrn_tlv *htt_stats_buf = tag_buf;
308 u8 *buf = stats_req->buf;
309 u32 len = stats_req->buf_len;
310 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
311 u16 num_elems = min_t(u16, (tag_len >> 2),
312 HTT_TX_PDEV_MAX_URRN_STATS);
313
314 len += scnprintf(buf + len, buf_len - len,
315 "HTT_TX_PDEV_STATS_URRN_TLV:\n");
316
317 len += print_array_to_buf(buf, len, "urrn_stats", htt_stats_buf->urrn_stats,
318 num_elems, "\n\n");
319
320 stats_req->buf_len = len;
321 }
322
323 static void
htt_print_tx_pdev_stats_flush_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)324 htt_print_tx_pdev_stats_flush_tlv(const void *tag_buf,
325 u16 tag_len,
326 struct debug_htt_stats_req *stats_req)
327 {
328 const struct ath12k_htt_tx_pdev_stats_flush_tlv *htt_stats_buf = tag_buf;
329 u8 *buf = stats_req->buf;
330 u32 len = stats_req->buf_len;
331 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
332 u16 num_elems = min_t(u16, (tag_len >> 2),
333 ATH12K_HTT_TX_PDEV_MAX_FLUSH_REASON_STATS);
334
335 len += scnprintf(buf + len, buf_len - len,
336 "HTT_TX_PDEV_STATS_FLUSH_TLV:\n");
337
338 len += print_array_to_buf(buf, len, "flush_errs", htt_stats_buf->flush_errs,
339 num_elems, "\n\n");
340
341 stats_req->buf_len = len;
342 }
343
344 static void
htt_print_tx_pdev_stats_sifs_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)345 htt_print_tx_pdev_stats_sifs_tlv(const void *tag_buf,
346 u16 tag_len,
347 struct debug_htt_stats_req *stats_req)
348 {
349 const struct ath12k_htt_tx_pdev_stats_sifs_tlv *htt_stats_buf = tag_buf;
350 u8 *buf = stats_req->buf;
351 u32 len = stats_req->buf_len;
352 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
353 u16 num_elems = min_t(u16, (tag_len >> 2),
354 ATH12K_HTT_TX_PDEV_MAX_SIFS_BURST_STATS);
355
356 len += scnprintf(buf + len, buf_len - len,
357 "HTT_TX_PDEV_STATS_SIFS_TLV:\n");
358
359 len += print_array_to_buf(buf, len, "sifs_status", htt_stats_buf->sifs_status,
360 num_elems, "\n\n");
361
362 stats_req->buf_len = len;
363 }
364
365 static void
htt_print_tx_pdev_mu_ppdu_dist_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)366 htt_print_tx_pdev_mu_ppdu_dist_stats_tlv(const void *tag_buf, u16 tag_len,
367 struct debug_htt_stats_req *stats_req)
368 {
369 const struct ath12k_htt_tx_pdev_mu_ppdu_dist_stats_tlv *htt_stats_buf = tag_buf;
370 char *mode;
371 u8 j, hw_mode, i, str_buf_len;
372 u8 *buf = stats_req->buf;
373 u32 len = stats_req->buf_len;
374 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
375 u32 stats_value;
376 u8 max_ppdu = ATH12K_HTT_STATS_MAX_NUM_MU_PPDU_PER_BURST;
377 u8 max_sched = ATH12K_HTT_STATS_MAX_NUM_SCHED_STATUS;
378 char str_buf[ATH12K_HTT_MAX_STRING_LEN];
379
380 if (tag_len < sizeof(*htt_stats_buf))
381 return;
382
383 hw_mode = le32_to_cpu(htt_stats_buf->hw_mode);
384
385 switch (hw_mode) {
386 case ATH12K_HTT_STATS_HWMODE_AC:
387 len += scnprintf(buf + len, buf_len - len,
388 "HTT_TX_PDEV_AC_MU_PPDU_DISTRIBUTION_STATS:\n");
389 mode = "ac";
390 break;
391 case ATH12K_HTT_STATS_HWMODE_AX:
392 len += scnprintf(buf + len, buf_len - len,
393 "HTT_TX_PDEV_AX_MU_PPDU_DISTRIBUTION_STATS:\n");
394 mode = "ax";
395 break;
396 case ATH12K_HTT_STATS_HWMODE_BE:
397 len += scnprintf(buf + len, buf_len - len,
398 "HTT_TX_PDEV_BE_MU_PPDU_DISTRIBUTION_STATS:\n");
399 mode = "be";
400 break;
401 default:
402 return;
403 }
404
405 for (i = 0; i < ATH12K_HTT_STATS_NUM_NR_BINS ; i++) {
406 len += scnprintf(buf + len, buf_len - len,
407 "%s_mu_mimo_num_seq_posted_nr%u = %u\n", mode,
408 ((i + 1) * 4), htt_stats_buf->num_seq_posted[i]);
409 str_buf_len = 0;
410 memset(str_buf, 0x0, sizeof(str_buf));
411 for (j = 0; j < ATH12K_HTT_STATS_MAX_NUM_MU_PPDU_PER_BURST ; j++) {
412 stats_value = le32_to_cpu(htt_stats_buf->num_ppdu_posted_per_burst
413 [i * max_ppdu + j]);
414 str_buf_len += scnprintf(&str_buf[str_buf_len],
415 ATH12K_HTT_MAX_STRING_LEN - str_buf_len,
416 " %u:%u,", j, stats_value);
417 }
418 /* To overwrite the last trailing comma */
419 str_buf[str_buf_len - 1] = '\0';
420 len += scnprintf(buf + len, buf_len - len,
421 "%s_mu_mimo_num_ppdu_posted_per_burst_nr%u = %s\n",
422 mode, ((i + 1) * 4), str_buf);
423 str_buf_len = 0;
424 memset(str_buf, 0x0, sizeof(str_buf));
425 for (j = 0; j < ATH12K_HTT_STATS_MAX_NUM_MU_PPDU_PER_BURST ; j++) {
426 stats_value = le32_to_cpu(htt_stats_buf->num_ppdu_cmpl_per_burst
427 [i * max_ppdu + j]);
428 str_buf_len += scnprintf(&str_buf[str_buf_len],
429 ATH12K_HTT_MAX_STRING_LEN - str_buf_len,
430 " %u:%u,", j, stats_value);
431 }
432 /* To overwrite the last trailing comma */
433 str_buf[str_buf_len - 1] = '\0';
434 len += scnprintf(buf + len, buf_len - len,
435 "%s_mu_mimo_num_ppdu_completed_per_burst_nr%u = %s\n",
436 mode, ((i + 1) * 4), str_buf);
437 str_buf_len = 0;
438 memset(str_buf, 0x0, sizeof(str_buf));
439 for (j = 0; j < ATH12K_HTT_STATS_MAX_NUM_SCHED_STATUS ; j++) {
440 stats_value = le32_to_cpu(htt_stats_buf->num_seq_term_status
441 [i * max_sched + j]);
442 str_buf_len += scnprintf(&str_buf[str_buf_len],
443 ATH12K_HTT_MAX_STRING_LEN - str_buf_len,
444 " %u:%u,", j, stats_value);
445 }
446 /* To overwrite the last trailing comma */
447 str_buf[str_buf_len - 1] = '\0';
448 len += scnprintf(buf + len, buf_len - len,
449 "%s_mu_mimo_num_seq_term_status_nr%u = %s\n\n",
450 mode, ((i + 1) * 4), str_buf);
451 }
452
453 stats_req->buf_len = len;
454 }
455
456 static void
htt_print_tx_pdev_stats_sifs_hist_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)457 htt_print_tx_pdev_stats_sifs_hist_tlv(const void *tag_buf,
458 u16 tag_len,
459 struct debug_htt_stats_req *stats_req)
460 {
461 const struct ath12k_htt_tx_pdev_stats_sifs_hist_tlv *htt_stats_buf = tag_buf;
462 u8 *buf = stats_req->buf;
463 u32 len = stats_req->buf_len;
464 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
465 u16 num_elems = min_t(u16, (tag_len >> 2),
466 ATH12K_HTT_TX_PDEV_MAX_SIFS_BURST_HIST_STATS);
467
468 len += scnprintf(buf + len, buf_len - len,
469 "HTT_TX_PDEV_STATS_SIFS_HIST_TLV:\n");
470
471 len += print_array_to_buf(buf, len, "sifs_hist_status",
472 htt_stats_buf->sifs_hist_status, num_elems, "\n\n");
473
474 stats_req->buf_len = len;
475 }
476
477 static void
htt_print_pdev_ctrl_path_tx_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)478 htt_print_pdev_ctrl_path_tx_stats_tlv(const void *tag_buf, u16 tag_len,
479 struct debug_htt_stats_req *stats_req)
480 {
481 const struct ath12k_htt_pdev_ctrl_path_tx_stats_tlv *htt_stats_buf = tag_buf;
482 u8 *buf = stats_req->buf;
483 u32 len = stats_req->buf_len;
484 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
485
486 if (len < sizeof(*htt_stats_buf))
487 return;
488
489 len += scnprintf(buf + len, buf_len - len,
490 "HTT_TX_PDEV_STATS_CTRL_PATH_TX_STATS:\n");
491 len += print_array_to_buf(buf, len, "fw_tx_mgmt_subtype",
492 htt_stats_buf->fw_tx_mgmt_subtype,
493 ATH12K_HTT_STATS_SUBTYPE_MAX, "\n\n");
494
495 stats_req->buf_len = len;
496 }
497
498 static void
ath12k_htt_print_stats_tx_sched_cmn_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)499 ath12k_htt_print_stats_tx_sched_cmn_tlv(const void *tag_buf,
500 u16 tag_len,
501 struct debug_htt_stats_req *stats_req)
502 {
503 const struct ath12k_htt_stats_tx_sched_cmn_tlv *htt_stats_buf = tag_buf;
504 u8 *buf = stats_req->buf;
505 u32 len = stats_req->buf_len;
506 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
507 u32 mac_id_word;
508
509 if (tag_len < sizeof(*htt_stats_buf))
510 return;
511
512 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
513
514 len += scnprintf(buf + len, buf_len - len, "HTT_STATS_TX_SCHED_CMN_TLV:\n");
515 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
516 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
517 len += scnprintf(buf + len, buf_len - len, "current_timestamp = %u\n\n",
518 le32_to_cpu(htt_stats_buf->current_timestamp));
519
520 stats_req->buf_len = len;
521 }
522
523 static void
ath12k_htt_print_tx_pdev_stats_sched_per_txq_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)524 ath12k_htt_print_tx_pdev_stats_sched_per_txq_tlv(const void *tag_buf,
525 u16 tag_len,
526 struct debug_htt_stats_req *stats_req)
527 {
528 const struct ath12k_htt_tx_pdev_stats_sched_per_txq_tlv *htt_stats_buf = tag_buf;
529 u8 *buf = stats_req->buf;
530 u32 len = stats_req->buf_len;
531 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
532 u32 mac_id_word;
533
534 if (tag_len < sizeof(*htt_stats_buf))
535 return;
536
537 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
538
539 len += scnprintf(buf + len, buf_len - len,
540 "HTT_TX_PDEV_STATS_SCHED_PER_TXQ_TLV:\n");
541 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
542 u32_get_bits(mac_id_word,
543 ATH12K_HTT_TX_PDEV_STATS_SCHED_PER_TXQ_MAC_ID));
544 len += scnprintf(buf + len, buf_len - len, "txq_id = %u\n",
545 u32_get_bits(mac_id_word,
546 ATH12K_HTT_TX_PDEV_STATS_SCHED_PER_TXQ_ID));
547 len += scnprintf(buf + len, buf_len - len, "sched_policy = %u\n",
548 le32_to_cpu(htt_stats_buf->sched_policy));
549 len += scnprintf(buf + len, buf_len - len,
550 "last_sched_cmd_posted_timestamp = %u\n",
551 le32_to_cpu(htt_stats_buf->last_sched_cmd_posted_timestamp));
552 len += scnprintf(buf + len, buf_len - len,
553 "last_sched_cmd_compl_timestamp = %u\n",
554 le32_to_cpu(htt_stats_buf->last_sched_cmd_compl_timestamp));
555 len += scnprintf(buf + len, buf_len - len, "sched_2_tac_lwm_count = %u\n",
556 le32_to_cpu(htt_stats_buf->sched_2_tac_lwm_count));
557 len += scnprintf(buf + len, buf_len - len, "sched_2_tac_ring_full = %u\n",
558 le32_to_cpu(htt_stats_buf->sched_2_tac_ring_full));
559 len += scnprintf(buf + len, buf_len - len, "sched_cmd_post_failure = %u\n",
560 le32_to_cpu(htt_stats_buf->sched_cmd_post_failure));
561 len += scnprintf(buf + len, buf_len - len, "num_active_tids = %u\n",
562 le32_to_cpu(htt_stats_buf->num_active_tids));
563 len += scnprintf(buf + len, buf_len - len, "num_ps_schedules = %u\n",
564 le32_to_cpu(htt_stats_buf->num_ps_schedules));
565 len += scnprintf(buf + len, buf_len - len, "sched_cmds_pending = %u\n",
566 le32_to_cpu(htt_stats_buf->sched_cmds_pending));
567 len += scnprintf(buf + len, buf_len - len, "num_tid_register = %u\n",
568 le32_to_cpu(htt_stats_buf->num_tid_register));
569 len += scnprintf(buf + len, buf_len - len, "num_tid_unregister = %u\n",
570 le32_to_cpu(htt_stats_buf->num_tid_unregister));
571 len += scnprintf(buf + len, buf_len - len, "num_qstats_queried = %u\n",
572 le32_to_cpu(htt_stats_buf->num_qstats_queried));
573 len += scnprintf(buf + len, buf_len - len, "qstats_update_pending = %u\n",
574 le32_to_cpu(htt_stats_buf->qstats_update_pending));
575 len += scnprintf(buf + len, buf_len - len, "last_qstats_query_timestamp = %u\n",
576 le32_to_cpu(htt_stats_buf->last_qstats_query_timestamp));
577 len += scnprintf(buf + len, buf_len - len, "num_tqm_cmdq_full = %u\n",
578 le32_to_cpu(htt_stats_buf->num_tqm_cmdq_full));
579 len += scnprintf(buf + len, buf_len - len, "num_de_sched_algo_trigger = %u\n",
580 le32_to_cpu(htt_stats_buf->num_de_sched_algo_trigger));
581 len += scnprintf(buf + len, buf_len - len, "num_rt_sched_algo_trigger = %u\n",
582 le32_to_cpu(htt_stats_buf->num_rt_sched_algo_trigger));
583 len += scnprintf(buf + len, buf_len - len, "num_tqm_sched_algo_trigger = %u\n",
584 le32_to_cpu(htt_stats_buf->num_tqm_sched_algo_trigger));
585 len += scnprintf(buf + len, buf_len - len, "notify_sched = %u\n",
586 le32_to_cpu(htt_stats_buf->notify_sched));
587 len += scnprintf(buf + len, buf_len - len, "dur_based_sendn_term = %u\n",
588 le32_to_cpu(htt_stats_buf->dur_based_sendn_term));
589 len += scnprintf(buf + len, buf_len - len, "su_notify2_sched = %u\n",
590 le32_to_cpu(htt_stats_buf->su_notify2_sched));
591 len += scnprintf(buf + len, buf_len - len, "su_optimal_queued_msdus_sched = %u\n",
592 le32_to_cpu(htt_stats_buf->su_optimal_queued_msdus_sched));
593 len += scnprintf(buf + len, buf_len - len, "su_delay_timeout_sched = %u\n",
594 le32_to_cpu(htt_stats_buf->su_delay_timeout_sched));
595 len += scnprintf(buf + len, buf_len - len, "su_min_txtime_sched_delay = %u\n",
596 le32_to_cpu(htt_stats_buf->su_min_txtime_sched_delay));
597 len += scnprintf(buf + len, buf_len - len, "su_no_delay = %u\n",
598 le32_to_cpu(htt_stats_buf->su_no_delay));
599 len += scnprintf(buf + len, buf_len - len, "num_supercycles = %u\n",
600 le32_to_cpu(htt_stats_buf->num_supercycles));
601 len += scnprintf(buf + len, buf_len - len, "num_subcycles_with_sort = %u\n",
602 le32_to_cpu(htt_stats_buf->num_subcycles_with_sort));
603 len += scnprintf(buf + len, buf_len - len, "num_subcycles_no_sort = %u\n\n",
604 le32_to_cpu(htt_stats_buf->num_subcycles_no_sort));
605
606 stats_req->buf_len = len;
607 }
608
609 static void
ath12k_htt_print_sched_txq_cmd_posted_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)610 ath12k_htt_print_sched_txq_cmd_posted_tlv(const void *tag_buf,
611 u16 tag_len,
612 struct debug_htt_stats_req *stats_req)
613 {
614 const struct ath12k_htt_sched_txq_cmd_posted_tlv *htt_stats_buf = tag_buf;
615 u8 *buf = stats_req->buf;
616 u32 len = stats_req->buf_len;
617 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
618 u16 num_elements = tag_len >> 2;
619
620 len += scnprintf(buf + len, buf_len - len, "HTT_SCHED_TXQ_CMD_POSTED_TLV:\n");
621 len += print_array_to_buf(buf, len, "sched_cmd_posted",
622 htt_stats_buf->sched_cmd_posted, num_elements, "\n\n");
623
624 stats_req->buf_len = len;
625 }
626
627 static void
ath12k_htt_print_sched_txq_cmd_reaped_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)628 ath12k_htt_print_sched_txq_cmd_reaped_tlv(const void *tag_buf,
629 u16 tag_len,
630 struct debug_htt_stats_req *stats_req)
631 {
632 const struct ath12k_htt_sched_txq_cmd_reaped_tlv *htt_stats_buf = tag_buf;
633 u8 *buf = stats_req->buf;
634 u32 len = stats_req->buf_len;
635 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
636 u16 num_elements = tag_len >> 2;
637
638 len += scnprintf(buf + len, buf_len - len, "HTT_SCHED_TXQ_CMD_REAPED_TLV:\n");
639 len += print_array_to_buf(buf, len, "sched_cmd_reaped",
640 htt_stats_buf->sched_cmd_reaped, num_elements, "\n\n");
641
642 stats_req->buf_len = len;
643 }
644
645 static void
ath12k_htt_print_sched_txq_sched_order_su_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)646 ath12k_htt_print_sched_txq_sched_order_su_tlv(const void *tag_buf,
647 u16 tag_len,
648 struct debug_htt_stats_req *stats_req)
649 {
650 const struct ath12k_htt_sched_txq_sched_order_su_tlv *htt_stats_buf = tag_buf;
651 u8 *buf = stats_req->buf;
652 u32 len = stats_req->buf_len;
653 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
654 u32 sched_order_su_num_entries = min_t(u32, (tag_len >> 2),
655 ATH12K_HTT_TX_PDEV_NUM_SCHED_ORDER_LOG);
656
657 len += scnprintf(buf + len, buf_len - len,
658 "HTT_SCHED_TXQ_SCHED_ORDER_SU_TLV:\n");
659 len += print_array_to_buf(buf, len, "sched_order_su",
660 htt_stats_buf->sched_order_su,
661 sched_order_su_num_entries, "\n\n");
662
663 stats_req->buf_len = len;
664 }
665
666 static void
ath12k_htt_print_sched_txq_sched_ineligibility_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)667 ath12k_htt_print_sched_txq_sched_ineligibility_tlv(const void *tag_buf,
668 u16 tag_len,
669 struct debug_htt_stats_req *stats_req)
670 {
671 const struct ath12k_htt_sched_txq_sched_ineligibility_tlv *htt_stats_buf =
672 tag_buf;
673 u8 *buf = stats_req->buf;
674 u32 len = stats_req->buf_len;
675 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
676 u32 sched_ineligibility_num_entries = tag_len >> 2;
677
678 len += scnprintf(buf + len, buf_len - len,
679 "HTT_SCHED_TXQ_SCHED_INELIGIBILITY:\n");
680 len += print_array_to_buf(buf, len, "sched_ineligibility",
681 htt_stats_buf->sched_ineligibility,
682 sched_ineligibility_num_entries, "\n\n");
683
684 stats_req->buf_len = len;
685 }
686
687 static void
ath12k_htt_print_sched_txq_supercycle_trigger_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)688 ath12k_htt_print_sched_txq_supercycle_trigger_tlv(const void *tag_buf,
689 u16 tag_len,
690 struct debug_htt_stats_req *stats_req)
691 {
692 const struct ath12k_htt_sched_txq_supercycle_triggers_tlv *htt_stats_buf =
693 tag_buf;
694 u8 *buf = stats_req->buf;
695 u32 len = stats_req->buf_len;
696 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
697 u16 num_elems = min_t(u16, (tag_len >> 2),
698 ATH12K_HTT_SCHED_SUPERCYCLE_TRIGGER_MAX);
699
700 len += scnprintf(buf + len, buf_len - len,
701 "HTT_SCHED_TXQ_SUPERCYCLE_TRIGGER:\n");
702 len += print_array_to_buf(buf, len, "supercycle_triggers",
703 htt_stats_buf->supercycle_triggers, num_elems, "\n\n");
704
705 stats_req->buf_len = len;
706 }
707
708 static void
ath12k_htt_print_hw_stats_pdev_errs_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)709 ath12k_htt_print_hw_stats_pdev_errs_tlv(const void *tag_buf, u16 tag_len,
710 struct debug_htt_stats_req *stats_req)
711 {
712 const struct ath12k_htt_hw_stats_pdev_errs_tlv *htt_buf = tag_buf;
713 u8 *buf = stats_req->buf;
714 u32 len = stats_req->buf_len;
715 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
716 u32 mac_id_word;
717
718 if (tag_len < sizeof(*htt_buf))
719 return;
720
721 mac_id_word = le32_to_cpu(htt_buf->mac_id__word);
722
723 len += scnprintf(buf + len, buf_len - len, "HTT_HW_STATS_PDEV_ERRS_TLV:\n");
724 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
725 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
726 len += scnprintf(buf + len, buf_len - len, "tx_abort = %u\n",
727 le32_to_cpu(htt_buf->tx_abort));
728 len += scnprintf(buf + len, buf_len - len, "tx_abort_fail_count = %u\n",
729 le32_to_cpu(htt_buf->tx_abort_fail_count));
730 len += scnprintf(buf + len, buf_len - len, "rx_abort = %u\n",
731 le32_to_cpu(htt_buf->rx_abort));
732 len += scnprintf(buf + len, buf_len - len, "rx_abort_fail_count = %u\n",
733 le32_to_cpu(htt_buf->rx_abort_fail_count));
734 len += scnprintf(buf + len, buf_len - len, "rx_flush_cnt = %u\n",
735 le32_to_cpu(htt_buf->rx_flush_cnt));
736 len += scnprintf(buf + len, buf_len - len, "warm_reset = %u\n",
737 le32_to_cpu(htt_buf->warm_reset));
738 len += scnprintf(buf + len, buf_len - len, "cold_reset = %u\n",
739 le32_to_cpu(htt_buf->cold_reset));
740 len += scnprintf(buf + len, buf_len - len, "mac_cold_reset_restore_cal = %u\n",
741 le32_to_cpu(htt_buf->mac_cold_reset_restore_cal));
742 len += scnprintf(buf + len, buf_len - len, "mac_cold_reset = %u\n",
743 le32_to_cpu(htt_buf->mac_cold_reset));
744 len += scnprintf(buf + len, buf_len - len, "mac_warm_reset = %u\n",
745 le32_to_cpu(htt_buf->mac_warm_reset));
746 len += scnprintf(buf + len, buf_len - len, "mac_only_reset = %u\n",
747 le32_to_cpu(htt_buf->mac_only_reset));
748 len += scnprintf(buf + len, buf_len - len, "phy_warm_reset = %u\n",
749 le32_to_cpu(htt_buf->phy_warm_reset));
750 len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_ucode_trig = %u\n",
751 le32_to_cpu(htt_buf->phy_warm_reset_ucode_trig));
752 len += scnprintf(buf + len, buf_len - len, "mac_warm_reset_restore_cal = %u\n",
753 le32_to_cpu(htt_buf->mac_warm_reset_restore_cal));
754 len += scnprintf(buf + len, buf_len - len, "mac_sfm_reset = %u\n",
755 le32_to_cpu(htt_buf->mac_sfm_reset));
756 len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_m3_ssr = %u\n",
757 le32_to_cpu(htt_buf->phy_warm_reset_m3_ssr));
758 len += scnprintf(buf + len, buf_len - len, "fw_rx_rings_reset = %u\n",
759 le32_to_cpu(htt_buf->fw_rx_rings_reset));
760 len += scnprintf(buf + len, buf_len - len, "tx_flush = %u\n",
761 le32_to_cpu(htt_buf->tx_flush));
762 len += scnprintf(buf + len, buf_len - len, "tx_glb_reset = %u\n",
763 le32_to_cpu(htt_buf->tx_glb_reset));
764 len += scnprintf(buf + len, buf_len - len, "tx_txq_reset = %u\n",
765 le32_to_cpu(htt_buf->tx_txq_reset));
766 len += scnprintf(buf + len, buf_len - len, "rx_timeout_reset = %u\n\n",
767 le32_to_cpu(htt_buf->rx_timeout_reset));
768
769 len += scnprintf(buf + len, buf_len - len, "PDEV_PHY_WARM_RESET_REASONS:\n");
770 len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_reason_phy_m3 = %u\n",
771 le32_to_cpu(htt_buf->phy_warm_reset_reason_phy_m3));
772 len += scnprintf(buf + len, buf_len - len,
773 "phy_warm_reset_reason_tx_hw_stuck = %u\n",
774 le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_hw_stuck));
775 len += scnprintf(buf + len, buf_len - len,
776 "phy_warm_reset_reason_num_cca_rx_frame_stuck = %u\n",
777 le32_to_cpu(htt_buf->phy_warm_reset_reason_num_rx_frame_stuck));
778 len += scnprintf(buf + len, buf_len - len,
779 "phy_warm_reset_reason_wal_rx_recovery_rst_rx_busy = %u\n",
780 le32_to_cpu(htt_buf->phy_warm_reset_reason_wal_rx_rec_rx_busy));
781 len += scnprintf(buf + len, buf_len - len,
782 "phy_warm_reset_reason_wal_rx_recovery_rst_mac_hang = %u\n",
783 le32_to_cpu(htt_buf->phy_warm_reset_reason_wal_rx_rec_mac_hng));
784 len += scnprintf(buf + len, buf_len - len,
785 "phy_warm_reset_reason_mac_reset_converted_phy_reset = %u\n",
786 le32_to_cpu(htt_buf->phy_warm_reset_reason_mac_conv_phy_reset));
787 len += scnprintf(buf + len, buf_len - len,
788 "phy_warm_reset_reason_tx_lifetime_expiry_cca_stuck = %u\n",
789 le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_exp_cca_stuck));
790 len += scnprintf(buf + len, buf_len - len,
791 "phy_warm_reset_reason_tx_consecutive_flush9_war = %u\n",
792 le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_consec_flsh_war));
793 len += scnprintf(buf + len, buf_len - len,
794 "phy_warm_reset_reason_tx_hwsch_reset_war = %u\n",
795 le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_hwsch_reset_war));
796 len += scnprintf(buf + len, buf_len - len,
797 "phy_warm_reset_reason_hwsch_wdog_or_cca_wdog_war = %u\n\n",
798 le32_to_cpu(htt_buf->phy_warm_reset_reason_hwsch_cca_wdog_war));
799
800 len += scnprintf(buf + len, buf_len - len, "WAL_RX_RECOVERY_STATS:\n");
801 len += scnprintf(buf + len, buf_len - len,
802 "wal_rx_recovery_rst_mac_hang_count = %u\n",
803 le32_to_cpu(htt_buf->wal_rx_recovery_rst_mac_hang_cnt));
804 len += scnprintf(buf + len, buf_len - len,
805 "wal_rx_recovery_rst_known_sig_count = %u\n",
806 le32_to_cpu(htt_buf->wal_rx_recovery_rst_known_sig_cnt));
807 len += scnprintf(buf + len, buf_len - len,
808 "wal_rx_recovery_rst_no_rx_count = %u\n",
809 le32_to_cpu(htt_buf->wal_rx_recovery_rst_no_rx_cnt));
810 len += scnprintf(buf + len, buf_len - len,
811 "wal_rx_recovery_rst_no_rx_consecutive_count = %u\n",
812 le32_to_cpu(htt_buf->wal_rx_recovery_rst_no_rx_consec_cnt));
813 len += scnprintf(buf + len, buf_len - len,
814 "wal_rx_recovery_rst_rx_busy_count = %u\n",
815 le32_to_cpu(htt_buf->wal_rx_recovery_rst_rx_busy_cnt));
816 len += scnprintf(buf + len, buf_len - len,
817 "wal_rx_recovery_rst_phy_mac_hang_count = %u\n\n",
818 le32_to_cpu(htt_buf->wal_rx_recovery_rst_phy_mac_hang_cnt));
819
820 len += scnprintf(buf + len, buf_len - len, "HTT_RX_DEST_DRAIN_STATS:\n");
821 len += scnprintf(buf + len, buf_len - len,
822 "rx_dest_drain_rx_descs_leak_prevention_done = %u\n",
823 le32_to_cpu(htt_buf->rx_dest_drain_rx_descs_leak_prevented));
824 len += scnprintf(buf + len, buf_len - len,
825 "rx_dest_drain_rx_descs_saved_cnt = %u\n",
826 le32_to_cpu(htt_buf->rx_dest_drain_rx_descs_saved_cnt));
827 len += scnprintf(buf + len, buf_len - len,
828 "rx_dest_drain_rxdma2reo_leak_detected = %u\n",
829 le32_to_cpu(htt_buf->rx_dest_drain_rxdma2reo_leak_detected));
830 len += scnprintf(buf + len, buf_len - len,
831 "rx_dest_drain_rxdma2fw_leak_detected = %u\n",
832 le32_to_cpu(htt_buf->rx_dest_drain_rxdma2fw_leak_detected));
833 len += scnprintf(buf + len, buf_len - len,
834 "rx_dest_drain_rxdma2wbm_leak_detected = %u\n",
835 le32_to_cpu(htt_buf->rx_dest_drain_rxdma2wbm_leak_detected));
836 len += scnprintf(buf + len, buf_len - len,
837 "rx_dest_drain_rxdma1_2sw_leak_detected = %u\n",
838 le32_to_cpu(htt_buf->rx_dest_drain_rxdma1_2sw_leak_detected));
839 len += scnprintf(buf + len, buf_len - len,
840 "rx_dest_drain_rx_drain_ok_mac_idle = %u\n",
841 le32_to_cpu(htt_buf->rx_dest_drain_rx_drain_ok_mac_idle));
842 len += scnprintf(buf + len, buf_len - len,
843 "rx_dest_drain_ok_mac_not_idle = %u\n",
844 le32_to_cpu(htt_buf->rx_dest_drain_ok_mac_not_idle));
845 len += scnprintf(buf + len, buf_len - len,
846 "rx_dest_drain_prerequisite_invld = %u\n",
847 le32_to_cpu(htt_buf->rx_dest_drain_prerequisite_invld));
848 len += scnprintf(buf + len, buf_len - len,
849 "rx_dest_drain_skip_for_non_lmac_reset = %u\n",
850 le32_to_cpu(htt_buf->rx_dest_drain_skip_non_lmac_reset));
851 len += scnprintf(buf + len, buf_len - len,
852 "rx_dest_drain_hw_fifo_not_empty_post_drain_wait = %u\n\n",
853 le32_to_cpu(htt_buf->rx_dest_drain_hw_fifo_notempty_post_wait));
854
855 stats_req->buf_len = len;
856 }
857
858 static void
ath12k_htt_print_hw_stats_intr_misc_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)859 ath12k_htt_print_hw_stats_intr_misc_tlv(const void *tag_buf, u16 tag_len,
860 struct debug_htt_stats_req *stats_req)
861 {
862 const struct ath12k_htt_hw_stats_intr_misc_tlv *htt_stats_buf = tag_buf;
863 u8 *buf = stats_req->buf;
864 u32 len = stats_req->buf_len;
865 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
866
867 if (tag_len < sizeof(*htt_stats_buf))
868 return;
869
870 len += scnprintf(buf + len, buf_len - len, "HTT_HW_STATS_INTR_MISC_TLV:\n");
871 len += scnprintf(buf + len, buf_len - len, "hw_intr_name = %s\n",
872 htt_stats_buf->hw_intr_name);
873 len += scnprintf(buf + len, buf_len - len, "mask = %u\n",
874 le32_to_cpu(htt_stats_buf->mask));
875 len += scnprintf(buf + len, buf_len - len, "count = %u\n\n",
876 le32_to_cpu(htt_stats_buf->count));
877
878 stats_req->buf_len = len;
879 }
880
881 static void
ath12k_htt_print_hw_stats_whal_tx_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)882 ath12k_htt_print_hw_stats_whal_tx_tlv(const void *tag_buf, u16 tag_len,
883 struct debug_htt_stats_req *stats_req)
884 {
885 const struct ath12k_htt_hw_stats_whal_tx_tlv *htt_stats_buf = tag_buf;
886 u8 *buf = stats_req->buf;
887 u32 len = stats_req->buf_len;
888 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
889 u32 mac_id_word;
890
891 if (tag_len < sizeof(*htt_stats_buf))
892 return;
893
894 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
895
896 len += scnprintf(buf + len, buf_len - len, "HTT_HW_STATS_WHAL_TX_TLV:\n");
897 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
898 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
899 len += scnprintf(buf + len, buf_len - len, "last_unpause_ppdu_id = %u\n",
900 le32_to_cpu(htt_stats_buf->last_unpause_ppdu_id));
901 len += scnprintf(buf + len, buf_len - len, "hwsch_unpause_wait_tqm_write = %u\n",
902 le32_to_cpu(htt_stats_buf->hwsch_unpause_wait_tqm_write));
903 len += scnprintf(buf + len, buf_len - len, "hwsch_dummy_tlv_skipped = %u\n",
904 le32_to_cpu(htt_stats_buf->hwsch_dummy_tlv_skipped));
905 len += scnprintf(buf + len, buf_len - len,
906 "hwsch_misaligned_offset_received = %u\n",
907 le32_to_cpu(htt_stats_buf->hwsch_misaligned_offset_received));
908 len += scnprintf(buf + len, buf_len - len, "hwsch_reset_count = %u\n",
909 le32_to_cpu(htt_stats_buf->hwsch_reset_count));
910 len += scnprintf(buf + len, buf_len - len, "hwsch_dev_reset_war = %u\n",
911 le32_to_cpu(htt_stats_buf->hwsch_dev_reset_war));
912 len += scnprintf(buf + len, buf_len - len, "hwsch_delayed_pause = %u\n",
913 le32_to_cpu(htt_stats_buf->hwsch_delayed_pause));
914 len += scnprintf(buf + len, buf_len - len, "hwsch_long_delayed_pause = %u\n",
915 le32_to_cpu(htt_stats_buf->hwsch_long_delayed_pause));
916 len += scnprintf(buf + len, buf_len - len, "sch_rx_ppdu_no_response = %u\n",
917 le32_to_cpu(htt_stats_buf->sch_rx_ppdu_no_response));
918 len += scnprintf(buf + len, buf_len - len, "sch_selfgen_response = %u\n",
919 le32_to_cpu(htt_stats_buf->sch_selfgen_response));
920 len += scnprintf(buf + len, buf_len - len, "sch_rx_sifs_resp_trigger= %u\n\n",
921 le32_to_cpu(htt_stats_buf->sch_rx_sifs_resp_trigger));
922
923 stats_req->buf_len = len;
924 }
925
926 static void
ath12k_htt_print_hw_war_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)927 ath12k_htt_print_hw_war_tlv(const void *tag_buf, u16 tag_len,
928 struct debug_htt_stats_req *stats_req)
929 {
930 const struct ath12k_htt_hw_war_stats_tlv *htt_stats_buf = tag_buf;
931 u8 *buf = stats_req->buf;
932 u32 len = stats_req->buf_len;
933 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
934 u16 fixed_len, array_len;
935 u8 i, array_words;
936 u32 mac_id;
937
938 if (tag_len < sizeof(*htt_stats_buf))
939 return;
940
941 mac_id = __le32_to_cpu(htt_stats_buf->mac_id__word);
942 fixed_len = sizeof(*htt_stats_buf);
943 array_len = tag_len - fixed_len;
944 array_words = array_len >> 2;
945
946 len += scnprintf(buf + len, buf_len - len, "HTT_HW_WAR_STATS_TLV:\n");
947 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
948 u32_get_bits(mac_id, ATH12K_HTT_STATS_MAC_ID));
949
950 for (i = 0; i < array_words; i++) {
951 len += scnprintf(buf + len, buf_len - len, "hw_war %u = %u\n\n",
952 i, le32_to_cpu(htt_stats_buf->hw_wars[i]));
953 }
954
955 stats_req->buf_len = len;
956 }
957
958 static void
ath12k_htt_print_tx_tqm_cmn_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)959 ath12k_htt_print_tx_tqm_cmn_stats_tlv(const void *tag_buf, u16 tag_len,
960 struct debug_htt_stats_req *stats_req)
961 {
962 const struct ath12k_htt_tx_tqm_cmn_stats_tlv *htt_stats_buf = tag_buf;
963 u8 *buf = stats_req->buf;
964 u32 len = stats_req->buf_len;
965 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
966 u32 mac_id_word;
967
968 if (tag_len < sizeof(*htt_stats_buf))
969 return;
970
971 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
972
973 len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_CMN_STATS_TLV:\n");
974 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
975 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
976 len += scnprintf(buf + len, buf_len - len, "max_cmdq_id = %u\n",
977 le32_to_cpu(htt_stats_buf->max_cmdq_id));
978 len += scnprintf(buf + len, buf_len - len, "list_mpdu_cnt_hist_intvl = %u\n",
979 le32_to_cpu(htt_stats_buf->list_mpdu_cnt_hist_intvl));
980 len += scnprintf(buf + len, buf_len - len, "add_msdu = %u\n",
981 le32_to_cpu(htt_stats_buf->add_msdu));
982 len += scnprintf(buf + len, buf_len - len, "q_empty = %u\n",
983 le32_to_cpu(htt_stats_buf->q_empty));
984 len += scnprintf(buf + len, buf_len - len, "q_not_empty = %u\n",
985 le32_to_cpu(htt_stats_buf->q_not_empty));
986 len += scnprintf(buf + len, buf_len - len, "drop_notification = %u\n",
987 le32_to_cpu(htt_stats_buf->drop_notification));
988 len += scnprintf(buf + len, buf_len - len, "desc_threshold = %u\n",
989 le32_to_cpu(htt_stats_buf->desc_threshold));
990 len += scnprintf(buf + len, buf_len - len, "hwsch_tqm_invalid_status = %u\n",
991 le32_to_cpu(htt_stats_buf->hwsch_tqm_invalid_status));
992 len += scnprintf(buf + len, buf_len - len, "missed_tqm_gen_mpdus = %u\n",
993 le32_to_cpu(htt_stats_buf->missed_tqm_gen_mpdus));
994 len += scnprintf(buf + len, buf_len - len,
995 "total_msduq_timestamp_updates = %u\n",
996 le32_to_cpu(htt_stats_buf->msduq_timestamp_updates));
997 len += scnprintf(buf + len, buf_len - len,
998 "total_msduq_timestamp_updates_by_get_mpdu_head_info_cmd = %u\n",
999 le32_to_cpu(htt_stats_buf->msduq_updates_mpdu_head_info_cmd));
1000 len += scnprintf(buf + len, buf_len - len,
1001 "total_msduq_timestamp_updates_by_emp_to_nonemp_status = %u\n",
1002 le32_to_cpu(htt_stats_buf->msduq_updates_emp_to_nonemp_status));
1003 len += scnprintf(buf + len, buf_len - len,
1004 "total_get_mpdu_head_info_cmds_by_sched_algo_la_query = %u\n",
1005 le32_to_cpu(htt_stats_buf->get_mpdu_head_info_cmds_by_query));
1006 len += scnprintf(buf + len, buf_len - len,
1007 "total_get_mpdu_head_info_cmds_by_tac = %u\n",
1008 le32_to_cpu(htt_stats_buf->get_mpdu_head_info_cmds_by_tac));
1009 len += scnprintf(buf + len, buf_len - len,
1010 "total_gen_mpdu_cmds_by_sched_algo_la_query = %u\n",
1011 le32_to_cpu(htt_stats_buf->gen_mpdu_cmds_by_query));
1012 len += scnprintf(buf + len, buf_len - len, "active_tqm_tids = %u\n",
1013 le32_to_cpu(htt_stats_buf->tqm_active_tids));
1014 len += scnprintf(buf + len, buf_len - len, "inactive_tqm_tids = %u\n",
1015 le32_to_cpu(htt_stats_buf->tqm_inactive_tids));
1016 len += scnprintf(buf + len, buf_len - len, "tqm_active_msduq_flows = %u\n",
1017 le32_to_cpu(htt_stats_buf->tqm_active_msduq_flows));
1018 len += scnprintf(buf + len, buf_len - len, "hi_prio_q_not_empty = %u\n\n",
1019 le32_to_cpu(htt_stats_buf->high_prio_q_not_empty));
1020
1021 stats_req->buf_len = len;
1022 }
1023
1024 static void
ath12k_htt_print_tx_tqm_error_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1025 ath12k_htt_print_tx_tqm_error_stats_tlv(const void *tag_buf, u16 tag_len,
1026 struct debug_htt_stats_req *stats_req)
1027 {
1028 const struct ath12k_htt_tx_tqm_error_stats_tlv *htt_stats_buf = tag_buf;
1029 u8 *buf = stats_req->buf;
1030 u32 len = stats_req->buf_len;
1031 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1032
1033 if (tag_len < sizeof(*htt_stats_buf))
1034 return;
1035
1036 len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_ERROR_STATS_TLV:\n");
1037 len += scnprintf(buf + len, buf_len - len, "q_empty_failure = %u\n",
1038 le32_to_cpu(htt_stats_buf->q_empty_failure));
1039 len += scnprintf(buf + len, buf_len - len, "q_not_empty_failure = %u\n",
1040 le32_to_cpu(htt_stats_buf->q_not_empty_failure));
1041 len += scnprintf(buf + len, buf_len - len, "add_msdu_failure = %u\n\n",
1042 le32_to_cpu(htt_stats_buf->add_msdu_failure));
1043
1044 len += scnprintf(buf + len, buf_len - len, "TQM_ERROR_RESET_STATS:\n");
1045 len += scnprintf(buf + len, buf_len - len, "tqm_cache_ctl_err = %u\n",
1046 le32_to_cpu(htt_stats_buf->tqm_cache_ctl_err));
1047 len += scnprintf(buf + len, buf_len - len, "tqm_soft_reset = %u\n",
1048 le32_to_cpu(htt_stats_buf->tqm_soft_reset));
1049 len += scnprintf(buf + len, buf_len - len,
1050 "tqm_reset_total_num_in_use_link_descs = %u\n",
1051 le32_to_cpu(htt_stats_buf->tqm_reset_num_in_use_link_descs));
1052 len += scnprintf(buf + len, buf_len - len,
1053 "tqm_reset_worst_case_num_lost_link_descs = %u\n",
1054 le32_to_cpu(htt_stats_buf->tqm_reset_num_lost_link_descs));
1055 len += scnprintf(buf + len, buf_len - len,
1056 "tqm_reset_worst_case_num_lost_host_tx_bufs_count = %u\n",
1057 le32_to_cpu(htt_stats_buf->tqm_reset_num_lost_host_tx_buf_cnt));
1058 len += scnprintf(buf + len, buf_len - len,
1059 "tqm_reset_num_in_use_link_descs_internal_tqm = %u\n",
1060 le32_to_cpu(htt_stats_buf->tqm_reset_num_in_use_internal_tqm));
1061 len += scnprintf(buf + len, buf_len - len,
1062 "tqm_reset_num_in_use_link_descs_wbm_idle_link_ring = %u\n",
1063 le32_to_cpu(htt_stats_buf->tqm_reset_num_in_use_idle_link_rng));
1064 len += scnprintf(buf + len, buf_len - len,
1065 "tqm_reset_time_to_tqm_hang_delta_ms = %u\n",
1066 le32_to_cpu(htt_stats_buf->tqm_reset_time_to_tqm_hang_delta_ms));
1067 len += scnprintf(buf + len, buf_len - len, "tqm_reset_recovery_time_ms = %u\n",
1068 le32_to_cpu(htt_stats_buf->tqm_reset_recovery_time_ms));
1069 len += scnprintf(buf + len, buf_len - len, "tqm_reset_num_peers_hdl = %u\n",
1070 le32_to_cpu(htt_stats_buf->tqm_reset_num_peers_hdl));
1071 len += scnprintf(buf + len, buf_len - len,
1072 "tqm_reset_cumm_dirty_hw_mpduq_proc_cnt = %u\n",
1073 le32_to_cpu(htt_stats_buf->tqm_reset_cumm_dirty_hw_mpduq_cnt));
1074 len += scnprintf(buf + len, buf_len - len,
1075 "tqm_reset_cumm_dirty_hw_msduq_proc = %u\n",
1076 le32_to_cpu(htt_stats_buf->tqm_reset_cumm_dirty_hw_msduq_proc));
1077 len += scnprintf(buf + len, buf_len - len,
1078 "tqm_reset_flush_cache_cmd_su_cnt = %u\n",
1079 le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_su_cnt));
1080 len += scnprintf(buf + len, buf_len - len,
1081 "tqm_reset_flush_cache_cmd_other_cnt = %u\n",
1082 le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_other_cnt));
1083 len += scnprintf(buf + len, buf_len - len,
1084 "tqm_reset_flush_cache_cmd_trig_type = %u\n",
1085 le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_trig_type));
1086 len += scnprintf(buf + len, buf_len - len,
1087 "tqm_reset_flush_cache_cmd_trig_cfg = %u\n",
1088 le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_trig_cfg));
1089 len += scnprintf(buf + len, buf_len - len,
1090 "tqm_reset_flush_cache_cmd_skip_cmd_status_null = %u\n\n",
1091 le32_to_cpu(htt_stats_buf->tqm_reset_flush_cmd_skp_status_null));
1092
1093 stats_req->buf_len = len;
1094 }
1095
1096 static void
ath12k_htt_print_tx_tqm_gen_mpdu_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1097 ath12k_htt_print_tx_tqm_gen_mpdu_stats_tlv(const void *tag_buf, u16 tag_len,
1098 struct debug_htt_stats_req *stats_req)
1099 {
1100 const struct ath12k_htt_tx_tqm_gen_mpdu_stats_tlv *htt_stats_buf = tag_buf;
1101 u8 *buf = stats_req->buf;
1102 u32 len = stats_req->buf_len;
1103 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1104 u16 num_elements = tag_len >> 2;
1105
1106 len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_GEN_MPDU_STATS_TLV:\n");
1107 len += print_array_to_buf(buf, len, "gen_mpdu_end_reason",
1108 htt_stats_buf->gen_mpdu_end_reason, num_elements,
1109 "\n\n");
1110
1111 stats_req->buf_len = len;
1112 }
1113
1114 static void
ath12k_htt_print_tx_tqm_list_mpdu_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1115 ath12k_htt_print_tx_tqm_list_mpdu_stats_tlv(const void *tag_buf, u16 tag_len,
1116 struct debug_htt_stats_req *stats_req)
1117 {
1118 const struct ath12k_htt_tx_tqm_list_mpdu_stats_tlv *htt_stats_buf = tag_buf;
1119 u8 *buf = stats_req->buf;
1120 u32 len = stats_req->buf_len;
1121 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1122 u16 num_elems = min_t(u16, (tag_len >> 2),
1123 ATH12K_HTT_TX_TQM_MAX_LIST_MPDU_END_REASON);
1124
1125 len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_LIST_MPDU_STATS_TLV:\n");
1126 len += print_array_to_buf(buf, len, "list_mpdu_end_reason",
1127 htt_stats_buf->list_mpdu_end_reason, num_elems, "\n\n");
1128
1129 stats_req->buf_len = len;
1130 }
1131
1132 static void
ath12k_htt_print_tx_tqm_list_mpdu_cnt_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1133 ath12k_htt_print_tx_tqm_list_mpdu_cnt_tlv(const void *tag_buf, u16 tag_len,
1134 struct debug_htt_stats_req *stats_req)
1135 {
1136 const struct ath12k_htt_tx_tqm_list_mpdu_cnt_tlv *htt_stats_buf = tag_buf;
1137 u8 *buf = stats_req->buf;
1138 u32 len = stats_req->buf_len;
1139 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1140 u16 num_elems = min_t(u16, (tag_len >> 2),
1141 ATH12K_HTT_TX_TQM_MAX_LIST_MPDU_CNT_HISTOGRAM_BINS);
1142
1143 len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_LIST_MPDU_CNT_TLV_V:\n");
1144 len += print_array_to_buf(buf, len, "list_mpdu_cnt_hist",
1145 htt_stats_buf->list_mpdu_cnt_hist, num_elems, "\n\n");
1146
1147 stats_req->buf_len = len;
1148 }
1149
1150 static void
ath12k_htt_print_tx_tqm_pdev_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1151 ath12k_htt_print_tx_tqm_pdev_stats_tlv(const void *tag_buf, u16 tag_len,
1152 struct debug_htt_stats_req *stats_req)
1153 {
1154 const struct ath12k_htt_tx_tqm_pdev_stats_tlv *htt_stats_buf = tag_buf;
1155 u8 *buf = stats_req->buf;
1156 u32 len = stats_req->buf_len;
1157 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1158
1159 if (tag_len < sizeof(*htt_stats_buf))
1160 return;
1161
1162 len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_PDEV_STATS_TLV_V:\n");
1163 len += scnprintf(buf + len, buf_len - len, "msdu_count = %u\n",
1164 le32_to_cpu(htt_stats_buf->msdu_count));
1165 len += scnprintf(buf + len, buf_len - len, "mpdu_count = %u\n",
1166 le32_to_cpu(htt_stats_buf->mpdu_count));
1167 len += scnprintf(buf + len, buf_len - len, "remove_msdu = %u\n",
1168 le32_to_cpu(htt_stats_buf->remove_msdu));
1169 len += scnprintf(buf + len, buf_len - len, "remove_mpdu = %u\n",
1170 le32_to_cpu(htt_stats_buf->remove_mpdu));
1171 len += scnprintf(buf + len, buf_len - len, "remove_msdu_ttl = %u\n",
1172 le32_to_cpu(htt_stats_buf->remove_msdu_ttl));
1173 len += scnprintf(buf + len, buf_len - len, "send_bar = %u\n",
1174 le32_to_cpu(htt_stats_buf->send_bar));
1175 len += scnprintf(buf + len, buf_len - len, "bar_sync = %u\n",
1176 le32_to_cpu(htt_stats_buf->bar_sync));
1177 len += scnprintf(buf + len, buf_len - len, "notify_mpdu = %u\n",
1178 le32_to_cpu(htt_stats_buf->notify_mpdu));
1179 len += scnprintf(buf + len, buf_len - len, "sync_cmd = %u\n",
1180 le32_to_cpu(htt_stats_buf->sync_cmd));
1181 len += scnprintf(buf + len, buf_len - len, "write_cmd = %u\n",
1182 le32_to_cpu(htt_stats_buf->write_cmd));
1183 len += scnprintf(buf + len, buf_len - len, "hwsch_trigger = %u\n",
1184 le32_to_cpu(htt_stats_buf->hwsch_trigger));
1185 len += scnprintf(buf + len, buf_len - len, "ack_tlv_proc = %u\n",
1186 le32_to_cpu(htt_stats_buf->ack_tlv_proc));
1187 len += scnprintf(buf + len, buf_len - len, "gen_mpdu_cmd = %u\n",
1188 le32_to_cpu(htt_stats_buf->gen_mpdu_cmd));
1189 len += scnprintf(buf + len, buf_len - len, "gen_list_cmd = %u\n",
1190 le32_to_cpu(htt_stats_buf->gen_list_cmd));
1191 len += scnprintf(buf + len, buf_len - len, "remove_mpdu_cmd = %u\n",
1192 le32_to_cpu(htt_stats_buf->remove_mpdu_cmd));
1193 len += scnprintf(buf + len, buf_len - len, "remove_mpdu_tried_cmd = %u\n",
1194 le32_to_cpu(htt_stats_buf->remove_mpdu_tried_cmd));
1195 len += scnprintf(buf + len, buf_len - len, "mpdu_queue_stats_cmd = %u\n",
1196 le32_to_cpu(htt_stats_buf->mpdu_queue_stats_cmd));
1197 len += scnprintf(buf + len, buf_len - len, "mpdu_head_info_cmd = %u\n",
1198 le32_to_cpu(htt_stats_buf->mpdu_head_info_cmd));
1199 len += scnprintf(buf + len, buf_len - len, "msdu_flow_stats_cmd = %u\n",
1200 le32_to_cpu(htt_stats_buf->msdu_flow_stats_cmd));
1201 len += scnprintf(buf + len, buf_len - len, "remove_msdu_cmd = %u\n",
1202 le32_to_cpu(htt_stats_buf->remove_msdu_cmd));
1203 len += scnprintf(buf + len, buf_len - len, "remove_msdu_ttl_cmd = %u\n",
1204 le32_to_cpu(htt_stats_buf->remove_msdu_ttl_cmd));
1205 len += scnprintf(buf + len, buf_len - len, "flush_cache_cmd = %u\n",
1206 le32_to_cpu(htt_stats_buf->flush_cache_cmd));
1207 len += scnprintf(buf + len, buf_len - len, "update_mpduq_cmd = %u\n",
1208 le32_to_cpu(htt_stats_buf->update_mpduq_cmd));
1209 len += scnprintf(buf + len, buf_len - len, "enqueue = %u\n",
1210 le32_to_cpu(htt_stats_buf->enqueue));
1211 len += scnprintf(buf + len, buf_len - len, "enqueue_notify = %u\n",
1212 le32_to_cpu(htt_stats_buf->enqueue_notify));
1213 len += scnprintf(buf + len, buf_len - len, "notify_mpdu_at_head = %u\n",
1214 le32_to_cpu(htt_stats_buf->notify_mpdu_at_head));
1215 len += scnprintf(buf + len, buf_len - len, "notify_mpdu_state_valid = %u\n",
1216 le32_to_cpu(htt_stats_buf->notify_mpdu_state_valid));
1217 len += scnprintf(buf + len, buf_len - len, "sched_udp_notify1 = %u\n",
1218 le32_to_cpu(htt_stats_buf->sched_udp_notify1));
1219 len += scnprintf(buf + len, buf_len - len, "sched_udp_notify2 = %u\n",
1220 le32_to_cpu(htt_stats_buf->sched_udp_notify2));
1221 len += scnprintf(buf + len, buf_len - len, "sched_nonudp_notify1 = %u\n",
1222 le32_to_cpu(htt_stats_buf->sched_nonudp_notify1));
1223 len += scnprintf(buf + len, buf_len - len, "sched_nonudp_notify2 = %u\n\n",
1224 le32_to_cpu(htt_stats_buf->sched_nonudp_notify2));
1225
1226 stats_req->buf_len = len;
1227 }
1228
1229 static void
ath12k_htt_print_tx_de_cmn_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1230 ath12k_htt_print_tx_de_cmn_stats_tlv(const void *tag_buf, u16 tag_len,
1231 struct debug_htt_stats_req *stats_req)
1232 {
1233 const struct ath12k_htt_tx_de_cmn_stats_tlv *htt_stats_buf = tag_buf;
1234 u8 *buf = stats_req->buf;
1235 u32 len = stats_req->buf_len;
1236 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1237 u32 mac_id_word;
1238
1239 if (tag_len < sizeof(*htt_stats_buf))
1240 return;
1241
1242 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
1243
1244 len += scnprintf(buf + len, buf_len - len, "HTT_TX_DE_CMN_STATS_TLV:\n");
1245 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
1246 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
1247 len += scnprintf(buf + len, buf_len - len, "tcl2fw_entry_count = %u\n",
1248 le32_to_cpu(htt_stats_buf->tcl2fw_entry_count));
1249 len += scnprintf(buf + len, buf_len - len, "not_to_fw = %u\n",
1250 le32_to_cpu(htt_stats_buf->not_to_fw));
1251 len += scnprintf(buf + len, buf_len - len, "invalid_pdev_vdev_peer = %u\n",
1252 le32_to_cpu(htt_stats_buf->invalid_pdev_vdev_peer));
1253 len += scnprintf(buf + len, buf_len - len, "tcl_res_invalid_addrx = %u\n",
1254 le32_to_cpu(htt_stats_buf->tcl_res_invalid_addrx));
1255 len += scnprintf(buf + len, buf_len - len, "wbm2fw_entry_count = %u\n",
1256 le32_to_cpu(htt_stats_buf->wbm2fw_entry_count));
1257 len += scnprintf(buf + len, buf_len - len, "invalid_pdev = %u\n",
1258 le32_to_cpu(htt_stats_buf->invalid_pdev));
1259 len += scnprintf(buf + len, buf_len - len, "tcl_res_addrx_timeout = %u\n",
1260 le32_to_cpu(htt_stats_buf->tcl_res_addrx_timeout));
1261 len += scnprintf(buf + len, buf_len - len, "invalid_vdev = %u\n",
1262 le32_to_cpu(htt_stats_buf->invalid_vdev));
1263 len += scnprintf(buf + len, buf_len - len, "invalid_tcl_exp_frame_desc = %u\n",
1264 le32_to_cpu(htt_stats_buf->invalid_tcl_exp_frame_desc));
1265 len += scnprintf(buf + len, buf_len - len, "vdev_id_mismatch_count = %u\n\n",
1266 le32_to_cpu(htt_stats_buf->vdev_id_mismatch_cnt));
1267
1268 stats_req->buf_len = len;
1269 }
1270
1271 static void
ath12k_htt_print_tx_de_eapol_packets_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1272 ath12k_htt_print_tx_de_eapol_packets_stats_tlv(const void *tag_buf, u16 tag_len,
1273 struct debug_htt_stats_req *stats_req)
1274 {
1275 const struct ath12k_htt_tx_de_eapol_packets_stats_tlv *htt_stats_buf = tag_buf;
1276 u8 *buf = stats_req->buf;
1277 u32 len = stats_req->buf_len;
1278 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1279
1280 if (tag_len < sizeof(*htt_stats_buf))
1281 return;
1282
1283 len += scnprintf(buf + len, buf_len - len,
1284 "HTT_TX_DE_EAPOL_PACKETS_STATS_TLV:\n");
1285 len += scnprintf(buf + len, buf_len - len, "m1_packets = %u\n",
1286 le32_to_cpu(htt_stats_buf->m1_packets));
1287 len += scnprintf(buf + len, buf_len - len, "m2_packets = %u\n",
1288 le32_to_cpu(htt_stats_buf->m2_packets));
1289 len += scnprintf(buf + len, buf_len - len, "m3_packets = %u\n",
1290 le32_to_cpu(htt_stats_buf->m3_packets));
1291 len += scnprintf(buf + len, buf_len - len, "m4_packets = %u\n",
1292 le32_to_cpu(htt_stats_buf->m4_packets));
1293 len += scnprintf(buf + len, buf_len - len, "g1_packets = %u\n",
1294 le32_to_cpu(htt_stats_buf->g1_packets));
1295 len += scnprintf(buf + len, buf_len - len, "g2_packets = %u\n",
1296 le32_to_cpu(htt_stats_buf->g2_packets));
1297 len += scnprintf(buf + len, buf_len - len, "rc4_packets = %u\n",
1298 le32_to_cpu(htt_stats_buf->rc4_packets));
1299 len += scnprintf(buf + len, buf_len - len, "eap_packets = %u\n",
1300 le32_to_cpu(htt_stats_buf->eap_packets));
1301 len += scnprintf(buf + len, buf_len - len, "eapol_start_packets = %u\n",
1302 le32_to_cpu(htt_stats_buf->eapol_start_packets));
1303 len += scnprintf(buf + len, buf_len - len, "eapol_logoff_packets = %u\n",
1304 le32_to_cpu(htt_stats_buf->eapol_logoff_packets));
1305 len += scnprintf(buf + len, buf_len - len, "eapol_encap_asf_packets = %u\n\n",
1306 le32_to_cpu(htt_stats_buf->eapol_encap_asf_packets));
1307
1308 stats_req->buf_len = len;
1309 }
1310
1311 static void
ath12k_htt_print_tx_de_classify_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1312 ath12k_htt_print_tx_de_classify_stats_tlv(const void *tag_buf, u16 tag_len,
1313 struct debug_htt_stats_req *stats_req)
1314 {
1315 const struct ath12k_htt_tx_de_classify_stats_tlv *htt_stats_buf = tag_buf;
1316 u8 *buf = stats_req->buf;
1317 u32 len = stats_req->buf_len;
1318 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1319
1320 if (tag_len < sizeof(*htt_stats_buf))
1321 return;
1322
1323 len += scnprintf(buf + len, buf_len - len, "HTT_TX_DE_CLASSIFY_STATS_TLV:\n");
1324 len += scnprintf(buf + len, buf_len - len, "arp_packets = %u\n",
1325 le32_to_cpu(htt_stats_buf->arp_packets));
1326 len += scnprintf(buf + len, buf_len - len, "igmp_packets = %u\n",
1327 le32_to_cpu(htt_stats_buf->igmp_packets));
1328 len += scnprintf(buf + len, buf_len - len, "dhcp_packets = %u\n",
1329 le32_to_cpu(htt_stats_buf->dhcp_packets));
1330 len += scnprintf(buf + len, buf_len - len, "host_inspected = %u\n",
1331 le32_to_cpu(htt_stats_buf->host_inspected));
1332 len += scnprintf(buf + len, buf_len - len, "htt_included = %u\n",
1333 le32_to_cpu(htt_stats_buf->htt_included));
1334 len += scnprintf(buf + len, buf_len - len, "htt_valid_mcs = %u\n",
1335 le32_to_cpu(htt_stats_buf->htt_valid_mcs));
1336 len += scnprintf(buf + len, buf_len - len, "htt_valid_nss = %u\n",
1337 le32_to_cpu(htt_stats_buf->htt_valid_nss));
1338 len += scnprintf(buf + len, buf_len - len, "htt_valid_preamble_type = %u\n",
1339 le32_to_cpu(htt_stats_buf->htt_valid_preamble_type));
1340 len += scnprintf(buf + len, buf_len - len, "htt_valid_chainmask = %u\n",
1341 le32_to_cpu(htt_stats_buf->htt_valid_chainmask));
1342 len += scnprintf(buf + len, buf_len - len, "htt_valid_guard_interval = %u\n",
1343 le32_to_cpu(htt_stats_buf->htt_valid_guard_interval));
1344 len += scnprintf(buf + len, buf_len - len, "htt_valid_retries = %u\n",
1345 le32_to_cpu(htt_stats_buf->htt_valid_retries));
1346 len += scnprintf(buf + len, buf_len - len, "htt_valid_bw_info = %u\n",
1347 le32_to_cpu(htt_stats_buf->htt_valid_bw_info));
1348 len += scnprintf(buf + len, buf_len - len, "htt_valid_power = %u\n",
1349 le32_to_cpu(htt_stats_buf->htt_valid_power));
1350 len += scnprintf(buf + len, buf_len - len, "htt_valid_key_flags = 0x%x\n",
1351 le32_to_cpu(htt_stats_buf->htt_valid_key_flags));
1352 len += scnprintf(buf + len, buf_len - len, "htt_valid_no_encryption = %u\n",
1353 le32_to_cpu(htt_stats_buf->htt_valid_no_encryption));
1354 len += scnprintf(buf + len, buf_len - len, "fse_entry_count = %u\n",
1355 le32_to_cpu(htt_stats_buf->fse_entry_count));
1356 len += scnprintf(buf + len, buf_len - len, "fse_priority_be = %u\n",
1357 le32_to_cpu(htt_stats_buf->fse_priority_be));
1358 len += scnprintf(buf + len, buf_len - len, "fse_priority_high = %u\n",
1359 le32_to_cpu(htt_stats_buf->fse_priority_high));
1360 len += scnprintf(buf + len, buf_len - len, "fse_priority_low = %u\n",
1361 le32_to_cpu(htt_stats_buf->fse_priority_low));
1362 len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_be = %u\n",
1363 le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_be));
1364 len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_over_sub = %u\n",
1365 le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_over_sub));
1366 len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_bursty = %u\n",
1367 le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_bursty));
1368 len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_interactive = %u\n",
1369 le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_interactive));
1370 len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_periodic = %u\n",
1371 le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_periodic));
1372 len += scnprintf(buf + len, buf_len - len, "fse_hwqueue_alloc = %u\n",
1373 le32_to_cpu(htt_stats_buf->fse_hwqueue_alloc));
1374 len += scnprintf(buf + len, buf_len - len, "fse_hwqueue_created = %u\n",
1375 le32_to_cpu(htt_stats_buf->fse_hwqueue_created));
1376 len += scnprintf(buf + len, buf_len - len, "fse_hwqueue_send_to_host = %u\n",
1377 le32_to_cpu(htt_stats_buf->fse_hwqueue_send_to_host));
1378 len += scnprintf(buf + len, buf_len - len, "mcast_entry = %u\n",
1379 le32_to_cpu(htt_stats_buf->mcast_entry));
1380 len += scnprintf(buf + len, buf_len - len, "bcast_entry = %u\n",
1381 le32_to_cpu(htt_stats_buf->bcast_entry));
1382 len += scnprintf(buf + len, buf_len - len, "htt_update_peer_cache = %u\n",
1383 le32_to_cpu(htt_stats_buf->htt_update_peer_cache));
1384 len += scnprintf(buf + len, buf_len - len, "htt_learning_frame = %u\n",
1385 le32_to_cpu(htt_stats_buf->htt_learning_frame));
1386 len += scnprintf(buf + len, buf_len - len, "fse_invalid_peer = %u\n",
1387 le32_to_cpu(htt_stats_buf->fse_invalid_peer));
1388 len += scnprintf(buf + len, buf_len - len, "mec_notify = %u\n\n",
1389 le32_to_cpu(htt_stats_buf->mec_notify));
1390
1391 stats_req->buf_len = len;
1392 }
1393
1394 static void
ath12k_htt_print_tx_de_classify_failed_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1395 ath12k_htt_print_tx_de_classify_failed_stats_tlv(const void *tag_buf, u16 tag_len,
1396 struct debug_htt_stats_req *stats_req)
1397 {
1398 const struct ath12k_htt_tx_de_classify_failed_stats_tlv *htt_stats_buf = tag_buf;
1399 u8 *buf = stats_req->buf;
1400 u32 len = stats_req->buf_len;
1401 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1402
1403 if (tag_len < sizeof(*htt_stats_buf))
1404 return;
1405
1406 len += scnprintf(buf + len, buf_len - len,
1407 "HTT_TX_DE_CLASSIFY_FAILED_STATS_TLV:\n");
1408 len += scnprintf(buf + len, buf_len - len, "ap_bss_peer_not_found = %u\n",
1409 le32_to_cpu(htt_stats_buf->ap_bss_peer_not_found));
1410 len += scnprintf(buf + len, buf_len - len, "ap_bcast_mcast_no_peer = %u\n",
1411 le32_to_cpu(htt_stats_buf->ap_bcast_mcast_no_peer));
1412 len += scnprintf(buf + len, buf_len - len, "sta_delete_in_progress = %u\n",
1413 le32_to_cpu(htt_stats_buf->sta_delete_in_progress));
1414 len += scnprintf(buf + len, buf_len - len, "ibss_no_bss_peer = %u\n",
1415 le32_to_cpu(htt_stats_buf->ibss_no_bss_peer));
1416 len += scnprintf(buf + len, buf_len - len, "invalid_vdev_type = %u\n",
1417 le32_to_cpu(htt_stats_buf->invalid_vdev_type));
1418 len += scnprintf(buf + len, buf_len - len, "invalid_ast_peer_entry = %u\n",
1419 le32_to_cpu(htt_stats_buf->invalid_ast_peer_entry));
1420 len += scnprintf(buf + len, buf_len - len, "peer_entry_invalid = %u\n",
1421 le32_to_cpu(htt_stats_buf->peer_entry_invalid));
1422 len += scnprintf(buf + len, buf_len - len, "ethertype_not_ip = %u\n",
1423 le32_to_cpu(htt_stats_buf->ethertype_not_ip));
1424 len += scnprintf(buf + len, buf_len - len, "eapol_lookup_failed = %u\n",
1425 le32_to_cpu(htt_stats_buf->eapol_lookup_failed));
1426 len += scnprintf(buf + len, buf_len - len, "qpeer_not_allow_data = %u\n",
1427 le32_to_cpu(htt_stats_buf->qpeer_not_allow_data));
1428 len += scnprintf(buf + len, buf_len - len, "fse_tid_override = %u\n",
1429 le32_to_cpu(htt_stats_buf->fse_tid_override));
1430 len += scnprintf(buf + len, buf_len - len, "ipv6_jumbogram_zero_length = %u\n",
1431 le32_to_cpu(htt_stats_buf->ipv6_jumbogram_zero_length));
1432 len += scnprintf(buf + len, buf_len - len, "qos_to_non_qos_in_prog = %u\n",
1433 le32_to_cpu(htt_stats_buf->qos_to_non_qos_in_prog));
1434 len += scnprintf(buf + len, buf_len - len, "ap_bcast_mcast_eapol = %u\n",
1435 le32_to_cpu(htt_stats_buf->ap_bcast_mcast_eapol));
1436 len += scnprintf(buf + len, buf_len - len, "unicast_on_ap_bss_peer = %u\n",
1437 le32_to_cpu(htt_stats_buf->unicast_on_ap_bss_peer));
1438 len += scnprintf(buf + len, buf_len - len, "ap_vdev_invalid = %u\n",
1439 le32_to_cpu(htt_stats_buf->ap_vdev_invalid));
1440 len += scnprintf(buf + len, buf_len - len, "incomplete_llc = %u\n",
1441 le32_to_cpu(htt_stats_buf->incomplete_llc));
1442 len += scnprintf(buf + len, buf_len - len, "eapol_duplicate_m3 = %u\n",
1443 le32_to_cpu(htt_stats_buf->eapol_duplicate_m3));
1444 len += scnprintf(buf + len, buf_len - len, "eapol_duplicate_m4 = %u\n\n",
1445 le32_to_cpu(htt_stats_buf->eapol_duplicate_m4));
1446
1447 stats_req->buf_len = len;
1448 }
1449
1450 static void
ath12k_htt_print_tx_de_classify_status_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1451 ath12k_htt_print_tx_de_classify_status_stats_tlv(const void *tag_buf, u16 tag_len,
1452 struct debug_htt_stats_req *stats_req)
1453 {
1454 const struct ath12k_htt_tx_de_classify_status_stats_tlv *htt_stats_buf = tag_buf;
1455 u8 *buf = stats_req->buf;
1456 u32 len = stats_req->buf_len;
1457 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1458
1459 if (tag_len < sizeof(*htt_stats_buf))
1460 return;
1461
1462 len += scnprintf(buf + len, buf_len - len,
1463 "HTT_TX_DE_CLASSIFY_STATUS_STATS_TLV:\n");
1464 len += scnprintf(buf + len, buf_len - len, "eok = %u\n",
1465 le32_to_cpu(htt_stats_buf->eok));
1466 len += scnprintf(buf + len, buf_len - len, "classify_done = %u\n",
1467 le32_to_cpu(htt_stats_buf->classify_done));
1468 len += scnprintf(buf + len, buf_len - len, "lookup_failed = %u\n",
1469 le32_to_cpu(htt_stats_buf->lookup_failed));
1470 len += scnprintf(buf + len, buf_len - len, "send_host_dhcp = %u\n",
1471 le32_to_cpu(htt_stats_buf->send_host_dhcp));
1472 len += scnprintf(buf + len, buf_len - len, "send_host_mcast = %u\n",
1473 le32_to_cpu(htt_stats_buf->send_host_mcast));
1474 len += scnprintf(buf + len, buf_len - len, "send_host_unknown_dest = %u\n",
1475 le32_to_cpu(htt_stats_buf->send_host_unknown_dest));
1476 len += scnprintf(buf + len, buf_len - len, "send_host = %u\n",
1477 le32_to_cpu(htt_stats_buf->send_host));
1478 len += scnprintf(buf + len, buf_len - len, "status_invalid = %u\n\n",
1479 le32_to_cpu(htt_stats_buf->status_invalid));
1480
1481 stats_req->buf_len = len;
1482 }
1483
1484 static void
ath12k_htt_print_tx_de_enqueue_packets_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1485 ath12k_htt_print_tx_de_enqueue_packets_stats_tlv(const void *tag_buf, u16 tag_len,
1486 struct debug_htt_stats_req *stats_req)
1487 {
1488 const struct ath12k_htt_tx_de_enqueue_packets_stats_tlv *htt_stats_buf = tag_buf;
1489 u8 *buf = stats_req->buf;
1490 u32 len = stats_req->buf_len;
1491 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1492
1493 if (tag_len < sizeof(*htt_stats_buf))
1494 return;
1495
1496 len += scnprintf(buf + len, buf_len - len,
1497 "HTT_TX_DE_ENQUEUE_PACKETS_STATS_TLV:\n");
1498 len += scnprintf(buf + len, buf_len - len, "enqueued_pkts = %u\n",
1499 le32_to_cpu(htt_stats_buf->enqueued_pkts));
1500 len += scnprintf(buf + len, buf_len - len, "to_tqm = %u\n",
1501 le32_to_cpu(htt_stats_buf->to_tqm));
1502 len += scnprintf(buf + len, buf_len - len, "to_tqm_bypass = %u\n\n",
1503 le32_to_cpu(htt_stats_buf->to_tqm_bypass));
1504
1505 stats_req->buf_len = len;
1506 }
1507
1508 static void
ath12k_htt_print_tx_de_enqueue_discard_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1509 ath12k_htt_print_tx_de_enqueue_discard_stats_tlv(const void *tag_buf, u16 tag_len,
1510 struct debug_htt_stats_req *stats_req)
1511 {
1512 const struct ath12k_htt_tx_de_enqueue_discard_stats_tlv *htt_stats_buf = tag_buf;
1513 u8 *buf = stats_req->buf;
1514 u32 len = stats_req->buf_len;
1515 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1516
1517 if (tag_len < sizeof(*htt_stats_buf))
1518 return;
1519
1520 len += scnprintf(buf + len, buf_len - len,
1521 "HTT_TX_DE_ENQUEUE_DISCARD_STATS_TLV:\n");
1522 len += scnprintf(buf + len, buf_len - len, "discarded_pkts = %u\n",
1523 le32_to_cpu(htt_stats_buf->discarded_pkts));
1524 len += scnprintf(buf + len, buf_len - len, "local_frames = %u\n",
1525 le32_to_cpu(htt_stats_buf->local_frames));
1526 len += scnprintf(buf + len, buf_len - len, "is_ext_msdu = %u\n\n",
1527 le32_to_cpu(htt_stats_buf->is_ext_msdu));
1528
1529 stats_req->buf_len = len;
1530 }
1531
1532 static void
ath12k_htt_print_tx_de_compl_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1533 ath12k_htt_print_tx_de_compl_stats_tlv(const void *tag_buf, u16 tag_len,
1534 struct debug_htt_stats_req *stats_req)
1535 {
1536 const struct ath12k_htt_tx_de_compl_stats_tlv *htt_stats_buf = tag_buf;
1537 u8 *buf = stats_req->buf;
1538 u32 len = stats_req->buf_len;
1539 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1540
1541 if (tag_len < sizeof(*htt_stats_buf))
1542 return;
1543
1544 len += scnprintf(buf + len, buf_len - len, "HTT_TX_DE_COMPL_STATS_TLV:\n");
1545 len += scnprintf(buf + len, buf_len - len, "tcl_dummy_frame = %u\n",
1546 le32_to_cpu(htt_stats_buf->tcl_dummy_frame));
1547 len += scnprintf(buf + len, buf_len - len, "tqm_dummy_frame = %u\n",
1548 le32_to_cpu(htt_stats_buf->tqm_dummy_frame));
1549 len += scnprintf(buf + len, buf_len - len, "tqm_notify_frame = %u\n",
1550 le32_to_cpu(htt_stats_buf->tqm_notify_frame));
1551 len += scnprintf(buf + len, buf_len - len, "fw2wbm_enq = %u\n",
1552 le32_to_cpu(htt_stats_buf->fw2wbm_enq));
1553 len += scnprintf(buf + len, buf_len - len, "tqm_bypass_frame = %u\n\n",
1554 le32_to_cpu(htt_stats_buf->tqm_bypass_frame));
1555
1556 stats_req->buf_len = len;
1557 }
1558
1559 static void
ath12k_htt_print_tx_selfgen_cmn_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1560 ath12k_htt_print_tx_selfgen_cmn_stats_tlv(const void *tag_buf, u16 tag_len,
1561 struct debug_htt_stats_req *stats_req)
1562 {
1563 const struct ath12k_htt_tx_selfgen_cmn_stats_tlv *htt_stats_buf = tag_buf;
1564 u8 *buf = stats_req->buf;
1565 u32 len = stats_req->buf_len;
1566 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1567 u32 mac_id_word;
1568
1569 if (tag_len < sizeof(*htt_stats_buf))
1570 return;
1571
1572 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
1573
1574 len += scnprintf(buf + len, buf_len - len, "HTT_TX_SELFGEN_CMN_STATS_TLV:\n");
1575 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
1576 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
1577 len += scnprintf(buf + len, buf_len - len, "su_bar = %u\n",
1578 le32_to_cpu(htt_stats_buf->su_bar));
1579 len += scnprintf(buf + len, buf_len - len, "rts = %u\n",
1580 le32_to_cpu(htt_stats_buf->rts));
1581 len += scnprintf(buf + len, buf_len - len, "cts2self = %u\n",
1582 le32_to_cpu(htt_stats_buf->cts2self));
1583 len += scnprintf(buf + len, buf_len - len, "qos_null = %u\n",
1584 le32_to_cpu(htt_stats_buf->qos_null));
1585 len += scnprintf(buf + len, buf_len - len, "delayed_bar_1 = %u\n",
1586 le32_to_cpu(htt_stats_buf->delayed_bar_1));
1587 len += scnprintf(buf + len, buf_len - len, "delayed_bar_2 = %u\n",
1588 le32_to_cpu(htt_stats_buf->delayed_bar_2));
1589 len += scnprintf(buf + len, buf_len - len, "delayed_bar_3 = %u\n",
1590 le32_to_cpu(htt_stats_buf->delayed_bar_3));
1591 len += scnprintf(buf + len, buf_len - len, "delayed_bar_4 = %u\n",
1592 le32_to_cpu(htt_stats_buf->delayed_bar_4));
1593 len += scnprintf(buf + len, buf_len - len, "delayed_bar_5 = %u\n",
1594 le32_to_cpu(htt_stats_buf->delayed_bar_5));
1595 len += scnprintf(buf + len, buf_len - len, "delayed_bar_6 = %u\n",
1596 le32_to_cpu(htt_stats_buf->delayed_bar_6));
1597 len += scnprintf(buf + len, buf_len - len, "delayed_bar_7 = %u\n\n",
1598 le32_to_cpu(htt_stats_buf->delayed_bar_7));
1599
1600 stats_req->buf_len = len;
1601 }
1602
1603 static void
ath12k_htt_print_tx_selfgen_ac_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1604 ath12k_htt_print_tx_selfgen_ac_stats_tlv(const void *tag_buf, u16 tag_len,
1605 struct debug_htt_stats_req *stats_req)
1606 {
1607 const struct ath12k_htt_tx_selfgen_ac_stats_tlv *htt_stats_buf = tag_buf;
1608 u8 *buf = stats_req->buf;
1609 u32 len = stats_req->buf_len;
1610 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1611
1612 if (tag_len < sizeof(*htt_stats_buf))
1613 return;
1614
1615 len += scnprintf(buf + len, buf_len - len, "HTT_TX_SELFGEN_AC_STATS_TLV:\n");
1616 len += scnprintf(buf + len, buf_len - len, "ac_su_ndpa_tried = %u\n",
1617 le32_to_cpu(htt_stats_buf->ac_su_ndpa));
1618 len += scnprintf(buf + len, buf_len - len, "ac_su_ndp_tried = %u\n",
1619 le32_to_cpu(htt_stats_buf->ac_su_ndp));
1620 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_ndpa_tried = %u\n",
1621 le32_to_cpu(htt_stats_buf->ac_mu_mimo_ndpa));
1622 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_ndp_tried = %u\n",
1623 le32_to_cpu(htt_stats_buf->ac_mu_mimo_ndp));
1624 len += print_array_to_buf_index(buf, len, "ac_mu_mimo_brpollX_tried = ", 1,
1625 htt_stats_buf->ac_mu_mimo_brpoll,
1626 ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS - 1,
1627 "\n\n");
1628
1629 stats_req->buf_len = len;
1630 }
1631
1632 static void
ath12k_htt_print_tx_selfgen_ax_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1633 ath12k_htt_print_tx_selfgen_ax_stats_tlv(const void *tag_buf, u16 tag_len,
1634 struct debug_htt_stats_req *stats_req)
1635 {
1636 const struct ath12k_htt_tx_selfgen_ax_stats_tlv *htt_stats_buf = tag_buf;
1637 u8 *buf = stats_req->buf;
1638 u32 len = stats_req->buf_len;
1639 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1640
1641 if (tag_len < sizeof(*htt_stats_buf))
1642 return;
1643
1644 len += scnprintf(buf + len, buf_len - len, "HTT_TX_SELFGEN_AX_STATS_TLV:\n");
1645 len += scnprintf(buf + len, buf_len - len, "ax_su_ndpa_tried = %u\n",
1646 le32_to_cpu(htt_stats_buf->ax_su_ndpa));
1647 len += scnprintf(buf + len, buf_len - len, "ax_su_ndp_tried = %u\n",
1648 le32_to_cpu(htt_stats_buf->ax_su_ndp));
1649 len += scnprintf(buf + len, buf_len - len, "ax_mu_mimo_ndpa_tried = %u\n",
1650 le32_to_cpu(htt_stats_buf->ax_mu_mimo_ndpa));
1651 len += scnprintf(buf + len, buf_len - len, "ax_mu_mimo_ndp_tried = %u\n",
1652 le32_to_cpu(htt_stats_buf->ax_mu_mimo_ndp));
1653 len += print_array_to_buf_index(buf, len, "ax_mu_mimo_brpollX_tried = ", 1,
1654 htt_stats_buf->ax_mu_mimo_brpoll,
1655 ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS - 1, "\n");
1656 len += scnprintf(buf + len, buf_len - len, "ax_basic_trigger = %u\n",
1657 le32_to_cpu(htt_stats_buf->ax_basic_trigger));
1658 len += scnprintf(buf + len, buf_len - len, "ax_ulmumimo_total_trigger = %u\n",
1659 le32_to_cpu(htt_stats_buf->ax_ulmumimo_trigger));
1660 len += scnprintf(buf + len, buf_len - len, "ax_bsr_trigger = %u\n",
1661 le32_to_cpu(htt_stats_buf->ax_bsr_trigger));
1662 len += scnprintf(buf + len, buf_len - len, "ax_mu_bar_trigger = %u\n",
1663 le32_to_cpu(htt_stats_buf->ax_mu_bar_trigger));
1664 len += scnprintf(buf + len, buf_len - len, "ax_mu_rts_trigger = %u\n\n",
1665 le32_to_cpu(htt_stats_buf->ax_mu_rts_trigger));
1666
1667 stats_req->buf_len = len;
1668 }
1669
1670 static void
ath12k_htt_print_tx_selfgen_be_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1671 ath12k_htt_print_tx_selfgen_be_stats_tlv(const void *tag_buf, u16 tag_len,
1672 struct debug_htt_stats_req *stats_req)
1673 {
1674 const struct ath12k_htt_tx_selfgen_be_stats_tlv *htt_stats_buf = tag_buf;
1675 u8 *buf = stats_req->buf;
1676 u32 len = stats_req->buf_len;
1677 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1678
1679 if (tag_len < sizeof(*htt_stats_buf))
1680 return;
1681
1682 len += scnprintf(buf + len, buf_len - len, "HTT_TX_SELFGEN_BE_STATS_TLV:\n");
1683 len += scnprintf(buf + len, buf_len - len, "be_su_ndpa_queued = %u\n",
1684 le32_to_cpu(htt_stats_buf->be_su_ndpa_queued));
1685 len += scnprintf(buf + len, buf_len - len, "be_su_ndpa_tried = %u\n",
1686 le32_to_cpu(htt_stats_buf->be_su_ndpa));
1687 len += scnprintf(buf + len, buf_len - len, "be_su_ndp_queued = %u\n",
1688 le32_to_cpu(htt_stats_buf->be_su_ndp_queued));
1689 len += scnprintf(buf + len, buf_len - len, "be_su_ndp_tried = %u\n",
1690 le32_to_cpu(htt_stats_buf->be_su_ndp));
1691 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndpa_queued = %u\n",
1692 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndpa_queued));
1693 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndpa_tried = %u\n",
1694 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndpa));
1695 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndp_queued = %u\n",
1696 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndp_queued));
1697 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndp_tried = %u\n",
1698 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndp));
1699 len += print_array_to_buf_index(buf, len, "be_mu_mimo_brpollX_queued = ", 1,
1700 htt_stats_buf->be_mu_mimo_brpoll_queued,
1701 ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS - 1,
1702 "\n");
1703 len += print_array_to_buf_index(buf, len, "be_mu_mimo_brpollX_tried = ", 1,
1704 htt_stats_buf->be_mu_mimo_brpoll,
1705 ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS - 1,
1706 "\n");
1707 len += print_array_to_buf(buf, len, "be_ul_mumimo_trigger = ",
1708 htt_stats_buf->be_ul_mumimo_trigger,
1709 ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS, "\n");
1710 len += scnprintf(buf + len, buf_len - len, "be_basic_trigger = %u\n",
1711 le32_to_cpu(htt_stats_buf->be_basic_trigger));
1712 len += scnprintf(buf + len, buf_len - len, "be_ulmumimo_total_trigger = %u\n",
1713 le32_to_cpu(htt_stats_buf->be_ulmumimo_trigger));
1714 len += scnprintf(buf + len, buf_len - len, "be_bsr_trigger = %u\n",
1715 le32_to_cpu(htt_stats_buf->be_bsr_trigger));
1716 len += scnprintf(buf + len, buf_len - len, "be_mu_bar_trigger = %u\n",
1717 le32_to_cpu(htt_stats_buf->be_mu_bar_trigger));
1718 len += scnprintf(buf + len, buf_len - len, "be_mu_rts_trigger = %u\n\n",
1719 le32_to_cpu(htt_stats_buf->be_mu_rts_trigger));
1720
1721 stats_req->buf_len = len;
1722 }
1723
1724 static void
ath12k_htt_print_tx_selfgen_ac_err_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1725 ath12k_htt_print_tx_selfgen_ac_err_stats_tlv(const void *tag_buf, u16 tag_len,
1726 struct debug_htt_stats_req *stats_req)
1727 {
1728 const struct ath12k_htt_tx_selfgen_ac_err_stats_tlv *htt_stats_buf = tag_buf;
1729 u8 *buf = stats_req->buf;
1730 u32 len = stats_req->buf_len;
1731 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1732
1733 if (tag_len < sizeof(*htt_stats_buf))
1734 return;
1735
1736 len += scnprintf(buf + len, buf_len - len, "HTT_TX_SELFGEN_AC_ERR_STATS_TLV:\n");
1737 len += scnprintf(buf + len, buf_len - len, "ac_su_ndp_err = %u\n",
1738 le32_to_cpu(htt_stats_buf->ac_su_ndp_err));
1739 len += scnprintf(buf + len, buf_len - len, "ac_su_ndpa_err = %u\n",
1740 le32_to_cpu(htt_stats_buf->ac_su_ndpa_err));
1741 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_ndpa_err = %u\n",
1742 le32_to_cpu(htt_stats_buf->ac_mu_mimo_ndpa_err));
1743 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_ndp_err = %u\n",
1744 le32_to_cpu(htt_stats_buf->ac_mu_mimo_ndp_err));
1745 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_brp1_err = %u\n",
1746 le32_to_cpu(htt_stats_buf->ac_mu_mimo_brp1_err));
1747 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_brp2_err = %u\n",
1748 le32_to_cpu(htt_stats_buf->ac_mu_mimo_brp2_err));
1749 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_brp3_err = %u\n\n",
1750 le32_to_cpu(htt_stats_buf->ac_mu_mimo_brp3_err));
1751
1752 stats_req->buf_len = len;
1753 }
1754
1755 static void
ath12k_htt_print_tx_selfgen_ax_err_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1756 ath12k_htt_print_tx_selfgen_ax_err_stats_tlv(const void *tag_buf, u16 tag_len,
1757 struct debug_htt_stats_req *stats_req)
1758 {
1759 const struct ath12k_htt_tx_selfgen_ax_err_stats_tlv *htt_stats_buf = tag_buf;
1760 u8 *buf = stats_req->buf;
1761 u32 len = stats_req->buf_len;
1762 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1763
1764 if (tag_len < sizeof(*htt_stats_buf))
1765 return;
1766
1767 len += scnprintf(buf + len, buf_len - len, "HTT_TX_SELFGEN_AX_ERR_STATS_TLV:\n");
1768 len += scnprintf(buf + len, buf_len - len, "ax_su_ndp_err = %u\n",
1769 le32_to_cpu(htt_stats_buf->ax_su_ndp_err));
1770 len += scnprintf(buf + len, buf_len - len, "ax_su_ndpa_err = %u\n",
1771 le32_to_cpu(htt_stats_buf->ax_su_ndpa_err));
1772 len += scnprintf(buf + len, buf_len - len, "ax_mu_mimo_ndpa_err = %u\n",
1773 le32_to_cpu(htt_stats_buf->ax_mu_mimo_ndpa_err));
1774 len += scnprintf(buf + len, buf_len - len, "ax_mu_mimo_ndp_err = %u\n",
1775 le32_to_cpu(htt_stats_buf->ax_mu_mimo_ndp_err));
1776 len += print_array_to_buf_index(buf, len, "ax_mu_mimo_brpX_err", 1,
1777 htt_stats_buf->ax_mu_mimo_brp_err,
1778 ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS - 1,
1779 "\n");
1780 len += scnprintf(buf + len, buf_len - len, "ax_basic_trigger_err = %u\n",
1781 le32_to_cpu(htt_stats_buf->ax_basic_trigger_err));
1782 len += scnprintf(buf + len, buf_len - len, "ax_ulmumimo_total_trigger_err = %u\n",
1783 le32_to_cpu(htt_stats_buf->ax_ulmumimo_trigger_err));
1784 len += scnprintf(buf + len, buf_len - len, "ax_bsr_trigger_err = %u\n",
1785 le32_to_cpu(htt_stats_buf->ax_bsr_trigger_err));
1786 len += scnprintf(buf + len, buf_len - len, "ax_mu_bar_trigger_err = %u\n",
1787 le32_to_cpu(htt_stats_buf->ax_mu_bar_trigger_err));
1788 len += scnprintf(buf + len, buf_len - len, "ax_mu_rts_trigger_err = %u\n\n",
1789 le32_to_cpu(htt_stats_buf->ax_mu_rts_trigger_err));
1790
1791 stats_req->buf_len = len;
1792 }
1793
1794 static void
ath12k_htt_print_tx_selfgen_be_err_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1795 ath12k_htt_print_tx_selfgen_be_err_stats_tlv(const void *tag_buf, u16 tag_len,
1796 struct debug_htt_stats_req *stats_req)
1797 {
1798 const struct ath12k_htt_tx_selfgen_be_err_stats_tlv *htt_stats_buf = tag_buf;
1799 u8 *buf = stats_req->buf;
1800 u32 len = stats_req->buf_len;
1801 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1802
1803 if (tag_len < sizeof(*htt_stats_buf))
1804 return;
1805
1806 len += scnprintf(buf + len, buf_len - len, "HTT_TX_SELFGEN_BE_ERR_STATS_TLV:\n");
1807 len += scnprintf(buf + len, buf_len - len, "be_su_ndp_err = %u\n",
1808 le32_to_cpu(htt_stats_buf->be_su_ndp_err));
1809 len += scnprintf(buf + len, buf_len - len, "be_su_ndp_flushed = %u\n",
1810 le32_to_cpu(htt_stats_buf->be_su_ndp_flushed));
1811 len += scnprintf(buf + len, buf_len - len, "be_su_ndpa_err = %u\n",
1812 le32_to_cpu(htt_stats_buf->be_su_ndpa_err));
1813 len += scnprintf(buf + len, buf_len - len, "be_su_ndpa_flushed = %u\n",
1814 le32_to_cpu(htt_stats_buf->be_su_ndpa_flushed));
1815 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndpa_err = %u\n",
1816 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndpa_err));
1817 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndpa_flushed = %u\n",
1818 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndpa_flushed));
1819 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndp_err = %u\n",
1820 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndp_err));
1821 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_ndp_flushed = %u\n",
1822 le32_to_cpu(htt_stats_buf->be_mu_mimo_ndp_flushed));
1823 len += print_array_to_buf_index(buf, len, "be_mu_mimo_brpX_err", 1,
1824 htt_stats_buf->be_mu_mimo_brp_err,
1825 ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS - 1,
1826 "\n");
1827 len += print_array_to_buf_index(buf, len, "be_mu_mimo_brpollX_flushed", 1,
1828 htt_stats_buf->be_mu_mimo_brpoll_flushed,
1829 ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS - 1,
1830 "\n");
1831 len += print_array_to_buf(buf, len, "be_mu_mimo_num_cbf_rcvd_on_brp_err",
1832 htt_stats_buf->be_mu_mimo_brp_err_num_cbf_rxd,
1833 ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS, "\n");
1834 len += print_array_to_buf(buf, len, "be_ul_mumimo_trigger_err",
1835 htt_stats_buf->be_ul_mumimo_trigger_err,
1836 ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS, "\n");
1837 len += scnprintf(buf + len, buf_len - len, "be_basic_trigger_err = %u\n",
1838 le32_to_cpu(htt_stats_buf->be_basic_trigger_err));
1839 len += scnprintf(buf + len, buf_len - len, "be_ulmumimo_total_trig_err = %u\n",
1840 le32_to_cpu(htt_stats_buf->be_ulmumimo_trigger_err));
1841 len += scnprintf(buf + len, buf_len - len, "be_bsr_trigger_err = %u\n",
1842 le32_to_cpu(htt_stats_buf->be_bsr_trigger_err));
1843 len += scnprintf(buf + len, buf_len - len, "be_mu_bar_trigger_err = %u\n",
1844 le32_to_cpu(htt_stats_buf->be_mu_bar_trigger_err));
1845 len += scnprintf(buf + len, buf_len - len, "be_mu_rts_trigger_err = %u\n\n",
1846 le32_to_cpu(htt_stats_buf->be_mu_rts_trigger_err));
1847
1848 stats_req->buf_len = len;
1849 }
1850
1851 static void
ath12k_htt_print_tx_selfgen_ac_sched_status_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats)1852 ath12k_htt_print_tx_selfgen_ac_sched_status_stats_tlv(const void *tag_buf, u16 tag_len,
1853 struct debug_htt_stats_req *stats)
1854 {
1855 const struct ath12k_htt_tx_selfgen_ac_sched_status_stats_tlv *htt_stats_buf =
1856 tag_buf;
1857 u8 *buf = stats->buf;
1858 u32 len = stats->buf_len;
1859 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1860
1861 if (tag_len < sizeof(*htt_stats_buf))
1862 return;
1863
1864 len += scnprintf(buf + len, buf_len - len,
1865 "HTT_TX_SELFGEN_AC_SCHED_STATUS_STATS_TLV:\n");
1866 len += print_array_to_buf(buf, len, "ac_su_ndpa_sch_status",
1867 htt_stats_buf->ac_su_ndpa_sch_status,
1868 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1869 len += print_array_to_buf(buf, len, "ac_su_ndp_sch_status",
1870 htt_stats_buf->ac_su_ndp_sch_status,
1871 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1872 len += print_array_to_buf(buf, len, "ac_mu_mimo_ndpa_sch_status",
1873 htt_stats_buf->ac_mu_mimo_ndpa_sch_status,
1874 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1875 len += print_array_to_buf(buf, len, "ac_mu_mimo_ndp_sch_status",
1876 htt_stats_buf->ac_mu_mimo_ndp_sch_status,
1877 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1878 len += print_array_to_buf(buf, len, "ac_mu_mimo_brp_sch_status",
1879 htt_stats_buf->ac_mu_mimo_brp_sch_status,
1880 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1881 len += print_array_to_buf(buf, len, "ac_su_ndp_sch_flag_err",
1882 htt_stats_buf->ac_su_ndp_sch_flag_err,
1883 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1884 len += print_array_to_buf(buf, len, "ac_mu_mimo_ndp_sch_flag_err",
1885 htt_stats_buf->ac_mu_mimo_ndp_sch_flag_err,
1886 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1887 len += print_array_to_buf(buf, len, "ac_mu_mimo_brp_sch_flag_err",
1888 htt_stats_buf->ac_mu_mimo_brp_sch_flag_err,
1889 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n\n");
1890
1891 stats->buf_len = len;
1892 }
1893
1894 static void
ath12k_htt_print_tx_selfgen_ax_sched_status_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats)1895 ath12k_htt_print_tx_selfgen_ax_sched_status_stats_tlv(const void *tag_buf, u16 tag_len,
1896 struct debug_htt_stats_req *stats)
1897 {
1898 const struct ath12k_htt_tx_selfgen_ax_sched_status_stats_tlv *htt_stats_buf =
1899 tag_buf;
1900 u8 *buf = stats->buf;
1901 u32 len = stats->buf_len;
1902 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1903
1904 if (tag_len < sizeof(*htt_stats_buf))
1905 return;
1906
1907 len += scnprintf(buf + len, buf_len - len,
1908 "HTT_TX_SELFGEN_AX_SCHED_STATUS_STATS_TLV:\n");
1909 len += print_array_to_buf(buf, len, "ax_su_ndpa_sch_status",
1910 htt_stats_buf->ax_su_ndpa_sch_status,
1911 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1912 len += print_array_to_buf(buf, len, "ax_su_ndp_sch_status",
1913 htt_stats_buf->ax_su_ndp_sch_status,
1914 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1915 len += print_array_to_buf(buf, len, "ax_mu_mimo_ndpa_sch_status",
1916 htt_stats_buf->ax_mu_mimo_ndpa_sch_status,
1917 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1918 len += print_array_to_buf(buf, len, "ax_mu_mimo_ndp_sch_status",
1919 htt_stats_buf->ax_mu_mimo_ndp_sch_status,
1920 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1921 len += print_array_to_buf(buf, len, "ax_mu_brp_sch_status",
1922 htt_stats_buf->ax_mu_brp_sch_status,
1923 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1924 len += print_array_to_buf(buf, len, "ax_mu_bar_sch_status",
1925 htt_stats_buf->ax_mu_bar_sch_status,
1926 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1927 len += print_array_to_buf(buf, len, "ax_basic_trig_sch_status",
1928 htt_stats_buf->ax_basic_trig_sch_status,
1929 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1930 len += print_array_to_buf(buf, len, "ax_su_ndp_sch_flag_err",
1931 htt_stats_buf->ax_su_ndp_sch_flag_err,
1932 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1933 len += print_array_to_buf(buf, len, "ax_mu_mimo_ndp_sch_flag_err",
1934 htt_stats_buf->ax_mu_mimo_ndp_sch_flag_err,
1935 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1936 len += print_array_to_buf(buf, len, "ax_mu_brp_sch_flag_err",
1937 htt_stats_buf->ax_mu_brp_sch_flag_err,
1938 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1939 len += print_array_to_buf(buf, len, "ax_mu_bar_sch_flag_err",
1940 htt_stats_buf->ax_mu_bar_sch_flag_err,
1941 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1942 len += print_array_to_buf(buf, len, "ax_basic_trig_sch_flag_err",
1943 htt_stats_buf->ax_basic_trig_sch_flag_err,
1944 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1945 len += print_array_to_buf(buf, len, "ax_ulmumimo_trig_sch_status",
1946 htt_stats_buf->ax_ulmumimo_trig_sch_status,
1947 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1948 len += print_array_to_buf(buf, len, "ax_ulmumimo_trig_sch_flag_err",
1949 htt_stats_buf->ax_ulmumimo_trig_sch_flag_err,
1950 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n\n");
1951
1952 stats->buf_len = len;
1953 }
1954
1955 static void
ath12k_htt_print_tx_selfgen_be_sched_status_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats)1956 ath12k_htt_print_tx_selfgen_be_sched_status_stats_tlv(const void *tag_buf, u16 tag_len,
1957 struct debug_htt_stats_req *stats)
1958 {
1959 const struct ath12k_htt_tx_selfgen_be_sched_status_stats_tlv *htt_stats_buf =
1960 tag_buf;
1961 u8 *buf = stats->buf;
1962 u32 len = stats->buf_len;
1963 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1964
1965 if (tag_len < sizeof(*htt_stats_buf))
1966 return;
1967
1968 len += scnprintf(buf + len, buf_len - len,
1969 "HTT_TX_SELFGEN_BE_SCHED_STATUS_STATS_TLV:\n");
1970 len += print_array_to_buf(buf, len, "be_su_ndpa_sch_status",
1971 htt_stats_buf->be_su_ndpa_sch_status,
1972 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1973 len += print_array_to_buf(buf, len, "be_su_ndp_sch_status",
1974 htt_stats_buf->be_su_ndp_sch_status,
1975 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1976 len += print_array_to_buf(buf, len, "be_mu_mimo_ndpa_sch_status",
1977 htt_stats_buf->be_mu_mimo_ndpa_sch_status,
1978 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1979 len += print_array_to_buf(buf, len, "be_mu_mimo_ndp_sch_status",
1980 htt_stats_buf->be_mu_mimo_ndp_sch_status,
1981 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1982 len += print_array_to_buf(buf, len, "be_mu_brp_sch_status",
1983 htt_stats_buf->be_mu_brp_sch_status,
1984 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1985 len += print_array_to_buf(buf, len, "be_mu_bar_sch_status",
1986 htt_stats_buf->be_mu_bar_sch_status,
1987 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1988 len += print_array_to_buf(buf, len, "be_basic_trig_sch_status",
1989 htt_stats_buf->be_basic_trig_sch_status,
1990 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
1991 len += print_array_to_buf(buf, len, "be_su_ndp_sch_flag_err",
1992 htt_stats_buf->be_su_ndp_sch_flag_err,
1993 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1994 len += print_array_to_buf(buf, len, "be_mu_mimo_ndp_sch_flag_err",
1995 htt_stats_buf->be_mu_mimo_ndp_sch_flag_err,
1996 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
1997 len += print_array_to_buf(buf, len, "be_mu_brp_sch_flag_err",
1998 htt_stats_buf->be_mu_brp_sch_flag_err,
1999 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
2000 len += print_array_to_buf(buf, len, "be_mu_bar_sch_flag_err",
2001 htt_stats_buf->be_mu_bar_sch_flag_err,
2002 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
2003 len += print_array_to_buf(buf, len, "be_basic_trig_sch_flag_err",
2004 htt_stats_buf->be_basic_trig_sch_flag_err,
2005 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n");
2006 len += print_array_to_buf(buf, len, "be_basic_trig_sch_flag_err",
2007 htt_stats_buf->be_basic_trig_sch_flag_err,
2008 ATH12K_HTT_TX_PDEV_STATS_NUM_TX_ERR_STATUS, "\n");
2009 len += print_array_to_buf(buf, len, "be_ulmumimo_trig_sch_flag_err",
2010 htt_stats_buf->be_ulmumimo_trig_sch_flag_err,
2011 ATH12K_HTT_TX_SELFGEN_SCH_TSFLAG_ERR_STATS, "\n\n");
2012
2013 stats->buf_len = len;
2014 }
2015
2016 static void
ath12k_htt_print_stats_string_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2017 ath12k_htt_print_stats_string_tlv(const void *tag_buf, u16 tag_len,
2018 struct debug_htt_stats_req *stats_req)
2019 {
2020 const struct ath12k_htt_stats_string_tlv *htt_stats_buf = tag_buf;
2021 u8 *buf = stats_req->buf;
2022 u32 len = stats_req->buf_len;
2023 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2024 u8 i;
2025 u16 index = 0;
2026 u32 datum;
2027 char data[ATH12K_HTT_MAX_STRING_LEN] = {0};
2028
2029 tag_len = tag_len >> 2;
2030
2031 len += scnprintf(buf + len, buf_len - len, "HTT_STATS_STRING_TLV:\n");
2032 for (i = 0; i < tag_len; i++) {
2033 datum = __le32_to_cpu(htt_stats_buf->data[i]);
2034 index += scnprintf(&data[index], ATH12K_HTT_MAX_STRING_LEN - index,
2035 "%.*s", 4, (char *)&datum);
2036 if (index >= ATH12K_HTT_MAX_STRING_LEN)
2037 break;
2038 }
2039 len += scnprintf(buf + len, buf_len - len, "data = %s\n\n", data);
2040
2041 stats_req->buf_len = len;
2042 }
2043
2044 static void
ath12k_htt_print_sring_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2045 ath12k_htt_print_sring_stats_tlv(const void *tag_buf, u16 tag_len,
2046 struct debug_htt_stats_req *stats_req)
2047 {
2048 const struct ath12k_htt_sring_stats_tlv *htt_stats_buf = tag_buf;
2049 u8 *buf = stats_req->buf;
2050 u32 len = stats_req->buf_len;
2051 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2052 u32 mac_id_word;
2053 u32 avail_words;
2054 u32 head_tail_ptr;
2055 u32 sring_stat;
2056 u32 tail_ptr;
2057
2058 if (tag_len < sizeof(*htt_stats_buf))
2059 return;
2060
2061 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__ring_id__arena__ep);
2062 avail_words = __le32_to_cpu(htt_stats_buf->num_avail_words__num_valid_words);
2063 head_tail_ptr = __le32_to_cpu(htt_stats_buf->head_ptr__tail_ptr);
2064 sring_stat = __le32_to_cpu(htt_stats_buf->consumer_empty__producer_full);
2065 tail_ptr = __le32_to_cpu(htt_stats_buf->prefetch_count__internal_tail_ptr);
2066
2067 len += scnprintf(buf + len, buf_len - len, "HTT_SRING_STATS_TLV:\n");
2068 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
2069 u32_get_bits(mac_id_word, ATH12K_HTT_SRING_STATS_MAC_ID));
2070 len += scnprintf(buf + len, buf_len - len, "ring_id = %u\n",
2071 u32_get_bits(mac_id_word, ATH12K_HTT_SRING_STATS_RING_ID));
2072 len += scnprintf(buf + len, buf_len - len, "arena = %u\n",
2073 u32_get_bits(mac_id_word, ATH12K_HTT_SRING_STATS_ARENA));
2074 len += scnprintf(buf + len, buf_len - len, "ep = %u\n",
2075 u32_get_bits(mac_id_word, ATH12K_HTT_SRING_STATS_EP));
2076 len += scnprintf(buf + len, buf_len - len, "base_addr_lsb = 0x%x\n",
2077 le32_to_cpu(htt_stats_buf->base_addr_lsb));
2078 len += scnprintf(buf + len, buf_len - len, "base_addr_msb = 0x%x\n",
2079 le32_to_cpu(htt_stats_buf->base_addr_msb));
2080 len += scnprintf(buf + len, buf_len - len, "ring_size = %u\n",
2081 le32_to_cpu(htt_stats_buf->ring_size));
2082 len += scnprintf(buf + len, buf_len - len, "elem_size = %u\n",
2083 le32_to_cpu(htt_stats_buf->elem_size));
2084 len += scnprintf(buf + len, buf_len - len, "num_avail_words = %u\n",
2085 u32_get_bits(avail_words,
2086 ATH12K_HTT_SRING_STATS_NUM_AVAIL_WORDS));
2087 len += scnprintf(buf + len, buf_len - len, "num_valid_words = %u\n",
2088 u32_get_bits(avail_words,
2089 ATH12K_HTT_SRING_STATS_NUM_VALID_WORDS));
2090 len += scnprintf(buf + len, buf_len - len, "head_ptr = %u\n",
2091 u32_get_bits(head_tail_ptr, ATH12K_HTT_SRING_STATS_HEAD_PTR));
2092 len += scnprintf(buf + len, buf_len - len, "tail_ptr = %u\n",
2093 u32_get_bits(head_tail_ptr, ATH12K_HTT_SRING_STATS_TAIL_PTR));
2094 len += scnprintf(buf + len, buf_len - len, "consumer_empty = %u\n",
2095 u32_get_bits(sring_stat,
2096 ATH12K_HTT_SRING_STATS_CONSUMER_EMPTY));
2097 len += scnprintf(buf + len, buf_len - len, "producer_full = %u\n",
2098 u32_get_bits(head_tail_ptr,
2099 ATH12K_HTT_SRING_STATS_PRODUCER_FULL));
2100 len += scnprintf(buf + len, buf_len - len, "prefetch_count = %u\n",
2101 u32_get_bits(tail_ptr, ATH12K_HTT_SRING_STATS_PREFETCH_COUNT));
2102 len += scnprintf(buf + len, buf_len - len, "internal_tail_ptr = %u\n\n",
2103 u32_get_bits(tail_ptr,
2104 ATH12K_HTT_SRING_STATS_INTERNAL_TAIL_PTR));
2105
2106 stats_req->buf_len = len;
2107 }
2108
2109 static void
ath12k_htt_print_sfm_cmn_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2110 ath12k_htt_print_sfm_cmn_tlv(const void *tag_buf, u16 tag_len,
2111 struct debug_htt_stats_req *stats_req)
2112 {
2113 const struct ath12k_htt_sfm_cmn_tlv *htt_stats_buf = tag_buf;
2114 u8 *buf = stats_req->buf;
2115 u32 len = stats_req->buf_len;
2116 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2117 u32 mac_id_word;
2118
2119 if (tag_len < sizeof(*htt_stats_buf))
2120 return;
2121
2122 mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
2123
2124 len += scnprintf(buf + len, buf_len - len, "HTT_SFM_CMN_TLV:\n");
2125 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
2126 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
2127 len += scnprintf(buf + len, buf_len - len, "buf_total = %u\n",
2128 le32_to_cpu(htt_stats_buf->buf_total));
2129 len += scnprintf(buf + len, buf_len - len, "mem_empty = %u\n",
2130 le32_to_cpu(htt_stats_buf->mem_empty));
2131 len += scnprintf(buf + len, buf_len - len, "deallocate_bufs = %u\n",
2132 le32_to_cpu(htt_stats_buf->deallocate_bufs));
2133 len += scnprintf(buf + len, buf_len - len, "num_records = %u\n\n",
2134 le32_to_cpu(htt_stats_buf->num_records));
2135
2136 stats_req->buf_len = len;
2137 }
2138
2139 static void
ath12k_htt_print_sfm_client_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2140 ath12k_htt_print_sfm_client_tlv(const void *tag_buf, u16 tag_len,
2141 struct debug_htt_stats_req *stats_req)
2142 {
2143 const struct ath12k_htt_sfm_client_tlv *htt_stats_buf = tag_buf;
2144 u8 *buf = stats_req->buf;
2145 u32 len = stats_req->buf_len;
2146 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2147
2148 if (tag_len < sizeof(*htt_stats_buf))
2149 return;
2150
2151 len += scnprintf(buf + len, buf_len - len, "HTT_SFM_CLIENT_TLV:\n");
2152 len += scnprintf(buf + len, buf_len - len, "client_id = %u\n",
2153 le32_to_cpu(htt_stats_buf->client_id));
2154 len += scnprintf(buf + len, buf_len - len, "buf_min = %u\n",
2155 le32_to_cpu(htt_stats_buf->buf_min));
2156 len += scnprintf(buf + len, buf_len - len, "buf_max = %u\n",
2157 le32_to_cpu(htt_stats_buf->buf_max));
2158 len += scnprintf(buf + len, buf_len - len, "buf_busy = %u\n",
2159 le32_to_cpu(htt_stats_buf->buf_busy));
2160 len += scnprintf(buf + len, buf_len - len, "buf_alloc = %u\n",
2161 le32_to_cpu(htt_stats_buf->buf_alloc));
2162 len += scnprintf(buf + len, buf_len - len, "buf_avail = %u\n",
2163 le32_to_cpu(htt_stats_buf->buf_avail));
2164 len += scnprintf(buf + len, buf_len - len, "num_users = %u\n\n",
2165 le32_to_cpu(htt_stats_buf->num_users));
2166
2167 stats_req->buf_len = len;
2168 }
2169
2170 static void
ath12k_htt_print_sfm_client_user_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2171 ath12k_htt_print_sfm_client_user_tlv(const void *tag_buf, u16 tag_len,
2172 struct debug_htt_stats_req *stats_req)
2173 {
2174 const struct ath12k_htt_sfm_client_user_tlv *htt_stats_buf = tag_buf;
2175 u8 *buf = stats_req->buf;
2176 u32 len = stats_req->buf_len;
2177 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2178 u16 num_elems = tag_len >> 2;
2179
2180 len += scnprintf(buf + len, buf_len - len, "HTT_SFM_CLIENT_USER_TLV:\n");
2181 len += print_array_to_buf(buf, len, "dwords_used_by_user_n",
2182 htt_stats_buf->dwords_used_by_user_n,
2183 num_elems, "\n\n");
2184
2185 stats_req->buf_len = len;
2186 }
2187
2188 static void
ath12k_htt_print_tx_pdev_mu_mimo_sch_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2189 ath12k_htt_print_tx_pdev_mu_mimo_sch_stats_tlv(const void *tag_buf, u16 tag_len,
2190 struct debug_htt_stats_req *stats_req)
2191 {
2192 const struct ath12k_htt_tx_pdev_mu_mimo_sch_stats_tlv *htt_stats_buf = tag_buf;
2193 u8 *buf = stats_req->buf;
2194 u32 len = stats_req->buf_len;
2195 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2196 u8 i;
2197
2198 if (tag_len < sizeof(*htt_stats_buf))
2199 return;
2200
2201 len += scnprintf(buf + len, buf_len - len,
2202 "HTT_TX_PDEV_MU_MIMO_SCH_STATS_TLV:\n");
2203 len += scnprintf(buf + len, buf_len - len, "mu_mimo_sch_posted = %u\n",
2204 le32_to_cpu(htt_stats_buf->mu_mimo_sch_posted));
2205 len += scnprintf(buf + len, buf_len - len, "mu_mimo_sch_failed = %u\n",
2206 le32_to_cpu(htt_stats_buf->mu_mimo_sch_failed));
2207 len += scnprintf(buf + len, buf_len - len, "mu_mimo_ppdu_posted = %u\n",
2208 le32_to_cpu(htt_stats_buf->mu_mimo_ppdu_posted));
2209 len += scnprintf(buf + len, buf_len - len,
2210 "\nac_mu_mimo_sch_posted_per_group_index %u (SU) = %u\n", 0,
2211 le32_to_cpu(htt_stats_buf->ac_mu_mimo_per_grp_sz[0]));
2212 for (i = 1; i < ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS; i++) {
2213 len += scnprintf(buf + len, buf_len - len,
2214 "ac_mu_mimo_sch_posted_per_group_index %u ", i);
2215 len += scnprintf(buf + len, buf_len - len,
2216 "(TOTAL STREAMS = %u) = %u\n", i + 1,
2217 le32_to_cpu(htt_stats_buf->ac_mu_mimo_per_grp_sz[i]));
2218 }
2219
2220 for (i = 0; i < ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS; i++) {
2221 len += scnprintf(buf + len, buf_len - len,
2222 "ac_mu_mimo_sch_posted_per_group_index %u ",
2223 i + ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS);
2224 len += scnprintf(buf + len, buf_len - len,
2225 "(TOTAL STREAMS = %u) = %u\n",
2226 i + ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS + 1,
2227 le32_to_cpu(htt_stats_buf->ac_mu_mimo_grp_sz_ext[i]));
2228 }
2229
2230 len += scnprintf(buf + len, buf_len - len,
2231 "\nax_mu_mimo_sch_posted_per_group_index %u (SU) = %u\n", 0,
2232 le32_to_cpu(htt_stats_buf->ax_mu_mimo_per_grp_sz[0]));
2233 for (i = 1; i < ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS; i++) {
2234 len += scnprintf(buf + len, buf_len - len,
2235 "ax_mu_mimo_sch_posted_per_group_index %u ", i);
2236 len += scnprintf(buf + len, buf_len - len,
2237 "(TOTAL STREAMS = %u) = %u\n", i + 1,
2238 le32_to_cpu(htt_stats_buf->ax_mu_mimo_per_grp_sz[i]));
2239 }
2240
2241 len += scnprintf(buf + len, buf_len - len,
2242 "\nbe_mu_mimo_sch_posted_per_group_index %u (SU) = %u\n", 0,
2243 le32_to_cpu(htt_stats_buf->be_mu_mimo_per_grp_sz[0]));
2244 for (i = 1; i < ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS; i++) {
2245 len += scnprintf(buf + len, buf_len - len,
2246 "be_mu_mimo_sch_posted_per_group_index %u ", i);
2247 len += scnprintf(buf + len, buf_len - len,
2248 "(TOTAL STREAMS = %u) = %u\n", i + 1,
2249 le32_to_cpu(htt_stats_buf->be_mu_mimo_per_grp_sz[i]));
2250 }
2251
2252 len += scnprintf(buf + len, buf_len - len, "\n11ac MU_MIMO SCH STATS:\n");
2253 for (i = 0; i < ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS; i++) {
2254 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_sch_nusers_");
2255 len += scnprintf(buf + len, buf_len - len, "%u = %u\n", i,
2256 le32_to_cpu(htt_stats_buf->ac_mu_mimo_sch_nusers[i]));
2257 }
2258
2259 len += scnprintf(buf + len, buf_len - len, "\n11ax MU_MIMO SCH STATS:\n");
2260 for (i = 0; i < ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS; i++) {
2261 len += scnprintf(buf + len, buf_len - len, "ax_mu_mimo_sch_nusers_");
2262 len += scnprintf(buf + len, buf_len - len, "%u = %u\n", i,
2263 le32_to_cpu(htt_stats_buf->ax_mu_mimo_sch_nusers[i]));
2264 }
2265
2266 len += scnprintf(buf + len, buf_len - len, "\n11be MU_MIMO SCH STATS:\n");
2267 for (i = 0; i < ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS; i++) {
2268 len += scnprintf(buf + len, buf_len - len, "be_mu_mimo_sch_nusers_");
2269 len += scnprintf(buf + len, buf_len - len, "%u = %u\n", i,
2270 le32_to_cpu(htt_stats_buf->be_mu_mimo_sch_nusers[i]));
2271 }
2272
2273 len += scnprintf(buf + len, buf_len - len, "\n11ax OFDMA SCH STATS:\n");
2274 for (i = 0; i < ATH12K_HTT_TX_NUM_OFDMA_USER_STATS; i++) {
2275 len += scnprintf(buf + len, buf_len - len,
2276 "ax_ofdma_sch_nusers_%u = %u\n", i,
2277 le32_to_cpu(htt_stats_buf->ax_ofdma_sch_nusers[i]));
2278 len += scnprintf(buf + len, buf_len - len,
2279 "ax_ul_ofdma_basic_sch_nusers_%u = %u\n", i,
2280 le32_to_cpu(htt_stats_buf->ax_ul_ofdma_nusers[i]));
2281 len += scnprintf(buf + len, buf_len - len,
2282 "ax_ul_ofdma_bsr_sch_nusers_%u = %u\n", i,
2283 le32_to_cpu(htt_stats_buf->ax_ul_ofdma_bsr_nusers[i]));
2284 len += scnprintf(buf + len, buf_len - len,
2285 "ax_ul_ofdma_bar_sch_nusers_%u = %u\n", i,
2286 le32_to_cpu(htt_stats_buf->ax_ul_ofdma_bar_nusers[i]));
2287 len += scnprintf(buf + len, buf_len - len,
2288 "ax_ul_ofdma_brp_sch_nusers_%u = %u\n\n", i,
2289 le32_to_cpu(htt_stats_buf->ax_ul_ofdma_brp_nusers[i]));
2290 }
2291
2292 len += scnprintf(buf + len, buf_len - len, "11ax UL MUMIMO SCH STATS:\n");
2293 for (i = 0; i < ATH12K_HTT_TX_NUM_UL_MUMIMO_USER_STATS; i++) {
2294 len += scnprintf(buf + len, buf_len - len,
2295 "ax_ul_mumimo_basic_sch_nusers_%u = %u\n", i,
2296 le32_to_cpu(htt_stats_buf->ax_ul_mumimo_nusers[i]));
2297 len += scnprintf(buf + len, buf_len - len,
2298 "ax_ul_mumimo_brp_sch_nusers_%u = %u\n\n", i,
2299 le32_to_cpu(htt_stats_buf->ax_ul_mumimo_brp_nusers[i]));
2300 }
2301
2302 stats_req->buf_len = len;
2303 }
2304
2305 static void
ath12k_htt_print_tx_pdev_mumimo_grp_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2306 ath12k_htt_print_tx_pdev_mumimo_grp_stats_tlv(const void *tag_buf, u16 tag_len,
2307 struct debug_htt_stats_req *stats_req)
2308 {
2309 const struct ath12k_htt_tx_pdev_mumimo_grp_stats_tlv *htt_stats_buf = tag_buf;
2310 u8 *buf = stats_req->buf;
2311 u32 len = stats_req->buf_len;
2312 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2313 int j;
2314
2315 if (tag_len < sizeof(*htt_stats_buf))
2316 return;
2317
2318 len += scnprintf(buf + len, buf_len - len, "HTT_TX_PDEV_MUMIMO_GRP_STATS:\n");
2319 len += print_array_to_buf(buf, len,
2320 "dl_mumimo_grp_tputs_observed (per bin = 300 mbps)",
2321 htt_stats_buf->dl_mumimo_grp_tputs,
2322 ATH12K_HTT_STATS_MUMIMO_TPUT_NUM_BINS, "\n");
2323 len += print_array_to_buf(buf, len, "dl_mumimo_grp eligible",
2324 htt_stats_buf->dl_mumimo_grp_eligible,
2325 ATH12K_HTT_STATS_NUM_MAX_MUMIMO_SZ, "\n");
2326 len += print_array_to_buf(buf, len, "dl_mumimo_grp_ineligible",
2327 htt_stats_buf->dl_mumimo_grp_ineligible,
2328 ATH12K_HTT_STATS_NUM_MAX_MUMIMO_SZ, "\n");
2329 len += scnprintf(buf + len, buf_len - len, "dl_mumimo_grp_invalid:\n");
2330 for (j = 0; j < ATH12K_HTT_STATS_NUM_MAX_MUMIMO_SZ; j++) {
2331 len += scnprintf(buf + len, buf_len - len, "grp_id = %u", j);
2332 len += print_array_to_buf(buf, len, "",
2333 htt_stats_buf->dl_mumimo_grp_invalid,
2334 ATH12K_HTT_STATS_MAX_INVALID_REASON_CODE,
2335 "\n");
2336 }
2337
2338 len += print_array_to_buf(buf, len, "ul_mumimo_grp_best_grp_size",
2339 htt_stats_buf->ul_mumimo_grp_best_grp_size,
2340 ATH12K_HTT_STATS_NUM_MAX_MUMIMO_SZ, "\n");
2341 len += print_array_to_buf(buf, len, "ul_mumimo_grp_best_num_usrs = ",
2342 htt_stats_buf->ul_mumimo_grp_best_usrs,
2343 ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS, "\n");
2344 len += print_array_to_buf(buf, len,
2345 "ul_mumimo_grp_tputs_observed (per bin = 300 mbps)",
2346 htt_stats_buf->ul_mumimo_grp_tputs,
2347 ATH12K_HTT_STATS_MUMIMO_TPUT_NUM_BINS, "\n\n");
2348
2349 stats_req->buf_len = len;
2350 }
2351
2352 static void
ath12k_htt_print_tx_pdev_mu_mimo_mpdu_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2353 ath12k_htt_print_tx_pdev_mu_mimo_mpdu_stats_tlv(const void *tag_buf, u16 tag_len,
2354 struct debug_htt_stats_req *stats_req)
2355 {
2356 const struct ath12k_htt_tx_pdev_mpdu_stats_tlv *htt_stats_buf = tag_buf;
2357 u8 *buf = stats_req->buf;
2358 u32 len = stats_req->buf_len;
2359 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2360 u32 user_index;
2361 u32 tx_sched_mode;
2362
2363 if (tag_len < sizeof(*htt_stats_buf))
2364 return;
2365
2366 user_index = __le32_to_cpu(htt_stats_buf->user_index);
2367 tx_sched_mode = __le32_to_cpu(htt_stats_buf->tx_sched_mode);
2368
2369 if (tx_sched_mode == ATH12K_HTT_STATS_TX_SCHED_MODE_MU_MIMO_AC) {
2370 if (!user_index)
2371 len += scnprintf(buf + len, buf_len - len,
2372 "HTT_TX_PDEV_MU_MIMO_AC_MPDU_STATS:\n");
2373
2374 if (user_index < ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS) {
2375 len += scnprintf(buf + len, buf_len - len,
2376 "ac_mu_mimo_mpdus_queued_usr_%u = %u\n",
2377 user_index,
2378 le32_to_cpu(htt_stats_buf->mpdus_queued_usr));
2379 len += scnprintf(buf + len, buf_len - len,
2380 "ac_mu_mimo_mpdus_tried_usr_%u = %u\n",
2381 user_index,
2382 le32_to_cpu(htt_stats_buf->mpdus_tried_usr));
2383 len += scnprintf(buf + len, buf_len - len,
2384 "ac_mu_mimo_mpdus_failed_usr_%u = %u\n",
2385 user_index,
2386 le32_to_cpu(htt_stats_buf->mpdus_failed_usr));
2387 len += scnprintf(buf + len, buf_len - len,
2388 "ac_mu_mimo_mpdus_requeued_usr_%u = %u\n",
2389 user_index,
2390 le32_to_cpu(htt_stats_buf->mpdus_requeued_usr));
2391 len += scnprintf(buf + len, buf_len - len,
2392 "ac_mu_mimo_err_no_ba_usr_%u = %u\n",
2393 user_index,
2394 le32_to_cpu(htt_stats_buf->err_no_ba_usr));
2395 len += scnprintf(buf + len, buf_len - len,
2396 "ac_mu_mimo_mpdu_underrun_usr_%u = %u\n",
2397 user_index,
2398 le32_to_cpu(htt_stats_buf->mpdu_underrun_usr));
2399 len += scnprintf(buf + len, buf_len - len,
2400 "ac_mu_mimo_ampdu_underrun_usr_%u = %u\n\n",
2401 user_index,
2402 le32_to_cpu(htt_stats_buf->ampdu_underrun_usr));
2403 }
2404 }
2405
2406 if (tx_sched_mode == ATH12K_HTT_STATS_TX_SCHED_MODE_MU_MIMO_AX) {
2407 if (!user_index)
2408 len += scnprintf(buf + len, buf_len - len,
2409 "HTT_TX_PDEV_MU_MIMO_AX_MPDU_STATS:\n");
2410
2411 if (user_index < ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS) {
2412 len += scnprintf(buf + len, buf_len - len,
2413 "ax_mu_mimo_mpdus_queued_usr_%u = %u\n",
2414 user_index,
2415 le32_to_cpu(htt_stats_buf->mpdus_queued_usr));
2416 len += scnprintf(buf + len, buf_len - len,
2417 "ax_mu_mimo_mpdus_tried_usr_%u = %u\n",
2418 user_index,
2419 le32_to_cpu(htt_stats_buf->mpdus_tried_usr));
2420 len += scnprintf(buf + len, buf_len - len,
2421 "ax_mu_mimo_mpdus_failed_usr_%u = %u\n",
2422 user_index,
2423 le32_to_cpu(htt_stats_buf->mpdus_failed_usr));
2424 len += scnprintf(buf + len, buf_len - len,
2425 "ax_mu_mimo_mpdus_requeued_usr_%u = %u\n",
2426 user_index,
2427 le32_to_cpu(htt_stats_buf->mpdus_requeued_usr));
2428 len += scnprintf(buf + len, buf_len - len,
2429 "ax_mu_mimo_err_no_ba_usr_%u = %u\n",
2430 user_index,
2431 le32_to_cpu(htt_stats_buf->err_no_ba_usr));
2432 len += scnprintf(buf + len, buf_len - len,
2433 "ax_mu_mimo_mpdu_underrun_usr_%u = %u\n",
2434 user_index,
2435 le32_to_cpu(htt_stats_buf->mpdu_underrun_usr));
2436 len += scnprintf(buf + len, buf_len - len,
2437 "ax_mu_mimo_ampdu_underrun_usr_%u = %u\n\n",
2438 user_index,
2439 le32_to_cpu(htt_stats_buf->ampdu_underrun_usr));
2440 }
2441 }
2442
2443 if (tx_sched_mode == ATH12K_HTT_STATS_TX_SCHED_MODE_MU_OFDMA_AX) {
2444 if (!user_index)
2445 len += scnprintf(buf + len, buf_len - len,
2446 "HTT_TX_PDEV_AX_MU_OFDMA_MPDU_STATS:\n");
2447
2448 if (user_index < ATH12K_HTT_TX_NUM_OFDMA_USER_STATS) {
2449 len += scnprintf(buf + len, buf_len - len,
2450 "ax_mu_ofdma_mpdus_queued_usr_%u = %u\n",
2451 user_index,
2452 le32_to_cpu(htt_stats_buf->mpdus_queued_usr));
2453 len += scnprintf(buf + len, buf_len - len,
2454 "ax_mu_ofdma_mpdus_tried_usr_%u = %u\n",
2455 user_index,
2456 le32_to_cpu(htt_stats_buf->mpdus_tried_usr));
2457 len += scnprintf(buf + len, buf_len - len,
2458 "ax_mu_ofdma_mpdus_failed_usr_%u = %u\n",
2459 user_index,
2460 le32_to_cpu(htt_stats_buf->mpdus_failed_usr));
2461 len += scnprintf(buf + len, buf_len - len,
2462 "ax_mu_ofdma_mpdus_requeued_usr_%u = %u\n",
2463 user_index,
2464 le32_to_cpu(htt_stats_buf->mpdus_requeued_usr));
2465 len += scnprintf(buf + len, buf_len - len,
2466 "ax_mu_ofdma_err_no_ba_usr_%u = %u\n",
2467 user_index,
2468 le32_to_cpu(htt_stats_buf->err_no_ba_usr));
2469 len += scnprintf(buf + len, buf_len - len,
2470 "ax_mu_ofdma_mpdu_underrun_usr_%u = %u\n",
2471 user_index,
2472 le32_to_cpu(htt_stats_buf->mpdu_underrun_usr));
2473 len += scnprintf(buf + len, buf_len - len,
2474 "ax_mu_ofdma_ampdu_underrun_usr_%u = %u\n\n",
2475 user_index,
2476 le32_to_cpu(htt_stats_buf->ampdu_underrun_usr));
2477 }
2478 }
2479
2480 stats_req->buf_len = len;
2481 }
2482
2483 static void
ath12k_htt_print_pdev_cca_stats_hist_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2484 ath12k_htt_print_pdev_cca_stats_hist_tlv(const void *tag_buf, u16 tag_len,
2485 struct debug_htt_stats_req *stats_req)
2486 {
2487 const struct ath12k_htt_pdev_cca_stats_hist_v1_tlv *htt_stats_buf = tag_buf;
2488 u8 *buf = stats_req->buf;
2489 u32 len = stats_req->buf_len;
2490 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2491
2492 if (tag_len < sizeof(*htt_stats_buf))
2493 return;
2494
2495 len += scnprintf(buf + len, buf_len - len, "HTT_PDEV_CCA_STATS_HIST_TLV :\n");
2496 len += scnprintf(buf + len, buf_len - len, "chan_num = %u\n",
2497 le32_to_cpu(htt_stats_buf->chan_num));
2498 len += scnprintf(buf + len, buf_len - len, "num_records = %u\n",
2499 le32_to_cpu(htt_stats_buf->num_records));
2500 len += scnprintf(buf + len, buf_len - len, "valid_cca_counters_bitmap = 0x%x\n",
2501 le32_to_cpu(htt_stats_buf->valid_cca_counters_bitmap));
2502 len += scnprintf(buf + len, buf_len - len, "collection_interval = %u\n\n",
2503 le32_to_cpu(htt_stats_buf->collection_interval));
2504
2505 stats_req->buf_len = len;
2506 }
2507
2508 static void
ath12k_htt_print_pdev_stats_cca_counters_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2509 ath12k_htt_print_pdev_stats_cca_counters_tlv(const void *tag_buf, u16 tag_len,
2510 struct debug_htt_stats_req *stats_req)
2511 {
2512 const struct ath12k_htt_pdev_stats_cca_counters_tlv *htt_stats_buf = tag_buf;
2513 u8 *buf = stats_req->buf;
2514 u32 len = stats_req->buf_len;
2515 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2516
2517 if (tag_len < sizeof(*htt_stats_buf))
2518 return;
2519
2520 len += scnprintf(buf + len, buf_len - len,
2521 "HTT_PDEV_STATS_CCA_COUNTERS_TLV:(in usec)\n");
2522 len += scnprintf(buf + len, buf_len - len, "tx_frame_usec = %u\n",
2523 le32_to_cpu(htt_stats_buf->tx_frame_usec));
2524 len += scnprintf(buf + len, buf_len - len, "rx_frame_usec = %u\n",
2525 le32_to_cpu(htt_stats_buf->rx_frame_usec));
2526 len += scnprintf(buf + len, buf_len - len, "rx_clear_usec = %u\n",
2527 le32_to_cpu(htt_stats_buf->rx_clear_usec));
2528 len += scnprintf(buf + len, buf_len - len, "my_rx_frame_usec = %u\n",
2529 le32_to_cpu(htt_stats_buf->my_rx_frame_usec));
2530 len += scnprintf(buf + len, buf_len - len, "usec_cnt = %u\n",
2531 le32_to_cpu(htt_stats_buf->usec_cnt));
2532 len += scnprintf(buf + len, buf_len - len, "med_rx_idle_usec = %u\n",
2533 le32_to_cpu(htt_stats_buf->med_rx_idle_usec));
2534 len += scnprintf(buf + len, buf_len - len, "med_tx_idle_global_usec = %u\n",
2535 le32_to_cpu(htt_stats_buf->med_tx_idle_global_usec));
2536 len += scnprintf(buf + len, buf_len - len, "cca_obss_usec = %u\n\n",
2537 le32_to_cpu(htt_stats_buf->cca_obss_usec));
2538
2539 stats_req->buf_len = len;
2540 }
2541
2542 static void
ath12k_htt_print_tx_sounding_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2543 ath12k_htt_print_tx_sounding_stats_tlv(const void *tag_buf, u16 tag_len,
2544 struct debug_htt_stats_req *stats_req)
2545 {
2546 const struct ath12k_htt_tx_sounding_stats_tlv *htt_stats_buf = tag_buf;
2547 const __le32 *cbf_20, *cbf_40, *cbf_80, *cbf_160, *cbf_320;
2548 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2549 u32 len = stats_req->buf_len;
2550 u8 *buf = stats_req->buf;
2551 u32 tx_sounding_mode;
2552 u8 i, u;
2553
2554 if (tag_len < sizeof(*htt_stats_buf))
2555 return;
2556
2557 cbf_20 = htt_stats_buf->cbf_20;
2558 cbf_40 = htt_stats_buf->cbf_40;
2559 cbf_80 = htt_stats_buf->cbf_80;
2560 cbf_160 = htt_stats_buf->cbf_160;
2561 cbf_320 = htt_stats_buf->cbf_320;
2562 tx_sounding_mode = le32_to_cpu(htt_stats_buf->tx_sounding_mode);
2563
2564 if (tx_sounding_mode == ATH12K_HTT_TX_AC_SOUNDING_MODE) {
2565 len += scnprintf(buf + len, buf_len - len,
2566 "HTT_TX_AC_SOUNDING_STATS_TLV:\n");
2567 len += scnprintf(buf + len, buf_len - len,
2568 "ac_cbf_20 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2569 le32_to_cpu(cbf_20[ATH12K_HTT_IMPL_STEER_STATS]),
2570 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2571 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2572 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2573 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2574 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2575 len += scnprintf(buf + len, buf_len - len,
2576 "ac_cbf_40 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2577 le32_to_cpu(cbf_40[ATH12K_HTT_IMPL_STEER_STATS]),
2578 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2579 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2580 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2581 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2582 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2583 len += scnprintf(buf + len, buf_len - len,
2584 "ac_cbf_80 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2585 le32_to_cpu(cbf_80[ATH12K_HTT_IMPL_STEER_STATS]),
2586 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2587 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2588 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2589 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2590 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2591 len += scnprintf(buf + len, buf_len - len,
2592 "ac_cbf_160 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2593 le32_to_cpu(cbf_160[ATH12K_HTT_IMPL_STEER_STATS]),
2594 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2595 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2596 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2597 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2598 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2599
2600 for (u = 0, i = 0; u < ATH12K_HTT_TX_NUM_AC_MUMIMO_USER_STATS; u++) {
2601 len += scnprintf(buf + len, buf_len - len,
2602 "Sounding User_%u = 20MHz: %u, ", u,
2603 le32_to_cpu(htt_stats_buf->sounding[i++]));
2604 len += scnprintf(buf + len, buf_len - len, "40MHz: %u, ",
2605 le32_to_cpu(htt_stats_buf->sounding[i++]));
2606 len += scnprintf(buf + len, buf_len - len, "80MHz: %u, ",
2607 le32_to_cpu(htt_stats_buf->sounding[i++]));
2608 len += scnprintf(buf + len, buf_len - len, "160MHz: %u\n",
2609 le32_to_cpu(htt_stats_buf->sounding[i++]));
2610 }
2611 } else if (tx_sounding_mode == ATH12K_HTT_TX_AX_SOUNDING_MODE) {
2612 len += scnprintf(buf + len, buf_len - len,
2613 "\nHTT_TX_AX_SOUNDING_STATS_TLV:\n");
2614 len += scnprintf(buf + len, buf_len - len,
2615 "ax_cbf_20 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2616 le32_to_cpu(cbf_20[ATH12K_HTT_IMPL_STEER_STATS]),
2617 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2618 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2619 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2620 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2621 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2622 len += scnprintf(buf + len, buf_len - len,
2623 "ax_cbf_40 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2624 le32_to_cpu(cbf_40[ATH12K_HTT_IMPL_STEER_STATS]),
2625 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2626 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2627 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2628 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2629 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2630 len += scnprintf(buf + len, buf_len - len,
2631 "ax_cbf_80 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2632 le32_to_cpu(cbf_80[ATH12K_HTT_IMPL_STEER_STATS]),
2633 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2634 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2635 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2636 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2637 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2638 len += scnprintf(buf + len, buf_len - len,
2639 "ax_cbf_160 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2640 le32_to_cpu(cbf_160[ATH12K_HTT_IMPL_STEER_STATS]),
2641 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2642 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2643 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2644 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2645 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2646
2647 for (u = 0, i = 0; u < ATH12K_HTT_TX_NUM_AX_MUMIMO_USER_STATS; u++) {
2648 len += scnprintf(buf + len, buf_len - len,
2649 "Sounding User_%u = 20MHz: %u, ", u,
2650 le32_to_cpu(htt_stats_buf->sounding[i++]));
2651 len += scnprintf(buf + len, buf_len - len, "40MHz: %u, ",
2652 le32_to_cpu(htt_stats_buf->sounding[i++]));
2653 len += scnprintf(buf + len, buf_len - len, "80MHz: %u, ",
2654 le32_to_cpu(htt_stats_buf->sounding[i++]));
2655 len += scnprintf(buf + len, buf_len - len, "160MHz: %u\n",
2656 le32_to_cpu(htt_stats_buf->sounding[i++]));
2657 }
2658 } else if (tx_sounding_mode == ATH12K_HTT_TX_BE_SOUNDING_MODE) {
2659 len += scnprintf(buf + len, buf_len - len,
2660 "\nHTT_TX_BE_SOUNDING_STATS_TLV:\n");
2661 len += scnprintf(buf + len, buf_len - len,
2662 "be_cbf_20 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2663 le32_to_cpu(cbf_20[ATH12K_HTT_IMPL_STEER_STATS]),
2664 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2665 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2666 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2667 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2668 le32_to_cpu(cbf_20[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2669 len += scnprintf(buf + len, buf_len - len,
2670 "be_cbf_40 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2671 le32_to_cpu(cbf_40[ATH12K_HTT_IMPL_STEER_STATS]),
2672 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2673 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2674 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2675 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2676 le32_to_cpu(cbf_40[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2677 len += scnprintf(buf + len, buf_len - len,
2678 "be_cbf_80 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2679 le32_to_cpu(cbf_80[ATH12K_HTT_IMPL_STEER_STATS]),
2680 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2681 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2682 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2683 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2684 le32_to_cpu(cbf_80[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2685 len += scnprintf(buf + len, buf_len - len,
2686 "be_cbf_160 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2687 le32_to_cpu(cbf_160[ATH12K_HTT_IMPL_STEER_STATS]),
2688 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2689 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2690 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2691 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2692 le32_to_cpu(cbf_160[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2693 len += scnprintf(buf + len, buf_len - len,
2694 "be_cbf_320 = IBF: %u, SU_SIFS: %u, SU_RBO: %u, ",
2695 le32_to_cpu(cbf_320[ATH12K_HTT_IMPL_STEER_STATS]),
2696 le32_to_cpu(cbf_320[ATH12K_HTT_EXPL_SUSIFS_STEER_STATS]),
2697 le32_to_cpu(cbf_320[ATH12K_HTT_EXPL_SURBO_STEER_STATS]));
2698 len += scnprintf(buf + len, buf_len - len, "MU_SIFS: %u, MU_RBO: %u\n",
2699 le32_to_cpu(cbf_320[ATH12K_HTT_EXPL_MUSIFS_STEER_STATS]),
2700 le32_to_cpu(cbf_320[ATH12K_HTT_EXPL_MURBO_STEER_STATS]));
2701 for (u = 0, i = 0; u < ATH12K_HTT_TX_NUM_BE_MUMIMO_USER_STATS; u++) {
2702 len += scnprintf(buf + len, buf_len - len,
2703 "Sounding User_%u = 20MHz: %u, ", u,
2704 le32_to_cpu(htt_stats_buf->sounding[i++]));
2705 len += scnprintf(buf + len, buf_len - len, "40MHz: %u, ",
2706 le32_to_cpu(htt_stats_buf->sounding[i++]));
2707 len += scnprintf(buf + len, buf_len - len, "80MHz: %u, ",
2708 le32_to_cpu(htt_stats_buf->sounding[i++]));
2709 len += scnprintf(buf + len, buf_len - len,
2710 "160MHz: %u, 320MHz: %u\n",
2711 le32_to_cpu(htt_stats_buf->sounding[i++]),
2712 le32_to_cpu(htt_stats_buf->sounding_320[u]));
2713 }
2714 } else if (tx_sounding_mode == ATH12K_HTT_TX_CMN_SOUNDING_MODE) {
2715 len += scnprintf(buf + len, buf_len - len,
2716 "\nCV UPLOAD HANDLER STATS:\n");
2717 len += scnprintf(buf + len, buf_len - len, "cv_nc_mismatch_err = %u\n",
2718 le32_to_cpu(htt_stats_buf->cv_nc_mismatch_err));
2719 len += scnprintf(buf + len, buf_len - len, "cv_fcs_err = %u\n",
2720 le32_to_cpu(htt_stats_buf->cv_fcs_err));
2721 len += scnprintf(buf + len, buf_len - len, "cv_frag_idx_mismatch = %u\n",
2722 le32_to_cpu(htt_stats_buf->cv_frag_idx_mismatch));
2723 len += scnprintf(buf + len, buf_len - len, "cv_invalid_peer_id = %u\n",
2724 le32_to_cpu(htt_stats_buf->cv_invalid_peer_id));
2725 len += scnprintf(buf + len, buf_len - len, "cv_no_txbf_setup = %u\n",
2726 le32_to_cpu(htt_stats_buf->cv_no_txbf_setup));
2727 len += scnprintf(buf + len, buf_len - len, "cv_expiry_in_update = %u\n",
2728 le32_to_cpu(htt_stats_buf->cv_expiry_in_update));
2729 len += scnprintf(buf + len, buf_len - len, "cv_pkt_bw_exceed = %u\n",
2730 le32_to_cpu(htt_stats_buf->cv_pkt_bw_exceed));
2731 len += scnprintf(buf + len, buf_len - len, "cv_dma_not_done_err = %u\n",
2732 le32_to_cpu(htt_stats_buf->cv_dma_not_done_err));
2733 len += scnprintf(buf + len, buf_len - len, "cv_update_failed = %u\n",
2734 le32_to_cpu(htt_stats_buf->cv_update_failed));
2735 len += scnprintf(buf + len, buf_len - len, "cv_dma_timeout_error = %u\n",
2736 le32_to_cpu(htt_stats_buf->cv_dma_timeout_error));
2737 len += scnprintf(buf + len, buf_len - len, "cv_buf_ibf_uploads = %u\n",
2738 le32_to_cpu(htt_stats_buf->cv_buf_ibf_uploads));
2739 len += scnprintf(buf + len, buf_len - len, "cv_buf_ebf_uploads = %u\n",
2740 le32_to_cpu(htt_stats_buf->cv_buf_ebf_uploads));
2741 len += scnprintf(buf + len, buf_len - len, "cv_buf_received = %u\n",
2742 le32_to_cpu(htt_stats_buf->cv_buf_received));
2743 len += scnprintf(buf + len, buf_len - len, "cv_buf_fed_back = %u\n\n",
2744 le32_to_cpu(htt_stats_buf->cv_buf_fed_back));
2745
2746 len += scnprintf(buf + len, buf_len - len, "CV QUERY STATS:\n");
2747 len += scnprintf(buf + len, buf_len - len, "cv_total_query = %u\n",
2748 le32_to_cpu(htt_stats_buf->cv_total_query));
2749 len += scnprintf(buf + len, buf_len - len,
2750 "cv_total_pattern_query = %u\n",
2751 le32_to_cpu(htt_stats_buf->cv_total_pattern_query));
2752 len += scnprintf(buf + len, buf_len - len, "cv_total_bw_query = %u\n",
2753 le32_to_cpu(htt_stats_buf->cv_total_bw_query));
2754 len += scnprintf(buf + len, buf_len - len, "cv_invalid_bw_coding = %u\n",
2755 le32_to_cpu(htt_stats_buf->cv_invalid_bw_coding));
2756 len += scnprintf(buf + len, buf_len - len, "cv_forced_sounding = %u\n",
2757 le32_to_cpu(htt_stats_buf->cv_forced_sounding));
2758 len += scnprintf(buf + len, buf_len - len,
2759 "cv_standalone_sounding = %u\n",
2760 le32_to_cpu(htt_stats_buf->cv_standalone_sounding));
2761 len += scnprintf(buf + len, buf_len - len, "cv_nc_mismatch = %u\n",
2762 le32_to_cpu(htt_stats_buf->cv_nc_mismatch));
2763 len += scnprintf(buf + len, buf_len - len, "cv_fb_type_mismatch = %u\n",
2764 le32_to_cpu(htt_stats_buf->cv_fb_type_mismatch));
2765 len += scnprintf(buf + len, buf_len - len, "cv_ofdma_bw_mismatch = %u\n",
2766 le32_to_cpu(htt_stats_buf->cv_ofdma_bw_mismatch));
2767 len += scnprintf(buf + len, buf_len - len, "cv_bw_mismatch = %u\n",
2768 le32_to_cpu(htt_stats_buf->cv_bw_mismatch));
2769 len += scnprintf(buf + len, buf_len - len, "cv_pattern_mismatch = %u\n",
2770 le32_to_cpu(htt_stats_buf->cv_pattern_mismatch));
2771 len += scnprintf(buf + len, buf_len - len, "cv_preamble_mismatch = %u\n",
2772 le32_to_cpu(htt_stats_buf->cv_preamble_mismatch));
2773 len += scnprintf(buf + len, buf_len - len, "cv_nr_mismatch = %u\n",
2774 le32_to_cpu(htt_stats_buf->cv_nr_mismatch));
2775 len += scnprintf(buf + len, buf_len - len,
2776 "cv_in_use_cnt_exceeded = %u\n",
2777 le32_to_cpu(htt_stats_buf->cv_in_use_cnt_exceeded));
2778 len += scnprintf(buf + len, buf_len - len, "cv_ntbr_sounding = %u\n",
2779 le32_to_cpu(htt_stats_buf->cv_ntbr_sounding));
2780 len += scnprintf(buf + len, buf_len - len,
2781 "cv_found_upload_in_progress = %u\n",
2782 le32_to_cpu(htt_stats_buf->cv_found_upload_in_progress));
2783 len += scnprintf(buf + len, buf_len - len,
2784 "cv_expired_during_query = %u\n",
2785 le32_to_cpu(htt_stats_buf->cv_expired_during_query));
2786 len += scnprintf(buf + len, buf_len - len, "cv_found = %u\n",
2787 le32_to_cpu(htt_stats_buf->cv_found));
2788 len += scnprintf(buf + len, buf_len - len, "cv_not_found = %u\n",
2789 le32_to_cpu(htt_stats_buf->cv_not_found));
2790 len += scnprintf(buf + len, buf_len - len, "cv_total_query_ibf = %u\n",
2791 le32_to_cpu(htt_stats_buf->cv_total_query_ibf));
2792 len += scnprintf(buf + len, buf_len - len, "cv_found_ibf = %u\n",
2793 le32_to_cpu(htt_stats_buf->cv_found_ibf));
2794 len += scnprintf(buf + len, buf_len - len, "cv_not_found_ibf = %u\n",
2795 le32_to_cpu(htt_stats_buf->cv_not_found_ibf));
2796 len += scnprintf(buf + len, buf_len - len,
2797 "cv_expired_during_query_ibf = %u\n\n",
2798 le32_to_cpu(htt_stats_buf->cv_expired_during_query_ibf));
2799 }
2800
2801 stats_req->buf_len = len;
2802 }
2803
2804 static void
ath12k_htt_print_pdev_obss_pd_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2805 ath12k_htt_print_pdev_obss_pd_stats_tlv(const void *tag_buf, u16 tag_len,
2806 struct debug_htt_stats_req *stats_req)
2807 {
2808 const struct ath12k_htt_pdev_obss_pd_stats_tlv *htt_stats_buf = tag_buf;
2809 u8 *buf = stats_req->buf;
2810 u32 len = stats_req->buf_len;
2811 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2812 u8 i;
2813 static const char *access_cat_names[ATH12K_HTT_NUM_AC_WMM] = {"best effort",
2814 "background",
2815 "video", "voice"};
2816
2817 if (tag_len < sizeof(*htt_stats_buf))
2818 return;
2819
2820 len += scnprintf(buf + len, buf_len - len, "HTT_PDEV_OBSS_PD_STATS_TLV:\n");
2821 len += scnprintf(buf + len, buf_len - len, "num_spatial_reuse_tx = %u\n",
2822 le32_to_cpu(htt_stats_buf->num_sr_tx_transmissions));
2823 len += scnprintf(buf + len, buf_len - len,
2824 "num_spatial_reuse_opportunities = %u\n",
2825 le32_to_cpu(htt_stats_buf->num_spatial_reuse_opportunities));
2826 len += scnprintf(buf + len, buf_len - len, "num_non_srg_opportunities = %u\n",
2827 le32_to_cpu(htt_stats_buf->num_non_srg_opportunities));
2828 len += scnprintf(buf + len, buf_len - len, "num_non_srg_ppdu_tried = %u\n",
2829 le32_to_cpu(htt_stats_buf->num_non_srg_ppdu_tried));
2830 len += scnprintf(buf + len, buf_len - len, "num_non_srg_ppdu_success = %u\n",
2831 le32_to_cpu(htt_stats_buf->num_non_srg_ppdu_success));
2832 len += scnprintf(buf + len, buf_len - len, "num_srg_opportunities = %u\n",
2833 le32_to_cpu(htt_stats_buf->num_srg_opportunities));
2834 len += scnprintf(buf + len, buf_len - len, "num_srg_ppdu_tried = %u\n",
2835 le32_to_cpu(htt_stats_buf->num_srg_ppdu_tried));
2836 len += scnprintf(buf + len, buf_len - len, "num_srg_ppdu_success = %u\n",
2837 le32_to_cpu(htt_stats_buf->num_srg_ppdu_success));
2838 len += scnprintf(buf + len, buf_len - len, "num_psr_opportunities = %u\n",
2839 le32_to_cpu(htt_stats_buf->num_psr_opportunities));
2840 len += scnprintf(buf + len, buf_len - len, "num_psr_ppdu_tried = %u\n",
2841 le32_to_cpu(htt_stats_buf->num_psr_ppdu_tried));
2842 len += scnprintf(buf + len, buf_len - len, "num_psr_ppdu_success = %u\n",
2843 le32_to_cpu(htt_stats_buf->num_psr_ppdu_success));
2844 len += scnprintf(buf + len, buf_len - len, "min_duration_check_flush_cnt = %u\n",
2845 le32_to_cpu(htt_stats_buf->num_obss_min_dur_check_flush_cnt));
2846 len += scnprintf(buf + len, buf_len - len, "sr_ppdu_abort_flush_cnt = %u\n\n",
2847 le32_to_cpu(htt_stats_buf->num_sr_ppdu_abort_flush_cnt));
2848
2849 len += scnprintf(buf + len, buf_len - len, "HTT_PDEV_OBSS_PD_PER_AC_STATS:\n");
2850 for (i = 0; i < ATH12K_HTT_NUM_AC_WMM; i++) {
2851 len += scnprintf(buf + len, buf_len - len, "Access Category %u (%s)\n",
2852 i, access_cat_names[i]);
2853 len += scnprintf(buf + len, buf_len - len,
2854 "num_non_srg_ppdu_tried = %u\n",
2855 le32_to_cpu(htt_stats_buf->num_non_srg_tried_per_ac[i]));
2856 len += scnprintf(buf + len, buf_len - len,
2857 "num_non_srg_ppdu_success = %u\n",
2858 le32_to_cpu(htt_stats_buf->num_non_srg_success_ac[i]));
2859 len += scnprintf(buf + len, buf_len - len, "num_srg_ppdu_tried = %u\n",
2860 le32_to_cpu(htt_stats_buf->num_srg_tried_per_ac[i]));
2861 len += scnprintf(buf + len, buf_len - len,
2862 "num_srg_ppdu_success = %u\n\n",
2863 le32_to_cpu(htt_stats_buf->num_srg_success_per_ac[i]));
2864 }
2865
2866 stats_req->buf_len = len;
2867 }
2868
2869 static void
ath12k_htt_print_latency_prof_ctx_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2870 ath12k_htt_print_latency_prof_ctx_tlv(const void *tag_buf, u16 tag_len,
2871 struct debug_htt_stats_req *stats_req)
2872 {
2873 const struct ath12k_htt_latency_prof_ctx_tlv *htt_stats_buf = tag_buf;
2874 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2875 u32 len = stats_req->buf_len;
2876 u8 *buf = stats_req->buf;
2877
2878 if (tag_len < sizeof(*htt_stats_buf))
2879 return;
2880
2881 len += scnprintf(buf + len, buf_len - len, "HTT_STATS_LATENCY_CTX_TLV:\n");
2882 len += scnprintf(buf + len, buf_len - len, "duration = %u\n",
2883 le32_to_cpu(htt_stats_buf->duration));
2884 len += scnprintf(buf + len, buf_len - len, "tx_msdu_cnt = %u\n",
2885 le32_to_cpu(htt_stats_buf->tx_msdu_cnt));
2886 len += scnprintf(buf + len, buf_len - len, "tx_mpdu_cnt = %u\n",
2887 le32_to_cpu(htt_stats_buf->tx_mpdu_cnt));
2888 len += scnprintf(buf + len, buf_len - len, "rx_msdu_cnt = %u\n",
2889 le32_to_cpu(htt_stats_buf->rx_msdu_cnt));
2890 len += scnprintf(buf + len, buf_len - len, "rx_mpdu_cnt = %u\n\n",
2891 le32_to_cpu(htt_stats_buf->rx_mpdu_cnt));
2892
2893 stats_req->buf_len = len;
2894 }
2895
2896 static void
ath12k_htt_print_latency_prof_cnt(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2897 ath12k_htt_print_latency_prof_cnt(const void *tag_buf, u16 tag_len,
2898 struct debug_htt_stats_req *stats_req)
2899 {
2900 const struct ath12k_htt_latency_prof_cnt_tlv *htt_stats_buf = tag_buf;
2901 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2902 u32 len = stats_req->buf_len;
2903 u8 *buf = stats_req->buf;
2904
2905 if (tag_len < sizeof(*htt_stats_buf))
2906 return;
2907
2908 len += scnprintf(buf + len, buf_len - len, "HTT_STATS_LATENCY_CNT_TLV:\n");
2909 len += scnprintf(buf + len, buf_len - len, "prof_enable_cnt = %u\n\n",
2910 le32_to_cpu(htt_stats_buf->prof_enable_cnt));
2911
2912 stats_req->buf_len = len;
2913 }
2914
2915 static void
ath12k_htt_print_latency_prof_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2916 ath12k_htt_print_latency_prof_stats_tlv(const void *tag_buf, u16 tag_len,
2917 struct debug_htt_stats_req *stats_req)
2918 {
2919 const struct ath12k_htt_latency_prof_stats_tlv *htt_stats_buf = tag_buf;
2920 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2921 u32 len = stats_req->buf_len;
2922 u8 *buf = stats_req->buf;
2923
2924 if (tag_len < sizeof(*htt_stats_buf))
2925 return;
2926
2927 if (le32_to_cpu(htt_stats_buf->print_header) == 1) {
2928 len += scnprintf(buf + len, buf_len - len,
2929 "HTT_STATS_LATENCY_PROF_TLV:\n");
2930 }
2931
2932 len += scnprintf(buf + len, buf_len - len, "Latency name = %s\n",
2933 htt_stats_buf->latency_prof_name);
2934 len += scnprintf(buf + len, buf_len - len, "count = %u\n",
2935 le32_to_cpu(htt_stats_buf->cnt));
2936 len += scnprintf(buf + len, buf_len - len, "minimum = %u\n",
2937 le32_to_cpu(htt_stats_buf->min));
2938 len += scnprintf(buf + len, buf_len - len, "maximum = %u\n",
2939 le32_to_cpu(htt_stats_buf->max));
2940 len += scnprintf(buf + len, buf_len - len, "last = %u\n",
2941 le32_to_cpu(htt_stats_buf->last));
2942 len += scnprintf(buf + len, buf_len - len, "total = %u\n",
2943 le32_to_cpu(htt_stats_buf->tot));
2944 len += scnprintf(buf + len, buf_len - len, "average = %u\n",
2945 le32_to_cpu(htt_stats_buf->avg));
2946 len += scnprintf(buf + len, buf_len - len, "histogram interval = %u\n",
2947 le32_to_cpu(htt_stats_buf->hist_intvl));
2948 len += print_array_to_buf(buf, len, "histogram", htt_stats_buf->hist,
2949 ATH12K_HTT_LATENCY_PROFILE_NUM_MAX_HIST, "\n\n");
2950
2951 stats_req->buf_len = len;
2952 }
2953
2954 static void
ath12k_htt_print_ul_ofdma_trigger_stats(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)2955 ath12k_htt_print_ul_ofdma_trigger_stats(const void *tag_buf, u16 tag_len,
2956 struct debug_htt_stats_req *stats_req)
2957 {
2958 const struct ath12k_htt_rx_pdev_ul_trigger_stats_tlv *htt_stats_buf = tag_buf;
2959 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
2960 u32 len = stats_req->buf_len;
2961 u8 *buf = stats_req->buf;
2962 u32 mac_id;
2963 u8 j;
2964
2965 if (tag_len < sizeof(*htt_stats_buf))
2966 return;
2967
2968 mac_id = __le32_to_cpu(htt_stats_buf->mac_id__word);
2969
2970 len += scnprintf(buf + len, buf_len - len,
2971 "HTT_RX_PDEV_UL_TRIGGER_STATS_TLV:\n");
2972 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
2973 u32_get_bits(mac_id, ATH12K_HTT_STATS_MAC_ID));
2974 len += scnprintf(buf + len, buf_len - len, "rx_11ax_ul_ofdma = %u\n",
2975 le32_to_cpu(htt_stats_buf->rx_11ax_ul_ofdma));
2976 len += print_array_to_buf(buf, len, "ul_ofdma_rx_mcs",
2977 htt_stats_buf->ul_ofdma_rx_mcs,
2978 ATH12K_HTT_RX_NUM_MCS_CNTRS, "\n");
2979 for (j = 0; j < ATH12K_HTT_RX_NUM_GI_CNTRS; j++) {
2980 len += scnprintf(buf + len, buf_len - len, "ul_ofdma_rx_gi[%u]", j);
2981 len += print_array_to_buf(buf, len, "",
2982 htt_stats_buf->ul_ofdma_rx_gi[j],
2983 ATH12K_HTT_RX_NUM_MCS_CNTRS, "\n");
2984 }
2985
2986 len += print_array_to_buf_index(buf, len, "ul_ofdma_rx_nss", 1,
2987 htt_stats_buf->ul_ofdma_rx_nss,
2988 ATH12K_HTT_RX_NUM_SPATIAL_STREAMS, "\n");
2989 len += print_array_to_buf(buf, len, "ul_ofdma_rx_bw",
2990 htt_stats_buf->ul_ofdma_rx_bw,
2991 ATH12K_HTT_RX_NUM_BW_CNTRS, "\n");
2992
2993 for (j = 0; j < ATH12K_HTT_RX_NUM_REDUCED_CHAN_TYPES; j++) {
2994 len += scnprintf(buf + len, buf_len - len, j == 0 ?
2995 "half_ul_ofdma_rx_bw" :
2996 "quarter_ul_ofdma_rx_bw");
2997 len += print_array_to_buf(buf, len, "", htt_stats_buf->red_bw[j],
2998 ATH12K_HTT_RX_NUM_BW_CNTRS, "\n");
2999 }
3000 len += scnprintf(buf + len, buf_len - len, "ul_ofdma_rx_stbc = %u\n",
3001 le32_to_cpu(htt_stats_buf->ul_ofdma_rx_stbc));
3002 len += scnprintf(buf + len, buf_len - len, "ul_ofdma_rx_ldpc = %u\n",
3003 le32_to_cpu(htt_stats_buf->ul_ofdma_rx_ldpc));
3004
3005 len += scnprintf(buf + len, buf_len - len, "rx_ulofdma_data_ru_size_ppdu = ");
3006 for (j = 0; j < ATH12K_HTT_RX_NUM_RU_SIZE_CNTRS; j++)
3007 len += scnprintf(buf + len, buf_len - len, " %s:%u ",
3008 ath12k_htt_ax_tx_rx_ru_size_to_str(j),
3009 le32_to_cpu(htt_stats_buf->data_ru_size_ppdu[j]));
3010 len += scnprintf(buf + len, buf_len - len, "\n");
3011
3012 len += scnprintf(buf + len, buf_len - len,
3013 "rx_ulofdma_non_data_ru_size_ppdu = ");
3014 for (j = 0; j < ATH12K_HTT_RX_NUM_RU_SIZE_CNTRS; j++)
3015 len += scnprintf(buf + len, buf_len - len, " %s:%u ",
3016 ath12k_htt_ax_tx_rx_ru_size_to_str(j),
3017 le32_to_cpu(htt_stats_buf->non_data_ru_size_ppdu[j]));
3018 len += scnprintf(buf + len, buf_len - len, "\n");
3019
3020 len += print_array_to_buf(buf, len, "rx_rssi_track_sta_aid",
3021 htt_stats_buf->uplink_sta_aid,
3022 ATH12K_HTT_RX_UL_MAX_UPLINK_RSSI_TRACK, "\n");
3023 len += print_array_to_buf(buf, len, "rx_sta_target_rssi",
3024 htt_stats_buf->uplink_sta_target_rssi,
3025 ATH12K_HTT_RX_UL_MAX_UPLINK_RSSI_TRACK, "\n");
3026 len += print_array_to_buf(buf, len, "rx_sta_fd_rssi",
3027 htt_stats_buf->uplink_sta_fd_rssi,
3028 ATH12K_HTT_RX_UL_MAX_UPLINK_RSSI_TRACK, "\n");
3029 len += print_array_to_buf(buf, len, "rx_sta_power_headroom",
3030 htt_stats_buf->uplink_sta_power_headroom,
3031 ATH12K_HTT_RX_UL_MAX_UPLINK_RSSI_TRACK, "\n");
3032 len += scnprintf(buf + len, buf_len - len,
3033 "ul_ofdma_basic_trigger_rx_qos_null_only = %u\n\n",
3034 le32_to_cpu(htt_stats_buf->ul_ofdma_bsc_trig_rx_qos_null_only));
3035
3036 stats_req->buf_len = len;
3037 }
3038
3039 static void
ath12k_htt_print_ul_ofdma_user_stats(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3040 ath12k_htt_print_ul_ofdma_user_stats(const void *tag_buf, u16 tag_len,
3041 struct debug_htt_stats_req *stats_req)
3042 {
3043 const struct ath12k_htt_rx_pdev_ul_ofdma_user_stats_tlv *htt_stats_buf = tag_buf;
3044 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3045 u32 len = stats_req->buf_len;
3046 u8 *buf = stats_req->buf;
3047 u32 user_index;
3048
3049 if (tag_len < sizeof(*htt_stats_buf))
3050 return;
3051
3052 user_index = __le32_to_cpu(htt_stats_buf->user_index);
3053
3054 if (!user_index)
3055 len += scnprintf(buf + len, buf_len - len,
3056 "HTT_RX_PDEV_UL_OFDMA_USER_STAS_TLV:\n");
3057 len += scnprintf(buf + len, buf_len - len, "rx_ulofdma_non_data_ppdu_%u = %u\n",
3058 user_index,
3059 le32_to_cpu(htt_stats_buf->rx_ulofdma_non_data_ppdu));
3060 len += scnprintf(buf + len, buf_len - len, "rx_ulofdma_data_ppdu_%u = %u\n",
3061 user_index,
3062 le32_to_cpu(htt_stats_buf->rx_ulofdma_data_ppdu));
3063 len += scnprintf(buf + len, buf_len - len, "rx_ulofdma_mpdu_ok_%u = %u\n",
3064 user_index,
3065 le32_to_cpu(htt_stats_buf->rx_ulofdma_mpdu_ok));
3066 len += scnprintf(buf + len, buf_len - len, "rx_ulofdma_mpdu_fail_%u = %u\n",
3067 user_index,
3068 le32_to_cpu(htt_stats_buf->rx_ulofdma_mpdu_fail));
3069 len += scnprintf(buf + len, buf_len - len,
3070 "rx_ulofdma_non_data_nusers_%u = %u\n", user_index,
3071 le32_to_cpu(htt_stats_buf->rx_ulofdma_non_data_nusers));
3072 len += scnprintf(buf + len, buf_len - len, "rx_ulofdma_data_nusers_%u = %u\n\n",
3073 user_index,
3074 le32_to_cpu(htt_stats_buf->rx_ulofdma_data_nusers));
3075
3076 stats_req->buf_len = len;
3077 }
3078
3079 static void
ath12k_htt_print_ul_mumimo_trig_stats(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3080 ath12k_htt_print_ul_mumimo_trig_stats(const void *tag_buf, u16 tag_len,
3081 struct debug_htt_stats_req *stats_req)
3082 {
3083 const struct ath12k_htt_rx_ul_mumimo_trig_stats_tlv *htt_stats_buf = tag_buf;
3084 char str_buf[ATH12K_HTT_MAX_STRING_LEN] = {0};
3085 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3086 u32 len = stats_req->buf_len;
3087 u8 *buf = stats_req->buf;
3088 u32 mac_id;
3089 u16 index;
3090 u8 i, j;
3091
3092 if (tag_len < sizeof(*htt_stats_buf))
3093 return;
3094
3095 mac_id = __le32_to_cpu(htt_stats_buf->mac_id__word);
3096
3097 len += scnprintf(buf + len, buf_len - len,
3098 "HTT_RX_PDEV_UL_MUMIMO_TRIG_STATS_TLV:\n");
3099 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
3100 u32_get_bits(mac_id, ATH12K_HTT_STATS_MAC_ID));
3101 len += scnprintf(buf + len, buf_len - len, "rx_11ax_ul_mumimo = %u\n",
3102 le32_to_cpu(htt_stats_buf->rx_11ax_ul_mumimo));
3103 index = 0;
3104 memset(str_buf, 0x0, ATH12K_HTT_MAX_STRING_LEN);
3105 for (i = 0; i < ATH12K_HTT_RX_NUM_MCS_CNTRS; i++)
3106 index += scnprintf(&str_buf[index], ATH12K_HTT_MAX_STRING_LEN - index,
3107 " %u:%u,", i,
3108 le32_to_cpu(htt_stats_buf->ul_mumimo_rx_mcs[i]));
3109
3110 for (i = 0; i < ATH12K_HTT_RX_NUM_EXTRA_MCS_CNTRS; i++)
3111 index += scnprintf(&str_buf[index], ATH12K_HTT_MAX_STRING_LEN - index,
3112 " %u:%u,", i + ATH12K_HTT_RX_NUM_MCS_CNTRS,
3113 le32_to_cpu(htt_stats_buf->ul_mumimo_rx_mcs_ext[i]));
3114 str_buf[--index] = '\0';
3115 len += scnprintf(buf + len, buf_len - len, "ul_mumimo_rx_mcs = %s\n", str_buf);
3116
3117 for (j = 0; j < ATH12K_HTT_RX_NUM_GI_CNTRS; j++) {
3118 index = 0;
3119 memset(&str_buf[index], 0x0, ATH12K_HTT_MAX_STRING_LEN);
3120 for (i = 0; i < ATH12K_HTT_RX_NUM_MCS_CNTRS; i++)
3121 index += scnprintf(&str_buf[index],
3122 ATH12K_HTT_MAX_STRING_LEN - index,
3123 " %u:%u,", i,
3124 le32_to_cpu(htt_stats_buf->ul_rx_gi[j][i]));
3125
3126 for (i = 0; i < ATH12K_HTT_RX_NUM_EXTRA_MCS_CNTRS; i++)
3127 index += scnprintf(&str_buf[index],
3128 ATH12K_HTT_MAX_STRING_LEN - index,
3129 " %u:%u,", i + ATH12K_HTT_RX_NUM_MCS_CNTRS,
3130 le32_to_cpu(htt_stats_buf->ul_gi_ext[j][i]));
3131 str_buf[--index] = '\0';
3132 len += scnprintf(buf + len, buf_len - len,
3133 "ul_mumimo_rx_gi_%u = %s\n", j, str_buf);
3134 }
3135
3136 index = 0;
3137 memset(str_buf, 0x0, ATH12K_HTT_MAX_STRING_LEN);
3138 len += print_array_to_buf_index(buf, len, "ul_mumimo_rx_nss", 1,
3139 htt_stats_buf->ul_mumimo_rx_nss,
3140 ATH12K_HTT_RX_NUM_SPATIAL_STREAMS, "\n");
3141
3142 len += print_array_to_buf(buf, len, "ul_mumimo_rx_bw",
3143 htt_stats_buf->ul_mumimo_rx_bw,
3144 ATH12K_HTT_RX_NUM_BW_CNTRS, "\n");
3145 for (i = 0; i < ATH12K_HTT_RX_NUM_REDUCED_CHAN_TYPES; i++) {
3146 index = 0;
3147 memset(str_buf, 0x0, ATH12K_HTT_MAX_STRING_LEN);
3148 for (j = 0; j < ATH12K_HTT_RX_NUM_BW_CNTRS; j++)
3149 index += scnprintf(&str_buf[index],
3150 ATH12K_HTT_MAX_STRING_LEN - index,
3151 " %u:%u,", j,
3152 le32_to_cpu(htt_stats_buf->red_bw[i][j]));
3153 str_buf[--index] = '\0';
3154 len += scnprintf(buf + len, buf_len - len, "%s = %s\n",
3155 i == 0 ? "half_ul_mumimo_rx_bw" :
3156 "quarter_ul_mumimo_rx_bw", str_buf);
3157 }
3158
3159 len += scnprintf(buf + len, buf_len - len, "ul_mumimo_rx_stbc = %u\n",
3160 le32_to_cpu(htt_stats_buf->ul_mumimo_rx_stbc));
3161 len += scnprintf(buf + len, buf_len - len, "ul_mumimo_rx_ldpc = %u\n",
3162 le32_to_cpu(htt_stats_buf->ul_mumimo_rx_ldpc));
3163
3164 for (j = 0; j < ATH12K_HTT_RX_NUM_SPATIAL_STREAMS; j++) {
3165 len += scnprintf(buf + len, buf_len - len,
3166 "rx_ul_mumimo_rssi_in_dbm: chain%u ", j);
3167 len += print_array_to_buf_s8(buf, len, "", 0,
3168 htt_stats_buf->ul_rssi[j],
3169 ATH12K_HTT_RX_NUM_BW_CNTRS, "\n");
3170 }
3171
3172 for (j = 0; j < ATH12K_HTT_TX_UL_MUMIMO_USER_STATS; j++) {
3173 len += scnprintf(buf + len, buf_len - len,
3174 "rx_ul_mumimo_target_rssi: user_%u ", j);
3175 len += print_array_to_buf_s8(buf, len, "", 0,
3176 htt_stats_buf->tgt_rssi[j],
3177 ATH12K_HTT_RX_NUM_BW_CNTRS, "\n");
3178 }
3179
3180 for (j = 0; j < ATH12K_HTT_TX_UL_MUMIMO_USER_STATS; j++) {
3181 len += scnprintf(buf + len, buf_len - len,
3182 "rx_ul_mumimo_fd_rssi: user_%u ", j);
3183 len += print_array_to_buf_s8(buf, len, "", 0,
3184 htt_stats_buf->fd[j],
3185 ATH12K_HTT_RX_NUM_SPATIAL_STREAMS, "\n");
3186 }
3187
3188 for (j = 0; j < ATH12K_HTT_TX_UL_MUMIMO_USER_STATS; j++) {
3189 len += scnprintf(buf + len, buf_len - len,
3190 "rx_ulmumimo_pilot_evm_db_mean: user_%u ", j);
3191 len += print_array_to_buf_s8(buf, len, "", 0,
3192 htt_stats_buf->db[j],
3193 ATH12K_HTT_RX_NUM_SPATIAL_STREAMS, "\n");
3194 }
3195
3196 len += scnprintf(buf + len, buf_len - len,
3197 "ul_mumimo_basic_trigger_rx_qos_null_only = %u\n\n",
3198 le32_to_cpu(htt_stats_buf->mumimo_bsc_trig_rx_qos_null_only));
3199
3200 stats_req->buf_len = len;
3201 }
3202
3203 static void
ath12k_htt_print_rx_fse_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3204 ath12k_htt_print_rx_fse_stats_tlv(const void *tag_buf, u16 tag_len,
3205 struct debug_htt_stats_req *stats_req)
3206 {
3207 const struct ath12k_htt_rx_fse_stats_tlv *htt_stats_buf = tag_buf;
3208 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3209 u32 len = stats_req->buf_len;
3210 u8 *buf = stats_req->buf;
3211
3212 if (tag_len < sizeof(*htt_stats_buf))
3213 return;
3214
3215 len += scnprintf(buf + len, buf_len - len, "HTT_STATS_RX_FSE_STATS_TLV:\n");
3216 len += scnprintf(buf + len, buf_len - len, "=== Software RX FSE STATS ===\n");
3217 len += scnprintf(buf + len, buf_len - len, "Enable count = %u\n",
3218 le32_to_cpu(htt_stats_buf->fse_enable_cnt));
3219 len += scnprintf(buf + len, buf_len - len, "Disable count = %u\n",
3220 le32_to_cpu(htt_stats_buf->fse_disable_cnt));
3221 len += scnprintf(buf + len, buf_len - len, "Cache invalidate entry count = %u\n",
3222 le32_to_cpu(htt_stats_buf->fse_cache_invalidate_entry_cnt));
3223 len += scnprintf(buf + len, buf_len - len, "Full cache invalidate count = %u\n",
3224 le32_to_cpu(htt_stats_buf->fse_full_cache_invalidate_cnt));
3225
3226 len += scnprintf(buf + len, buf_len - len, "\n=== Hardware RX FSE STATS ===\n");
3227 len += scnprintf(buf + len, buf_len - len, "Cache hits count = %u\n",
3228 le32_to_cpu(htt_stats_buf->fse_num_cache_hits_cnt));
3229 len += scnprintf(buf + len, buf_len - len, "Cache no. of searches = %u\n",
3230 le32_to_cpu(htt_stats_buf->fse_num_searches_cnt));
3231 len += scnprintf(buf + len, buf_len - len, "Cache occupancy peak count:\n");
3232 len += scnprintf(buf + len, buf_len - len, "[0] = %u [1-16] = %u [17-32] = %u ",
3233 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[0]),
3234 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[1]),
3235 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[2]));
3236 len += scnprintf(buf + len, buf_len - len, "[33-48] = %u [49-64] = %u ",
3237 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[3]),
3238 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[4]));
3239 len += scnprintf(buf + len, buf_len - len, "[65-80] = %u [81-96] = %u ",
3240 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[5]),
3241 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[6]));
3242 len += scnprintf(buf + len, buf_len - len, "[97-112] = %u [113-127] = %u ",
3243 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[7]),
3244 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[8]));
3245 len += scnprintf(buf + len, buf_len - len, "[128] = %u\n",
3246 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_peak_cnt[9]));
3247 len += scnprintf(buf + len, buf_len - len, "Cache occupancy current count:\n");
3248 len += scnprintf(buf + len, buf_len - len, "[0] = %u [1-16] = %u [17-32] = %u ",
3249 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[0]),
3250 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[1]),
3251 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[2]));
3252 len += scnprintf(buf + len, buf_len - len, "[33-48] = %u [49-64] = %u ",
3253 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[3]),
3254 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[4]));
3255 len += scnprintf(buf + len, buf_len - len, "[65-80] = %u [81-96] = %u ",
3256 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[5]),
3257 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[6]));
3258 len += scnprintf(buf + len, buf_len - len, "[97-112] = %u [113-127] = %u ",
3259 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[7]),
3260 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[8]));
3261 len += scnprintf(buf + len, buf_len - len, "[128] = %u\n",
3262 le32_to_cpu(htt_stats_buf->fse_cache_occupancy_curr_cnt[9]));
3263 len += scnprintf(buf + len, buf_len - len, "Cache search square count:\n");
3264 len += scnprintf(buf + len, buf_len - len, "[0] = %u [1-50] = %u [51-100] = %u ",
3265 le32_to_cpu(htt_stats_buf->fse_search_stat_square_cnt[0]),
3266 le32_to_cpu(htt_stats_buf->fse_search_stat_square_cnt[1]),
3267 le32_to_cpu(htt_stats_buf->fse_search_stat_square_cnt[2]));
3268 len += scnprintf(buf + len, buf_len - len, "[101-200] = %u [201-255] = %u ",
3269 le32_to_cpu(htt_stats_buf->fse_search_stat_square_cnt[3]),
3270 le32_to_cpu(htt_stats_buf->fse_search_stat_square_cnt[4]));
3271 len += scnprintf(buf + len, buf_len - len, "[256] = %u\n",
3272 le32_to_cpu(htt_stats_buf->fse_search_stat_square_cnt[5]));
3273 len += scnprintf(buf + len, buf_len - len, "Cache search peak pending count:\n");
3274 len += scnprintf(buf + len, buf_len - len, "[0] = %u [1-2] = %u [3-4] = %u ",
3275 le32_to_cpu(htt_stats_buf->fse_search_stat_peak_cnt[0]),
3276 le32_to_cpu(htt_stats_buf->fse_search_stat_peak_cnt[1]),
3277 le32_to_cpu(htt_stats_buf->fse_search_stat_peak_cnt[2]));
3278 len += scnprintf(buf + len, buf_len - len, "[Greater/Equal to 5] = %u\n",
3279 le32_to_cpu(htt_stats_buf->fse_search_stat_peak_cnt[3]));
3280 len += scnprintf(buf + len, buf_len - len, "Cache search tot pending count:\n");
3281 len += scnprintf(buf + len, buf_len - len, "[0] = %u [1-2] = %u [3-4] = %u ",
3282 le32_to_cpu(htt_stats_buf->fse_search_stat_pending_cnt[0]),
3283 le32_to_cpu(htt_stats_buf->fse_search_stat_pending_cnt[1]),
3284 le32_to_cpu(htt_stats_buf->fse_search_stat_pending_cnt[2]));
3285 len += scnprintf(buf + len, buf_len - len, "[Greater/Equal to 5] = %u\n\n",
3286 le32_to_cpu(htt_stats_buf->fse_search_stat_pending_cnt[3]));
3287
3288 stats_req->buf_len = len;
3289 }
3290
3291 static void
ath12k_htt_print_pdev_tx_rate_txbf_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3292 ath12k_htt_print_pdev_tx_rate_txbf_stats_tlv(const void *tag_buf, u16 tag_len,
3293 struct debug_htt_stats_req *stats_req)
3294 {
3295 const struct ath12k_htt_pdev_txrate_txbf_stats_tlv *htt_stats_buf = tag_buf;
3296 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3297 u32 len = stats_req->buf_len;
3298 u8 *buf = stats_req->buf;
3299 u8 i;
3300
3301 if (tag_len < sizeof(*htt_stats_buf))
3302 return;
3303
3304 len += scnprintf(buf + len, buf_len - len,
3305 "HTT_STATS_PDEV_TX_RATE_TXBF_STATS:\n");
3306 len += scnprintf(buf + len, buf_len - len, "Legacy OFDM Rates: 6 Mbps: %u, ",
3307 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[0]));
3308 len += scnprintf(buf + len, buf_len - len, "9 Mbps: %u, 12 Mbps: %u, ",
3309 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[1]),
3310 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[2]));
3311 len += scnprintf(buf + len, buf_len - len, "18 Mbps: %u\n",
3312 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[3]));
3313 len += scnprintf(buf + len, buf_len - len, "24 Mbps: %u, 36 Mbps: %u, ",
3314 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[4]),
3315 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[5]));
3316 len += scnprintf(buf + len, buf_len - len, "48 Mbps: %u, 54 Mbps: %u\n",
3317 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[6]),
3318 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[7]));
3319
3320 len += print_array_to_buf(buf, len, "tx_ol_mcs", htt_stats_buf->tx_su_ol_mcs,
3321 ATH12K_HTT_TX_BF_RATE_STATS_NUM_MCS_COUNTERS, "\n");
3322 len += print_array_to_buf(buf, len, "tx_ibf_mcs", htt_stats_buf->tx_su_ibf_mcs,
3323 ATH12K_HTT_TX_BF_RATE_STATS_NUM_MCS_COUNTERS, "\n");
3324 len += print_array_to_buf(buf, len, "tx_txbf_mcs", htt_stats_buf->tx_su_txbf_mcs,
3325 ATH12K_HTT_TX_BF_RATE_STATS_NUM_MCS_COUNTERS, "\n");
3326 len += print_array_to_buf_index(buf, len, "tx_ol_nss", 1,
3327 htt_stats_buf->tx_su_ol_nss,
3328 ATH12K_HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS,
3329 "\n");
3330 len += print_array_to_buf_index(buf, len, "tx_ibf_nss", 1,
3331 htt_stats_buf->tx_su_ibf_nss,
3332 ATH12K_HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS,
3333 "\n");
3334 len += print_array_to_buf_index(buf, len, "tx_txbf_nss", 1,
3335 htt_stats_buf->tx_su_txbf_nss,
3336 ATH12K_HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS,
3337 "\n");
3338 len += print_array_to_buf(buf, len, "tx_ol_bw", htt_stats_buf->tx_su_ol_bw,
3339 ATH12K_HTT_TXBF_NUM_BW_CNTRS, "\n");
3340 for (i = 0; i < ATH12K_HTT_TXBF_NUM_REDUCED_CHAN_TYPES; i++)
3341 len += print_array_to_buf(buf, len, i ? "quarter_tx_ol_bw" :
3342 "half_tx_ol_bw",
3343 htt_stats_buf->ol[i],
3344 ATH12K_HTT_TXBF_NUM_BW_CNTRS,
3345 "\n");
3346
3347 len += print_array_to_buf(buf, len, "tx_ibf_bw", htt_stats_buf->tx_su_ibf_bw,
3348 ATH12K_HTT_TXBF_NUM_BW_CNTRS, "\n");
3349 for (i = 0; i < ATH12K_HTT_TXBF_NUM_REDUCED_CHAN_TYPES; i++)
3350 len += print_array_to_buf(buf, len, i ? "quarter_tx_ibf_bw" :
3351 "half_tx_ibf_bw",
3352 htt_stats_buf->ibf[i],
3353 ATH12K_HTT_TXBF_NUM_BW_CNTRS,
3354 "\n");
3355
3356 len += print_array_to_buf(buf, len, "tx_txbf_bw", htt_stats_buf->tx_su_txbf_bw,
3357 ATH12K_HTT_TXBF_NUM_BW_CNTRS, "\n");
3358 for (i = 0; i < ATH12K_HTT_TXBF_NUM_REDUCED_CHAN_TYPES; i++)
3359 len += print_array_to_buf(buf, len, i ? "quarter_tx_txbf_bw" :
3360 "half_tx_txbf_bw",
3361 htt_stats_buf->txbf[i],
3362 ATH12K_HTT_TXBF_NUM_BW_CNTRS,
3363 "\n");
3364 len += scnprintf(buf + len, buf_len - len, "\n");
3365
3366 len += scnprintf(buf + len, buf_len - len,
3367 "HTT_STATS_PDEV_TXBF_FLAG_RETURN_STATS:\n");
3368 len += scnprintf(buf + len, buf_len - len, "TXBF_reason_code_stats: 0:%u, 1:%u,",
3369 le32_to_cpu(htt_stats_buf->txbf_flag_set_mu_mode),
3370 le32_to_cpu(htt_stats_buf->txbf_flag_set_final_status));
3371 len += scnprintf(buf + len, buf_len - len, " 2:%u, 3:%u, 4:%u, 5:%u, ",
3372 le32_to_cpu(htt_stats_buf->txbf_flag_not_set_verified_txbf_mode),
3373 le32_to_cpu(htt_stats_buf->txbf_flag_not_set_disable_p2p_access),
3374 le32_to_cpu(htt_stats_buf->txbf_flag_not_set_max_nss_in_he160),
3375 le32_to_cpu(htt_stats_buf->txbf_flag_not_set_disable_uldlofdma));
3376 len += scnprintf(buf + len, buf_len - len, "6:%u, 7:%u\n\n",
3377 le32_to_cpu(htt_stats_buf->txbf_flag_not_set_mcs_threshold_val),
3378 le32_to_cpu(htt_stats_buf->txbf_flag_not_set_final_status));
3379
3380 stats_req->buf_len = len;
3381 }
3382
3383 static void
ath12k_htt_print_txbf_ofdma_ax_ndpa_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3384 ath12k_htt_print_txbf_ofdma_ax_ndpa_stats_tlv(const void *tag_buf, u16 tag_len,
3385 struct debug_htt_stats_req *stats_req)
3386 {
3387 const struct ath12k_htt_txbf_ofdma_ax_ndpa_stats_tlv *stats_buf = tag_buf;
3388 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3389 u32 len = stats_req->buf_len;
3390 u8 *buf = stats_req->buf;
3391 u32 num_elements;
3392 u8 i;
3393
3394 if (tag_len < sizeof(*stats_buf))
3395 return;
3396
3397 num_elements = le32_to_cpu(stats_buf->num_elems_ax_ndpa_arr);
3398
3399 len += scnprintf(buf + len, buf_len - len, "HTT_TXBF_OFDMA_AX_NDPA_STATS_TLV:\n");
3400 len += scnprintf(buf + len, buf_len - len, "ax_ofdma_ndpa_queued =");
3401 for (i = 0; i < num_elements; i++)
3402 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3403 le32_to_cpu(stats_buf->ax_ndpa[i].ax_ofdma_ndpa_queued));
3404 len--;
3405 *(buf + len) = '\0';
3406
3407 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_ndpa_tried =");
3408 for (i = 0; i < num_elements; i++)
3409 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3410 le32_to_cpu(stats_buf->ax_ndpa[i].ax_ofdma_ndpa_tried));
3411 len--;
3412 *(buf + len) = '\0';
3413
3414 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_ndpa_flushed =");
3415 for (i = 0; i < num_elements; i++)
3416 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3417 le32_to_cpu(stats_buf->ax_ndpa[i].ax_ofdma_ndpa_flush));
3418 len--;
3419 *(buf + len) = '\0';
3420
3421 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_ndpa_err =");
3422 for (i = 0; i < num_elements; i++)
3423 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3424 le32_to_cpu(stats_buf->ax_ndpa[i].ax_ofdma_ndpa_err));
3425 len--;
3426 *(buf + len) = '\0';
3427
3428 len += scnprintf(buf + len, buf_len - len, "\n\n");
3429
3430 stats_req->buf_len = len;
3431 }
3432
3433 static void
ath12k_htt_print_txbf_ofdma_ax_ndp_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3434 ath12k_htt_print_txbf_ofdma_ax_ndp_stats_tlv(const void *tag_buf, u16 tag_len,
3435 struct debug_htt_stats_req *stats_req)
3436 {
3437 const struct ath12k_htt_txbf_ofdma_ax_ndp_stats_tlv *stats_buf = tag_buf;
3438 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3439 u32 len = stats_req->buf_len;
3440 u8 *buf = stats_req->buf;
3441 u32 num_elements;
3442 u8 i;
3443
3444 if (tag_len < sizeof(*stats_buf))
3445 return;
3446
3447 num_elements = le32_to_cpu(stats_buf->num_elems_ax_ndp_arr);
3448
3449 len += scnprintf(buf + len, buf_len - len, "HTT_TXBF_OFDMA_AX_NDP_STATS_TLV:\n");
3450 len += scnprintf(buf + len, buf_len - len, "ax_ofdma_ndp_queued =");
3451 for (i = 0; i < num_elements; i++)
3452 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3453 le32_to_cpu(stats_buf->ax_ndp[i].ax_ofdma_ndp_queued));
3454 len--;
3455 *(buf + len) = '\0';
3456
3457 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_ndp_tried =");
3458 for (i = 0; i < num_elements; i++)
3459 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3460 le32_to_cpu(stats_buf->ax_ndp[i].ax_ofdma_ndp_tried));
3461 len--;
3462 *(buf + len) = '\0';
3463
3464 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_ndp_flushed =");
3465 for (i = 0; i < num_elements; i++)
3466 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3467 le32_to_cpu(stats_buf->ax_ndp[i].ax_ofdma_ndp_flush));
3468 len--;
3469 *(buf + len) = '\0';
3470
3471 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_ndp_err =");
3472 for (i = 0; i < num_elements; i++)
3473 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3474 le32_to_cpu(stats_buf->ax_ndp[i].ax_ofdma_ndp_err));
3475 len--;
3476 *(buf + len) = '\0';
3477
3478 len += scnprintf(buf + len, buf_len - len, "\n\n");
3479
3480 stats_req->buf_len = len;
3481 }
3482
3483 static void
ath12k_htt_print_txbf_ofdma_ax_brp_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3484 ath12k_htt_print_txbf_ofdma_ax_brp_stats_tlv(const void *tag_buf, u16 tag_len,
3485 struct debug_htt_stats_req *stats_req)
3486 {
3487 const struct ath12k_htt_txbf_ofdma_ax_brp_stats_tlv *stats_buf = tag_buf;
3488 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3489 u32 len = stats_req->buf_len;
3490 u8 *buf = stats_req->buf;
3491 u32 num_elements;
3492 u8 i;
3493
3494 if (tag_len < sizeof(*stats_buf))
3495 return;
3496
3497 num_elements = le32_to_cpu(stats_buf->num_elems_ax_brp_arr);
3498
3499 len += scnprintf(buf + len, buf_len - len, "HTT_TXBF_OFDMA_AX_BRP_STATS_TLV:\n");
3500 len += scnprintf(buf + len, buf_len - len, "ax_ofdma_brpoll_queued =");
3501 for (i = 0; i < num_elements; i++)
3502 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3503 le32_to_cpu(stats_buf->ax_brp[i].ax_ofdma_brp_queued));
3504 len--;
3505 *(buf + len) = '\0';
3506
3507 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_brpoll_tied =");
3508 for (i = 0; i < num_elements; i++)
3509 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3510 le32_to_cpu(stats_buf->ax_brp[i].ax_ofdma_brp_tried));
3511 len--;
3512 *(buf + len) = '\0';
3513
3514 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_brpoll_flushed =");
3515 for (i = 0; i < num_elements; i++)
3516 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3517 le32_to_cpu(stats_buf->ax_brp[i].ax_ofdma_brp_flushed));
3518 len--;
3519 *(buf + len) = '\0';
3520
3521 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_brp_err =");
3522 for (i = 0; i < num_elements; i++)
3523 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3524 le32_to_cpu(stats_buf->ax_brp[i].ax_ofdma_brp_err));
3525 len--;
3526 *(buf + len) = '\0';
3527
3528 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_brp_err_num_cbf_rcvd =");
3529 for (i = 0; i < num_elements; i++)
3530 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3531 le32_to_cpu(stats_buf->ax_brp[i].ax_ofdma_num_cbf_rcvd));
3532 len--;
3533 *(buf + len) = '\0';
3534
3535 len += scnprintf(buf + len, buf_len - len, "\n\n");
3536
3537 stats_req->buf_len = len;
3538 }
3539
3540 static void
ath12k_htt_print_txbf_ofdma_ax_steer_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3541 ath12k_htt_print_txbf_ofdma_ax_steer_stats_tlv(const void *tag_buf, u16 tag_len,
3542 struct debug_htt_stats_req *stats_req)
3543 {
3544 const struct ath12k_htt_txbf_ofdma_ax_steer_stats_tlv *stats_buf = tag_buf;
3545 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3546 u32 len = stats_req->buf_len;
3547 u8 *buf = stats_req->buf;
3548 u32 num_elements;
3549 u8 i;
3550
3551 if (tag_len < sizeof(*stats_buf))
3552 return;
3553
3554 num_elements = le32_to_cpu(stats_buf->num_elems_ax_steer_arr);
3555
3556 len += scnprintf(buf + len, buf_len - len,
3557 "HTT_TXBF_OFDMA_AX_STEER_STATS_TLV:\n");
3558 len += scnprintf(buf + len, buf_len - len, "ax_ofdma_num_ppdu_steer =");
3559 for (i = 0; i < num_elements; i++)
3560 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3561 le32_to_cpu(stats_buf->ax_steer[i].num_ppdu_steer));
3562 len--;
3563 *(buf + len) = '\0';
3564
3565 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_num_usrs_prefetch =");
3566 for (i = 0; i < num_elements; i++)
3567 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3568 le32_to_cpu(stats_buf->ax_steer[i].num_usr_prefetch));
3569 len--;
3570 *(buf + len) = '\0';
3571
3572 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_num_usrs_sound =");
3573 for (i = 0; i < num_elements; i++)
3574 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3575 le32_to_cpu(stats_buf->ax_steer[i].num_usr_sound));
3576 len--;
3577 *(buf + len) = '\0';
3578
3579 len += scnprintf(buf + len, buf_len - len, "\nax_ofdma_num_usrs_force_sound =");
3580 for (i = 0; i < num_elements; i++)
3581 len += scnprintf(buf + len, buf_len - len, " %u:%u,", i + 1,
3582 le32_to_cpu(stats_buf->ax_steer[i].num_usr_force_sound));
3583 len--;
3584 *(buf + len) = '\0';
3585
3586 len += scnprintf(buf + len, buf_len - len, "\n\n");
3587
3588 stats_req->buf_len = len;
3589 }
3590
3591 static void
ath12k_htt_print_txbf_ofdma_ax_steer_mpdu_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3592 ath12k_htt_print_txbf_ofdma_ax_steer_mpdu_stats_tlv(const void *tag_buf, u16 tag_len,
3593 struct debug_htt_stats_req *stats_req)
3594 {
3595 const struct ath12k_htt_txbf_ofdma_ax_steer_mpdu_stats_tlv *stats_buf = tag_buf;
3596 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3597 u32 len = stats_req->buf_len;
3598 u8 *buf = stats_req->buf;
3599
3600 if (tag_len < sizeof(*stats_buf))
3601 return;
3602
3603 len += scnprintf(buf + len, buf_len - len,
3604 "HTT_TXBF_OFDMA_AX_STEER_MPDU_STATS_TLV:\n");
3605 len += scnprintf(buf + len, buf_len - len, "rbo_steer_mpdus_tried = %u\n",
3606 le32_to_cpu(stats_buf->ax_ofdma_rbo_steer_mpdus_tried));
3607 len += scnprintf(buf + len, buf_len - len, "rbo_steer_mpdus_failed = %u\n",
3608 le32_to_cpu(stats_buf->ax_ofdma_rbo_steer_mpdus_failed));
3609 len += scnprintf(buf + len, buf_len - len, "sifs_steer_mpdus_tried = %u\n",
3610 le32_to_cpu(stats_buf->ax_ofdma_sifs_steer_mpdus_tried));
3611 len += scnprintf(buf + len, buf_len - len, "sifs_steer_mpdus_failed = %u\n\n",
3612 le32_to_cpu(stats_buf->ax_ofdma_sifs_steer_mpdus_failed));
3613
3614 stats_req->buf_len = len;
3615 }
3616
ath12k_htt_print_dlpager_entry(const struct ath12k_htt_pgs_info * pg_info,int idx,char * str_buf)3617 static void ath12k_htt_print_dlpager_entry(const struct ath12k_htt_pgs_info *pg_info,
3618 int idx, char *str_buf)
3619 {
3620 u64 page_timestamp;
3621 u16 index = 0;
3622
3623 page_timestamp = ath12k_le32hilo_to_u64(pg_info->ts_msb, pg_info->ts_lsb);
3624
3625 index += snprintf(&str_buf[index], ATH12K_HTT_MAX_STRING_LEN - index,
3626 "Index - %u ; Page Number - %u ; ",
3627 idx, le32_to_cpu(pg_info->page_num));
3628 index += snprintf(&str_buf[index], ATH12K_HTT_MAX_STRING_LEN - index,
3629 "Num of pages - %u ; Timestamp - %lluus\n",
3630 le32_to_cpu(pg_info->num_pgs), page_timestamp);
3631 }
3632
3633 static void
ath12k_htt_print_dlpager_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3634 ath12k_htt_print_dlpager_stats_tlv(const void *tag_buf, u16 tag_len,
3635 struct debug_htt_stats_req *stats_req)
3636 {
3637 const struct ath12k_htt_dl_pager_stats_tlv *stat_buf = tag_buf;
3638 u32 len = stats_req->buf_len;
3639 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3640 u32 dword_lock, dword_unlock;
3641 int i;
3642 u8 *buf = stats_req->buf;
3643 u8 pg_locked;
3644 u8 pg_unlock;
3645 char str_buf[ATH12K_HTT_MAX_STRING_LEN] = {0};
3646
3647 if (tag_len < sizeof(*stat_buf))
3648 return;
3649
3650 dword_lock = le32_get_bits(stat_buf->info2,
3651 ATH12K_HTT_DLPAGER_TOTAL_LOCK_PAGES_INFO2);
3652 dword_unlock = le32_get_bits(stat_buf->info2,
3653 ATH12K_HTT_DLPAGER_TOTAL_FREE_PAGES_INFO2);
3654
3655 pg_locked = ATH12K_HTT_STATS_PAGE_LOCKED;
3656 pg_unlock = ATH12K_HTT_STATS_PAGE_UNLOCKED;
3657
3658 len += scnprintf(buf + len, buf_len - len, "HTT_DLPAGER_STATS_TLV:\n");
3659 len += scnprintf(buf + len, buf_len - len, "ASYNC locked pages = %u\n",
3660 le32_get_bits(stat_buf->info0,
3661 ATH12K_HTT_DLPAGER_ASYNC_LOCK_PG_CNT_INFO0));
3662 len += scnprintf(buf + len, buf_len - len, "SYNC locked pages = %u\n",
3663 le32_get_bits(stat_buf->info0,
3664 ATH12K_HTT_DLPAGER_SYNC_LOCK_PG_CNT_INFO0));
3665 len += scnprintf(buf + len, buf_len - len, "Total locked pages = %u\n",
3666 le32_get_bits(stat_buf->info1,
3667 ATH12K_HTT_DLPAGER_TOTAL_LOCK_PAGES_INFO1));
3668 len += scnprintf(buf + len, buf_len - len, "Total free pages = %u\n",
3669 le32_get_bits(stat_buf->info1,
3670 ATH12K_HTT_DLPAGER_TOTAL_FREE_PAGES_INFO1));
3671
3672 len += scnprintf(buf + len, buf_len - len, "\nLOCKED PAGES HISTORY\n");
3673 len += scnprintf(buf + len, buf_len - len, "last_locked_page_idx = %u\n",
3674 dword_lock ? dword_lock - 1 : (ATH12K_PAGER_MAX - 1));
3675
3676 for (i = 0; i < ATH12K_PAGER_MAX; i++) {
3677 memset(str_buf, 0x0, ATH12K_HTT_MAX_STRING_LEN);
3678 ath12k_htt_print_dlpager_entry(&stat_buf->pgs_info[pg_locked][i],
3679 i, str_buf);
3680 len += scnprintf(buf + len, buf_len - len, "%s", str_buf);
3681 }
3682
3683 len += scnprintf(buf + len, buf_len - len, "\nUNLOCKED PAGES HISTORY\n");
3684 len += scnprintf(buf + len, buf_len - len, "last_unlocked_page_idx = %u\n",
3685 dword_unlock ? dword_unlock - 1 : ATH12K_PAGER_MAX - 1);
3686
3687 for (i = 0; i < ATH12K_PAGER_MAX; i++) {
3688 memset(str_buf, 0x0, ATH12K_HTT_MAX_STRING_LEN);
3689 ath12k_htt_print_dlpager_entry(&stat_buf->pgs_info[pg_unlock][i],
3690 i, str_buf);
3691 len += scnprintf(buf + len, buf_len - len, "%s", str_buf);
3692 }
3693
3694 len += scnprintf(buf + len, buf_len - len, "\n");
3695
3696 stats_req->buf_len = len;
3697 }
3698
3699 static void
ath12k_htt_print_phy_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3700 ath12k_htt_print_phy_stats_tlv(const void *tag_buf, u16 tag_len,
3701 struct debug_htt_stats_req *stats_req)
3702 {
3703 const struct ath12k_htt_phy_stats_tlv *htt_stats_buf = tag_buf;
3704 u32 len = stats_req->buf_len;
3705 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3706 u8 *buf = stats_req->buf, i;
3707
3708 if (tag_len < sizeof(*htt_stats_buf))
3709 return;
3710
3711 len += scnprintf(buf + len, buf_len - len, "HTT_PHY_STATS_TLV:\n");
3712 for (i = 0; i < ATH12K_HTT_STATS_MAX_CHAINS; i++)
3713 len += scnprintf(buf + len, buf_len - len, "bdf_nf_chain[%d] = %d\n",
3714 i, a_sle32_to_cpu(htt_stats_buf->nf_chain[i]));
3715 for (i = 0; i < ATH12K_HTT_STATS_MAX_CHAINS; i++)
3716 len += scnprintf(buf + len, buf_len - len, "runtime_nf_chain[%d] = %d\n",
3717 i, a_sle32_to_cpu(htt_stats_buf->runtime_nf_chain[i]));
3718 len += scnprintf(buf + len, buf_len - len, "false_radar_cnt = %u / %u (mins)\n",
3719 le32_to_cpu(htt_stats_buf->false_radar_cnt),
3720 le32_to_cpu(htt_stats_buf->fw_run_time));
3721 len += scnprintf(buf + len, buf_len - len, "radar_cs_cnt = %u\n",
3722 le32_to_cpu(htt_stats_buf->radar_cs_cnt));
3723 len += scnprintf(buf + len, buf_len - len, "ani_level = %d\n\n",
3724 a_sle32_to_cpu(htt_stats_buf->ani_level));
3725
3726 stats_req->buf_len = len;
3727 }
3728
3729 static void
ath12k_htt_print_phy_counters_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3730 ath12k_htt_print_phy_counters_tlv(const void *tag_buf, u16 tag_len,
3731 struct debug_htt_stats_req *stats_req)
3732 {
3733 const struct ath12k_htt_phy_counters_tlv *htt_stats_buf = tag_buf;
3734 u32 len = stats_req->buf_len;
3735 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3736 u8 *buf = stats_req->buf;
3737
3738 if (tag_len < sizeof(*htt_stats_buf))
3739 return;
3740
3741 len += scnprintf(buf + len, buf_len - len, "HTT_PHY_COUNTERS_TLV:\n");
3742 len += scnprintf(buf + len, buf_len - len, "rx_ofdma_timing_err_cnt = %u\n",
3743 le32_to_cpu(htt_stats_buf->rx_ofdma_timing_err_cnt));
3744 len += scnprintf(buf + len, buf_len - len, "rx_cck_fail_cnt = %u\n",
3745 le32_to_cpu(htt_stats_buf->rx_cck_fail_cnt));
3746 len += scnprintf(buf + len, buf_len - len, "mactx_abort_cnt = %u\n",
3747 le32_to_cpu(htt_stats_buf->mactx_abort_cnt));
3748 len += scnprintf(buf + len, buf_len - len, "macrx_abort_cnt = %u\n",
3749 le32_to_cpu(htt_stats_buf->macrx_abort_cnt));
3750 len += scnprintf(buf + len, buf_len - len, "phytx_abort_cnt = %u\n",
3751 le32_to_cpu(htt_stats_buf->phytx_abort_cnt));
3752 len += scnprintf(buf + len, buf_len - len, "phyrx_abort_cnt = %u\n",
3753 le32_to_cpu(htt_stats_buf->phyrx_abort_cnt));
3754 len += scnprintf(buf + len, buf_len - len, "phyrx_defer_abort_cnt = %u\n",
3755 le32_to_cpu(htt_stats_buf->phyrx_defer_abort_cnt));
3756 len += scnprintf(buf + len, buf_len - len, "rx_gain_adj_lstf_event_cnt = %u\n",
3757 le32_to_cpu(htt_stats_buf->rx_gain_adj_lstf_event_cnt));
3758 len += scnprintf(buf + len, buf_len - len, "rx_gain_adj_non_legacy_cnt = %u\n",
3759 le32_to_cpu(htt_stats_buf->rx_gain_adj_non_legacy_cnt));
3760 len += print_array_to_buf(buf, len, "rx_pkt_cnt", htt_stats_buf->rx_pkt_cnt,
3761 ATH12K_HTT_MAX_RX_PKT_CNT, "\n");
3762 len += print_array_to_buf(buf, len, "rx_pkt_crc_pass_cnt",
3763 htt_stats_buf->rx_pkt_crc_pass_cnt,
3764 ATH12K_HTT_MAX_RX_PKT_CRC_PASS_CNT, "\n");
3765 len += print_array_to_buf(buf, len, "per_blk_err_cnt",
3766 htt_stats_buf->per_blk_err_cnt,
3767 ATH12K_HTT_MAX_PER_BLK_ERR_CNT, "\n");
3768 len += print_array_to_buf(buf, len, "rx_ota_err_cnt",
3769 htt_stats_buf->rx_ota_err_cnt,
3770 ATH12K_HTT_MAX_RX_OTA_ERR_CNT, "\n\n");
3771
3772 stats_req->buf_len = len;
3773 }
3774
3775 static void
ath12k_htt_print_phy_reset_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3776 ath12k_htt_print_phy_reset_stats_tlv(const void *tag_buf, u16 tag_len,
3777 struct debug_htt_stats_req *stats_req)
3778 {
3779 const struct ath12k_htt_phy_reset_stats_tlv *htt_stats_buf = tag_buf;
3780 u32 len = stats_req->buf_len;
3781 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3782 u8 *buf = stats_req->buf;
3783
3784 if (tag_len < sizeof(*htt_stats_buf))
3785 return;
3786
3787 len += scnprintf(buf + len, buf_len - len, "HTT_PHY_RESET_STATS_TLV:\n");
3788 len += scnprintf(buf + len, buf_len - len, "pdev_id = %u\n",
3789 le32_to_cpu(htt_stats_buf->pdev_id));
3790 len += scnprintf(buf + len, buf_len - len, "chan_mhz = %u\n",
3791 le32_to_cpu(htt_stats_buf->chan_mhz));
3792 len += scnprintf(buf + len, buf_len - len, "chan_band_center_freq1 = %u\n",
3793 le32_to_cpu(htt_stats_buf->chan_band_center_freq1));
3794 len += scnprintf(buf + len, buf_len - len, "chan_band_center_freq2 = %u\n",
3795 le32_to_cpu(htt_stats_buf->chan_band_center_freq2));
3796 len += scnprintf(buf + len, buf_len - len, "chan_phy_mode = %u\n",
3797 le32_to_cpu(htt_stats_buf->chan_phy_mode));
3798 len += scnprintf(buf + len, buf_len - len, "chan_flags = 0x%0x\n",
3799 le32_to_cpu(htt_stats_buf->chan_flags));
3800 len += scnprintf(buf + len, buf_len - len, "chan_num = %u\n",
3801 le32_to_cpu(htt_stats_buf->chan_num));
3802 len += scnprintf(buf + len, buf_len - len, "reset_cause = 0x%0x\n",
3803 le32_to_cpu(htt_stats_buf->reset_cause));
3804 len += scnprintf(buf + len, buf_len - len, "prev_reset_cause = 0x%0x\n",
3805 le32_to_cpu(htt_stats_buf->prev_reset_cause));
3806 len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_src = 0x%0x\n",
3807 le32_to_cpu(htt_stats_buf->phy_warm_reset_src));
3808 len += scnprintf(buf + len, buf_len - len, "rx_gain_tbl_mode = %d\n",
3809 le32_to_cpu(htt_stats_buf->rx_gain_tbl_mode));
3810 len += scnprintf(buf + len, buf_len - len, "xbar_val = 0x%0x\n",
3811 le32_to_cpu(htt_stats_buf->xbar_val));
3812 len += scnprintf(buf + len, buf_len - len, "force_calibration = %u\n",
3813 le32_to_cpu(htt_stats_buf->force_calibration));
3814 len += scnprintf(buf + len, buf_len - len, "phyrf_mode = %u\n",
3815 le32_to_cpu(htt_stats_buf->phyrf_mode));
3816 len += scnprintf(buf + len, buf_len - len, "phy_homechan = %u\n",
3817 le32_to_cpu(htt_stats_buf->phy_homechan));
3818 len += scnprintf(buf + len, buf_len - len, "phy_tx_ch_mask = 0x%0x\n",
3819 le32_to_cpu(htt_stats_buf->phy_tx_ch_mask));
3820 len += scnprintf(buf + len, buf_len - len, "phy_rx_ch_mask = 0x%0x\n",
3821 le32_to_cpu(htt_stats_buf->phy_rx_ch_mask));
3822 len += scnprintf(buf + len, buf_len - len, "phybb_ini_mask = 0x%0x\n",
3823 le32_to_cpu(htt_stats_buf->phybb_ini_mask));
3824 len += scnprintf(buf + len, buf_len - len, "phyrf_ini_mask = 0x%0x\n",
3825 le32_to_cpu(htt_stats_buf->phyrf_ini_mask));
3826 len += scnprintf(buf + len, buf_len - len, "phy_dfs_en_mask = 0x%0x\n",
3827 le32_to_cpu(htt_stats_buf->phy_dfs_en_mask));
3828 len += scnprintf(buf + len, buf_len - len, "phy_sscan_en_mask = 0x%0x\n",
3829 le32_to_cpu(htt_stats_buf->phy_sscan_en_mask));
3830 len += scnprintf(buf + len, buf_len - len, "phy_synth_sel_mask = 0x%0x\n",
3831 le32_to_cpu(htt_stats_buf->phy_synth_sel_mask));
3832 len += scnprintf(buf + len, buf_len - len, "phy_adfs_freq = %u\n",
3833 le32_to_cpu(htt_stats_buf->phy_adfs_freq));
3834 len += scnprintf(buf + len, buf_len - len, "cck_fir_settings = 0x%0x\n",
3835 le32_to_cpu(htt_stats_buf->cck_fir_settings));
3836 len += scnprintf(buf + len, buf_len - len, "phy_dyn_pri_chan = %u\n",
3837 le32_to_cpu(htt_stats_buf->phy_dyn_pri_chan));
3838 len += scnprintf(buf + len, buf_len - len, "cca_thresh = 0x%0x\n",
3839 le32_to_cpu(htt_stats_buf->cca_thresh));
3840 len += scnprintf(buf + len, buf_len - len, "dyn_cca_status = %u\n",
3841 le32_to_cpu(htt_stats_buf->dyn_cca_status));
3842 len += scnprintf(buf + len, buf_len - len, "rxdesense_thresh_hw = 0x%x\n",
3843 le32_to_cpu(htt_stats_buf->rxdesense_thresh_hw));
3844 len += scnprintf(buf + len, buf_len - len, "rxdesense_thresh_sw = 0x%x\n\n",
3845 le32_to_cpu(htt_stats_buf->rxdesense_thresh_sw));
3846
3847 stats_req->buf_len = len;
3848 }
3849
3850 static void
ath12k_htt_print_phy_reset_counters_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3851 ath12k_htt_print_phy_reset_counters_tlv(const void *tag_buf, u16 tag_len,
3852 struct debug_htt_stats_req *stats_req)
3853 {
3854 const struct ath12k_htt_phy_reset_counters_tlv *htt_stats_buf = tag_buf;
3855 u32 len = stats_req->buf_len;
3856 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3857 u8 *buf = stats_req->buf;
3858
3859 if (tag_len < sizeof(*htt_stats_buf))
3860 return;
3861
3862 len += scnprintf(buf + len, buf_len - len, "HTT_PHY_RESET_COUNTERS_TLV:\n");
3863 len += scnprintf(buf + len, buf_len - len, "pdev_id = %u\n",
3864 le32_to_cpu(htt_stats_buf->pdev_id));
3865 len += scnprintf(buf + len, buf_len - len, "cf_active_low_fail_cnt = %u\n",
3866 le32_to_cpu(htt_stats_buf->cf_active_low_fail_cnt));
3867 len += scnprintf(buf + len, buf_len - len, "cf_active_low_pass_cnt = %u\n",
3868 le32_to_cpu(htt_stats_buf->cf_active_low_pass_cnt));
3869 len += scnprintf(buf + len, buf_len - len, "phy_off_through_vreg_cnt = %u\n",
3870 le32_to_cpu(htt_stats_buf->phy_off_through_vreg_cnt));
3871 len += scnprintf(buf + len, buf_len - len, "force_calibration_cnt = %u\n",
3872 le32_to_cpu(htt_stats_buf->force_calibration_cnt));
3873 len += scnprintf(buf + len, buf_len - len, "rf_mode_switch_phy_off_cnt = %u\n",
3874 le32_to_cpu(htt_stats_buf->rf_mode_switch_phy_off_cnt));
3875 len += scnprintf(buf + len, buf_len - len, "temperature_recal_cnt = %u\n\n",
3876 le32_to_cpu(htt_stats_buf->temperature_recal_cnt));
3877
3878 stats_req->buf_len = len;
3879 }
3880
3881 static void
ath12k_htt_print_phy_tpc_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3882 ath12k_htt_print_phy_tpc_stats_tlv(const void *tag_buf, u16 tag_len,
3883 struct debug_htt_stats_req *stats_req)
3884 {
3885 const struct ath12k_htt_phy_tpc_stats_tlv *htt_stats_buf = tag_buf;
3886 u32 len = stats_req->buf_len;
3887 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3888 u8 *buf = stats_req->buf;
3889
3890 if (tag_len < sizeof(*htt_stats_buf))
3891 return;
3892
3893 len += scnprintf(buf + len, buf_len - len, "HTT_PHY_TPC_STATS_TLV:\n");
3894 len += scnprintf(buf + len, buf_len - len, "pdev_id = %u\n",
3895 le32_to_cpu(htt_stats_buf->pdev_id));
3896 len += scnprintf(buf + len, buf_len - len, "tx_power_scale = %u\n",
3897 le32_to_cpu(htt_stats_buf->tx_power_scale));
3898 len += scnprintf(buf + len, buf_len - len, "tx_power_scale_db = %u\n",
3899 le32_to_cpu(htt_stats_buf->tx_power_scale_db));
3900 len += scnprintf(buf + len, buf_len - len, "min_negative_tx_power = %d\n",
3901 le32_to_cpu(htt_stats_buf->min_negative_tx_power));
3902 len += scnprintf(buf + len, buf_len - len, "reg_ctl_domain = %u\n",
3903 le32_to_cpu(htt_stats_buf->reg_ctl_domain));
3904 len += scnprintf(buf + len, buf_len - len, "twice_max_rd_power = %u\n",
3905 le32_to_cpu(htt_stats_buf->twice_max_rd_power));
3906 len += scnprintf(buf + len, buf_len - len, "max_tx_power = %u\n",
3907 le32_to_cpu(htt_stats_buf->max_tx_power));
3908 len += scnprintf(buf + len, buf_len - len, "home_max_tx_power = %u\n",
3909 le32_to_cpu(htt_stats_buf->home_max_tx_power));
3910 len += scnprintf(buf + len, buf_len - len, "psd_power = %d\n",
3911 le32_to_cpu(htt_stats_buf->psd_power));
3912 len += scnprintf(buf + len, buf_len - len, "eirp_power = %u\n",
3913 le32_to_cpu(htt_stats_buf->eirp_power));
3914 len += scnprintf(buf + len, buf_len - len, "power_type_6ghz = %u\n",
3915 le32_to_cpu(htt_stats_buf->power_type_6ghz));
3916 len += print_array_to_buf(buf, len, "max_reg_allowed_power",
3917 htt_stats_buf->max_reg_allowed_power,
3918 ATH12K_HTT_STATS_MAX_CHAINS, "\n");
3919 len += print_array_to_buf(buf, len, "max_reg_allowed_power_6ghz",
3920 htt_stats_buf->max_reg_allowed_power_6ghz,
3921 ATH12K_HTT_STATS_MAX_CHAINS, "\n");
3922 len += print_array_to_buf(buf, len, "sub_band_cfreq",
3923 htt_stats_buf->sub_band_cfreq,
3924 ATH12K_HTT_MAX_CH_PWR_INFO_SIZE, "\n");
3925 len += print_array_to_buf(buf, len, "sub_band_txpower",
3926 htt_stats_buf->sub_band_txpower,
3927 ATH12K_HTT_MAX_CH_PWR_INFO_SIZE, "\n\n");
3928
3929 stats_req->buf_len = len;
3930 }
3931
3932 static void
ath12k_htt_print_soc_txrx_stats_common_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3933 ath12k_htt_print_soc_txrx_stats_common_tlv(const void *tag_buf, u16 tag_len,
3934 struct debug_htt_stats_req *stats_req)
3935 {
3936 const struct ath12k_htt_t2h_soc_txrx_stats_common_tlv *htt_stats_buf = tag_buf;
3937 u64 drop_count;
3938 u32 len = stats_req->buf_len;
3939 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3940 u8 *buf = stats_req->buf;
3941
3942 if (tag_len < sizeof(*htt_stats_buf))
3943 return;
3944
3945 drop_count = ath12k_le32hilo_to_u64(htt_stats_buf->inv_peers_msdu_drop_count_hi,
3946 htt_stats_buf->inv_peers_msdu_drop_count_lo);
3947
3948 len += scnprintf(buf + len, buf_len - len, "HTT_SOC_COMMON_STATS_TLV:\n");
3949 len += scnprintf(buf + len, buf_len - len, "soc_drop_count = %llu\n\n",
3950 drop_count);
3951
3952 stats_req->buf_len = len;
3953 }
3954
3955 static void
ath12k_htt_print_tx_per_rate_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3956 ath12k_htt_print_tx_per_rate_stats_tlv(const void *tag_buf, u16 tag_len,
3957 struct debug_htt_stats_req *stats_req)
3958 {
3959 const struct ath12k_htt_tx_per_rate_stats_tlv *stats_buf = tag_buf;
3960 u32 len = stats_req->buf_len;
3961 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3962 u32 ru_size_cnt = 0;
3963 u32 rc_mode, ru_type;
3964 u8 *buf = stats_req->buf, i;
3965 const char *mode_prefix;
3966
3967 if (tag_len < sizeof(*stats_buf))
3968 return;
3969
3970 rc_mode = le32_to_cpu(stats_buf->rc_mode);
3971 ru_type = le32_to_cpu(stats_buf->ru_type);
3972
3973 switch (rc_mode) {
3974 case ATH12K_HTT_STATS_RC_MODE_DLSU:
3975 len += scnprintf(buf + len, buf_len - len, "HTT_TX_PER_STATS:\n");
3976 len += scnprintf(buf + len, buf_len - len, "\nPER_STATS_SU:\n");
3977 mode_prefix = "su";
3978 break;
3979 case ATH12K_HTT_STATS_RC_MODE_DLMUMIMO:
3980 len += scnprintf(buf + len, buf_len - len, "\nPER_STATS_DL_MUMIMO:\n");
3981 mode_prefix = "mu";
3982 break;
3983 case ATH12K_HTT_STATS_RC_MODE_DLOFDMA:
3984 len += scnprintf(buf + len, buf_len - len, "\nPER_STATS_DL_OFDMA:\n");
3985 mode_prefix = "ofdma";
3986 if (ru_type == ATH12K_HTT_STATS_RU_TYPE_SINGLE_RU_ONLY)
3987 ru_size_cnt = ATH12K_HTT_TX_RX_PDEV_STATS_NUM_AX_RU_SIZE_CNTRS;
3988 else if (ru_type == ATH12K_HTT_STATS_RU_TYPE_SINGLE_AND_MULTI_RU)
3989 ru_size_cnt = ATH12K_HTT_TX_RX_PDEV_NUM_BE_RU_SIZE_CNTRS;
3990 break;
3991 case ATH12K_HTT_STATS_RC_MODE_ULMUMIMO:
3992 len += scnprintf(buf + len, buf_len - len, "HTT_RX_PER_STATS:\n");
3993 len += scnprintf(buf + len, buf_len - len, "\nPER_STATS_UL_MUMIMO:\n");
3994 mode_prefix = "ulmu";
3995 break;
3996 case ATH12K_HTT_STATS_RC_MODE_ULOFDMA:
3997 len += scnprintf(buf + len, buf_len - len, "\nPER_STATS_UL_OFDMA:\n");
3998 mode_prefix = "ulofdma";
3999 if (ru_type == ATH12K_HTT_STATS_RU_TYPE_SINGLE_RU_ONLY)
4000 ru_size_cnt = ATH12K_HTT_TX_RX_PDEV_STATS_NUM_AX_RU_SIZE_CNTRS;
4001 else if (ru_type == ATH12K_HTT_STATS_RU_TYPE_SINGLE_AND_MULTI_RU)
4002 ru_size_cnt = ATH12K_HTT_TX_RX_PDEV_NUM_BE_RU_SIZE_CNTRS;
4003 break;
4004 default:
4005 return;
4006 }
4007
4008 len += scnprintf(buf + len, buf_len - len, "\nPER per BW:\n");
4009 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA ||
4010 rc_mode == ATH12K_HTT_STATS_RC_MODE_ULMUMIMO)
4011 len += scnprintf(buf + len, buf_len - len, "data_ppdus_%s = ",
4012 mode_prefix);
4013 else
4014 len += scnprintf(buf + len, buf_len - len, "ppdus_tried_%s = ",
4015 mode_prefix);
4016 for (i = 0; i < ATH12K_HTT_TX_PDEV_STATS_NUM_BW_CNTRS; i++)
4017 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i,
4018 le32_to_cpu(stats_buf->per_bw[i].ppdus_tried));
4019 len += scnprintf(buf + len, buf_len - len, " %u:%u\n", i,
4020 le32_to_cpu(stats_buf->per_bw320.ppdus_tried));
4021
4022 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA ||
4023 rc_mode == ATH12K_HTT_STATS_RC_MODE_ULMUMIMO)
4024 len += scnprintf(buf + len, buf_len - len, "non_data_ppdus_%s = ",
4025 mode_prefix);
4026 else
4027 len += scnprintf(buf + len, buf_len - len, "ppdus_ack_failed_%s = ",
4028 mode_prefix);
4029 for (i = 0; i < ATH12K_HTT_TX_PDEV_STATS_NUM_BW_CNTRS; i++)
4030 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i,
4031 le32_to_cpu(stats_buf->per_bw[i].ppdus_ack_failed));
4032 len += scnprintf(buf + len, buf_len - len, " %u:%u\n", i,
4033 le32_to_cpu(stats_buf->per_bw320.ppdus_ack_failed));
4034
4035 len += scnprintf(buf + len, buf_len - len, "mpdus_tried_%s = ", mode_prefix);
4036 for (i = 0; i < ATH12K_HTT_TX_PDEV_STATS_NUM_BW_CNTRS; i++)
4037 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i,
4038 le32_to_cpu(stats_buf->per_bw[i].mpdus_tried));
4039 len += scnprintf(buf + len, buf_len - len, " %u:%u\n", i,
4040 le32_to_cpu(stats_buf->per_bw320.mpdus_tried));
4041
4042 len += scnprintf(buf + len, buf_len - len, "mpdus_failed_%s = ", mode_prefix);
4043 for (i = 0; i < ATH12K_HTT_TX_PDEV_STATS_NUM_BW_CNTRS; i++)
4044 len += scnprintf(buf + len, buf_len - len, " %u:%u", i,
4045 le32_to_cpu(stats_buf->per_bw[i].mpdus_failed));
4046 len += scnprintf(buf + len, buf_len - len, " %u:%u\n", i,
4047 le32_to_cpu(stats_buf->per_bw320.mpdus_failed));
4048
4049 len += scnprintf(buf + len, buf_len - len, "\nPER per NSS:\n");
4050 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA ||
4051 rc_mode == ATH12K_HTT_STATS_RC_MODE_ULMUMIMO)
4052 len += scnprintf(buf + len, buf_len - len, "data_ppdus_%s = ",
4053 mode_prefix);
4054 else
4055 len += scnprintf(buf + len, buf_len - len, "ppdus_tried_%s = ",
4056 mode_prefix);
4057 for (i = 0; i < ATH12K_HTT_PDEV_STAT_NUM_SPATIAL_STREAMS; i++)
4058 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i + 1,
4059 le32_to_cpu(stats_buf->per_nss[i].ppdus_tried));
4060 len += scnprintf(buf + len, buf_len - len, "\n");
4061
4062 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA ||
4063 rc_mode == ATH12K_HTT_STATS_RC_MODE_ULMUMIMO)
4064 len += scnprintf(buf + len, buf_len - len, "non_data_ppdus_%s = ",
4065 mode_prefix);
4066 else
4067 len += scnprintf(buf + len, buf_len - len, "ppdus_ack_failed_%s = ",
4068 mode_prefix);
4069 for (i = 0; i < ATH12K_HTT_PDEV_STAT_NUM_SPATIAL_STREAMS; i++)
4070 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i + 1,
4071 le32_to_cpu(stats_buf->per_nss[i].ppdus_ack_failed));
4072 len += scnprintf(buf + len, buf_len - len, "\n");
4073
4074 len += scnprintf(buf + len, buf_len - len, "mpdus_tried_%s = ", mode_prefix);
4075 for (i = 0; i < ATH12K_HTT_PDEV_STAT_NUM_SPATIAL_STREAMS; i++)
4076 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i + 1,
4077 le32_to_cpu(stats_buf->per_nss[i].mpdus_tried));
4078 len += scnprintf(buf + len, buf_len - len, "\n");
4079
4080 len += scnprintf(buf + len, buf_len - len, "mpdus_failed_%s = ", mode_prefix);
4081 for (i = 0; i < ATH12K_HTT_PDEV_STAT_NUM_SPATIAL_STREAMS; i++)
4082 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i + 1,
4083 le32_to_cpu(stats_buf->per_nss[i].mpdus_failed));
4084 len += scnprintf(buf + len, buf_len - len, "\n");
4085
4086 len += scnprintf(buf + len, buf_len - len, "\nPER per MCS:\n");
4087 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA ||
4088 rc_mode == ATH12K_HTT_STATS_RC_MODE_ULMUMIMO)
4089 len += scnprintf(buf + len, buf_len - len, "data_ppdus_%s = ",
4090 mode_prefix);
4091 else
4092 len += scnprintf(buf + len, buf_len - len, "ppdus_tried_%s = ",
4093 mode_prefix);
4094 for (i = 0; i < ATH12K_HTT_TXBF_RATE_STAT_NUM_MCS_CNTRS; i++)
4095 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i,
4096 le32_to_cpu(stats_buf->per_mcs[i].ppdus_tried));
4097 len += scnprintf(buf + len, buf_len - len, "\n");
4098
4099 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA ||
4100 rc_mode == ATH12K_HTT_STATS_RC_MODE_ULMUMIMO)
4101 len += scnprintf(buf + len, buf_len - len, "non_data_ppdus_%s = ",
4102 mode_prefix);
4103 else
4104 len += scnprintf(buf + len, buf_len - len, "ppdus_ack_failed_%s = ",
4105 mode_prefix);
4106 for (i = 0; i < ATH12K_HTT_TXBF_RATE_STAT_NUM_MCS_CNTRS; i++)
4107 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i,
4108 le32_to_cpu(stats_buf->per_mcs[i].ppdus_ack_failed));
4109 len += scnprintf(buf + len, buf_len - len, "\n");
4110
4111 len += scnprintf(buf + len, buf_len - len, "mpdus_tried_%s = ", mode_prefix);
4112 for (i = 0; i < ATH12K_HTT_TXBF_RATE_STAT_NUM_MCS_CNTRS; i++)
4113 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i,
4114 le32_to_cpu(stats_buf->per_mcs[i].mpdus_tried));
4115 len += scnprintf(buf + len, buf_len - len, "\n");
4116
4117 len += scnprintf(buf + len, buf_len - len, "mpdus_failed_%s = ", mode_prefix);
4118 for (i = 0; i < ATH12K_HTT_TXBF_RATE_STAT_NUM_MCS_CNTRS; i++)
4119 len += scnprintf(buf + len, buf_len - len, " %u:%u ", i,
4120 le32_to_cpu(stats_buf->per_mcs[i].mpdus_failed));
4121 len += scnprintf(buf + len, buf_len - len, "\n");
4122
4123 if ((rc_mode == ATH12K_HTT_STATS_RC_MODE_DLOFDMA ||
4124 rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA) &&
4125 ru_type != ATH12K_HTT_STATS_RU_TYPE_INVALID) {
4126 len += scnprintf(buf + len, buf_len - len, "\nPER per RU:\n");
4127
4128 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA)
4129 len += scnprintf(buf + len, buf_len - len, "data_ppdus_%s = ",
4130 mode_prefix);
4131 else
4132 len += scnprintf(buf + len, buf_len - len, "ppdus_tried_%s = ",
4133 mode_prefix);
4134 for (i = 0; i < ru_size_cnt; i++)
4135 len += scnprintf(buf + len, buf_len - len, " %s:%u ",
4136 ath12k_tx_ru_size_to_str(ru_type, i),
4137 le32_to_cpu(stats_buf->ru[i].ppdus_tried));
4138 len += scnprintf(buf + len, buf_len - len, "\n");
4139
4140 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_ULOFDMA)
4141 len += scnprintf(buf + len, buf_len - len,
4142 "non_data_ppdus_%s = ", mode_prefix);
4143 else
4144 len += scnprintf(buf + len, buf_len - len,
4145 "ppdus_ack_failed_%s = ", mode_prefix);
4146 for (i = 0; i < ru_size_cnt; i++)
4147 len += scnprintf(buf + len, buf_len - len, " %s:%u ",
4148 ath12k_tx_ru_size_to_str(ru_type, i),
4149 le32_to_cpu(stats_buf->ru[i].ppdus_ack_failed));
4150 len += scnprintf(buf + len, buf_len - len, "\n");
4151
4152 len += scnprintf(buf + len, buf_len - len, "mpdus_tried_%s = ",
4153 mode_prefix);
4154 for (i = 0; i < ru_size_cnt; i++)
4155 len += scnprintf(buf + len, buf_len - len, " %s:%u ",
4156 ath12k_tx_ru_size_to_str(ru_type, i),
4157 le32_to_cpu(stats_buf->ru[i].mpdus_tried));
4158 len += scnprintf(buf + len, buf_len - len, "\n");
4159
4160 len += scnprintf(buf + len, buf_len - len, "mpdus_failed_%s = ",
4161 mode_prefix);
4162 for (i = 0; i < ru_size_cnt; i++)
4163 len += scnprintf(buf + len, buf_len - len, " %s:%u ",
4164 ath12k_tx_ru_size_to_str(ru_type, i),
4165 le32_to_cpu(stats_buf->ru[i].mpdus_failed));
4166 len += scnprintf(buf + len, buf_len - len, "\n\n");
4167 }
4168
4169 if (rc_mode == ATH12K_HTT_STATS_RC_MODE_DLMUMIMO) {
4170 len += scnprintf(buf + len, buf_len - len, "\nlast_probed_bw = %u\n",
4171 le32_to_cpu(stats_buf->last_probed_bw));
4172 len += scnprintf(buf + len, buf_len - len, "last_probed_nss = %u\n",
4173 le32_to_cpu(stats_buf->last_probed_nss));
4174 len += scnprintf(buf + len, buf_len - len, "last_probed_mcs = %u\n",
4175 le32_to_cpu(stats_buf->last_probed_mcs));
4176 len += print_array_to_buf(buf, len, "MU Probe count per RC MODE",
4177 stats_buf->probe_cnt,
4178 ATH12K_HTT_RC_MODE_2D_COUNT, "\n\n");
4179 }
4180
4181 stats_req->buf_len = len;
4182 }
4183
4184 static void
ath12k_htt_print_ast_entry_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4185 ath12k_htt_print_ast_entry_tlv(const void *tag_buf, u16 tag_len,
4186 struct debug_htt_stats_req *stats_req)
4187 {
4188 const struct ath12k_htt_ast_entry_tlv *htt_stats_buf = tag_buf;
4189 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4190 u32 len = stats_req->buf_len;
4191 u8 *buf = stats_req->buf;
4192 u32 mac_addr_l32;
4193 u32 mac_addr_h16;
4194 u32 ast_info;
4195
4196 if (tag_len < sizeof(*htt_stats_buf))
4197 return;
4198
4199 mac_addr_l32 = le32_to_cpu(htt_stats_buf->mac_addr.mac_addr_l32);
4200 mac_addr_h16 = le32_to_cpu(htt_stats_buf->mac_addr.mac_addr_h16);
4201 ast_info = le32_to_cpu(htt_stats_buf->info);
4202
4203 len += scnprintf(buf + len, buf_len - len, "HTT_AST_ENTRY_TLV:\n");
4204 len += scnprintf(buf + len, buf_len - len, "ast_index = %u\n",
4205 le32_to_cpu(htt_stats_buf->ast_index));
4206 len += scnprintf(buf + len, buf_len - len,
4207 "mac_addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
4208 u32_get_bits(mac_addr_l32, ATH12K_HTT_MAC_ADDR_L32_0),
4209 u32_get_bits(mac_addr_l32, ATH12K_HTT_MAC_ADDR_L32_1),
4210 u32_get_bits(mac_addr_l32, ATH12K_HTT_MAC_ADDR_L32_2),
4211 u32_get_bits(mac_addr_l32, ATH12K_HTT_MAC_ADDR_L32_3),
4212 u32_get_bits(mac_addr_h16, ATH12K_HTT_MAC_ADDR_H16_0),
4213 u32_get_bits(mac_addr_h16, ATH12K_HTT_MAC_ADDR_H16_1));
4214
4215 len += scnprintf(buf + len, buf_len - len, "sw_peer_id = %u\n",
4216 le32_to_cpu(htt_stats_buf->sw_peer_id));
4217 len += scnprintf(buf + len, buf_len - len, "pdev_id = %u\n",
4218 u32_get_bits(ast_info, ATH12K_HTT_AST_PDEV_ID_INFO));
4219 len += scnprintf(buf + len, buf_len - len, "vdev_id = %u\n",
4220 u32_get_bits(ast_info, ATH12K_HTT_AST_VDEV_ID_INFO));
4221 len += scnprintf(buf + len, buf_len - len, "next_hop = %u\n",
4222 u32_get_bits(ast_info, ATH12K_HTT_AST_NEXT_HOP_INFO));
4223 len += scnprintf(buf + len, buf_len - len, "mcast = %u\n",
4224 u32_get_bits(ast_info, ATH12K_HTT_AST_MCAST_INFO));
4225 len += scnprintf(buf + len, buf_len - len, "monitor_direct = %u\n",
4226 u32_get_bits(ast_info, ATH12K_HTT_AST_MONITOR_DIRECT_INFO));
4227 len += scnprintf(buf + len, buf_len - len, "mesh_sta = %u\n",
4228 u32_get_bits(ast_info, ATH12K_HTT_AST_MESH_STA_INFO));
4229 len += scnprintf(buf + len, buf_len - len, "mec = %u\n",
4230 u32_get_bits(ast_info, ATH12K_HTT_AST_MEC_INFO));
4231 len += scnprintf(buf + len, buf_len - len, "intra_bss = %u\n\n",
4232 u32_get_bits(ast_info, ATH12K_HTT_AST_INTRA_BSS_INFO));
4233
4234 stats_req->buf_len = len;
4235 }
4236
4237 static const char*
ath12k_htt_get_punct_dir_type_str(enum ath12k_htt_stats_direction direction)4238 ath12k_htt_get_punct_dir_type_str(enum ath12k_htt_stats_direction direction)
4239 {
4240 switch (direction) {
4241 case ATH12K_HTT_STATS_DIRECTION_TX:
4242 return "tx";
4243 case ATH12K_HTT_STATS_DIRECTION_RX:
4244 return "rx";
4245 default:
4246 return "unknown";
4247 }
4248 }
4249
4250 static const char*
ath12k_htt_get_punct_ppdu_type_str(enum ath12k_htt_stats_ppdu_type ppdu_type)4251 ath12k_htt_get_punct_ppdu_type_str(enum ath12k_htt_stats_ppdu_type ppdu_type)
4252 {
4253 switch (ppdu_type) {
4254 case ATH12K_HTT_STATS_PPDU_TYPE_MODE_SU:
4255 return "su";
4256 case ATH12K_HTT_STATS_PPDU_TYPE_DL_MU_MIMO:
4257 return "dl_mu_mimo";
4258 case ATH12K_HTT_STATS_PPDU_TYPE_UL_MU_MIMO:
4259 return "ul_mu_mimo";
4260 case ATH12K_HTT_STATS_PPDU_TYPE_DL_MU_OFDMA:
4261 return "dl_mu_ofdma";
4262 case ATH12K_HTT_STATS_PPDU_TYPE_UL_MU_OFDMA:
4263 return "ul_mu_ofdma";
4264 default:
4265 return "unknown";
4266 }
4267 }
4268
4269 static const char*
ath12k_htt_get_punct_pream_type_str(enum ath12k_htt_stats_param_type pream_type)4270 ath12k_htt_get_punct_pream_type_str(enum ath12k_htt_stats_param_type pream_type)
4271 {
4272 switch (pream_type) {
4273 case ATH12K_HTT_STATS_PREAM_OFDM:
4274 return "ofdm";
4275 case ATH12K_HTT_STATS_PREAM_CCK:
4276 return "cck";
4277 case ATH12K_HTT_STATS_PREAM_HT:
4278 return "ht";
4279 case ATH12K_HTT_STATS_PREAM_VHT:
4280 return "ac";
4281 case ATH12K_HTT_STATS_PREAM_HE:
4282 return "ax";
4283 case ATH12K_HTT_STATS_PREAM_EHT:
4284 return "be";
4285 default:
4286 return "unknown";
4287 }
4288 }
4289
4290 static void
ath12k_htt_print_puncture_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4291 ath12k_htt_print_puncture_stats_tlv(const void *tag_buf, u16 tag_len,
4292 struct debug_htt_stats_req *stats_req)
4293 {
4294 const struct ath12k_htt_pdev_puncture_stats_tlv *stats_buf = tag_buf;
4295 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4296 u32 len = stats_req->buf_len;
4297 u8 *buf = stats_req->buf;
4298 const char *direction;
4299 const char *ppdu_type;
4300 const char *preamble;
4301 u32 mac_id__word;
4302 u32 subband_limit;
4303 u8 i;
4304
4305 if (tag_len < sizeof(*stats_buf))
4306 return;
4307
4308 mac_id__word = le32_to_cpu(stats_buf->mac_id__word);
4309 subband_limit = min(le32_to_cpu(stats_buf->subband_cnt),
4310 ATH12K_HTT_PUNCT_STATS_MAX_SUBBAND_CNT);
4311
4312 direction = ath12k_htt_get_punct_dir_type_str(le32_to_cpu(stats_buf->direction));
4313 ppdu_type = ath12k_htt_get_punct_ppdu_type_str(le32_to_cpu(stats_buf->ppdu_type));
4314 preamble = ath12k_htt_get_punct_pream_type_str(le32_to_cpu(stats_buf->preamble));
4315
4316 len += scnprintf(buf + len, buf_len - len, "HTT_PDEV_PUNCTURE_STATS_TLV:\n");
4317 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4318 u32_get_bits(mac_id__word, ATH12K_HTT_STATS_MAC_ID));
4319 len += scnprintf(buf + len, buf_len - len,
4320 "%s_%s_%s_last_used_pattern_mask = 0x%08x\n",
4321 direction, preamble, ppdu_type,
4322 le32_to_cpu(stats_buf->last_used_pattern_mask));
4323
4324 for (i = 0; i < subband_limit; i++) {
4325 len += scnprintf(buf + len, buf_len - len,
4326 "%s_%s_%s_num_subbands_used_cnt_%02d = %u\n",
4327 direction, preamble, ppdu_type, i + 1,
4328 le32_to_cpu(stats_buf->num_subbands_used_cnt[i]));
4329 }
4330 len += scnprintf(buf + len, buf_len - len, "\n");
4331
4332 stats_req->buf_len = len;
4333 }
4334
4335 static void
ath12k_htt_print_dmac_reset_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4336 ath12k_htt_print_dmac_reset_stats_tlv(const void *tag_buf, u16 tag_len,
4337 struct debug_htt_stats_req *stats_req)
4338 {
4339 const struct ath12k_htt_dmac_reset_stats_tlv *htt_stats_buf = tag_buf;
4340 u8 *buf = stats_req->buf;
4341 u32 len = stats_req->buf_len;
4342 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4343 u64 time;
4344
4345 if (tag_len < sizeof(*htt_stats_buf))
4346 return;
4347
4348 len += scnprintf(buf + len, buf_len - len, "HTT_DMAC_RESET_STATS_TLV:\n");
4349 len += scnprintf(buf + len, buf_len - len, "reset_count = %u\n",
4350 le32_to_cpu(htt_stats_buf->reset_count));
4351 time = ath12k_le32hilo_to_u64(htt_stats_buf->reset_time_hi_ms,
4352 htt_stats_buf->reset_time_lo_ms);
4353 len += scnprintf(buf + len, buf_len - len, "reset_time_ms = %llu\n", time);
4354 time = ath12k_le32hilo_to_u64(htt_stats_buf->disengage_time_hi_ms,
4355 htt_stats_buf->disengage_time_lo_ms);
4356 len += scnprintf(buf + len, buf_len - len, "disengage_time_ms = %llu\n", time);
4357
4358 time = ath12k_le32hilo_to_u64(htt_stats_buf->engage_time_hi_ms,
4359 htt_stats_buf->engage_time_lo_ms);
4360 len += scnprintf(buf + len, buf_len - len, "engage_time_ms = %llu\n", time);
4361
4362 len += scnprintf(buf + len, buf_len - len, "disengage_count = %u\n",
4363 le32_to_cpu(htt_stats_buf->disengage_count));
4364 len += scnprintf(buf + len, buf_len - len, "engage_count = %u\n",
4365 le32_to_cpu(htt_stats_buf->engage_count));
4366 len += scnprintf(buf + len, buf_len - len, "drain_dest_ring_mask = 0x%x\n\n",
4367 le32_to_cpu(htt_stats_buf->drain_dest_ring_mask));
4368
4369 stats_req->buf_len = len;
4370 }
4371
4372 static void
ath12k_htt_print_pdev_sched_algo_ofdma_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4373 ath12k_htt_print_pdev_sched_algo_ofdma_stats_tlv(const void *tag_buf, u16 tag_len,
4374 struct debug_htt_stats_req *stats_req)
4375 {
4376 const struct ath12k_htt_pdev_sched_algo_ofdma_stats_tlv *htt_stats_buf = tag_buf;
4377 u8 *buf = stats_req->buf;
4378 u32 len = stats_req->buf_len;
4379 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4380 u32 mac_id_word;
4381
4382 if (tag_len < sizeof(*htt_stats_buf))
4383 return;
4384
4385 mac_id_word = le32_to_cpu(htt_stats_buf->mac_id__word);
4386
4387 len += scnprintf(buf + len, buf_len - len, "HTT_PDEV_SCHED_ALGO_TLV:\n");
4388 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4389 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
4390 len += print_array_to_buf(buf, len, "rate_based_dlofdma_enabled_count",
4391 htt_stats_buf->rate_based_dlofdma_enabled_cnt,
4392 ATH12K_HTT_NUM_AC_WMM, "\n");
4393 len += print_array_to_buf(buf, len, "rate_based_dlofdma_disabled_count",
4394 htt_stats_buf->rate_based_dlofdma_disabled_cnt,
4395 ATH12K_HTT_NUM_AC_WMM, "\n");
4396 len += print_array_to_buf(buf, len, "rate_based_dlofdma_probing_count",
4397 htt_stats_buf->rate_based_dlofdma_disabled_cnt,
4398 ATH12K_HTT_NUM_AC_WMM, "\n");
4399 len += print_array_to_buf(buf, len, "rate_based_dlofdma_monitoring_count",
4400 htt_stats_buf->rate_based_dlofdma_monitor_cnt,
4401 ATH12K_HTT_NUM_AC_WMM, "\n");
4402 len += print_array_to_buf(buf, len, "chan_acc_lat_based_dlofdma_enabled_count",
4403 htt_stats_buf->chan_acc_lat_based_dlofdma_enabled_cnt,
4404 ATH12K_HTT_NUM_AC_WMM, "\n");
4405 len += print_array_to_buf(buf, len, "chan_acc_lat_based_dlofdma_disabled_count",
4406 htt_stats_buf->chan_acc_lat_based_dlofdma_disabled_cnt,
4407 ATH12K_HTT_NUM_AC_WMM, "\n");
4408 len += print_array_to_buf(buf, len, "chan_acc_lat_based_dlofdma_monitoring_count",
4409 htt_stats_buf->chan_acc_lat_based_dlofdma_monitor_cnt,
4410 ATH12K_HTT_NUM_AC_WMM, "\n");
4411 len += print_array_to_buf(buf, len, "downgrade_to_dl_su_ru_alloc_fail",
4412 htt_stats_buf->downgrade_to_dl_su_ru_alloc_fail,
4413 ATH12K_HTT_NUM_AC_WMM, "\n");
4414 len += print_array_to_buf(buf, len, "candidate_list_single_user_disable_ofdma",
4415 htt_stats_buf->candidate_list_single_user_disable_ofdma,
4416 ATH12K_HTT_NUM_AC_WMM, "\n");
4417 len += print_array_to_buf(buf, len, "dl_cand_list_dropped_high_ul_qos_weight",
4418 htt_stats_buf->dl_cand_list_dropped_high_ul_qos_weight,
4419 ATH12K_HTT_NUM_AC_WMM, "\n");
4420 len += print_array_to_buf(buf, len, "ax_dlofdma_disabled_due_to_pipelining",
4421 htt_stats_buf->ax_dlofdma_disabled_due_to_pipelining,
4422 ATH12K_HTT_NUM_AC_WMM, "\n");
4423 len += print_array_to_buf(buf, len, "dlofdma_disabled_su_only_eligible",
4424 htt_stats_buf->dlofdma_disabled_su_only_eligible,
4425 ATH12K_HTT_NUM_AC_WMM, "\n");
4426 len += print_array_to_buf(buf, len, "dlofdma_disabled_consec_no_mpdus_tried",
4427 htt_stats_buf->dlofdma_disabled_consec_no_mpdus_tried,
4428 ATH12K_HTT_NUM_AC_WMM, "\n");
4429 len += print_array_to_buf(buf, len, "dlofdma_disabled_consec_no_mpdus_success",
4430 htt_stats_buf->dlofdma_disabled_consec_no_mpdus_success,
4431 ATH12K_HTT_NUM_AC_WMM, "\n\n");
4432
4433 stats_req->buf_len = len;
4434 }
4435
4436 static void
ath12k_htt_print_tx_pdev_rate_stats_be_ofdma_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4437 ath12k_htt_print_tx_pdev_rate_stats_be_ofdma_tlv(const void *tag_buf, u16 tag_len,
4438 struct debug_htt_stats_req *stats_req)
4439 {
4440 const struct ath12k_htt_tx_pdev_rate_stats_be_ofdma_tlv *htt_stats_buf = tag_buf;
4441 u8 *buf = stats_req->buf;
4442 u32 len = stats_req->buf_len;
4443 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4444 u32 mac_id_word;
4445 u8 i;
4446
4447 if (tag_len < sizeof(*htt_stats_buf))
4448 return;
4449
4450 mac_id_word = le32_to_cpu(htt_stats_buf->mac_id__word);
4451
4452 len += scnprintf(buf + len, buf_len - len,
4453 "HTT_TX_PDEV_RATE_STATS_BE_OFDMA_TLV:\n");
4454 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4455 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
4456 len += scnprintf(buf + len, buf_len - len, "be_ofdma_tx_ldpc = %u\n",
4457 le32_to_cpu(htt_stats_buf->be_ofdma_tx_ldpc));
4458 len += print_array_to_buf(buf, len, "be_ofdma_tx_mcs",
4459 htt_stats_buf->be_ofdma_tx_mcs,
4460 ATH12K_HTT_TX_PDEV_NUM_BE_MCS_CNTRS, "\n");
4461 len += print_array_to_buf(buf, len, "be_ofdma_eht_sig_mcs",
4462 htt_stats_buf->be_ofdma_eht_sig_mcs,
4463 ATH12K_HTT_TX_PDEV_NUM_EHT_SIG_MCS_CNTRS, "\n");
4464 len += scnprintf(buf + len, buf_len - len, "be_ofdma_tx_ru_size = ");
4465 for (i = 0; i < ATH12K_HTT_TX_RX_PDEV_NUM_BE_RU_SIZE_CNTRS; i++)
4466 len += scnprintf(buf + len, buf_len - len, " %s:%u ",
4467 ath12k_htt_be_tx_rx_ru_size_to_str(i),
4468 le32_to_cpu(htt_stats_buf->be_ofdma_tx_ru_size[i]));
4469 len += scnprintf(buf + len, buf_len - len, "\n");
4470 len += print_array_to_buf_index(buf, len, "be_ofdma_tx_nss = ", 1,
4471 htt_stats_buf->be_ofdma_tx_nss,
4472 ATH12K_HTT_PDEV_STAT_NUM_SPATIAL_STREAMS,
4473 "\n");
4474 len += print_array_to_buf(buf, len, "be_ofdma_tx_bw",
4475 htt_stats_buf->be_ofdma_tx_bw,
4476 ATH12K_HTT_TX_PDEV_NUM_BE_BW_CNTRS, "\n");
4477 for (i = 0; i < ATH12K_HTT_TX_PDEV_NUM_GI_CNTRS; i++) {
4478 len += scnprintf(buf + len, buf_len - len,
4479 "be_ofdma_tx_gi[%u]", i);
4480 len += print_array_to_buf(buf, len, "", htt_stats_buf->gi[i],
4481 ATH12K_HTT_TX_PDEV_NUM_BE_MCS_CNTRS, "\n");
4482 }
4483 len += scnprintf(buf + len, buf_len - len, "\n");
4484
4485 stats_req->buf_len = len;
4486 }
4487
4488 static void
ath12k_htt_print_pdev_mbssid_ctrl_frame_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4489 ath12k_htt_print_pdev_mbssid_ctrl_frame_stats_tlv(const void *tag_buf, u16 tag_len,
4490 struct debug_htt_stats_req *stats_req)
4491 {
4492 const struct ath12k_htt_pdev_mbssid_ctrl_frame_tlv *htt_stats_buf = tag_buf;
4493 u8 *buf = stats_req->buf;
4494 u32 len = stats_req->buf_len;
4495 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4496 u32 mac_id_word;
4497
4498 if (tag_len < sizeof(*htt_stats_buf))
4499 return;
4500
4501 mac_id_word = le32_to_cpu(htt_stats_buf->mac_id__word);
4502
4503 len += scnprintf(buf + len, buf_len - len, "HTT_MBSSID_CTRL_FRAME_STATS_TLV:\n");
4504 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4505 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
4506 len += scnprintf(buf + len, buf_len - len, "basic_trigger_across_bss = %u\n",
4507 le32_to_cpu(htt_stats_buf->basic_trigger_across_bss));
4508 len += scnprintf(buf + len, buf_len - len, "basic_trigger_within_bss = %u\n",
4509 le32_to_cpu(htt_stats_buf->basic_trigger_within_bss));
4510 len += scnprintf(buf + len, buf_len - len, "bsr_trigger_across_bss = %u\n",
4511 le32_to_cpu(htt_stats_buf->bsr_trigger_across_bss));
4512 len += scnprintf(buf + len, buf_len - len, "bsr_trigger_within_bss = %u\n",
4513 le32_to_cpu(htt_stats_buf->bsr_trigger_within_bss));
4514 len += scnprintf(buf + len, buf_len - len, "mu_rts_across_bss = %u\n",
4515 le32_to_cpu(htt_stats_buf->mu_rts_across_bss));
4516 len += scnprintf(buf + len, buf_len - len, "mu_rts_within_bss = %u\n",
4517 le32_to_cpu(htt_stats_buf->mu_rts_within_bss));
4518 len += scnprintf(buf + len, buf_len - len, "ul_mumimo_trigger_across_bss = %u\n",
4519 le32_to_cpu(htt_stats_buf->ul_mumimo_trigger_across_bss));
4520 len += scnprintf(buf + len, buf_len - len,
4521 "ul_mumimo_trigger_within_bss = %u\n\n",
4522 le32_to_cpu(htt_stats_buf->ul_mumimo_trigger_within_bss));
4523
4524 stats_req->buf_len = len;
4525 }
4526
4527 static inline void
ath12k_htt_print_tx_pdev_rate_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4528 ath12k_htt_print_tx_pdev_rate_stats_tlv(const void *tag_buf, u16 tag_len,
4529 struct debug_htt_stats_req *stats_req)
4530 {
4531 const struct ath12k_htt_tx_pdev_rate_stats_tlv *htt_stats_buf = tag_buf;
4532 u8 *buf = stats_req->buf;
4533 u32 len = stats_req->buf_len;
4534 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4535 u8 i, j;
4536 u32 mac_id_word;
4537
4538 if (tag_len < sizeof(*htt_stats_buf))
4539 return;
4540
4541 mac_id_word = le32_to_cpu(htt_stats_buf->mac_id_word);
4542
4543 len += scnprintf(buf + len, buf_len - len, "HTT_TX_PDEV_RATE_STATS_TLV:\n");
4544 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4545 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
4546 len += scnprintf(buf + len, buf_len - len, "tx_ldpc = %u\n",
4547 le32_to_cpu(htt_stats_buf->tx_ldpc));
4548 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_tx_ldpc = %u\n",
4549 le32_to_cpu(htt_stats_buf->ac_mu_mimo_tx_ldpc));
4550 len += scnprintf(buf + len, buf_len - len, "ax_mu_mimo_tx_ldpc = %u\n",
4551 le32_to_cpu(htt_stats_buf->ax_mu_mimo_tx_ldpc));
4552 len += scnprintf(buf + len, buf_len - len, "ofdma_tx_ldpc = %u\n",
4553 le32_to_cpu(htt_stats_buf->ofdma_tx_ldpc));
4554 len += scnprintf(buf + len, buf_len - len, "rts_cnt = %u\n",
4555 le32_to_cpu(htt_stats_buf->rts_cnt));
4556 len += scnprintf(buf + len, buf_len - len, "rts_success = %u\n",
4557 le32_to_cpu(htt_stats_buf->rts_success));
4558 len += scnprintf(buf + len, buf_len - len, "ack_rssi = %u\n",
4559 le32_to_cpu(htt_stats_buf->ack_rssi));
4560 len += scnprintf(buf + len, buf_len - len,
4561 "Legacy CCK Rates: 1 Mbps: %u, 2 Mbps: %u, 5.5 Mbps: %u, 12 Mbps: %u\n",
4562 le32_to_cpu(htt_stats_buf->tx_legacy_cck_rate[0]),
4563 le32_to_cpu(htt_stats_buf->tx_legacy_cck_rate[1]),
4564 le32_to_cpu(htt_stats_buf->tx_legacy_cck_rate[2]),
4565 le32_to_cpu(htt_stats_buf->tx_legacy_cck_rate[3]));
4566 len += scnprintf(buf + len, buf_len - len,
4567 "Legacy OFDM Rates: 6 Mbps: %u, 9 Mbps: %u, 12 Mbps: %u, 18 Mbps: %u\n"
4568 " 24 Mbps: %u, 36 Mbps: %u, 48 Mbps: %u, 54 Mbps: %u\n",
4569 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[0]),
4570 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[1]),
4571 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[2]),
4572 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[3]),
4573 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[4]),
4574 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[5]),
4575 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[6]),
4576 le32_to_cpu(htt_stats_buf->tx_legacy_ofdm_rate[7]));
4577 len += scnprintf(buf + len, buf_len - len, "HE LTF: 1x: %u, 2x: %u, 4x: %u\n",
4578 le32_to_cpu(htt_stats_buf->tx_he_ltf[1]),
4579 le32_to_cpu(htt_stats_buf->tx_he_ltf[2]),
4580 le32_to_cpu(htt_stats_buf->tx_he_ltf[3]));
4581
4582 len += print_array_to_buf(buf, len, "tx_mcs", htt_stats_buf->tx_mcs,
4583 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS, NULL);
4584 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; j++)
4585 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4586 j + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4587 le32_to_cpu(htt_stats_buf->tx_mcs_ext[j]));
4588 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA2_MCS_COUNTERS; j++)
4589 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4590 j + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS +
4591 ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA2_MCS_COUNTERS,
4592 le32_to_cpu(htt_stats_buf->tx_mcs_ext_2[j]));
4593 len += scnprintf(buf + len, buf_len - len, "\n");
4594
4595 len += print_array_to_buf(buf, len, "ax_mu_mimo_tx_mcs",
4596 htt_stats_buf->ax_mu_mimo_tx_mcs,
4597 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS, NULL);
4598 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; j++)
4599 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4600 j + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4601 le32_to_cpu(htt_stats_buf->ax_mu_mimo_tx_mcs_ext[j]));
4602 len += scnprintf(buf + len, buf_len - len, "\n");
4603
4604 len += print_array_to_buf(buf, len, "ofdma_tx_mcs",
4605 htt_stats_buf->ofdma_tx_mcs,
4606 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS, NULL);
4607 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; j++)
4608 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4609 j + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4610 le32_to_cpu(htt_stats_buf->ofdma_tx_mcs_ext[j]));
4611 len += scnprintf(buf + len, buf_len - len, "\n");
4612
4613 len += scnprintf(buf + len, buf_len - len, "tx_nss =");
4614 for (j = 1; j <= ATH12K_HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++)
4615 len += scnprintf(buf + len, buf_len - len, " %u:%u,",
4616 j, le32_to_cpu(htt_stats_buf->tx_nss[j - 1]));
4617 len--;
4618 len += scnprintf(buf + len, buf_len - len, "\n");
4619
4620 len += scnprintf(buf + len, buf_len - len, "ac_mu_mimo_tx_nss =");
4621 for (j = 1; j <= ATH12K_HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++)
4622 len += scnprintf(buf + len, buf_len - len, " %u:%u,",
4623 j, le32_to_cpu(htt_stats_buf->ac_mu_mimo_tx_nss[j - 1]));
4624 len--;
4625 len += scnprintf(buf + len, buf_len - len, "\n");
4626
4627 len += scnprintf(buf + len, buf_len - len, "ax_mu_mimo_tx_nss =");
4628 for (j = 1; j <= ATH12K_HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++)
4629 len += scnprintf(buf + len, buf_len - len, " %u:%u,",
4630 j, le32_to_cpu(htt_stats_buf->ax_mu_mimo_tx_nss[j - 1]));
4631 len--;
4632 len += scnprintf(buf + len, buf_len - len, "\n");
4633
4634 len += scnprintf(buf + len, buf_len - len, "ofdma_tx_nss =");
4635 for (j = 1; j <= ATH12K_HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++)
4636 len += scnprintf(buf + len, buf_len - len, " %u:%u,",
4637 j, le32_to_cpu(htt_stats_buf->ofdma_tx_nss[j - 1]));
4638 len--;
4639 len += scnprintf(buf + len, buf_len - len, "\n");
4640
4641 len += print_array_to_buf(buf, len, "tx_bw", htt_stats_buf->tx_bw,
4642 ATH12K_HTT_TX_PDEV_STATS_NUM_BW_COUNTERS, NULL);
4643 len += scnprintf(buf + len, buf_len - len, ", %u:%u\n",
4644 ATH12K_HTT_TX_PDEV_STATS_NUM_BW_COUNTERS,
4645 le32_to_cpu(htt_stats_buf->tx_bw_320mhz));
4646
4647 len += print_array_to_buf(buf, len, "tx_stbc",
4648 htt_stats_buf->tx_stbc,
4649 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS, NULL);
4650 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; j++)
4651 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4652 j + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4653 le32_to_cpu(htt_stats_buf->tx_stbc_ext[j]));
4654 len += scnprintf(buf + len, buf_len - len, "\n");
4655
4656 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
4657 len += scnprintf(buf + len, (buf_len - len),
4658 "tx_gi[%u] =", j);
4659 len += print_array_to_buf(buf, len, NULL, htt_stats_buf->tx_gi[j],
4660 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4661 NULL);
4662 for (i = 0; i < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++)
4663 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4664 i + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4665 le32_to_cpu(htt_stats_buf->tx_gi_ext[j][i]));
4666 len += scnprintf(buf + len, buf_len - len, "\n");
4667 }
4668
4669 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
4670 len += scnprintf(buf + len, (buf_len - len),
4671 "ac_mu_mimo_tx_gi[%u] =", j);
4672 len += print_array_to_buf(buf, len, NULL,
4673 htt_stats_buf->ac_mu_mimo_tx_gi[j],
4674 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4675 "\n");
4676 }
4677
4678 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
4679 len += scnprintf(buf + len, (buf_len - len),
4680 "ax_mu_mimo_tx_gi[%u] =", j);
4681 len += print_array_to_buf(buf, len, NULL, htt_stats_buf->ax_mimo_tx_gi[j],
4682 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4683 NULL);
4684 for (i = 0; i < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++)
4685 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4686 i + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4687 le32_to_cpu(htt_stats_buf->ax_tx_gi_ext[j][i]));
4688 len += scnprintf(buf + len, buf_len - len, "\n");
4689 }
4690
4691 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
4692 len += scnprintf(buf + len, (buf_len - len),
4693 "ofdma_tx_gi[%u] = ", j);
4694 len += print_array_to_buf(buf, len, NULL, htt_stats_buf->ofdma_tx_gi[j],
4695 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4696 NULL);
4697 for (i = 0; i < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++)
4698 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4699 i + ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
4700 le32_to_cpu(htt_stats_buf->ofd_tx_gi_ext[j][i]));
4701 len += scnprintf(buf + len, buf_len - len, "\n");
4702 }
4703
4704 len += print_array_to_buf(buf, len, "tx_su_mcs", htt_stats_buf->tx_su_mcs,
4705 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4706 len += print_array_to_buf(buf, len, "tx_mu_mcs", htt_stats_buf->tx_mu_mcs,
4707 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4708 len += print_array_to_buf(buf, len, "ac_mu_mimo_tx_mcs",
4709 htt_stats_buf->ac_mu_mimo_tx_mcs,
4710 ATH12K_HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4711 len += print_array_to_buf(buf, len, "ac_mu_mimo_tx_bw",
4712 htt_stats_buf->ac_mu_mimo_tx_bw,
4713 ATH12K_HTT_TX_PDEV_STATS_NUM_BW_COUNTERS, "\n");
4714 len += print_array_to_buf(buf, len, "ax_mu_mimo_tx_bw",
4715 htt_stats_buf->ax_mu_mimo_tx_bw,
4716 ATH12K_HTT_TX_PDEV_STATS_NUM_BW_COUNTERS, "\n");
4717 len += print_array_to_buf(buf, len, "ofdma_tx_bw",
4718 htt_stats_buf->ofdma_tx_bw,
4719 ATH12K_HTT_TX_PDEV_STATS_NUM_BW_COUNTERS, "\n");
4720 len += print_array_to_buf(buf, len, "tx_pream", htt_stats_buf->tx_pream,
4721 ATH12K_HTT_TX_PDEV_STATS_NUM_PREAMBLE_TYPES, "\n");
4722 len += print_array_to_buf(buf, len, "tx_dcm", htt_stats_buf->tx_dcm,
4723 ATH12K_HTT_TX_PDEV_STATS_NUM_DCM_COUNTERS, "\n");
4724
4725 stats_req->buf_len = len;
4726 }
4727
4728 static inline void
ath12k_htt_print_rx_pdev_rate_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4729 ath12k_htt_print_rx_pdev_rate_stats_tlv(const void *tag_buf, u16 tag_len,
4730 struct debug_htt_stats_req *stats_req)
4731 {
4732 const struct ath12k_htt_rx_pdev_rate_stats_tlv *htt_stats_buf = tag_buf;
4733 u8 *buf = stats_req->buf;
4734 u32 len = stats_req->buf_len;
4735 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4736 u8 i, j;
4737 u32 mac_id_word;
4738
4739 if (tag_len < sizeof(*htt_stats_buf))
4740 return;
4741
4742 mac_id_word = le32_to_cpu(htt_stats_buf->mac_id_word);
4743
4744 len += scnprintf(buf + len, buf_len - len, "HTT_RX_PDEV_RATE_STATS_TLV:\n");
4745 len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4746 u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
4747 len += scnprintf(buf + len, buf_len - len, "nsts = %u\n",
4748 le32_to_cpu(htt_stats_buf->nsts));
4749 len += scnprintf(buf + len, buf_len - len, "rx_ldpc = %u\n",
4750 le32_to_cpu(htt_stats_buf->rx_ldpc));
4751 len += scnprintf(buf + len, buf_len - len, "rts_cnt = %u\n",
4752 le32_to_cpu(htt_stats_buf->rts_cnt));
4753 len += scnprintf(buf + len, buf_len - len, "rssi_mgmt = %u\n",
4754 le32_to_cpu(htt_stats_buf->rssi_mgmt));
4755 len += scnprintf(buf + len, buf_len - len, "rssi_data = %u\n",
4756 le32_to_cpu(htt_stats_buf->rssi_data));
4757 len += scnprintf(buf + len, buf_len - len, "rssi_comb = %u\n",
4758 le32_to_cpu(htt_stats_buf->rssi_comb));
4759 len += scnprintf(buf + len, buf_len - len, "rssi_in_dbm = %d\n",
4760 le32_to_cpu(htt_stats_buf->rssi_in_dbm));
4761 len += scnprintf(buf + len, buf_len - len, "rx_evm_nss_count = %u\n",
4762 le32_to_cpu(htt_stats_buf->nss_count));
4763 len += scnprintf(buf + len, buf_len - len, "rx_evm_pilot_count = %u\n",
4764 le32_to_cpu(htt_stats_buf->pilot_count));
4765 len += scnprintf(buf + len, buf_len - len, "rx_11ax_su_ext = %u\n",
4766 le32_to_cpu(htt_stats_buf->rx_11ax_su_ext));
4767 len += scnprintf(buf + len, buf_len - len, "rx_11ac_mumimo = %u\n",
4768 le32_to_cpu(htt_stats_buf->rx_11ac_mumimo));
4769 len += scnprintf(buf + len, buf_len - len, "rx_11ax_mumimo = %u\n",
4770 le32_to_cpu(htt_stats_buf->rx_11ax_mumimo));
4771 len += scnprintf(buf + len, buf_len - len, "rx_11ax_ofdma = %u\n",
4772 le32_to_cpu(htt_stats_buf->rx_11ax_ofdma));
4773 len += scnprintf(buf + len, buf_len - len, "txbf = %u\n",
4774 le32_to_cpu(htt_stats_buf->txbf));
4775 len += scnprintf(buf + len, buf_len - len, "rx_su_ndpa = %u\n",
4776 le32_to_cpu(htt_stats_buf->rx_su_ndpa));
4777 len += scnprintf(buf + len, buf_len - len, "rx_mu_ndpa = %u\n",
4778 le32_to_cpu(htt_stats_buf->rx_mu_ndpa));
4779 len += scnprintf(buf + len, buf_len - len, "rx_br_poll = %u\n",
4780 le32_to_cpu(htt_stats_buf->rx_br_poll));
4781 len += scnprintf(buf + len, buf_len - len, "rx_active_dur_us_low = %u\n",
4782 le32_to_cpu(htt_stats_buf->rx_active_dur_us_low));
4783 len += scnprintf(buf + len, buf_len - len, "rx_active_dur_us_high = %u\n",
4784 le32_to_cpu(htt_stats_buf->rx_active_dur_us_high));
4785 len += scnprintf(buf + len, buf_len - len, "rx_11ax_ul_ofdma = %u\n",
4786 le32_to_cpu(htt_stats_buf->rx_11ax_ul_ofdma));
4787 len += scnprintf(buf + len, buf_len - len, "ul_ofdma_rx_stbc = %u\n",
4788 le32_to_cpu(htt_stats_buf->ul_ofdma_rx_stbc));
4789 len += scnprintf(buf + len, buf_len - len, "ul_ofdma_rx_ldpc = %u\n",
4790 le32_to_cpu(htt_stats_buf->ul_ofdma_rx_ldpc));
4791 len += scnprintf(buf + len, buf_len - len, "per_chain_rssi_pkt_type = %#x\n",
4792 le32_to_cpu(htt_stats_buf->per_chain_rssi_pkt_type));
4793
4794 len += print_array_to_buf(buf, len, "rx_nss", htt_stats_buf->rx_nss,
4795 ATH12K_HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS, "\n");
4796 len += print_array_to_buf(buf, len, "rx_dcm", htt_stats_buf->rx_dcm,
4797 ATH12K_HTT_RX_PDEV_STATS_NUM_DCM_COUNTERS, "\n");
4798 len += print_array_to_buf(buf, len, "rx_stbc", htt_stats_buf->rx_stbc,
4799 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4800 len += print_array_to_buf(buf, len, "rx_bw", htt_stats_buf->rx_bw,
4801 ATH12K_HTT_RX_PDEV_STATS_NUM_BW_COUNTERS, "\n");
4802 len += print_array_to_buf(buf, len, "rx_pream", htt_stats_buf->rx_pream,
4803 ATH12K_HTT_RX_PDEV_STATS_NUM_PREAMBLE_TYPES, "\n");
4804 len += print_array_to_buf(buf, len, "rx_11ax_su_txbf_mcs",
4805 htt_stats_buf->rx_11ax_su_txbf_mcs,
4806 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4807 len += print_array_to_buf(buf, len, "rx_11ax_mu_txbf_mcs",
4808 htt_stats_buf->rx_11ax_mu_txbf_mcs,
4809 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4810 len += print_array_to_buf(buf, len, "rx_legacy_cck_rate",
4811 htt_stats_buf->rx_legacy_cck_rate,
4812 ATH12K_HTT_RX_PDEV_STATS_NUM_LEGACY_CCK_STATS, "\n");
4813 len += print_array_to_buf(buf, len, "rx_legacy_ofdm_rate",
4814 htt_stats_buf->rx_legacy_ofdm_rate,
4815 ATH12K_HTT_RX_PDEV_STATS_NUM_LEGACY_OFDM_STATS, "\n");
4816 len += print_array_to_buf(buf, len, "ul_ofdma_rx_mcs",
4817 htt_stats_buf->ul_ofdma_rx_mcs,
4818 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4819 len += print_array_to_buf(buf, len, "ul_ofdma_rx_nss",
4820 htt_stats_buf->ul_ofdma_rx_nss,
4821 ATH12K_HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS, "\n");
4822 len += print_array_to_buf(buf, len, "ul_ofdma_rx_bw",
4823 htt_stats_buf->ul_ofdma_rx_bw,
4824 ATH12K_HTT_RX_PDEV_STATS_NUM_BW_COUNTERS, "\n");
4825 len += print_array_to_buf(buf, len, "rx_ulofdma_non_data_ppdu",
4826 htt_stats_buf->rx_ulofdma_non_data_ppdu,
4827 ATH12K_HTT_RX_PDEV_MAX_OFDMA_NUM_USER, "\n");
4828 len += print_array_to_buf(buf, len, "rx_ulofdma_data_ppdu",
4829 htt_stats_buf->rx_ulofdma_data_ppdu,
4830 ATH12K_HTT_RX_PDEV_MAX_OFDMA_NUM_USER, "\n");
4831 len += print_array_to_buf(buf, len, "rx_ulofdma_mpdu_ok",
4832 htt_stats_buf->rx_ulofdma_mpdu_ok,
4833 ATH12K_HTT_RX_PDEV_MAX_OFDMA_NUM_USER, "\n");
4834 len += print_array_to_buf(buf, len, "rx_ulofdma_mpdu_fail",
4835 htt_stats_buf->rx_ulofdma_mpdu_fail,
4836 ATH12K_HTT_RX_PDEV_MAX_OFDMA_NUM_USER, "\n");
4837 len += print_array_to_buf(buf, len, "rx_ulofdma_non_data_nusers",
4838 htt_stats_buf->rx_ulofdma_non_data_nusers,
4839 ATH12K_HTT_RX_PDEV_MAX_OFDMA_NUM_USER, "\n");
4840 len += print_array_to_buf(buf, len, "rx_ulofdma_data_nusers",
4841 htt_stats_buf->rx_ulofdma_data_nusers,
4842 ATH12K_HTT_RX_PDEV_MAX_OFDMA_NUM_USER, "\n");
4843 len += print_array_to_buf(buf, len, "rx_11ax_dl_ofdma_mcs",
4844 htt_stats_buf->rx_11ax_dl_ofdma_mcs,
4845 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS, "\n");
4846 len += print_array_to_buf(buf, len, "rx_11ax_dl_ofdma_ru",
4847 htt_stats_buf->rx_11ax_dl_ofdma_ru,
4848 ATH12K_HTT_RX_PDEV_STATS_NUM_RU_SIZE_COUNTERS, "\n");
4849 len += print_array_to_buf(buf, len, "rx_ulmumimo_non_data_ppdu",
4850 htt_stats_buf->rx_ulmumimo_non_data_ppdu,
4851 ATH12K_HTT_RX_PDEV_MAX_ULMUMIMO_NUM_USER, "\n");
4852 len += print_array_to_buf(buf, len, "rx_ulmumimo_data_ppdu",
4853 htt_stats_buf->rx_ulmumimo_data_ppdu,
4854 ATH12K_HTT_RX_PDEV_MAX_ULMUMIMO_NUM_USER, "\n");
4855 len += print_array_to_buf(buf, len, "rx_ulmumimo_mpdu_ok",
4856 htt_stats_buf->rx_ulmumimo_mpdu_ok,
4857 ATH12K_HTT_RX_PDEV_MAX_ULMUMIMO_NUM_USER, "\n");
4858 len += print_array_to_buf(buf, len, "rx_ulmumimo_mpdu_fail",
4859 htt_stats_buf->rx_ulmumimo_mpdu_fail,
4860 ATH12K_HTT_RX_PDEV_MAX_ULMUMIMO_NUM_USER, "\n");
4861
4862 len += print_array_to_buf(buf, len, "rx_mcs",
4863 htt_stats_buf->rx_mcs,
4864 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS, NULL);
4865 for (j = 0; j < ATH12K_HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; j++)
4866 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4867 j + ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS,
4868 le32_to_cpu(htt_stats_buf->rx_mcs_ext[j]));
4869 len += scnprintf(buf + len, buf_len - len, "\n");
4870
4871 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++) {
4872 len += scnprintf(buf + len, buf_len - len,
4873 "pilot_evm_db[%u] =", j);
4874 len += print_array_to_buf(buf, len, NULL,
4875 htt_stats_buf->rx_pil_evm_db[j],
4876 ATH12K_HTT_RX_PDEV_STATS_RXEVM_MAX_PILOTS_NSS,
4877 "\n");
4878 }
4879
4880 len += scnprintf(buf + len, buf_len - len, "pilot_evm_db_mean =");
4881 for (i = 0; i < ATH12K_HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++)
4882 len += scnprintf(buf + len,
4883 buf_len - len,
4884 " %u:%d,", i,
4885 le32_to_cpu(htt_stats_buf->rx_pilot_evm_db_mean[i]));
4886 len--;
4887 len += scnprintf(buf + len, buf_len - len, "\n");
4888
4889 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++) {
4890 len += scnprintf(buf + len, buf_len - len,
4891 "rssi_chain_in_db[%u] = ", j);
4892 for (i = 0; i < ATH12K_HTT_RX_PDEV_STATS_NUM_BW_COUNTERS; i++)
4893 len += scnprintf(buf + len,
4894 buf_len - len,
4895 " %u: %d,", i,
4896 htt_stats_buf->rssi_chain_in_db[j][i]);
4897 len--;
4898 len += scnprintf(buf + len, buf_len - len, "\n");
4899 }
4900
4901 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
4902 len += scnprintf(buf + len, buf_len - len,
4903 "rx_gi[%u] = ", j);
4904 len += print_array_to_buf(buf, len, NULL,
4905 htt_stats_buf->rx_gi[j],
4906 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS,
4907 "\n");
4908 }
4909
4910 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
4911 len += scnprintf(buf + len, buf_len - len,
4912 "ul_ofdma_rx_gi[%u] = ", j);
4913 len += print_array_to_buf(buf, len, NULL,
4914 htt_stats_buf->ul_ofdma_rx_gi[j],
4915 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS,
4916 "\n");
4917 }
4918
4919 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++) {
4920 len += scnprintf(buf + len, buf_len - len,
4921 "rx_ul_fd_rssi: nss[%u] = ", j);
4922 for (i = 0; i < ATH12K_HTT_RX_PDEV_MAX_OFDMA_NUM_USER; i++)
4923 len += scnprintf(buf + len,
4924 buf_len - len,
4925 " %u:%d,",
4926 i, htt_stats_buf->rx_ul_fd_rssi[j][i]);
4927 len--;
4928 len += scnprintf(buf + len, buf_len - len, "\n");
4929 }
4930
4931 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS; j++) {
4932 len += scnprintf(buf + len, buf_len - len,
4933 "rx_per_chain_rssi_in_dbm[%u] =", j);
4934 for (i = 0; i < ATH12K_HTT_RX_PDEV_STATS_NUM_BW_COUNTERS; i++)
4935 len += scnprintf(buf + len,
4936 buf_len - len,
4937 " %u:%d,",
4938 i,
4939 htt_stats_buf->rx_per_chain_rssi_in_dbm[j][i]);
4940 len--;
4941 len += scnprintf(buf + len, buf_len - len, "\n");
4942 }
4943
4944 stats_req->buf_len = len;
4945 }
4946
4947 static inline void
ath12k_htt_print_rx_pdev_rate_ext_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)4948 ath12k_htt_print_rx_pdev_rate_ext_stats_tlv(const void *tag_buf, u16 tag_len,
4949 struct debug_htt_stats_req *stats_req)
4950 {
4951 const struct ath12k_htt_rx_pdev_rate_ext_stats_tlv *htt_stats_buf = tag_buf;
4952 u8 *buf = stats_req->buf;
4953 u32 len = stats_req->buf_len;
4954 u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4955 u8 j;
4956
4957 if (tag_len < sizeof(*htt_stats_buf))
4958 return;
4959
4960 len += scnprintf(buf + len, buf_len - len, "HTT_RX_PDEV_RATE_EXT_STATS_TLV:\n");
4961 len += scnprintf(buf + len, buf_len - len, "rssi_mgmt_in_dbm = %d\n",
4962 le32_to_cpu(htt_stats_buf->rssi_mgmt_in_dbm));
4963
4964 len += print_array_to_buf(buf, len, "rx_stbc_ext",
4965 htt_stats_buf->rx_stbc_ext,
4966 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT, "\n");
4967 len += print_array_to_buf(buf, len, "ul_ofdma_rx_mcs_ext",
4968 htt_stats_buf->ul_ofdma_rx_mcs_ext,
4969 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT, "\n");
4970 len += print_array_to_buf(buf, len, "rx_11ax_su_txbf_mcs_ext",
4971 htt_stats_buf->rx_11ax_su_txbf_mcs_ext,
4972 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT, "\n");
4973 len += print_array_to_buf(buf, len, "rx_11ax_mu_txbf_mcs_ext",
4974 htt_stats_buf->rx_11ax_mu_txbf_mcs_ext,
4975 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT, "\n");
4976 len += print_array_to_buf(buf, len, "rx_11ax_dl_ofdma_mcs_ext",
4977 htt_stats_buf->rx_11ax_dl_ofdma_mcs_ext,
4978 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT, "\n");
4979 len += print_array_to_buf(buf, len, "rx_bw_ext",
4980 htt_stats_buf->rx_bw_ext,
4981 ATH12K_HTT_RX_PDEV_STATS_NUM_BW_EXT2_COUNTERS, "\n");
4982 len += print_array_to_buf(buf, len, "rx_su_punctured_mode",
4983 htt_stats_buf->rx_su_punctured_mode,
4984 ATH12K_HTT_RX_PDEV_STATS_NUM_PUNCTURED_MODE_COUNTERS,
4985 "\n");
4986
4987 len += print_array_to_buf(buf, len, "rx_mcs_ext",
4988 htt_stats_buf->rx_mcs_ext,
4989 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT,
4990 NULL);
4991 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_EXTRA2_MCS_COUNTERS; j++)
4992 len += scnprintf(buf + len, buf_len - len, ", %u:%u",
4993 j + ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT,
4994 le32_to_cpu(htt_stats_buf->rx_mcs_ext_2[j]));
4995 len += scnprintf(buf + len, buf_len - len, "\n");
4996
4997 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
4998 len += scnprintf(buf + len, buf_len - len,
4999 "rx_gi_ext[%u] = ", j);
5000 len += print_array_to_buf(buf, len, NULL,
5001 htt_stats_buf->rx_gi_ext[j],
5002 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT,
5003 "\n");
5004 }
5005
5006 for (j = 0; j < ATH12K_HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
5007 len += scnprintf(buf + len, buf_len - len,
5008 "ul_ofdma_rx_gi_ext[%u] = ", j);
5009 len += print_array_to_buf(buf, len, NULL,
5010 htt_stats_buf->ul_ofdma_rx_gi_ext[j],
5011 ATH12K_HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT,
5012 "\n");
5013 }
5014
5015 stats_req->buf_len = len;
5016 }
5017
ath12k_dbg_htt_ext_stats_parse(struct ath12k_base * ab,u16 tag,u16 len,const void * tag_buf,void * user_data)5018 static int ath12k_dbg_htt_ext_stats_parse(struct ath12k_base *ab,
5019 u16 tag, u16 len, const void *tag_buf,
5020 void *user_data)
5021 {
5022 struct debug_htt_stats_req *stats_req = user_data;
5023
5024 switch (tag) {
5025 case HTT_STATS_TX_PDEV_CMN_TAG:
5026 htt_print_tx_pdev_stats_cmn_tlv(tag_buf, len, stats_req);
5027 break;
5028 case HTT_STATS_TX_PDEV_UNDERRUN_TAG:
5029 htt_print_tx_pdev_stats_urrn_tlv(tag_buf, len, stats_req);
5030 break;
5031 case HTT_STATS_TX_PDEV_SIFS_TAG:
5032 htt_print_tx_pdev_stats_sifs_tlv(tag_buf, len, stats_req);
5033 break;
5034 case HTT_STATS_TX_PDEV_FLUSH_TAG:
5035 htt_print_tx_pdev_stats_flush_tlv(tag_buf, len, stats_req);
5036 break;
5037 case HTT_STATS_TX_PDEV_SIFS_HIST_TAG:
5038 htt_print_tx_pdev_stats_sifs_hist_tlv(tag_buf, len, stats_req);
5039 break;
5040 case HTT_STATS_PDEV_CTRL_PATH_TX_STATS_TAG:
5041 htt_print_pdev_ctrl_path_tx_stats_tlv(tag_buf, len, stats_req);
5042 break;
5043 case HTT_STATS_MU_PPDU_DIST_TAG:
5044 htt_print_tx_pdev_mu_ppdu_dist_stats_tlv(tag_buf, len, stats_req);
5045 break;
5046 case HTT_STATS_TX_SCHED_CMN_TAG:
5047 ath12k_htt_print_stats_tx_sched_cmn_tlv(tag_buf, len, stats_req);
5048 break;
5049 case HTT_STATS_TX_PDEV_SCHEDULER_TXQ_STATS_TAG:
5050 ath12k_htt_print_tx_pdev_stats_sched_per_txq_tlv(tag_buf, len, stats_req);
5051 break;
5052 case HTT_STATS_SCHED_TXQ_CMD_POSTED_TAG:
5053 ath12k_htt_print_sched_txq_cmd_posted_tlv(tag_buf, len, stats_req);
5054 break;
5055 case HTT_STATS_SCHED_TXQ_CMD_REAPED_TAG:
5056 ath12k_htt_print_sched_txq_cmd_reaped_tlv(tag_buf, len, stats_req);
5057 break;
5058 case HTT_STATS_SCHED_TXQ_SCHED_ORDER_SU_TAG:
5059 ath12k_htt_print_sched_txq_sched_order_su_tlv(tag_buf, len, stats_req);
5060 break;
5061 case HTT_STATS_SCHED_TXQ_SCHED_INELIGIBILITY_TAG:
5062 ath12k_htt_print_sched_txq_sched_ineligibility_tlv(tag_buf, len,
5063 stats_req);
5064 break;
5065 case HTT_STATS_SCHED_TXQ_SUPERCYCLE_TRIGGER_TAG:
5066 ath12k_htt_print_sched_txq_supercycle_trigger_tlv(tag_buf, len,
5067 stats_req);
5068 break;
5069 case HTT_STATS_HW_PDEV_ERRS_TAG:
5070 ath12k_htt_print_hw_stats_pdev_errs_tlv(tag_buf, len, stats_req);
5071 break;
5072 case HTT_STATS_HW_INTR_MISC_TAG:
5073 ath12k_htt_print_hw_stats_intr_misc_tlv(tag_buf, len, stats_req);
5074 break;
5075 case HTT_STATS_WHAL_TX_TAG:
5076 ath12k_htt_print_hw_stats_whal_tx_tlv(tag_buf, len, stats_req);
5077 break;
5078 case HTT_STATS_HW_WAR_TAG:
5079 ath12k_htt_print_hw_war_tlv(tag_buf, len, stats_req);
5080 break;
5081 case HTT_STATS_TX_TQM_CMN_TAG:
5082 ath12k_htt_print_tx_tqm_cmn_stats_tlv(tag_buf, len, stats_req);
5083 break;
5084 case HTT_STATS_TX_TQM_ERROR_STATS_TAG:
5085 ath12k_htt_print_tx_tqm_error_stats_tlv(tag_buf, len, stats_req);
5086 break;
5087 case HTT_STATS_TX_TQM_GEN_MPDU_TAG:
5088 ath12k_htt_print_tx_tqm_gen_mpdu_stats_tlv(tag_buf, len, stats_req);
5089 break;
5090 case HTT_STATS_TX_TQM_LIST_MPDU_TAG:
5091 ath12k_htt_print_tx_tqm_list_mpdu_stats_tlv(tag_buf, len, stats_req);
5092 break;
5093 case HTT_STATS_TX_TQM_LIST_MPDU_CNT_TAG:
5094 ath12k_htt_print_tx_tqm_list_mpdu_cnt_tlv(tag_buf, len, stats_req);
5095 break;
5096 case HTT_STATS_TX_TQM_PDEV_TAG:
5097 ath12k_htt_print_tx_tqm_pdev_stats_tlv(tag_buf, len, stats_req);
5098 break;
5099 case HTT_STATS_TX_DE_CMN_TAG:
5100 ath12k_htt_print_tx_de_cmn_stats_tlv(tag_buf, len, stats_req);
5101 break;
5102 case HTT_STATS_TX_DE_EAPOL_PACKETS_TAG:
5103 ath12k_htt_print_tx_de_eapol_packets_stats_tlv(tag_buf, len, stats_req);
5104 break;
5105 case HTT_STATS_TX_DE_CLASSIFY_STATS_TAG:
5106 ath12k_htt_print_tx_de_classify_stats_tlv(tag_buf, len, stats_req);
5107 break;
5108 case HTT_STATS_TX_DE_CLASSIFY_FAILED_TAG:
5109 ath12k_htt_print_tx_de_classify_failed_stats_tlv(tag_buf, len, stats_req);
5110 break;
5111 case HTT_STATS_TX_DE_CLASSIFY_STATUS_TAG:
5112 ath12k_htt_print_tx_de_classify_status_stats_tlv(tag_buf, len, stats_req);
5113 break;
5114 case HTT_STATS_TX_DE_ENQUEUE_PACKETS_TAG:
5115 ath12k_htt_print_tx_de_enqueue_packets_stats_tlv(tag_buf, len, stats_req);
5116 break;
5117 case HTT_STATS_TX_DE_ENQUEUE_DISCARD_TAG:
5118 ath12k_htt_print_tx_de_enqueue_discard_stats_tlv(tag_buf, len, stats_req);
5119 break;
5120 case HTT_STATS_TX_DE_COMPL_STATS_TAG:
5121 ath12k_htt_print_tx_de_compl_stats_tlv(tag_buf, len, stats_req);
5122 break;
5123 case HTT_STATS_TX_SELFGEN_CMN_STATS_TAG:
5124 ath12k_htt_print_tx_selfgen_cmn_stats_tlv(tag_buf, len, stats_req);
5125 break;
5126 case HTT_STATS_TX_SELFGEN_AC_STATS_TAG:
5127 ath12k_htt_print_tx_selfgen_ac_stats_tlv(tag_buf, len, stats_req);
5128 break;
5129 case HTT_STATS_TX_SELFGEN_AX_STATS_TAG:
5130 ath12k_htt_print_tx_selfgen_ax_stats_tlv(tag_buf, len, stats_req);
5131 break;
5132 case HTT_STATS_TX_SELFGEN_BE_STATS_TAG:
5133 ath12k_htt_print_tx_selfgen_be_stats_tlv(tag_buf, len, stats_req);
5134 break;
5135 case HTT_STATS_TX_SELFGEN_AC_ERR_STATS_TAG:
5136 ath12k_htt_print_tx_selfgen_ac_err_stats_tlv(tag_buf, len, stats_req);
5137 break;
5138 case HTT_STATS_TX_SELFGEN_AX_ERR_STATS_TAG:
5139 ath12k_htt_print_tx_selfgen_ax_err_stats_tlv(tag_buf, len, stats_req);
5140 break;
5141 case HTT_STATS_TX_SELFGEN_BE_ERR_STATS_TAG:
5142 ath12k_htt_print_tx_selfgen_be_err_stats_tlv(tag_buf, len, stats_req);
5143 break;
5144 case HTT_STATS_TX_SELFGEN_AC_SCHED_STATUS_STATS_TAG:
5145 ath12k_htt_print_tx_selfgen_ac_sched_status_stats_tlv(tag_buf, len,
5146 stats_req);
5147 break;
5148 case HTT_STATS_TX_SELFGEN_AX_SCHED_STATUS_STATS_TAG:
5149 ath12k_htt_print_tx_selfgen_ax_sched_status_stats_tlv(tag_buf, len,
5150 stats_req);
5151 break;
5152 case HTT_STATS_TX_SELFGEN_BE_SCHED_STATUS_STATS_TAG:
5153 ath12k_htt_print_tx_selfgen_be_sched_status_stats_tlv(tag_buf, len,
5154 stats_req);
5155 break;
5156 case HTT_STATS_STRING_TAG:
5157 ath12k_htt_print_stats_string_tlv(tag_buf, len, stats_req);
5158 break;
5159 case HTT_STATS_SRING_STATS_TAG:
5160 ath12k_htt_print_sring_stats_tlv(tag_buf, len, stats_req);
5161 break;
5162 case HTT_STATS_SFM_CMN_TAG:
5163 ath12k_htt_print_sfm_cmn_tlv(tag_buf, len, stats_req);
5164 break;
5165 case HTT_STATS_SFM_CLIENT_TAG:
5166 ath12k_htt_print_sfm_client_tlv(tag_buf, len, stats_req);
5167 break;
5168 case HTT_STATS_SFM_CLIENT_USER_TAG:
5169 ath12k_htt_print_sfm_client_user_tlv(tag_buf, len, stats_req);
5170 break;
5171 case HTT_STATS_TX_PDEV_MU_MIMO_STATS_TAG:
5172 ath12k_htt_print_tx_pdev_mu_mimo_sch_stats_tlv(tag_buf, len, stats_req);
5173 break;
5174 case HTT_STATS_TX_PDEV_MUMIMO_GRP_STATS_TAG:
5175 ath12k_htt_print_tx_pdev_mumimo_grp_stats_tlv(tag_buf, len, stats_req);
5176 break;
5177 case HTT_STATS_TX_PDEV_MPDU_STATS_TAG:
5178 ath12k_htt_print_tx_pdev_mu_mimo_mpdu_stats_tlv(tag_buf, len, stats_req);
5179 break;
5180 case HTT_STATS_PDEV_CCA_1SEC_HIST_TAG:
5181 case HTT_STATS_PDEV_CCA_100MSEC_HIST_TAG:
5182 case HTT_STATS_PDEV_CCA_STAT_CUMULATIVE_TAG:
5183 ath12k_htt_print_pdev_cca_stats_hist_tlv(tag_buf, len, stats_req);
5184 break;
5185 case HTT_STATS_PDEV_CCA_COUNTERS_TAG:
5186 ath12k_htt_print_pdev_stats_cca_counters_tlv(tag_buf, len, stats_req);
5187 break;
5188 case HTT_STATS_TX_SOUNDING_STATS_TAG:
5189 ath12k_htt_print_tx_sounding_stats_tlv(tag_buf, len, stats_req);
5190 break;
5191 case HTT_STATS_PDEV_OBSS_PD_TAG:
5192 ath12k_htt_print_pdev_obss_pd_stats_tlv(tag_buf, len, stats_req);
5193 break;
5194 case HTT_STATS_LATENCY_CTX_TAG:
5195 ath12k_htt_print_latency_prof_ctx_tlv(tag_buf, len, stats_req);
5196 break;
5197 case HTT_STATS_LATENCY_CNT_TAG:
5198 ath12k_htt_print_latency_prof_cnt(tag_buf, len, stats_req);
5199 break;
5200 case HTT_STATS_LATENCY_PROF_STATS_TAG:
5201 ath12k_htt_print_latency_prof_stats_tlv(tag_buf, len, stats_req);
5202 break;
5203 case HTT_STATS_RX_PDEV_UL_TRIG_STATS_TAG:
5204 ath12k_htt_print_ul_ofdma_trigger_stats(tag_buf, len, stats_req);
5205 break;
5206 case HTT_STATS_RX_PDEV_UL_OFDMA_USER_STATS_TAG:
5207 ath12k_htt_print_ul_ofdma_user_stats(tag_buf, len, stats_req);
5208 break;
5209 case HTT_STATS_RX_PDEV_UL_MUMIMO_TRIG_STATS_TAG:
5210 ath12k_htt_print_ul_mumimo_trig_stats(tag_buf, len, stats_req);
5211 break;
5212 case HTT_STATS_RX_FSE_STATS_TAG:
5213 ath12k_htt_print_rx_fse_stats_tlv(tag_buf, len, stats_req);
5214 break;
5215 case HTT_STATS_PDEV_TX_RATE_TXBF_STATS_TAG:
5216 ath12k_htt_print_pdev_tx_rate_txbf_stats_tlv(tag_buf, len, stats_req);
5217 break;
5218 case HTT_STATS_TXBF_OFDMA_AX_NDPA_STATS_TAG:
5219 ath12k_htt_print_txbf_ofdma_ax_ndpa_stats_tlv(tag_buf, len, stats_req);
5220 break;
5221 case HTT_STATS_TXBF_OFDMA_AX_NDP_STATS_TAG:
5222 ath12k_htt_print_txbf_ofdma_ax_ndp_stats_tlv(tag_buf, len, stats_req);
5223 break;
5224 case HTT_STATS_TXBF_OFDMA_AX_BRP_STATS_TAG:
5225 ath12k_htt_print_txbf_ofdma_ax_brp_stats_tlv(tag_buf, len, stats_req);
5226 break;
5227 case HTT_STATS_TXBF_OFDMA_AX_STEER_STATS_TAG:
5228 ath12k_htt_print_txbf_ofdma_ax_steer_stats_tlv(tag_buf, len, stats_req);
5229 break;
5230 case HTT_STATS_TXBF_OFDMA_AX_STEER_MPDU_STATS_TAG:
5231 ath12k_htt_print_txbf_ofdma_ax_steer_mpdu_stats_tlv(tag_buf, len,
5232 stats_req);
5233 break;
5234 case HTT_STATS_DLPAGER_STATS_TAG:
5235 ath12k_htt_print_dlpager_stats_tlv(tag_buf, len, stats_req);
5236 break;
5237 case HTT_STATS_PHY_STATS_TAG:
5238 ath12k_htt_print_phy_stats_tlv(tag_buf, len, stats_req);
5239 break;
5240 case HTT_STATS_PHY_COUNTERS_TAG:
5241 ath12k_htt_print_phy_counters_tlv(tag_buf, len, stats_req);
5242 break;
5243 case HTT_STATS_PHY_RESET_STATS_TAG:
5244 ath12k_htt_print_phy_reset_stats_tlv(tag_buf, len, stats_req);
5245 break;
5246 case HTT_STATS_PHY_RESET_COUNTERS_TAG:
5247 ath12k_htt_print_phy_reset_counters_tlv(tag_buf, len, stats_req);
5248 break;
5249 case HTT_STATS_PHY_TPC_STATS_TAG:
5250 ath12k_htt_print_phy_tpc_stats_tlv(tag_buf, len, stats_req);
5251 break;
5252 case HTT_STATS_SOC_TXRX_STATS_COMMON_TAG:
5253 ath12k_htt_print_soc_txrx_stats_common_tlv(tag_buf, len, stats_req);
5254 break;
5255 case HTT_STATS_PER_RATE_STATS_TAG:
5256 ath12k_htt_print_tx_per_rate_stats_tlv(tag_buf, len, stats_req);
5257 break;
5258 case HTT_STATS_AST_ENTRY_TAG:
5259 ath12k_htt_print_ast_entry_tlv(tag_buf, len, stats_req);
5260 break;
5261 case HTT_STATS_PDEV_PUNCTURE_STATS_TAG:
5262 ath12k_htt_print_puncture_stats_tlv(tag_buf, len, stats_req);
5263 break;
5264 case HTT_STATS_DMAC_RESET_STATS_TAG:
5265 ath12k_htt_print_dmac_reset_stats_tlv(tag_buf, len, stats_req);
5266 break;
5267 case HTT_STATS_PDEV_SCHED_ALGO_OFDMA_STATS_TAG:
5268 ath12k_htt_print_pdev_sched_algo_ofdma_stats_tlv(tag_buf, len, stats_req);
5269 break;
5270 case HTT_STATS_TX_PDEV_RATE_STATS_BE_OFDMA_TAG:
5271 ath12k_htt_print_tx_pdev_rate_stats_be_ofdma_tlv(tag_buf, len, stats_req);
5272 break;
5273 case HTT_STATS_PDEV_MBSSID_CTRL_FRAME_STATS_TAG:
5274 ath12k_htt_print_pdev_mbssid_ctrl_frame_stats_tlv(tag_buf, len,
5275 stats_req);
5276 break;
5277 case HTT_STATS_TX_PDEV_RATE_STATS_TAG:
5278 ath12k_htt_print_tx_pdev_rate_stats_tlv(tag_buf, len, stats_req);
5279 break;
5280 case HTT_STATS_RX_PDEV_RATE_STATS_TAG:
5281 ath12k_htt_print_rx_pdev_rate_stats_tlv(tag_buf, len, stats_req);
5282 break;
5283 case HTT_STATS_RX_PDEV_RATE_EXT_STATS_TAG:
5284 ath12k_htt_print_rx_pdev_rate_ext_stats_tlv(tag_buf, len, stats_req);
5285 break;
5286 default:
5287 break;
5288 }
5289
5290 return 0;
5291 }
5292
ath12k_debugfs_htt_ext_stats_handler(struct ath12k_base * ab,struct sk_buff * skb)5293 void ath12k_debugfs_htt_ext_stats_handler(struct ath12k_base *ab,
5294 struct sk_buff *skb)
5295 {
5296 struct ath12k_htt_extd_stats_msg *msg;
5297 struct debug_htt_stats_req *stats_req;
5298 struct ath12k *ar;
5299 u32 len, pdev_id, stats_info;
5300 u64 cookie;
5301 int ret;
5302 bool send_completion = false;
5303
5304 msg = (struct ath12k_htt_extd_stats_msg *)skb->data;
5305 cookie = le64_to_cpu(msg->cookie);
5306
5307 if (u64_get_bits(cookie, ATH12K_HTT_STATS_COOKIE_MSB) !=
5308 ATH12K_HTT_STATS_MAGIC_VALUE) {
5309 ath12k_warn(ab, "received invalid htt ext stats event\n");
5310 return;
5311 }
5312
5313 pdev_id = u64_get_bits(cookie, ATH12K_HTT_STATS_COOKIE_LSB);
5314 rcu_read_lock();
5315 ar = ath12k_mac_get_ar_by_pdev_id(ab, pdev_id);
5316 if (!ar) {
5317 ath12k_warn(ab, "failed to get ar for pdev_id %d\n", pdev_id);
5318 goto exit;
5319 }
5320
5321 stats_req = ar->debug.htt_stats.stats_req;
5322 if (!stats_req)
5323 goto exit;
5324
5325 spin_lock_bh(&ar->data_lock);
5326
5327 stats_info = le32_to_cpu(msg->info1);
5328 stats_req->done = u32_get_bits(stats_info, ATH12K_HTT_T2H_EXT_STATS_INFO1_DONE);
5329 if (stats_req->done)
5330 send_completion = true;
5331
5332 spin_unlock_bh(&ar->data_lock);
5333
5334 len = u32_get_bits(stats_info, ATH12K_HTT_T2H_EXT_STATS_INFO1_LENGTH);
5335 if (len > skb->len) {
5336 ath12k_warn(ab, "invalid length %d for HTT stats", len);
5337 goto exit;
5338 }
5339
5340 ret = ath12k_dp_htt_tlv_iter(ab, msg->data, len,
5341 ath12k_dbg_htt_ext_stats_parse,
5342 stats_req);
5343 if (ret)
5344 ath12k_warn(ab, "Failed to parse tlv %d\n", ret);
5345
5346 if (send_completion)
5347 complete(&stats_req->htt_stats_rcvd);
5348 exit:
5349 rcu_read_unlock();
5350 }
5351
ath12k_read_htt_stats_type(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)5352 static ssize_t ath12k_read_htt_stats_type(struct file *file,
5353 char __user *user_buf,
5354 size_t count, loff_t *ppos)
5355 {
5356 struct ath12k *ar = file->private_data;
5357 enum ath12k_dbg_htt_ext_stats_type type;
5358 char buf[32];
5359 size_t len;
5360
5361 wiphy_lock(ath12k_ar_to_hw(ar)->wiphy);
5362 type = ar->debug.htt_stats.type;
5363 wiphy_unlock(ath12k_ar_to_hw(ar)->wiphy);
5364
5365 len = scnprintf(buf, sizeof(buf), "%u\n", type);
5366
5367 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
5368 }
5369
ath12k_write_htt_stats_type(struct file * file,const char __user * user_buf,size_t count,loff_t * ppos)5370 static ssize_t ath12k_write_htt_stats_type(struct file *file,
5371 const char __user *user_buf,
5372 size_t count, loff_t *ppos)
5373 {
5374 struct ath12k *ar = file->private_data;
5375 enum ath12k_dbg_htt_ext_stats_type type;
5376 unsigned int cfg_param[4] = {0};
5377 const int size = 32;
5378 int num_args;
5379
5380 char *buf __free(kfree) = kzalloc(size, GFP_KERNEL);
5381 if (!buf)
5382 return -ENOMEM;
5383
5384 if (copy_from_user(buf, user_buf, count))
5385 return -EFAULT;
5386
5387 num_args = sscanf(buf, "%u %u %u %u %u\n", &type, &cfg_param[0],
5388 &cfg_param[1], &cfg_param[2], &cfg_param[3]);
5389 if (!num_args || num_args > 5)
5390 return -EINVAL;
5391
5392 if (type == ATH12K_DBG_HTT_EXT_STATS_RESET ||
5393 type >= ATH12K_DBG_HTT_NUM_EXT_STATS)
5394 return -EINVAL;
5395
5396 wiphy_lock(ath12k_ar_to_hw(ar)->wiphy);
5397
5398 ar->debug.htt_stats.type = type;
5399 ar->debug.htt_stats.cfg_param[0] = cfg_param[0];
5400 ar->debug.htt_stats.cfg_param[1] = cfg_param[1];
5401 ar->debug.htt_stats.cfg_param[2] = cfg_param[2];
5402 ar->debug.htt_stats.cfg_param[3] = cfg_param[3];
5403
5404 wiphy_unlock(ath12k_ar_to_hw(ar)->wiphy);
5405
5406 return count;
5407 }
5408
5409 static const struct file_operations fops_htt_stats_type = {
5410 .read = ath12k_read_htt_stats_type,
5411 .write = ath12k_write_htt_stats_type,
5412 .open = simple_open,
5413 .owner = THIS_MODULE,
5414 .llseek = default_llseek,
5415 };
5416
ath12k_debugfs_htt_stats_req(struct ath12k * ar)5417 static int ath12k_debugfs_htt_stats_req(struct ath12k *ar)
5418 {
5419 struct debug_htt_stats_req *stats_req = ar->debug.htt_stats.stats_req;
5420 enum ath12k_dbg_htt_ext_stats_type type = stats_req->type;
5421 u64 cookie;
5422 int ret, pdev_id;
5423 struct htt_ext_stats_cfg_params cfg_params = { 0 };
5424
5425 lockdep_assert_wiphy(ath12k_ar_to_hw(ar)->wiphy);
5426
5427 init_completion(&stats_req->htt_stats_rcvd);
5428
5429 pdev_id = ath12k_mac_get_target_pdev_id(ar);
5430 stats_req->done = false;
5431 stats_req->pdev_id = pdev_id;
5432
5433 cookie = u64_encode_bits(ATH12K_HTT_STATS_MAGIC_VALUE,
5434 ATH12K_HTT_STATS_COOKIE_MSB);
5435 cookie |= u64_encode_bits(pdev_id, ATH12K_HTT_STATS_COOKIE_LSB);
5436
5437 if (stats_req->override_cfg_param) {
5438 cfg_params.cfg0 = stats_req->cfg_param[0];
5439 cfg_params.cfg1 = stats_req->cfg_param[1];
5440 cfg_params.cfg2 = stats_req->cfg_param[2];
5441 cfg_params.cfg3 = stats_req->cfg_param[3];
5442 }
5443
5444 ret = ath12k_dp_tx_htt_h2t_ext_stats_req(ar, type, &cfg_params, cookie);
5445 if (ret) {
5446 ath12k_warn(ar->ab, "failed to send htt stats request: %d\n", ret);
5447 return ret;
5448 }
5449 if (!wait_for_completion_timeout(&stats_req->htt_stats_rcvd, 3 * HZ)) {
5450 spin_lock_bh(&ar->data_lock);
5451 if (!stats_req->done) {
5452 stats_req->done = true;
5453 spin_unlock_bh(&ar->data_lock);
5454 ath12k_warn(ar->ab, "stats request timed out\n");
5455 return -ETIMEDOUT;
5456 }
5457 spin_unlock_bh(&ar->data_lock);
5458 }
5459
5460 return 0;
5461 }
5462
ath12k_open_htt_stats(struct inode * inode,struct file * file)5463 static int ath12k_open_htt_stats(struct inode *inode,
5464 struct file *file)
5465 {
5466 struct ath12k *ar = inode->i_private;
5467 struct debug_htt_stats_req *stats_req;
5468 enum ath12k_dbg_htt_ext_stats_type type = ar->debug.htt_stats.type;
5469 struct ath12k_hw *ah = ath12k_ar_to_ah(ar);
5470 int ret;
5471
5472 if (type == ATH12K_DBG_HTT_EXT_STATS_RESET)
5473 return -EPERM;
5474
5475 wiphy_lock(ath12k_ar_to_hw(ar)->wiphy);
5476
5477 if (ah->state != ATH12K_HW_STATE_ON) {
5478 ret = -ENETDOWN;
5479 goto err_unlock;
5480 }
5481
5482 if (ar->debug.htt_stats.stats_req) {
5483 ret = -EAGAIN;
5484 goto err_unlock;
5485 }
5486
5487 stats_req = kzalloc(sizeof(*stats_req) + ATH12K_HTT_STATS_BUF_SIZE, GFP_KERNEL);
5488 if (!stats_req) {
5489 ret = -ENOMEM;
5490 goto err_unlock;
5491 }
5492
5493 ar->debug.htt_stats.stats_req = stats_req;
5494 stats_req->type = type;
5495 stats_req->cfg_param[0] = ar->debug.htt_stats.cfg_param[0];
5496 stats_req->cfg_param[1] = ar->debug.htt_stats.cfg_param[1];
5497 stats_req->cfg_param[2] = ar->debug.htt_stats.cfg_param[2];
5498 stats_req->cfg_param[3] = ar->debug.htt_stats.cfg_param[3];
5499 stats_req->override_cfg_param = !!stats_req->cfg_param[0] ||
5500 !!stats_req->cfg_param[1] ||
5501 !!stats_req->cfg_param[2] ||
5502 !!stats_req->cfg_param[3];
5503
5504 ret = ath12k_debugfs_htt_stats_req(ar);
5505 if (ret < 0)
5506 goto out;
5507
5508 file->private_data = stats_req;
5509
5510 wiphy_unlock(ath12k_ar_to_hw(ar)->wiphy);
5511
5512 return 0;
5513 out:
5514 kfree(stats_req);
5515 ar->debug.htt_stats.stats_req = NULL;
5516 err_unlock:
5517 wiphy_unlock(ath12k_ar_to_hw(ar)->wiphy);
5518
5519 return ret;
5520 }
5521
ath12k_release_htt_stats(struct inode * inode,struct file * file)5522 static int ath12k_release_htt_stats(struct inode *inode,
5523 struct file *file)
5524 {
5525 struct ath12k *ar = inode->i_private;
5526
5527 wiphy_lock(ath12k_ar_to_hw(ar)->wiphy);
5528 kfree(file->private_data);
5529 ar->debug.htt_stats.stats_req = NULL;
5530 wiphy_unlock(ath12k_ar_to_hw(ar)->wiphy);
5531
5532 return 0;
5533 }
5534
ath12k_read_htt_stats(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)5535 static ssize_t ath12k_read_htt_stats(struct file *file,
5536 char __user *user_buf,
5537 size_t count, loff_t *ppos)
5538 {
5539 struct debug_htt_stats_req *stats_req = file->private_data;
5540 char *buf;
5541 u32 length;
5542
5543 buf = stats_req->buf;
5544 length = min_t(u32, stats_req->buf_len, ATH12K_HTT_STATS_BUF_SIZE);
5545 return simple_read_from_buffer(user_buf, count, ppos, buf, length);
5546 }
5547
5548 static const struct file_operations fops_dump_htt_stats = {
5549 .open = ath12k_open_htt_stats,
5550 .release = ath12k_release_htt_stats,
5551 .read = ath12k_read_htt_stats,
5552 .owner = THIS_MODULE,
5553 .llseek = default_llseek,
5554 };
5555
ath12k_write_htt_stats_reset(struct file * file,const char __user * user_buf,size_t count,loff_t * ppos)5556 static ssize_t ath12k_write_htt_stats_reset(struct file *file,
5557 const char __user *user_buf,
5558 size_t count, loff_t *ppos)
5559 {
5560 struct ath12k *ar = file->private_data;
5561 enum ath12k_dbg_htt_ext_stats_type type;
5562 struct htt_ext_stats_cfg_params cfg_params = { 0 };
5563 u8 param_pos;
5564 int ret;
5565
5566 ret = kstrtou32_from_user(user_buf, count, 0, &type);
5567 if (ret)
5568 return ret;
5569
5570 if (type >= ATH12K_DBG_HTT_NUM_EXT_STATS ||
5571 type == ATH12K_DBG_HTT_EXT_STATS_RESET)
5572 return -E2BIG;
5573
5574 wiphy_lock(ath12k_ar_to_hw(ar)->wiphy);
5575 cfg_params.cfg0 = HTT_STAT_DEFAULT_RESET_START_OFFSET;
5576 param_pos = (type >> 5) + 1;
5577
5578 switch (param_pos) {
5579 case ATH12K_HTT_STATS_RESET_PARAM_CFG_32_BYTES:
5580 cfg_params.cfg1 = 1 << (cfg_params.cfg0 + type);
5581 break;
5582 case ATH12K_HTT_STATS_RESET_PARAM_CFG_64_BYTES:
5583 cfg_params.cfg2 = ATH12K_HTT_STATS_RESET_BITMAP32_BIT(cfg_params.cfg0 +
5584 type);
5585 break;
5586 case ATH12K_HTT_STATS_RESET_PARAM_CFG_128_BYTES:
5587 cfg_params.cfg3 = ATH12K_HTT_STATS_RESET_BITMAP64_BIT(cfg_params.cfg0 +
5588 type);
5589 break;
5590 default:
5591 break;
5592 }
5593
5594 ret = ath12k_dp_tx_htt_h2t_ext_stats_req(ar,
5595 ATH12K_DBG_HTT_EXT_STATS_RESET,
5596 &cfg_params,
5597 0ULL);
5598 if (ret) {
5599 ath12k_warn(ar->ab, "failed to send htt stats request: %d\n", ret);
5600 wiphy_unlock(ath12k_ar_to_hw(ar)->wiphy);
5601 return ret;
5602 }
5603
5604 ar->debug.htt_stats.reset = type;
5605 wiphy_unlock(ath12k_ar_to_hw(ar)->wiphy);
5606
5607 return count;
5608 }
5609
5610 static const struct file_operations fops_htt_stats_reset = {
5611 .write = ath12k_write_htt_stats_reset,
5612 .open = simple_open,
5613 .owner = THIS_MODULE,
5614 .llseek = default_llseek,
5615 };
5616
ath12k_debugfs_htt_stats_register(struct ath12k * ar)5617 void ath12k_debugfs_htt_stats_register(struct ath12k *ar)
5618 {
5619 debugfs_create_file("htt_stats_type", 0600, ar->debug.debugfs_pdev,
5620 ar, &fops_htt_stats_type);
5621 debugfs_create_file("htt_stats", 0400, ar->debug.debugfs_pdev,
5622 ar, &fops_dump_htt_stats);
5623 debugfs_create_file("htt_stats_reset", 0200, ar->debug.debugfs_pdev,
5624 ar, &fops_htt_stats_reset);
5625 }
5626