wifi: renew patch drivers/net/wireless
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rtl8188eu / include / rtw_mlme.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __RTW_MLME_H_
21 #define __RTW_MLME_H_
22
23
24 #define MAX_BSS_CNT     128
25 //#define   MAX_JOIN_TIMEOUT    2000
26 //#define   MAX_JOIN_TIMEOUT    2500
27 #define   MAX_JOIN_TIMEOUT      6500
28
29 //      Commented by Albert 20101105
30 //      Increase the scanning timeout because of increasing the SURVEY_TO value.
31
32 #define         SCANNING_TIMEOUT        8000
33
34 #ifdef PALTFORM_OS_WINCE
35 #define SCANQUEUE_LIFETIME 12000000 // unit:us
36 #else
37 #define SCANQUEUE_LIFETIME 20000 // 20sec, unit:msec
38 #endif
39
40 #define WIFI_NULL_STATE         0x00000000
41 #define WIFI_ASOC_STATE         0x00000001              // Under Linked state...
42 #define WIFI_REASOC_STATE       0x00000002
43 #define WIFI_SLEEP_STATE        0x00000004
44 #define WIFI_STATION_STATE      0x00000008
45 #define WIFI_AP_STATE                   0x00000010
46 #define WIFI_ADHOC_STATE                0x00000020
47 #define WIFI_ADHOC_MASTER_STATE 0x00000040
48 #define WIFI_UNDER_LINKING      0x00000080
49
50 #define WIFI_UNDER_WPS                  0x00000100
51 //#define       WIFI_UNDER_CMD                  0x00000200
52 //#define       WIFI_UNDER_P2P                  0x00000400
53 #define WIFI_STA_ALIVE_CHK_STATE        0x00000400
54 #define WIFI_SITE_MONITOR                       0x00000800              //to indicate the station is under site surveying
55 #ifdef WDS
56 #define WIFI_WDS                                0x00001000
57 #define WIFI_WDS_RX_BEACON      0x00002000              // already rx WDS AP beacon
58 #endif
59 #ifdef AUTO_CONFIG
60 #define WIFI_AUTOCONF                   0x00004000
61 #define WIFI_AUTOCONF_IND       0x00008000
62 #endif
63
64 /*
65 // ========== P2P Section Start ===============
66 #define WIFI_P2P_LISTEN_STATE           0x00010000
67 #define WIFI_P2P_GROUP_FORMATION_STATE          0x00020000
68 // ========== P2P Section End ===============
69 */
70
71 //#ifdef UNDER_MPTEST
72 #define WIFI_MP_STATE                                                   0x00010000
73 #define WIFI_MP_CTX_BACKGROUND                          0x00020000      // in continous tx background
74 #define WIFI_MP_CTX_ST                                          0x00040000      // in continous tx with single-tone
75 #define WIFI_MP_CTX_BACKGROUND_PENDING  0x00080000      // pending in continous tx background due to out of skb
76 #define WIFI_MP_CTX_CCK_HW                                      0x00100000      // in continous tx
77 #define WIFI_MP_CTX_CCK_CS                                      0x00200000      // in continous tx with carrier suppression
78 #define   WIFI_MP_LPBK_STATE                                    0x00400000
79 //#endif
80
81 //#define _FW_UNDER_CMD         WIFI_UNDER_CMD
82 #define _FW_UNDER_LINKING       WIFI_UNDER_LINKING
83 #define _FW_LINKED                      WIFI_ASOC_STATE
84 #define _FW_UNDER_SURVEY        WIFI_SITE_MONITOR
85
86
87 enum dot11AuthAlgrthmNum {
88  dot11AuthAlgrthm_Open = 0,
89  dot11AuthAlgrthm_Shared,
90  dot11AuthAlgrthm_8021X,
91  dot11AuthAlgrthm_Auto,
92  dot11AuthAlgrthm_WAPI,
93  dot11AuthAlgrthm_MaxNum
94 };
95
96 // Scan type including active and passive scan.
97 typedef enum _RT_SCAN_TYPE
98 {
99         SCAN_PASSIVE,
100         SCAN_ACTIVE,
101         SCAN_MIX,
102 }RT_SCAN_TYPE, *PRT_SCAN_TYPE;
103
104 enum  _BAND
105 {
106         GHZ24_50 = 0,
107         GHZ_50,
108         GHZ_24,
109         GHZ_MAX,
110 };
111
112 #define rtw_band_valid(band) ((band) >= GHZ24_50 && (band) < GHZ_MAX)
113
114 enum DriverInterface {
115         DRIVER_WEXT =  1,
116         DRIVER_CFG80211 = 2
117 };
118
119 enum SCAN_RESULT_TYPE
120 {
121         SCAN_RESULT_P2P_ONLY = 0,               //      Will return all the P2P devices.
122         SCAN_RESULT_ALL = 1,                    //      Will return all the scanned device, include AP.
123         SCAN_RESULT_WFD_TYPE = 2                //      Will just return the correct WFD device.
124                                                                         //      If this device is Miracast sink device, it will just return all the Miracast source devices.
125 };
126
127 /*
128
129 there are several "locks" in mlme_priv,
130 since mlme_priv is a shared resource between many threads,
131 like ISR/Call-Back functions, the OID handlers, and even timer functions.
132
133
134 Each _queue has its own locks, already.
135 Other items are protected by mlme_priv.lock.
136
137 To avoid possible dead lock, any thread trying to modifiying mlme_priv
138 SHALL not lock up more than one locks at a time!
139
140 */
141
142
143 #define traffic_threshold       10
144 #define traffic_scan_period     500
145
146 struct sitesurvey_ctrl {
147         u64     last_tx_pkts;
148         uint    last_rx_pkts;
149         sint    traffic_busy;
150         _timer  sitesurvey_ctrl_timer;
151 };
152
153 typedef struct _RT_LINK_DETECT_T{
154         u32                             NumTxOkInPeriod;
155         u32                             NumRxOkInPeriod;
156         u32                             NumRxUnicastOkInPeriod;
157         BOOLEAN                 bBusyTraffic;
158         BOOLEAN                 bTxBusyTraffic;
159         BOOLEAN                 bRxBusyTraffic;
160         BOOLEAN                 bHigherBusyTraffic; // For interrupt migration purpose.
161         BOOLEAN                 bHigherBusyRxTraffic; // We may disable Tx interrupt according as Rx traffic.
162         BOOLEAN                 bHigherBusyTxTraffic; // We may disable Tx interrupt according as Tx traffic.
163         //u8 TrafficBusyState;
164         u8 TrafficTransitionCount;
165         u32 LowPowerTransitionCount;
166 }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
167
168 struct profile_info {
169         u8      ssidlen;
170         u8      ssid[ WLAN_SSID_MAXLEN ];
171         u8      peermac[ ETH_ALEN ];
172 };
173
174 struct tx_invite_req_info{
175         u8                                      token;
176         u8                                      benable;
177         u8                                      go_ssid[ WLAN_SSID_MAXLEN ];
178         u8                                      ssidlen;
179         u8                                      go_bssid[ ETH_ALEN ];
180         u8                                      peer_macaddr[ ETH_ALEN ];
181         u8                                      operating_ch;   //      This information will be set by using the p2p_set op_ch=x
182         u8                                      peer_ch;                //      The listen channel for peer P2P device
183
184 };
185
186 struct tx_invite_resp_info{
187         u8                                      token;  //      Used to record the dialog token of p2p invitation request frame.
188 };
189
190 #ifdef CONFIG_WFD
191
192 struct wifi_display_info{
193         u16                                                     wfd_enable;                     //      Eanble/Disable the WFD function.
194         u16                                                     rtsp_ctrlport;          //      TCP port number at which the this WFD device listens for RTSP messages
195         u16                                                     peer_rtsp_ctrlport;     //      TCP port number at which the peer WFD device listens for RTSP messages
196                                                                                                         //      This filed should be filled when receiving the gropu negotiation request
197
198         u8                                                      peer_session_avail;     //      WFD session is available or not for the peer wfd device.
199                                                                                                         //      This variable will be set when sending the provisioning discovery request to peer WFD device.
200                                                                                                         //      And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command.
201         u8                                                      ip_address[4];
202         u8                                                      peer_ip_address[4];
203         u8                                                      wfd_pc;                         //      WFD preferred connection
204                                                                                                         //      0 -> Prefer to use the P2P for WFD connection on peer side.
205                                                                                                         //      1 -> Prefer to use the TDLS for WFD connection on peer side.
206                                                                                         
207         u8                                                      wfd_device_type;        //      WFD Device Type
208                                                                                                         //      0 -> WFD Source Device
209                                                                                                         //      1 -> WFD Primary Sink Device
210         enum    SCAN_RESULT_TYPE        scan_result_type;       //      Used when P2P is enable. This parameter will impact the scan result.
211
212 };
213 #endif //CONFIG_WFD
214
215 struct tx_provdisc_req_info{
216         u16                                     wps_config_method_request;      //      Used when sending the provisioning request frame
217         u16                                     peer_channel_num[2];            //      The channel number which the receiver stands.
218         NDIS_802_11_SSID        ssid;
219         u8                                      peerDevAddr[ ETH_ALEN ];                //      Peer device address
220         u8                                      peerIFAddr[ ETH_ALEN ];         //      Peer interface address
221         u8                                      benable;                                        //      This provision discovery request frame is trigger to send or not
222 };
223
224 struct rx_provdisc_req_info{    //When peer device issue prov_disc_req first, we should store the following informations
225         u8                                      peerDevAddr[ ETH_ALEN ];                //      Peer device address
226         u8                                      strconfig_method_desc_of_prov_disc_req[4];      //      description for the config method located in the provisioning discovery request frame.  
227                                                                                                                                         //      The UI must know this information to know which config method the remote p2p device is requiring.
228 };
229
230 struct tx_nego_req_info{
231         u16                                     peer_channel_num[2];            //      The channel number which the receiver stands.
232         u8                                      peerDevAddr[ ETH_ALEN ];                //      Peer device address
233         u8                                      benable;                                        //      This negoitation request frame is trigger to send or not
234 };
235
236 struct group_id_info{
237         u8                                      go_device_addr[ ETH_ALEN ];     //      The GO's device address of this P2P group
238         u8                                      ssid[ WLAN_SSID_MAXLEN ];       //      The SSID of this P2P group
239 };
240
241 struct scan_limit_info{
242         u8                                      scan_op_ch_only;                        //      When this flag is set, the driver should just scan the operation channel
243 #ifndef CONFIG_P2P_OP_CHK_SOCIAL_CH
244         u8                                      operation_ch[2];                                //      Store the operation channel of invitation request frame
245 #else
246         u8                                      operation_ch[5];                                //      Store additional channel 1,6,11  for Android 4.2 IOT & Nexus 4
247 #endif //CONFIG_P2P_OP_CHK_SOCIAL_CH
248 };
249
250 #ifdef CONFIG_IOCTL_CFG80211
251 struct cfg80211_wifidirect_info{
252         _timer                                  remain_on_ch_timer;
253         u8                                              restore_channel;
254         struct ieee80211_channel        remain_on_ch_channel;
255         enum nl80211_channel_type       remain_on_ch_type;
256         u64                                             remain_on_ch_cookie;
257         bool is_ro_ch;
258         u32 last_ro_ch_time; /* this will be updated at the beginning and end of ro_ch */
259 };
260 #endif //CONFIG_IOCTL_CFG80211
261
262 struct wifidirect_info{
263         _adapter*                               padapter;
264         _timer                                  find_phase_timer;
265         _timer                                  restore_p2p_state_timer;
266         
267         //      Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer.
268         _timer                                  pre_tx_scan_timer;
269         _timer                                  reset_ch_sitesurvey;
270         _timer                                  reset_ch_sitesurvey2;   //      Just for resetting the scan limit function by using p2p nego
271 #ifdef CONFIG_CONCURRENT_MODE
272         //      Used to switch the channel between legacy AP and listen state.
273         _timer                                  ap_p2p_switch_timer;
274 #endif
275         struct tx_provdisc_req_info     tx_prov_disc_info;
276         struct rx_provdisc_req_info rx_prov_disc_info;
277         struct tx_invite_req_info       invitereq_info;
278         struct profile_info                     profileinfo[ P2P_MAX_PERSISTENT_GROUP_NUM ];    //      Store the profile information of persistent group
279         struct tx_invite_resp_info      inviteresp_info;
280         struct tx_nego_req_info nego_req_info;
281         struct group_id_info            groupid_info;   //      Store the group id information when doing the group negotiation handshake.
282         struct scan_limit_info          rx_invitereq_info;      //      Used for get the limit scan channel from the Invitation procedure
283         struct scan_limit_info          p2p_info;               //      Used for get the limit scan channel from the P2P negotiation handshake
284 #ifdef CONFIG_WFD
285         struct wifi_display_info                *wfd_info;
286 #endif  
287         enum P2P_ROLE                   role;
288         enum P2P_STATE                  pre_p2p_state;
289         enum P2P_STATE                  p2p_state;
290         u8                                              device_addr[ETH_ALEN];  //      The device address should be the mac address of this device.
291         u8                                              interface_addr[ETH_ALEN];
292         u8                                              social_chan[4];
293         u8                                              listen_channel;
294         u8                                              operating_channel;
295         u8                                              listen_dwell;           //      This value should be between 1 and 3
296         u8                                              support_rate[8];
297         u8                                              p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
298         u8                                              intent;         //      should only include the intent value.
299         u8                                              p2p_peer_interface_addr[ ETH_ALEN ];
300         u8                                              p2p_peer_device_addr[ ETH_ALEN ];
301         u8                                              peer_intent;    //      Included the intent value and tie breaker value.
302         u8                                              device_name[ WPS_MAX_DEVICE_NAME_LEN ]; //      Device name for displaying on searching device screen
303         u8                                              device_name_len;
304         u8                                              profileindex;   //      Used to point to the index of profileinfo array
305         u8                                              peer_operating_ch;
306         u8                                              find_phase_state_exchange_cnt;
307         u16                                             device_password_id_for_nego;    //      The device password ID for group negotation
308         u8                                              negotiation_dialog_token;
309         u8                                              nego_ssid[ WLAN_SSID_MAXLEN ];  //      SSID information for group negotitation
310         u8                                              nego_ssidlen;
311         u8                                              p2p_group_ssid[WLAN_SSID_MAXLEN];
312         u8                                              p2p_group_ssid_len;
313         u8                                              persistent_supported;           //      Flag to know the persistent function should be supported or not.
314                                                                                                                 //      In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI.
315                                                                                                                 //      0: disable
316                                                                                                                 //      1: enable
317         u8                                              session_available;                      //      Flag to set the WFD session available to enable or disable "by Sigma"
318                                                                                                                 //      In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI.
319                                                                                                                 //      0: disable
320                                                                                                                 //      1: enable
321
322         u8                                              wfd_tdls_enable;                        //      Flag to enable or disable the TDLS by WFD Sigma
323                                                                                                                 //      0: disable
324                                                                                                                 //      1: enable
325         u8                                              wfd_tdls_weaksec;                       //      Flag to enable or disable the weak security function for TDLS by WFD Sigma
326                                                                                                                 //      0: disable
327                                                                                                                 //      In this case, the driver can't issue the tdsl setup request frame.
328                                                                                                                 //      1: enable
329                                                                                                                 //      In this case, the driver can issue the tdls setup request frame
330                                                                                                                 //      even the current security is weak security.
331
332         enum    P2P_WPSINFO             ui_got_wps_info;                        //      This field will store the WPS value (PIN value or PBC) that UI had got from the user.
333         u16                                             supported_wps_cm;                       //      This field describes the WPS config method which this driver supported.
334                                                                                                                 //      The value should be the combination of config method defined in page104 of WPS v2.0 spec.       
335         u8                                              external_uuid;                          // UUID flag
336         u8                                              uuid[16];                                       // UUID
337         uint                                            channel_list_attr_len;          //      This field will contain the length of body of P2P Channel List attribute of group negotitation response frame.
338         u8                                              channel_list_attr[100];         //      This field will contain the body of P2P Channel List attribute of group negotitation response frame.
339                                                                                                                 //      We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame.
340         u8                                              driver_interface;                       //      Indicate DRIVER_WEXT or DRIVER_CFG80211
341
342 #ifdef CONFIG_CONCURRENT_MODE
343         u16                                             ext_listen_interval;    //      The interval to be available with legacy AP (ms)
344         u16                                             ext_listen_period;      //      The time period to be available for P2P listen state (ms)
345 #endif
346 #ifdef CONFIG_P2P_PS
347         enum P2P_PS_MODE                p2p_ps_mode; // indicate p2p ps mode
348         enum P2P_PS_STATE               p2p_ps_state; // indicate p2p ps state
349         u8                                              noa_index; // Identifies and instance of Notice of Absence timing.
350         u8                                              ctwindow; // Client traffic window. A period of time in TU after TBTT.
351         u8                                              opp_ps; // opportunistic power save.
352         u8                                              noa_num; // number of NoA descriptor in P2P IE.
353         u8                                              noa_count[P2P_MAX_NOA_NUM]; // Count for owner, Type of client.
354         u32                                             noa_duration[P2P_MAX_NOA_NUM]; // Max duration for owner, preferred or min acceptable duration for client.
355         u32                                             noa_interval[P2P_MAX_NOA_NUM]; // Length of interval for owner, preferred or max acceptable interval of client.
356         u32                                             noa_start_time[P2P_MAX_NOA_NUM]; // schedule expressed in terms of the lower 4 bytes of the TSF timer.
357 #endif // CONFIG_P2P_PS
358 };
359
360 struct tdls_ss_record{  //signal strength record
361         u8              macaddr[ETH_ALEN];
362         u8              RxPWDBAll;
363         u8              is_tdls_sta;    // _TRUE: direct link sta, _FALSE: else
364 };
365
366 struct tdls_info{
367         u8                                      ap_prohibited;
368         u8                                      link_established;
369         u8                                      sta_cnt;
370         u8                                      sta_maximum;    // 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else;
371         struct tdls_ss_record   ss_record;
372         u8                                      ch_sensing;
373         u8                                      cur_channel;
374         u8                                      candidate_ch;
375         u8                                      collect_pkt_num[MAX_CHANNEL_NUM];
376         _lock                           cmd_lock;
377         _lock                           hdl_lock;
378         u8                                      watchdog_count;
379         u8                                      dev_discovered;         //WFD_TDLS: for sigma test
380         u8                                      tdls_enable;
381         u8                                      external_setup; // _TRUE: setup is handled by wpa_supplicant
382 #ifdef CONFIG_WFD
383         struct wifi_display_info                *wfd_info;
384 #endif          
385 };
386
387 struct tdls_txmgmt {
388         u8 peer[ETH_ALEN];
389         u8 action_code;
390         u8 dialog_token;
391         u16 status_code;
392         u8 *buf;
393         size_t len;
394         u8 external_support;
395 };
396
397 /* used for mlme_priv.roam_flags */
398 enum {
399         RTW_ROAM_ON_EXPIRED = BIT0,
400         RTW_ROAM_ON_RESUME = BIT1,
401         RTW_ROAM_ACTIVE = BIT2,
402 };
403
404 struct mlme_priv {
405
406         _lock   lock;
407         sint    fw_state;       //shall we protect this variable? maybe not necessarily...
408         u8 bScanInProcess;
409         u8      to_join; //flag
410         #ifdef CONFIG_LAYER2_ROAMING
411         u8 to_roam; /* roaming trying times */
412         struct wlan_network *roam_network; /* the target of active roam */
413         u8 roam_flags;
414         u8 roam_rssi_diff_th; /* rssi difference threshold for active scan candidate selection */
415         u32 roam_scan_int_ms; /* scan interval for active roam */
416         u32 roam_scanr_exp_ms; /* scan result expire time in ms  for roam */
417         u8 roam_tgt_addr[ETH_ALEN]; /* request to roam to speicific target without other consideration */
418         #endif
419
420         u8      *nic_hdl;
421
422         u8      not_indic_disco;
423         _list           *pscanned;
424         _queue  free_bss_pool;
425         _queue  scanned_queue;
426         u8              *free_bss_buf;
427         u32     num_of_scanned;
428
429         NDIS_802_11_SSID        assoc_ssid;
430         u8      assoc_bssid[6];
431
432         struct wlan_network     cur_network;
433         struct wlan_network *cur_network_scanned;
434 #ifdef CONFIG_ARP_KEEP_ALIVE
435         // for arp offload keep alive
436         u8      gw_mac_addr[6];
437         u8      gw_ip[4];
438 #endif
439
440         //uint wireless_mode; no used, remove it
441
442         u32     auto_scan_int_ms;
443
444         _timer assoc_timer;
445
446         uint assoc_by_bssid;
447         uint assoc_by_rssi;
448
449         _timer scan_to_timer; // driver itself handles scan_timeout status.
450         u32 scan_start_time; // used to evaluate the time spent in scanning
451
452         #ifdef CONFIG_SET_SCAN_DENY_TIMER
453         _timer set_scan_deny_timer;
454         ATOMIC_T set_scan_deny; //0: allowed, 1: deny
455         #endif
456
457         struct qos_priv qospriv;
458
459 #ifdef CONFIG_80211N_HT
460
461         /* Number of non-HT AP/stations */
462         int num_sta_no_ht;
463
464         /* Number of HT AP/stations 20 MHz */
465         //int num_sta_ht_20mhz; 
466
467
468         int num_FortyMHzIntolerant;
469
470         struct ht_priv  htpriv;
471
472 #endif
473
474 #ifdef CONFIG_80211AC_VHT
475         struct vht_priv vhtpriv;
476 #endif
477 #ifdef CONFIG_BEAMFORMING
478         struct beamforming_info beamforming_info;
479 #endif
480
481 #ifdef CONFIG_DFS
482         u8      handle_dfs;
483 #endif //CONFIG_DFS
484
485         RT_LINK_DETECT_T        LinkDetectInfo;
486         _timer  dynamic_chk_timer; //dynamic/periodic check timer
487
488         u8      acm_mask; // for wmm acm mask
489         u8      ChannelPlan;
490         RT_SCAN_TYPE    scan_mode; // active: 1, passive: 0
491
492         u8 *wps_probe_req_ie;
493         u32 wps_probe_req_ie_len;
494
495 #if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
496         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
497          * in 802.11g BSS) */
498         int num_sta_non_erp;
499
500         /* Number of associated stations that do not support Short Slot Time */
501         int num_sta_no_short_slot_time;
502
503         /* Number of associated stations that do not support Short Preamble */
504         int num_sta_no_short_preamble;
505
506         int olbc; /* Overlapping Legacy BSS Condition */
507
508         /* Number of HT associated stations that do not support greenfield */
509         int num_sta_ht_no_gf;
510
511         /* Number of associated non-HT stations */
512         //int num_sta_no_ht;
513
514         /* Number of HT associated stations 20 MHz */
515         int num_sta_ht_20mhz;
516
517         /* Overlapping BSS information */
518         int olbc_ht;
519         
520 #ifdef CONFIG_80211N_HT
521         u16 ht_op_mode;
522 #endif /* CONFIG_80211N_HT */   
523
524         u8 *assoc_req;
525         u32 assoc_req_len;
526         u8 *assoc_rsp;
527         u32 assoc_rsp_len;
528
529         u8 *wps_beacon_ie;      
530         //u8 *wps_probe_req_ie;
531         u8 *wps_probe_resp_ie;
532         u8 *wps_assoc_resp_ie; // for CONFIG_IOCTL_CFG80211, this IE could include p2p ie / wfd ie
533
534         u32 wps_beacon_ie_len;
535         //u32 wps_probe_req_ie_len;
536         u32 wps_probe_resp_ie_len;
537         u32 wps_assoc_resp_ie_len; // for CONFIG_IOCTL_CFG80211, this IE len could include p2p ie / wfd ie
538         
539         u8 *p2p_beacon_ie;
540         u8 *p2p_probe_req_ie;
541         u8 *p2p_probe_resp_ie;  
542         u8 *p2p_go_probe_resp_ie; //for GO      
543         u8 *p2p_assoc_req_ie;
544
545         u32 p2p_beacon_ie_len;
546         u32 p2p_probe_req_ie_len;
547         u32 p2p_probe_resp_ie_len;
548         u32 p2p_go_probe_resp_ie_len; //for GO
549         u32 p2p_assoc_req_ie_len;
550 /*
551 #if defined(CONFIG_P2P) && defined(CONFIG_IOCTL_CFG80211)
552         //u8 *wps_p2p_beacon_ie;
553         u8 *p2p_beacon_ie;
554         u8 *wps_p2p_probe_resp_ie;
555         u8 *wps_p2p_assoc_resp_ie;
556         //u32 wps_p2p_beacon_ie_len;
557         u32 p2p_beacon_ie_len;
558         u32 wps_p2p_probe_resp_ie_len;
559         u32 wps_p2p_assoc_resp_ie_len;
560 #endif
561 */
562         
563         _lock   bcn_update_lock;
564         u8              update_bcn;
565         
566         
567 #endif //#if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
568
569 #if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
570         
571         u8 *wfd_beacon_ie;
572         u8 *wfd_probe_req_ie;
573         u8 *wfd_probe_resp_ie;  
574         u8 *wfd_go_probe_resp_ie; //for GO      
575         u8 *wfd_assoc_req_ie;
576
577         u32 wfd_beacon_ie_len;
578         u32 wfd_probe_req_ie_len;
579         u32 wfd_probe_resp_ie_len;
580         u32 wfd_go_probe_resp_ie_len; //for GO
581         u32 wfd_assoc_req_ie_len;
582
583 #endif
584
585 #ifdef RTK_DMP_PLATFORM
586         // DMP kobject_hotplug function  signal need in passive level
587         _workitem       Linkup_workitem;
588         _workitem       Linkdown_workitem;
589 #endif
590
591 #ifdef CONFIG_INTEL_WIDI
592         int     widi_state;
593         int     listen_state;
594         _timer  listen_timer;
595         ATOMIC_T        rx_probe_rsp; // 1:receive probe respone from RDS source.
596         u8      *l2sdTaBuffer;
597         u8      channel_idx;
598         u8      group_cnt;      //In WiDi 3.5, they specified another scan algo. for WFD/RDS co-existed
599         u8      sa_ext[L2SDTA_SERVICE_VE_LEN];
600
601         u8      widi_enable;
602         /**
603          * For WiDi 4; upper layer would set
604          * p2p_primary_device_type_category_id
605          * p2p_primary_device_type_sub_category_id
606          * p2p_secondary_device_type_category_id
607          * p2p_secondary_device_type_sub_category_id
608          */
609         u16     p2p_pdt_cid;
610         u16     p2p_pdt_scid;
611         u8      num_p2p_sdt;
612         u16     p2p_sdt_cid[MAX_NUM_P2P_SDT];
613         u16     p2p_sdt_scid[MAX_NUM_P2P_SDT];
614         u8      p2p_reject_disable;     //When starting NL80211 wpa_supplicant/hostapd, it will call netdev_close
615                                                         //such that it will cause p2p disabled. Use this flag to reject.
616 #endif // CONFIG_INTEL_WIDI
617
618 #ifdef CONFIG_CONCURRENT_MODE
619         u8      scanning_via_buddy_intf;
620 #endif
621
622 };
623
624 #define rtw_mlme_set_auto_scan_int(adapter, ms) \
625         do { \
626                 adapter->mlmepriv.auto_scan_int_ms = ms; \
627         while (0)
628
629 void rtw_mlme_reset_auto_scan_int(_adapter *adapter);
630
631 #ifdef CONFIG_AP_MODE
632
633 struct hostapd_priv
634 {
635         _adapter *padapter;
636
637 #ifdef CONFIG_HOSTAPD_MLME
638         struct net_device *pmgnt_netdev;
639         struct usb_anchor anchored;
640 #endif  
641         
642 };
643
644 extern int hostapd_mode_init(_adapter *padapter);
645 extern void hostapd_mode_unload(_adapter *padapter);
646 #endif
647
648
649 extern void rtw_joinbss_event_prehandle(_adapter *adapter, u8 *pbuf);
650 extern void rtw_survey_event_callback(_adapter *adapter, u8 *pbuf);
651 extern void rtw_surveydone_event_callback(_adapter *adapter, u8 *pbuf);
652 extern void rtw_joinbss_event_callback(_adapter *adapter, u8 *pbuf);
653 extern void rtw_stassoc_event_callback(_adapter *adapter, u8 *pbuf);
654 extern void rtw_stadel_event_callback(_adapter *adapter, u8 *pbuf);
655 extern void rtw_atimdone_event_callback(_adapter *adapter, u8 *pbuf);
656 extern void rtw_cpwm_event_callback(_adapter *adapter, u8 *pbuf);
657
658 extern void rtw_join_timeout_handler(RTW_TIMER_HDL_ARGS);
659 extern void _rtw_scan_timeout_handler(RTW_TIMER_HDL_ARGS);
660
661 thread_return event_thread(thread_context context);
662
663 extern void rtw_free_network_queue(_adapter *adapter,u8 isfreeall);
664 extern int rtw_init_mlme_priv(_adapter *adapter);// (struct mlme_priv *pmlmepriv);
665
666 extern void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv);
667
668
669 extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
670 extern sint rtw_set_key(_adapter *adapter,struct security_priv *psecuritypriv,sint keyid, u8 set_tx, bool enqueue);
671 extern sint rtw_set_auth(_adapter *adapter,struct security_priv *psecuritypriv);
672
673 __inline static u8 *get_bssid(struct mlme_priv *pmlmepriv)
674 {       //if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid
675         // if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address
676         return pmlmepriv->cur_network.network.MacAddress;
677 }
678
679 __inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
680 {
681         if (pmlmepriv->fw_state & state)
682                 return _TRUE;
683
684         return _FALSE;
685 }
686
687 __inline static sint get_fwstate(struct mlme_priv *pmlmepriv)
688 {
689         return pmlmepriv->fw_state;
690 }
691
692 /*
693  * No Limit on the calling context,
694  * therefore set it to be the critical section...
695  *
696  * ### NOTE:#### (!!!!)
697  * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
698  */
699 __inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
700 {
701         pmlmepriv->fw_state |= state;
702         //FOR HW integration
703         if(_FW_UNDER_SURVEY==state){
704                 pmlmepriv->bScanInProcess = _TRUE;
705         }
706 }
707
708 __inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
709 {
710         pmlmepriv->fw_state &= ~state;
711         //FOR HW integration
712         if(_FW_UNDER_SURVEY==state){
713                 pmlmepriv->bScanInProcess = _FALSE;
714         }
715 }
716
717 /*
718  * No Limit on the calling context,
719  * therefore set it to be the critical section...
720  */
721 __inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
722 {
723         _irqL irqL;
724
725         _enter_critical_bh(&pmlmepriv->lock, &irqL);
726         if (check_fwstate(pmlmepriv, state) == _TRUE)
727                 pmlmepriv->fw_state ^= state;
728         _exit_critical_bh(&pmlmepriv->lock, &irqL);
729 }
730
731 __inline static void clr_fwstate_ex(struct mlme_priv *pmlmepriv, sint state)
732 {
733         _irqL irqL;
734
735         _enter_critical_bh(&pmlmepriv->lock, &irqL);
736         _clr_fwstate_(pmlmepriv, state);
737         _exit_critical_bh(&pmlmepriv->lock, &irqL);
738 }
739
740 __inline static void up_scanned_network(struct mlme_priv *pmlmepriv)
741 {
742         _irqL irqL;
743
744         _enter_critical_bh(&pmlmepriv->lock, &irqL);
745         pmlmepriv->num_of_scanned++;
746         _exit_critical_bh(&pmlmepriv->lock, &irqL);
747 }
748
749 #ifdef CONFIG_CONCURRENT_MODE
750 sint rtw_buddy_adapter_up(_adapter *padapter);
751 sint check_buddy_fwstate(_adapter *padapter, sint state);
752 u8 rtw_get_buddy_bBusyTraffic(_adapter *padapter);
753 #endif //CONFIG_CONCURRENT_MODE
754
755 __inline static void down_scanned_network(struct mlme_priv *pmlmepriv)
756 {
757         _irqL irqL;
758
759         _enter_critical_bh(&pmlmepriv->lock, &irqL);
760         pmlmepriv->num_of_scanned--;
761         _exit_critical_bh(&pmlmepriv->lock, &irqL);
762 }
763
764 __inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
765 {
766         _irqL irqL;
767
768         _enter_critical_bh(&pmlmepriv->lock, &irqL);
769         pmlmepriv->num_of_scanned = val;
770         _exit_critical_bh(&pmlmepriv->lock, &irqL);
771 }
772
773 extern u16 rtw_get_capability(WLAN_BSSID_EX *bss);
774 extern void rtw_update_scanned_network(_adapter *adapter, WLAN_BSSID_EX *target);
775 extern void rtw_disconnect_hdl_under_linked(_adapter* adapter, struct sta_info *psta, u8 free_assoc);
776 extern void rtw_generate_random_ibss(u8 *pibss);
777 extern struct wlan_network* rtw_find_network(_queue *scanned_queue, u8 *addr);
778 extern struct wlan_network* rtw_get_oldest_wlan_network(_queue *scanned_queue);
779 struct wlan_network *_rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
780 struct wlan_network *rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
781
782 extern void rtw_free_assoc_resources(_adapter* adapter, int lock_scanned_queue);
783 extern void rtw_indicate_disconnect(_adapter* adapter);
784 extern void rtw_indicate_connect(_adapter* adapter);
785 void rtw_indicate_scan_done( _adapter *padapter, bool aborted);
786 void rtw_scan_abort(_adapter *adapter);
787
788 extern int rtw_restruct_sec_ie(_adapter *adapter,u8 *in_ie,u8 *out_ie,uint in_len);
789 extern int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len);
790 extern void rtw_init_registrypriv_dev_network(_adapter *adapter);
791
792 extern void rtw_update_registrypriv_dev_network(_adapter *adapter);
793
794 extern void rtw_get_encrypt_decrypt_from_registrypriv(_adapter *adapter);
795
796 extern void _rtw_join_timeout_handler(_adapter *adapter);
797 extern void rtw_scan_timeout_handler(_adapter *adapter);
798
799 extern void rtw_dynamic_check_timer_handlder(_adapter *adapter);
800 #ifdef CONFIG_SET_SCAN_DENY_TIMER
801 bool rtw_is_scan_deny(_adapter *adapter);
802 void rtw_clear_scan_deny(_adapter *adapter);
803 void rtw_set_scan_deny_timer_hdl(_adapter *adapter);
804 void rtw_set_scan_deny(_adapter *adapter, u32 ms);
805 #else
806 #define rtw_is_scan_deny(adapter) _FALSE
807 #define rtw_clear_scan_deny(adapter) do {} while (0)
808 #define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
809 #define rtw_set_scan_deny(adapter, ms) do {} while (0)
810 #endif
811
812
813 extern int _rtw_init_mlme_priv(_adapter *padapter);
814
815 void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
816
817 extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
818
819 extern int _rtw_enqueue_network(_queue *queue, struct wlan_network *pnetwork);
820
821 //extern struct wlan_network* _rtw_dequeue_network(_queue *queue);
822
823 extern struct wlan_network* _rtw_alloc_network(struct mlme_priv *pmlmepriv);
824
825
826 extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
827 extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
828
829
830 extern struct wlan_network* _rtw_find_network(_queue *scanned_queue, u8 *addr);
831
832 extern void _rtw_free_network_queue(_adapter* padapter, u8 isfreeall);
833
834 extern sint rtw_if_up(_adapter *padapter);
835
836 sint rtw_linked_check(_adapter *padapter);
837
838 u8 *rtw_get_capability_from_ie(u8 *ie);
839 u8 *rtw_get_timestampe_from_ie(u8 *ie);
840 u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
841
842
843 void rtw_joinbss_reset(_adapter *padapter);
844
845 #ifdef CONFIG_80211N_HT
846 void    rtw_ht_use_default_setting(_adapter *padapter);
847 void rtw_build_wmm_ie_ht(_adapter *padapter, u8 *out_ie, uint *pout_len);
848 unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel);
849 void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel);
850 void rtw_issue_addbareq_cmd(_adapter *padapter, struct xmit_frame *pxmitframe);
851 void rtw_append_exented_cap(_adapter *padapter, u8 *out_ie, uint *pout_len);
852 #endif
853
854 int rtw_is_same_ibss(_adapter *adapter, struct wlan_network *pnetwork);
855 int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst, u8 feature);
856
857 #ifdef CONFIG_LAYER2_ROAMING
858 #define rtw_roam_flags(adapter) ((adapter)->mlmepriv.roam_flags)
859 #define rtw_chk_roam_flags(adapter, flags) ((adapter)->mlmepriv.roam_flags & flags)
860 #define rtw_clr_roam_flags(adapter, flags) \
861         do { \
862                 ((adapter)->mlmepriv.roam_flags &= ~flags); \
863         } while (0)
864
865 #define rtw_set_roam_flags(adapter, flags) \
866         do { \
867                 ((adapter)->mlmepriv.roam_flags |= flags); \
868         } while (0)
869
870 #define rtw_assign_roam_flags(adapter, flags) \
871         do { \
872                 ((adapter)->mlmepriv.roam_flags = flags); \
873         } while (0)
874
875 void _rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
876 void rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
877 void rtw_set_to_roam(_adapter *adapter, u8 to_roam);
878 u8 rtw_dec_to_roam(_adapter *adapter);
879 u8 rtw_to_roam(_adapter *adapter);
880 int rtw_select_roaming_candidate(struct mlme_priv *pmlmepriv);
881 #else
882 #define rtw_roam_flags(adapter) 0
883 #define rtw_chk_roam_flags(adapter, flags) 0
884 #define rtw_clr_roam_flags(adapter, flags) do {} while (0)
885 #define rtw_set_roam_flags(adapter, flags) do {} while (0)
886 #define rtw_assign_roam_flags(adapter, flags) do {} while (0)
887 #define _rtw_roaming(adapter, tgt_network) do {} while(0)
888 #define rtw_roaming(adapter, tgt_network) do {} while(0)
889 #define rtw_set_to_roam(adapter, to_roam) do {} while(0)
890 #define rtw_dec_to_roam(adapter) 0
891 #define rtw_to_roam(adapter) 0
892 #define rtw_select_roaming_candidate(mlme) _FAIL
893 #endif /* CONFIG_LAYER2_ROAMING */
894
895 void rtw_sta_media_status_rpt(_adapter *adapter,struct sta_info *psta, u32 mstatus);
896
897 #ifdef CONFIG_INTEL_PROXIM
898 void rtw_proxim_enable(_adapter *padapter);
899 void rtw_proxim_disable(_adapter *padapter);
900 void rtw_proxim_send_packet(_adapter *padapter,u8 *pbuf,u16 len,u8 hw_rate);
901 #endif //CONFIG_INTEL_PROXIM
902 #endif //__RTL871X_MLME_H_
903