net: wireless: rockchip_wlan: add rtl8188eu support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / 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 #ifdef CONFIG_SCAN_BACKOP
34 #define CONC_SCANNING_TIMEOUT_SINGLE_BAND 10000
35 #define CONC_SCANNING_TIMEOUT_DUAL_BAND 15000
36 #endif
37
38 #ifdef PALTFORM_OS_WINCE
39 #define SCANQUEUE_LIFETIME 12000000 // unit:us
40 #else
41 #define SCANQUEUE_LIFETIME 20000 // 20sec, unit:msec
42 #endif
43
44 #define WIFI_NULL_STATE                                 0x00000000
45 #define WIFI_ASOC_STATE                                 0x00000001 /* Linked */
46 #define WIFI_REASOC_STATE                               0x00000002
47 #define WIFI_SLEEP_STATE                                0x00000004
48 #define WIFI_STATION_STATE                              0x00000008
49 #define WIFI_AP_STATE                                   0x00000010
50 #define WIFI_ADHOC_STATE                                0x00000020
51 #define WIFI_ADHOC_MASTER_STATE                 0x00000040
52 #define WIFI_UNDER_LINKING                              0x00000080
53 #define WIFI_UNDER_WPS                                  0x00000100
54 /*#define WIFI_UNDEFINED_STATE                  0x00000200*/
55 #define WIFI_STA_ALIVE_CHK_STATE                0x00000400
56 #define WIFI_SITE_MONITOR                               0x00000800 /* under site surveying */
57 #define WIFI_WDS                                                0x00001000
58 #define WIFI_WDS_RX_BEACON                              0x00002000 /* already rx WDS AP beacon */
59 #define WIFI_AUTOCONF                                   0x00004000
60 #define WIFI_AUTOCONF_IND                               0x00008000
61 #define WIFI_MP_STATE                                   0x00010000
62 #define WIFI_MP_CTX_BACKGROUND                  0x00020000 /* in continuous tx background */
63 #define WIFI_MP_CTX_ST                                  0x00040000 /* in continuous tx with single-tone */
64 #define WIFI_MP_CTX_BACKGROUND_PENDING  0x00080000 /* pending in continuous tx background due to out of skb */
65 #define WIFI_MP_CTX_CCK_HW                              0x00100000 /* in continuous tx */
66 #define WIFI_MP_CTX_CCK_CS                              0x00200000 /* in continuous tx with carrier suppression */
67 #define WIFI_MP_LPBK_STATE                              0x00400000
68 #define WIFI_OP_CH_SWITCHING                    0x00800000
69 /*#define WIFI_UNDEFINED_STATE                  0x01000000*/
70 /*#define WIFI_UNDEFINED_STATE                  0x02000000*/
71 /*#define WIFI_UNDEFINED_STATE                  0x04000000*/
72 /*#define WIFI_UNDEFINED_STATE                  0x08000000*/
73 /*#define WIFI_UNDEFINED_STATE                  0x10000000*/
74 /*#define WIFI_UNDEFINED_STATE                  0x20000000*/
75 /*#define WIFI_UNDEFINED_STATE                  0x40000000*/
76 #define WIFI_MONITOR_STATE                              0x80000000
77
78 #define MIRACAST_DISABLED       0
79 #define MIRACAST_SOURCE         BIT0
80 #define MIRACAST_SINK           BIT1
81
82 #define MIRACAST_MODE_REVERSE(mode) \
83         ((((mode) & MIRACAST_SOURCE) ? MIRACAST_SINK : 0) | (((mode) & MIRACAST_SINK) ? MIRACAST_SOURCE : 0))
84
85 bool is_miracast_enabled(_adapter *adapter);
86 bool rtw_chk_miracast_mode(_adapter *adapter, u8 mode);
87 const char *get_miracast_mode_str(int mode);
88 void rtw_wfd_st_switch(struct sta_info *sta, bool on);
89
90 #define MLME_STATE(adapter) get_fwstate(&((adapter)->mlmepriv))
91
92 #define MLME_IS_STA(adapter) (MLME_STATE((adapter)) & WIFI_STATION_STATE)
93 #define MLME_IS_AP(adapter) (MLME_STATE((adapter)) & WIFI_AP_STATE)
94 #define MLME_IS_ADHOC(adapter) (MLME_STATE((adapter)) & WIFI_ADHOC_STATE)
95 #define MLME_IS_ADHOC_MASTER(adapter) (MLME_STATE((adapter)) & WIFI_ADHOC_MASTER_STATE)
96 #define MLME_IS_MONITOR(adapter) (MLME_STATE((adapter)) & WIFI_MONITOR_STATE)
97 #define MLME_IS_MP(adapter) (MLME_STATE((adapter)) & WIFI_MP_STATE)
98 #ifdef CONFIG_P2P
99 #define MLME_IS_GC(adapter) rtw_p2p_chk_role(&(adapter)->wdinfo, P2P_ROLE_CLIENT)
100 #define MLME_IS_GO(adapter) rtw_p2p_chk_role(&(adapter)->wdinfo, P2P_ROLE_GO)
101 #else /* !CONFIG_P2P */
102 #define MLME_IS_GC(adapter) 0
103 #define MLME_IS_GO(adapter) 0
104 #endif /* !CONFIG_P2P */
105 #define MLME_IS_MSRC(adapter) rtw_chk_miracast_mode((adapter), MIRACAST_SOURCE)
106 #define MLME_IS_MSINK(adapter) rtw_chk_miracast_mode((adapter), MIRACAST_SINK)
107
108 #define MLME_STATE_FMT "%s%s%s%s%s%s%s%s%s%s%s%s%s%s"
109 #define MLME_STATE_ARG(adapter) \
110         MLME_IS_STA((adapter)) ? (MLME_IS_GC((adapter)) ? " GC" : " STA") : "", \
111         MLME_IS_AP((adapter)) ? (MLME_IS_GO((adapter)) ? " GO" : " AP") : "", \
112         MLME_IS_ADHOC((adapter)) ? " ADHOC" : "", \
113         MLME_IS_ADHOC_MASTER((adapter)) ? " ADHOC_M" : "", \
114         MLME_IS_MONITOR((adapter)) ? " MONITOR" : "", \
115         MLME_IS_MP((adapter)) ? " MP" : "", \
116         MLME_IS_MSRC((adapter)) ? " MSRC" : "", \
117         MLME_IS_MSINK((adapter)) ? " MSINK" : "", \
118         (MLME_STATE((adapter)) & WIFI_SITE_MONITOR) ? " SCAN" : "", \
119         (MLME_STATE((adapter)) & WIFI_UNDER_LINKING) ? " LINKING" : "", \
120         (MLME_STATE((adapter)) & WIFI_ASOC_STATE) ? " ASOC" : "", \
121         (MLME_STATE((adapter)) & WIFI_OP_CH_SWITCHING) ? " OP_CH_SW" : "", \
122         (MLME_STATE((adapter)) & WIFI_UNDER_WPS) ? " WPS" : "", \
123         (MLME_STATE((adapter)) & WIFI_SLEEP_STATE) ? " SLEEP" : ""
124
125 #define _FW_UNDER_LINKING       WIFI_UNDER_LINKING
126 #define _FW_LINKED                      WIFI_ASOC_STATE
127 #define _FW_UNDER_SURVEY        WIFI_SITE_MONITOR
128
129
130 enum dot11AuthAlgrthmNum {
131  dot11AuthAlgrthm_Open = 0,
132  dot11AuthAlgrthm_Shared,
133  dot11AuthAlgrthm_8021X,
134  dot11AuthAlgrthm_Auto,
135  dot11AuthAlgrthm_WAPI,
136  dot11AuthAlgrthm_MaxNum
137 };
138
139 // Scan type including active and passive scan.
140 typedef enum _RT_SCAN_TYPE
141 {
142         SCAN_PASSIVE,
143         SCAN_ACTIVE,
144         SCAN_MIX,
145 }RT_SCAN_TYPE, *PRT_SCAN_TYPE;
146
147 #define WIFI_FREQUENCY_BAND_AUTO 0
148 #define WIFI_FREQUENCY_BAND_5GHZ 1
149 #define WIFI_FREQUENCY_BAND_2GHZ 2
150
151 #define rtw_band_valid(band) ((band) <= WIFI_FREQUENCY_BAND_2GHZ)
152
153 enum DriverInterface {
154         DRIVER_WEXT =  1,
155         DRIVER_CFG80211 = 2
156 };
157
158 enum SCAN_RESULT_TYPE
159 {
160         SCAN_RESULT_P2P_ONLY = 0,               //      Will return all the P2P devices.
161         SCAN_RESULT_ALL = 1,                    //      Will return all the scanned device, include AP.
162         SCAN_RESULT_WFD_TYPE = 2                //      Will just return the correct WFD device.
163                                                                         //      If this device is Miracast sink device, it will just return all the Miracast source devices.
164 };
165
166 /*
167
168 there are several "locks" in mlme_priv,
169 since mlme_priv is a shared resource between many threads,
170 like ISR/Call-Back functions, the OID handlers, and even timer functions.
171
172
173 Each _queue has its own locks, already.
174 Other items are protected by mlme_priv.lock.
175
176 To avoid possible dead lock, any thread trying to modifiying mlme_priv
177 SHALL not lock up more than one locks at a time!
178
179 */
180
181
182 #define traffic_threshold       10
183 #define traffic_scan_period     500
184
185 struct sitesurvey_ctrl {
186         u64     last_tx_pkts;
187         uint    last_rx_pkts;
188         sint    traffic_busy;
189         _timer  sitesurvey_ctrl_timer;
190 };
191
192 typedef struct _RT_LINK_DETECT_T{
193         u32                             NumTxOkInPeriod;
194         u32                             NumRxOkInPeriod;
195         u32                             NumRxUnicastOkInPeriod;
196         BOOLEAN                 bBusyTraffic;
197         BOOLEAN                 bTxBusyTraffic;
198         BOOLEAN                 bRxBusyTraffic;
199         BOOLEAN                 bHigherBusyTraffic; // For interrupt migration purpose.
200         BOOLEAN                 bHigherBusyRxTraffic; // We may disable Tx interrupt according as Rx traffic.
201         BOOLEAN                 bHigherBusyTxTraffic; // We may disable Tx interrupt according as Tx traffic.
202         //u8 TrafficBusyState;
203         u8 TrafficTransitionCount;
204         u32 LowPowerTransitionCount;
205 }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
206
207 struct profile_info {
208         u8      ssidlen;
209         u8      ssid[ WLAN_SSID_MAXLEN ];
210         u8      peermac[ ETH_ALEN ];
211 };
212
213 struct tx_invite_req_info{
214         u8                                      token;
215         u8                                      benable;
216         u8                                      go_ssid[ WLAN_SSID_MAXLEN ];
217         u8                                      ssidlen;
218         u8                                      go_bssid[ ETH_ALEN ];
219         u8                                      peer_macaddr[ ETH_ALEN ];
220         u8                                      operating_ch;   //      This information will be set by using the p2p_set op_ch=x
221         u8                                      peer_ch;                //      The listen channel for peer P2P device
222
223 };
224
225 struct tx_invite_resp_info{
226         u8                                      token;  //      Used to record the dialog token of p2p invitation request frame.
227 };
228
229 #ifdef CONFIG_WFD
230
231 struct wifi_display_info{
232         u16                                                     wfd_enable;                     //      Eanble/Disable the WFD function.
233         u16                                                     init_rtsp_ctrlport;     /* init value of rtsp_ctrlport when WFD enable */
234         u16                                                     rtsp_ctrlport;          /* TCP port number at which the this WFD device listens for RTSP messages, 0 when WFD disable */
235         u16                                                     tdls_rtsp_ctrlport;     /* rtsp_ctrlport used by tdls, will sync when rtsp_ctrlport is changed by user */
236         u16                                                     peer_rtsp_ctrlport;     //      TCP port number at which the peer WFD device listens for RTSP messages
237                                                                                                         //      This filed should be filled when receiving the gropu negotiation request
238
239         u8                                                      peer_session_avail;     //      WFD session is available or not for the peer wfd device.
240                                                                                                         //      This variable will be set when sending the provisioning discovery request to peer WFD device.
241                                                                                                         //      And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command.
242         u8                                                      ip_address[4];
243         u8                                                      peer_ip_address[4];
244         u8                                                      wfd_pc;                         //      WFD preferred connection
245                                                                                                         //      0 -> Prefer to use the P2P for WFD connection on peer side.
246                                                                                                         //      1 -> Prefer to use the TDLS for WFD connection on peer side.
247                                                                                         
248         u8                                                      wfd_device_type;        //      WFD Device Type
249                                                                                                         //      0 -> WFD Source Device
250                                                                                                         //      1 -> WFD Primary Sink Device
251         enum    SCAN_RESULT_TYPE        scan_result_type;       //      Used when P2P is enable. This parameter will impact the scan result.
252         u8 op_wfd_mode;
253         u8 stack_wfd_mode;
254 };
255 #endif //CONFIG_WFD
256
257 struct tx_provdisc_req_info{
258         u16                                     wps_config_method_request;      //      Used when sending the provisioning request frame
259         u16                                     peer_channel_num[2];            //      The channel number which the receiver stands.
260         NDIS_802_11_SSID        ssid;
261         u8                                      peerDevAddr[ ETH_ALEN ];                //      Peer device address
262         u8                                      peerIFAddr[ ETH_ALEN ];         //      Peer interface address
263         u8                                      benable;                                        //      This provision discovery request frame is trigger to send or not
264 };
265
266 struct rx_provdisc_req_info{    //When peer device issue prov_disc_req first, we should store the following informations
267         u8                                      peerDevAddr[ ETH_ALEN ];                //      Peer device address
268         u8                                      strconfig_method_desc_of_prov_disc_req[4];      //      description for the config method located in the provisioning discovery request frame.  
269                                                                                                                                         //      The UI must know this information to know which config method the remote p2p device is requiring.
270 };
271
272 struct tx_nego_req_info{
273         u16                                     peer_channel_num[2];            //      The channel number which the receiver stands.
274         u8                                      peerDevAddr[ ETH_ALEN ];                //      Peer device address
275         u8                                      benable;                                        //      This negoitation request frame is trigger to send or not
276         u8                                      peer_ch;                                   /*   The listen channel for peer P2P device    */
277 };
278
279 struct group_id_info{
280         u8                                      go_device_addr[ ETH_ALEN ];     //      The GO's device address of this P2P group
281         u8                                      ssid[ WLAN_SSID_MAXLEN ];       //      The SSID of this P2P group
282 };
283
284 struct scan_limit_info{
285         u8                                      scan_op_ch_only;                        //      When this flag is set, the driver should just scan the operation channel
286 #ifndef CONFIG_P2P_OP_CHK_SOCIAL_CH
287         u8                                      operation_ch[2];                                //      Store the operation channel of invitation request frame
288 #else
289         u8                                      operation_ch[5];                                //      Store additional channel 1,6,11  for Android 4.2 IOT & Nexus 4
290 #endif //CONFIG_P2P_OP_CHK_SOCIAL_CH
291 };
292
293 #ifdef CONFIG_IOCTL_CFG80211
294 struct cfg80211_wifidirect_info{
295         _timer                                  remain_on_ch_timer;
296         u8                                              restore_channel;
297         struct ieee80211_channel        remain_on_ch_channel;
298         enum nl80211_channel_type       remain_on_ch_type;
299         ATOMIC_T ro_ch_cookie_gen;
300         u64 remain_on_ch_cookie;
301         bool is_ro_ch;
302         u32 last_ro_ch_time; /* this will be updated at the beginning and end of ro_ch */
303 };
304 #endif //CONFIG_IOCTL_CFG80211
305
306 #ifdef CONFIG_P2P_WOWLAN
307
308 enum P2P_WOWLAN_RECV_FRAME_TYPE
309 {
310         P2P_WOWLAN_RECV_NEGO_REQ = 0,
311         P2P_WOWLAN_RECV_INVITE_REQ = 1,
312         P2P_WOWLAN_RECV_PROVISION_REQ = 2,
313 };
314
315 struct p2p_wowlan_info{
316
317         u8                                              is_trigger;
318         enum P2P_WOWLAN_RECV_FRAME_TYPE wowlan_recv_frame_type;
319         u8                                              wowlan_peer_addr[ETH_ALEN];
320         u16                                             wowlan_peer_wpsconfig;
321         u8                                              wowlan_peer_is_persistent;
322         u8                                              wowlan_peer_invitation_type;
323 };
324
325 #endif //CONFIG_P2P_WOWLAN
326
327 struct wifidirect_info{
328         _adapter*                               padapter;
329         _timer                                  find_phase_timer;
330         _timer                                  restore_p2p_state_timer;
331         
332         //      Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer.
333         _timer                                  pre_tx_scan_timer;
334         _timer                                  reset_ch_sitesurvey;
335         _timer                                  reset_ch_sitesurvey2;   //      Just for resetting the scan limit function by using p2p nego
336 #ifdef CONFIG_CONCURRENT_MODE
337         //      Used to switch the channel between legacy AP and listen state.
338         _timer                                  ap_p2p_switch_timer;
339 #endif
340         struct tx_provdisc_req_info     tx_prov_disc_info;
341         struct rx_provdisc_req_info rx_prov_disc_info;
342         struct tx_invite_req_info       invitereq_info;
343         struct profile_info                     profileinfo[ P2P_MAX_PERSISTENT_GROUP_NUM ];    //      Store the profile information of persistent group
344         struct tx_invite_resp_info      inviteresp_info;
345         struct tx_nego_req_info nego_req_info;
346         struct group_id_info            groupid_info;   //      Store the group id information when doing the group negotiation handshake.
347         struct scan_limit_info          rx_invitereq_info;      //      Used for get the limit scan channel from the Invitation procedure
348         struct scan_limit_info          p2p_info;               //      Used for get the limit scan channel from the P2P negotiation handshake
349 #ifdef CONFIG_WFD
350         struct wifi_display_info                *wfd_info;
351 #endif  
352
353 #ifdef CONFIG_P2P_WOWLAN
354         struct p2p_wowlan_info          p2p_wow_info;
355 #endif //CONFIG_P2P_WOWLAN
356
357         enum P2P_ROLE                   role;
358         enum P2P_STATE                  pre_p2p_state;
359         enum P2P_STATE                  p2p_state;
360         u8                                              device_addr[ETH_ALEN];  //      The device address should be the mac address of this device.
361         u8                                              interface_addr[ETH_ALEN];
362         u8                                              social_chan[4];
363         u8                                              listen_channel;
364         u8                                              operating_channel;
365         u8                                              listen_dwell;           //      This value should be between 1 and 3
366         u8                                              support_rate[8];
367         u8                                              p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
368         u8                                              intent;         //      should only include the intent value.
369         u8                                              p2p_peer_interface_addr[ ETH_ALEN ];
370         u8                                              p2p_peer_device_addr[ ETH_ALEN ];
371         u8                                              peer_intent;    //      Included the intent value and tie breaker value.
372         u8                                              device_name[ WPS_MAX_DEVICE_NAME_LEN ]; //      Device name for displaying on searching device screen
373         u8                                              device_name_len;
374         u8                                              profileindex;   //      Used to point to the index of profileinfo array
375         u8                                              peer_operating_ch;
376         u8                                              find_phase_state_exchange_cnt;
377         u16                                             device_password_id_for_nego;    //      The device password ID for group negotation
378         u8                                              negotiation_dialog_token;
379         u8                                              nego_ssid[ WLAN_SSID_MAXLEN ];  //      SSID information for group negotitation
380         u8                                              nego_ssidlen;
381         u8                                              p2p_group_ssid[WLAN_SSID_MAXLEN];
382         u8                                              p2p_group_ssid_len;
383         u8                                              persistent_supported;           //      Flag to know the persistent function should be supported or not.
384                                                                                                                 //      In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI.
385                                                                                                                 //      0: disable
386                                                                                                                 //      1: enable
387         u8                                              session_available;                      //      Flag to set the WFD session available to enable or disable "by Sigma"
388                                                                                                                 //      In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI.
389                                                                                                                 //      0: disable
390                                                                                                                 //      1: enable
391
392         u8                                              wfd_tdls_enable;                        //      Flag to enable or disable the TDLS by WFD Sigma
393                                                                                                                 //      0: disable
394                                                                                                                 //      1: enable
395         u8                                              wfd_tdls_weaksec;                       //      Flag to enable or disable the weak security function for TDLS by WFD Sigma
396                                                                                                                 //      0: disable
397                                                                                                                 //      In this case, the driver can't issue the tdsl setup request frame.
398                                                                                                                 //      1: enable
399                                                                                                                 //      In this case, the driver can issue the tdls setup request frame
400                                                                                                                 //      even the current security is weak security.
401
402         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.
403         u16                                             supported_wps_cm;                       //      This field describes the WPS config method which this driver supported.
404                                                                                                                 //      The value should be the combination of config method defined in page104 of WPS v2.0 spec.       
405         u8                                              external_uuid;                          // UUID flag
406         u8                                              uuid[16];                                       // UUID
407         uint                                            channel_list_attr_len;          //      This field will contain the length of body of P2P Channel List attribute of group negotitation response frame.
408         u8                                              channel_list_attr[100];         //      This field will contain the body of P2P Channel List attribute of group negotitation response frame.
409                                                                                                                 //      We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame.
410         u8                                              driver_interface;                       //      Indicate DRIVER_WEXT or DRIVER_CFG80211
411
412 #ifdef CONFIG_CONCURRENT_MODE
413         u16                                             ext_listen_interval;    //      The interval to be available with legacy AP (ms)
414         u16                                             ext_listen_period;      //      The time period to be available for P2P listen state (ms)
415 #endif
416 #ifdef CONFIG_P2P_PS
417         enum P2P_PS_MODE                p2p_ps_mode; // indicate p2p ps mode
418         enum P2P_PS_STATE               p2p_ps_state; // indicate p2p ps state
419         u8                                              noa_index; // Identifies and instance of Notice of Absence timing.
420         u8                                              ctwindow; // Client traffic window. A period of time in TU after TBTT.
421         u8                                              opp_ps; // opportunistic power save.
422         u8                                              noa_num; // number of NoA descriptor in P2P IE.
423         u8                                              noa_count[P2P_MAX_NOA_NUM]; // Count for owner, Type of client.
424         u32                                             noa_duration[P2P_MAX_NOA_NUM]; // Max duration for owner, preferred or min acceptable duration for client.
425         u32                                             noa_interval[P2P_MAX_NOA_NUM]; // Length of interval for owner, preferred or max acceptable interval of client.
426         u32                                             noa_start_time[P2P_MAX_NOA_NUM]; // schedule expressed in terms of the lower 4 bytes of the TSF timer.
427 #endif // CONFIG_P2P_PS
428 };
429
430 struct tdls_ss_record{  //signal strength record
431         u8              macaddr[ETH_ALEN];
432         u8              RxPWDBAll;
433         u8              is_tdls_sta;    // _TRUE: direct link sta, _FALSE: else
434 };
435
436 struct tdls_temp_mgmt{
437         u8      initiator;      // 0: None, 1: we initiate, 2: peer initiate
438         u8      peer_addr[ETH_ALEN];
439 };
440
441 #ifdef CONFIG_TDLS_CH_SW
442 struct tdls_ch_switch{
443         u32     ch_sw_state;
444         ATOMIC_T        chsw_on;
445         u8      addr[ETH_ALEN];
446         u8      off_ch_num;
447         u8      ch_offset;
448         u32     cur_time;
449         u8      delay_switch_back;
450         u8      dump_stack;
451         struct submit_ctx       chsw_sctx;
452 };
453 #endif
454
455 struct tdls_info{
456         u8                                      ap_prohibited;
457         u8                                      ch_switch_prohibited;
458         u8                                      link_established;
459         u8                                      sta_cnt;
460         u8                                      sta_maximum;    /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */
461         struct tdls_ss_record   ss_record;
462 #ifdef CONFIG_TDLS_CH_SW        
463         struct tdls_ch_switch   chsw_info;
464 #endif
465
466         u8                                      ch_sensing;
467         u8                                      cur_channel;
468         u8                                      collect_pkt_num[MAX_CHANNEL_NUM];
469         _lock                           cmd_lock;
470         _lock                           hdl_lock;
471         u8                                      watchdog_count;
472         u8                                      dev_discovered;         /* WFD_TDLS: for sigma test */
473         u8                                      tdls_enable;
474
475         /* Let wpa_supplicant to setup*/
476         u8                                      driver_setup;
477 #ifdef CONFIG_WFD
478         struct wifi_display_info                *wfd_info;
479 #endif          
480 };
481
482 struct tdls_txmgmt {
483         u8 peer[ETH_ALEN];
484         u8 action_code;
485         u8 dialog_token;
486         u16 status_code;
487         u8 *buf;
488         size_t len;
489 };
490
491 /* used for mlme_priv.roam_flags */
492 enum {
493         RTW_ROAM_ON_EXPIRED = BIT0,
494         RTW_ROAM_ON_RESUME = BIT1,
495         RTW_ROAM_ACTIVE = BIT2,
496 };
497
498 struct beacon_keys {
499         u8 ssid[IW_ESSID_MAX_SIZE];
500         u32 ssid_len;
501         u8 bcn_channel;
502         u16 ht_cap_info;
503         u8 ht_info_infos_0_sco; // bit0 & bit1 in infos[0] is second channel offset
504         int encryp_protocol;
505         int pairwise_cipher;
506         int group_cipher;
507         int is_8021x;
508 };
509
510 struct mlme_priv {
511
512         _lock   lock;
513         sint    fw_state;       //shall we protect this variable? maybe not necessarily...
514         u8 bScanInProcess;
515         u8      to_join; //flag
516         #ifdef CONFIG_LAYER2_ROAMING
517         u8 to_roam; /* roaming trying times */
518         struct wlan_network *roam_network; /* the target of active roam */
519         u8 roam_flags;
520         u8 roam_rssi_diff_th; /* rssi difference threshold for active scan candidate selection */
521         u32 roam_scan_int_ms; /* scan interval for active roam */
522         u32 roam_scanr_exp_ms; /* scan result expire time in ms  for roam */
523         u8 roam_tgt_addr[ETH_ALEN]; /* request to roam to speicific target without other consideration */
524         #endif
525
526         u8      *nic_hdl;
527
528         #ifdef SUPPLICANT_RTK_VERSION_LOWER_THAN_JB42
529         u8      not_indic_disco;
530         #endif
531         _list           *pscanned;
532         _queue  free_bss_pool;
533         _queue  scanned_queue;
534         u8              *free_bss_buf;
535         u32     num_of_scanned;
536
537         NDIS_802_11_SSID        assoc_ssid;
538         u8      assoc_bssid[6];
539
540         struct wlan_network     cur_network;
541         struct wlan_network *cur_network_scanned;
542
543         // bcn check info
544         struct beacon_keys cur_beacon_keys; // save current beacon keys
545         struct beacon_keys new_beacon_keys; // save new beacon keys
546         u8 new_beacon_cnts; // if new_beacon_cnts >= threshold, ap beacon is changed
547
548 #ifdef CONFIG_ARP_KEEP_ALIVE
549         // for arp offload keep alive
550         u8 bGetGateway;
551         u8      gw_mac_addr[6];
552         u8      gw_ip[4];
553 #endif
554
555         //uint wireless_mode; no used, remove it
556
557         u32     auto_scan_int_ms;
558
559         _timer assoc_timer;
560
561         uint assoc_by_bssid;
562         uint assoc_by_rssi;
563
564         _timer scan_to_timer; // driver itself handles scan_timeout status.
565         u32 scan_start_time; // used to evaluate the time spent in scanning
566
567         #ifdef CONFIG_SET_SCAN_DENY_TIMER
568         _timer set_scan_deny_timer;
569         ATOMIC_T set_scan_deny; //0: allowed, 1: deny
570         #endif
571
572         struct qos_priv qospriv;
573
574 #ifdef CONFIG_80211N_HT
575
576         /* Number of non-HT AP/stations */
577         int num_sta_no_ht;
578
579         /* Number of HT AP/stations 20 MHz */
580         //int num_sta_ht_20mhz; 
581
582
583         int num_FortyMHzIntolerant;
584
585         struct ht_priv  htpriv;
586
587 #endif
588
589 #ifdef CONFIG_80211AC_VHT
590         struct vht_priv vhtpriv;
591 #endif
592 #ifdef CONFIG_BEAMFORMING
593 #if (BEAMFORMING_SUPPORT == 0)/*for driver beamforming*/
594         struct beamforming_info beamforming_info;
595 #endif
596 #endif
597
598 #ifdef CONFIG_DFS
599         u8      handle_dfs;
600 #endif
601 #ifdef CONFIG_DFS_MASTER
602         /* TODO: move to rfctl */
603         _timer dfs_master_timer;
604 #endif
605
606         RT_LINK_DETECT_T        LinkDetectInfo;
607         _timer  dynamic_chk_timer; //dynamic/periodic check timer
608
609         u8      acm_mask; // for wmm acm mask
610         const struct country_chplan *country_ent;
611         u8      ChannelPlan;
612         RT_SCAN_TYPE    scan_mode; // active: 1, passive: 0
613
614         u8 *wps_probe_req_ie;
615         u32 wps_probe_req_ie_len;
616
617         u8 ext_capab_ie_data[8];/*currently for ap mode only*/
618         u8 ext_capab_ie_len; 
619         
620 #if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
621         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
622          * in 802.11g BSS) */
623         int num_sta_non_erp;
624
625         /* Number of associated stations that do not support Short Slot Time */
626         int num_sta_no_short_slot_time;
627
628         /* Number of associated stations that do not support Short Preamble */
629         int num_sta_no_short_preamble;
630
631         int olbc; /* Overlapping Legacy BSS Condition (Legacy b/g)*/
632
633         /* Number of HT associated stations that do not support greenfield */
634         int num_sta_ht_no_gf;
635
636         /* Number of associated non-HT stations */
637         //int num_sta_no_ht;
638
639         /* Number of HT associated stations 20 MHz */
640         int num_sta_ht_20mhz;
641
642         /* number of associated stations 40MHz intolerant */
643         int num_sta_40mhz_intolerant;
644         
645         /* Overlapping BSS information */
646         int olbc_ht;
647         
648 #ifdef CONFIG_80211N_HT
649         int ht_20mhz_width_req; 
650         int ht_intolerant_ch_reported;          
651         u16 ht_op_mode;
652         u8 sw_to_20mhz; /*switch to 20Mhz BW*/
653 #endif /* CONFIG_80211N_HT */   
654
655         u8 *assoc_req;
656         u32 assoc_req_len;
657         u8 *assoc_rsp;
658         u32 assoc_rsp_len;
659
660         u8 *wps_beacon_ie;      
661         //u8 *wps_probe_req_ie;
662         u8 *wps_probe_resp_ie;
663         u8 *wps_assoc_resp_ie; // for CONFIG_IOCTL_CFG80211, this IE could include p2p ie / wfd ie
664
665         u32 wps_beacon_ie_len;
666         //u32 wps_probe_req_ie_len;
667         u32 wps_probe_resp_ie_len;
668         u32 wps_assoc_resp_ie_len; // for CONFIG_IOCTL_CFG80211, this IE len could include p2p ie / wfd ie
669         
670         u8 *p2p_beacon_ie;
671         u8 *p2p_probe_req_ie;
672         u8 *p2p_probe_resp_ie;  
673         u8 *p2p_go_probe_resp_ie; //for GO      
674         u8 *p2p_assoc_req_ie;
675         u8 *p2p_assoc_resp_ie;
676
677         u32 p2p_beacon_ie_len;
678         u32 p2p_probe_req_ie_len;
679         u32 p2p_probe_resp_ie_len;
680         u32 p2p_go_probe_resp_ie_len; //for GO
681         u32 p2p_assoc_req_ie_len;
682         u32 p2p_assoc_resp_ie_len;
683         
684         _lock   bcn_update_lock;
685         u8              update_bcn;
686         
687         u8 ori_ch;
688         u8 ori_bw;
689         u8 ori_offset;
690 #endif //#if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
691
692 #if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
693         
694         u8 *wfd_beacon_ie;
695         u8 *wfd_probe_req_ie;
696         u8 *wfd_probe_resp_ie;  
697         u8 *wfd_go_probe_resp_ie; //for GO      
698         u8 *wfd_assoc_req_ie;
699         u8 *wfd_assoc_resp_ie;
700
701         u32 wfd_beacon_ie_len;
702         u32 wfd_probe_req_ie_len;
703         u32 wfd_probe_resp_ie_len;
704         u32 wfd_go_probe_resp_ie_len; //for GO
705         u32 wfd_assoc_req_ie_len;
706         u32 wfd_assoc_resp_ie_len;
707
708 #endif
709
710 #ifdef RTK_DMP_PLATFORM
711         // DMP kobject_hotplug function  signal need in passive level
712         _workitem       Linkup_workitem;
713         _workitem       Linkdown_workitem;
714 #endif
715
716 #ifdef CONFIG_INTEL_WIDI
717         int     widi_state;
718         int     listen_state;
719         _timer  listen_timer;
720         ATOMIC_T        rx_probe_rsp; // 1:receive probe respone from RDS source.
721         u8      *l2sdTaBuffer;
722         u8      channel_idx;
723         u8      group_cnt;      //In WiDi 3.5, they specified another scan algo. for WFD/RDS co-existed
724         u8      sa_ext[L2SDTA_SERVICE_VE_LEN];
725
726         u8      widi_enable;
727         /**
728          * For WiDi 4; upper layer would set
729          * p2p_primary_device_type_category_id
730          * p2p_primary_device_type_sub_category_id
731          * p2p_secondary_device_type_category_id
732          * p2p_secondary_device_type_sub_category_id
733          */
734         u16     p2p_pdt_cid;
735         u16     p2p_pdt_scid;
736         u8      num_p2p_sdt;
737         u16     p2p_sdt_cid[MAX_NUM_P2P_SDT];
738         u16     p2p_sdt_scid[MAX_NUM_P2P_SDT];
739         u8      p2p_reject_disable;     //When starting NL80211 wpa_supplicant/hostapd, it will call netdev_close
740                                                         //such that it will cause p2p disabled. Use this flag to reject.
741 #endif // CONFIG_INTEL_WIDI
742
743 #ifdef CONFIG_CONCURRENT_MODE
744         u8      scanning_via_buddy_intf;
745 #endif
746
747 //      u8      NumOfBcnInfoChkFail;
748 //      u32     timeBcnInfoChkStart;
749 };
750
751 #define mlme_set_scan_to_timer(mlme, ms) \
752         do { \
753                 /* DBG_871X("%s set_scan_to_timer(%p, %d)\n", __FUNCTION__, (mlme), (ms)); */ \
754                 _set_timer(&(mlme)->scan_to_timer, (ms)); \
755         } while(0)
756
757 #define rtw_mlme_set_auto_scan_int(adapter, ms) \
758         do { \
759                 adapter->mlmepriv.auto_scan_int_ms = ms; \
760         } while (0)
761
762 void rtw_mlme_reset_auto_scan_int(_adapter *adapter);
763
764 #ifdef CONFIG_AP_MODE
765
766 struct hostapd_priv
767 {
768         _adapter *padapter;
769
770 #ifdef CONFIG_HOSTAPD_MLME
771         struct net_device *pmgnt_netdev;
772         struct usb_anchor anchored;
773 #endif  
774         
775 };
776
777 extern int hostapd_mode_init(_adapter *padapter);
778 extern void hostapd_mode_unload(_adapter *padapter);
779 #endif
780
781
782 extern void rtw_joinbss_event_prehandle(_adapter *adapter, u8 *pbuf);
783 extern void rtw_survey_event_callback(_adapter *adapter, u8 *pbuf);
784 extern void rtw_surveydone_event_callback(_adapter *adapter, u8 *pbuf);
785 extern void rtw_joinbss_event_callback(_adapter *adapter, u8 *pbuf);
786 extern void rtw_stassoc_event_callback(_adapter *adapter, u8 *pbuf);
787 extern void rtw_stadel_event_callback(_adapter *adapter, u8 *pbuf);
788 extern void rtw_atimdone_event_callback(_adapter *adapter, u8 *pbuf);
789 extern void rtw_cpwm_event_callback(_adapter *adapter, u8 *pbuf);
790 extern void rtw_wmm_event_callback(PADAPTER padapter, u8 *pbuf);
791 #ifdef CONFIG_IEEE80211W
792 void rtw_sta_timeout_event_callback(_adapter *adapter, u8 *pbuf);
793 #endif /* CONFIG_IEEE80211W */
794 extern void rtw_join_timeout_handler(RTW_TIMER_HDL_ARGS);
795 extern void _rtw_scan_timeout_handler(RTW_TIMER_HDL_ARGS);
796
797 thread_return event_thread(thread_context context);
798
799 extern void rtw_free_network_queue(_adapter *adapter,u8 isfreeall);
800 extern int rtw_init_mlme_priv(_adapter *adapter);// (struct mlme_priv *pmlmepriv);
801
802 extern void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv);
803
804
805 extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
806 extern sint rtw_set_key(_adapter *adapter,struct security_priv *psecuritypriv,sint keyid, u8 set_tx, bool enqueue);
807 extern sint rtw_set_auth(_adapter *adapter,struct security_priv *psecuritypriv);
808
809 __inline static u8 *get_bssid(struct mlme_priv *pmlmepriv)
810 {       //if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid
811         // if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address
812         return pmlmepriv->cur_network.network.MacAddress;
813 }
814
815 __inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
816 {
817         if (pmlmepriv->fw_state & state)
818                 return _TRUE;
819
820         return _FALSE;
821 }
822
823 __inline static sint get_fwstate(struct mlme_priv *pmlmepriv)
824 {
825         return pmlmepriv->fw_state;
826 }
827
828 /*
829  * No Limit on the calling context,
830  * therefore set it to be the critical section...
831  *
832  * ### NOTE:#### (!!!!)
833  * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
834  */
835 __inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
836 {
837         pmlmepriv->fw_state |= state;
838         //FOR HW integration
839         if(_FW_UNDER_SURVEY==state){
840                 pmlmepriv->bScanInProcess = _TRUE;
841         }
842 }
843
844 __inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
845 {
846         pmlmepriv->fw_state &= ~state;
847         //FOR HW integration
848         if(_FW_UNDER_SURVEY==state){
849                 pmlmepriv->bScanInProcess = _FALSE;
850         }
851 }
852
853 /*
854  * No Limit on the calling context,
855  * therefore set it to be the critical section...
856  */
857 __inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
858 {
859         _irqL irqL;
860
861         _enter_critical_bh(&pmlmepriv->lock, &irqL);
862         _clr_fwstate_(pmlmepriv, state);
863         _exit_critical_bh(&pmlmepriv->lock, &irqL);
864 }
865
866 __inline static void up_scanned_network(struct mlme_priv *pmlmepriv)
867 {
868         _irqL irqL;
869
870         _enter_critical_bh(&pmlmepriv->lock, &irqL);
871         pmlmepriv->num_of_scanned++;
872         _exit_critical_bh(&pmlmepriv->lock, &irqL);
873 }
874
875 #ifdef CONFIG_CONCURRENT_MODE
876 sint rtw_buddy_adapter_up(_adapter *padapter);
877 sint check_buddy_fwstate(_adapter *padapter, sint state);
878 u8 rtw_get_buddy_bBusyTraffic(_adapter *padapter);
879 #endif //CONFIG_CONCURRENT_MODE
880
881 __inline static void down_scanned_network(struct mlme_priv *pmlmepriv)
882 {
883         _irqL irqL;
884
885         _enter_critical_bh(&pmlmepriv->lock, &irqL);
886         pmlmepriv->num_of_scanned--;
887         _exit_critical_bh(&pmlmepriv->lock, &irqL);
888 }
889
890 __inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
891 {
892         _irqL irqL;
893
894         _enter_critical_bh(&pmlmepriv->lock, &irqL);
895         pmlmepriv->num_of_scanned = val;
896         _exit_critical_bh(&pmlmepriv->lock, &irqL);
897 }
898
899 extern u16 rtw_get_capability(WLAN_BSSID_EX *bss);
900 extern void rtw_update_scanned_network(_adapter *adapter, WLAN_BSSID_EX *target);
901 extern void rtw_disconnect_hdl_under_linked(_adapter* adapter, struct sta_info *psta, u8 free_assoc);
902 extern void rtw_generate_random_ibss(u8 *pibss);
903 extern struct wlan_network* rtw_find_network(_queue *scanned_queue, u8 *addr);
904 extern struct wlan_network* rtw_get_oldest_wlan_network(_queue *scanned_queue);
905 struct wlan_network *_rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
906 struct wlan_network *rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
907
908 extern void rtw_free_assoc_resources(_adapter* adapter, int lock_scanned_queue);
909 extern void rtw_indicate_disconnect(_adapter* adapter);
910 extern void rtw_indicate_connect(_adapter* adapter);
911 void rtw_indicate_scan_done( _adapter *padapter, bool aborted);
912
913 void rtw_drv_scan_by_self(_adapter *padapter);
914 void rtw_scan_wait_completed(_adapter *adapter);
915 u32 rtw_scan_abort_timeout(_adapter *adapter, u32 timeout_ms);
916 void rtw_scan_abort_no_wait(_adapter *adapter);
917 void rtw_scan_abort(_adapter *adapter);
918
919 extern int rtw_restruct_sec_ie(_adapter *adapter,u8 *in_ie,u8 *out_ie,uint in_len);
920 extern int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len);
921 extern void rtw_init_registrypriv_dev_network(_adapter *adapter);
922
923 extern void rtw_update_registrypriv_dev_network(_adapter *adapter);
924
925 extern void rtw_get_encrypt_decrypt_from_registrypriv(_adapter *adapter);
926
927 extern void _rtw_join_timeout_handler(_adapter *adapter);
928 extern void rtw_scan_timeout_handler(_adapter *adapter);
929
930 extern void rtw_dynamic_check_timer_handlder(_adapter *adapter);
931 #ifdef CONFIG_SET_SCAN_DENY_TIMER
932 bool rtw_is_scan_deny(_adapter *adapter);
933 void rtw_clear_scan_deny(_adapter *adapter);
934 void rtw_set_scan_deny_timer_hdl(_adapter *adapter);
935 void rtw_set_scan_deny(_adapter *adapter, u32 ms);
936 #else
937 #define rtw_is_scan_deny(adapter) _FALSE
938 #define rtw_clear_scan_deny(adapter) do {} while (0)
939 #define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
940 #define rtw_set_scan_deny(adapter, ms) do {} while (0)
941 #endif
942
943 void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
944
945 #define MLME_BEACON_IE                  0
946 #define MLME_PROBE_REQ_IE               1
947 #define MLME_PROBE_RESP_IE              2
948 #define MLME_GO_PROBE_RESP_IE   3
949 #define MLME_ASSOC_REQ_IE               4
950 #define MLME_ASSOC_RESP_IE              5
951
952 #if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
953 int rtw_mlme_update_wfd_ie_data(struct mlme_priv *mlme, u8 type, u8 *ie, u32 ie_len);
954 #endif
955
956 extern int _rtw_init_mlme_priv(_adapter *padapter);
957 extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
958
959 extern int _rtw_enqueue_network(_queue *queue, struct wlan_network *pnetwork);
960
961 //extern struct wlan_network* _rtw_dequeue_network(_queue *queue);
962
963 extern struct wlan_network* _rtw_alloc_network(struct mlme_priv *pmlmepriv);
964
965
966 extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
967 extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
968
969
970 extern struct wlan_network* _rtw_find_network(_queue *scanned_queue, u8 *addr);
971
972 extern void _rtw_free_network_queue(_adapter* padapter, u8 isfreeall);
973
974 extern sint rtw_if_up(_adapter *padapter);
975
976 sint rtw_linked_check(_adapter *padapter);
977
978 u8 *rtw_get_capability_from_ie(u8 *ie);
979 u8 *rtw_get_timestampe_from_ie(u8 *ie);
980 u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
981
982
983 void rtw_joinbss_reset(_adapter *padapter);
984
985 #ifdef CONFIG_80211N_HT
986 void    rtw_ht_use_default_setting(_adapter *padapter);
987 void rtw_build_wmm_ie_ht(_adapter *padapter, u8 *out_ie, uint *pout_len);
988 unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel);
989 void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel);
990 void rtw_issue_addbareq_cmd(_adapter *padapter, struct xmit_frame *pxmitframe);
991 void rtw_append_exented_cap(_adapter *padapter, u8 *out_ie, uint *pout_len);
992 #endif
993
994 int rtw_is_same_ibss(_adapter *adapter, struct wlan_network *pnetwork);
995 int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst, u8 feature);
996
997 #ifdef CONFIG_LAYER2_ROAMING
998 #define rtw_roam_flags(adapter) ((adapter)->mlmepriv.roam_flags)
999 #define rtw_chk_roam_flags(adapter, flags) ((adapter)->mlmepriv.roam_flags & flags)
1000 #define rtw_clr_roam_flags(adapter, flags) \
1001         do { \
1002                 ((adapter)->mlmepriv.roam_flags &= ~flags); \
1003         } while (0)
1004
1005 #define rtw_set_roam_flags(adapter, flags) \
1006         do { \
1007                 ((adapter)->mlmepriv.roam_flags |= flags); \
1008         } while (0)
1009
1010 #define rtw_assign_roam_flags(adapter, flags) \
1011         do { \
1012                 ((adapter)->mlmepriv.roam_flags = flags); \
1013         } while (0)
1014
1015 void _rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
1016 void rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
1017 void rtw_set_to_roam(_adapter *adapter, u8 to_roam);
1018 u8 rtw_dec_to_roam(_adapter *adapter);
1019 u8 rtw_to_roam(_adapter *adapter);
1020 int rtw_select_roaming_candidate(struct mlme_priv *pmlmepriv);
1021 #else
1022 #define rtw_roam_flags(adapter) 0
1023 #define rtw_chk_roam_flags(adapter, flags) 0
1024 #define rtw_clr_roam_flags(adapter, flags) do {} while (0)
1025 #define rtw_set_roam_flags(adapter, flags) do {} while (0)
1026 #define rtw_assign_roam_flags(adapter, flags) do {} while (0)
1027 #define _rtw_roaming(adapter, tgt_network) do {} while(0)
1028 #define rtw_roaming(adapter, tgt_network) do {} while(0)
1029 #define rtw_set_to_roam(adapter, to_roam) do {} while(0)
1030 #define rtw_dec_to_roam(adapter) 0
1031 #define rtw_to_roam(adapter) 0
1032 #define rtw_select_roaming_candidate(mlme) _FAIL
1033 #endif /* CONFIG_LAYER2_ROAMING */
1034
1035 bool rtw_adjust_chbw(_adapter *adapter, u8 req_ch, u8 *req_bw, u8 *req_offset);
1036
1037 struct sta_media_status_rpt_cmd_parm {
1038         struct sta_info *sta;
1039         bool connected;
1040 };
1041
1042 void rtw_sta_media_status_rpt(_adapter *adapter, struct sta_info *sta, bool connected);
1043 u8 rtw_sta_media_status_rpt_cmd(_adapter *adapter, struct sta_info *sta, bool connected);
1044 void rtw_sta_media_status_rpt_cmd_hdl(_adapter *adapter, struct sta_media_status_rpt_cmd_parm *parm);
1045
1046 #ifdef CONFIG_INTEL_PROXIM
1047 void rtw_proxim_enable(_adapter *padapter);
1048 void rtw_proxim_disable(_adapter *padapter);
1049 void rtw_proxim_send_packet(_adapter *padapter,u8 *pbuf,u16 len,u8 hw_rate);
1050 #endif //CONFIG_INTEL_PROXIM
1051
1052 #define IPV4_SRC(_iphdr)                        (((u8 *)(_iphdr)) + 12)
1053 #define IPV4_DST(_iphdr)                        (((u8 *)(_iphdr)) + 16)
1054 #define GET_IPV4_IHL(_iphdr)            BE_BITS_TO_1BYTE(((u8 *)(_iphdr)) + 0, 0, 4)
1055 #define GET_IPV4_PROTOCOL(_iphdr)       BE_BITS_TO_1BYTE(((u8 *)(_iphdr)) + 9, 0, 8)
1056 #define GET_IPV4_SRC(_iphdr)            BE_BITS_TO_4BYTE(((u8 *)(_iphdr)) + 12, 0, 32)
1057 #define GET_IPV4_DST(_iphdr)            BE_BITS_TO_4BYTE(((u8 *)(_iphdr)) + 16, 0, 32)
1058
1059 #define GET_UDP_SRC(_udphdr)                    BE_BITS_TO_2BYTE(((u8 *)(_udphdr)) + 0, 0, 16)
1060 #define GET_UDP_DST(_udphdr)                    BE_BITS_TO_2BYTE(((u8 *)(_udphdr)) + 2, 0, 16)
1061
1062 #define TCP_SRC(_tcphdr)                                (((u8 *)(_tcphdr)) + 0)
1063 #define TCP_DST(_tcphdr)                                (((u8 *)(_tcphdr)) + 2)
1064 #define GET_TCP_SRC(_tcphdr)                    BE_BITS_TO_2BYTE(((u8 *)(_tcphdr)) + 0, 0, 16)
1065 #define GET_TCP_DST(_tcphdr)                    BE_BITS_TO_2BYTE(((u8 *)(_tcphdr)) + 2, 0, 16)
1066 #define GET_TCP_SEQ(_tcphdr)                    BE_BITS_TO_4BYTE(((u8 *)(_tcphdr)) + 4, 0, 32)
1067 #define GET_TCP_ACK_SEQ(_tcphdr)                BE_BITS_TO_4BYTE(((u8 *)(_tcphdr)) + 8, 0, 32)
1068 #define GET_TCP_DOFF(_tcphdr)                   BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 12, 4, 4)
1069 #define GET_TCP_FIN(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 0, 1)
1070 #define GET_TCP_SYN(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 1, 1)
1071 #define GET_TCP_RST(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 2, 1)
1072 #define GET_TCP_PSH(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 3, 1)
1073 #define GET_TCP_ACK(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 4, 1)
1074 #define GET_TCP_URG(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 5, 1)
1075 #define GET_TCP_ECE(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 6, 1)
1076 #define GET_TCP_CWR(_tcphdr)                    BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 7, 1)
1077
1078 #endif //__RTL871X_MLME_H_
1079