OSDN Git Service

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