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