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