GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / staging / rtl8723bs / 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  ******************************************************************************/
15 #ifndef __RTW_MLME_H_
16 #define __RTW_MLME_H_
17
18
19 #define MAX_BSS_CNT     128
20 /* define   MAX_JOIN_TIMEOUT    2000 */
21 /* define   MAX_JOIN_TIMEOUT    2500 */
22 #define   MAX_JOIN_TIMEOUT      6500
23
24 /*      Commented by Albert 20101105 */
25 /*      Increase the scanning timeout because of increasing the SURVEY_TO value. */
26
27 #define         SCANNING_TIMEOUT        8000
28
29 #ifdef PALTFORM_OS_WINCE
30 #define SCANQUEUE_LIFETIME 12000000 /*  unit:us */
31 #else
32 #define SCANQUEUE_LIFETIME 20000 /*  20sec, unit:msec */
33 #endif
34
35 #define WIFI_NULL_STATE         0x00000000
36 #define WIFI_ASOC_STATE         0x00000001              /*  Under Linked state... */
37 #define WIFI_REASOC_STATE       0x00000002
38 #define WIFI_SLEEP_STATE        0x00000004
39 #define WIFI_STATION_STATE      0x00000008
40 #define WIFI_AP_STATE                   0x00000010
41 #define WIFI_ADHOC_STATE                0x00000020
42 #define WIFI_ADHOC_MASTER_STATE 0x00000040
43 #define WIFI_UNDER_LINKING      0x00000080
44
45 #define WIFI_UNDER_WPS                  0x00000100
46 /* define       WIFI_UNDER_CMD                  0x00000200 */
47 /* define       WIFI_UNDER_P2P                  0x00000400 */
48 #define WIFI_STA_ALIVE_CHK_STATE        0x00000400
49 #define WIFI_SITE_MONITOR                       0x00000800              /* to indicate the station is under site surveying */
50 #ifdef WDS
51 #define WIFI_WDS                                0x00001000
52 #define WIFI_WDS_RX_BEACON      0x00002000              /*  already rx WDS AP beacon */
53 #endif
54 #ifdef AUTO_CONFIG
55 #define WIFI_AUTOCONF                   0x00004000
56 #define WIFI_AUTOCONF_IND       0x00008000
57 #endif
58
59 /**
60 *  ========== P2P Section Start ===============
61 #define WIFI_P2P_LISTEN_STATE           0x00010000
62 #define WIFI_P2P_GROUP_FORMATION_STATE          0x00020000
63   ========== P2P Section End ===============
64 */
65
66 /* ifdef UNDER_MPTEST */
67 #define WIFI_MP_STATE                                                   0x00010000
68 #define WIFI_MP_CTX_BACKGROUND                          0x00020000      /*  in continous tx background */
69 #define WIFI_MP_CTX_ST                                          0x00040000      /*  in continous tx with single-tone */
70 #define WIFI_MP_CTX_BACKGROUND_PENDING  0x00080000      /*  pending in continous tx background due to out of skb */
71 #define WIFI_MP_CTX_CCK_HW                                      0x00100000      /*  in continous tx */
72 #define WIFI_MP_CTX_CCK_CS                                      0x00200000      /*  in continous tx with carrier suppression */
73 #define   WIFI_MP_LPBK_STATE                                    0x00400000
74 /* endif */
75
76 /* define _FW_UNDER_CMD         WIFI_UNDER_CMD */
77 #define _FW_UNDER_LINKING       WIFI_UNDER_LINKING
78 #define _FW_LINKED                      WIFI_ASOC_STATE
79 #define _FW_UNDER_SURVEY        WIFI_SITE_MONITOR
80
81
82 enum dot11AuthAlgrthmNum {
83  dot11AuthAlgrthm_Open = 0,
84  dot11AuthAlgrthm_Shared,
85  dot11AuthAlgrthm_8021X,
86  dot11AuthAlgrthm_Auto,
87  dot11AuthAlgrthm_WAPI,
88  dot11AuthAlgrthm_MaxNum
89 };
90
91 /*  Scan type including active and passive scan. */
92 typedef enum _RT_SCAN_TYPE
93 {
94         SCAN_PASSIVE,
95         SCAN_ACTIVE,
96         SCAN_MIX,
97 }RT_SCAN_TYPE, *PRT_SCAN_TYPE;
98
99 enum  _BAND
100 {
101         GHZ24_50 = 0,
102         GHZ_50,
103         GHZ_24,
104         GHZ_MAX,
105 };
106
107 #define rtw_band_valid(band) ((band) >= GHZ24_50 && (band) < GHZ_MAX)
108
109 enum DriverInterface {
110         DRIVER_WEXT =  1,
111         DRIVER_CFG80211 = 2
112 };
113
114 enum SCAN_RESULT_TYPE
115 {
116         SCAN_RESULT_P2P_ONLY = 0,               /*      Will return all the P2P devices. */
117         SCAN_RESULT_ALL = 1,                    /*      Will return all the scanned device, include AP. */
118         SCAN_RESULT_WFD_TYPE = 2                /*      Will just return the correct WFD device. */
119                                                                         /*      If this device is Miracast sink device, it will just return all the Miracast source devices. */
120 };
121
122 /*
123
124 there are several "locks" in mlme_priv,
125 since mlme_priv is a shared resource between many threads,
126 like ISR/Call-Back functions, the OID handlers, and even timer functions.
127
128
129 Each struct __queue has its own locks, already.
130 Other items are protected by mlme_priv.lock.
131
132 To avoid possible dead lock, any thread trying to modifiying mlme_priv
133 SHALL not lock up more than one locks at a time!
134
135 */
136
137
138 #define traffic_threshold       10
139 #define traffic_scan_period     500
140
141 struct sitesurvey_ctrl {
142         u64     last_tx_pkts;
143         uint    last_rx_pkts;
144         sint    traffic_busy;
145         _timer  sitesurvey_ctrl_timer;
146 };
147
148 typedef struct _RT_LINK_DETECT_T{
149         u32                     NumTxOkInPeriod;
150         u32                     NumRxOkInPeriod;
151         u32                     NumRxUnicastOkInPeriod;
152         bool                    bBusyTraffic;
153         bool                    bTxBusyTraffic;
154         bool                    bRxBusyTraffic;
155         bool                    bHigherBusyTraffic; /*  For interrupt migration purpose. */
156         bool                    bHigherBusyRxTraffic; /*  We may disable Tx interrupt according as Rx traffic. */
157         bool                    bHigherBusyTxTraffic; /*  We may disable Tx interrupt according as Tx traffic. */
158         /* u8 TrafficBusyState; */
159         u8 TrafficTransitionCount;
160         u32 LowPowerTransitionCount;
161 }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
162
163 struct profile_info {
164         u8 ssidlen;
165         u8 ssid[ WLAN_SSID_MAXLEN ];
166         u8 peermac[ ETH_ALEN ];
167 };
168
169 struct tx_invite_req_info{
170         u8                      token;
171         u8                      benable;
172         u8                      go_ssid[ WLAN_SSID_MAXLEN ];
173         u8                      ssidlen;
174         u8                      go_bssid[ ETH_ALEN ];
175         u8                      peer_macaddr[ ETH_ALEN ];
176         u8                      operating_ch;   /*      This information will be set by using the p2p_set op_ch =x */
177         u8                      peer_ch;                /*      The listen channel for peer P2P device */
178
179 };
180
181 struct tx_invite_resp_info{
182         u8                      token;  /*      Used to record the dialog token of p2p invitation request frame. */
183 };
184
185 struct tx_provdisc_req_info{
186         u16                             wps_config_method_request;      /*      Used when sending the provisioning request frame */
187         u16                             peer_channel_num[2];            /*      The channel number which the receiver stands. */
188         struct ndis_802_11_ssid ssid;
189         u8                      peerDevAddr[ ETH_ALEN ];                /*      Peer device address */
190         u8                      peerIFAddr[ ETH_ALEN ];         /*      Peer interface address */
191         u8                      benable;                                        /*      This provision discovery request frame is trigger to send or not */
192 };
193
194 struct rx_provdisc_req_info{    /* When peer device issue prov_disc_req first, we should store the following informations */
195         u8                      peerDevAddr[ ETH_ALEN ];                /*      Peer device address */
196         u8                      strconfig_method_desc_of_prov_disc_req[4];      /*      description for the config method located in the provisioning discovery request frame. */
197                                                                                                                                         /*      The UI must know this information to know which config method the remote p2p device is requiring. */
198 };
199
200 struct tx_nego_req_info{
201         u16                             peer_channel_num[2];            /*      The channel number which the receiver stands. */
202         u8                      peerDevAddr[ ETH_ALEN ];                /*      Peer device address */
203         u8                      benable;                                        /*      This negoitation request frame is trigger to send or not */
204 };
205
206 struct group_id_info{
207         u8                      go_device_addr[ ETH_ALEN ];     /*      The GO's device address of this P2P group */
208         u8                      ssid[ WLAN_SSID_MAXLEN ];       /*      The SSID of this P2P group */
209 };
210
211 struct scan_limit_info{
212         u8                      scan_op_ch_only;                        /*      When this flag is set, the driver should just scan the operation channel */
213         u8                      operation_ch[2];                                /*      Store the operation channel of invitation request frame */
214 };
215
216 struct cfg80211_wifidirect_info{
217         _timer                                  remain_on_ch_timer;
218         u8                              restore_channel;
219         struct ieee80211_channel        remain_on_ch_channel;
220         enum nl80211_channel_type       remain_on_ch_type;
221         u64                                             remain_on_ch_cookie;
222         bool is_ro_ch;
223         unsigned long last_ro_ch_time; /* this will be updated at the beginning and end of ro_ch */
224 };
225
226 struct wifidirect_info{
227         struct adapter *                        padapter;
228         _timer                                  find_phase_timer;
229         _timer                                  restore_p2p_state_timer;
230
231         /*      Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer. */
232         _timer                                  pre_tx_scan_timer;
233         _timer                                  reset_ch_sitesurvey;
234         _timer                                  reset_ch_sitesurvey2;   /*      Just for resetting the scan limit function by using p2p nego */
235         struct tx_provdisc_req_info tx_prov_disc_info;
236         struct rx_provdisc_req_info rx_prov_disc_info;
237         struct tx_invite_req_info invitereq_info;
238         struct profile_info             profileinfo[ P2P_MAX_PERSISTENT_GROUP_NUM ];    /*      Store the profile information of persistent group */
239         struct tx_invite_resp_info inviteresp_info;
240         struct tx_nego_req_info nego_req_info;
241         struct group_id_info    groupid_info;   /*      Store the group id information when doing the group negotiation handshake. */
242         struct scan_limit_info  rx_invitereq_info;      /*      Used for get the limit scan channel from the Invitation procedure */
243         struct scan_limit_info  p2p_info;               /*      Used for get the limit scan channel from the P2P negotiation handshake */
244         enum P2P_ROLE                   role;
245         enum P2P_STATE                  pre_p2p_state;
246         enum P2P_STATE                  p2p_state;
247         u8                              device_addr[ETH_ALEN];  /*      The device address should be the mac address of this device. */
248         u8                              interface_addr[ETH_ALEN];
249         u8                              social_chan[4];
250         u8                              listen_channel;
251         u8                              operating_channel;
252         u8                              listen_dwell;           /*      This value should be between 1 and 3 */
253         u8                              support_rate[8];
254         u8                              p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
255         u8                              intent;         /*      should only include the intent value. */
256         u8                              p2p_peer_interface_addr[ ETH_ALEN ];
257         u8                              p2p_peer_device_addr[ ETH_ALEN ];
258         u8                              peer_intent;    /*      Included the intent value and tie breaker value. */
259         u8                              device_name[ WPS_MAX_DEVICE_NAME_LEN ]; /*      Device name for displaying on searching device screen */
260         u8                              device_name_len;
261         u8                              profileindex;   /*      Used to point to the index of profileinfo array */
262         u8                              peer_operating_ch;
263         u8                              find_phase_state_exchange_cnt;
264         u16                                     device_password_id_for_nego;    /*      The device password ID for group negotation */
265         u8                              negotiation_dialog_token;
266         u8                              nego_ssid[ WLAN_SSID_MAXLEN ];  /*      SSID information for group negotitation */
267         u8                              nego_ssidlen;
268         u8                              p2p_group_ssid[WLAN_SSID_MAXLEN];
269         u8                              p2p_group_ssid_len;
270         u8                              persistent_supported;           /*      Flag to know the persistent function should be supported or not. */
271                                                                                                                 /*      In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI. */
272                                                                                                                 /*      0: disable */
273                                                                                                                 /*      1: enable */
274         u8                              session_available;                      /*      Flag to set the WFD session available to enable or disable "by Sigma" */
275                                                                                                                 /*      In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI. */
276                                                                                                                 /*      0: disable */
277                                                                                                                 /*      1: enable */
278
279         u8                              wfd_tdls_enable;                        /*      Flag to enable or disable the TDLS by WFD Sigma */
280                                                                                                                 /*      0: disable */
281                                                                                                                 /*      1: enable */
282         u8                              wfd_tdls_weaksec;                       /*      Flag to enable or disable the weak security function for TDLS by WFD Sigma */
283                                                                                                                 /*      0: disable */
284                                                                                                                 /*      In this case, the driver can't issue the tdsl setup request frame. */
285                                                                                                                 /*      1: enable */
286                                                                                                                 /*      In this case, the driver can issue the tdls setup request frame */
287                                                                                                                 /*      even the current security is weak security. */
288
289         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. */
290         u16                                     supported_wps_cm;                       /*      This field describes the WPS config method which this driver supported. */
291                                                                                                                 /*      The value should be the combination of config method defined in page104 of WPS v2.0 spec. */
292         u8                              external_uuid;                          /*  UUID flag */
293         u8                              uuid[16];                                       /*  UUID */
294         uint                                            channel_list_attr_len;          /*      This field will contain the length of body of P2P Channel List attribute of group negotitation response frame. */
295         u8                              channel_list_attr[100];         /*      This field will contain the body of P2P Channel List attribute of group negotitation response frame. */
296                                                                                                                 /*      We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame. */
297         u8                              driver_interface;                       /*      Indicate DRIVER_WEXT or DRIVER_CFG80211 */
298 };
299
300 struct tdls_ss_record{  /* signal strength record */
301         u8 macaddr[ETH_ALEN];
302         u8 RxPWDBAll;
303         u8 is_tdls_sta; /*  true: direct link sta, false: else */
304 };
305
306 struct tdls_info{
307         u8                      ap_prohibited;
308         u8                      link_established;
309         u8                      sta_cnt;
310         u8                      sta_maximum;    /*  1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */
311         struct tdls_ss_record   ss_record;
312         u8                      ch_sensing;
313         u8                      cur_channel;
314         u8                      candidate_ch;
315         u8                      collect_pkt_num[MAX_CHANNEL_NUM];
316         _lock                           cmd_lock;
317         _lock                           hdl_lock;
318         u8                      watchdog_count;
319         u8                      dev_discovered;         /* WFD_TDLS: for sigma test */
320         u8                      tdls_enable;
321         u8                      external_setup; /*  true: setup is handled by wpa_supplicant */
322 };
323
324 struct tdls_txmgmt {
325         u8 peer[ETH_ALEN];
326         u8 action_code;
327         u8 dialog_token;
328         u16 status_code;
329         u8 *buf;
330         size_t len;
331         u8 external_support;
332 };
333
334 /* used for mlme_priv.roam_flags */
335 enum {
336         RTW_ROAM_ON_EXPIRED = BIT0,
337         RTW_ROAM_ON_RESUME = BIT1,
338         RTW_ROAM_ACTIVE = BIT2,
339 };
340
341 struct mlme_priv {
342
343         _lock   lock;
344         sint    fw_state;       /* shall we protect this variable? maybe not necessarily... */
345         u8 bScanInProcess;
346         u8 to_join; /* flag */
347
348         u8 to_roam; /* roaming trying times */
349         struct wlan_network *roam_network; /* the target of active roam */
350         u8 roam_flags;
351         u8 roam_rssi_diff_th; /* rssi difference threshold for active scan candidate selection */
352         u32 roam_scan_int_ms; /* scan interval for active roam */
353         u32 roam_scanr_exp_ms; /* scan result expire time in ms  for roam */
354         u8 roam_tgt_addr[ETH_ALEN]; /* request to roam to speicific target without other consideration */
355
356         u8 *nic_hdl;
357
358         u8 not_indic_disco;
359         struct list_head                *pscanned;
360         struct __queue  free_bss_pool;
361         struct __queue  scanned_queue;
362         u8 *free_bss_buf;
363         u32 num_of_scanned;
364
365         struct ndis_802_11_ssid assoc_ssid;
366         u8 assoc_bssid[6];
367
368         struct wlan_network     cur_network;
369         struct wlan_network *cur_network_scanned;
370
371         /* uint wireless_mode; no used, remove it */
372
373         u32 auto_scan_int_ms;
374
375         _timer assoc_timer;
376
377         uint assoc_by_bssid;
378         uint assoc_by_rssi;
379
380         _timer scan_to_timer; /*  driver itself handles scan_timeout status. */
381         unsigned long scan_start_time; /*  used to evaluate the time spent in scanning */
382
383         _timer set_scan_deny_timer;
384         atomic_t set_scan_deny; /* 0: allowed, 1: deny */
385
386         struct qos_priv qospriv;
387
388         /* Number of non-HT AP/stations */
389         int num_sta_no_ht;
390
391         /* Number of HT AP/stations 20 MHz */
392         /* int num_sta_ht_20mhz; */
393
394
395         int num_FortyMHzIntolerant;
396
397         struct ht_priv htpriv;
398
399         RT_LINK_DETECT_T        LinkDetectInfo;
400         _timer  dynamic_chk_timer; /* dynamic/periodic check timer */
401
402         u8 acm_mask; /*  for wmm acm mask */
403         u8 ChannelPlan;
404         RT_SCAN_TYPE    scan_mode; /*  active: 1, passive: 0 */
405
406         u8 *wps_probe_req_ie;
407         u32 wps_probe_req_ie_len;
408
409         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
410          * in 802.11g BSS) */
411         int num_sta_non_erp;
412
413         /* Number of associated stations that do not support Short Slot Time */
414         int num_sta_no_short_slot_time;
415
416         /* Number of associated stations that do not support Short Preamble */
417         int num_sta_no_short_preamble;
418
419         int olbc; /* Overlapping Legacy BSS Condition */
420
421         /* Number of HT associated stations that do not support greenfield */
422         int num_sta_ht_no_gf;
423
424         /* Number of associated non-HT stations */
425         /* int num_sta_no_ht; */
426
427         /* Number of HT associated stations 20 MHz */
428         int num_sta_ht_20mhz;
429
430         /* Overlapping BSS information */
431         int olbc_ht;
432
433         u16 ht_op_mode;
434
435         u8 *assoc_req;
436         u32 assoc_req_len;
437         u8 *assoc_rsp;
438         u32 assoc_rsp_len;
439
440         u8 *wps_beacon_ie;
441         /* u8 *wps_probe_req_ie; */
442         u8 *wps_probe_resp_ie;
443         u8 *wps_assoc_resp_ie; /*  for CONFIG_IOCTL_CFG80211, this IE could include p2p ie / wfd ie */
444
445         u32 wps_beacon_ie_len;
446         /* u32 wps_probe_req_ie_len; */
447         u32 wps_probe_resp_ie_len;
448         u32 wps_assoc_resp_ie_len; /*  for CONFIG_IOCTL_CFG80211, this IE len could include p2p ie / wfd ie */
449
450         u8 *p2p_beacon_ie;
451         u8 *p2p_probe_req_ie;
452         u8 *p2p_probe_resp_ie;
453         u8 *p2p_go_probe_resp_ie; /* for GO */
454         u8 *p2p_assoc_req_ie;
455
456         u32 p2p_beacon_ie_len;
457         u32 p2p_probe_req_ie_len;
458         u32 p2p_probe_resp_ie_len;
459         u32 p2p_go_probe_resp_ie_len; /* for GO */
460         u32 p2p_assoc_req_ie_len;
461
462         _lock   bcn_update_lock;
463         u8 update_bcn;
464
465 #ifdef CONFIG_INTEL_WIDI
466         int     widi_state;
467         int     listen_state;
468         _timer  listen_timer;
469         atomic_t        rx_probe_rsp; /*  1:receive probe respone from RDS source. */
470         u8 *l2sdTaBuffer;
471         u8 channel_idx;
472         u8 group_cnt;   /* In WiDi 3.5, they specified another scan algo. for WFD/RDS co-existed */
473         u8 sa_ext[L2SDTA_SERVICE_VE_LEN];
474
475         u8 widi_enable;
476         /**
477          * For WiDi 4; upper layer would set
478          * p2p_primary_device_type_category_id
479          * p2p_primary_device_type_sub_category_id
480          * p2p_secondary_device_type_category_id
481          * p2p_secondary_device_type_sub_category_id
482          */
483         u16 p2p_pdt_cid;
484         u16 p2p_pdt_scid;
485         u8 num_p2p_sdt;
486         u16 p2p_sdt_cid[MAX_NUM_P2P_SDT];
487         u16 p2p_sdt_scid[MAX_NUM_P2P_SDT];
488         u8 p2p_reject_disable;  /* When starting NL80211 wpa_supplicant/hostapd, it will call netdev_close */
489                                                         /* such that it will cause p2p disabled. Use this flag to reject. */
490 #endif /*  CONFIG_INTEL_WIDI */
491
492         u8 NumOfBcnInfoChkFail;
493         unsigned long   timeBcnInfoChkStart;
494 };
495
496 #define rtw_mlme_set_auto_scan_int(adapter, ms) \
497         do { \
498                 adapter->mlmepriv.auto_scan_int_ms = ms; \
499         while (0)
500
501 void rtw_mlme_reset_auto_scan_int(struct adapter *adapter);
502
503 struct hostapd_priv
504 {
505         struct adapter *padapter;
506 };
507
508 extern int hostapd_mode_init(struct adapter *padapter);
509 extern void hostapd_mode_unload(struct adapter *padapter);
510
511 extern void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf);
512 extern void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf);
513 extern void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
514 extern void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
515 extern void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
516 extern void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
517 extern void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf);
518 extern void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf);
519 extern void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf);
520
521 extern void rtw_join_timeout_handler(RTW_TIMER_HDL_ARGS);
522 extern void _rtw_scan_timeout_handler(RTW_TIMER_HDL_ARGS);
523
524 int event_thread(void *context);
525
526 extern void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall);
527 extern int rtw_init_mlme_priv(struct adapter *adapter);/*  (struct mlme_priv *pmlmepriv); */
528
529 extern void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv);
530
531
532 extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
533 extern sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue);
534 extern sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
535
536 __inline static u8 *get_bssid(struct mlme_priv *pmlmepriv)
537 {       /* if sta_mode:pmlmepriv->cur_network.network.MacAddress => bssid */
538         /*  if adhoc_mode:pmlmepriv->cur_network.network.MacAddress => ibss mac address */
539         return pmlmepriv->cur_network.network.MacAddress;
540 }
541
542 __inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
543 {
544         if (pmlmepriv->fw_state & state)
545                 return true;
546
547         return false;
548 }
549
550 __inline static sint get_fwstate(struct mlme_priv *pmlmepriv)
551 {
552         return pmlmepriv->fw_state;
553 }
554
555 /*
556  * No Limit on the calling context,
557  * therefore set it to be the critical section...
558  *
559  * ### NOTE:#### (!!!!)
560  * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
561  */
562 __inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
563 {
564         pmlmepriv->fw_state |= state;
565         /* FOR HW integration */
566         if (_FW_UNDER_SURVEY ==state) {
567                 pmlmepriv->bScanInProcess = true;
568         }
569 }
570
571 __inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
572 {
573         pmlmepriv->fw_state &= ~state;
574         /* FOR HW integration */
575         if (_FW_UNDER_SURVEY ==state) {
576                 pmlmepriv->bScanInProcess = false;
577         }
578 }
579
580 /*
581  * No Limit on the calling context,
582  * therefore set it to be the critical section...
583  */
584 __inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
585 {
586         spin_lock_bh(&pmlmepriv->lock);
587         if (check_fwstate(pmlmepriv, state) == true)
588                 pmlmepriv->fw_state ^= state;
589         spin_unlock_bh(&pmlmepriv->lock);
590 }
591
592 __inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
593 {
594         spin_lock_bh(&pmlmepriv->lock);
595         pmlmepriv->num_of_scanned = val;
596         spin_unlock_bh(&pmlmepriv->lock);
597 }
598
599 extern u16 rtw_get_capability(struct wlan_bssid_ex *bss);
600 extern void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target);
601 extern void rtw_disconnect_hdl_under_linked(struct adapter * adapter, struct sta_info *psta, u8 free_assoc);
602 extern void rtw_generate_random_ibss(u8 *pibss);
603 extern struct wlan_network* rtw_find_network(struct __queue *scanned_queue, u8 *addr);
604 extern struct wlan_network* rtw_get_oldest_wlan_network(struct __queue *scanned_queue);
605 struct wlan_network *_rtw_find_same_network(struct __queue *scanned_queue, struct wlan_network *network);
606
607 extern void rtw_free_assoc_resources(struct adapter * adapter, int lock_scanned_queue);
608 extern void rtw_indicate_disconnect(struct adapter * adapter);
609 extern void rtw_indicate_connect(struct adapter * adapter);
610 void rtw_indicate_scan_done(struct adapter *padapter, bool aborted);
611 void rtw_scan_abort(struct adapter *adapter);
612
613 extern int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len);
614 extern int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len);
615 extern void rtw_init_registrypriv_dev_network(struct adapter *adapter);
616
617 extern void rtw_update_registrypriv_dev_network(struct adapter *adapter);
618
619 extern void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
620
621 extern void _rtw_join_timeout_handler(struct adapter *adapter);
622 extern void rtw_scan_timeout_handler(struct adapter *adapter);
623
624 extern void rtw_dynamic_check_timer_handlder(struct adapter *adapter);
625 bool rtw_is_scan_deny(struct adapter *adapter);
626 void rtw_clear_scan_deny(struct adapter *adapter);
627 void rtw_set_scan_deny_timer_hdl(struct adapter *adapter);
628 void rtw_set_scan_deny(struct adapter *adapter, u32 ms);
629
630 extern int _rtw_init_mlme_priv(struct adapter *padapter);
631
632 void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
633
634 extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
635
636 /* extern struct wlan_network* _rtw_dequeue_network(struct __queue *queue); */
637
638 extern struct wlan_network* _rtw_alloc_network(struct mlme_priv *pmlmepriv);
639
640
641 extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
642 extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
643
644
645 extern struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, u8 *addr);
646
647 extern void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall);
648
649 extern sint rtw_if_up(struct adapter *padapter);
650
651 sint rtw_linked_check(struct adapter *padapter);
652
653 u8 *rtw_get_capability_from_ie(u8 *ie);
654 u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
655
656
657 void rtw_joinbss_reset(struct adapter *padapter);
658
659 void rtw_ht_use_default_setting(struct adapter *padapter);
660 void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len);
661 unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel);
662 void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channel);
663 void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitframe);
664 void rtw_append_exented_cap(struct adapter *padapter, u8 *out_ie, uint *pout_len);
665
666 int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork);
667 int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 feature);
668
669 #define rtw_roam_flags(adapter) ((adapter)->mlmepriv.roam_flags)
670 #define rtw_chk_roam_flags(adapter, flags) ((adapter)->mlmepriv.roam_flags & flags)
671 #define rtw_clr_roam_flags(adapter, flags) \
672         do { \
673                 ((adapter)->mlmepriv.roam_flags &= ~flags); \
674         } while (0)
675
676 #define rtw_set_roam_flags(adapter, flags) \
677         do { \
678                 ((adapter)->mlmepriv.roam_flags |= flags); \
679         } while (0)
680
681 #define rtw_assign_roam_flags(adapter, flags) \
682         do { \
683                 ((adapter)->mlmepriv.roam_flags = flags); \
684         } while (0)
685
686 void _rtw_roaming(struct adapter *adapter, struct wlan_network *tgt_network);
687 void rtw_roaming(struct adapter *adapter, struct wlan_network *tgt_network);
688 void rtw_set_to_roam(struct adapter *adapter, u8 to_roam);
689 u8 rtw_dec_to_roam(struct adapter *adapter);
690 u8 rtw_to_roam(struct adapter *adapter);
691 int rtw_select_roaming_candidate(struct mlme_priv *pmlmepriv);
692
693 void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u32 mstatus);
694
695 #endif /* __RTL871X_MLME_H_ */