rtw_cfgvendor.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. *****************************************************************************/
  15. #ifndef _RTW_CFGVENDOR_H_
  16. #define _RTW_CFGVENDOR_H_
  17. #define OUI_GOOGLE 0x001A11
  18. #define ATTRIBUTE_U32_LEN (NLA_HDRLEN + 4)
  19. #define VENDOR_ID_OVERHEAD ATTRIBUTE_U32_LEN
  20. #define VENDOR_SUBCMD_OVERHEAD ATTRIBUTE_U32_LEN
  21. #define VENDOR_DATA_OVERHEAD (NLA_HDRLEN)
  22. #define SCAN_RESULTS_COMPLETE_FLAG_LEN ATTRIBUTE_U32_LEN
  23. #define SCAN_INDEX_HDR_LEN (NLA_HDRLEN)
  24. #define SCAN_ID_HDR_LEN ATTRIBUTE_U32_LEN
  25. #define SCAN_FLAGS_HDR_LEN ATTRIBUTE_U32_LEN
  26. #define GSCAN_NUM_RESULTS_HDR_LEN ATTRIBUTE_U32_LEN
  27. #define GSCAN_RESULTS_HDR_LEN (NLA_HDRLEN)
  28. #define GSCAN_BATCH_RESULT_HDR_LEN (SCAN_INDEX_HDR_LEN + SCAN_ID_HDR_LEN + \
  29. SCAN_FLAGS_HDR_LEN + \
  30. GSCAN_NUM_RESULTS_HDR_LEN + \
  31. GSCAN_RESULTS_HDR_LEN)
  32. #define VENDOR_REPLY_OVERHEAD (VENDOR_ID_OVERHEAD + \
  33. VENDOR_SUBCMD_OVERHEAD + \
  34. VENDOR_DATA_OVERHEAD)
  35. typedef enum {
  36. /* don't use 0 as a valid subcommand */
  37. VENDOR_NL80211_SUBCMD_UNSPECIFIED,
  38. /* define all vendor startup commands between 0x0 and 0x0FFF */
  39. VENDOR_NL80211_SUBCMD_RANGE_START = 0x0001,
  40. VENDOR_NL80211_SUBCMD_RANGE_END = 0x0FFF,
  41. /* define all GScan related commands between 0x1000 and 0x10FF */
  42. ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START = 0x1000,
  43. ANDROID_NL80211_SUBCMD_GSCAN_RANGE_END = 0x10FF,
  44. /* define all NearbyDiscovery related commands between 0x1100 and 0x11FF */
  45. ANDROID_NL80211_SUBCMD_NBD_RANGE_START = 0x1100,
  46. ANDROID_NL80211_SUBCMD_NBD_RANGE_END = 0x11FF,
  47. /* define all RTT related commands between 0x1100 and 0x11FF */
  48. ANDROID_NL80211_SUBCMD_RTT_RANGE_START = 0x1100,
  49. ANDROID_NL80211_SUBCMD_RTT_RANGE_END = 0x11FF,
  50. ANDROID_NL80211_SUBCMD_LSTATS_RANGE_START = 0x1200,
  51. ANDROID_NL80211_SUBCMD_LSTATS_RANGE_END = 0x12FF,
  52. /* define all Logger related commands between 0x1400 and 0x14FF */
  53. ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START = 0x1400,
  54. ANDROID_NL80211_SUBCMD_DEBUG_RANGE_END = 0x14FF,
  55. /* define all wifi offload related commands between 0x1600 and 0x16FF */
  56. ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_START = 0x1600,
  57. ANDROID_NL80211_SUBCMD_WIFI_OFFLOAD_RANGE_END = 0x16FF,
  58. /* define all NAN related commands between 0x1700 and 0x17FF */
  59. ANDROID_NL80211_SUBCMD_NAN_RANGE_START = 0x1700,
  60. ANDROID_NL80211_SUBCMD_NAN_RANGE_END = 0x17FF,
  61. /* define all Android Packet Filter related commands between 0x1800 and 0x18FF */
  62. ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START = 0x1800,
  63. ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_END = 0x18FF,
  64. /* This is reserved for future usage */
  65. } ANDROID_VENDOR_SUB_COMMAND;
  66. enum rtw_vendor_subcmd {
  67. GSCAN_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_GSCAN_RANGE_START,
  68. GSCAN_SUBCMD_SET_CONFIG, /* 0x1001 */
  69. GSCAN_SUBCMD_SET_SCAN_CONFIG, /* 0x1002 */
  70. GSCAN_SUBCMD_ENABLE_GSCAN, /* 0x1003 */
  71. GSCAN_SUBCMD_GET_SCAN_RESULTS, /* 0x1004 */
  72. GSCAN_SUBCMD_SCAN_RESULTS, /* 0x1005 */
  73. GSCAN_SUBCMD_SET_HOTLIST, /* 0x1006 */
  74. GSCAN_SUBCMD_SET_SIGNIFICANT_CHANGE_CONFIG, /* 0x1007 */
  75. GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, /* 0x1008 */
  76. GSCAN_SUBCMD_GET_CHANNEL_LIST, /* 0x1009 */
  77. WIFI_SUBCMD_GET_FEATURE_SET, /* 0x100A */
  78. WIFI_SUBCMD_GET_FEATURE_SET_MATRIX, /* 0x100B */
  79. WIFI_SUBCMD_SET_PNO_RANDOM_MAC_OUI, /* 0x100C */
  80. WIFI_SUBCMD_NODFS_SET, /* 0x100D */
  81. WIFI_SUBCMD_SET_COUNTRY_CODE, /* 0x100E */
  82. /* Add more sub commands here */
  83. GSCAN_SUBCMD_SET_EPNO_SSID, /* 0x100F */
  84. WIFI_SUBCMD_SET_SSID_WHITE_LIST, /* 0x1010 */
  85. WIFI_SUBCMD_SET_ROAM_PARAMS, /* 0x1011 */
  86. WIFI_SUBCMD_ENABLE_LAZY_ROAM, /* 0x1012 */
  87. WIFI_SUBCMD_SET_BSSID_PREF, /* 0x1013 */
  88. WIFI_SUBCMD_SET_BSSID_BLACKLIST, /* 0x1014 */
  89. GSCAN_SUBCMD_ANQPO_CONFIG, /* 0x1015 */
  90. WIFI_SUBCMD_SET_RSSI_MONITOR, /* 0x1016 */
  91. WIFI_SUBCMD_CONFIG_ND_OFFLOAD, /* 0x1017 */
  92. /* Add more sub commands here */
  93. GSCAN_SUBCMD_MAX,
  94. RTT_SUBCMD_SET_CONFIG = ANDROID_NL80211_SUBCMD_RTT_RANGE_START,
  95. RTT_SUBCMD_CANCEL_CONFIG,
  96. RTT_SUBCMD_GETCAPABILITY,
  97. APF_SUBCMD_GET_CAPABILITIES = ANDROID_NL80211_SUBCMD_PKT_FILTER_RANGE_START,
  98. APF_SUBCMD_SET_FILTER,
  99. LOGGER_START_LOGGING = ANDROID_NL80211_SUBCMD_DEBUG_RANGE_START,
  100. LOGGER_TRIGGER_MEM_DUMP,
  101. LOGGER_GET_MEM_DUMP,
  102. LOGGER_GET_VER,
  103. LOGGER_GET_RING_STATUS,
  104. LOGGER_GET_RING_DATA,
  105. LOGGER_GET_FEATURE,
  106. LOGGER_RESET_LOGGING,
  107. LOGGER_TRIGGER_DRIVER_MEM_DUMP,
  108. LOGGER_GET_DRIVER_MEM_DUMP,
  109. LOGGER_START_PKT_FATE_MONITORING,
  110. LOGGER_GET_TX_PKT_FATES,
  111. LOGGER_GET_RX_PKT_FATES,
  112. VENDOR_SUBCMD_MAX
  113. };
  114. enum gscan_attributes {
  115. GSCAN_ATTRIBUTE_NUM_BUCKETS = 10,
  116. GSCAN_ATTRIBUTE_BASE_PERIOD,
  117. GSCAN_ATTRIBUTE_BUCKETS_BAND,
  118. GSCAN_ATTRIBUTE_BUCKET_ID,
  119. GSCAN_ATTRIBUTE_BUCKET_PERIOD,
  120. GSCAN_ATTRIBUTE_BUCKET_NUM_CHANNELS,
  121. GSCAN_ATTRIBUTE_BUCKET_CHANNELS,
  122. GSCAN_ATTRIBUTE_NUM_AP_PER_SCAN,
  123. GSCAN_ATTRIBUTE_REPORT_THRESHOLD,
  124. GSCAN_ATTRIBUTE_NUM_SCANS_TO_CACHE,
  125. GSCAN_ATTRIBUTE_BAND = GSCAN_ATTRIBUTE_BUCKETS_BAND,
  126. GSCAN_ATTRIBUTE_ENABLE_FEATURE = 20,
  127. GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE,
  128. GSCAN_ATTRIBUTE_FLUSH_FEATURE,
  129. GSCAN_ATTRIBUTE_ENABLE_FULL_SCAN_RESULTS,
  130. GSCAN_ATTRIBUTE_REPORT_EVENTS,
  131. /* remaining reserved for additional attributes */
  132. GSCAN_ATTRIBUTE_NUM_OF_RESULTS = 30,
  133. GSCAN_ATTRIBUTE_FLUSH_RESULTS,
  134. GSCAN_ATTRIBUTE_SCAN_RESULTS, /* flat array of wifi_scan_result */
  135. GSCAN_ATTRIBUTE_SCAN_ID, /* indicates scan number */
  136. GSCAN_ATTRIBUTE_SCAN_FLAGS, /* indicates if scan was aborted */
  137. GSCAN_ATTRIBUTE_AP_FLAGS, /* flags on significant change event */
  138. GSCAN_ATTRIBUTE_NUM_CHANNELS,
  139. GSCAN_ATTRIBUTE_CHANNEL_LIST,
  140. /* remaining reserved for additional attributes */
  141. GSCAN_ATTRIBUTE_SSID = 40,
  142. GSCAN_ATTRIBUTE_BSSID,
  143. GSCAN_ATTRIBUTE_CHANNEL,
  144. GSCAN_ATTRIBUTE_RSSI,
  145. GSCAN_ATTRIBUTE_TIMESTAMP,
  146. GSCAN_ATTRIBUTE_RTT,
  147. GSCAN_ATTRIBUTE_RTTSD,
  148. /* remaining reserved for additional attributes */
  149. GSCAN_ATTRIBUTE_HOTLIST_BSSIDS = 50,
  150. GSCAN_ATTRIBUTE_RSSI_LOW,
  151. GSCAN_ATTRIBUTE_RSSI_HIGH,
  152. GSCAN_ATTRIBUTE_HOSTLIST_BSSID_ELEM,
  153. GSCAN_ATTRIBUTE_HOTLIST_FLUSH,
  154. /* remaining reserved for additional attributes */
  155. GSCAN_ATTRIBUTE_RSSI_SAMPLE_SIZE = 60,
  156. GSCAN_ATTRIBUTE_LOST_AP_SAMPLE_SIZE,
  157. GSCAN_ATTRIBUTE_MIN_BREACHING,
  158. GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_BSSIDS,
  159. GSCAN_ATTRIBUTE_SIGNIFICANT_CHANGE_FLUSH,
  160. GSCAN_ATTRIBUTE_MAX
  161. };
  162. enum gscan_bucket_attributes {
  163. GSCAN_ATTRIBUTE_CH_BUCKET_1,
  164. GSCAN_ATTRIBUTE_CH_BUCKET_2,
  165. GSCAN_ATTRIBUTE_CH_BUCKET_3,
  166. GSCAN_ATTRIBUTE_CH_BUCKET_4,
  167. GSCAN_ATTRIBUTE_CH_BUCKET_5,
  168. GSCAN_ATTRIBUTE_CH_BUCKET_6,
  169. GSCAN_ATTRIBUTE_CH_BUCKET_7
  170. };
  171. enum gscan_ch_attributes {
  172. GSCAN_ATTRIBUTE_CH_ID_1,
  173. GSCAN_ATTRIBUTE_CH_ID_2,
  174. GSCAN_ATTRIBUTE_CH_ID_3,
  175. GSCAN_ATTRIBUTE_CH_ID_4,
  176. GSCAN_ATTRIBUTE_CH_ID_5,
  177. GSCAN_ATTRIBUTE_CH_ID_6,
  178. GSCAN_ATTRIBUTE_CH_ID_7
  179. };
  180. enum wifi_rssi_monitor_attr {
  181. RSSI_MONITOR_ATTRIBUTE_MAX_RSSI,
  182. RSSI_MONITOR_ATTRIBUTE_MIN_RSSI,
  183. RSSI_MONITOR_ATTRIBUTE_START,
  184. };
  185. enum rtt_attributes {
  186. RTT_ATTRIBUTE_TARGET_CNT,
  187. RTT_ATTRIBUTE_TARGET_INFO,
  188. RTT_ATTRIBUTE_TARGET_MAC,
  189. RTT_ATTRIBUTE_TARGET_TYPE,
  190. RTT_ATTRIBUTE_TARGET_PEER,
  191. RTT_ATTRIBUTE_TARGET_CHAN,
  192. RTT_ATTRIBUTE_TARGET_MODE,
  193. RTT_ATTRIBUTE_TARGET_INTERVAL,
  194. RTT_ATTRIBUTE_TARGET_NUM_MEASUREMENT,
  195. RTT_ATTRIBUTE_TARGET_NUM_PKT,
  196. RTT_ATTRIBUTE_TARGET_NUM_RETRY
  197. };
  198. enum logger_attributes {
  199. LOGGER_ATTRIBUTE_GET_DRIVER,
  200. LOGGER_ATTRIBUTE_GET_FW,
  201. LOGGER_ATTRIBUTE_RING_ID,
  202. LOGGER_ATTRIBUTE_RING_NAME,
  203. LOGGER_ATTRIBUTE_RING_FLAGS,
  204. LOGGER_ATTRIBUTE_LOG_LEVEL,
  205. LOGGER_ATTRIBUTE_LOG_TIME_INTVAL,
  206. LOGGER_ATTRIBUTE_LOG_MIN_DATA_SIZE,
  207. LOGGER_ATTRIBUTE_FW_DUMP_LEN,
  208. LOGGER_ATTRIBUTE_FW_DUMP_DATA,
  209. LOGGERG_ATTRIBUTE_RING_DATA,
  210. LOGGER_ATTRIBUTE_RING_STATUS,
  211. LOGGER_ATTRIBUTE_RING_NUM
  212. };
  213. typedef enum rtw_vendor_event {
  214. RTK_RESERVED1,
  215. RTK_RESERVED2,
  216. GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS ,
  217. GSCAN_EVENT_HOTLIST_RESULTS_FOUND,
  218. GSCAN_EVENT_SCAN_RESULTS_AVAILABLE,
  219. GSCAN_EVENT_FULL_SCAN_RESULTS,
  220. RTT_EVENT_COMPLETE,
  221. GSCAN_EVENT_COMPLETE_SCAN,
  222. GSCAN_EVENT_HOTLIST_RESULTS_LOST,
  223. GSCAN_EVENT_EPNO_EVENT,
  224. GOOGLE_DEBUG_RING_EVENT,
  225. GOOGLE_DEBUG_MEM_DUMP_EVENT,
  226. GSCAN_EVENT_ANQPO_HOTSPOT_MATCH,
  227. GOOGLE_RSSI_MONITOR_EVENT
  228. } rtw_vendor_event_t;
  229. enum andr_wifi_feature_set_attr {
  230. ANDR_WIFI_ATTRIBUTE_NUM_FEATURE_SET,
  231. ANDR_WIFI_ATTRIBUTE_FEATURE_SET,
  232. ANDR_WIFI_ATTRIBUTE_RANDOM_MAC_OUI,
  233. ANDR_WIFI_ATTRIBUTE_NODFS_SET,
  234. ANDR_WIFI_ATTRIBUTE_COUNTRY,
  235. ANDR_WIFI_ATTRIBUTE_ND_OFFLOAD_VALUE
  236. // Add more attribute here
  237. };
  238. typedef enum rtw_vendor_gscan_attribute {
  239. ATTR_START_GSCAN,
  240. ATTR_STOP_GSCAN,
  241. ATTR_SET_SCAN_BATCH_CFG_ID, /* set batch scan params */
  242. ATTR_SET_SCAN_GEOFENCE_CFG_ID, /* set list of bssids to track */
  243. ATTR_SET_SCAN_SIGNIFICANT_CFG_ID, /* set list of bssids, rssi threshold etc.. */
  244. ATTR_SET_SCAN_CFG_ID, /* set common scan config params here */
  245. ATTR_GET_GSCAN_CAPABILITIES_ID,
  246. /* Add more sub commands here */
  247. ATTR_GSCAN_MAX
  248. } rtw_vendor_gscan_attribute_t;
  249. typedef enum gscan_batch_attribute {
  250. ATTR_GSCAN_BATCH_BESTN,
  251. ATTR_GSCAN_BATCH_MSCAN,
  252. ATTR_GSCAN_BATCH_BUFFER_THRESHOLD
  253. } gscan_batch_attribute_t;
  254. typedef enum gscan_geofence_attribute {
  255. ATTR_GSCAN_NUM_HOTLIST_BSSID,
  256. ATTR_GSCAN_HOTLIST_BSSID
  257. } gscan_geofence_attribute_t;
  258. typedef enum gscan_complete_event {
  259. WIFI_SCAN_BUFFER_FULL,
  260. WIFI_SCAN_COMPLETE
  261. } gscan_complete_event_t;
  262. /* wifi_hal.h */
  263. /* WiFi Common definitions */
  264. typedef unsigned char byte;
  265. typedef int wifi_request_id;
  266. typedef int wifi_channel; // indicates channel frequency in MHz
  267. typedef int wifi_rssi;
  268. typedef byte mac_addr[6];
  269. typedef byte oui[3];
  270. typedef int64_t wifi_timestamp; // In microseconds (us)
  271. typedef int64_t wifi_timespan; // In picoseconds (ps)
  272. struct wifi_info;
  273. struct wifi_interface_info;
  274. typedef struct wifi_info *wifi_handle;
  275. typedef struct wifi_interface_info *wifi_interface_handle;
  276. /* channel operating width */
  277. typedef enum {
  278. WIFI_CHAN_WIDTH_20 = 0,
  279. WIFI_CHAN_WIDTH_40 = 1,
  280. WIFI_CHAN_WIDTH_80 = 2,
  281. WIFI_CHAN_WIDTH_160 = 3,
  282. WIFI_CHAN_WIDTH_80P80 = 4,
  283. WIFI_CHAN_WIDTH_5 = 5,
  284. WIFI_CHAN_WIDTH_10 = 6,
  285. WIFI_CHAN_WIDTH_INVALID = -1
  286. } wifi_channel_width;
  287. typedef int wifi_radio;
  288. typedef struct {
  289. wifi_channel_width width;
  290. int center_frequency0;
  291. int center_frequency1;
  292. int primary_frequency;
  293. } wifi_channel_spec;
  294. typedef enum {
  295. WIFI_SUCCESS = 0,
  296. WIFI_ERROR_NONE = 0,
  297. WIFI_ERROR_UNKNOWN = -1,
  298. WIFI_ERROR_UNINITIALIZED = -2,
  299. WIFI_ERROR_NOT_SUPPORTED = -3,
  300. WIFI_ERROR_NOT_AVAILABLE = -4, // Not available right now, but try later
  301. WIFI_ERROR_INVALID_ARGS = -5,
  302. WIFI_ERROR_INVALID_REQUEST_ID = -6,
  303. WIFI_ERROR_TIMED_OUT = -7,
  304. WIFI_ERROR_TOO_MANY_REQUESTS = -8, // Too many instances of this request
  305. WIFI_ERROR_OUT_OF_MEMORY = -9,
  306. WIFI_ERROR_BUSY = -10,
  307. } wifi_error;
  308. typedef int wifi_ring_buffer_id;
  309. /* ring buffer params */
  310. /**
  311. * written_bytes and read_bytes implement a producer consumer API
  312. * hence written_bytes >= read_bytes
  313. * a modulo arithmetic of the buffer size has to be applied to those counters:
  314. * actual offset into ring buffer = written_bytes % ring_buffer_byte_size
  315. *
  316. */
  317. typedef struct {
  318. u8 name[32];
  319. u32 flags;
  320. wifi_ring_buffer_id ring_id; // unique integer representing the ring
  321. u32 ring_buffer_byte_size; // total memory size allocated for the buffer
  322. u32 verbose_level; // verbose level for ring buffer
  323. u32 written_bytes; // number of bytes that was written to the buffer by driver,
  324. // monotonously increasing integer
  325. u32 read_bytes; // number of bytes that was read from the buffer by user land,
  326. // monotonously increasing integer
  327. u32 written_records; // number of records that was written to the buffer by driver,
  328. // monotonously increasing integer
  329. } wifi_ring_buffer_status;
  330. #ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS
  331. #define STATS_MAJOR_VERSION 1
  332. #define STATS_MINOR_VERSION 0
  333. #define STATS_MICRO_VERSION 0
  334. typedef enum {
  335. WIFI_DISCONNECTED = 0,
  336. WIFI_AUTHENTICATING = 1,
  337. WIFI_ASSOCIATING = 2,
  338. WIFI_ASSOCIATED = 3,
  339. WIFI_EAPOL_STARTED = 4, // if done by firmware/driver
  340. WIFI_EAPOL_COMPLETED = 5, // if done by firmware/driver
  341. } wifi_connection_state;
  342. typedef enum {
  343. WIFI_ROAMING_IDLE = 0,
  344. WIFI_ROAMING_ACTIVE = 1,
  345. } wifi_roam_state;
  346. typedef enum {
  347. WIFI_INTERFACE_STA = 0,
  348. WIFI_INTERFACE_SOFTAP = 1,
  349. WIFI_INTERFACE_IBSS = 2,
  350. WIFI_INTERFACE_P2P_CLIENT = 3,
  351. WIFI_INTERFACE_P2P_GO = 4,
  352. WIFI_INTERFACE_NAN = 5,
  353. WIFI_INTERFACE_MESH = 6,
  354. WIFI_INTERFACE_UNKNOWN = -1
  355. } wifi_interface_mode;
  356. #define WIFI_CAPABILITY_QOS 0x00000001 // set for QOS association
  357. #define WIFI_CAPABILITY_PROTECTED 0x00000002 // set for protected association (802.11 beacon frame control protected bit set)
  358. #define WIFI_CAPABILITY_INTERWORKING 0x00000004 // set if 802.11 Extended Capabilities element interworking bit is set
  359. #define WIFI_CAPABILITY_HS20 0x00000008 // set for HS20 association
  360. #define WIFI_CAPABILITY_SSID_UTF8 0x00000010 // set is 802.11 Extended Capabilities element UTF-8 SSID bit is set
  361. #define WIFI_CAPABILITY_COUNTRY 0x00000020 // set is 802.11 Country Element is present
  362. typedef struct {
  363. wifi_interface_mode mode; // interface mode
  364. u8 mac_addr[6]; // interface mac address (self)
  365. wifi_connection_state state; // connection state (valid for STA, CLI only)
  366. wifi_roam_state roaming; // roaming state
  367. u32 capabilities; // WIFI_CAPABILITY_XXX (self)
  368. u8 ssid[33]; // null terminated SSID
  369. u8 bssid[6]; // bssid
  370. u8 ap_country_str[3]; // country string advertised by AP
  371. u8 country_str[3]; // country string for this association
  372. } wifi_interface_link_layer_info;
  373. /* channel information */
  374. typedef struct {
  375. wifi_channel_width width; // channel width (20, 40, 80, 80+80, 160)
  376. wifi_channel center_freq; // primary 20 MHz channel
  377. wifi_channel center_freq0; // center frequency (MHz) first segment
  378. wifi_channel center_freq1; // center frequency (MHz) second segment
  379. } wifi_channel_info;
  380. /* wifi rate */
  381. typedef struct {
  382. u32 preamble :3; // 0: OFDM, 1:CCK, 2:HT 3:VHT 4..7 reserved
  383. u32 nss :2; // 0:1x1, 1:2x2, 3:3x3, 4:4x4
  384. u32 bw :3; // 0:20MHz, 1:40Mhz, 2:80Mhz, 3:160Mhz
  385. u32 rateMcsIdx :8; // OFDM/CCK rate code would be as per ieee std in the units of 0.5mbps
  386. // HT/VHT it would be mcs index
  387. u32 reserved :16; // reserved
  388. u32 bitrate; // units of 100 Kbps
  389. } wifi_rate;
  390. /* channel statistics */
  391. typedef struct {
  392. wifi_channel_info channel; // channel
  393. u32 on_time; // msecs the radio is awake (32 bits number accruing over time)
  394. u32 cca_busy_time; // msecs the CCA register is busy (32 bits number accruing over time)
  395. } wifi_channel_stat;
  396. // Max number of tx power levels. The actual number vary per device and is specified by |num_tx_levels|
  397. #define RADIO_STAT_MAX_TX_LEVELS 256
  398. /* Internal radio statistics structure in the driver */
  399. typedef struct {
  400. wifi_radio radio; // wifi radio (if multiple radio supported)
  401. u32 on_time; // msecs the radio is awake (32 bits number accruing over time)
  402. u32 tx_time; // msecs the radio is transmitting (32 bits number accruing over time)
  403. u32 rx_time; // msecs the radio is in active receive (32 bits number accruing over time)
  404. u32 on_time_scan; // msecs the radio is awake due to all scan (32 bits number accruing over time)
  405. u32 on_time_nbd; // msecs the radio is awake due to NAN (32 bits number accruing over time)
  406. u32 on_time_gscan; // msecs the radio is awake due to G?scan (32 bits number accruing over time)
  407. u32 on_time_roam_scan; // msecs the radio is awake due to roam?scan (32 bits number accruing over time)
  408. u32 on_time_pno_scan; // msecs the radio is awake due to PNO scan (32 bits number accruing over time)
  409. u32 on_time_hs20; // msecs the radio is awake due to HS2.0 scans and GAS exchange (32 bits number accruing over time)
  410. u32 num_channels; // number of channels
  411. wifi_channel_stat channels[]; // channel statistics
  412. } wifi_radio_stat_internal;
  413. /**
  414. * Packet statistics reporting by firmware is performed on MPDU basi (i.e. counters increase by 1 for each MPDU)
  415. * As well, "data packet" in associated comments, shall be interpreted as 802.11 data packet,
  416. * that is, 802.11 frame control subtype == 2 and excluding management and control frames.
  417. *
  418. * As an example, in the case of transmission of an MSDU fragmented in 16 MPDUs which are transmitted
  419. * OTA in a 16 units long a-mpdu, for which a block ack is received with 5 bits set:
  420. * tx_mpdu : shall increase by 5
  421. * retries : shall increase by 16
  422. * tx_ampdu : shall increase by 1
  423. * data packet counters shall not increase regardless of the number of BAR potentially sent by device for this a-mpdu
  424. * data packet counters shall not increase regardless of the number of BA received by device for this a-mpdu
  425. *
  426. * For each subsequent retransmission of the 11 remaining non ACK'ed mpdus
  427. * (regardless of the fact that they are transmitted in a-mpdu or not)
  428. * retries : shall increase by 1
  429. *
  430. * If no subsequent BA or ACK are received from AP, until packet lifetime expires for those 11 packet that were not ACK'ed
  431. * mpdu_lost : shall increase by 11
  432. */
  433. /* per rate statistics */
  434. typedef struct {
  435. wifi_rate rate; // rate information
  436. u32 tx_mpdu; // number of successfully transmitted data pkts (ACK rcvd)
  437. u32 rx_mpdu; // number of received data pkts
  438. u32 mpdu_lost; // number of data packet losses (no ACK)
  439. u32 retries; // total number of data pkt retries
  440. u32 retries_short; // number of short data pkt retries
  441. u32 retries_long; // number of long data pkt retries
  442. } wifi_rate_stat;
  443. /* access categories */
  444. typedef enum {
  445. WIFI_AC_VO = 0,
  446. WIFI_AC_VI = 1,
  447. WIFI_AC_BE = 2,
  448. WIFI_AC_BK = 3,
  449. WIFI_AC_MAX = 4,
  450. } wifi_traffic_ac;
  451. /* wifi peer type */
  452. typedef enum
  453. {
  454. WIFI_PEER_STA,
  455. WIFI_PEER_AP,
  456. WIFI_PEER_P2P_GO,
  457. WIFI_PEER_P2P_CLIENT,
  458. WIFI_PEER_NAN,
  459. WIFI_PEER_TDLS,
  460. WIFI_PEER_INVALID,
  461. } wifi_peer_type;
  462. /* per peer statistics */
  463. typedef struct {
  464. wifi_peer_type type; // peer type (AP, TDLS, GO etc.)
  465. u8 peer_mac_address[6]; // mac address
  466. u32 capabilities; // peer WIFI_CAPABILITY_XXX
  467. u32 num_rate; // number of rates
  468. wifi_rate_stat rate_stats[]; // per rate statistics, number of entries = num_rate
  469. } wifi_peer_info;
  470. /* Per access category statistics */
  471. typedef struct {
  472. wifi_traffic_ac ac; // access category (VI, VO, BE, BK)
  473. u32 tx_mpdu; // number of successfully transmitted unicast data pkts (ACK rcvd)
  474. u32 rx_mpdu; // number of received unicast data packets
  475. u32 tx_mcast; // number of succesfully transmitted multicast data packets
  476. // STA case: implies ACK received from AP for the unicast packet in which mcast pkt was sent
  477. u32 rx_mcast; // number of received multicast data packets
  478. u32 rx_ampdu; // number of received unicast a-mpdus; support of this counter is optional
  479. u32 tx_ampdu; // number of transmitted unicast a-mpdus; support of this counter is optional
  480. u32 mpdu_lost; // number of data pkt losses (no ACK)
  481. u32 retries; // total number of data pkt retries
  482. u32 retries_short; // number of short data pkt retries
  483. u32 retries_long; // number of long data pkt retries
  484. u32 contention_time_min; // data pkt min contention time (usecs)
  485. u32 contention_time_max; // data pkt max contention time (usecs)
  486. u32 contention_time_avg; // data pkt avg contention time (usecs)
  487. u32 contention_num_samples; // num of data pkts used for contention statistics
  488. } wifi_wmm_ac_stat;
  489. /* interface statistics */
  490. typedef struct {
  491. wifi_interface_handle iface; // wifi interface
  492. wifi_interface_link_layer_info info; // current state of the interface
  493. u32 beacon_rx; // access point beacon received count from connected AP
  494. u64 average_tsf_offset; // average beacon offset encountered (beacon_TSF - TBTT)
  495. // The average_tsf_offset field is used so as to calculate the
  496. // typical beacon contention time on the channel as well may be
  497. // used to debug beacon synchronization and related power consumption issue
  498. u32 leaky_ap_detected; // indicate that this AP typically leaks packets beyond the driver guard time.
  499. 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
  500. u32 leaky_ap_guard_time; // guard time currently in force (when implementing IEEE power management based on
  501. // frame control PM bit), How long driver waits before shutting down the radio and
  502. // after receiving an ACK for a data frame with PM bit set)
  503. u32 mgmt_rx; // access point mgmt frames received count from connected AP (including Beacon)
  504. u32 mgmt_action_rx; // action frames received count
  505. u32 mgmt_action_tx; // action frames transmit count
  506. wifi_rssi rssi_mgmt; // access Point Beacon and Management frames RSSI (averaged)
  507. wifi_rssi rssi_data; // access Point Data Frames RSSI (averaged) from connected AP
  508. wifi_rssi rssi_ack; // access Point ACK RSSI (averaged) from connected AP
  509. wifi_wmm_ac_stat ac[WIFI_AC_MAX]; // per ac data packet statistics
  510. u32 num_peers; // number of peers
  511. wifi_peer_info peer_info[]; // per peer statistics
  512. } wifi_iface_stat;
  513. /* configuration params */
  514. typedef struct {
  515. u32 mpdu_size_threshold; // threshold to classify the pkts as short or long
  516. // packet size < mpdu_size_threshold => short
  517. u32 aggressive_statistics_gathering; // set for field debug mode. Driver should collect all statistics regardless of performance impact.
  518. } wifi_link_layer_params;
  519. #define RSSI_MONITOR_EVT_VERSION 1
  520. typedef struct {
  521. u8 version;
  522. s8 cur_rssi;
  523. mac_addr BSSID;
  524. } rssi_monitor_evt;
  525. /* wifi statistics bitmap */
  526. #define WIFI_STATS_RADIO 0x00000001 // all radio statistics
  527. #define WIFI_STATS_RADIO_CCA 0x00000002 // cca_busy_time (within radio statistics)
  528. #define WIFI_STATS_RADIO_CHANNELS 0x00000004 // all channel statistics (within radio statistics)
  529. #define WIFI_STATS_RADIO_SCAN 0x00000008 // all scan statistics (within radio statistics)
  530. #define WIFI_STATS_IFACE 0x00000010 // all interface statistics
  531. #define WIFI_STATS_IFACE_TXRATE 0x00000020 // all tx rate statistics (within interface statistics)
  532. #define WIFI_STATS_IFACE_AC 0x00000040 // all ac statistics (within interface statistics)
  533. #define WIFI_STATS_IFACE_CONTENTION 0x00000080 // all contention (min, max, avg) statistics (within ac statisctics)
  534. #endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */
  535. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(RTW_VENDOR_EXT_SUPPORT)
  536. extern int rtw_cfgvendor_attach(struct wiphy *wiphy);
  537. extern int rtw_cfgvendor_detach(struct wiphy *wiphy);
  538. extern int rtw_cfgvendor_send_async_event(struct wiphy *wiphy,
  539. struct net_device *dev, int event_id, const void *data, int len);
  540. #if defined(GSCAN_SUPPORT) && 0
  541. extern int rtw_cfgvendor_send_hotlist_event(struct wiphy *wiphy,
  542. struct net_device *dev, void *data, int len, rtw_vendor_event_t event);
  543. #endif
  544. #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(RTW_VENDOR_EXT_SUPPORT) */
  545. #ifdef CONFIG_RTW_CFGVEDNOR_RSSIMONITOR
  546. void rtw_cfgvendor_rssi_monitor_evt(_adapter *padapter);
  547. #endif
  548. #ifdef CONFIG_RTW_CFGVENDOR_RANDOM_MAC_OUI
  549. void rtw_hal_pno_random_gen_mac_addr(PADAPTER adapter);
  550. void rtw_hal_set_hw_mac_addr(PADAPTER adapter, u8 *mac_addr);
  551. #endif
  552. #endif /* _RTW_CFGVENDOR_H_ */