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