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