1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef __RTW_MLME_H_
16#define __RTW_MLME_H_
17
18#include <osdep_service.h>
19#include <mlme_osdep.h>
20#include <drv_types.h>
21#include <wlan_bssdef.h>
22
23#define MAX_BSS_CNT 128
24#define MAX_JOIN_TIMEOUT 6500
25
26
27
28#define SCANNING_TIMEOUT 8000
29
30#define SCAN_INTERVAL (30)
31
32#define SCANQUEUE_LIFETIME 20
33
34#define WIFI_NULL_STATE 0x00000000
35
36#define WIFI_ASOC_STATE 0x00000001
37#define WIFI_REASOC_STATE 0x00000002
38#define WIFI_SLEEP_STATE 0x00000004
39#define WIFI_STATION_STATE 0x00000008
40
41#define WIFI_AP_STATE 0x00000010
42#define WIFI_ADHOC_STATE 0x00000020
43#define WIFI_ADHOC_MASTER_STATE 0x00000040
44#define WIFI_UNDER_LINKING 0x00000080
45
46#define WIFI_UNDER_WPS 0x00000100
47#define WIFI_STA_ALIVE_CHK_STATE 0x00000400
48#define WIFI_SITE_MONITOR 0x00000800
49
50#define WIFI_MP_STATE 0x00010000
51#define WIFI_MP_CTX_BACKGROUND 0x00020000
52#define WIFI_MP_CTX_ST 0x00040000
53#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000
54#define WIFI_MP_CTX_CCK_HW 0x00100000
55#define WIFI_MP_CTX_CCK_CS 0x00200000
56#define WIFI_MP_LPBK_STATE 0x00400000
57
58#define _FW_UNDER_LINKING WIFI_UNDER_LINKING
59#define _FW_LINKED WIFI_ASOC_STATE
60#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
61
62enum dot11AuthAlgrthmNum {
63 dot11AuthAlgrthm_Open = 0,
64 dot11AuthAlgrthm_Shared,
65 dot11AuthAlgrthm_8021X,
66 dot11AuthAlgrthm_Auto,
67 dot11AuthAlgrthm_WAPI,
68 dot11AuthAlgrthm_MaxNum
69};
70
71
72enum rt_scan_type {
73 SCAN_PASSIVE,
74 SCAN_ACTIVE,
75 SCAN_MIX,
76};
77
78enum SCAN_RESULT_TYPE {
79 SCAN_RESULT_P2P_ONLY = 0,
80 SCAN_RESULT_ALL = 1,
81
82 SCAN_RESULT_WFD_TYPE = 2
83
84
85
86
87};
88
89
90
91
92
93
94
95
96
97
98
99
100
101#define traffic_threshold 10
102#define traffic_scan_period 500
103
104struct rt_link_detect {
105 u32 NumTxOkInPeriod;
106 u32 NumRxOkInPeriod;
107 u32 NumRxUnicastOkInPeriod;
108 bool bBusyTraffic;
109 bool bTxBusyTraffic;
110 bool bRxBusyTraffic;
111 bool bHigherBusyTraffic;
112 bool bHigherBusyRxTraffic;
113
114 bool bHigherBusyTxTraffic;
115
116};
117
118struct profile_info {
119 u8 ssidlen;
120 u8 ssid[WLAN_SSID_MAXLEN];
121 u8 peermac[ETH_ALEN];
122};
123
124struct tx_invite_req_info {
125 u8 token;
126 u8 benable;
127 u8 go_ssid[WLAN_SSID_MAXLEN];
128 u8 ssidlen;
129 u8 go_bssid[ETH_ALEN];
130 u8 peer_macaddr[ETH_ALEN];
131 u8 operating_ch;
132
133 u8 peer_ch;
134};
135
136struct tx_invite_resp_info {
137 u8 token;
138
139};
140
141struct tx_provdisc_req_info {
142 u16 wps_config_method_request;
143
144 u16 peer_channel_num[2];
145
146 struct ndis_802_11_ssid ssid;
147 u8 peerDevAddr[ETH_ALEN];
148 u8 peerIFAddr[ETH_ALEN];
149 u8 benable;
150
151
152};
153
154
155
156
157
158struct rx_provdisc_req_info {
159 u8 peerDevAddr[ETH_ALEN];
160 u8 strconfig_method_desc_of_prov_disc_req[4];
161
162
163};
164
165struct tx_nego_req_info {
166 u16 peer_channel_num[2];
167 u8 peerDevAddr[ETH_ALEN];
168 u8 benable;
169
170};
171
172struct group_id_info {
173 u8 go_device_addr[ETH_ALEN];
174
175 u8 ssid[WLAN_SSID_MAXLEN];
176};
177
178struct scan_limit_info {
179 u8 scan_op_ch_only;
180
181 u8 operation_ch[2];
182};
183
184struct wifidirect_info {
185 struct adapter *padapter;
186 struct timer_list find_phase_timer;
187 struct timer_list restore_p2p_state_timer;
188
189
190
191 struct timer_list pre_tx_scan_timer;
192 struct timer_list reset_ch_sitesurvey;
193 struct timer_list reset_ch_sitesurvey2;
194
195 struct tx_provdisc_req_info tx_prov_disc_info;
196 struct rx_provdisc_req_info rx_prov_disc_info;
197 struct tx_invite_req_info invitereq_info;
198
199 struct profile_info profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM];
200 struct tx_invite_resp_info inviteresp_info;
201 struct tx_nego_req_info nego_req_info;
202
203 struct group_id_info groupid_info;
204
205 struct scan_limit_info rx_invitereq_info;
206
207 struct scan_limit_info p2p_info;
208 enum P2P_ROLE role;
209 enum P2P_STATE pre_p2p_state;
210 enum P2P_STATE p2p_state;
211
212 u8 device_addr[ETH_ALEN];
213 u8 interface_addr[ETH_ALEN];
214 u8 social_chan[4];
215 u8 listen_channel;
216 u8 operating_channel;
217 u8 listen_dwell;
218 u8 support_rate[8];
219 u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
220 u8 intent;
221 u8 p2p_peer_interface_addr[ETH_ALEN];
222 u8 p2p_peer_device_addr[ETH_ALEN];
223 u8 peer_intent;
224
225 u8 device_name[WPS_MAX_DEVICE_NAME_LEN];
226 u8 device_name_len;
227 u8 profileindex;
228 u8 peer_operating_ch;
229 u8 find_phase_state_exchange_cnt;
230
231 u16 device_password_id_for_nego;
232 u8 negotiation_dialog_token;
233
234 u8 nego_ssid[WLAN_SSID_MAXLEN];
235 u8 nego_ssidlen;
236 u8 p2p_group_ssid[WLAN_SSID_MAXLEN];
237 u8 p2p_group_ssid_len;
238
239 u8 persistent_supported;
240
241
242
243
244 u8 session_available;
245
246
247
248
249
250 u8 wfd_tdls_enable;
251
252
253 u8 wfd_tdls_weaksec;
254
255
256
257
258
259
260
261
262
263
264
265 enum P2P_WPSINFO ui_got_wps_info;
266 u16 supported_wps_cm;
267
268
269
270
271
272 uint channel_list_attr_len;
273
274
275
276
277 u8 channel_list_attr[100];
278 enum P2P_PS_MODE p2p_ps_mode;
279 enum P2P_PS_STATE p2p_ps_state;
280 u8 noa_index;
281 u8 ctwindow;
282 u8 opp_ps;
283 u8 noa_num;
284 u8 noa_count[P2P_MAX_NOA_NUM];
285
286
287 u32 noa_duration[P2P_MAX_NOA_NUM];
288
289
290 u32 noa_interval[P2P_MAX_NOA_NUM];
291
292 u32 noa_start_time[P2P_MAX_NOA_NUM];
293};
294
295struct mlme_priv {
296 spinlock_t lock;
297 int fw_state;
298 u8 bScanInProcess;
299 u8 to_join;
300 u8 to_roaming;
301
302 u8 *nic_hdl;
303
304 struct list_head *pscanned;
305 struct __queue free_bss_pool;
306 struct __queue scanned_queue;
307 u8 *free_bss_buf;
308
309 struct ndis_802_11_ssid assoc_ssid;
310 u8 assoc_bssid[6];
311
312 struct wlan_network cur_network;
313
314 u32 scan_interval;
315
316 struct timer_list assoc_timer;
317
318 uint assoc_by_bssid;
319
320 struct timer_list scan_to_timer;
321
322 struct qos_priv qospriv;
323
324
325 int num_sta_no_ht;
326
327
328
329
330 int num_FortyMHzIntolerant;
331 struct ht_priv htpriv;
332 struct rt_link_detect LinkDetectInfo;
333 struct timer_list dynamic_chk_timer;
334
335 u8 key_mask;
336 u8 acm_mask;
337 u8 ChannelPlan;
338 enum rt_scan_type scan_mode;
339
340
341
342 u8 *wps_probe_req_ie;
343 u32 wps_probe_req_ie_len;
344
345 u8 *assoc_req;
346 u32 assoc_req_len;
347 u8 *assoc_rsp;
348 u32 assoc_rsp_len;
349
350#if defined(CONFIG_88EU_AP_MODE)
351
352
353 int num_sta_non_erp;
354
355
356 int num_sta_no_short_slot_time;
357
358
359 int num_sta_no_short_preamble;
360
361 int olbc;
362
363
364 int num_sta_ht_no_gf;
365
366
367
368
369
370 int num_sta_ht_20mhz;
371
372
373 int olbc_ht;
374
375 u16 ht_op_mode;
376
377 u8 *wps_beacon_ie;
378
379 u8 *wps_probe_resp_ie;
380 u8 *wps_assoc_resp_ie;
381
382 u32 wps_beacon_ie_len;
383 u32 wps_probe_resp_ie_len;
384 u32 wps_assoc_resp_ie_len;
385
386 spinlock_t bcn_update_lock;
387 u8 update_bcn;
388#endif
389};
390
391#ifdef CONFIG_88EU_AP_MODE
392
393struct hostapd_priv {
394 struct adapter *padapter;
395};
396
397int hostapd_mode_init(struct adapter *padapter);
398void hostapd_mode_unload(struct adapter *padapter);
399#endif
400
401extern unsigned char WPA_TKIP_CIPHER[4];
402extern unsigned char RSN_TKIP_CIPHER[4];
403extern unsigned char REALTEK_96B_IE[];
404extern unsigned char MCS_rate_2R[16];
405extern unsigned char MCS_rate_1R[16];
406
407void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf);
408void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf);
409void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
410void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
411void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
412void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
413void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf);
414void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf);
415void indicate_wx_scan_complete_event(struct adapter *padapter);
416void rtw_indicate_wx_assoc_event(struct adapter *padapter);
417void rtw_indicate_wx_disassoc_event(struct adapter *padapter);
418int event_thread(void *context);
419void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall);
420int rtw_init_mlme_priv(struct adapter *adapter);
421void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
422int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
423int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv,
424 int keyid, u8 set_tx);
425int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
426
427static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
428{
429
430 return pmlmepriv->cur_network.network.MacAddress;
431}
432
433static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state)
434{
435 if (pmlmepriv->fw_state & state)
436 return true;
437
438 return false;
439}
440
441static inline int get_fwstate(struct mlme_priv *pmlmepriv)
442{
443 return pmlmepriv->fw_state;
444}
445
446
447
448
449
450
451
452
453static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state)
454{
455 pmlmepriv->fw_state |= state;
456
457 if (_FW_UNDER_SURVEY == state)
458 pmlmepriv->bScanInProcess = true;
459}
460
461static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state)
462{
463 pmlmepriv->fw_state &= ~state;
464
465 if (_FW_UNDER_SURVEY == state)
466 pmlmepriv->bScanInProcess = false;
467}
468
469
470
471
472
473static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state)
474{
475 spin_lock_bh(&pmlmepriv->lock);
476 if (check_fwstate(pmlmepriv, state) == true)
477 pmlmepriv->fw_state ^= state;
478 spin_unlock_bh(&pmlmepriv->lock);
479}
480
481static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state)
482{
483 spin_lock_bh(&pmlmepriv->lock);
484 _clr_fwstate_(pmlmepriv, state);
485 spin_unlock_bh(&pmlmepriv->lock);
486}
487
488u16 rtw_get_capability(struct wlan_bssid_ex *bss);
489void rtw_update_scanned_network(struct adapter *adapter,
490 struct wlan_bssid_ex *target);
491void rtw_disconnect_hdl_under_linked(struct adapter *adapter,
492 struct sta_info *psta, u8 free_assoc);
493void rtw_generate_random_ibss(u8 *pibss);
494struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr);
495struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue);
496
497void rtw_free_assoc_resources(struct adapter *adapter);
498void rtw_free_assoc_resources_locked(struct adapter *adapter);
499void rtw_indicate_disconnect(struct adapter *adapter);
500void rtw_indicate_connect(struct adapter *adapter);
501void rtw_indicate_scan_done(struct adapter *padapter, bool aborted);
502void rtw_scan_abort(struct adapter *adapter);
503
504int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
505 uint in_len);
506int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
507 uint in_len, uint initial_out_len);
508void rtw_init_registrypriv_dev_network(struct adapter *adapter);
509
510void rtw_update_registrypriv_dev_network(struct adapter *adapter);
511
512void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
513
514void _rtw_join_timeout_handler(unsigned long data);
515void rtw_scan_timeout_handler(unsigned long data);
516
517void rtw_dynamic_check_timer_handlder(unsigned long data);
518#define rtw_is_scan_deny(adapter) false
519#define rtw_clear_scan_deny(adapter) do {} while (0)
520#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
521#define rtw_set_scan_deny(adapter, ms) do {} while (0)
522
523void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
524
525struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv);
526
527void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv,
528 struct wlan_network *pnetwork);
529
530int rtw_if_up(struct adapter *padapter);
531
532u8 *rtw_get_capability_from_ie(u8 *ie);
533u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
534
535void rtw_joinbss_reset(struct adapter *padapter);
536
537unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie,
538 u8 *out_ie, uint in_len, uint *pout_len);
539void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len);
540void rtw_issue_addbareq_cmd(struct adapter *padapter,
541 struct xmit_frame *pxmitframe);
542
543int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork);
544int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst);
545
546void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
547void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
548
549void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta);
550
551#endif
552