1 /* 2 * Common stats definitions for clients of dongle 3 * ports 4 * 5 * Copyright (C) 2020, Broadcom. 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 * 22 * <<Broadcom-WL-IPTag/Open:>> 23 * 24 * $Id$ 25 */ 26 27 #ifndef _dngl_stats_h_ 28 #define _dngl_stats_h_ 29 30 #include <ethernet.h> 31 #include <802.11.h> 32 #include <linux/compat.h> 33 34 /* XXX happens to mirror a section of linux's net_device_stats struct */ 35 typedef struct { 36 unsigned long rx_packets; /* total packets received */ 37 unsigned long tx_packets; /* total packets transmitted */ 38 unsigned long rx_bytes; /* total bytes received */ 39 unsigned long tx_bytes; /* total bytes transmitted */ 40 unsigned long rx_errors; /* bad packets received */ 41 unsigned long tx_errors; /* packet transmit problems */ 42 unsigned long rx_dropped; /* packets dropped by dongle */ 43 unsigned long tx_dropped; /* packets dropped by dongle */ 44 unsigned long multicast; /* multicast packets received */ 45 } dngl_stats_t; 46 47 typedef int32 wifi_radio; 48 typedef int32 wifi_channel; 49 typedef int32 wifi_rssi; 50 typedef struct { uint16 version; uint16 length; } ver_len; 51 52 typedef enum wifi_channel_width { 53 WIFI_CHAN_WIDTH_20 = 0, 54 WIFI_CHAN_WIDTH_40 = 1, 55 WIFI_CHAN_WIDTH_80 = 2, 56 WIFI_CHAN_WIDTH_160 = 3, 57 WIFI_CHAN_WIDTH_80P80 = 4, 58 WIFI_CHAN_WIDTH_5 = 5, 59 WIFI_CHAN_WIDTH_10 = 6, 60 WIFI_CHAN_WIDTH_INVALID = -1 61 } wifi_channel_width_t; 62 63 typedef enum { 64 WIFI_DISCONNECTED = 0, 65 WIFI_AUTHENTICATING = 1, 66 WIFI_ASSOCIATING = 2, 67 WIFI_ASSOCIATED = 3, 68 WIFI_EAPOL_STARTED = 4, /* if done by firmware/driver */ 69 WIFI_EAPOL_COMPLETED = 5, /* if done by firmware/driver */ 70 } wifi_connection_state; 71 72 typedef enum { 73 WIFI_ROAMING_IDLE = 0, 74 WIFI_ROAMING_ACTIVE = 1 75 } wifi_roam_state; 76 77 typedef enum { 78 WIFI_INTERFACE_STA = 0, 79 WIFI_INTERFACE_SOFTAP = 1, 80 WIFI_INTERFACE_IBSS = 2, 81 WIFI_INTERFACE_P2P_CLIENT = 3, 82 WIFI_INTERFACE_P2P_GO = 4, 83 WIFI_INTERFACE_NAN = 5, 84 WIFI_INTERFACE_MESH = 6 85 } wifi_interface_mode; 86 87 #define WIFI_CAPABILITY_QOS 0x00000001 /* set for QOS association */ 88 #define WIFI_CAPABILITY_PROTECTED 0x00000002 /* set for protected association (802.11 89 * beacon frame control protected bit set) 90 */ 91 #define WIFI_CAPABILITY_INTERWORKING 0x00000004 /* set if 802.11 Extended Capabilities 92 * element interworking bit is set 93 */ 94 #define WIFI_CAPABILITY_HS20 0x00000008 /* set for HS20 association */ 95 #define WIFI_CAPABILITY_SSID_UTF8 0x00000010 /* set is 802.11 Extended Capabilities 96 * element UTF-8 SSID bit is set 97 */ 98 #define WIFI_CAPABILITY_COUNTRY 0x00000020 /* set is 802.11 Country Element is present */ 99 #ifdef LINUX 100 #define PACK_ATTRIBUTE __attribute__ ((packed)) 101 #else 102 #define PACK_ATTRIBUTE 103 #endif 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 #ifdef CONFIG_COMPAT 342 /* interface statistics */ 343 typedef struct { 344 compat_uptr_t iface; /* wifi interface */ 345 wifi_interface_info info; /* current state of the interface */ 346 uint32 beacon_rx; /* access point beacon received count from 347 * connected AP 348 */ 349 uint64 average_tsf_offset; /* average beacon offset encountered (beacon_TSF - TBTT) 350 * The average_tsf_offset field is used so as to calculate 351 * the typical beacon contention time on the channel as well 352 * may be used to debug beacon synchronization and related 353 * power consumption issue 354 */ 355 uint32 leaky_ap_detected; /* indicate that this AP 356 * typically leaks packets beyond 357 * the driver guard time. 358 */ 359 uint32 leaky_ap_avg_num_frames_leaked; /* average number of frame leaked by AP after 360 * frame with PM bit set was ACK'ed by AP 361 */ 362 uint32 leaky_ap_guard_time; /* guard time currently in force 363 * (when implementing IEEE power management 364 * based on frame control PM bit), How long 365 * driver waits before shutting down the radio and after 366 * receiving an ACK for a data frame with PM bit set) 367 */ 368 uint32 mgmt_rx; /* access point mgmt frames received count from 369 * connected AP (including Beacon) 370 */ 371 uint32 mgmt_action_rx; /* action frames received count */ 372 uint32 mgmt_action_tx; /* action frames transmit count */ 373 wifi_rssi rssi_mgmt; /* access Point Beacon and Management frames RSSI 374 * (averaged) 375 */ 376 wifi_rssi rssi_data; /* access Point Data Frames RSSI (averaged) from 377 * connected AP 378 */ 379 wifi_rssi rssi_ack; /* access Point ACK RSSI (averaged) from 380 * connected AP 381 */ 382 wifi_wmm_ac_stat ac[WIFI_AC_MAX]; /* per ac data packet statistics */ 383 uint32 num_peers; /* number of peers */ 384 wifi_peer_info peer_info[1]; /* per peer statistics */ 385 } compat_wifi_iface_stat; 386 #endif /* CONFIG_COMPAT */ 387 388 #endif /* _dngl_stats_h_ */ 389