xref: /OK3568_Linux_fs/external/rkwifibt/drivers/infineon/dngl_stats.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Common stats definitions for clients of dongle
3  * ports
4  *
5  * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation
6  *
7  * Copyright (C) 1999-2017, Broadcom Corporation
8  *
9  *      Unless you and Broadcom execute a separate written software license
10  * agreement governing use of this software, this software is licensed to you
11  * under the terms of the GNU General Public License version 2 (the "GPL"),
12  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
13  * following added to such license:
14  *
15  *      As a special exception, the copyright holders of this software give you
16  * permission to link this software with independent modules, and to copy and
17  * distribute the resulting executable under terms of your choice, provided that
18  * you also meet, for each linked independent module, the terms and conditions of
19  * the license of that module.  An independent module is a module which is not
20  * derived from this software.  The special exception does not apply to any
21  * modifications of the software.
22  *
23  *      Notwithstanding the above, under no circumstances may you combine this
24  * software in any way with any other Broadcom software provided under a license
25  * other than the GPL, without Broadcom's express prior written consent.
26  *
27  *
28  * <<Broadcom-WL-IPTag/Open:>>
29  *
30  * $Id: dngl_stats.h 687039 2017-02-27 08:07:06Z $
31  */
32 
33 #ifndef _dngl_stats_h_
34 #define _dngl_stats_h_
35 
36 #include <ethernet.h>
37 #include <802.11.h>
38 
39 typedef struct {
40 	unsigned long	rx_packets;		/* total packets received */
41 	unsigned long	tx_packets;		/* total packets transmitted */
42 	unsigned long	rx_bytes;		/* total bytes received */
43 	unsigned long	tx_bytes;		/* total bytes transmitted */
44 	unsigned long	rx_errors;		/* bad packets received */
45 	unsigned long	tx_errors;		/* packet transmit problems */
46 	unsigned long	rx_dropped;		/* packets dropped by dongle */
47 	unsigned long	tx_dropped;		/* packets dropped by dongle */
48 	unsigned long   multicast;      /* multicast packets received */
49 } dngl_stats_t;
50 
51 typedef int32 wifi_radio;
52 typedef int32 wifi_channel;
53 typedef int32 wifi_rssi;
54 typedef struct { uint16 version; uint16 length; } ver_len;
55 
56 typedef enum wifi_channel_width {
57 	WIFI_CHAN_WIDTH_20	  = 0,
58 	WIFI_CHAN_WIDTH_40	  = 1,
59 	WIFI_CHAN_WIDTH_80	  = 2,
60 	WIFI_CHAN_WIDTH_160   = 3,
61 	WIFI_CHAN_WIDTH_80P80 = 4,
62 	WIFI_CHAN_WIDTH_5	  = 5,
63 	WIFI_CHAN_WIDTH_10	  = 6,
64 	WIFI_CHAN_WIDTH_INVALID = -1
65 } wifi_channel_width_t;
66 
67 typedef enum {
68 	WIFI_DISCONNECTED = 0,
69 	WIFI_AUTHENTICATING = 1,
70 	WIFI_ASSOCIATING = 2,
71 	WIFI_ASSOCIATED = 3,
72 	WIFI_EAPOL_STARTED = 4,   /* if done by firmware/driver */
73 	WIFI_EAPOL_COMPLETED = 5, /* if done by firmware/driver */
74 } wifi_connection_state;
75 
76 typedef enum {
77 	WIFI_ROAMING_IDLE = 0,
78 	WIFI_ROAMING_ACTIVE = 1
79 } wifi_roam_state;
80 
81 typedef enum {
82 	WIFI_INTERFACE_STA = 0,
83 	WIFI_INTERFACE_SOFTAP = 1,
84 	WIFI_INTERFACE_IBSS = 2,
85 	WIFI_INTERFACE_P2P_CLIENT = 3,
86 	WIFI_INTERFACE_P2P_GO = 4,
87 	WIFI_INTERFACE_NAN = 5,
88 	WIFI_INTERFACE_MESH = 6
89 } wifi_interface_mode;
90 
91 #define WIFI_CAPABILITY_QOS          0x00000001     /* set for QOS association */
92 #define WIFI_CAPABILITY_PROTECTED    0x00000002     /* set for protected association (802.11
93 						     * beacon frame control protected bit set)
94 						     */
95 #define WIFI_CAPABILITY_INTERWORKING 0x00000004     /* set if 802.11 Extended Capabilities
96 						     * element interworking bit is set
97 						     */
98 #define WIFI_CAPABILITY_HS20         0x00000008     /* set for HS20 association */
99 #define WIFI_CAPABILITY_SSID_UTF8    0x00000010     /* set is 802.11 Extended Capabilities
100 						     * element UTF-8 SSID bit is set
101 						     */
102 #define WIFI_CAPABILITY_COUNTRY      0x00000020     /* set is 802.11 Country Element is present */
103 #define PACK_ATTRIBUTE __attribute__ ((packed))
104 typedef struct {
105 	wifi_interface_mode mode;     /* interface mode */
106 	uint8 mac_addr[6];               /* interface mac address (self) */
107 	uint8 PAD[2];
108 	wifi_connection_state state;  /* connection state (valid for STA, CLI only) */
109 	wifi_roam_state roaming;      /* roaming state */
110 	uint32 capabilities;             /* WIFI_CAPABILITY_XXX (self) */
111 	uint8 ssid[DOT11_MAX_SSID_LEN+1]; /* null terminated SSID */
112 	uint8 bssid[ETHER_ADDR_LEN];     /* bssid */
113 	uint8 PAD[1];
114 	uint8 ap_country_str[3];         /* country string advertised by AP */
115 	uint8 country_str[3];            /* country string for this association */
116 	uint8 PAD[2];
117 } wifi_interface_info;
118 
119 typedef wifi_interface_info *wifi_interface_handle;
120 
121 /* channel information */
122 typedef struct {
123 	wifi_channel_width_t width;   /* channel width (20, 40, 80, 80+80, 160) */
124 	wifi_channel center_freq;   /* primary 20 MHz channel */
125 	wifi_channel center_freq0;  /* center frequency (MHz) first segment */
126 	wifi_channel center_freq1;  /* center frequency (MHz) second segment */
127 } wifi_channel_info;
128 
129 /* wifi rate */
130 typedef struct {
131 	uint32 preamble;   /* 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved */
132 	uint32 nss;   	/* 0:1x1, 1:2x2, 3:3x3, 4:4x4 */
133 	uint32 bw;   	/* 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz */
134 	uint32 rateMcsIdx; /* OFDM/CCK rate code would be as per ieee std
135 			    * in the units of 0.5mbps
136 			    */
137 			/* HT/VHT it would be mcs index */
138 	uint32 reserved;   /* reserved */
139 	uint32 bitrate;    /* units of 100 Kbps */
140 } wifi_rate;
141 
142 typedef struct {
143 	uint32 preamble   :3;   /* 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved */
144 	uint32 nss        :2;   /* 0:1x1, 1:2x2, 3:3x3, 4:4x4 */
145 	uint32 bw         :3;   /* 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz */
146 	uint32 rateMcsIdx :8;   /* OFDM/CCK rate code would be as per ieee std
147 					* in the units of 0.5mbps HT/VHT it would be
148 					* mcs index
149 					*/
150 	uint32 reserved  :16;   /* reserved */
151 	uint32 bitrate;         /* units of 100 Kbps */
152 } wifi_rate_v1;
153 
154 /* channel statistics */
155 typedef struct {
156 	wifi_channel_info channel;  /* channel */
157 	uint32 on_time;			/* msecs the radio is awake (32 bits number
158 				         * accruing over time)
159 					 */
160 	uint32 cca_busy_time;          /* msecs the CCA register is busy (32 bits number
161 					* accruing over time)
162 					*/
163 } wifi_channel_stat;
164 
165 /* radio statistics */
166 typedef struct {
167 	struct {
168 		uint16 version;
169 		uint16 length;
170 	};
171 	wifi_radio radio;               /* wifi radio (if multiple radio supported) */
172 	uint32 on_time;                    /* msecs the radio is awake (32 bits number
173 					    * accruing over time)
174 					    */
175 	uint32 tx_time;                    /* msecs the radio is transmitting (32 bits
176 					    * number accruing over time)
177 					    */
178 	uint32 rx_time;                    /* msecs the radio is in active receive (32 bits
179 					    * number accruing over time)
180 					    */
181 	uint32 on_time_scan;               /* msecs the radio is awake due to all scan (32 bits
182 					    * number accruing over time)
183 					    */
184 	uint32 on_time_nbd;                /* msecs the radio is awake due to NAN (32 bits
185 					    * number accruing over time)
186 					    */
187 	uint32 on_time_gscan;              /* msecs the radio is awake due to G?scan (32 bits
188 					    * number accruing over time)
189 					    */
190 	uint32 on_time_roam_scan;          /* msecs the radio is awake due to roam?scan (32 bits
191 					    * number accruing over time)
192 					    */
193 	uint32 on_time_pno_scan;           /* msecs the radio is awake due to PNO scan (32 bits
194 					    * number accruing over time)
195 					    */
196 	uint32 on_time_hs20;               /* msecs the radio is awake due to HS2.0 scans and
197 					    * GAS exchange (32 bits number accruing over time)
198 					    */
199 	uint32 num_channels;               /* number of channels */
200 	wifi_channel_stat channels[1];   /* channel statistics */
201 } wifi_radio_stat;
202 
203 typedef struct {
204 	wifi_radio radio;
205 	uint32 on_time;
206 	uint32 tx_time;
207 	uint32 rx_time;
208 	uint32 on_time_scan;
209 	uint32 on_time_nbd;
210 	uint32 on_time_gscan;
211 	uint32 on_time_roam_scan;
212 	uint32 on_time_pno_scan;
213 	uint32 on_time_hs20;
214 	uint32 num_channels;
215 } wifi_radio_stat_h;
216 
217 /* per rate statistics */
218 typedef struct {
219 	wifi_rate_v1 rate;     /* rate information */
220 	uint32 tx_mpdu;        /* number of successfully transmitted data pkts (ACK rcvd) */
221 	uint32 rx_mpdu;        /* number of received data pkts */
222 	uint32 mpdu_lost;      /* number of data packet losses (no ACK) */
223 	uint32 retries;        /* total number of data pkt retries */
224 	uint32 retries_short;  /* number of short data pkt retries */
225 	uint32 retries_long;   /* number of long data pkt retries */
226 } wifi_rate_stat_v1;
227 
228 typedef struct {
229 	uint16 version;
230 	uint16 length;
231 	uint32 tx_mpdu;        /* number of successfully transmitted data pkts (ACK rcvd) */
232 	uint32 rx_mpdu;        /* number of received data pkts */
233 	uint32 mpdu_lost;      /* number of data packet losses (no ACK) */
234 	uint32 retries;        /* total number of data pkt retries */
235 	uint32 retries_short;  /* number of short data pkt retries */
236 	uint32 retries_long;   /* number of long data pkt retries */
237 	wifi_rate rate;
238 } wifi_rate_stat;
239 
240 /* access categories */
241 typedef enum {
242 	WIFI_AC_VO  = 0,
243 	WIFI_AC_VI  = 1,
244 	WIFI_AC_BE  = 2,
245 	WIFI_AC_BK  = 3,
246 	WIFI_AC_MAX = 4
247 } wifi_traffic_ac;
248 
249 /* wifi peer type */
250 typedef enum
251 {
252 	WIFI_PEER_STA,
253 	WIFI_PEER_AP,
254 	WIFI_PEER_P2P_GO,
255 	WIFI_PEER_P2P_CLIENT,
256 	WIFI_PEER_NAN,
257 	WIFI_PEER_TDLS,
258 	WIFI_PEER_INVALID
259 } wifi_peer_type;
260 
261 /* per peer statistics */
262 typedef struct {
263 	wifi_peer_type type;           /* peer type (AP, TDLS, GO etc.) */
264 	uint8 peer_mac_address[6];        /* mac address */
265 	uint32 capabilities;              /* peer WIFI_CAPABILITY_XXX */
266 	uint32 num_rate;                  /* number of rates */
267 	wifi_rate_stat rate_stats[1];   /* per rate statistics, number of entries  = num_rate */
268 } wifi_peer_info;
269 
270 /* per access category statistics */
271 typedef struct {
272 	wifi_traffic_ac ac;             /* access category (VI, VO, BE, BK) */
273 	uint32 tx_mpdu;                    /* number of successfully transmitted unicast data pkts
274 					    * (ACK rcvd)
275 					    */
276 	uint32 rx_mpdu;                    /* number of received unicast mpdus */
277 	uint32 tx_mcast;                   /* number of succesfully transmitted multicast
278 					    * data packets
279 					    */
280 					   /* STA case: implies ACK received from AP for the
281 					    * unicast packet in which mcast pkt was sent
282 					    */
283 	uint32 rx_mcast;                   /* number of received multicast data packets */
284 	uint32 rx_ampdu;                   /* number of received unicast a-mpdus */
285 	uint32 tx_ampdu;                   /* number of transmitted unicast a-mpdus */
286 	uint32 mpdu_lost;                  /* number of data pkt losses (no ACK) */
287 	uint32 retries;                    /* total number of data pkt retries */
288 	uint32 retries_short;              /* number of short data pkt retries */
289 	uint32 retries_long;               /* number of long data pkt retries */
290 	uint32 contention_time_min;        /* data pkt min contention time (usecs) */
291 	uint32 contention_time_max;        /* data pkt max contention time (usecs) */
292 	uint32 contention_time_avg;        /* data pkt avg contention time (usecs) */
293 	uint32 contention_num_samples;     /* num of data pkts used for contention statistics */
294 } wifi_wmm_ac_stat;
295 
296 /* interface statistics */
297 typedef struct {
298 	wifi_interface_handle iface;          /* wifi interface */
299 	wifi_interface_info info;             /* current state of the interface */
300 	uint32 beacon_rx;                     /* access point beacon received count from
301 					       * connected AP
302 					       */
303 	uint64 average_tsf_offset;	/* average beacon offset encountered (beacon_TSF - TBTT)
304 					* The average_tsf_offset field is used so as to calculate
305 					* the typical beacon contention time on the channel as well
306 					* may be used to debug beacon synchronization and related
307 					* power consumption issue
308 					*/
309 	uint32 leaky_ap_detected;	/* indicate that this AP
310 					* typically leaks packets beyond
311 					* the driver guard time.
312 					*/
313 	uint32 leaky_ap_avg_num_frames_leaked;	/* average number of frame leaked by AP after
314 					* frame with PM bit set was ACK'ed by AP
315 					*/
316 	uint32 leaky_ap_guard_time;		/* guard time currently in force
317 					* (when implementing IEEE power management
318 					* based on frame control PM bit), How long
319 					* driver waits before shutting down the radio and after
320 					* receiving an ACK for a data frame with PM bit set)
321 					*/
322 	uint32 mgmt_rx;                       /* access point mgmt frames received count from
323 				       * connected AP (including Beacon)
324 				       */
325 	uint32 mgmt_action_rx;                /* action frames received count */
326 	uint32 mgmt_action_tx;                /* action frames transmit count */
327 	wifi_rssi rssi_mgmt;                  /* access Point Beacon and Management frames RSSI
328 					       * (averaged)
329 					       */
330 	wifi_rssi rssi_data;                  /* access Point Data Frames RSSI (averaged) from
331 					       * connected AP
332 					       */
333 	wifi_rssi rssi_ack;                   /* access Point ACK RSSI (averaged) from
334 					       * connected AP
335 					       */
336 	wifi_wmm_ac_stat ac[WIFI_AC_MAX];     /* per ac data packet statistics */
337 	uint32 num_peers;                        /* number of peers */
338 	wifi_peer_info peer_info[1];           /* per peer statistics */
339 } wifi_iface_stat;
340 
341 #endif /* _dngl_stats_h_ */
342