1 /* 2 * Common stats definitions for clients of dongle 3 * ports 4 * 5 * Copyright (C) 1999-2017, Broadcom Corporation 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 681171 2017-01-25 05:27:08Z $ 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 wifi_connection_state state; /* connection state (valid for STA, CLI only) */ 106 wifi_roam_state roaming; /* roaming state */ 107 uint32 capabilities; /* WIFI_CAPABILITY_XXX (self) */ 108 uint8 ssid[DOT11_MAX_SSID_LEN+1]; /* null terminated SSID */ 109 uint8 bssid[ETHER_ADDR_LEN]; /* bssid */ 110 uint8 ap_country_str[3]; /* country string advertised by AP */ 111 uint8 country_str[3]; /* country string for this association */ 112 } wifi_interface_info; 113 114 typedef wifi_interface_info *wifi_interface_handle; 115 116 /* channel information */ 117 typedef struct { 118 wifi_channel_width_t width; /* channel width (20, 40, 80, 80+80, 160) */ 119 wifi_channel center_freq; /* primary 20 MHz channel */ 120 wifi_channel center_freq0; /* center frequency (MHz) first segment */ 121 wifi_channel center_freq1; /* center frequency (MHz) second segment */ 122 } wifi_channel_info; 123 124 /* wifi rate */ 125 typedef struct { 126 uint32 preamble; /* 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved */ 127 uint32 nss; /* 0:1x1, 1:2x2, 3:3x3, 4:4x4 */ 128 uint32 bw; /* 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz */ 129 uint32 rateMcsIdx; /* OFDM/CCK rate code would be as per ieee std 130 * in the units of 0.5mbps 131 */ 132 /* HT/VHT it would be mcs index */ 133 uint32 reserved; /* reserved */ 134 uint32 bitrate; /* units of 100 Kbps */ 135 } wifi_rate; 136 137 typedef struct { 138 uint32 preamble :3; /* 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved */ 139 uint32 nss :2; /* 0:1x1, 1:2x2, 3:3x3, 4:4x4 */ 140 uint32 bw :3; /* 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz */ 141 uint32 rateMcsIdx :8; /* OFDM/CCK rate code would be as per ieee std 142 * in the units of 0.5mbps HT/VHT it would be 143 * mcs index 144 */ 145 uint32 reserved :16; /* reserved */ 146 uint32 bitrate; /* units of 100 Kbps */ 147 } wifi_rate_v1; 148 149 /* channel statistics */ 150 typedef struct { 151 wifi_channel_info channel; /* channel */ 152 uint32 on_time; /* msecs the radio is awake (32 bits number 153 * accruing over time) 154 */ 155 uint32 cca_busy_time; /* msecs the CCA register is busy (32 bits number 156 * accruing over time) 157 */ 158 } wifi_channel_stat; 159 160 /* radio statistics */ 161 typedef struct { 162 struct { 163 uint16 version; 164 uint16 length; 165 }; 166 wifi_radio radio; /* wifi radio (if multiple radio supported) */ 167 uint32 on_time; /* msecs the radio is awake (32 bits number 168 * accruing over time) 169 */ 170 uint32 tx_time; /* msecs the radio is transmitting (32 bits 171 * number accruing over time) 172 */ 173 uint32 rx_time; /* msecs the radio is in active receive (32 bits 174 * number accruing over time) 175 */ 176 uint32 on_time_scan; /* msecs the radio is awake due to all scan (32 bits 177 * number accruing over time) 178 */ 179 uint32 on_time_nbd; /* msecs the radio is awake due to NAN (32 bits 180 * number accruing over time) 181 */ 182 uint32 on_time_gscan; /* msecs the radio is awake due to G?scan (32 bits 183 * number accruing over time) 184 */ 185 uint32 on_time_roam_scan; /* msecs the radio is awake due to roam?scan (32 bits 186 * number accruing over time) 187 */ 188 uint32 on_time_pno_scan; /* msecs the radio is awake due to PNO scan (32 bits 189 * number accruing over time) 190 */ 191 uint32 on_time_hs20; /* msecs the radio is awake due to HS2.0 scans and 192 * GAS exchange (32 bits number accruing over time) 193 */ 194 uint32 num_channels; /* number of channels */ 195 wifi_channel_stat channels[1]; /* channel statistics */ 196 } wifi_radio_stat; 197 198 typedef struct { 199 wifi_radio radio; 200 uint32 on_time; 201 uint32 tx_time; 202 uint32 rx_time; 203 uint32 on_time_scan; 204 uint32 on_time_nbd; 205 uint32 on_time_gscan; 206 uint32 on_time_roam_scan; 207 uint32 on_time_pno_scan; 208 uint32 on_time_hs20; 209 uint32 num_channels; 210 } wifi_radio_stat_h; 211 212 /* per rate statistics */ 213 typedef struct { 214 wifi_rate_v1 rate; /* rate information */ 215 uint32 tx_mpdu; /* number of successfully transmitted data pkts (ACK rcvd) */ 216 uint32 rx_mpdu; /* number of received data pkts */ 217 uint32 mpdu_lost; /* number of data packet losses (no ACK) */ 218 uint32 retries; /* total number of data pkt retries */ 219 uint32 retries_short; /* number of short data pkt retries */ 220 uint32 retries_long; /* number of long data pkt retries */ 221 } wifi_rate_stat_v1; 222 223 typedef struct { 224 uint16 version; 225 uint16 length; 226 uint32 tx_mpdu; /* number of successfully transmitted data pkts (ACK rcvd) */ 227 uint32 rx_mpdu; /* number of received data pkts */ 228 uint32 mpdu_lost; /* number of data packet losses (no ACK) */ 229 uint32 retries; /* total number of data pkt retries */ 230 uint32 retries_short; /* number of short data pkt retries */ 231 uint32 retries_long; /* number of long data pkt retries */ 232 wifi_rate rate; 233 } wifi_rate_stat; 234 235 /* access categories */ 236 typedef enum { 237 WIFI_AC_VO = 0, 238 WIFI_AC_VI = 1, 239 WIFI_AC_BE = 2, 240 WIFI_AC_BK = 3, 241 WIFI_AC_MAX = 4 242 } wifi_traffic_ac; 243 244 /* wifi peer type */ 245 typedef enum 246 { 247 WIFI_PEER_STA, 248 WIFI_PEER_AP, 249 WIFI_PEER_P2P_GO, 250 WIFI_PEER_P2P_CLIENT, 251 WIFI_PEER_NAN, 252 WIFI_PEER_TDLS, 253 WIFI_PEER_INVALID 254 } wifi_peer_type; 255 256 /* per peer statistics */ 257 typedef struct { 258 wifi_peer_type type; /* peer type (AP, TDLS, GO etc.) */ 259 uint8 peer_mac_address[6]; /* mac address */ 260 uint32 capabilities; /* peer WIFI_CAPABILITY_XXX */ 261 uint32 num_rate; /* number of rates */ 262 wifi_rate_stat rate_stats[1]; /* per rate statistics, number of entries = num_rate */ 263 } wifi_peer_info; 264 265 /* per access category statistics */ 266 typedef struct { 267 wifi_traffic_ac ac; /* access category (VI, VO, BE, BK) */ 268 uint32 tx_mpdu; /* number of successfully transmitted unicast data pkts 269 * (ACK rcvd) 270 */ 271 uint32 rx_mpdu; /* number of received unicast mpdus */ 272 uint32 tx_mcast; /* number of succesfully transmitted multicast 273 * data packets 274 */ 275 /* STA case: implies ACK received from AP for the 276 * unicast packet in which mcast pkt was sent 277 */ 278 uint32 rx_mcast; /* number of received multicast data packets */ 279 uint32 rx_ampdu; /* number of received unicast a-mpdus */ 280 uint32 tx_ampdu; /* number of transmitted unicast a-mpdus */ 281 uint32 mpdu_lost; /* number of data pkt losses (no ACK) */ 282 uint32 retries; /* total number of data pkt retries */ 283 uint32 retries_short; /* number of short data pkt retries */ 284 uint32 retries_long; /* number of long data pkt retries */ 285 uint32 contention_time_min; /* data pkt min contention time (usecs) */ 286 uint32 contention_time_max; /* data pkt max contention time (usecs) */ 287 uint32 contention_time_avg; /* data pkt avg contention time (usecs) */ 288 uint32 contention_num_samples; /* num of data pkts used for contention statistics */ 289 } wifi_wmm_ac_stat; 290 291 /* interface statistics */ 292 typedef struct { 293 wifi_interface_handle iface; /* wifi interface */ 294 wifi_interface_info info; /* current state of the interface */ 295 uint32 beacon_rx; /* access point beacon received count from 296 * connected AP 297 */ 298 uint64 average_tsf_offset; /* average beacon offset encountered (beacon_TSF - TBTT) 299 * The average_tsf_offset field is used so as to calculate 300 * the typical beacon contention time on the channel as well 301 * may be used to debug beacon synchronization and related 302 * power consumption issue 303 */ 304 uint32 leaky_ap_detected; /* indicate that this AP 305 * typically leaks packets beyond 306 * the driver guard time. 307 */ 308 uint32 leaky_ap_avg_num_frames_leaked; /* average number of frame leaked by AP after 309 * frame with PM bit set was ACK'ed by AP 310 */ 311 uint32 leaky_ap_guard_time; /* guard time currently in force 312 * (when implementing IEEE power management 313 * based on frame control PM bit), How long 314 * driver waits before shutting down the radio and after 315 * receiving an ACK for a data frame with PM bit set) 316 */ 317 uint32 mgmt_rx; /* access point mgmt frames received count from 318 * connected AP (including Beacon) 319 */ 320 uint32 mgmt_action_rx; /* action frames received count */ 321 uint32 mgmt_action_tx; /* action frames transmit count */ 322 wifi_rssi rssi_mgmt; /* access Point Beacon and Management frames RSSI 323 * (averaged) 324 */ 325 wifi_rssi rssi_data; /* access Point Data Frames RSSI (averaged) from 326 * connected AP 327 */ 328 wifi_rssi rssi_ack; /* access Point ACK RSSI (averaged) from 329 * connected AP 330 */ 331 wifi_wmm_ac_stat ac[WIFI_AC_MAX]; /* per ac data packet statistics */ 332 uint32 num_peers; /* number of peers */ 333 wifi_peer_info peer_info[1]; /* per peer statistics */ 334 } wifi_iface_stat; 335 336 #ifdef CONFIG_COMPAT 337 /* interface statistics */ 338 typedef struct { 339 compat_uptr_t iface; /* wifi interface */ 340 wifi_interface_info info; /* current state of the interface */ 341 uint32 beacon_rx; /* access point beacon received count from 342 * connected AP 343 */ 344 uint64 average_tsf_offset; /* average beacon offset encountered (beacon_TSF - TBTT) 345 * The average_tsf_offset field is used so as to calculate 346 * the typical beacon contention time on the channel as well 347 * may be used to debug beacon synchronization and related 348 * power consumption issue 349 */ 350 uint32 leaky_ap_detected; /* indicate that this AP 351 * typically leaks packets beyond 352 * the driver guard time. 353 */ 354 uint32 leaky_ap_avg_num_frames_leaked; /* average number of frame leaked by AP after 355 * frame with PM bit set was ACK'ed by AP 356 */ 357 uint32 leaky_ap_guard_time; /* guard time currently in force 358 * (when implementing IEEE power management 359 * based on frame control PM bit), How long 360 * driver waits before shutting down the radio and after 361 * receiving an ACK for a data frame with PM bit set) 362 */ 363 uint32 mgmt_rx; /* access point mgmt frames received count from 364 * connected AP (including Beacon) 365 */ 366 uint32 mgmt_action_rx; /* action frames received count */ 367 uint32 mgmt_action_tx; /* action frames transmit count */ 368 wifi_rssi rssi_mgmt; /* access Point Beacon and Management frames RSSI 369 * (averaged) 370 */ 371 wifi_rssi rssi_data; /* access Point Data Frames RSSI (averaged) from 372 * connected AP 373 */ 374 wifi_rssi rssi_ack; /* access Point ACK RSSI (averaged) from 375 * connected AP 376 */ 377 wifi_wmm_ac_stat ac[WIFI_AC_MAX]; /* per ac data packet statistics */ 378 uint32 num_peers; /* number of peers */ 379 wifi_peer_info peer_info[1]; /* per peer statistics */ 380 } compat_wifi_iface_stat; 381 #endif /* CONFIG_COMPAT */ 382 383 #endif /* _dngl_stats_h_ */ 384