1 #include "wifi_hal.h"
\r
3 #ifndef __WIFI_HAL_STATS_H
\r
4 #define __WIFI_HAL_STATS_H
\r
9 #endif /* __cplusplus */
\r
11 #define STATS_MAJOR_VERSION 1
\r
12 #define STATS_MINOR_VERSION 0
\r
13 #define STATS_MICRO_VERSION 0
\r
15 typedef int wifi_radio;
\r
16 typedef int wifi_channel;
\r
18 /* channel operating width */
\r
20 WIFI_CHAN_WIDTH_20 = 0,
\r
21 WIFI_CHAN_WIDTH_40 = 1,
\r
22 WIFI_CHAN_WIDTH_80 = 2,
\r
23 WIFI_CHAN_WIDTH_160 = 3,
\r
24 WIFI_CHAN_WIDTH_80P80 = 4,
\r
25 WIFI_CHAN_WIDTH_5 = 5,
\r
26 WIFI_CHAN_WIDTH_10 = 6,
\r
27 WIFI_CHAN_WIDTH_INVALID = -1
\r
28 } wifi_channel_width;
\r
31 WIFI_DISCONNECTED = 0,
\r
32 WIFI_AUTHENTICATING = 1,
\r
33 WIFI_ASSOCIATING = 2,
\r
34 WIFI_ASSOCIATED = 3,
\r
35 WIFI_EAPOL_STARTED = 4, // if done by firmware/driver
\r
36 WIFI_EAPOL_COMPLETED = 5, // if done by firmware/driver
\r
37 } wifi_connection_state;
\r
40 WIFI_ROAMING_IDLE = 0,
\r
41 WIFI_ROAMING_ACTIVE = 1,
\r
45 WIFI_INTERFACE_STA = 0,
\r
46 WIFI_INTERFACE_SOFTAP = 1,
\r
47 WIFI_INTERFACE_IBSS = 2,
\r
48 WIFI_INTERFACE_P2P_CLIENT = 3,
\r
49 WIFI_INTERFACE_P2P_GO = 4,
\r
50 WIFI_INTERFACE_NAN = 5,
\r
51 WIFI_INTERFACE_MESH = 6,
\r
52 WIFI_INTERFACE_UNKNOWN = -1
\r
53 } wifi_interface_mode;
\r
55 #define WIFI_CAPABILITY_QOS 0x00000001 // set for QOS association
\r
56 #define WIFI_CAPABILITY_PROTECTED 0x00000002 // set for protected association (802.11 beacon frame control protected bit set)
\r
57 #define WIFI_CAPABILITY_INTERWORKING 0x00000004 // set if 802.11 Extended Capabilities element interworking bit is set
\r
58 #define WIFI_CAPABILITY_HS20 0x00000008 // set for HS20 association
\r
59 #define WIFI_CAPABILITY_SSID_UTF8 0x00000010 // set is 802.11 Extended Capabilities element UTF-8 SSID bit is set
\r
60 #define WIFI_CAPABILITY_COUNTRY 0x00000020 // set is 802.11 Country Element is present
\r
63 wifi_interface_mode mode; // interface mode
\r
64 u8 mac_addr[6]; // interface mac address (self)
\r
65 wifi_connection_state state; // connection state (valid for STA, CLI only)
\r
66 wifi_roam_state roaming; // roaming state
\r
67 u32 capabilities; // WIFI_CAPABILITY_XXX (self)
\r
68 u8 ssid[33]; // null terminated SSID
\r
69 u8 bssid[6]; // bssid
\r
70 u8 ap_country_str[3]; // country string advertised by AP
\r
71 u8 country_str[3]; // country string for this association
\r
72 } wifi_interface_link_layer_info;
\r
74 /* channel information */
\r
76 wifi_channel_width width; // channel width (20, 40, 80, 80+80, 160)
\r
77 wifi_channel center_freq; // primary 20 MHz channel
\r
78 wifi_channel center_freq0; // center frequency (MHz) first segment
\r
79 wifi_channel center_freq1; // center frequency (MHz) second segment
\r
80 } wifi_channel_info;
\r
84 u32 preamble :3; // 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved
\r
85 u32 nss :2; // 0:1x1, 1:2x2, 3:3x3, 4:4x4
\r
86 u32 bw :3; // 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz
\r
87 u32 rateMcsIdx :8; // OFDM/CCK rate code would be as per ieee std in the units of 0.5mbps
\r
88 // HT/VHT it would be mcs index
\r
89 u32 reserved :16; // reserved
\r
90 u32 bitrate; // units of 100 Kbps
\r
93 /* channel statistics */
\r
95 wifi_channel_info channel; // channel
\r
96 u32 on_time; // msecs the radio is awake (32 bits number accruing over time)
\r
97 u32 cca_busy_time; // msecs the CCA register is busy (32 bits number accruing over time)
\r
98 } wifi_channel_stat;
\r
100 /* radio statistics */
\r
102 wifi_radio radio; // wifi radio (if multiple radio supported)
\r
103 u32 on_time; // msecs the radio is awake (32 bits number accruing over time)
\r
104 u32 tx_time; // msecs the radio is transmitting (32 bits number accruing over time)
\r
105 u32 rx_time; // msecs the radio is in active receive (32 bits number accruing over time)
\r
106 u32 on_time_scan; // msecs the radio is awake due to all scan (32 bits number accruing over time)
\r
107 u32 on_time_nbd; // msecs the radio is awake due to NAN (32 bits number accruing over time)
\r
108 u32 on_time_gscan; // msecs the radio is awake due to G?scan (32 bits number accruing over time)
\r
109 u32 on_time_roam_scan; // msecs the radio is awake due to roam?scan (32 bits number accruing over time)
\r
110 u32 on_time_pno_scan; // msecs the radio is awake due to PNO scan (32 bits number accruing over time)
\r
111 u32 on_time_hs20; // msecs the radio is awake due to HS2.0 scans and GAS exchange (32 bits number accruing over time)
\r
112 u32 num_channels; // number of channels
\r
113 wifi_channel_stat channels[]; // channel statistics
\r
117 * Packet statistics reporting by firmware is performed on MPDU basi (i.e. counters increase by 1 for each MPDU)
\r
118 * As well, "data packet" in associated comments, shall be interpreted as 802.11 data packet,
\r
119 * that is, 802.11 frame control subtype == 2 and excluding management and control frames.
\r
121 * As an example, in the case of transmission of an MSDU fragmented in 16 MPDUs which are transmitted
\r
122 * OTA in a 16 units long a-mpdu, for which a block ack is received with 5 bits set:
\r
123 * tx_mpdu : shall increase by 5
\r
124 * retries : shall increase by 16
\r
125 * tx_ampdu : shall increase by 1
\r
126 * data packet counters shall not increase regardless of the number of BAR potentially sent by device for this a-mpdu
\r
127 * data packet counters shall not increase regardless of the number of BA received by device for this a-mpdu
\r
129 * For each subsequent retransmission of the 11 remaining non ACK'ed mpdus
\r
130 * (regardless of the fact that they are transmitted in a-mpdu or not)
\r
131 * retries : shall increase by 1
\r
133 * If no subsequent BA or ACK are received from AP, until packet lifetime expires for those 11 packet that were not ACK'ed
\r
134 * mpdu_lost : shall increase by 11
\r
137 /* per rate statistics */
\r
139 wifi_rate rate; // rate information
\r
140 u32 tx_mpdu; // number of successfully transmitted data pkts (ACK rcvd)
\r
141 u32 rx_mpdu; // number of received data pkts
\r
142 u32 mpdu_lost; // number of data packet losses (no ACK)
\r
143 u32 retries; // total number of data pkt retries
\r
144 u32 retries_short; // number of short data pkt retries
\r
145 u32 retries_long; // number of long data pkt retries
\r
148 /* access categories */
\r
157 /* wifi peer type */
\r
163 WIFI_PEER_P2P_CLIENT,
\r
169 /* per peer statistics */
\r
171 wifi_peer_type type; // peer type (AP, TDLS, GO etc.)
\r
172 u8 peer_mac_address[6]; // mac address
\r
173 u32 capabilities; // peer WIFI_CAPABILITY_XXX
\r
174 u32 num_rate; // number of rates
\r
175 wifi_rate_stat rate_stats[]; // per rate statistics, number of entries = num_rate
\r
178 /* Per access category statistics */
\r
180 wifi_traffic_ac ac; // access category (VI, VO, BE, BK)
\r
181 u32 tx_mpdu; // number of successfully transmitted unicast data pkts (ACK rcvd)
\r
182 u32 rx_mpdu; // number of received unicast data packets
\r
183 u32 tx_mcast; // number of succesfully transmitted multicast data packets
\r
184 // STA case: implies ACK received from AP for the unicast packet in which mcast pkt was sent
\r
185 u32 rx_mcast; // number of received multicast data packets
\r
186 u32 rx_ampdu; // number of received unicast a-mpdus; support of this counter is optional
\r
187 u32 tx_ampdu; // number of transmitted unicast a-mpdus; support of this counter is optional
\r
188 u32 mpdu_lost; // number of data pkt losses (no ACK)
\r
189 u32 retries; // total number of data pkt retries
\r
190 u32 retries_short; // number of short data pkt retries
\r
191 u32 retries_long; // number of long data pkt retries
\r
192 u32 contention_time_min; // data pkt min contention time (usecs)
\r
193 u32 contention_time_max; // data pkt max contention time (usecs)
\r
194 u32 contention_time_avg; // data pkt avg contention time (usecs)
\r
195 u32 contention_num_samples; // num of data pkts used for contention statistics
\r
196 } wifi_wmm_ac_stat;
\r
198 /* interface statistics */
\r
200 wifi_interface_handle iface; // wifi interface
\r
201 wifi_interface_link_layer_info info; // current state of the interface
\r
202 u32 beacon_rx; // access point beacon received count from connected AP
\r
203 u64 average_tsf_offset; // average beacon offset encountered (beacon_TSF - TBTT)
\r
204 // The average_tsf_offset field is used so as to calculate the
\r
205 // typical beacon contention time on the channel as well may be
\r
206 // used to debug beacon synchronization and related power consumption issue
\r
207 u32 leaky_ap_detected; // indicate that this AP typically leaks packets beyond the driver guard time.
\r
208 u32 leaky_ap_avg_num_frames_leaked; // average number of frame leaked by AP after frame with PM bit set was ACK'ed by AP
\r
209 u32 leaky_ap_guard_time; // guard time currently in force (when implementing IEEE power management based on
\r
210 // frame control PM bit), How long driver waits before shutting down the radio and
\r
211 // after receiving an ACK for a data frame with PM bit set)
\r
212 u32 mgmt_rx; // access point mgmt frames received count from connected AP (including Beacon)
\r
213 u32 mgmt_action_rx; // action frames received count
\r
214 u32 mgmt_action_tx; // action frames transmit count
\r
215 wifi_rssi rssi_mgmt; // access Point Beacon and Management frames RSSI (averaged)
\r
216 wifi_rssi rssi_data; // access Point Data Frames RSSI (averaged) from connected AP
\r
217 wifi_rssi rssi_ack; // access Point ACK RSSI (averaged) from connected AP
\r
218 wifi_wmm_ac_stat ac[WIFI_AC_MAX]; // per ac data packet statistics
\r
219 u32 num_peers; // number of peers
\r
220 wifi_peer_info peer_info[]; // per peer statistics
\r
223 /* configuration params */
\r
225 u32 mpdu_size_threshold; // threshold to classify the pkts as short or long
\r
226 // packet size < mpdu_size_threshold => short
\r
227 u32 aggressive_statistics_gathering; // set for field debug mode. Driver should collect all statistics regardless of performance impact.
\r
228 } wifi_link_layer_params;
\r
230 /* API to trigger the link layer statistics collection.
\r
231 Unless his API is invoked - link layer statistics will not be collected.
\r
232 Radio statistics (once started) do not stop or get reset unless wifi_clear_link_stats is invoked
\r
233 Interface statistics (once started) reset and start afresh after each connection */
\r
234 wifi_error wifi_set_link_stats(wifi_interface_handle iface, wifi_link_layer_params params);
\r
236 /* callback for reporting link layer stats */
\r
238 void (*on_link_stats_results) (wifi_request_id id, wifi_iface_stat *iface_stat,
\r
239 int num_radios, wifi_radio_stat *radio_stat);
\r
240 } wifi_stats_result_handler;
\r
242 /* api to collect the link layer statistics for a given iface and all the radio stats */
\r
243 wifi_error wifi_get_link_stats(wifi_request_id id,
\r
244 wifi_interface_handle iface, wifi_stats_result_handler handler);
\r
246 /* wifi statistics bitmap */
\r
247 #define WIFI_STATS_RADIO 0x00000001 // all radio statistics
\r
248 #define WIFI_STATS_RADIO_CCA 0x00000002 // cca_busy_time (within radio statistics)
\r
249 #define WIFI_STATS_RADIO_CHANNELS 0x00000004 // all channel statistics (within radio statistics)
\r
250 #define WIFI_STATS_RADIO_SCAN 0x00000008 // all scan statistics (within radio statistics)
\r
251 #define WIFI_STATS_IFACE 0x00000010 // all interface statistics
\r
252 #define WIFI_STATS_IFACE_TXRATE 0x00000020 // all tx rate statistics (within interface statistics)
\r
253 #define WIFI_STATS_IFACE_AC 0x00000040 // all ac statistics (within interface statistics)
\r
254 #define WIFI_STATS_IFACE_CONTENTION 0x00000080 // all contention (min, max, avg) statistics (within ac statisctics)
\r
256 /* clear api to reset statistics, stats_clear_rsp_mask identifies what stats have been cleared
\r
257 stop_req = 1 will imply whether to stop the statistics collection.
\r
258 stop_rsp = 1 will imply that stop_req was honored and statistics collection was stopped.
\r
260 wifi_error wifi_clear_link_stats(wifi_interface_handle iface,
\r
261 u32 stats_clear_req_mask, u32 *stats_clear_rsp_mask, u8 stop_req, u8 *stop_rsp);
\r
265 #endif /* __cplusplus */
\r
267 #endif /*__WIFI_HAL_STATS_ */
\r