xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/dp_stats.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 #include "qdf_types.h"
20 #include "qdf_module.h"
21 #include "dp_peer.h"
22 #include "dp_types.h"
23 #include "dp_tx.h"
24 #include "dp_internal.h"
25 #include "htt_stats.h"
26 #include "htt_ppdu_stats.h"
27 #ifdef QCA_PEER_EXT_STATS
28 #include <cdp_txrx_hist_struct.h>
29 #include "dp_hist.h"
30 #endif
31 #ifdef WIFI_MONITOR_SUPPORT
32 #include "dp_htt.h"
33 #include <dp_mon.h>
34 #endif
35 #ifdef IPA_OFFLOAD
36 #include "dp_ipa.h"
37 #endif
38 #define DP_MAX_STRING_LEN 1000
39 #define DP_HTT_TX_RX_EXPECTED_TLVS (((uint64_t)1 << HTT_STATS_TX_PDEV_CMN_TAG) |\
40 	((uint64_t)1 << HTT_STATS_TX_PDEV_UNDERRUN_TAG) |\
41 	((uint64_t)1 << HTT_STATS_TX_PDEV_SIFS_TAG) |\
42 	((uint64_t)1 << HTT_STATS_TX_PDEV_FLUSH_TAG) |\
43 	((uint64_t)1 << HTT_STATS_RX_PDEV_FW_STATS_TAG) |\
44 	((uint64_t)1 << HTT_STATS_RX_SOC_FW_STATS_TAG) |\
45 	((uint64_t)1 << HTT_STATS_RX_SOC_FW_REFILL_RING_EMPTY_TAG) |\
46 	((uint64_t)1 << HTT_STATS_RX_SOC_FW_REFILL_RING_NUM_REFILL_TAG) |\
47 	((uint64_t)1 << HTT_STATS_RX_PDEV_FW_RING_MPDU_ERR_TAG) |\
48 	((uint64_t)1 << HTT_STATS_RX_PDEV_FW_MPDU_DROP_TAG))
49 
50 #define DP_HTT_HW_INTR_NAME_LEN  HTT_STATS_MAX_HW_INTR_NAME_LEN
51 #define DP_HTT_HW_MODULE_NAME_LEN  HTT_STATS_MAX_HW_MODULE_NAME_LEN
52 #define DP_HTT_COUNTER_NAME_LEN  HTT_MAX_COUNTER_NAME
53 #define DP_HTT_LOW_WM_HIT_COUNT_LEN  HTT_STATS_LOW_WM_BINS
54 #define DP_HTT_HIGH_WM_HIT_COUNT_LEN  HTT_STATS_HIGH_WM_BINS
55 #define DP_HTT_TX_MCS_LEN  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS
56 #define DP_HTT_TX_MCS_EXT_LEN  HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS
57 #define DP_HTT_TX_MCS_EXT2_LEN  HTT_TX_PDEV_STATS_NUM_EXTRA2_MCS_COUNTERS
58 #define DP_HTT_TX_SU_MCS_LEN  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS
59 #define DP_HTT_TX_SU_MCS_EXT_LEN  HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS
60 #define DP_HTT_TX_MU_MCS_LEN  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS
61 #define DP_HTT_TX_MU_MCS_EXT_LEN  HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS
62 #define DP_HTT_TX_NSS_LEN  HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS
63 #define DP_HTT_TX_BW_LEN  HTT_TX_PDEV_STATS_NUM_BW_COUNTERS
64 #define DP_HTT_TX_PREAM_LEN  HTT_TX_PDEV_STATS_NUM_PREAMBLE_TYPES
65 #define DP_HTT_TX_PDEV_GI_LEN  HTT_TX_PDEV_STATS_NUM_GI_COUNTERS
66 #define DP_HTT_TX_DCM_LEN  HTT_TX_PDEV_STATS_NUM_DCM_COUNTERS
67 #define DP_HTT_RX_MCS_LEN  HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS
68 #define DP_HTT_RX_MCS_EXT_LEN  HTT_RX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS
69 #define DP_HTT_RX_PDEV_MCS_LEN_EXT HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS_EXT
70 #define DP_HTT_RX_PDEV_MCS_LEN_EXT2 HTT_RX_PDEV_STATS_NUM_EXTRA2_MCS_COUNTERS
71 #define DP_HTT_RX_NSS_LEN  HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS
72 #define DP_HTT_RX_DCM_LEN  HTT_RX_PDEV_STATS_NUM_DCM_COUNTERS
73 #define DP_HTT_RX_BW_LEN  HTT_RX_PDEV_STATS_NUM_BW_COUNTERS
74 #define DP_HTT_RX_PREAM_LEN  HTT_RX_PDEV_STATS_NUM_PREAMBLE_TYPES
75 #define DP_HTT_RSSI_CHAIN_LEN  HTT_RX_PDEV_STATS_NUM_SPATIAL_STREAMS
76 #define DP_HTT_RX_GI_LEN  HTT_RX_PDEV_STATS_NUM_GI_COUNTERS
77 #define DP_HTT_FW_RING_MGMT_SUBTYPE_LEN  HTT_STATS_SUBTYPE_MAX
78 #define DP_HTT_FW_RING_CTRL_SUBTYPE_LEN  HTT_STATS_SUBTYPE_MAX
79 #define DP_HTT_FW_RING_MPDU_ERR_LEN  HTT_RX_STATS_RXDMA_MAX_ERR
80 #define DP_HTT_TID_NAME_LEN  MAX_HTT_TID_NAME
81 #define DP_HTT_PEER_NUM_SS HTT_RX_PEER_STATS_NUM_SPATIAL_STREAMS
82 #define DP_HTT_PDEV_TX_GI_LEN HTT_TX_PDEV_STATS_NUM_GI_COUNTERS
83 
84 #define DP_MAX_INT_CONTEXTS_STRING_LENGTH (6 * WLAN_CFG_INT_NUM_CONTEXTS)
85 #define DP_NSS_LENGTH (6 * SS_COUNT)
86 #define DP_MU_GROUP_LENGTH (6 * DP_MU_GROUP_SHOW)
87 #define DP_MU_GROUP_SHOW 16
88 #define DP_RXDMA_ERR_LENGTH (6 * HAL_RXDMA_ERR_MAX)
89 #define DP_REO_ERR_LENGTH (6 * HAL_REO_ERR_MAX)
90 #define STATS_PROC_TIMEOUT        (HZ / 1000)
91 
92 #define dp_stats_alert(params...) QDF_TRACE_FATAL(QDF_MODULE_ID_DP_STATS, params)
93 #define dp_stats_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_STATS, params)
94 #define dp_stats_warn(params...) QDF_TRACE_WARN(QDF_MODULE_ID_DP_STATS, params)
95 #define dp_stats_info(params...) \
96 	__QDF_TRACE_FL(QDF_TRACE_LEVEL_INFO_HIGH, QDF_MODULE_ID_DP_STATS, ## params)
97 #define dp_stats_debug(params...) QDF_TRACE_DEBUG(QDF_MODULE_ID_DP_STATS, params)
98 
99 #ifdef WLAN_FEATURE_11BE
100 static const struct cdp_rate_debug dp_ppdu_rate_string[DOT11_MAX][MAX_MCS] = {
101 	{
102 		{"HE MCS 0 (BPSK 1/2)     ", MCS_VALID},
103 		{"HE MCS 1 (QPSK 1/2)     ", MCS_VALID},
104 		{"HE MCS 2 (QPSK 3/4)     ", MCS_VALID},
105 		{"HE MCS 3 (16-QAM 1/2)   ", MCS_VALID},
106 		{"HE MCS 4 (16-QAM 3/4)   ", MCS_VALID},
107 		{"HE MCS 5 (64-QAM 2/3)   ", MCS_VALID},
108 		{"HE MCS 6 (64-QAM 3/4)   ", MCS_VALID},
109 		{"HE MCS 7 (64-QAM 5/6)   ", MCS_VALID},
110 		{"HE MCS 8 (256-QAM 3/4)  ", MCS_VALID},
111 		{"HE MCS 9 (256-QAM 5/6)  ", MCS_VALID},
112 		{"HE MCS 10 (1024-QAM 3/4)", MCS_VALID},
113 		{"HE MCS 11 (1024-QAM 5/6)", MCS_VALID},
114 		{"HE MCS 12 (4096-QAM 3/4)", MCS_VALID},
115 		{"HE MCS 13 (4096-QAM 5/6)", MCS_VALID},
116 		{"INVALID ", MCS_INVALID},
117 		{"INVALID ", MCS_INVALID},
118 		{"INVALID ", MCS_INVALID},
119 	},
120 	{
121 		{"EHT MCS 0 (BPSK 1/2)     ", MCS_VALID},
122 		{"EHT MCS 1 (QPSK 1/2)     ", MCS_VALID},
123 		{"EHT MCS 2 (QPSK 3/4)     ", MCS_VALID},
124 		{"EHT MCS 3 (16-QAM 1/2)   ", MCS_VALID},
125 		{"EHT MCS 4 (16-QAM 3/4)   ", MCS_VALID},
126 		{"EHT MCS 5 (64-QAM 2/3)   ", MCS_VALID},
127 		{"EHT MCS 6 (64-QAM 3/4)   ", MCS_VALID},
128 		{"EHT MCS 7 (64-QAM 5/6)   ", MCS_VALID},
129 		{"EHT MCS 8 (256-QAM 3/4)  ", MCS_VALID},
130 		{"EHT MCS 9 (256-QAM 5/6)  ", MCS_VALID},
131 		{"EHT MCS 10 (1024-QAM 3/4)", MCS_VALID},
132 		{"EHT MCS 11 (1024-QAM 5/6)", MCS_VALID},
133 		{"EHT MCS 12 (4096-QAM 3/4)", MCS_VALID},
134 		{"EHT MCS 13 (4096-QAM 5/6)", MCS_VALID},
135 		{"EHT MCS 14 (BPSK-DCM 1/2)", MCS_VALID},
136 		{"EHT MCS 15 (BPSK-DCM 1/2)", MCS_VALID},
137 		{"INVALID ", MCS_INVALID},
138 	}
139 };
140 #else
141 static const struct cdp_rate_debug dp_ppdu_rate_string[DOT11_MAX][MAX_MCS] = {
142 	{
143 		{"HE MCS 0 (BPSK 1/2)     ", MCS_VALID},
144 		{"HE MCS 1 (QPSK 1/2)     ", MCS_VALID},
145 		{"HE MCS 2 (QPSK 3/4)     ", MCS_VALID},
146 		{"HE MCS 3 (16-QAM 1/2)   ", MCS_VALID},
147 		{"HE MCS 4 (16-QAM 3/4)   ", MCS_VALID},
148 		{"HE MCS 5 (64-QAM 2/3)   ", MCS_VALID},
149 		{"HE MCS 6 (64-QAM 3/4)   ", MCS_VALID},
150 		{"HE MCS 7 (64-QAM 5/6)   ", MCS_VALID},
151 		{"HE MCS 8 (256-QAM 3/4)  ", MCS_VALID},
152 		{"HE MCS 9 (256-QAM 5/6)  ", MCS_VALID},
153 		{"HE MCS 10 (1024-QAM 3/4)", MCS_VALID},
154 		{"HE MCS 11 (1024-QAM 5/6)", MCS_VALID},
155 		{"HE MCS 12 (4096-QAM 3/4)", MCS_VALID},
156 		{"HE MCS 13 (4096-QAM 5/6)", MCS_VALID},
157 		{"INVALID ", MCS_INVALID},
158 	}
159 };
160 #endif
161 
162 #ifdef WLAN_FEATURE_11BE
163 static const struct cdp_rate_debug
164 dp_mu_rate_string[TXRX_TYPE_MU_MAX][MAX_MCS] = {
165 	{
166 		{"HE MU-MIMO MCS 0 (BPSK 1/2)     ", MCS_VALID},
167 		{"HE MU-MIMO MCS 1 (QPSK 1/2)     ", MCS_VALID},
168 		{"HE MU-MIMO MCS 2 (QPSK 3/4)     ", MCS_VALID},
169 		{"HE MU-MIMO MCS 3 (16-QAM 1/2)   ", MCS_VALID},
170 		{"HE MU-MIMO MCS 4 (16-QAM 3/4)   ", MCS_VALID},
171 		{"HE MU-MIMO MCS 5 (64-QAM 2/3)   ", MCS_VALID},
172 		{"HE MU-MIMO MCS 6 (64-QAM 3/4)   ", MCS_VALID},
173 		{"HE MU-MIMO MCS 7 (64-QAM 5/6)   ", MCS_VALID},
174 		{"HE MU-MIMO MCS 8 (256-QAM 3/4)  ", MCS_VALID},
175 		{"HE MU-MIMO MCS 9 (256-QAM 5/6)  ", MCS_VALID},
176 		{"HE MU-MIMO MCS 10 (1024-QAM 3/4)", MCS_VALID},
177 		{"HE MU-MIMO MCS 11 (1024-QAM 5/6)", MCS_VALID},
178 		{"HE MU-MIMO MCS 12 (4096-QAM 3/4)", MCS_VALID},
179 		{"HE MU-MIMO MCS 13 (4096-QAM 5/6)", MCS_VALID},
180 		{"INVALID ", MCS_INVALID},
181 		{"INVALID ", MCS_INVALID},
182 		{"INVALID ", MCS_INVALID},
183 	},
184 	{
185 		{"HE OFDMA MCS 0 (BPSK 1/2)     ", MCS_VALID},
186 		{"HE OFDMA MCS 1 (QPSK 1/2)     ", MCS_VALID},
187 		{"HE OFDMA MCS 2 (QPSK 3/4)     ", MCS_VALID},
188 		{"HE OFDMA MCS 3 (16-QAM 1/2)   ", MCS_VALID},
189 		{"HE OFDMA MCS 4 (16-QAM 3/4)   ", MCS_VALID},
190 		{"HE OFDMA MCS 5 (64-QAM 2/3)   ", MCS_VALID},
191 		{"HE OFDMA MCS 6 (64-QAM 3/4)   ", MCS_VALID},
192 		{"HE OFDMA MCS 7 (64-QAM 5/6)   ", MCS_VALID},
193 		{"HE OFDMA MCS 8 (256-QAM 3/4)  ", MCS_VALID},
194 		{"HE OFDMA MCS 9 (256-QAM 5/6)  ", MCS_VALID},
195 		{"HE OFDMA MCS 10 (1024-QAM 3/4)", MCS_VALID},
196 		{"HE OFDMA MCS 11 (1024-QAM 5/6)", MCS_VALID},
197 		{"HE OFDMA MCS 12 (4096-QAM 3/4)", MCS_VALID},
198 		{"HE OFDMA MCS 13 (4096-QAM 5/6)", MCS_VALID},
199 		{"INVALID ", MCS_INVALID},
200 		{"INVALID ", MCS_INVALID},
201 		{"INVALID ", MCS_INVALID},
202 	}
203 };
204 
205 static const struct cdp_rate_debug
206 dp_mu_be_rate_string[TXRX_TYPE_MU_MAX][MAX_MCS] = {
207 	{
208 		{"EHT MU-MIMO MCS 0 (BPSK 1/2)     ", MCS_VALID},
209 		{"EHT MU-MIMO MCS 1 (QPSK 1/2)     ", MCS_VALID},
210 		{"EHT MU-MIMO MCS 2 (QPSK 3/4)     ", MCS_VALID},
211 		{"EHT MU-MIMO MCS 3 (16-QAM 1/2)   ", MCS_VALID},
212 		{"EHT MU-MIMO MCS 4 (16-QAM 3/4)   ", MCS_VALID},
213 		{"EHT MU-MIMO MCS 5 (64-QAM 2/3)   ", MCS_VALID},
214 		{"EHT MU-MIMO MCS 6 (64-QAM 3/4)   ", MCS_VALID},
215 		{"EHT MU-MIMO MCS 7 (64-QAM 5/6)   ", MCS_VALID},
216 		{"EHT MU-MIMO MCS 8 (256-QAM 3/4)  ", MCS_VALID},
217 		{"EHT MU-MIMO MCS 9 (256-QAM 5/6)  ", MCS_VALID},
218 		{"EHT MU-MIMO MCS 10 (1024-QAM 3/4)", MCS_VALID},
219 		{"EHT MU-MIMO MCS 11 (1024-QAM 5/6)", MCS_VALID},
220 		{"EHT MU-MIMO MCS 12 (4096-QAM 3/4)", MCS_VALID},
221 		{"EHT MU-MIMO MCS 13 (4096-QAM 5/6)", MCS_VALID},
222 		{"EHT MU-MIMO MCS 14 (BPSK-DCM 1/2)", MCS_VALID},
223 		{"EHT MU-MIMO MCS 15 (BPSK-DCM 1/2)", MCS_VALID},
224 		{"INVALID ", MCS_INVALID},
225 	},
226 	{
227 		{"EHT OFDMA MCS 0 (BPSK 1/2)     ", MCS_VALID},
228 		{"EHT OFDMA MCS 1 (QPSK 1/2)     ", MCS_VALID},
229 		{"EHT OFDMA MCS 2 (QPSK 3/4)     ", MCS_VALID},
230 		{"EHT OFDMA MCS 3 (16-QAM 1/2)   ", MCS_VALID},
231 		{"EHT OFDMA MCS 4 (16-QAM 3/4)   ", MCS_VALID},
232 		{"EHT OFDMA MCS 5 (64-QAM 2/3)   ", MCS_VALID},
233 		{"EHT OFDMA MCS 6 (64-QAM 3/4)   ", MCS_VALID},
234 		{"EHT OFDMA MCS 7 (64-QAM 5/6)   ", MCS_VALID},
235 		{"EHT OFDMA MCS 8 (256-QAM 3/4)  ", MCS_VALID},
236 		{"EHT OFDMA MCS 9 (256-QAM 5/6)  ", MCS_VALID},
237 		{"EHT OFDMA MCS 10 (1024-QAM 3/4)", MCS_VALID},
238 		{"EHT OFDMA MCS 11 (1024-QAM 5/6)", MCS_VALID},
239 		{"EHT OFDMA MCS 12 (4096-QAM 3/4)", MCS_VALID},
240 		{"EHT OFDMA MCS 13 (4096-QAM 5/6)", MCS_VALID},
241 		{"EHT OFDMA MCS 14 (BPSK-DCM 1/2)", MCS_VALID},
242 		{"EHT OFDMA MCS 15 (BPSK-DCM 1/2)", MCS_VALID},
243 		{"INVALID ", MCS_INVALID},
244 	}
245 };
246 #else
247 static const struct cdp_rate_debug
248 dp_mu_rate_string[TXRX_TYPE_MU_MAX][MAX_MCS] = {
249 	{
250 		{"HE MU-MIMO MCS 0 (BPSK 1/2)     ", MCS_VALID},
251 		{"HE MU-MIMO MCS 1 (QPSK 1/2)     ", MCS_VALID},
252 		{"HE MU-MIMO MCS 2 (QPSK 3/4)     ", MCS_VALID},
253 		{"HE MU-MIMO MCS 3 (16-QAM 1/2)   ", MCS_VALID},
254 		{"HE MU-MIMO MCS 4 (16-QAM 3/4)   ", MCS_VALID},
255 		{"HE MU-MIMO MCS 5 (64-QAM 2/3)   ", MCS_VALID},
256 		{"HE MU-MIMO MCS 6 (64-QAM 3/4)   ", MCS_VALID},
257 		{"HE MU-MIMO MCS 7 (64-QAM 5/6)   ", MCS_VALID},
258 		{"HE MU-MIMO MCS 8 (256-QAM 3/4)  ", MCS_VALID},
259 		{"HE MU-MIMO MCS 9 (256-QAM 5/6)  ", MCS_VALID},
260 		{"HE MU-MIMO MCS 10 (1024-QAM 3/4)", MCS_VALID},
261 		{"HE MU-MIMO MCS 11 (1024-QAM 5/6)", MCS_VALID},
262 		{"HE MU-MIMO MCS 12 (4096-QAM 3/4)", MCS_VALID},
263 		{"HE MU-MIMO MCS 13 (4096-QAM 5/6)", MCS_VALID},
264 		{"INVALID ", MCS_INVALID},
265 	},
266 	{
267 		{"HE OFDMA MCS 0 (BPSK 1/2)     ", MCS_VALID},
268 		{"HE OFDMA MCS 1 (QPSK 1/2)     ", MCS_VALID},
269 		{"HE OFDMA MCS 2 (QPSK 3/4)     ", MCS_VALID},
270 		{"HE OFDMA MCS 3 (16-QAM 1/2)   ", MCS_VALID},
271 		{"HE OFDMA MCS 4 (16-QAM 3/4)   ", MCS_VALID},
272 		{"HE OFDMA MCS 5 (64-QAM 2/3)   ", MCS_VALID},
273 		{"HE OFDMA MCS 6 (64-QAM 3/4)   ", MCS_VALID},
274 		{"HE OFDMA MCS 7 (64-QAM 5/6)   ", MCS_VALID},
275 		{"HE OFDMA MCS 8 (256-QAM 3/4)  ", MCS_VALID},
276 		{"HE OFDMA MCS 9 (256-QAM 5/6)  ", MCS_VALID},
277 		{"HE OFDMA MCS 10 (1024-QAM 3/4)", MCS_VALID},
278 		{"HE OFDMA MCS 11 (1024-QAM 5/6)", MCS_VALID},
279 		{"HE OFDMA MCS 12 (4096-QAM 3/4)", MCS_VALID},
280 		{"HE OFDMA MCS 13 (4096-QAM 5/6)", MCS_VALID},
281 		{"INVALID ", MCS_INVALID},
282 	}
283 };
284 #endif
285 
286 const char *mu_reception_mode[TXRX_TYPE_MU_MAX] = {
287 	"MU MIMO", "MU OFDMA"
288 };
289 
290 #ifdef QCA_ENH_V3_STATS_SUPPORT
291 #ifndef WLAN_CONFIG_TX_DELAY
292 const char *fw_to_hw_delay_bucket[CDP_DELAY_BUCKET_MAX + 1] = {
293 	"0 to 9 ms", "10 to 19 ms",
294 	"20 to 29 ms", "30 to 39 ms",
295 	"40 to 49 ms", "50 to 59 ms",
296 	"60 to 69 ms", "70 to 79 ms",
297 	"80 to 89 ms", "90 to 99 ms",
298 	"101 to 249 ms", "250 to 499 ms", "500+ ms"
299 };
300 #else
301 const char *fw_to_hw_delay_bucket[CDP_DELAY_BUCKET_MAX + 1] = {
302 	"0 to 250 us", "250 to 500 us",
303 	"500 to 750 us", "750 to 1000 us",
304 	"1000 to 1500 us", "1500 to 2000 us",
305 	"2000 to 2500 us", "2500 to 5000 us",
306 	"5000 to 6000 us", "6000 to 7000 ms",
307 	"7000 to 8000 us", "8000 to 9000 us", "9000+ us"
308 };
309 #endif
310 #elif defined(HW_TX_DELAY_STATS_ENABLE)
311 const char *fw_to_hw_delay_bucket[CDP_DELAY_BUCKET_MAX + 1] = {
312 	"0 to 2 ms", "2 to 4 ms",
313 	"4 to 6 ms", "6 to 8 ms",
314 	"8 to 10 ms", "10 to 20 ms",
315 	"20 to 30 ms", "30 to 40 ms",
316 	"40 to 50 ms", "50 to 100 ms",
317 	"100 to 250 ms", "250 to 500 ms", "500+ ms"
318 };
319 #endif
320 
321 #if defined(HW_TX_DELAY_STATS_ENABLE)
322 const char *fw_to_hw_delay_bkt_str[CDP_DELAY_BUCKET_MAX + 1] = {
323 	"0-2ms", "2-4",
324 	"4-6", "6-8",
325 	"8-10", "10-20",
326 	"20-30", "30-40",
327 	"40-50", "50-100",
328 	"100-250", "250-500", "500+ ms"
329 };
330 #endif
331 
332 #ifdef QCA_ENH_V3_STATS_SUPPORT
333 #ifndef WLAN_CONFIG_TX_DELAY
334 const char *sw_enq_delay_bucket[CDP_DELAY_BUCKET_MAX + 1] = {
335 	"0 to 1 ms", "1 to 2 ms",
336 	"2 to 3 ms", "3 to 4 ms",
337 	"4 to 5 ms", "5 to 6 ms",
338 	"6 to 7 ms", "7 to 8 ms",
339 	"8 to 9 ms", "9 to 10 ms",
340 	"10 to 11 ms", "11 to 12 ms", "12+ ms"
341 };
342 #else
343 const char *sw_enq_delay_bucket[CDP_DELAY_BUCKET_MAX + 1] = {
344 	"0 to 250 us", "250 to 500 us",
345 	"500 to 750 us", "750 to 1000 us",
346 	"1000 to 1500 us", "1500 to 2000 us",
347 	"2000 to 2500 us", "2500 to 5000 us",
348 	"5000 to 6000 us", "6000 to 7000 ms",
349 	"7000 to 8000 us", "8000 to 9000 us", "9000+ us"
350 };
351 #endif
352 
353 const char *intfrm_delay_bucket[CDP_DELAY_BUCKET_MAX + 1] = {
354 	"0 to 4 ms", "5 to 9 ms",
355 	"10 to 14 ms", "15 to 19 ms",
356 	"20 to 24 ms", "25 to 29 ms",
357 	"30 to 34 ms", "35 to 39 ms",
358 	"40 to 44 ms", "45 to 49 ms",
359 	"50 to 54 ms", "55 to 59 ms", "60+ ms"
360 };
361 #endif
362 
363 #define TID_COUNTER_STATS 1	/* Success/drop stats type */
364 #define TID_DELAY_STATS 2	/* Delay stats type */
365 #define TID_RX_ERROR_STATS 3	/* Rx Error stats type */
366 
367 #ifdef WLAN_SYSFS_DP_STATS
DP_PRINT_STATS(const char * fmt,...)368 void DP_PRINT_STATS(const char *fmt, ...)
369 {
370 	void *soc_void = NULL;
371 	va_list val;
372 	uint16_t buf_written = 0;
373 	uint16_t curr_len = 0;
374 	uint16_t max_len = 0;
375 	struct dp_soc *soc = NULL;
376 
377 	soc_void = cds_get_context(QDF_MODULE_ID_SOC);
378 	if (!soc_void)
379 		return;
380 
381 	soc = cdp_soc_t_to_dp_soc(soc_void);
382 
383 	va_start(val, fmt);
384 	QDF_VTRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH, (char *)fmt, val);
385 	/* writing to the buffer */
386 	if (soc->sysfs_config && soc->sysfs_config->printing_mode == PRINTING_MODE_ENABLED) {
387 		if (soc->sysfs_config->process_id == qdf_get_current_pid()) {
388 			curr_len = soc->sysfs_config->curr_buffer_length;
389 			max_len = soc->sysfs_config->max_buffer_length;
390 			if ((max_len - curr_len) <= 1)
391 				goto fail;
392 
393 			qdf_spinlock_acquire(&soc->sysfs_config->sysfs_write_user_buffer);
394 			if (soc->sysfs_config->buf) {
395 				buf_written = vscnprintf(soc->sysfs_config->buf + curr_len,
396 							 max_len - curr_len, fmt, val);
397 				curr_len += buf_written;
398 				if ((max_len - curr_len) <= 1)
399 					goto rel_lock;
400 
401 				buf_written += scnprintf(soc->sysfs_config->buf + curr_len,
402 							 max_len - curr_len, "\n");
403 				soc->sysfs_config->curr_buffer_length +=  buf_written;
404 			}
405 			qdf_spinlock_release(&soc->sysfs_config->sysfs_write_user_buffer);
406 		}
407 	}
408 	va_end(val);
409 	return;
410 
411 rel_lock:
412 	qdf_spinlock_release(&soc->sysfs_config->sysfs_write_user_buffer);
413 fail:
414 	va_end(val);
415 }
416 #endif /* WLAN_SYSFS_DP_STATS */
417 /**
418  * dp_print_stats_string_tlv() - display htt_stats_string_tlv
419  * @tag_buf: buffer containing the tlv htt_stats_string_tlv
420  *
421  * Return: void
422  */
dp_print_stats_string_tlv(uint32_t * tag_buf)423 static void dp_print_stats_string_tlv(uint32_t *tag_buf)
424 {
425 	htt_stats_string_tlv *dp_stats_buf =
426 		(htt_stats_string_tlv *)tag_buf;
427 	uint8_t i;
428 	uint16_t index = 0;
429 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
430 	char *data = qdf_mem_malloc(DP_MAX_STRING_LEN);
431 
432 	if (!data) {
433 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
434 			  FL("Output buffer not allocated"));
435 		return;
436 	}
437 
438 	DP_PRINT_STATS("HTT_STATS_STRING_TLV:");
439 	for (i = 0; i <  tag_len; i++) {
440 		index += qdf_snprint(&data[index],
441 				DP_MAX_STRING_LEN - index,
442 				" %u:%u,", i, dp_stats_buf->data[i]);
443 	}
444 	DP_PRINT_STATS("data = %s\n", data);
445 	qdf_mem_free(data);
446 }
447 
448 /**
449  * dp_print_tx_pdev_stats_cmn_tlv() - display htt_tx_pdev_stats_cmn_tlv
450  * @tag_buf: buffer containing the tlv htt_tx_pdev_stats_cmn_tlv
451  *
452  * Return: void
453  */
dp_print_tx_pdev_stats_cmn_tlv(uint32_t * tag_buf)454 static void dp_print_tx_pdev_stats_cmn_tlv(uint32_t *tag_buf)
455 {
456 	htt_tx_pdev_stats_cmn_tlv *dp_stats_buf =
457 		(htt_tx_pdev_stats_cmn_tlv *)tag_buf;
458 
459 	DP_PRINT_STATS("HTT_TX_PDEV_STATS_CMN_TLV:");
460 	DP_PRINT_STATS("mac_id__word = %u",
461 		       dp_stats_buf->mac_id__word);
462 	DP_PRINT_STATS("hw_queued = %u",
463 		       dp_stats_buf->hw_queued);
464 	DP_PRINT_STATS("hw_reaped = %u",
465 		       dp_stats_buf->hw_reaped);
466 	DP_PRINT_STATS("underrun = %u",
467 		       dp_stats_buf->underrun);
468 	DP_PRINT_STATS("hw_paused = %u",
469 		       dp_stats_buf->hw_paused);
470 	DP_PRINT_STATS("hw_flush = %u",
471 		       dp_stats_buf->hw_flush);
472 	DP_PRINT_STATS("hw_filt = %u",
473 		       dp_stats_buf->hw_filt);
474 	DP_PRINT_STATS("tx_abort = %u",
475 		       dp_stats_buf->tx_abort);
476 	DP_PRINT_STATS("mpdu_requeued = %u",
477 		       dp_stats_buf->mpdu_requed);
478 	DP_PRINT_STATS("tx_xretry = %u",
479 		       dp_stats_buf->tx_xretry);
480 	DP_PRINT_STATS("data_rc = %u",
481 		       dp_stats_buf->data_rc);
482 	DP_PRINT_STATS("mpdu_dropped_xretry = %u",
483 		       dp_stats_buf->mpdu_dropped_xretry);
484 	DP_PRINT_STATS("illegal_rate_phy_err = %u",
485 		       dp_stats_buf->illgl_rate_phy_err);
486 	DP_PRINT_STATS("cont_xretry = %u",
487 		       dp_stats_buf->cont_xretry);
488 	DP_PRINT_STATS("tx_timeout = %u",
489 		       dp_stats_buf->tx_timeout);
490 	DP_PRINT_STATS("pdev_resets = %u",
491 		       dp_stats_buf->pdev_resets);
492 	DP_PRINT_STATS("phy_underrun = %u",
493 		       dp_stats_buf->phy_underrun);
494 	DP_PRINT_STATS("txop_ovf = %u",
495 		       dp_stats_buf->txop_ovf);
496 	DP_PRINT_STATS("seq_posted = %u",
497 		       dp_stats_buf->seq_posted);
498 	DP_PRINT_STATS("seq_failed_queueing = %u",
499 		       dp_stats_buf->seq_failed_queueing);
500 	DP_PRINT_STATS("seq_completed = %u",
501 		       dp_stats_buf->seq_completed);
502 	DP_PRINT_STATS("seq_restarted = %u",
503 		       dp_stats_buf->seq_restarted);
504 	DP_PRINT_STATS("mu_seq_posted = %u",
505 		       dp_stats_buf->mu_seq_posted);
506 	DP_PRINT_STATS("seq_switch_hw_paused = %u",
507 		       dp_stats_buf->seq_switch_hw_paused);
508 	DP_PRINT_STATS("next_seq_posted_dsr = %u",
509 		       dp_stats_buf->next_seq_posted_dsr);
510 	DP_PRINT_STATS("seq_posted_isr = %u",
511 		       dp_stats_buf->seq_posted_isr);
512 	DP_PRINT_STATS("seq_ctrl_cached = %u",
513 		       dp_stats_buf->seq_ctrl_cached);
514 	DP_PRINT_STATS("mpdu_count_tqm = %u",
515 		       dp_stats_buf->mpdu_count_tqm);
516 	DP_PRINT_STATS("msdu_count_tqm = %u",
517 		       dp_stats_buf->msdu_count_tqm);
518 	DP_PRINT_STATS("mpdu_removed_tqm = %u",
519 		       dp_stats_buf->mpdu_removed_tqm);
520 	DP_PRINT_STATS("msdu_removed_tqm = %u",
521 		       dp_stats_buf->msdu_removed_tqm);
522 	DP_PRINT_STATS("mpdus_sw_flush = %u",
523 		       dp_stats_buf->mpdus_sw_flush);
524 	DP_PRINT_STATS("mpdus_hw_filter = %u",
525 		       dp_stats_buf->mpdus_hw_filter);
526 	DP_PRINT_STATS("mpdus_truncated = %u",
527 		       dp_stats_buf->mpdus_truncated);
528 	DP_PRINT_STATS("mpdus_ack_failed = %u",
529 		       dp_stats_buf->mpdus_ack_failed);
530 	DP_PRINT_STATS("mpdus_expired = %u",
531 		       dp_stats_buf->mpdus_expired);
532 	DP_PRINT_STATS("mpdus_seq_hw_retry = %u",
533 		       dp_stats_buf->mpdus_seq_hw_retry);
534 	DP_PRINT_STATS("ack_tlv_proc = %u",
535 		       dp_stats_buf->ack_tlv_proc);
536 	DP_PRINT_STATS("coex_abort_mpdu_cnt_valid = %u",
537 		       dp_stats_buf->coex_abort_mpdu_cnt_valid);
538 	DP_PRINT_STATS("coex_abort_mpdu_cnt = %u\n",
539 		       dp_stats_buf->coex_abort_mpdu_cnt);
540 }
541 
542 /**
543  * dp_print_tx_pdev_stats_urrn_tlv_v() - display htt_tx_pdev_stats_urrn_tlv_v
544  * @tag_buf: buffer containing the tlv htt_tx_pdev_stats_urrn_tlv_v
545  *
546  * Return: void
547  */
dp_print_tx_pdev_stats_urrn_tlv_v(uint32_t * tag_buf)548 static void dp_print_tx_pdev_stats_urrn_tlv_v(uint32_t *tag_buf)
549 {
550 	htt_tx_pdev_stats_urrn_tlv_v *dp_stats_buf =
551 		(htt_tx_pdev_stats_urrn_tlv_v *)tag_buf;
552 	uint8_t i;
553 	uint16_t index = 0;
554 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
555 	char *urrn_stats = qdf_mem_malloc(DP_MAX_STRING_LEN);
556 
557 	if (!urrn_stats) {
558 		dp_stats_err("Output buffer not allocated");
559 		return;
560 	}
561 
562 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_PDEV_MAX_URRN_STATS);
563 	DP_PRINT_STATS("HTT_TX_PDEV_STATS_URRN_TLV_V:");
564 	for (i = 0; i <  tag_len; i++) {
565 		index += qdf_snprint(&urrn_stats[index],
566 				DP_MAX_STRING_LEN - index,
567 				" %u:%u,", i, dp_stats_buf->urrn_stats[i]);
568 	}
569 	DP_PRINT_STATS("urrn_stats = %s\n", urrn_stats);
570 	qdf_mem_free(urrn_stats);
571 }
572 
573 /**
574  * dp_print_tx_pdev_stats_flush_tlv_v() - display htt_tx_pdev_stats_flush_tlv_v
575  * @tag_buf: buffer containing the tlv htt_tx_pdev_stats_flush_tlv_v
576  *
577  * Return: void
578  */
dp_print_tx_pdev_stats_flush_tlv_v(uint32_t * tag_buf)579 static void dp_print_tx_pdev_stats_flush_tlv_v(uint32_t *tag_buf)
580 {
581 	htt_tx_pdev_stats_flush_tlv_v *dp_stats_buf =
582 		(htt_tx_pdev_stats_flush_tlv_v *)tag_buf;
583 	uint8_t i;
584 	uint16_t index = 0;
585 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
586 	char *flush_errs = qdf_mem_malloc(DP_MAX_STRING_LEN);
587 
588 	if (!flush_errs) {
589 		dp_stats_err("Output buffer not allocated");
590 		return;
591 	}
592 
593 	tag_len = qdf_min(tag_len,
594 			(uint32_t)HTT_TX_PDEV_MAX_FLUSH_REASON_STATS);
595 
596 	DP_PRINT_STATS("HTT_TX_PDEV_STATS_FLUSH_TLV_V:");
597 	for (i = 0; i <  tag_len; i++) {
598 		index += qdf_snprint(&flush_errs[index],
599 				DP_MAX_STRING_LEN - index,
600 				" %u:%u,", i, dp_stats_buf->flush_errs[i]);
601 	}
602 	DP_PRINT_STATS("flush_errs = %s\n", flush_errs);
603 	qdf_mem_free(flush_errs);
604 }
605 
606 /**
607  * dp_print_tx_pdev_stats_sifs_tlv_v() - display htt_tx_pdev_stats_sifs_tlv_v
608  * @tag_buf: buffer containing the tlv htt_tx_pdev_stats_sifs_tlv_v
609  *
610  * Return: void
611  */
dp_print_tx_pdev_stats_sifs_tlv_v(uint32_t * tag_buf)612 static void dp_print_tx_pdev_stats_sifs_tlv_v(uint32_t *tag_buf)
613 {
614 	htt_tx_pdev_stats_sifs_tlv_v *dp_stats_buf =
615 		(htt_tx_pdev_stats_sifs_tlv_v *)tag_buf;
616 	uint8_t i;
617 	uint16_t index = 0;
618 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
619 	char *sifs_status = qdf_mem_malloc(DP_MAX_STRING_LEN);
620 
621 	if (!sifs_status) {
622 		dp_stats_err("Output buffer not allocated");
623 		return;
624 	}
625 
626 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_PDEV_MAX_SIFS_BURST_STATS);
627 
628 	DP_PRINT_STATS("HTT_TX_PDEV_STATS_SIFS_TLV_V:");
629 	for (i = 0; i <  tag_len; i++) {
630 		index += qdf_snprint(&sifs_status[index],
631 				DP_MAX_STRING_LEN - index,
632 				" %u:%u,", i, dp_stats_buf->sifs_status[i]);
633 	}
634 	DP_PRINT_STATS("sifs_status = %s\n", sifs_status);
635 	qdf_mem_free(sifs_status);
636 }
637 
638 /**
639  * dp_print_tx_pdev_stats_phy_err_tlv_v() - display htt_tx_pdev_stats_phy_err_tlv_v
640  * @tag_buf: buffer containing the tlv htt_tx_pdev_stats_phy_err_tlv_v
641  *
642  * Return: void
643  */
dp_print_tx_pdev_stats_phy_err_tlv_v(uint32_t * tag_buf)644 static void dp_print_tx_pdev_stats_phy_err_tlv_v(uint32_t *tag_buf)
645 {
646 	htt_tx_pdev_stats_phy_err_tlv_v *dp_stats_buf =
647 		(htt_tx_pdev_stats_phy_err_tlv_v *)tag_buf;
648 	uint8_t i;
649 	uint16_t index = 0;
650 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
651 	char *phy_errs = qdf_mem_malloc(DP_MAX_STRING_LEN);
652 
653 	if (!phy_errs) {
654 		dp_stats_err("Output buffer not allocated");
655 		return;
656 	}
657 
658 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_PDEV_MAX_PHY_ERR_STATS);
659 
660 	DP_PRINT_STATS("HTT_TX_PDEV_STATS_PHY_ERR_TLV_V:");
661 	for (i = 0; i <  tag_len; i++) {
662 		index += qdf_snprint(&phy_errs[index],
663 				DP_MAX_STRING_LEN - index,
664 				" %u:%u,", i, dp_stats_buf->phy_errs[i]);
665 	}
666 	DP_PRINT_STATS("phy_errs = %s\n", phy_errs);
667 	qdf_mem_free(phy_errs);
668 }
669 
670 /**
671  * dp_print_hw_stats_intr_misc_tlv() - display htt_hw_stats_intr_misc_tlv
672  * @tag_buf: buffer containing the tlv htt_hw_stats_intr_misc_tlv
673  *
674  * Return: void
675  */
dp_print_hw_stats_intr_misc_tlv(uint32_t * tag_buf)676 static void dp_print_hw_stats_intr_misc_tlv(uint32_t *tag_buf)
677 {
678 	htt_hw_stats_intr_misc_tlv *dp_stats_buf =
679 		(htt_hw_stats_intr_misc_tlv *)tag_buf;
680 	uint8_t i;
681 	uint16_t index = 0;
682 	char *hw_intr_name = qdf_mem_malloc(DP_MAX_STRING_LEN);
683 
684 	if (!hw_intr_name) {
685 		dp_stats_err("Output buffer not allocated");
686 		return;
687 	}
688 
689 	DP_PRINT_STATS("HTT_HW_STATS_INTR_MISC_TLV:");
690 	for (i = 0; i <  DP_HTT_HW_INTR_NAME_LEN; i++) {
691 		index += qdf_snprint(&hw_intr_name[index],
692 				DP_MAX_STRING_LEN - index,
693 				" %u:%u,", i, dp_stats_buf->hw_intr_name[i]);
694 	}
695 	DP_PRINT_STATS("hw_intr_name = %s ", hw_intr_name);
696 	DP_PRINT_STATS("mask = %u",
697 		       dp_stats_buf->mask);
698 	DP_PRINT_STATS("count = %u\n",
699 		       dp_stats_buf->count);
700 	qdf_mem_free(hw_intr_name);
701 }
702 
703 /**
704  * dp_print_hw_stats_wd_timeout_tlv() - display htt_hw_stats_wd_timeout_tlv
705  * @tag_buf: buffer containing the tlv htt_hw_stats_wd_timeout_tlv
706  *
707  * Return: void
708  */
dp_print_hw_stats_wd_timeout_tlv(uint32_t * tag_buf)709 static void dp_print_hw_stats_wd_timeout_tlv(uint32_t *tag_buf)
710 {
711 	htt_hw_stats_wd_timeout_tlv *dp_stats_buf =
712 		(htt_hw_stats_wd_timeout_tlv *)tag_buf;
713 	uint8_t i;
714 	uint16_t index = 0;
715 	char *hw_module_name = qdf_mem_malloc(DP_MAX_STRING_LEN);
716 
717 	if (!hw_module_name) {
718 		dp_stats_err("Output buffer not allocated");
719 		return;
720 	}
721 
722 	DP_PRINT_STATS("HTT_HW_STATS_WD_TIMEOUT_TLV:");
723 	for (i = 0; i <  DP_HTT_HW_MODULE_NAME_LEN; i++) {
724 		index += qdf_snprint(&hw_module_name[index],
725 				DP_MAX_STRING_LEN - index,
726 				" %u:%u,", i, dp_stats_buf->hw_module_name[i]);
727 	}
728 	DP_PRINT_STATS("hw_module_name = %s ", hw_module_name);
729 	DP_PRINT_STATS("count = %u",
730 		       dp_stats_buf->count);
731 	qdf_mem_free(hw_module_name);
732 }
733 
734 /**
735  * dp_print_hw_stats_pdev_errs_tlv() - display htt_hw_stats_pdev_errs_tlv
736  * @tag_buf: buffer containing the tlv htt_hw_stats_pdev_errs_tlv
737  *
738  * Return: void
739  */
dp_print_hw_stats_pdev_errs_tlv(uint32_t * tag_buf)740 static void dp_print_hw_stats_pdev_errs_tlv(uint32_t *tag_buf)
741 {
742 	htt_hw_stats_pdev_errs_tlv *dp_stats_buf =
743 		(htt_hw_stats_pdev_errs_tlv *)tag_buf;
744 
745 	DP_PRINT_STATS("HTT_HW_STATS_PDEV_ERRS_TLV:");
746 	DP_PRINT_STATS("mac_id__word = %u",
747 		       dp_stats_buf->mac_id__word);
748 	DP_PRINT_STATS("tx_abort = %u",
749 		       dp_stats_buf->tx_abort);
750 	DP_PRINT_STATS("tx_abort_fail_count = %u",
751 		       dp_stats_buf->tx_abort_fail_count);
752 	DP_PRINT_STATS("rx_abort = %u",
753 		       dp_stats_buf->rx_abort);
754 	DP_PRINT_STATS("rx_abort_fail_count = %u",
755 		       dp_stats_buf->rx_abort_fail_count);
756 	DP_PRINT_STATS("warm_reset = %u",
757 		       dp_stats_buf->warm_reset);
758 	DP_PRINT_STATS("cold_reset = %u",
759 		       dp_stats_buf->cold_reset);
760 	DP_PRINT_STATS("tx_flush = %u",
761 		       dp_stats_buf->tx_flush);
762 	DP_PRINT_STATS("tx_glb_reset = %u",
763 		       dp_stats_buf->tx_glb_reset);
764 	DP_PRINT_STATS("tx_txq_reset = %u",
765 		       dp_stats_buf->tx_txq_reset);
766 	DP_PRINT_STATS("rx_timeout_reset = %u\n",
767 		       dp_stats_buf->rx_timeout_reset);
768 }
769 
770 /**
771  * dp_print_msdu_flow_stats_tlv() - display htt_msdu_flow_stats_tlv
772  * @tag_buf: buffer containing the tlv htt_msdu_flow_stats_tlv
773  *
774  * Return: void
775  */
dp_print_msdu_flow_stats_tlv(uint32_t * tag_buf)776 static void dp_print_msdu_flow_stats_tlv(uint32_t *tag_buf)
777 {
778 	htt_msdu_flow_stats_tlv *dp_stats_buf =
779 		(htt_msdu_flow_stats_tlv *)tag_buf;
780 
781 	DP_PRINT_STATS("HTT_MSDU_FLOW_STATS_TLV:");
782 	DP_PRINT_STATS("last_update_timestamp = %u",
783 		       dp_stats_buf->last_update_timestamp);
784 	DP_PRINT_STATS("last_add_timestamp = %u",
785 		       dp_stats_buf->last_add_timestamp);
786 	DP_PRINT_STATS("last_remove_timestamp = %u",
787 		       dp_stats_buf->last_remove_timestamp);
788 	DP_PRINT_STATS("total_processed_msdu_count = %u",
789 		       dp_stats_buf->total_processed_msdu_count);
790 	DP_PRINT_STATS("cur_msdu_count_in_flowq = %u",
791 		       dp_stats_buf->cur_msdu_count_in_flowq);
792 	DP_PRINT_STATS("sw_peer_id = %u",
793 		       dp_stats_buf->sw_peer_id);
794 	DP_PRINT_STATS("tx_flow_no__tid_num__drop_rule = %u\n",
795 		       dp_stats_buf->tx_flow_no__tid_num__drop_rule);
796 }
797 
798 /**
799  * dp_print_tx_tid_stats_tlv() - display htt_tx_tid_stats_tlv
800  * @tag_buf: buffer containing the tlv htt_tx_tid_stats_tlv
801  *
802  * Return: void
803  */
dp_print_tx_tid_stats_tlv(uint32_t * tag_buf)804 static void dp_print_tx_tid_stats_tlv(uint32_t *tag_buf)
805 {
806 	htt_tx_tid_stats_tlv *dp_stats_buf =
807 		(htt_tx_tid_stats_tlv *)tag_buf;
808 	uint8_t i;
809 	uint16_t index = 0;
810 	char *tid_name = qdf_mem_malloc(DP_MAX_STRING_LEN);
811 
812 	if (!tid_name) {
813 		dp_stats_err("Output buffer not allocated");
814 		return;
815 	}
816 
817 	DP_PRINT_STATS("HTT_TX_TID_STATS_TLV:");
818 	for (i = 0; i <  DP_HTT_TID_NAME_LEN; i++) {
819 		index += qdf_snprint(&tid_name[index],
820 				DP_MAX_STRING_LEN - index,
821 				" %u:%u,", i, dp_stats_buf->tid_name[i]);
822 	}
823 	DP_PRINT_STATS("tid_name = %s ", tid_name);
824 	DP_PRINT_STATS("sw_peer_id__tid_num = %u",
825 		       dp_stats_buf->sw_peer_id__tid_num);
826 	DP_PRINT_STATS("num_sched_pending__num_ppdu_in_hwq = %u",
827 		       dp_stats_buf->num_sched_pending__num_ppdu_in_hwq);
828 	DP_PRINT_STATS("tid_flags = %u",
829 		       dp_stats_buf->tid_flags);
830 	DP_PRINT_STATS("hw_queued = %u",
831 		       dp_stats_buf->hw_queued);
832 	DP_PRINT_STATS("hw_reaped = %u",
833 		       dp_stats_buf->hw_reaped);
834 	DP_PRINT_STATS("mpdus_hw_filter = %u",
835 		       dp_stats_buf->mpdus_hw_filter);
836 	DP_PRINT_STATS("qdepth_bytes = %u",
837 		       dp_stats_buf->qdepth_bytes);
838 	DP_PRINT_STATS("qdepth_num_msdu = %u",
839 		       dp_stats_buf->qdepth_num_msdu);
840 	DP_PRINT_STATS("qdepth_num_mpdu = %u",
841 		       dp_stats_buf->qdepth_num_mpdu);
842 	DP_PRINT_STATS("last_scheduled_tsmp = %u",
843 		       dp_stats_buf->last_scheduled_tsmp);
844 	DP_PRINT_STATS("pause_module_id = %u",
845 		       dp_stats_buf->pause_module_id);
846 	DP_PRINT_STATS("block_module_id = %u\n",
847 		       dp_stats_buf->block_module_id);
848 	DP_PRINT_STATS("tid_tx_airtime = %u\n",
849 		       dp_stats_buf->tid_tx_airtime);
850 	qdf_mem_free(tid_name);
851 }
852 
853 /**
854  * dp_print_tx_tid_stats_v1_tlv() - display htt_tx_tid_stats_v1_tlv
855  * @tag_buf: buffer containing the tlv htt_tx_tid_stats_v1_tlv
856  *
857  * Return: void
858  */
dp_print_tx_tid_stats_v1_tlv(uint32_t * tag_buf)859 static void dp_print_tx_tid_stats_v1_tlv(uint32_t *tag_buf)
860 {
861 	htt_tx_tid_stats_v1_tlv *dp_stats_buf =
862 		(htt_tx_tid_stats_v1_tlv *)tag_buf;
863 	uint8_t i;
864 	uint16_t index = 0;
865 	char *tid_name = qdf_mem_malloc(DP_MAX_STRING_LEN);
866 
867 	if (!tid_name) {
868 		dp_stats_err("Output buffer not allocated");
869 		return;
870 	}
871 
872 	DP_PRINT_STATS("HTT_TX_TID_STATS_V1_TLV:");
873 	for (i = 0; i <  DP_HTT_TID_NAME_LEN; i++) {
874 		index += qdf_snprint(&tid_name[index],
875 				DP_MAX_STRING_LEN - index,
876 				" %u:%u,", i, dp_stats_buf->tid_name[i]);
877 	}
878 	DP_PRINT_STATS("tid_name = %s ", tid_name);
879 	DP_PRINT_STATS("sw_peer_id__tid_num = %u",
880 		       dp_stats_buf->sw_peer_id__tid_num);
881 	DP_PRINT_STATS("num_sched_pending__num_ppdu_in_hwq = %u",
882 		       dp_stats_buf->num_sched_pending__num_ppdu_in_hwq);
883 	DP_PRINT_STATS("tid_flags = %u",
884 		       dp_stats_buf->tid_flags);
885 	DP_PRINT_STATS("max_qdepth_bytes = %u",
886 		       dp_stats_buf->max_qdepth_bytes);
887 	DP_PRINT_STATS("max_qdepth_n_msdus = %u",
888 		       dp_stats_buf->max_qdepth_n_msdus);
889 	DP_PRINT_STATS("rsvd = %u",
890 		       dp_stats_buf->rsvd);
891 	DP_PRINT_STATS("qdepth_bytes = %u",
892 		       dp_stats_buf->qdepth_bytes);
893 	DP_PRINT_STATS("qdepth_num_msdu = %u",
894 		       dp_stats_buf->qdepth_num_msdu);
895 	DP_PRINT_STATS("qdepth_num_mpdu = %u",
896 		       dp_stats_buf->qdepth_num_mpdu);
897 	DP_PRINT_STATS("last_scheduled_tsmp = %u",
898 		       dp_stats_buf->last_scheduled_tsmp);
899 	DP_PRINT_STATS("pause_module_id = %u",
900 		       dp_stats_buf->pause_module_id);
901 	DP_PRINT_STATS("block_module_id = %u\n",
902 		       dp_stats_buf->block_module_id);
903 	DP_PRINT_STATS("tid_tx_airtime = %u\n",
904 		       dp_stats_buf->tid_tx_airtime);
905 	qdf_mem_free(tid_name);
906 }
907 
908 /**
909  * dp_print_rx_tid_stats_tlv() - display htt_rx_tid_stats_tlv
910  * @tag_buf: buffer containing the tlv htt_rx_tid_stats_tlv
911  *
912  * Return: void
913  */
dp_print_rx_tid_stats_tlv(uint32_t * tag_buf)914 static void dp_print_rx_tid_stats_tlv(uint32_t *tag_buf)
915 {
916 	htt_rx_tid_stats_tlv *dp_stats_buf =
917 		(htt_rx_tid_stats_tlv *)tag_buf;
918 	uint8_t i;
919 	uint16_t index = 0;
920 	char *tid_name = qdf_mem_malloc(DP_MAX_STRING_LEN);
921 
922 	if (!tid_name) {
923 		dp_stats_err("Output buffer not allocated");
924 		return;
925 	}
926 
927 	DP_PRINT_STATS("HTT_RX_TID_STATS_TLV:");
928 	DP_PRINT_STATS("sw_peer_id__tid_num = %u",
929 		       dp_stats_buf->sw_peer_id__tid_num);
930 	for (i = 0; i <  DP_HTT_TID_NAME_LEN; i++) {
931 		index += qdf_snprint(&tid_name[index],
932 				DP_MAX_STRING_LEN - index,
933 				" %u:%u,", i, dp_stats_buf->tid_name[i]);
934 	}
935 	DP_PRINT_STATS("tid_name = %s ", tid_name);
936 	DP_PRINT_STATS("dup_in_reorder = %u",
937 		       dp_stats_buf->dup_in_reorder);
938 	DP_PRINT_STATS("dup_past_outside_window = %u",
939 		       dp_stats_buf->dup_past_outside_window);
940 	DP_PRINT_STATS("dup_past_within_window = %u",
941 		       dp_stats_buf->dup_past_within_window);
942 	DP_PRINT_STATS("rxdesc_err_decrypt = %u\n",
943 		       dp_stats_buf->rxdesc_err_decrypt);
944 	qdf_mem_free(tid_name);
945 }
946 
947 /**
948  * dp_print_counter_tlv() - display htt_counter_tlv
949  * @tag_buf: buffer containing the tlv htt_counter_tlv
950  *
951  * Return: void
952  */
dp_print_counter_tlv(uint32_t * tag_buf)953 static void dp_print_counter_tlv(uint32_t *tag_buf)
954 {
955 	htt_counter_tlv *dp_stats_buf =
956 		(htt_counter_tlv *)tag_buf;
957 	uint8_t i;
958 	uint16_t index = 0;
959 	char *counter_name = qdf_mem_malloc(DP_MAX_STRING_LEN);
960 
961 	if (!counter_name) {
962 		dp_stats_err("Output buffer not allocated");
963 		return;
964 	}
965 
966 	DP_PRINT_STATS("HTT_COUNTER_TLV:");
967 	for (i = 0; i <  DP_HTT_COUNTER_NAME_LEN; i++) {
968 		index += qdf_snprint(&counter_name[index],
969 				DP_MAX_STRING_LEN - index,
970 				" %u:%u,", i, dp_stats_buf->counter_name[i]);
971 	}
972 	DP_PRINT_STATS("counter_name = %s ", counter_name);
973 	DP_PRINT_STATS("count = %u\n",
974 		       dp_stats_buf->count);
975 	qdf_mem_free(counter_name);
976 }
977 
978 /**
979  * dp_print_peer_stats_cmn_tlv() - display htt_peer_stats_cmn_tlv
980  * @tag_buf: buffer containing the tlv htt_peer_stats_cmn_tlv
981  *
982  * Return: void
983  */
dp_print_peer_stats_cmn_tlv(uint32_t * tag_buf)984 static void dp_print_peer_stats_cmn_tlv(uint32_t *tag_buf)
985 {
986 	htt_peer_stats_cmn_tlv *dp_stats_buf =
987 		(htt_peer_stats_cmn_tlv *)tag_buf;
988 
989 	DP_PRINT_STATS("HTT_PEER_STATS_CMN_TLV:");
990 	DP_PRINT_STATS("ppdu_cnt = %u",
991 		       dp_stats_buf->ppdu_cnt);
992 	DP_PRINT_STATS("mpdu_cnt = %u",
993 		       dp_stats_buf->mpdu_cnt);
994 	DP_PRINT_STATS("msdu_cnt = %u",
995 		       dp_stats_buf->msdu_cnt);
996 	DP_PRINT_STATS("pause_bitmap = %u",
997 		       dp_stats_buf->pause_bitmap);
998 	DP_PRINT_STATS("block_bitmap = %u",
999 		       dp_stats_buf->block_bitmap);
1000 	DP_PRINT_STATS("current_timestamp = %u\n",
1001 		       dp_stats_buf->current_timestamp);
1002 	DP_PRINT_STATS("inactive_time = %u",
1003 		       dp_stats_buf->inactive_time);
1004 }
1005 
1006 /**
1007  * dp_print_peer_details_tlv() - display htt_peer_details_tlv
1008  * @tag_buf: buffer containing the tlv htt_peer_details_tlv
1009  *
1010  * Return: void
1011  */
dp_print_peer_details_tlv(uint32_t * tag_buf)1012 static void dp_print_peer_details_tlv(uint32_t *tag_buf)
1013 {
1014 	htt_peer_details_tlv *dp_stats_buf =
1015 		(htt_peer_details_tlv *)tag_buf;
1016 
1017 	DP_PRINT_STATS("HTT_PEER_DETAILS_TLV:");
1018 	DP_PRINT_STATS("peer_type = %u",
1019 		       dp_stats_buf->peer_type);
1020 	DP_PRINT_STATS("sw_peer_id = %u",
1021 		       dp_stats_buf->sw_peer_id);
1022 	DP_PRINT_STATS("vdev_pdev_ast_idx = %u",
1023 		       dp_stats_buf->vdev_pdev_ast_idx);
1024 	DP_PRINT_STATS("mac_addr(upper 4 bytes) = %u",
1025 		       dp_stats_buf->mac_addr.mac_addr31to0);
1026 	DP_PRINT_STATS("mac_addr(lower 2 bytes) = %u",
1027 		       dp_stats_buf->mac_addr.mac_addr47to32);
1028 	DP_PRINT_STATS("peer_flags = %u",
1029 		       dp_stats_buf->peer_flags);
1030 	DP_PRINT_STATS("qpeer_flags = %u\n",
1031 		       dp_stats_buf->qpeer_flags);
1032 }
1033 
1034 /**
1035  * dp_print_tx_peer_rate_stats_tlv() - display htt_tx_peer_rate_stats_tlv
1036  * @tag_buf: buffer containing the tlv htt_tx_peer_rate_stats_tlv
1037  *
1038  * Return: void
1039  */
dp_print_tx_peer_rate_stats_tlv(uint32_t * tag_buf)1040 static void dp_print_tx_peer_rate_stats_tlv(uint32_t *tag_buf)
1041 {
1042 	htt_tx_peer_rate_stats_tlv *dp_stats_buf =
1043 		(htt_tx_peer_rate_stats_tlv *)tag_buf;
1044 	uint8_t i, j;
1045 	uint16_t index = 0;
1046 	char *tx_gi[HTT_TX_PEER_STATS_NUM_GI_COUNTERS] = {0};
1047 	char *tx_gi_ext[HTT_TX_PEER_STATS_NUM_GI_COUNTERS] = {0};
1048 	char *str_buf = qdf_mem_malloc(DP_MAX_STRING_LEN);
1049 
1050 	if (!str_buf) {
1051 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
1052 			  FL("Output buffer not allocated"));
1053 		return;
1054 	}
1055 
1056 	for (i = 0; i < HTT_TX_PEER_STATS_NUM_GI_COUNTERS; i++) {
1057 		tx_gi[i] = (char *)qdf_mem_malloc(DP_MAX_STRING_LEN);
1058 		tx_gi_ext[i] = (char *)qdf_mem_malloc(DP_MAX_STRING_LEN);
1059 		if (!tx_gi[i] || !tx_gi_ext[i]) {
1060 			dp_err("Unable to allocate buffer for tx_gi");
1061 			goto fail1;
1062 		}
1063 	}
1064 
1065 	DP_PRINT_STATS("HTT_TX_PEER_RATE_STATS_TLV:");
1066 	DP_PRINT_STATS("tx_ldpc = %u",
1067 		       dp_stats_buf->tx_ldpc);
1068 	DP_PRINT_STATS("rts_cnt = %u",
1069 		       dp_stats_buf->rts_cnt);
1070 	DP_PRINT_STATS("ack_rssi = %u",
1071 		       dp_stats_buf->ack_rssi);
1072 
1073 	index = 0;
1074 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1075 	for (i = 0; i <  DP_HTT_TX_MCS_LEN; i++) {
1076 		index += qdf_snprint(&str_buf[index],
1077 				DP_MAX_STRING_LEN - index,
1078 				" %u:%u,", i, dp_stats_buf->tx_mcs[i]);
1079 	}
1080 	for (i = 0; i <  DP_HTT_TX_MCS_EXT_LEN; i++) {
1081 		index += qdf_snprint(&str_buf[index],
1082 				DP_MAX_STRING_LEN - index,
1083 				" %u:%u,", i + DP_HTT_TX_MCS_LEN,
1084 				dp_stats_buf->tx_mcs_ext[i]);
1085 	}
1086 	DP_PRINT_STATS("tx_mcs = %s ", str_buf);
1087 
1088 	index = 0;
1089 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1090 	for (i = 0; i <  DP_HTT_TX_SU_MCS_LEN; i++) {
1091 		index += qdf_snprint(&str_buf[index],
1092 				DP_MAX_STRING_LEN - index,
1093 				" %u:%u,", i, dp_stats_buf->tx_su_mcs[i]);
1094 	}
1095 	for (i = 0; i <  DP_HTT_TX_SU_MCS_EXT_LEN; i++) {
1096 		index += qdf_snprint(&str_buf[index],
1097 				DP_MAX_STRING_LEN - index,
1098 				" %u:%u,", i + DP_HTT_TX_SU_MCS_LEN,
1099 				dp_stats_buf->tx_su_mcs_ext[i]);
1100 	}
1101 	DP_PRINT_STATS("tx_su_mcs = %s ", str_buf);
1102 
1103 
1104 	index = 0;
1105 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1106 	for (i = 0; i <  DP_HTT_TX_MU_MCS_LEN; i++) {
1107 		index += qdf_snprint(&str_buf[index],
1108 				DP_MAX_STRING_LEN - index,
1109 				" %u:%u,", i, dp_stats_buf->tx_mu_mcs[i]);
1110 	}
1111 	for (i = 0; i <  DP_HTT_TX_MU_MCS_EXT_LEN; i++) {
1112 		index += qdf_snprint(&str_buf[index],
1113 				DP_MAX_STRING_LEN - index,
1114 				" %u:%u,", i + DP_HTT_TX_MU_MCS_LEN,
1115 				dp_stats_buf->tx_mu_mcs_ext[i]);
1116 	}
1117 	DP_PRINT_STATS("tx_mu_mcs = %s ", str_buf);
1118 
1119 	index = 0;
1120 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1121 	for (i = 0; i <  DP_HTT_TX_NSS_LEN; i++) {
1122 		/* 0 stands for NSS 1, 1 stands for NSS 2, etc. */
1123 		index += qdf_snprint(&str_buf[index],
1124 				DP_MAX_STRING_LEN - index,
1125 				" %u:%u,", (i + 1),
1126 				dp_stats_buf->tx_nss[i]);
1127 	}
1128 	DP_PRINT_STATS("tx_nss = %s ", str_buf);
1129 	index = 0;
1130 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1131 	for (i = 0; i <  DP_HTT_TX_BW_LEN; i++) {
1132 		index += qdf_snprint(&str_buf[index],
1133 				DP_MAX_STRING_LEN - index,
1134 				" %u:%u,", i, dp_stats_buf->tx_bw[i]);
1135 	}
1136 	DP_PRINT_STATS("tx_bw = %s ", str_buf);
1137 
1138 	index = 0;
1139 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1140 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
1141 		index += qdf_snprint(&str_buf[index],
1142 				DP_MAX_STRING_LEN - index,
1143 				" %u:%u,", i, dp_stats_buf->tx_stbc[i]);
1144 	}
1145 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++) {
1146 		index += qdf_snprint(&str_buf[index],
1147 				DP_MAX_STRING_LEN - index,
1148 				" %u:%u,", i +  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
1149 				dp_stats_buf->tx_stbc_ext[i]);
1150 	}
1151 	DP_PRINT_STATS("tx_stbc = %s ", str_buf);
1152 
1153 
1154 	index = 0;
1155 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1156 
1157 	for (i = 0; i <  DP_HTT_TX_PREAM_LEN; i++) {
1158 		index += qdf_snprint(&str_buf[index],
1159 				DP_MAX_STRING_LEN - index,
1160 				" %u:%u,", i, dp_stats_buf->tx_pream[i]);
1161 	}
1162 	DP_PRINT_STATS("tx_pream = %s ", str_buf);
1163 
1164 	for (j = 0; j < HTT_TX_PEER_STATS_NUM_GI_COUNTERS; j++) {
1165 		index = 0;
1166 		for (i = 0; i <  HTT_TX_PEER_STATS_NUM_MCS_COUNTERS; i++) {
1167 			index += qdf_snprint(&tx_gi[j][index],
1168 					DP_MAX_STRING_LEN - index,
1169 					" %u:%u,", i,
1170 					dp_stats_buf->tx_gi[j][i]);
1171 		}
1172 		DP_PRINT_STATS("tx_gi[%u] = %s ", j, tx_gi[j]);
1173 	}
1174 
1175 	for (j = 0; j < HTT_TX_PEER_STATS_NUM_GI_COUNTERS; j++) {
1176 		index = 0;
1177 		for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++) {
1178 			index += qdf_snprint(&tx_gi_ext[j][index],
1179 					DP_MAX_STRING_LEN - index,
1180 					" %u:%u,", i,
1181 					dp_stats_buf->tx_gi_ext[j][i]);
1182 		}
1183 		DP_PRINT_STATS("tx_gi_ext[%u] = %s ", j, tx_gi_ext[j]);
1184 	}
1185 
1186 	index = 0;
1187 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1188 	for (i = 0; i <  DP_HTT_TX_DCM_LEN; i++) {
1189 		index += qdf_snprint(&str_buf[index],
1190 				DP_MAX_STRING_LEN - index,
1191 				" %u:%u,", i, dp_stats_buf->tx_dcm[i]);
1192 	}
1193 	DP_PRINT_STATS("tx_dcm = %s\n", str_buf);
1194 
1195 fail1:
1196 	for (i = 0; i < HTT_TX_PEER_STATS_NUM_GI_COUNTERS; i++) {
1197 		if (tx_gi[i])
1198 			qdf_mem_free(tx_gi[i]);
1199 		if (tx_gi_ext[i])
1200 			qdf_mem_free(tx_gi_ext[i]);
1201 	}
1202 	qdf_mem_free(str_buf);
1203 }
1204 
1205 /**
1206  * dp_print_rx_peer_rate_stats_tlv() - display htt_rx_peer_rate_stats_tlv
1207  * @tag_buf: buffer containing the tlv htt_rx_peer_rate_stats_tlv
1208  *
1209  * Return: void
1210  */
dp_print_rx_peer_rate_stats_tlv(uint32_t * tag_buf)1211 static void dp_print_rx_peer_rate_stats_tlv(uint32_t *tag_buf)
1212 {
1213 	htt_rx_peer_rate_stats_tlv *dp_stats_buf =
1214 		(htt_rx_peer_rate_stats_tlv *)tag_buf;
1215 	uint8_t i, j;
1216 	uint16_t index = 0;
1217 	char *rssi_chain[DP_HTT_PEER_NUM_SS] = {0};
1218 	char *rx_gi[HTT_RX_PEER_STATS_NUM_GI_COUNTERS] = {0};
1219 	char *rx_gi_ext[HTT_RX_PEER_STATS_NUM_GI_COUNTERS] = {0};
1220 	char *str_buf = qdf_mem_malloc(DP_MAX_STRING_LEN);
1221 
1222 	if (!str_buf) {
1223 		dp_stats_err("Output buffer not allocated");
1224 		return;
1225 	}
1226 
1227 	for (i = 0; i < DP_HTT_PEER_NUM_SS; i++) {
1228 		rssi_chain[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
1229 		if (!rssi_chain[i]) {
1230 			dp_err("Unable to allocate buffer for rssi_chain");
1231 			goto fail1;
1232 		}
1233 	}
1234 
1235 	for (i = 0; i < HTT_RX_PEER_STATS_NUM_GI_COUNTERS; i++) {
1236 		rx_gi[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
1237 		rx_gi_ext[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
1238 		if (!rx_gi[i] || !rx_gi_ext[i]) {
1239 			dp_err("Unable to allocate buffer for rx_gi");
1240 			goto fail1;
1241 		}
1242 	}
1243 
1244 	DP_PRINT_STATS("HTT_RX_PEER_RATE_STATS_TLV:");
1245 	DP_PRINT_STATS("nsts = %u",
1246 		       dp_stats_buf->nsts);
1247 	DP_PRINT_STATS("rx_ldpc = %u",
1248 		       dp_stats_buf->rx_ldpc);
1249 	DP_PRINT_STATS("rts_cnt = %u",
1250 		       dp_stats_buf->rts_cnt);
1251 	DP_PRINT_STATS("rssi_mgmt = %u",
1252 		       dp_stats_buf->rssi_mgmt);
1253 	DP_PRINT_STATS("rssi_data = %u",
1254 		       dp_stats_buf->rssi_data);
1255 	DP_PRINT_STATS("rssi_comb = %u",
1256 		       dp_stats_buf->rssi_comb);
1257 
1258 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1259 	for (i = 0; i <  DP_HTT_RX_MCS_LEN; i++) {
1260 		index += qdf_snprint(&str_buf[index],
1261 				DP_MAX_STRING_LEN - index,
1262 				" %u:%u,", i, dp_stats_buf->rx_mcs[i]);
1263 	}
1264 	for (i = 0; i <  DP_HTT_RX_MCS_EXT_LEN; i++) {
1265 		index += qdf_snprint(&str_buf[index],
1266 				DP_MAX_STRING_LEN - index,
1267 				" %u:%u,", i + DP_HTT_RX_MCS_LEN,
1268 				dp_stats_buf->rx_mcs_ext[i]);
1269 	}
1270 	DP_PRINT_STATS("rx_mcs = %s ", str_buf);
1271 
1272 	index = 0;
1273 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1274 	for (i = 0; i <  DP_HTT_RX_NSS_LEN; i++) {
1275 		/* 0 stands for NSS 1, 1 stands for NSS 2, etc. */
1276 		index += qdf_snprint(&str_buf[index],
1277 				DP_MAX_STRING_LEN - index,
1278 				" %u:%u,", (i + 1),
1279 				dp_stats_buf->rx_nss[i]);
1280 	}
1281 	DP_PRINT_STATS("rx_nss = %s ", str_buf);
1282 
1283 	index = 0;
1284 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1285 	for (i = 0; i <  DP_HTT_RX_DCM_LEN; i++) {
1286 		index += qdf_snprint(&str_buf[index],
1287 				DP_MAX_STRING_LEN - index,
1288 				" %u:%u,", i, dp_stats_buf->rx_dcm[i]);
1289 	}
1290 	DP_PRINT_STATS("rx_dcm = %s ", str_buf);
1291 
1292 	index = 0;
1293 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1294 	for (i = 0; i <  HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
1295 		index += qdf_snprint(&str_buf[index],
1296 				DP_MAX_STRING_LEN - index,
1297 				" %u:%u,", i, dp_stats_buf->rx_stbc[i]);
1298 	}
1299 	for (i = 0; i <  HTT_RX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++) {
1300 		index += qdf_snprint(&str_buf[index],
1301 				DP_MAX_STRING_LEN - index,
1302 				" %u:%u,", i + HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS,
1303 				dp_stats_buf->rx_stbc_ext[i]);
1304 	}
1305 	DP_PRINT_STATS("rx_stbc = %s ", str_buf);
1306 
1307 	index = 0;
1308 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1309 	for (i = 0; i <  DP_HTT_RX_BW_LEN; i++) {
1310 		index += qdf_snprint(&str_buf[index],
1311 				DP_MAX_STRING_LEN - index,
1312 				" %u:%u,", i, dp_stats_buf->rx_bw[i]);
1313 	}
1314 	DP_PRINT_STATS("rx_bw = %s ", str_buf);
1315 
1316 	for (j = 0; j < DP_HTT_PEER_NUM_SS; j++) {
1317 		qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1318 		index = 0;
1319 		for (i = 0; i <  HTT_RX_PEER_STATS_NUM_BW_COUNTERS; i++) {
1320 			index += qdf_snprint(&rssi_chain[j][index],
1321 					DP_MAX_STRING_LEN - index,
1322 					" %u:%u,", i,
1323 					dp_stats_buf->rssi_chain[j][i]);
1324 		}
1325 		DP_PRINT_STATS("rssi_chain[%u] = %s ", j, rssi_chain[j]);
1326 	}
1327 
1328 	for (j = 0; j < HTT_RX_PEER_STATS_NUM_GI_COUNTERS; j++) {
1329 		index = 0;
1330 		for (i = 0; i <  HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
1331 			index += qdf_snprint(&rx_gi[j][index],
1332 					DP_MAX_STRING_LEN - index,
1333 					" %u:%u,", i,
1334 					dp_stats_buf->rx_gi[j][i]);
1335 		}
1336 		DP_PRINT_STATS("rx_gi[%u] = %s ", j, rx_gi[j]);
1337 	}
1338 
1339 	for (j = 0; j < HTT_RX_PEER_STATS_NUM_GI_COUNTERS; j++) {
1340 		index = 0;
1341 		for (i = 0; i <  HTT_RX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++) {
1342 			index += qdf_snprint(&rx_gi_ext[j][index],
1343 					DP_MAX_STRING_LEN - index,
1344 					" %u:%u,", i,
1345 					dp_stats_buf->rx_gi_ext[j][i]);
1346 		}
1347 		DP_PRINT_STATS("rx_gi_ext[%u] = %s ", j, rx_gi_ext[j]);
1348 	}
1349 
1350 	index = 0;
1351 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
1352 	for (i = 0; i <  DP_HTT_RX_PREAM_LEN; i++) {
1353 		index += qdf_snprint(&str_buf[index],
1354 				DP_MAX_STRING_LEN - index,
1355 				" %u:%u,", i, dp_stats_buf->rx_pream[i]);
1356 	}
1357 	DP_PRINT_STATS("rx_pream = %s\n", str_buf);
1358 
1359 fail1:
1360 	for (i = 0; i < DP_HTT_PEER_NUM_SS; i++) {
1361 		if (!rssi_chain[i])
1362 			break;
1363 		qdf_mem_free(rssi_chain[i]);
1364 	}
1365 
1366 	for (i = 0; i < HTT_RX_PEER_STATS_NUM_GI_COUNTERS; i++) {
1367 		if (rx_gi[i])
1368 			qdf_mem_free(rx_gi[i]);
1369 		if (rx_gi_ext[i])
1370 			qdf_mem_free(rx_gi_ext[i]);
1371 	}
1372 	qdf_mem_free(str_buf);
1373 }
1374 
1375 /**
1376  * dp_print_tx_hwq_mu_mimo_sch_stats_tlv() - display htt_tx_hwq_mu_mimo_sch_stats
1377  * @tag_buf: buffer containing the tlv htt_tx_hwq_mu_mimo_sch_stats_tlv
1378  *
1379  * Return: void
1380  */
dp_print_tx_hwq_mu_mimo_sch_stats_tlv(uint32_t * tag_buf)1381 static void dp_print_tx_hwq_mu_mimo_sch_stats_tlv(uint32_t *tag_buf)
1382 {
1383 	htt_tx_hwq_mu_mimo_sch_stats_tlv *dp_stats_buf =
1384 		(htt_tx_hwq_mu_mimo_sch_stats_tlv *)tag_buf;
1385 
1386 	DP_PRINT_STATS("HTT_TX_HWQ_MU_MIMO_SCH_STATS_TLV:");
1387 	DP_PRINT_STATS("mu_mimo_sch_posted = %u",
1388 		       dp_stats_buf->mu_mimo_sch_posted);
1389 	DP_PRINT_STATS("mu_mimo_sch_failed = %u",
1390 		       dp_stats_buf->mu_mimo_sch_failed);
1391 	DP_PRINT_STATS("mu_mimo_ppdu_posted = %u\n",
1392 		       dp_stats_buf->mu_mimo_ppdu_posted);
1393 }
1394 
1395 /**
1396  * dp_print_tx_hwq_mu_mimo_mpdu_stats_tlv() - display htt_tx_hwq_mu_mimo_mpdu_stats
1397  * @tag_buf: buffer containing the tlv htt_tx_hwq_mu_mimo_mpdu_stats_tlv
1398  *
1399  * Return: void
1400  */
dp_print_tx_hwq_mu_mimo_mpdu_stats_tlv(uint32_t * tag_buf)1401 static void dp_print_tx_hwq_mu_mimo_mpdu_stats_tlv(uint32_t *tag_buf)
1402 {
1403 	htt_tx_hwq_mu_mimo_mpdu_stats_tlv *dp_stats_buf =
1404 		(htt_tx_hwq_mu_mimo_mpdu_stats_tlv *)tag_buf;
1405 
1406 	DP_PRINT_STATS("HTT_TX_HWQ_MU_MIMO_MPDU_STATS_TLV:");
1407 	DP_PRINT_STATS("mu_mimo_mpdus_queued_usr = %u",
1408 		       dp_stats_buf->mu_mimo_mpdus_queued_usr);
1409 	DP_PRINT_STATS("mu_mimo_mpdus_tried_usr = %u",
1410 		       dp_stats_buf->mu_mimo_mpdus_tried_usr);
1411 	DP_PRINT_STATS("mu_mimo_mpdus_failed_usr = %u",
1412 		       dp_stats_buf->mu_mimo_mpdus_failed_usr);
1413 	DP_PRINT_STATS("mu_mimo_mpdus_requeued_usr = %u",
1414 		       dp_stats_buf->mu_mimo_mpdus_requeued_usr);
1415 	DP_PRINT_STATS("mu_mimo_err_no_ba_usr = %u",
1416 		       dp_stats_buf->mu_mimo_err_no_ba_usr);
1417 	DP_PRINT_STATS("mu_mimo_mpdu_underrun_usr = %u",
1418 		       dp_stats_buf->mu_mimo_mpdu_underrun_usr);
1419 	DP_PRINT_STATS("mu_mimo_ampdu_underrun_usr = %u\n",
1420 		       dp_stats_buf->mu_mimo_ampdu_underrun_usr);
1421 }
1422 
1423 /**
1424  * dp_print_tx_hwq_mu_mimo_cmn_stats_tlv() - display htt_tx_hwq_mu_mimo_cmn_stats
1425  * @tag_buf: buffer containing the tlv htt_tx_hwq_mu_mimo_cmn_stats_tlv
1426  *
1427  * Return: void
1428  */
dp_print_tx_hwq_mu_mimo_cmn_stats_tlv(uint32_t * tag_buf)1429 static inline void dp_print_tx_hwq_mu_mimo_cmn_stats_tlv(uint32_t *tag_buf)
1430 {
1431 	htt_tx_hwq_mu_mimo_cmn_stats_tlv *dp_stats_buf =
1432 		(htt_tx_hwq_mu_mimo_cmn_stats_tlv *)tag_buf;
1433 
1434 	DP_PRINT_STATS("HTT_TX_HWQ_MU_MIMO_CMN_STATS_TLV:");
1435 	DP_PRINT_STATS("mac_id__hwq_id__word = %u\n",
1436 		       dp_stats_buf->mac_id__hwq_id__word);
1437 }
1438 
1439 /**
1440  * dp_print_tx_hwq_stats_cmn_tlv() - display htt_tx_hwq_stats_cmn_tlv
1441  * @tag_buf: buffer containing the tlv htt_tx_hwq_stats_cmn_tlv
1442  *
1443  * Return: void
1444  */
dp_print_tx_hwq_stats_cmn_tlv(uint32_t * tag_buf)1445 static void dp_print_tx_hwq_stats_cmn_tlv(uint32_t *tag_buf)
1446 {
1447 	htt_tx_hwq_stats_cmn_tlv *dp_stats_buf =
1448 		(htt_tx_hwq_stats_cmn_tlv *)tag_buf;
1449 
1450 	DP_PRINT_STATS("HTT_TX_HWQ_STATS_CMN_TLV:");
1451 	DP_PRINT_STATS("mac_id__hwq_id__word = %u",
1452 		       dp_stats_buf->mac_id__hwq_id__word);
1453 	DP_PRINT_STATS("xretry = %u",
1454 		       dp_stats_buf->xretry);
1455 	DP_PRINT_STATS("underrun_cnt = %u",
1456 		       dp_stats_buf->underrun_cnt);
1457 	DP_PRINT_STATS("flush_cnt = %u",
1458 		       dp_stats_buf->flush_cnt);
1459 	DP_PRINT_STATS("filt_cnt = %u",
1460 		       dp_stats_buf->filt_cnt);
1461 	DP_PRINT_STATS("null_mpdu_bmap = %u",
1462 		       dp_stats_buf->null_mpdu_bmap);
1463 	DP_PRINT_STATS("user_ack_failure = %u",
1464 		       dp_stats_buf->user_ack_failure);
1465 	DP_PRINT_STATS("ack_tlv_proc = %u",
1466 		       dp_stats_buf->ack_tlv_proc);
1467 	DP_PRINT_STATS("sched_id_proc = %u",
1468 		       dp_stats_buf->sched_id_proc);
1469 	DP_PRINT_STATS("null_mpdu_tx_count = %u",
1470 		       dp_stats_buf->null_mpdu_tx_count);
1471 	DP_PRINT_STATS("mpdu_bmap_not_recvd = %u",
1472 		       dp_stats_buf->mpdu_bmap_not_recvd);
1473 	DP_PRINT_STATS("num_bar = %u",
1474 		       dp_stats_buf->num_bar);
1475 	DP_PRINT_STATS("rts = %u",
1476 		       dp_stats_buf->rts);
1477 	DP_PRINT_STATS("cts2self = %u",
1478 		       dp_stats_buf->cts2self);
1479 	DP_PRINT_STATS("qos_null = %u",
1480 		       dp_stats_buf->qos_null);
1481 	DP_PRINT_STATS("mpdu_tried_cnt = %u",
1482 		       dp_stats_buf->mpdu_tried_cnt);
1483 	DP_PRINT_STATS("mpdu_queued_cnt = %u",
1484 		       dp_stats_buf->mpdu_queued_cnt);
1485 	DP_PRINT_STATS("mpdu_ack_fail_cnt = %u",
1486 		       dp_stats_buf->mpdu_ack_fail_cnt);
1487 	DP_PRINT_STATS("mpdu_filt_cnt = %u",
1488 		       dp_stats_buf->mpdu_filt_cnt);
1489 	DP_PRINT_STATS("false_mpdu_ack_count = %u\n",
1490 		       dp_stats_buf->false_mpdu_ack_count);
1491 }
1492 
1493 /**
1494  * dp_print_tx_hwq_difs_latency_stats_tlv_v() -
1495  *			display htt_tx_hwq_difs_latency_stats_tlv_v
1496  * @tag_buf: buffer containing the tlv htt_tx_hwq_difs_latency_stats_tlv_v
1497  *
1498  * Return: void
1499  */
dp_print_tx_hwq_difs_latency_stats_tlv_v(uint32_t * tag_buf)1500 static void dp_print_tx_hwq_difs_latency_stats_tlv_v(uint32_t *tag_buf)
1501 {
1502 	htt_tx_hwq_difs_latency_stats_tlv_v *dp_stats_buf =
1503 		(htt_tx_hwq_difs_latency_stats_tlv_v *)tag_buf;
1504 	uint8_t i;
1505 	uint16_t index = 0;
1506 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
1507 	char *difs_latency_hist = qdf_mem_malloc(DP_MAX_STRING_LEN);
1508 
1509 	if (!difs_latency_hist) {
1510 		dp_stats_err("Output buffer not allocated");
1511 		return;
1512 	}
1513 
1514 	tag_len = qdf_min(tag_len,
1515 			(uint32_t)HTT_TX_HWQ_MAX_DIFS_LATENCY_BINS);
1516 
1517 	DP_PRINT_STATS("HTT_TX_HWQ_DIFS_LATENCY_STATS_TLV_V:");
1518 	DP_PRINT_STATS("hist_intvl = %u",
1519 		       dp_stats_buf->hist_intvl);
1520 
1521 	for (i = 0; i <  tag_len; i++) {
1522 		index += qdf_snprint(&difs_latency_hist[index],
1523 				DP_MAX_STRING_LEN - index,
1524 				" %u:%u,", i,
1525 				dp_stats_buf->difs_latency_hist[i]);
1526 	}
1527 	DP_PRINT_STATS("difs_latency_hist = %s\n", difs_latency_hist);
1528 	qdf_mem_free(difs_latency_hist);
1529 }
1530 
1531 /**
1532  * dp_print_tx_hwq_cmd_result_stats_tlv_v() - display htt_tx_hwq_cmd_result_stats
1533  * @tag_buf: buffer containing the tlv htt_tx_hwq_cmd_result_stats_tlv_v
1534  *
1535  * Return: void
1536  */
dp_print_tx_hwq_cmd_result_stats_tlv_v(uint32_t * tag_buf)1537 static void dp_print_tx_hwq_cmd_result_stats_tlv_v(uint32_t *tag_buf)
1538 {
1539 	htt_tx_hwq_cmd_result_stats_tlv_v *dp_stats_buf =
1540 		(htt_tx_hwq_cmd_result_stats_tlv_v *)tag_buf;
1541 	uint8_t i;
1542 	uint16_t index = 0;
1543 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
1544 	char *cmd_result = qdf_mem_malloc(DP_MAX_STRING_LEN);
1545 
1546 	if (!cmd_result) {
1547 		dp_stats_err("Output buffer not allocated");
1548 		return;
1549 	}
1550 
1551 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_HWQ_MAX_CMD_RESULT_STATS);
1552 
1553 	DP_PRINT_STATS("HTT_TX_HWQ_CMD_RESULT_STATS_TLV_V:");
1554 	for (i = 0; i <  tag_len; i++) {
1555 		index += qdf_snprint(&cmd_result[index],
1556 				DP_MAX_STRING_LEN - index,
1557 				" %u:%u,", i, dp_stats_buf->cmd_result[i]);
1558 	}
1559 	DP_PRINT_STATS("cmd_result = %s ", cmd_result);
1560 	qdf_mem_free(cmd_result);
1561 }
1562 
1563 /**
1564  * dp_print_tx_hwq_cmd_stall_stats_tlv_v() - display htt_tx_hwq_cmd_stall_stats_tlv
1565  * @tag_buf: buffer containing the tlv htt_tx_hwq_cmd_stall_stats_tlv_v
1566  *
1567  * Return: void
1568  */
dp_print_tx_hwq_cmd_stall_stats_tlv_v(uint32_t * tag_buf)1569 static void dp_print_tx_hwq_cmd_stall_stats_tlv_v(uint32_t *tag_buf)
1570 {
1571 	htt_tx_hwq_cmd_stall_stats_tlv_v *dp_stats_buf =
1572 		(htt_tx_hwq_cmd_stall_stats_tlv_v *)tag_buf;
1573 	uint8_t i;
1574 	uint16_t index = 0;
1575 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
1576 	char *cmd_stall_status = qdf_mem_malloc(DP_MAX_STRING_LEN);
1577 
1578 	if (!cmd_stall_status) {
1579 		dp_stats_err("Output buffer not allocated");
1580 		return;
1581 	}
1582 
1583 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_HWQ_MAX_CMD_STALL_STATS);
1584 
1585 	DP_PRINT_STATS("HTT_TX_HWQ_CMD_STALL_STATS_TLV_V:");
1586 	for (i = 0; i <  tag_len; i++) {
1587 		index += qdf_snprint(&cmd_stall_status[index],
1588 				DP_MAX_STRING_LEN - index,
1589 				" %u:%u,", i,
1590 				dp_stats_buf->cmd_stall_status[i]);
1591 	}
1592 	DP_PRINT_STATS("cmd_stall_status = %s\n", cmd_stall_status);
1593 	qdf_mem_free(cmd_stall_status);
1594 }
1595 
1596 /**
1597  * dp_print_tx_hwq_fes_result_stats_tlv_v() - display htt_tx_hwq_fes_result_stats
1598  * @tag_buf: buffer containing the tlv htt_tx_hwq_fes_result_stats_tlv_v
1599  *
1600  * Return: void
1601  */
dp_print_tx_hwq_fes_result_stats_tlv_v(uint32_t * tag_buf)1602 static void dp_print_tx_hwq_fes_result_stats_tlv_v(uint32_t *tag_buf)
1603 {
1604 	htt_tx_hwq_fes_result_stats_tlv_v *dp_stats_buf =
1605 		(htt_tx_hwq_fes_result_stats_tlv_v *)tag_buf;
1606 	uint8_t i;
1607 	uint16_t index = 0;
1608 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
1609 	char *fes_result = qdf_mem_malloc(DP_MAX_STRING_LEN);
1610 
1611 	if (!fes_result) {
1612 		dp_stats_err("Output buffer not allocated");
1613 		return;
1614 	}
1615 
1616 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_HWQ_MAX_FES_RESULT_STATS);
1617 
1618 	DP_PRINT_STATS("HTT_TX_HWQ_FES_RESULT_STATS_TLV_V:");
1619 	for (i = 0; i <  tag_len; i++) {
1620 		index += qdf_snprint(&fes_result[index],
1621 				DP_MAX_STRING_LEN - index,
1622 				" %u:%u,", i, dp_stats_buf->fes_result[i]);
1623 	}
1624 	DP_PRINT_STATS("fes_result = %s ", fes_result);
1625 	qdf_mem_free(fes_result);
1626 }
1627 
1628 /**
1629  * dp_print_tx_selfgen_cmn_stats_tlv() - display htt_tx_selfgen_cmn_stats_tlv
1630  * @tag_buf: buffer containing the tlv htt_tx_selfgen_cmn_stats_tlv
1631  *
1632  * Return: void
1633  */
dp_print_tx_selfgen_cmn_stats_tlv(uint32_t * tag_buf)1634 static void dp_print_tx_selfgen_cmn_stats_tlv(uint32_t *tag_buf)
1635 {
1636 	htt_tx_selfgen_cmn_stats_tlv *dp_stats_buf =
1637 		(htt_tx_selfgen_cmn_stats_tlv *)tag_buf;
1638 	DP_PRINT_STATS("HTT_TX_SELFGEN_CMN_STATS_TLV:");
1639 	DP_PRINT_STATS("mac_id__word = %u",
1640 		       dp_stats_buf->mac_id__word);
1641 	DP_PRINT_STATS("su_bar = %u",
1642 		       dp_stats_buf->su_bar);
1643 	DP_PRINT_STATS("rts = %u",
1644 		       dp_stats_buf->rts);
1645 	DP_PRINT_STATS("cts2self = %u",
1646 		       dp_stats_buf->cts2self);
1647 	DP_PRINT_STATS("qos_null = %u",
1648 		       dp_stats_buf->qos_null);
1649 	DP_PRINT_STATS("delayed_bar_1 = %u",
1650 		       dp_stats_buf->delayed_bar_1);
1651 	DP_PRINT_STATS("delayed_bar_2 = %u",
1652 		       dp_stats_buf->delayed_bar_2);
1653 	DP_PRINT_STATS("delayed_bar_3 = %u",
1654 		       dp_stats_buf->delayed_bar_3);
1655 	DP_PRINT_STATS("delayed_bar_4 = %u",
1656 		       dp_stats_buf->delayed_bar_4);
1657 	DP_PRINT_STATS("delayed_bar_5 = %u",
1658 		       dp_stats_buf->delayed_bar_5);
1659 	DP_PRINT_STATS("delayed_bar_6 = %u",
1660 		       dp_stats_buf->delayed_bar_6);
1661 	DP_PRINT_STATS("delayed_bar_7 = %u\n",
1662 		       dp_stats_buf->delayed_bar_7);
1663 }
1664 
1665 /**
1666  * dp_print_tx_selfgen_ac_stats_tlv() - display htt_tx_selfgen_ac_stats_tlv
1667  * @tag_buf: buffer containing the tlv htt_tx_selfgen_ac_stats_tlv
1668  *
1669  * Return: void
1670  */
dp_print_tx_selfgen_ac_stats_tlv(uint32_t * tag_buf)1671 static void dp_print_tx_selfgen_ac_stats_tlv(uint32_t *tag_buf)
1672 {
1673 	htt_tx_selfgen_ac_stats_tlv *dp_stats_buf =
1674 		(htt_tx_selfgen_ac_stats_tlv *)tag_buf;
1675 
1676 	DP_PRINT_STATS("HTT_TX_SELFGEN_AC_STATS_TLV:");
1677 	DP_PRINT_STATS("ac_su_ndpa = %u",
1678 		       dp_stats_buf->ac_su_ndpa);
1679 	DP_PRINT_STATS("ac_su_ndp = %u",
1680 		       dp_stats_buf->ac_su_ndp);
1681 	DP_PRINT_STATS("ac_mu_mimo_ndpa = %u",
1682 		       dp_stats_buf->ac_mu_mimo_ndpa);
1683 	DP_PRINT_STATS("ac_mu_mimo_ndp = %u",
1684 		       dp_stats_buf->ac_mu_mimo_ndp);
1685 	DP_PRINT_STATS("ac_mu_mimo_brpoll_1 = %u",
1686 		       dp_stats_buf->ac_mu_mimo_brpoll_1);
1687 	DP_PRINT_STATS("ac_mu_mimo_brpoll_2 = %u",
1688 		       dp_stats_buf->ac_mu_mimo_brpoll_2);
1689 	DP_PRINT_STATS("ac_mu_mimo_brpoll_3 = %u\n",
1690 		       dp_stats_buf->ac_mu_mimo_brpoll_3);
1691 }
1692 
1693 /**
1694  * dp_print_tx_selfgen_ax_stats_tlv() - display htt_tx_selfgen_ax_stats_tlv
1695  * @tag_buf: buffer containing the tlv htt_tx_selfgen_ax_stats_tlv
1696  *
1697  * Return: void
1698  */
dp_print_tx_selfgen_ax_stats_tlv(uint32_t * tag_buf)1699 static void dp_print_tx_selfgen_ax_stats_tlv(uint32_t *tag_buf)
1700 {
1701 	htt_tx_selfgen_ax_stats_tlv *dp_stats_buf =
1702 		(htt_tx_selfgen_ax_stats_tlv *)tag_buf;
1703 
1704 	DP_PRINT_STATS("HTT_TX_SELFGEN_AX_STATS_TLV:");
1705 	DP_PRINT_STATS("ax_su_ndpa = %u",
1706 		       dp_stats_buf->ax_su_ndpa);
1707 	DP_PRINT_STATS("ax_su_ndp = %u",
1708 		       dp_stats_buf->ax_su_ndp);
1709 	DP_PRINT_STATS("ax_mu_mimo_ndpa = %u",
1710 		       dp_stats_buf->ax_mu_mimo_ndpa);
1711 	DP_PRINT_STATS("ax_mu_mimo_ndp = %u",
1712 		       dp_stats_buf->ax_mu_mimo_ndp);
1713 	DP_PRINT_STATS("ax_mu_mimo_brpoll_1 = %u",
1714 		       dp_stats_buf->ax_mu_mimo_brpoll_1);
1715 	DP_PRINT_STATS("ax_mu_mimo_brpoll_2 = %u",
1716 		       dp_stats_buf->ax_mu_mimo_brpoll_2);
1717 	DP_PRINT_STATS("ax_mu_mimo_brpoll_3 = %u",
1718 		       dp_stats_buf->ax_mu_mimo_brpoll_3);
1719 	DP_PRINT_STATS("ax_mu_mimo_brpoll_4 = %u",
1720 		       dp_stats_buf->ax_mu_mimo_brpoll_4);
1721 	DP_PRINT_STATS("ax_mu_mimo_brpoll_5 = %u",
1722 		       dp_stats_buf->ax_mu_mimo_brpoll_5);
1723 	DP_PRINT_STATS("ax_mu_mimo_brpoll_6 = %u",
1724 		       dp_stats_buf->ax_mu_mimo_brpoll_6);
1725 	DP_PRINT_STATS("ax_mu_mimo_brpoll_7 = %u",
1726 		       dp_stats_buf->ax_mu_mimo_brpoll_7);
1727 	DP_PRINT_STATS("ax_basic_trigger = %u",
1728 		       dp_stats_buf->ax_basic_trigger);
1729 	DP_PRINT_STATS("ax_bsr_trigger = %u",
1730 		       dp_stats_buf->ax_bsr_trigger);
1731 	DP_PRINT_STATS("ax_mu_bar_trigger = %u",
1732 		       dp_stats_buf->ax_mu_bar_trigger);
1733 	DP_PRINT_STATS("ax_mu_rts_trigger = %u\n",
1734 		       dp_stats_buf->ax_mu_rts_trigger);
1735 }
1736 
1737 /**
1738  * dp_print_tx_selfgen_ac_err_stats_tlv() - display htt_tx_selfgen_ac_err_stats_tlv
1739  * @tag_buf: buffer containing the tlv htt_tx_selfgen_ac_err_stats_tlv
1740  *
1741  * Return: void
1742  */
dp_print_tx_selfgen_ac_err_stats_tlv(uint32_t * tag_buf)1743 static void dp_print_tx_selfgen_ac_err_stats_tlv(uint32_t *tag_buf)
1744 {
1745 	htt_tx_selfgen_ac_err_stats_tlv *dp_stats_buf =
1746 		(htt_tx_selfgen_ac_err_stats_tlv *)tag_buf;
1747 
1748 	DP_PRINT_STATS("HTT_TX_SELFGEN_AC_ERR_STATS_TLV:");
1749 	DP_PRINT_STATS("ac_su_ndp_err = %u",
1750 		       dp_stats_buf->ac_su_ndp_err);
1751 	DP_PRINT_STATS("ac_su_ndpa_err = %u",
1752 		       dp_stats_buf->ac_su_ndpa_err);
1753 	DP_PRINT_STATS("ac_mu_mimo_ndpa_err = %u",
1754 		       dp_stats_buf->ac_mu_mimo_ndpa_err);
1755 	DP_PRINT_STATS("ac_mu_mimo_ndp_err = %u",
1756 		       dp_stats_buf->ac_mu_mimo_ndp_err);
1757 	DP_PRINT_STATS("ac_mu_mimo_brp1_err = %u",
1758 		       dp_stats_buf->ac_mu_mimo_brp1_err);
1759 	DP_PRINT_STATS("ac_mu_mimo_brp2_err = %u",
1760 		       dp_stats_buf->ac_mu_mimo_brp2_err);
1761 	DP_PRINT_STATS("ac_mu_mimo_brp3_err = %u\n",
1762 		       dp_stats_buf->ac_mu_mimo_brp3_err);
1763 }
1764 
1765 /* dp_print_tx_selfgen_be_err_stats_tlv: display htt_tx_selfgen_be_err_stats_tlv
1766  * @tag_buf: buffer containing the tlv htt_tx_selfgen_be_err_stats_tlv
1767  *
1768  * Return: void
1769  */
dp_print_tx_selfgen_be_err_stats_tlv(uint32_t * tag_buf)1770 static void dp_print_tx_selfgen_be_err_stats_tlv(uint32_t *tag_buf)
1771 {
1772 	htt_tx_selfgen_be_err_stats_tlv *dp_stats_buf =
1773 		(htt_tx_selfgen_be_err_stats_tlv *)tag_buf;
1774 	uint16_t i;
1775 
1776 	DP_PRINT_STATS("HTT_TX_SELFGEN_BE_ERR_STATS_TLV:");
1777 	DP_PRINT_STATS("be_su_ndp_err = %u",
1778 		       dp_stats_buf->be_su_ndp_err);
1779 	DP_PRINT_STATS("be_su_ndpa_err = %u",
1780 		       dp_stats_buf->be_su_ndpa_err);
1781 	DP_PRINT_STATS("be_mu_mimo_ndpa_err = %u",
1782 		       dp_stats_buf->be_mu_mimo_ndpa_err);
1783 	DP_PRINT_STATS("be_mu_mimo_ndp_err = %u",
1784 		       dp_stats_buf->be_mu_mimo_ndp_err);
1785 	for (i = 0; i < (HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS - 1); i++)
1786 		DP_PRINT_STATS("be_mu_mimo_brp_err_%d: %u",
1787 			       i, dp_stats_buf->be_mu_mimo_brp_err[i]);
1788 	DP_PRINT_STATS("be_basic_trigger_err = %u",
1789 		       dp_stats_buf->be_basic_trigger_err);
1790 	DP_PRINT_STATS("be_bsr_trigger_err = %u",
1791 		       dp_stats_buf->be_bsr_trigger_err);
1792 	DP_PRINT_STATS("be_mu_bar_trigger_err = %u",
1793 		       dp_stats_buf->be_mu_bar_trigger_err);
1794 	DP_PRINT_STATS("be_mu_rts_trigger_err = %u",
1795 		       dp_stats_buf->be_mu_rts_trigger_err);
1796 	DP_PRINT_STATS("be_ulmumimo_trigger_err = %u",
1797 		       dp_stats_buf->be_ulmumimo_trigger_err);
1798 	for (i = 0; i < (HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS - 1); i++)
1799 		DP_PRINT_STATS("be_mu_mimo_brp_err_num_cbf_received _%d: %u", i,
1800 			       dp_stats_buf->be_mu_mimo_brp_err_num_cbf_received[i]);
1801 	DP_PRINT_STATS("be_su_ndpa_flushed = %u",
1802 		       dp_stats_buf->be_su_ndpa_flushed);
1803 	DP_PRINT_STATS("be_su_ndp_flushed = %u",
1804 		       dp_stats_buf->be_su_ndp_flushed);
1805 	DP_PRINT_STATS("be_mu_mimo_ndpa_flushed = %u",
1806 		       dp_stats_buf->be_mu_mimo_ndpa_flushed);
1807 	DP_PRINT_STATS("be_mu_mimo_ndp_flushed = %u",
1808 		       dp_stats_buf->be_mu_mimo_ndp_flushed);
1809 	for (i = 0; i < (HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS - 1); i++)
1810 		DP_PRINT_STATS("be_mu_mimo_brpoll_flushed_%d: %u",
1811 			       i, dp_stats_buf->be_mu_mimo_brpoll_flushed[i]);
1812 	for (i = 0; i < (HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS - 1); i++)
1813 		DP_PRINT_STATS("be_ul_mumimo_trigger_err_%d: %u",
1814 			       i, dp_stats_buf->be_ul_mumimo_trigger_err[i]);
1815 }
1816 
1817 /**
1818  * dp_print_tx_selfgen_be_stats_tlv() - display htt_tx_selfgen_be_stats_tlv
1819  * @tag_buf: buffer containing the tlv htt_tx_selfgen_be_stats_tlv
1820  *
1821  * Return: void
1822  */
dp_print_tx_selfgen_be_stats_tlv(uint32_t * tag_buf)1823 static void dp_print_tx_selfgen_be_stats_tlv(uint32_t *tag_buf)
1824 {
1825 	htt_tx_selfgen_be_stats_tlv *dp_stats_buf =
1826 		(htt_tx_selfgen_be_stats_tlv *)tag_buf;
1827 	uint16_t i;
1828 
1829 	DP_PRINT_STATS("HTT_TX_SELFGEN_BE_STATS_TLV:");
1830 	DP_PRINT_STATS("be_su_ndpa = %u",
1831 		       dp_stats_buf->be_su_ndpa);
1832 	DP_PRINT_STATS("be_su_ndp = %u",
1833 		       dp_stats_buf->be_su_ndp);
1834 	DP_PRINT_STATS("be_mu_mimo_ndpa = %u",
1835 		       dp_stats_buf->be_mu_mimo_ndpa);
1836 	DP_PRINT_STATS("be_mu_mimo_ndp = %u",
1837 		       dp_stats_buf->be_mu_mimo_ndp);
1838 	for (i = 0; i < (HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS - 1); i++)
1839 		DP_PRINT_STATS("be_mu_mimo_brpoll_%d = %u",
1840 			       i, dp_stats_buf->be_mu_mimo_brpoll[i]);
1841 	DP_PRINT_STATS("be_basic_trigger = %u",
1842 		       dp_stats_buf->be_basic_trigger);
1843 	DP_PRINT_STATS("be_bsr_trigger = %u",
1844 		       dp_stats_buf->be_bsr_trigger);
1845 	DP_PRINT_STATS("be_mu_bar_trigger = %u",
1846 		       dp_stats_buf->be_mu_bar_trigger);
1847 	DP_PRINT_STATS("be_mu_rts_trigger = %u",
1848 		       dp_stats_buf->be_mu_rts_trigger);
1849 	DP_PRINT_STATS("be_ulmumimo_trigger = %u",
1850 		       dp_stats_buf->be_ulmumimo_trigger);
1851 	DP_PRINT_STATS("be_su_ndpa_queued = %u",
1852 		       dp_stats_buf->be_su_ndpa_queued);
1853 	DP_PRINT_STATS("be_su_ndp_queued = %u",
1854 		       dp_stats_buf->be_su_ndp_queued);
1855 	DP_PRINT_STATS("be_mu_mimo_ndpa_queued = %u",
1856 		       dp_stats_buf->be_mu_mimo_ndpa_queued);
1857 	DP_PRINT_STATS("be_mu_mimo_ndp_queued = %u",
1858 		       dp_stats_buf->be_mu_mimo_ndp_queued);
1859 	for (i = 0; i < (HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS - 1); i++)
1860 		DP_PRINT_STATS("be_mu_mimo_brpoll_queued_%d = %u",
1861 			       i, dp_stats_buf->be_mu_mimo_brpoll_queued[i]);
1862 	for (i = 0; i < (HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS - 1); i++)
1863 		DP_PRINT_STATS("be_ul_mumimo_trigger_%d = %u",
1864 			       i, dp_stats_buf->be_ul_mumimo_trigger[i]);
1865 }
1866 
1867 /**
1868  * dp_print_tx_selfgen_ax_err_stats_tlv() - display htt_tx_selfgen_ax_err_stats_tlv
1869  * @tag_buf: buffer containing the tlv htt_tx_selfgen_ax_err_stats_tlv
1870  *
1871  * Return: void
1872  */
dp_print_tx_selfgen_ax_err_stats_tlv(uint32_t * tag_buf)1873 static void dp_print_tx_selfgen_ax_err_stats_tlv(uint32_t *tag_buf)
1874 {
1875 	htt_tx_selfgen_ax_err_stats_tlv *dp_stats_buf =
1876 		(htt_tx_selfgen_ax_err_stats_tlv *)tag_buf;
1877 
1878 	DP_PRINT_STATS("HTT_TX_SELFGEN_AX_ERR_STATS_TLV:");
1879 	DP_PRINT_STATS("ax_su_ndp_err = %u",
1880 		       dp_stats_buf->ax_su_ndp_err);
1881 	DP_PRINT_STATS("ax_su_ndpa_err = %u",
1882 		       dp_stats_buf->ax_su_ndpa_err);
1883 	DP_PRINT_STATS("ax_mu_mimo_ndpa_err = %u",
1884 		       dp_stats_buf->ax_mu_mimo_ndpa_err);
1885 	DP_PRINT_STATS("ax_mu_mimo_ndp_err = %u",
1886 		       dp_stats_buf->ax_mu_mimo_ndp_err);
1887 	DP_PRINT_STATS("ax_mu_mimo_brp1_err = %u",
1888 		       dp_stats_buf->ax_mu_mimo_brp1_err);
1889 	DP_PRINT_STATS("ax_mu_mimo_brp2_err = %u",
1890 		       dp_stats_buf->ax_mu_mimo_brp2_err);
1891 	DP_PRINT_STATS("ax_mu_mimo_brp3_err = %u",
1892 		       dp_stats_buf->ax_mu_mimo_brp3_err);
1893 	DP_PRINT_STATS("ax_mu_mimo_brp4_err = %u",
1894 		       dp_stats_buf->ax_mu_mimo_brp4_err);
1895 	DP_PRINT_STATS("ax_mu_mimo_brp5_err = %u",
1896 		       dp_stats_buf->ax_mu_mimo_brp5_err);
1897 	DP_PRINT_STATS("ax_mu_mimo_brp6_err = %u",
1898 		       dp_stats_buf->ax_mu_mimo_brp6_err);
1899 	DP_PRINT_STATS("ax_mu_mimo_brp7_err = %u",
1900 		       dp_stats_buf->ax_mu_mimo_brp7_err);
1901 	DP_PRINT_STATS("ax_basic_trigger_err = %u",
1902 		       dp_stats_buf->ax_basic_trigger_err);
1903 	DP_PRINT_STATS("ax_bsr_trigger_err = %u",
1904 		       dp_stats_buf->ax_bsr_trigger_err);
1905 	DP_PRINT_STATS("ax_mu_bar_trigger_err = %u",
1906 		       dp_stats_buf->ax_mu_bar_trigger_err);
1907 	DP_PRINT_STATS("ax_mu_rts_trigger_err = %u\n",
1908 		       dp_stats_buf->ax_mu_rts_trigger_err);
1909 }
1910 
1911 /**
1912  * dp_print_tx_sounding_stats_tlv() - display htt_tx_sounding_stats_tlv
1913  * @tag_buf: buffer containing the tlv htt_tx_soundig_stats_tlv
1914  *
1915  * Return: void
1916  */
dp_print_tx_sounding_stats_tlv(uint32_t * tag_buf)1917 static void dp_print_tx_sounding_stats_tlv(uint32_t *tag_buf)
1918 {
1919 	htt_tx_sounding_stats_tlv *dp_stats_buf =
1920 		(htt_tx_sounding_stats_tlv *)tag_buf;
1921 	uint16_t i;
1922 	uint16_t max_bw = HTT_TX_PDEV_STATS_NUM_BW_COUNTERS;
1923 
1924 	switch (dp_stats_buf->tx_sounding_mode) {
1925 	case HTT_TX_AC_SOUNDING_MODE:
1926 		DP_PRINT_STATS("\n HTT_TX_AC_SOUNDING_STATS_TLV: ");
1927 		DP_PRINT_STATS("ac_cbf_20 =  IBF : %d, SU_SIFS : %d, "
1928 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1929 			dp_stats_buf->cbf_20[0], dp_stats_buf->cbf_20[1],
1930 			dp_stats_buf->cbf_20[2], dp_stats_buf->cbf_20[3],
1931 			dp_stats_buf->cbf_20[4]);
1932 		DP_PRINT_STATS("ac_cbf_40 =  IBF : %d, SU_SIFS : %d, "
1933 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1934 			dp_stats_buf->cbf_40[0], dp_stats_buf->cbf_40[1],
1935 			dp_stats_buf->cbf_40[2], dp_stats_buf->cbf_40[3],
1936 			dp_stats_buf->cbf_40[4]);
1937 		DP_PRINT_STATS("ac_cbf_80 =  IBF : %d, SU_SIFS : %d, "
1938 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1939 			dp_stats_buf->cbf_80[0], dp_stats_buf->cbf_80[1],
1940 			dp_stats_buf->cbf_80[2], dp_stats_buf->cbf_80[3],
1941 			dp_stats_buf->cbf_80[4]);
1942 		DP_PRINT_STATS("ac_cbf_160 =  IBF : %d, SU_SIFS : %d, "
1943 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1944 			dp_stats_buf->cbf_160[0], dp_stats_buf->cbf_160[1],
1945 			dp_stats_buf->cbf_160[2], dp_stats_buf->cbf_160[3],
1946 			dp_stats_buf->cbf_160[4]);
1947 		for (i = 0;
1948 		     i < HTT_TX_PDEV_STATS_NUM_AC_MUMIMO_USER_STATS;
1949 		     i++) {
1950 				DP_PRINT_STATS("Sounding User %d = 20MHz: %d, "
1951 				       "40MHz : %d, 80MHz: %d, 160MHz: %d", i,
1952 				dp_stats_buf->sounding[(i * max_bw) + 0],
1953 				dp_stats_buf->sounding[(i * max_bw) + 1],
1954 				dp_stats_buf->sounding[(i * max_bw) + 2],
1955 				dp_stats_buf->sounding[(i * max_bw) + 3]);
1956 		}
1957 		break;
1958 	case HTT_TX_AX_SOUNDING_MODE:
1959 		DP_PRINT_STATS("\n HTT_TX_AX_SOUNDING_STATS_TLV: ");
1960 		DP_PRINT_STATS("ax_cbf_20 =  IBF : %d, SU_SIFS : %d, "
1961 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1962 			dp_stats_buf->cbf_20[0], dp_stats_buf->cbf_20[1],
1963 			dp_stats_buf->cbf_20[2], dp_stats_buf->cbf_20[3],
1964 			dp_stats_buf->cbf_20[4]);
1965 		DP_PRINT_STATS("ax_cbf_40 =  IBF : %d, SU_SIFS : %d, "
1966 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1967 			dp_stats_buf->cbf_40[0], dp_stats_buf->cbf_40[1],
1968 			dp_stats_buf->cbf_40[2], dp_stats_buf->cbf_40[3],
1969 			dp_stats_buf->cbf_40[4]);
1970 		DP_PRINT_STATS("ax_cbf_80 =  IBF : %d, SU_SIFS : %d, "
1971 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1972 			dp_stats_buf->cbf_80[0], dp_stats_buf->cbf_80[1],
1973 			dp_stats_buf->cbf_80[2], dp_stats_buf->cbf_80[3],
1974 			dp_stats_buf->cbf_80[4]);
1975 		DP_PRINT_STATS("ax_cbf_160 =  IBF : %d, SU_SIFS : %d, "
1976 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1977 			dp_stats_buf->cbf_160[0], dp_stats_buf->cbf_160[1],
1978 			dp_stats_buf->cbf_160[2], dp_stats_buf->cbf_160[3],
1979 			dp_stats_buf->cbf_160[4]);
1980 		for (i = 0;
1981 		     i < HTT_TX_PDEV_STATS_NUM_AX_MUMIMO_USER_STATS;
1982 		     i++) {
1983 			DP_PRINT_STATS("Sounding User %d = 20MHz: %d, "
1984 				       "40MHz : %d, 80MHz: %d, 160MHz: %d", i,
1985 				dp_stats_buf->sounding[(i * max_bw) + 0],
1986 				dp_stats_buf->sounding[(i * max_bw) + 1],
1987 				dp_stats_buf->sounding[(i * max_bw) + 2],
1988 				dp_stats_buf->sounding[(i * max_bw) + 3]);
1989 		}
1990 		break;
1991 	case HTT_TX_BE_SOUNDING_MODE:
1992 		DP_PRINT_STATS("\n HTT_TX_BE_SOUNDING_STATS_TLV: ");
1993 		DP_PRINT_STATS("be_cbf_20 =  IBF : %d, SU_SIFS : %d, "
1994 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
1995 			dp_stats_buf->cbf_20[0], dp_stats_buf->cbf_20[1],
1996 			dp_stats_buf->cbf_20[2], dp_stats_buf->cbf_20[3],
1997 			dp_stats_buf->cbf_20[4]);
1998 		DP_PRINT_STATS("be_cbf_40 =  IBF : %d, SU_SIFS : %d, "
1999 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
2000 			dp_stats_buf->cbf_40[0], dp_stats_buf->cbf_40[1],
2001 			dp_stats_buf->cbf_40[2], dp_stats_buf->cbf_40[3],
2002 			dp_stats_buf->cbf_40[4]);
2003 		DP_PRINT_STATS("be_cbf_80 =  IBF : %d, SU_SIFS : %d, "
2004 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
2005 			dp_stats_buf->cbf_80[0], dp_stats_buf->cbf_80[1],
2006 			dp_stats_buf->cbf_80[2], dp_stats_buf->cbf_80[3],
2007 			dp_stats_buf->cbf_80[4]);
2008 		DP_PRINT_STATS("be_cbf_160 =  IBF : %d, SU_SIFS : %d, "
2009 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
2010 			dp_stats_buf->cbf_160[0], dp_stats_buf->cbf_160[1],
2011 			dp_stats_buf->cbf_160[2], dp_stats_buf->cbf_160[3],
2012 			dp_stats_buf->cbf_160[4]);
2013 		DP_PRINT_STATS("be_cbf_320 =  IBF : %d, SU_SIFS : %d, "
2014 			"SU_RBO : %d, MU_SIFS : %d, MU_RBO : %d:",
2015 			dp_stats_buf->cbf_320[0], dp_stats_buf->cbf_320[1],
2016 			dp_stats_buf->cbf_320[2], dp_stats_buf->cbf_320[3],
2017 			dp_stats_buf->cbf_320[4]);
2018 		for (i = 0;
2019 		     i < HTT_TX_PDEV_STATS_NUM_BE_MUMIMO_USER_STATS;
2020 		     i++) {
2021 			DP_PRINT_STATS("Sounding User %d = 20MHz: %d, "
2022 				       "40MHz : %d, 80MHz: %d, 160MHz: %d, "
2023 				       "320MHz: %d", i,
2024 				dp_stats_buf->sounding[(i * max_bw) + 0],
2025 				dp_stats_buf->sounding[(i * max_bw) + 1],
2026 				dp_stats_buf->sounding[(i * max_bw) + 2],
2027 				dp_stats_buf->sounding[(i * max_bw) + 3],
2028 				dp_stats_buf->sounding_320[i]);
2029 		}
2030 		break;
2031 	case HTT_TX_CMN_SOUNDING_MODE:
2032 		DP_PRINT_STATS("\n CV UPLOAD HANDLER STATS:");
2033 		DP_PRINT_STATS("cv_nc_mismatch_err         : %u",
2034 			       dp_stats_buf->cv_nc_mismatch_err);
2035 		DP_PRINT_STATS("cv_fcs_err                 : %u",
2036 			       dp_stats_buf->cv_fcs_err);
2037 		DP_PRINT_STATS("cv_frag_idx_mismatch       : %u",
2038 			       dp_stats_buf->cv_frag_idx_mismatch);
2039 		DP_PRINT_STATS("cv_invalid_peer_id         : %u",
2040 			       dp_stats_buf->cv_invalid_peer_id);
2041 		DP_PRINT_STATS("cv_no_txbf_setup           : %u",
2042 			       dp_stats_buf->cv_no_txbf_setup);
2043 		DP_PRINT_STATS("cv_expiry_in_update        : %u",
2044 			       dp_stats_buf->cv_expiry_in_update);
2045 		DP_PRINT_STATS("cv_pkt_bw_exceed           : %u",
2046 			       dp_stats_buf->cv_pkt_bw_exceed);
2047 		DP_PRINT_STATS("cv_dma_not_done_err        : %u",
2048 			       dp_stats_buf->cv_dma_not_done_err);
2049 		DP_PRINT_STATS("cv_update_failed           : %u\n",
2050 			       dp_stats_buf->cv_update_failed);
2051 
2052 		DP_PRINT_STATS("\n CV QUERY STATS:");
2053 		DP_PRINT_STATS("cv_total_query             : %u",
2054 			       dp_stats_buf->cv_total_query);
2055 		DP_PRINT_STATS("cv_total_pattern_query     : %u",
2056 			       dp_stats_buf->cv_total_pattern_query);
2057 		DP_PRINT_STATS("cv_total_bw_query          : %u",
2058 			       dp_stats_buf->cv_total_bw_query);
2059 		DP_PRINT_STATS("cv_total_query             : %u",
2060 			       dp_stats_buf->cv_total_query);
2061 		DP_PRINT_STATS("cv_invalid_bw_coding       : %u",
2062 			       dp_stats_buf->cv_invalid_bw_coding);
2063 		DP_PRINT_STATS("cv_forced_sounding         : %u",
2064 			       dp_stats_buf->cv_forced_sounding);
2065 		DP_PRINT_STATS("cv_standalone_sounding     : %u",
2066 			       dp_stats_buf->cv_standalone_sounding);
2067 		DP_PRINT_STATS("cv_nc_mismatch             : %u",
2068 			       dp_stats_buf->cv_nc_mismatch);
2069 		DP_PRINT_STATS("cv_fb_type_mismatch        : %u",
2070 			       dp_stats_buf->cv_fb_type_mismatch);
2071 		DP_PRINT_STATS("cv_ofdma_bw_mismatch       : %u",
2072 			       dp_stats_buf->cv_ofdma_bw_mismatch);
2073 		DP_PRINT_STATS("cv_bw_mismatch             : %u",
2074 			       dp_stats_buf->cv_bw_mismatch);
2075 		DP_PRINT_STATS("cv_pattern_mismatch        : %u",
2076 			       dp_stats_buf->cv_pattern_mismatch);
2077 		DP_PRINT_STATS("cv_preamble_mismatch       : %u",
2078 			       dp_stats_buf->cv_preamble_mismatch);
2079 		DP_PRINT_STATS("cv_nr_mismatch             : %u",
2080 			       dp_stats_buf->cv_nr_mismatch);
2081 		DP_PRINT_STATS("cv_in_use_cnt_exceeded     : %u",
2082 			       dp_stats_buf->cv_in_use_cnt_exceeded);
2083 		DP_PRINT_STATS("cv_found                   : %u",
2084 			       dp_stats_buf->cv_found);
2085 		DP_PRINT_STATS("cv_not found               : %u",
2086 			       dp_stats_buf->cv_not_found);
2087 		DP_PRINT_STATS("cv_ntbr_sounding           : %u",
2088 			       dp_stats_buf->cv_ntbr_sounding);
2089 		DP_PRINT_STATS("cv_found_upload_in_progress: %u",
2090 			       dp_stats_buf->cv_found_upload_in_progress);
2091 		DP_PRINT_STATS("cv_expired_during_query    : %u\n",
2092 			       dp_stats_buf->cv_expired_during_query);
2093 		break;
2094 	default:
2095 		break;
2096 
2097 	}
2098 }
2099 
2100 /**
2101  * dp_print_tx_pdev_mu_mimo_sch_stats_tlv() - display htt_tx_pdev_mu_mimo_sch_stats
2102  * @tag_buf: buffer containing the tlv htt_tx_pdev_mu_mimo_sch_stats_tlv
2103  *
2104  * Return: void
2105  */
dp_print_tx_pdev_mu_mimo_sch_stats_tlv(uint32_t * tag_buf)2106 static void dp_print_tx_pdev_mu_mimo_sch_stats_tlv(uint32_t *tag_buf)
2107 {
2108 	uint8_t i;
2109 	htt_tx_pdev_mu_mimo_sch_stats_tlv *dp_stats_buf =
2110 		(htt_tx_pdev_mu_mimo_sch_stats_tlv *)tag_buf;
2111 
2112 	DP_PRINT_STATS("HTT_TX_PDEV_MU_MIMO_SCH_STATS_TLV:");
2113 	DP_PRINT_STATS("mu_mimo_sch_posted = %u",
2114 		       dp_stats_buf->mu_mimo_sch_posted);
2115 	DP_PRINT_STATS("mu_mimo_sch_failed = %u",
2116 		       dp_stats_buf->mu_mimo_sch_failed);
2117 	DP_PRINT_STATS("mu_mimo_ppdu_posted = %u\n",
2118 		       dp_stats_buf->mu_mimo_ppdu_posted);
2119 
2120 	DP_PRINT_STATS("\n11ac MU_MIMO SCH STATS:\n");
2121 
2122 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_AC_MUMIMO_USER_STATS; i++) {
2123 		DP_PRINT_STATS("ac_mu_mimo_sch_nusers_%u = %u", i,
2124 			       dp_stats_buf->ac_mu_mimo_sch_nusers[i]);
2125 	}
2126 
2127 	DP_PRINT_STATS("\n11ax MU_MIMO SCH STATS:\n");
2128 
2129 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_AX_MUMIMO_USER_STATS; i++) {
2130 		DP_PRINT_STATS("ax_mu_mimo_sch_nusers_%u = %u", i,
2131 			       dp_stats_buf->ax_mu_mimo_sch_nusers[i]);
2132 	}
2133 
2134 	DP_PRINT_STATS("\n11ax OFDMA SCH STATS:\n");
2135 
2136 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_AX_MUMIMO_USER_STATS; i++) {
2137 		DP_PRINT_STATS("ax_ofdma_sch_nusers_%u = %u", i,
2138 			       dp_stats_buf->ax_ofdma_sch_nusers[i]);
2139 	}
2140 }
2141 
2142 /**
2143  * dp_print_tx_pdev_mu_mimo_mpdu_stats_tlv() - display
2144  *				htt_tx_pdev_mu_mimo_mpdu_stats_tlv
2145  * @tag_buf: buffer containing the tlv htt_tx_pdev_mu_mimo_mpdu_stats_tlv
2146  *
2147  * Return: void
2148  */
dp_print_tx_pdev_mu_mimo_mpdu_stats_tlv(uint32_t * tag_buf)2149 static void dp_print_tx_pdev_mu_mimo_mpdu_stats_tlv(uint32_t *tag_buf)
2150 {
2151 	htt_tx_pdev_mpdu_stats_tlv *dp_stats_buf =
2152 		(htt_tx_pdev_mpdu_stats_tlv *)tag_buf;
2153 
2154 	if (dp_stats_buf->tx_sched_mode ==
2155 			HTT_STATS_TX_SCHED_MODE_MU_MIMO_AC) {
2156 		if (!dp_stats_buf->user_index)
2157 			DP_PRINT_STATS(
2158 				       "\nHTT_TX_PDEV_MU_MIMO_AC_MPDU_STATS:\n");
2159 
2160 		if (dp_stats_buf->user_index <
2161 			HTT_TX_PDEV_STATS_NUM_AC_MUMIMO_USER_STATS) {
2162 			DP_PRINT_STATS(
2163 				       "ac_mu_mimo_mpdus_queued_usr_%u = %u",
2164 				       dp_stats_buf->user_index,
2165 				       dp_stats_buf->mpdus_queued_usr);
2166 			DP_PRINT_STATS(
2167 				       "ac_mu_mimo_mpdus_tried_usr_%u = %u",
2168 				       dp_stats_buf->user_index,
2169 				       dp_stats_buf->mpdus_tried_usr);
2170 			DP_PRINT_STATS(
2171 				       "ac_mu_mimo_mpdus_failed_usr_%u = %u",
2172 				       dp_stats_buf->user_index,
2173 				       dp_stats_buf->mpdus_failed_usr);
2174 			DP_PRINT_STATS(
2175 				       "ac_mu_mimo_mpdus_requeued_usr_%u = %u",
2176 				       dp_stats_buf->user_index,
2177 				       dp_stats_buf->mpdus_requeued_usr);
2178 			DP_PRINT_STATS(
2179 				       "ac_mu_mimo_err_no_ba_usr_%u = %u",
2180 				       dp_stats_buf->user_index,
2181 				       dp_stats_buf->err_no_ba_usr);
2182 			DP_PRINT_STATS(
2183 				       "ac_mu_mimo_mpdu_underrun_usr_%u = %u",
2184 				       dp_stats_buf->user_index,
2185 				       dp_stats_buf->mpdu_underrun_usr);
2186 			DP_PRINT_STATS(
2187 				       "ac_mu_mimo_ampdu_underrun_usr_%u = %u\n",
2188 				       dp_stats_buf->user_index,
2189 				       dp_stats_buf->ampdu_underrun_usr);
2190 		}
2191 	}
2192 
2193 	if (dp_stats_buf->tx_sched_mode == HTT_STATS_TX_SCHED_MODE_MU_MIMO_AX) {
2194 		if (!dp_stats_buf->user_index)
2195 			DP_PRINT_STATS(
2196 				       "\nHTT_TX_PDEV_MU_MIMO_AX_MPDU_STATS:\n");
2197 
2198 		if (dp_stats_buf->user_index <
2199 				HTT_TX_PDEV_STATS_NUM_AX_MUMIMO_USER_STATS) {
2200 			DP_PRINT_STATS(
2201 				       "ax_mu_mimo_mpdus_queued_usr_%u = %u",
2202 				       dp_stats_buf->user_index,
2203 				       dp_stats_buf->mpdus_queued_usr);
2204 			DP_PRINT_STATS(
2205 				       "ax_mu_mimo_mpdus_tried_usr_%u = %u",
2206 				       dp_stats_buf->user_index,
2207 				       dp_stats_buf->mpdus_tried_usr);
2208 			DP_PRINT_STATS(
2209 				       "ax_mu_mimo_mpdus_failed_usr_%u = %u",
2210 				       dp_stats_buf->user_index,
2211 				       dp_stats_buf->mpdus_failed_usr);
2212 			DP_PRINT_STATS(
2213 				       "ax_mu_mimo_mpdus_requeued_usr_%u = %u",
2214 				       dp_stats_buf->user_index,
2215 				       dp_stats_buf->mpdus_requeued_usr);
2216 			DP_PRINT_STATS(
2217 				       "ax_mu_mimo_err_no_ba_usr_%u = %u",
2218 				       dp_stats_buf->user_index,
2219 				       dp_stats_buf->err_no_ba_usr);
2220 			DP_PRINT_STATS(
2221 				       "ax_mu_mimo_mpdu_underrun_usr_%u = %u",
2222 				       dp_stats_buf->user_index,
2223 				       dp_stats_buf->mpdu_underrun_usr);
2224 			DP_PRINT_STATS(
2225 				       "ax_mu_mimo_ampdu_underrun_usr_%u = %u\n",
2226 				       dp_stats_buf->user_index,
2227 				       dp_stats_buf->ampdu_underrun_usr);
2228 		}
2229 	}
2230 
2231 	if (dp_stats_buf->tx_sched_mode ==
2232 			HTT_STATS_TX_SCHED_MODE_MU_OFDMA_AX) {
2233 		if (!dp_stats_buf->user_index)
2234 			DP_PRINT_STATS(
2235 				       "\nHTT_TX_PDEV_AX_MU_OFDMA_MPDU_STATS:\n");
2236 
2237 		if (dp_stats_buf->user_index <
2238 				HTT_TX_PDEV_STATS_NUM_OFDMA_USER_STATS) {
2239 			DP_PRINT_STATS(
2240 				       "ax_mu_ofdma_mpdus_queued_usr_%u = %u",
2241 				       dp_stats_buf->user_index,
2242 				       dp_stats_buf->mpdus_queued_usr);
2243 			DP_PRINT_STATS(
2244 				       "ax_mu_ofdma_mpdus_tried_usr_%u = %u",
2245 				       dp_stats_buf->user_index,
2246 				       dp_stats_buf->mpdus_tried_usr);
2247 			DP_PRINT_STATS(
2248 				       "ax_mu_ofdma_mpdus_failed_usr_%u = %u",
2249 				       dp_stats_buf->user_index,
2250 				       dp_stats_buf->mpdus_failed_usr);
2251 			DP_PRINT_STATS(
2252 				       "ax_mu_ofdma_mpdus_requeued_usr_%u = %u",
2253 				       dp_stats_buf->user_index,
2254 				       dp_stats_buf->mpdus_requeued_usr);
2255 			DP_PRINT_STATS(
2256 				       "ax_mu_ofdma_err_no_ba_usr_%u = %u",
2257 				       dp_stats_buf->user_index,
2258 				       dp_stats_buf->err_no_ba_usr);
2259 			DP_PRINT_STATS(
2260 				       "ax_mu_ofdma_mpdu_underrun_usr_%u = %u",
2261 				       dp_stats_buf->user_index,
2262 				       dp_stats_buf->mpdu_underrun_usr);
2263 			DP_PRINT_STATS(
2264 				       "ax_mu_ofdma_ampdu_underrun_usr_%u = %u\n",
2265 				       dp_stats_buf->user_index,
2266 				       dp_stats_buf->ampdu_underrun_usr);
2267 		}
2268 	}
2269 }
2270 
2271 /**
2272  * dp_print_sched_txq_cmd_posted_tlv_v() - display htt_sched_txq_cmd_posted_tlv_v
2273  * @tag_buf: buffer containing the tlv htt_sched_txq_cmd_posted_tlv_v
2274  *
2275  * Return: void
2276  */
dp_print_sched_txq_cmd_posted_tlv_v(uint32_t * tag_buf)2277 static void dp_print_sched_txq_cmd_posted_tlv_v(uint32_t *tag_buf)
2278 {
2279 	htt_sched_txq_cmd_posted_tlv_v *dp_stats_buf =
2280 		(htt_sched_txq_cmd_posted_tlv_v *)tag_buf;
2281 	uint8_t i;
2282 	uint16_t index = 0;
2283 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
2284 	char *sched_cmd_posted = qdf_mem_malloc(DP_MAX_STRING_LEN);
2285 
2286 	if (!sched_cmd_posted) {
2287 		dp_stats_err("Output buffer not allocated");
2288 		return;
2289 	}
2290 
2291 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_PDEV_SCHED_TX_MODE_MAX);
2292 
2293 	DP_PRINT_STATS("HTT_SCHED_TXQ_CMD_POSTED_TLV_V:");
2294 	for (i = 0; i <  tag_len; i++) {
2295 		index += qdf_snprint(&sched_cmd_posted[index],
2296 				DP_MAX_STRING_LEN - index,
2297 				" %u:%u,", i,
2298 				dp_stats_buf->sched_cmd_posted[i]);
2299 	}
2300 	DP_PRINT_STATS("sched_cmd_posted = %s\n", sched_cmd_posted);
2301 	qdf_mem_free(sched_cmd_posted);
2302 }
2303 
2304 /**
2305  * dp_print_sched_txq_cmd_reaped_tlv_v() - display htt_sched_txq_cmd_reaped_tlv_v
2306  * @tag_buf: buffer containing the tlv htt_sched_txq_cmd_reaped_tlv_v
2307  *
2308  * Return: void
2309  */
dp_print_sched_txq_cmd_reaped_tlv_v(uint32_t * tag_buf)2310 static void dp_print_sched_txq_cmd_reaped_tlv_v(uint32_t *tag_buf)
2311 {
2312 	htt_sched_txq_cmd_reaped_tlv_v *dp_stats_buf =
2313 		(htt_sched_txq_cmd_reaped_tlv_v *)tag_buf;
2314 	uint8_t i;
2315 	uint16_t index = 0;
2316 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
2317 	char *sched_cmd_reaped = qdf_mem_malloc(DP_MAX_STRING_LEN);
2318 
2319 	if (!sched_cmd_reaped) {
2320 		dp_stats_err("Output buffer not allocated");
2321 		return;
2322 	}
2323 
2324 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_PDEV_SCHED_TX_MODE_MAX);
2325 
2326 	DP_PRINT_STATS("HTT_SCHED_TXQ_CMD_REAPED_TLV_V:");
2327 	for (i = 0; i <  tag_len; i++) {
2328 		index += qdf_snprint(&sched_cmd_reaped[index],
2329 				DP_MAX_STRING_LEN - index,
2330 				" %u:%u,", i,
2331 				dp_stats_buf->sched_cmd_reaped[i]);
2332 	}
2333 	DP_PRINT_STATS("sched_cmd_reaped = %s\n", sched_cmd_reaped);
2334 	qdf_mem_free(sched_cmd_reaped);
2335 }
2336 
2337 /**
2338  * dp_print_tx_pdev_stats_sched_per_txq_tlv() - display
2339  *				htt_tx_pdev_stats_sched_per_txq_tlv
2340  * @tag_buf: buffer containing the tlv htt_tx_pdev_stats_sched_per_txq_tlv
2341  *
2342  * Return: void
2343  */
dp_print_tx_pdev_stats_sched_per_txq_tlv(uint32_t * tag_buf)2344 static void dp_print_tx_pdev_stats_sched_per_txq_tlv(uint32_t *tag_buf)
2345 {
2346 	htt_tx_pdev_stats_sched_per_txq_tlv *dp_stats_buf =
2347 		(htt_tx_pdev_stats_sched_per_txq_tlv *)tag_buf;
2348 
2349 	DP_PRINT_STATS("HTT_TX_PDEV_STATS_SCHED_PER_TXQ_TLV:");
2350 	DP_PRINT_STATS("mac_id__txq_id__word = %u",
2351 		       dp_stats_buf->mac_id__txq_id__word);
2352 	DP_PRINT_STATS("sched_policy = %u",
2353 		       dp_stats_buf->sched_policy);
2354 	DP_PRINT_STATS("last_sched_cmd_posted_timestamp = %u",
2355 		       dp_stats_buf->last_sched_cmd_posted_timestamp);
2356 	DP_PRINT_STATS("last_sched_cmd_compl_timestamp = %u",
2357 		       dp_stats_buf->last_sched_cmd_compl_timestamp);
2358 	DP_PRINT_STATS("sched_2_tac_lwm_count = %u",
2359 		       dp_stats_buf->sched_2_tac_lwm_count);
2360 	DP_PRINT_STATS("sched_2_tac_ring_full = %u",
2361 		       dp_stats_buf->sched_2_tac_ring_full);
2362 	DP_PRINT_STATS("sched_cmd_post_failure = %u",
2363 		       dp_stats_buf->sched_cmd_post_failure);
2364 	DP_PRINT_STATS("num_active_tids = %u",
2365 		       dp_stats_buf->num_active_tids);
2366 	DP_PRINT_STATS("num_ps_schedules = %u",
2367 		       dp_stats_buf->num_ps_schedules);
2368 	DP_PRINT_STATS("sched_cmds_pending = %u",
2369 		       dp_stats_buf->sched_cmds_pending);
2370 	DP_PRINT_STATS("num_tid_register = %u",
2371 		       dp_stats_buf->num_tid_register);
2372 	DP_PRINT_STATS("num_tid_unregister = %u",
2373 		       dp_stats_buf->num_tid_unregister);
2374 	DP_PRINT_STATS("num_qstats_queried = %u",
2375 		       dp_stats_buf->num_qstats_queried);
2376 	DP_PRINT_STATS("qstats_update_pending = %u",
2377 		       dp_stats_buf->qstats_update_pending);
2378 	DP_PRINT_STATS("last_qstats_query_timestamp = %u",
2379 		       dp_stats_buf->last_qstats_query_timestamp);
2380 	DP_PRINT_STATS("num_tqm_cmdq_full = %u",
2381 		       dp_stats_buf->num_tqm_cmdq_full);
2382 	DP_PRINT_STATS("num_de_sched_algo_trigger = %u",
2383 		       dp_stats_buf->num_de_sched_algo_trigger);
2384 	DP_PRINT_STATS("num_rt_sched_algo_trigger = %u",
2385 		       dp_stats_buf->num_rt_sched_algo_trigger);
2386 	DP_PRINT_STATS("num_tqm_sched_algo_trigger = %u",
2387 		       dp_stats_buf->num_tqm_sched_algo_trigger);
2388 	DP_PRINT_STATS("notify_sched = %u\n",
2389 		       dp_stats_buf->notify_sched);
2390 }
2391 
2392 /**
2393  * dp_print_stats_tx_sched_cmn_tlv() - display htt_stats_tx_sched_cmn_tlv
2394  * @tag_buf: buffer containing the tlv htt_stats_tx_sched_cmn_tlv
2395  *
2396  * Return: void
2397  */
dp_print_stats_tx_sched_cmn_tlv(uint32_t * tag_buf)2398 static void dp_print_stats_tx_sched_cmn_tlv(uint32_t *tag_buf)
2399 {
2400 	htt_stats_tx_sched_cmn_tlv *dp_stats_buf =
2401 		(htt_stats_tx_sched_cmn_tlv *)tag_buf;
2402 
2403 	DP_PRINT_STATS("HTT_STATS_TX_SCHED_CMN_TLV:");
2404 	DP_PRINT_STATS("mac_id__word = %u",
2405 		       dp_stats_buf->mac_id__word);
2406 	DP_PRINT_STATS("current_timestamp = %u\n",
2407 		       dp_stats_buf->current_timestamp);
2408 }
2409 
2410 /**
2411  * dp_print_tx_tqm_gen_mpdu_stats_tlv_v() - display htt_tx_tqm_gen_mpdu_stats_tlv_v
2412  * @tag_buf: buffer containing the tlv htt_tx_tqm_gen_mpdu_stats_tlv_v
2413  *
2414  * Return: void
2415  */
dp_print_tx_tqm_gen_mpdu_stats_tlv_v(uint32_t * tag_buf)2416 static void dp_print_tx_tqm_gen_mpdu_stats_tlv_v(uint32_t *tag_buf)
2417 {
2418 	htt_tx_tqm_gen_mpdu_stats_tlv_v *dp_stats_buf =
2419 		(htt_tx_tqm_gen_mpdu_stats_tlv_v *)tag_buf;
2420 	uint8_t i;
2421 	uint16_t index = 0;
2422 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
2423 	char *gen_mpdu_end_reason = qdf_mem_malloc(DP_MAX_STRING_LEN);
2424 
2425 	if (!gen_mpdu_end_reason) {
2426 		dp_stats_err("Output buffer not allocated");
2427 		return;
2428 	}
2429 
2430 	tag_len = qdf_min(tag_len,
2431 			(uint32_t)HTT_TX_TQM_MAX_GEN_MPDU_END_REASON);
2432 
2433 	DP_PRINT_STATS("HTT_TX_TQM_GEN_MPDU_STATS_TLV_V:");
2434 	for (i = 0; i <  tag_len; i++) {
2435 		index += qdf_snprint(&gen_mpdu_end_reason[index],
2436 				DP_MAX_STRING_LEN - index,
2437 				" %u:%u,", i,
2438 				dp_stats_buf->gen_mpdu_end_reason[i]);
2439 	}
2440 	DP_PRINT_STATS("gen_mpdu_end_reason = %s\n", gen_mpdu_end_reason);
2441 	qdf_mem_free(gen_mpdu_end_reason);
2442 }
2443 
2444 /**
2445  * dp_print_tx_tqm_list_mpdu_stats_tlv_v() - display htt_tx_tqm_list_mpdu_stats_tlv
2446  * @tag_buf: buffer containing the tlv htt_tx_tqm_list_mpdu_stats_tlv_v
2447  *
2448  * Return: void
2449  */
dp_print_tx_tqm_list_mpdu_stats_tlv_v(uint32_t * tag_buf)2450 static void dp_print_tx_tqm_list_mpdu_stats_tlv_v(uint32_t *tag_buf)
2451 {
2452 	htt_tx_tqm_list_mpdu_stats_tlv_v *dp_stats_buf =
2453 		(htt_tx_tqm_list_mpdu_stats_tlv_v *)tag_buf;
2454 	uint8_t i;
2455 	uint16_t index = 0;
2456 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
2457 	char *list_mpdu_end_reason = qdf_mem_malloc(DP_MAX_STRING_LEN);
2458 
2459 	if (!list_mpdu_end_reason) {
2460 		dp_stats_err("Output buffer not allocated");
2461 		return;
2462 	}
2463 
2464 	tag_len = qdf_min(tag_len,
2465 			(uint32_t)HTT_TX_TQM_MAX_LIST_MPDU_END_REASON);
2466 
2467 	DP_PRINT_STATS("HTT_TX_TQM_LIST_MPDU_STATS_TLV_V:");
2468 	for (i = 0; i <  tag_len; i++) {
2469 		index += qdf_snprint(&list_mpdu_end_reason[index],
2470 				DP_MAX_STRING_LEN - index,
2471 				" %u:%u,", i,
2472 				dp_stats_buf->list_mpdu_end_reason[i]);
2473 	}
2474 	DP_PRINT_STATS("list_mpdu_end_reason = %s\n",
2475 		       list_mpdu_end_reason);
2476 	qdf_mem_free(list_mpdu_end_reason);
2477 }
2478 
2479 /**
2480  * dp_print_tx_tqm_list_mpdu_cnt_tlv_v() - display htt_tx_tqm_list_mpdu_cnt_tlv_v
2481  * @tag_buf: buffer containing the tlv htt_tx_tqm_list_mpdu_cnt_tlv_v
2482  *
2483  * Return: void
2484  */
dp_print_tx_tqm_list_mpdu_cnt_tlv_v(uint32_t * tag_buf)2485 static void dp_print_tx_tqm_list_mpdu_cnt_tlv_v(uint32_t *tag_buf)
2486 {
2487 	htt_tx_tqm_list_mpdu_cnt_tlv_v *dp_stats_buf =
2488 		(htt_tx_tqm_list_mpdu_cnt_tlv_v *)tag_buf;
2489 	uint8_t i;
2490 	uint16_t index = 0;
2491 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
2492 	char *list_mpdu_cnt_hist = qdf_mem_malloc(DP_MAX_STRING_LEN);
2493 
2494 	if (!list_mpdu_cnt_hist) {
2495 		dp_stats_err("Output buffer not allocated");
2496 		return;
2497 	}
2498 
2499 	tag_len = qdf_min(tag_len,
2500 			(uint32_t)HTT_TX_TQM_MAX_LIST_MPDU_CNT_HISTOGRAM_BINS);
2501 
2502 	DP_PRINT_STATS("HTT_TX_TQM_LIST_MPDU_CNT_TLV_V:");
2503 	for (i = 0; i <  tag_len; i++) {
2504 		index += qdf_snprint(&list_mpdu_cnt_hist[index],
2505 				DP_MAX_STRING_LEN - index,
2506 				" %u:%u,", i,
2507 				dp_stats_buf->list_mpdu_cnt_hist[i]);
2508 	}
2509 	DP_PRINT_STATS("list_mpdu_cnt_hist = %s\n", list_mpdu_cnt_hist);
2510 	qdf_mem_free(list_mpdu_cnt_hist);
2511 }
2512 
2513 /**
2514  * dp_print_tx_tqm_pdev_stats_tlv_v() - display htt_tx_tqm_pdev_stats_tlv_v
2515  * @tag_buf: buffer containing the tlv htt_tx_tqm_pdev_stats_tlv_v
2516  *
2517  * Return: void
2518  */
dp_print_tx_tqm_pdev_stats_tlv_v(uint32_t * tag_buf)2519 static void dp_print_tx_tqm_pdev_stats_tlv_v(uint32_t *tag_buf)
2520 {
2521 	htt_tx_tqm_pdev_stats_tlv_v *dp_stats_buf =
2522 		(htt_tx_tqm_pdev_stats_tlv_v *)tag_buf;
2523 
2524 	DP_PRINT_STATS("HTT_TX_TQM_PDEV_STATS_TLV_V:");
2525 	DP_PRINT_STATS("msdu_count = %u",
2526 		       dp_stats_buf->msdu_count);
2527 	DP_PRINT_STATS("mpdu_count = %u",
2528 		       dp_stats_buf->mpdu_count);
2529 	DP_PRINT_STATS("remove_msdu = %u",
2530 		       dp_stats_buf->remove_msdu);
2531 	DP_PRINT_STATS("remove_mpdu = %u",
2532 		       dp_stats_buf->remove_mpdu);
2533 	DP_PRINT_STATS("remove_msdu_ttl = %u",
2534 		       dp_stats_buf->remove_msdu_ttl);
2535 	DP_PRINT_STATS("send_bar = %u",
2536 		       dp_stats_buf->send_bar);
2537 	DP_PRINT_STATS("bar_sync = %u",
2538 		       dp_stats_buf->bar_sync);
2539 	DP_PRINT_STATS("notify_mpdu = %u",
2540 		       dp_stats_buf->notify_mpdu);
2541 	DP_PRINT_STATS("sync_cmd = %u",
2542 		       dp_stats_buf->sync_cmd);
2543 	DP_PRINT_STATS("write_cmd = %u",
2544 		       dp_stats_buf->write_cmd);
2545 	DP_PRINT_STATS("hwsch_trigger = %u",
2546 		       dp_stats_buf->hwsch_trigger);
2547 	DP_PRINT_STATS("ack_tlv_proc = %u",
2548 		       dp_stats_buf->ack_tlv_proc);
2549 	DP_PRINT_STATS("gen_mpdu_cmd = %u",
2550 		       dp_stats_buf->gen_mpdu_cmd);
2551 	DP_PRINT_STATS("gen_list_cmd = %u",
2552 		       dp_stats_buf->gen_list_cmd);
2553 	DP_PRINT_STATS("remove_mpdu_cmd = %u",
2554 		       dp_stats_buf->remove_mpdu_cmd);
2555 	DP_PRINT_STATS("remove_mpdu_tried_cmd = %u",
2556 		       dp_stats_buf->remove_mpdu_tried_cmd);
2557 	DP_PRINT_STATS("mpdu_queue_stats_cmd = %u",
2558 		       dp_stats_buf->mpdu_queue_stats_cmd);
2559 	DP_PRINT_STATS("mpdu_head_info_cmd = %u",
2560 		       dp_stats_buf->mpdu_head_info_cmd);
2561 	DP_PRINT_STATS("msdu_flow_stats_cmd = %u",
2562 		       dp_stats_buf->msdu_flow_stats_cmd);
2563 	DP_PRINT_STATS("remove_msdu_cmd = %u",
2564 		       dp_stats_buf->remove_msdu_cmd);
2565 	DP_PRINT_STATS("remove_msdu_ttl_cmd = %u",
2566 		       dp_stats_buf->remove_msdu_ttl_cmd);
2567 	DP_PRINT_STATS("flush_cache_cmd = %u",
2568 		       dp_stats_buf->flush_cache_cmd);
2569 	DP_PRINT_STATS("update_mpduq_cmd = %u",
2570 		       dp_stats_buf->update_mpduq_cmd);
2571 	DP_PRINT_STATS("enqueue = %u",
2572 		       dp_stats_buf->enqueue);
2573 	DP_PRINT_STATS("enqueue_notify = %u",
2574 		       dp_stats_buf->enqueue_notify);
2575 	DP_PRINT_STATS("notify_mpdu_at_head = %u",
2576 		       dp_stats_buf->notify_mpdu_at_head);
2577 	DP_PRINT_STATS("notify_mpdu_state_valid = %u\n",
2578 		       dp_stats_buf->notify_mpdu_state_valid);
2579 }
2580 
2581 /**
2582  * dp_print_tx_tqm_cmn_stats_tlv() - display htt_tx_tqm_cmn_stats_tlv
2583  * @tag_buf: buffer containing the tlv htt_tx_tqm_cmn_stats_tlv
2584  *
2585  * Return: void
2586  */
dp_print_tx_tqm_cmn_stats_tlv(uint32_t * tag_buf)2587 static void dp_print_tx_tqm_cmn_stats_tlv(uint32_t *tag_buf)
2588 {
2589 	htt_tx_tqm_cmn_stats_tlv *dp_stats_buf =
2590 		(htt_tx_tqm_cmn_stats_tlv *)tag_buf;
2591 
2592 	DP_PRINT_STATS("HTT_TX_TQM_CMN_STATS_TLV:");
2593 	DP_PRINT_STATS("mac_id__word = %u",
2594 		       dp_stats_buf->mac_id__word);
2595 	DP_PRINT_STATS("max_cmdq_id = %u",
2596 		       dp_stats_buf->max_cmdq_id);
2597 	DP_PRINT_STATS("list_mpdu_cnt_hist_intvl = %u",
2598 		       dp_stats_buf->list_mpdu_cnt_hist_intvl);
2599 	DP_PRINT_STATS("add_msdu = %u",
2600 		       dp_stats_buf->add_msdu);
2601 	DP_PRINT_STATS("q_empty = %u",
2602 		       dp_stats_buf->q_empty);
2603 	DP_PRINT_STATS("q_not_empty = %u",
2604 		       dp_stats_buf->q_not_empty);
2605 	DP_PRINT_STATS("drop_notification = %u",
2606 		       dp_stats_buf->drop_notification);
2607 	DP_PRINT_STATS("desc_threshold = %u\n",
2608 		       dp_stats_buf->desc_threshold);
2609 }
2610 
2611 /**
2612  * dp_print_tx_tqm_error_stats_tlv() - display htt_tx_tqm_error_stats_tlv
2613  * @tag_buf: buffer containing the tlv htt_tx_tqm_error_stats_tlv
2614  *
2615  * Return: void
2616  */
dp_print_tx_tqm_error_stats_tlv(uint32_t * tag_buf)2617 static void dp_print_tx_tqm_error_stats_tlv(uint32_t *tag_buf)
2618 {
2619 	htt_tx_tqm_error_stats_tlv *dp_stats_buf =
2620 		(htt_tx_tqm_error_stats_tlv *)tag_buf;
2621 
2622 	DP_PRINT_STATS("HTT_TX_TQM_ERROR_STATS_TLV:");
2623 	DP_PRINT_STATS("q_empty_failure = %u",
2624 		       dp_stats_buf->q_empty_failure);
2625 	DP_PRINT_STATS("q_not_empty_failure = %u",
2626 		       dp_stats_buf->q_not_empty_failure);
2627 	DP_PRINT_STATS("add_msdu_failure = %u\n",
2628 		       dp_stats_buf->add_msdu_failure);
2629 }
2630 
2631 /**
2632  * dp_print_tx_tqm_cmdq_status_tlv() - display htt_tx_tqm_cmdq_status_tlv
2633  * @tag_buf: buffer containing the tlv htt_tx_tqm_cmdq_status_tlv
2634  *
2635  * Return: void
2636  */
dp_print_tx_tqm_cmdq_status_tlv(uint32_t * tag_buf)2637 static void dp_print_tx_tqm_cmdq_status_tlv(uint32_t *tag_buf)
2638 {
2639 	htt_tx_tqm_cmdq_status_tlv *dp_stats_buf =
2640 		(htt_tx_tqm_cmdq_status_tlv *)tag_buf;
2641 
2642 	DP_PRINT_STATS("HTT_TX_TQM_CMDQ_STATUS_TLV:");
2643 	DP_PRINT_STATS("mac_id__cmdq_id__word = %u",
2644 		       dp_stats_buf->mac_id__cmdq_id__word);
2645 	DP_PRINT_STATS("sync_cmd = %u",
2646 		       dp_stats_buf->sync_cmd);
2647 	DP_PRINT_STATS("write_cmd = %u",
2648 		       dp_stats_buf->write_cmd);
2649 	DP_PRINT_STATS("gen_mpdu_cmd = %u",
2650 		       dp_stats_buf->gen_mpdu_cmd);
2651 	DP_PRINT_STATS("mpdu_queue_stats_cmd = %u",
2652 		       dp_stats_buf->mpdu_queue_stats_cmd);
2653 	DP_PRINT_STATS("mpdu_head_info_cmd = %u",
2654 		       dp_stats_buf->mpdu_head_info_cmd);
2655 	DP_PRINT_STATS("msdu_flow_stats_cmd = %u",
2656 		       dp_stats_buf->msdu_flow_stats_cmd);
2657 	DP_PRINT_STATS("remove_mpdu_cmd = %u",
2658 		       dp_stats_buf->remove_mpdu_cmd);
2659 	DP_PRINT_STATS("remove_msdu_cmd = %u",
2660 		       dp_stats_buf->remove_msdu_cmd);
2661 	DP_PRINT_STATS("flush_cache_cmd = %u",
2662 		       dp_stats_buf->flush_cache_cmd);
2663 	DP_PRINT_STATS("update_mpduq_cmd = %u",
2664 		       dp_stats_buf->update_mpduq_cmd);
2665 	DP_PRINT_STATS("update_msduq_cmd = %u\n",
2666 		       dp_stats_buf->update_msduq_cmd);
2667 }
2668 
2669 /**
2670  * dp_print_tx_de_eapol_packets_stats_tlv() - display htt_tx_de_eapol_packets_stats
2671  * @tag_buf: buffer containing the tlv htt_tx_de_eapol_packets_stats_tlv
2672  *
2673  * Return: void
2674  */
dp_print_tx_de_eapol_packets_stats_tlv(uint32_t * tag_buf)2675 static void dp_print_tx_de_eapol_packets_stats_tlv(uint32_t *tag_buf)
2676 {
2677 	htt_tx_de_eapol_packets_stats_tlv *dp_stats_buf =
2678 		(htt_tx_de_eapol_packets_stats_tlv *)tag_buf;
2679 
2680 	DP_PRINT_STATS("HTT_TX_DE_EAPOL_PACKETS_STATS_TLV:");
2681 	DP_PRINT_STATS("m1_packets = %u",
2682 		       dp_stats_buf->m1_packets);
2683 	DP_PRINT_STATS("m2_packets = %u",
2684 		       dp_stats_buf->m2_packets);
2685 	DP_PRINT_STATS("m3_packets = %u",
2686 		       dp_stats_buf->m3_packets);
2687 	DP_PRINT_STATS("m4_packets = %u",
2688 		       dp_stats_buf->m4_packets);
2689 	DP_PRINT_STATS("g1_packets = %u",
2690 		       dp_stats_buf->g1_packets);
2691 	DP_PRINT_STATS("g2_packets = %u\n",
2692 		       dp_stats_buf->g2_packets);
2693 }
2694 
2695 /**
2696  * dp_print_tx_de_classify_failed_stats_tlv() - display
2697  *				htt_tx_de_classify_failed_stats_tlv
2698  * @tag_buf: buffer containing the tlv htt_tx_de_classify_failed_stats_tlv
2699  *
2700  * Return: void
2701  */
dp_print_tx_de_classify_failed_stats_tlv(uint32_t * tag_buf)2702 static void dp_print_tx_de_classify_failed_stats_tlv(uint32_t *tag_buf)
2703 {
2704 	htt_tx_de_classify_failed_stats_tlv *dp_stats_buf =
2705 		(htt_tx_de_classify_failed_stats_tlv *)tag_buf;
2706 
2707 	DP_PRINT_STATS("HTT_TX_DE_CLASSIFY_FAILED_STATS_TLV:");
2708 	DP_PRINT_STATS("ap_bss_peer_not_found = %u",
2709 		       dp_stats_buf->ap_bss_peer_not_found);
2710 	DP_PRINT_STATS("ap_bcast_mcast_no_peer = %u",
2711 		       dp_stats_buf->ap_bcast_mcast_no_peer);
2712 	DP_PRINT_STATS("sta_delete_in_progress = %u",
2713 		       dp_stats_buf->sta_delete_in_progress);
2714 	DP_PRINT_STATS("ibss_no_bss_peer = %u",
2715 		       dp_stats_buf->ibss_no_bss_peer);
2716 	DP_PRINT_STATS("invaild_vdev_type = %u",
2717 		       dp_stats_buf->invaild_vdev_type);
2718 	DP_PRINT_STATS("invalid_ast_peer_entry = %u",
2719 		       dp_stats_buf->invalid_ast_peer_entry);
2720 	DP_PRINT_STATS("peer_entry_invalid = %u",
2721 		       dp_stats_buf->peer_entry_invalid);
2722 	DP_PRINT_STATS("ethertype_not_ip = %u",
2723 		       dp_stats_buf->ethertype_not_ip);
2724 	DP_PRINT_STATS("eapol_lookup_failed = %u",
2725 		       dp_stats_buf->eapol_lookup_failed);
2726 	DP_PRINT_STATS("qpeer_not_allow_data = %u",
2727 		       dp_stats_buf->qpeer_not_allow_data);
2728 	DP_PRINT_STATS("fse_tid_override = %u\n",
2729 		       dp_stats_buf->fse_tid_override);
2730 }
2731 
2732 /**
2733  * dp_print_tx_de_classify_stats_tlv() - display htt_tx_de_classify_stats_tlv
2734  * @tag_buf: buffer containing the tlv htt_tx_de_classify_stats_tlv
2735  *
2736  * Return: void
2737  */
dp_print_tx_de_classify_stats_tlv(uint32_t * tag_buf)2738 static void dp_print_tx_de_classify_stats_tlv(uint32_t *tag_buf)
2739 {
2740 	htt_tx_de_classify_stats_tlv *dp_stats_buf =
2741 		(htt_tx_de_classify_stats_tlv *)tag_buf;
2742 
2743 	DP_PRINT_STATS("HTT_TX_DE_CLASSIFY_STATS_TLV:");
2744 	DP_PRINT_STATS("arp_packets = %u",
2745 		       dp_stats_buf->arp_packets);
2746 	DP_PRINT_STATS("igmp_packets = %u",
2747 		       dp_stats_buf->igmp_packets);
2748 	DP_PRINT_STATS("dhcp_packets = %u",
2749 		       dp_stats_buf->dhcp_packets);
2750 	DP_PRINT_STATS("host_inspected = %u",
2751 		       dp_stats_buf->host_inspected);
2752 	DP_PRINT_STATS("htt_included = %u",
2753 		       dp_stats_buf->htt_included);
2754 	DP_PRINT_STATS("htt_valid_mcs = %u",
2755 		       dp_stats_buf->htt_valid_mcs);
2756 	DP_PRINT_STATS("htt_valid_nss = %u",
2757 		       dp_stats_buf->htt_valid_nss);
2758 	DP_PRINT_STATS("htt_valid_preamble_type = %u",
2759 		       dp_stats_buf->htt_valid_preamble_type);
2760 	DP_PRINT_STATS("htt_valid_chainmask = %u",
2761 		       dp_stats_buf->htt_valid_chainmask);
2762 	DP_PRINT_STATS("htt_valid_guard_interval = %u",
2763 		       dp_stats_buf->htt_valid_guard_interval);
2764 	DP_PRINT_STATS("htt_valid_retries = %u",
2765 		       dp_stats_buf->htt_valid_retries);
2766 	DP_PRINT_STATS("htt_valid_bw_info = %u",
2767 		       dp_stats_buf->htt_valid_bw_info);
2768 	DP_PRINT_STATS("htt_valid_power = %u",
2769 		       dp_stats_buf->htt_valid_power);
2770 	DP_PRINT_STATS("htt_valid_key_flags = %u",
2771 		       dp_stats_buf->htt_valid_key_flags);
2772 	DP_PRINT_STATS("htt_valid_no_encryption = %u",
2773 		       dp_stats_buf->htt_valid_no_encryption);
2774 	DP_PRINT_STATS("fse_entry_count = %u",
2775 		       dp_stats_buf->fse_entry_count);
2776 	DP_PRINT_STATS("fse_priority_be = %u",
2777 		       dp_stats_buf->fse_priority_be);
2778 	DP_PRINT_STATS("fse_priority_high = %u",
2779 		       dp_stats_buf->fse_priority_high);
2780 	DP_PRINT_STATS("fse_priority_low = %u",
2781 		       dp_stats_buf->fse_priority_low);
2782 	DP_PRINT_STATS("fse_traffic_ptrn_be = %u",
2783 		       dp_stats_buf->fse_traffic_ptrn_be);
2784 	DP_PRINT_STATS("fse_traffic_ptrn_over_sub = %u",
2785 		       dp_stats_buf->fse_traffic_ptrn_over_sub);
2786 	DP_PRINT_STATS("fse_traffic_ptrn_bursty = %u",
2787 		       dp_stats_buf->fse_traffic_ptrn_bursty);
2788 	DP_PRINT_STATS("fse_traffic_ptrn_interactive = %u",
2789 		       dp_stats_buf->fse_traffic_ptrn_interactive);
2790 	DP_PRINT_STATS("fse_traffic_ptrn_periodic = %u",
2791 		       dp_stats_buf->fse_traffic_ptrn_periodic);
2792 	DP_PRINT_STATS("fse_hwqueue_alloc = %u",
2793 		       dp_stats_buf->fse_hwqueue_alloc);
2794 	DP_PRINT_STATS("fse_hwqueue_created = %u",
2795 		       dp_stats_buf->fse_hwqueue_created);
2796 	DP_PRINT_STATS("fse_hwqueue_send_to_host = %u",
2797 		       dp_stats_buf->fse_hwqueue_send_to_host);
2798 	DP_PRINT_STATS("mcast_entry = %u",
2799 		       dp_stats_buf->mcast_entry);
2800 	DP_PRINT_STATS("bcast_entry = %u\n",
2801 		       dp_stats_buf->bcast_entry);
2802 }
2803 
2804 /**
2805  * dp_print_tx_de_classify_status_stats_tlv() - display
2806  *				htt_tx_de_classify_status_stats_tlv
2807  * @tag_buf: buffer containing the tlv htt_tx_de_classify_status_stats_tlv
2808  *
2809  * Return: void
2810  */
dp_print_tx_de_classify_status_stats_tlv(uint32_t * tag_buf)2811 static void dp_print_tx_de_classify_status_stats_tlv(uint32_t *tag_buf)
2812 {
2813 	htt_tx_de_classify_status_stats_tlv *dp_stats_buf =
2814 		(htt_tx_de_classify_status_stats_tlv *)tag_buf;
2815 
2816 	DP_PRINT_STATS("HTT_TX_DE_CLASSIFY_STATUS_STATS_TLV:");
2817 	DP_PRINT_STATS("eok = %u",
2818 		       dp_stats_buf->eok);
2819 	DP_PRINT_STATS("classify_done = %u",
2820 		       dp_stats_buf->classify_done);
2821 	DP_PRINT_STATS("lookup_failed = %u",
2822 		       dp_stats_buf->lookup_failed);
2823 	DP_PRINT_STATS("send_host_dhcp = %u",
2824 		       dp_stats_buf->send_host_dhcp);
2825 	DP_PRINT_STATS("send_host_mcast = %u",
2826 		       dp_stats_buf->send_host_mcast);
2827 	DP_PRINT_STATS("send_host_unknown_dest = %u",
2828 		       dp_stats_buf->send_host_unknown_dest);
2829 	DP_PRINT_STATS("send_host = %u",
2830 		       dp_stats_buf->send_host);
2831 	DP_PRINT_STATS("status_invalid = %u\n",
2832 		       dp_stats_buf->status_invalid);
2833 }
2834 
2835 /**
2836  * dp_print_tx_de_enqueue_packets_stats_tlv() - display
2837  *				htt_tx_de_enqueue_packets_stats_tlv
2838  * @tag_buf: buffer containing the tlv htt_tx_de_enqueue_packets_stats_tlv
2839  *
2840  * Return: void
2841  */
dp_print_tx_de_enqueue_packets_stats_tlv(uint32_t * tag_buf)2842 static void dp_print_tx_de_enqueue_packets_stats_tlv(uint32_t *tag_buf)
2843 {
2844 	htt_tx_de_enqueue_packets_stats_tlv *dp_stats_buf =
2845 		(htt_tx_de_enqueue_packets_stats_tlv *)tag_buf;
2846 
2847 	DP_PRINT_STATS("HTT_TX_DE_ENQUEUE_PACKETS_STATS_TLV:");
2848 	DP_PRINT_STATS("enqueued_pkts = %u",
2849 		       dp_stats_buf->enqueued_pkts);
2850 	DP_PRINT_STATS("to_tqm = %u",
2851 		       dp_stats_buf->to_tqm);
2852 	DP_PRINT_STATS("to_tqm_bypass = %u\n",
2853 		       dp_stats_buf->to_tqm_bypass);
2854 }
2855 
2856 /**
2857  * dp_print_tx_de_enqueue_discard_stats_tlv() - display
2858  *					htt_tx_de_enqueue_discard_stats_tlv
2859  * @tag_buf: buffer containing the tlv htt_tx_de_enqueue_discard_stats_tlv
2860  *
2861  * Return: void
2862  */
dp_print_tx_de_enqueue_discard_stats_tlv(uint32_t * tag_buf)2863 static void dp_print_tx_de_enqueue_discard_stats_tlv(uint32_t *tag_buf)
2864 {
2865 	htt_tx_de_enqueue_discard_stats_tlv *dp_stats_buf =
2866 		(htt_tx_de_enqueue_discard_stats_tlv *)tag_buf;
2867 
2868 	DP_PRINT_STATS("HTT_TX_DE_ENQUEUE_DISCARD_STATS_TLV:");
2869 	DP_PRINT_STATS("discarded_pkts = %u",
2870 		       dp_stats_buf->discarded_pkts);
2871 	DP_PRINT_STATS("local_frames = %u",
2872 		       dp_stats_buf->local_frames);
2873 	DP_PRINT_STATS("is_ext_msdu = %u\n",
2874 		       dp_stats_buf->is_ext_msdu);
2875 }
2876 
2877 /**
2878  * dp_print_tx_de_compl_stats_tlv() - display htt_tx_de_compl_stats_tlv
2879  * @tag_buf: buffer containing the tlv htt_tx_de_compl_stats_tlv
2880  *
2881  * Return: void
2882  */
dp_print_tx_de_compl_stats_tlv(uint32_t * tag_buf)2883 static void dp_print_tx_de_compl_stats_tlv(uint32_t *tag_buf)
2884 {
2885 	htt_tx_de_compl_stats_tlv *dp_stats_buf =
2886 		(htt_tx_de_compl_stats_tlv *)tag_buf;
2887 
2888 	DP_PRINT_STATS("HTT_TX_DE_COMPL_STATS_TLV:");
2889 	DP_PRINT_STATS("tcl_dummy_frame = %u",
2890 		       dp_stats_buf->tcl_dummy_frame);
2891 	DP_PRINT_STATS("tqm_dummy_frame = %u",
2892 		       dp_stats_buf->tqm_dummy_frame);
2893 	DP_PRINT_STATS("tqm_notify_frame = %u",
2894 		       dp_stats_buf->tqm_notify_frame);
2895 	DP_PRINT_STATS("fw2wbm_enq = %u",
2896 		       dp_stats_buf->fw2wbm_enq);
2897 	DP_PRINT_STATS("tqm_bypass_frame = %u\n",
2898 		       dp_stats_buf->tqm_bypass_frame);
2899 }
2900 
2901 /**
2902  * dp_print_tx_de_cmn_stats_tlv() - display htt_tx_de_cmn_stats_tlv
2903  * @tag_buf: buffer containing the tlv htt_tx_de_cmn_stats_tlv
2904  *
2905  * Return: void
2906  */
dp_print_tx_de_cmn_stats_tlv(uint32_t * tag_buf)2907 static void dp_print_tx_de_cmn_stats_tlv(uint32_t *tag_buf)
2908 {
2909 	htt_tx_de_cmn_stats_tlv *dp_stats_buf =
2910 		(htt_tx_de_cmn_stats_tlv *)tag_buf;
2911 
2912 	DP_PRINT_STATS("HTT_TX_DE_CMN_STATS_TLV:");
2913 	DP_PRINT_STATS("mac_id__word = %u",
2914 		       dp_stats_buf->mac_id__word);
2915 	DP_PRINT_STATS("tcl2fw_entry_count = %u",
2916 		       dp_stats_buf->tcl2fw_entry_count);
2917 	DP_PRINT_STATS("not_to_fw = %u",
2918 		       dp_stats_buf->not_to_fw);
2919 	DP_PRINT_STATS("invalid_pdev_vdev_peer = %u",
2920 		       dp_stats_buf->invalid_pdev_vdev_peer);
2921 	DP_PRINT_STATS("tcl_res_invalid_addrx = %u",
2922 		       dp_stats_buf->tcl_res_invalid_addrx);
2923 	DP_PRINT_STATS("wbm2fw_entry_count = %u",
2924 		       dp_stats_buf->wbm2fw_entry_count);
2925 	DP_PRINT_STATS("invalid_pdev = %u\n",
2926 		       dp_stats_buf->invalid_pdev);
2927 }
2928 
2929 /**
2930  * dp_print_ring_if_stats_tlv() - display htt_ring_if_stats_tlv
2931  * @tag_buf: buffer containing the tlv htt_ring_if_stats_tlv
2932  *
2933  * Return: void
2934  */
dp_print_ring_if_stats_tlv(uint32_t * tag_buf)2935 static void dp_print_ring_if_stats_tlv(uint32_t *tag_buf)
2936 {
2937 	htt_ring_if_stats_tlv *dp_stats_buf =
2938 		(htt_ring_if_stats_tlv *)tag_buf;
2939 	uint8_t i;
2940 	uint16_t index = 0;
2941 	char *wm_hit_count = qdf_mem_malloc(DP_MAX_STRING_LEN);
2942 
2943 	if (!wm_hit_count) {
2944 		dp_stats_err("Output buffer not allocated");
2945 		return;
2946 	}
2947 
2948 	DP_PRINT_STATS("HTT_RING_IF_STATS_TLV:");
2949 	DP_PRINT_STATS("base_addr = %u",
2950 		       dp_stats_buf->base_addr);
2951 	DP_PRINT_STATS("elem_size = %u",
2952 		       dp_stats_buf->elem_size);
2953 	DP_PRINT_STATS("num_elems__prefetch_tail_idx = %u",
2954 		       dp_stats_buf->num_elems__prefetch_tail_idx);
2955 	DP_PRINT_STATS("head_idx__tail_idx = %u",
2956 		       dp_stats_buf->head_idx__tail_idx);
2957 	DP_PRINT_STATS("shadow_head_idx__shadow_tail_idx = %u",
2958 		       dp_stats_buf->shadow_head_idx__shadow_tail_idx);
2959 	DP_PRINT_STATS("num_tail_incr = %u",
2960 		       dp_stats_buf->num_tail_incr);
2961 	DP_PRINT_STATS("lwm_thresh__hwm_thresh = %u",
2962 		       dp_stats_buf->lwm_thresh__hwm_thresh);
2963 	DP_PRINT_STATS("overrun_hit_count = %u",
2964 		       dp_stats_buf->overrun_hit_count);
2965 	DP_PRINT_STATS("underrun_hit_count = %u",
2966 		       dp_stats_buf->underrun_hit_count);
2967 	DP_PRINT_STATS("prod_blockwait_count = %u",
2968 		       dp_stats_buf->prod_blockwait_count);
2969 	DP_PRINT_STATS("cons_blockwait_count = %u",
2970 		       dp_stats_buf->cons_blockwait_count);
2971 
2972 	for (i = 0; i <  DP_HTT_LOW_WM_HIT_COUNT_LEN; i++) {
2973 		index += qdf_snprint(&wm_hit_count[index],
2974 				DP_MAX_STRING_LEN - index,
2975 				" %u:%u,", i,
2976 				dp_stats_buf->low_wm_hit_count[i]);
2977 	}
2978 	DP_PRINT_STATS("low_wm_hit_count = %s ", wm_hit_count);
2979 
2980 	qdf_mem_zero(wm_hit_count, DP_MAX_STRING_LEN);
2981 
2982 	index = 0;
2983 	for (i = 0; i <  DP_HTT_HIGH_WM_HIT_COUNT_LEN; i++) {
2984 		index += qdf_snprint(&wm_hit_count[index],
2985 				DP_MAX_STRING_LEN - index,
2986 				" %u:%u,", i,
2987 				dp_stats_buf->high_wm_hit_count[i]);
2988 	}
2989 	DP_PRINT_STATS("high_wm_hit_count = %s\n", wm_hit_count);
2990 	qdf_mem_free(wm_hit_count);
2991 }
2992 
2993 /**
2994  * dp_print_ring_if_cmn_tlv() - display htt_ring_if_cmn_tlv
2995  * @tag_buf: buffer containing the tlv htt_ring_if_cmn_tlv
2996  *
2997  * Return: void
2998  */
dp_print_ring_if_cmn_tlv(uint32_t * tag_buf)2999 static void dp_print_ring_if_cmn_tlv(uint32_t *tag_buf)
3000 {
3001 	htt_ring_if_cmn_tlv *dp_stats_buf =
3002 		(htt_ring_if_cmn_tlv *)tag_buf;
3003 
3004 	DP_PRINT_STATS("HTT_RING_IF_CMN_TLV:");
3005 	DP_PRINT_STATS("mac_id__word = %u",
3006 		       dp_stats_buf->mac_id__word);
3007 	DP_PRINT_STATS("num_records = %u\n",
3008 		       dp_stats_buf->num_records);
3009 }
3010 
3011 /**
3012  * dp_print_sfm_client_user_tlv_v() - display htt_sfm_client_user_tlv_v
3013  * @tag_buf: buffer containing the tlv htt_sfm_client_user_tlv_v
3014  *
3015  * Return: void
3016  */
dp_print_sfm_client_user_tlv_v(uint32_t * tag_buf)3017 static void dp_print_sfm_client_user_tlv_v(uint32_t *tag_buf)
3018 {
3019 	htt_sfm_client_user_tlv_v *dp_stats_buf =
3020 		(htt_sfm_client_user_tlv_v *)tag_buf;
3021 	uint8_t i;
3022 	uint16_t index = 0;
3023 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
3024 	char *dwords_used_by_user_n = qdf_mem_malloc(DP_MAX_STRING_LEN);
3025 
3026 	if (!dwords_used_by_user_n) {
3027 		dp_stats_err("Output buffer not allocated");
3028 		return;
3029 	}
3030 
3031 	DP_PRINT_STATS("HTT_SFM_CLIENT_USER_TLV_V:");
3032 	for (i = 0; i <  tag_len; i++) {
3033 		index += qdf_snprint(&dwords_used_by_user_n[index],
3034 				DP_MAX_STRING_LEN - index,
3035 				" %u:%u,", i,
3036 				dp_stats_buf->dwords_used_by_user_n[i]);
3037 	}
3038 	DP_PRINT_STATS("dwords_used_by_user_n = %s\n",
3039 		       dwords_used_by_user_n);
3040 	qdf_mem_free(dwords_used_by_user_n);
3041 }
3042 
3043 /**
3044  * dp_print_sfm_client_tlv() - display htt_sfm_client_tlv
3045  * @tag_buf: buffer containing the tlv htt_sfm_client_tlv
3046  *
3047  * Return: void
3048  */
dp_print_sfm_client_tlv(uint32_t * tag_buf)3049 static void dp_print_sfm_client_tlv(uint32_t *tag_buf)
3050 {
3051 	htt_sfm_client_tlv *dp_stats_buf =
3052 		(htt_sfm_client_tlv *)tag_buf;
3053 
3054 	DP_PRINT_STATS("HTT_SFM_CLIENT_TLV:");
3055 	DP_PRINT_STATS("client_id = %u",
3056 		       dp_stats_buf->client_id);
3057 	DP_PRINT_STATS("buf_min = %u",
3058 		       dp_stats_buf->buf_min);
3059 	DP_PRINT_STATS("buf_max = %u",
3060 		       dp_stats_buf->buf_max);
3061 	DP_PRINT_STATS("buf_busy = %u",
3062 		       dp_stats_buf->buf_busy);
3063 	DP_PRINT_STATS("buf_alloc = %u",
3064 		       dp_stats_buf->buf_alloc);
3065 	DP_PRINT_STATS("buf_avail = %u",
3066 		       dp_stats_buf->buf_avail);
3067 	DP_PRINT_STATS("num_users = %u\n",
3068 		       dp_stats_buf->num_users);
3069 }
3070 
3071 /**
3072  * dp_print_sfm_cmn_tlv() - display htt_sfm_cmn_tlv
3073  * @tag_buf: buffer containing the tlv htt_sfm_cmn_tlv
3074  *
3075  * Return: void
3076  */
dp_print_sfm_cmn_tlv(uint32_t * tag_buf)3077 static void dp_print_sfm_cmn_tlv(uint32_t *tag_buf)
3078 {
3079 	htt_sfm_cmn_tlv *dp_stats_buf =
3080 		(htt_sfm_cmn_tlv *)tag_buf;
3081 
3082 	DP_PRINT_STATS("HTT_SFM_CMN_TLV:");
3083 	DP_PRINT_STATS("mac_id__word = %u",
3084 		       dp_stats_buf->mac_id__word);
3085 	DP_PRINT_STATS("buf_total = %u",
3086 		       dp_stats_buf->buf_total);
3087 	DP_PRINT_STATS("mem_empty = %u",
3088 		       dp_stats_buf->mem_empty);
3089 	DP_PRINT_STATS("deallocate_bufs = %u",
3090 		       dp_stats_buf->deallocate_bufs);
3091 	DP_PRINT_STATS("num_records = %u\n",
3092 		       dp_stats_buf->num_records);
3093 }
3094 
3095 /**
3096  * dp_print_sring_stats_tlv() - display htt_sring_stats_tlv
3097  * @tag_buf: buffer containing the tlv htt_sring_stats_tlv
3098  *
3099  * Return: void
3100  */
dp_print_sring_stats_tlv(uint32_t * tag_buf)3101 static void dp_print_sring_stats_tlv(uint32_t *tag_buf)
3102 {
3103 	htt_sring_stats_tlv *dp_stats_buf =
3104 		(htt_sring_stats_tlv *)tag_buf;
3105 
3106 	DP_PRINT_STATS("HTT_SRING_STATS_TLV:");
3107 	DP_PRINT_STATS("mac_id__ring_id__arena__ep = %u",
3108 		       dp_stats_buf->mac_id__ring_id__arena__ep);
3109 	DP_PRINT_STATS("base_addr_lsb = %u",
3110 		       dp_stats_buf->base_addr_lsb);
3111 	DP_PRINT_STATS("base_addr_msb = %u",
3112 		       dp_stats_buf->base_addr_msb);
3113 	DP_PRINT_STATS("ring_size = %u",
3114 		       dp_stats_buf->ring_size);
3115 	DP_PRINT_STATS("elem_size = %u",
3116 		       dp_stats_buf->elem_size);
3117 	DP_PRINT_STATS("num_avail_words__num_valid_words = %u",
3118 		       dp_stats_buf->num_avail_words__num_valid_words);
3119 	DP_PRINT_STATS("head_ptr__tail_ptr = %u",
3120 		       dp_stats_buf->head_ptr__tail_ptr);
3121 	DP_PRINT_STATS("consumer_empty__producer_full = %u",
3122 		       dp_stats_buf->consumer_empty__producer_full);
3123 	DP_PRINT_STATS("prefetch_count__internal_tail_ptr = %u\n",
3124 		       dp_stats_buf->prefetch_count__internal_tail_ptr);
3125 }
3126 
3127 /**
3128  * dp_print_sring_cmn_tlv() - display htt_sring_cmn_tlv
3129  * @tag_buf: buffer containing the tlv htt_sring_cmn_tlv
3130  *
3131  * Return: void
3132  */
dp_print_sring_cmn_tlv(uint32_t * tag_buf)3133 static void dp_print_sring_cmn_tlv(uint32_t *tag_buf)
3134 {
3135 	htt_sring_cmn_tlv *dp_stats_buf =
3136 		(htt_sring_cmn_tlv *)tag_buf;
3137 
3138 	DP_PRINT_STATS("HTT_SRING_CMN_TLV:");
3139 	DP_PRINT_STATS("num_records = %u\n",
3140 		       dp_stats_buf->num_records);
3141 }
3142 
3143 /**
3144  * dp_print_tx_pdev_rate_stats_tlv() - display htt_tx_pdev_rate_stats_tlv
3145  * @tag_buf: buffer containing the tlv htt_tx_pdev_rate_stats_tlv
3146  *
3147  * Return: void
3148  */
dp_print_tx_pdev_rate_stats_tlv(uint32_t * tag_buf)3149 static void dp_print_tx_pdev_rate_stats_tlv(uint32_t *tag_buf)
3150 {
3151 	htt_tx_pdev_rate_stats_tlv *dp_stats_buf =
3152 		(htt_tx_pdev_rate_stats_tlv *)tag_buf;
3153 	uint8_t i, j;
3154 	uint16_t index = 0;
3155 	char *tx_gi[HTT_TX_PDEV_STATS_NUM_GI_COUNTERS] = {0};
3156 	char *tx_gi_ext[HTT_TX_PDEV_STATS_NUM_GI_COUNTERS] = {0};
3157 	char *ac_mu_mimo_tx_gi[HTT_TX_PDEV_STATS_NUM_GI_COUNTERS] = {0};
3158 	char *ax_mu_mimo_tx_gi[HTT_TX_PDEV_STATS_NUM_GI_COUNTERS] = {0};
3159 	char *ofdma_tx_gi[HTT_TX_PDEV_STATS_NUM_GI_COUNTERS] = {0};
3160 	char *str_buf = qdf_mem_malloc(DP_MAX_STRING_LEN);
3161 
3162 	if (!str_buf) {
3163 		dp_err("Output buffer not allocated");
3164 		return;
3165 	}
3166 
3167 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; i++) {
3168 		tx_gi[i] = (char *)qdf_mem_malloc(DP_MAX_STRING_LEN);
3169 		tx_gi_ext[i] = (char *)qdf_mem_malloc(DP_MAX_STRING_LEN);
3170 		if (!tx_gi[i] || !tx_gi_ext[i]) {
3171 			dp_err("Unable to allocate buffer for tx_gi");
3172 			goto fail1;
3173 		}
3174 		ac_mu_mimo_tx_gi[i] = (char *)qdf_mem_malloc(DP_MAX_STRING_LEN);
3175 		if (!ac_mu_mimo_tx_gi[i]) {
3176 			dp_err("Unable to allocate buffer for ac_mu_mimo_tx_gi");
3177 			goto fail1;
3178 		}
3179 		ax_mu_mimo_tx_gi[i] = (char *)qdf_mem_malloc(DP_MAX_STRING_LEN);
3180 		if (!ax_mu_mimo_tx_gi[i]) {
3181 			dp_err("Unable to allocate buffer for ax_mu_mimo_tx_gi");
3182 			goto fail1;
3183 		}
3184 		ofdma_tx_gi[i] = (char *)qdf_mem_malloc(DP_MAX_STRING_LEN);
3185 		if (!ofdma_tx_gi[i]) {
3186 			dp_err("Unable to allocate buffer for ofdma_tx_gi");
3187 			goto fail1;
3188 		}
3189 	}
3190 
3191 	DP_PRINT_STATS("HTT_TX_PDEV_RATE_STATS_TLV:");
3192 	DP_PRINT_STATS("mac_id__word = %u",
3193 		       dp_stats_buf->mac_id__word);
3194 	DP_PRINT_STATS("tx_ldpc = %u",
3195 		       dp_stats_buf->tx_ldpc);
3196 	DP_PRINT_STATS("rts_cnt = %u",
3197 		       dp_stats_buf->rts_cnt);
3198 	DP_PRINT_STATS("rts_success = %u",
3199 		       dp_stats_buf->rts_success);
3200 
3201 	DP_PRINT_STATS("ack_rssi = %u",
3202 		       dp_stats_buf->ack_rssi);
3203 
3204 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3205 	for (i = 0; i <  DP_HTT_TX_MCS_LEN; i++) {
3206 		index += qdf_snprint(&str_buf[index],
3207 				DP_MAX_STRING_LEN - index,
3208 				" %u:%u,", i, dp_stats_buf->tx_mcs[i]);
3209 	}
3210 
3211 	for (i = 0; i <  DP_HTT_TX_MCS_EXT_LEN; i++) {
3212 		index += qdf_snprint(&str_buf[index],
3213 				DP_MAX_STRING_LEN - index,
3214 				" %u:%u,", i + DP_HTT_TX_MCS_LEN,
3215 				dp_stats_buf->tx_mcs_ext[i]);
3216 	}
3217 
3218 	for (i = 0; i <  DP_HTT_TX_MCS_EXT2_LEN; i++) {
3219 		index += qdf_snprint(&str_buf[index],
3220 				DP_MAX_STRING_LEN - index,
3221 				" %u:%u,", i + DP_HTT_TX_MCS_LEN +
3222 				DP_HTT_TX_MCS_EXT_LEN,
3223 				dp_stats_buf->tx_mcs_ext_2[i]);
3224 	}
3225 	DP_PRINT_STATS("tx_mcs = %s ", str_buf);
3226 
3227 	index = 0;
3228 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3229 	for (i = 0; i <  DP_HTT_TX_SU_MCS_LEN; i++) {
3230 		index += qdf_snprint(&str_buf[index],
3231 				DP_MAX_STRING_LEN - index,
3232 				" %u:%u,", i, dp_stats_buf->tx_su_mcs[i]);
3233 	}
3234 	DP_PRINT_STATS("tx_su_mcs = %s ", str_buf);
3235 
3236 	index = 0;
3237 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3238 	for (i = 0; i <  DP_HTT_TX_MU_MCS_LEN; i++) {
3239 		index += qdf_snprint(&str_buf[index],
3240 				DP_MAX_STRING_LEN - index,
3241 				" %u:%u,", i, dp_stats_buf->tx_mu_mcs[i]);
3242 	}
3243 	DP_PRINT_STATS("tx_mu_mcs = %s ", str_buf);
3244 
3245 	index = 0;
3246 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3247 	for (i = 0; i <  DP_HTT_TX_NSS_LEN; i++) {
3248 		/* 0 stands for NSS 1, 1 stands for NSS 2, etc. */
3249 		index += qdf_snprint(&str_buf[index],
3250 				DP_MAX_STRING_LEN - index,
3251 				" %u:%u,", (i + 1),
3252 				dp_stats_buf->tx_nss[i]);
3253 	}
3254 	DP_PRINT_STATS("tx_nss = %s ", str_buf);
3255 
3256 	index = 0;
3257 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3258 	for (i = 0; i <  DP_HTT_TX_BW_LEN; i++) {
3259 		index += qdf_snprint(&str_buf[index],
3260 				DP_MAX_STRING_LEN - index,
3261 				" %u:%u,", i, dp_stats_buf->tx_bw[i]);
3262 	}
3263 	DP_PRINT_STATS("tx_bw = %s ", str_buf);
3264 
3265 	DP_PRINT_STATS("tx_bw_320mhz = %u ", dp_stats_buf->tx_bw_320mhz);
3266 
3267 	index = 0;
3268 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3269 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3270 		index += qdf_snprint(&str_buf[index],
3271 				DP_MAX_STRING_LEN - index,
3272 				" %u:%u,", i, dp_stats_buf->tx_stbc[i]);
3273 	}
3274 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++) {
3275 		index += qdf_snprint(&str_buf[index],
3276 				DP_MAX_STRING_LEN - index,
3277 				" %u:%u,", i + HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS,
3278 				dp_stats_buf->tx_stbc_ext[i]);
3279 	}
3280 	DP_PRINT_STATS("tx_stbc = %s ", str_buf);
3281 
3282 	index = 0;
3283 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3284 	for (i = 0; i <  DP_HTT_TX_PREAM_LEN; i++) {
3285 		index += qdf_snprint(&str_buf[index],
3286 				DP_MAX_STRING_LEN - index,
3287 				" %u:%u,", i, dp_stats_buf->tx_pream[i]);
3288 	}
3289 	DP_PRINT_STATS("tx_pream = %s ", str_buf);
3290 
3291 	for (j = 0; j < DP_HTT_PDEV_TX_GI_LEN; j++) {
3292 		index = 0;
3293 		qdf_mem_zero(tx_gi[j], DP_MAX_STRING_LEN);
3294 		for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3295 			index += qdf_snprint(&tx_gi[j][index],
3296 					DP_MAX_STRING_LEN - index,
3297 					" %u:%u,", i,
3298 					dp_stats_buf->tx_gi[j][i]);
3299 		}
3300 		DP_PRINT_STATS("tx_gi[%u] = %s ", j, tx_gi[j]);
3301 	}
3302 
3303 	for (j = 0; j < DP_HTT_PDEV_TX_GI_LEN; j++) {
3304 		index = 0;
3305 		qdf_mem_zero(tx_gi_ext[j], DP_MAX_STRING_LEN);
3306 		for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_EXTRA_MCS_COUNTERS; i++) {
3307 			index += qdf_snprint(&tx_gi_ext[j][index],
3308 					DP_MAX_STRING_LEN - index,
3309 					" %u:%u,", i,
3310 					dp_stats_buf->tx_gi_ext[j][i]);
3311 		}
3312 		DP_PRINT_STATS("tx_gi_ext[%u] = %s ", j, tx_gi_ext[j]);
3313 	}
3314 
3315 	index = 0;
3316 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3317 	for (i = 0; i <  DP_HTT_TX_DCM_LEN; i++) {
3318 		index += qdf_snprint(&str_buf[index],
3319 				DP_MAX_STRING_LEN - index,
3320 				" %u:%u,", i, dp_stats_buf->tx_dcm[i]);
3321 	}
3322 	DP_PRINT_STATS("tx_dcm = %s", str_buf);
3323 
3324 	index = 0;
3325 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3326 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_PUNCTURED_MODE_COUNTERS; i++) {
3327 		index += qdf_snprint(&str_buf[index],
3328 				DP_MAX_STRING_LEN - index,
3329 				" %u:%u,", i,
3330 				dp_stats_buf->tx_su_punctured_mode[i]);
3331 	}
3332 	DP_PRINT_STATS("tx_su_punctured_mode = %s\n", str_buf);
3333 
3334 	DP_PRINT_STATS("rts_success = %u",
3335 		       dp_stats_buf->rts_success);
3336 	DP_PRINT_STATS("ac_mu_mimo_tx_ldpc = %u",
3337 		       dp_stats_buf->ac_mu_mimo_tx_ldpc);
3338 	DP_PRINT_STATS("ax_mu_mimo_tx_ldpc = %u",
3339 		       dp_stats_buf->ax_mu_mimo_tx_ldpc);
3340 	DP_PRINT_STATS("ofdma_tx_ldpc = %u",
3341 		       dp_stats_buf->ofdma_tx_ldpc);
3342 
3343 	index = 0;
3344 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3345 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_LEGACY_CCK_STATS; i++) {
3346 		index += qdf_snprint(&str_buf[index],
3347 				     DP_MAX_STRING_LEN - index,
3348 				     " %u:%u,",
3349 				     i, dp_stats_buf->tx_legacy_cck_rate[i]);
3350 	}
3351 	DP_PRINT_STATS("tx_legacy_cck_rate = %s ", str_buf);
3352 
3353 	index = 0;
3354 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3355 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_LEGACY_OFDM_STATS; i++) {
3356 		index += qdf_snprint(&str_buf[index],
3357 				     DP_MAX_STRING_LEN - index,
3358 				     " %u:%u,", i,
3359 				     dp_stats_buf->tx_legacy_ofdm_rate[i]);
3360 	}
3361 	DP_PRINT_STATS("tx_legacy_ofdm_rate = %s ", str_buf);
3362 
3363 	index = 0;
3364 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3365 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_LTF; i++) {
3366 		index += qdf_snprint(&str_buf[index],
3367 				     DP_MAX_STRING_LEN - index,
3368 				     " %u:%u,",
3369 				     i, dp_stats_buf->tx_he_ltf[i]);
3370 	}
3371 	DP_PRINT_STATS("tx_he_ltf = %s ", str_buf);
3372 
3373 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3374 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3375 		index += qdf_snprint(&str_buf[index],
3376 				     DP_MAX_STRING_LEN - index,
3377 				     " %u:%u,",
3378 				     i, dp_stats_buf->ofdma_tx_mcs[i]);
3379 	}
3380 	DP_PRINT_STATS("ofdma_tx_mcs = %s ", str_buf);
3381 
3382 	index = 0;
3383 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3384 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3385 		index += qdf_snprint(&str_buf[index],
3386 				     DP_MAX_STRING_LEN - index,
3387 				     " %u:%u,",
3388 				     i, dp_stats_buf->ac_mu_mimo_tx_mcs[i]);
3389 	}
3390 	DP_PRINT_STATS("ac_mu_mimo_tx_mcs = %s ", str_buf);
3391 
3392 	index = 0;
3393 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3394 	for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3395 		index += qdf_snprint(&str_buf[index],
3396 				     DP_MAX_STRING_LEN - index,
3397 				     " %u:%u,",
3398 				     i, dp_stats_buf->ax_mu_mimo_tx_mcs[i]);
3399 	}
3400 	DP_PRINT_STATS("ax_mu_mimo_tx_mcs = %s ", str_buf);
3401 
3402 	index = 0;
3403 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3404 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3405 		index += qdf_snprint(&str_buf[index],
3406 				     DP_MAX_STRING_LEN - index,
3407 				     " %u:%u,",
3408 				     i, dp_stats_buf->ofdma_tx_mcs[i]);
3409 	}
3410 	DP_PRINT_STATS("ofdma_tx_mcs = %s ", str_buf);
3411 
3412 	index = 0;
3413 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3414 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++) {
3415 		index += qdf_snprint(&str_buf[index],
3416 				     DP_MAX_STRING_LEN - index,
3417 				     " %u:%u,",
3418 				     i, dp_stats_buf->ac_mu_mimo_tx_nss[i]);
3419 	}
3420 	DP_PRINT_STATS("ac_mu_mimo_tx_nss = %s ", str_buf);
3421 
3422 	index = 0;
3423 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3424 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++) {
3425 		index += qdf_snprint(&str_buf[index],
3426 				     DP_MAX_STRING_LEN - index,
3427 				     " %u:%u,",
3428 				     i, dp_stats_buf->ax_mu_mimo_tx_nss[i]);
3429 	}
3430 	DP_PRINT_STATS("ax_mu_mimo_tx_nss = %s ", str_buf);
3431 
3432 	index = 0;
3433 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3434 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++) {
3435 		index += qdf_snprint(&str_buf[index],
3436 				     DP_MAX_STRING_LEN - index,
3437 				     " %u:%u,",
3438 				     i, dp_stats_buf->ofdma_tx_nss[i]);
3439 	}
3440 	DP_PRINT_STATS("ofdma_tx_nss = %s ", str_buf);
3441 
3442 	index = 0;
3443 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3444 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_BW_COUNTERS; i++) {
3445 		index += qdf_snprint(&str_buf[index],
3446 				     DP_MAX_STRING_LEN - index,
3447 				     " %u:%u,",
3448 				     i, dp_stats_buf->ac_mu_mimo_tx_bw[i]);
3449 	}
3450 	DP_PRINT_STATS("ac_mu_mimo_tx_bw = %s ", str_buf);
3451 
3452 	index = 0;
3453 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3454 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_BW_COUNTERS; i++) {
3455 		index += qdf_snprint(&str_buf[index],
3456 				     DP_MAX_STRING_LEN - index,
3457 				     " %u:%u,",
3458 				     i, dp_stats_buf->ax_mu_mimo_tx_bw[i]);
3459 	}
3460 	DP_PRINT_STATS("ax_mu_mimo_tx_bw = %s ", str_buf);
3461 
3462 	index = 0;
3463 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3464 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_BW_COUNTERS; i++) {
3465 		index += qdf_snprint(&str_buf[index],
3466 				     DP_MAX_STRING_LEN - index,
3467 				     " %u:%u,",
3468 				     i, dp_stats_buf->ofdma_tx_bw[i]);
3469 	}
3470 
3471 	DP_PRINT_STATS("ofdma_tx_bw = %s ", str_buf);
3472 
3473 	for (j = 0; j < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
3474 		index = 0;
3475 		qdf_mem_zero(ac_mu_mimo_tx_gi[j], DP_MAX_STRING_LEN);
3476 		for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3477 			index += qdf_snprint(&ac_mu_mimo_tx_gi[j][index],
3478 					     DP_MAX_STRING_LEN - index,
3479 					     " %u:%u,", i,
3480 					     dp_stats_buf->
3481 					     ac_mu_mimo_tx_gi[j][i]);
3482 		}
3483 		DP_PRINT_STATS("ac_mu_mimo_tx_gi[%u] = %s ",
3484 			       j, ac_mu_mimo_tx_gi[j]);
3485 	}
3486 
3487 	for (j = 0; j < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
3488 		index = 0;
3489 		qdf_mem_zero(ax_mu_mimo_tx_gi[j], DP_MAX_STRING_LEN);
3490 		for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3491 			index += qdf_snprint(&ax_mu_mimo_tx_gi[j][index],
3492 					DP_MAX_STRING_LEN - index,
3493 					" %u:%u,", i,
3494 					dp_stats_buf->ax_mu_mimo_tx_gi[j][i]);
3495 		}
3496 		DP_PRINT_STATS("ax_mu_mimo_tx_gi[%u] = %s ",
3497 			       j, ax_mu_mimo_tx_gi[j]);
3498 	}
3499 
3500 	for (j = 0; j < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
3501 		index = 0;
3502 		qdf_mem_zero(ofdma_tx_gi[j], DP_MAX_STRING_LEN);
3503 		for (i = 0; i <  HTT_TX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3504 			index += qdf_snprint(&ofdma_tx_gi[j][index],
3505 					DP_MAX_STRING_LEN - index,
3506 					" %u:%u,", i,
3507 					dp_stats_buf->ofdma_tx_gi[j][i]);
3508 		}
3509 		DP_PRINT_STATS("ofdma_tx_gi[%u] = %s ",
3510 			       j, ofdma_tx_gi[j]);
3511 	}
3512 
3513 fail1:
3514 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; i++) {
3515 		if (tx_gi[i])
3516 			qdf_mem_free(tx_gi[i]);
3517 		if (tx_gi_ext[i])
3518 			qdf_mem_free(tx_gi_ext[i]);
3519 		if (ac_mu_mimo_tx_gi[i])
3520 			qdf_mem_free(ac_mu_mimo_tx_gi[i]);
3521 		if (ax_mu_mimo_tx_gi[i])
3522 			qdf_mem_free(ax_mu_mimo_tx_gi[i]);
3523 		if (ofdma_tx_gi[i])
3524 			qdf_mem_free(ofdma_tx_gi[i]);
3525 	}
3526 	qdf_mem_free(str_buf);
3527 }
3528 
3529 /**
3530  * dp_print_rx_pdev_rate_ext_stats_tlv() -
3531  *					display htt_rx_pdev_rate_ext_stats_tlv
3532  * @pdev: pdev pointer
3533  * @tag_buf: buffer containing the tlv htt_rx_pdev_rate_ext_stats_tlv
3534  *
3535  * Return: void
3536  */
dp_print_rx_pdev_rate_ext_stats_tlv(struct dp_pdev * pdev,uint32_t * tag_buf)3537 static void dp_print_rx_pdev_rate_ext_stats_tlv(struct dp_pdev *pdev,
3538 						uint32_t *tag_buf)
3539 {
3540 	htt_rx_pdev_rate_ext_stats_tlv *dp_stats_buf =
3541 		(htt_rx_pdev_rate_ext_stats_tlv *)tag_buf;
3542 	uint8_t i, j;
3543 	uint16_t index = 0;
3544 	char *rx_gi_ext[HTT_RX_PDEV_STATS_NUM_GI_COUNTERS] = {0};
3545 	char *ul_ofdma_rx_gi_ext[HTT_TX_PDEV_STATS_NUM_GI_COUNTERS] = {0};
3546 	char *str_buf = qdf_mem_malloc(DP_MAX_STRING_LEN);
3547 
3548 	if (!str_buf) {
3549 		dp_err("Output buffer not allocated");
3550 		return;
3551 	}
3552 
3553 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; i++) {
3554 		rx_gi_ext[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
3555 		if (!rx_gi_ext[i]) {
3556 			dp_err("Unable to allocate buffer for rx_gi_ext");
3557 			goto fail1;
3558 		}
3559 
3560 		ul_ofdma_rx_gi_ext[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
3561 		if (!ul_ofdma_rx_gi_ext[i]) {
3562 			dp_err("Unable to allocate buffer for ul_ofdma_rx_gi_ext");
3563 			goto fail1;
3564 		}
3565 	}
3566 
3567 	index = 0;
3568 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3569 	for (i = 0; i <  DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3570 		index += qdf_snprint(&str_buf[index],
3571 				DP_MAX_STRING_LEN - index,
3572 				" %u:%u,", i, dp_stats_buf->rx_mcs_ext[i]);
3573 	}
3574 
3575 	for (i = 0; i <  DP_HTT_RX_PDEV_MCS_LEN_EXT2; i++) {
3576 		index += qdf_snprint(&str_buf[index],
3577 				DP_MAX_STRING_LEN - index,
3578 				" %u:%u,", i + DP_HTT_RX_PDEV_MCS_LEN_EXT,
3579 				 dp_stats_buf->rx_mcs_ext_2[i]);
3580 	}
3581 	DP_PRINT_STATS("rx_mcs_ext = %s ", str_buf);
3582 
3583 	index = 0;
3584 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3585 	for (i = 0; i <  DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3586 		index += qdf_snprint(&str_buf[index],
3587 				DP_MAX_STRING_LEN - index,
3588 				" %u:%u,", i, dp_stats_buf->rx_stbc_ext[i]);
3589 	}
3590 	DP_PRINT_STATS("rx_stbc_ext = %s ", str_buf);
3591 
3592 	for (j = 0; j < DP_HTT_RX_GI_LEN; j++) {
3593 		index = 0;
3594 		qdf_mem_zero(rx_gi_ext[j], DP_MAX_STRING_LEN);
3595 		for (i = 0; i <  DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3596 			index += qdf_snprint(&rx_gi_ext[j][index],
3597 					DP_MAX_STRING_LEN - index,
3598 					" %u:%u,", i,
3599 					dp_stats_buf->rx_gi_ext[j][i]);
3600 		}
3601 		DP_PRINT_STATS("rx_gi_ext[%u] = %s ", j, rx_gi_ext[j]);
3602 	}
3603 
3604 	index = 0;
3605 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3606 	for (i = 0; i < DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3607 		index += qdf_snprint(&str_buf[index],
3608 				     DP_MAX_STRING_LEN - index,
3609 				     " %u:%u,",
3610 				     i, dp_stats_buf->ul_ofdma_rx_mcs_ext[i]);
3611 	}
3612 	DP_PRINT_STATS("ul_ofdma_rx_mcs_ext = %s", str_buf);
3613 
3614 	for (j = 0; j < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
3615 		index = 0;
3616 		qdf_mem_zero(ul_ofdma_rx_gi_ext[j], DP_MAX_STRING_LEN);
3617 		for (i = 0; i < DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3618 			index += qdf_snprint(&ul_ofdma_rx_gi_ext[j][index],
3619 					     DP_MAX_STRING_LEN - index,
3620 					     " %u:%u,", i,
3621 					     dp_stats_buf->
3622 					     ul_ofdma_rx_gi_ext[j][i]);
3623 		}
3624 		DP_PRINT_STATS("ul_ofdma_rx_gi_ext[%u] = %s ",
3625 			       j, ul_ofdma_rx_gi_ext[j]);
3626 	}
3627 
3628 	index = 0;
3629 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3630 	for (i = 0; i < DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3631 		index += qdf_snprint(&str_buf[index],
3632 		DP_MAX_STRING_LEN - index,
3633 		" %u:%u,", i,
3634 		dp_stats_buf->rx_11ax_su_txbf_mcs_ext[i]);
3635 	}
3636 	DP_PRINT_STATS("rx_11ax_su_txbf_mcs_ext = %s ", str_buf);
3637 
3638 	index = 0;
3639 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3640 	for (i = 0; i < DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3641 		index += qdf_snprint(&str_buf[index],
3642 		DP_MAX_STRING_LEN - index,
3643 		" %u:%u,", i,
3644 		dp_stats_buf->rx_11ax_mu_txbf_mcs_ext[i]);
3645 	}
3646 	DP_PRINT_STATS("rx_11ax_mu_txbf_mcs_ext = %s ", str_buf);
3647 
3648 	index = 0;
3649 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3650 	for (i = 0; i < DP_HTT_RX_PDEV_MCS_LEN_EXT; i++) {
3651 		index += qdf_snprint(&str_buf[index],
3652 		DP_MAX_STRING_LEN - index,
3653 		" %u:%u,", i,
3654 		dp_stats_buf->rx_11ax_dl_ofdma_mcs_ext[i]);
3655 	}
3656 	DP_PRINT_STATS("rx_11ax_dl_ofdma_mcs_ext = %s ", str_buf);
3657 
3658 	index = 0;
3659 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3660 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_BW_EXT2_COUNTERS; i++) {
3661 		index += qdf_snprint(&str_buf[index],
3662 		DP_MAX_STRING_LEN - index,
3663 		" %u:%u,", i,
3664 		dp_stats_buf->rx_bw_ext[i]);
3665 	}
3666 	DP_PRINT_STATS("rx_bw_ext = %s ", str_buf);
3667 
3668 	index = 0;
3669 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3670 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_PUNCTURED_MODE_COUNTERS; i++) {
3671 		index += qdf_snprint(&str_buf[index],
3672 		DP_MAX_STRING_LEN - index,
3673 		" %u:%u,", i,
3674 		dp_stats_buf->rx_su_punctured_mode[i]);
3675 	}
3676 	DP_PRINT_STATS("rx_su_punctured_mode = %s ", str_buf);
3677 
3678 fail1:
3679 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; i++) {
3680 		if (ul_ofdma_rx_gi_ext[i])
3681 			qdf_mem_free(ul_ofdma_rx_gi_ext[i]);
3682 		if (rx_gi_ext[i])
3683 			qdf_mem_free(rx_gi_ext[i]);
3684 	}
3685 
3686 	qdf_mem_free(str_buf);
3687 }
3688 
3689 /**
3690  * dp_print_rx_pdev_rate_stats_tlv() - display htt_rx_pdev_rate_stats_tlv
3691  * @pdev: pdev pointer
3692  * @tag_buf: buffer containing the tlv htt_rx_pdev_rate_stats_tlv
3693  *
3694  * Return: void
3695  */
dp_print_rx_pdev_rate_stats_tlv(struct dp_pdev * pdev,uint32_t * tag_buf)3696 static void dp_print_rx_pdev_rate_stats_tlv(struct dp_pdev *pdev,
3697 					    uint32_t *tag_buf)
3698 {
3699 	htt_rx_pdev_rate_stats_tlv *dp_stats_buf =
3700 		(htt_rx_pdev_rate_stats_tlv *)tag_buf;
3701 	uint8_t i, j;
3702 	uint16_t index = 0;
3703 	char *rssi_chain[DP_HTT_RSSI_CHAIN_LEN];
3704 	char *rx_gi[HTT_RX_PDEV_STATS_NUM_GI_COUNTERS];
3705 	char *str_buf = qdf_mem_malloc(DP_MAX_STRING_LEN);
3706 	char *ul_ofdma_rx_gi[HTT_TX_PDEV_STATS_NUM_GI_COUNTERS];
3707 
3708 	if (!str_buf) {
3709 		dp_err("Output buffer not allocated");
3710 		return;
3711 	}
3712 
3713 	for (i = 0; i < DP_HTT_RSSI_CHAIN_LEN; i++) {
3714 		rssi_chain[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
3715 		if (!rssi_chain[i]) {
3716 			dp_err("Unable to allocate buffer for rssi_chain");
3717 			goto fail1;
3718 		}
3719 	}
3720 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; i++) {
3721 		rx_gi[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
3722 		if (!rx_gi[i]) {
3723 			dp_err("Unable to allocate buffer for rx_gi");
3724 			goto fail2;
3725 		}
3726 	}
3727 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; i++) {
3728 		ul_ofdma_rx_gi[i] = qdf_mem_malloc(DP_MAX_STRING_LEN);
3729 		if (!ul_ofdma_rx_gi[i]) {
3730 			dp_err("Unable to allocate buffer for ul_ofdma_rx_gi");
3731 			goto fail3;
3732 		}
3733 	}
3734 
3735 	DP_PRINT_STATS("ul_ofdma_data_rx_ppdu = %d",
3736 		       pdev->stats.ul_ofdma.data_rx_ppdu);
3737 
3738 	for (i = 0; i < OFDMA_NUM_USERS; i++) {
3739 		DP_PRINT_STATS("ul_ofdma data %d user = %d",
3740 			       i, pdev->stats.ul_ofdma.data_users[i]);
3741 	}
3742 
3743 	index = 0;
3744 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3745 	for (i = 0; i < OFDMA_NUM_RU_SIZE; i++) {
3746 		index += qdf_snprint(&str_buf[index],
3747 			DP_MAX_STRING_LEN - index,
3748 			" %u:%u,", i,
3749 			pdev->stats.ul_ofdma.data_rx_ru_size[i]);
3750 	}
3751 	DP_PRINT_STATS("ul_ofdma_data_rx_ru_size= %s", str_buf);
3752 
3753 	index = 0;
3754 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3755 	for (i = 0; i < OFDMA_NUM_RU_SIZE; i++) {
3756 		index += qdf_snprint(&str_buf[index],
3757 			DP_MAX_STRING_LEN - index,
3758 			" %u:%u,", i,
3759 			pdev->stats.ul_ofdma.nondata_rx_ru_size[i]);
3760 	}
3761 	DP_PRINT_STATS("ul_ofdma_nondata_rx_ru_size= %s", str_buf);
3762 
3763 	DP_PRINT_STATS("HTT_RX_PDEV_RATE_STATS_TLV:");
3764 	DP_PRINT_STATS("mac_id__word = %u",
3765 		       dp_stats_buf->mac_id__word);
3766 	DP_PRINT_STATS("nsts = %u",
3767 		       dp_stats_buf->nsts);
3768 	DP_PRINT_STATS("rx_ldpc = %u",
3769 		       dp_stats_buf->rx_ldpc);
3770 	DP_PRINT_STATS("rts_cnt = %u",
3771 		       dp_stats_buf->rts_cnt);
3772 	DP_PRINT_STATS("rssi_mgmt = %u",
3773 		       dp_stats_buf->rssi_mgmt);
3774 	DP_PRINT_STATS("rssi_data = %u",
3775 		       dp_stats_buf->rssi_data);
3776 	DP_PRINT_STATS("rssi_comb = %u",
3777 		       dp_stats_buf->rssi_comb);
3778 	DP_PRINT_STATS("rssi_in_dbm = %d",
3779 		       dp_stats_buf->rssi_in_dbm);
3780 	DP_PRINT_STATS("rx_11ax_su_ext = %u",
3781 		       dp_stats_buf->rx_11ax_su_ext);
3782 	DP_PRINT_STATS("rx_11ac_mumimo = %u",
3783 		       dp_stats_buf->rx_11ac_mumimo);
3784 	DP_PRINT_STATS("rx_11ax_mumimo = %u",
3785 		       dp_stats_buf->rx_11ax_mumimo);
3786 	DP_PRINT_STATS("rx_11ax_ofdma = %u",
3787 		       dp_stats_buf->rx_11ax_ofdma);
3788 	DP_PRINT_STATS("txbf = %u",
3789 		       dp_stats_buf->txbf);
3790 	DP_PRINT_STATS("rx_su_ndpa = %u",
3791 		       dp_stats_buf->rx_su_ndpa);
3792 	DP_PRINT_STATS("rx_br_poll = %u",
3793 		       dp_stats_buf->rx_br_poll);
3794 
3795 	index = 0;
3796 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3797 	for (i = 0; i <  DP_HTT_RX_MCS_LEN; i++) {
3798 		index += qdf_snprint(&str_buf[index],
3799 				DP_MAX_STRING_LEN - index,
3800 				" %u:%u,", i, dp_stats_buf->rx_mcs[i]);
3801 	}
3802 	for (i = 0; i <  DP_HTT_RX_MCS_EXT_LEN; i++) {
3803 		index += qdf_snprint(&str_buf[index],
3804 				DP_MAX_STRING_LEN - index,
3805 				" %u:%u,", i + DP_HTT_RX_MCS_LEN,
3806 				dp_stats_buf->rx_mcs_ext[i]);
3807 	}
3808 	DP_PRINT_STATS("rx_mcs = %s ", str_buf);
3809 
3810 	index = 0;
3811 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3812 	for (i = 0; i <  DP_HTT_RX_NSS_LEN; i++) {
3813 		/* 0 stands for NSS 1, 1 stands for NSS 2, etc. */
3814 		index += qdf_snprint(&str_buf[index],
3815 				DP_MAX_STRING_LEN - index,
3816 				" %u:%u,", (i + 1),
3817 				dp_stats_buf->rx_nss[i]);
3818 	}
3819 	DP_PRINT_STATS("rx_nss = %s ", str_buf);
3820 
3821 	index = 0;
3822 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3823 	for (i = 0; i <  DP_HTT_RX_DCM_LEN; i++) {
3824 		index += qdf_snprint(&str_buf[index],
3825 				DP_MAX_STRING_LEN - index,
3826 				" %u:%u,", i, dp_stats_buf->rx_dcm[i]);
3827 	}
3828 	DP_PRINT_STATS("rx_dcm = %s ", str_buf);
3829 
3830 	index = 0;
3831 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3832 	for (i = 0; i <  HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3833 		index += qdf_snprint(&str_buf[index],
3834 				DP_MAX_STRING_LEN - index,
3835 				" %u:%u,", i, dp_stats_buf->rx_stbc[i]);
3836 	}
3837 	DP_PRINT_STATS("rx_stbc = %s ", str_buf);
3838 
3839 	index = 0;
3840 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3841 	for (i = 0; i <  DP_HTT_RX_BW_LEN; i++) {
3842 		index += qdf_snprint(&str_buf[index],
3843 				DP_MAX_STRING_LEN - index,
3844 				" %u:%u,", i, dp_stats_buf->rx_bw[i]);
3845 	}
3846 	DP_PRINT_STATS("rx_bw = %s ", str_buf);
3847 
3848 	for (j = 0; j < DP_HTT_RSSI_CHAIN_LEN; j++) {
3849 		index = 0;
3850 		for (i = 0; i <  HTT_RX_PDEV_STATS_NUM_BW_COUNTERS; i++) {
3851 			index += qdf_snprint(&rssi_chain[j][index],
3852 					DP_MAX_STRING_LEN - index,
3853 					" %u:%u,", i,
3854 					dp_stats_buf->rssi_chain[j][i]);
3855 		}
3856 		DP_PRINT_STATS("rssi_chain[%u] = %s ", j, rssi_chain[j]);
3857 	}
3858 
3859 	for (j = 0; j < DP_HTT_RX_GI_LEN; j++) {
3860 		index = 0;
3861 		qdf_mem_zero(rx_gi[j], DP_MAX_STRING_LEN);
3862 		for (i = 0; i <  HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3863 			index += qdf_snprint(&rx_gi[j][index],
3864 					DP_MAX_STRING_LEN - index,
3865 					" %u:%u,", i,
3866 					dp_stats_buf->rx_gi[j][i]);
3867 		}
3868 		DP_PRINT_STATS("rx_gi[%u] = %s ", j, rx_gi[j]);
3869 	}
3870 
3871 	index = 0;
3872 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3873 	for (i = 0; i <  DP_HTT_RX_PREAM_LEN; i++) {
3874 		index += qdf_snprint(&str_buf[index],
3875 				     DP_MAX_STRING_LEN - index,
3876 				     " %u:%u,",
3877 				     i,
3878 				     dp_stats_buf->rx_pream[i]);
3879 	}
3880 	DP_PRINT_STATS("rx_pream = %s", str_buf);
3881 
3882 	index = 0;
3883 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3884 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_LEGACY_CCK_STATS; i++) {
3885 		index += qdf_snprint(&str_buf[index],
3886 				     DP_MAX_STRING_LEN - index,
3887 				     " %u:%u,",
3888 				     i,
3889 				     dp_stats_buf->rx_legacy_cck_rate[i]);
3890 	}
3891 	DP_PRINT_STATS("rx_legacy_cck_rate = %s", str_buf);
3892 
3893 	index = 0;
3894 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3895 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_LEGACY_OFDM_STATS; i++) {
3896 		index += qdf_snprint(&str_buf[index],
3897 				     DP_MAX_STRING_LEN - index,
3898 				     " %u:%u,",
3899 				     i,
3900 				     dp_stats_buf->rx_legacy_ofdm_rate[i]);
3901 	}
3902 	DP_PRINT_STATS("rx_legacy_ofdm_rate = %s", str_buf);
3903 
3904 	index = 0;
3905 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3906 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3907 		index += qdf_snprint(&str_buf[index],
3908 				     DP_MAX_STRING_LEN - index,
3909 				     " %u:%u,",
3910 				     i, dp_stats_buf->ul_ofdma_rx_mcs[i]);
3911 	}
3912 	DP_PRINT_STATS("ul_ofdma_rx_mcs = %s", str_buf);
3913 
3914 	DP_PRINT_STATS("rx_11ax_ul_ofdma = %u",
3915 		       dp_stats_buf->rx_11ax_ul_ofdma);
3916 
3917 	for (j = 0; j < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; j++) {
3918 		index = 0;
3919 		qdf_mem_zero(ul_ofdma_rx_gi[j], DP_MAX_STRING_LEN);
3920 		for (i = 0; i < HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3921 			index += qdf_snprint(&ul_ofdma_rx_gi[j][index],
3922 					     DP_MAX_STRING_LEN - index,
3923 					     " %u:%u,", i,
3924 					     dp_stats_buf->
3925 					     ul_ofdma_rx_gi[j][i]);
3926 		}
3927 		DP_PRINT_STATS("ul_ofdma_rx_gi[%u] = %s ",
3928 			       j, ul_ofdma_rx_gi[j]);
3929 	}
3930 
3931 	index = 0;
3932 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3933 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_SPATIAL_STREAMS; i++) {
3934 		index += qdf_snprint(&str_buf[index],
3935 				DP_MAX_STRING_LEN - index,
3936 				" %u:%u,", i, dp_stats_buf->ul_ofdma_rx_nss[i]);
3937 	}
3938 	DP_PRINT_STATS("ul_ofdma_rx_nss = %s", str_buf);
3939 
3940 	index = 0;
3941 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3942 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_BW_COUNTERS; i++) {
3943 		index += qdf_snprint(&str_buf[index],
3944 				DP_MAX_STRING_LEN - index,
3945 				" %u:%u,", i, dp_stats_buf->ul_ofdma_rx_bw[i]);
3946 	}
3947 	DP_PRINT_STATS("ul_ofdma_rx_bw = %s", str_buf);
3948 	DP_PRINT_STATS("ul_ofdma_rx_stbc = %u",
3949 		       dp_stats_buf->ul_ofdma_rx_stbc);
3950 	DP_PRINT_STATS("ul_ofdma_rx_ldpc = %u",
3951 		       dp_stats_buf->ul_ofdma_rx_ldpc);
3952 
3953 	index = 0;
3954 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3955 	for (i = 0; i < HTT_RX_PDEV_MAX_OFDMA_NUM_USER; i++) {
3956 		index += qdf_snprint(&str_buf[index],
3957 				     DP_MAX_STRING_LEN - index,
3958 				     " %u:%u,", i,
3959 				     dp_stats_buf->rx_ulofdma_non_data_ppdu[i]);
3960 	}
3961 	DP_PRINT_STATS("rx_ulofdma_non_data_ppdu = %s", str_buf);
3962 
3963 	index = 0;
3964 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3965 	for (i = 0; i < HTT_RX_PDEV_MAX_OFDMA_NUM_USER; i++) {
3966 		index += qdf_snprint(&str_buf[index],
3967 				     DP_MAX_STRING_LEN - index,
3968 				     " %u:%u,",
3969 				     i, dp_stats_buf->rx_ulofdma_data_ppdu[i]);
3970 	}
3971 	DP_PRINT_STATS("rx_ulofdma_data_ppdu = %s", str_buf);
3972 
3973 	index = 0;
3974 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3975 	for (i = 0; i < HTT_RX_PDEV_MAX_OFDMA_NUM_USER; i++) {
3976 		index += qdf_snprint(&str_buf[index],
3977 				     DP_MAX_STRING_LEN - index,
3978 				     " %u:%u,",
3979 				     i, dp_stats_buf->rx_ulofdma_mpdu_ok[i]);
3980 	}
3981 	DP_PRINT_STATS("rx_ulofdma_mpdu_ok = %s", str_buf);
3982 
3983 	index = 0;
3984 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3985 	for (i = 0; i < HTT_RX_PDEV_MAX_OFDMA_NUM_USER; i++) {
3986 		index += qdf_snprint(&str_buf[index],
3987 				     DP_MAX_STRING_LEN - index,
3988 				     " %u:%u,",
3989 				     i, dp_stats_buf->rx_ulofdma_mpdu_fail[i]);
3990 	}
3991 	DP_PRINT_STATS("rx_ulofdma_mpdu_fail = %s", str_buf);
3992 
3993 	index = 0;
3994 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
3995 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
3996 		index += qdf_snprint(&str_buf[index],
3997 				     DP_MAX_STRING_LEN - index,
3998 				     " %u:%u,",
3999 				     i, dp_stats_buf->rx_11ax_su_txbf_mcs[i]);
4000 	}
4001 	DP_PRINT_STATS("rx_11ax_su_txbf_mcs = %s", str_buf);
4002 
4003 	index = 0;
4004 	qdf_mem_zero(str_buf, DP_MAX_STRING_LEN);
4005 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_MCS_COUNTERS; i++) {
4006 		index += qdf_snprint(&str_buf[index],
4007 				     DP_MAX_STRING_LEN - index,
4008 				     " %u:%u,",
4009 				     i, dp_stats_buf->rx_11ax_mu_txbf_mcs[i]);
4010 	}
4011 	DP_PRINT_STATS("rx_11ax_mu_txbf_mcs = %s", str_buf);
4012 
4013 	for (i = 0; i < HTT_TX_PDEV_STATS_NUM_GI_COUNTERS; i++)
4014 		qdf_mem_free(ul_ofdma_rx_gi[i]);
4015 
4016 fail3:
4017 	for (i = 0; i < HTT_RX_PDEV_STATS_NUM_GI_COUNTERS; i++)
4018 		qdf_mem_free(rx_gi[i]);
4019 fail2:
4020 	for (i = 0; i < DP_HTT_RSSI_CHAIN_LEN; i++)
4021 		qdf_mem_free(rssi_chain[i]);
4022 fail1:
4023 	qdf_mem_free(str_buf);
4024 
4025 }
4026 
4027 /**
4028  * dp_print_rx_soc_fw_stats_tlv() - display htt_rx_soc_fw_stats_tlv
4029  * @tag_buf: buffer containing the tlv htt_rx_soc_fw_stats_tlv
4030  *
4031  * Return: void
4032  */
dp_print_rx_soc_fw_stats_tlv(uint32_t * tag_buf)4033 static void dp_print_rx_soc_fw_stats_tlv(uint32_t *tag_buf)
4034 {
4035 	htt_rx_soc_fw_stats_tlv *dp_stats_buf =
4036 		(htt_rx_soc_fw_stats_tlv *)tag_buf;
4037 
4038 	DP_PRINT_STATS("HTT_RX_SOC_FW_STATS_TLV:");
4039 	DP_PRINT_STATS("fw_reo_ring_data_msdu = %u",
4040 		       dp_stats_buf->fw_reo_ring_data_msdu);
4041 	DP_PRINT_STATS("fw_to_host_data_msdu_bcmc = %u",
4042 		       dp_stats_buf->fw_to_host_data_msdu_bcmc);
4043 	DP_PRINT_STATS("fw_to_host_data_msdu_uc = %u",
4044 		       dp_stats_buf->fw_to_host_data_msdu_uc);
4045 	DP_PRINT_STATS("ofld_remote_data_buf_recycle_cnt = %u",
4046 		       dp_stats_buf->ofld_remote_data_buf_recycle_cnt);
4047 	DP_PRINT_STATS("ofld_remote_free_buf_indication_cnt = %u",
4048 		       dp_stats_buf->ofld_remote_free_buf_indication_cnt);
4049 	DP_PRINT_STATS("ofld_buf_to_host_data_msdu_uc = %u ",
4050 		       dp_stats_buf->ofld_buf_to_host_data_msdu_uc);
4051 	DP_PRINT_STATS("reo_fw_ring_to_host_data_msdu_uc = %u ",
4052 		       dp_stats_buf->reo_fw_ring_to_host_data_msdu_uc);
4053 	DP_PRINT_STATS("wbm_sw_ring_reap = %u ",
4054 		       dp_stats_buf->wbm_sw_ring_reap);
4055 	DP_PRINT_STATS("wbm_forward_to_host_cnt = %u ",
4056 		       dp_stats_buf->wbm_forward_to_host_cnt);
4057 	DP_PRINT_STATS("wbm_target_recycle_cnt = %u ",
4058 		       dp_stats_buf->wbm_target_recycle_cnt);
4059 	DP_PRINT_STATS("target_refill_ring_recycle_cnt = %u",
4060 		       dp_stats_buf->target_refill_ring_recycle_cnt);
4061 
4062 }
4063 
4064 /**
4065  * dp_print_rx_soc_fw_refill_ring_empty_tlv_v() - display
4066  *					htt_rx_soc_fw_refill_ring_empty_tlv_v
4067  * @tag_buf: buffer containing the tlv htt_rx_soc_fw_refill_ring_empty_tlv_v
4068  *
4069  * Return: void
4070  */
dp_print_rx_soc_fw_refill_ring_empty_tlv_v(uint32_t * tag_buf)4071 static void dp_print_rx_soc_fw_refill_ring_empty_tlv_v(uint32_t *tag_buf)
4072 {
4073 	htt_rx_soc_fw_refill_ring_empty_tlv_v *dp_stats_buf =
4074 		(htt_rx_soc_fw_refill_ring_empty_tlv_v *)tag_buf;
4075 	uint8_t i;
4076 	uint16_t index = 0;
4077 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
4078 	char *refill_ring_empty_cnt = qdf_mem_malloc(DP_MAX_STRING_LEN);
4079 
4080 	if (!refill_ring_empty_cnt) {
4081 		dp_stats_err("Output buffer not allocated");
4082 		return;
4083 	}
4084 
4085 	tag_len = qdf_min(tag_len, (uint32_t)HTT_RX_STATS_REFILL_MAX_RING);
4086 
4087 	DP_PRINT_STATS("HTT_RX_SOC_FW_REFILL_RING_EMPTY_TLV_V:");
4088 	for (i = 0; i <  tag_len; i++) {
4089 		index += qdf_snprint(&refill_ring_empty_cnt[index],
4090 				DP_MAX_STRING_LEN - index,
4091 				" %u:%u,", i,
4092 				dp_stats_buf->refill_ring_empty_cnt[i]);
4093 	}
4094 	DP_PRINT_STATS("refill_ring_empty_cnt = %s\n",
4095 		       refill_ring_empty_cnt);
4096 	qdf_mem_free(refill_ring_empty_cnt);
4097 }
4098 
4099 /**
4100  * dp_print_rx_soc_fw_refill_ring_num_refill_tlv_v() - display
4101  *				htt_rx_soc_fw_refill_ring_num_refill_tlv_v
4102  * @tag_buf: buffer containing the tlv htt_rx_soc_fw_refill_ring_num_refill_tlv
4103  *
4104  * Return: void
4105  */
dp_print_rx_soc_fw_refill_ring_num_refill_tlv_v(uint32_t * tag_buf)4106 static void dp_print_rx_soc_fw_refill_ring_num_refill_tlv_v(
4107 		uint32_t *tag_buf)
4108 {
4109 	htt_rx_soc_fw_refill_ring_num_refill_tlv_v *dp_stats_buf =
4110 		(htt_rx_soc_fw_refill_ring_num_refill_tlv_v *)tag_buf;
4111 	uint8_t i;
4112 	uint16_t index = 0;
4113 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
4114 	char *refill_ring_num_refill = qdf_mem_malloc(DP_MAX_STRING_LEN);
4115 
4116 	if (!refill_ring_num_refill) {
4117 		dp_stats_err("Output buffer not allocated");
4118 		return;
4119 	}
4120 
4121 	tag_len = qdf_min(tag_len, (uint32_t)HTT_TX_PDEV_MAX_URRN_STATS);
4122 
4123 	DP_PRINT_STATS("HTT_RX_SOC_FW_REFILL_RING_NUM_REFILL_TLV_V:");
4124 	for (i = 0; i <  tag_len; i++) {
4125 		index += qdf_snprint(&refill_ring_num_refill[index],
4126 				DP_MAX_STRING_LEN - index,
4127 				" %u:%u,", i,
4128 				dp_stats_buf->refill_ring_num_refill[i]);
4129 	}
4130 	DP_PRINT_STATS("refill_ring_num_refill = %s\n",
4131 		       refill_ring_num_refill);
4132 	qdf_mem_free(refill_ring_num_refill);
4133 }
4134 
4135 /**
4136  * dp_print_rx_pdev_fw_stats_tlv() - display htt_rx_pdev_fw_stats_tlv
4137  * @tag_buf: buffer containing the tlv htt_rx_pdev_fw_stats_tlv
4138  *
4139  * Return: void
4140  */
dp_print_rx_pdev_fw_stats_tlv(uint32_t * tag_buf)4141 static void dp_print_rx_pdev_fw_stats_tlv(uint32_t *tag_buf)
4142 {
4143 	htt_rx_pdev_fw_stats_tlv *dp_stats_buf =
4144 		(htt_rx_pdev_fw_stats_tlv *)tag_buf;
4145 	uint8_t i;
4146 	uint16_t index = 0;
4147 	char fw_ring_subtype_buf[DP_MAX_STRING_LEN];
4148 
4149 	DP_PRINT_STATS("HTT_RX_PDEV_FW_STATS_TLV:");
4150 	DP_PRINT_STATS("mac_id__word = %u",
4151 		       dp_stats_buf->mac_id__word);
4152 	DP_PRINT_STATS("ppdu_recvd = %u",
4153 		       dp_stats_buf->ppdu_recvd);
4154 	DP_PRINT_STATS("mpdu_cnt_fcs_ok = %u",
4155 		       dp_stats_buf->mpdu_cnt_fcs_ok);
4156 	DP_PRINT_STATS("mpdu_cnt_fcs_err = %u",
4157 		       dp_stats_buf->mpdu_cnt_fcs_err);
4158 	DP_PRINT_STATS("tcp_msdu_cnt = %u",
4159 		       dp_stats_buf->tcp_msdu_cnt);
4160 	DP_PRINT_STATS("tcp_ack_msdu_cnt = %u",
4161 		       dp_stats_buf->tcp_ack_msdu_cnt);
4162 	DP_PRINT_STATS("udp_msdu_cnt = %u",
4163 		       dp_stats_buf->udp_msdu_cnt);
4164 	DP_PRINT_STATS("other_msdu_cnt = %u",
4165 		       dp_stats_buf->other_msdu_cnt);
4166 	DP_PRINT_STATS("fw_ring_mpdu_ind = %u",
4167 		       dp_stats_buf->fw_ring_mpdu_ind);
4168 
4169 	qdf_mem_zero(fw_ring_subtype_buf, DP_MAX_STRING_LEN);
4170 	for (i = 0; i <  DP_HTT_FW_RING_MGMT_SUBTYPE_LEN; i++) {
4171 		index += qdf_snprint(&fw_ring_subtype_buf[index],
4172 				DP_MAX_STRING_LEN - index,
4173 				" %u:%u,", i,
4174 				dp_stats_buf->fw_ring_mgmt_subtype[i]);
4175 	}
4176 	DP_PRINT_STATS("fw_ring_mgmt_subtype = %s ", fw_ring_subtype_buf);
4177 
4178 	index = 0;
4179 	qdf_mem_zero(fw_ring_subtype_buf, DP_MAX_STRING_LEN);
4180 	for (i = 0; i <  DP_HTT_FW_RING_CTRL_SUBTYPE_LEN; i++) {
4181 		index += qdf_snprint(&fw_ring_subtype_buf[index],
4182 				DP_MAX_STRING_LEN - index,
4183 				" %u:%u,", i,
4184 				dp_stats_buf->fw_ring_ctrl_subtype[i]);
4185 	}
4186 	DP_PRINT_STATS("fw_ring_ctrl_subtype = %s ", fw_ring_subtype_buf);
4187 	DP_PRINT_STATS("fw_ring_mcast_data_msdu = %u",
4188 		       dp_stats_buf->fw_ring_mcast_data_msdu);
4189 	DP_PRINT_STATS("fw_ring_bcast_data_msdu = %u",
4190 		       dp_stats_buf->fw_ring_bcast_data_msdu);
4191 	DP_PRINT_STATS("fw_ring_ucast_data_msdu = %u",
4192 		       dp_stats_buf->fw_ring_ucast_data_msdu);
4193 	DP_PRINT_STATS("fw_ring_null_data_msdu = %u",
4194 		       dp_stats_buf->fw_ring_null_data_msdu);
4195 	DP_PRINT_STATS("fw_ring_mpdu_drop = %u",
4196 		       dp_stats_buf->fw_ring_mpdu_drop);
4197 	DP_PRINT_STATS("ofld_local_data_ind_cnt = %u",
4198 		       dp_stats_buf->ofld_local_data_ind_cnt);
4199 	DP_PRINT_STATS("ofld_local_data_buf_recycle_cnt = %u",
4200 		       dp_stats_buf->ofld_local_data_buf_recycle_cnt);
4201 	DP_PRINT_STATS("drx_local_data_ind_cnt = %u",
4202 		       dp_stats_buf->drx_local_data_ind_cnt);
4203 	DP_PRINT_STATS("drx_local_data_buf_recycle_cnt = %u",
4204 		       dp_stats_buf->drx_local_data_buf_recycle_cnt);
4205 	DP_PRINT_STATS("local_nondata_ind_cnt = %u",
4206 		       dp_stats_buf->local_nondata_ind_cnt);
4207 	DP_PRINT_STATS("local_nondata_buf_recycle_cnt = %u",
4208 		       dp_stats_buf->local_nondata_buf_recycle_cnt);
4209 	DP_PRINT_STATS("fw_status_buf_ring_refill_cnt = %u",
4210 		       dp_stats_buf->fw_status_buf_ring_refill_cnt);
4211 	DP_PRINT_STATS("fw_status_buf_ring_empty_cnt = %u",
4212 		       dp_stats_buf->fw_status_buf_ring_empty_cnt);
4213 	DP_PRINT_STATS("fw_pkt_buf_ring_refill_cnt = %u",
4214 		       dp_stats_buf->fw_pkt_buf_ring_refill_cnt);
4215 	DP_PRINT_STATS("fw_pkt_buf_ring_empty_cnt = %u",
4216 		       dp_stats_buf->fw_pkt_buf_ring_empty_cnt);
4217 	DP_PRINT_STATS("fw_link_buf_ring_refill_cnt = %u",
4218 		       dp_stats_buf->fw_link_buf_ring_refill_cnt);
4219 	DP_PRINT_STATS("fw_link_buf_ring_empty_cnt = %u",
4220 		       dp_stats_buf->fw_link_buf_ring_empty_cnt);
4221 	DP_PRINT_STATS("host_pkt_buf_ring_refill_cnt = %u",
4222 		       dp_stats_buf->host_pkt_buf_ring_refill_cnt);
4223 	DP_PRINT_STATS("host_pkt_buf_ring_empty_cnt = %u",
4224 		       dp_stats_buf->host_pkt_buf_ring_empty_cnt);
4225 	DP_PRINT_STATS("mon_pkt_buf_ring_refill_cnt = %u",
4226 		       dp_stats_buf->mon_pkt_buf_ring_refill_cnt);
4227 	DP_PRINT_STATS("mon_pkt_buf_ring_empty_cnt = %u",
4228 		       dp_stats_buf->mon_pkt_buf_ring_empty_cnt);
4229 	DP_PRINT_STATS("mon_status_buf_ring_refill_cnt = %u",
4230 		       dp_stats_buf->mon_status_buf_ring_refill_cnt);
4231 	DP_PRINT_STATS("mon_status_buf_ring_empty_cnt = %u",
4232 		       dp_stats_buf->mon_status_buf_ring_empty_cnt);
4233 	DP_PRINT_STATS("mon_desc_buf_ring_refill_cnt = %u",
4234 		       dp_stats_buf->mon_desc_buf_ring_refill_cnt);
4235 	DP_PRINT_STATS("mon_desc_buf_ring_empty_cnt = %u",
4236 		       dp_stats_buf->mon_desc_buf_ring_empty_cnt);
4237 	DP_PRINT_STATS("mon_dest_ring_update_cnt = %u",
4238 		       dp_stats_buf->mon_dest_ring_update_cnt);
4239 	DP_PRINT_STATS("mon_dest_ring_full_cnt = %u",
4240 		       dp_stats_buf->mon_dest_ring_full_cnt);
4241 	DP_PRINT_STATS("rx_suspend_cnt = %u",
4242 		       dp_stats_buf->rx_suspend_cnt);
4243 	DP_PRINT_STATS("rx_suspend_fail_cnt = %u",
4244 		       dp_stats_buf->rx_suspend_fail_cnt);
4245 	DP_PRINT_STATS("rx_resume_cnt = %u",
4246 		       dp_stats_buf->rx_resume_cnt);
4247 	DP_PRINT_STATS("rx_resume_fail_cnt = %u",
4248 		       dp_stats_buf->rx_resume_fail_cnt);
4249 	DP_PRINT_STATS("rx_ring_switch_cnt = %u",
4250 		       dp_stats_buf->rx_ring_switch_cnt);
4251 	DP_PRINT_STATS("rx_ring_restore_cnt = %u",
4252 		       dp_stats_buf->rx_ring_restore_cnt);
4253 	DP_PRINT_STATS("rx_flush_cnt = %u\n",
4254 		       dp_stats_buf->rx_flush_cnt);
4255 }
4256 
4257 /**
4258  * dp_print_rx_pdev_fw_ring_mpdu_err_tlv_v() - display
4259  *				htt_rx_pdev_fw_ring_mpdu_err_tlv_v
4260  * @tag_buf: buffer containing the tlv htt_rx_pdev_fw_ring_mpdu_err_tlv_v
4261  *
4262  * Return: void
4263  */
dp_print_rx_pdev_fw_ring_mpdu_err_tlv_v(uint32_t * tag_buf)4264 static void dp_print_rx_pdev_fw_ring_mpdu_err_tlv_v(uint32_t *tag_buf)
4265 {
4266 	htt_rx_pdev_fw_ring_mpdu_err_tlv_v *dp_stats_buf =
4267 		(htt_rx_pdev_fw_ring_mpdu_err_tlv_v *)tag_buf;
4268 	uint8_t i;
4269 	uint16_t index = 0;
4270 	char *fw_ring_mpdu_err = qdf_mem_malloc(DP_MAX_STRING_LEN);
4271 
4272 	if (!fw_ring_mpdu_err) {
4273 		dp_stats_err("Output buffer not allocated");
4274 		return;
4275 	}
4276 
4277 	DP_PRINT_STATS("HTT_RX_PDEV_FW_RING_MPDU_ERR_TLV_V:");
4278 	for (i = 0; i <  DP_HTT_FW_RING_MPDU_ERR_LEN; i++) {
4279 		index += qdf_snprint(&fw_ring_mpdu_err[index],
4280 				DP_MAX_STRING_LEN - index,
4281 				" %u:%u,", i,
4282 				dp_stats_buf->fw_ring_mpdu_err[i]);
4283 	}
4284 	DP_PRINT_STATS("fw_ring_mpdu_err = %s\n", fw_ring_mpdu_err);
4285 	qdf_mem_free(fw_ring_mpdu_err);
4286 }
4287 
4288 /**
4289  * dp_print_rx_pdev_fw_mpdu_drop_tlv_v() - display htt_rx_pdev_fw_mpdu_drop_tlv_v
4290  * @tag_buf: buffer containing the tlv htt_rx_pdev_fw_mpdu_drop_tlv_v
4291  *
4292  * Return: void
4293  */
dp_print_rx_pdev_fw_mpdu_drop_tlv_v(uint32_t * tag_buf)4294 static void dp_print_rx_pdev_fw_mpdu_drop_tlv_v(uint32_t *tag_buf)
4295 {
4296 	htt_rx_pdev_fw_mpdu_drop_tlv_v *dp_stats_buf =
4297 		(htt_rx_pdev_fw_mpdu_drop_tlv_v *)tag_buf;
4298 	uint8_t i;
4299 	uint16_t index = 0;
4300 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
4301 	char *fw_mpdu_drop = qdf_mem_malloc(DP_MAX_STRING_LEN);
4302 
4303 	if (!fw_mpdu_drop) {
4304 		dp_stats_err("Output buffer not allocated");
4305 		return;
4306 	}
4307 
4308 	tag_len = qdf_min(tag_len, (uint32_t)HTT_RX_STATS_FW_DROP_REASON_MAX);
4309 
4310 	DP_PRINT_STATS("HTT_RX_PDEV_FW_MPDU_DROP_TLV_V:");
4311 	for (i = 0; i <  tag_len; i++) {
4312 		index += qdf_snprint(&fw_mpdu_drop[index],
4313 				DP_MAX_STRING_LEN - index,
4314 				" %u:%u,", i, dp_stats_buf->fw_mpdu_drop[i]);
4315 	}
4316 	DP_PRINT_STATS("fw_mpdu_drop = %s\n", fw_mpdu_drop);
4317 	qdf_mem_free(fw_mpdu_drop);
4318 }
4319 
4320 /**
4321  * dp_print_rx_soc_fw_refill_ring_num_rxdma_err_tlv() - Accounts for rxdma error
4322  * packets
4323  * @tag_buf: Buffer
4324  *
4325  * Return: void
4326  */
4327 static uint64_t
dp_print_rx_soc_fw_refill_ring_num_rxdma_err_tlv(uint32_t * tag_buf)4328 dp_print_rx_soc_fw_refill_ring_num_rxdma_err_tlv(uint32_t *tag_buf)
4329 {
4330 	htt_rx_soc_fw_refill_ring_num_rxdma_err_tlv_v *dp_stats_buf =
4331 		(htt_rx_soc_fw_refill_ring_num_rxdma_err_tlv_v *)tag_buf;
4332 
4333 	uint8_t i;
4334 	uint16_t index = 0;
4335 	char rxdma_err_cnt[DP_MAX_STRING_LEN] = {'\0'};
4336 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
4337 	uint64_t total_rxdma_err_cnt = 0;
4338 
4339 	tag_len = qdf_min(tag_len, (uint32_t)HTT_RX_RXDMA_MAX_ERR_CODE);
4340 
4341 	DP_PRINT_STATS("HTT_RX_SOC_FW_REFILL_RING_NUM_RXDMA_ERR_TLV_V");
4342 
4343 	for (i = 0; i <  tag_len; i++) {
4344 		index += snprintf(&rxdma_err_cnt[index],
4345 				DP_MAX_STRING_LEN - index,
4346 				" %u() -%u,", i,
4347 				dp_stats_buf->rxdma_err[i]);
4348 		total_rxdma_err_cnt += dp_stats_buf->rxdma_err[i];
4349 	}
4350 
4351 	DP_PRINT_STATS("rxdma_err = %s\n", rxdma_err_cnt);
4352 
4353 	return total_rxdma_err_cnt;
4354 }
4355 
4356 /**
4357  * dp_print_rx_soc_fw_refill_ring_num_reo_err_tlv() - Accounts for reo error
4358  * packets
4359  * @tag_buf: Buffer
4360  *
4361  * Return: void
4362  */
dp_print_rx_soc_fw_refill_ring_num_reo_err_tlv(uint32_t * tag_buf)4363 static void dp_print_rx_soc_fw_refill_ring_num_reo_err_tlv(uint32_t *tag_buf)
4364 {
4365 	htt_rx_soc_fw_refill_ring_num_reo_err_tlv_v *dp_stats_buf =
4366 		(htt_rx_soc_fw_refill_ring_num_reo_err_tlv_v *)tag_buf;
4367 
4368 	uint8_t i;
4369 	uint16_t index = 0;
4370 	char reo_err_cnt[DP_MAX_STRING_LEN] = {'\0'};
4371 	uint32_t tag_len = (HTT_STATS_TLV_LENGTH_GET(*tag_buf) >> 2);
4372 
4373 	tag_len = qdf_min(tag_len, (uint32_t)HTT_RX_REO_MAX_ERR_CODE);
4374 
4375 	DP_PRINT_STATS("HTT_RX_SOC_FW_REFILL_RING_NUM_REO_ERR_TLV_V");
4376 
4377 	for (i = 0; i <  tag_len; i++) {
4378 		index += snprintf(&reo_err_cnt[index],
4379 				DP_MAX_STRING_LEN - index,
4380 				" %u() -%u,", i,
4381 				dp_stats_buf->reo_err[i]);
4382 	}
4383 
4384 	DP_PRINT_STATS("reo_err = %s\n", reo_err_cnt);
4385 }
4386 
4387 /**
4388  * dp_print_rx_reo_debug_stats_tlv() - REO Statistics
4389  * @tag_buf: Buffer
4390  *
4391  * Return: void
4392  */
dp_print_rx_reo_debug_stats_tlv(uint32_t * tag_buf)4393 static void dp_print_rx_reo_debug_stats_tlv(uint32_t *tag_buf)
4394 {
4395 	htt_rx_reo_resource_stats_tlv_v *dp_stats_buf =
4396 			(htt_rx_reo_resource_stats_tlv_v *)tag_buf;
4397 
4398 	DP_PRINT_STATS("HTT_RX_REO_RESOURCE_STATS_TLV");
4399 
4400 	DP_PRINT_STATS("sample_id() - %u ",
4401 		       dp_stats_buf->sample_id);
4402 	DP_PRINT_STATS("total_max: %u ",
4403 		       dp_stats_buf->total_max);
4404 	DP_PRINT_STATS("total_avg: %u ",
4405 		       dp_stats_buf->total_avg);
4406 	DP_PRINT_STATS("total_sample: %u ",
4407 		       dp_stats_buf->total_sample);
4408 	DP_PRINT_STATS("non_zeros_avg: %u ",
4409 		       dp_stats_buf->non_zeros_avg);
4410 	DP_PRINT_STATS("non_zeros_sample: %u ",
4411 		       dp_stats_buf->non_zeros_sample);
4412 	DP_PRINT_STATS("last_non_zeros_max: %u ",
4413 		       dp_stats_buf->last_non_zeros_max);
4414 	DP_PRINT_STATS("last_non_zeros_min: %u ",
4415 		       dp_stats_buf->last_non_zeros_min);
4416 	DP_PRINT_STATS("last_non_zeros_avg: %u ",
4417 		       dp_stats_buf->last_non_zeros_avg);
4418 	DP_PRINT_STATS("last_non_zeros_sample: %u\n ",
4419 		       dp_stats_buf->last_non_zeros_sample);
4420 }
4421 
4422 /**
4423  * dp_print_rx_pdev_fw_stats_phy_err_tlv() - Accounts for phy errors
4424  * @tag_buf: Buffer
4425  *
4426  * Return: void
4427  */
dp_print_rx_pdev_fw_stats_phy_err_tlv(uint32_t * tag_buf)4428 static void dp_print_rx_pdev_fw_stats_phy_err_tlv(uint32_t *tag_buf)
4429 {
4430 	htt_rx_pdev_fw_stats_phy_err_tlv *dp_stats_buf =
4431 		(htt_rx_pdev_fw_stats_phy_err_tlv *)tag_buf;
4432 
4433 	uint8_t i = 0;
4434 	uint16_t index = 0;
4435 	char phy_errs[DP_MAX_STRING_LEN];
4436 
4437 	DP_PRINT_STATS("HTT_RX_PDEV_FW_STATS_PHY_ERR_TLV");
4438 
4439 	DP_PRINT_STATS("mac_id_word() - %u",
4440 		       dp_stats_buf->mac_id__word);
4441 	DP_PRINT_STATS("total_phy_err_cnt: %u",
4442 		       dp_stats_buf->total_phy_err_cnt);
4443 
4444 	for (i = 0; i < HTT_STATS_PHY_ERR_MAX; i++) {
4445 		index += snprintf(&phy_errs[index],
4446 				DP_MAX_STRING_LEN - index,
4447 				" %u:%u,", i, dp_stats_buf->phy_err[i]);
4448 	}
4449 
4450 	DP_PRINT_STATS("phy_errs: %s\n",  phy_errs);
4451 }
4452 
dp_htt_stats_print_tag(struct dp_pdev * pdev,uint8_t tag_type,uint32_t * tag_buf)4453 void dp_htt_stats_print_tag(struct dp_pdev *pdev,
4454 			    uint8_t tag_type, uint32_t *tag_buf)
4455 {
4456 	switch (tag_type) {
4457 	case HTT_STATS_TX_PDEV_CMN_TAG:
4458 		dp_print_tx_pdev_stats_cmn_tlv(tag_buf);
4459 		break;
4460 	case HTT_STATS_TX_PDEV_UNDERRUN_TAG:
4461 		dp_print_tx_pdev_stats_urrn_tlv_v(tag_buf);
4462 		break;
4463 	case HTT_STATS_TX_PDEV_SIFS_TAG:
4464 		dp_print_tx_pdev_stats_sifs_tlv_v(tag_buf);
4465 		break;
4466 	case HTT_STATS_TX_PDEV_FLUSH_TAG:
4467 		dp_print_tx_pdev_stats_flush_tlv_v(tag_buf);
4468 		break;
4469 
4470 	case HTT_STATS_TX_PDEV_PHY_ERR_TAG:
4471 		dp_print_tx_pdev_stats_phy_err_tlv_v(tag_buf);
4472 		break;
4473 
4474 	case HTT_STATS_STRING_TAG:
4475 		dp_print_stats_string_tlv(tag_buf);
4476 		break;
4477 
4478 	case HTT_STATS_TX_HWQ_CMN_TAG:
4479 		dp_print_tx_hwq_stats_cmn_tlv(tag_buf);
4480 		break;
4481 
4482 	case HTT_STATS_TX_HWQ_DIFS_LATENCY_TAG:
4483 		dp_print_tx_hwq_difs_latency_stats_tlv_v(tag_buf);
4484 		break;
4485 
4486 	case HTT_STATS_TX_HWQ_CMD_RESULT_TAG:
4487 		dp_print_tx_hwq_cmd_result_stats_tlv_v(tag_buf);
4488 		break;
4489 
4490 	case HTT_STATS_TX_HWQ_CMD_STALL_TAG:
4491 		dp_print_tx_hwq_cmd_stall_stats_tlv_v(tag_buf);
4492 		break;
4493 
4494 	case HTT_STATS_TX_HWQ_FES_STATUS_TAG:
4495 		dp_print_tx_hwq_fes_result_stats_tlv_v(tag_buf);
4496 		break;
4497 
4498 	case HTT_STATS_TX_TQM_GEN_MPDU_TAG:
4499 		dp_print_tx_tqm_gen_mpdu_stats_tlv_v(tag_buf);
4500 		break;
4501 
4502 	case HTT_STATS_TX_TQM_LIST_MPDU_TAG:
4503 		dp_print_tx_tqm_list_mpdu_stats_tlv_v(tag_buf);
4504 		break;
4505 
4506 	case HTT_STATS_TX_TQM_LIST_MPDU_CNT_TAG:
4507 		dp_print_tx_tqm_list_mpdu_cnt_tlv_v(tag_buf);
4508 		break;
4509 
4510 	case HTT_STATS_TX_TQM_CMN_TAG:
4511 		dp_print_tx_tqm_cmn_stats_tlv(tag_buf);
4512 		break;
4513 
4514 	case HTT_STATS_TX_TQM_PDEV_TAG:
4515 		dp_print_tx_tqm_pdev_stats_tlv_v(tag_buf);
4516 		break;
4517 
4518 	case HTT_STATS_TX_TQM_CMDQ_STATUS_TAG:
4519 		dp_print_tx_tqm_cmdq_status_tlv(tag_buf);
4520 		break;
4521 
4522 	case HTT_STATS_TX_DE_EAPOL_PACKETS_TAG:
4523 		dp_print_tx_de_eapol_packets_stats_tlv(tag_buf);
4524 		break;
4525 
4526 	case HTT_STATS_TX_DE_CLASSIFY_FAILED_TAG:
4527 		dp_print_tx_de_classify_failed_stats_tlv(tag_buf);
4528 		break;
4529 
4530 	case HTT_STATS_TX_DE_CLASSIFY_STATS_TAG:
4531 		dp_print_tx_de_classify_stats_tlv(tag_buf);
4532 		break;
4533 
4534 	case HTT_STATS_TX_DE_CLASSIFY_STATUS_TAG:
4535 		dp_print_tx_de_classify_status_stats_tlv(tag_buf);
4536 		break;
4537 
4538 	case HTT_STATS_TX_DE_ENQUEUE_PACKETS_TAG:
4539 		dp_print_tx_de_enqueue_packets_stats_tlv(tag_buf);
4540 		break;
4541 
4542 	case HTT_STATS_TX_DE_ENQUEUE_DISCARD_TAG:
4543 		dp_print_tx_de_enqueue_discard_stats_tlv(tag_buf);
4544 		break;
4545 
4546 	case HTT_STATS_TX_DE_CMN_TAG:
4547 		dp_print_tx_de_cmn_stats_tlv(tag_buf);
4548 		break;
4549 
4550 	case HTT_STATS_RING_IF_TAG:
4551 		dp_print_ring_if_stats_tlv(tag_buf);
4552 		break;
4553 
4554 	case HTT_STATS_TX_PDEV_MU_MIMO_STATS_TAG:
4555 		dp_print_tx_pdev_mu_mimo_sch_stats_tlv(tag_buf);
4556 		break;
4557 
4558 	case HTT_STATS_SFM_CMN_TAG:
4559 		dp_print_sfm_cmn_tlv(tag_buf);
4560 		break;
4561 
4562 	case HTT_STATS_SRING_STATS_TAG:
4563 		dp_print_sring_stats_tlv(tag_buf);
4564 		break;
4565 
4566 	case HTT_STATS_RX_PDEV_FW_STATS_TAG:
4567 		dp_print_rx_pdev_fw_stats_tlv(tag_buf);
4568 		break;
4569 
4570 	case HTT_STATS_RX_PDEV_FW_RING_MPDU_ERR_TAG:
4571 		dp_print_rx_pdev_fw_ring_mpdu_err_tlv_v(tag_buf);
4572 		break;
4573 
4574 	case HTT_STATS_RX_PDEV_FW_MPDU_DROP_TAG:
4575 		dp_print_rx_pdev_fw_mpdu_drop_tlv_v(tag_buf);
4576 		break;
4577 
4578 	case HTT_STATS_RX_SOC_FW_STATS_TAG:
4579 		dp_print_rx_soc_fw_stats_tlv(tag_buf);
4580 		break;
4581 
4582 	case HTT_STATS_RX_SOC_FW_REFILL_RING_EMPTY_TAG:
4583 		dp_print_rx_soc_fw_refill_ring_empty_tlv_v(tag_buf);
4584 		break;
4585 
4586 	case HTT_STATS_RX_SOC_FW_REFILL_RING_NUM_REFILL_TAG:
4587 		dp_print_rx_soc_fw_refill_ring_num_refill_tlv_v(
4588 				tag_buf);
4589 		break;
4590 
4591 	case HTT_STATS_TX_PDEV_RATE_STATS_TAG:
4592 		dp_print_tx_pdev_rate_stats_tlv(tag_buf);
4593 		break;
4594 
4595 	case HTT_STATS_RX_PDEV_RATE_STATS_TAG:
4596 		dp_print_rx_pdev_rate_stats_tlv(pdev, tag_buf);
4597 		break;
4598 
4599 	case HTT_STATS_RX_PDEV_RATE_EXT_STATS_TAG:
4600 		dp_print_rx_pdev_rate_ext_stats_tlv(pdev, tag_buf);
4601 		break;
4602 
4603 	case HTT_STATS_TX_PDEV_SCHEDULER_TXQ_STATS_TAG:
4604 		dp_print_tx_pdev_stats_sched_per_txq_tlv(tag_buf);
4605 		break;
4606 
4607 	case HTT_STATS_TX_SCHED_CMN_TAG:
4608 		dp_print_stats_tx_sched_cmn_tlv(tag_buf);
4609 		break;
4610 
4611 	case HTT_STATS_TX_PDEV_MPDU_STATS_TAG:
4612 		dp_print_tx_pdev_mu_mimo_mpdu_stats_tlv(tag_buf);
4613 		break;
4614 
4615 	case HTT_STATS_SCHED_TXQ_CMD_POSTED_TAG:
4616 		dp_print_sched_txq_cmd_posted_tlv_v(tag_buf);
4617 		break;
4618 
4619 	case HTT_STATS_RING_IF_CMN_TAG:
4620 		dp_print_ring_if_cmn_tlv(tag_buf);
4621 		break;
4622 
4623 	case HTT_STATS_SFM_CLIENT_USER_TAG:
4624 		dp_print_sfm_client_user_tlv_v(tag_buf);
4625 		break;
4626 
4627 	case HTT_STATS_SFM_CLIENT_TAG:
4628 		dp_print_sfm_client_tlv(tag_buf);
4629 		break;
4630 
4631 	case HTT_STATS_TX_TQM_ERROR_STATS_TAG:
4632 		dp_print_tx_tqm_error_stats_tlv(tag_buf);
4633 		break;
4634 
4635 	case HTT_STATS_SCHED_TXQ_CMD_REAPED_TAG:
4636 		dp_print_sched_txq_cmd_reaped_tlv_v(tag_buf);
4637 		break;
4638 
4639 	case HTT_STATS_SRING_CMN_TAG:
4640 		dp_print_sring_cmn_tlv(tag_buf);
4641 		break;
4642 
4643 	case HTT_STATS_TX_SELFGEN_AC_ERR_STATS_TAG:
4644 		dp_print_tx_selfgen_ac_err_stats_tlv(tag_buf);
4645 		break;
4646 
4647 	case HTT_STATS_TX_SELFGEN_CMN_STATS_TAG:
4648 		dp_print_tx_selfgen_cmn_stats_tlv(tag_buf);
4649 		break;
4650 
4651 	case HTT_STATS_TX_SELFGEN_AC_STATS_TAG:
4652 		dp_print_tx_selfgen_ac_stats_tlv(tag_buf);
4653 		break;
4654 
4655 	case HTT_STATS_TX_SELFGEN_AX_STATS_TAG:
4656 		dp_print_tx_selfgen_ax_stats_tlv(tag_buf);
4657 		break;
4658 
4659 	case HTT_STATS_TX_SELFGEN_AX_ERR_STATS_TAG:
4660 		dp_print_tx_selfgen_ax_err_stats_tlv(tag_buf);
4661 		break;
4662 
4663 	case  HTT_STATS_TX_SELFGEN_BE_STATS_TAG:
4664 		dp_print_tx_selfgen_be_stats_tlv(tag_buf);
4665 		break;
4666 
4667 	case HTT_STATS_TX_SELFGEN_BE_ERR_STATS_TAG:
4668 		dp_print_tx_selfgen_be_err_stats_tlv(tag_buf);
4669 		break;
4670 
4671 	case HTT_STATS_TX_SOUNDING_STATS_TAG:
4672 		dp_print_tx_sounding_stats_tlv(tag_buf);
4673 		break;
4674 
4675 	case HTT_STATS_TX_HWQ_MUMIMO_SCH_STATS_TAG:
4676 		dp_print_tx_hwq_mu_mimo_sch_stats_tlv(tag_buf);
4677 		break;
4678 
4679 	case HTT_STATS_TX_HWQ_MUMIMO_MPDU_STATS_TAG:
4680 		dp_print_tx_hwq_mu_mimo_mpdu_stats_tlv(tag_buf);
4681 		break;
4682 
4683 	case HTT_STATS_TX_HWQ_MUMIMO_CMN_STATS_TAG:
4684 		dp_print_tx_hwq_mu_mimo_cmn_stats_tlv(tag_buf);
4685 		break;
4686 
4687 	case HTT_STATS_HW_INTR_MISC_TAG:
4688 		dp_print_hw_stats_intr_misc_tlv(tag_buf);
4689 		break;
4690 
4691 	case HTT_STATS_HW_WD_TIMEOUT_TAG:
4692 		dp_print_hw_stats_wd_timeout_tlv(tag_buf);
4693 		break;
4694 
4695 	case HTT_STATS_HW_PDEV_ERRS_TAG:
4696 		dp_print_hw_stats_pdev_errs_tlv(tag_buf);
4697 		break;
4698 
4699 	case HTT_STATS_COUNTER_NAME_TAG:
4700 		dp_print_counter_tlv(tag_buf);
4701 		break;
4702 
4703 	case HTT_STATS_TX_TID_DETAILS_TAG:
4704 		dp_print_tx_tid_stats_tlv(tag_buf);
4705 		break;
4706 
4707 	case HTT_STATS_TX_TID_DETAILS_V1_TAG:
4708 		dp_print_tx_tid_stats_v1_tlv(tag_buf);
4709 		break;
4710 
4711 	case HTT_STATS_RX_TID_DETAILS_TAG:
4712 		dp_print_rx_tid_stats_tlv(tag_buf);
4713 		break;
4714 
4715 	case HTT_STATS_PEER_STATS_CMN_TAG:
4716 		dp_print_peer_stats_cmn_tlv(tag_buf);
4717 		break;
4718 
4719 	case HTT_STATS_PEER_DETAILS_TAG:
4720 		dp_print_peer_details_tlv(tag_buf);
4721 		break;
4722 
4723 	case HTT_STATS_PEER_MSDU_FLOWQ_TAG:
4724 		dp_print_msdu_flow_stats_tlv(tag_buf);
4725 		break;
4726 
4727 	case HTT_STATS_PEER_TX_RATE_STATS_TAG:
4728 		dp_print_tx_peer_rate_stats_tlv(tag_buf);
4729 		break;
4730 
4731 	case HTT_STATS_PEER_RX_RATE_STATS_TAG:
4732 		dp_print_rx_peer_rate_stats_tlv(tag_buf);
4733 		break;
4734 
4735 	case HTT_STATS_TX_DE_COMPL_STATS_TAG:
4736 		dp_print_tx_de_compl_stats_tlv(tag_buf);
4737 		break;
4738 
4739 	case HTT_STATS_RX_REFILL_RXDMA_ERR_TAG:
4740 		pdev->stats.err.fw_reported_rxdma_error =
4741 		dp_print_rx_soc_fw_refill_ring_num_rxdma_err_tlv(tag_buf);
4742 		break;
4743 
4744 	case HTT_STATS_RX_REFILL_REO_ERR_TAG:
4745 		dp_print_rx_soc_fw_refill_ring_num_reo_err_tlv(tag_buf);
4746 		break;
4747 
4748 	case HTT_STATS_RX_REO_RESOURCE_STATS_TAG:
4749 		dp_print_rx_reo_debug_stats_tlv(tag_buf);
4750 		break;
4751 
4752 	case HTT_STATS_RX_PDEV_FW_STATS_PHY_ERR_TAG:
4753 		dp_print_rx_pdev_fw_stats_phy_err_tlv(tag_buf);
4754 		break;
4755 
4756 	default:
4757 		break;
4758 	}
4759 }
4760 
dp_htt_stats_copy_tag(struct dp_pdev * pdev,uint8_t tag_type,uint32_t * tag_buf)4761 void dp_htt_stats_copy_tag(struct dp_pdev *pdev, uint8_t tag_type, uint32_t *tag_buf)
4762 {
4763 	void *dest_ptr = NULL;
4764 	uint32_t size = 0;
4765 	uint32_t size_expected = 0;
4766 	uint64_t val = 1;
4767 
4768 	pdev->fw_stats_tlv_bitmap_rcvd |= (val << tag_type);
4769 	switch (tag_type) {
4770 	case HTT_STATS_TX_PDEV_CMN_TAG:
4771 		dest_ptr = &pdev->stats.htt_tx_pdev_stats.cmn_tlv;
4772 		size = sizeof(htt_tx_pdev_stats_cmn_tlv);
4773 		size_expected = sizeof(struct cdp_htt_tx_pdev_stats_cmn_tlv);
4774 		break;
4775 	case HTT_STATS_TX_PDEV_UNDERRUN_TAG:
4776 		dest_ptr = &pdev->stats.htt_tx_pdev_stats.underrun_tlv;
4777 		size = sizeof(htt_tx_pdev_stats_urrn_tlv_v);
4778 		size_expected = sizeof(struct cdp_htt_tx_pdev_stats_urrn_tlv_v);
4779 		break;
4780 	case HTT_STATS_TX_PDEV_SIFS_TAG:
4781 		dest_ptr = &pdev->stats.htt_tx_pdev_stats.sifs_tlv;
4782 		size = sizeof(htt_tx_pdev_stats_sifs_tlv_v);
4783 		size_expected = sizeof(struct cdp_htt_tx_pdev_stats_sifs_tlv_v);
4784 		break;
4785 	case HTT_STATS_TX_PDEV_FLUSH_TAG:
4786 		dest_ptr = &pdev->stats.htt_tx_pdev_stats.flush_tlv;
4787 		size = sizeof(htt_tx_pdev_stats_flush_tlv_v);
4788 		size_expected =
4789 			sizeof(struct cdp_htt_tx_pdev_stats_flush_tlv_v);
4790 		break;
4791 	case HTT_STATS_TX_PDEV_PHY_ERR_TAG:
4792 		dest_ptr = &pdev->stats.htt_tx_pdev_stats.phy_err_tlv;
4793 		size = sizeof(htt_tx_pdev_stats_phy_err_tlv_v);
4794 		size_expected =
4795 			sizeof(struct cdp_htt_tx_pdev_stats_phy_err_tlv_v);
4796 		break;
4797 	case HTT_STATS_RX_PDEV_FW_STATS_TAG:
4798 		dest_ptr = &pdev->stats.htt_rx_pdev_stats.fw_stats_tlv;
4799 		size = sizeof(htt_rx_pdev_fw_stats_tlv);
4800 		size_expected = sizeof(struct cdp_htt_rx_pdev_fw_stats_tlv);
4801 		break;
4802 	case HTT_STATS_RX_SOC_FW_STATS_TAG:
4803 		dest_ptr = &pdev->stats.htt_rx_pdev_stats.soc_stats.fw_tlv;
4804 		size = sizeof(htt_rx_soc_fw_stats_tlv);
4805 		size_expected = sizeof(struct cdp_htt_rx_soc_fw_stats_tlv);
4806 		break;
4807 	case HTT_STATS_RX_SOC_FW_REFILL_RING_EMPTY_TAG:
4808 		dest_ptr = &pdev->stats.htt_rx_pdev_stats.soc_stats.fw_refill_ring_empty_tlv;
4809 		size = sizeof(htt_rx_soc_fw_refill_ring_empty_tlv_v);
4810 		size_expected =
4811 		sizeof(struct cdp_htt_rx_soc_fw_refill_ring_empty_tlv_v);
4812 		break;
4813 	case HTT_STATS_RX_SOC_FW_REFILL_RING_NUM_REFILL_TAG:
4814 		dest_ptr = &pdev->stats.htt_rx_pdev_stats.soc_stats.fw_refill_ring_num_refill_tlv;
4815 		size = sizeof(htt_rx_soc_fw_refill_ring_num_refill_tlv_v);
4816 		size_expected =
4817 		sizeof(struct cdp_htt_rx_soc_fw_refill_ring_num_refill_tlv_v);
4818 		break;
4819 	case HTT_STATS_RX_PDEV_FW_RING_MPDU_ERR_TAG:
4820 		dest_ptr = &pdev->stats.htt_rx_pdev_stats.fw_ring_mpdu_err_tlv;
4821 		size = sizeof(htt_rx_pdev_fw_ring_mpdu_err_tlv_v);
4822 		size_expected =
4823 			sizeof(struct cdp_htt_rx_pdev_fw_ring_mpdu_err_tlv_v);
4824 		break;
4825 	case HTT_STATS_RX_PDEV_FW_MPDU_DROP_TAG:
4826 		dest_ptr = &pdev->stats.htt_rx_pdev_stats.fw_ring_mpdu_drop;
4827 		size = sizeof(htt_rx_pdev_fw_mpdu_drop_tlv_v);
4828 		size_expected =
4829 			sizeof(struct cdp_htt_rx_pdev_fw_mpdu_drop_tlv_v);
4830 		break;
4831 	default:
4832 		break;
4833 	}
4834 
4835 	if (size_expected < size)
4836 		dp_warn("Buffer Overflow:FW Struct Size:%d Host Struct Size:%d"
4837 			, size, size_expected);
4838 
4839 	if (dest_ptr)
4840 		qdf_mem_copy(dest_ptr, tag_buf, size_expected);
4841 
4842 	if (((pdev->fw_stats_tlv_bitmap_rcvd) & DP_HTT_TX_RX_EXPECTED_TLVS)
4843 	      == DP_HTT_TX_RX_EXPECTED_TLVS) {
4844 		qdf_event_set(&pdev->fw_stats_event);
4845 	}
4846 }
4847 
4848 #ifdef VDEV_PEER_PROTOCOL_COUNT
4849 #ifdef VDEV_PEER_PROTOCOL_COUNT_TESTING
dp_peer_stats_update_protocol_test_cnt(struct dp_vdev * vdev,bool is_egress,bool is_rx)4850 static QDF_STATUS dp_peer_stats_update_protocol_test_cnt(struct dp_vdev *vdev,
4851 							 bool is_egress,
4852 							 bool is_rx)
4853 {
4854 	int mask;
4855 
4856 	if (is_egress)
4857 		if (is_rx)
4858 			mask = VDEV_PEER_PROTOCOL_RX_EGRESS_MASK;
4859 		else
4860 			mask = VDEV_PEER_PROTOCOL_TX_EGRESS_MASK;
4861 	else
4862 		if (is_rx)
4863 			mask = VDEV_PEER_PROTOCOL_RX_INGRESS_MASK;
4864 		else
4865 			mask = VDEV_PEER_PROTOCOL_TX_INGRESS_MASK;
4866 
4867 	if (qdf_unlikely(vdev->peer_protocol_count_dropmask & mask)) {
4868 		dp_info("drop mask set %x", vdev->peer_protocol_count_dropmask);
4869 		return QDF_STATUS_SUCCESS;
4870 	}
4871 	return QDF_STATUS_E_FAILURE;
4872 }
4873 
4874 #else
dp_peer_stats_update_protocol_test_cnt(struct dp_vdev * vdev,bool is_egress,bool is_rx)4875 static QDF_STATUS dp_peer_stats_update_protocol_test_cnt(struct dp_vdev *vdev,
4876 							 bool is_egress,
4877 							 bool is_rx)
4878 {
4879 	return QDF_STATUS_E_FAILURE;
4880 }
4881 #endif
4882 
dp_vdev_peer_stats_update_protocol_cnt(struct dp_vdev * vdev,qdf_nbuf_t nbuf,struct dp_txrx_peer * txrx_peer,bool is_egress,bool is_rx)4883 void dp_vdev_peer_stats_update_protocol_cnt(struct dp_vdev *vdev,
4884 					    qdf_nbuf_t nbuf,
4885 					    struct dp_txrx_peer *txrx_peer,
4886 					    bool is_egress,
4887 					    bool is_rx)
4888 {
4889 	struct dp_peer_per_pkt_stats *per_pkt_stats;
4890 	struct protocol_trace_count *protocol_trace_cnt;
4891 	enum cdp_protocol_trace prot;
4892 	struct dp_soc *soc;
4893 	struct ether_header *eh;
4894 	char *mac;
4895 	bool new_peer_ref = false;
4896 	struct dp_peer *peer = NULL;
4897 
4898 	if (qdf_likely(!vdev->peer_protocol_count_track))
4899 		return;
4900 	if (qdf_unlikely(dp_peer_stats_update_protocol_test_cnt(vdev,
4901 								is_egress,
4902 								is_rx) ==
4903 					       QDF_STATUS_SUCCESS))
4904 		return;
4905 
4906 	soc = vdev->pdev->soc;
4907 	eh = (struct ether_header *)qdf_nbuf_data(nbuf);
4908 	if (is_rx)
4909 		mac = eh->ether_shost;
4910 	else
4911 		mac = eh->ether_dhost;
4912 
4913 	if (!txrx_peer) {
4914 		peer = dp_peer_find_hash_find(soc, mac, 0, vdev->vdev_id,
4915 					      DP_MOD_ID_GENERIC_STATS);
4916 		new_peer_ref = true;
4917 		if (!peer)
4918 			return;
4919 
4920 		txrx_peer = peer->txrx_peer;
4921 		if (!txrx_peer)
4922 			goto dp_vdev_peer_stats_update_protocol_cnt_free_peer;
4923 	}
4924 	per_pkt_stats = &txrx_peer->stats[0].per_pkt_stats;
4925 
4926 	if (qdf_nbuf_is_icmp_pkt(nbuf) == true)
4927 		prot = CDP_TRACE_ICMP;
4928 	else if (qdf_nbuf_is_ipv4_arp_pkt(nbuf) == true)
4929 		prot = CDP_TRACE_ARP;
4930 	else if (qdf_nbuf_is_ipv4_eapol_pkt(nbuf) == true)
4931 		prot = CDP_TRACE_EAP;
4932 	else
4933 		goto dp_vdev_peer_stats_update_protocol_cnt_free_peer;
4934 
4935 	if (is_rx)
4936 		protocol_trace_cnt = per_pkt_stats->rx.protocol_trace_cnt;
4937 	else
4938 		protocol_trace_cnt = per_pkt_stats->tx.protocol_trace_cnt;
4939 
4940 	if (is_egress)
4941 		protocol_trace_cnt[prot].egress_cnt++;
4942 	else
4943 		protocol_trace_cnt[prot].ingress_cnt++;
4944 dp_vdev_peer_stats_update_protocol_cnt_free_peer:
4945 	if (new_peer_ref)
4946 		dp_peer_unref_delete(peer, DP_MOD_ID_GENERIC_STATS);
4947 }
4948 
dp_peer_stats_update_protocol_cnt(struct cdp_soc_t * soc_hdl,int8_t vdev_id,qdf_nbuf_t nbuf,bool is_egress,bool is_rx)4949 void dp_peer_stats_update_protocol_cnt(struct cdp_soc_t *soc_hdl,
4950 				       int8_t vdev_id,
4951 				       qdf_nbuf_t nbuf,
4952 				       bool is_egress,
4953 				       bool is_rx)
4954 {
4955 	struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
4956 	struct dp_vdev *vdev;
4957 
4958 	vdev = dp_vdev_get_ref_by_id(soc, vdev_id, DP_MOD_ID_GENERIC_STATS);
4959 	if (!vdev)
4960 		return;
4961 
4962 	if (qdf_likely(vdev->peer_protocol_count_track))
4963 		dp_vdev_peer_stats_update_protocol_cnt(vdev, nbuf, NULL,
4964 						       is_egress, is_rx);
4965 
4966 	dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_GENERIC_STATS);
4967 }
4968 #endif
4969 
4970 #if defined(QCA_ENH_V3_STATS_SUPPORT) || defined(HW_TX_DELAY_STATS_ENABLE)
4971 /**
4972  * dp_vow_str_fw_to_hw_delay() - Return string for a delay
4973  * @index: Index of delay
4974  *
4975  * Return: char const pointer
4976  */
dp_vow_str_fw_to_hw_delay(uint8_t index)4977 static inline const char *dp_vow_str_fw_to_hw_delay(uint8_t index)
4978 {
4979 	if (index > CDP_DELAY_BUCKET_MAX) {
4980 		return "Invalid index";
4981 	}
4982 	return fw_to_hw_delay_bucket[index];
4983 }
4984 
4985 #if defined(HW_TX_DELAY_STATS_ENABLE)
4986 /**
4987  * dp_str_fw_to_hw_delay_bkt() - Return string for concise logging of delay
4988  * @index: Index of delay
4989  *
4990  * Return: char const pointer
4991  */
dp_str_fw_to_hw_delay_bkt(uint8_t index)4992 static inline const char *dp_str_fw_to_hw_delay_bkt(uint8_t index)
4993 {
4994 	if (index > CDP_DELAY_BUCKET_MAX)
4995 		return "Invalid";
4996 
4997 	return fw_to_hw_delay_bkt_str[index];
4998 }
4999 #endif
5000 
5001 /**
5002  * dp_accumulate_delay_stats() - Update delay stats members
5003  * @total: Update stats total structure
5004  * @per_ring: per ring structures from where stats need to be accumulated
5005  *
5006  * Return: void
5007  */
5008 static void
dp_accumulate_delay_stats(struct cdp_delay_stats * total,struct cdp_delay_stats * per_ring)5009 dp_accumulate_delay_stats(struct cdp_delay_stats *total,
5010 			  struct cdp_delay_stats *per_ring)
5011 {
5012 	uint8_t index;
5013 
5014 	for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++)
5015 		total->delay_bucket[index] += per_ring->delay_bucket[index];
5016 	total->min_delay = QDF_MIN(total->min_delay, per_ring->min_delay);
5017 	total->max_delay = QDF_MAX(total->max_delay, per_ring->max_delay);
5018 	total->avg_delay = ((total->avg_delay + per_ring->avg_delay) >> 1);
5019 }
5020 #endif
5021 
5022 #ifdef QCA_ENH_V3_STATS_SUPPORT
5023 /**
5024  * dp_vow_str_sw_enq_delay() - Return string for a delay
5025  * @index: Index of delay
5026  *
5027  * Return: char const pointer
5028  */
dp_vow_str_sw_enq_delay(uint8_t index)5029 static inline const char *dp_vow_str_sw_enq_delay(uint8_t index)
5030 {
5031 	if (index > CDP_DELAY_BUCKET_MAX) {
5032 		return "Invalid index";
5033 	}
5034 	return sw_enq_delay_bucket[index];
5035 }
5036 
5037 /**
5038  * dp_vow_str_intfrm_delay() - Return string for a delay
5039  * @index: Index of delay
5040  *
5041  * Return: char const pointer
5042  */
dp_vow_str_intfrm_delay(uint8_t index)5043 static inline const char *dp_vow_str_intfrm_delay(uint8_t index)
5044 {
5045 	if (index > CDP_DELAY_BUCKET_MAX) {
5046 		return "Invalid index";
5047 	}
5048 	return intfrm_delay_bucket[index];
5049 }
5050 
5051 /**
5052  * dp_accumulate_tid_stats() - Accumulate TID stats from each ring
5053  * @pdev: pdev handle
5054  * @tid: traffic ID
5055  * @total_tx: fill this tx structure to get stats from all wbm rings
5056  * @total_rx: fill this rx structure to get stats from all reo rings
5057  * @type: delay stats or regular frame counters
5058  *
5059  * Return: void
5060  */
5061 static void
dp_accumulate_tid_stats(struct dp_pdev * pdev,uint8_t tid,struct cdp_tid_tx_stats * total_tx,struct cdp_tid_rx_stats * total_rx,uint8_t type)5062 dp_accumulate_tid_stats(struct dp_pdev *pdev, uint8_t tid,
5063 			struct cdp_tid_tx_stats *total_tx,
5064 			struct cdp_tid_rx_stats *total_rx, uint8_t type)
5065 {
5066 	uint8_t i = 0, ring_id = 0, drop = 0, tqm_status_idx = 0, htt_status_idx = 0;
5067 	struct cdp_tid_stats *tid_stats = &pdev->stats.tid_stats;
5068 	struct cdp_tid_tx_stats *per_ring_tx = NULL;
5069 	struct cdp_tid_rx_stats *per_ring_rx = NULL;
5070 
5071 	if (wlan_cfg_get_dp_soc_nss_cfg(pdev->soc->wlan_cfg_ctx)) {
5072 		qdf_mem_copy(total_tx, &tid_stats->tid_tx_stats[0][tid],
5073 			     sizeof(struct cdp_tid_tx_stats));
5074 		qdf_mem_copy(total_rx, &tid_stats->tid_rx_stats[0][tid],
5075 			     sizeof(struct cdp_tid_rx_stats));
5076 		return;
5077 	} else {
5078 		qdf_mem_zero(total_tx, sizeof(struct cdp_tid_tx_stats));
5079 		qdf_mem_zero(total_rx, sizeof(struct cdp_tid_rx_stats));
5080 	}
5081 
5082 	switch (type) {
5083 	case TID_COUNTER_STATS:
5084 	{
5085 		for (ring_id = 0; ring_id < CDP_MAX_TX_COMP_RINGS; ring_id++) {
5086 			per_ring_tx = &tid_stats->tid_tx_stats[ring_id][tid];
5087 			total_tx->success_cnt += per_ring_tx->success_cnt;
5088 			total_tx->comp_fail_cnt += per_ring_tx->comp_fail_cnt;
5089 			for (tqm_status_idx = 0; tqm_status_idx < CDP_MAX_TX_TQM_STATUS; tqm_status_idx++) {
5090 				total_tx->tqm_status_cnt[tqm_status_idx] +=
5091 					per_ring_tx->tqm_status_cnt[tqm_status_idx];
5092 			}
5093 
5094 			for (htt_status_idx = 0; htt_status_idx < CDP_MAX_TX_HTT_STATUS; htt_status_idx++) {
5095 				total_tx->htt_status_cnt[htt_status_idx] +=
5096 					per_ring_tx->htt_status_cnt[htt_status_idx];
5097 			}
5098 
5099 			for (drop = 0; drop < TX_MAX_DROP; drop++)
5100 				total_tx->swdrop_cnt[drop] +=
5101 					per_ring_tx->swdrop_cnt[drop];
5102 		}
5103 		for (ring_id = 0; ring_id < CDP_MAX_RX_RINGS; ring_id++) {
5104 			per_ring_rx = &tid_stats->tid_rx_stats[ring_id][tid];
5105 			total_rx->delivered_to_stack +=
5106 				per_ring_rx->delivered_to_stack;
5107 			total_rx->intrabss_cnt += per_ring_rx->intrabss_cnt;
5108 			total_rx->msdu_cnt += per_ring_rx->msdu_cnt;
5109 			total_rx->mcast_msdu_cnt += per_ring_rx->mcast_msdu_cnt;
5110 			total_rx->bcast_msdu_cnt += per_ring_rx->bcast_msdu_cnt;
5111 			for (drop = 0; drop < RX_MAX_DROP; drop++)
5112 				total_rx->fail_cnt[drop] +=
5113 					per_ring_rx->fail_cnt[drop];
5114 		}
5115 		break;
5116 	}
5117 
5118 	case TID_DELAY_STATS:
5119 	{
5120 		for (ring_id = 0; ring_id < CDP_MAX_TX_COMP_RINGS; ring_id++) {
5121 			per_ring_tx = &tid_stats->tid_tx_stats[ring_id][tid];
5122 			dp_accumulate_delay_stats(&total_tx->swq_delay,
5123 						  &per_ring_tx->swq_delay);
5124 			dp_accumulate_delay_stats(&total_tx->hwtx_delay,
5125 						  &per_ring_tx->hwtx_delay);
5126 			dp_accumulate_delay_stats(&total_tx->intfrm_delay,
5127 						  &per_ring_tx->intfrm_delay);
5128 		}
5129 		for (ring_id = 0; ring_id < CDP_MAX_RX_RINGS; ring_id++) {
5130 			per_ring_rx = &tid_stats->tid_rx_stats[ring_id][tid];
5131 			dp_accumulate_delay_stats(&total_rx->intfrm_delay,
5132 						  &per_ring_rx->intfrm_delay);
5133 			dp_accumulate_delay_stats(&total_rx->to_stack_delay,
5134 						  &per_ring_rx->to_stack_delay);
5135 		}
5136 		break;
5137 	}
5138 
5139 	case TID_RX_ERROR_STATS:
5140 	{
5141 		for (ring_id = 0; ring_id < CDP_MAX_RX_RINGS; ring_id++) {
5142 			per_ring_rx = &tid_stats->tid_rx_stats[ring_id][tid];
5143 			total_rx->reo_err.err_src_reo_code_inv += per_ring_rx->reo_err.err_src_reo_code_inv;
5144 			for (i = 0; i < CDP_REO_CODE_MAX; i++) {
5145 				total_rx->reo_err.err_reo_codes[i] += per_ring_rx->reo_err.err_reo_codes[i];
5146 			}
5147 
5148 			total_rx->rxdma_err.err_src_rxdma_code_inv += per_ring_rx->rxdma_err.err_src_rxdma_code_inv;
5149 			for (i = 0; i < CDP_DMA_CODE_MAX; i++) {
5150 				total_rx->rxdma_err.err_dma_codes[i] += per_ring_rx->rxdma_err.err_dma_codes[i];
5151 			}
5152 		}
5153 		break;
5154 	}
5155 	default:
5156 		qdf_err("Invalid stats type: %d", type);
5157 		break;
5158 	}
5159 }
5160 
dp_pdev_print_tid_stats(struct dp_pdev * pdev)5161 void dp_pdev_print_tid_stats(struct dp_pdev *pdev)
5162 {
5163 	struct cdp_tid_tx_stats total_tx;
5164 	struct cdp_tid_rx_stats total_rx;
5165 	uint8_t tid, tqm_status_idx, htt_status_idx;
5166 	struct cdp_tid_rx_stats *rx_wbm_stats = NULL;
5167 
5168 	DP_PRINT_STATS("Packets received in hardstart: %llu ",
5169 			pdev->stats.tid_stats.ingress_stack);
5170 	DP_PRINT_STATS("Packets dropped in osif layer: %llu ",
5171 			pdev->stats.tid_stats.osif_drop);
5172 	DP_PRINT_STATS("Per TID Video Stats:\n");
5173 
5174 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
5175 		rx_wbm_stats = &pdev->stats.tid_stats.tid_rx_wbm_stats[0][tid];
5176 
5177 		dp_accumulate_tid_stats(pdev, tid, &total_tx, &total_rx,
5178 					TID_COUNTER_STATS);
5179 		DP_PRINT_STATS("----TID: %d----", tid);
5180 		DP_PRINT_STATS("Tx TQM Success Count: %llu",
5181 				total_tx.tqm_status_cnt[HAL_TX_TQM_RR_FRAME_ACKED]);
5182 		DP_PRINT_STATS("Tx HTT Success Count: %llu",
5183 				total_tx.htt_status_cnt[HTT_TX_FW2WBM_TX_STATUS_OK]);
5184 		for (tqm_status_idx = 1; tqm_status_idx < CDP_MAX_TX_TQM_STATUS; tqm_status_idx++) {
5185 			if (total_tx.tqm_status_cnt[tqm_status_idx]) {
5186 				DP_PRINT_STATS("Tx TQM Drop Count[%d]: %llu",
5187 						tqm_status_idx, total_tx.tqm_status_cnt[tqm_status_idx]);
5188 			}
5189 		}
5190 
5191 		for (htt_status_idx = 1; htt_status_idx < CDP_MAX_TX_HTT_STATUS; htt_status_idx++) {
5192 			if (total_tx.htt_status_cnt[htt_status_idx]) {
5193 				DP_PRINT_STATS("Tx HTT Drop Count[%d]: %llu",
5194 						htt_status_idx, total_tx.htt_status_cnt[htt_status_idx]);
5195 			}
5196 		}
5197 
5198 		DP_PRINT_STATS("Tx Hardware Drop Count: %llu",
5199 			       total_tx.swdrop_cnt[TX_HW_ENQUEUE]);
5200 		DP_PRINT_STATS("Tx Software Drop Count: %llu",
5201 			       total_tx.swdrop_cnt[TX_SW_ENQUEUE]);
5202 		DP_PRINT_STATS("Tx Descriptor Error Count: %llu",
5203 			       total_tx.swdrop_cnt[TX_DESC_ERR]);
5204 		DP_PRINT_STATS("Tx HAL Ring Error Count: %llu",
5205 			       total_tx.swdrop_cnt[TX_HAL_RING_ACCESS_ERR]);
5206 		DP_PRINT_STATS("Tx Dma Map Error Count: %llu",
5207 			       total_tx.swdrop_cnt[TX_DMA_MAP_ERR]);
5208 		DP_PRINT_STATS("Rx Delievered Count: %llu",
5209 			       total_rx.delivered_to_stack);
5210 		DP_PRINT_STATS("Rx Software Enqueue Drop Count: %llu",
5211 			       total_rx.fail_cnt[ENQUEUE_DROP]);
5212 		DP_PRINT_STATS("Rx Intrabss Drop Count: %llu",
5213 			       total_rx.fail_cnt[INTRABSS_DROP]);
5214 		DP_PRINT_STATS("Rx Msdu Done Failure Count: %llu",
5215 			       total_rx.fail_cnt[MSDU_DONE_FAILURE]);
5216 		DP_PRINT_STATS("Rx Invalid Peer Count: %llu",
5217 			       total_rx.fail_cnt[INVALID_PEER_VDEV]);
5218 		DP_PRINT_STATS("Rx Policy Check Drop Count: %llu",
5219 			       total_rx.fail_cnt[POLICY_CHECK_DROP]);
5220 		DP_PRINT_STATS("Rx Mec Drop Count: %llu",
5221 			       total_rx.fail_cnt[MEC_DROP]);
5222 		DP_PRINT_STATS("Rx Nawds Mcast Drop Count: %llu",
5223 			       total_rx.fail_cnt[NAWDS_MCAST_DROP]);
5224 		DP_PRINT_STATS("Rx Mesh Filter Drop Count: %llu",
5225 			       total_rx.fail_cnt[MESH_FILTER_DROP]);
5226 		DP_PRINT_STATS("Rx Intra Bss Deliver Count: %llu",
5227 			       total_rx.intrabss_cnt);
5228 		DP_PRINT_STATS("Rx MSDU Count: %llu", total_rx.msdu_cnt);
5229 		DP_PRINT_STATS("Rx Multicast MSDU Count: %llu",
5230 			       total_rx.mcast_msdu_cnt);
5231 		DP_PRINT_STATS("Rx Broadcast MSDU Count: %llu\n",
5232 			       total_rx.bcast_msdu_cnt);
5233 		DP_PRINT_STATS("Rx WBM Intra Bss Deliver Count: %llu",
5234 			       rx_wbm_stats->intrabss_cnt);
5235 		DP_PRINT_STATS("Rx WBM Intrabss Drop Count: %llu",
5236 			       rx_wbm_stats->fail_cnt[INTRABSS_DROP]);
5237 	}
5238 }
5239 
dp_pdev_print_delay_stats(struct dp_pdev * pdev)5240 void dp_pdev_print_delay_stats(struct dp_pdev *pdev)
5241 {
5242 	struct dp_soc *soc = pdev->soc;
5243 	struct cdp_tid_tx_stats total_tx;
5244 	struct cdp_tid_rx_stats total_rx;
5245 
5246 	uint8_t tid, index;
5247 	uint64_t count = 0;
5248 
5249 	if (!soc)
5250 		return;
5251 
5252 	tid = 0;
5253 	index = 0;
5254 
5255 	DP_PRINT_STATS("Per TID Delay Non-Zero Stats:\n");
5256 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
5257 		dp_accumulate_tid_stats(pdev, tid, &total_tx, &total_rx,
5258 					TID_DELAY_STATS);
5259 		DP_PRINT_STATS("----TID: %d----", tid);
5260 
5261 		DP_PRINT_STATS("Software Enqueue Delay:");
5262 		for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++) {
5263 			count = total_tx.swq_delay.delay_bucket[index];
5264 			if (count) {
5265 				DP_PRINT_STATS("%s:  Packets = %llu",
5266 					       dp_vow_str_sw_enq_delay(index),
5267 					       count);
5268 			}
5269 		}
5270 
5271 		DP_PRINT_STATS("Min = %u", total_tx.swq_delay.min_delay);
5272 		DP_PRINT_STATS("Max = %u", total_tx.swq_delay.max_delay);
5273 		DP_PRINT_STATS("Avg = %u\n", total_tx.swq_delay.avg_delay);
5274 
5275 		DP_PRINT_STATS("Hardware Transmission Delay:");
5276 		for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++) {
5277 			count = total_tx.hwtx_delay.delay_bucket[index];
5278 			if (count) {
5279 				DP_PRINT_STATS("%s:  Packets = %llu",
5280 					       dp_vow_str_fw_to_hw_delay(index),
5281 					       count);
5282 			}
5283 		}
5284 		DP_PRINT_STATS("Min = %u", total_tx.hwtx_delay.min_delay);
5285 		DP_PRINT_STATS("Max = %u", total_tx.hwtx_delay.max_delay);
5286 		DP_PRINT_STATS("Avg = %u\n", total_tx.hwtx_delay.avg_delay);
5287 
5288 		DP_PRINT_STATS("Tx Interframe Delay:");
5289 		for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++) {
5290 			count = total_tx.intfrm_delay.delay_bucket[index];
5291 			if (count) {
5292 				DP_PRINT_STATS("%s:  Packets = %llu",
5293 					       dp_vow_str_intfrm_delay(index),
5294 					       count);
5295 			}
5296 		}
5297 		DP_PRINT_STATS("Min = %u", total_tx.intfrm_delay.min_delay);
5298 		DP_PRINT_STATS("Max = %u", total_tx.intfrm_delay.max_delay);
5299 		DP_PRINT_STATS("Avg = %u\n", total_tx.intfrm_delay.avg_delay);
5300 
5301 		DP_PRINT_STATS("Rx Interframe Delay:");
5302 		for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++) {
5303 			count = total_rx.intfrm_delay.delay_bucket[index];
5304 			if (count) {
5305 				DP_PRINT_STATS("%s:  Packets = %llu",
5306 					       dp_vow_str_intfrm_delay(index),
5307 					       count);
5308 			}
5309 		}
5310 		DP_PRINT_STATS("Min = %u", total_rx.intfrm_delay.min_delay);
5311 		DP_PRINT_STATS("Max = %u", total_rx.intfrm_delay.max_delay);
5312 		DP_PRINT_STATS("Avg = %u\n", total_rx.intfrm_delay.avg_delay);
5313 
5314 		DP_PRINT_STATS("Rx Reap to Stack Delay:");
5315 		for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++) {
5316 			count = total_rx.to_stack_delay.delay_bucket[index];
5317 			if (count) {
5318 				DP_PRINT_STATS("%s:  Packets = %llu",
5319 					       dp_vow_str_intfrm_delay(index),
5320 					       count);
5321 			}
5322 		}
5323 
5324 		DP_PRINT_STATS("Min = %u", total_rx.to_stack_delay.min_delay);
5325 		DP_PRINT_STATS("Max = %u", total_rx.to_stack_delay.max_delay);
5326 		DP_PRINT_STATS("Avg = %u\n", total_rx.to_stack_delay.avg_delay);
5327 	}
5328 }
5329 
dp_pdev_print_rx_error_stats(struct dp_pdev * pdev)5330 void dp_pdev_print_rx_error_stats(struct dp_pdev *pdev)
5331 {
5332 	struct dp_soc *soc = pdev->soc;
5333 	struct cdp_tid_rx_stats total_rx;
5334 	struct cdp_tid_tx_stats total_tx;
5335 
5336 	uint8_t tid, index;
5337 
5338 	if (!soc)
5339 		return;
5340 
5341 
5342 	DP_PRINT_STATS("Per TID RX Error Stats:\n");
5343 	for (tid = 0; tid < CDP_MAX_VOW_TID; tid++) {
5344 		dp_accumulate_tid_stats(pdev, tid, &total_tx, &total_rx,
5345 					TID_RX_ERROR_STATS);
5346 		DP_PRINT_STATS("----TID: %d----", tid + 4);
5347 
5348 		DP_PRINT_STATS("Rx REO Error stats:");
5349 		DP_PRINT_STATS("err_src_reo_code_inv = %llu", total_rx.reo_err.err_src_reo_code_inv);
5350 		for (index = 0; index < CDP_REO_CODE_MAX; index++) {
5351 			DP_PRINT_STATS("err src reo codes: %d = %llu", index, total_rx.reo_err.err_reo_codes[index]);
5352 		}
5353 
5354 		DP_PRINT_STATS("Rx Rxdma Error stats:");
5355 		DP_PRINT_STATS("err_src_rxdma_code_inv = %llu", total_rx.rxdma_err.err_src_rxdma_code_inv);
5356 		for (index = 0; index < CDP_DMA_CODE_MAX; index++) {
5357 			DP_PRINT_STATS("err src dma codes: %d = %llu", index, total_rx.rxdma_err.err_dma_codes[index]);
5358 		}
5359 	}
5360 }
5361 
dp_pdev_get_tid_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_tid_stats_intf * tid_stats)5362 QDF_STATUS dp_pdev_get_tid_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
5363 				 struct cdp_tid_stats_intf *tid_stats)
5364 {
5365 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
5366 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
5367 	struct cdp_tid_rx_stats rx;
5368 	struct cdp_tid_tx_stats tx;
5369 	uint8_t tid;
5370 	uint32_t size;
5371 
5372 	if (!pdev)
5373 		return QDF_STATUS_E_INVAL;
5374 
5375 	size = sizeof(struct cdp_delay_stats);
5376 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
5377 		dp_accumulate_tid_stats(pdev, tid, &tx, &rx, TID_COUNTER_STATS);
5378 		/* Copy specific accumulated Tx tid stats */
5379 		tid_stats->tx_total[tid].success_cnt = tx.success_cnt;
5380 		tid_stats->tx_total[tid].comp_fail_cnt = tx.comp_fail_cnt;
5381 		qdf_mem_copy(&tid_stats->tx_total[tid].tqm_status_cnt[0],
5382 			     &tx.tqm_status_cnt[0],
5383 			     CDP_MAX_TX_TQM_STATUS * sizeof(uint64_t));
5384 		qdf_mem_copy(&tid_stats->tx_total[tid].htt_status_cnt[0],
5385 			     &tx.htt_status_cnt[0],
5386 			     CDP_MAX_TX_HTT_STATUS * sizeof(uint64_t));
5387 		qdf_mem_copy(&tid_stats->tx_total[tid].swdrop_cnt[0],
5388 			     &tx.swdrop_cnt[0], TX_MAX_DROP * sizeof(uint64_t));
5389 
5390 		/* Copy specific accumulated Rx tid stats */
5391 		tid_stats->rx_total[tid].delivered_to_stack =
5392 							rx.delivered_to_stack;
5393 		tid_stats->rx_total[tid].intrabss_cnt = rx.intrabss_cnt;
5394 		tid_stats->rx_total[tid].msdu_cnt = rx.msdu_cnt;
5395 		tid_stats->rx_total[tid].mcast_msdu_cnt = rx.mcast_msdu_cnt;
5396 		tid_stats->rx_total[tid].bcast_msdu_cnt = rx.bcast_msdu_cnt;
5397 		qdf_mem_copy(&tid_stats->rx_total[tid].fail_cnt[0],
5398 			     &rx.fail_cnt[0], RX_MAX_DROP * sizeof(uint64_t));
5399 
5400 		dp_accumulate_tid_stats(pdev, tid, &tx, &rx, TID_DELAY_STATS);
5401 		/* Copy specific accumulated Tx delay stats */
5402 		qdf_mem_copy(&tid_stats->tx_total[tid].swq_delay,
5403 			     &tx.swq_delay, size);
5404 		qdf_mem_copy(&tid_stats->tx_total[tid].hwtx_delay,
5405 			     &tx.hwtx_delay, size);
5406 		qdf_mem_copy(&tid_stats->tx_total[tid].intfrm_delay,
5407 			     &tx.intfrm_delay, size);
5408 
5409 		/* Copy specific accumulated Rx delay stats */
5410 		qdf_mem_copy(&tid_stats->rx_total[tid].intfrm_delay,
5411 			     &rx.intfrm_delay, size);
5412 		qdf_mem_copy(&tid_stats->rx_total[tid].to_stack_delay,
5413 			     &rx.to_stack_delay, size);
5414 	}
5415 	for (tid = 0; tid < CDP_MAX_VOW_TID; tid++) {
5416 		dp_accumulate_tid_stats(pdev, tid, &tx, &rx,
5417 					TID_RX_ERROR_STATS);
5418 		/* Copy specific accumulated VOW Rx stats */
5419 		qdf_mem_copy(&tid_stats->rx_total[tid].reo_err,
5420 			     &rx.reo_err, sizeof(struct cdp_reo_error_stats));
5421 		qdf_mem_copy(&tid_stats->rx_total[tid].rxdma_err, &rx.rxdma_err,
5422 			     sizeof(struct cdp_rxdma_error_stats));
5423 	}
5424 	tid_stats->ingress_stack = pdev->stats.tid_stats.ingress_stack;
5425 	tid_stats->osif_drop = pdev->stats.tid_stats.osif_drop;
5426 
5427 	return QDF_STATUS_SUCCESS;
5428 }
5429 #else
dp_pdev_get_tid_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_tid_stats_intf * tid_stats)5430 QDF_STATUS dp_pdev_get_tid_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
5431 				 struct cdp_tid_stats_intf *tid_stats)
5432 {
5433 	return QDF_STATUS_E_INVAL;
5434 }
5435 #endif
5436 
5437 #ifdef HW_TX_DELAY_STATS_ENABLE
5438 #define DP_TX_DELAY_STATS_STR_LEN 512
5439 #define DP_SHORT_DELAY_BKT_COUNT 5
dp_vdev_print_tx_delay_stats(struct dp_vdev * vdev)5440 static void dp_vdev_print_tx_delay_stats(struct dp_vdev *vdev)
5441 {
5442 	struct cdp_delay_stats delay_stats;
5443 	struct cdp_tid_tx_stats *per_ring;
5444 	uint8_t tid, index;
5445 	uint32_t count = 0;
5446 	uint8_t ring_id;
5447 	char *buf;
5448 	size_t pos, buf_len;
5449 	char hw_tx_delay_str[DP_TX_DELAY_STATS_STR_LEN] = {"\0"};
5450 
5451 	buf_len = DP_TX_DELAY_STATS_STR_LEN;
5452 	if (!vdev)
5453 		return;
5454 
5455 	dp_info("vdev_id: %d Per TID HW Tx completion latency Stats:",
5456 		vdev->vdev_id);
5457 	buf = hw_tx_delay_str;
5458 	dp_info("  Tid%32sPkts_per_delay_bucket%60s | Min | Max | Avg |",
5459 		"", "");
5460 	pos = 0;
5461 	pos += qdf_scnprintf(buf + pos, buf_len - pos, "%6s", "");
5462 	for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++) {
5463 		if (index < DP_SHORT_DELAY_BKT_COUNT)
5464 			pos += qdf_scnprintf(buf + pos, buf_len - pos, "%7s",
5465 					     dp_str_fw_to_hw_delay_bkt(index));
5466 		else
5467 			pos += qdf_scnprintf(buf + pos, buf_len - pos, "%9s",
5468 					     dp_str_fw_to_hw_delay_bkt(index));
5469 	}
5470 	dp_info("%s", hw_tx_delay_str);
5471 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
5472 		qdf_mem_zero(&delay_stats, sizeof(delay_stats));
5473 		for (ring_id = 0; ring_id < CDP_MAX_TX_COMP_RINGS; ring_id++) {
5474 			per_ring = &vdev->stats.tid_tx_stats[ring_id][tid];
5475 			dp_accumulate_delay_stats(&delay_stats,
5476 						  &per_ring->hwtx_delay);
5477 		}
5478 		pos = 0;
5479 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "%4u  ", tid);
5480 		for (index = 0; index < CDP_DELAY_BUCKET_MAX; index++) {
5481 			count = delay_stats.delay_bucket[index];
5482 			if (index < DP_SHORT_DELAY_BKT_COUNT)
5483 				pos += qdf_scnprintf(buf + pos, buf_len - pos,
5484 						     "%6u|", count);
5485 			else
5486 				pos += qdf_scnprintf(buf + pos, buf_len - pos,
5487 						     "%8u|", count);
5488 		}
5489 		pos += qdf_scnprintf(buf + pos, buf_len - pos,
5490 			"%10u | %3u | %3u|", delay_stats.min_delay,
5491 			delay_stats.max_delay, delay_stats.avg_delay);
5492 		dp_info("%s", hw_tx_delay_str);
5493 	}
5494 }
5495 
dp_pdev_print_tx_delay_stats(struct dp_soc * soc)5496 void dp_pdev_print_tx_delay_stats(struct dp_soc *soc)
5497 {
5498 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, 0);
5499 	struct dp_vdev *vdev;
5500 	struct dp_vdev **vdev_array = NULL;
5501 	int index = 0, num_vdev = 0;
5502 
5503 	if (!pdev) {
5504 		dp_err("pdev is NULL");
5505 		return;
5506 	}
5507 
5508 	vdev_array =
5509 		qdf_mem_malloc(sizeof(struct dp_vdev *) * WLAN_PDEV_MAX_VDEVS);
5510 	if (!vdev_array)
5511 		return;
5512 
5513 	qdf_spin_lock_bh(&pdev->vdev_list_lock);
5514 	DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
5515 		if (dp_vdev_get_ref(soc, vdev, DP_MOD_ID_GENERIC_STATS))
5516 			continue;
5517 		vdev_array[index] = vdev;
5518 		index = index + 1;
5519 	}
5520 	qdf_spin_unlock_bh(&pdev->vdev_list_lock);
5521 
5522 	num_vdev = index;
5523 
5524 	for (index = 0; index < num_vdev; index++) {
5525 		vdev = vdev_array[index];
5526 		if (qdf_unlikely(dp_is_vdev_tx_delay_stats_enabled(vdev)))
5527 			dp_vdev_print_tx_delay_stats(vdev);
5528 		dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_GENERIC_STATS);
5529 	}
5530 	qdf_mem_free(vdev_array);
5531 }
5532 
5533 /**
5534  * dp_reset_delay_stats() - reset delay stats
5535  * @per_ring: per ring structures from where stats need to be accumulated
5536  *
5537  * Return: void
5538  */
dp_reset_delay_stats(struct cdp_delay_stats * per_ring)5539 static void dp_reset_delay_stats(struct cdp_delay_stats *per_ring)
5540 {
5541 	qdf_mem_zero(per_ring, sizeof(struct cdp_delay_stats));
5542 }
5543 
5544 /**
5545  * dp_vdev_init_tx_delay_stats() - Clear tx delay stats
5546  * @vdev: vdev handle
5547  *
5548  * Return: None
5549  */
dp_vdev_init_tx_delay_stats(struct dp_vdev * vdev)5550 static void dp_vdev_init_tx_delay_stats(struct dp_vdev *vdev)
5551 {
5552 	struct cdp_tid_tx_stats *per_ring;
5553 	uint8_t tid;
5554 	uint8_t ring_id;
5555 
5556 	if (!vdev)
5557 		return;
5558 
5559 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
5560 		for (ring_id = 0; ring_id < CDP_MAX_TX_COMP_RINGS; ring_id++) {
5561 			per_ring = &vdev->stats.tid_tx_stats[ring_id][tid];
5562 			dp_reset_delay_stats(&per_ring->hwtx_delay);
5563 		}
5564 	}
5565 }
5566 
dp_pdev_clear_tx_delay_stats(struct dp_soc * soc)5567 void dp_pdev_clear_tx_delay_stats(struct dp_soc *soc)
5568 {
5569 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, 0);
5570 	struct dp_vdev *vdev;
5571 	struct dp_vdev **vdev_array = NULL;
5572 	int index = 0, num_vdev = 0;
5573 
5574 	if (!pdev) {
5575 		dp_err("pdev is NULL");
5576 		return;
5577 	}
5578 
5579 	vdev_array =
5580 		qdf_mem_malloc(sizeof(struct dp_vdev *) * WLAN_PDEV_MAX_VDEVS);
5581 	if (!vdev_array)
5582 		return;
5583 
5584 	qdf_spin_lock_bh(&pdev->vdev_list_lock);
5585 	DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
5586 		if (dp_vdev_get_ref(soc, vdev, DP_MOD_ID_GENERIC_STATS) !=
5587 		    QDF_STATUS_SUCCESS)
5588 			continue;
5589 		vdev_array[index] = vdev;
5590 		index = index + 1;
5591 	}
5592 	qdf_spin_unlock_bh(&pdev->vdev_list_lock);
5593 
5594 	num_vdev = index;
5595 
5596 	for (index = 0; index < num_vdev; index++) {
5597 		vdev = vdev_array[index];
5598 		dp_vdev_init_tx_delay_stats(vdev);
5599 		dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_GENERIC_STATS);
5600 	}
5601 	qdf_mem_free(vdev_array);
5602 }
5603 #endif
5604 
dp_print_soc_cfg_params(struct dp_soc * soc)5605 void dp_print_soc_cfg_params(struct dp_soc *soc)
5606 {
5607 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
5608 	uint8_t index = 0, i = 0;
5609 	char ring_mask[DP_MAX_INT_CONTEXTS_STRING_LENGTH] = {'\0'};
5610 	int num_of_int_contexts;
5611 
5612 	if (!soc) {
5613 		dp_err("Context is null");
5614 		return;
5615 	}
5616 
5617 	soc_cfg_ctx = soc->wlan_cfg_ctx;
5618 
5619 	if (!soc_cfg_ctx) {
5620 		dp_err("Context is null");
5621 		return;
5622 	}
5623 
5624 	num_of_int_contexts =
5625 			wlan_cfg_get_num_contexts(soc_cfg_ctx);
5626 
5627 	DP_PRINT_STATS("No. of interrupt contexts: %u",
5628 		       soc_cfg_ctx->num_int_ctxts);
5629 	DP_PRINT_STATS("Max clients: %u",
5630 		       soc_cfg_ctx->max_clients);
5631 	DP_PRINT_STATS("Max alloc size: %u ",
5632 		       soc_cfg_ctx->max_alloc_size);
5633 	DP_PRINT_STATS("Per pdev tx ring: %u ",
5634 		       soc_cfg_ctx->per_pdev_tx_ring);
5635 	DP_PRINT_STATS("Num tcl data rings: %u ",
5636 		       soc_cfg_ctx->num_tcl_data_rings);
5637 	DP_PRINT_STATS("Per pdev rx ring: %u ",
5638 		       soc_cfg_ctx->per_pdev_rx_ring);
5639 	DP_PRINT_STATS("Per pdev lmac ring: %u ",
5640 		       soc_cfg_ctx->per_pdev_lmac_ring);
5641 	DP_PRINT_STATS("Num of reo dest rings: %u ",
5642 		       soc_cfg_ctx->num_reo_dest_rings);
5643 	DP_PRINT_STATS("Num tx desc pool: %u ",
5644 		       soc_cfg_ctx->num_tx_desc_pool);
5645 	DP_PRINT_STATS("Num tx ext desc pool: %u ",
5646 		       soc_cfg_ctx->num_tx_ext_desc_pool);
5647 	DP_PRINT_STATS("Num tx desc: %u ",
5648 		       soc_cfg_ctx->num_tx_desc);
5649 	DP_PRINT_STATS("Num tx ext desc: %u ",
5650 		       soc_cfg_ctx->num_tx_ext_desc);
5651 	DP_PRINT_STATS("Htt packet type: %u ",
5652 		       soc_cfg_ctx->htt_packet_type);
5653 	DP_PRINT_STATS("Max peer_ids: %u ",
5654 		       soc_cfg_ctx->max_peer_id);
5655 	DP_PRINT_STATS("Tx ring size: %u ",
5656 		       soc_cfg_ctx->tx_ring_size);
5657 	DP_PRINT_STATS("Tx comp ring size: %u ",
5658 		       soc_cfg_ctx->tx_comp_ring_size);
5659 	DP_PRINT_STATS("Tx comp ring size nss: %u ",
5660 		       soc_cfg_ctx->tx_comp_ring_size_nss);
5661 	DP_PRINT_STATS("Int batch threshold tx: %u ",
5662 		       soc_cfg_ctx->int_batch_threshold_tx);
5663 	DP_PRINT_STATS("Int timer threshold tx: %u ",
5664 		       soc_cfg_ctx->int_timer_threshold_tx);
5665 	DP_PRINT_STATS("Int batch threshold rx: %u ",
5666 		       soc_cfg_ctx->int_batch_threshold_rx);
5667 	DP_PRINT_STATS("Int timer threshold rx: %u ",
5668 		       soc_cfg_ctx->int_timer_threshold_rx);
5669 	DP_PRINT_STATS("Int batch threshold other: %u ",
5670 		       soc_cfg_ctx->int_batch_threshold_other);
5671 	DP_PRINT_STATS("Int timer threshold other: %u ",
5672 		       soc_cfg_ctx->int_timer_threshold_other);
5673 	DP_PRINT_STATS("Int batch threshold mon dest: %u ",
5674 		       soc_cfg_ctx->int_batch_threshold_mon_dest);
5675 	DP_PRINT_STATS("Int timer threshold mon dest: %u ",
5676 		       soc_cfg_ctx->int_timer_threshold_mon_dest);
5677 	DP_PRINT_STATS("Int batch threshold ppe2tcl: %u ",
5678 		       soc_cfg_ctx->int_batch_threshold_ppe2tcl);
5679 	DP_PRINT_STATS("Int timer threshold ppe2tcl: %u ",
5680 		       soc_cfg_ctx->int_timer_threshold_ppe2tcl);
5681 
5682 	DP_PRINT_STATS("DP NAPI scale factor: %u ",
5683 		       soc_cfg_ctx->napi_scale_factor);
5684 
5685 	for (i = 0; i < num_of_int_contexts; i++) {
5686 		index += qdf_snprint(&ring_mask[index],
5687 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5688 				     " %d",
5689 				     soc_cfg_ctx->int_tx_ring_mask[i]);
5690 	}
5691 
5692 	DP_PRINT_STATS("Tx ring mask (0-%d):%s",
5693 		       num_of_int_contexts, ring_mask);
5694 
5695 	index = 0;
5696 	for (i = 0; i < num_of_int_contexts; i++) {
5697 		index += qdf_snprint(&ring_mask[index],
5698 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5699 				     " %d",
5700 				     soc_cfg_ctx->int_rx_ring_mask[i]);
5701 	}
5702 
5703 	DP_PRINT_STATS("Rx ring mask (0-%d):%s",
5704 		       num_of_int_contexts, ring_mask);
5705 
5706 	index = 0;
5707 	for (i = 0; i < num_of_int_contexts; i++) {
5708 		index += qdf_snprint(&ring_mask[index],
5709 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5710 				     " %d",
5711 				     soc_cfg_ctx->int_rx_mon_ring_mask[i]);
5712 	}
5713 
5714 	DP_PRINT_STATS("Rx mon ring mask (0-%d):%s",
5715 		       num_of_int_contexts, ring_mask);
5716 
5717 	index = 0;
5718 	for (i = 0; i < num_of_int_contexts; i++) {
5719 		index += qdf_snprint(&ring_mask[index],
5720 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5721 				     " %d",
5722 				     soc_cfg_ctx->int_rx_err_ring_mask[i]);
5723 	}
5724 
5725 	DP_PRINT_STATS("Rx err ring mask (0-%d):%s",
5726 		       num_of_int_contexts, ring_mask);
5727 
5728 	index = 0;
5729 	for (i = 0; i < num_of_int_contexts; i++) {
5730 		index += qdf_snprint(&ring_mask[index],
5731 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5732 				     " %d",
5733 				     soc_cfg_ctx->int_rx_wbm_rel_ring_mask[i]);
5734 	}
5735 
5736 	DP_PRINT_STATS("Rx wbm rel ring mask (0-%d):%s",
5737 		       num_of_int_contexts, ring_mask);
5738 
5739 	index = 0;
5740 	for (i = 0; i < num_of_int_contexts; i++) {
5741 		index += qdf_snprint(&ring_mask[index],
5742 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5743 				     " %d",
5744 				     soc_cfg_ctx->int_reo_status_ring_mask[i]);
5745 	}
5746 
5747 	DP_PRINT_STATS("Reo ring mask (0-%d):%s",
5748 		       num_of_int_contexts, ring_mask);
5749 
5750 	index = 0;
5751 	for (i = 0; i < num_of_int_contexts; i++) {
5752 		index += qdf_snprint(&ring_mask[index],
5753 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5754 				     " %d",
5755 				     soc_cfg_ctx->int_rxdma2host_ring_mask[i]);
5756 	}
5757 
5758 	DP_PRINT_STATS("Rxdma2host ring mask (0-%d):%s",
5759 		       num_of_int_contexts, ring_mask);
5760 
5761 	index = 0;
5762 	for (i = 0; i < num_of_int_contexts; i++) {
5763 		index += qdf_snprint(&ring_mask[index],
5764 				     DP_MAX_INT_CONTEXTS_STRING_LENGTH - index,
5765 				     " %d",
5766 				     soc_cfg_ctx->int_host2rxdma_ring_mask[i]);
5767 	}
5768 
5769 	DP_PRINT_STATS("Host2rxdma ring mask (0-%d):%s",
5770 		       num_of_int_contexts, ring_mask);
5771 
5772 	DP_PRINT_STATS("Rx hash: %u ",
5773 		       soc_cfg_ctx->rx_hash);
5774 	DP_PRINT_STATS("Tso enabled: %u ",
5775 		       soc_cfg_ctx->tso_enabled);
5776 	DP_PRINT_STATS("Lro enabled: %u ",
5777 		       soc_cfg_ctx->lro_enabled);
5778 	DP_PRINT_STATS("Sg enabled: %u ",
5779 		       soc_cfg_ctx->sg_enabled);
5780 	DP_PRINT_STATS("Gro enabled: %u ",
5781 		       soc_cfg_ctx->gro_enabled);
5782 	DP_PRINT_STATS("TC based dynamic GRO: %u ",
5783 		       soc_cfg_ctx->tc_based_dynamic_gro);
5784 	DP_PRINT_STATS("TC ingress prio: %u ",
5785 		       soc_cfg_ctx->tc_ingress_prio);
5786 	DP_PRINT_STATS("rawmode enabled: %u ",
5787 		       soc_cfg_ctx->rawmode_enabled);
5788 	DP_PRINT_STATS("peer flow ctrl enabled: %u ",
5789 		       soc_cfg_ctx->peer_flow_ctrl_enabled);
5790 	DP_PRINT_STATS("napi enabled: %u ",
5791 		       soc_cfg_ctx->napi_enabled);
5792 	DP_PRINT_STATS("P2P Tcp Udp checksum offload: %u ",
5793 		       soc_cfg_ctx->p2p_tcp_udp_checksumoffload);
5794 	DP_PRINT_STATS("NAN Tcp Udp checksum offload: %u ",
5795 		       soc_cfg_ctx->nan_tcp_udp_checksumoffload);
5796 	DP_PRINT_STATS("Tcp Udp checksum offload: %u ",
5797 		       soc_cfg_ctx->tcp_udp_checksumoffload);
5798 	DP_PRINT_STATS("Defrag timeout check: %u ",
5799 		       soc_cfg_ctx->defrag_timeout_check);
5800 	DP_PRINT_STATS("Rx defrag min timeout: %u ",
5801 		       soc_cfg_ctx->rx_defrag_min_timeout);
5802 	DP_PRINT_STATS("WBM release ring: %u ",
5803 		       soc_cfg_ctx->wbm_release_ring);
5804 	DP_PRINT_STATS("TCL CMD_CREDIT ring: %u ",
5805 		       soc_cfg_ctx->tcl_cmd_credit_ring);
5806 	DP_PRINT_STATS("TCL Status ring: %u ",
5807 		       soc_cfg_ctx->tcl_status_ring);
5808 	DP_PRINT_STATS("REO Destination ring: %u ",
5809 		       soc_cfg_ctx->reo_dst_ring_size);
5810 	DP_PRINT_STATS("REO Reinject ring: %u ",
5811 		       soc_cfg_ctx->reo_reinject_ring);
5812 	DP_PRINT_STATS("RX release ring: %u ",
5813 		       soc_cfg_ctx->rx_release_ring);
5814 	DP_PRINT_STATS("REO Exception ring: %u ",
5815 		       soc_cfg_ctx->reo_exception_ring);
5816 	DP_PRINT_STATS("REO CMD ring: %u ",
5817 		       soc_cfg_ctx->reo_cmd_ring);
5818 	DP_PRINT_STATS("REO STATUS ring: %u ",
5819 		       soc_cfg_ctx->reo_status_ring);
5820 	DP_PRINT_STATS("RXDMA refill ring: %u ",
5821 		       soc_cfg_ctx->rxdma_refill_ring);
5822 	DP_PRINT_STATS("TX_desc limit_0: %u ",
5823 		       soc_cfg_ctx->tx_desc_limit_0);
5824 	DP_PRINT_STATS("TX_desc limit_1: %u ",
5825 		       soc_cfg_ctx->tx_desc_limit_1);
5826 	DP_PRINT_STATS("TX_desc limit_2: %u ",
5827 		       soc_cfg_ctx->tx_desc_limit_2);
5828 	DP_PRINT_STATS("TX device limit: %u ",
5829 		       soc_cfg_ctx->tx_device_limit);
5830 	DP_PRINT_STATS("TX sw internode queue: %u ",
5831 		       soc_cfg_ctx->tx_sw_internode_queue);
5832 	DP_PRINT_STATS("RXDMA err dst ring: %u ",
5833 		       soc_cfg_ctx->rxdma_err_dst_ring);
5834 	DP_PRINT_STATS("RX Flow Tag Enabled: %u ",
5835 		       soc_cfg_ctx->is_rx_flow_tag_enabled);
5836 	DP_PRINT_STATS("RX Flow Search Table Size (# of entries): %u ",
5837 		       soc_cfg_ctx->rx_flow_search_table_size);
5838 	DP_PRINT_STATS("RX Flow Search Table Per PDev : %u ",
5839 		       soc_cfg_ctx->is_rx_flow_search_table_per_pdev);
5840 	DP_PRINT_STATS("Rx desc pool size: %u ",
5841 		       soc_cfg_ctx->rx_sw_desc_num);
5842 }
5843 
5844 void
dp_print_pdev_cfg_params(struct dp_pdev * pdev)5845 dp_print_pdev_cfg_params(struct dp_pdev *pdev)
5846 {
5847 	struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
5848 
5849 	if (!pdev) {
5850 		dp_err("Context is null");
5851 		return;
5852 	}
5853 
5854 	pdev_cfg_ctx = pdev->wlan_cfg_ctx;
5855 
5856 	if (!pdev_cfg_ctx) {
5857 		dp_err("Context is null");
5858 		return;
5859 	}
5860 
5861 	DP_PRINT_STATS("Rx dma buf ring size: %d ",
5862 		       pdev_cfg_ctx->rx_dma_buf_ring_size);
5863 	DP_PRINT_STATS("DMA Mon buf ring size: %d ",
5864 		       pdev_cfg_ctx->dma_mon_buf_ring_size);
5865 	DP_PRINT_STATS("DMA Mon dest ring size: %d ",
5866 		       pdev_cfg_ctx->dma_rx_mon_dest_ring_size);
5867 	DP_PRINT_STATS("DMA Mon status ring size: %d ",
5868 		       pdev_cfg_ctx->dma_mon_status_ring_size);
5869 	DP_PRINT_STATS("Rxdma monitor desc ring: %d",
5870 		       pdev_cfg_ctx->rxdma_monitor_desc_ring);
5871 	DP_PRINT_STATS("Num mac rings: %d ",
5872 		       pdev_cfg_ctx->num_mac_rings);
5873 }
5874 
5875 void
dp_print_ring_stat_from_hal(struct dp_soc * soc,struct dp_srng * srng,enum hal_ring_type ring_type)5876 dp_print_ring_stat_from_hal(struct dp_soc *soc,  struct dp_srng *srng,
5877 			    enum hal_ring_type ring_type)
5878 {
5879 	uint32_t tailp;
5880 	uint32_t headp;
5881 	int32_t hw_headp = -1;
5882 	int32_t hw_tailp = -1;
5883 	uint32_t ring_usage;
5884 	const char *ring_name;
5885 
5886 	if (soc && srng && srng->hal_srng) {
5887 		ring_name = dp_srng_get_str_from_hal_ring_type(ring_type);
5888 		hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &tailp, &headp);
5889 		ring_usage = hal_get_ring_usage(srng->hal_srng,
5890 						ring_type, &headp, &tailp);
5891 
5892 		DP_PRINT_STATS("%s:SW: Head = %d Tail = %d Ring Usage = %u",
5893 			       ring_name, headp, tailp, ring_usage);
5894 
5895 		hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &hw_headp,
5896 				&hw_tailp, ring_type);
5897 		ring_usage = 0;
5898 		if (hw_headp >= 0 && tailp >= 0)
5899 			ring_usage =
5900 				hal_get_ring_usage(
5901 					srng->hal_srng, ring_type,
5902 					&hw_headp, &hw_tailp);
5903 		DP_PRINT_STATS("%s:HW: Head = %d Tail = %d Ring Usage = %u",
5904 			       ring_name, hw_headp, hw_tailp, ring_usage);
5905 	}
5906 }
5907 
5908 qdf_export_symbol(dp_print_ring_stat_from_hal);
5909 
5910 #ifdef FEATURE_TSO_STATS
5911 /**
5912  * dp_print_tso_seg_stats - tso segment stats
5913  * @pdev: pdev handle
5914  * @id: tso packet id
5915  *
5916  * Return: None
5917  */
dp_print_tso_seg_stats(struct dp_pdev * pdev,uint32_t id)5918 static void dp_print_tso_seg_stats(struct dp_pdev *pdev, uint32_t id)
5919 {
5920 	uint8_t num_seg;
5921 	uint32_t segid;
5922 
5923 	/* TSO LEVEL 2 - SEGMENT INFO */
5924 	num_seg = pdev->stats.tso_stats.tso_info.tso_packet_info[id].num_seg;
5925 	for (segid = 0; segid < CDP_MAX_TSO_SEGMENTS && segid < num_seg; segid++) {
5926 		DP_PRINT_STATS(
5927 			  "Segment id:[%u] fragments: %u | Segment Length %u | TCP Seq no.: %u | ip_id: %u",
5928 			  segid,
5929 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5930 			  .tso_seg[segid].num_frags,
5931 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5932 			  .tso_seg[segid].total_len,
5933 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5934 			  .tso_seg[segid].tso_flags.tcp_seq_num,
5935 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5936 			  .tso_seg[segid].tso_flags.ip_id);
5937 		DP_PRINT_STATS(
5938 			  "fin: %u syn: %u rst: %u psh: %u ack: %u urg: %u ece: %u cwr: %u ns: %u",
5939 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5940 			  .tso_seg[segid].tso_flags.fin,
5941 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5942 			  .tso_seg[segid].tso_flags.syn,
5943 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5944 			  .tso_seg[segid].tso_flags.rst,
5945 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5946 			  .tso_seg[segid].tso_flags.psh,
5947 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5948 			  .tso_seg[segid].tso_flags.ack,
5949 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5950 			  .tso_seg[segid].tso_flags.urg,
5951 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5952 			  .tso_seg[segid].tso_flags.ece,
5953 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5954 			  .tso_seg[segid].tso_flags.cwr,
5955 			  pdev->stats.tso_stats.tso_info.tso_packet_info[id]
5956 			  .tso_seg[segid].tso_flags.ns);
5957 	}
5958 }
5959 #else
5960 static inline
dp_print_tso_seg_stats(struct dp_pdev * pdev,uint32_t id)5961 void dp_print_tso_seg_stats(struct dp_pdev *pdev, uint32_t id)
5962 {
5963 }
5964 #endif /* FEATURE_TSO_STATS */
5965 
5966 /**
5967  * dp_print_mon_ring_stat_from_hal() - Print stat for monitor rings based
5968  *					on target
5969  * @pdev: physical device handle
5970  * @mac_id: mac id
5971  *
5972  * Return: void
5973  */
5974 static inline
dp_print_mon_ring_stat_from_hal(struct dp_pdev * pdev,uint8_t mac_id)5975 void dp_print_mon_ring_stat_from_hal(struct dp_pdev *pdev, uint8_t mac_id)
5976 {
5977 	if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
5978 		dp_print_ring_stat_from_hal(pdev->soc,
5979 			&pdev->soc->rxdma_mon_buf_ring[mac_id],
5980 			RXDMA_MONITOR_BUF);
5981 		dp_print_ring_stat_from_hal(pdev->soc,
5982 			&pdev->soc->rxdma_mon_dst_ring[mac_id],
5983 			RXDMA_MONITOR_DST);
5984 		dp_print_ring_stat_from_hal(pdev->soc,
5985 			&pdev->soc->rxdma_mon_desc_ring[mac_id],
5986 			RXDMA_MONITOR_DESC);
5987 	}
5988 
5989 	dp_print_ring_stat_from_hal(pdev->soc,
5990 				    &pdev->soc->rxdma_mon_status_ring[mac_id],
5991 					RXDMA_MONITOR_STATUS);
5992 }
5993 
5994 #if defined(IPA_OFFLOAD) && defined(QCA_WIFI_QCN9224)
5995 /**
5996  * dp_print_wbm2sw_ring_stats_from_hal() - Print ring stats from hal for ipa
5997  *                                         use case
5998  * @pdev : physical device handle
5999  *
6000  * Return: void
6001  */
6002 static inline void
dp_print_wbm2sw_ring_stats_from_hal(struct dp_pdev * pdev)6003 dp_print_wbm2sw_ring_stats_from_hal(struct dp_pdev *pdev)
6004 {
6005 	uint8_t i = 0;
6006 
6007 	for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
6008 		if (i != IPA_TX_COMP_RING_IDX)
6009 			dp_print_ring_stat_from_hal(pdev->soc,
6010 						    &pdev->soc->tx_comp_ring[i],
6011 						    WBM2SW_RELEASE);
6012 	}
6013 }
6014 #else
6015 static inline void
dp_print_wbm2sw_ring_stats_from_hal(struct dp_pdev * pdev)6016 dp_print_wbm2sw_ring_stats_from_hal(struct dp_pdev *pdev)
6017 {
6018 	uint8_t i = 0;
6019 
6020 	for (i = 0; i < pdev->soc->num_tcl_data_rings; i++)
6021 		dp_print_ring_stat_from_hal(pdev->soc,
6022 					    &pdev->soc->tx_comp_ring[i],
6023 					    WBM2SW_RELEASE);
6024 }
6025 #endif
6026 
6027 /*
6028  * Format is:
6029  * [0 18 1728, 1 15 1222, 2 24 1969,...]
6030  * 2 character space for [ and ]
6031  * 8 reo * 3 white space = 24
6032  * 8 char space for reo rings
6033  * 8 * 10 (uint32_t max value is 4294967295) = 80
6034  * 8 * 20 (uint64_t max value is 18446744073709551615) = 160
6035  * 8 commas
6036  * 1 for \0
6037  * Total of 283
6038  */
6039 #define DP_STATS_STR_LEN 283
6040 #ifndef WLAN_SOFTUMAC_SUPPORT
6041 static int
dp_fill_rx_interrupt_ctx_stats(struct dp_intr * intr_ctx,char * buf,int buf_len)6042 dp_fill_rx_interrupt_ctx_stats(struct dp_intr *intr_ctx,
6043 			       char *buf, int buf_len)
6044 {
6045 	int i;
6046 	int pos = 0;
6047 
6048 	if (buf_len <= 0 || !buf) {
6049 		dp_err("incorrect buf or buf_len(%d)!", buf_len);
6050 		return pos;
6051 	}
6052 
6053 	for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
6054 		if (intr_ctx->intr_stats.num_rx_ring_masks[i])
6055 			pos += qdf_scnprintf(buf + pos,
6056 					     buf_len - pos,
6057 					     "reo[%u]:%u ", i,
6058 					     intr_ctx->intr_stats.num_rx_ring_masks[i]);
6059 	}
6060 	return pos;
6061 }
6062 
6063 static int
dp_fill_tx_interrupt_ctx_stats(struct dp_intr * intr_ctx,char * buf,int buf_len)6064 dp_fill_tx_interrupt_ctx_stats(struct dp_intr *intr_ctx,
6065 			       char *buf, int buf_len)
6066 {	int i;
6067 	int pos = 0;
6068 
6069 	if (buf_len <= 0 || !buf) {
6070 		dp_err("incorrect buf or buf_len(%d)!", buf_len);
6071 		return pos;
6072 	}
6073 
6074 	for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
6075 		if (intr_ctx->intr_stats.num_tx_ring_masks[i])
6076 			pos += qdf_scnprintf(buf + pos,
6077 					     buf_len - pos,
6078 					     "tx_comps[%u]:%u ", i,
6079 					     intr_ctx->intr_stats.num_tx_ring_masks[i]);
6080 	}
6081 	return pos;
6082 }
6083 
dp_print_umac_ring_stats(struct dp_pdev * pdev)6084 static inline void dp_print_umac_ring_stats(struct dp_pdev *pdev)
6085 {
6086 	uint8_t i;
6087 
6088 	dp_print_ring_stat_from_hal(pdev->soc,
6089 				    &pdev->soc->wbm_idle_link_ring,
6090 				    WBM_IDLE_LINK);
6091 	dp_print_ring_stat_from_hal(pdev->soc,
6092 				    &pdev->soc->reo_exception_ring,
6093 				    REO_EXCEPTION);
6094 	dp_print_ring_stat_from_hal(pdev->soc,
6095 				    &pdev->soc->reo_reinject_ring,
6096 				    REO_REINJECT);
6097 	dp_print_ring_stat_from_hal(pdev->soc,
6098 				    &pdev->soc->reo_cmd_ring,
6099 				    REO_CMD);
6100 	dp_print_ring_stat_from_hal(pdev->soc,
6101 				    &pdev->soc->reo_status_ring,
6102 				    REO_STATUS);
6103 	dp_print_ring_stat_from_hal(pdev->soc,
6104 				    &pdev->soc->rx_rel_ring,
6105 				    WBM2SW_RELEASE);
6106 	dp_print_ring_stat_from_hal(pdev->soc,
6107 				    &pdev->soc->tcl_cmd_credit_ring,
6108 				    TCL_CMD_CREDIT);
6109 	dp_print_ring_stat_from_hal(pdev->soc,
6110 				    &pdev->soc->tcl_status_ring,
6111 				    TCL_STATUS);
6112 	dp_print_ring_stat_from_hal(pdev->soc,
6113 				    &pdev->soc->wbm_desc_rel_ring,
6114 				    SW2WBM_RELEASE);
6115 	for (i = 0; i < MAX_REO_DEST_RINGS; i++)
6116 		dp_print_ring_stat_from_hal(pdev->soc,
6117 					    &pdev->soc->reo_dest_ring[i],
6118 					    REO_DST);
6119 
6120 	for (i = 0; i < pdev->soc->num_tcl_data_rings; i++)
6121 		dp_print_ring_stat_from_hal(pdev->soc,
6122 					    &pdev->soc->tcl_data_ring[i],
6123 					    TCL_DATA);
6124 	dp_print_wbm2sw_ring_stats_from_hal(pdev);
6125 }
6126 
dp_print_ce_ring_stats(struct dp_pdev * pdev)6127 static inline void dp_print_ce_ring_stats(struct dp_pdev *pdev) {}
6128 
dp_print_tx_ring_stats(struct dp_soc * soc)6129 static inline void dp_print_tx_ring_stats(struct dp_soc *soc)
6130 {
6131 	uint8_t i;
6132 
6133 	for (i = 0; i < soc->num_tcl_data_rings; i++) {
6134 		DP_PRINT_STATS("Enqueue to SW2TCL%u: %u", i + 1,
6135 			       soc->stats.tx.tcl_enq[i]);
6136 		DP_PRINT_STATS("TX completions reaped from ring %u: %u",
6137 			       i, soc->stats.tx.tx_comp[i]);
6138 	}
6139 }
6140 
dp_print_rx_ring_stats(struct dp_pdev * pdev)6141 static inline void dp_print_rx_ring_stats(struct dp_pdev *pdev)
6142 {
6143 	uint8_t dp_stats_str[DP_STATS_STR_LEN] = {'\0'};
6144 	uint8_t *buf = dp_stats_str;
6145 	size_t pos = 0;
6146 	size_t buf_len = DP_STATS_STR_LEN;
6147 	uint8_t i;
6148 
6149 	pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "REO/msdus/bytes [");
6150 	for (i = 0; i < CDP_MAX_RX_RINGS; i++) {
6151 		if (!pdev->stats.rx.rcvd_reo[i].num)
6152 			continue;
6153 
6154 		pos += qdf_scnprintf(buf + pos, buf_len - pos,
6155 				     "%d %llu %llu, ",
6156 				     i, pdev->stats.rx.rcvd_reo[i].num,
6157 				     pdev->stats.rx.rcvd_reo[i].bytes);
6158 	}
6159 	pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "]");
6160 	DP_PRINT_STATS("%s", dp_stats_str);
6161 }
6162 
6163 static inline void
dp_print_rx_err_stats(struct dp_soc * soc,struct dp_pdev * pdev)6164 dp_print_rx_err_stats(struct dp_soc *soc, struct dp_pdev *pdev)
6165 {
6166 	uint8_t error_code;
6167 
6168 	DP_PRINT_STATS("intra-bss EAPOL drops: %u",
6169 		       soc->stats.rx.err.intrabss_eapol_drop);
6170 	DP_PRINT_STATS("mic errors %u",
6171 		       pdev->stats.rx.err.mic_err);
6172 	DP_PRINT_STATS("Invalid peer on rx path: %llu",
6173 		       pdev->soc->stats.rx.err.rx_invalid_peer.num);
6174 	DP_PRINT_STATS("sw_peer_id invalid %llu",
6175 		       pdev->soc->stats.rx.err.rx_invalid_peer_id.num);
6176 	DP_PRINT_STATS("packet_len invalid %llu",
6177 		       pdev->soc->stats.rx.err.rx_invalid_pkt_len.num);
6178 	DP_PRINT_STATS("sa or da idx invalid %u",
6179 		       pdev->soc->stats.rx.err.invalid_sa_da_idx);
6180 	DP_PRINT_STATS("defrag peer uninit %u",
6181 		       pdev->soc->stats.rx.err.defrag_peer_uninit);
6182 	DP_PRINT_STATS("pkts delivered no peer %u",
6183 		       pdev->soc->stats.rx.err.pkt_delivered_no_peer);
6184 	DP_PRINT_STATS("RX invalid cookie: %d",
6185 		       soc->stats.rx.err.invalid_cookie);
6186 	DP_PRINT_STATS("RX stale cookie: %d",
6187 		       soc->stats.rx.err.stale_cookie);
6188 	DP_PRINT_STATS("2k jump delba sent: %u",
6189 		       pdev->soc->stats.rx.err.rx_2k_jump_delba_sent);
6190 	DP_PRINT_STATS("2k jump msdu to stack: %u",
6191 		       pdev->soc->stats.rx.err.rx_2k_jump_to_stack);
6192 	DP_PRINT_STATS("2k jump msdu drop: %u",
6193 		       pdev->soc->stats.rx.err.rx_2k_jump_drop);
6194 	DP_PRINT_STATS("REO err oor msdu to stack %u",
6195 		       pdev->soc->stats.rx.err.reo_err_oor_to_stack);
6196 	DP_PRINT_STATS("REO err oor msdu drop: %u",
6197 		       pdev->soc->stats.rx.err.reo_err_oor_drop);
6198 	DP_PRINT_STATS("Rx err msdu rejected: %d",
6199 		       soc->stats.rx.err.rejected);
6200 	DP_PRINT_STATS("Rx raw frame dropped: %d",
6201 		       soc->stats.rx.err.raw_frm_drop);
6202 	DP_PRINT_STATS("Rx stale link desc cookie: %d",
6203 		       pdev->soc->stats.rx.err.invalid_link_cookie);
6204 	DP_PRINT_STATS("Rx nbuf sanity fails: %d",
6205 		       pdev->soc->stats.rx.err.nbuf_sanity_fail);
6206 	DP_PRINT_STATS("Rx refill duplicate link desc: %d",
6207 		       pdev->soc->stats.rx.err.dup_refill_link_desc);
6208 	DP_PRINT_STATS("Rx ipa smmu map duplicate: %d",
6209 		       pdev->soc->stats.rx.err.ipa_smmu_map_dup);
6210 	DP_PRINT_STATS("Rx ipa smmu unmap duplicate: %d",
6211 		       pdev->soc->stats.rx.err.ipa_smmu_unmap_dup);
6212 	DP_PRINT_STATS("Rx ipa smmu unmap no pipes: %d",
6213 		       pdev->soc->stats.rx.err.ipa_unmap_no_pipe);
6214 	DP_PRINT_STATS("PN-in-Dest error frame pn-check fail: %d",
6215 		       soc->stats.rx.err.pn_in_dest_check_fail);
6216 
6217 	DP_PRINT_STATS("Reo Statistics");
6218 	DP_PRINT_STATS("near_full: %u ", soc->stats.rx.near_full);
6219 	DP_PRINT_STATS("rbm error: %u msdus",
6220 		       pdev->soc->stats.rx.err.invalid_rbm);
6221 	DP_PRINT_STATS("hal ring access fail: %u msdus",
6222 		       pdev->soc->stats.rx.err.hal_ring_access_fail);
6223 
6224 	DP_PRINT_STATS("hal ring access full fail: %u msdus",
6225 		       pdev->soc->stats.rx.err.hal_ring_access_full_fail);
6226 
6227 	for (error_code = 0; error_code < HAL_REO_ERR_MAX;
6228 	     error_code++) {
6229 		if (!pdev->soc->stats.rx.err.reo_error[error_code])
6230 			continue;
6231 		DP_PRINT_STATS("Reo error number (%u): %u msdus",
6232 			       error_code,
6233 			       pdev->soc->stats.rx.err.reo_error[error_code]);
6234 	}
6235 }
6236 
dp_print_soc_tx_stats(struct dp_soc * soc)6237 void dp_print_soc_tx_stats(struct dp_soc *soc)
6238 {
6239 	uint8_t desc_pool_id;
6240 	struct dp_tx_desc_pool_s *tx_desc_pool;
6241 
6242 	soc->stats.tx.desc_in_use = 0;
6243 
6244 	DP_PRINT_STATS("SOC Tx Stats:\n");
6245 
6246 	for (desc_pool_id = 0;
6247 	     desc_pool_id < wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
6248 	     desc_pool_id++) {
6249 		tx_desc_pool = dp_get_tx_desc_pool(soc, desc_pool_id);
6250 		soc->stats.tx.desc_in_use +=
6251 			tx_desc_pool->num_allocated;
6252 		tx_desc_pool = dp_get_spcl_tx_desc_pool(soc, desc_pool_id);
6253 		soc->stats.tx.desc_in_use +=
6254 			tx_desc_pool->num_allocated;
6255 	}
6256 
6257 	DP_PRINT_STATS("Tx Descriptors In Use = %u",
6258 		       soc->stats.tx.desc_in_use);
6259 	DP_PRINT_STATS("Tx Invalid peer:");
6260 	DP_PRINT_STATS("	Packets = %llu",
6261 		       soc->stats.tx.tx_invalid_peer.num);
6262 	DP_PRINT_STATS("	Bytes = %llu",
6263 		       soc->stats.tx.tx_invalid_peer.bytes);
6264 	DP_PRINT_STATS("Packets dropped due to TCL ring full = %u %u %u %u",
6265 		       soc->stats.tx.tcl_ring_full[0],
6266 		       soc->stats.tx.tcl_ring_full[1],
6267 		       soc->stats.tx.tcl_ring_full[2],
6268 		       soc->stats.tx.tcl_ring_full[3]);
6269 	DP_PRINT_STATS("Tx invalid completion release = %u",
6270 		       soc->stats.tx.invalid_release_source);
6271 	DP_PRINT_STATS("TX invalid Desc from completion ring = %u",
6272 		       soc->stats.tx.invalid_tx_comp_desc);
6273 	DP_PRINT_STATS("Tx comp wbm internal error = %d : [%d %d %d %d]",
6274 		       soc->stats.tx.wbm_internal_error[WBM_INT_ERROR_ALL],
6275 		       soc->stats.tx.wbm_internal_error[WBM_INT_ERROR_REO_NULL_BUFFER],
6276 		       soc->stats.tx.wbm_internal_error[WBM_INT_ERROR_REO_NULL_LINK_DESC],
6277 		       soc->stats.tx.wbm_internal_error[WBM_INT_ERROR_REO_NULL_MSDU_BUFF],
6278 		       soc->stats.tx.wbm_internal_error[WBM_INT_ERROR_REO_BUFF_REAPED]);
6279 	DP_PRINT_STATS("Tx comp non wbm internal error = %d",
6280 		       soc->stats.tx.non_wbm_internal_err);
6281 	DP_PRINT_STATS("Tx comp loop pkt limit hit = %d",
6282 		       soc->stats.tx.tx_comp_loop_pkt_limit_hit);
6283 	DP_PRINT_STATS("Tx comp HP out of sync2 = %d",
6284 		       soc->stats.tx.hp_oos2);
6285 	dp_print_tx_ppeds_stats(soc);
6286 }
6287 
6288 #define DP_INT_CTX_STATS_STRING_LEN 512
dp_print_soc_interrupt_stats(struct dp_soc * soc)6289 void dp_print_soc_interrupt_stats(struct dp_soc *soc)
6290 {
6291 	char *buf;
6292 	char int_ctx_str[DP_INT_CTX_STATS_STRING_LEN] = {'\0'};
6293 	int i, pos, buf_len;
6294 	struct dp_intr_stats *intr_stats;
6295 
6296 	buf = int_ctx_str;
6297 	buf_len = DP_INT_CTX_STATS_STRING_LEN;
6298 
6299 	for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
6300 		pos = 0;
6301 		qdf_mem_zero(int_ctx_str, sizeof(int_ctx_str));
6302 		intr_stats = &soc->intr_ctx[i].intr_stats;
6303 
6304 		if (!intr_stats->num_masks && !intr_stats->num_near_full_masks)
6305 			continue;
6306 
6307 		pos += qdf_scnprintf(buf + pos,
6308 				     buf_len - pos,
6309 				     "%2u[%3d] - Total:%u ",
6310 				     i,
6311 				     hif_get_int_ctx_irq_num(soc->hif_handle,
6312 							     i),
6313 				     intr_stats->num_masks);
6314 
6315 		if (soc->intr_ctx[i].tx_ring_mask)
6316 			pos += dp_fill_tx_interrupt_ctx_stats(&soc->intr_ctx[i],
6317 							      buf + pos,
6318 							      buf_len - pos);
6319 
6320 		if (soc->intr_ctx[i].rx_ring_mask)
6321 			pos += dp_fill_rx_interrupt_ctx_stats(&soc->intr_ctx[i],
6322 							      buf + pos,
6323 							      buf_len - pos);
6324 		if (soc->intr_ctx[i].rx_err_ring_mask)
6325 			pos += qdf_scnprintf(buf + pos,
6326 					     buf_len - pos,
6327 					     "reo_err:%u ",
6328 					     intr_stats->num_rx_err_ring_masks);
6329 
6330 		if (soc->intr_ctx[i].rx_wbm_rel_ring_mask)
6331 			pos += qdf_scnprintf(buf + pos,
6332 					     buf_len - pos,
6333 					     "wbm_rx_err:%u ",
6334 					     intr_stats->num_rx_wbm_rel_ring_masks);
6335 
6336 		if (soc->intr_ctx[i].rxdma2host_ring_mask)
6337 			pos += qdf_scnprintf(buf + pos,
6338 					     buf_len - pos,
6339 					     "rxdma2_host_err:%u ",
6340 					     intr_stats->num_rxdma2host_ring_masks);
6341 
6342 		if (soc->intr_ctx[i].rx_near_full_grp_1_mask)
6343 			pos += qdf_scnprintf(buf + pos,
6344 					     buf_len - pos,
6345 					     "rx_near_full_grp_1:%u ",
6346 					     intr_stats->num_near_full_masks);
6347 
6348 		if (soc->intr_ctx[i].rx_near_full_grp_2_mask)
6349 			pos += qdf_scnprintf(buf + pos,
6350 					     buf_len - pos,
6351 					     "rx_near_full_grp_2:%u ",
6352 					     intr_stats->num_near_full_masks);
6353 		if (soc->intr_ctx[i].tx_ring_near_full_mask)
6354 			pos += qdf_scnprintf(buf + pos,
6355 					     buf_len - pos,
6356 					     "tx_near_full:%u ",
6357 					     intr_stats->num_near_full_masks);
6358 
6359 		dp_info("%s", int_ctx_str);
6360 	}
6361 }
6362 #else
dp_print_umac_ring_stats(struct dp_pdev * pdev)6363 static inline void dp_print_umac_ring_stats(struct dp_pdev *pdev) {}
6364 
dp_print_ce_ring_stats(struct dp_pdev * pdev)6365 static inline void dp_print_ce_ring_stats(struct dp_pdev *pdev)
6366 {
6367 	hif_ce_print_ring_stats(pdev->soc->hif_handle);
6368 }
6369 
dp_print_tx_ring_stats(struct dp_soc * soc)6370 static inline void dp_print_tx_ring_stats(struct dp_soc *soc)
6371 {
6372 	uint8_t i;
6373 
6374 	for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
6375 		DP_PRINT_STATS("Enqueue to Tx ring %u: %u", i + 1,
6376 			       soc->stats.tx.tcl_enq[i]);
6377 		DP_PRINT_STATS("TX completions reaped from ring %u: %u",
6378 			       i, soc->stats.tx.tx_comp[i]);
6379 	}
6380 }
6381 
dp_print_rx_ring_stats(struct dp_pdev * pdev)6382 static inline void dp_print_rx_ring_stats(struct dp_pdev *pdev)
6383 {
6384 	uint8_t dp_stats_str[DP_STATS_STR_LEN] = {'\0'};
6385 	uint8_t *buf = dp_stats_str;
6386 	size_t pos = 0;
6387 	size_t buf_len = DP_STATS_STR_LEN;
6388 	uint8_t i;
6389 
6390 	pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "RX/msdus/bytes [");
6391 	for (i = 0; i < CDP_MAX_RX_RINGS; i++) {
6392 		if (!pdev->stats.rx.rcvd_reo[i].num)
6393 			continue;
6394 
6395 		pos += qdf_scnprintf(buf + pos, buf_len - pos,
6396 				     "%d %llu %llu, ",
6397 				     i, pdev->stats.rx.rcvd_reo[i].num,
6398 				     pdev->stats.rx.rcvd_reo[i].bytes);
6399 	}
6400 	pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "]");
6401 	DP_PRINT_STATS("%s", dp_stats_str);
6402 }
6403 
6404 static inline void
dp_print_rx_err_stats(struct dp_soc * soc,struct dp_pdev * pdev)6405 dp_print_rx_err_stats(struct dp_soc *soc, struct dp_pdev *pdev)
6406 {
6407 	DP_PRINT_STATS("intra-bss EAPOL drops: %u",
6408 		       soc->stats.rx.err.intrabss_eapol_drop);
6409 	DP_PRINT_STATS("mic errors %u",
6410 		       pdev->stats.rx.err.mic_err);
6411 	DP_PRINT_STATS("2k jump msdu drop: %u",
6412 		       pdev->soc->stats.rx.err.rx_2k_jump_drop);
6413 	DP_PRINT_STATS("REO err oor msdu drop: %u",
6414 		       pdev->soc->stats.rx.err.reo_err_oor_drop);
6415 	DP_PRINT_STATS("Invalid peer on rx path: %llu",
6416 		       pdev->soc->stats.rx.err.rx_invalid_peer.num);
6417 	DP_PRINT_STATS("sw_peer_id invalid %llu",
6418 		       pdev->soc->stats.rx.err.rx_invalid_peer_id.num);
6419 	DP_PRINT_STATS("packet_len invalid %llu",
6420 		       pdev->soc->stats.rx.err.rx_invalid_pkt_len.num);
6421 	DP_PRINT_STATS("sa or da idx invalid %u",
6422 		       pdev->soc->stats.rx.err.invalid_sa_da_idx);
6423 	DP_PRINT_STATS("defrag peer uninit %u",
6424 		       pdev->soc->stats.rx.err.defrag_peer_uninit);
6425 	DP_PRINT_STATS("pkts delivered no peer %u",
6426 		       pdev->soc->stats.rx.err.pkt_delivered_no_peer);
6427 	DP_PRINT_STATS("RX invalid cookie: %d",
6428 		       soc->stats.rx.err.invalid_cookie);
6429 	DP_PRINT_STATS("RX stale cookie: %d",
6430 		       soc->stats.rx.err.stale_cookie);
6431 	DP_PRINT_STATS("Rx err msdu rejected: %d",
6432 		       soc->stats.rx.err.rejected);
6433 	DP_PRINT_STATS("Rx raw frame dropped: %d",
6434 		       soc->stats.rx.err.raw_frm_drop);
6435 	DP_PRINT_STATS("Rx nbuf sanity fails: %d",
6436 		       pdev->soc->stats.rx.err.nbuf_sanity_fail);
6437 	DP_PRINT_STATS("PN-in-Dest error frame pn-check fail: %d",
6438 		       soc->stats.rx.err.pn_in_dest_check_fail);
6439 }
6440 
dp_print_soc_tx_stats(struct dp_soc * soc)6441 void dp_print_soc_tx_stats(struct dp_soc *soc)
6442 {
6443 	uint8_t desc_pool_id;
6444 
6445 	soc->stats.tx.desc_in_use = 0;
6446 
6447 	DP_PRINT_STATS("SOC Tx Stats:\n");
6448 
6449 	for (desc_pool_id = 0;
6450 	     desc_pool_id < wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
6451 	     desc_pool_id++)
6452 		soc->stats.tx.desc_in_use +=
6453 			soc->tx_desc[desc_pool_id].num_allocated;
6454 
6455 	DP_PRINT_STATS("Tx Descriptors In Use = %u",
6456 		       soc->stats.tx.desc_in_use);
6457 	DP_PRINT_STATS("Tx Invalid peer:");
6458 	DP_PRINT_STATS("	Packets = %llu",
6459 		       soc->stats.tx.tx_invalid_peer.num);
6460 	DP_PRINT_STATS("	Bytes = %llu",
6461 		       soc->stats.tx.tx_invalid_peer.bytes);
6462 	DP_PRINT_STATS("Packets dropped due to Tx ring full = %u",
6463 		       soc->stats.tx.tcl_ring_full[0]);
6464 	DP_PRINT_STATS("Tx invalid completion release = %u",
6465 		       soc->stats.tx.invalid_release_source);
6466 	DP_PRINT_STATS("TX invalid Desc from completion ring = %u",
6467 		       soc->stats.tx.invalid_tx_comp_desc);
6468 	dp_print_tx_ppeds_stats(soc);
6469 }
6470 
6471 /* TODO: print CE intr stats? */
dp_print_soc_interrupt_stats(struct dp_soc * soc)6472 void dp_print_soc_interrupt_stats(struct dp_soc *soc) {}
6473 #endif
6474 
6475 void
dp_print_ring_stats(struct dp_pdev * pdev)6476 dp_print_ring_stats(struct dp_pdev *pdev)
6477 {
6478 	struct dp_soc *soc = pdev->soc;
6479 	uint32_t i;
6480 	int mac_id;
6481 	int lmac_id;
6482 
6483 	if (hif_rtpm_get(HIF_RTPM_GET_SYNC, HIF_RTPM_ID_DP_RING_STATS))
6484 		return;
6485 
6486 	dp_print_ce_ring_stats(pdev);
6487 	dp_print_umac_ring_stats(pdev);
6488 
6489 	if (pdev->soc->features.dmac_cmn_src_rxbuf_ring_enabled) {
6490 		for (i = 0; i < pdev->soc->num_rx_refill_buf_rings; i++) {
6491 			dp_print_ring_stat_from_hal
6492 				(pdev->soc, &pdev->soc->rx_refill_buf_ring[i],
6493 				 RXDMA_BUF);
6494 		}
6495 	} else {
6496 		lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0,
6497 						     pdev->pdev_id);
6498 		dp_print_ring_stat_from_hal
6499 			(pdev->soc, &pdev->soc->rx_refill_buf_ring[lmac_id],
6500 			 RXDMA_BUF);
6501 	}
6502 
6503 	dp_print_ring_stat_from_hal(pdev->soc,
6504 				    &pdev->rx_refill_buf_ring2,
6505 				    RXDMA_BUF);
6506 
6507 	for (i = 0; i < MAX_RX_MAC_RINGS; i++)
6508 		dp_print_ring_stat_from_hal(pdev->soc,
6509 					    &pdev->rx_mac_buf_ring[i],
6510 					    RXDMA_BUF);
6511 
6512 	for (mac_id = 0;
6513 	     mac_id  < soc->wlan_cfg_ctx->num_rxdma_status_rings_per_pdev;
6514 	     mac_id++) {
6515 		lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
6516 						     mac_id, pdev->pdev_id);
6517 
6518 		dp_print_mon_ring_stat_from_hal(pdev, lmac_id);
6519 	}
6520 
6521 	for (i = 0; i < soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev; i++) {
6522 		lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
6523 						     i, pdev->pdev_id);
6524 
6525 		dp_print_ring_stat_from_hal(pdev->soc,
6526 					    &pdev->soc->rxdma_err_dst_ring
6527 					    [lmac_id],
6528 					    RXDMA_DST);
6529 	}
6530 
6531 	dp_print_txmon_ring_stat_from_hal(pdev);
6532 
6533 #ifdef WLAN_SUPPORT_PPEDS
6534 	if (pdev->soc->arch_ops.dp_txrx_ppeds_rings_status)
6535 		pdev->soc->arch_ops.dp_txrx_ppeds_rings_status(pdev->soc);
6536 #endif
6537 	hif_rtpm_put(HIF_RTPM_PUT_ASYNC, HIF_RTPM_ID_DP_RING_STATS);
6538 }
6539 
6540 /**
6541  * dp_print_common_rates_info(): Print common rate for tx or rx
6542  * @pkt_type_array: rate type array contains rate info
6543  *
6544  * Return: void
6545  */
6546 static inline void
dp_print_common_rates_info(struct cdp_pkt_type * pkt_type_array)6547 dp_print_common_rates_info(struct cdp_pkt_type *pkt_type_array)
6548 {
6549 	uint8_t mcs, pkt_type;
6550 
6551 	DP_PRINT_STATS("MSDU Count");
6552 	for (pkt_type = 0; pkt_type < DOT11_MAX; pkt_type++) {
6553 		for (mcs = 0; mcs < MAX_MCS; mcs++) {
6554 			if (!cdp_rate_string[pkt_type][mcs].valid)
6555 				continue;
6556 
6557 			DP_PRINT_STATS("	%s = %d",
6558 				       cdp_rate_string[pkt_type][mcs].mcs_type,
6559 				       pkt_type_array[pkt_type].mcs_count[mcs]);
6560 		}
6561 
6562 		DP_PRINT_STATS("\n");
6563 	}
6564 }
6565 
6566 /**
6567  * dp_print_common_ppdu_rates_info(): Print ppdu rate for tx or rx
6568  * @pkt_type_array: rate type array contains rate info
6569  * @pkt_type: packet type
6570  *
6571  * Return: void
6572  */
6573 #ifdef WLAN_FEATURE_11BE
6574 static inline void
dp_print_common_ppdu_rates_info(struct cdp_pkt_type * pkt_type_array,enum cdp_packet_type pkt_type)6575 dp_print_common_ppdu_rates_info(struct cdp_pkt_type *pkt_type_array,
6576 				enum cdp_packet_type pkt_type)
6577 {
6578 	uint8_t mcs;
6579 
6580 	DP_PRINT_STATS("PPDU Count");
6581 	for (mcs = 0; mcs < MAX_MCS; mcs++) {
6582 		if (pkt_type == DOT11_AX) {
6583 			if (!dp_ppdu_rate_string[0][mcs].valid)
6584 				continue;
6585 
6586 			DP_PRINT_STATS("	%s = %d",
6587 				       dp_ppdu_rate_string[0][mcs].mcs_type,
6588 				       pkt_type_array->mcs_count[mcs]);
6589 		} else if (pkt_type == DOT11_BE) {
6590 			if (!dp_ppdu_rate_string[1][mcs].valid)
6591 				continue;
6592 
6593 			DP_PRINT_STATS("	%s = %d",
6594 				       dp_ppdu_rate_string[1][mcs].mcs_type,
6595 				       pkt_type_array->mcs_count[mcs]);
6596 		}
6597 	}
6598 
6599 	DP_PRINT_STATS("\n");
6600 }
6601 #else
6602 static inline void
dp_print_common_ppdu_rates_info(struct cdp_pkt_type * pkt_type_array,enum cdp_packet_type pkt_type)6603 dp_print_common_ppdu_rates_info(struct cdp_pkt_type *pkt_type_array,
6604 				enum cdp_packet_type pkt_type)
6605 {
6606 	uint8_t mcs;
6607 
6608 	DP_PRINT_STATS("PPDU Count");
6609 	for (mcs = 0; mcs < MAX_MCS; mcs++) {
6610 		if (!dp_ppdu_rate_string[0][mcs].valid)
6611 			continue;
6612 
6613 		DP_PRINT_STATS("	%s = %d",
6614 			       dp_ppdu_rate_string[0][mcs].mcs_type,
6615 			       pkt_type_array->mcs_count[mcs]);
6616 	}
6617 
6618 	DP_PRINT_STATS("\n");
6619 }
6620 #endif
6621 
6622 /**
6623  * dp_print_mu_be_ppdu_rates_info(): Print mu be rate for tx or rx
6624  * @pkt_type_array: rate type array contains rate info
6625  *
6626  * Return: void
6627  */
6628 #ifdef WLAN_FEATURE_11BE
6629 static inline void
dp_print_mu_be_ppdu_rates_info(struct cdp_pkt_type * pkt_type_array)6630 dp_print_mu_be_ppdu_rates_info(struct cdp_pkt_type *pkt_type_array)
6631 {
6632 	uint8_t mcs, pkt_type;
6633 
6634 	DP_PRINT_STATS("PPDU Count");
6635 	for (pkt_type = 0; pkt_type < TXRX_TYPE_MU_MAX; pkt_type++) {
6636 		for (mcs = 0; mcs < MAX_MCS; mcs++) {
6637 			if (!dp_mu_be_rate_string[pkt_type][mcs].valid)
6638 				continue;
6639 
6640 			DP_PRINT_STATS("	%s = %d",
6641 				       dp_mu_be_rate_string[pkt_type][mcs].mcs_type,
6642 				       pkt_type_array[pkt_type].mcs_count[mcs]);
6643 		}
6644 
6645 		DP_PRINT_STATS("\n");
6646 	}
6647 }
6648 #endif
6649 
6650 static inline void
dp_print_mu_ppdu_rates_info(struct cdp_rx_mu * rx_mu)6651 dp_print_mu_ppdu_rates_info(struct cdp_rx_mu *rx_mu)
6652 {
6653 	uint8_t mcs, pkt_type;
6654 
6655 	DP_PRINT_STATS("PPDU Count");
6656 	for (pkt_type = 0; pkt_type < TXRX_TYPE_MU_MAX; pkt_type++) {
6657 		for (mcs = 0; mcs < MAX_MCS; mcs++) {
6658 			if (!dp_mu_rate_string[pkt_type][mcs].valid)
6659 				continue;
6660 
6661 			DP_PRINT_STATS("	%s = %d",
6662 				dp_mu_rate_string[pkt_type][mcs].mcs_type,
6663 				rx_mu[pkt_type].ppdu.mcs_count[mcs]);
6664 		}
6665 
6666 		DP_PRINT_STATS("\n");
6667 	}
6668 }
6669 
6670 #ifdef WLAN_FEATURE_11BE
dp_print_rx_bw_stats(struct dp_pdev * pdev)6671 static inline void dp_print_rx_bw_stats(struct dp_pdev *pdev)
6672 {
6673 	DP_PRINT_STATS("BW Counts = 20MHz %d, 40MHz %d, 80MHz %d, 160MHz %d, 320MHz %d",
6674 		       pdev->stats.rx.bw[0], pdev->stats.rx.bw[1],
6675 		       pdev->stats.rx.bw[2], pdev->stats.rx.bw[3],
6676 		       pdev->stats.rx.bw[4]);
6677 }
6678 
dp_print_tx_bw_stats(struct dp_pdev * pdev)6679 static inline void dp_print_tx_bw_stats(struct dp_pdev *pdev)
6680 {
6681 	DP_PRINT_STATS("BW Counts = 20MHz %d, 40MHz %d, 80MHz %d, 160MHz %d, 320MHz %d",
6682 		       pdev->stats.tx.bw[0], pdev->stats.tx.bw[1],
6683 		       pdev->stats.tx.bw[2], pdev->stats.tx.bw[3],
6684 		       pdev->stats.tx.bw[4]);
6685 }
6686 #else
dp_print_rx_bw_stats(struct dp_pdev * pdev)6687 static inline void dp_print_rx_bw_stats(struct dp_pdev *pdev)
6688 {
6689 	DP_PRINT_STATS("BW Counts = 20MHz %d, 40MHz %d, 80MHz %d, 160MHz %d",
6690 		       pdev->stats.rx.bw[0], pdev->stats.rx.bw[1],
6691 		       pdev->stats.rx.bw[2], pdev->stats.rx.bw[3]);
6692 }
6693 
dp_print_tx_bw_stats(struct dp_pdev * pdev)6694 static inline void dp_print_tx_bw_stats(struct dp_pdev *pdev)
6695 {
6696 	DP_PRINT_STATS("BW Counts = 20MHz %d, 40MHz %d, 80MHz %d, 160MHz %d",
6697 		       pdev->stats.tx.bw[0], pdev->stats.tx.bw[1],
6698 		       pdev->stats.tx.bw[2], pdev->stats.tx.bw[3]);
6699 }
6700 #endif
6701 
dp_print_rx_rates(struct dp_vdev * vdev)6702 void dp_print_rx_rates(struct dp_vdev *vdev)
6703 {
6704 	struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
6705 	uint8_t i;
6706 	uint8_t index = 0;
6707 	char nss[DP_NSS_LENGTH];
6708 
6709 	DP_PRINT_STATS("Rx Rate Info:\n");
6710 	dp_print_common_rates_info(pdev->stats.rx.pkt_type);
6711 
6712 	index = 0;
6713 	for (i = 0; i < SS_COUNT; i++) {
6714 		index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index,
6715 				     " %d", pdev->stats.rx.nss[i]);
6716 	}
6717 	DP_PRINT_STATS("NSS(1-8) = %s",
6718 		       nss);
6719 
6720 	DP_PRINT_STATS("SGI = 0.8us %d 0.4us %d 1.6us %d 3.2us %d",
6721 		       pdev->stats.rx.sgi_count[0],
6722 		       pdev->stats.rx.sgi_count[1],
6723 		       pdev->stats.rx.sgi_count[2],
6724 		       pdev->stats.rx.sgi_count[3]);
6725 
6726 	dp_print_rx_bw_stats(pdev);
6727 
6728 	DP_PRINT_STATS("Reception Type ="
6729 		       "SU: %d MU_MIMO:%d MU_OFDMA:%d MU_OFDMA_MIMO:%d",
6730 		       pdev->stats.rx.reception_type[0],
6731 		       pdev->stats.rx.reception_type[1],
6732 		       pdev->stats.rx.reception_type[2],
6733 		       pdev->stats.rx.reception_type[3]);
6734 	DP_PRINT_STATS("Aggregation:\n");
6735 	DP_PRINT_STATS("Number of Msdu's Part of Ampdus = %d",
6736 		       pdev->stats.rx.ampdu_cnt);
6737 	DP_PRINT_STATS("Number of Msdu's With No Mpdu Level Aggregation : %d",
6738 		       pdev->stats.rx.non_ampdu_cnt);
6739 	DP_PRINT_STATS("Number of Msdu's Part of Amsdu: %d",
6740 		       pdev->stats.rx.amsdu_cnt);
6741 	DP_PRINT_STATS("Number of Msdu's With No Msdu Level Aggregation: %d",
6742 		       pdev->stats.rx.non_amsdu_cnt);
6743 }
6744 
dp_print_tx_rates(struct dp_vdev * vdev)6745 void dp_print_tx_rates(struct dp_vdev *vdev)
6746 {
6747 	struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
6748 
6749 	DP_PRINT_STATS("Tx Rate Info:\n");
6750 	dp_print_common_rates_info(pdev->stats.tx.pkt_type);
6751 
6752 	DP_PRINT_STATS("SGI = 0.8us %d 0.4us %d 1.6us %d 3.2us %d",
6753 		       pdev->stats.tx.sgi_count[0],
6754 		       pdev->stats.tx.sgi_count[1],
6755 		       pdev->stats.tx.sgi_count[2],
6756 		       pdev->stats.tx.sgi_count[3]);
6757 
6758 	dp_print_tx_bw_stats(pdev);
6759 
6760 	DP_PRINT_STATS("OFDMA = %d", pdev->stats.tx.ofdma);
6761 	DP_PRINT_STATS("STBC = %d", pdev->stats.tx.stbc);
6762 	DP_PRINT_STATS("LDPC = %d", pdev->stats.tx.ldpc);
6763 	DP_PRINT_STATS("Retries = %d", pdev->stats.tx.retries);
6764 	DP_PRINT_STATS("Last ack rssi = %d\n", pdev->stats.tx.last_ack_rssi);
6765 	DP_PRINT_STATS("Number of PPDU's with Punctured Preamble = %d",
6766 			   pdev->stats.tx.pream_punct_cnt);
6767 
6768 	DP_PRINT_STATS("Aggregation:\n");
6769 	DP_PRINT_STATS("Number of Msdu's Part of Ampdus = %d",
6770 		       pdev->stats.tx.ampdu_cnt);
6771 	DP_PRINT_STATS("Number of Msdu's With No Mpdu Level Aggregation : %d",
6772 		       pdev->stats.tx.non_ampdu_cnt);
6773 	DP_PRINT_STATS("Number of Msdu's Part of Amsdu = %d",
6774 		       pdev->stats.tx.amsdu_cnt);
6775 	DP_PRINT_STATS("Number of Msdu's With No Msdu Level Aggregation = %d",
6776 		       pdev->stats.tx.non_amsdu_cnt);
6777 }
6778 
6779 /**
6780  * dp_print_nss(): Print nss count
6781  * @nss: printable nss count array
6782  * @pnss: nss count array
6783  * @ss_count: number of nss
6784  *
6785  * Return: void
6786  */
dp_print_nss(char * nss,uint32_t * pnss,uint32_t ss_count)6787 static void dp_print_nss(char *nss, uint32_t *pnss, uint32_t ss_count)
6788 {
6789 	uint32_t index;
6790 	uint8_t i;
6791 
6792 	index = 0;
6793 	for (i = 0; i < ss_count; i++) {
6794 		index += qdf_snprint(&nss[index], DP_NSS_LENGTH - index,
6795 				     " %d", *(pnss + i));
6796 	}
6797 }
6798 
6799 /**
6800  * dp_print_jitter_stats(): Print per-tid jitter stats
6801  * @peer: DP peer object
6802  * @pdev: DP pdev object
6803  *
6804  * Return: void
6805  */
6806 #ifdef WLAN_PEER_JITTER
dp_print_jitter_stats(struct dp_peer * peer,struct dp_pdev * pdev)6807 static void dp_print_jitter_stats(struct dp_peer *peer, struct dp_pdev *pdev)
6808 {
6809 	uint8_t tid = 0;
6810 
6811 	if (!pdev || !wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx))
6812 		return;
6813 
6814 	if (!peer->txrx_peer || !peer->txrx_peer->jitter_stats)
6815 		return;
6816 
6817 	DP_PRINT_STATS("Per TID Tx HW Enqueue-Comp Jitter Stats:\n");
6818 	for (tid = 0; tid < qdf_min(CDP_DATA_TID_MAX, DP_MAX_TIDS); tid++) {
6819 		struct cdp_peer_tid_stats *rx_tid =
6820 					&peer->txrx_peer->jitter_stats[tid];
6821 
6822 		DP_PRINT_STATS("Node tid = %d\n"
6823 				"Average Jiiter            : %u (us)\n"
6824 				"Average Delay             : %u (us)\n"
6825 				"Total Average error count : %llu\n"
6826 				"Total Success Count       : %llu\n"
6827 				"Total Drop                : %llu\n",
6828 				tid,
6829 				rx_tid->tx_avg_jitter,
6830 				rx_tid->tx_avg_delay,
6831 				rx_tid->tx_avg_err,
6832 				rx_tid->tx_total_success,
6833 				rx_tid->tx_drop);
6834 	}
6835 }
6836 #else
dp_print_jitter_stats(struct dp_peer * peer,struct dp_pdev * pdev)6837 static void dp_print_jitter_stats(struct dp_peer *peer, struct dp_pdev *pdev)
6838 {
6839 }
6840 #endif /* WLAN_PEER_JITTER */
6841 
6842 #ifdef QCA_PEER_EXT_STATS
6843 /**
6844  * dp_print_hist_stats() - Print delay histogram
6845  * @hstats: Histogram stats
6846  * @hist_type: histogram type
6847  *
6848  * Return: void
6849  */
dp_print_hist_stats(struct cdp_hist_stats * hstats,enum cdp_hist_types hist_type)6850 static void dp_print_hist_stats(struct cdp_hist_stats *hstats,
6851 				enum cdp_hist_types hist_type)
6852 {
6853 	uint8_t index = 0;
6854 	uint64_t count = 0;
6855 	bool hist_delay_data = false;
6856 
6857 	for (index = 0; index < CDP_HIST_BUCKET_MAX; index++) {
6858 		count = hstats->hist.freq[index];
6859 		if (!count)
6860 			continue;
6861 		hist_delay_data = true;
6862 		if (hist_type == CDP_HIST_TYPE_SW_ENQEUE_DELAY)
6863 			DP_PRINT_STATS("%s:  Packets = %llu",
6864 				       dp_vow_str_sw_enq_delay(index),
6865 				       count);
6866 		else if (hist_type == CDP_HIST_TYPE_HW_COMP_DELAY)
6867 			DP_PRINT_STATS("%s:  Packets = %llu",
6868 				       dp_vow_str_fw_to_hw_delay(index),
6869 				       count);
6870 		else if (hist_type == CDP_HIST_TYPE_REAP_STACK)
6871 			DP_PRINT_STATS("%s:  Packets = %llu",
6872 				       dp_vow_str_intfrm_delay(index),
6873 				       count);
6874 	}
6875 
6876 	/*
6877 	 * If none of the buckets have any packets,
6878 	 * there is no need to display the stats.
6879 	 */
6880 	if (hist_delay_data) {
6881 		DP_PRINT_STATS("Min = %u", hstats->min);
6882 		DP_PRINT_STATS("Max = %u", hstats->max);
6883 		DP_PRINT_STATS("Avg = %u\n", hstats->avg);
6884 	}
6885 }
6886 
6887 #ifdef CONFIG_SAWF
6888 /**
6889  * dp_accumulate_delay_avg_stats(): Accumulate the delay average stats
6890  * @stats: cdp_delay_tid stats
6891  * @dst_stats: Destination delay Tx stats
6892  * @tid: TID value
6893  *
6894  * Return: void
6895  */
dp_accumulate_delay_avg_stats(struct cdp_delay_tid_stats stats[][CDP_MAX_TXRX_CTX],struct cdp_delay_tx_stats * dst_stats,uint8_t tid)6896 static void dp_accumulate_delay_avg_stats(struct cdp_delay_tid_stats stats[]
6897 					  [CDP_MAX_TXRX_CTX],
6898 					  struct cdp_delay_tx_stats *dst_stats,
6899 					  uint8_t tid)
6900 {
6901 	uint32_t num_rings = 0;
6902 	uint8_t ring_id;
6903 
6904 	for (ring_id = 0; ring_id < CDP_MAX_TXRX_CTX; ring_id++) {
6905 		struct cdp_delay_tx_stats *dstats =
6906 				&stats[tid][ring_id].tx_delay;
6907 
6908 		if (dstats->swdelay_avg || dstats->hwdelay_avg) {
6909 			dst_stats->nwdelay_avg += dstats->nwdelay_avg;
6910 			dst_stats->swdelay_avg += dstats->swdelay_avg;
6911 			dst_stats->hwdelay_avg += dstats->hwdelay_avg;
6912 			num_rings++;
6913 		}
6914 	}
6915 
6916 	if (!num_rings)
6917 		return;
6918 
6919 	dst_stats->nwdelay_avg = qdf_do_div(dst_stats->nwdelay_avg,
6920 					    num_rings);
6921 	dst_stats->swdelay_avg = qdf_do_div(dst_stats->swdelay_avg,
6922 					    num_rings);
6923 	dst_stats->hwdelay_avg = qdf_do_div(dst_stats->hwdelay_avg,
6924 					    num_rings);
6925 }
6926 #else
dp_accumulate_delay_avg_stats(struct cdp_delay_tid_stats stats[][CDP_MAX_TXRX_CTX],struct cdp_delay_tx_stats * dst_stats,uint8_t tid)6927 static void dp_accumulate_delay_avg_stats(struct cdp_delay_tid_stats stats[]
6928 					  [CDP_MAX_TXRX_CTX],
6929 					  struct cdp_delay_tx_stats *dst_stats,
6930 					  uint8_t tid)
6931 {
6932 }
6933 #endif
6934 
6935 /**
6936  * dp_accumulate_delay_tid_stats(): Accumulate the tid stats to the
6937  *                                  hist stats.
6938  * @soc: DP SoC handle
6939  * @stats: cdp_delay_tid stats
6940  * @dst_hstats: Destination histogram to copy tid stats
6941  * @tid: TID value
6942  * @mode:
6943  *
6944  * Return: void
6945  */
dp_accumulate_delay_tid_stats(struct dp_soc * soc,struct cdp_delay_tid_stats stats[][CDP_MAX_TXRX_CTX],struct cdp_hist_stats * dst_hstats,uint8_t tid,uint32_t mode)6946 static void dp_accumulate_delay_tid_stats(struct dp_soc *soc,
6947 					  struct cdp_delay_tid_stats stats[]
6948 					  [CDP_MAX_TXRX_CTX],
6949 					  struct cdp_hist_stats *dst_hstats,
6950 					  uint8_t tid, uint32_t mode)
6951 {
6952 	uint8_t ring_id;
6953 
6954 	if (wlan_cfg_get_dp_soc_nss_cfg(soc->wlan_cfg_ctx)) {
6955 		struct cdp_delay_tid_stats *dstats =
6956 				&stats[tid][0];
6957 		struct cdp_hist_stats *src_hstats = NULL;
6958 
6959 		switch (mode) {
6960 		case CDP_HIST_TYPE_SW_ENQEUE_DELAY:
6961 			src_hstats = &dstats->tx_delay.tx_swq_delay;
6962 			break;
6963 		case CDP_HIST_TYPE_HW_COMP_DELAY:
6964 			src_hstats = &dstats->tx_delay.hwtx_delay;
6965 			break;
6966 		case CDP_HIST_TYPE_REAP_STACK:
6967 			src_hstats = &dstats->rx_delay.to_stack_delay;
6968 			break;
6969 		default:
6970 			break;
6971 		}
6972 
6973 		if (src_hstats)
6974 			dp_copy_hist_stats(src_hstats, dst_hstats);
6975 
6976 		return;
6977 	}
6978 
6979 	for (ring_id = 0; ring_id < CDP_MAX_TXRX_CTX; ring_id++) {
6980 		struct cdp_delay_tid_stats *dstats =
6981 				&stats[tid][ring_id];
6982 		struct cdp_hist_stats *src_hstats = NULL;
6983 
6984 		switch (mode) {
6985 		case CDP_HIST_TYPE_SW_ENQEUE_DELAY:
6986 			src_hstats = &dstats->tx_delay.tx_swq_delay;
6987 			break;
6988 		case CDP_HIST_TYPE_HW_COMP_DELAY:
6989 			src_hstats = &dstats->tx_delay.hwtx_delay;
6990 			break;
6991 		case CDP_HIST_TYPE_REAP_STACK:
6992 			src_hstats = &dstats->rx_delay.to_stack_delay;
6993 			break;
6994 		default:
6995 			break;
6996 		}
6997 
6998 		if (src_hstats)
6999 			dp_accumulate_hist_stats(src_hstats, dst_hstats);
7000 	}
7001 }
7002 
7003 /**
7004  * dp_peer_print_tx_delay_stats() - Print peer delay stats
7005  * @pdev: DP pdev handle
7006  * @peer: DP peer handle
7007  *
7008  * Return: void
7009  */
dp_peer_print_tx_delay_stats(struct dp_pdev * pdev,struct dp_peer * peer)7010 static void dp_peer_print_tx_delay_stats(struct dp_pdev *pdev,
7011 					 struct dp_peer *peer)
7012 {
7013 	struct dp_peer_delay_stats *delay_stats;
7014 	struct dp_soc *soc = NULL;
7015 	struct cdp_hist_stats hist_stats;
7016 	uint8_t tid;
7017 
7018 	if (!peer || !peer->txrx_peer)
7019 		return;
7020 
7021 	if (!pdev || !pdev->soc)
7022 		return;
7023 
7024 	soc = pdev->soc;
7025 	if (!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx))
7026 		return;
7027 
7028 	delay_stats = peer->txrx_peer->delay_stats;
7029 	if (!delay_stats)
7030 		return;
7031 
7032 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
7033 		DP_PRINT_STATS("----TID: %d----", tid);
7034 		DP_PRINT_STATS("Software Enqueue Delay:");
7035 		dp_hist_init(&hist_stats, CDP_HIST_TYPE_SW_ENQEUE_DELAY);
7036 		dp_accumulate_delay_tid_stats(soc, delay_stats->delay_tid_stats,
7037 					      &hist_stats, tid,
7038 					      CDP_HIST_TYPE_SW_ENQEUE_DELAY);
7039 		dp_print_hist_stats(&hist_stats, CDP_HIST_TYPE_SW_ENQEUE_DELAY);
7040 
7041 		DP_PRINT_STATS("Hardware Transmission Delay:");
7042 		dp_hist_init(&hist_stats, CDP_HIST_TYPE_HW_COMP_DELAY);
7043 		dp_accumulate_delay_tid_stats(soc, delay_stats->delay_tid_stats,
7044 					      &hist_stats, tid,
7045 					      CDP_HIST_TYPE_HW_COMP_DELAY);
7046 		dp_print_hist_stats(&hist_stats, CDP_HIST_TYPE_HW_COMP_DELAY);
7047 	}
7048 }
7049 
7050 /**
7051  * dp_peer_print_rx_delay_stats() - Print peer delay stats
7052  * @pdev: DP pdev handle
7053  * @peer: DP peer handle
7054  *
7055  * Return: void
7056  */
dp_peer_print_rx_delay_stats(struct dp_pdev * pdev,struct dp_peer * peer)7057 static void dp_peer_print_rx_delay_stats(struct dp_pdev *pdev,
7058 					 struct dp_peer *peer)
7059 {
7060 	struct dp_peer_delay_stats *delay_stats;
7061 	struct dp_soc *soc = NULL;
7062 	struct cdp_hist_stats hist_stats;
7063 	uint8_t tid;
7064 
7065 	if (!peer || !peer->txrx_peer)
7066 		return;
7067 
7068 	if (!pdev || !pdev->soc)
7069 		return;
7070 
7071 	soc = pdev->soc;
7072 	if (!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx))
7073 		return;
7074 
7075 	delay_stats = peer->txrx_peer->delay_stats;
7076 	if (!delay_stats)
7077 		return;
7078 
7079 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
7080 		DP_PRINT_STATS("----TID: %d----", tid);
7081 		DP_PRINT_STATS("Rx Reap2stack Deliver Delay:");
7082 		dp_hist_init(&hist_stats, CDP_HIST_TYPE_REAP_STACK);
7083 		dp_accumulate_delay_tid_stats(soc, delay_stats->delay_tid_stats,
7084 					      &hist_stats, tid,
7085 					      CDP_HIST_TYPE_REAP_STACK);
7086 		dp_print_hist_stats(&hist_stats, CDP_HIST_TYPE_REAP_STACK);
7087 	}
7088 }
7089 
7090 #else
dp_peer_print_tx_delay_stats(struct dp_pdev * pdev,struct dp_peer * peer)7091 static inline void dp_peer_print_tx_delay_stats(struct dp_pdev *pdev,
7092 						struct dp_peer *peer)
7093 {
7094 }
7095 
dp_peer_print_rx_delay_stats(struct dp_pdev * pdev,struct dp_peer * peer)7096 static inline void dp_peer_print_rx_delay_stats(struct dp_pdev *pdev,
7097 						struct dp_peer *peer)
7098 {
7099 }
7100 #endif
7101 
7102 #ifdef WLAN_FEATURE_11BE
dp_print_peer_txrx_stats_be(struct cdp_peer_stats * peer_stats,enum peer_stats_type stats_type)7103 void dp_print_peer_txrx_stats_be(struct cdp_peer_stats *peer_stats,
7104 				 enum peer_stats_type stats_type)
7105 {
7106 	uint8_t i;
7107 
7108 	if (stats_type == PEER_TX_STATS) {
7109 		DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d 320MHZ %d\n",
7110 			       peer_stats->tx.bw[CMN_BW_20MHZ],
7111 			       peer_stats->tx.bw[CMN_BW_40MHZ],
7112 			       peer_stats->tx.bw[CMN_BW_80MHZ],
7113 			       peer_stats->tx.bw[CMN_BW_160MHZ],
7114 			       peer_stats->tx.bw[CMN_BW_320MHZ]);
7115 		DP_PRINT_STATS("Punctured BW Counts = NO_PUNC %d 20MHz %d 40MHz %d 80MHz %d 120MHz %d\n",
7116 			       peer_stats->tx.punc_bw[NO_PUNCTURE],
7117 			       peer_stats->tx.punc_bw[PUNCTURED_20MHZ],
7118 			       peer_stats->tx.punc_bw[PUNCTURED_40MHZ],
7119 			       peer_stats->tx.punc_bw[PUNCTURED_80MHZ],
7120 			       peer_stats->tx.punc_bw[PUNCTURED_120MHZ]);
7121 		DP_PRINT_STATS("RU Locations");
7122 		for (i = 0; i < RU_INDEX_MAX; i++)
7123 			DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7124 				       cdp_ru_string[i].ru_type,
7125 				       peer_stats->tx.ru_loc[i].num_msdu,
7126 				       peer_stats->tx.ru_loc[i].num_mpdu,
7127 				       peer_stats->tx.ru_loc[i].mpdu_tried);
7128 		dp_print_common_ppdu_rates_info(&peer_stats->tx.su_be_ppdu_cnt,
7129 						DOT11_BE);
7130 		dp_print_mu_be_ppdu_rates_info(&peer_stats->tx.mu_be_ppdu_cnt[0]);
7131 
7132 	} else {
7133 		DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d 320MHZ %d",
7134 			       peer_stats->rx.bw[CMN_BW_20MHZ],
7135 			       peer_stats->rx.bw[CMN_BW_40MHZ],
7136 			       peer_stats->rx.bw[CMN_BW_80MHZ],
7137 			       peer_stats->rx.bw[CMN_BW_160MHZ],
7138 			       peer_stats->rx.bw[CMN_BW_320MHZ]);
7139 		DP_PRINT_STATS("Punctured BW Counts = NO_PUNC %d 20MHz %d 40MHz %d 80MHz %d 120MHz %d\n",
7140 			       peer_stats->rx.punc_bw[NO_PUNCTURE],
7141 			       peer_stats->rx.punc_bw[PUNCTURED_20MHZ],
7142 			       peer_stats->rx.punc_bw[PUNCTURED_40MHZ],
7143 			       peer_stats->rx.punc_bw[PUNCTURED_80MHZ],
7144 			       peer_stats->rx.punc_bw[PUNCTURED_120MHZ]);
7145 		dp_print_common_ppdu_rates_info(&peer_stats->rx.su_be_ppdu_cnt,
7146 						DOT11_BE);
7147 		dp_print_mu_be_ppdu_rates_info(&peer_stats->rx.mu_be_ppdu_cnt[0]);
7148 	}
7149 }
7150 #else
dp_print_peer_txrx_stats_be(struct cdp_peer_stats * peer_stats,enum peer_stats_type stats_type)7151 void dp_print_peer_txrx_stats_be(struct cdp_peer_stats *peer_stats,
7152 				 enum peer_stats_type stats_type)
7153 {
7154 }
7155 #endif
7156 
dp_print_peer_txrx_stats_li(struct cdp_peer_stats * peer_stats,enum peer_stats_type stats_type)7157 void dp_print_peer_txrx_stats_li(struct cdp_peer_stats *peer_stats,
7158 				 enum peer_stats_type stats_type)
7159 {
7160 	if (stats_type == PEER_TX_STATS) {
7161 		DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d\n",
7162 			       peer_stats->tx.bw[CMN_BW_20MHZ],
7163 			       peer_stats->tx.bw[CMN_BW_40MHZ],
7164 			       peer_stats->tx.bw[CMN_BW_80MHZ],
7165 			       peer_stats->tx.bw[CMN_BW_160MHZ]);
7166 		DP_PRINT_STATS("RU Locations");
7167 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7168 			       cdp_ru_string[RU_26_INDEX].ru_type,
7169 			       peer_stats->tx.ru_loc[RU_26_INDEX].num_msdu,
7170 			       peer_stats->tx.ru_loc[RU_26_INDEX].num_mpdu,
7171 			       peer_stats->tx.ru_loc[RU_26_INDEX].mpdu_tried);
7172 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7173 			       cdp_ru_string[RU_52_INDEX].ru_type,
7174 			       peer_stats->tx.ru_loc[RU_52_INDEX].num_msdu,
7175 			       peer_stats->tx.ru_loc[RU_52_INDEX].num_mpdu,
7176 			       peer_stats->tx.ru_loc[RU_52_INDEX].mpdu_tried);
7177 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7178 			       cdp_ru_string[RU_106_INDEX].ru_type,
7179 			       peer_stats->tx.ru_loc[RU_106_INDEX].num_msdu,
7180 			       peer_stats->tx.ru_loc[RU_106_INDEX].num_mpdu,
7181 			       peer_stats->tx.ru_loc[RU_106_INDEX].mpdu_tried);
7182 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7183 			       cdp_ru_string[RU_242_INDEX].ru_type,
7184 			       peer_stats->tx.ru_loc[RU_242_INDEX].num_msdu,
7185 			       peer_stats->tx.ru_loc[RU_242_INDEX].num_mpdu,
7186 			       peer_stats->tx.ru_loc[RU_242_INDEX].mpdu_tried);
7187 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7188 			       cdp_ru_string[RU_484_INDEX].ru_type,
7189 			       peer_stats->tx.ru_loc[RU_484_INDEX].num_msdu,
7190 			       peer_stats->tx.ru_loc[RU_484_INDEX].num_mpdu,
7191 			       peer_stats->tx.ru_loc[RU_484_INDEX].mpdu_tried);
7192 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7193 			       cdp_ru_string[RU_996_INDEX].ru_type,
7194 			       peer_stats->tx.ru_loc[RU_996_INDEX].num_msdu,
7195 			       peer_stats->tx.ru_loc[RU_996_INDEX].num_mpdu,
7196 			       peer_stats->tx.ru_loc[RU_996_INDEX].mpdu_tried);
7197 	} else {
7198 		DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d",
7199 			       peer_stats->rx.bw[CMN_BW_20MHZ],
7200 			       peer_stats->rx.bw[CMN_BW_40MHZ],
7201 			       peer_stats->rx.bw[CMN_BW_80MHZ],
7202 			       peer_stats->rx.bw[CMN_BW_160MHZ]);
7203 	}
7204 }
7205 
dp_print_peer_txrx_stats_rh(struct cdp_peer_stats * peer_stats,enum peer_stats_type stats_type)7206 void dp_print_peer_txrx_stats_rh(struct cdp_peer_stats *peer_stats,
7207 				 enum peer_stats_type stats_type)
7208 {
7209 	if (stats_type == PEER_TX_STATS) {
7210 		DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d\n",
7211 			       peer_stats->tx.bw[CMN_BW_20MHZ],
7212 			       peer_stats->tx.bw[CMN_BW_40MHZ],
7213 			       peer_stats->tx.bw[CMN_BW_80MHZ],
7214 			       peer_stats->tx.bw[CMN_BW_160MHZ]);
7215 		DP_PRINT_STATS("RU Locations");
7216 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7217 			       cdp_ru_string[RU_26_INDEX].ru_type,
7218 			       peer_stats->tx.ru_loc[RU_26_INDEX].num_msdu,
7219 			       peer_stats->tx.ru_loc[RU_26_INDEX].num_mpdu,
7220 			       peer_stats->tx.ru_loc[RU_26_INDEX].mpdu_tried);
7221 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7222 			       cdp_ru_string[RU_52_INDEX].ru_type,
7223 			       peer_stats->tx.ru_loc[RU_52_INDEX].num_msdu,
7224 			       peer_stats->tx.ru_loc[RU_52_INDEX].num_mpdu,
7225 			       peer_stats->tx.ru_loc[RU_52_INDEX].mpdu_tried);
7226 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7227 			       cdp_ru_string[RU_106_INDEX].ru_type,
7228 			       peer_stats->tx.ru_loc[RU_106_INDEX].num_msdu,
7229 			       peer_stats->tx.ru_loc[RU_106_INDEX].num_mpdu,
7230 			       peer_stats->tx.ru_loc[RU_106_INDEX].mpdu_tried);
7231 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7232 			       cdp_ru_string[RU_242_INDEX].ru_type,
7233 			       peer_stats->tx.ru_loc[RU_242_INDEX].num_msdu,
7234 			       peer_stats->tx.ru_loc[RU_242_INDEX].num_mpdu,
7235 			       peer_stats->tx.ru_loc[RU_242_INDEX].mpdu_tried);
7236 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7237 			       cdp_ru_string[RU_484_INDEX].ru_type,
7238 			       peer_stats->tx.ru_loc[RU_484_INDEX].num_msdu,
7239 			       peer_stats->tx.ru_loc[RU_484_INDEX].num_mpdu,
7240 			       peer_stats->tx.ru_loc[RU_484_INDEX].mpdu_tried);
7241 		DP_PRINT_STATS("%s: MSDUs Success = %d MPDUs Success = %d MPDUs Tried = %d",
7242 			       cdp_ru_string[RU_996_INDEX].ru_type,
7243 			       peer_stats->tx.ru_loc[RU_996_INDEX].num_msdu,
7244 			       peer_stats->tx.ru_loc[RU_996_INDEX].num_mpdu,
7245 			       peer_stats->tx.ru_loc[RU_996_INDEX].mpdu_tried);
7246 	} else {
7247 		DP_PRINT_STATS("BW Counts = 20MHZ %d 40MHZ %d 80MHZ %d 160MHZ %d",
7248 			       peer_stats->rx.bw[CMN_BW_20MHZ],
7249 			       peer_stats->rx.bw[CMN_BW_40MHZ],
7250 			       peer_stats->rx.bw[CMN_BW_80MHZ],
7251 			       peer_stats->rx.bw[CMN_BW_160MHZ]);
7252 	}
7253 }
7254 
7255 #ifdef REO_SHARED_QREF_TABLE_EN
dp_peer_print_reo_qref_table(struct dp_peer * peer)7256 static void dp_peer_print_reo_qref_table(struct dp_peer *peer)
7257 {
7258 	struct hal_soc *hal;
7259 	int i;
7260 	uint64_t *reo_qref_addr;
7261 	uint32_t peer_idx;
7262 
7263 	hal = (struct hal_soc *)peer->vdev->pdev->soc->hal_soc;
7264 
7265 	if (!hal_reo_shared_qaddr_is_enable((hal_soc_handle_t)hal))
7266 		return;
7267 
7268 	if ((!hal->reo_qref.non_mlo_reo_qref_table_vaddr) ||
7269 	    (!hal->reo_qref.mlo_reo_qref_table_vaddr)) {
7270 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
7271 			  FL("REO shared table not allocated"));
7272 		return;
7273 	}
7274 
7275 	if (IS_MLO_DP_LINK_PEER(peer))
7276 		return;
7277 
7278 	if (IS_MLO_DP_MLD_PEER(peer)) {
7279 		hal = (struct hal_soc *)
7280 			  peer->vdev->pdev->soc->hal_soc;
7281 		peer_idx = (peer->peer_id - HAL_ML_PEER_ID_START) *
7282 			    DP_MAX_TIDS;
7283 		reo_qref_addr =
7284 			&hal->reo_qref.mlo_reo_qref_table_vaddr[peer_idx];
7285 	} else {
7286 		peer_idx = (peer->peer_id * DP_MAX_TIDS);
7287 		reo_qref_addr =
7288 			&hal->reo_qref.non_mlo_reo_qref_table_vaddr[peer_idx];
7289 	}
7290 	DP_PRINT_STATS("Reo Qref table for peer_id: %d\n", peer->peer_id);
7291 
7292 	for (i = 0; i < DP_MAX_TIDS; i++)
7293 		DP_PRINT_STATS("    Tid [%d]  :%llx", i, reo_qref_addr[i]);
7294 }
7295 #else
dp_peer_print_reo_qref_table(struct dp_peer * peer)7296 static inline void dp_peer_print_reo_qref_table(struct dp_peer *peer)
7297 {
7298 }
7299 #endif
7300 
dp_print_peer_stats(struct dp_peer * peer,struct cdp_peer_stats * peer_stats)7301 void dp_print_peer_stats(struct dp_peer *peer,
7302 			 struct cdp_peer_stats *peer_stats)
7303 {
7304 	uint8_t i;
7305 	uint32_t index;
7306 	uint32_t j;
7307 	char nss[DP_NSS_LENGTH];
7308 	char mu_group_id[DP_MU_GROUP_LENGTH];
7309 	struct dp_pdev *pdev;
7310 	uint32_t *pnss;
7311 	enum cdp_mu_packet_type rx_mu_type;
7312 	struct cdp_rx_mu *rx_mu;
7313 
7314 	pdev = peer->vdev->pdev;
7315 
7316 	DP_PRINT_STATS("Node Tx Stats:\n");
7317 	DP_PRINT_STATS("Total Packet Completions = %llu",
7318 		       peer_stats->tx.comp_pkt.num);
7319 	DP_PRINT_STATS("Total Bytes Completions = %llu",
7320 		       peer_stats->tx.comp_pkt.bytes);
7321 	DP_PRINT_STATS("Success Packets = %llu",
7322 		       peer_stats->tx.tx_success.num);
7323 	DP_PRINT_STATS("Success Bytes = %llu",
7324 		       peer_stats->tx.tx_success.bytes);
7325 	DP_PRINT_STATS("Success Packets in TWT Session = %llu",
7326 		       peer_stats->tx.tx_success_twt.num);
7327 	DP_PRINT_STATS("Success Bytes in TWT Session = %llu",
7328 		       peer_stats->tx.tx_success_twt.bytes);
7329 	DP_PRINT_STATS("Unicast Success Packets = %llu",
7330 		       peer_stats->tx.ucast.num);
7331 	DP_PRINT_STATS("Unicast Success Bytes = %llu",
7332 		       peer_stats->tx.ucast.bytes);
7333 	DP_PRINT_STATS("Multicast Success Packets = %llu",
7334 		       peer_stats->tx.mcast.num);
7335 	DP_PRINT_STATS("Multicast Success Bytes = %llu",
7336 		       peer_stats->tx.mcast.bytes);
7337 	DP_PRINT_STATS("Broadcast Success Packets = %llu",
7338 		       peer_stats->tx.bcast.num);
7339 	DP_PRINT_STATS("Broadcast Success Bytes = %llu",
7340 		       peer_stats->tx.bcast.bytes);
7341 	DP_PRINT_STATS("Packets Successfully Sent after one or more retry = %d",
7342 		       peer_stats->tx.retry_count);
7343 	DP_PRINT_STATS("Packets Successfully Sent after more than one retry = %d",
7344 		       peer_stats->tx.multiple_retry_count);
7345 	DP_PRINT_STATS("Packets Failed = %d",
7346 		       peer_stats->tx.tx_failed);
7347 	DP_PRINT_STATS("Packets Failed due to retry threshold breach = %d",
7348 		       peer_stats->tx.failed_retry_count);
7349 	DP_PRINT_STATS("Packets In OFDMA = %d",
7350 		       peer_stats->tx.ofdma);
7351 	DP_PRINT_STATS("Packets In STBC = %d",
7352 		       peer_stats->tx.stbc);
7353 	DP_PRINT_STATS("Packets In LDPC = %d",
7354 		       peer_stats->tx.ldpc);
7355 	DP_PRINT_STATS("Packet Retries = %d",
7356 		       peer_stats->tx.retries);
7357 	DP_PRINT_STATS("MSDU's Part of AMSDU = %d",
7358 		       peer_stats->tx.amsdu_cnt);
7359 	DP_PRINT_STATS("Msdu's As Part of Ampdu = %d",
7360 		       peer_stats->tx.non_ampdu_cnt);
7361 	DP_PRINT_STATS("Msdu's As Ampdu = %d",
7362 		       peer_stats->tx.ampdu_cnt);
7363 	DP_PRINT_STATS("Last Packet RSSI = %d",
7364 		       peer_stats->tx.last_ack_rssi);
7365 	DP_PRINT_STATS("Dropped At FW: Removed Pkts = %llu",
7366 		       peer_stats->tx.dropped.fw_rem.num);
7367 	DP_PRINT_STATS("Release source not TQM = %u",
7368 		       peer_stats->tx.release_src_not_tqm);
7369 	if (pdev && !wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx)) {
7370 		DP_PRINT_STATS("Dropped At FW: Removed bytes = %llu",
7371 			peer_stats->tx.dropped.fw_rem.bytes);
7372 	}
7373 	DP_PRINT_STATS("Dropped At FW: Removed transmitted = %d",
7374 		       peer_stats->tx.dropped.fw_rem_tx);
7375 	DP_PRINT_STATS("Dropped At FW: Removed Untransmitted = %d",
7376 		       peer_stats->tx.dropped.fw_rem_notx);
7377 	DP_PRINT_STATS("Dropped At FW: removed untransmitted fw_reason1 = %u",
7378 		       peer_stats->tx.dropped.fw_reason1);
7379 	DP_PRINT_STATS("Dropped At FW: removed untransmitted fw_reason2 = %u",
7380 		       peer_stats->tx.dropped.fw_reason2);
7381 	DP_PRINT_STATS("Dropped At FW: removed untransmitted fw_reason3 = %u",
7382 		       peer_stats->tx.dropped.fw_reason3);
7383 	DP_PRINT_STATS("Dropped At FW:removed untransmitted disable queue = %u",
7384 		       peer_stats->tx.dropped.fw_rem_queue_disable);
7385 	DP_PRINT_STATS("Dropped At FW: removed untransmitted no match = %u",
7386 		       peer_stats->tx.dropped.fw_rem_no_match);
7387 	DP_PRINT_STATS("Dropped due to HW threshold criteria = %u",
7388 		       peer_stats->tx.dropped.drop_threshold);
7389 	DP_PRINT_STATS("Dropped due Link desc not available drop in HW = %u",
7390 		       peer_stats->tx.dropped.drop_link_desc_na);
7391 	DP_PRINT_STATS("Drop bit set or invalid flow = %u",
7392 		       peer_stats->tx.dropped.invalid_drop);
7393 	DP_PRINT_STATS("MCAST vdev drop in HW = %u",
7394 		       peer_stats->tx.dropped.mcast_vdev_drop);
7395 	DP_PRINT_STATS("Dropped : Age Out = %d",
7396 		       peer_stats->tx.dropped.age_out);
7397 	DP_PRINT_STATS("Dropped : Invalid Reason = %u",
7398 		       peer_stats->tx.dropped.invalid_rr);
7399 	DP_PRINT_STATS("NAWDS : ");
7400 	DP_PRINT_STATS("Nawds multicast Drop Tx Packet = %d",
7401 		       peer_stats->tx.nawds_mcast_drop);
7402 	DP_PRINT_STATS("	Nawds multicast  Tx Packet Count = %llu",
7403 		       peer_stats->tx.nawds_mcast.num);
7404 	DP_PRINT_STATS("	Nawds multicast  Tx Packet Bytes = %llu",
7405 		       peer_stats->tx.nawds_mcast.bytes);
7406 
7407 	DP_PRINT_STATS("PPDU's = %d", peer_stats->tx.tx_ppdus);
7408 	DP_PRINT_STATS("Number of PPDU's with Punctured Preamble = %d",
7409 		       peer_stats->tx.pream_punct_cnt);
7410 	DP_PRINT_STATS("MPDU's Successful = %d",
7411 		       peer_stats->tx.tx_mpdus_success);
7412 	DP_PRINT_STATS("MPDU's Tried = %d", peer_stats->tx.tx_mpdus_tried);
7413 
7414 	DP_PRINT_STATS("Rate Info:");
7415 	dp_print_common_rates_info(peer_stats->tx.pkt_type);
7416 
7417 	DP_PRINT_STATS("SGI = 0.8us %d 0.4us %d 1.6us %d 3.2us %d",
7418 		       peer_stats->tx.sgi_count[0],
7419 		       peer_stats->tx.sgi_count[1],
7420 		       peer_stats->tx.sgi_count[2],
7421 		       peer_stats->tx.sgi_count[3]);
7422 
7423 	DP_PRINT_STATS("Wireless Mutlimedia ");
7424 	DP_PRINT_STATS("	 Best effort = %d",
7425 		       peer_stats->tx.wme_ac_type[0]);
7426 	DP_PRINT_STATS("	 Background= %d",
7427 		       peer_stats->tx.wme_ac_type[1]);
7428 	DP_PRINT_STATS("	 Video = %d",
7429 		       peer_stats->tx.wme_ac_type[2]);
7430 	DP_PRINT_STATS("	 Voice = %d",
7431 		       peer_stats->tx.wme_ac_type[3]);
7432 
7433 	DP_PRINT_STATS("Excess Retries per AC ");
7434 	DP_PRINT_STATS("	 Best effort = %d",
7435 		       peer_stats->tx.excess_retries_per_ac[0]);
7436 	DP_PRINT_STATS("	 Background= %d",
7437 		       peer_stats->tx.excess_retries_per_ac[1]);
7438 	DP_PRINT_STATS("	 Video = %d",
7439 		       peer_stats->tx.excess_retries_per_ac[2]);
7440 	DP_PRINT_STATS("	 Voice = %d",
7441 		       peer_stats->tx.excess_retries_per_ac[3]);
7442 
7443 	pnss = &peer_stats->tx.nss[0];
7444 	dp_print_nss(nss, pnss, SS_COUNT);
7445 
7446 	DP_PRINT_STATS("NSS(1-8) = %s", nss);
7447 
7448 	DP_PRINT_STATS("Transmit Type :");
7449 	DP_PRINT_STATS("MSDUs Success: SU %d, MU_MIMO %d, MU_OFDMA %d, MU_MIMO_OFDMA %d",
7450 		       peer_stats->tx.transmit_type[SU].num_msdu,
7451 		       peer_stats->tx.transmit_type[MU_MIMO].num_msdu,
7452 		       peer_stats->tx.transmit_type[MU_OFDMA].num_msdu,
7453 		       peer_stats->tx.transmit_type[MU_MIMO_OFDMA].num_msdu);
7454 
7455 	DP_PRINT_STATS("MPDUs Success: SU %d, MU_MIMO %d, MU_OFDMA %d, MU_MIMO_OFDMA %d",
7456 		       peer_stats->tx.transmit_type[SU].num_mpdu,
7457 		       peer_stats->tx.transmit_type[MU_MIMO].num_mpdu,
7458 		       peer_stats->tx.transmit_type[MU_OFDMA].num_mpdu,
7459 		       peer_stats->tx.transmit_type[MU_MIMO_OFDMA].num_mpdu);
7460 
7461 	DP_PRINT_STATS("MPDUs Tried: SU %d, MU_MIMO %d, MU_OFDMA %d, MU_MIMO_OFDMA %d",
7462 		       peer_stats->tx.transmit_type[SU].mpdu_tried,
7463 		       peer_stats->tx.transmit_type[MU_MIMO].mpdu_tried,
7464 		       peer_stats->tx.transmit_type[MU_OFDMA].mpdu_tried,
7465 		       peer_stats->tx.transmit_type[MU_MIMO_OFDMA].mpdu_tried);
7466 
7467 	for (i = 0; i < MAX_MU_GROUP_ID;) {
7468 		index = 0;
7469 		for (j = 0; j < DP_MU_GROUP_SHOW && i < MAX_MU_GROUP_ID;
7470 		     j++) {
7471 			index += qdf_snprint(&mu_group_id[index],
7472 					     DP_MU_GROUP_LENGTH - index,
7473 					     " %d",
7474 					     peer_stats->tx.mu_group_id[i]);
7475 			i++;
7476 		}
7477 
7478 		DP_PRINT_STATS("User position list for GID %02d->%d: [%s]",
7479 			       i - DP_MU_GROUP_SHOW, i - 1, mu_group_id);
7480 	}
7481 
7482 	DP_PRINT_STATS("Last Packet RU index [%d], Size [%d]",
7483 		       peer_stats->tx.ru_start, peer_stats->tx.ru_tones);
7484 
7485 	DP_PRINT_STATS("Aggregation:");
7486 	DP_PRINT_STATS("Number of Msdu's Part of Amsdu = %d",
7487 		       peer_stats->tx.amsdu_cnt);
7488 	DP_PRINT_STATS("Number of Msdu's With No Msdu Level Aggregation = %d",
7489 		       peer_stats->tx.non_amsdu_cnt);
7490 
7491 	DP_PRINT_STATS("Bytes and Packets transmitted  in last one sec:");
7492 	DP_PRINT_STATS("	Bytes transmitted in last sec: %d",
7493 		       peer_stats->tx.tx_byte_rate);
7494 	DP_PRINT_STATS("	Data transmitted in last sec: %d",
7495 		       peer_stats->tx.tx_data_rate);
7496 
7497 	if (pdev && pdev->soc->arch_ops.txrx_print_peer_stats)
7498 		pdev->soc->arch_ops.txrx_print_peer_stats(peer_stats,
7499 							  PEER_TX_STATS);
7500 
7501 	if (!IS_MLO_DP_LINK_PEER(peer)) {
7502 		dp_print_jitter_stats(peer, pdev);
7503 		dp_peer_print_tx_delay_stats(pdev, peer);
7504 	}
7505 
7506 	if (IS_MLO_DP_MLD_PEER(peer))
7507 		DP_PRINT_STATS("TX Invalid Link ID Packet Count = %u",
7508 			       peer_stats->tx.inval_link_id_pkt_cnt);
7509 
7510 	DP_PRINT_STATS("Node Rx Stats:");
7511 	DP_PRINT_STATS("Packets Sent To Stack = %llu",
7512 		       peer_stats->rx.rx_success.num);
7513 	DP_PRINT_STATS("Bytes Sent To Stack = %llu",
7514 		       peer_stats->rx.rx_success.bytes);
7515 	for (i = 0; i <  CDP_MAX_RX_RINGS; i++) {
7516 		DP_PRINT_STATS("Ring Id = %d", i);
7517 		DP_PRINT_STATS("	Packets Received = %llu",
7518 			       peer_stats->rx.rcvd_reo[i].num);
7519 		DP_PRINT_STATS("	Bytes Received = %llu",
7520 			       peer_stats->rx.rcvd_reo[i].bytes);
7521 	}
7522 	for (i = 0; i < CDP_MAX_LMACS; i++)
7523 		DP_PRINT_STATS("Packets Received on lmac[%d] = %llu ( %llu )",
7524 			       i, peer_stats->rx.rx_lmac[i].num,
7525 			       peer_stats->rx.rx_lmac[i].bytes);
7526 
7527 	DP_PRINT_STATS("Unicast Packets Received = %llu",
7528 		       peer_stats->rx.unicast.num);
7529 	DP_PRINT_STATS("Unicast Bytes Received = %llu",
7530 		       peer_stats->rx.unicast.bytes);
7531 	DP_PRINT_STATS("Multicast Packets Received = %llu",
7532 		       peer_stats->rx.multicast.num);
7533 	DP_PRINT_STATS("Multicast Bytes Received = %llu",
7534 		       peer_stats->rx.multicast.bytes);
7535 	DP_PRINT_STATS("Broadcast Packets Received = %llu",
7536 		       peer_stats->rx.bcast.num);
7537 	DP_PRINT_STATS("Broadcast Bytes Received = %llu",
7538 		       peer_stats->rx.bcast.bytes);
7539 	DP_PRINT_STATS("Packets Sent To Stack in TWT Session = %llu",
7540 		       peer_stats->rx.to_stack_twt.num);
7541 	DP_PRINT_STATS("Bytes Sent To Stack in TWT Session = %llu",
7542 		       peer_stats->rx.to_stack_twt.bytes);
7543 	DP_PRINT_STATS("Intra BSS Packets Received = %llu",
7544 		       peer_stats->rx.intra_bss.pkts.num);
7545 	DP_PRINT_STATS("Intra BSS Bytes Received = %llu",
7546 		       peer_stats->rx.intra_bss.pkts.bytes);
7547 	DP_PRINT_STATS("Intra BSS Packets Failed = %llu",
7548 		       peer_stats->rx.intra_bss.fail.num);
7549 	DP_PRINT_STATS("Intra BSS Bytes Failed = %llu",
7550 		       peer_stats->rx.intra_bss.fail.bytes);
7551 	DP_PRINT_STATS("Intra BSS MDNS Packets Not Forwarded  = %d",
7552 		       peer_stats->rx.intra_bss.mdns_no_fwd);
7553 	DP_PRINT_STATS("Raw Packets Received = %llu",
7554 		       peer_stats->rx.raw.num);
7555 	DP_PRINT_STATS("Raw Bytes Received = %llu",
7556 		       peer_stats->rx.raw.bytes);
7557 	DP_PRINT_STATS("Errors: MIC Errors = %d",
7558 		       peer_stats->rx.err.mic_err);
7559 	DP_PRINT_STATS("Errors: Decryption Errors = %d",
7560 		       peer_stats->rx.err.decrypt_err);
7561 	DP_PRINT_STATS("Errors: PN Errors = %d",
7562 		       peer_stats->rx.err.pn_err);
7563 	DP_PRINT_STATS("Errors: OOR Errors = %d",
7564 		       peer_stats->rx.err.oor_err);
7565 	DP_PRINT_STATS("Errors: 2k Jump Errors = %d",
7566 		       peer_stats->rx.err.jump_2k_err);
7567 	DP_PRINT_STATS("Errors: RXDMA Wifi Parse Errors = %d",
7568 		       peer_stats->rx.err.rxdma_wifi_parse_err);
7569 	DP_PRINT_STATS("Msdu's Received As Part of Ampdu = %d",
7570 		       peer_stats->rx.non_ampdu_cnt);
7571 	DP_PRINT_STATS("Msdu's Received As Ampdu = %d",
7572 		       peer_stats->rx.ampdu_cnt);
7573 	DP_PRINT_STATS("Msdu's Received Not Part of Amsdu's = %d",
7574 		       peer_stats->rx.non_amsdu_cnt);
7575 	DP_PRINT_STATS("MSDUs Received As Part of Amsdu = %d",
7576 		       peer_stats->rx.amsdu_cnt);
7577 	DP_PRINT_STATS("MSDU Rx Retries= %d", peer_stats->rx.rx_retries);
7578 	DP_PRINT_STATS("MPDU Rx Retries= %d", peer_stats->rx.mpdu_retry_cnt);
7579 	DP_PRINT_STATS("NAWDS : ");
7580 	DP_PRINT_STATS("	Nawds multicast Drop Rx Packet = %d",
7581 		       peer_stats->rx.nawds_mcast_drop);
7582 	DP_PRINT_STATS(" 3address multicast Drop Rx Packet = %d",
7583 		       peer_stats->rx.mcast_3addr_drop);
7584 	DP_PRINT_STATS("SGI = 0.8us %d 0.4us %d 1.6us %d 3.2us %d",
7585 		       peer_stats->rx.sgi_count[0],
7586 		       peer_stats->rx.sgi_count[1],
7587 		       peer_stats->rx.sgi_count[2],
7588 		       peer_stats->rx.sgi_count[3]);
7589 
7590 	DP_PRINT_STATS("Wireless Mutlimedia ");
7591 	DP_PRINT_STATS("	 Best effort = %d",
7592 		       peer_stats->rx.wme_ac_type[0]);
7593 	DP_PRINT_STATS("	 Background= %d",
7594 		       peer_stats->rx.wme_ac_type[1]);
7595 	DP_PRINT_STATS("	 Video = %d",
7596 		       peer_stats->rx.wme_ac_type[2]);
7597 	DP_PRINT_STATS("	 Voice = %d",
7598 		       peer_stats->rx.wme_ac_type[3]);
7599 
7600 	DP_PRINT_STATS(" Total Rx PPDU Count = %d", peer_stats->rx.rx_ppdus);
7601 	DP_PRINT_STATS(" Total Rx MPDU Count = %d", peer_stats->rx.rx_mpdus);
7602 	DP_PRINT_STATS("MSDU Reception Type");
7603 	DP_PRINT_STATS("SU %d MU_MIMO %d MU_OFDMA %d MU_OFDMA_MIMO %d",
7604 		       peer_stats->rx.reception_type[0],
7605 		       peer_stats->rx.reception_type[1],
7606 		       peer_stats->rx.reception_type[2],
7607 		       peer_stats->rx.reception_type[3]);
7608 	DP_PRINT_STATS("PPDU Reception Type");
7609 	DP_PRINT_STATS("SU %d MU_MIMO %d MU_OFDMA %d MU_OFDMA_MIMO %d",
7610 		       peer_stats->rx.ppdu_cnt[0],
7611 		       peer_stats->rx.ppdu_cnt[1],
7612 		       peer_stats->rx.ppdu_cnt[2],
7613 		       peer_stats->rx.ppdu_cnt[3]);
7614 
7615 	dp_print_common_rates_info(peer_stats->rx.pkt_type);
7616 	dp_print_common_ppdu_rates_info(&peer_stats->rx.su_ax_ppdu_cnt,
7617 					DOT11_AX);
7618 	dp_print_mu_ppdu_rates_info(&peer_stats->rx.rx_mu[0]);
7619 
7620 	pnss = &peer_stats->rx.nss[0];
7621 	dp_print_nss(nss, pnss, SS_COUNT);
7622 	DP_PRINT_STATS("MSDU Count");
7623 	DP_PRINT_STATS("	NSS(1-8) = %s", nss);
7624 
7625 	DP_PRINT_STATS("reception mode SU");
7626 	pnss = &peer_stats->rx.ppdu_nss[0];
7627 	dp_print_nss(nss, pnss, SS_COUNT);
7628 
7629 	DP_PRINT_STATS("	PPDU Count");
7630 	DP_PRINT_STATS("	NSS(1-8) = %s", nss);
7631 
7632 	DP_PRINT_STATS("	MPDU OK = %d, MPDU Fail = %d",
7633 		       peer_stats->rx.mpdu_cnt_fcs_ok,
7634 		       peer_stats->rx.mpdu_cnt_fcs_err);
7635 
7636 	for (rx_mu_type = 0; rx_mu_type < TXRX_TYPE_MU_MAX; rx_mu_type++) {
7637 		DP_PRINT_STATS("reception mode %s",
7638 			       mu_reception_mode[rx_mu_type]);
7639 		rx_mu = &peer_stats->rx.rx_mu[rx_mu_type];
7640 
7641 		pnss = &rx_mu->ppdu_nss[0];
7642 		dp_print_nss(nss, pnss, SS_COUNT);
7643 		DP_PRINT_STATS("	PPDU Count");
7644 		DP_PRINT_STATS("	NSS(1-8) = %s", nss);
7645 
7646 		DP_PRINT_STATS("	MPDU OK = %d, MPDU Fail = %d",
7647 			       rx_mu->mpdu_cnt_fcs_ok,
7648 			       rx_mu->mpdu_cnt_fcs_err);
7649 	}
7650 
7651 	DP_PRINT_STATS("Aggregation:");
7652 	DP_PRINT_STATS("	Msdu's Part of Ampdu = %d",
7653 		       peer_stats->rx.ampdu_cnt);
7654 	DP_PRINT_STATS("	Msdu's With No Mpdu Level Aggregation = %d",
7655 		       peer_stats->rx.non_ampdu_cnt);
7656 	DP_PRINT_STATS("	Msdu's Part of Amsdu = %d",
7657 		       peer_stats->rx.amsdu_cnt);
7658 	DP_PRINT_STATS("	Msdu's With No Msdu Level Aggregation = %d",
7659 		       peer_stats->rx.non_amsdu_cnt);
7660 
7661 	DP_PRINT_STATS("Bytes and Packets received in last one sec:");
7662 	DP_PRINT_STATS("	Bytes received in last sec: %d",
7663 		       peer_stats->rx.rx_byte_rate);
7664 	DP_PRINT_STATS("	Data received in last sec: %d",
7665 		       peer_stats->rx.rx_data_rate);
7666 	DP_PRINT_STATS("MEC Packet Drop = %llu",
7667 		       peer_stats->rx.mec_drop.num);
7668 	DP_PRINT_STATS("MEC Byte Drop = %llu",
7669 		       peer_stats->rx.mec_drop.bytes);
7670 	DP_PRINT_STATS("Multipass Rx Packet Drop = %d",
7671 		       peer_stats->rx.multipass_rx_pkt_drop);
7672 	DP_PRINT_STATS("Peer Unauth Rx Packet Drop = %d",
7673 		       peer_stats->rx.peer_unauth_rx_pkt_drop);
7674 	DP_PRINT_STATS("Policy Check Rx Packet Drop = %d",
7675 		       peer_stats->rx.policy_check_drop);
7676 	if (pdev && pdev->soc->arch_ops.txrx_print_peer_stats)
7677 		pdev->soc->arch_ops.txrx_print_peer_stats(peer_stats,
7678 							  PEER_RX_STATS);
7679 
7680 	if (!IS_MLO_DP_LINK_PEER(peer))
7681 		dp_peer_print_rx_delay_stats(pdev, peer);
7682 
7683 	if (IS_MLO_DP_MLD_PEER(peer))
7684 		DP_PRINT_STATS("RX Invalid Link ID Packet Count = %u",
7685 			       peer_stats->rx.inval_link_id_pkt_cnt);
7686 
7687 	dp_peer_print_reo_qref_table(peer);
7688 }
7689 
dp_print_per_ring_stats(struct dp_soc * soc)7690 void dp_print_per_ring_stats(struct dp_soc *soc)
7691 {
7692 	uint8_t ring;
7693 	uint16_t core;
7694 	uint64_t total_packets;
7695 
7696 	DP_PRINT_STATS("Rx packets per ring:");
7697 	for (ring = 0; ring < MAX_REO_DEST_RINGS; ring++) {
7698 		total_packets = 0;
7699 		DP_PRINT_STATS("Packets on ring %u:", ring);
7700 		for (core = 0; core < num_possible_cpus(); core++) {
7701 			if (!soc->stats.rx.ring_packets[core][ring])
7702 				continue;
7703 			DP_PRINT_STATS("Packets arriving on core %u: %llu",
7704 				       core,
7705 				       soc->stats.rx.ring_packets[core][ring]);
7706 			total_packets += soc->stats.rx.ring_packets[core][ring];
7707 		}
7708 		DP_PRINT_STATS("Total packets on ring %u: %llu",
7709 			       ring, total_packets);
7710 	}
7711 }
7712 
dp_pdev_print_tx_rx_rates(struct dp_pdev * pdev)7713 static void dp_pdev_print_tx_rx_rates(struct dp_pdev *pdev)
7714 {
7715 	struct dp_vdev *vdev;
7716 	struct dp_vdev **vdev_array = NULL;
7717 	int index = 0, num_vdev = 0;
7718 
7719 	if (!pdev) {
7720 		dp_err("pdev is NULL");
7721 		return;
7722 	}
7723 
7724 	vdev_array =
7725 		qdf_mem_malloc(sizeof(struct dp_vdev *) * WLAN_PDEV_MAX_VDEVS);
7726 	if (!vdev_array)
7727 		return;
7728 
7729 	qdf_spin_lock_bh(&pdev->vdev_list_lock);
7730 	DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
7731 		if (dp_vdev_get_ref(pdev->soc, vdev, DP_MOD_ID_GENERIC_STATS))
7732 			continue;
7733 		vdev_array[index] = vdev;
7734 		index = index + 1;
7735 	}
7736 	qdf_spin_unlock_bh(&pdev->vdev_list_lock);
7737 
7738 	num_vdev = index;
7739 
7740 	for (index = 0; index < num_vdev; index++) {
7741 		vdev = vdev_array[index];
7742 		dp_print_rx_rates(vdev);
7743 		dp_print_tx_rates(vdev);
7744 		dp_vdev_unref_delete(pdev->soc, vdev, DP_MOD_ID_GENERIC_STATS);
7745 	}
7746 	qdf_mem_free(vdev_array);
7747 }
7748 
dp_txrx_path_stats(struct dp_soc * soc)7749 void dp_txrx_path_stats(struct dp_soc *soc)
7750 {
7751 	uint8_t error_code;
7752 	uint8_t loop_pdev;
7753 	struct dp_pdev *pdev;
7754 	uint8_t i;
7755 	uint8_t *buf;
7756 	size_t pos, buf_len;
7757 	uint8_t dp_stats_str[DP_STATS_STR_LEN] = {'\0'};
7758 
7759 	if (!soc) {
7760 		dp_err("Invalid access");
7761 		return;
7762 	}
7763 
7764 	for (loop_pdev = 0; loop_pdev < soc->pdev_count; loop_pdev++) {
7765 		pdev = soc->pdev_list[loop_pdev];
7766 		dp_aggregate_pdev_stats(pdev);
7767 		DP_PRINT_STATS("Tx path Statistics:");
7768 		DP_PRINT_STATS("from stack: %llu msdus (%llu bytes)",
7769 			       pdev->stats.tx_i.rcvd.num,
7770 			       pdev->stats.tx_i.rcvd.bytes);
7771 		DP_PRINT_STATS("processed from host: %llu msdus (%llu bytes)",
7772 			       pdev->stats.tx_i.processed.num,
7773 			       pdev->stats.tx_i.processed.bytes);
7774 		DP_PRINT_STATS("successfully transmitted: %llu msdus (%llu bytes)",
7775 			       pdev->stats.tx.tx_success.num,
7776 			       pdev->stats.tx.tx_success.bytes);
7777 
7778 		dp_print_tx_ring_stats(soc);
7779 
7780 		DP_PRINT_STATS("Invalid release source: %u",
7781 			       soc->stats.tx.invalid_release_source);
7782 		DP_PRINT_STATS("Invalid TX desc from completion ring: %u",
7783 			       soc->stats.tx.invalid_tx_comp_desc);
7784 		DP_PRINT_STATS("Dropped in host:");
7785 		DP_PRINT_STATS("Total packets dropped: %llu",
7786 			       pdev->stats.tx_i.dropped.dropped_pkt.num);
7787 		DP_PRINT_STATS("Descriptor not available: %llu",
7788 			       pdev->stats.tx_i.dropped.desc_na.num);
7789 		DP_PRINT_STATS("Ring full: %u",
7790 			       pdev->stats.tx_i.dropped.ring_full);
7791 		DP_PRINT_STATS("Enqueue fail: %u",
7792 			       pdev->stats.tx_i.dropped.enqueue_fail);
7793 		DP_PRINT_STATS("Pkt dropped in vdev-id check: %u",
7794 			       pdev->stats.tx_i.dropped.fail_per_pkt_vdev_id_check);
7795 		DP_PRINT_STATS("DMA Error: %u",
7796 			       pdev->stats.tx_i.dropped.dma_error);
7797 		DP_PRINT_STATS("Drop Ingress: %u",
7798 			       pdev->stats.tx_i.dropped.drop_ingress);
7799 		DP_PRINT_STATS("Resources full: %u",
7800 			       pdev->stats.tx_i.dropped.res_full);
7801 		DP_PRINT_STATS("Headroom insufficient: %u",
7802 			       pdev->stats.tx_i.dropped.headroom_insufficient);
7803 		DP_PRINT_STATS("Invalid peer id in exception path: %u",
7804 			       pdev->stats.tx_i.dropped.invalid_peer_id_in_exc_path);
7805 		DP_PRINT_STATS("Tx Mcast Drop: %u",
7806 			       pdev->stats.tx_i.dropped.tx_mcast_drop);
7807 		DP_PRINT_STATS("FW2WBM Tx Drop: %u",
7808 			       pdev->stats.tx_i.dropped.fw2wbm_tx_drop);
7809 
7810 		DP_PRINT_STATS("Dropped in hardware:");
7811 		DP_PRINT_STATS("total packets dropped: %u",
7812 			       pdev->stats.tx.tx_failed);
7813 		DP_PRINT_STATS("mpdu age out: %u",
7814 			       pdev->stats.tx.dropped.age_out);
7815 		DP_PRINT_STATS("firmware removed packets: %llu (%llu bytes)",
7816 			       pdev->stats.tx.dropped.fw_rem.num,
7817 			       pdev->stats.tx.dropped.fw_rem.bytes);
7818 		DP_PRINT_STATS("firmware removed tx: %u",
7819 			       pdev->stats.tx.dropped.fw_rem_tx);
7820 		DP_PRINT_STATS("firmware removed notx %u",
7821 			       pdev->stats.tx.dropped.fw_rem_notx);
7822 		DP_PRINT_STATS("Invalid peer on tx path: %llu",
7823 			       pdev->soc->stats.tx.tx_invalid_peer.num);
7824 		DP_PRINT_STATS("Tx desc freed in non-completion path: %u",
7825 			       pdev->soc->stats.tx.tx_comp_exception);
7826 		DP_PRINT_STATS("Tx desc force freed: %u",
7827 			       pdev->soc->stats.tx.tx_comp_force_freed);
7828 
7829 		buf = dp_stats_str;
7830 		buf_len = DP_STATS_STR_LEN;
7831 		pos = 0;
7832 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "Tx/IRQ [Range:Pkts] [");
7833 
7834 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "1: %u, ",
7835 				     pdev->stats.tx_comp_histogram.pkts_1);
7836 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "2-20: %u, ",
7837 				     pdev->stats.tx_comp_histogram.pkts_2_20);
7838 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "21-40: %u, ",
7839 				     pdev->stats.tx_comp_histogram.pkts_21_40);
7840 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "41-60: %u, ",
7841 				     pdev->stats.tx_comp_histogram.pkts_41_60);
7842 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "61-80: %u, ",
7843 				     pdev->stats.tx_comp_histogram.pkts_61_80);
7844 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "81-100: %u, ",
7845 				     pdev->stats.tx_comp_histogram.pkts_81_100);
7846 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "101-200: %u, ",
7847 				    pdev->stats.tx_comp_histogram.pkts_101_200);
7848 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "201+: %u",
7849 				   pdev->stats.tx_comp_histogram.pkts_201_plus);
7850 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "]");
7851 		DP_PRINT_STATS("%s", dp_stats_str);
7852 
7853 		DP_PRINT_STATS("Rx path statistics:");
7854 
7855 		DP_PRINT_STATS("delivered %llu msdus ( %llu bytes)",
7856 			       pdev->stats.rx.to_stack.num,
7857 			       pdev->stats.rx.to_stack.bytes);
7858 
7859 		dp_print_rx_ring_stats(pdev);
7860 
7861 		for (i = 0; i < CDP_MAX_LMACS; i++)
7862 			DP_PRINT_STATS("received on lmac[%d] %llu msdus (%llu bytes)",
7863 				       i, pdev->stats.rx.rx_lmac[i].num,
7864 				       pdev->stats.rx.rx_lmac[i].bytes);
7865 		DP_PRINT_STATS("intra-bss packets %llu msdus ( %llu bytes)",
7866 			       pdev->stats.rx.intra_bss.pkts.num,
7867 			       pdev->stats.rx.intra_bss.pkts.bytes);
7868 		DP_PRINT_STATS("intra-bss fails %llu msdus ( %llu bytes)",
7869 			       pdev->stats.rx.intra_bss.fail.num,
7870 			       pdev->stats.rx.intra_bss.fail.bytes);
7871 		DP_PRINT_STATS("intra-bss no mdns fwds %u msdus",
7872 			       pdev->stats.rx.intra_bss.mdns_no_fwd);
7873 
7874 		DP_PRINT_STATS("raw packets %llu msdus ( %llu bytes)",
7875 			       pdev->stats.rx.raw.num,
7876 			       pdev->stats.rx.raw.bytes);
7877 
7878 		DP_PRINT_STATS("Rx BAR frames:%d", soc->stats.rx.bar_frame);
7879 
7880 		dp_print_rx_err_stats(soc, pdev);
7881 
7882 		for (error_code = 0; error_code < HAL_RXDMA_ERR_MAX;
7883 				error_code++) {
7884 			if (!pdev->soc->stats.rx.err.rxdma_error[error_code])
7885 				continue;
7886 			DP_PRINT_STATS("Rxdma error number (%u): %u msdus",
7887 				       error_code,
7888 				       pdev->soc->stats.rx.err
7889 				       .rxdma_error[error_code]);
7890 		}
7891 
7892 		pos = 0;
7893 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "Rx/IRQ [Range:Pkts] [");
7894 
7895 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "1: %u, ",
7896 				     pdev->stats.rx_ind_histogram.pkts_1);
7897 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "2-20: %u, ",
7898 				     pdev->stats.rx_ind_histogram.pkts_2_20);
7899 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "21-40: %u, ",
7900 				     pdev->stats.rx_ind_histogram.pkts_21_40);
7901 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "41-60: %u, ",
7902 				     pdev->stats.rx_ind_histogram.pkts_41_60);
7903 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "61-80: %u, ",
7904 				     pdev->stats.rx_ind_histogram.pkts_61_80);
7905 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "81-100: %u, ",
7906 				     pdev->stats.rx_ind_histogram.pkts_81_100);
7907 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "101-200: %u, ",
7908 				    pdev->stats.rx_ind_histogram.pkts_101_200);
7909 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "201+: %u",
7910 				   pdev->stats.rx_ind_histogram.pkts_201_plus);
7911 		pos += qdf_scnprintf(buf + pos, buf_len - pos, "%s", "]");
7912 		DP_PRINT_STATS("%s", dp_stats_str);
7913 
7914 		DP_PRINT_STATS("%s: tso_enable: %u lro_enable: %u rx_hash: %u napi_enable: %u",
7915 			       __func__,
7916 			       pdev->soc->wlan_cfg_ctx
7917 			       ->tso_enabled,
7918 			       pdev->soc->wlan_cfg_ctx
7919 			       ->lro_enabled,
7920 			       pdev->soc->wlan_cfg_ctx
7921 			       ->rx_hash,
7922 			       pdev->soc->wlan_cfg_ctx
7923 			       ->napi_enabled);
7924 #ifdef QCA_LL_TX_FLOW_CONTROL_V2
7925 		DP_PRINT_STATS("%s: Tx flow stop queue: %u tx flow start queue offset: %u",
7926 			       __func__,
7927 			       pdev->soc->wlan_cfg_ctx
7928 			       ->tx_flow_stop_queue_threshold,
7929 			       pdev->soc->wlan_cfg_ctx
7930 			       ->tx_flow_start_queue_offset);
7931 #endif
7932 		dp_pdev_print_tx_rx_rates(pdev);
7933 	}
7934 }
7935 
7936 #ifndef WLAN_SOFTUMAC_SUPPORT
7937 /**
7938  * dp_peer_ctrl_frames_stats_get() - function to agreegate peer stats
7939  * Current scope is bar received count
7940  *
7941  * @soc : Datapath SOC handle
7942  * @peer: Datapath peer handle
7943  * @arg : argument to iterate function
7944  *
7945  * Return: void
7946  */
7947 static void
dp_peer_ctrl_frames_stats_get(struct dp_soc * soc,struct dp_peer * peer,void * arg)7948 dp_peer_ctrl_frames_stats_get(struct dp_soc *soc,
7949 			      struct dp_peer *peer,
7950 			      void *arg)
7951 {
7952 	uint32_t waitcnt;
7953 	struct dp_peer *tgt_peer = dp_get_tgt_peer_from_peer(peer);
7954 	struct dp_pdev *pdev = tgt_peer->vdev->pdev;
7955 
7956 	waitcnt = 0;
7957 	dp_peer_rxtid_stats(tgt_peer, dp_rx_bar_stats_cb, pdev);
7958 	while (!(qdf_atomic_read(&pdev->stats_cmd_complete)) &&
7959 	       waitcnt < 10) {
7960 		schedule_timeout_interruptible(
7961 				STATS_PROC_TIMEOUT);
7962 		waitcnt++;
7963 	}
7964 	qdf_atomic_set(&pdev->stats_cmd_complete, 0);
7965 }
7966 
7967 #else
7968 /**
7969  * dp_peer_ctrl_frames_stats_get() - function to agreegate peer stats
7970  * Current scope is bar received count
7971  *
7972  * @soc : Datapath SOC handle
7973  * @peer: Datapath peer handle
7974  * @arg : argument to iterate function
7975  *
7976  * Return: void
7977  */
7978 static void
dp_peer_ctrl_frames_stats_get(struct dp_soc * soc,struct dp_peer * peer,void * arg)7979 dp_peer_ctrl_frames_stats_get(struct dp_soc *soc,
7980 			      struct dp_peer *peer,
7981 			      void *arg)
7982 {
7983 }
7984 #endif /* WLAN_SOFTUMAC_SUPPORT */
7985 
7986 void
dp_print_pdev_tx_stats(struct dp_pdev * pdev)7987 dp_print_pdev_tx_stats(struct dp_pdev *pdev)
7988 {
7989 	uint8_t i = 0, index = 0;
7990 
7991 	DP_PRINT_STATS("PDEV Tx Stats:\n");
7992 	DP_PRINT_STATS("Received From Stack:");
7993 	DP_PRINT_STATS("	Packets = %llu",
7994 		       pdev->stats.tx_i.rcvd.num);
7995 	DP_PRINT_STATS("	Bytes = %llu",
7996 		       pdev->stats.tx_i.rcvd.bytes);
7997 	DP_PRINT_STATS("Received from Stack in FP:");
7998 	DP_PRINT_STATS("	Packets = %llu",
7999 		       pdev->stats.tx_i.rcvd_in_fast_xmit_flow);
8000 	DP_PRINT_STATS("Received from Stack per core:");
8001 	DP_PRINT_STATS("	Packets = %u %u %u %u",
8002 		       pdev->stats.tx_i.rcvd_per_core[0],
8003 		       pdev->stats.tx_i.rcvd_per_core[1],
8004 		       pdev->stats.tx_i.rcvd_per_core[2],
8005 		       pdev->stats.tx_i.rcvd_per_core[3]);
8006 	DP_PRINT_STATS("Processed:");
8007 	DP_PRINT_STATS("	Packets = %llu",
8008 		       pdev->stats.tx_i.processed.num);
8009 	DP_PRINT_STATS("	Bytes = %llu",
8010 		       pdev->stats.tx_i.processed.bytes);
8011 	DP_PRINT_STATS("Total Completions:");
8012 	DP_PRINT_STATS("	Packets = %llu",
8013 		       pdev->stats.tx.comp_pkt.num);
8014 	DP_PRINT_STATS("	Bytes = %llu",
8015 		       pdev->stats.tx.comp_pkt.bytes);
8016 	DP_PRINT_STATS("Successful Completions:");
8017 	DP_PRINT_STATS("	Packets = %llu",
8018 		       pdev->stats.tx.tx_success.num);
8019 	DP_PRINT_STATS("	Bytes = %llu",
8020 		       pdev->stats.tx.tx_success.bytes);
8021 	DP_PRINT_STATS("Dropped:");
8022 	DP_PRINT_STATS("	Total = %llu",
8023 		       pdev->stats.tx_i.dropped.dropped_pkt.num);
8024 	DP_PRINT_STATS("	Dma_map_error = %u",
8025 		       pdev->stats.tx_i.dropped.dma_error);
8026 	DP_PRINT_STATS("	Ring Full = %u",
8027 		       pdev->stats.tx_i.dropped.ring_full);
8028 	DP_PRINT_STATS("	Descriptor Not available = %llu",
8029 		       pdev->stats.tx_i.dropped.desc_na.num);
8030 	DP_PRINT_STATS("	HW enqueue failed= %u",
8031 		       pdev->stats.tx_i.dropped.enqueue_fail);
8032 	DP_PRINT_STATS("        Descriptor alloc fail = %llu",
8033 		       pdev->stats.tx_i.dropped.desc_na_exc_alloc_fail.num);
8034 	DP_PRINT_STATS("        Tx outstanding too many = %llu",
8035 		       pdev->stats.tx_i.dropped.desc_na_exc_outstand.num);
8036 	DP_PRINT_STATS("	Pkt dropped in vdev-id check= %u",
8037 		       pdev->stats.tx_i.dropped.fail_per_pkt_vdev_id_check);
8038 	DP_PRINT_STATS("	Resources Full = %u",
8039 		       pdev->stats.tx_i.dropped.res_full);
8040 	DP_PRINT_STATS("	Drop Ingress = %u",
8041 		       pdev->stats.tx_i.dropped.drop_ingress);
8042 	DP_PRINT_STATS("	invalid peer id in exception path = %u",
8043 		       pdev->stats.tx_i.dropped.invalid_peer_id_in_exc_path);
8044 	DP_PRINT_STATS("	Tx Mcast Drop = %u",
8045 		       pdev->stats.tx_i.dropped.tx_mcast_drop);
8046 	DP_PRINT_STATS("	PPE-DS FW2WBM Tx Drop = %u",
8047 		       pdev->stats.tx_i.dropped.fw2wbm_tx_drop);
8048 	DP_PRINT_STATS("Tx failed = %u",
8049 		       pdev->stats.tx.tx_failed);
8050 	DP_PRINT_STATS("	FW removed Pkts = %llu",
8051 		       pdev->stats.tx.dropped.fw_rem.num);
8052 	DP_PRINT_STATS("	FW removed bytes= %llu",
8053 		       pdev->stats.tx.dropped.fw_rem.bytes);
8054 	DP_PRINT_STATS("	FW removed transmitted = %u",
8055 		       pdev->stats.tx.dropped.fw_rem_tx);
8056 	DP_PRINT_STATS("	FW removed untransmitted = %u",
8057 		       pdev->stats.tx.dropped.fw_rem_notx);
8058 	DP_PRINT_STATS("	FW removed untransmitted fw_reason1 = %u",
8059 		       pdev->stats.tx.dropped.fw_reason1);
8060 	DP_PRINT_STATS("	FW removed untransmitted fw_reason2 = %u",
8061 		       pdev->stats.tx.dropped.fw_reason2);
8062 	DP_PRINT_STATS("	FW removed untransmitted fw_reason3 = %u",
8063 		       pdev->stats.tx.dropped.fw_reason3);
8064 	DP_PRINT_STATS("	FW removed untransmitted disable queue = %u",
8065 		       pdev->stats.tx.dropped.fw_rem_queue_disable);
8066 	DP_PRINT_STATS("	FW removed untransmitted no match = %u",
8067 		       pdev->stats.tx.dropped.fw_rem_no_match);
8068 	DP_PRINT_STATS("	Dropped due to HW threshold criteria = %u",
8069 		       pdev->stats.tx.dropped.drop_threshold);
8070 	DP_PRINT_STATS("	Link desc not available drop = %u",
8071 		       pdev->stats.tx.dropped.drop_link_desc_na);
8072 	DP_PRINT_STATS("	Drop bit set or invalid flow = %u",
8073 		       pdev->stats.tx.dropped.invalid_drop);
8074 	DP_PRINT_STATS("	MCAST vdev drop in HW = %u",
8075 		       pdev->stats.tx.dropped.mcast_vdev_drop);
8076 	DP_PRINT_STATS("	Dropped with invalid reason = %u",
8077 		       pdev->stats.tx.dropped.invalid_rr);
8078 	DP_PRINT_STATS("	Aged Out from msdu/mpdu queues = %u",
8079 		       pdev->stats.tx.dropped.age_out);
8080 	DP_PRINT_STATS("	headroom insufficient = %u",
8081 		       pdev->stats.tx_i.dropped.headroom_insufficient);
8082 	DP_PRINT_STATS("Multicast:");
8083 	DP_PRINT_STATS("	Packets: %llu",
8084 		       pdev->stats.tx.mcast.num);
8085 	DP_PRINT_STATS("	Bytes: %llu",
8086 		       pdev->stats.tx.mcast.bytes);
8087 	DP_PRINT_STATS("Scatter Gather:");
8088 	DP_PRINT_STATS("	Packets = %llu",
8089 		       pdev->stats.tx_i.sg.sg_pkt.num);
8090 	DP_PRINT_STATS("	Bytes = %llu",
8091 		       pdev->stats.tx_i.sg.sg_pkt.bytes);
8092 	DP_PRINT_STATS("	Dropped By Host = %llu",
8093 		       pdev->stats.tx_i.sg.dropped_host.num);
8094 	DP_PRINT_STATS("	Dropped By Target = %u",
8095 		       pdev->stats.tx_i.sg.dropped_target);
8096 	DP_PRINT_STATS("Mcast Enhancement:");
8097 	DP_PRINT_STATS("	Packets = %llu",
8098 		       pdev->stats.tx_i.mcast_en.mcast_pkt.num);
8099 	DP_PRINT_STATS("	Bytes = %llu",
8100 		       pdev->stats.tx_i.mcast_en.mcast_pkt.bytes);
8101 	DP_PRINT_STATS("	Dropped: Map Errors = %u",
8102 		       pdev->stats.tx_i.mcast_en.dropped_map_error);
8103 	DP_PRINT_STATS("	Dropped: Self Mac = %u",
8104 		       pdev->stats.tx_i.mcast_en.dropped_self_mac);
8105 	DP_PRINT_STATS("	Dropped: Send Fail = %u",
8106 		       pdev->stats.tx_i.mcast_en.dropped_send_fail);
8107 	DP_PRINT_STATS("	Unicast sent = %u",
8108 		       pdev->stats.tx_i.mcast_en.ucast);
8109 
8110 	DP_PRINT_STATS("EAPOL Packets dropped:");
8111 	DP_PRINT_STATS("        Dropped: TX desc errors = %u",
8112 		       pdev->stats.eap_drop_stats.tx_desc_err);
8113 	DP_PRINT_STATS("        Dropped: Tx HAL ring access errors = %u",
8114 		       pdev->stats.eap_drop_stats.tx_hal_ring_access_err);
8115 	DP_PRINT_STATS("        Dropped: TX DMA map errors = %u",
8116 		       pdev->stats.eap_drop_stats.tx_dma_map_err);
8117 	DP_PRINT_STATS("        Dropped: Tx HW enqueue errors = %u",
8118 		       pdev->stats.eap_drop_stats.tx_hw_enqueue);
8119 	DP_PRINT_STATS("        Dropped: TX SW enqueue errors= %u",
8120 		       pdev->stats.eap_drop_stats.tx_sw_enqueue);
8121 
8122 	DP_PRINT_STATS("IGMP Mcast Enhancement:");
8123 	DP_PRINT_STATS("	IGMP packets received = %u",
8124 		       pdev->stats.tx_i.igmp_mcast_en.igmp_rcvd);
8125 	DP_PRINT_STATS("	Converted to uncast = %u",
8126 		       pdev->stats.tx_i.igmp_mcast_en.igmp_ucast_converted);
8127 	DP_PRINT_STATS("Raw:");
8128 	DP_PRINT_STATS("	Packets = %llu",
8129 		       pdev->stats.tx_i.raw.raw_pkt.num);
8130 	DP_PRINT_STATS("	Bytes = %llu",
8131 		       pdev->stats.tx_i.raw.raw_pkt.bytes);
8132 	DP_PRINT_STATS("	DMA map error = %u",
8133 		       pdev->stats.tx_i.raw.dma_map_error);
8134 	DP_PRINT_STATS("        RAW pkt type[!data] error = %u",
8135 		       pdev->stats.tx_i.raw.invalid_raw_pkt_datatype);
8136 	DP_PRINT_STATS("        Frags count overflow  error = %u",
8137 		       pdev->stats.tx_i.raw.num_frags_overflow_err);
8138 	DP_PRINT_STATS("Reinjected:");
8139 	DP_PRINT_STATS("	Packets = %llu",
8140 		       pdev->stats.tx_i.reinject_pkts.num);
8141 	DP_PRINT_STATS("	Bytes = %llu\n",
8142 		       pdev->stats.tx_i.reinject_pkts.bytes);
8143 	DP_PRINT_STATS("Inspected:");
8144 	DP_PRINT_STATS("	Packets = %llu",
8145 		       pdev->stats.tx_i.inspect_pkts.num);
8146 	DP_PRINT_STATS("	Bytes = %llu",
8147 		       pdev->stats.tx_i.inspect_pkts.bytes);
8148 	DP_PRINT_STATS("Nawds Multicast:");
8149 	DP_PRINT_STATS("	Packets = %llu",
8150 		       pdev->stats.tx_i.nawds_mcast.num);
8151 	DP_PRINT_STATS("	Bytes = %llu",
8152 		       pdev->stats.tx_i.nawds_mcast.bytes);
8153 	DP_PRINT_STATS("CCE Classified:");
8154 	DP_PRINT_STATS("	CCE Classified Packets: %u",
8155 		       pdev->stats.tx_i.cce_classified);
8156 	DP_PRINT_STATS("	RAW CCE Classified Packets: %u",
8157 		       pdev->stats.tx_i.cce_classified_raw);
8158 	DP_PRINT_STATS("Mesh stats:");
8159 	DP_PRINT_STATS("	frames to firmware: %u",
8160 		       pdev->stats.tx_i.mesh.exception_fw);
8161 	DP_PRINT_STATS("	completions from fw: %u",
8162 		       pdev->stats.tx_i.mesh.completion_fw);
8163 	DP_PRINT_STATS("PPDU stats counter");
8164 	for (index = 0; index < CDP_PPDU_STATS_MAX_TAG; index++) {
8165 		DP_PRINT_STATS("	Tag[%d] = %llu", index,
8166 			       pdev->stats.ppdu_stats_counter[index]);
8167 	}
8168 	DP_PRINT_STATS("BA not received for delayed_ba: %u",
8169 		       pdev->stats.cdp_delayed_ba_not_recev);
8170 
8171 	dp_monitor_print_tx_stats(pdev);
8172 
8173 	DP_PRINT_STATS("tx_ppdu_proc: %llu",
8174 		       pdev->stats.tx_ppdu_proc);
8175 	DP_PRINT_STATS("ack ba comes twice: %llu",
8176 		       pdev->stats.ack_ba_comes_twice);
8177 	DP_PRINT_STATS("ppdu dropped because of incomplete tlv: %llu",
8178 		       pdev->stats.ppdu_drop);
8179 	DP_PRINT_STATS("ppdu dropped because of wrap around: %llu",
8180 		       pdev->stats.ppdu_wrap_drop);
8181 
8182 	for (i = 0; i < CDP_WDI_NUM_EVENTS; i++) {
8183 		if (pdev->stats.wdi_event[i])
8184 			DP_PRINT_STATS("Wdi msgs received for event ID[%d]:%d",
8185 				       i, pdev->stats.wdi_event[i]);
8186 	}
8187 
8188 	dp_monitor_print_pdev_tx_capture_stats(pdev);
8189 }
8190 
8191 #if defined(WLAN_FEATURE_11BE_MLO) && defined(WLAN_MCAST_MLO)
dp_print_vdev_mlo_mcast_tx_stats(struct dp_vdev * vdev)8192 void dp_print_vdev_mlo_mcast_tx_stats(struct dp_vdev *vdev)
8193 {
8194 	uint8_t idx;
8195 	uint32_t send_pkt_count = 0;
8196 	uint32_t fail_pkt_count = 0;
8197 
8198 	for (idx = 0; idx < DP_INGRESS_STATS_MAX_SIZE; idx++) {
8199 		send_pkt_count +=
8200 			vdev->stats.tx_i[idx].mlo_mcast.send_pkt_count;
8201 		fail_pkt_count +=
8202 			vdev->stats.tx_i[idx].mlo_mcast.fail_pkt_count;
8203 	}
8204 	DP_PRINT_STATS("MLO MCAST TX stats:");
8205 	DP_PRINT_STATS("	send packet count = %u", send_pkt_count);
8206 	DP_PRINT_STATS("	failed packet count = %u", fail_pkt_count);
8207 }
8208 #endif
8209 
8210 #ifdef WLAN_SUPPORT_RX_FLOW_TAG
dp_rx_basic_fst_stats(struct dp_pdev * pdev)8211 static inline void dp_rx_basic_fst_stats(struct dp_pdev *pdev)
8212 {
8213 	DP_PRINT_STATS("\tNo of IPv4 Flow entries inserted = %d",
8214 		       qdf_atomic_read(&pdev->soc->ipv4_fse_cnt));
8215 	DP_PRINT_STATS("\tNo of IPv6 Flow entries inserted = %d",
8216 		       qdf_atomic_read(&pdev->soc->ipv6_fse_cnt));
8217 }
8218 #else
dp_rx_basic_fst_stats(struct dp_pdev * pdev)8219 static inline void dp_rx_basic_fst_stats(struct dp_pdev *pdev)
8220 {
8221 }
8222 #endif
8223 
8224 void
dp_print_pdev_rx_stats(struct dp_pdev * pdev)8225 dp_print_pdev_rx_stats(struct dp_pdev *pdev)
8226 {
8227 	uint8_t i;
8228 
8229 	DP_PRINT_STATS("PDEV Rx Stats:\n");
8230 	DP_PRINT_STATS("Received From HW (Per Rx Ring):");
8231 	DP_PRINT_STATS("	Packets = %llu %llu %llu %llu",
8232 		       pdev->stats.rx.rcvd_reo[0].num,
8233 		       pdev->stats.rx.rcvd_reo[1].num,
8234 		       pdev->stats.rx.rcvd_reo[2].num,
8235 		       pdev->stats.rx.rcvd_reo[3].num);
8236 	DP_PRINT_STATS("	Bytes = %llu %llu %llu %llu",
8237 		       pdev->stats.rx.rcvd_reo[0].bytes,
8238 		       pdev->stats.rx.rcvd_reo[1].bytes,
8239 		       pdev->stats.rx.rcvd_reo[2].bytes,
8240 		       pdev->stats.rx.rcvd_reo[3].bytes);
8241 	for (i = 0; i < CDP_MAX_LMACS; i++)
8242 		DP_PRINT_STATS("Packets Received on lmac[%d] = %llu (%llu)",
8243 			       i, pdev->stats.rx.rx_lmac[i].num,
8244 			       pdev->stats.rx.rx_lmac[i].bytes);
8245 	DP_PRINT_STATS("Replenished:");
8246 	DP_PRINT_STATS("	Packets = %llu",
8247 		       pdev->stats.replenish.pkts.num);
8248 	DP_PRINT_STATS("	Buffers Added To Freelist = %u",
8249 		       pdev->stats.buf_freelist);
8250 	DP_PRINT_STATS("	Low threshold intr = %d",
8251 		       pdev->stats.replenish.low_thresh_intrs);
8252 	DP_PRINT_STATS("Dropped:");
8253 	DP_PRINT_STATS("	msdu_not_done = %u",
8254 		       pdev->stats.dropped.msdu_not_done);
8255 	DP_PRINT_STATS("        wifi parse = %u",
8256 		       pdev->stats.dropped.wifi_parse);
8257 	DP_PRINT_STATS("        mon_rx_drop = %u",
8258 		       pdev->stats.dropped.mon_rx_drop);
8259 	DP_PRINT_STATS("        mon_radiotap_update_err = %u",
8260 		       pdev->stats.dropped.mon_radiotap_update_err);
8261 	DP_PRINT_STATS("        mon_ver_err = %u",
8262 		       pdev->stats.dropped.mon_ver_err);
8263 	DP_PRINT_STATS("        mec_drop = %llu",
8264 		       pdev->stats.rx.mec_drop.num);
8265 	DP_PRINT_STATS("	Bytes = %llu",
8266 		       pdev->stats.rx.mec_drop.bytes);
8267 	DP_PRINT_STATS("	peer_unauth_drop = %u",
8268 		       pdev->stats.rx.peer_unauth_rx_pkt_drop);
8269 	DP_PRINT_STATS("	policy_check_drop = %u",
8270 		       pdev->stats.rx.policy_check_drop);
8271 	DP_PRINT_STATS("Sent To Stack:");
8272 	DP_PRINT_STATS("	Packets = %llu",
8273 		       pdev->stats.rx.to_stack.num);
8274 	DP_PRINT_STATS("	Bytes = %llu",
8275 		       pdev->stats.rx.to_stack.bytes);
8276 	DP_PRINT_STATS("        vlan_tag_stp_cnt = %u",
8277 		       pdev->stats.vlan_tag_stp_cnt);
8278 	DP_PRINT_STATS("Multicast/Broadcast:");
8279 	DP_PRINT_STATS("	Packets = %llu",
8280 		       pdev->stats.rx.multicast.num);
8281 	DP_PRINT_STATS("	Bytes = %llu",
8282 		       pdev->stats.rx.multicast.bytes);
8283 	DP_PRINT_STATS("Errors:");
8284 	DP_PRINT_STATS("	Rxdma Ring Un-inititalized = %u",
8285 		       pdev->stats.replenish.rxdma_err);
8286 	DP_PRINT_STATS("	Desc Alloc Failed: = %u",
8287 		       pdev->stats.err.desc_alloc_fail);
8288 	DP_PRINT_STATS("        Low threshold Desc Alloc Failed: = %u",
8289 		       pdev->stats.err.desc_lt_alloc_fail);
8290 	DP_PRINT_STATS("	IP checksum error = %u",
8291 		       pdev->stats.err.ip_csum_err);
8292 	DP_PRINT_STATS("	TCP/UDP checksum error = %u",
8293 		       pdev->stats.err.tcp_udp_csum_err);
8294 	DP_PRINT_STATS("	Failed frag alloc = %u",
8295 		       pdev->stats.replenish.frag_alloc_fail);
8296 
8297 	dp_pdev_iterate_peer_lock_safe(pdev, dp_peer_ctrl_frames_stats_get,
8298 				       NULL, DP_MOD_ID_GENERIC_STATS);
8299 
8300 	/* Get bar_recv_cnt */
8301 	DP_PRINT_STATS("BAR Received Count: = %u",
8302 		       pdev->stats.rx.bar_recv_cnt);
8303 
8304 	DP_PRINT_STATS("RX Buffer Pool Stats:\n");
8305 	DP_PRINT_STATS("\tBuffers consumed during refill = %llu",
8306 		       pdev->stats.rx_buffer_pool.num_bufs_consumed);
8307 	DP_PRINT_STATS("\tSuccessful allocations during refill = %llu",
8308 		       pdev->stats.rx_buffer_pool.num_bufs_alloc_success);
8309 	DP_PRINT_STATS("\tAllocations from the pool during replenish = %llu",
8310 		       pdev->stats.rx_buffer_pool.num_pool_bufs_replenish);
8311 
8312 	DP_PRINT_STATS("Invalid MSDU count = %u",
8313 		       pdev->stats.invalid_msdu_cnt);
8314 
8315 	dp_rx_basic_fst_stats(pdev);
8316 }
8317 
8318 #ifdef WLAN_SUPPORT_PPEDS
dp_print_tx_ppeds_stats(struct dp_soc * soc)8319 void dp_print_tx_ppeds_stats(struct dp_soc *soc)
8320 {
8321 	if (soc->arch_ops.dp_tx_ppeds_inuse_desc)
8322 		soc->arch_ops.dp_tx_ppeds_inuse_desc(soc);
8323 
8324 	DP_PRINT_STATS("PPE-DS Tx desc fw2wbm_tx_drop %u",
8325 		       soc->stats.tx.fw2wbm_tx_drop);
8326 
8327 	if (soc->arch_ops.dp_txrx_ppeds_rings_stats)
8328 		soc->arch_ops.dp_txrx_ppeds_rings_stats(soc);
8329 }
8330 #else
dp_print_tx_ppeds_stats(struct dp_soc * soc)8331 void dp_print_tx_ppeds_stats(struct dp_soc *soc)
8332 {
8333 }
8334 #endif
8335 
8336 #ifdef QCA_SUPPORT_DP_GLOBAL_CTX
dp_print_global_desc_count(void)8337 void dp_print_global_desc_count(void)
8338 {
8339 	struct dp_global_context *dp_global;
8340 
8341 	dp_global = wlan_objmgr_get_global_ctx();
8342 
8343 	DP_PRINT_STATS("Global Tx Descriptors in use = %u",
8344 		       dp_tx_get_global_desc_in_use(dp_global));
8345 }
8346 #endif
8347 
8348 #ifdef WLAN_DP_SRNG_USAGE_WM_TRACKING
8349 #define DP_SRNG_HIGH_WM_STATS_STRING_LEN 512
dp_dump_srng_high_wm_stats(struct dp_soc * soc,uint64_t srng_mask)8350 void dp_dump_srng_high_wm_stats(struct dp_soc *soc, uint64_t srng_mask)
8351 {
8352 	char *buf;
8353 	int ring, pos, buf_len;
8354 	char srng_high_wm_str[DP_SRNG_HIGH_WM_STATS_STRING_LEN] = {'\0'};
8355 
8356 	if (!srng_mask)
8357 		return;
8358 
8359 	buf = srng_high_wm_str;
8360 	buf_len = DP_SRNG_HIGH_WM_STATS_STRING_LEN;
8361 
8362 	dp_info("%8s %7s %12s %10s %10s %10s %10s %10s %10s",
8363 		"ring_id", "high_wm", "time", "<50", "50-60", "60-70",
8364 		"70-80", "80-90", "90-100");
8365 
8366 	if (srng_mask & DP_SRNG_WM_MASK_REO_DST) {
8367 		for (ring = 0; ring < soc->num_reo_dest_rings; ring++) {
8368 			pos = 0;
8369 			pos += hal_dump_srng_high_wm_stats(soc->hal_soc,
8370 					    soc->reo_dest_ring[ring].hal_srng,
8371 					    buf, buf_len, pos);
8372 			dp_info("%s", srng_high_wm_str);
8373 		}
8374 	}
8375 
8376 	if (srng_mask & DP_SRNG_WM_MASK_TX_COMP) {
8377 		for (ring = 0; ring < soc->num_tcl_data_rings; ring++) {
8378 			if (wlan_cfg_get_wbm_ring_num_for_index(
8379 						soc->wlan_cfg_ctx, ring) ==
8380 			    INVALID_WBM_RING_NUM)
8381 				continue;
8382 
8383 			pos = 0;
8384 			pos += hal_dump_srng_high_wm_stats(soc->hal_soc,
8385 					soc->tx_comp_ring[ring].hal_srng,
8386 					buf, buf_len, pos);
8387 			dp_info("%s", srng_high_wm_str);
8388 		}
8389 	}
8390 }
8391 #endif
8392 
8393 #ifdef GLOBAL_ASSERT_AVOIDANCE
dp_print_assert_war_stats(struct dp_soc * soc)8394 static void dp_print_assert_war_stats(struct dp_soc *soc)
8395 {
8396 	DP_PRINT_STATS("Rx WAR stats: [%d] [%d] [%d] [%d]",
8397 		       soc->stats.rx.err.rx_desc_null,
8398 		       soc->stats.rx.err.wbm_err_buf_rel_type,
8399 		       soc->stats.rx.err.reo_err_rx_desc_null,
8400 		       soc->stats.rx.err.intra_bss_bad_chipid);
8401 }
8402 #else
dp_print_assert_war_stats(struct dp_soc * soc)8403 static void dp_print_assert_war_stats(struct dp_soc *soc)
8404 {
8405 }
8406 #endif
8407 void
dp_print_soc_rx_stats(struct dp_soc * soc)8408 dp_print_soc_rx_stats(struct dp_soc *soc)
8409 {
8410 	uint32_t i;
8411 	char reo_error[DP_REO_ERR_LENGTH];
8412 	char rxdma_error[DP_RXDMA_ERR_LENGTH];
8413 	uint8_t index = 0;
8414 
8415 	DP_PRINT_STATS("No of AST Entries = %d", soc->num_ast_entries);
8416 	DP_PRINT_STATS("SOC Rx Stats:\n");
8417 	DP_PRINT_STATS("Fast recycled packets: %llu",
8418 		       soc->stats.rx.fast_recycled);
8419 	DP_PRINT_STATS("Fragmented packets: %u",
8420 		       soc->stats.rx.rx_frags);
8421 	DP_PRINT_STATS("Reo reinjected packets: %u",
8422 		       soc->stats.rx.reo_reinject);
8423 	DP_PRINT_STATS("Errors:\n");
8424 	DP_PRINT_STATS("Rx Decrypt Errors = %d",
8425 		       (soc->stats.rx.err.rxdma_error[HAL_RXDMA_ERR_DECRYPT] +
8426 		       soc->stats.rx.err.rxdma_error[HAL_RXDMA_ERR_TKIP_MIC]));
8427 	DP_PRINT_STATS("Invalid RBM = %d",
8428 		       soc->stats.rx.err.invalid_rbm);
8429 	DP_PRINT_STATS("Invalid Vdev = %d",
8430 		       soc->stats.rx.err.invalid_vdev);
8431 	DP_PRINT_STATS("Invalid sa_idx or da_idx = %d",
8432 		       soc->stats.rx.err.invalid_sa_da_idx);
8433 	DP_PRINT_STATS("Defrag peer uninit = %d",
8434 		       soc->stats.rx.err.defrag_peer_uninit);
8435 	DP_PRINT_STATS("Pkts delivered no peer = %d",
8436 		       soc->stats.rx.err.pkt_delivered_no_peer);
8437 	DP_PRINT_STATS("Invalid Pdev = %d",
8438 		       soc->stats.rx.err.invalid_pdev);
8439 	DP_PRINT_STATS("Invalid Peer = %llu",
8440 		       soc->stats.rx.err.rx_invalid_peer.num);
8441 	DP_PRINT_STATS("HAL Ring Access Fail = %d",
8442 		       soc->stats.rx.err.hal_ring_access_fail);
8443 	DP_PRINT_STATS("HAL Ring Access Full Fail = %d",
8444 		       soc->stats.rx.err.hal_ring_access_full_fail);
8445 	DP_PRINT_STATS("MSDU Done failures = %d",
8446 		       soc->stats.rx.err.msdu_done_fail);
8447 	DP_PRINT_STATS("RX frags: %d", soc->stats.rx.rx_frags);
8448 	DP_PRINT_STATS("RX frag wait: %d", soc->stats.rx.rx_frag_wait);
8449 	DP_PRINT_STATS("RX frag err: %d", soc->stats.rx.rx_frag_err);
8450 	DP_PRINT_STATS("RX frag OOR: %d", soc->stats.rx.rx_frag_oor);
8451 
8452 	DP_PRINT_STATS("RX HP out_of_sync: %d", soc->stats.rx.hp_oos2);
8453 	DP_PRINT_STATS("RX Ring Near Full: %d", soc->stats.rx.near_full);
8454 
8455 	DP_PRINT_STATS("RX Reap Loop Pkt Limit Hit: %d",
8456 		       soc->stats.rx.reap_loop_pkt_limit_hit);
8457 	DP_PRINT_STATS("RX DESC invalid magic: %u",
8458 		       soc->stats.rx.err.rx_desc_invalid_magic);
8459 	DP_PRINT_STATS("RX DUP DESC: %d",
8460 		       soc->stats.rx.err.hal_reo_dest_dup);
8461 	DP_PRINT_STATS("RX REL DUP DESC: %d",
8462 		       soc->stats.rx.err.hal_wbm_rel_dup);
8463 
8464 	DP_PRINT_STATS("RXDMA ERR DUP DESC: %d",
8465 		       soc->stats.rx.err.hal_rxdma_err_dup);
8466 
8467 	DP_PRINT_STATS("RX scatter msdu: %d",
8468 		       soc->stats.rx.err.scatter_msdu);
8469 
8470 	DP_PRINT_STATS("RX invalid cookie: %d",
8471 		       soc->stats.rx.err.invalid_cookie);
8472 
8473 	DP_PRINT_STATS("RX stale cookie: %d",
8474 		       soc->stats.rx.err.stale_cookie);
8475 
8476 	DP_PRINT_STATS("RX wait completed msdu break: %d",
8477 		       soc->stats.rx.msdu_scatter_wait_break);
8478 
8479 	DP_PRINT_STATS("2k jump delba sent: %d",
8480 		       soc->stats.rx.err.rx_2k_jump_delba_sent);
8481 
8482 	DP_PRINT_STATS("2k jump msdu to stack: %d",
8483 		       soc->stats.rx.err.rx_2k_jump_to_stack);
8484 
8485 	DP_PRINT_STATS("2k jump msdu drop: %d",
8486 		       soc->stats.rx.err.rx_2k_jump_drop);
8487 
8488 	DP_PRINT_STATS("REO err oor msdu to stack %d",
8489 		       soc->stats.rx.err.reo_err_oor_to_stack);
8490 
8491 	DP_PRINT_STATS("REO err oor msdu drop: %d",
8492 		       soc->stats.rx.err.reo_err_oor_drop);
8493 
8494 	DP_PRINT_STATS("Rx err msdu rejected: %d",
8495 		       soc->stats.rx.err.rejected);
8496 
8497 	DP_PRINT_STATS("Rx stale link desc cookie: %d",
8498 		       soc->stats.rx.err.invalid_link_cookie);
8499 
8500 	DP_PRINT_STATS("Rx nbuf sanity fail: %d",
8501 		       soc->stats.rx.err.nbuf_sanity_fail);
8502 
8503 	DP_PRINT_STATS("Rx err msdu continuation err: %d",
8504 		       soc->stats.rx.err.msdu_continuation_err);
8505 
8506 	DP_PRINT_STATS("ssn update count: %d",
8507 		       soc->stats.rx.err.ssn_update_count);
8508 
8509 	DP_PRINT_STATS("bar handle update fail count: %d",
8510 		       soc->stats.rx.err.bar_handle_fail_count);
8511 
8512 	DP_PRINT_STATS("PN-in-Dest error frame pn-check fail: %d",
8513 		       soc->stats.rx.err.pn_in_dest_check_fail);
8514 
8515 	for (i = 0; i < HAL_RXDMA_ERR_MAX; i++) {
8516 		index += qdf_snprint(&rxdma_error[index],
8517 				DP_RXDMA_ERR_LENGTH - index,
8518 				" %d", soc->stats.rx.err.rxdma_error[i]);
8519 	}
8520 	DP_PRINT_STATS("RXDMA Error (0-31):%s", rxdma_error);
8521 
8522 	index = 0;
8523 	for (i = 0; i < HAL_REO_ERR_MAX; i++) {
8524 		index += qdf_snprint(&reo_error[index],
8525 				DP_REO_ERR_LENGTH - index,
8526 				" %d", soc->stats.rx.err.reo_error[i]);
8527 	}
8528 	DP_PRINT_STATS("REO Error(0-14):%s", reo_error);
8529 	DP_PRINT_STATS("REO CMD SEND FAIL: %d",
8530 		       soc->stats.rx.err.reo_cmd_send_fail);
8531 
8532 	DP_PRINT_STATS("Rx BAR frames:%d", soc->stats.rx.bar_frame);
8533 	DP_PRINT_STATS("Rxdma2rel route drop:%d",
8534 		       soc->stats.rx.rxdma2rel_route_drop);
8535 	DP_PRINT_STATS("Reo2rel route drop:%d",
8536 		       soc->stats.rx.reo2rel_route_drop);
8537 	DP_PRINT_STATS("Rx Flush count:%d", soc->stats.rx.err.rx_flush_count);
8538 	DP_PRINT_STATS("RX HW stats request count:%d",
8539 		       soc->stats.rx.rx_hw_stats_requested);
8540 	DP_PRINT_STATS("RX HW stats request timeout:%d",
8541 		       soc->stats.rx.rx_hw_stats_timeout);
8542 	DP_PRINT_STATS("Rx invalid TID count:%d",
8543 		       soc->stats.rx.err.rx_invalid_tid_err);
8544 	DP_PRINT_STATS("Rx Defrag Address1 Invalid:%d",
8545 		       soc->stats.rx.err.defrag_ad1_invalid);
8546 	DP_PRINT_STATS("Rx decrypt error frame for valid peer:%d",
8547 		       soc->stats.rx.err.decrypt_err_drop);
8548 	dp_print_assert_war_stats(soc);
8549 }
8550 
8551 #ifdef FEATURE_TSO_STATS
dp_print_tso_stats(struct dp_soc * soc,enum qdf_stats_verbosity_level level)8552 void dp_print_tso_stats(struct dp_soc *soc,
8553 			enum qdf_stats_verbosity_level level)
8554 {
8555 	uint8_t loop_pdev;
8556 	uint32_t id;
8557 	struct dp_pdev *pdev;
8558 
8559 	for (loop_pdev = 0; loop_pdev < soc->pdev_count; loop_pdev++) {
8560 		pdev = soc->pdev_list[loop_pdev];
8561 		DP_PRINT_STATS("TSO Statistics\n");
8562 		DP_PRINT_STATS(
8563 			  "From stack: %llu | Successful completions: %llu | TSO Packets: %llu | TSO Completions: %d",
8564 			  pdev->stats.tx_i.rcvd.num,
8565 			  pdev->stats.tx.tx_success.num,
8566 			  pdev->stats.tso_stats.num_tso_pkts.num,
8567 			  pdev->stats.tso_stats.tso_comp);
8568 
8569 		for (id = 0; id < CDP_MAX_TSO_PACKETS; id++) {
8570 			/* TSO LEVEL 1 - PACKET INFO */
8571 			DP_PRINT_STATS(
8572 				  "Packet_Id:[%u]: Packet Length %zu | No. of segments: %u",
8573 				  id,
8574 				  pdev->stats.tso_stats.tso_info
8575 				  .tso_packet_info[id].tso_packet_len,
8576 				  pdev->stats.tso_stats.tso_info
8577 				  .tso_packet_info[id].num_seg);
8578 			/* TSO LEVEL 2 */
8579 			if (level == QDF_STATS_VERBOSITY_LEVEL_HIGH)
8580 				dp_print_tso_seg_stats(pdev, id);
8581 		}
8582 
8583 		DP_PRINT_STATS(
8584 			  "TSO Histogram: Single: %llu | 2-5 segs: %llu | 6-10: %llu segs | 11-15 segs: %llu | 16-20 segs: %llu | 20+ segs: %llu",
8585 			  pdev->stats.tso_stats.seg_histogram.segs_1,
8586 			  pdev->stats.tso_stats.seg_histogram.segs_2_5,
8587 			  pdev->stats.tso_stats.seg_histogram.segs_6_10,
8588 			  pdev->stats.tso_stats.seg_histogram.segs_11_15,
8589 			  pdev->stats.tso_stats.seg_histogram.segs_16_20,
8590 			  pdev->stats.tso_stats.seg_histogram.segs_20_plus);
8591 	}
8592 }
8593 
dp_stats_tso_segment_histogram_update(struct dp_pdev * pdev,uint8_t _p_cntrs)8594 void dp_stats_tso_segment_histogram_update(struct dp_pdev *pdev,
8595 					   uint8_t _p_cntrs)
8596 {
8597 	if (_p_cntrs == 1) {
8598 		DP_STATS_INC(pdev,
8599 			     tso_stats.seg_histogram.segs_1, 1);
8600 	} else if (_p_cntrs >= 2 && _p_cntrs <= 5) {
8601 		DP_STATS_INC(pdev,
8602 			     tso_stats.seg_histogram.segs_2_5, 1);
8603 	} else if (_p_cntrs > 5 && _p_cntrs <= 10) {
8604 		DP_STATS_INC(pdev,
8605 			     tso_stats.seg_histogram.segs_6_10, 1);
8606 	} else if (_p_cntrs > 10 && _p_cntrs <= 15) {
8607 		DP_STATS_INC(pdev,
8608 			     tso_stats.seg_histogram.segs_11_15, 1);
8609 	} else if (_p_cntrs > 15 && _p_cntrs <= 20) {
8610 		DP_STATS_INC(pdev,
8611 			     tso_stats.seg_histogram.segs_16_20, 1);
8612 	} else if (_p_cntrs > 20) {
8613 		DP_STATS_INC(pdev,
8614 			     tso_stats.seg_histogram.segs_20_plus, 1);
8615 	}
8616 }
8617 
dp_tso_segment_update(struct dp_pdev * pdev,uint32_t stats_idx,uint8_t idx,struct qdf_tso_seg_t seg)8618 void dp_tso_segment_update(struct dp_pdev *pdev,
8619 			   uint32_t stats_idx,
8620 			   uint8_t idx,
8621 			   struct qdf_tso_seg_t seg)
8622 {
8623 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8624 		     .tso_seg[idx].num_frags,
8625 		     seg.num_frags);
8626 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8627 		     .tso_seg[idx].total_len,
8628 		     seg.total_len);
8629 
8630 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8631 		     .tso_seg[idx].tso_flags.tso_enable,
8632 		     seg.tso_flags.tso_enable);
8633 
8634 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8635 		     .tso_seg[idx].tso_flags.fin,
8636 		     seg.tso_flags.fin);
8637 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8638 		     .tso_seg[idx].tso_flags.syn,
8639 		     seg.tso_flags.syn);
8640 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8641 		     .tso_seg[idx].tso_flags.rst,
8642 		     seg.tso_flags.rst);
8643 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8644 		     .tso_seg[idx].tso_flags.psh,
8645 		     seg.tso_flags.psh);
8646 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8647 		     .tso_seg[idx].tso_flags.ack,
8648 		     seg.tso_flags.ack);
8649 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8650 		     .tso_seg[idx].tso_flags.urg,
8651 		     seg.tso_flags.urg);
8652 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8653 		     .tso_seg[idx].tso_flags.ece,
8654 		     seg.tso_flags.ece);
8655 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8656 		     .tso_seg[idx].tso_flags.cwr,
8657 		     seg.tso_flags.cwr);
8658 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8659 		     .tso_seg[idx].tso_flags.ns,
8660 		     seg.tso_flags.ns);
8661 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8662 		     .tso_seg[idx].tso_flags.tcp_seq_num,
8663 		     seg.tso_flags.tcp_seq_num);
8664 	DP_STATS_UPD(pdev, tso_stats.tso_info.tso_packet_info[stats_idx]
8665 		     .tso_seg[idx].tso_flags.ip_id,
8666 		     seg.tso_flags.ip_id);
8667 }
8668 
dp_tso_packet_update(struct dp_pdev * pdev,uint32_t stats_idx,qdf_nbuf_t msdu,uint16_t num_segs)8669 void dp_tso_packet_update(struct dp_pdev *pdev, uint32_t stats_idx,
8670 			  qdf_nbuf_t msdu, uint16_t num_segs)
8671 {
8672 	DP_STATS_UPD(pdev,
8673 		     tso_stats.tso_info.tso_packet_info[stats_idx]
8674 		     .num_seg,
8675 		     num_segs);
8676 
8677 	DP_STATS_UPD(pdev,
8678 		     tso_stats.tso_info.tso_packet_info[stats_idx]
8679 		     .tso_packet_len,
8680 		     qdf_nbuf_get_tcp_payload_len(msdu));
8681 }
8682 
dp_tso_segment_stats_update(struct dp_pdev * pdev,struct qdf_tso_seg_elem_t * stats_seg,uint32_t stats_idx)8683 void dp_tso_segment_stats_update(struct dp_pdev *pdev,
8684 				 struct qdf_tso_seg_elem_t *stats_seg,
8685 				 uint32_t stats_idx)
8686 {
8687 	uint8_t tso_seg_idx = 0;
8688 
8689 	while (stats_seg  && (tso_seg_idx < CDP_MAX_TSO_SEGMENTS)) {
8690 		dp_tso_segment_update(pdev, stats_idx,
8691 				      tso_seg_idx,
8692 				      stats_seg->seg);
8693 		++tso_seg_idx;
8694 		stats_seg = stats_seg->next;
8695 	}
8696 }
8697 
dp_txrx_clear_tso_stats(struct dp_soc * soc)8698 void dp_txrx_clear_tso_stats(struct dp_soc *soc)
8699 {
8700 	uint8_t loop_pdev;
8701 	struct dp_pdev *pdev;
8702 
8703 	for (loop_pdev = 0; loop_pdev < soc->pdev_count; loop_pdev++) {
8704 		pdev = soc->pdev_list[loop_pdev];
8705 		dp_init_tso_stats(pdev);
8706 	}
8707 }
8708 #endif /* FEATURE_TSO_STATS */
8709 
dp_txrx_get_peer_per_pkt_stats_param(struct dp_peer * peer,enum cdp_peer_stats_type type,cdp_peer_stats_param_t * buf)8710 QDF_STATUS dp_txrx_get_peer_per_pkt_stats_param(struct dp_peer *peer,
8711 						enum cdp_peer_stats_type type,
8712 						cdp_peer_stats_param_t *buf)
8713 {
8714 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
8715 	struct dp_peer *tgt_peer;
8716 	struct dp_txrx_peer *txrx_peer;
8717 	struct dp_peer_per_pkt_stats *peer_stats;
8718 	uint8_t link_id = 0;
8719 	uint8_t idx = 0;
8720 	uint8_t stats_arr_size;
8721 	struct cdp_pkt_info pkt_info = {0};
8722 	struct dp_soc *soc = peer->vdev->pdev->soc;
8723 	struct dp_pdev *pdev = peer->vdev->pdev;
8724 
8725 	txrx_peer = dp_get_txrx_peer(peer);
8726 	if (!txrx_peer)
8727 		return QDF_STATUS_E_FAILURE;
8728 
8729 	stats_arr_size = txrx_peer->stats_arr_size;
8730 
8731 	if (IS_MLO_DP_LINK_PEER(peer))
8732 		link_id = dp_get_peer_hw_link_id(soc, pdev);
8733 
8734 	switch (type) {
8735 	case cdp_peer_tx_ucast:
8736 		if (link_id > 0) {
8737 			peer_stats = &txrx_peer->stats[link_id].per_pkt_stats;
8738 			buf->tx_ucast = peer_stats->tx.ucast;
8739 		} else {
8740 			for (idx = 0; idx < stats_arr_size; idx++) {
8741 				peer_stats =
8742 					&txrx_peer->stats[idx].per_pkt_stats;
8743 				pkt_info.num += peer_stats->tx.ucast.num;
8744 				pkt_info.bytes += peer_stats->tx.ucast.bytes;
8745 			}
8746 
8747 			buf->tx_ucast = pkt_info;
8748 		}
8749 
8750 		break;
8751 	case cdp_peer_tx_mcast:
8752 		if (link_id > 0) {
8753 			peer_stats = &txrx_peer->stats[link_id].per_pkt_stats;
8754 			buf->tx_mcast = peer_stats->tx.mcast;
8755 		} else {
8756 			for (idx = 0; idx < stats_arr_size; idx++) {
8757 				peer_stats =
8758 					&txrx_peer->stats[idx].per_pkt_stats;
8759 				pkt_info.num += peer_stats->tx.mcast.num;
8760 				pkt_info.bytes += peer_stats->tx.mcast.bytes;
8761 			}
8762 
8763 			buf->tx_mcast = pkt_info;
8764 		}
8765 
8766 		break;
8767 	case cdp_peer_tx_inactive_time:
8768 		tgt_peer = dp_get_tgt_peer_from_peer(peer);
8769 		if (tgt_peer)
8770 			buf->tx_inactive_time =
8771 					tgt_peer->stats.tx.inactive_time;
8772 		else
8773 			ret = QDF_STATUS_E_FAILURE;
8774 		break;
8775 	case cdp_peer_rx_ucast:
8776 		if (link_id > 0) {
8777 			peer_stats = &txrx_peer->stats[link_id].per_pkt_stats;
8778 			buf->rx_ucast = peer_stats->rx.unicast;
8779 		} else {
8780 			for (idx = 0; idx < stats_arr_size; idx++) {
8781 				peer_stats =
8782 					&txrx_peer->stats[idx].per_pkt_stats;
8783 				pkt_info.num += peer_stats->rx.unicast.num;
8784 				pkt_info.bytes += peer_stats->rx.unicast.bytes;
8785 			}
8786 
8787 			buf->rx_ucast = pkt_info;
8788 		}
8789 
8790 		break;
8791 	default:
8792 		ret = QDF_STATUS_E_FAILURE;
8793 		break;
8794 	}
8795 
8796 	return ret;
8797 }
8798 
8799 #ifdef QCA_ENHANCED_STATS_SUPPORT
8800 #ifdef WLAN_FEATURE_11BE_MLO
dp_txrx_get_peer_extd_stats_param(struct dp_peer * peer,enum cdp_peer_stats_type type,cdp_peer_stats_param_t * buf)8801 QDF_STATUS dp_txrx_get_peer_extd_stats_param(struct dp_peer *peer,
8802 					     enum cdp_peer_stats_type type,
8803 					     cdp_peer_stats_param_t *buf)
8804 {
8805 	QDF_STATUS ret = QDF_STATUS_E_FAILURE;
8806 	struct dp_soc *soc = peer->vdev->pdev->soc;
8807 
8808 	if (IS_MLO_DP_MLD_PEER(peer)) {
8809 		struct dp_peer *link_peer;
8810 		struct dp_soc *link_peer_soc;
8811 
8812 		link_peer = dp_get_primary_link_peer_by_id(soc, peer->peer_id,
8813 							   DP_MOD_ID_CDP);
8814 
8815 		if (link_peer) {
8816 			link_peer_soc = link_peer->vdev->pdev->soc;
8817 			ret = dp_monitor_peer_get_stats_param(link_peer_soc,
8818 							      link_peer,
8819 							      type, buf);
8820 			dp_peer_unref_delete(link_peer, DP_MOD_ID_CDP);
8821 		}
8822 		return ret;
8823 	} else {
8824 		return dp_monitor_peer_get_stats_param(soc, peer, type, buf);
8825 	}
8826 }
8827 #else
dp_txrx_get_peer_extd_stats_param(struct dp_peer * peer,enum cdp_peer_stats_type type,cdp_peer_stats_param_t * buf)8828 QDF_STATUS dp_txrx_get_peer_extd_stats_param(struct dp_peer *peer,
8829 					     enum cdp_peer_stats_type type,
8830 					     cdp_peer_stats_param_t *buf)
8831 {
8832 	struct dp_soc *soc = peer->vdev->pdev->soc;
8833 
8834 	return dp_monitor_peer_get_stats_param(soc, peer, type, buf);
8835 }
8836 #endif
8837 #else
dp_txrx_get_peer_extd_stats_param(struct dp_peer * peer,enum cdp_peer_stats_type type,cdp_peer_stats_param_t * buf)8838 QDF_STATUS dp_txrx_get_peer_extd_stats_param(struct dp_peer *peer,
8839 					     enum cdp_peer_stats_type type,
8840 					     cdp_peer_stats_param_t *buf)
8841 {
8842 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
8843 	struct dp_txrx_peer *txrx_peer;
8844 	struct dp_peer_extd_stats *peer_stats;
8845 
8846 	txrx_peer = dp_get_txrx_peer(peer);
8847 	if (!txrx_peer)
8848 		return QDF_STATUS_E_FAILURE;
8849 
8850 	peer_stats = &txrx_peer->stats[0].extd_stats;
8851 
8852 	switch (type) {
8853 	case cdp_peer_tx_rate:
8854 		buf->tx_rate = peer_stats->tx.tx_rate;
8855 		break;
8856 	case cdp_peer_tx_last_tx_rate:
8857 		buf->last_tx_rate = peer_stats->tx.last_tx_rate;
8858 		break;
8859 	case cdp_peer_tx_ratecode:
8860 		buf->tx_ratecode = peer_stats->tx.tx_ratecode;
8861 		break;
8862 	case cdp_peer_rx_rate:
8863 		buf->rx_rate = peer_stats->rx.rx_rate;
8864 		break;
8865 	case cdp_peer_rx_last_rx_rate:
8866 		buf->last_rx_rate = peer_stats->rx.last_rx_rate;
8867 		break;
8868 	case cdp_peer_rx_ratecode:
8869 		buf->rx_ratecode = peer_stats->rx.rx_ratecode;
8870 		break;
8871 	case cdp_peer_rx_avg_snr:
8872 		buf->rx_avg_snr = peer_stats->rx.avg_snr;
8873 		break;
8874 	case cdp_peer_rx_snr:
8875 		buf->rx_snr = peer_stats->rx.snr;
8876 		break;
8877 	default:
8878 		ret = QDF_STATUS_E_FAILURE;
8879 		break;
8880 	}
8881 
8882 	return ret;
8883 }
8884 #endif
8885 
8886 /**
8887  * dp_is_wds_extended() - Check if wds ext is enabled
8888  * @txrx_peer: DP txrx_peer handle
8889  *
8890  * Return: true if enabled, false if not
8891  */
8892 #ifdef QCA_SUPPORT_WDS_EXTENDED
8893 static inline
dp_is_wds_extended(struct dp_txrx_peer * txrx_peer)8894 bool dp_is_wds_extended(struct dp_txrx_peer *txrx_peer)
8895 {
8896 	if (qdf_atomic_test_bit(WDS_EXT_PEER_INIT_BIT,
8897 				&txrx_peer->wds_ext.init))
8898 		return true;
8899 
8900 	return false;
8901 }
8902 #else
8903 static inline
dp_is_wds_extended(struct dp_txrx_peer * txrx_peer)8904 bool dp_is_wds_extended(struct dp_txrx_peer *txrx_peer)
8905 {
8906 	return false;
8907 }
8908 #endif /* QCA_SUPPORT_WDS_EXTENDED */
8909 
8910 /**
8911  * dp_peer_get_hw_txrx_stats_en() - Get value of hw_txrx_stats_en
8912  * @txrx_peer: DP txrx_peer handle
8913  *
8914  * Return: true if enabled, false if not
8915  */
8916 #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
8917 static inline
dp_peer_get_hw_txrx_stats_en(struct dp_txrx_peer * txrx_peer)8918 bool dp_peer_get_hw_txrx_stats_en(struct dp_txrx_peer *txrx_peer)
8919 {
8920 	return txrx_peer->hw_txrx_stats_en;
8921 }
8922 #else
8923 static inline
dp_peer_get_hw_txrx_stats_en(struct dp_txrx_peer * txrx_peer)8924 bool dp_peer_get_hw_txrx_stats_en(struct dp_txrx_peer *txrx_peer)
8925 {
8926 	return false;
8927 }
8928 #endif
8929 
8930 #ifdef WLAN_FEATURE_11BE_MLO
dp_get_stats_peer(struct dp_peer * peer)8931 static inline struct dp_peer *dp_get_stats_peer(struct dp_peer *peer)
8932 {
8933 	/* ML primary link peer return mld_peer */
8934 	if (IS_MLO_DP_LINK_PEER(peer) && peer->primary_link)
8935 		return peer->mld_peer;
8936 
8937 	return peer;
8938 }
8939 #else
dp_get_stats_peer(struct dp_peer * peer)8940 static inline struct dp_peer *dp_get_stats_peer(struct dp_peer *peer)
8941 {
8942 	return peer;
8943 }
8944 #endif
8945 
dp_update_vdev_be_basic_stats(struct dp_txrx_peer * txrx_peer,struct dp_vdev_stats * tgtobj)8946 void dp_update_vdev_be_basic_stats(struct dp_txrx_peer *txrx_peer,
8947 				   struct dp_vdev_stats *tgtobj)
8948 {
8949 	if (qdf_unlikely(!txrx_peer || !tgtobj))
8950 		return;
8951 
8952 	if (!dp_peer_get_hw_txrx_stats_en(txrx_peer)) {
8953 		tgtobj->tx.comp_pkt.num += txrx_peer->comp_pkt.num;
8954 		tgtobj->tx.comp_pkt.bytes += txrx_peer->comp_pkt.bytes;
8955 		tgtobj->tx.tx_failed += txrx_peer->tx_failed;
8956 	}
8957 	tgtobj->rx.to_stack.num += txrx_peer->to_stack.num;
8958 	tgtobj->rx.to_stack.bytes += txrx_peer->to_stack.bytes;
8959 }
8960 
dp_update_vdev_basic_stats(struct dp_txrx_peer * txrx_peer,struct cdp_vdev_stats * tgtobj)8961 void dp_update_vdev_basic_stats(struct dp_txrx_peer *txrx_peer,
8962 				struct cdp_vdev_stats *tgtobj)
8963 {
8964 	if (qdf_unlikely(!txrx_peer || !tgtobj))
8965 		return;
8966 
8967 	if (!dp_peer_get_hw_txrx_stats_en(txrx_peer)) {
8968 		tgtobj->tx.comp_pkt.num += txrx_peer->comp_pkt.num;
8969 		tgtobj->tx.comp_pkt.bytes += txrx_peer->comp_pkt.bytes;
8970 		tgtobj->tx.tx_failed += txrx_peer->tx_failed;
8971 	}
8972 	tgtobj->rx.to_stack.num += txrx_peer->to_stack.num;
8973 	tgtobj->rx.to_stack.bytes += txrx_peer->to_stack.bytes;
8974 }
8975 
8976 #ifdef QCA_ENHANCED_STATS_SUPPORT
dp_update_vdev_stats(struct dp_soc * soc,struct dp_peer * srcobj,void * arg)8977 void dp_update_vdev_stats(struct dp_soc *soc, struct dp_peer *srcobj,
8978 			  void *arg)
8979 {
8980 	struct dp_txrx_peer *txrx_peer;
8981 	struct cdp_vdev_stats *vdev_stats = (struct cdp_vdev_stats *)arg;
8982 	struct dp_peer_per_pkt_stats *per_pkt_stats;
8983 	uint8_t link_id = 0;
8984 	struct dp_pdev *pdev = srcobj->vdev->pdev;
8985 
8986 	txrx_peer = dp_get_txrx_peer(srcobj);
8987 	if (qdf_unlikely(!txrx_peer))
8988 		goto link_stats;
8989 
8990 	if (dp_peer_is_primary_link_peer(srcobj)) {
8991 		dp_update_vdev_basic_stats(txrx_peer, vdev_stats);
8992 		per_pkt_stats = &txrx_peer->stats[0].per_pkt_stats;
8993 		DP_UPDATE_PER_PKT_STATS(vdev_stats, per_pkt_stats);
8994 	}
8995 
8996 	if (IS_MLO_DP_LINK_PEER(srcobj)) {
8997 		link_id = dp_get_peer_hw_link_id(soc, pdev);
8998 		if (link_id > 0) {
8999 			per_pkt_stats = &txrx_peer->
9000 				stats[link_id].per_pkt_stats;
9001 			DP_UPDATE_PER_PKT_STATS(vdev_stats, per_pkt_stats);
9002 		}
9003 	}
9004 
9005 link_stats:
9006 	dp_monitor_peer_get_stats(soc, srcobj, vdev_stats, UPDATE_VDEV_STATS_MLD);
9007 }
9008 
dp_get_vdev_stats_for_unmap_peer_legacy(struct dp_vdev * vdev,struct dp_peer * peer)9009 void dp_get_vdev_stats_for_unmap_peer_legacy(struct dp_vdev *vdev,
9010 					     struct dp_peer *peer)
9011 {
9012 	struct dp_txrx_peer *txrx_peer = dp_get_txrx_peer(peer);
9013 	struct dp_vdev_stats *vdev_stats = &vdev->stats;
9014 	struct dp_soc *soc = vdev->pdev->soc;
9015 	struct dp_peer_per_pkt_stats *per_pkt_stats;
9016 
9017 	if (!txrx_peer)
9018 		goto link_stats;
9019 
9020 	dp_peer_aggregate_tid_stats(peer);
9021 
9022 	per_pkt_stats = &txrx_peer->stats[0].per_pkt_stats;
9023 	dp_update_vdev_be_basic_stats(txrx_peer, vdev_stats);
9024 	DP_UPDATE_PER_PKT_STATS(vdev_stats, per_pkt_stats);
9025 
9026 link_stats:
9027 	dp_monitor_peer_get_stats(soc, peer, vdev_stats, UPDATE_VDEV_STATS);
9028 }
9029 
dp_update_vdev_stats_on_peer_unmap(struct dp_vdev * vdev,struct dp_peer * peer)9030 void dp_update_vdev_stats_on_peer_unmap(struct dp_vdev *vdev,
9031 					struct dp_peer *peer)
9032 {
9033 	struct dp_soc *soc = vdev->pdev->soc;
9034 
9035 	if (soc->arch_ops.dp_get_vdev_stats_for_unmap_peer)
9036 		soc->arch_ops.dp_get_vdev_stats_for_unmap_peer(vdev, peer);
9037 }
9038 #else
dp_update_vdev_stats(struct dp_soc * soc,struct dp_peer * srcobj,void * arg)9039 void dp_update_vdev_stats(struct dp_soc *soc, struct dp_peer *srcobj,
9040 			  void *arg)
9041 {
9042 	struct dp_txrx_peer *txrx_peer;
9043 	struct cdp_vdev_stats *vdev_stats = (struct cdp_vdev_stats *)arg;
9044 	struct dp_peer_per_pkt_stats *per_pkt_stats;
9045 	struct dp_peer_extd_stats *extd_stats;
9046 	uint8_t inx = 0;
9047 	uint8_t stats_arr_size = 0;
9048 
9049 	txrx_peer = dp_get_txrx_peer(srcobj);
9050 	if (qdf_unlikely(!txrx_peer))
9051 		return;
9052 
9053 	if (qdf_unlikely(dp_is_wds_extended(txrx_peer)))
9054 		return;
9055 
9056 	if (!dp_peer_is_primary_link_peer(srcobj))
9057 		return;
9058 
9059 	stats_arr_size = txrx_peer->stats_arr_size;
9060 	dp_update_vdev_basic_stats(txrx_peer, vdev_stats);
9061 
9062 	for (inx = 0; inx < stats_arr_size; inx++) {
9063 		per_pkt_stats = &txrx_peer->stats[inx].per_pkt_stats;
9064 		extd_stats = &txrx_peer->stats[inx].extd_stats;
9065 		DP_UPDATE_EXTD_STATS(vdev_stats, extd_stats);
9066 		DP_UPDATE_PER_PKT_STATS(vdev_stats, per_pkt_stats);
9067 	}
9068 }
9069 
dp_update_vdev_stats_on_peer_unmap(struct dp_vdev * vdev,struct dp_peer * peer)9070 void dp_update_vdev_stats_on_peer_unmap(struct dp_vdev *vdev,
9071 					struct dp_peer *peer)
9072 {
9073 	struct dp_txrx_peer *txrx_peer;
9074 	struct dp_peer_per_pkt_stats *per_pkt_stats;
9075 	struct dp_peer_extd_stats *extd_stats;
9076 	struct dp_vdev_stats *vdev_stats = &vdev->stats;
9077 	uint8_t inx = 0;
9078 	uint8_t stats_arr_size = 0;
9079 
9080 	txrx_peer = dp_get_txrx_peer(peer);
9081 	if (!txrx_peer)
9082 		return;
9083 
9084 	stats_arr_size = txrx_peer->stats_arr_size;
9085 	dp_update_vdev_be_basic_stats(txrx_peer, vdev_stats);
9086 
9087 	for (inx = 0; inx < stats_arr_size; inx++) {
9088 		per_pkt_stats = &txrx_peer->stats[inx].per_pkt_stats;
9089 		extd_stats = &txrx_peer->stats[inx].extd_stats;
9090 		DP_UPDATE_EXTD_STATS(vdev_stats, extd_stats);
9091 		DP_UPDATE_PER_PKT_STATS(vdev_stats, per_pkt_stats);
9092 	}
9093 }
9094 
dp_get_vdev_stats_for_unmap_peer_legacy(struct dp_vdev * vdev,struct dp_peer * peer)9095 void dp_get_vdev_stats_for_unmap_peer_legacy(struct dp_vdev *vdev,
9096 					     struct dp_peer *peer)
9097 {
9098 }
9099 #endif
9100 
dp_update_pdev_stats(struct dp_pdev * tgtobj,struct cdp_vdev_stats * srcobj)9101 void dp_update_pdev_stats(struct dp_pdev *tgtobj,
9102 			  struct cdp_vdev_stats *srcobj)
9103 {
9104 	uint8_t i;
9105 	uint8_t pream_type;
9106 	uint8_t mu_type;
9107 	struct cdp_pdev_stats *pdev_stats = NULL;
9108 
9109 	pdev_stats = &tgtobj->stats;
9110 	for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) {
9111 		for (i = 0; i < MAX_MCS; i++) {
9112 			tgtobj->stats.tx.pkt_type[pream_type].
9113 				mcs_count[i] +=
9114 			srcobj->tx.pkt_type[pream_type].
9115 				mcs_count[i];
9116 			tgtobj->stats.rx.pkt_type[pream_type].
9117 				mcs_count[i] +=
9118 			srcobj->rx.pkt_type[pream_type].
9119 				mcs_count[i];
9120 		}
9121 	}
9122 
9123 	for (i = 0; i < MAX_BW; i++) {
9124 		tgtobj->stats.tx.bw[i] += srcobj->tx.bw[i];
9125 		tgtobj->stats.rx.bw[i] += srcobj->rx.bw[i];
9126 	}
9127 
9128 	for (i = 0; i < SS_COUNT; i++) {
9129 		tgtobj->stats.tx.nss[i] += srcobj->tx.nss[i];
9130 		tgtobj->stats.rx.nss[i] += srcobj->rx.nss[i];
9131 		tgtobj->stats.rx.ppdu_nss[i] += srcobj->rx.ppdu_nss[i];
9132 	}
9133 
9134 	for (i = 0; i < WME_AC_MAX; i++) {
9135 		tgtobj->stats.tx.wme_ac_type[i] +=
9136 			srcobj->tx.wme_ac_type[i];
9137 		tgtobj->stats.tx.wme_ac_type_bytes[i] +=
9138 			srcobj->tx.wme_ac_type_bytes[i];
9139 		tgtobj->stats.rx.wme_ac_type[i] +=
9140 			srcobj->rx.wme_ac_type[i];
9141 		tgtobj->stats.rx.wme_ac_type_bytes[i] +=
9142 			srcobj->rx.wme_ac_type_bytes[i];
9143 		tgtobj->stats.tx.excess_retries_per_ac[i] +=
9144 			srcobj->tx.excess_retries_per_ac[i];
9145 	}
9146 
9147 	for (i = 0; i < MAX_GI; i++) {
9148 		tgtobj->stats.tx.sgi_count[i] +=
9149 			srcobj->tx.sgi_count[i];
9150 		tgtobj->stats.rx.sgi_count[i] +=
9151 			srcobj->rx.sgi_count[i];
9152 	}
9153 
9154 	for (i = 0; i < MAX_RECEPTION_TYPES; i++) {
9155 		tgtobj->stats.rx.reception_type[i] +=
9156 			srcobj->rx.reception_type[i];
9157 		tgtobj->stats.rx.ppdu_cnt[i] += srcobj->rx.ppdu_cnt[i];
9158 	}
9159 
9160 	for (i = 0; i < MAX_TRANSMIT_TYPES; i++) {
9161 		tgtobj->stats.tx.transmit_type[i].num_msdu +=
9162 				srcobj->tx.transmit_type[i].num_msdu;
9163 		tgtobj->stats.tx.transmit_type[i].num_mpdu +=
9164 				srcobj->tx.transmit_type[i].num_mpdu;
9165 		tgtobj->stats.tx.transmit_type[i].mpdu_tried +=
9166 				srcobj->tx.transmit_type[i].mpdu_tried;
9167 	}
9168 
9169 	for (i = 0; i < QDF_PROTO_SUBTYPE_MAX; i++)
9170 		tgtobj->stats.tx.no_ack_count[i] += srcobj->tx.no_ack_count[i];
9171 
9172 	for (i = 0; i < MAX_MU_GROUP_ID; i++)
9173 		tgtobj->stats.tx.mu_group_id[i] = srcobj->tx.mu_group_id[i];
9174 
9175 	for (i = 0; i < MAX_RU_LOCATIONS; i++) {
9176 		tgtobj->stats.tx.ru_loc[i].num_msdu +=
9177 			srcobj->tx.ru_loc[i].num_msdu;
9178 		tgtobj->stats.tx.ru_loc[i].num_mpdu +=
9179 			srcobj->tx.ru_loc[i].num_mpdu;
9180 		tgtobj->stats.tx.ru_loc[i].mpdu_tried +=
9181 			srcobj->tx.ru_loc[i].mpdu_tried;
9182 	}
9183 
9184 	tgtobj->stats.tx.tx_ppdus += srcobj->tx.tx_ppdus;
9185 	tgtobj->stats.tx.tx_mpdus_success += srcobj->tx.tx_mpdus_success;
9186 	tgtobj->stats.tx.tx_mpdus_tried += srcobj->tx.tx_mpdus_tried;
9187 	tgtobj->stats.tx.retries_mpdu += srcobj->tx.retries_mpdu;
9188 	tgtobj->stats.tx.mpdu_success_with_retries +=
9189 		srcobj->tx.mpdu_success_with_retries;
9190 	tgtobj->stats.tx.last_tx_ts = srcobj->tx.last_tx_ts;
9191 	tgtobj->stats.tx.tx_rate = srcobj->tx.tx_rate;
9192 	tgtobj->stats.tx.last_tx_rate = srcobj->tx.last_tx_rate;
9193 	tgtobj->stats.tx.last_tx_rate_mcs = srcobj->tx.last_tx_rate_mcs;
9194 	tgtobj->stats.tx.mcast_last_tx_rate = srcobj->tx.mcast_last_tx_rate;
9195 	tgtobj->stats.tx.mcast_last_tx_rate_mcs =
9196 		srcobj->tx.mcast_last_tx_rate_mcs;
9197 	tgtobj->stats.tx.rnd_avg_tx_rate = srcobj->tx.rnd_avg_tx_rate;
9198 	tgtobj->stats.tx.avg_tx_rate = srcobj->tx.avg_tx_rate;
9199 	tgtobj->stats.tx.tx_ratecode = srcobj->tx.tx_ratecode;
9200 	tgtobj->stats.tx.ru_start = srcobj->tx.ru_start;
9201 	tgtobj->stats.tx.ru_tones = srcobj->tx.ru_tones;
9202 	tgtobj->stats.tx.last_ack_rssi = srcobj->tx.last_ack_rssi;
9203 	tgtobj->stats.tx.nss_info = srcobj->tx.nss_info;
9204 	tgtobj->stats.tx.mcs_info = srcobj->tx.mcs_info;
9205 	tgtobj->stats.tx.bw_info = srcobj->tx.bw_info;
9206 	tgtobj->stats.tx.gi_info = srcobj->tx.gi_info;
9207 	tgtobj->stats.tx.preamble_info = srcobj->tx.preamble_info;
9208 	tgtobj->stats.tx.comp_pkt.bytes += srcobj->tx.comp_pkt.bytes;
9209 	tgtobj->stats.tx.comp_pkt.num += srcobj->tx.comp_pkt.num;
9210 	tgtobj->stats.tx.ucast.num += srcobj->tx.ucast.num;
9211 	tgtobj->stats.tx.ucast.bytes += srcobj->tx.ucast.bytes;
9212 	tgtobj->stats.tx.mcast.num += srcobj->tx.mcast.num;
9213 	tgtobj->stats.tx.mcast.bytes += srcobj->tx.mcast.bytes;
9214 	tgtobj->stats.tx.bcast.num += srcobj->tx.bcast.num;
9215 	tgtobj->stats.tx.bcast.bytes += srcobj->tx.bcast.bytes;
9216 	tgtobj->stats.tx.tx_success.num += srcobj->tx.tx_success.num;
9217 	tgtobj->stats.tx.tx_success.bytes +=
9218 		srcobj->tx.tx_success.bytes;
9219 	tgtobj->stats.tx.nawds_mcast.num +=
9220 		srcobj->tx.nawds_mcast.num;
9221 	tgtobj->stats.tx.nawds_mcast.bytes +=
9222 		srcobj->tx.nawds_mcast.bytes;
9223 	tgtobj->stats.tx.nawds_mcast_drop +=
9224 		srcobj->tx.nawds_mcast_drop;
9225 	tgtobj->stats.tx.num_ppdu_cookie_valid +=
9226 		srcobj->tx.num_ppdu_cookie_valid;
9227 	tgtobj->stats.tx.tx_failed += srcobj->tx.tx_failed;
9228 	tgtobj->stats.tx.ofdma += srcobj->tx.ofdma;
9229 	tgtobj->stats.tx.stbc += srcobj->tx.stbc;
9230 	tgtobj->stats.tx.ldpc += srcobj->tx.ldpc;
9231 	tgtobj->stats.tx.pream_punct_cnt += srcobj->tx.pream_punct_cnt;
9232 	tgtobj->stats.tx.retries += srcobj->tx.retries;
9233 	tgtobj->stats.tx.non_amsdu_cnt += srcobj->tx.non_amsdu_cnt;
9234 	tgtobj->stats.tx.amsdu_cnt += srcobj->tx.amsdu_cnt;
9235 	tgtobj->stats.tx.non_ampdu_cnt += srcobj->tx.non_ampdu_cnt;
9236 	tgtobj->stats.tx.ampdu_cnt += srcobj->tx.ampdu_cnt;
9237 	tgtobj->stats.tx.dropped.fw_rem.num += srcobj->tx.dropped.fw_rem.num;
9238 	tgtobj->stats.tx.dropped.fw_rem.bytes +=
9239 			srcobj->tx.dropped.fw_rem.bytes;
9240 	tgtobj->stats.tx.dropped.fw_rem_tx +=
9241 			srcobj->tx.dropped.fw_rem_tx;
9242 	tgtobj->stats.tx.dropped.fw_rem_notx +=
9243 			srcobj->tx.dropped.fw_rem_notx;
9244 	tgtobj->stats.tx.dropped.fw_reason1 +=
9245 			srcobj->tx.dropped.fw_reason1;
9246 	tgtobj->stats.tx.dropped.fw_reason2 +=
9247 			srcobj->tx.dropped.fw_reason2;
9248 	tgtobj->stats.tx.dropped.fw_reason3 +=
9249 			srcobj->tx.dropped.fw_reason3;
9250 	tgtobj->stats.tx.dropped.fw_rem_queue_disable +=
9251 				srcobj->tx.dropped.fw_rem_queue_disable;
9252 	tgtobj->stats.tx.dropped.fw_rem_no_match +=
9253 				srcobj->tx.dropped.fw_rem_no_match;
9254 	tgtobj->stats.tx.dropped.drop_threshold +=
9255 				srcobj->tx.dropped.drop_threshold;
9256 	tgtobj->stats.tx.dropped.drop_link_desc_na +=
9257 				srcobj->tx.dropped.drop_link_desc_na;
9258 	tgtobj->stats.tx.dropped.invalid_drop +=
9259 				srcobj->tx.dropped.invalid_drop;
9260 	tgtobj->stats.tx.dropped.mcast_vdev_drop +=
9261 					srcobj->tx.dropped.mcast_vdev_drop;
9262 	tgtobj->stats.tx.dropped.invalid_rr +=
9263 				srcobj->tx.dropped.invalid_rr;
9264 	tgtobj->stats.tx.dropped.age_out += srcobj->tx.dropped.age_out;
9265 	tgtobj->stats.rx.err.mic_err += srcobj->rx.err.mic_err;
9266 	tgtobj->stats.rx.err.decrypt_err += srcobj->rx.err.decrypt_err;
9267 	tgtobj->stats.rx.err.fcserr += srcobj->rx.err.fcserr;
9268 	tgtobj->stats.rx.err.pn_err += srcobj->rx.err.pn_err;
9269 	tgtobj->stats.rx.err.oor_err += srcobj->rx.err.oor_err;
9270 	tgtobj->stats.rx.err.jump_2k_err += srcobj->rx.err.jump_2k_err;
9271 	tgtobj->stats.rx.err.rxdma_wifi_parse_err +=
9272 				srcobj->rx.err.rxdma_wifi_parse_err;
9273 	if (srcobj->rx.snr != 0)
9274 		tgtobj->stats.rx.snr = srcobj->rx.snr;
9275 	tgtobj->stats.rx.rx_rate = srcobj->rx.rx_rate;
9276 	tgtobj->stats.rx.last_rx_rate = srcobj->rx.last_rx_rate;
9277 	tgtobj->stats.rx.rnd_avg_rx_rate = srcobj->rx.rnd_avg_rx_rate;
9278 	tgtobj->stats.rx.avg_rx_rate = srcobj->rx.avg_rx_rate;
9279 	tgtobj->stats.rx.rx_ratecode = srcobj->rx.rx_ratecode;
9280 	tgtobj->stats.rx.avg_snr = srcobj->rx.avg_snr;
9281 	tgtobj->stats.rx.rx_snr_measured_time = srcobj->rx.rx_snr_measured_time;
9282 	tgtobj->stats.rx.last_snr = srcobj->rx.last_snr;
9283 	tgtobj->stats.rx.nss_info = srcobj->rx.nss_info;
9284 	tgtobj->stats.rx.mcs_info = srcobj->rx.mcs_info;
9285 	tgtobj->stats.rx.bw_info = srcobj->rx.bw_info;
9286 	tgtobj->stats.rx.gi_info = srcobj->rx.gi_info;
9287 	tgtobj->stats.rx.preamble_info = srcobj->rx.preamble_info;
9288 	tgtobj->stats.rx.non_ampdu_cnt += srcobj->rx.non_ampdu_cnt;
9289 	tgtobj->stats.rx.ampdu_cnt += srcobj->rx.ampdu_cnt;
9290 	tgtobj->stats.rx.non_amsdu_cnt += srcobj->rx.non_amsdu_cnt;
9291 	tgtobj->stats.rx.amsdu_cnt += srcobj->rx.amsdu_cnt;
9292 	tgtobj->stats.rx.nawds_mcast_drop += srcobj->rx.nawds_mcast_drop;
9293 	tgtobj->stats.rx.mcast_3addr_drop += srcobj->rx.mcast_3addr_drop;
9294 	tgtobj->stats.rx.to_stack.num += srcobj->rx.to_stack.num;
9295 	tgtobj->stats.rx.to_stack.bytes += srcobj->rx.to_stack.bytes;
9296 
9297 	for (i = 0; i < CDP_MAX_RX_RINGS; i++) {
9298 		tgtobj->stats.rx.rcvd_reo[i].num +=
9299 			srcobj->rx.rcvd_reo[i].num;
9300 		tgtobj->stats.rx.rcvd_reo[i].bytes +=
9301 			srcobj->rx.rcvd_reo[i].bytes;
9302 	}
9303 
9304 	for (i = 0; i < CDP_MAX_LMACS; i++) {
9305 		tgtobj->stats.rx.rx_lmac[i].num +=
9306 			srcobj->rx.rx_lmac[i].num;
9307 		tgtobj->stats.rx.rx_lmac[i].bytes +=
9308 			srcobj->rx.rx_lmac[i].bytes;
9309 	}
9310 
9311 	if (srcobj->rx.to_stack.num >= (srcobj->rx.multicast.num))
9312 		srcobj->rx.unicast.num =
9313 			srcobj->rx.to_stack.num -
9314 				(srcobj->rx.multicast.num);
9315 	if (srcobj->rx.to_stack.bytes >= srcobj->rx.multicast.bytes)
9316 		srcobj->rx.unicast.bytes =
9317 			srcobj->rx.to_stack.bytes -
9318 				(srcobj->rx.multicast.bytes);
9319 
9320 	tgtobj->stats.rx.unicast.num += srcobj->rx.unicast.num;
9321 	tgtobj->stats.rx.unicast.bytes += srcobj->rx.unicast.bytes;
9322 	tgtobj->stats.rx.multicast.num += srcobj->rx.multicast.num;
9323 	tgtobj->stats.rx.multicast.bytes += srcobj->rx.multicast.bytes;
9324 	tgtobj->stats.rx.bcast.num += srcobj->rx.bcast.num;
9325 	tgtobj->stats.rx.bcast.bytes += srcobj->rx.bcast.bytes;
9326 	tgtobj->stats.rx.raw.num += srcobj->rx.raw.num;
9327 	tgtobj->stats.rx.raw.bytes += srcobj->rx.raw.bytes;
9328 	tgtobj->stats.rx.intra_bss.pkts.num +=
9329 			srcobj->rx.intra_bss.pkts.num;
9330 	tgtobj->stats.rx.intra_bss.pkts.bytes +=
9331 			srcobj->rx.intra_bss.pkts.bytes;
9332 	tgtobj->stats.rx.intra_bss.fail.num +=
9333 			srcobj->rx.intra_bss.fail.num;
9334 	tgtobj->stats.rx.intra_bss.fail.bytes +=
9335 			srcobj->rx.intra_bss.fail.bytes;
9336 
9337 	tgtobj->stats.tx.last_ack_rssi =
9338 		srcobj->tx.last_ack_rssi;
9339 	tgtobj->stats.rx.mec_drop.num += srcobj->rx.mec_drop.num;
9340 	tgtobj->stats.rx.mec_drop.bytes += srcobj->rx.mec_drop.bytes;
9341 	tgtobj->stats.rx.ppeds_drop.num += srcobj->rx.ppeds_drop.num;
9342 	tgtobj->stats.rx.ppeds_drop.bytes += srcobj->rx.ppeds_drop.bytes;
9343 	tgtobj->stats.rx.multipass_rx_pkt_drop +=
9344 		srcobj->rx.multipass_rx_pkt_drop;
9345 	tgtobj->stats.rx.peer_unauth_rx_pkt_drop +=
9346 		srcobj->rx.peer_unauth_rx_pkt_drop;
9347 	tgtobj->stats.rx.policy_check_drop +=
9348 		srcobj->rx.policy_check_drop;
9349 
9350 	for (mu_type = 0 ; mu_type < TXRX_TYPE_MU_MAX; mu_type++) {
9351 		tgtobj->stats.rx.rx_mu[mu_type].mpdu_cnt_fcs_ok +=
9352 			srcobj->rx.rx_mu[mu_type].mpdu_cnt_fcs_ok;
9353 		tgtobj->stats.rx.rx_mu[mu_type].mpdu_cnt_fcs_err +=
9354 			srcobj->rx.rx_mu[mu_type].mpdu_cnt_fcs_err;
9355 		for (i = 0; i < SS_COUNT; i++)
9356 			tgtobj->stats.rx.rx_mu[mu_type].ppdu_nss[i] +=
9357 				srcobj->rx.rx_mu[mu_type].ppdu_nss[i];
9358 		for (i = 0; i < MAX_MCS; i++)
9359 			tgtobj->stats.rx.rx_mu[mu_type].ppdu.mcs_count[i] +=
9360 				srcobj->rx.rx_mu[mu_type].ppdu.mcs_count[i];
9361 	}
9362 
9363 	for (i = 0; i < MAX_MCS; i++) {
9364 		tgtobj->stats.rx.su_ax_ppdu_cnt.mcs_count[i] +=
9365 			srcobj->rx.su_ax_ppdu_cnt.mcs_count[i];
9366 		tgtobj->stats.rx.rx_mpdu_cnt[i] += srcobj->rx.rx_mpdu_cnt[i];
9367 	}
9368 
9369 	tgtobj->stats.rx.mpdu_cnt_fcs_ok += srcobj->rx.mpdu_cnt_fcs_ok;
9370 	tgtobj->stats.rx.mpdu_cnt_fcs_err += srcobj->rx.mpdu_cnt_fcs_err;
9371 	tgtobj->stats.rx.rx_mpdus += srcobj->rx.rx_mpdus;
9372 	tgtobj->stats.rx.rx_ppdus += srcobj->rx.rx_ppdus;
9373 	tgtobj->stats.rx.mpdu_retry_cnt += srcobj->rx.mpdu_retry_cnt;
9374 	tgtobj->stats.rx.rx_retries += srcobj->rx.rx_retries;
9375 
9376 	DP_UPDATE_11BE_STATS(pdev_stats, srcobj);
9377 }
9378 
dp_update_vdev_ingress_stats(struct dp_vdev * tgtobj)9379 void dp_update_vdev_ingress_stats(struct dp_vdev *tgtobj)
9380 {
9381 	uint8_t idx;
9382 
9383 	for (idx = 0; idx < DP_INGRESS_STATS_MAX_SIZE; idx++) {
9384 		tgtobj->stats.tx_i[idx].dropped.dropped_pkt.num +=
9385 			tgtobj->stats.tx_i[idx].dropped.dma_error +
9386 			tgtobj->stats.tx_i[idx].dropped.ring_full +
9387 			tgtobj->stats.tx_i[idx].dropped.enqueue_fail +
9388 			tgtobj->stats.tx_i[idx].dropped.fail_per_pkt_vdev_id_check +
9389 			tgtobj->stats.tx_i[idx].dropped.desc_na.num +
9390 			tgtobj->stats.tx_i[idx].dropped.res_full +
9391 			tgtobj->stats.tx_i[idx].dropped.drop_ingress +
9392 			tgtobj->stats.tx_i[idx].dropped.headroom_insufficient +
9393 			tgtobj->stats.tx_i[idx].dropped.invalid_peer_id_in_exc_path +
9394 			tgtobj->stats.tx_i[idx].dropped.tx_mcast_drop +
9395 			tgtobj->stats.tx_i[idx].dropped.fw2wbm_tx_drop;
9396 	}
9397 }
9398 
9399 #ifdef HW_TX_DELAY_STATS_ENABLE
9400 static inline
dp_update_hw_tx_delay_stats(struct cdp_vdev_stats * vdev_stats,struct dp_vdev_stats * stats)9401 void dp_update_hw_tx_delay_stats(struct cdp_vdev_stats *vdev_stats,
9402 				 struct dp_vdev_stats *stats)
9403 {
9404 
9405 	qdf_mem_copy(&vdev_stats->tid_tx_stats, &stats->tid_tx_stats,
9406 		     sizeof(stats->tid_tx_stats));
9407 
9408 }
9409 #else
9410 static inline
dp_update_hw_tx_delay_stats(struct cdp_vdev_stats * vdev_stats,struct dp_vdev_stats * stats)9411 void dp_update_hw_tx_delay_stats(struct cdp_vdev_stats *vdev_stats,
9412 				 struct dp_vdev_stats *stats)
9413 {
9414 }
9415 #endif
9416 
dp_copy_vdev_stats_to_tgt_buf(struct cdp_vdev_stats * vdev_stats,struct dp_vdev_stats * stats,enum dp_pkt_xmit_type xmit_type)9417 void dp_copy_vdev_stats_to_tgt_buf(struct cdp_vdev_stats *vdev_stats,
9418 				   struct dp_vdev_stats *stats,
9419 				   enum dp_pkt_xmit_type xmit_type)
9420 {
9421 	DP_UPDATE_LINK_VDEV_INGRESS_STATS(vdev_stats, stats, xmit_type);
9422 	qdf_mem_copy(&vdev_stats->rx_i, &stats->rx_i, sizeof(stats->rx_i));
9423 	qdf_mem_copy(&vdev_stats->tx, &stats->tx, sizeof(stats->tx));
9424 	qdf_mem_copy(&vdev_stats->rx, &stats->rx, sizeof(stats->rx));
9425 	qdf_mem_copy(&vdev_stats->tso_stats, &stats->tso_stats,
9426 		     sizeof(stats->tso_stats));
9427 	dp_update_hw_tx_delay_stats(vdev_stats, stats);
9428 
9429 }
9430 
dp_update_vdev_rate_stats(struct cdp_vdev_stats * tgtobj,struct dp_vdev_stats * srcobj)9431 void dp_update_vdev_rate_stats(struct cdp_vdev_stats *tgtobj,
9432 			       struct dp_vdev_stats *srcobj)
9433 {
9434 	tgtobj->tx.last_tx_rate = srcobj->tx.last_tx_rate;
9435 	tgtobj->tx.last_tx_rate_mcs = srcobj->tx.last_tx_rate_mcs;
9436 	tgtobj->tx.mcast_last_tx_rate = srcobj->tx.mcast_last_tx_rate;
9437 	tgtobj->tx.mcast_last_tx_rate_mcs = srcobj->tx.mcast_last_tx_rate_mcs;
9438 	tgtobj->rx.last_rx_rate = srcobj->rx.last_rx_rate;
9439 }
9440 
dp_update_pdev_ingress_stats(struct dp_pdev * tgtobj,struct dp_vdev * srcobj)9441 void dp_update_pdev_ingress_stats(struct dp_pdev *tgtobj,
9442 				  struct dp_vdev *srcobj)
9443 {
9444 	int idx;
9445 
9446 	for (idx = 0; idx < DP_INGRESS_STATS_MAX_SIZE; idx++) {
9447 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, nawds_mcast, idx);
9448 
9449 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, rcvd, idx);
9450 		DP_STATS_AGGR_IDX(tgtobj, srcobj,
9451 				  tx_i, rcvd_in_fast_xmit_flow, idx);
9452 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, rcvd_per_core[0], idx);
9453 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, rcvd_per_core[1], idx);
9454 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, rcvd_per_core[2], idx);
9455 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, rcvd_per_core[3], idx);
9456 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, processed, idx);
9457 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, reinject_pkts, idx);
9458 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, inspect_pkts, idx);
9459 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, raw.raw_pkt, idx);
9460 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, raw.dma_map_error, idx);
9461 		DP_STATS_AGGR_IDX(tgtobj, srcobj,
9462 				  tx_i, raw.num_frags_overflow_err, idx);
9463 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, sg.dropped_host.num,
9464 				  idx);
9465 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, sg.dropped_target, idx);
9466 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, sg.sg_pkt, idx);
9467 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, mcast_en.mcast_pkt,
9468 				      idx);
9469 		DP_STATS_AGGR_IDX(tgtobj, srcobj,
9470 				  tx_i, mcast_en.dropped_map_error, idx);
9471 		DP_STATS_AGGR_IDX(tgtobj, srcobj,
9472 				  tx_i, mcast_en.dropped_self_mac, idx);
9473 		DP_STATS_AGGR_IDX(tgtobj, srcobj,
9474 				  tx_i, mcast_en.dropped_send_fail, idx);
9475 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, mcast_en.ucast, idx);
9476 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i,
9477 				  igmp_mcast_en.igmp_rcvd, idx);
9478 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i,
9479 				  igmp_mcast_en.igmp_ucast_converted, idx);
9480 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, dropped.dma_error, idx);
9481 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, dropped.ring_full, idx);
9482 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, dropped.enqueue_fail,
9483 				  idx);
9484 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i,
9485 				  dropped.fail_per_pkt_vdev_id_check, idx);
9486 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, dropped.desc_na.num,
9487 				  idx);
9488 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, dropped.res_full, idx);
9489 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, dropped.drop_ingress,
9490 				  idx);
9491 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i,
9492 				  dropped.headroom_insufficient, idx);
9493 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i,
9494 				  dropped.invalid_peer_id_in_exc_path, idx);
9495 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i,
9496 				  dropped.tx_mcast_drop, idx);
9497 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, dropped.fw2wbm_tx_drop,
9498 				  idx);
9499 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, cce_classified, idx);
9500 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, cce_classified_raw,
9501 				  idx);
9502 		DP_STATS_AGGR_PKT_IDX(tgtobj, srcobj, tx_i, sniffer_rcvd, idx);
9503 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, mesh.exception_fw, idx);
9504 		DP_STATS_AGGR_IDX(tgtobj, srcobj, tx_i, mesh.completion_fw,
9505 				  idx);
9506 	}
9507 	DP_STATS_AGGR_PKT(tgtobj, srcobj, rx_i.reo_rcvd_pkt);
9508 	DP_STATS_AGGR_PKT(tgtobj, srcobj, rx_i.null_q_desc_pkt);
9509 	DP_STATS_AGGR_PKT(tgtobj, srcobj, rx_i.routed_eapol_pkt);
9510 
9511 	tgtobj->stats.tx_i.dropped.dropped_pkt.num =
9512 		tgtobj->stats.tx_i.dropped.dma_error +
9513 		tgtobj->stats.tx_i.dropped.ring_full +
9514 		tgtobj->stats.tx_i.dropped.enqueue_fail +
9515 		tgtobj->stats.tx_i.dropped.fail_per_pkt_vdev_id_check +
9516 		tgtobj->stats.tx_i.dropped.desc_na.num +
9517 		tgtobj->stats.tx_i.dropped.res_full +
9518 		tgtobj->stats.tx_i.dropped.drop_ingress +
9519 		tgtobj->stats.tx_i.dropped.headroom_insufficient +
9520 		tgtobj->stats.tx_i.dropped.invalid_peer_id_in_exc_path +
9521 		tgtobj->stats.tx_i.dropped.tx_mcast_drop;
9522 }
9523 
dp_txrx_get_soc_stats(struct cdp_soc_t * soc_hdl,struct cdp_soc_stats * soc_stats)9524 QDF_STATUS dp_txrx_get_soc_stats(struct cdp_soc_t *soc_hdl,
9525 				 struct cdp_soc_stats *soc_stats)
9526 {
9527 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9528 	uint8_t inx;
9529 	uint8_t cpus;
9530 
9531 	/* soc tx stats */
9532 	soc_stats->tx.egress = soc->stats.tx.egress[0];
9533 	soc_stats->tx.tx_invalid_peer = soc->stats.tx.tx_invalid_peer;
9534 	for (inx = 0; inx < CDP_MAX_TX_DATA_RINGS; inx++) {
9535 		soc_stats->tx.tx_hw_enq[inx] = soc->stats.tx.tcl_enq[inx];
9536 		soc_stats->tx.tx_hw_ring_full[inx] =
9537 					soc->stats.tx.tcl_ring_full[inx];
9538 	}
9539 	soc_stats->tx.desc_in_use = soc->stats.tx.desc_in_use;
9540 	soc_stats->tx.dropped_fw_removed = soc->stats.tx.dropped_fw_removed;
9541 	soc_stats->tx.invalid_release_source =
9542 					soc->stats.tx.invalid_release_source;
9543 	soc_stats->tx.invalid_tx_comp_desc =
9544 					soc->stats.tx.invalid_tx_comp_desc;
9545 	for (inx = 0; inx < CDP_MAX_WIFI_INT_ERROR_REASONS; inx++)
9546 		soc_stats->tx.wifi_internal_error[inx] =
9547 					soc->stats.tx.wbm_internal_error[inx];
9548 	soc_stats->tx.non_wifi_internal_err =
9549 					soc->stats.tx.non_wbm_internal_err;
9550 	soc_stats->tx.tx_comp_loop_pkt_limit_hit =
9551 				soc->stats.tx.tx_comp_loop_pkt_limit_hit;
9552 	soc_stats->tx.hp_oos2 = soc->stats.tx.hp_oos2;
9553 	soc_stats->tx.tx_comp_exception = soc->stats.tx.tx_comp_exception;
9554 	/* soc rx stats */
9555 	soc_stats->rx.ingress = soc->stats.rx.ingress;
9556 	soc_stats->rx.err_ring_pkts = soc->stats.rx.err_ring_pkts;
9557 	soc_stats->rx.rx_frags = soc->stats.rx.rx_frags;
9558 	soc_stats->rx.rx_hw_reinject = soc->stats.rx.reo_reinject;
9559 	soc_stats->rx.bar_frame = soc->stats.rx.bar_frame;
9560 	soc_stats->rx.rx_frag_err_len_error =
9561 					soc->stats.rx.rx_frag_err_len_error;
9562 	soc_stats->rx.rx_frag_err_no_peer = soc->stats.rx.rx_frag_err_no_peer;
9563 	soc_stats->rx.rx_frag_wait = soc->stats.rx.rx_frag_wait;
9564 	soc_stats->rx.rx_frag_err = soc->stats.rx.rx_frag_err;
9565 	soc_stats->rx.rx_frag_oor = soc->stats.rx.rx_frag_oor;
9566 	soc_stats->rx.reap_loop_pkt_limit_hit =
9567 					soc->stats.rx.reap_loop_pkt_limit_hit;
9568 	soc_stats->rx.hp_oos2 = soc->stats.rx.hp_oos2;
9569 	soc_stats->rx.near_full = soc->stats.rx.near_full;
9570 	soc_stats->rx.msdu_scatter_wait_break =
9571 					soc->stats.rx.msdu_scatter_wait_break;
9572 	soc_stats->rx.rx_sw_route_drop = soc->stats.rx.rxdma2rel_route_drop;
9573 	soc_stats->rx.rx_hw_route_drop = soc->stats.rx.reo2rel_route_drop;
9574 	soc_stats->rx.rx_packets.num_cpus = qdf_min((uint32_t)CDP_NR_CPUS,
9575 						    num_possible_cpus());
9576 	for (cpus = 0; cpus < soc_stats->rx.rx_packets.num_cpus; cpus++) {
9577 		for (inx = 0; inx < CDP_MAX_RX_DEST_RINGS; inx++)
9578 			soc_stats->rx.rx_packets.pkts[cpus][inx] =
9579 					soc->stats.rx.ring_packets[cpus][inx];
9580 	}
9581 	soc_stats->rx.err.rx_rejected = soc->stats.rx.err.rejected;
9582 	soc_stats->rx.err.rx_raw_frm_drop = soc->stats.rx.err.raw_frm_drop;
9583 	soc_stats->rx.err.phy_ring_access_fail =
9584 					soc->stats.rx.err.hal_ring_access_fail;
9585 	soc_stats->rx.err.phy_ring_access_full_fail =
9586 				soc->stats.rx.err.hal_ring_access_full_fail;
9587 	for (inx = 0; inx < CDP_MAX_RX_DEST_RINGS; inx++)
9588 		soc_stats->rx.err.phy_rx_hw_error[inx] =
9589 					soc->stats.rx.err.hal_reo_error[inx];
9590 	soc_stats->rx.err.phy_rx_hw_dest_dup =
9591 					soc->stats.rx.err.hal_reo_dest_dup;
9592 	soc_stats->rx.err.phy_wifi_rel_dup = soc->stats.rx.err.hal_wbm_rel_dup;
9593 	soc_stats->rx.err.phy_rx_sw_err_dup =
9594 					soc->stats.rx.err.hal_rxdma_err_dup;
9595 	soc_stats->rx.err.invalid_rbm = soc->stats.rx.err.invalid_rbm;
9596 	soc_stats->rx.err.invalid_vdev = soc->stats.rx.err.invalid_vdev;
9597 	soc_stats->rx.err.invalid_pdev = soc->stats.rx.err.invalid_pdev;
9598 	soc_stats->rx.err.pkt_delivered_no_peer =
9599 					soc->stats.rx.err.pkt_delivered_no_peer;
9600 	soc_stats->rx.err.defrag_peer_uninit =
9601 					soc->stats.rx.err.defrag_peer_uninit;
9602 	soc_stats->rx.err.invalid_sa_da_idx =
9603 					soc->stats.rx.err.invalid_sa_da_idx;
9604 	soc_stats->rx.err.msdu_done_fail = soc->stats.rx.err.msdu_done_fail;
9605 	soc_stats->rx.err.rx_invalid_peer = soc->stats.rx.err.rx_invalid_peer;
9606 	soc_stats->rx.err.rx_invalid_peer_id =
9607 					soc->stats.rx.err.rx_invalid_peer_id;
9608 	soc_stats->rx.err.rx_invalid_pkt_len =
9609 					soc->stats.rx.err.rx_invalid_pkt_len;
9610 	for (inx = 0; inx < qdf_min((uint32_t)CDP_WIFI_ERR_MAX,
9611 				    (uint32_t)HAL_RXDMA_ERR_MAX); inx++)
9612 		soc_stats->rx.err.rx_sw_error[inx] =
9613 					soc->stats.rx.err.rxdma_error[inx];
9614 	for (inx = 0; inx < qdf_min((uint32_t)CDP_RX_ERR_MAX,
9615 				    (uint32_t)HAL_REO_ERR_MAX); inx++)
9616 		soc_stats->rx.err.rx_hw_error[inx] =
9617 					soc->stats.rx.err.reo_error[inx];
9618 	soc_stats->rx.err.rx_desc_invalid_magic =
9619 					soc->stats.rx.err.rx_desc_invalid_magic;
9620 	soc_stats->rx.err.rx_hw_cmd_send_fail =
9621 					soc->stats.rx.err.reo_cmd_send_fail;
9622 	soc_stats->rx.err.rx_hw_cmd_send_drain =
9623 					soc->stats.rx.err.reo_cmd_send_drain;
9624 	soc_stats->rx.err.scatter_msdu = soc->stats.rx.err.scatter_msdu;
9625 	soc_stats->rx.err.invalid_cookie = soc->stats.rx.err.invalid_cookie;
9626 	soc_stats->rx.err.stale_cookie = soc->stats.rx.err.stale_cookie;
9627 	soc_stats->rx.err.rx_2k_jump_delba_sent =
9628 					soc->stats.rx.err.rx_2k_jump_delba_sent;
9629 	soc_stats->rx.err.rx_2k_jump_to_stack =
9630 					soc->stats.rx.err.rx_2k_jump_to_stack;
9631 	soc_stats->rx.err.rx_2k_jump_drop = soc->stats.rx.err.rx_2k_jump_drop;
9632 	soc_stats->rx.err.rx_hw_err_msdu_buf_rcved =
9633 				soc->stats.rx.err.reo_err_msdu_buf_rcved;
9634 	soc_stats->rx.err.rx_hw_err_msdu_buf_invalid_cookie =
9635 			soc->stats.rx.err.reo_err_msdu_buf_invalid_cookie;
9636 	soc_stats->rx.err.rx_hw_err_oor_drop =
9637 					soc->stats.rx.err.reo_err_oor_drop;
9638 	soc_stats->rx.err.rx_hw_err_oor_to_stack =
9639 					soc->stats.rx.err.reo_err_oor_to_stack;
9640 	soc_stats->rx.err.rx_hw_err_oor_sg_count =
9641 					soc->stats.rx.err.reo_err_oor_sg_count;
9642 	soc_stats->rx.err.msdu_count_mismatch =
9643 					soc->stats.rx.err.msdu_count_mismatch;
9644 	soc_stats->rx.err.invalid_link_cookie =
9645 					soc->stats.rx.err.invalid_link_cookie;
9646 	soc_stats->rx.err.nbuf_sanity_fail = soc->stats.rx.err.nbuf_sanity_fail;
9647 	soc_stats->rx.err.dup_refill_link_desc =
9648 					soc->stats.rx.err.dup_refill_link_desc;
9649 	soc_stats->rx.err.msdu_continuation_err =
9650 					soc->stats.rx.err.msdu_continuation_err;
9651 	soc_stats->rx.err.ssn_update_count = soc->stats.rx.err.ssn_update_count;
9652 	soc_stats->rx.err.bar_handle_fail_count =
9653 					soc->stats.rx.err.bar_handle_fail_count;
9654 	soc_stats->rx.err.intrabss_eapol_drop =
9655 					soc->stats.rx.err.intrabss_eapol_drop;
9656 	soc_stats->rx.err.pn_in_dest_check_fail =
9657 					soc->stats.rx.err.pn_in_dest_check_fail;
9658 	soc_stats->rx.err.msdu_len_err = soc->stats.rx.err.msdu_len_err;
9659 	soc_stats->rx.err.rx_flush_count = soc->stats.rx.err.rx_flush_count;
9660 	/* soc ast stats */
9661 	soc_stats->ast.added = soc->stats.ast.added;
9662 	soc_stats->ast.deleted = soc->stats.ast.deleted;
9663 	soc_stats->ast.aged_out = soc->stats.ast.aged_out;
9664 	soc_stats->ast.map_err = soc->stats.ast.map_err;
9665 	soc_stats->ast.ast_mismatch = soc->stats.ast.ast_mismatch;
9666 	/* soc mec stats */
9667 	soc_stats->mec.added = soc->stats.mec.added;
9668 	soc_stats->mec.deleted = soc->stats.mec.deleted;
9669 
9670 	return QDF_STATUS_SUCCESS;
9671 }
9672 
9673 #ifdef QCA_PEER_EXT_STATS
9674 QDF_STATUS
dp_txrx_get_peer_delay_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_delay_tid_stats * delay_stats)9675 dp_txrx_get_peer_delay_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
9676 			     uint8_t *peer_mac,
9677 			     struct cdp_delay_tid_stats *delay_stats)
9678 {
9679 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9680 	struct dp_peer *peer = NULL;
9681 	struct dp_peer_delay_stats *pext_stats;
9682 	struct cdp_delay_rx_stats *rx_delay;
9683 	struct cdp_delay_tx_stats *tx_delay;
9684 	uint8_t tid;
9685 	struct cdp_peer_info peer_info = { 0 };
9686 
9687 	if (!wlan_cfg_is_peer_ext_stats_enabled(soc->wlan_cfg_ctx))
9688 		return QDF_STATUS_E_FAILURE;
9689 
9690 	DP_PEER_INFO_PARAMS_INIT(&peer_info, vdev_id, peer_mac, false,
9691 				 CDP_WILD_PEER_TYPE);
9692 
9693 	peer = dp_peer_hash_find_wrapper(soc, &peer_info, DP_MOD_ID_CDP);
9694 	if (!peer)
9695 		return QDF_STATUS_E_FAILURE;
9696 
9697 	if (!peer->txrx_peer) {
9698 		dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
9699 		return QDF_STATUS_E_FAILURE;
9700 	}
9701 
9702 	pext_stats = peer->txrx_peer->delay_stats;
9703 	if (!pext_stats) {
9704 		dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
9705 		return QDF_STATUS_E_FAILURE;
9706 	}
9707 
9708 	for (tid = 0; tid < CDP_MAX_DATA_TIDS; tid++) {
9709 		rx_delay = &delay_stats[tid].rx_delay;
9710 		dp_accumulate_delay_tid_stats(soc, pext_stats->delay_tid_stats,
9711 					      &rx_delay->to_stack_delay, tid,
9712 					      CDP_HIST_TYPE_REAP_STACK);
9713 		tx_delay = &delay_stats[tid].tx_delay;
9714 		dp_accumulate_delay_avg_stats(pext_stats->delay_tid_stats,
9715 					      tx_delay,
9716 					      tid);
9717 		dp_accumulate_delay_tid_stats(soc, pext_stats->delay_tid_stats,
9718 					      &tx_delay->tx_swq_delay, tid,
9719 					      CDP_HIST_TYPE_SW_ENQEUE_DELAY);
9720 		dp_accumulate_delay_tid_stats(soc, pext_stats->delay_tid_stats,
9721 					      &tx_delay->hwtx_delay, tid,
9722 					      CDP_HIST_TYPE_HW_COMP_DELAY);
9723 	}
9724 	dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
9725 
9726 	return QDF_STATUS_SUCCESS;
9727 }
9728 #else
9729 QDF_STATUS
dp_txrx_get_peer_delay_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_delay_tid_stats * delay_stats)9730 dp_txrx_get_peer_delay_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
9731 			     uint8_t *peer_mac,
9732 			     struct cdp_delay_tid_stats *delay_stats)
9733 {
9734 	return QDF_STATUS_E_FAILURE;
9735 }
9736 #endif /* QCA_PEER_EXT_STATS */
9737 
9738 #ifdef WLAN_PEER_JITTER
9739 QDF_STATUS
dp_txrx_get_peer_jitter_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_tid_stats * tid_stats)9740 dp_txrx_get_peer_jitter_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
9741 			      uint8_t vdev_id, uint8_t *peer_mac,
9742 			      struct cdp_peer_tid_stats *tid_stats)
9743 {
9744 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9745 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
9746 	struct dp_peer *peer = NULL;
9747 	uint8_t tid;
9748 	struct cdp_peer_info peer_info = { 0 };
9749 	struct cdp_peer_tid_stats *jitter_stats;
9750 	uint8_t ring_id;
9751 
9752 	if (!pdev)
9753 		return QDF_STATUS_E_FAILURE;
9754 
9755 	if (!wlan_cfg_is_peer_jitter_stats_enabled(soc->wlan_cfg_ctx))
9756 		return QDF_STATUS_E_FAILURE;
9757 
9758 	DP_PEER_INFO_PARAMS_INIT(&peer_info, vdev_id, peer_mac, false,
9759 				 CDP_WILD_PEER_TYPE);
9760 
9761 	peer = dp_peer_hash_find_wrapper(soc, &peer_info, DP_MOD_ID_CDP);
9762 	if (!peer)
9763 		return QDF_STATUS_E_FAILURE;
9764 
9765 	if (!peer->txrx_peer || !peer->txrx_peer->jitter_stats) {
9766 		dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
9767 		return QDF_STATUS_E_FAILURE;
9768 	}
9769 
9770 	if (wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx)) {
9771 		for (tid = 0; tid < qdf_min(CDP_DATA_TID_MAX, DP_MAX_TIDS); tid++) {
9772 			struct cdp_peer_tid_stats *rx_tid =
9773 					&peer->txrx_peer->jitter_stats[tid];
9774 
9775 			tid_stats[tid].tx_avg_jitter = rx_tid->tx_avg_jitter;
9776 			tid_stats[tid].tx_avg_delay = rx_tid->tx_avg_delay;
9777 			tid_stats[tid].tx_avg_err = rx_tid->tx_avg_err;
9778 			tid_stats[tid].tx_total_success = rx_tid->tx_total_success;
9779 			tid_stats[tid].tx_drop = rx_tid->tx_drop;
9780 		}
9781 
9782 	} else {
9783 		jitter_stats = peer->txrx_peer->jitter_stats;
9784 		for (tid = 0; tid < qdf_min(CDP_DATA_TID_MAX, DP_MAX_TIDS); tid++) {
9785 			for (ring_id = 0; ring_id < CDP_MAX_TXRX_CTX; ring_id++) {
9786 				struct cdp_peer_tid_stats *rx_tid =
9787 					&jitter_stats[tid *
9788 					CDP_MAX_TXRX_CTX + ring_id];
9789 				tid_stats[tid].tx_avg_jitter =
9790 					(rx_tid->tx_avg_jitter +
9791 					tid_stats[tid].tx_avg_jitter) >> 1;
9792 				tid_stats[tid].tx_avg_delay =
9793 					(rx_tid->tx_avg_delay +
9794 					tid_stats[tid].tx_avg_delay) >> 1;
9795 				tid_stats[tid].tx_avg_err = (rx_tid->tx_avg_err
9796 					+ tid_stats[tid].tx_avg_err) >> 1;
9797 				tid_stats[tid].tx_total_success +=
9798 						rx_tid->tx_total_success;
9799 				tid_stats[tid].tx_drop += rx_tid->tx_drop;
9800 			}
9801 		}
9802 	}
9803 
9804 	dp_peer_unref_delete(peer, DP_MOD_ID_CDP);
9805 
9806 	return QDF_STATUS_SUCCESS;
9807 }
9808 #else
9809 QDF_STATUS
dp_txrx_get_peer_jitter_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_tid_stats * tid_stats)9810 dp_txrx_get_peer_jitter_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
9811 			      uint8_t vdev_id, uint8_t *peer_mac,
9812 			      struct cdp_peer_tid_stats *tid_stats)
9813 {
9814 	return QDF_STATUS_E_FAILURE;
9815 }
9816 #endif /* WLAN_PEER_JITTER */
9817 
9818 #ifdef WLAN_TX_PKT_CAPTURE_ENH
9819 QDF_STATUS
dp_peer_get_tx_capture_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_tx_capture_stats * stats)9820 dp_peer_get_tx_capture_stats(struct cdp_soc_t *soc_hdl,
9821 			     uint8_t vdev_id, uint8_t *peer_mac,
9822 			     struct cdp_peer_tx_capture_stats *stats)
9823 {
9824 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9825 	struct dp_peer *peer = dp_peer_find_hash_find(soc, peer_mac, 0, vdev_id,
9826 						      DP_MOD_ID_TX_CAPTURE);
9827 	QDF_STATUS status;
9828 
9829 	if (!peer)
9830 		return QDF_STATUS_E_FAILURE;
9831 
9832 	status = dp_monitor_peer_tx_capture_get_stats(soc, peer, stats);
9833 	dp_peer_unref_delete(peer, DP_MOD_ID_TX_CAPTURE);
9834 
9835 	return status;
9836 }
9837 
9838 QDF_STATUS
dp_pdev_get_tx_capture_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_pdev_tx_capture_stats * stats)9839 dp_pdev_get_tx_capture_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
9840 			     struct cdp_pdev_tx_capture_stats *stats)
9841 {
9842 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9843 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
9844 
9845 	if (!pdev)
9846 		return QDF_STATUS_E_FAILURE;
9847 
9848 	return dp_monitor_pdev_tx_capture_get_stats(soc, pdev, stats);
9849 }
9850 #else /* WLAN_TX_PKT_CAPTURE_ENH */
9851 QDF_STATUS
dp_peer_get_tx_capture_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * peer_mac,struct cdp_peer_tx_capture_stats * stats)9852 dp_peer_get_tx_capture_stats(struct cdp_soc_t *soc_hdl,
9853 			     uint8_t vdev_id, uint8_t *peer_mac,
9854 			     struct cdp_peer_tx_capture_stats *stats)
9855 {
9856 	return QDF_STATUS_E_FAILURE;
9857 }
9858 
9859 QDF_STATUS
dp_pdev_get_tx_capture_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_pdev_tx_capture_stats * stats)9860 dp_pdev_get_tx_capture_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
9861 			     struct cdp_pdev_tx_capture_stats *stats)
9862 {
9863 	return QDF_STATUS_E_FAILURE;
9864 }
9865 #endif /* WLAN_TX_PKT_CAPTURE_ENH */
9866 
9867 #ifdef WLAN_CONFIG_TELEMETRY_AGENT
9868 QDF_STATUS
dp_get_pdev_telemetry_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_pdev_telemetry_stats * stats)9869 dp_get_pdev_telemetry_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
9870 			    struct cdp_pdev_telemetry_stats *stats)
9871 {
9872 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9873 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
9874 	uint8_t ac = 0;
9875 
9876 	if (!pdev)
9877 		return QDF_STATUS_E_FAILURE;
9878 
9879 	/* consumption is in micro seconds, convert it to seconds and
9880 	 * then calculate %age per sec
9881 	 */
9882 	for (ac = 0; ac < WME_AC_MAX; ac++) {
9883 		stats->link_airtime[ac] =
9884 			((pdev->stats.telemetry_stats.link_airtime[ac] * 100) / 1000000);
9885 		stats->tx_mpdu_failed[ac] = pdev->stats.telemetry_stats.tx_mpdu_failed[ac];
9886 		stats->tx_mpdu_total[ac] = pdev->stats.telemetry_stats.tx_mpdu_total[ac];
9887 	}
9888 	return QDF_STATUS_SUCCESS;
9889 }
9890 
9891 QDF_STATUS
dp_get_peer_telemetry_stats(struct cdp_soc_t * soc_hdl,uint8_t * addr,struct cdp_peer_telemetry_stats * stats)9892 dp_get_peer_telemetry_stats(struct cdp_soc_t *soc_hdl, uint8_t *addr,
9893 			    struct cdp_peer_telemetry_stats *stats)
9894 {
9895 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9896 	struct dp_peer *peer = dp_peer_find_hash_find(soc, addr, 0, DP_VDEV_ALL,
9897 						      DP_MOD_ID_MISC);
9898 
9899 	if (!peer)
9900 		return QDF_STATUS_E_FAILURE;
9901 
9902 	dp_monitor_peer_telemetry_stats(peer, stats);
9903 	dp_peer_unref_delete(peer, DP_MOD_ID_MISC);
9904 
9905 	return QDF_STATUS_SUCCESS;
9906 }
9907 
9908 QDF_STATUS
dp_get_pdev_deter_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_pdev_deter_stats * stats)9909 dp_get_pdev_deter_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
9910 			struct cdp_pdev_deter_stats *stats)
9911 {
9912 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9913 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
9914 
9915 	if (!pdev)
9916 		return QDF_STATUS_E_FAILURE;
9917 
9918 	qdf_mem_copy(stats->dl_ofdma_usr, pdev->stats.deter_stats.dl_ofdma_usr,
9919 		     sizeof(stats->dl_ofdma_usr[0]) * CDP_MU_MAX_USERS);
9920 	qdf_mem_copy(stats->ul_ofdma_usr, pdev->stats.deter_stats.ul_ofdma_usr,
9921 		     sizeof(stats->ul_ofdma_usr[0]) * CDP_MU_MAX_USERS);
9922 	qdf_mem_copy(stats->dl_mimo_usr, pdev->stats.deter_stats.dl_mimo_usr,
9923 		     sizeof(stats->dl_mimo_usr[0]) * CDP_MU_MAX_MIMO_USERS);
9924 	qdf_mem_copy(stats->ul_mimo_usr, pdev->stats.deter_stats.ul_mimo_usr,
9925 		     sizeof(stats->ul_mimo_usr[0]) * CDP_MU_MAX_MIMO_USERS);
9926 
9927 	qdf_mem_copy(stats->ul_mode_cnt, pdev->stats.deter_stats.ul_mode_cnt,
9928 		     sizeof(stats->ul_mode_cnt[0]) * TX_MODE_UL_MAX);
9929 	qdf_mem_copy(stats->dl_mode_cnt, pdev->stats.deter_stats.dl_mode_cnt,
9930 		     sizeof(stats->dl_mode_cnt[0]) * TX_MODE_DL_MAX);
9931 	qdf_mem_copy(stats->ch_access_delay,
9932 		     pdev->stats.deter_stats.ch_access_delay,
9933 		     sizeof(stats->ch_access_delay[0]) * WME_AC_MAX);
9934 
9935 	qdf_mem_copy(stats->ts,
9936 		     pdev->stats.deter_stats.ts,
9937 		     sizeof(stats->ts[0]) * TX_MODE_UL_MAX);
9938 
9939 	stats->ch_util.ap_tx_util = pdev->stats.deter_stats.ch_util.ap_tx_util;
9940 	stats->ch_util.ap_rx_util = pdev->stats.deter_stats.ch_util.ap_rx_util;
9941 	stats->ch_util.ap_chan_util =
9942 			pdev->stats.deter_stats.ch_util.ap_chan_util;
9943 	stats->rx_su_cnt = pdev->stats.deter_stats.rx_su_cnt;
9944 
9945 	return QDF_STATUS_SUCCESS;
9946 }
9947 
9948 QDF_STATUS
dp_get_peer_deter_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id,uint8_t * addr,struct cdp_peer_deter_stats * stats)9949 dp_get_peer_deter_stats(struct cdp_soc_t *soc_hdl,
9950 			uint8_t vdev_id,
9951 			uint8_t *addr,
9952 			struct cdp_peer_deter_stats *stats)
9953 {
9954 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9955 	struct dp_peer *peer = dp_peer_find_hash_find(soc, addr, 0, vdev_id,
9956 						      DP_MOD_ID_MISC);
9957 
9958 	if (!peer)
9959 		return QDF_STATUS_E_FAILURE;
9960 
9961 	dp_monitor_peer_deter_stats(peer, stats);
9962 	dp_peer_unref_delete(peer, DP_MOD_ID_MISC);
9963 
9964 	return QDF_STATUS_SUCCESS;
9965 }
9966 
9967 QDF_STATUS
dp_update_pdev_chan_util_stats(struct cdp_soc_t * soc_hdl,uint8_t pdev_id,struct cdp_pdev_chan_util_stats * ch_util)9968 dp_update_pdev_chan_util_stats(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
9969 			       struct cdp_pdev_chan_util_stats *ch_util)
9970 {
9971 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
9972 	struct dp_pdev *pdev = dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
9973 
9974 	if (!pdev)
9975 		return QDF_STATUS_E_FAILURE;
9976 
9977 	pdev->stats.deter_stats.ch_util.ap_tx_util = ch_util->ap_tx_util;
9978 	pdev->stats.deter_stats.ch_util.ap_rx_util = ch_util->ap_rx_util;
9979 	pdev->stats.deter_stats.ch_util.ap_chan_util = ch_util->ap_chan_util;
9980 
9981 	return QDF_STATUS_SUCCESS;
9982 }
9983 #endif
9984 #ifndef CONFIG_AP_PLATFORM
9985 #if defined WLAN_FEATURE_11BE_MLO && defined DP_MLO_LINK_STATS_SUPPORT
9986 /**
9987  * dp_print_per_link_peer_txrx_stats() - print link peer stats
9988  * @peer_stats: buffer holding peer stats
9989  * @pdev: DP pdev handle
9990  *
9991  * return None
9992  */
9993 static inline void
dp_print_per_link_peer_txrx_stats(struct cdp_peer_stats * peer_stats,struct dp_pdev * pdev)9994 dp_print_per_link_peer_txrx_stats(struct cdp_peer_stats *peer_stats,
9995 				  struct dp_pdev *pdev)
9996 {
9997 	uint8_t i;
9998 	uint32_t index;
9999 	uint32_t j;
10000 	char nss[DP_NSS_LENGTH];
10001 	char mu_group_id[DP_MU_GROUP_LENGTH];
10002 	uint32_t *pnss;
10003 	enum cdp_mu_packet_type rx_mu_type;
10004 	struct cdp_rx_mu *rx_mu;
10005 
10006 	DP_PRINT_STATS("peer_mac_addr = " QDF_MAC_ADDR_FMT,
10007 		       QDF_MAC_ADDR_REF(peer_stats->mac_addr.bytes));
10008 	DP_PRINT_STATS("Node Tx Stats:");
10009 	DP_PRINT_STATS("Success Packets = %llu",
10010 		       peer_stats->tx.tx_success.num);
10011 	DP_PRINT_STATS("Success Bytes = %llu",
10012 		       peer_stats->tx.tx_success.bytes);
10013 	DP_PRINT_STATS("Success Packets in TWT Session = %llu",
10014 		       peer_stats->tx.tx_success_twt.num);
10015 	DP_PRINT_STATS("Success Bytes in TWT Session = %llu",
10016 		       peer_stats->tx.tx_success_twt.bytes);
10017 	DP_PRINT_STATS("Unicast Success Packets = %llu",
10018 		       peer_stats->tx.ucast.num);
10019 	DP_PRINT_STATS("Unicast Success Bytes = %llu",
10020 		       peer_stats->tx.ucast.bytes);
10021 	DP_PRINT_STATS("Multicast Success Packets = %llu",
10022 		       peer_stats->tx.mcast.num);
10023 	DP_PRINT_STATS("Multicast Success Bytes = %llu",
10024 		       peer_stats->tx.mcast.bytes);
10025 	DP_PRINT_STATS("Broadcast Success Packets = %llu",
10026 		       peer_stats->tx.bcast.num);
10027 	DP_PRINT_STATS("Broadcast Success Bytes = %llu",
10028 		       peer_stats->tx.bcast.bytes);
10029 	DP_PRINT_STATS("Packets Successfully Sent after one or more retry = %u",
10030 		       peer_stats->tx.retry_count);
10031 	DP_PRINT_STATS("Packets  Sent Success after more than one retry = %u",
10032 		       peer_stats->tx.multiple_retry_count);
10033 	DP_PRINT_STATS("Packets Failed due to retry threshold breach = %u",
10034 		       peer_stats->tx.failed_retry_count);
10035 	DP_PRINT_STATS("Packets In OFDMA = %u",
10036 		       peer_stats->tx.ofdma);
10037 	DP_PRINT_STATS("Packets In STBC = %u",
10038 		       peer_stats->tx.stbc);
10039 	DP_PRINT_STATS("Packets In LDPC = %u",
10040 		       peer_stats->tx.ldpc);
10041 	DP_PRINT_STATS("Packet Retries = %u",
10042 		       peer_stats->tx.retries);
10043 	DP_PRINT_STATS("MSDU's Part of AMSDU = %u",
10044 		       peer_stats->tx.amsdu_cnt);
10045 	DP_PRINT_STATS("Msdu's As Part of Ampdu = %u",
10046 		       peer_stats->tx.non_ampdu_cnt);
10047 	DP_PRINT_STATS("Msdu's As Ampdu = %u",
10048 		       peer_stats->tx.ampdu_cnt);
10049 	DP_PRINT_STATS("Last Packet RSSI = %u",
10050 		       peer_stats->tx.last_ack_rssi);
10051 	DP_PRINT_STATS("Dropped At FW: Removed Pkts = %llu",
10052 		       peer_stats->tx.dropped.fw_rem.num);
10053 	DP_PRINT_STATS("Release source not TQM = %u",
10054 		       peer_stats->tx.release_src_not_tqm);
10055 	if (pdev &&
10056 	    !wlan_cfg_get_dp_pdev_nss_enabled(pdev->wlan_cfg_ctx)) {
10057 		DP_PRINT_STATS("Dropped At FW: Removed bytes = %llu",
10058 			       peer_stats->tx.dropped.fw_rem.bytes);
10059 	}
10060 	DP_PRINT_STATS("Dropped At FW: Removed transmitted = %u",
10061 		       peer_stats->tx.dropped.fw_rem_tx);
10062 	DP_PRINT_STATS("Dropped At FW: Removed Untransmitted = %u",
10063 		       peer_stats->tx.dropped.fw_rem_notx);
10064 	DP_PRINT_STATS("Dropped At FW: removed untransmitted fw_reason1 = %u",
10065 		       peer_stats->tx.dropped.fw_reason1);
10066 	DP_PRINT_STATS("Dropped At FW: removed untransmitted fw_reason2 = %u",
10067 		       peer_stats->tx.dropped.fw_reason2);
10068 	DP_PRINT_STATS("Dropped At FW: removed untransmitted fw_reason3 = %u",
10069 		       peer_stats->tx.dropped.fw_reason3);
10070 	DP_PRINT_STATS("Dropped At FW:removed untransmitted disable queue = %u",
10071 		       peer_stats->tx.dropped.fw_rem_queue_disable);
10072 	DP_PRINT_STATS("Dropped At FW: removed untransmitted no match = %u",
10073 		       peer_stats->tx.dropped.fw_rem_no_match);
10074 	DP_PRINT_STATS("Dropped due to HW threshold criteria = %u",
10075 		       peer_stats->tx.dropped.drop_threshold);
10076 	DP_PRINT_STATS("Dropped due Link desc not available drop in HW = %u",
10077 		       peer_stats->tx.dropped.drop_link_desc_na);
10078 	DP_PRINT_STATS("Drop bit set or invalid flow = %u",
10079 		       peer_stats->tx.dropped.invalid_drop);
10080 	DP_PRINT_STATS("MCAST vdev drop in HW = %u",
10081 		       peer_stats->tx.dropped.mcast_vdev_drop);
10082 	DP_PRINT_STATS("Dropped : Age Out = %u",
10083 		       peer_stats->tx.dropped.age_out);
10084 	DP_PRINT_STATS("Dropped : Invalid Reason = %u",
10085 		       peer_stats->tx.dropped.invalid_rr);
10086 	DP_PRINT_STATS("NAWDS : ");
10087 	DP_PRINT_STATS("Nawds multicast Drop Tx Packet = %u",
10088 		       peer_stats->tx.nawds_mcast_drop);
10089 	DP_PRINT_STATS("	Nawds multicast  Tx Packet Count = %llu",
10090 		       peer_stats->tx.nawds_mcast.num);
10091 	DP_PRINT_STATS("	Nawds multicast Tx Packet Bytes = %llu",
10092 		       peer_stats->tx.nawds_mcast.bytes);
10093 
10094 	DP_PRINT_STATS("PPDU's = %u", peer_stats->tx.tx_ppdus);
10095 	DP_PRINT_STATS("Number of PPDU's with Punctured Preamble = %u",
10096 		       peer_stats->tx.pream_punct_cnt);
10097 	DP_PRINT_STATS("MPDU's Successful = %u",
10098 		       peer_stats->tx.tx_mpdus_success);
10099 	DP_PRINT_STATS("MPDU's Tried = %u",
10100 		       peer_stats->tx.tx_mpdus_tried);
10101 
10102 	DP_PRINT_STATS("Rate Info:");
10103 	dp_print_common_rates_info(peer_stats->tx.pkt_type);
10104 	DP_PRINT_STATS("SGI = 0.8us %u 0.4us %u 1.6us %u 3.2us %u",
10105 		       peer_stats->tx.sgi_count[0],
10106 		       peer_stats->tx.sgi_count[1],
10107 		       peer_stats->tx.sgi_count[2],
10108 		       peer_stats->tx.sgi_count[3]);
10109 
10110 	DP_PRINT_STATS("Wireless Mutlimedia ");
10111 	DP_PRINT_STATS("	 Best effort = %u",
10112 		       peer_stats->tx.wme_ac_type[0]);
10113 	DP_PRINT_STATS("	 Background= %u",
10114 		       peer_stats->tx.wme_ac_type[1]);
10115 	DP_PRINT_STATS("	 Video = %u",
10116 		       peer_stats->tx.wme_ac_type[2]);
10117 	DP_PRINT_STATS("	 Voice = %u",
10118 		       peer_stats->tx.wme_ac_type[3]);
10119 
10120 	DP_PRINT_STATS("Excess Retries per AC ");
10121 	DP_PRINT_STATS("	 Best effort = %u",
10122 		       peer_stats->tx.excess_retries_per_ac[0]);
10123 	DP_PRINT_STATS("	 Background= %u",
10124 		       peer_stats->tx.excess_retries_per_ac[1]);
10125 	DP_PRINT_STATS("	 Video = %u",
10126 		       peer_stats->tx.excess_retries_per_ac[2]);
10127 	DP_PRINT_STATS("	 Voice = %u",
10128 		       peer_stats->tx.excess_retries_per_ac[3]);
10129 
10130 	pnss = &peer_stats->tx.nss[0];
10131 	dp_print_nss(nss, pnss, SS_COUNT);
10132 
10133 	DP_PRINT_STATS("NSS(1-8) = %s", nss);
10134 
10135 	DP_PRINT_STATS("Transmit Type :");
10136 	DP_PRINT_STATS("MSDUs Success: SU %u, MU_MIMO %u, MU_OFDMA %u, MU_MIMO_OFDMA %u",
10137 		       peer_stats->tx.transmit_type[SU].num_msdu,
10138 		       peer_stats->tx.transmit_type[MU_MIMO].num_msdu,
10139 		       peer_stats->tx.transmit_type[MU_OFDMA].num_msdu,
10140 		       peer_stats->tx.transmit_type[MU_MIMO_OFDMA].num_msdu);
10141 
10142 	DP_PRINT_STATS("MPDUs Success: SU %u, MU_MIMO %u, MU_OFDMA %u, MU_MIMO_OFDMA %u",
10143 		       peer_stats->tx.transmit_type[SU].num_mpdu,
10144 		       peer_stats->tx.transmit_type[MU_MIMO].num_mpdu,
10145 		       peer_stats->tx.transmit_type[MU_OFDMA].num_mpdu,
10146 		       peer_stats->tx.transmit_type[MU_MIMO_OFDMA].num_mpdu);
10147 
10148 	DP_PRINT_STATS("MPDUs Tried: SU %u, MU_MIMO %u, MU_OFDMA %u, MU_MIMO_OFDMA %u",
10149 		       peer_stats->tx.transmit_type[SU].mpdu_tried,
10150 		       peer_stats->tx.transmit_type[MU_MIMO].mpdu_tried,
10151 		       peer_stats->tx.transmit_type[MU_OFDMA].mpdu_tried,
10152 		       peer_stats->tx.transmit_type[MU_MIMO_OFDMA].mpdu_tried);
10153 
10154 	for (i = 0; i < MAX_MU_GROUP_ID;) {
10155 		index = 0;
10156 		for (j = 0; j < DP_MU_GROUP_SHOW && i < MAX_MU_GROUP_ID;
10157 			j++) {
10158 			index += qdf_snprint(&mu_group_id[index],
10159 					     DP_MU_GROUP_LENGTH - index,
10160 					     " %u",
10161 					     peer_stats->tx.mu_group_id[i]);
10162 			i++;
10163 		}
10164 
10165 		DP_PRINT_STATS("User position list for GID %02d->%u: [%s]",
10166 			       i - DP_MU_GROUP_SHOW, i - 1,
10167 			       mu_group_id);
10168 	}
10169 
10170 	DP_PRINT_STATS("Last Packet RU index [%u], Size [%u]",
10171 		       peer_stats->tx.ru_start,
10172 		       peer_stats->tx.ru_tones);
10173 
10174 	DP_PRINT_STATS("Aggregation:");
10175 	DP_PRINT_STATS("Number of Msdu's Part of Amsdu = %u",
10176 		       peer_stats->tx.amsdu_cnt);
10177 	DP_PRINT_STATS("Number of Msdu's With No Msdu Level Aggregation = %u",
10178 		       peer_stats->tx.non_amsdu_cnt);
10179 
10180 	if (pdev && pdev->soc->arch_ops.txrx_print_peer_stats)
10181 		pdev->soc->arch_ops.txrx_print_peer_stats(peer_stats,
10182 							PEER_TX_STATS);
10183 
10184 	DP_PRINT_STATS("Node Rx Stats:");
10185 	for (i = 0; i <  CDP_MAX_RX_RINGS; i++) {
10186 		DP_PRINT_STATS("Ring Id = %u", i);
10187 		DP_PRINT_STATS("	Packets Received = %llu",
10188 			       peer_stats->rx.rcvd_reo[i].num);
10189 		DP_PRINT_STATS("	Bytes Received = %llu",
10190 			       peer_stats->rx.rcvd_reo[i].bytes);
10191 	}
10192 	for (i = 0; i < CDP_MAX_LMACS; i++)
10193 		DP_PRINT_STATS("Packets Received on lmac[%u] = %llu ( %llu ),",
10194 			       i, peer_stats->rx.rx_lmac[i].num,
10195 			       peer_stats->rx.rx_lmac[i].bytes);
10196 
10197 	DP_PRINT_STATS("Unicast Packets Received = %llu",
10198 		       peer_stats->rx.unicast.num);
10199 	DP_PRINT_STATS("Unicast Bytes Received = %llu",
10200 		       peer_stats->rx.unicast.bytes);
10201 	DP_PRINT_STATS("Multicast Packets Received = %llu",
10202 		       peer_stats->rx.multicast.num);
10203 	DP_PRINT_STATS("Multicast Bytes Received = %llu",
10204 		       peer_stats->rx.multicast.bytes);
10205 	DP_PRINT_STATS("Broadcast Packets Received = %llu",
10206 		       peer_stats->rx.bcast.num);
10207 	DP_PRINT_STATS("Broadcast Bytes Received = %llu",
10208 		       peer_stats->rx.bcast.bytes);
10209 	DP_PRINT_STATS("Packets Sent To Stack in TWT Session = %llu",
10210 		       peer_stats->rx.to_stack_twt.num);
10211 	DP_PRINT_STATS("Bytes Sent To Stack in TWT Session = %llu",
10212 		       peer_stats->rx.to_stack_twt.bytes);
10213 	DP_PRINT_STATS("Intra BSS Packets Received = %llu",
10214 		       peer_stats->rx.intra_bss.pkts.num);
10215 	DP_PRINT_STATS("Intra BSS Bytes Received = %llu",
10216 		       peer_stats->rx.intra_bss.pkts.bytes);
10217 	DP_PRINT_STATS("Intra BSS Packets Failed = %llu",
10218 		       peer_stats->rx.intra_bss.fail.num);
10219 	DP_PRINT_STATS("Intra BSS Bytes Failed = %llu",
10220 		       peer_stats->rx.intra_bss.fail.bytes);
10221 	DP_PRINT_STATS("Intra BSS MDNS Packets Not Forwarded  = %u",
10222 		       peer_stats->rx.intra_bss.mdns_no_fwd);
10223 	DP_PRINT_STATS("Raw Packets Received = %llu",
10224 		       peer_stats->rx.raw.num);
10225 	DP_PRINT_STATS("Raw Bytes Received = %llu",
10226 		       peer_stats->rx.raw.bytes);
10227 	DP_PRINT_STATS("Errors: MIC Errors = %u",
10228 		       peer_stats->rx.err.mic_err);
10229 	DP_PRINT_STATS("Errors: Decryption Errors = %u",
10230 		       peer_stats->rx.err.decrypt_err);
10231 	DP_PRINT_STATS("Errors: PN Errors = %u",
10232 		       peer_stats->rx.err.pn_err);
10233 	DP_PRINT_STATS("Errors: OOR Errors = %u",
10234 		       peer_stats->rx.err.oor_err);
10235 	DP_PRINT_STATS("Errors: 2k Jump Errors = %u",
10236 		       peer_stats->rx.err.jump_2k_err);
10237 	DP_PRINT_STATS("Errors: RXDMA Wifi Parse Errors = %u",
10238 		       peer_stats->rx.err.rxdma_wifi_parse_err);
10239 	DP_PRINT_STATS("Msdu's Received As Part of Ampdu = %u",
10240 		       peer_stats->rx.non_ampdu_cnt);
10241 	DP_PRINT_STATS("Msdu's Received As Ampdu = %u",
10242 		       peer_stats->rx.ampdu_cnt);
10243 	DP_PRINT_STATS("Msdu's Received Not Part of Amsdu's = %u",
10244 		       peer_stats->rx.non_amsdu_cnt);
10245 	DP_PRINT_STATS("MSDUs Received As Part of Amsdu = %u",
10246 		       peer_stats->rx.amsdu_cnt);
10247 	DP_PRINT_STATS("MSDU Rx Retries= %u",
10248 		       peer_stats->rx.rx_retries);
10249 	DP_PRINT_STATS("MPDU Rx Retries= %u",
10250 		       peer_stats->rx.mpdu_retry_cnt);
10251 	DP_PRINT_STATS("NAWDS : ");
10252 	DP_PRINT_STATS("	Nawds multicast Drop Rx Packet = %u",
10253 		       peer_stats->rx.nawds_mcast_drop);
10254 	DP_PRINT_STATS(" 3address multicast Drop Rx Packet = %u",
10255 		       peer_stats->rx.mcast_3addr_drop);
10256 	DP_PRINT_STATS("SGI = 0.8us %u 0.4us %u 1.6us %u 3.2us %u",
10257 		       peer_stats->rx.sgi_count[0],
10258 		       peer_stats->rx.sgi_count[1],
10259 		       peer_stats->rx.sgi_count[2],
10260 		       peer_stats->rx.sgi_count[3]);
10261 
10262 	DP_PRINT_STATS("Wireless Mutlimedia ");
10263 	DP_PRINT_STATS("	 Best effort = %u",
10264 		       peer_stats->rx.wme_ac_type[0]);
10265 	DP_PRINT_STATS("	 Background= %u",
10266 		       peer_stats->rx.wme_ac_type[1]);
10267 	DP_PRINT_STATS("	 Video = %u",
10268 		       peer_stats->rx.wme_ac_type[2]);
10269 	DP_PRINT_STATS("	 Voice = %u",
10270 		       peer_stats->rx.wme_ac_type[3]);
10271 
10272 	DP_PRINT_STATS(" Total Rx PPDU Count = %u",
10273 		       peer_stats->rx.rx_ppdus);
10274 	DP_PRINT_STATS(" Total Rx MPDU Count = %u",
10275 		       peer_stats->rx.rx_mpdus);
10276 	DP_PRINT_STATS("MSDU Reception Type");
10277 	DP_PRINT_STATS("SU %u MU_MIMO %u MU_OFDMA %u MU_OFDMA_MIMO %u",
10278 		       peer_stats->rx.reception_type[0],
10279 		       peer_stats->rx.reception_type[1],
10280 		       peer_stats->rx.reception_type[2],
10281 		       peer_stats->rx.reception_type[3]);
10282 	DP_PRINT_STATS("PPDU Reception Type");
10283 	DP_PRINT_STATS("SU %u MU_MIMO %u MU_OFDMA %u MU_OFDMA_MIMO %u",
10284 		       peer_stats->rx.ppdu_cnt[0],
10285 		       peer_stats->rx.ppdu_cnt[1],
10286 		       peer_stats->rx.ppdu_cnt[2],
10287 		       peer_stats->rx.ppdu_cnt[3]);
10288 
10289 	dp_print_common_rates_info(peer_stats->rx.pkt_type);
10290 	dp_print_common_ppdu_rates_info(&peer_stats->rx.su_ax_ppdu_cnt,
10291 					DOT11_AX);
10292 	dp_print_mu_ppdu_rates_info(&peer_stats->rx.rx_mu[0]);
10293 
10294 	pnss = &peer_stats->rx.nss[0];
10295 	dp_print_nss(nss, pnss, SS_COUNT);
10296 	DP_PRINT_STATS("MSDU Count");
10297 	DP_PRINT_STATS("	NSS(1-8) = %s", nss);
10298 
10299 	DP_PRINT_STATS("reception mode SU");
10300 	pnss = &peer_stats->rx.ppdu_nss[0];
10301 	dp_print_nss(nss, pnss, SS_COUNT);
10302 
10303 	DP_PRINT_STATS("	PPDU Count");
10304 	DP_PRINT_STATS("	NSS(1-8) = %s", nss);
10305 
10306 	DP_PRINT_STATS("	MPDU OK = %u, MPDU Fail = %u",
10307 		       peer_stats->rx.mpdu_cnt_fcs_ok,
10308 		       peer_stats->rx.mpdu_cnt_fcs_err);
10309 
10310 	for (rx_mu_type = 0; rx_mu_type < TXRX_TYPE_MU_MAX;
10311 	     rx_mu_type++) {
10312 		DP_PRINT_STATS("reception mode %s",
10313 			       mu_reception_mode[rx_mu_type]);
10314 		rx_mu = &peer_stats->rx.rx_mu[rx_mu_type];
10315 
10316 		pnss = &rx_mu->ppdu_nss[0];
10317 		dp_print_nss(nss, pnss, SS_COUNT);
10318 		DP_PRINT_STATS("	PPDU Count");
10319 		DP_PRINT_STATS("	NSS(1-8) = %s", nss);
10320 
10321 		DP_PRINT_STATS("	MPDU OK = %u, MPDU Fail = %u",
10322 			       rx_mu->mpdu_cnt_fcs_ok,
10323 			       rx_mu->mpdu_cnt_fcs_err);
10324 	}
10325 
10326 	DP_PRINT_STATS("Aggregation:");
10327 	DP_PRINT_STATS("   Msdu's Part of Ampdu = %u",
10328 		       peer_stats->rx.ampdu_cnt);
10329 	DP_PRINT_STATS("   Msdu's With No Mpdu Level Aggregation = %u",
10330 		       peer_stats->rx.non_ampdu_cnt);
10331 	DP_PRINT_STATS("   Msdu's Part of Amsdu = %u",
10332 		       peer_stats->rx.amsdu_cnt);
10333 	DP_PRINT_STATS("   Msdu's With No Msdu Level Aggregation = %u",
10334 		       peer_stats->rx.non_amsdu_cnt);
10335 	DP_PRINT_STATS("MEC Packet Drop = %llu",
10336 		       peer_stats->rx.mec_drop.num);
10337 	DP_PRINT_STATS("MEC Byte Drop = %llu",
10338 		       peer_stats->rx.mec_drop.bytes);
10339 	DP_PRINT_STATS("Multipass Rx Packet Drop = %u",
10340 		       peer_stats->rx.multipass_rx_pkt_drop);
10341 	DP_PRINT_STATS("Peer Unauth Rx Packet Drop = %u",
10342 		       peer_stats->rx.peer_unauth_rx_pkt_drop);
10343 	DP_PRINT_STATS("Policy Check Rx Packet Drop = %u",
10344 		       peer_stats->rx.policy_check_drop);
10345 	if (pdev && pdev->soc->arch_ops.txrx_print_peer_stats)
10346 		pdev->soc->arch_ops.txrx_print_peer_stats(peer_stats,
10347 							PEER_RX_STATS);
10348 }
10349 
10350 /**
10351  * dp_print_per_link_peer_stats() - print per link peer stats of MLD peer
10352  * @peer: MLD DP_PEER handle
10353  * @peer_stats: buffer holding peer stats
10354  * @num_links: Number of Link peers.
10355  *
10356  * This API should only be called with MLD peer and peer_stats should
10357  * point to buffer of size = (sizeof(*peer_stats) * num_links).
10358  *
10359  * return None
10360  */
10361 static
dp_print_per_link_peer_stats(struct dp_peer * peer,struct cdp_peer_stats * peer_stats,uint8_t num_links)10362 void dp_print_per_link_peer_stats(struct dp_peer *peer,
10363 				  struct cdp_peer_stats *peer_stats,
10364 				  uint8_t num_links)
10365 {
10366 	uint8_t index;
10367 	struct dp_pdev *pdev = peer->vdev->pdev;
10368 
10369 	if (!IS_MLO_DP_MLD_PEER(peer))
10370 		return;
10371 
10372 	DP_PRINT_STATS("Node Tx ML peer Stats:\n");
10373 	DP_PRINT_STATS("Total Packet Completions = %llu",
10374 		       peer_stats->tx.comp_pkt.num);
10375 	DP_PRINT_STATS("Total Bytes Completions = %llu",
10376 		       peer_stats->tx.comp_pkt.bytes);
10377 	DP_PRINT_STATS("Packets Failed = %u",
10378 		       peer_stats->tx.tx_failed);
10379 	DP_PRINT_STATS("Bytes and Packets transmitted  in last one sec:");
10380 	DP_PRINT_STATS("	Bytes transmitted in last sec: %u",
10381 		       peer_stats->tx.tx_byte_rate);
10382 	DP_PRINT_STATS("	Data transmitted in last sec: %u",
10383 		       peer_stats->tx.tx_data_rate);
10384 
10385 	if (!IS_MLO_DP_LINK_PEER(peer)) {
10386 		dp_print_jitter_stats(peer, pdev);
10387 		dp_peer_print_tx_delay_stats(pdev, peer);
10388 	}
10389 
10390 	DP_PRINT_STATS("Node Rx ML peer Stats:\n");
10391 	DP_PRINT_STATS("Packets Sent To Stack = %llu",
10392 		       peer_stats->rx.to_stack.num);
10393 	DP_PRINT_STATS("Bytes Sent To Stack = %llu",
10394 		       peer_stats->rx.to_stack.bytes);
10395 	DP_PRINT_STATS("Bytes and Packets received in last one sec:");
10396 	DP_PRINT_STATS("	Bytes received in last sec: %u",
10397 		       peer_stats->rx.rx_byte_rate);
10398 	DP_PRINT_STATS("	Data received in last sec: %u",
10399 		       peer_stats->rx.rx_data_rate);
10400 	if (!IS_MLO_DP_LINK_PEER(peer))
10401 		dp_peer_print_rx_delay_stats(pdev, peer);
10402 
10403 	dp_peer_print_reo_qref_table(peer);
10404 	DP_PRINT_STATS("Per Link TxRx Stats:\n");
10405 	for (index = 0; index < num_links; index++) {
10406 		DP_PRINT_STATS("Link %u TxRx Stats:\n", index);
10407 		dp_print_per_link_peer_txrx_stats(&peer_stats[index], pdev);
10408 	}
10409 }
10410 
dp_print_per_link_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id)10411 void dp_print_per_link_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id)
10412 {
10413 	struct dp_mld_link_peers link_peers_info;
10414 	struct dp_peer *peer, *ml_peer = NULL;
10415 	struct cdp_peer_stats *peer_stats = NULL;
10416 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
10417 	struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
10418 						     DP_MOD_ID_GENERIC_STATS);
10419 	if (!vdev) {
10420 		dp_err_rl("vdev is NULL, vdev_id: %u", vdev_id);
10421 		return;
10422 	}
10423 	peer = dp_vdev_bss_peer_ref_n_get(soc, vdev, DP_MOD_ID_GENERIC_STATS);
10424 
10425 	if (!peer) {
10426 		dp_err("Peer is NULL, vdev_id: %u", vdev_id);
10427 		dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_GENERIC_STATS);
10428 		return;
10429 	}
10430 	if (IS_MLO_DP_LINK_PEER(peer))
10431 		ml_peer = peer->mld_peer;
10432 	if (ml_peer) {
10433 		dp_get_link_peers_ref_from_mld_peer(soc, ml_peer,
10434 						    &link_peers_info,
10435 						    DP_MOD_ID_GENERIC_STATS);
10436 		peer_stats = qdf_mem_malloc(sizeof(*peer_stats) *
10437 					    link_peers_info.num_links);
10438 		if (!peer_stats) {
10439 			dp_err("malloc failed, vdev_id: %u, ML peer_id: %u",
10440 			       vdev_id, ml_peer->peer_id);
10441 			dp_release_link_peers_ref(&link_peers_info,
10442 						  DP_MOD_ID_GENERIC_STATS);
10443 			goto fail;
10444 		}
10445 
10446 		dp_get_per_link_peer_stats(ml_peer, peer_stats,
10447 					   ml_peer->peer_type,
10448 					   link_peers_info.num_links);
10449 		dp_print_per_link_peer_stats(ml_peer, peer_stats,
10450 					     link_peers_info.num_links);
10451 		dp_release_link_peers_ref(&link_peers_info,
10452 					  DP_MOD_ID_GENERIC_STATS);
10453 		qdf_mem_free(peer_stats);
10454 	} else {
10455 		peer_stats = qdf_mem_malloc(sizeof(*peer_stats));
10456 		if (!peer_stats) {
10457 			dp_err("malloc failed, vdev_id: %u, peer_id: %u",
10458 			       vdev_id, peer->peer_id);
10459 			goto fail;
10460 		}
10461 		dp_get_peer_stats(peer, peer_stats);
10462 		dp_print_peer_stats(peer, peer_stats);
10463 		qdf_mem_free(peer_stats);
10464 	}
10465 
10466 fail:
10467 	dp_peer_unref_delete(peer, DP_MOD_ID_GENERIC_STATS);
10468 	dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_GENERIC_STATS);
10469 }
10470 #else
dp_print_per_link_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id)10471 void dp_print_per_link_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id)
10472 {
10473 	struct dp_peer *peer;
10474 	struct cdp_peer_stats *peer_stats = NULL;
10475 	struct dp_soc *soc = (struct dp_soc *)soc_hdl;
10476 	struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
10477 						     DP_MOD_ID_GENERIC_STATS);
10478 	if (!vdev) {
10479 		dp_err_rl("vdev is null for vdev_id: %u", vdev_id);
10480 		return;
10481 	}
10482 	peer = dp_vdev_bss_peer_ref_n_get(soc, vdev, DP_MOD_ID_GENERIC_STATS);
10483 
10484 	if (!peer) {
10485 		dp_err_rl("Peer is NULL, vdev_id: %u", vdev_id);
10486 		dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_GENERIC_STATS);
10487 		return;
10488 	}
10489 	peer_stats = qdf_mem_malloc(sizeof(*peer_stats));
10490 	if (!peer_stats) {
10491 		dp_err_rl("peer_stats malloc failed, vdev_id: %u, peer_id: %u",
10492 			  vdev_id, peer->peer_id);
10493 		goto fail;
10494 	}
10495 
10496 	dp_get_peer_stats(peer, peer_stats);
10497 	dp_print_peer_stats(peer, peer_stats);
10498 	qdf_mem_free(peer_stats);
10499 
10500 fail:
10501 	dp_peer_unref_delete(peer, DP_MOD_ID_GENERIC_STATS);
10502 	dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_GENERIC_STATS);
10503 }
10504 #endif /* DP_MLO_LINK_STATS_SUPPORT */
10505 #else
dp_print_per_link_stats(struct cdp_soc_t * soc_hdl,uint8_t vdev_id)10506 void dp_print_per_link_stats(struct cdp_soc_t *soc_hdl, uint8_t vdev_id)
10507 {
10508 }
10509 #endif /* CONFIG_AP_PLATFORM */
10510