13f73c24fSDinesh Karthikeyan // SPDX-License-Identifier: BSD-3-Clause-Clear
23f73c24fSDinesh Karthikeyan /*
33f73c24fSDinesh Karthikeyan * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
43f73c24fSDinesh Karthikeyan * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
53f73c24fSDinesh Karthikeyan */
63f73c24fSDinesh Karthikeyan
73f73c24fSDinesh Karthikeyan #include <linux/vmalloc.h>
83f73c24fSDinesh Karthikeyan #include "core.h"
93f73c24fSDinesh Karthikeyan #include "debug.h"
103f73c24fSDinesh Karthikeyan #include "debugfs_htt_stats.h"
11ad201b35SDinesh Karthikeyan #include "dp_tx.h"
12adf6df96SDinesh Karthikeyan #include "dp_rx.h"
13adf6df96SDinesh Karthikeyan
14adf6df96SDinesh Karthikeyan static u32
print_array_to_buf(u8 * buf,u32 offset,const char * header,const __le32 * array,u32 array_len,const char * footer)15adf6df96SDinesh Karthikeyan print_array_to_buf(u8 *buf, u32 offset, const char *header,
16adf6df96SDinesh Karthikeyan const __le32 *array, u32 array_len, const char *footer)
17adf6df96SDinesh Karthikeyan {
18adf6df96SDinesh Karthikeyan int index = 0;
19adf6df96SDinesh Karthikeyan u8 i;
20adf6df96SDinesh Karthikeyan
21adf6df96SDinesh Karthikeyan if (header) {
22adf6df96SDinesh Karthikeyan index += scnprintf(buf + offset,
23adf6df96SDinesh Karthikeyan ATH12K_HTT_STATS_BUF_SIZE - offset,
24adf6df96SDinesh Karthikeyan "%s = ", header);
25adf6df96SDinesh Karthikeyan }
26adf6df96SDinesh Karthikeyan for (i = 0; i < array_len; i++) {
27adf6df96SDinesh Karthikeyan index += scnprintf(buf + offset + index,
28adf6df96SDinesh Karthikeyan (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
29adf6df96SDinesh Karthikeyan " %u:%u,", i, le32_to_cpu(array[i]));
30adf6df96SDinesh Karthikeyan }
31adf6df96SDinesh Karthikeyan /* To overwrite the last trailing comma */
32adf6df96SDinesh Karthikeyan index--;
33adf6df96SDinesh Karthikeyan *(buf + offset + index) = '\0';
34adf6df96SDinesh Karthikeyan
35adf6df96SDinesh Karthikeyan if (footer) {
36adf6df96SDinesh Karthikeyan index += scnprintf(buf + offset + index,
37adf6df96SDinesh Karthikeyan (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
38adf6df96SDinesh Karthikeyan "%s", footer);
39adf6df96SDinesh Karthikeyan }
40adf6df96SDinesh Karthikeyan return index;
41adf6df96SDinesh Karthikeyan }
42adf6df96SDinesh Karthikeyan
43adf6df96SDinesh Karthikeyan static void
htt_print_tx_pdev_stats_cmn_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)44adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_cmn_tlv(const void *tag_buf, u16 tag_len,
45adf6df96SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
46adf6df96SDinesh Karthikeyan {
47adf6df96SDinesh Karthikeyan const struct ath12k_htt_tx_pdev_stats_cmn_tlv *htt_stats_buf = tag_buf;
48adf6df96SDinesh Karthikeyan u8 *buf = stats_req->buf;
49adf6df96SDinesh Karthikeyan u32 len = stats_req->buf_len;
50adf6df96SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
51adf6df96SDinesh Karthikeyan u32 mac_id_word;
52adf6df96SDinesh Karthikeyan
53adf6df96SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
54adf6df96SDinesh Karthikeyan return;
55adf6df96SDinesh Karthikeyan
56adf6df96SDinesh Karthikeyan mac_id_word = le32_to_cpu(htt_stats_buf->mac_id__word);
57adf6df96SDinesh Karthikeyan
58adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_PDEV_STATS_CMN_TLV:\n");
59adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
60adf6df96SDinesh Karthikeyan u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
61adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "comp_delivered = %u\n",
62adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->comp_delivered));
63adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "self_triggers = %u\n",
64adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->self_triggers));
65adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hw_queued = %u\n",
66adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hw_queued));
67adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hw_reaped = %u\n",
68adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hw_reaped));
69adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "underrun = %u\n",
70adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->underrun));
71adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hw_paused = %u\n",
72adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hw_paused));
73adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hw_flush = %u\n",
74adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hw_flush));
75adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hw_filt = %u\n",
76adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hw_filt));
77adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_abort = %u\n",
78adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tx_abort));
79adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ppdu_ok = %u\n",
80adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ppdu_ok));
81adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_requeued = %u\n",
82adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_requed));
83adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_xretry = %u\n",
84adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tx_xretry));
85adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "data_rc = %u\n",
86adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->data_rc));
87adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_dropped_xretry = %u\n",
88adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_dropped_xretry));
89adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "illegal_rate_phy_err = %u\n",
90adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->illgl_rate_phy_err));
91adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "cont_xretry = %u\n",
92adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->cont_xretry));
93adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_timeout = %u\n",
94adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tx_timeout));
95adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_time_dur_data = %u\n",
96adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tx_time_dur_data));
97adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "pdev_resets = %u\n",
98adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->pdev_resets));
99adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "phy_underrun = %u\n",
100adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->phy_underrun));
101adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "txop_ovf = %u\n",
102adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->txop_ovf));
103adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_posted = %u\n",
104adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_posted));
105adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_failed_queueing = %u\n",
106adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_failed_queueing));
107adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_completed = %u\n",
108adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_completed));
109adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_restarted = %u\n",
110adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_restarted));
111adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_txop_repost_stop = %u\n",
112adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_txop_repost_stop));
113adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "next_seq_cancel = %u\n",
114adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->next_seq_cancel));
115adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "dl_mu_mimo_seq_posted = %u\n",
116adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mu_seq_posted));
117adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "dl_mu_ofdma_seq_posted = %u\n",
118adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mu_ofdma_seq_posted));
119adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ul_mu_mimo_seq_posted = %u\n",
120adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ul_mumimo_seq_posted));
121adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ul_mu_ofdma_seq_posted = %u\n",
122adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ul_ofdma_seq_posted));
123adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mu_mimo_peer_blacklisted = %u\n",
124adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_mu_peer_blacklisted));
125adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_qdepth_repost_stop = %u\n",
126adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_qdepth_repost_stop));
127adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_min_msdu_repost_stop = %u\n",
128adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_min_msdu_repost_stop));
129adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mu_seq_min_msdu_repost_stop = %u\n",
130adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mu_seq_min_msdu_repost_stop));
131adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_switch_hw_paused = %u\n",
132adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_switch_hw_paused));
133adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "next_seq_posted_dsr = %u\n",
134adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->next_seq_posted_dsr));
135adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_posted_isr = %u\n",
136adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_posted_isr));
137adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "seq_ctrl_cached = %u\n",
138adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->seq_ctrl_cached));
139adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_count_tqm = %u\n",
140adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_count_tqm));
141adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "msdu_count_tqm = %u\n",
142adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->msdu_count_tqm));
143adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_removed_tqm = %u\n",
144adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_removed_tqm));
145adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "msdu_removed_tqm = %u\n",
146adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->msdu_removed_tqm));
147adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_mpdus_max_retries = %u\n",
148adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_mpdus_max_retries));
149adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdus_sw_flush = %u\n",
150adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdus_sw_flush));
151adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdus_hw_filter = %u\n",
152adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdus_hw_filter));
153adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdus_truncated = %u\n",
154adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdus_truncated));
155adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdus_ack_failed = %u\n",
156adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdus_ack_failed));
157adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdus_expired = %u\n",
158adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdus_expired));
159adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdus_seq_hw_retry = %u\n",
160adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdus_seq_hw_retry));
161adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ack_tlv_proc = %u\n",
162adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ack_tlv_proc));
163adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "coex_abort_mpdu_cnt_valid = %u\n",
164adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->coex_abort_mpdu_cnt_valid));
165adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "coex_abort_mpdu_cnt = %u\n",
166adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->coex_abort_mpdu_cnt));
167adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_total_ppdus_tried_ota = %u\n",
168adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_total_ppdus_tried_ota));
169adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_data_ppdus_tried_ota = %u\n",
170adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_data_ppdus_tried_ota));
171adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "local_ctrl_mgmt_enqued = %u\n",
172adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->local_ctrl_mgmt_enqued));
173adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "local_ctrl_mgmt_freed = %u\n",
174adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->local_ctrl_mgmt_freed));
175adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "local_data_enqued = %u\n",
176adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->local_data_enqued));
177adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "local_data_freed = %u\n",
178adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->local_data_freed));
179adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_tried = %u\n",
180adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_tried));
181adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "isr_wait_seq_posted = %u\n",
182adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->isr_wait_seq_posted));
183adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_active_dur_us_low = %u\n",
184adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tx_active_dur_us_low));
185adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_active_dur_us_high = %u\n",
186adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tx_active_dur_us_high));
187adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fes_offsets_err_cnt = %u\n\n",
188adf6df96SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fes_offsets_err_cnt));
189adf6df96SDinesh Karthikeyan
190adf6df96SDinesh Karthikeyan stats_req->buf_len = len;
191adf6df96SDinesh Karthikeyan }
192adf6df96SDinesh Karthikeyan
193adf6df96SDinesh Karthikeyan static void
htt_print_tx_pdev_stats_urrn_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)194adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_urrn_tlv(const void *tag_buf,
195adf6df96SDinesh Karthikeyan u16 tag_len,
196adf6df96SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
197adf6df96SDinesh Karthikeyan {
198adf6df96SDinesh Karthikeyan const struct ath12k_htt_tx_pdev_stats_urrn_tlv *htt_stats_buf = tag_buf;
199adf6df96SDinesh Karthikeyan u8 *buf = stats_req->buf;
200adf6df96SDinesh Karthikeyan u32 len = stats_req->buf_len;
201adf6df96SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
202adf6df96SDinesh Karthikeyan u16 num_elems = min_t(u16, (tag_len >> 2),
203adf6df96SDinesh Karthikeyan HTT_TX_PDEV_MAX_URRN_STATS);
204adf6df96SDinesh Karthikeyan
205adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
206adf6df96SDinesh Karthikeyan "HTT_TX_PDEV_STATS_URRN_TLV:\n");
207adf6df96SDinesh Karthikeyan
208adf6df96SDinesh Karthikeyan len += print_array_to_buf(buf, len, "urrn_stats", htt_stats_buf->urrn_stats,
209adf6df96SDinesh Karthikeyan num_elems, "\n\n");
210adf6df96SDinesh Karthikeyan
211adf6df96SDinesh Karthikeyan stats_req->buf_len = len;
212adf6df96SDinesh Karthikeyan }
213adf6df96SDinesh Karthikeyan
214adf6df96SDinesh Karthikeyan static void
htt_print_tx_pdev_stats_flush_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)215adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_flush_tlv(const void *tag_buf,
216adf6df96SDinesh Karthikeyan u16 tag_len,
217adf6df96SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
218adf6df96SDinesh Karthikeyan {
219adf6df96SDinesh Karthikeyan const struct ath12k_htt_tx_pdev_stats_flush_tlv *htt_stats_buf = tag_buf;
220adf6df96SDinesh Karthikeyan u8 *buf = stats_req->buf;
221adf6df96SDinesh Karthikeyan u32 len = stats_req->buf_len;
222adf6df96SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
223adf6df96SDinesh Karthikeyan u16 num_elems = min_t(u16, (tag_len >> 2),
224adf6df96SDinesh Karthikeyan ATH12K_HTT_TX_PDEV_MAX_FLUSH_REASON_STATS);
225adf6df96SDinesh Karthikeyan
226adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
227adf6df96SDinesh Karthikeyan "HTT_TX_PDEV_STATS_FLUSH_TLV:\n");
228adf6df96SDinesh Karthikeyan
229adf6df96SDinesh Karthikeyan len += print_array_to_buf(buf, len, "flush_errs", htt_stats_buf->flush_errs,
230adf6df96SDinesh Karthikeyan num_elems, "\n\n");
231adf6df96SDinesh Karthikeyan
232adf6df96SDinesh Karthikeyan stats_req->buf_len = len;
233adf6df96SDinesh Karthikeyan }
234adf6df96SDinesh Karthikeyan
235adf6df96SDinesh Karthikeyan static void
htt_print_tx_pdev_stats_sifs_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)236adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_sifs_tlv(const void *tag_buf,
237adf6df96SDinesh Karthikeyan u16 tag_len,
238adf6df96SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
239adf6df96SDinesh Karthikeyan {
240adf6df96SDinesh Karthikeyan const struct ath12k_htt_tx_pdev_stats_sifs_tlv *htt_stats_buf = tag_buf;
241adf6df96SDinesh Karthikeyan u8 *buf = stats_req->buf;
242adf6df96SDinesh Karthikeyan u32 len = stats_req->buf_len;
243adf6df96SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
244adf6df96SDinesh Karthikeyan u16 num_elems = min_t(u16, (tag_len >> 2),
245adf6df96SDinesh Karthikeyan ATH12K_HTT_TX_PDEV_MAX_SIFS_BURST_STATS);
246adf6df96SDinesh Karthikeyan
247adf6df96SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
248adf6df96SDinesh Karthikeyan "HTT_TX_PDEV_STATS_SIFS_TLV:\n");
249adf6df96SDinesh Karthikeyan
250adf6df96SDinesh Karthikeyan len += print_array_to_buf(buf, len, "sifs_status", htt_stats_buf->sifs_status,
251adf6df96SDinesh Karthikeyan num_elems, "\n\n");
252adf6df96SDinesh Karthikeyan
253adf6df96SDinesh Karthikeyan stats_req->buf_len = len;
254adf6df96SDinesh Karthikeyan }
255adf6df96SDinesh Karthikeyan
256a9f2976fSRamya Gnanasekar 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)257a9f2976fSRamya Gnanasekar htt_print_tx_pdev_mu_ppdu_dist_stats_tlv(const void *tag_buf, u16 tag_len,
258a9f2976fSRamya Gnanasekar struct debug_htt_stats_req *stats_req)
259a9f2976fSRamya Gnanasekar {
260a9f2976fSRamya Gnanasekar const struct ath12k_htt_tx_pdev_mu_ppdu_dist_stats_tlv *htt_stats_buf = tag_buf;
261a9f2976fSRamya Gnanasekar char *mode;
262a9f2976fSRamya Gnanasekar u8 j, hw_mode, i, str_buf_len;
263a9f2976fSRamya Gnanasekar u8 *buf = stats_req->buf;
264a9f2976fSRamya Gnanasekar u32 len = stats_req->buf_len;
265a9f2976fSRamya Gnanasekar u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
266a9f2976fSRamya Gnanasekar u32 stats_value;
267a9f2976fSRamya Gnanasekar u8 max_ppdu = ATH12K_HTT_STATS_MAX_NUM_MU_PPDU_PER_BURST;
268a9f2976fSRamya Gnanasekar u8 max_sched = ATH12K_HTT_STATS_MAX_NUM_SCHED_STATUS;
269a9f2976fSRamya Gnanasekar char str_buf[ATH12K_HTT_MAX_STRING_LEN];
270a9f2976fSRamya Gnanasekar
271a9f2976fSRamya Gnanasekar if (tag_len < sizeof(*htt_stats_buf))
272a9f2976fSRamya Gnanasekar return;
273a9f2976fSRamya Gnanasekar
274a9f2976fSRamya Gnanasekar hw_mode = le32_to_cpu(htt_stats_buf->hw_mode);
275a9f2976fSRamya Gnanasekar
276a9f2976fSRamya Gnanasekar switch (hw_mode) {
277a9f2976fSRamya Gnanasekar case ATH12K_HTT_STATS_HWMODE_AC:
278a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
279a9f2976fSRamya Gnanasekar "HTT_TX_PDEV_AC_MU_PPDU_DISTRIBUTION_STATS:\n");
280a9f2976fSRamya Gnanasekar mode = "ac";
281a9f2976fSRamya Gnanasekar break;
282a9f2976fSRamya Gnanasekar case ATH12K_HTT_STATS_HWMODE_AX:
283a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
284a9f2976fSRamya Gnanasekar "HTT_TX_PDEV_AX_MU_PPDU_DISTRIBUTION_STATS:\n");
285a9f2976fSRamya Gnanasekar mode = "ax";
286a9f2976fSRamya Gnanasekar break;
287a9f2976fSRamya Gnanasekar case ATH12K_HTT_STATS_HWMODE_BE:
288a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
289a9f2976fSRamya Gnanasekar "HTT_TX_PDEV_BE_MU_PPDU_DISTRIBUTION_STATS:\n");
290a9f2976fSRamya Gnanasekar mode = "be";
291a9f2976fSRamya Gnanasekar break;
292a9f2976fSRamya Gnanasekar default:
293a9f2976fSRamya Gnanasekar return;
294a9f2976fSRamya Gnanasekar }
295a9f2976fSRamya Gnanasekar
296a9f2976fSRamya Gnanasekar for (i = 0; i < ATH12K_HTT_STATS_NUM_NR_BINS ; i++) {
297a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
298a9f2976fSRamya Gnanasekar "%s_mu_mimo_num_seq_posted_nr%u = %u\n", mode,
299a9f2976fSRamya Gnanasekar ((i + 1) * 4), htt_stats_buf->num_seq_posted[i]);
300a9f2976fSRamya Gnanasekar str_buf_len = 0;
301a9f2976fSRamya Gnanasekar memset(str_buf, 0x0, sizeof(str_buf));
302a9f2976fSRamya Gnanasekar for (j = 0; j < ATH12K_HTT_STATS_MAX_NUM_MU_PPDU_PER_BURST ; j++) {
303a9f2976fSRamya Gnanasekar stats_value = le32_to_cpu(htt_stats_buf->num_ppdu_posted_per_burst
304a9f2976fSRamya Gnanasekar [i * max_ppdu + j]);
305a9f2976fSRamya Gnanasekar str_buf_len += scnprintf(&str_buf[str_buf_len],
306a9f2976fSRamya Gnanasekar ATH12K_HTT_MAX_STRING_LEN - str_buf_len,
307a9f2976fSRamya Gnanasekar " %u:%u,", j, stats_value);
308a9f2976fSRamya Gnanasekar }
309a9f2976fSRamya Gnanasekar /* To overwrite the last trailing comma */
310a9f2976fSRamya Gnanasekar str_buf[str_buf_len - 1] = '\0';
311a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
312a9f2976fSRamya Gnanasekar "%s_mu_mimo_num_ppdu_posted_per_burst_nr%u = %s\n",
313a9f2976fSRamya Gnanasekar mode, ((i + 1) * 4), str_buf);
314a9f2976fSRamya Gnanasekar str_buf_len = 0;
315a9f2976fSRamya Gnanasekar memset(str_buf, 0x0, sizeof(str_buf));
316a9f2976fSRamya Gnanasekar for (j = 0; j < ATH12K_HTT_STATS_MAX_NUM_MU_PPDU_PER_BURST ; j++) {
317a9f2976fSRamya Gnanasekar stats_value = le32_to_cpu(htt_stats_buf->num_ppdu_cmpl_per_burst
318a9f2976fSRamya Gnanasekar [i * max_ppdu + j]);
319a9f2976fSRamya Gnanasekar str_buf_len += scnprintf(&str_buf[str_buf_len],
320a9f2976fSRamya Gnanasekar ATH12K_HTT_MAX_STRING_LEN - str_buf_len,
321a9f2976fSRamya Gnanasekar " %u:%u,", j, stats_value);
322a9f2976fSRamya Gnanasekar }
323a9f2976fSRamya Gnanasekar /* To overwrite the last trailing comma */
324a9f2976fSRamya Gnanasekar str_buf[str_buf_len - 1] = '\0';
325a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
326a9f2976fSRamya Gnanasekar "%s_mu_mimo_num_ppdu_completed_per_burst_nr%u = %s\n",
327a9f2976fSRamya Gnanasekar mode, ((i + 1) * 4), str_buf);
328a9f2976fSRamya Gnanasekar str_buf_len = 0;
329a9f2976fSRamya Gnanasekar memset(str_buf, 0x0, sizeof(str_buf));
330a9f2976fSRamya Gnanasekar for (j = 0; j < ATH12K_HTT_STATS_MAX_NUM_SCHED_STATUS ; j++) {
331a9f2976fSRamya Gnanasekar stats_value = le32_to_cpu(htt_stats_buf->num_seq_term_status
332a9f2976fSRamya Gnanasekar [i * max_sched + j]);
333a9f2976fSRamya Gnanasekar str_buf_len += scnprintf(&str_buf[str_buf_len],
334a9f2976fSRamya Gnanasekar ATH12K_HTT_MAX_STRING_LEN - str_buf_len,
335a9f2976fSRamya Gnanasekar " %u:%u,", j, stats_value);
336a9f2976fSRamya Gnanasekar }
337a9f2976fSRamya Gnanasekar /* To overwrite the last trailing comma */
338a9f2976fSRamya Gnanasekar str_buf[str_buf_len - 1] = '\0';
339a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
340a9f2976fSRamya Gnanasekar "%s_mu_mimo_num_seq_term_status_nr%u = %s\n\n",
341a9f2976fSRamya Gnanasekar mode, ((i + 1) * 4), str_buf);
342a9f2976fSRamya Gnanasekar }
343a9f2976fSRamya Gnanasekar
344a9f2976fSRamya Gnanasekar stats_req->buf_len = len;
345a9f2976fSRamya Gnanasekar }
346a9f2976fSRamya Gnanasekar
347a9f2976fSRamya Gnanasekar static void
htt_print_tx_pdev_stats_sifs_hist_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)348a9f2976fSRamya Gnanasekar htt_print_tx_pdev_stats_sifs_hist_tlv(const void *tag_buf,
349a9f2976fSRamya Gnanasekar u16 tag_len,
350a9f2976fSRamya Gnanasekar struct debug_htt_stats_req *stats_req)
351a9f2976fSRamya Gnanasekar {
352a9f2976fSRamya Gnanasekar const struct ath12k_htt_tx_pdev_stats_sifs_hist_tlv *htt_stats_buf = tag_buf;
353a9f2976fSRamya Gnanasekar u8 *buf = stats_req->buf;
354a9f2976fSRamya Gnanasekar u32 len = stats_req->buf_len;
355a9f2976fSRamya Gnanasekar u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
356a9f2976fSRamya Gnanasekar u16 num_elems = min_t(u16, (tag_len >> 2),
357a9f2976fSRamya Gnanasekar ATH12K_HTT_TX_PDEV_MAX_SIFS_BURST_HIST_STATS);
358a9f2976fSRamya Gnanasekar
359a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
360a9f2976fSRamya Gnanasekar "HTT_TX_PDEV_STATS_SIFS_HIST_TLV:\n");
361a9f2976fSRamya Gnanasekar
362a9f2976fSRamya Gnanasekar len += print_array_to_buf(buf, len, "sifs_hist_status",
363a9f2976fSRamya Gnanasekar htt_stats_buf->sifs_hist_status, num_elems, "\n\n");
364a9f2976fSRamya Gnanasekar
365a9f2976fSRamya Gnanasekar stats_req->buf_len = len;
366a9f2976fSRamya Gnanasekar }
367a9f2976fSRamya Gnanasekar
368a9f2976fSRamya Gnanasekar static void
htt_print_pdev_ctrl_path_tx_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)369a9f2976fSRamya Gnanasekar htt_print_pdev_ctrl_path_tx_stats_tlv(const void *tag_buf, u16 tag_len,
370a9f2976fSRamya Gnanasekar struct debug_htt_stats_req *stats_req)
371a9f2976fSRamya Gnanasekar {
372a9f2976fSRamya Gnanasekar const struct ath12k_htt_pdev_ctrl_path_tx_stats_tlv *htt_stats_buf = tag_buf;
373a9f2976fSRamya Gnanasekar u8 *buf = stats_req->buf;
374a9f2976fSRamya Gnanasekar u32 len = stats_req->buf_len;
375a9f2976fSRamya Gnanasekar u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
376a9f2976fSRamya Gnanasekar
377a9f2976fSRamya Gnanasekar if (len < sizeof(*htt_stats_buf))
378a9f2976fSRamya Gnanasekar return;
379a9f2976fSRamya Gnanasekar
380a9f2976fSRamya Gnanasekar len += scnprintf(buf + len, buf_len - len,
381a9f2976fSRamya Gnanasekar "HTT_TX_PDEV_STATS_CTRL_PATH_TX_STATS:\n");
382a9f2976fSRamya Gnanasekar len += print_array_to_buf(buf, len, "fw_tx_mgmt_subtype",
383a9f2976fSRamya Gnanasekar htt_stats_buf->fw_tx_mgmt_subtype,
384a9f2976fSRamya Gnanasekar ATH12K_HTT_STATS_SUBTYPE_MAX, "\n\n");
385a9f2976fSRamya Gnanasekar
386a9f2976fSRamya Gnanasekar stats_req->buf_len = len;
387a9f2976fSRamya Gnanasekar }
388a9f2976fSRamya Gnanasekar
3894b6dfc75SDinesh Karthikeyan static void
ath12k_htt_print_stats_tx_sched_cmn_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)3904b6dfc75SDinesh Karthikeyan ath12k_htt_print_stats_tx_sched_cmn_tlv(const void *tag_buf,
3914b6dfc75SDinesh Karthikeyan u16 tag_len,
3924b6dfc75SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
3934b6dfc75SDinesh Karthikeyan {
3944b6dfc75SDinesh Karthikeyan const struct ath12k_htt_stats_tx_sched_cmn_tlv *htt_stats_buf = tag_buf;
3954b6dfc75SDinesh Karthikeyan u8 *buf = stats_req->buf;
3964b6dfc75SDinesh Karthikeyan u32 len = stats_req->buf_len;
3974b6dfc75SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
3984b6dfc75SDinesh Karthikeyan u32 mac_id_word;
3994b6dfc75SDinesh Karthikeyan
4004b6dfc75SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
4014b6dfc75SDinesh Karthikeyan return;
4024b6dfc75SDinesh Karthikeyan
4034b6dfc75SDinesh Karthikeyan mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
4044b6dfc75SDinesh Karthikeyan
4054b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_STATS_TX_SCHED_CMN_TLV:\n");
4064b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4074b6dfc75SDinesh Karthikeyan u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
4084b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "current_timestamp = %u\n\n",
4094b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->current_timestamp));
4104b6dfc75SDinesh Karthikeyan
4114b6dfc75SDinesh Karthikeyan stats_req->buf_len = len;
4124b6dfc75SDinesh Karthikeyan }
4134b6dfc75SDinesh Karthikeyan
4144b6dfc75SDinesh Karthikeyan 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)4154b6dfc75SDinesh Karthikeyan ath12k_htt_print_tx_pdev_stats_sched_per_txq_tlv(const void *tag_buf,
4164b6dfc75SDinesh Karthikeyan u16 tag_len,
4174b6dfc75SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
4184b6dfc75SDinesh Karthikeyan {
4194b6dfc75SDinesh Karthikeyan const struct ath12k_htt_tx_pdev_stats_sched_per_txq_tlv *htt_stats_buf = tag_buf;
4204b6dfc75SDinesh Karthikeyan u8 *buf = stats_req->buf;
4214b6dfc75SDinesh Karthikeyan u32 len = stats_req->buf_len;
4224b6dfc75SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
4234b6dfc75SDinesh Karthikeyan u32 mac_id_word;
4244b6dfc75SDinesh Karthikeyan
4254b6dfc75SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
4264b6dfc75SDinesh Karthikeyan return;
4274b6dfc75SDinesh Karthikeyan
4284b6dfc75SDinesh Karthikeyan mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
4294b6dfc75SDinesh Karthikeyan
4304b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
4314b6dfc75SDinesh Karthikeyan "HTT_TX_PDEV_STATS_SCHED_PER_TXQ_TLV:\n");
4324b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
4334b6dfc75SDinesh Karthikeyan u32_get_bits(mac_id_word,
4344b6dfc75SDinesh Karthikeyan ATH12K_HTT_TX_PDEV_STATS_SCHED_PER_TXQ_MAC_ID));
4354b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "txq_id = %u\n",
4364b6dfc75SDinesh Karthikeyan u32_get_bits(mac_id_word,
4374b6dfc75SDinesh Karthikeyan ATH12K_HTT_TX_PDEV_STATS_SCHED_PER_TXQ_ID));
4384b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_policy = %u\n",
4394b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_policy));
4404b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
4414b6dfc75SDinesh Karthikeyan "last_sched_cmd_posted_timestamp = %u\n",
4424b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->last_sched_cmd_posted_timestamp));
4434b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
4444b6dfc75SDinesh Karthikeyan "last_sched_cmd_compl_timestamp = %u\n",
4454b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->last_sched_cmd_compl_timestamp));
4464b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_2_tac_lwm_count = %u\n",
4474b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_2_tac_lwm_count));
4484b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_2_tac_ring_full = %u\n",
4494b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_2_tac_ring_full));
4504b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_cmd_post_failure = %u\n",
4514b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_cmd_post_failure));
4524b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_active_tids = %u\n",
4534b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_active_tids));
4544b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_ps_schedules = %u\n",
4554b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_ps_schedules));
4564b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_cmds_pending = %u\n",
4574b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_cmds_pending));
4584b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_tid_register = %u\n",
4594b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_tid_register));
4604b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_tid_unregister = %u\n",
4614b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_tid_unregister));
4624b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_qstats_queried = %u\n",
4634b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_qstats_queried));
4644b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "qstats_update_pending = %u\n",
4654b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->qstats_update_pending));
4664b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "last_qstats_query_timestamp = %u\n",
4674b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->last_qstats_query_timestamp));
4684b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_tqm_cmdq_full = %u\n",
4694b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_tqm_cmdq_full));
4704b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_de_sched_algo_trigger = %u\n",
4714b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_de_sched_algo_trigger));
4724b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_rt_sched_algo_trigger = %u\n",
4734b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_rt_sched_algo_trigger));
4744b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_tqm_sched_algo_trigger = %u\n",
4754b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_tqm_sched_algo_trigger));
4764b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "notify_sched = %u\n",
4774b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->notify_sched));
4784b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "dur_based_sendn_term = %u\n",
4794b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->dur_based_sendn_term));
4804b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "su_notify2_sched = %u\n",
4814b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->su_notify2_sched));
4824b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "su_optimal_queued_msdus_sched = %u\n",
4834b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->su_optimal_queued_msdus_sched));
4844b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "su_delay_timeout_sched = %u\n",
4854b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->su_delay_timeout_sched));
4864b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "su_min_txtime_sched_delay = %u\n",
4874b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->su_min_txtime_sched_delay));
4884b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "su_no_delay = %u\n",
4894b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->su_no_delay));
4904b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_supercycles = %u\n",
4914b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_supercycles));
4924b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_subcycles_with_sort = %u\n",
4934b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_subcycles_with_sort));
4944b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "num_subcycles_no_sort = %u\n\n",
4954b6dfc75SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->num_subcycles_no_sort));
4964b6dfc75SDinesh Karthikeyan
4974b6dfc75SDinesh Karthikeyan stats_req->buf_len = len;
4984b6dfc75SDinesh Karthikeyan }
4994b6dfc75SDinesh Karthikeyan
5004b6dfc75SDinesh Karthikeyan static void
ath12k_htt_print_sched_txq_cmd_posted_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)5014b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_cmd_posted_tlv(const void *tag_buf,
5024b6dfc75SDinesh Karthikeyan u16 tag_len,
5034b6dfc75SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
5044b6dfc75SDinesh Karthikeyan {
5054b6dfc75SDinesh Karthikeyan const struct ath12k_htt_sched_txq_cmd_posted_tlv *htt_stats_buf = tag_buf;
5064b6dfc75SDinesh Karthikeyan u8 *buf = stats_req->buf;
5074b6dfc75SDinesh Karthikeyan u32 len = stats_req->buf_len;
5084b6dfc75SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
5094b6dfc75SDinesh Karthikeyan u16 num_elements = tag_len >> 2;
5104b6dfc75SDinesh Karthikeyan
5114b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_SCHED_TXQ_CMD_POSTED_TLV:\n");
5124b6dfc75SDinesh Karthikeyan len += print_array_to_buf(buf, len, "sched_cmd_posted",
5134b6dfc75SDinesh Karthikeyan htt_stats_buf->sched_cmd_posted, num_elements, "\n\n");
5144b6dfc75SDinesh Karthikeyan
5154b6dfc75SDinesh Karthikeyan stats_req->buf_len = len;
5164b6dfc75SDinesh Karthikeyan }
5174b6dfc75SDinesh Karthikeyan
5184b6dfc75SDinesh Karthikeyan static void
ath12k_htt_print_sched_txq_cmd_reaped_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)5194b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_cmd_reaped_tlv(const void *tag_buf,
5204b6dfc75SDinesh Karthikeyan u16 tag_len,
5214b6dfc75SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
5224b6dfc75SDinesh Karthikeyan {
5234b6dfc75SDinesh Karthikeyan const struct ath12k_htt_sched_txq_cmd_reaped_tlv *htt_stats_buf = tag_buf;
5244b6dfc75SDinesh Karthikeyan u8 *buf = stats_req->buf;
5254b6dfc75SDinesh Karthikeyan u32 len = stats_req->buf_len;
5264b6dfc75SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
5274b6dfc75SDinesh Karthikeyan u16 num_elements = tag_len >> 2;
5284b6dfc75SDinesh Karthikeyan
5294b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_SCHED_TXQ_CMD_REAPED_TLV:\n");
5304b6dfc75SDinesh Karthikeyan len += print_array_to_buf(buf, len, "sched_cmd_reaped",
5314b6dfc75SDinesh Karthikeyan htt_stats_buf->sched_cmd_reaped, num_elements, "\n\n");
5324b6dfc75SDinesh Karthikeyan
5334b6dfc75SDinesh Karthikeyan stats_req->buf_len = len;
5344b6dfc75SDinesh Karthikeyan }
5354b6dfc75SDinesh Karthikeyan
5364b6dfc75SDinesh Karthikeyan 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)5374b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_sched_order_su_tlv(const void *tag_buf,
5384b6dfc75SDinesh Karthikeyan u16 tag_len,
5394b6dfc75SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
5404b6dfc75SDinesh Karthikeyan {
5414b6dfc75SDinesh Karthikeyan const struct ath12k_htt_sched_txq_sched_order_su_tlv *htt_stats_buf = tag_buf;
5424b6dfc75SDinesh Karthikeyan u8 *buf = stats_req->buf;
5434b6dfc75SDinesh Karthikeyan u32 len = stats_req->buf_len;
5444b6dfc75SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
5454b6dfc75SDinesh Karthikeyan u32 sched_order_su_num_entries = min_t(u32, (tag_len >> 2),
5464b6dfc75SDinesh Karthikeyan ATH12K_HTT_TX_PDEV_NUM_SCHED_ORDER_LOG);
5474b6dfc75SDinesh Karthikeyan
5484b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
5494b6dfc75SDinesh Karthikeyan "HTT_SCHED_TXQ_SCHED_ORDER_SU_TLV:\n");
5504b6dfc75SDinesh Karthikeyan len += print_array_to_buf(buf, len, "sched_order_su",
5514b6dfc75SDinesh Karthikeyan htt_stats_buf->sched_order_su,
5524b6dfc75SDinesh Karthikeyan sched_order_su_num_entries, "\n\n");
5534b6dfc75SDinesh Karthikeyan
5544b6dfc75SDinesh Karthikeyan stats_req->buf_len = len;
5554b6dfc75SDinesh Karthikeyan }
5564b6dfc75SDinesh Karthikeyan
5574b6dfc75SDinesh Karthikeyan static void
ath12k_htt_print_sched_txq_sched_ineligibility_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)5584b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_sched_ineligibility_tlv(const void *tag_buf,
5594b6dfc75SDinesh Karthikeyan u16 tag_len,
5604b6dfc75SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
5614b6dfc75SDinesh Karthikeyan {
5624b6dfc75SDinesh Karthikeyan const struct ath12k_htt_sched_txq_sched_ineligibility_tlv *htt_stats_buf =
5634b6dfc75SDinesh Karthikeyan tag_buf;
5644b6dfc75SDinesh Karthikeyan u8 *buf = stats_req->buf;
5654b6dfc75SDinesh Karthikeyan u32 len = stats_req->buf_len;
5664b6dfc75SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
5674b6dfc75SDinesh Karthikeyan u32 sched_ineligibility_num_entries = tag_len >> 2;
5684b6dfc75SDinesh Karthikeyan
5694b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
5704b6dfc75SDinesh Karthikeyan "HTT_SCHED_TXQ_SCHED_INELIGIBILITY:\n");
5714b6dfc75SDinesh Karthikeyan len += print_array_to_buf(buf, len, "sched_ineligibility",
5724b6dfc75SDinesh Karthikeyan htt_stats_buf->sched_ineligibility,
5734b6dfc75SDinesh Karthikeyan sched_ineligibility_num_entries, "\n\n");
5744b6dfc75SDinesh Karthikeyan
5754b6dfc75SDinesh Karthikeyan stats_req->buf_len = len;
5764b6dfc75SDinesh Karthikeyan }
5774b6dfc75SDinesh Karthikeyan
5784b6dfc75SDinesh Karthikeyan static void
ath12k_htt_print_sched_txq_supercycle_trigger_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)5794b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_supercycle_trigger_tlv(const void *tag_buf,
5804b6dfc75SDinesh Karthikeyan u16 tag_len,
5814b6dfc75SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
5824b6dfc75SDinesh Karthikeyan {
5834b6dfc75SDinesh Karthikeyan const struct ath12k_htt_sched_txq_supercycle_triggers_tlv *htt_stats_buf =
5844b6dfc75SDinesh Karthikeyan tag_buf;
5854b6dfc75SDinesh Karthikeyan u8 *buf = stats_req->buf;
5864b6dfc75SDinesh Karthikeyan u32 len = stats_req->buf_len;
5874b6dfc75SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
5884b6dfc75SDinesh Karthikeyan u16 num_elems = min_t(u16, (tag_len >> 2),
5894b6dfc75SDinesh Karthikeyan ATH12K_HTT_SCHED_SUPERCYCLE_TRIGGER_MAX);
5904b6dfc75SDinesh Karthikeyan
5914b6dfc75SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
5924b6dfc75SDinesh Karthikeyan "HTT_SCHED_TXQ_SUPERCYCLE_TRIGGER:\n");
5934b6dfc75SDinesh Karthikeyan len += print_array_to_buf(buf, len, "supercycle_triggers",
5944b6dfc75SDinesh Karthikeyan htt_stats_buf->supercycle_triggers, num_elems, "\n\n");
5954b6dfc75SDinesh Karthikeyan
5964b6dfc75SDinesh Karthikeyan stats_req->buf_len = len;
5974b6dfc75SDinesh Karthikeyan }
5984b6dfc75SDinesh Karthikeyan
599cf1187b3SDinesh Karthikeyan static void
ath12k_htt_print_hw_stats_pdev_errs_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)600cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_stats_pdev_errs_tlv(const void *tag_buf, u16 tag_len,
601cf1187b3SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
602cf1187b3SDinesh Karthikeyan {
603cf1187b3SDinesh Karthikeyan const struct ath12k_htt_hw_stats_pdev_errs_tlv *htt_buf = tag_buf;
604cf1187b3SDinesh Karthikeyan u8 *buf = stats_req->buf;
605cf1187b3SDinesh Karthikeyan u32 len = stats_req->buf_len;
606cf1187b3SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
607cf1187b3SDinesh Karthikeyan u32 mac_id_word;
608cf1187b3SDinesh Karthikeyan
609cf1187b3SDinesh Karthikeyan if (tag_len < sizeof(*htt_buf))
610cf1187b3SDinesh Karthikeyan return;
611cf1187b3SDinesh Karthikeyan
612cf1187b3SDinesh Karthikeyan mac_id_word = le32_to_cpu(htt_buf->mac_id__word);
613cf1187b3SDinesh Karthikeyan
614cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_HW_STATS_PDEV_ERRS_TLV:\n");
615cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
616cf1187b3SDinesh Karthikeyan u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
617cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_abort = %u\n",
618cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->tx_abort));
619cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_abort_fail_count = %u\n",
620cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->tx_abort_fail_count));
621cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "rx_abort = %u\n",
622cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_abort));
623cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "rx_abort_fail_count = %u\n",
624cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_abort_fail_count));
625cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "rx_flush_cnt = %u\n",
626cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_flush_cnt));
627cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "warm_reset = %u\n",
628cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->warm_reset));
629cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "cold_reset = %u\n",
630cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->cold_reset));
631cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_cold_reset_restore_cal = %u\n",
632cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->mac_cold_reset_restore_cal));
633cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_cold_reset = %u\n",
634cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->mac_cold_reset));
635cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_warm_reset = %u\n",
636cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->mac_warm_reset));
637cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_only_reset = %u\n",
638cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->mac_only_reset));
639cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "phy_warm_reset = %u\n",
640cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset));
641cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_ucode_trig = %u\n",
642cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_ucode_trig));
643cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_warm_reset_restore_cal = %u\n",
644cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->mac_warm_reset_restore_cal));
645cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_sfm_reset = %u\n",
646cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->mac_sfm_reset));
647cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_m3_ssr = %u\n",
648cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_m3_ssr));
649cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fw_rx_rings_reset = %u\n",
650cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->fw_rx_rings_reset));
651cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_flush = %u\n",
652cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->tx_flush));
653cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_glb_reset = %u\n",
654cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->tx_glb_reset));
655cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tx_txq_reset = %u\n",
656cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->tx_txq_reset));
657cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "rx_timeout_reset = %u\n\n",
658cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_timeout_reset));
659cf1187b3SDinesh Karthikeyan
660cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "PDEV_PHY_WARM_RESET_REASONS:\n");
661cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "phy_warm_reset_reason_phy_m3 = %u\n",
662cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_phy_m3));
663cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
664cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_tx_hw_stuck = %u\n",
665cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_hw_stuck));
666cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
667cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_num_cca_rx_frame_stuck = %u\n",
668cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_num_rx_frame_stuck));
669cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
670cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_wal_rx_recovery_rst_rx_busy = %u\n",
671cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_wal_rx_rec_rx_busy));
672cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
673cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_wal_rx_recovery_rst_mac_hang = %u\n",
674cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_wal_rx_rec_mac_hng));
675cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
676cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_mac_reset_converted_phy_reset = %u\n",
677cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_mac_conv_phy_reset));
678cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
679cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_tx_lifetime_expiry_cca_stuck = %u\n",
680cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_exp_cca_stuck));
681cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
682cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_tx_consecutive_flush9_war = %u\n",
683cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_consec_flsh_war));
684cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
685cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_tx_hwsch_reset_war = %u\n",
686cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_tx_hwsch_reset_war));
687cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
688cf1187b3SDinesh Karthikeyan "phy_warm_reset_reason_hwsch_wdog_or_cca_wdog_war = %u\n\n",
689cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->phy_warm_reset_reason_hwsch_cca_wdog_war));
690cf1187b3SDinesh Karthikeyan
691cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "WAL_RX_RECOVERY_STATS:\n");
692cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
693cf1187b3SDinesh Karthikeyan "wal_rx_recovery_rst_mac_hang_count = %u\n",
694cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->wal_rx_recovery_rst_mac_hang_cnt));
695cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
696cf1187b3SDinesh Karthikeyan "wal_rx_recovery_rst_known_sig_count = %u\n",
697cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->wal_rx_recovery_rst_known_sig_cnt));
698cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
699cf1187b3SDinesh Karthikeyan "wal_rx_recovery_rst_no_rx_count = %u\n",
700cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->wal_rx_recovery_rst_no_rx_cnt));
701cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
702cf1187b3SDinesh Karthikeyan "wal_rx_recovery_rst_no_rx_consecutive_count = %u\n",
703cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->wal_rx_recovery_rst_no_rx_consec_cnt));
704cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
705cf1187b3SDinesh Karthikeyan "wal_rx_recovery_rst_rx_busy_count = %u\n",
706cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->wal_rx_recovery_rst_rx_busy_cnt));
707cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
708cf1187b3SDinesh Karthikeyan "wal_rx_recovery_rst_phy_mac_hang_count = %u\n\n",
709cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->wal_rx_recovery_rst_phy_mac_hang_cnt));
710cf1187b3SDinesh Karthikeyan
711cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_RX_DEST_DRAIN_STATS:\n");
712cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
713cf1187b3SDinesh Karthikeyan "rx_dest_drain_rx_descs_leak_prevention_done = %u\n",
714cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_rx_descs_leak_prevented));
715cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
716cf1187b3SDinesh Karthikeyan "rx_dest_drain_rx_descs_saved_cnt = %u\n",
717cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_rx_descs_saved_cnt));
718cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
719cf1187b3SDinesh Karthikeyan "rx_dest_drain_rxdma2reo_leak_detected = %u\n",
720cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_rxdma2reo_leak_detected));
721cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
722cf1187b3SDinesh Karthikeyan "rx_dest_drain_rxdma2fw_leak_detected = %u\n",
723cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_rxdma2fw_leak_detected));
724cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
725cf1187b3SDinesh Karthikeyan "rx_dest_drain_rxdma2wbm_leak_detected = %u\n",
726cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_rxdma2wbm_leak_detected));
727cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
728cf1187b3SDinesh Karthikeyan "rx_dest_drain_rxdma1_2sw_leak_detected = %u\n",
729cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_rxdma1_2sw_leak_detected));
730cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
731cf1187b3SDinesh Karthikeyan "rx_dest_drain_rx_drain_ok_mac_idle = %u\n",
732cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_rx_drain_ok_mac_idle));
733cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
734cf1187b3SDinesh Karthikeyan "rx_dest_drain_ok_mac_not_idle = %u\n",
735cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_ok_mac_not_idle));
736cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
737cf1187b3SDinesh Karthikeyan "rx_dest_drain_prerequisite_invld = %u\n",
738cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_prerequisite_invld));
739cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
740cf1187b3SDinesh Karthikeyan "rx_dest_drain_skip_for_non_lmac_reset = %u\n",
741cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_skip_non_lmac_reset));
742cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
743cf1187b3SDinesh Karthikeyan "rx_dest_drain_hw_fifo_not_empty_post_drain_wait = %u\n\n",
744cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_buf->rx_dest_drain_hw_fifo_notempty_post_wait));
745cf1187b3SDinesh Karthikeyan
746cf1187b3SDinesh Karthikeyan stats_req->buf_len = len;
747cf1187b3SDinesh Karthikeyan }
748cf1187b3SDinesh Karthikeyan
749cf1187b3SDinesh Karthikeyan static void
ath12k_htt_print_hw_stats_intr_misc_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)750cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_stats_intr_misc_tlv(const void *tag_buf, u16 tag_len,
751cf1187b3SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
752cf1187b3SDinesh Karthikeyan {
753cf1187b3SDinesh Karthikeyan const struct ath12k_htt_hw_stats_intr_misc_tlv *htt_stats_buf = tag_buf;
754cf1187b3SDinesh Karthikeyan u8 *buf = stats_req->buf;
755cf1187b3SDinesh Karthikeyan u32 len = stats_req->buf_len;
756cf1187b3SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
757cf1187b3SDinesh Karthikeyan
758cf1187b3SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
759cf1187b3SDinesh Karthikeyan return;
760cf1187b3SDinesh Karthikeyan
761cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_HW_STATS_INTR_MISC_TLV:\n");
762cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hw_intr_name = %s\n",
763cf1187b3SDinesh Karthikeyan htt_stats_buf->hw_intr_name);
764cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mask = %u\n",
765cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mask));
766cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "count = %u\n\n",
767cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->count));
768cf1187b3SDinesh Karthikeyan
769cf1187b3SDinesh Karthikeyan stats_req->buf_len = len;
770cf1187b3SDinesh Karthikeyan }
771cf1187b3SDinesh Karthikeyan
772cf1187b3SDinesh Karthikeyan static void
ath12k_htt_print_hw_stats_whal_tx_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)773cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_stats_whal_tx_tlv(const void *tag_buf, u16 tag_len,
774cf1187b3SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
775cf1187b3SDinesh Karthikeyan {
776cf1187b3SDinesh Karthikeyan const struct ath12k_htt_hw_stats_whal_tx_tlv *htt_stats_buf = tag_buf;
777cf1187b3SDinesh Karthikeyan u8 *buf = stats_req->buf;
778cf1187b3SDinesh Karthikeyan u32 len = stats_req->buf_len;
779cf1187b3SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
780cf1187b3SDinesh Karthikeyan u32 mac_id_word;
781cf1187b3SDinesh Karthikeyan
782cf1187b3SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
783cf1187b3SDinesh Karthikeyan return;
784cf1187b3SDinesh Karthikeyan
785cf1187b3SDinesh Karthikeyan mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
786cf1187b3SDinesh Karthikeyan
787cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_HW_STATS_WHAL_TX_TLV:\n");
788cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
789cf1187b3SDinesh Karthikeyan u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
790cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "last_unpause_ppdu_id = %u\n",
791cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->last_unpause_ppdu_id));
792cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_unpause_wait_tqm_write = %u\n",
793cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_unpause_wait_tqm_write));
794cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_dummy_tlv_skipped = %u\n",
795cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_dummy_tlv_skipped));
796cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
797cf1187b3SDinesh Karthikeyan "hwsch_misaligned_offset_received = %u\n",
798cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_misaligned_offset_received));
799cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_reset_count = %u\n",
800cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_reset_count));
801cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_dev_reset_war = %u\n",
802cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_dev_reset_war));
803cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_delayed_pause = %u\n",
804cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_delayed_pause));
805cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_long_delayed_pause = %u\n",
806cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_long_delayed_pause));
807cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sch_rx_ppdu_no_response = %u\n",
808cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sch_rx_ppdu_no_response));
809cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sch_selfgen_response = %u\n",
810cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sch_selfgen_response));
811cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sch_rx_sifs_resp_trigger= %u\n\n",
812cf1187b3SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sch_rx_sifs_resp_trigger));
813cf1187b3SDinesh Karthikeyan
814cf1187b3SDinesh Karthikeyan stats_req->buf_len = len;
815cf1187b3SDinesh Karthikeyan }
816cf1187b3SDinesh Karthikeyan
817cf1187b3SDinesh Karthikeyan static void
ath12k_htt_print_hw_war_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)818cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_war_tlv(const void *tag_buf, u16 tag_len,
819cf1187b3SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
820cf1187b3SDinesh Karthikeyan {
821cf1187b3SDinesh Karthikeyan const struct ath12k_htt_hw_war_stats_tlv *htt_stats_buf = tag_buf;
822cf1187b3SDinesh Karthikeyan u8 *buf = stats_req->buf;
823cf1187b3SDinesh Karthikeyan u32 len = stats_req->buf_len;
824cf1187b3SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
825cf1187b3SDinesh Karthikeyan u16 fixed_len, array_len;
826cf1187b3SDinesh Karthikeyan u8 i, array_words;
827cf1187b3SDinesh Karthikeyan u32 mac_id;
828cf1187b3SDinesh Karthikeyan
829cf1187b3SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
830cf1187b3SDinesh Karthikeyan return;
831cf1187b3SDinesh Karthikeyan
832cf1187b3SDinesh Karthikeyan mac_id = __le32_to_cpu(htt_stats_buf->mac_id__word);
833cf1187b3SDinesh Karthikeyan fixed_len = sizeof(*htt_stats_buf);
834cf1187b3SDinesh Karthikeyan array_len = tag_len - fixed_len;
835cf1187b3SDinesh Karthikeyan array_words = array_len >> 2;
836cf1187b3SDinesh Karthikeyan
837cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_HW_WAR_STATS_TLV:\n");
838cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
839cf1187b3SDinesh Karthikeyan u32_get_bits(mac_id, ATH12K_HTT_STATS_MAC_ID));
840cf1187b3SDinesh Karthikeyan
841cf1187b3SDinesh Karthikeyan for (i = 0; i < array_words; i++) {
842cf1187b3SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hw_war %u = %u\n\n",
843cf1187b3SDinesh Karthikeyan i, le32_to_cpu(htt_stats_buf->hw_wars[i]));
844cf1187b3SDinesh Karthikeyan }
845cf1187b3SDinesh Karthikeyan
846cf1187b3SDinesh Karthikeyan stats_req->buf_len = len;
847cf1187b3SDinesh Karthikeyan }
848cf1187b3SDinesh Karthikeyan
8495344fc76SDinesh Karthikeyan static void
ath12k_htt_print_tx_tqm_cmn_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)8505344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_cmn_stats_tlv(const void *tag_buf, u16 tag_len,
8515344fc76SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
8525344fc76SDinesh Karthikeyan {
8535344fc76SDinesh Karthikeyan const struct ath12k_htt_tx_tqm_cmn_stats_tlv *htt_stats_buf = tag_buf;
8545344fc76SDinesh Karthikeyan u8 *buf = stats_req->buf;
8555344fc76SDinesh Karthikeyan u32 len = stats_req->buf_len;
8565344fc76SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
8575344fc76SDinesh Karthikeyan u32 mac_id_word;
8585344fc76SDinesh Karthikeyan
8595344fc76SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
8605344fc76SDinesh Karthikeyan return;
8615344fc76SDinesh Karthikeyan
8625344fc76SDinesh Karthikeyan mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
8635344fc76SDinesh Karthikeyan
8645344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_CMN_STATS_TLV:\n");
8655344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
8665344fc76SDinesh Karthikeyan u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
8675344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "max_cmdq_id = %u\n",
8685344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->max_cmdq_id));
8695344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "list_mpdu_cnt_hist_intvl = %u\n",
8705344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->list_mpdu_cnt_hist_intvl));
8715344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "add_msdu = %u\n",
8725344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->add_msdu));
8735344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "q_empty = %u\n",
8745344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->q_empty));
8755344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "q_not_empty = %u\n",
8765344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->q_not_empty));
8775344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "drop_notification = %u\n",
8785344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->drop_notification));
8795344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "desc_threshold = %u\n",
8805344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->desc_threshold));
8815344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_tqm_invalid_status = %u\n",
8825344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_tqm_invalid_status));
8835344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "missed_tqm_gen_mpdus = %u\n",
8845344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->missed_tqm_gen_mpdus));
8855344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
8865344fc76SDinesh Karthikeyan "total_msduq_timestamp_updates = %u\n",
8875344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->msduq_timestamp_updates));
8885344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
8895344fc76SDinesh Karthikeyan "total_msduq_timestamp_updates_by_get_mpdu_head_info_cmd = %u\n",
8905344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->msduq_updates_mpdu_head_info_cmd));
8915344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
8925344fc76SDinesh Karthikeyan "total_msduq_timestamp_updates_by_emp_to_nonemp_status = %u\n",
8935344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->msduq_updates_emp_to_nonemp_status));
8945344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
8955344fc76SDinesh Karthikeyan "total_get_mpdu_head_info_cmds_by_sched_algo_la_query = %u\n",
8965344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->get_mpdu_head_info_cmds_by_query));
8975344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
8985344fc76SDinesh Karthikeyan "total_get_mpdu_head_info_cmds_by_tac = %u\n",
8995344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->get_mpdu_head_info_cmds_by_tac));
9005344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9015344fc76SDinesh Karthikeyan "total_gen_mpdu_cmds_by_sched_algo_la_query = %u\n",
9025344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->gen_mpdu_cmds_by_query));
9035344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "active_tqm_tids = %u\n",
9045344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_active_tids));
9055344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "inactive_tqm_tids = %u\n",
9065344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_inactive_tids));
9075344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_active_msduq_flows = %u\n",
9085344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_active_msduq_flows));
9095344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hi_prio_q_not_empty = %u\n\n",
9105344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->high_prio_q_not_empty));
9115344fc76SDinesh Karthikeyan
9125344fc76SDinesh Karthikeyan stats_req->buf_len = len;
9135344fc76SDinesh Karthikeyan }
9145344fc76SDinesh Karthikeyan
9155344fc76SDinesh Karthikeyan static void
ath12k_htt_print_tx_tqm_error_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)9165344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_error_stats_tlv(const void *tag_buf, u16 tag_len,
9175344fc76SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
9185344fc76SDinesh Karthikeyan {
9195344fc76SDinesh Karthikeyan const struct ath12k_htt_tx_tqm_error_stats_tlv *htt_stats_buf = tag_buf;
9205344fc76SDinesh Karthikeyan u8 *buf = stats_req->buf;
9215344fc76SDinesh Karthikeyan u32 len = stats_req->buf_len;
9225344fc76SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
9235344fc76SDinesh Karthikeyan
9245344fc76SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
9255344fc76SDinesh Karthikeyan return;
9265344fc76SDinesh Karthikeyan
9275344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_ERROR_STATS_TLV:\n");
9285344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "q_empty_failure = %u\n",
9295344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->q_empty_failure));
9305344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "q_not_empty_failure = %u\n",
9315344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->q_not_empty_failure));
9325344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "add_msdu_failure = %u\n\n",
9335344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->add_msdu_failure));
9345344fc76SDinesh Karthikeyan
9355344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "TQM_ERROR_RESET_STATS:\n");
9365344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_cache_ctl_err = %u\n",
9375344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_cache_ctl_err));
9385344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_soft_reset = %u\n",
9395344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_soft_reset));
9405344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9415344fc76SDinesh Karthikeyan "tqm_reset_total_num_in_use_link_descs = %u\n",
9425344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_num_in_use_link_descs));
9435344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9445344fc76SDinesh Karthikeyan "tqm_reset_worst_case_num_lost_link_descs = %u\n",
9455344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_num_lost_link_descs));
9465344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9475344fc76SDinesh Karthikeyan "tqm_reset_worst_case_num_lost_host_tx_bufs_count = %u\n",
9485344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_num_lost_host_tx_buf_cnt));
9495344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9505344fc76SDinesh Karthikeyan "tqm_reset_num_in_use_link_descs_internal_tqm = %u\n",
9515344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_num_in_use_internal_tqm));
9525344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9535344fc76SDinesh Karthikeyan "tqm_reset_num_in_use_link_descs_wbm_idle_link_ring = %u\n",
9545344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_num_in_use_idle_link_rng));
9555344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9565344fc76SDinesh Karthikeyan "tqm_reset_time_to_tqm_hang_delta_ms = %u\n",
9575344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_time_to_tqm_hang_delta_ms));
9585344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_reset_recovery_time_ms = %u\n",
9595344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_recovery_time_ms));
9605344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_reset_num_peers_hdl = %u\n",
9615344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_num_peers_hdl));
9625344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9635344fc76SDinesh Karthikeyan "tqm_reset_cumm_dirty_hw_mpduq_proc_cnt = %u\n",
9645344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_cumm_dirty_hw_mpduq_cnt));
9655344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9665344fc76SDinesh Karthikeyan "tqm_reset_cumm_dirty_hw_msduq_proc = %u\n",
9675344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_cumm_dirty_hw_msduq_proc));
9685344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9695344fc76SDinesh Karthikeyan "tqm_reset_flush_cache_cmd_su_cnt = %u\n",
9705344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_su_cnt));
9715344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9725344fc76SDinesh Karthikeyan "tqm_reset_flush_cache_cmd_other_cnt = %u\n",
9735344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_other_cnt));
9745344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9755344fc76SDinesh Karthikeyan "tqm_reset_flush_cache_cmd_trig_type = %u\n",
9765344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_trig_type));
9775344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9785344fc76SDinesh Karthikeyan "tqm_reset_flush_cache_cmd_trig_cfg = %u\n",
9795344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_flush_cache_cmd_trig_cfg));
9805344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
9815344fc76SDinesh Karthikeyan "tqm_reset_flush_cache_cmd_skip_cmd_status_null = %u\n\n",
9825344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_reset_flush_cmd_skp_status_null));
9835344fc76SDinesh Karthikeyan
9845344fc76SDinesh Karthikeyan stats_req->buf_len = len;
9855344fc76SDinesh Karthikeyan }
9865344fc76SDinesh Karthikeyan
9875344fc76SDinesh Karthikeyan 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)9885344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_gen_mpdu_stats_tlv(const void *tag_buf, u16 tag_len,
9895344fc76SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
9905344fc76SDinesh Karthikeyan {
9915344fc76SDinesh Karthikeyan const struct ath12k_htt_tx_tqm_gen_mpdu_stats_tlv *htt_stats_buf = tag_buf;
9925344fc76SDinesh Karthikeyan u8 *buf = stats_req->buf;
9935344fc76SDinesh Karthikeyan u32 len = stats_req->buf_len;
9945344fc76SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
9955344fc76SDinesh Karthikeyan u16 num_elements = tag_len >> 2;
9965344fc76SDinesh Karthikeyan
9975344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_GEN_MPDU_STATS_TLV:\n");
9985344fc76SDinesh Karthikeyan len += print_array_to_buf(buf, len, "gen_mpdu_end_reason",
9995344fc76SDinesh Karthikeyan htt_stats_buf->gen_mpdu_end_reason, num_elements,
10005344fc76SDinesh Karthikeyan "\n\n");
10015344fc76SDinesh Karthikeyan
10025344fc76SDinesh Karthikeyan stats_req->buf_len = len;
10035344fc76SDinesh Karthikeyan }
10045344fc76SDinesh Karthikeyan
10055344fc76SDinesh Karthikeyan 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)10065344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_list_mpdu_stats_tlv(const void *tag_buf, u16 tag_len,
10075344fc76SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
10085344fc76SDinesh Karthikeyan {
10095344fc76SDinesh Karthikeyan const struct ath12k_htt_tx_tqm_list_mpdu_stats_tlv *htt_stats_buf = tag_buf;
10105344fc76SDinesh Karthikeyan u8 *buf = stats_req->buf;
10115344fc76SDinesh Karthikeyan u32 len = stats_req->buf_len;
10125344fc76SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
10135344fc76SDinesh Karthikeyan u16 num_elems = min_t(u16, (tag_len >> 2),
10145344fc76SDinesh Karthikeyan ATH12K_HTT_TX_TQM_MAX_LIST_MPDU_END_REASON);
10155344fc76SDinesh Karthikeyan
10165344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_LIST_MPDU_STATS_TLV:\n");
10175344fc76SDinesh Karthikeyan len += print_array_to_buf(buf, len, "list_mpdu_end_reason",
10185344fc76SDinesh Karthikeyan htt_stats_buf->list_mpdu_end_reason, num_elems, "\n\n");
10195344fc76SDinesh Karthikeyan
10205344fc76SDinesh Karthikeyan stats_req->buf_len = len;
10215344fc76SDinesh Karthikeyan }
10225344fc76SDinesh Karthikeyan
10235344fc76SDinesh Karthikeyan 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)10245344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_list_mpdu_cnt_tlv(const void *tag_buf, u16 tag_len,
10255344fc76SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
10265344fc76SDinesh Karthikeyan {
10275344fc76SDinesh Karthikeyan const struct ath12k_htt_tx_tqm_list_mpdu_cnt_tlv *htt_stats_buf = tag_buf;
10285344fc76SDinesh Karthikeyan u8 *buf = stats_req->buf;
10295344fc76SDinesh Karthikeyan u32 len = stats_req->buf_len;
10305344fc76SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
10315344fc76SDinesh Karthikeyan u16 num_elems = min_t(u16, (tag_len >> 2),
10325344fc76SDinesh Karthikeyan ATH12K_HTT_TX_TQM_MAX_LIST_MPDU_CNT_HISTOGRAM_BINS);
10335344fc76SDinesh Karthikeyan
10345344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_LIST_MPDU_CNT_TLV_V:\n");
10355344fc76SDinesh Karthikeyan len += print_array_to_buf(buf, len, "list_mpdu_cnt_hist",
10365344fc76SDinesh Karthikeyan htt_stats_buf->list_mpdu_cnt_hist, num_elems, "\n\n");
10375344fc76SDinesh Karthikeyan
10385344fc76SDinesh Karthikeyan stats_req->buf_len = len;
10395344fc76SDinesh Karthikeyan }
10405344fc76SDinesh Karthikeyan
10415344fc76SDinesh Karthikeyan static void
ath12k_htt_print_tx_tqm_pdev_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)10425344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_pdev_stats_tlv(const void *tag_buf, u16 tag_len,
10435344fc76SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
10445344fc76SDinesh Karthikeyan {
10455344fc76SDinesh Karthikeyan const struct ath12k_htt_tx_tqm_pdev_stats_tlv *htt_stats_buf = tag_buf;
10465344fc76SDinesh Karthikeyan u8 *buf = stats_req->buf;
10475344fc76SDinesh Karthikeyan u32 len = stats_req->buf_len;
10485344fc76SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
10495344fc76SDinesh Karthikeyan
10505344fc76SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
10515344fc76SDinesh Karthikeyan return;
10525344fc76SDinesh Karthikeyan
10535344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_TQM_PDEV_STATS_TLV_V:\n");
10545344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "msdu_count = %u\n",
10555344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->msdu_count));
10565344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_count = %u\n",
10575344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_count));
10585344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_msdu = %u\n",
10595344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_msdu));
10605344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_mpdu = %u\n",
10615344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_mpdu));
10625344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_msdu_ttl = %u\n",
10635344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_msdu_ttl));
10645344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "send_bar = %u\n",
10655344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->send_bar));
10665344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "bar_sync = %u\n",
10675344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->bar_sync));
10685344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "notify_mpdu = %u\n",
10695344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->notify_mpdu));
10705344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sync_cmd = %u\n",
10715344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sync_cmd));
10725344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "write_cmd = %u\n",
10735344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->write_cmd));
10745344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "hwsch_trigger = %u\n",
10755344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->hwsch_trigger));
10765344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ack_tlv_proc = %u\n",
10775344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ack_tlv_proc));
10785344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "gen_mpdu_cmd = %u\n",
10795344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->gen_mpdu_cmd));
10805344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "gen_list_cmd = %u\n",
10815344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->gen_list_cmd));
10825344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_mpdu_cmd = %u\n",
10835344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_mpdu_cmd));
10845344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_mpdu_tried_cmd = %u\n",
10855344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_mpdu_tried_cmd));
10865344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_queue_stats_cmd = %u\n",
10875344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_queue_stats_cmd));
10885344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mpdu_head_info_cmd = %u\n",
10895344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mpdu_head_info_cmd));
10905344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "msdu_flow_stats_cmd = %u\n",
10915344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->msdu_flow_stats_cmd));
10925344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_msdu_cmd = %u\n",
10935344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_msdu_cmd));
10945344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "remove_msdu_ttl_cmd = %u\n",
10955344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->remove_msdu_ttl_cmd));
10965344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "flush_cache_cmd = %u\n",
10975344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->flush_cache_cmd));
10985344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "update_mpduq_cmd = %u\n",
10995344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->update_mpduq_cmd));
11005344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "enqueue = %u\n",
11015344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->enqueue));
11025344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "enqueue_notify = %u\n",
11035344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->enqueue_notify));
11045344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "notify_mpdu_at_head = %u\n",
11055344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->notify_mpdu_at_head));
11065344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "notify_mpdu_state_valid = %u\n",
11075344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->notify_mpdu_state_valid));
11085344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_udp_notify1 = %u\n",
11095344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_udp_notify1));
11105344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_udp_notify2 = %u\n",
11115344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_udp_notify2));
11125344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_nonudp_notify1 = %u\n",
11135344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_nonudp_notify1));
11145344fc76SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sched_nonudp_notify2 = %u\n\n",
11155344fc76SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sched_nonudp_notify2));
11165344fc76SDinesh Karthikeyan
11175344fc76SDinesh Karthikeyan stats_req->buf_len = len;
11185344fc76SDinesh Karthikeyan }
11195344fc76SDinesh Karthikeyan
1120*04aee7a8SDinesh Karthikeyan static void
ath12k_htt_print_tx_de_cmn_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1121*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_cmn_stats_tlv(const void *tag_buf, u16 tag_len,
1122*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1123*04aee7a8SDinesh Karthikeyan {
1124*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_cmn_stats_tlv *htt_stats_buf = tag_buf;
1125*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1126*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1127*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1128*04aee7a8SDinesh Karthikeyan u32 mac_id_word;
1129*04aee7a8SDinesh Karthikeyan
1130*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1131*04aee7a8SDinesh Karthikeyan return;
1132*04aee7a8SDinesh Karthikeyan
1133*04aee7a8SDinesh Karthikeyan mac_id_word = __le32_to_cpu(htt_stats_buf->mac_id__word);
1134*04aee7a8SDinesh Karthikeyan
1135*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_DE_CMN_STATS_TLV:\n");
1136*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mac_id = %u\n",
1137*04aee7a8SDinesh Karthikeyan u32_get_bits(mac_id_word, ATH12K_HTT_STATS_MAC_ID));
1138*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tcl2fw_entry_count = %u\n",
1139*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tcl2fw_entry_count));
1140*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "not_to_fw = %u\n",
1141*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->not_to_fw));
1142*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "invalid_pdev_vdev_peer = %u\n",
1143*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->invalid_pdev_vdev_peer));
1144*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tcl_res_invalid_addrx = %u\n",
1145*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tcl_res_invalid_addrx));
1146*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "wbm2fw_entry_count = %u\n",
1147*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->wbm2fw_entry_count));
1148*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "invalid_pdev = %u\n",
1149*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->invalid_pdev));
1150*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tcl_res_addrx_timeout = %u\n",
1151*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tcl_res_addrx_timeout));
1152*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "invalid_vdev = %u\n",
1153*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->invalid_vdev));
1154*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "invalid_tcl_exp_frame_desc = %u\n",
1155*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->invalid_tcl_exp_frame_desc));
1156*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "vdev_id_mismatch_count = %u\n\n",
1157*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->vdev_id_mismatch_cnt));
1158*04aee7a8SDinesh Karthikeyan
1159*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1160*04aee7a8SDinesh Karthikeyan }
1161*04aee7a8SDinesh Karthikeyan
1162*04aee7a8SDinesh Karthikeyan 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)1163*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_eapol_packets_stats_tlv(const void *tag_buf, u16 tag_len,
1164*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1165*04aee7a8SDinesh Karthikeyan {
1166*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_eapol_packets_stats_tlv *htt_stats_buf = tag_buf;
1167*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1168*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1169*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1170*04aee7a8SDinesh Karthikeyan
1171*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1172*04aee7a8SDinesh Karthikeyan return;
1173*04aee7a8SDinesh Karthikeyan
1174*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
1175*04aee7a8SDinesh Karthikeyan "HTT_TX_DE_EAPOL_PACKETS_STATS_TLV:\n");
1176*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "m1_packets = %u\n",
1177*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->m1_packets));
1178*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "m2_packets = %u\n",
1179*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->m2_packets));
1180*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "m3_packets = %u\n",
1181*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->m3_packets));
1182*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "m4_packets = %u\n",
1183*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->m4_packets));
1184*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "g1_packets = %u\n",
1185*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->g1_packets));
1186*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "g2_packets = %u\n",
1187*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->g2_packets));
1188*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "rc4_packets = %u\n",
1189*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->rc4_packets));
1190*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eap_packets = %u\n",
1191*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eap_packets));
1192*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eapol_start_packets = %u\n",
1193*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eapol_start_packets));
1194*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eapol_logoff_packets = %u\n",
1195*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eapol_logoff_packets));
1196*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eapol_encap_asf_packets = %u\n\n",
1197*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eapol_encap_asf_packets));
1198*04aee7a8SDinesh Karthikeyan
1199*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1200*04aee7a8SDinesh Karthikeyan }
1201*04aee7a8SDinesh Karthikeyan
1202*04aee7a8SDinesh Karthikeyan static void
ath12k_htt_print_tx_de_classify_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1203*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_classify_stats_tlv(const void *tag_buf, u16 tag_len,
1204*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1205*04aee7a8SDinesh Karthikeyan {
1206*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_classify_stats_tlv *htt_stats_buf = tag_buf;
1207*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1208*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1209*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1210*04aee7a8SDinesh Karthikeyan
1211*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1212*04aee7a8SDinesh Karthikeyan return;
1213*04aee7a8SDinesh Karthikeyan
1214*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_DE_CLASSIFY_STATS_TLV:\n");
1215*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "arp_packets = %u\n",
1216*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->arp_packets));
1217*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "igmp_packets = %u\n",
1218*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->igmp_packets));
1219*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "dhcp_packets = %u\n",
1220*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->dhcp_packets));
1221*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "host_inspected = %u\n",
1222*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->host_inspected));
1223*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_included = %u\n",
1224*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_included));
1225*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_mcs = %u\n",
1226*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_mcs));
1227*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_nss = %u\n",
1228*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_nss));
1229*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_preamble_type = %u\n",
1230*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_preamble_type));
1231*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_chainmask = %u\n",
1232*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_chainmask));
1233*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_guard_interval = %u\n",
1234*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_guard_interval));
1235*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_retries = %u\n",
1236*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_retries));
1237*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_bw_info = %u\n",
1238*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_bw_info));
1239*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_power = %u\n",
1240*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_power));
1241*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_key_flags = 0x%x\n",
1242*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_key_flags));
1243*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_valid_no_encryption = %u\n",
1244*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_valid_no_encryption));
1245*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_entry_count = %u\n",
1246*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_entry_count));
1247*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_priority_be = %u\n",
1248*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_priority_be));
1249*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_priority_high = %u\n",
1250*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_priority_high));
1251*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_priority_low = %u\n",
1252*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_priority_low));
1253*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_be = %u\n",
1254*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_be));
1255*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_over_sub = %u\n",
1256*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_over_sub));
1257*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_bursty = %u\n",
1258*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_bursty));
1259*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_interactive = %u\n",
1260*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_interactive));
1261*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_traffic_ptrn_periodic = %u\n",
1262*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_traffic_ptrn_periodic));
1263*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_hwqueue_alloc = %u\n",
1264*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_hwqueue_alloc));
1265*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_hwqueue_created = %u\n",
1266*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_hwqueue_created));
1267*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_hwqueue_send_to_host = %u\n",
1268*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_hwqueue_send_to_host));
1269*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mcast_entry = %u\n",
1270*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mcast_entry));
1271*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "bcast_entry = %u\n",
1272*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->bcast_entry));
1273*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_update_peer_cache = %u\n",
1274*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_update_peer_cache));
1275*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "htt_learning_frame = %u\n",
1276*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->htt_learning_frame));
1277*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_invalid_peer = %u\n",
1278*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_invalid_peer));
1279*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "mec_notify = %u\n\n",
1280*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->mec_notify));
1281*04aee7a8SDinesh Karthikeyan
1282*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1283*04aee7a8SDinesh Karthikeyan }
1284*04aee7a8SDinesh Karthikeyan
1285*04aee7a8SDinesh Karthikeyan 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)1286*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_classify_failed_stats_tlv(const void *tag_buf, u16 tag_len,
1287*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1288*04aee7a8SDinesh Karthikeyan {
1289*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_classify_failed_stats_tlv *htt_stats_buf = tag_buf;
1290*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1291*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1292*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1293*04aee7a8SDinesh Karthikeyan
1294*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1295*04aee7a8SDinesh Karthikeyan return;
1296*04aee7a8SDinesh Karthikeyan
1297*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
1298*04aee7a8SDinesh Karthikeyan "HTT_TX_DE_CLASSIFY_FAILED_STATS_TLV:\n");
1299*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ap_bss_peer_not_found = %u\n",
1300*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ap_bss_peer_not_found));
1301*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ap_bcast_mcast_no_peer = %u\n",
1302*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ap_bcast_mcast_no_peer));
1303*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "sta_delete_in_progress = %u\n",
1304*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->sta_delete_in_progress));
1305*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ibss_no_bss_peer = %u\n",
1306*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ibss_no_bss_peer));
1307*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "invalid_vdev_type = %u\n",
1308*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->invalid_vdev_type));
1309*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "invalid_ast_peer_entry = %u\n",
1310*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->invalid_ast_peer_entry));
1311*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "peer_entry_invalid = %u\n",
1312*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->peer_entry_invalid));
1313*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ethertype_not_ip = %u\n",
1314*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ethertype_not_ip));
1315*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eapol_lookup_failed = %u\n",
1316*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eapol_lookup_failed));
1317*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "qpeer_not_allow_data = %u\n",
1318*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->qpeer_not_allow_data));
1319*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fse_tid_override = %u\n",
1320*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fse_tid_override));
1321*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ipv6_jumbogram_zero_length = %u\n",
1322*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ipv6_jumbogram_zero_length));
1323*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "qos_to_non_qos_in_prog = %u\n",
1324*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->qos_to_non_qos_in_prog));
1325*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ap_bcast_mcast_eapol = %u\n",
1326*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ap_bcast_mcast_eapol));
1327*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "unicast_on_ap_bss_peer = %u\n",
1328*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->unicast_on_ap_bss_peer));
1329*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "ap_vdev_invalid = %u\n",
1330*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->ap_vdev_invalid));
1331*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "incomplete_llc = %u\n",
1332*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->incomplete_llc));
1333*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eapol_duplicate_m3 = %u\n",
1334*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eapol_duplicate_m3));
1335*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eapol_duplicate_m4 = %u\n\n",
1336*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eapol_duplicate_m4));
1337*04aee7a8SDinesh Karthikeyan
1338*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1339*04aee7a8SDinesh Karthikeyan }
1340*04aee7a8SDinesh Karthikeyan
1341*04aee7a8SDinesh Karthikeyan 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)1342*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_classify_status_stats_tlv(const void *tag_buf, u16 tag_len,
1343*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1344*04aee7a8SDinesh Karthikeyan {
1345*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_classify_status_stats_tlv *htt_stats_buf = tag_buf;
1346*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1347*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1348*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1349*04aee7a8SDinesh Karthikeyan
1350*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1351*04aee7a8SDinesh Karthikeyan return;
1352*04aee7a8SDinesh Karthikeyan
1353*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
1354*04aee7a8SDinesh Karthikeyan "HTT_TX_DE_CLASSIFY_STATUS_STATS_TLV:\n");
1355*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "eok = %u\n",
1356*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->eok));
1357*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "classify_done = %u\n",
1358*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->classify_done));
1359*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "lookup_failed = %u\n",
1360*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->lookup_failed));
1361*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "send_host_dhcp = %u\n",
1362*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->send_host_dhcp));
1363*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "send_host_mcast = %u\n",
1364*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->send_host_mcast));
1365*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "send_host_unknown_dest = %u\n",
1366*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->send_host_unknown_dest));
1367*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "send_host = %u\n",
1368*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->send_host));
1369*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "status_invalid = %u\n\n",
1370*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->status_invalid));
1371*04aee7a8SDinesh Karthikeyan
1372*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1373*04aee7a8SDinesh Karthikeyan }
1374*04aee7a8SDinesh Karthikeyan
1375*04aee7a8SDinesh Karthikeyan 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)1376*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_enqueue_packets_stats_tlv(const void *tag_buf, u16 tag_len,
1377*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1378*04aee7a8SDinesh Karthikeyan {
1379*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_enqueue_packets_stats_tlv *htt_stats_buf = tag_buf;
1380*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1381*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1382*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1383*04aee7a8SDinesh Karthikeyan
1384*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1385*04aee7a8SDinesh Karthikeyan return;
1386*04aee7a8SDinesh Karthikeyan
1387*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
1388*04aee7a8SDinesh Karthikeyan "HTT_TX_DE_ENQUEUE_PACKETS_STATS_TLV:\n");
1389*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "enqueued_pkts = %u\n",
1390*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->enqueued_pkts));
1391*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "to_tqm = %u\n",
1392*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->to_tqm));
1393*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "to_tqm_bypass = %u\n\n",
1394*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->to_tqm_bypass));
1395*04aee7a8SDinesh Karthikeyan
1396*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1397*04aee7a8SDinesh Karthikeyan }
1398*04aee7a8SDinesh Karthikeyan
1399*04aee7a8SDinesh Karthikeyan 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)1400*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_enqueue_discard_stats_tlv(const void *tag_buf, u16 tag_len,
1401*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1402*04aee7a8SDinesh Karthikeyan {
1403*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_enqueue_discard_stats_tlv *htt_stats_buf = tag_buf;
1404*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1405*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1406*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1407*04aee7a8SDinesh Karthikeyan
1408*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1409*04aee7a8SDinesh Karthikeyan return;
1410*04aee7a8SDinesh Karthikeyan
1411*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len,
1412*04aee7a8SDinesh Karthikeyan "HTT_TX_DE_ENQUEUE_DISCARD_STATS_TLV:\n");
1413*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "discarded_pkts = %u\n",
1414*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->discarded_pkts));
1415*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "local_frames = %u\n",
1416*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->local_frames));
1417*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "is_ext_msdu = %u\n\n",
1418*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->is_ext_msdu));
1419*04aee7a8SDinesh Karthikeyan
1420*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1421*04aee7a8SDinesh Karthikeyan }
1422*04aee7a8SDinesh Karthikeyan
1423*04aee7a8SDinesh Karthikeyan static void
ath12k_htt_print_tx_de_compl_stats_tlv(const void * tag_buf,u16 tag_len,struct debug_htt_stats_req * stats_req)1424*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_compl_stats_tlv(const void *tag_buf, u16 tag_len,
1425*04aee7a8SDinesh Karthikeyan struct debug_htt_stats_req *stats_req)
1426*04aee7a8SDinesh Karthikeyan {
1427*04aee7a8SDinesh Karthikeyan const struct ath12k_htt_tx_de_compl_stats_tlv *htt_stats_buf = tag_buf;
1428*04aee7a8SDinesh Karthikeyan u8 *buf = stats_req->buf;
1429*04aee7a8SDinesh Karthikeyan u32 len = stats_req->buf_len;
1430*04aee7a8SDinesh Karthikeyan u32 buf_len = ATH12K_HTT_STATS_BUF_SIZE;
1431*04aee7a8SDinesh Karthikeyan
1432*04aee7a8SDinesh Karthikeyan if (tag_len < sizeof(*htt_stats_buf))
1433*04aee7a8SDinesh Karthikeyan return;
1434*04aee7a8SDinesh Karthikeyan
1435*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "HTT_TX_DE_COMPL_STATS_TLV:\n");
1436*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tcl_dummy_frame = %u\n",
1437*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tcl_dummy_frame));
1438*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_dummy_frame = %u\n",
1439*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_dummy_frame));
1440*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_notify_frame = %u\n",
1441*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_notify_frame));
1442*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "fw2wbm_enq = %u\n",
1443*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->fw2wbm_enq));
1444*04aee7a8SDinesh Karthikeyan len += scnprintf(buf + len, buf_len - len, "tqm_bypass_frame = %u\n\n",
1445*04aee7a8SDinesh Karthikeyan le32_to_cpu(htt_stats_buf->tqm_bypass_frame));
1446*04aee7a8SDinesh Karthikeyan
1447*04aee7a8SDinesh Karthikeyan stats_req->buf_len = len;
1448*04aee7a8SDinesh Karthikeyan }
1449*04aee7a8SDinesh Karthikeyan
ath12k_dbg_htt_ext_stats_parse(struct ath12k_base * ab,u16 tag,u16 len,const void * tag_buf,void * user_data)1450adf6df96SDinesh Karthikeyan static int ath12k_dbg_htt_ext_stats_parse(struct ath12k_base *ab,
1451adf6df96SDinesh Karthikeyan u16 tag, u16 len, const void *tag_buf,
1452adf6df96SDinesh Karthikeyan void *user_data)
1453adf6df96SDinesh Karthikeyan {
1454adf6df96SDinesh Karthikeyan struct debug_htt_stats_req *stats_req = user_data;
1455adf6df96SDinesh Karthikeyan
1456adf6df96SDinesh Karthikeyan switch (tag) {
1457adf6df96SDinesh Karthikeyan case HTT_STATS_TX_PDEV_CMN_TAG:
1458adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_cmn_tlv(tag_buf, len, stats_req);
1459adf6df96SDinesh Karthikeyan break;
1460adf6df96SDinesh Karthikeyan case HTT_STATS_TX_PDEV_UNDERRUN_TAG:
1461adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_urrn_tlv(tag_buf, len, stats_req);
1462adf6df96SDinesh Karthikeyan break;
1463adf6df96SDinesh Karthikeyan case HTT_STATS_TX_PDEV_SIFS_TAG:
1464adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_sifs_tlv(tag_buf, len, stats_req);
1465adf6df96SDinesh Karthikeyan break;
1466adf6df96SDinesh Karthikeyan case HTT_STATS_TX_PDEV_FLUSH_TAG:
1467adf6df96SDinesh Karthikeyan htt_print_tx_pdev_stats_flush_tlv(tag_buf, len, stats_req);
1468adf6df96SDinesh Karthikeyan break;
1469a9f2976fSRamya Gnanasekar case HTT_STATS_TX_PDEV_SIFS_HIST_TAG:
1470a9f2976fSRamya Gnanasekar htt_print_tx_pdev_stats_sifs_hist_tlv(tag_buf, len, stats_req);
1471a9f2976fSRamya Gnanasekar break;
1472a9f2976fSRamya Gnanasekar case HTT_STATS_PDEV_CTRL_PATH_TX_STATS_TAG:
1473a9f2976fSRamya Gnanasekar htt_print_pdev_ctrl_path_tx_stats_tlv(tag_buf, len, stats_req);
1474a9f2976fSRamya Gnanasekar break;
1475a9f2976fSRamya Gnanasekar case HTT_STATS_MU_PPDU_DIST_TAG:
1476a9f2976fSRamya Gnanasekar htt_print_tx_pdev_mu_ppdu_dist_stats_tlv(tag_buf, len, stats_req);
1477a9f2976fSRamya Gnanasekar break;
14784b6dfc75SDinesh Karthikeyan case HTT_STATS_TX_SCHED_CMN_TAG:
14794b6dfc75SDinesh Karthikeyan ath12k_htt_print_stats_tx_sched_cmn_tlv(tag_buf, len, stats_req);
14804b6dfc75SDinesh Karthikeyan break;
14814b6dfc75SDinesh Karthikeyan case HTT_STATS_TX_PDEV_SCHEDULER_TXQ_STATS_TAG:
14824b6dfc75SDinesh Karthikeyan ath12k_htt_print_tx_pdev_stats_sched_per_txq_tlv(tag_buf, len, stats_req);
14834b6dfc75SDinesh Karthikeyan break;
14844b6dfc75SDinesh Karthikeyan case HTT_STATS_SCHED_TXQ_CMD_POSTED_TAG:
14854b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_cmd_posted_tlv(tag_buf, len, stats_req);
14864b6dfc75SDinesh Karthikeyan break;
14874b6dfc75SDinesh Karthikeyan case HTT_STATS_SCHED_TXQ_CMD_REAPED_TAG:
14884b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_cmd_reaped_tlv(tag_buf, len, stats_req);
14894b6dfc75SDinesh Karthikeyan break;
14904b6dfc75SDinesh Karthikeyan case HTT_STATS_SCHED_TXQ_SCHED_ORDER_SU_TAG:
14914b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_sched_order_su_tlv(tag_buf, len, stats_req);
14924b6dfc75SDinesh Karthikeyan break;
14934b6dfc75SDinesh Karthikeyan case HTT_STATS_SCHED_TXQ_SCHED_INELIGIBILITY_TAG:
14944b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_sched_ineligibility_tlv(tag_buf, len,
14954b6dfc75SDinesh Karthikeyan stats_req);
14964b6dfc75SDinesh Karthikeyan break;
14974b6dfc75SDinesh Karthikeyan case HTT_STATS_SCHED_TXQ_SUPERCYCLE_TRIGGER_TAG:
14984b6dfc75SDinesh Karthikeyan ath12k_htt_print_sched_txq_supercycle_trigger_tlv(tag_buf, len,
14994b6dfc75SDinesh Karthikeyan stats_req);
15004b6dfc75SDinesh Karthikeyan break;
1501cf1187b3SDinesh Karthikeyan case HTT_STATS_HW_PDEV_ERRS_TAG:
1502cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_stats_pdev_errs_tlv(tag_buf, len, stats_req);
1503cf1187b3SDinesh Karthikeyan break;
1504cf1187b3SDinesh Karthikeyan case HTT_STATS_HW_INTR_MISC_TAG:
1505cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_stats_intr_misc_tlv(tag_buf, len, stats_req);
1506cf1187b3SDinesh Karthikeyan break;
1507cf1187b3SDinesh Karthikeyan case HTT_STATS_WHAL_TX_TAG:
1508cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_stats_whal_tx_tlv(tag_buf, len, stats_req);
1509cf1187b3SDinesh Karthikeyan break;
1510cf1187b3SDinesh Karthikeyan case HTT_STATS_HW_WAR_TAG:
1511cf1187b3SDinesh Karthikeyan ath12k_htt_print_hw_war_tlv(tag_buf, len, stats_req);
1512cf1187b3SDinesh Karthikeyan break;
15135344fc76SDinesh Karthikeyan case HTT_STATS_TX_TQM_CMN_TAG:
15145344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_cmn_stats_tlv(tag_buf, len, stats_req);
15155344fc76SDinesh Karthikeyan break;
15165344fc76SDinesh Karthikeyan case HTT_STATS_TX_TQM_ERROR_STATS_TAG:
15175344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_error_stats_tlv(tag_buf, len, stats_req);
15185344fc76SDinesh Karthikeyan break;
15195344fc76SDinesh Karthikeyan case HTT_STATS_TX_TQM_GEN_MPDU_TAG:
15205344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_gen_mpdu_stats_tlv(tag_buf, len, stats_req);
15215344fc76SDinesh Karthikeyan break;
15225344fc76SDinesh Karthikeyan case HTT_STATS_TX_TQM_LIST_MPDU_TAG:
15235344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_list_mpdu_stats_tlv(tag_buf, len, stats_req);
15245344fc76SDinesh Karthikeyan break;
15255344fc76SDinesh Karthikeyan case HTT_STATS_TX_TQM_LIST_MPDU_CNT_TAG:
15265344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_list_mpdu_cnt_tlv(tag_buf, len, stats_req);
15275344fc76SDinesh Karthikeyan break;
15285344fc76SDinesh Karthikeyan case HTT_STATS_TX_TQM_PDEV_TAG:
15295344fc76SDinesh Karthikeyan ath12k_htt_print_tx_tqm_pdev_stats_tlv(tag_buf, len, stats_req);
15305344fc76SDinesh Karthikeyan break;
1531*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_CMN_TAG:
1532*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_cmn_stats_tlv(tag_buf, len, stats_req);
1533*04aee7a8SDinesh Karthikeyan break;
1534*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_EAPOL_PACKETS_TAG:
1535*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_eapol_packets_stats_tlv(tag_buf, len, stats_req);
1536*04aee7a8SDinesh Karthikeyan break;
1537*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_CLASSIFY_STATS_TAG:
1538*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_classify_stats_tlv(tag_buf, len, stats_req);
1539*04aee7a8SDinesh Karthikeyan break;
1540*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_CLASSIFY_FAILED_TAG:
1541*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_classify_failed_stats_tlv(tag_buf, len, stats_req);
1542*04aee7a8SDinesh Karthikeyan break;
1543*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_CLASSIFY_STATUS_TAG:
1544*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_classify_status_stats_tlv(tag_buf, len, stats_req);
1545*04aee7a8SDinesh Karthikeyan break;
1546*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_ENQUEUE_PACKETS_TAG:
1547*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_enqueue_packets_stats_tlv(tag_buf, len, stats_req);
1548*04aee7a8SDinesh Karthikeyan break;
1549*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_ENQUEUE_DISCARD_TAG:
1550*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_enqueue_discard_stats_tlv(tag_buf, len, stats_req);
1551*04aee7a8SDinesh Karthikeyan break;
1552*04aee7a8SDinesh Karthikeyan case HTT_STATS_TX_DE_COMPL_STATS_TAG:
1553*04aee7a8SDinesh Karthikeyan ath12k_htt_print_tx_de_compl_stats_tlv(tag_buf, len, stats_req);
1554*04aee7a8SDinesh Karthikeyan break;
1555adf6df96SDinesh Karthikeyan default:
1556adf6df96SDinesh Karthikeyan break;
1557adf6df96SDinesh Karthikeyan }
1558adf6df96SDinesh Karthikeyan
1559adf6df96SDinesh Karthikeyan return 0;
1560adf6df96SDinesh Karthikeyan }
1561adf6df96SDinesh Karthikeyan
ath12k_debugfs_htt_ext_stats_handler(struct ath12k_base * ab,struct sk_buff * skb)1562adf6df96SDinesh Karthikeyan void ath12k_debugfs_htt_ext_stats_handler(struct ath12k_base *ab,
1563adf6df96SDinesh Karthikeyan struct sk_buff *skb)
1564adf6df96SDinesh Karthikeyan {
1565adf6df96SDinesh Karthikeyan struct ath12k_htt_extd_stats_msg *msg;
1566adf6df96SDinesh Karthikeyan struct debug_htt_stats_req *stats_req;
1567adf6df96SDinesh Karthikeyan struct ath12k *ar;
1568adf6df96SDinesh Karthikeyan u32 len, pdev_id, stats_info;
1569adf6df96SDinesh Karthikeyan u64 cookie;
1570adf6df96SDinesh Karthikeyan int ret;
1571adf6df96SDinesh Karthikeyan bool send_completion = false;
1572adf6df96SDinesh Karthikeyan
1573adf6df96SDinesh Karthikeyan msg = (struct ath12k_htt_extd_stats_msg *)skb->data;
1574adf6df96SDinesh Karthikeyan cookie = le64_to_cpu(msg->cookie);
1575adf6df96SDinesh Karthikeyan
1576adf6df96SDinesh Karthikeyan if (u64_get_bits(cookie, ATH12K_HTT_STATS_COOKIE_MSB) !=
1577adf6df96SDinesh Karthikeyan ATH12K_HTT_STATS_MAGIC_VALUE) {
1578adf6df96SDinesh Karthikeyan ath12k_warn(ab, "received invalid htt ext stats event\n");
1579adf6df96SDinesh Karthikeyan return;
1580adf6df96SDinesh Karthikeyan }
1581adf6df96SDinesh Karthikeyan
1582adf6df96SDinesh Karthikeyan pdev_id = u64_get_bits(cookie, ATH12K_HTT_STATS_COOKIE_LSB);
1583adf6df96SDinesh Karthikeyan rcu_read_lock();
1584adf6df96SDinesh Karthikeyan ar = ath12k_mac_get_ar_by_pdev_id(ab, pdev_id);
1585adf6df96SDinesh Karthikeyan if (!ar) {
1586adf6df96SDinesh Karthikeyan ath12k_warn(ab, "failed to get ar for pdev_id %d\n", pdev_id);
1587adf6df96SDinesh Karthikeyan goto exit;
1588adf6df96SDinesh Karthikeyan }
1589adf6df96SDinesh Karthikeyan
1590adf6df96SDinesh Karthikeyan stats_req = ar->debug.htt_stats.stats_req;
1591adf6df96SDinesh Karthikeyan if (!stats_req)
1592adf6df96SDinesh Karthikeyan goto exit;
1593adf6df96SDinesh Karthikeyan
1594adf6df96SDinesh Karthikeyan spin_lock_bh(&ar->data_lock);
1595adf6df96SDinesh Karthikeyan
1596adf6df96SDinesh Karthikeyan stats_info = le32_to_cpu(msg->info1);
1597adf6df96SDinesh Karthikeyan stats_req->done = u32_get_bits(stats_info, ATH12K_HTT_T2H_EXT_STATS_INFO1_DONE);
1598adf6df96SDinesh Karthikeyan if (stats_req->done)
1599adf6df96SDinesh Karthikeyan send_completion = true;
1600adf6df96SDinesh Karthikeyan
1601adf6df96SDinesh Karthikeyan spin_unlock_bh(&ar->data_lock);
1602adf6df96SDinesh Karthikeyan
1603adf6df96SDinesh Karthikeyan len = u32_get_bits(stats_info, ATH12K_HTT_T2H_EXT_STATS_INFO1_LENGTH);
1604adf6df96SDinesh Karthikeyan if (len > skb->len) {
1605adf6df96SDinesh Karthikeyan ath12k_warn(ab, "invalid length %d for HTT stats", len);
1606adf6df96SDinesh Karthikeyan goto exit;
1607adf6df96SDinesh Karthikeyan }
1608adf6df96SDinesh Karthikeyan
1609adf6df96SDinesh Karthikeyan ret = ath12k_dp_htt_tlv_iter(ab, msg->data, len,
1610adf6df96SDinesh Karthikeyan ath12k_dbg_htt_ext_stats_parse,
1611adf6df96SDinesh Karthikeyan stats_req);
1612adf6df96SDinesh Karthikeyan if (ret)
1613adf6df96SDinesh Karthikeyan ath12k_warn(ab, "Failed to parse tlv %d\n", ret);
1614adf6df96SDinesh Karthikeyan
1615adf6df96SDinesh Karthikeyan if (send_completion)
1616adf6df96SDinesh Karthikeyan complete(&stats_req->htt_stats_rcvd);
1617adf6df96SDinesh Karthikeyan exit:
1618adf6df96SDinesh Karthikeyan rcu_read_unlock();
1619adf6df96SDinesh Karthikeyan }
16203f73c24fSDinesh Karthikeyan
ath12k_read_htt_stats_type(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)16213f73c24fSDinesh Karthikeyan static ssize_t ath12k_read_htt_stats_type(struct file *file,
16223f73c24fSDinesh Karthikeyan char __user *user_buf,
16233f73c24fSDinesh Karthikeyan size_t count, loff_t *ppos)
16243f73c24fSDinesh Karthikeyan {
16253f73c24fSDinesh Karthikeyan struct ath12k *ar = file->private_data;
16263f73c24fSDinesh Karthikeyan enum ath12k_dbg_htt_ext_stats_type type;
16273f73c24fSDinesh Karthikeyan char buf[32];
16283f73c24fSDinesh Karthikeyan size_t len;
16293f73c24fSDinesh Karthikeyan
16303f73c24fSDinesh Karthikeyan mutex_lock(&ar->conf_mutex);
16313f73c24fSDinesh Karthikeyan type = ar->debug.htt_stats.type;
16323f73c24fSDinesh Karthikeyan mutex_unlock(&ar->conf_mutex);
16333f73c24fSDinesh Karthikeyan
16343f73c24fSDinesh Karthikeyan len = scnprintf(buf, sizeof(buf), "%u\n", type);
16353f73c24fSDinesh Karthikeyan
16363f73c24fSDinesh Karthikeyan return simple_read_from_buffer(user_buf, count, ppos, buf, len);
16373f73c24fSDinesh Karthikeyan }
16383f73c24fSDinesh Karthikeyan
ath12k_write_htt_stats_type(struct file * file,const char __user * user_buf,size_t count,loff_t * ppos)16393f73c24fSDinesh Karthikeyan static ssize_t ath12k_write_htt_stats_type(struct file *file,
16403f73c24fSDinesh Karthikeyan const char __user *user_buf,
16413f73c24fSDinesh Karthikeyan size_t count, loff_t *ppos)
16423f73c24fSDinesh Karthikeyan {
16433f73c24fSDinesh Karthikeyan struct ath12k *ar = file->private_data;
16443f73c24fSDinesh Karthikeyan enum ath12k_dbg_htt_ext_stats_type type;
16453f73c24fSDinesh Karthikeyan unsigned int cfg_param[4] = {0};
16463f73c24fSDinesh Karthikeyan const int size = 32;
16473f73c24fSDinesh Karthikeyan int num_args;
16483f73c24fSDinesh Karthikeyan
16493f73c24fSDinesh Karthikeyan char *buf __free(kfree) = kzalloc(size, GFP_KERNEL);
16503f73c24fSDinesh Karthikeyan if (!buf)
16513f73c24fSDinesh Karthikeyan return -ENOMEM;
16523f73c24fSDinesh Karthikeyan
16533f73c24fSDinesh Karthikeyan if (copy_from_user(buf, user_buf, count))
16543f73c24fSDinesh Karthikeyan return -EFAULT;
16553f73c24fSDinesh Karthikeyan
16563f73c24fSDinesh Karthikeyan num_args = sscanf(buf, "%u %u %u %u %u\n", &type, &cfg_param[0],
16573f73c24fSDinesh Karthikeyan &cfg_param[1], &cfg_param[2], &cfg_param[3]);
16583f73c24fSDinesh Karthikeyan if (!num_args || num_args > 5)
16593f73c24fSDinesh Karthikeyan return -EINVAL;
16603f73c24fSDinesh Karthikeyan
16613f73c24fSDinesh Karthikeyan if (type == ATH12K_DBG_HTT_EXT_STATS_RESET ||
16623f73c24fSDinesh Karthikeyan type >= ATH12K_DBG_HTT_NUM_EXT_STATS)
16633f73c24fSDinesh Karthikeyan return -EINVAL;
16643f73c24fSDinesh Karthikeyan
16653f73c24fSDinesh Karthikeyan mutex_lock(&ar->conf_mutex);
16663f73c24fSDinesh Karthikeyan
16673f73c24fSDinesh Karthikeyan ar->debug.htt_stats.type = type;
16683f73c24fSDinesh Karthikeyan ar->debug.htt_stats.cfg_param[0] = cfg_param[0];
16693f73c24fSDinesh Karthikeyan ar->debug.htt_stats.cfg_param[1] = cfg_param[1];
16703f73c24fSDinesh Karthikeyan ar->debug.htt_stats.cfg_param[2] = cfg_param[2];
16713f73c24fSDinesh Karthikeyan ar->debug.htt_stats.cfg_param[3] = cfg_param[3];
16723f73c24fSDinesh Karthikeyan
16733f73c24fSDinesh Karthikeyan mutex_unlock(&ar->conf_mutex);
16743f73c24fSDinesh Karthikeyan
16753f73c24fSDinesh Karthikeyan return count;
16763f73c24fSDinesh Karthikeyan }
16773f73c24fSDinesh Karthikeyan
16783f73c24fSDinesh Karthikeyan static const struct file_operations fops_htt_stats_type = {
16793f73c24fSDinesh Karthikeyan .read = ath12k_read_htt_stats_type,
16803f73c24fSDinesh Karthikeyan .write = ath12k_write_htt_stats_type,
16813f73c24fSDinesh Karthikeyan .open = simple_open,
16823f73c24fSDinesh Karthikeyan .owner = THIS_MODULE,
16833f73c24fSDinesh Karthikeyan .llseek = default_llseek,
16843f73c24fSDinesh Karthikeyan };
16853f73c24fSDinesh Karthikeyan
ath12k_debugfs_htt_stats_req(struct ath12k * ar)1686ad201b35SDinesh Karthikeyan static int ath12k_debugfs_htt_stats_req(struct ath12k *ar)
1687ad201b35SDinesh Karthikeyan {
1688ad201b35SDinesh Karthikeyan struct debug_htt_stats_req *stats_req = ar->debug.htt_stats.stats_req;
1689ad201b35SDinesh Karthikeyan enum ath12k_dbg_htt_ext_stats_type type = stats_req->type;
1690ad201b35SDinesh Karthikeyan u64 cookie;
1691ad201b35SDinesh Karthikeyan int ret, pdev_id;
1692ad201b35SDinesh Karthikeyan struct htt_ext_stats_cfg_params cfg_params = { 0 };
1693ad201b35SDinesh Karthikeyan
1694ad201b35SDinesh Karthikeyan lockdep_assert_held(&ar->conf_mutex);
1695ad201b35SDinesh Karthikeyan
1696ad201b35SDinesh Karthikeyan init_completion(&stats_req->htt_stats_rcvd);
1697ad201b35SDinesh Karthikeyan
1698ad201b35SDinesh Karthikeyan pdev_id = ath12k_mac_get_target_pdev_id(ar);
1699ad201b35SDinesh Karthikeyan stats_req->done = false;
1700ad201b35SDinesh Karthikeyan stats_req->pdev_id = pdev_id;
1701ad201b35SDinesh Karthikeyan
1702ad201b35SDinesh Karthikeyan cookie = u64_encode_bits(ATH12K_HTT_STATS_MAGIC_VALUE,
1703ad201b35SDinesh Karthikeyan ATH12K_HTT_STATS_COOKIE_MSB);
1704ad201b35SDinesh Karthikeyan cookie |= u64_encode_bits(pdev_id, ATH12K_HTT_STATS_COOKIE_LSB);
1705ad201b35SDinesh Karthikeyan
1706ad201b35SDinesh Karthikeyan if (stats_req->override_cfg_param) {
1707ad201b35SDinesh Karthikeyan cfg_params.cfg0 = stats_req->cfg_param[0];
1708ad201b35SDinesh Karthikeyan cfg_params.cfg1 = stats_req->cfg_param[1];
1709ad201b35SDinesh Karthikeyan cfg_params.cfg2 = stats_req->cfg_param[2];
1710ad201b35SDinesh Karthikeyan cfg_params.cfg3 = stats_req->cfg_param[3];
1711ad201b35SDinesh Karthikeyan }
1712ad201b35SDinesh Karthikeyan
1713ad201b35SDinesh Karthikeyan ret = ath12k_dp_tx_htt_h2t_ext_stats_req(ar, type, &cfg_params, cookie);
1714ad201b35SDinesh Karthikeyan if (ret) {
1715ad201b35SDinesh Karthikeyan ath12k_warn(ar->ab, "failed to send htt stats request: %d\n", ret);
1716ad201b35SDinesh Karthikeyan return ret;
1717ad201b35SDinesh Karthikeyan }
1718ad201b35SDinesh Karthikeyan if (!wait_for_completion_timeout(&stats_req->htt_stats_rcvd, 3 * HZ)) {
1719ad201b35SDinesh Karthikeyan spin_lock_bh(&ar->data_lock);
1720ad201b35SDinesh Karthikeyan if (!stats_req->done) {
1721ad201b35SDinesh Karthikeyan stats_req->done = true;
1722ad201b35SDinesh Karthikeyan spin_unlock_bh(&ar->data_lock);
1723ad201b35SDinesh Karthikeyan ath12k_warn(ar->ab, "stats request timed out\n");
1724ad201b35SDinesh Karthikeyan return -ETIMEDOUT;
1725ad201b35SDinesh Karthikeyan }
1726ad201b35SDinesh Karthikeyan spin_unlock_bh(&ar->data_lock);
1727ad201b35SDinesh Karthikeyan }
1728ad201b35SDinesh Karthikeyan
1729ad201b35SDinesh Karthikeyan return 0;
1730ad201b35SDinesh Karthikeyan }
1731ad201b35SDinesh Karthikeyan
ath12k_open_htt_stats(struct inode * inode,struct file * file)1732ad201b35SDinesh Karthikeyan static int ath12k_open_htt_stats(struct inode *inode,
1733ad201b35SDinesh Karthikeyan struct file *file)
1734ad201b35SDinesh Karthikeyan {
1735ad201b35SDinesh Karthikeyan struct ath12k *ar = inode->i_private;
1736ad201b35SDinesh Karthikeyan struct debug_htt_stats_req *stats_req;
1737ad201b35SDinesh Karthikeyan enum ath12k_dbg_htt_ext_stats_type type = ar->debug.htt_stats.type;
1738ad201b35SDinesh Karthikeyan struct ath12k_hw *ah = ath12k_ar_to_ah(ar);
1739ad201b35SDinesh Karthikeyan int ret;
1740ad201b35SDinesh Karthikeyan
1741ad201b35SDinesh Karthikeyan if (type == ATH12K_DBG_HTT_EXT_STATS_RESET)
1742ad201b35SDinesh Karthikeyan return -EPERM;
1743ad201b35SDinesh Karthikeyan
1744ad201b35SDinesh Karthikeyan mutex_lock(&ar->conf_mutex);
1745ad201b35SDinesh Karthikeyan
1746ad201b35SDinesh Karthikeyan if (ah->state != ATH12K_HW_STATE_ON) {
1747ad201b35SDinesh Karthikeyan ret = -ENETDOWN;
1748ad201b35SDinesh Karthikeyan goto err_unlock;
1749ad201b35SDinesh Karthikeyan }
1750ad201b35SDinesh Karthikeyan
1751ad201b35SDinesh Karthikeyan if (ar->debug.htt_stats.stats_req) {
1752ad201b35SDinesh Karthikeyan ret = -EAGAIN;
1753ad201b35SDinesh Karthikeyan goto err_unlock;
1754ad201b35SDinesh Karthikeyan }
1755ad201b35SDinesh Karthikeyan
1756ad201b35SDinesh Karthikeyan stats_req = kzalloc(sizeof(*stats_req) + ATH12K_HTT_STATS_BUF_SIZE, GFP_KERNEL);
1757ad201b35SDinesh Karthikeyan if (!stats_req) {
1758ad201b35SDinesh Karthikeyan ret = -ENOMEM;
1759ad201b35SDinesh Karthikeyan goto err_unlock;
1760ad201b35SDinesh Karthikeyan }
1761ad201b35SDinesh Karthikeyan
1762ad201b35SDinesh Karthikeyan ar->debug.htt_stats.stats_req = stats_req;
1763ad201b35SDinesh Karthikeyan stats_req->type = type;
1764ad201b35SDinesh Karthikeyan stats_req->cfg_param[0] = ar->debug.htt_stats.cfg_param[0];
1765ad201b35SDinesh Karthikeyan stats_req->cfg_param[1] = ar->debug.htt_stats.cfg_param[1];
1766ad201b35SDinesh Karthikeyan stats_req->cfg_param[2] = ar->debug.htt_stats.cfg_param[2];
1767ad201b35SDinesh Karthikeyan stats_req->cfg_param[3] = ar->debug.htt_stats.cfg_param[3];
1768ad201b35SDinesh Karthikeyan stats_req->override_cfg_param = !!stats_req->cfg_param[0] ||
1769ad201b35SDinesh Karthikeyan !!stats_req->cfg_param[1] ||
1770ad201b35SDinesh Karthikeyan !!stats_req->cfg_param[2] ||
1771ad201b35SDinesh Karthikeyan !!stats_req->cfg_param[3];
1772ad201b35SDinesh Karthikeyan
1773ad201b35SDinesh Karthikeyan ret = ath12k_debugfs_htt_stats_req(ar);
1774ad201b35SDinesh Karthikeyan if (ret < 0)
1775ad201b35SDinesh Karthikeyan goto out;
1776ad201b35SDinesh Karthikeyan
1777ad201b35SDinesh Karthikeyan file->private_data = stats_req;
1778ad201b35SDinesh Karthikeyan
1779ad201b35SDinesh Karthikeyan mutex_unlock(&ar->conf_mutex);
1780ad201b35SDinesh Karthikeyan
1781ad201b35SDinesh Karthikeyan return 0;
1782ad201b35SDinesh Karthikeyan out:
1783ad201b35SDinesh Karthikeyan kfree(stats_req);
1784ad201b35SDinesh Karthikeyan ar->debug.htt_stats.stats_req = NULL;
1785ad201b35SDinesh Karthikeyan err_unlock:
1786ad201b35SDinesh Karthikeyan mutex_unlock(&ar->conf_mutex);
1787ad201b35SDinesh Karthikeyan
1788ad201b35SDinesh Karthikeyan return ret;
1789ad201b35SDinesh Karthikeyan }
1790ad201b35SDinesh Karthikeyan
ath12k_release_htt_stats(struct inode * inode,struct file * file)1791ad201b35SDinesh Karthikeyan static int ath12k_release_htt_stats(struct inode *inode,
1792ad201b35SDinesh Karthikeyan struct file *file)
1793ad201b35SDinesh Karthikeyan {
1794ad201b35SDinesh Karthikeyan struct ath12k *ar = inode->i_private;
1795ad201b35SDinesh Karthikeyan
1796ad201b35SDinesh Karthikeyan mutex_lock(&ar->conf_mutex);
1797ad201b35SDinesh Karthikeyan kfree(file->private_data);
1798ad201b35SDinesh Karthikeyan ar->debug.htt_stats.stats_req = NULL;
1799ad201b35SDinesh Karthikeyan mutex_unlock(&ar->conf_mutex);
1800ad201b35SDinesh Karthikeyan
1801ad201b35SDinesh Karthikeyan return 0;
1802ad201b35SDinesh Karthikeyan }
1803ad201b35SDinesh Karthikeyan
ath12k_read_htt_stats(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)1804ad201b35SDinesh Karthikeyan static ssize_t ath12k_read_htt_stats(struct file *file,
1805ad201b35SDinesh Karthikeyan char __user *user_buf,
1806ad201b35SDinesh Karthikeyan size_t count, loff_t *ppos)
1807ad201b35SDinesh Karthikeyan {
1808ad201b35SDinesh Karthikeyan struct debug_htt_stats_req *stats_req = file->private_data;
1809ad201b35SDinesh Karthikeyan char *buf;
1810ad201b35SDinesh Karthikeyan u32 length;
1811ad201b35SDinesh Karthikeyan
1812ad201b35SDinesh Karthikeyan buf = stats_req->buf;
1813ad201b35SDinesh Karthikeyan length = min_t(u32, stats_req->buf_len, ATH12K_HTT_STATS_BUF_SIZE);
1814ad201b35SDinesh Karthikeyan return simple_read_from_buffer(user_buf, count, ppos, buf, length);
1815ad201b35SDinesh Karthikeyan }
1816ad201b35SDinesh Karthikeyan
1817ad201b35SDinesh Karthikeyan static const struct file_operations fops_dump_htt_stats = {
1818ad201b35SDinesh Karthikeyan .open = ath12k_open_htt_stats,
1819ad201b35SDinesh Karthikeyan .release = ath12k_release_htt_stats,
1820ad201b35SDinesh Karthikeyan .read = ath12k_read_htt_stats,
1821ad201b35SDinesh Karthikeyan .owner = THIS_MODULE,
1822ad201b35SDinesh Karthikeyan .llseek = default_llseek,
1823ad201b35SDinesh Karthikeyan };
1824ad201b35SDinesh Karthikeyan
ath12k_write_htt_stats_reset(struct file * file,const char __user * user_buf,size_t count,loff_t * ppos)1825ad201b35SDinesh Karthikeyan static ssize_t ath12k_write_htt_stats_reset(struct file *file,
1826ad201b35SDinesh Karthikeyan const char __user *user_buf,
1827ad201b35SDinesh Karthikeyan size_t count, loff_t *ppos)
1828ad201b35SDinesh Karthikeyan {
1829ad201b35SDinesh Karthikeyan struct ath12k *ar = file->private_data;
1830ad201b35SDinesh Karthikeyan enum ath12k_dbg_htt_ext_stats_type type;
1831ad201b35SDinesh Karthikeyan struct htt_ext_stats_cfg_params cfg_params = { 0 };
1832ad201b35SDinesh Karthikeyan u8 param_pos;
1833ad201b35SDinesh Karthikeyan int ret;
1834ad201b35SDinesh Karthikeyan
1835ad201b35SDinesh Karthikeyan ret = kstrtou32_from_user(user_buf, count, 0, &type);
1836ad201b35SDinesh Karthikeyan if (ret)
1837ad201b35SDinesh Karthikeyan return ret;
1838ad201b35SDinesh Karthikeyan
1839ad201b35SDinesh Karthikeyan if (type >= ATH12K_DBG_HTT_NUM_EXT_STATS ||
1840ad201b35SDinesh Karthikeyan type == ATH12K_DBG_HTT_EXT_STATS_RESET)
1841ad201b35SDinesh Karthikeyan return -E2BIG;
1842ad201b35SDinesh Karthikeyan
1843ad201b35SDinesh Karthikeyan mutex_lock(&ar->conf_mutex);
1844ad201b35SDinesh Karthikeyan cfg_params.cfg0 = HTT_STAT_DEFAULT_RESET_START_OFFSET;
1845ad201b35SDinesh Karthikeyan param_pos = (type >> 5) + 1;
1846ad201b35SDinesh Karthikeyan
1847ad201b35SDinesh Karthikeyan switch (param_pos) {
1848ad201b35SDinesh Karthikeyan case ATH12K_HTT_STATS_RESET_PARAM_CFG_32_BYTES:
1849ad201b35SDinesh Karthikeyan cfg_params.cfg1 = 1 << (cfg_params.cfg0 + type);
1850ad201b35SDinesh Karthikeyan break;
1851ad201b35SDinesh Karthikeyan case ATH12K_HTT_STATS_RESET_PARAM_CFG_64_BYTES:
1852ad201b35SDinesh Karthikeyan cfg_params.cfg2 = ATH12K_HTT_STATS_RESET_BITMAP32_BIT(cfg_params.cfg0 +
1853ad201b35SDinesh Karthikeyan type);
1854ad201b35SDinesh Karthikeyan break;
1855ad201b35SDinesh Karthikeyan case ATH12K_HTT_STATS_RESET_PARAM_CFG_128_BYTES:
1856ad201b35SDinesh Karthikeyan cfg_params.cfg3 = ATH12K_HTT_STATS_RESET_BITMAP64_BIT(cfg_params.cfg0 +
1857ad201b35SDinesh Karthikeyan type);
1858ad201b35SDinesh Karthikeyan break;
1859ad201b35SDinesh Karthikeyan default:
1860ad201b35SDinesh Karthikeyan break;
1861ad201b35SDinesh Karthikeyan }
1862ad201b35SDinesh Karthikeyan
1863ad201b35SDinesh Karthikeyan ret = ath12k_dp_tx_htt_h2t_ext_stats_req(ar,
1864ad201b35SDinesh Karthikeyan ATH12K_DBG_HTT_EXT_STATS_RESET,
1865ad201b35SDinesh Karthikeyan &cfg_params,
1866ad201b35SDinesh Karthikeyan 0ULL);
1867ad201b35SDinesh Karthikeyan if (ret) {
1868ad201b35SDinesh Karthikeyan ath12k_warn(ar->ab, "failed to send htt stats request: %d\n", ret);
1869ad201b35SDinesh Karthikeyan mutex_unlock(&ar->conf_mutex);
1870ad201b35SDinesh Karthikeyan return ret;
1871ad201b35SDinesh Karthikeyan }
1872ad201b35SDinesh Karthikeyan
1873ad201b35SDinesh Karthikeyan ar->debug.htt_stats.reset = type;
1874ad201b35SDinesh Karthikeyan mutex_unlock(&ar->conf_mutex);
1875ad201b35SDinesh Karthikeyan
1876ad201b35SDinesh Karthikeyan return count;
1877ad201b35SDinesh Karthikeyan }
1878ad201b35SDinesh Karthikeyan
1879ad201b35SDinesh Karthikeyan static const struct file_operations fops_htt_stats_reset = {
1880ad201b35SDinesh Karthikeyan .write = ath12k_write_htt_stats_reset,
1881ad201b35SDinesh Karthikeyan .open = simple_open,
1882ad201b35SDinesh Karthikeyan .owner = THIS_MODULE,
1883ad201b35SDinesh Karthikeyan .llseek = default_llseek,
1884ad201b35SDinesh Karthikeyan };
1885ad201b35SDinesh Karthikeyan
ath12k_debugfs_htt_stats_register(struct ath12k * ar)18863f73c24fSDinesh Karthikeyan void ath12k_debugfs_htt_stats_register(struct ath12k *ar)
18873f73c24fSDinesh Karthikeyan {
18883f73c24fSDinesh Karthikeyan debugfs_create_file("htt_stats_type", 0600, ar->debug.debugfs_pdev,
18893f73c24fSDinesh Karthikeyan ar, &fops_htt_stats_type);
1890ad201b35SDinesh Karthikeyan debugfs_create_file("htt_stats", 0400, ar->debug.debugfs_pdev,
1891ad201b35SDinesh Karthikeyan ar, &fops_dump_htt_stats);
1892ad201b35SDinesh Karthikeyan debugfs_create_file("htt_stats_reset", 0200, ar->debug.debugfs_pdev,
1893ad201b35SDinesh Karthikeyan ar, &fops_htt_stats_reset);
18943f73c24fSDinesh Karthikeyan }
1895