dngl_stats.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /*
  2. * Common stats definitions for clients of dongle
  3. * ports
  4. *
  5. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  6. *
  7. * Copyright (C) 1999-2020, Broadcom Corporation
  8. *
  9. * Unless you and Broadcom execute a separate written software license
  10. * agreement governing use of this software, this software is licensed to you
  11. * under the terms of the GNU General Public License version 2 (the "GPL"),
  12. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  13. * following added to such license:
  14. *
  15. * As a special exception, the copyright holders of this software give you
  16. * permission to link this software with independent modules, and to copy and
  17. * distribute the resulting executable under terms of your choice, provided that
  18. * you also meet, for each linked independent module, the terms and conditions of
  19. * the license of that module. An independent module is a module which is not
  20. * derived from this software. The special exception does not apply to any
  21. * modifications of the software.
  22. *
  23. * Notwithstanding the above, under no circumstances may you combine this
  24. * software in any way with any other Broadcom software provided under a license
  25. * other than the GPL, without Broadcom's express prior written consent.
  26. *
  27. *
  28. * <<Broadcom-WL-IPTag/Open:>>
  29. *
  30. * $Id: dngl_stats.h 687039 2017-02-27 08:07:06Z $
  31. */
  32. #ifndef _dngl_stats_h_
  33. #define _dngl_stats_h_
  34. #include <ethernet.h>
  35. #include <802.11.h>
  36. typedef struct {
  37. unsigned long rx_packets; /* total packets received */
  38. unsigned long tx_packets; /* total packets transmitted */
  39. unsigned long rx_bytes; /* total bytes received */
  40. unsigned long tx_bytes; /* total bytes transmitted */
  41. unsigned long rx_errors; /* bad packets received */
  42. unsigned long tx_errors; /* packet transmit problems */
  43. unsigned long rx_dropped; /* packets dropped by dongle */
  44. unsigned long tx_dropped; /* packets dropped by dongle */
  45. unsigned long multicast; /* multicast packets received */
  46. } dngl_stats_t;
  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. typedef enum wifi_channel_width {
  52. WIFI_CHAN_WIDTH_20 = 0,
  53. WIFI_CHAN_WIDTH_40 = 1,
  54. WIFI_CHAN_WIDTH_80 = 2,
  55. WIFI_CHAN_WIDTH_160 = 3,
  56. WIFI_CHAN_WIDTH_80P80 = 4,
  57. WIFI_CHAN_WIDTH_5 = 5,
  58. WIFI_CHAN_WIDTH_10 = 6,
  59. WIFI_CHAN_WIDTH_INVALID = -1
  60. } wifi_channel_width_t;
  61. typedef enum {
  62. WIFI_DISCONNECTED = 0,
  63. WIFI_AUTHENTICATING = 1,
  64. WIFI_ASSOCIATING = 2,
  65. WIFI_ASSOCIATED = 3,
  66. WIFI_EAPOL_STARTED = 4, /* if done by firmware/driver */
  67. WIFI_EAPOL_COMPLETED = 5, /* if done by firmware/driver */
  68. } wifi_connection_state;
  69. typedef enum {
  70. WIFI_ROAMING_IDLE = 0,
  71. WIFI_ROAMING_ACTIVE = 1
  72. } wifi_roam_state;
  73. typedef enum {
  74. WIFI_INTERFACE_STA = 0,
  75. WIFI_INTERFACE_SOFTAP = 1,
  76. WIFI_INTERFACE_IBSS = 2,
  77. WIFI_INTERFACE_P2P_CLIENT = 3,
  78. WIFI_INTERFACE_P2P_GO = 4,
  79. WIFI_INTERFACE_NAN = 5,
  80. WIFI_INTERFACE_MESH = 6
  81. } wifi_interface_mode;
  82. #define WIFI_CAPABILITY_QOS 0x00000001 /* set for QOS association */
  83. #define WIFI_CAPABILITY_PROTECTED 0x00000002 /* set for protected association (802.11
  84. * beacon frame control protected bit set)
  85. */
  86. #define WIFI_CAPABILITY_INTERWORKING 0x00000004 /* set if 802.11 Extended Capabilities
  87. * element interworking bit is set
  88. */
  89. #define WIFI_CAPABILITY_HS20 0x00000008 /* set for HS20 association */
  90. #define WIFI_CAPABILITY_SSID_UTF8 0x00000010 /* set is 802.11 Extended Capabilities
  91. * element UTF-8 SSID bit is set
  92. */
  93. #define WIFI_CAPABILITY_COUNTRY 0x00000020 /* set is 802.11 Country Element is present */
  94. #define PACK_ATTRIBUTE __attribute__ ((packed))
  95. typedef struct {
  96. wifi_interface_mode mode; /* interface mode */
  97. uint8 mac_addr[6]; /* interface mac address (self) */
  98. uint8 PAD[2];
  99. wifi_connection_state state; /* connection state (valid for STA, CLI only) */
  100. wifi_roam_state roaming; /* roaming state */
  101. uint32 capabilities; /* WIFI_CAPABILITY_XXX (self) */
  102. uint8 ssid[DOT11_MAX_SSID_LEN+1]; /* null terminated SSID */
  103. uint8 bssid[ETHER_ADDR_LEN]; /* bssid */
  104. uint8 PAD[1];
  105. uint8 ap_country_str[3]; /* country string advertised by AP */
  106. uint8 country_str[3]; /* country string for this association */
  107. uint8 PAD[2];
  108. } wifi_interface_info;
  109. typedef wifi_interface_info *wifi_interface_handle;
  110. /* channel information */
  111. typedef struct {
  112. wifi_channel_width_t width; /* channel width (20, 40, 80, 80+80, 160) */
  113. wifi_channel center_freq; /* primary 20 MHz channel */
  114. wifi_channel center_freq0; /* center frequency (MHz) first segment */
  115. wifi_channel center_freq1; /* center frequency (MHz) second segment */
  116. } wifi_channel_info;
  117. /* wifi rate */
  118. typedef struct {
  119. uint32 preamble; /* 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved */
  120. uint32 nss; /* 0:1x1, 1:2x2, 3:3x3, 4:4x4 */
  121. uint32 bw; /* 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz */
  122. uint32 rateMcsIdx; /* OFDM/CCK rate code would be as per ieee std
  123. * in the units of 0.5mbps
  124. */
  125. /* HT/VHT it would be mcs index */
  126. uint32 reserved; /* reserved */
  127. uint32 bitrate; /* units of 100 Kbps */
  128. } wifi_rate;
  129. typedef struct {
  130. uint32 preamble :3; /* 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved */
  131. uint32 nss :2; /* 0:1x1, 1:2x2, 3:3x3, 4:4x4 */
  132. uint32 bw :3; /* 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz */
  133. uint32 rateMcsIdx :8; /* OFDM/CCK rate code would be as per ieee std
  134. * in the units of 0.5mbps HT/VHT it would be
  135. * mcs index
  136. */
  137. uint32 reserved :16; /* reserved */
  138. uint32 bitrate; /* units of 100 Kbps */
  139. } wifi_rate_v1;
  140. /* channel statistics */
  141. typedef struct {
  142. wifi_channel_info channel; /* channel */
  143. uint32 on_time; /* msecs the radio is awake (32 bits number
  144. * accruing over time)
  145. */
  146. uint32 cca_busy_time; /* msecs the CCA register is busy (32 bits number
  147. * accruing over time)
  148. */
  149. } wifi_channel_stat;
  150. /* radio statistics */
  151. typedef struct {
  152. struct {
  153. uint16 version;
  154. uint16 length;
  155. };
  156. wifi_radio radio; /* wifi radio (if multiple radio supported) */
  157. uint32 on_time; /* msecs the radio is awake (32 bits number
  158. * accruing over time)
  159. */
  160. uint32 tx_time; /* msecs the radio is transmitting (32 bits
  161. * number accruing over time)
  162. */
  163. uint32 rx_time; /* msecs the radio is in active receive (32 bits
  164. * number accruing over time)
  165. */
  166. uint32 on_time_scan; /* msecs the radio is awake due to all scan (32 bits
  167. * number accruing over time)
  168. */
  169. uint32 on_time_nbd; /* msecs the radio is awake due to NAN (32 bits
  170. * number accruing over time)
  171. */
  172. uint32 on_time_gscan; /* msecs the radio is awake due to G?scan (32 bits
  173. * number accruing over time)
  174. */
  175. uint32 on_time_roam_scan; /* msecs the radio is awake due to roam?scan (32 bits
  176. * number accruing over time)
  177. */
  178. uint32 on_time_pno_scan; /* msecs the radio is awake due to PNO scan (32 bits
  179. * number accruing over time)
  180. */
  181. uint32 on_time_hs20; /* msecs the radio is awake due to HS2.0 scans and
  182. * GAS exchange (32 bits number accruing over time)
  183. */
  184. uint32 num_channels; /* number of channels */
  185. wifi_channel_stat channels[1]; /* channel statistics */
  186. } wifi_radio_stat;
  187. typedef struct {
  188. wifi_radio radio;
  189. uint32 on_time;
  190. uint32 tx_time;
  191. uint32 rx_time;
  192. uint32 on_time_scan;
  193. uint32 on_time_nbd;
  194. uint32 on_time_gscan;
  195. uint32 on_time_roam_scan;
  196. uint32 on_time_pno_scan;
  197. uint32 on_time_hs20;
  198. uint32 num_channels;
  199. } wifi_radio_stat_h;
  200. /* per rate statistics */
  201. typedef struct {
  202. wifi_rate_v1 rate; /* rate information */
  203. uint32 tx_mpdu; /* number of successfully transmitted data pkts (ACK rcvd) */
  204. uint32 rx_mpdu; /* number of received data pkts */
  205. uint32 mpdu_lost; /* number of data packet losses (no ACK) */
  206. uint32 retries; /* total number of data pkt retries */
  207. uint32 retries_short; /* number of short data pkt retries */
  208. uint32 retries_long; /* number of long data pkt retries */
  209. } wifi_rate_stat_v1;
  210. typedef struct {
  211. uint16 version;
  212. uint16 length;
  213. uint32 tx_mpdu; /* number of successfully transmitted data pkts (ACK rcvd) */
  214. uint32 rx_mpdu; /* number of received data pkts */
  215. uint32 mpdu_lost; /* number of data packet losses (no ACK) */
  216. uint32 retries; /* total number of data pkt retries */
  217. uint32 retries_short; /* number of short data pkt retries */
  218. uint32 retries_long; /* number of long data pkt retries */
  219. wifi_rate rate;
  220. } wifi_rate_stat;
  221. /* access categories */
  222. typedef enum {
  223. WIFI_AC_VO = 0,
  224. WIFI_AC_VI = 1,
  225. WIFI_AC_BE = 2,
  226. WIFI_AC_BK = 3,
  227. WIFI_AC_MAX = 4
  228. } wifi_traffic_ac;
  229. /* wifi peer type */
  230. typedef enum
  231. {
  232. WIFI_PEER_STA,
  233. WIFI_PEER_AP,
  234. WIFI_PEER_P2P_GO,
  235. WIFI_PEER_P2P_CLIENT,
  236. WIFI_PEER_NAN,
  237. WIFI_PEER_TDLS,
  238. WIFI_PEER_INVALID
  239. } wifi_peer_type;
  240. /* per peer statistics */
  241. typedef struct {
  242. wifi_peer_type type; /* peer type (AP, TDLS, GO etc.) */
  243. uint8 peer_mac_address[6]; /* mac address */
  244. uint32 capabilities; /* peer WIFI_CAPABILITY_XXX */
  245. uint32 num_rate; /* number of rates */
  246. wifi_rate_stat rate_stats[1]; /* per rate statistics, number of entries = num_rate */
  247. } wifi_peer_info;
  248. /* per access category statistics */
  249. typedef struct {
  250. wifi_traffic_ac ac; /* access category (VI, VO, BE, BK) */
  251. uint32 tx_mpdu; /* number of successfully transmitted unicast data pkts
  252. * (ACK rcvd)
  253. */
  254. uint32 rx_mpdu; /* number of received unicast mpdus */
  255. uint32 tx_mcast; /* number of succesfully transmitted multicast
  256. * data packets
  257. */
  258. /* STA case: implies ACK received from AP for the
  259. * unicast packet in which mcast pkt was sent
  260. */
  261. uint32 rx_mcast; /* number of received multicast data packets */
  262. uint32 rx_ampdu; /* number of received unicast a-mpdus */
  263. uint32 tx_ampdu; /* number of transmitted unicast a-mpdus */
  264. uint32 mpdu_lost; /* number of data pkt losses (no ACK) */
  265. uint32 retries; /* total number of data pkt retries */
  266. uint32 retries_short; /* number of short data pkt retries */
  267. uint32 retries_long; /* number of long data pkt retries */
  268. uint32 contention_time_min; /* data pkt min contention time (usecs) */
  269. uint32 contention_time_max; /* data pkt max contention time (usecs) */
  270. uint32 contention_time_avg; /* data pkt avg contention time (usecs) */
  271. uint32 contention_num_samples; /* num of data pkts used for contention statistics */
  272. } wifi_wmm_ac_stat;
  273. /* interface statistics */
  274. typedef struct {
  275. wifi_interface_handle iface; /* wifi interface */
  276. wifi_interface_info info; /* current state of the interface */
  277. uint32 beacon_rx; /* access point beacon received count from
  278. * connected AP
  279. */
  280. uint64 average_tsf_offset; /* average beacon offset encountered (beacon_TSF - TBTT)
  281. * The average_tsf_offset field is used so as to calculate
  282. * the typical beacon contention time on the channel as well
  283. * may be used to debug beacon synchronization and related
  284. * power consumption issue
  285. */
  286. uint32 leaky_ap_detected; /* indicate that this AP
  287. * typically leaks packets beyond
  288. * the driver guard time.
  289. */
  290. uint32 leaky_ap_avg_num_frames_leaked; /* average number of frame leaked by AP after
  291. * frame with PM bit set was ACK'ed by AP
  292. */
  293. uint32 leaky_ap_guard_time; /* guard time currently in force
  294. * (when implementing IEEE power management
  295. * based on frame control PM bit), How long
  296. * driver waits before shutting down the radio and after
  297. * receiving an ACK for a data frame with PM bit set)
  298. */
  299. uint32 mgmt_rx; /* access point mgmt frames received count from
  300. * connected AP (including Beacon)
  301. */
  302. uint32 mgmt_action_rx; /* action frames received count */
  303. uint32 mgmt_action_tx; /* action frames transmit count */
  304. wifi_rssi rssi_mgmt; /* access Point Beacon and Management frames RSSI
  305. * (averaged)
  306. */
  307. wifi_rssi rssi_data; /* access Point Data Frames RSSI (averaged) from
  308. * connected AP
  309. */
  310. wifi_rssi rssi_ack; /* access Point ACK RSSI (averaged) from
  311. * connected AP
  312. */
  313. wifi_wmm_ac_stat ac[WIFI_AC_MAX]; /* per ac data packet statistics */
  314. uint32 num_peers; /* number of peers */
  315. wifi_peer_info peer_info[1]; /* per peer statistics */
  316. } wifi_iface_stat;
  317. #endif /* _dngl_stats_h_ */