xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_stats_struct.h (revision 569cc296edb935e5bbb6f0a4bca30cab7856c360)
1 /*
2  * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * @file cdp_txrx_stats_struct.h
21  * @brief Define the host data path stats API functions
22  * called by the host control SW and the OS interface module
23  */
24 #ifndef _CDP_TXRX_STATS_STRUCT_H_
25 #define _CDP_TXRX_STATS_STRUCT_H_
26 
27 #include <qdf_types.h>
28 #include <cdp_txrx_hist_struct.h>
29 
30 #define TXRX_STATS_LEVEL_OFF   0
31 #define TXRX_STATS_LEVEL_BASIC 1
32 #define TXRX_STATS_LEVEL_FULL  2
33 
34 #define BSS_CHAN_INFO_READ                        1
35 #define BSS_CHAN_INFO_READ_AND_CLEAR              2
36 
37 #define TX_FRAME_TYPE_DATA 0
38 #define TX_FRAME_TYPE_MGMT 1
39 #define TX_FRAME_TYPE_BEACON 2
40 
41 #ifndef TXRX_STATS_LEVEL
42 #define TXRX_STATS_LEVEL TXRX_STATS_LEVEL_BASIC
43 #endif
44 
45 /* 1 additional MCS is for invalid values */
46 #define MAX_MCS (14 + 1)
47 #define MAX_MCS_11A 8
48 #define MAX_MCS_11B 7
49 #define MAX_MCS_11AC 12
50 /* 1 additional GI is for invalid values */
51 #define MAX_GI (4 + 1)
52 #define SS_COUNT 8
53 #define MAX_BW 7
54 #define MAX_RECEPTION_TYPES 4
55 
56 #define MAX_TRANSMIT_TYPES	9
57 
58 #define MAX_USER_POS		8
59 #define MAX_MU_GROUP_ID		64
60 #define MAX_RU_LOCATIONS	6
61 #define RU_26			1
62 #define RU_52			2
63 #define RU_106			4
64 #define RU_242			9
65 #define RU_484			18
66 #define RU_996			37
67 
68 /* WME stream classes */
69 #define WME_AC_BE    0    /* best effort */
70 #define WME_AC_BK    1    /* background */
71 #define WME_AC_VI    2    /* video */
72 #define WME_AC_VO    3    /* voice */
73 #define WME_AC_MAX   4    /* MAX AC Value */
74 
75 #define CDP_MAX_RX_RINGS 4  /* max rx rings */
76 #define CDP_MAX_TX_COMP_RINGS 3  /* max tx completion rings */
77 #define CDP_MAX_TX_TQM_STATUS 9  /* max tx tqm completion status */
78 #define CDP_MAX_TX_HTT_STATUS 7  /* max tx htt completion status */
79 
80 /*
81  * Max of TxRx context
82  */
83 #define CDP_MAX_TXRX_CTX CDP_MAX_RX_RINGS
84 
85 /* TID level VoW stats macros
86  * to add and get stats
87  */
88 #define PFLOW_TXRX_TIDQ_STATS_ADD(_peer, _tid, _var, _val) \
89 	(((_peer)->tidq_stats[_tid]).stats[_var]) += _val
90 #define PFLOW_TXRX_TIDQ_STATS_GET(_peer, _tid, _var, _val) \
91 	((_peer)->tidq_stats[_tid].stats[_var])
92 /*
93  * Video only stats
94  */
95 #define PFLOW_CTRL_PDEV_VIDEO_STATS_SET(_pdev, _var, _val) \
96 	(((_pdev)->vow.vistats[_var]).value) = _val
97 #define PFLOW_CTRL_PDEV_VIDEO_STATS_GET(_pdev, _var) \
98 	((_pdev)->vow.vistats[_var].value)
99 #define PFLOW_CTRL_PDEV_VIDEO_STATS_ADD(_pdev, _var, _val) \
100 	(((_pdev)->vow.vistats[_var]).value) += _val
101 /*
102  * video delay stats
103  */
104 #define PFLOW_CTRL_PDEV_DELAY_VIDEO_STATS_SET(_pdev, _var, _val) \
105 	(((_pdev)->vow.delaystats[_var]).value) = _val
106 #define PFLOW_CTRL_PDEV_DELAY_VIDEO_STATS_GET(_pdev, _var) \
107 	((_pdev)->vow.delaystats[_var].value)
108 #define PFLOW_CTRL_PDEV_DELAY_VIDEO_STATS_ADD(_pdev, _var, _val) \
109 	(((_pdev)->vow.delaystats[_var]).value) += _val
110 /*
111  * Number of TLVs sent by FW. Needs to reflect
112  * HTT_PPDU_STATS_MAX_TAG declared in FW
113  */
114 #define CDP_PPDU_STATS_MAX_TAG 14
115 #define CDP_MAX_DATA_TIDS 9
116 
117 #define CDP_WDI_NUM_EVENTS WDI_NUM_EVENTS
118 
119 #define CDP_FCTL_RETRY 0x0800
120 #define CDP_FC_IS_RETRY_SET(_fc) \
121 	((_fc) & qdf_cpu_to_le16(CDP_FCTL_RETRY))
122 
123 #define INVALID_RSSI 255
124 
125 #define CDP_RSSI_MULTIPLIER BIT(8)
126 #define CDP_RSSI_MUL(x, mul) ((x) * (mul))
127 #define CDP_RSSI_RND(x, mul) ((((x) % (mul)) >= ((mul) / 2)) ?\
128 	((x) + ((mul) - 1)) / (mul) : (x) / (mul))
129 
130 #define CDP_RSSI_OUT(x) (CDP_RSSI_RND((x), CDP_RSSI_MULTIPLIER))
131 #define CDP_RSSI_IN(x)  (CDP_RSSI_MUL((x), CDP_RSSI_MULTIPLIER))
132 #define CDP_RSSI_AVG(x, y) ((((x) << 2) + (y) - (x)) >> 2)
133 
134 #define CDP_RSSI_UPDATE_AVG(x, y) x = CDP_RSSI_AVG((x), CDP_RSSI_IN((y)))
135 
136 /*Max SU EVM count */
137 #define DP_RX_MAX_SU_EVM_COUNT 32
138 
139 #define WDI_EVENT_BASE 0x100
140 
141 #define CDP_TXRX_RATECODE_MCS_MASK 0xF
142 #define CDP_TXRX_RATECODE_NSS_MASK 0x3
143 #define CDP_TXRX_RATECODE_NSS_LSB 4
144 #define CDP_TXRX_RATECODE_PREM_MASK 0x3
145 #define CDP_TXRX_RATECODE_PREM_LSB 6
146 
147 /* Below BW_GAIN should be added to the SNR value of every ppdu based on the
148  * bandwidth. This table is obtained from HALPHY.
149  * BW         BW_Gain
150  * 20          0
151  * 40          3dBm
152  * 80          6dBm
153  * 160/80P80   9dBm
154  */
155 
156 #define PKT_BW_GAIN_20MHZ 0
157 #define PKT_BW_GAIN_40MHZ 3
158 #define PKT_BW_GAIN_80MHZ 6
159 #define PKT_BW_GAIN_160MHZ 9
160 
161 /*
162  * cdp_tx_transmit_type: Transmit type index
163  * SU: SU Transmit type index
164  * MU_MIMO: MU_MIMO Transmit type index
165  * MU_OFDMA: MU_OFDMA Transmit type index
166  * MU_MIMO_OFDMA: MU MIMO OFDMA Transmit type index
167  */
168 enum cdp_tx_transmit_type {
169 	SU = 0,
170 	MU_MIMO,
171 	MU_OFDMA,
172 	MU_MIMO_OFDMA,
173 };
174 
175 /*
176  * cdp_ru_index: Different RU index
177  *
178  * RU_26_INDEX : 26-tone Resource Unit index
179  * RU_52_INDEX : 52-tone Resource Unit index
180  * RU_106_INDEX: 106-tone Resource Unit index
181  * RU_242_INDEX: 242-tone Resource Unit index
182  * RU_484_INDEX: 484-tone Resource Unit index
183  * RU_996_INDEX: 996-tone Resource Unit index
184  */
185 enum cdp_ru_index {
186 	RU_26_INDEX = 0,
187 	RU_52_INDEX,
188 	RU_106_INDEX,
189 	RU_242_INDEX,
190 	RU_484_INDEX,
191 	RU_996_INDEX,
192 	RU_INDEX_MAX,
193 };
194 
195 struct cdp_ru_debug {
196 	char *ru_type;
197 };
198 
199 static const struct cdp_ru_debug cdp_ru_string[RU_INDEX_MAX] = {
200 	{ "RU_26" },
201 	{ "RU_52" },
202 	{ "RU_106" },
203 	{ "RU_242" },
204 	{ "RU_484" },
205 	{ "RU_996" }
206 };
207 
208 #ifdef FEATURE_TSO_STATS
209 /* Number of TSO Packet Statistics captured */
210 #define CDP_MAX_TSO_PACKETS 5
211 /* Information for Number of Segments for a TSO Packet captured */
212 #define CDP_MAX_TSO_SEGMENTS 2
213 /* Information for Number of Fragments for a TSO Segment captured */
214 #define CDP_MAX_TSO_FRAGMENTS 6
215 #endif /* FEATURE_TSO_STATS */
216 
217 /* Different Packet Types */
218 enum cdp_packet_type {
219 	DOT11_A = 0,
220 	DOT11_B = 1,
221 	DOT11_N = 2,
222 	DOT11_AC = 3,
223 	DOT11_AX = 4,
224 	DOT11_MAX = 5,
225 };
226 
227 #define MCS_VALID 1
228 #define MCS_INVALID 0
229 
230 #define CDP_MAX_MCS_STRING_LEN 34
231 /*
232  * struct cdp_rate_debug
233  *
234  * @mcs_type: print string for a given mcs
235  * @valid: valid mcs rate?
236  */
237 struct cdp_rate_debug {
238 	char mcs_type[CDP_MAX_MCS_STRING_LEN];
239 	uint8_t valid;
240 };
241 
242 static const struct cdp_rate_debug cdp_rate_string[DOT11_MAX][MAX_MCS] = {
243 	{
244 		{"OFDM 48 Mbps", MCS_VALID},
245 		{"OFDM 24 Mbps", MCS_VALID},
246 		{"OFDM 12 Mbps", MCS_VALID},
247 		{"OFDM 6 Mbps ", MCS_VALID},
248 		{"OFDM 54 Mbps", MCS_VALID},
249 		{"OFDM 36 Mbps", MCS_VALID},
250 		{"OFDM 18 Mbps", MCS_VALID},
251 		{"OFDM 9 Mbps ", MCS_VALID},
252 		{"INVALID ", MCS_INVALID},
253 		{"INVALID ", MCS_INVALID},
254 		{"INVALID ", MCS_INVALID},
255 		{"INVALID ", MCS_INVALID},
256 		{"INVALID ", MCS_INVALID},
257 	},
258 	{
259 		{"CCK 11 Mbps Long  ", MCS_VALID},
260 		{"CCK 5.5 Mbps Long ", MCS_VALID},
261 		{"CCK 2 Mbps Long   ", MCS_VALID},
262 		{"CCK 1 Mbps Long   ", MCS_VALID},
263 		{"CCK 11 Mbps Short ", MCS_VALID},
264 		{"CCK 5.5 Mbps Short", MCS_VALID},
265 		{"CCK 2 Mbps Short  ", MCS_VALID},
266 		{"INVALID ", MCS_INVALID},
267 		{"INVALID ", MCS_INVALID},
268 		{"INVALID ", MCS_INVALID},
269 		{"INVALID ", MCS_INVALID},
270 		{"INVALID ", MCS_INVALID},
271 		{"INVALID ", MCS_INVALID},
272 	},
273 	{
274 		{"HT MCS 0 (BPSK 1/2)  ", MCS_VALID},
275 		{"HT MCS 1 (QPSK 1/2)  ", MCS_VALID},
276 		{"HT MCS 2 (QPSK 3/4)  ", MCS_VALID},
277 		{"HT MCS 3 (16-QAM 1/2)", MCS_VALID},
278 		{"HT MCS 4 (16-QAM 3/4)", MCS_VALID},
279 		{"HT MCS 5 (64-QAM 2/3)", MCS_VALID},
280 		{"HT MCS 6 (64-QAM 3/4)", MCS_VALID},
281 		{"HT MCS 7 (64-QAM 5/6)", MCS_VALID},
282 		{"INVALID ", MCS_INVALID},
283 		{"INVALID ", MCS_INVALID},
284 		{"INVALID ", MCS_INVALID},
285 		{"INVALID ", MCS_INVALID},
286 		{"INVALID ", MCS_INVALID},
287 	},
288 	{
289 		{"VHT MCS 0 (BPSK 1/2)     ", MCS_VALID},
290 		{"VHT MCS 1 (QPSK 1/2)     ", MCS_VALID},
291 		{"VHT MCS 2 (QPSK 3/4)     ", MCS_VALID},
292 		{"VHT MCS 3 (16-QAM 1/2)   ", MCS_VALID},
293 		{"VHT MCS 4 (16-QAM 3/4)   ", MCS_VALID},
294 		{"VHT MCS 5 (64-QAM 2/3)   ", MCS_VALID},
295 		{"VHT MCS 6 (64-QAM 3/4)   ", MCS_VALID},
296 		{"VHT MCS 7 (64-QAM 5/6)   ", MCS_VALID},
297 		{"VHT MCS 8 (256-QAM 3/4)  ", MCS_VALID},
298 		{"VHT MCS 9 (256-QAM 5/6)  ", MCS_VALID},
299 		{"VHT MCS 10 (1024-QAM 3/4)", MCS_VALID},
300 		{"VHT MCS 11 (1024-QAM 5/6)", MCS_VALID},
301 		{"INVALID ", MCS_INVALID},
302 	},
303 	{
304 		{"HE MCS 0 (BPSK 1/2)     ", MCS_VALID},
305 		{"HE MCS 1 (QPSK 1/2)     ", MCS_VALID},
306 		{"HE MCS 2 (QPSK 3/4)     ", MCS_VALID},
307 		{"HE MCS 3 (16-QAM 1/2)   ", MCS_VALID},
308 		{"HE MCS 4 (16-QAM 3/4)   ", MCS_VALID},
309 		{"HE MCS 5 (64-QAM 2/3)   ", MCS_VALID},
310 		{"HE MCS 6 (64-QAM 3/4)   ", MCS_VALID},
311 		{"HE MCS 7 (64-QAM 5/6)   ", MCS_VALID},
312 		{"HE MCS 8 (256-QAM 3/4)  ", MCS_VALID},
313 		{"HE MCS 9 (256-QAM 5/6)  ", MCS_VALID},
314 		{"HE MCS 10 (1024-QAM 3/4)", MCS_VALID},
315 		{"HE MCS 11 (1024-QAM 5/6)", MCS_VALID},
316 		{"HE MCS 12 (4096-QAM 3/4)", MCS_VALID},
317 		{"HE MCS 13 (4096-QAM 5/6)", MCS_VALID},
318 		{"INVALID ", MCS_INVALID},
319 	}
320 };
321 
322 /*
323  * cdp_mu_packet_type: MU Rx type index
324  * RX_TYPE_MU_MIMO: MU MIMO Rx type index
325  * RX_TYPE_MU_OFDMA: MU OFDMA Rx type index
326  * MU_MIMO_OFDMA: MU Rx MAX type index
327  */
328 enum cdp_mu_packet_type {
329 	RX_TYPE_MU_MIMO = 0,
330 	RX_TYPE_MU_OFDMA = 1,
331 	RX_TYPE_MU_MAX = 2,
332 };
333 
334 enum WDI_EVENT {
335 	WDI_EVENT_TX_STATUS = WDI_EVENT_BASE,
336 	WDI_EVENT_OFFLOAD_ALL,
337 	WDI_EVENT_RX_DESC_REMOTE,
338 	WDI_EVENT_RX_PEER_INVALID,
339 	WDI_EVENT_DBG_PRINT, /* NEED to integrate pktlog changes*/
340 	WDI_EVENT_RX_CBF_REMOTE,
341 	WDI_EVENT_RATE_FIND,
342 	WDI_EVENT_RATE_UPDATE,
343 	WDI_EVENT_SW_EVENT,
344 	WDI_EVENT_RX_DESC,
345 	WDI_EVENT_LITE_T2H,
346 	WDI_EVENT_LITE_RX,
347 	WDI_EVENT_RX_PPDU_DESC,
348 	WDI_EVENT_TX_PPDU_DESC,
349 	WDI_EVENT_TX_MSDU_DESC,
350 	WDI_EVENT_TX_DATA,
351 	WDI_EVENT_RX_DATA,
352 	WDI_EVENT_TX_MGMT_CTRL,
353 	WDI_EVENT_HTT_STATS,
354 	WDI_EVENT_TX_BEACON,
355 	WDI_EVENT_PEER_STATS,
356 	WDI_EVENT_TX_SOJOURN_STAT,
357 	WDI_EVENT_UPDATE_DP_STATS,
358 	WDI_EVENT_RX_MGMT_CTRL,
359 	WDI_EVENT_PEER_CREATE,
360 	WDI_EVENT_PEER_DESTROY,
361 	WDI_EVENT_PEER_FLUSH_RATE_STATS,
362 	WDI_EVENT_FLUSH_RATE_STATS_REQ,
363 	WDI_EVENT_RX_MPDU,
364 	WDI_EVENT_HMWDS_AST_ADD_STATUS,
365 	WDI_EVENT_PEER_QOS_STATS,
366 	/* End of new event items */
367 	WDI_EVENT_LAST
368 };
369 
370 #define WDI_NUM_EVENTS WDI_EVENT_LAST - WDI_EVENT_BASE
371 
372 struct cdp_stats_extd {
373 };
374 
375 /* TID level Tx/Rx stats
376  *
377  */
378 enum cdp_txrx_tidq_stats {
379 	/* Tx Counters */
380 	TX_MSDU_TOTAL_LINUX_SUBSYSTEM,
381 	TX_MSDU_TOTAL_FROM_OSIF,
382 	TX_MSDU_TX_COMP_PKT_CNT,
383 	/* Rx Counters */
384 	RX_MSDU_TOTAL_FROM_FW,
385 	RX_MSDU_MCAST_FROM_FW,
386 	RX_TID_MISMATCH_FROM_FW,
387 	RX_MSDU_MISC_PKTS,
388 	RX_MSDU_IS_ARP,
389 	RX_MSDU_IS_EAP,
390 	RX_MSDU_IS_DHCP,
391 	RX_AGGREGATE_10,
392 	RX_AGGREGATE_20,
393 	RX_AGGREGATE_30,
394 	RX_AGGREGATE_40,
395 	RX_AGGREGATE_50,
396 	RX_AGGREGATE_60,
397 	RX_AGGREGATE_MORE,
398 	RX_AMSDU_1,
399 	RX_AMSDU_2,
400 	RX_AMSDU_3,
401 	RX_AMSDU_4,
402 	RX_AMSDU_MORE,
403 	RX_MSDU_CHAINED_FROM_FW,
404 	RX_MSDU_REORDER_FAILED_FROM_FW,
405 	RX_MSDU_REORDER_FLUSHED_FROM_FW,
406 	RX_MSDU_DISCARD_FROM_FW,
407 	RX_MSDU_DUPLICATE_FROM_FW,
408 	RX_MSDU_DELIVERED_TO_STACK,
409 	TIDQ_STATS_MAX,
410 };
411 
412 struct cdp_tidq_stats {
413 	uint32_t stats[TIDQ_STATS_MAX];
414 };
415 
416 #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
417 /**
418  * struct cdp_rx_ppdu_cfr_info - struct for storing ppdu info extracted from HW
419  * TLVs, this will be used for CFR correlation
420  *
421  * @bb_captured_channel : Set by RXPCU when MACRX_FREEZE_CAPTURE_CHANNEL TLV is
422  * sent to PHY, SW checks it to correlate current PPDU TLVs with uploaded
423  * channel information.
424  *
425  * @bb_captured_timeout : Set by RxPCU to indicate channel capture condition is
426  * met, but MACRX_FREEZE_CAPTURE_CHANNEL is not sent to PHY due to AST delay,
427  * which means the rx_frame_falling edge to FREEZE TLV ready time exceeds
428  * the threshold time defined by RXPCU register FREEZE_TLV_DELAY_CNT_THRESH.
429  * Bb_captured_reason is still valid in this case.
430  *
431  * @bb_captured_reason : Copy capture_reason of MACRX_FREEZE_CAPTURE_CHANNEL
432  * TLV to here for FW usage. Valid when bb_captured_channel or
433  * bb_captured_timeout is set.
434  * <enum 0 freeze_reason_TM>
435  * <enum 1 freeze_reason_FTM>
436  * <enum 2 freeze_reason_ACK_resp_to_TM_FTM>
437  * <enum 3 freeze_reason_TA_RA_TYPE_FILTER>
438  * <enum 4 freeze_reason_NDPA_NDP>
439  * <enum 5 freeze_reason_ALL_PACKET>
440  * <legal 0-5>
441  *
442  * @rx_location_info_valid: Indicates whether CFR DMA address in the PPDU TLV
443  * is valid
444  * <enum 0 rx_location_info_is_not_valid>
445  * <enum 1 rx_location_info_is_valid>
446  * <legal all>
447  *
448  * @chan_capture_status : capture status reported by ucode
449  * a. CAPTURE_IDLE: FW has disabled "REPETITIVE_CHE_CAPTURE_CTRL"
450  * b. CAPTURE_BUSY: previous PPDU’s channel capture upload DMA ongoing. (Note
451  * that this upload is triggered after receiving freeze_channel_capture TLV
452  * after last PPDU is rx)
453  * c. CAPTURE_ACTIVE: channel capture is enabled and no previous channel
454  * capture ongoing
455  * d. CAPTURE_NO_BUFFER: next buffer in IPC ring not available
456  *
457  * @rtt_che_buffer_pointer_high8 : The high 8 bits of the 40 bits pointer to
458  * external RTT channel information buffer
459  *
460  * @rtt_che_buffer_pointer_low32 : The low 32 bits of the 40 bits pointer to
461  * external RTT channel information buffer
462  *
463  */
464 
465 struct cdp_rx_ppdu_cfr_info {
466 	bool bb_captured_channel;
467 	bool bb_captured_timeout;
468 	uint8_t bb_captured_reason;
469 	bool rx_location_info_valid;
470 	uint8_t chan_capture_status;
471 	uint8_t rtt_che_buffer_pointer_high8;
472 	uint32_t rtt_che_buffer_pointer_low32;
473 };
474 #endif
475 /*
476  * struct cdp_rx_su_evm_info: Rx evm info
477  * @number_of_symbols: number of symbols
478  * @nss_count: number of spatial streams
479  * @pilot_count: number of pilot count
480  */
481 struct cdp_rx_su_evm_info {
482 	uint16_t number_of_symbols;
483 	uint8_t  nss_count;
484 	uint8_t  pilot_count;
485 	uint32_t pilot_evm[DP_RX_MAX_SU_EVM_COUNT];
486 };
487 
488 /*
489  * cdp_delay_stats_mode: Different types of delay statistics
490  *
491  * @CDP_DELAY_STATS_SW_ENQ: Stack to hw enqueue delay
492  * @CDP_DELAY_STATS_TX_INTERFRAME: Interframe delay at radio entry point
493  * @CDP_DELAY_STATS_FW_HW_TRANSMIT: Hw enqueue to tx completion delay
494  * @CDP_DELAY_STATS_REAP_STACK: Delay in ring reap to indicating network stack
495  * @CDP_DELAY_STATS_RX_INTERFRAME: Rx inteframe delay
496  * @CDP_DELAY_STATS_MODE_MAX: Maximum delay mode
497  */
498 enum cdp_delay_stats_mode {
499 	CDP_DELAY_STATS_SW_ENQ,
500 	CDP_DELAY_STATS_TX_INTERFRAME,
501 	CDP_DELAY_STATS_FW_HW_TRANSMIT,
502 	CDP_DELAY_STATS_REAP_STACK,
503 	CDP_DELAY_STATS_RX_INTERFRAME,
504 	CDP_DELAY_STATS_MODE_MAX,
505 };
506 
507 /*
508  * cdp_delay_bucket_index
509  *	Index to be used for all delay stats
510  */
511 enum cdp_delay_bucket_index {
512 	CDP_DELAY_BUCKET_0,
513 	CDP_DELAY_BUCKET_1,
514 	CDP_DELAY_BUCKET_2,
515 	CDP_DELAY_BUCKET_3,
516 	CDP_DELAY_BUCKET_4,
517 	CDP_DELAY_BUCKET_5,
518 	CDP_DELAY_BUCKET_6,
519 	CDP_DELAY_BUCKET_7,
520 	CDP_DELAY_BUCKET_8,
521 	CDP_DELAY_BUCKET_9,
522 	CDP_DELAY_BUCKET_10,
523 	CDP_DELAY_BUCKET_11,
524 	CDP_DELAY_BUCKET_12,
525 	CDP_DELAY_BUCKET_MAX,
526 };
527 
528 /*
529  * struct cdp_tx_host_drop - packet drop due to following reasons.
530  */
531 enum cdp_tx_sw_drop {
532 	TX_DESC_ERR,
533 	TX_HAL_RING_ACCESS_ERR,
534 	TX_DMA_MAP_ERR,
535 	TX_HW_ENQUEUE,
536 	TX_SW_ENQUEUE,
537 	TX_MAX_DROP,
538 };
539 
540 /*
541  * struct cdp_rx_host_drop - packet drop due to following reasons.
542  */
543 enum cdp_rx_sw_drop {
544 	INTRABSS_DROP,
545 	MSDU_DONE_FAILURE,
546 	INVALID_PEER_VDEV,
547 	POLICY_CHECK_DROP,
548 	MEC_DROP,
549 	NAWDS_MCAST_DROP,
550 	MESH_FILTER_DROP,
551 	ENQUEUE_DROP,
552 	RX_MAX_DROP,
553 };
554 
555 /*
556  * struct cdp_delay_stats
557  * @delay_bucket: division of buckets as per latency
558  * @min_delay: minimum delay
559  * @max_delay: maximum delay
560  * @avg_delay: average delay
561  */
562 struct cdp_delay_stats {
563 	uint64_t delay_bucket[CDP_DELAY_BUCKET_MAX];
564 	uint32_t min_delay;
565 	uint32_t max_delay;
566 	uint32_t avg_delay;
567 };
568 
569 /*
570  * struct cdp_tid_tx_stats
571  * @swq_delay: delay between wifi driver entry point and enqueue to HW in tx
572  * @hwtx_delay: delay between wifi driver exit (enqueue to HW) and tx completion
573  * @intfrm_delay: interframe delay
574  * @success_cnt: total successful transmit count
575  * @comp_fail_cnt: firmware drop found in tx completion path
576  * @swdrop_cnt: software drop in tx path
577  * @tqm_status_cnt: TQM completion status count
578  * @htt_status_cnt: HTT completion status count
579  */
580 struct cdp_tid_tx_stats {
581 	struct cdp_delay_stats swq_delay;
582 	struct cdp_delay_stats hwtx_delay;
583 	struct cdp_delay_stats intfrm_delay;
584 	uint64_t success_cnt;
585 	uint64_t comp_fail_cnt;
586 	uint64_t swdrop_cnt[TX_MAX_DROP];
587 	uint64_t tqm_status_cnt[CDP_MAX_TX_TQM_STATUS];
588 	uint64_t htt_status_cnt[CDP_MAX_TX_HTT_STATUS];
589 };
590 
591 /*
592  * struct cdp_tid_tx_stats
593  * @to_stack_delay: Time taken between ring reap to indication to network stack
594  * @intfrm_delay: Interframe rx delay
595  * @delivered_cnt: Total packets indicated to stack
596  * @intrabss_cnt: Rx total intraBSS frames
597  * @msdu_cnt: number of msdu received from HW
598  * @mcast_msdu_cnt: Num Mcast Msdus received from HW in Rx
599  * @bcast_msdu_cnt: Num Bcast Msdus received from HW in Rx
600  * @fail_cnt: Rx deliver drop counters
601  */
602 struct cdp_tid_rx_stats {
603 	struct cdp_delay_stats to_stack_delay;
604 	struct cdp_delay_stats intfrm_delay;
605 	uint64_t delivered_to_stack;
606 	uint64_t intrabss_cnt;
607 	uint64_t msdu_cnt;
608 	uint64_t mcast_msdu_cnt;
609 	uint64_t bcast_msdu_cnt;
610 	uint64_t fail_cnt[RX_MAX_DROP];
611 };
612 
613 /*
614  * struct cdp_tid_stats
615  * @ingress_stack: Total packets received from linux stack
616  * @osif_drop: drops in osif layer
617  * @tid_tx_stats: transmit counters per tid
618  * @tid_rx_stats: receive counters per tid
619  */
620 struct cdp_tid_stats {
621 	uint64_t ingress_stack;
622 	uint64_t osif_drop;
623 	struct cdp_tid_tx_stats tid_tx_stats[CDP_MAX_TX_COMP_RINGS]
624 					    [CDP_MAX_DATA_TIDS];
625 	struct cdp_tid_rx_stats tid_rx_stats[CDP_MAX_RX_RINGS]
626 					    [CDP_MAX_DATA_TIDS];
627 };
628 
629 /*
630  * struct cdp_delay_tx_stats: Tx delay stats
631  * @tx_swq_delay: software enqueue delay
632  * @hwtx_delay: HW enque to completion delay
633  */
634 struct cdp_delay_tx_stats {
635 	struct cdp_hist_stats    tx_swq_delay;
636 	struct cdp_hist_stats    hwtx_delay;
637 };
638 
639 /*
640  * struct cdp_delay_rx_stats: Rx delay stats
641  * @to_stack_delay: To stack delay
642  */
643 struct cdp_delay_rx_stats {
644 	struct cdp_hist_stats    to_stack_delay;
645 };
646 
647 /*
648  * struct cdp_delay_tid_stats: Delay tid stats
649  * @tx_delay: Tx delay related stats
650  * @rx_delay: Rx delay related stats
651  */
652 struct cdp_delay_tid_stats {
653 	struct cdp_delay_tx_stats  tx_delay;
654 	struct cdp_delay_rx_stats  rx_delay;
655 };
656 
657 /*
658  * cdp_peer_ext_stats: Peer extended stats
659  * @delay_stats: Per TID delay stats
660  */
661 struct cdp_peer_ext_stats {
662 	struct cdp_delay_tid_stats delay_stats[CDP_MAX_DATA_TIDS]
663 						[CDP_MAX_TXRX_CTX];
664 
665 	/*Customer can add MSDU level Tx/Rx stats */
666 };
667 
668 /* struct cdp_pkt_info - packet info
669  * @num: no of packets
670  * @bytes: total no of bytes
671  */
672 struct cdp_pkt_info {
673 	uint32_t num;
674 	uint64_t bytes;
675 };
676 
677 /* struct cdp_pkt_type - packet type
678  * @mcs_count: Counter array for each MCS index
679  */
680 struct cdp_pkt_type {
681 	uint32_t mcs_count[MAX_MCS];
682 };
683 
684 /*
685  * struct cdp_rx_mu - Rx MU Stats
686  * @ppdu_nss[SS_COUNT]: Packet Count in spatial streams
687  * @mpdu_cnt_fcs_ok: Rx success mpdu count
688  * @mpdu_cnt_fcs_err: Rx fail mpdu count
689  * @cdp_pkt_type: counter array for each MCS index
690  */
691 struct cdp_rx_mu {
692 	uint32_t ppdu_nss[SS_COUNT];
693 	uint32_t mpdu_cnt_fcs_ok;
694 	uint32_t mpdu_cnt_fcs_err;
695 	struct cdp_pkt_type ppdu;
696 };
697 
698 /* struct cdp_tx_pkt_info - tx packet info
699  * num_msdu - successful msdu
700  * num_mpdu - successful mpdu from compltn common
701  * mpdu_tried - mpdu tried
702  *
703  * tx packet info counter field for mpdu success/tried and msdu
704  */
705 struct cdp_tx_pkt_info {
706 	uint32_t num_msdu;
707 	uint32_t num_mpdu;
708 	uint32_t mpdu_tried;
709 };
710 
711 #ifdef FEATURE_TSO_STATS
712 /**
713  * struct cdp_tso_seg_histogram - Segment histogram for TCP Packets
714  * @segs_1: packets with single segments
715  * @segs_2_5: packets with 2-5 segments
716  * @segs_6_10: packets with 6-10 segments
717  * @segs_11_15: packets with 11-15 segments
718  * @segs_16_20: packets with 16-20 segments
719  * @segs_20_plus: packets with 20 plus segments
720  */
721 struct cdp_tso_seg_histogram {
722 	uint64_t segs_1;
723 	uint64_t segs_2_5;
724 	uint64_t segs_6_10;
725 	uint64_t segs_11_15;
726 	uint64_t segs_16_20;
727 	uint64_t segs_20_plus;
728 };
729 
730 /**
731  * struct cdp_tso_packet_info - Stats for TSO segments within a TSO packet
732  * @tso_seg: TSO Segment information
733  * @num_seg: Number of segments
734  * @tso_packet_len: Size of the tso packet
735  * @tso_seg_idx: segment number
736  */
737 struct cdp_tso_packet_info {
738 	struct qdf_tso_seg_t tso_seg[CDP_MAX_TSO_SEGMENTS];
739 	uint8_t num_seg;
740 	size_t tso_packet_len;
741 	uint32_t tso_seg_idx;
742 };
743 
744 /**
745  * struct cdp_tso_info - stats for tso packets
746  * @tso_packet_info: TSO packet information
747  */
748 struct cdp_tso_info {
749 	struct cdp_tso_packet_info tso_packet_info[CDP_MAX_TSO_PACKETS];
750 };
751 #endif /* FEATURE_TSO_STATS */
752 
753 /**
754  * struct cdp_tso_stats -  TSO stats information
755  * @num_tso_pkts: Total number of TSO Packets
756  * @tso_comp: Total tso packet completions
757  * @dropped_host: TSO packets dropped by host
758  * @tso_no_mem_dropped: TSO packets dropped by host due to descriptor
759 			unavailablity
760  * @dropped_target: TSO packets_dropped by target
761  * @tso_info: Per TSO packet counters
762  * @seg_histogram: TSO histogram stats
763  */
764 struct cdp_tso_stats {
765 	struct cdp_pkt_info num_tso_pkts;
766 	uint32_t tso_comp;
767 	struct cdp_pkt_info dropped_host;
768 	struct cdp_pkt_info tso_no_mem_dropped;
769 	uint32_t dropped_target;
770 #ifdef FEATURE_TSO_STATS
771 	struct cdp_tso_info tso_info;
772 	struct cdp_tso_seg_histogram seg_histogram;
773 #endif /* FEATURE_TSO_STATS */
774 };
775 
776 #define CDP_PEER_STATS_START 0
777 
778 enum cdp_peer_stats_type {
779 	cdp_peer_stats_min = CDP_PEER_STATS_START,
780 
781 	/* Tx types */
782 	cdp_peer_tx_ucast = cdp_peer_stats_min,
783 	cdp_peer_tx_mcast,
784 	cdp_peer_tx_rate,
785 	cdp_peer_tx_last_tx_rate,
786 	cdp_peer_tx_inactive_time,
787 	cdp_peer_tx_ratecode,
788 	cdp_peer_tx_flags,
789 	cdp_peer_tx_power,
790 
791 	/* Rx types */
792 	cdp_peer_rx_rate,
793 	cdp_peer_rx_last_rx_rate,
794 	cdp_peer_rx_ratecode,
795 	cdp_peer_rx_ucast,
796 	cdp_peer_rx_flags,
797 	cdp_peer_rx_avg_rssi,
798 	cdp_peer_stats_max,
799 };
800 
801 /*
802  * The max size of cdp_peer_stats_param_t is limited to 16 bytes.
803  * If the buffer size is exceeding this size limit,
804  * dp_txrx_get_peer_stats is to be used instead.
805  */
806 typedef union cdp_peer_stats_buf {
807 	/* Tx types */
808 	struct cdp_pkt_info tx_ucast;
809 	struct cdp_pkt_info tx_mcast;
810 	uint32_t tx_rate;
811 	uint32_t last_tx_rate;
812 	uint32_t tx_inactive_time;
813 	uint32_t tx_flags;
814 	uint32_t tx_power;
815 	uint16_t tx_ratecode;
816 
817 	/* Rx types */
818 	struct cdp_pkt_info rx_ucast;
819 	uint32_t rx_rate;
820 	uint32_t last_rx_rate;
821 	uint32_t rx_ratecode;
822 	uint32_t rx_flags;
823 	uint32_t rx_avg_rssi;
824 } cdp_peer_stats_param_t; /* Max union size 16 bytes */
825 
826 /**
827  * enum cdp_protocol_trace -  Protocols supported by per-peer protocol trace
828  * @CDP_TRACE_ICMP: ICMP packets
829  * @CDP_TRACE_EAP: EAPOL packets
830  * @CDP_TRACE_ARP: ARP packets
831  *
832  * Enumeration of all protocols supported by per-peer protocol trace feature
833  */
834 enum cdp_protocol_trace {
835 	CDP_TRACE_ICMP,
836 	CDP_TRACE_EAP,
837 	CDP_TRACE_ARP,
838 	CDP_TRACE_MAX
839 };
840 
841 /**
842  * struct protocol_trace_count - type of count on per-peer protocol trace
843  * @egress_cnt: how many packets go out of host driver
844  * @ingress_cnt: how many packets come into the host driver
845  *
846  * Type of count on per-peer protocol trace
847  */
848 struct protocol_trace_count {
849 	uint16_t egress_cnt;
850 	uint16_t ingress_cnt;
851 };
852 /* struct cdp_tx_stats - tx stats
853  * @cdp_pkt_info comp_pkt: Pkt Info for which completions were received
854  * @cdp_pkt_info ucast: Unicast Packet Count
855  * @cdp_pkt_info mcast: Multicast Packet Count
856  * @cdp_pkt_info bcast: Broadcast Packet Count
857  * @cdp_pkt_info nawds_mcast: NAWDS  Multicast Packet Count
858  * @cdp_pkt_info tx_success: Successful Tx Packets
859  * @nawds_mcast_drop: NAWDS  Multicast Drop Count
860  * @protocol_trace_cnt: per-peer protocol counter
861  * @tx_failed: Total Tx failure
862  * @ofdma: Total Packets as ofdma
863  * @stbc: Packets in STBC
864  * @ldpc: Packets in LDPC
865  * @retries: Packet retries
866  * @non_amsdu_cnt: Number of MSDUs with no MSDU level aggregation
867  * @amsdu_cnt: Number of MSDUs part of AMSDU
868  * @tx_rate: Tx Rate
869  * @last_tx_rate: Last tx rate for unicast packets
870  * @last_tx_rate_mcs: Tx rate mcs for unicast packets
871  * @mcast_last_tx_rate: Last tx rate for multicast packets
872  * @mcast_last_tx_rate_mcs: Last tx rate mcs for multicast
873  * @last_per: Tx Per
874  * @rnd_avg_tx_rate: Rounded average tx rate
875  * @avg_tx_rate: Average TX rate
876  * @last_ack_rssi: RSSI of last acked packet
877  * @tx_bytes_success_last: last Tx success bytes
878  * @tx_data_success_last: last Tx success data
879  * @tx_byte_rate: Bytes Trasmitted in last one sec
880  * @tx_data_rate: Data Transmitted in last one sec
881  * @sgi_count[MAX_GI]: SGI count
882  * @pream_punct_cnt: Preamble Punctured count
883  * @nss[SS_COUNT]: Packet count for different num_spatial_stream values
884  * @bw[MAX_BW]: Packet Count for different bandwidths
885  * @wme_ac_type[WME_AC_MAX]: Wireless Multimedia type Count
886  * @excess_retries_per_ac[WME_AC_MAX]: Wireless Multimedia type Count
887  * @dot11_tx_pkts: dot11 tx packets
888  * @fw_rem: Discarded by firmware
889  * @fw_rem_notx: firmware_discard_untransmitted
890  * @fw_rem_tx: firmware_discard_transmitted
891  * @age_out: aged out in mpdu/msdu queues
892  * @fw_reason1: discarded by firmware reason 1
893  * @fw_reason2: discarded by firmware reason 2
894  * @fw_reason3: discarded by firmware reason 3
895  * @mcs_count: MCS Count
896  * @an_tx_cnt: ald tx count
897  * @an_tx_rates_used: ald rx rate used
898  * @an_tx_bytes: ald tx bytes
899  * @ald_txcount: ald tx count
900  * @ald_lastper: ald last PER
901  * @ald_max4msframelen: ald max frame len
902  * @an_tx_ratecount: ald tx ratecount
903  * @ald_retries: ald retries
904  * @ald_ac_nobufs: #buffer overflows per node per AC
905  * @ald_ac_excretries: #pkts dropped after excessive retries per node per AC
906  * @rssi_chain: rssi chain
907  * @inactive_time: inactive time in secs
908  * @tx_flags: tx flags
909  * @tx_power: Tx power latest
910  * @is_tx_no_ack: no ack received
911  * @tx_ratecode: Tx rate code of last frame
912  * @is_tx_nodefkey: tx failed 'cuz no defkey
913  * @is_tx_noheadroom: tx failed 'cuz no space
914  * @is_crypto_enmicfail:
915  * @is_tx_nonode: tx failed for no node
916  * @is_tx_unknownmgt: tx of unknown mgt frame
917  * @is_tx_badcipher: tx failed 'cuz key type
918  * @ampdu_cnt: completion of aggregation
919  * @non_ampdu_cnt: tx completion not aggregated
920  * @failed_retry_count: packets failed due to retry above 802.11 retry limit
921  * @retry_count: packets successfully send after one or more retry
922  * @multiple_retry_count: packets successfully sent after more than one retry
923  * @transmit_type: pkt info for tx transmit type
924  * @mu_group_id: mumimo mu group id
925  * @ru_start: RU start index
926  * @ru_tones: RU tones size
927  * @ru_loc: pkt info for RU location 26/ 52/ 106/ 242/ 484 counter
928  * @num_ppdu_cookie_valid : Number of comp received with valid ppdu cookie
929  * @tx_success_twt: Successful Tx Packets in TWT session
930  */
931 struct cdp_tx_stats {
932 	struct cdp_pkt_info comp_pkt;
933 	struct cdp_pkt_info ucast;
934 	struct cdp_pkt_info mcast;
935 	struct cdp_pkt_info bcast;
936 	struct cdp_pkt_info nawds_mcast;
937 #ifdef VDEV_PEER_PROTOCOL_COUNT
938 	struct protocol_trace_count protocol_trace_cnt[CDP_TRACE_MAX];
939 #endif
940 	struct cdp_pkt_info tx_success;
941 	uint32_t nawds_mcast_drop;
942 	uint32_t tx_failed;
943 	uint32_t ofdma;
944 	uint32_t stbc;
945 	uint32_t ldpc;
946 	uint32_t retries;
947 	uint32_t non_amsdu_cnt;
948 	uint32_t amsdu_cnt;
949 	uint32_t tx_rate;
950 	uint32_t last_tx_rate;
951 	uint32_t last_tx_rate_mcs;
952 	uint32_t mcast_last_tx_rate;
953 	uint32_t mcast_last_tx_rate_mcs;
954 	uint32_t last_per;
955 	uint64_t rnd_avg_tx_rate;
956 	uint64_t avg_tx_rate;
957 	uint32_t last_ack_rssi;
958 	uint32_t tx_bytes_success_last;
959 	uint32_t tx_data_success_last;
960 	uint32_t tx_byte_rate;
961 	uint32_t tx_data_rate;
962 	uint32_t tx_data_ucast_last;
963 	uint32_t tx_data_ucast_rate;
964 	struct cdp_pkt_type pkt_type[DOT11_MAX];
965 	uint32_t sgi_count[MAX_GI];
966 	uint32_t pream_punct_cnt;
967 
968 	uint32_t nss[SS_COUNT];
969 
970 	uint32_t bw[MAX_BW];
971 
972 	uint32_t wme_ac_type[WME_AC_MAX];
973 
974 	uint32_t excess_retries_per_ac[WME_AC_MAX];
975 	struct cdp_pkt_info dot11_tx_pkts;
976 
977 	struct {
978 		struct cdp_pkt_info fw_rem;
979 		uint32_t fw_rem_notx;
980 		uint32_t fw_rem_tx;
981 		uint32_t age_out;
982 		uint32_t fw_reason1;
983 		uint32_t fw_reason2;
984 		uint32_t fw_reason3;
985 	} dropped;
986 
987 
988 	uint32_t fw_tx_cnt;
989 	uint32_t fw_tx_bytes;
990 	uint32_t fw_txcount;
991 	uint32_t fw_max4msframelen;
992 	uint32_t fw_ratecount;
993 
994 	uint32_t ac_nobufs[WME_AC_MAX];
995 	uint32_t rssi_chain[WME_AC_MAX];
996 	uint32_t inactive_time;
997 
998 	uint32_t tx_flags;
999 	uint32_t tx_power;
1000 
1001 	/* MSDUs which the target sent but couldn't get an ack for */
1002 	struct cdp_pkt_info is_tx_no_ack;
1003 	uint16_t tx_ratecode;
1004 
1005 	/*add for peer and upadted from ppdu*/
1006 	uint32_t ampdu_cnt;
1007 	uint32_t non_ampdu_cnt;
1008 	uint32_t failed_retry_count;
1009 	uint32_t retry_count;
1010 	uint32_t multiple_retry_count;
1011 	uint32_t last_tx_rate_used;
1012 
1013 	struct cdp_tx_pkt_info transmit_type[MAX_TRANSMIT_TYPES];
1014 	uint32_t mu_group_id[MAX_MU_GROUP_ID];
1015 	uint32_t ru_start;
1016 	uint32_t ru_tones;
1017 	struct cdp_tx_pkt_info ru_loc[MAX_RU_LOCATIONS];
1018 
1019 	uint32_t num_ppdu_cookie_valid;
1020 	uint32_t no_ack_count[QDF_PROTO_SUBTYPE_MAX];
1021 	struct cdp_pkt_info tx_success_twt;
1022 };
1023 
1024 /* struct cdp_rx_stats - rx Level Stats
1025  * @to_stack: Total packets sent up the stack
1026  * @rcvd_reo[CDP_MAX_RX_RINGS]:  Packets received on the reo ring
1027  * @unicast: Total unicast packets
1028  * @multicast: Total multicast packets
1029  * @bcast:  Broadcast Packet Count
1030  * @raw: Raw Pakets received
1031  * @nawds_mcast_drop: Total multicast packets
1032  * @mec_drop: Total MEC packets dropped
1033  * @pkts: Intra BSS packets received
1034  * @fail: Intra BSS packets failed
1035  * @mdns_no_fwd: Intra BSS MDNS packets not forwarded
1036  * @protocol_trace_cnt: per-peer protocol counters
1037  * @mic_err: Rx MIC errors CCMP
1038  * @decrypt_err: Rx Decryption Errors CRC
1039  * @fcserr: rx MIC check failed (CCMP)
1040  * @wme_ac_type[WME_AC_MAX]: Wireless Multimedia type Count
1041  * @reception_type[MAX_RECEPTION_TYPES]: Reception type os packets
1042  * @mcs_count[MAX_MCS]: mcs count
1043  * @sgi_count[MAX_GI]: sgi count
1044  * @nss[SS_COUNT]: packet count in spatiel Streams
1045  * @ppdu_nss[SS_COUNT]: PPDU packet count in spatial streams
1046  * @mpdu_cnt_fcs_ok: SU Rx success mpdu count
1047  * @mpdu_cnt_fcs_err: SU Rx fail mpdu count
1048  * @su_ax_ppdu_cnt: SU Rx packet count
1049  * @ppdu_cnt[MAX_RECEPTION_TYPES]: PPDU packet count in reception type
1050  * @rx_mu[RX_TYPE_MU_MAX]: Rx MU stats
1051  * @bw[MAX_BW]:  Packet Count in different bandwidths
1052  * @non_ampdu_cnt: Number of MSDUs with no MPDU level aggregation
1053  * @ampdu_cnt: Number of MSDUs part of AMSPU
1054  * @non_amsdu_cnt: Number of MSDUs with no MSDU level aggregation
1055  * @amsdu_cnt: Number of MSDUs part of AMSDU
1056  * @bar_recv_cnt: Number of bar received
1057  * @avg_rssi: Average rssi
1058  * @rx_rate: Rx rate
1059  * @last_rx_rate: Previous rx rate
1060  * @rnd_avg_rx_rate: Rounded average rx rate
1061  * @avg_rx_rate:  Average Rx rate
1062  * @dot11_rx_pkts: dot11 rx packets
1063  * @rx_bytes_last: last Rx success bytes
1064  * @rx_data_last: last rx success data
1065  * @rx_byte_rate: bytes received in last one sec
1066  * @rx_data_rate: data received in last one sec
1067  * @rx_retries: retries of packet in rx
1068  * @rx_mpdus: mpdu in rx
1069  * @rx_ppdus: ppdu in rx
1070  * @is_rx_tooshort: tooshort
1071  * @is_rx_decap: rx decap
1072  * @rx_ccmpmic: rx MIC check failed (CCMP)
1073  * @rx_tkipmic: rx MIC check failed (TKIP)
1074  * @rx_tkipicv: rx ICV check failed (TKIP)
1075  * @rx_wpimic: rx MIC check failed (WPI)
1076  * @rx_wepfail: rx wep processing failed
1077  * @rx_aggr: aggregation on rx
1078  * @rx_discard: packets discard in rx
1079  * @rx_ratecode: Rx rate code of last frame
1080  * @rx_flags: rx flags
1081  * @rx_rssi_measured_time: Time at which rssi is measured
1082  * @rssi: RSSI of received signal
1083  * @last_rssi: Previous rssi
1084  * @multipass_rx_pkt_drop: Dropped multipass rx pkt
1085  * @rx_mpdu_cnt: rx mpdu count per MCS rate
1086  * @to_stack_twt: Total packets sent up the stack in TWT session
1087  */
1088 struct cdp_rx_stats {
1089 	struct cdp_pkt_info to_stack;
1090 	struct cdp_pkt_info rcvd_reo[CDP_MAX_RX_RINGS];
1091 	struct cdp_pkt_info unicast;
1092 	struct cdp_pkt_info multicast;
1093 	struct cdp_pkt_info bcast;
1094 	struct cdp_pkt_info raw;
1095 	uint32_t nawds_mcast_drop;
1096 	struct cdp_pkt_info mec_drop;
1097 	struct {
1098 		struct cdp_pkt_info pkts;
1099 		struct cdp_pkt_info fail;
1100 		uint32_t mdns_no_fwd;
1101 	} intra_bss;
1102 #ifdef VDEV_PEER_PROTOCOL_COUNT
1103 	struct protocol_trace_count protocol_trace_cnt[CDP_TRACE_MAX];
1104 #endif
1105 
1106 	struct {
1107 		uint32_t mic_err;
1108 		uint32_t decrypt_err;
1109 		uint32_t fcserr;
1110 	} err;
1111 
1112 	uint32_t wme_ac_type[WME_AC_MAX];
1113 	uint32_t reception_type[MAX_RECEPTION_TYPES];
1114 	struct cdp_pkt_type pkt_type[DOT11_MAX];
1115 	uint32_t sgi_count[MAX_GI];
1116 	uint32_t nss[SS_COUNT];
1117 	uint32_t ppdu_nss[SS_COUNT];
1118 	uint32_t mpdu_cnt_fcs_ok;
1119 	uint32_t mpdu_cnt_fcs_err;
1120 	struct cdp_pkt_type su_ax_ppdu_cnt;
1121 	uint32_t ppdu_cnt[MAX_RECEPTION_TYPES];
1122 	struct cdp_rx_mu rx_mu[RX_TYPE_MU_MAX];
1123 	uint32_t bw[MAX_BW];
1124 	uint32_t non_ampdu_cnt;
1125 	uint32_t ampdu_cnt;
1126 	uint32_t non_amsdu_cnt;
1127 	uint32_t amsdu_cnt;
1128 	uint32_t bar_recv_cnt;
1129 	uint32_t avg_rssi;
1130 	uint32_t rx_rate;
1131 	uint32_t last_rx_rate;
1132 	uint32_t rnd_avg_rx_rate;
1133 	uint32_t avg_rx_rate;
1134 	struct cdp_pkt_info  dot11_rx_pkts;
1135 
1136 	uint32_t rx_bytes_success_last;
1137 	uint32_t rx_data_success_last;
1138 	uint32_t rx_byte_rate;
1139 	uint32_t rx_data_rate;
1140 
1141 	uint32_t rx_retries;
1142 	uint32_t rx_mpdus;
1143 	uint32_t rx_ppdus;
1144 
1145 	/*add for peer updated for ppdu*/
1146 	uint32_t rx_aggr;
1147 	uint32_t rx_discard;
1148 	uint32_t rx_ratecode;
1149 	uint32_t rx_flags;
1150 	uint32_t rx_rssi_measured_time;
1151 	uint8_t rssi;
1152 	uint8_t last_rssi;
1153 	uint32_t multipass_rx_pkt_drop;
1154 	uint32_t rx_mpdu_cnt[MAX_MCS];
1155 	struct cdp_pkt_info to_stack_twt;
1156 };
1157 
1158 /* struct cdp_tx_ingress_stats - Tx ingress Stats
1159  * @rcvd: Total packets received for transmission
1160  * @processed: Tx packets processed
1161  * @inspect_pkts: Total packets passed to inspect handler
1162  * @nawds_mcast: NAWDS  Multicast Packet Count
1163  * @bcast: Number of broadcast packets
1164  * @raw_pkt: Total Raw packets
1165  * @dma_map_error: DMA map error
1166  * @num_frags_overflow_err: msdu's nbuf count exceeds num of segemnts
1167  * @num_seg: No of segments in TSO packets
1168  * @tso_pkt:total no of TSO packets
1169  * @non_tso_pkts: non - TSO packets
1170  * @dropped_host: TSO packets dropped by host
1171  * @dropped_target:TSO packets dropped by target
1172  * @sg_pkt: Total scatter gather packets
1173  * @non_sg_pkts: non SG packets
1174  * @dropped_host: SG packets dropped by host
1175  * @dropped_target: SG packets dropped by target
1176  * @dma_map_error: Dma map error
1177  * @mcast_pkt: total no of multicast conversion packets
1178  * @dropped_map_error: packets dropped due to map error
1179  * @dropped_self_mac: packets dropped due to self Mac address
1180  * @dropped_send_fail: Packets dropped due to send fail
1181  * @ucast: total unicast packets transmitted
1182  * @fail_seg_alloc: Segment allocation failure
1183  * @clone_fail: NBUF clone failure
1184  * @igmp_rcvd: igmp pkts received for conversion to ucast pkts
1185  * @igmp_ucast_converted: unicast pkts sent as part of VoW IGMP improvements
1186  * @dropped_pkt: Total scatter gather packets
1187  * @desc_na: Desc Not Available
1188  * @exc_desc_na: Exception desc Not Available
1189  * @ring_full: ring full
1190  * @enqueue_fail: hw enqueue fail
1191  * @dma_error: dma fail
1192  * @res_full: Resource Full: Congestion Control
1193  * @fail_per_pkt_vdev_id_check: Per pkt vdev id check
1194  * @exception_fw: packets sent to fw
1195  * @completion_fw: packets completions received from fw
1196  * @cce_classified:Number of packets classified by CCE
1197  * @cce_classified_raw:Number of raw packets classified by CCE
1198  * @sniffer_rcvd: Number of packets received with ppdu cookie
1199  */
1200 struct cdp_tx_ingress_stats {
1201 	struct cdp_pkt_info rcvd;
1202 	struct cdp_pkt_info processed;
1203 	struct cdp_pkt_info reinject_pkts;
1204 	struct cdp_pkt_info inspect_pkts;
1205 	struct cdp_pkt_info nawds_mcast;
1206 	struct cdp_pkt_info bcast;
1207 
1208 	struct {
1209 		struct cdp_pkt_info raw_pkt;
1210 		uint32_t dma_map_error;
1211 		uint32_t invalid_raw_pkt_datatype;
1212 		uint32_t num_frags_overflow_err;
1213 	} raw;
1214 
1215 	/* Scatter Gather packet info */
1216 	struct {
1217 		struct cdp_pkt_info sg_pkt;
1218 		struct cdp_pkt_info non_sg_pkts;
1219 		struct cdp_pkt_info  dropped_host;
1220 		uint32_t dropped_target;
1221 		uint32_t dma_map_error;
1222 	} sg;
1223 
1224 	/* Multicast Enhancement packets info */
1225 	struct {
1226 		struct cdp_pkt_info mcast_pkt;
1227 		uint32_t dropped_map_error;
1228 		uint32_t dropped_self_mac;
1229 		uint32_t dropped_send_fail;
1230 		uint32_t ucast;
1231 		uint32_t fail_seg_alloc;
1232 		uint32_t clone_fail;
1233 	} mcast_en;
1234 
1235 	/* IGMP Multicast Enhancement packets info */
1236 	struct {
1237 		uint32_t igmp_rcvd;
1238 		uint32_t igmp_ucast_converted;
1239 	} igmp_mcast_en;
1240 
1241 	/* Packets dropped on the Tx side */
1242 	struct {
1243 		struct cdp_pkt_info dropped_pkt;
1244 		struct cdp_pkt_info  desc_na;
1245 		struct cdp_pkt_info  exc_desc_na;
1246 		uint32_t ring_full;
1247 		uint32_t enqueue_fail;
1248 		uint32_t dma_error;
1249 		uint32_t res_full;
1250 		/* headroom insufficient */
1251 		uint32_t headroom_insufficient;
1252 		uint32_t fail_per_pkt_vdev_id_check;
1253 	} dropped;
1254 
1255 	/* Mesh packets info */
1256 	struct {
1257 		uint32_t exception_fw;
1258 		uint32_t completion_fw;
1259 	} mesh;
1260 
1261 	uint32_t cce_classified;
1262 	uint32_t cce_classified_raw;
1263 	struct cdp_pkt_info sniffer_rcvd;
1264 	struct cdp_tso_stats tso_stats;
1265 };
1266 
1267 /* struct cdp_vdev_stats - vdev stats structure
1268  * @tx_i: ingress tx stats
1269  * @tx: cdp tx stats
1270  * @rx: cdp rx stats
1271  * @tso_stats: tso stats
1272  */
1273 struct cdp_vdev_stats {
1274 	struct cdp_tx_ingress_stats tx_i;
1275 	struct cdp_tx_stats tx;
1276 	struct cdp_rx_stats rx;
1277 	struct cdp_tso_stats tso_stats;
1278 };
1279 
1280 /* struct cdp_peer_stats - peer stats structure
1281  * @tx: cdp tx stats
1282  * @rx: cdp rx stats
1283  */
1284 struct cdp_peer_stats {
1285 	/* CDP Tx Stats */
1286 	struct cdp_tx_stats tx;
1287 	/* CDP Rx Stats */
1288 	struct cdp_rx_stats rx;
1289 };
1290 
1291 /* struct cdp_peer_tid_stats - Per peer and per TID stats
1292  * @tx_avg_jitter: tx average jitter
1293  * @tx_avg_delay: tx average delay
1294  * @tx_avg_err: tx average error
1295  * @tx_total_success: tx total success
1296  * @tx_drop: tx drop
1297  */
1298 struct cdp_peer_tid_stats {
1299 #ifdef WLAN_PEER_JITTER
1300 	uint32_t tx_avg_jitter;
1301 	uint32_t tx_avg_delay;
1302 	uint64_t tx_avg_err;
1303 	uint64_t tx_total_success;
1304 	uint64_t tx_drop;
1305 #endif
1306 };
1307 
1308 /* struct cdp_interface_peer_stats - interface structure for txrx peer stats
1309  * @peer_mac: peer mac address
1310  * @vdev_id : vdev_id for the peer
1311  * @last_peer_tx_rate: peer tx rate for last transmission
1312  * @peer_tx_rate: tx rate for current transmission
1313  * @peer_rssi: current rssi value of peer
1314  * @tx_packet_count: tx packet count
1315  * @rx_packet_count: rx packet count
1316  * @tx_byte_count: tx byte count
1317  * @rx_byte_count: rx byte count
1318  * @per: per error rate
1319  * @ack_rssi: RSSI of the last ack received
1320  * @rssi_changed: denotes rssi is changed
1321  */
1322 struct cdp_interface_peer_stats {
1323 	uint8_t  peer_mac[QDF_MAC_ADDR_SIZE];
1324 	uint8_t  vdev_id;
1325 	uint8_t  rssi_changed;
1326 	uint32_t last_peer_tx_rate;
1327 	uint32_t peer_tx_rate;
1328 	uint32_t peer_rssi;
1329 	uint32_t tx_packet_count;
1330 	uint32_t rx_packet_count;
1331 	uint32_t tx_byte_count;
1332 	uint32_t rx_byte_count;
1333 	uint32_t per;
1334 	uint32_t ack_rssi;
1335 };
1336 
1337 /* struct cdp_interface_peer_qos_stats - interface structure for peer qos stats
1338  * @peer_mac: peer mac address
1339  * @frame_control: frame control field
1340  * @qos_control: qos control field
1341  * @frame_control_info_valid: frame_control valid
1342  * @qos_control_info_valid: qos_control valid
1343  * @vdev_id : vdev_id for the peer
1344  */
1345 struct cdp_interface_peer_qos_stats {
1346 	uint8_t  peer_mac[QDF_MAC_ADDR_SIZE];
1347 	uint16_t frame_control;
1348 	uint16_t qos_control;
1349 	uint8_t  frame_control_info_valid;
1350 	uint8_t  qos_control_info_valid;
1351 	uint8_t  vdev_id;
1352 };
1353 
1354 /* Tx completions per interrupt */
1355 struct cdp_hist_tx_comp {
1356 	uint32_t pkts_1;
1357 	uint32_t pkts_2_20;
1358 	uint32_t pkts_21_40;
1359 	uint32_t pkts_41_60;
1360 	uint32_t pkts_61_80;
1361 	uint32_t pkts_81_100;
1362 	uint32_t pkts_101_200;
1363 	uint32_t pkts_201_plus;
1364 };
1365 
1366 /* Rx ring descriptors reaped per interrupt */
1367 struct cdp_hist_rx_ind {
1368 	uint32_t pkts_1;
1369 	uint32_t pkts_2_20;
1370 	uint32_t pkts_21_40;
1371 	uint32_t pkts_41_60;
1372 	uint32_t pkts_61_80;
1373 	uint32_t pkts_81_100;
1374 	uint32_t pkts_101_200;
1375 	uint32_t pkts_201_plus;
1376 };
1377 
1378 struct cdp_htt_tlv_hdr {
1379 	/* BIT [11 :  0]   :- tag
1380 	 * BIT [23 : 12]   :- length
1381 	 * BIT [31 : 24]   :- reserved
1382 	 */
1383 	uint32_t tag__length;
1384 };
1385 
1386 #define HTT_STATS_SUBTYPE_MAX     16
1387 
1388 struct cdp_htt_rx_pdev_fw_stats_tlv {
1389     struct cdp_htt_tlv_hdr tlv_hdr;
1390 
1391     /* BIT [ 7 :  0]   :- mac_id
1392      * BIT [31 :  8]   :- reserved
1393      */
1394     uint32_t mac_id__word;
1395     /* Num PPDU status processed from HW */
1396     uint32_t ppdu_recvd;
1397     /* Num MPDU across PPDUs with FCS ok */
1398     uint32_t mpdu_cnt_fcs_ok;
1399     /* Num MPDU across PPDUs with FCS err */
1400     uint32_t mpdu_cnt_fcs_err;
1401     /* Num MSDU across PPDUs */
1402     uint32_t tcp_msdu_cnt;
1403     /* Num MSDU across PPDUs */
1404     uint32_t tcp_ack_msdu_cnt;
1405     /* Num MSDU across PPDUs */
1406     uint32_t udp_msdu_cnt;
1407     /* Num MSDU across PPDUs */
1408     uint32_t other_msdu_cnt;
1409     /* Num MPDU on FW ring indicated */
1410     uint32_t fw_ring_mpdu_ind;
1411     /* Num MGMT MPDU given to protocol */
1412     uint32_t fw_ring_mgmt_subtype[HTT_STATS_SUBTYPE_MAX];
1413     /* Num ctrl MPDU given to protocol */
1414     uint32_t fw_ring_ctrl_subtype[HTT_STATS_SUBTYPE_MAX];
1415     /* Num mcast data packet received */
1416     uint32_t fw_ring_mcast_data_msdu;
1417     /* Num broadcast data packet received */
1418     uint32_t fw_ring_bcast_data_msdu;
1419     /* Num unicat data packet received */
1420     uint32_t fw_ring_ucast_data_msdu;
1421     /* Num null data packet received  */
1422     uint32_t fw_ring_null_data_msdu;
1423     /* Num MPDU on FW ring dropped */
1424     uint32_t fw_ring_mpdu_drop;
1425 
1426     /* Num buf indication to offload */
1427     uint32_t ofld_local_data_ind_cnt;
1428     /* Num buf recycle from offload */
1429     uint32_t ofld_local_data_buf_recycle_cnt;
1430     /* Num buf indication to data_rx */
1431     uint32_t drx_local_data_ind_cnt;
1432     /* Num buf recycle from data_rx */
1433     uint32_t drx_local_data_buf_recycle_cnt;
1434     /* Num buf indication to protocol */
1435     uint32_t local_nondata_ind_cnt;
1436     /* Num buf recycle from protocol */
1437     uint32_t local_nondata_buf_recycle_cnt;
1438 
1439     /* Num buf fed */
1440     uint32_t fw_status_buf_ring_refill_cnt;
1441     /* Num ring empty encountered */
1442     uint32_t fw_status_buf_ring_empty_cnt;
1443     /* Num buf fed  */
1444     uint32_t fw_pkt_buf_ring_refill_cnt;
1445     /* Num ring empty encountered */
1446     uint32_t fw_pkt_buf_ring_empty_cnt;
1447     /* Num buf fed  */
1448     uint32_t fw_link_buf_ring_refill_cnt;
1449     /* Num ring empty encountered  */
1450     uint32_t fw_link_buf_ring_empty_cnt;
1451 
1452     /* Num buf fed */
1453     uint32_t host_pkt_buf_ring_refill_cnt;
1454     /* Num ring empty encountered */
1455     uint32_t host_pkt_buf_ring_empty_cnt;
1456     /* Num buf fed */
1457     uint32_t mon_pkt_buf_ring_refill_cnt;
1458     /* Num ring empty encountered */
1459     uint32_t mon_pkt_buf_ring_empty_cnt;
1460     /* Num buf fed */
1461     uint32_t mon_status_buf_ring_refill_cnt;
1462     /* Num ring empty encountered */
1463     uint32_t mon_status_buf_ring_empty_cnt;
1464     /* Num buf fed */
1465     uint32_t mon_desc_buf_ring_refill_cnt;
1466     /* Num ring empty encountered */
1467     uint32_t mon_desc_buf_ring_empty_cnt;
1468     /* Num buf fed */
1469     uint32_t mon_dest_ring_update_cnt;
1470     /* Num ring full encountered */
1471     uint32_t mon_dest_ring_full_cnt;
1472 
1473     /* Num rx suspend is attempted */
1474     uint32_t rx_suspend_cnt;
1475     /* Num rx suspend failed */
1476     uint32_t rx_suspend_fail_cnt;
1477     /* Num rx resume attempted */
1478     uint32_t rx_resume_cnt;
1479     /* Num rx resume failed */
1480     uint32_t rx_resume_fail_cnt;
1481     /* Num rx ring switch */
1482     uint32_t rx_ring_switch_cnt;
1483     /* Num rx ring restore */
1484     uint32_t rx_ring_restore_cnt;
1485     /* Num rx flush issued */
1486     uint32_t rx_flush_cnt;
1487 };
1488 
1489 /* == TX PDEV STATS == */
1490 struct cdp_htt_tx_pdev_stats_cmn_tlv {
1491     struct cdp_htt_tlv_hdr tlv_hdr;
1492 
1493     /* BIT [ 7 :  0]   :- mac_id
1494      * BIT [31 :  8]   :- reserved
1495      */
1496     uint32_t mac_id__word;
1497     /* Num queued to HW */
1498     uint32_t hw_queued;
1499     /* Num PPDU reaped from HW */
1500     uint32_t hw_reaped;
1501     /* Num underruns */
1502     uint32_t underrun;
1503     /* Num HW Paused counter. */
1504     uint32_t hw_paused;
1505     /* Num HW flush counter. */
1506     uint32_t hw_flush;
1507     /* Num HW filtered counter. */
1508     uint32_t hw_filt;
1509     /* Num PPDUs cleaned up in TX abort */
1510     uint32_t tx_abort;
1511     /* Num MPDUs requed by SW */
1512     uint32_t mpdu_requed;
1513     /* excessive retries */
1514     uint32_t tx_xretry;
1515     /* Last used data hw rate code */
1516     uint32_t data_rc;
1517     /* frames dropped due to excessive sw retries */
1518     uint32_t mpdu_dropped_xretry;
1519     /* illegal rate phy errors  */
1520     uint32_t illgl_rate_phy_err;
1521     /* wal pdev continuous xretry */
1522     uint32_t cont_xretry;
1523     /* wal pdev continuous xretry */
1524     uint32_t tx_timeout;
1525     /* wal pdev resets  */
1526     uint32_t pdev_resets;
1527     /* PhY/BB underrun */
1528     uint32_t phy_underrun;
1529     /* MPDU is more than txop limit */
1530     uint32_t txop_ovf;
1531     /* Number of Sequences posted */
1532     uint32_t seq_posted;
1533     /* Number of Sequences failed queueing */
1534     uint32_t seq_failed_queueing;
1535     /* Number of Sequences completed */
1536     uint32_t seq_completed;
1537     /* Number of Sequences restarted */
1538     uint32_t seq_restarted;
1539     /* Number of MU Sequences posted */
1540     uint32_t mu_seq_posted;
1541     /* Number of time HW ring is paused between seq switch within ISR */
1542     uint32_t seq_switch_hw_paused;
1543     /* Number of times seq continuation in DSR */
1544     uint32_t next_seq_posted_dsr;
1545     /* Number of times seq continuation in ISR */
1546     uint32_t seq_posted_isr;
1547     /* Number of seq_ctrl cached. */
1548     uint32_t seq_ctrl_cached;
1549     /* Number of MPDUs successfully transmitted */
1550     uint32_t mpdu_count_tqm;
1551     /* Number of MSDUs successfully transmitted */
1552     uint32_t msdu_count_tqm;
1553     /* Number of MPDUs dropped */
1554     uint32_t mpdu_removed_tqm;
1555     /* Number of MSDUs dropped */
1556     uint32_t msdu_removed_tqm;
1557     /* Num MPDUs flushed by SW, HWPAUSED, SW TXABORT (Reset,channel change) */
1558     uint32_t mpdus_sw_flush;
1559     /* Num MPDUs filtered by HW, all filter condition (TTL expired) */
1560     uint32_t mpdus_hw_filter;
1561     /* Num MPDUs truncated by PDG (TXOP, TBTT, PPDU_duration based on rate, dyn_bw) */
1562     uint32_t mpdus_truncated;
1563     /* Num MPDUs that was tried but didn't receive ACK or BA */
1564     uint32_t mpdus_ack_failed;
1565     /* Num MPDUs that was dropped due to expiry (MSDU TTL). */
1566     uint32_t mpdus_expired;
1567     /* Num MPDUs that was retried within seq_ctrl (MGMT/LEGACY) */
1568     uint32_t mpdus_seq_hw_retry;
1569     /* Num of TQM acked cmds processed */
1570     uint32_t ack_tlv_proc;
1571     /* coex_abort_mpdu_cnt valid. */
1572     uint32_t coex_abort_mpdu_cnt_valid;
1573     /* coex_abort_mpdu_cnt from TX FES stats. */
1574     uint32_t coex_abort_mpdu_cnt;
1575     /* Number of total PPDUs(DATA, MGMT, excludes selfgen) tried over the air (OTA) */
1576     uint32_t num_total_ppdus_tried_ota;
1577     /* Number of data PPDUs tried over the air (OTA) */
1578     uint32_t num_data_ppdus_tried_ota;
1579     /* Num Local control/mgmt frames (MSDUs) queued */
1580     uint32_t local_ctrl_mgmt_enqued;
1581     /* local_ctrl_mgmt_freed:
1582      * Num Local control/mgmt frames (MSDUs) done
1583      * It includes all local ctrl/mgmt completions
1584      * (acked, no ack, flush, TTL, etc)
1585      */
1586     uint32_t local_ctrl_mgmt_freed;
1587     /* Num Local data frames (MSDUs) queued */
1588     uint32_t local_data_enqued;
1589     /* local_data_freed:
1590      * Num Local data frames (MSDUs) done
1591      * It includes all local data completions
1592      * (acked, no ack, flush, TTL, etc)
1593      */
1594     uint32_t local_data_freed;
1595 
1596 	/* Num MPDUs tried by SW */
1597 	uint32_t mpdu_tried;
1598 	/* Num of waiting seq posted in isr completion handler */
1599 	uint32_t isr_wait_seq_posted;
1600 	uint32_t tx_active_dur_us_low;
1601 	uint32_t tx_active_dur_us_high;
1602 };
1603 
1604 struct cdp_htt_tx_pdev_stats_urrn_tlv_v {
1605     struct cdp_htt_tlv_hdr tlv_hdr;
1606     uint32_t urrn_stats[1]; /* HTT_TX_PDEV_MAX_URRN_STATS */
1607 };
1608 
1609 /* NOTE: Variable length TLV, use length spec to infer array size */
1610 struct cdp_htt_tx_pdev_stats_flush_tlv_v {
1611     struct cdp_htt_tlv_hdr tlv_hdr;
1612     uint32_t flush_errs[1]; /* HTT_TX_PDEV_MAX_FLUSH_REASON_STATS */
1613 };
1614 
1615 /* NOTE: Variable length TLV, use length spec to infer array size */
1616 struct cdp_htt_tx_pdev_stats_sifs_tlv_v {
1617     struct cdp_htt_tlv_hdr tlv_hdr;
1618     uint32_t sifs_status[1]; /* HTT_TX_PDEV_MAX_SIFS_BURST_STATS */
1619 };
1620 
1621 /* NOTE: Variable length TLV, use length spec to infer array size */
1622 struct cdp_htt_tx_pdev_stats_phy_err_tlv_v {
1623     struct cdp_htt_tlv_hdr tlv_hdr;
1624     uint32_t  phy_errs[1]; /* HTT_TX_PDEV_MAX_PHY_ERR_STATS */
1625 };
1626 
1627 /* == RX PDEV/SOC STATS == */
1628 /* HTT_STATS_RX_SOC_FW_STATS_TAG */
1629 struct cdp_htt_rx_soc_fw_stats_tlv {
1630     struct cdp_htt_tlv_hdr tlv_hdr;
1631     /* Num Packets received on REO FW ring */
1632     uint32_t fw_reo_ring_data_msdu;
1633     /* Num bc/mc packets indicated from fw to host */
1634     uint32_t fw_to_host_data_msdu_bcmc;
1635     /* Num unicast packets indicated from fw to host */
1636     uint32_t fw_to_host_data_msdu_uc;
1637     /* Num remote buf recycle from offload  */
1638     uint32_t ofld_remote_data_buf_recycle_cnt;
1639     /* Num remote free buf given to offload */
1640     uint32_t ofld_remote_free_buf_indication_cnt;
1641 };
1642 
1643 struct cdp_htt_rx_soc_fw_refill_ring_num_refill_tlv_v {
1644     struct cdp_htt_tlv_hdr tlv_hdr;
1645     /* Num total buf refilled from refill ring */
1646     uint32_t refill_ring_num_refill[1]; /* HTT_RX_STATS_REFILL_MAX_RING */
1647 };
1648 
1649 struct cdp_htt_rx_pdev_fw_ring_mpdu_err_tlv_v {
1650     struct cdp_htt_tlv_hdr tlv_hdr;
1651     /* Num error MPDU for each RxDMA error type  */
1652     uint32_t fw_ring_mpdu_err[1]; /* HTT_RX_STATS_RXDMA_MAX_ERR */
1653 };
1654 
1655 struct cdp_htt_rx_pdev_fw_mpdu_drop_tlv_v {
1656     struct cdp_htt_tlv_hdr tlv_hdr;
1657     /* Num MPDU dropped  */
1658     uint32_t fw_mpdu_drop[1]; /* HTT_RX_STATS_FW_DROP_REASON_MAX */
1659 };
1660 
1661 #define HTT_STATS_PHY_ERR_MAX 43
1662 
1663 struct cdp_htt_rx_pdev_fw_stats_phy_err_tlv {
1664     struct cdp_htt_tlv_hdr tlv_hdr;
1665 
1666     /* BIT [ 7 :  0]   :- mac_id
1667      * BIT [31 :  8]   :- reserved
1668      */
1669     uint32_t mac_id__word;
1670     /* Num of phy err */
1671     uint32_t total_phy_err_cnt;
1672     /* Counts of different types of phy errs
1673      * The mapping of PHY error types to phy_err array elements is HW dependent.
1674      * The only currently-supported mapping is shown below:
1675      *
1676      * 0 phyrx_err_phy_off Reception aborted due to receiving a PHY_OFF TLV
1677      * 1 phyrx_err_synth_off
1678      * 2 phyrx_err_ofdma_timing
1679      * 3 phyrx_err_ofdma_signal_parity
1680      * 4 phyrx_err_ofdma_rate_illegal
1681      * 5 phyrx_err_ofdma_length_illegal
1682      * 6 phyrx_err_ofdma_restart
1683      * 7 phyrx_err_ofdma_service
1684      * 8 phyrx_err_ppdu_ofdma_power_drop
1685      * 9 phyrx_err_cck_blokker
1686      * 10 phyrx_err_cck_timing
1687      * 11 phyrx_err_cck_header_crc
1688      * 12 phyrx_err_cck_rate_illegal
1689      * 13 phyrx_err_cck_length_illegal
1690      * 14 phyrx_err_cck_restart
1691      * 15 phyrx_err_cck_service
1692      * 16 phyrx_err_cck_power_drop
1693      * 17 phyrx_err_ht_crc_err
1694      * 18 phyrx_err_ht_length_illegal
1695      * 19 phyrx_err_ht_rate_illegal
1696      * 20 phyrx_err_ht_zlf
1697      * 21 phyrx_err_false_radar_ext
1698      * 22 phyrx_err_green_field
1699      * 23 phyrx_err_bw_gt_dyn_bw
1700      * 24 phyrx_err_leg_ht_mismatch
1701      * 25 phyrx_err_vht_crc_error
1702      * 26 phyrx_err_vht_siga_unsupported
1703      * 27 phyrx_err_vht_lsig_len_invalid
1704      * 28 phyrx_err_vht_ndp_or_zlf
1705      * 29 phyrx_err_vht_nsym_lt_zero
1706      * 30 phyrx_err_vht_rx_extra_symbol_mismatch
1707      * 31 phyrx_err_vht_rx_skip_group_id0
1708      * 32 phyrx_err_vht_rx_skip_group_id1to62
1709      * 33 phyrx_err_vht_rx_skip_group_id63
1710      * 34 phyrx_err_ofdm_ldpc_decoder_disabled
1711      * 35 phyrx_err_defer_nap
1712      * 36 phyrx_err_fdomain_timeout
1713      * 37 phyrx_err_lsig_rel_check
1714      * 38 phyrx_err_bt_collision
1715      * 39 phyrx_err_unsupported_mu_feedback
1716      * 40 phyrx_err_ppdu_tx_interrupt_rx
1717      * 41 phyrx_err_unsupported_cbf
1718      * 42 phyrx_err_other
1719      */
1720     uint32_t phy_err[HTT_STATS_PHY_ERR_MAX];
1721 };
1722 
1723 struct cdp_htt_rx_soc_fw_refill_ring_empty_tlv_v {
1724     struct cdp_htt_tlv_hdr tlv_hdr;
1725     /* Num ring empty encountered */
1726     uint32_t refill_ring_empty_cnt[1]; /* HTT_RX_STATS_REFILL_MAX_RING */
1727 };
1728 
1729 struct cdp_htt_tx_pdev_stats {
1730     struct cdp_htt_tx_pdev_stats_cmn_tlv cmn_tlv;
1731     struct cdp_htt_tx_pdev_stats_urrn_tlv_v underrun_tlv;
1732     struct cdp_htt_tx_pdev_stats_sifs_tlv_v sifs_tlv;
1733     struct cdp_htt_tx_pdev_stats_flush_tlv_v flush_tlv;
1734     struct cdp_htt_tx_pdev_stats_phy_err_tlv_v phy_err_tlv;
1735 };
1736 
1737 struct cdp_htt_rx_soc_stats_t {
1738     struct cdp_htt_rx_soc_fw_stats_tlv fw_tlv;
1739     struct cdp_htt_rx_soc_fw_refill_ring_empty_tlv_v fw_refill_ring_empty_tlv;
1740     struct cdp_htt_rx_soc_fw_refill_ring_num_refill_tlv_v fw_refill_ring_num_refill_tlv;
1741 };
1742 
1743 struct cdp_htt_rx_pdev_stats {
1744     struct cdp_htt_rx_soc_stats_t soc_stats;
1745     struct cdp_htt_rx_pdev_fw_stats_tlv fw_stats_tlv;
1746     struct cdp_htt_rx_pdev_fw_ring_mpdu_err_tlv_v fw_ring_mpdu_err_tlv;
1747     struct cdp_htt_rx_pdev_fw_mpdu_drop_tlv_v fw_ring_mpdu_drop;
1748     struct cdp_htt_rx_pdev_fw_stats_phy_err_tlv fw_stats_phy_err_tlv;
1749 };
1750 
1751 #ifdef WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG
1752 /* Since protocol type enumeration value is passed as CCE metadata
1753  * to firmware, add a constant offset before passing it to firmware
1754  */
1755 #define RX_PROTOCOL_TAG_START_OFFSET  128
1756 /* This should align with packet type enumerations in ieee80211_ioctl.h
1757  * and wmi_unified_param.h files
1758  */
1759 #define RX_PROTOCOL_TAG_MAX   24
1760 /* Macro that should be used to dump the statistics counter for all
1761  * protocol types
1762  */
1763 #define RX_PROTOCOL_TAG_ALL 0xff
1764 #endif /* WLAN_SUPPORT_RX_PROTOCOL_TYPE_TAG */
1765 
1766 #define OFDMA_NUM_RU_SIZE 7
1767 
1768 #define OFDMA_NUM_USERS	37
1769 
1770 #if defined(WLAN_CFR_ENABLE) && defined(WLAN_ENH_CFR_ENABLE)
1771 /*
1772  * mac_freeze_capture_reason - capture reason counters
1773  * @FREEZE_REASON_TM: When m_directed_ftm is enabled, this CFR data is
1774  * captured for a Timing Measurement (TM) frame.
1775  * @FREEZE_REASON_FTM: When m_directed_ftm is enabled, this CFR data is
1776  * captured for a Fine Timing Measurement (FTM) frame.
1777  * @FREEZE_REASON_ACK_RESP_TO_TM_FTM: When m_all_ftm_ack is enabled, this CFR
1778  * data is captured for an ACK received for the FTM/TM frame sent to a station.
1779  * @FREEZE_REASON_TA_RA_TYPE_FILTER: When m_ta_ra_filter is enabled, this CFR
1780  * data is captured for a PPDU received,since the CFR TA_RA filter is met.
1781  * @FREEZE_REASON_NDPA_NDP: When m_ndpa_ndp_directed(or)m_ndpa_ndp_all is
1782  * enabled, this CFR data is captured for an NDP frame received.
1783  * @FREEZE_REASON_ALL_PACKET: When m_all_packet is enabled, this CFR data is
1784  * captured for an incoming PPDU.
1785  */
1786 enum mac_freeze_capture_reason {
1787 	FREEZE_REASON_TM = 0,
1788 	FREEZE_REASON_FTM,
1789 	FREEZE_REASON_ACK_RESP_TO_TM_FTM,
1790 	FREEZE_REASON_TA_RA_TYPE_FILTER,
1791 	FREEZE_REASON_NDPA_NDP,
1792 	FREEZE_REASON_ALL_PACKET,
1793 	FREEZE_REASON_MAX,
1794 };
1795 
1796 /*
1797  * chan_capture_status: capture status counters
1798  * @CAPTURE_IDLE: CFR data is not captured, since VCSR setting for CFR/RCC is
1799  * not enabled.
1800  * @CAPTURE_BUSY: CFR data is not available, since previous channel
1801  * upload is in progress
1802  * @CAPTURE_ACTIVE: CFR data is captured in HW registers
1803  * @CAPTURE_NO_BUFFER: CFR data is not captured, since no buffer is available
1804  * in IPC ring to DMA CFR data
1805  */
1806 enum chan_capture_status {
1807 	CAPTURE_IDLE = 0,
1808 	CAPTURE_BUSY,
1809 	CAPTURE_ACTIVE,
1810 	CAPTURE_NO_BUFFER,
1811 	CAPTURE_MAX,
1812 };
1813 
1814 /* struct cdp_cfr_rcc_stats - CFR RCC debug statistics
1815  * @bb_captured_channel_cnt: No. of PPDUs for which MAC sent Freeze TLV to PHY
1816  * @bb_captured_timeout_cnt: No. of PPDUs for which CFR filter criteria matched
1817  * but MAC did not send Freeze TLV to PHY as time exceeded freeze tlv delay
1818  * count threshold
1819  * @rx_loc_info_valid_cnt: No. of PPDUs for which PHY could find a valid buffer
1820  * in ucode IPC ring
1821  * @chan_capture_status[]: capture status counters
1822  *	[0] - No. of PPDUs with capture status CAPTURE_IDLE
1823  *	[1] - No. of PPDUs with capture status CAPTURE_BUSY
1824  *	[2] - No. of PPDUs with capture status CAPTURE_ACTIVE
1825  *	[3] - No. of PPDUs with capture status CAPTURE_NO_BUFFER
1826  * @reason_cnt[]: capture reason counters
1827  *	[0] - No. PPDUs filtered due to freeze_reason_TM
1828  *	[1] - No. PPDUs filtered due to freeze_reason_FTM
1829  *	[2] - No. PPDUs filtered due to freeze_reason_ACK_resp_to_TM_FTM
1830  *	[3] - No. PPDUs filtered due to freeze_reason_TA_RA_TYPE_FILTER
1831  *	[4] - No. PPDUs filtered due to freeze_reason_NDPA_NDP
1832  *	[5] - No. PPDUs filtered due to freeze_reason_ALL_PACKET
1833  */
1834 struct cdp_cfr_rcc_stats {
1835 	uint64_t bb_captured_channel_cnt;
1836 	uint64_t bb_captured_timeout_cnt;
1837 	uint64_t rx_loc_info_valid_cnt;
1838 	uint64_t chan_capture_status[CAPTURE_MAX];
1839 	uint64_t reason_cnt[FREEZE_REASON_MAX];
1840 };
1841 #else
1842 struct cdp_cfr_rcc_stats {
1843 };
1844 #endif
1845 /* struct cdp_pdev_stats - pdev stats
1846  * @msdu_not_done: packets dropped because msdu done bit not set
1847  * @mec:Multicast Echo check
1848  * @mesh_filter: Mesh Filtered packets
1849  * @mon_rx_drop: packets dropped on monitor vap
1850  * @wifi_parse: rxdma errors due to wifi parse error
1851  * @mon_radiotap_update_err: not enough space to update radiotap
1852  * @pkts: total packets replenished
1853  * @rxdma_err: rxdma errors for replenished
1854  * @nbuf_alloc_fail: nbuf alloc failed
1855  * @frag_alloc_fail: frag alloc failed
1856  * @map_err: Mapping failure
1857  * @x86_fail: x86 failures
1858  * @low_thresh_intrs: low threshold interrupts
1859  * @rx_raw_pkts: Rx Raw Packets
1860  * @mesh_mem_alloc: Mesh Rx Stats Alloc fail
1861  * @tso_desc_cnt: TSO descriptors
1862  * @sg_desc_cnt: SG Descriptors
1863  * @vlan_tag_stp_cnt: Vlan tagged Stp packets in wifi parse error
1864  * @desc_alloc_fail: desc alloc failed errors
1865  * @ip_csum_err: ip checksum errors
1866  * @tcp_udp_csum_err: tcp/udp checksum errors
1867  * @buf_freelist: buffers added back in freelist
1868  * @tx_i: Tx Ingress stats
1869  * @tx:CDP Tx Stats
1870  * @rx: CDP Rx Stats
1871  * @tx_comp_histogram: Number of Tx completions per interrupt
1872  * @rx_ind_histogram:  Number of Rx ring descriptors reaped per interrupt
1873  * @ppdu_stats_counter: ppdu stats counter
1874  * @cdp_delayed_ba_not_recev: counter for delayed ba not received
1875  * @htt_tx_pdev_stats: htt pdev stats for tx
1876  * @htt_rx_pdev_stats: htt pdev stats for rx
1877  * @data_rx_ru_size: UL ofdma data ru size counter array
1878  * @nondata_rx_ru_size: UL ofdma non data ru size counter array
1879  * @data_rx_ppdu: data rx ppdu counter
1880  * @data_user: data user counter array
1881  * @tx_ppdu_proc: stats counter for tx ppdu processed
1882  * @ack_ba_comes_twice: stats counter for ack_ba_comes twice
1883  * @ppdu_drop: stats counter for ppdu_desc drop once threshold reached
1884  * @ppdu_wrap_drop: stats counter for ppdu desc drop on wrap around
1885  */
1886 struct cdp_pdev_stats {
1887 	struct {
1888 		uint32_t msdu_not_done;
1889 		uint32_t mec;
1890 		uint32_t mesh_filter;
1891 		uint32_t wifi_parse;
1892 		/* Monitor mode related */
1893 		uint32_t mon_rx_drop;
1894 		uint32_t mon_radiotap_update_err;
1895 	} dropped;
1896 
1897 	struct {
1898 		struct cdp_pkt_info pkts;
1899 		uint32_t rxdma_err;
1900 		uint32_t nbuf_alloc_fail;
1901 		uint32_t frag_alloc_fail;
1902 		uint32_t map_err;
1903 		uint32_t x86_fail;
1904 		uint32_t low_thresh_intrs;
1905 	} replenish;
1906 
1907 	uint32_t rx_raw_pkts;
1908 	uint32_t mesh_mem_alloc;
1909 	uint32_t tso_desc_cnt;
1910 	uint32_t sg_desc_cnt;
1911 	uint32_t vlan_tag_stp_cnt;
1912 
1913 	/* Rx errors */
1914 	struct {
1915 		uint32_t desc_alloc_fail;
1916 		uint32_t ip_csum_err;
1917 		uint32_t tcp_udp_csum_err;
1918 		uint32_t rxdma_error;
1919 		uint32_t reo_error;
1920 	} err;
1921 
1922 	uint32_t buf_freelist;
1923 	struct cdp_tx_ingress_stats tx_i;
1924 	struct cdp_tx_stats tx;
1925 	struct cdp_rx_stats rx;
1926 	struct cdp_hist_tx_comp tx_comp_histogram;
1927 	struct cdp_hist_rx_ind rx_ind_histogram;
1928 	uint64_t ppdu_stats_counter[CDP_PPDU_STATS_MAX_TAG];
1929 	uint32_t cdp_delayed_ba_not_recev;
1930 
1931 	struct cdp_htt_tx_pdev_stats  htt_tx_pdev_stats;
1932 	struct cdp_htt_rx_pdev_stats  htt_rx_pdev_stats;
1933 
1934 	/* Received wdi messages from fw */
1935 	uint32_t wdi_event[CDP_WDI_NUM_EVENTS];
1936 	struct cdp_tid_stats tid_stats;
1937 
1938 	/* numbers of data/nondata per RU sizes */
1939 	struct {
1940 		uint32_t data_rx_ru_size[OFDMA_NUM_RU_SIZE];
1941 		uint32_t nondata_rx_ru_size[OFDMA_NUM_RU_SIZE];
1942 		uint32_t data_rx_ppdu;
1943 		uint32_t data_users[OFDMA_NUM_USERS];
1944 	} ul_ofdma;
1945 
1946 	struct cdp_tso_stats tso_stats;
1947 	struct cdp_cfr_rcc_stats rcc;
1948 
1949 	uint64_t tx_ppdu_proc;
1950 	uint64_t ack_ba_comes_twice;
1951 	uint64_t ppdu_drop;
1952 	uint64_t ppdu_wrap_drop;
1953 
1954 	struct {
1955 		uint64_t num_bufs_consumed;
1956 		uint64_t num_pool_bufs_replenish;
1957 		uint64_t num_bufs_alloc_success;
1958 	} rx_buffer_pool;
1959 };
1960 
1961 /* struct cdp_peer_hmwds_ast_add_status - hmwds peer ast add status
1962  * @vdev_id: vdev id
1963  * @status: ast add status
1964  * @peer_mac: peer mac address
1965  * @ast_mac: ast node mac address
1966  */
1967 struct cdp_peer_hmwds_ast_add_status {
1968 	uint32_t vdev_id;
1969 	uint32_t status;
1970 	uint8_t  peer_mac[QDF_MAC_ADDR_SIZE];
1971 	uint8_t  ast_mac[QDF_MAC_ADDR_SIZE];
1972 };
1973 
1974 enum cdp_soc_param_t {
1975 	DP_SOC_PARAM_MSDU_EXCEPTION_DESC,
1976 	DP_SOC_PARAM_CMEM_FSE_SUPPORT,
1977 	DP_SOC_PARAM_MAX,
1978 };
1979 
1980 #ifdef QCA_ENH_V3_STATS_SUPPORT
1981 /*
1982  * Enumeration of PDEV Configuration parameter
1983  */
1984 enum _dp_param_t {
1985 	DP_PARAM_MSDU_TTL,
1986 	DP_PARAM_TOTAL_Q_SIZE_RANGE0,
1987 	DP_PARAM_TOTAL_Q_SIZE_RANGE1,
1988 	DP_PARAM_TOTAL_Q_SIZE_RANGE2,
1989 	DP_PARAM_TOTAL_Q_SIZE_RANGE3,
1990 	DP_PARAM_VIDEO_DELAY_STATS_FC,
1991 	DP_PARAM_QFLUSHINTERVAL,
1992 	DP_PARAM_TOTAL_Q_SIZE,
1993 	DP_PARAM_MIN_THRESHOLD,
1994 	DP_PARAM_MAX_Q_LIMIT,
1995 	DP_PARAM_MIN_Q_LIMIT,
1996 	DP_PARAM_CONG_CTRL_TIMER_INTV,
1997 	DP_PARAM_STATS_TIMER_INTV,
1998 	DP_PARAM_ROTTING_TIMER_INTV,
1999 	DP_PARAM_LATENCY_PROFILE,
2000 	DP_PARAM_HOSTQ_DUMP,
2001 	DP_PARAM_TIDQ_MAP,
2002 	DP_PARAM_VIDEO_STATS_FC,
2003 	DP_PARAM_STATS_FC,
2004 
2005 	DP_PARAM_MAX,
2006 };
2007 #endif
2008 /* Bitmasks for stats that can block */
2009 #define EXT_TXRX_FW_STATS		0x0001
2010 #endif
2011