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