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