1
2
3
4
5
6
7#ifndef __RTW_MLME_H_
8#define __RTW_MLME_H_
9
10
11#define MAX_BSS_CNT 128
12
13
14#define MAX_JOIN_TIMEOUT 6500
15
16
17
18
19#define SCANNING_TIMEOUT 8000
20
21#ifdef PALTFORM_OS_WINCE
22#define SCANQUEUE_LIFETIME 12000000
23#else
24#define SCANQUEUE_LIFETIME 20000
25#endif
26
27#define WIFI_NULL_STATE 0x00000000
28#define WIFI_ASOC_STATE 0x00000001
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
39
40#define WIFI_STA_ALIVE_CHK_STATE 0x00000400
41#define WIFI_SITE_MONITOR 0x00000800
42#ifdef WDS
43#define WIFI_WDS 0x00001000
44#define WIFI_WDS_RX_BEACON 0x00002000
45#endif
46#ifdef AUTO_CONFIG
47#define WIFI_AUTOCONF 0x00004000
48#define WIFI_AUTOCONF_IND 0x00008000
49#endif
50
51
52
53
54
55
56
57
58
59#define WIFI_MP_STATE 0x00010000
60#define WIFI_MP_CTX_BACKGROUND 0x00020000
61#define WIFI_MP_CTX_ST 0x00040000
62#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000
63#define WIFI_MP_CTX_CCK_HW 0x00100000
64#define WIFI_MP_CTX_CCK_CS 0x00200000
65#define WIFI_MP_LPBK_STATE 0x00400000
66
67
68
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
74enum dot11AuthAlgrthmNum {
75 dot11AuthAlgrthm_Open = 0,
76 dot11AuthAlgrthm_Shared,
77 dot11AuthAlgrthm_8021X,
78 dot11AuthAlgrthm_Auto,
79 dot11AuthAlgrthm_WAPI,
80 dot11AuthAlgrthm_MaxNum
81};
82
83
84typedef enum _RT_SCAN_TYPE
85{
86 SCAN_PASSIVE,
87 SCAN_ACTIVE,
88 SCAN_MIX,
89}RT_SCAN_TYPE, *PRT_SCAN_TYPE;
90
91enum _BAND
92{
93 GHZ24_50 = 0,
94 GHZ_50,
95 GHZ_24,
96 GHZ_MAX,
97};
98
99#define rtw_band_valid(band) ((band) >= GHZ24_50 && (band) < GHZ_MAX)
100
101enum DriverInterface {
102 DRIVER_WEXT = 1,
103 DRIVER_CFG80211 = 2
104};
105
106enum SCAN_RESULT_TYPE
107{
108 SCAN_RESULT_P2P_ONLY = 0,
109 SCAN_RESULT_ALL = 1,
110 SCAN_RESULT_WFD_TYPE = 2
111
112};
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130#define traffic_threshold 10
131#define traffic_scan_period 500
132
133struct sitesurvey_ctrl {
134 u64 last_tx_pkts;
135 uint last_rx_pkts;
136 sint traffic_busy;
137 _timer sitesurvey_ctrl_timer;
138};
139
140typedef struct _RT_LINK_DETECT_T{
141 u32 NumTxOkInPeriod;
142 u32 NumRxOkInPeriod;
143 u32 NumRxUnicastOkInPeriod;
144 bool bBusyTraffic;
145 bool bTxBusyTraffic;
146 bool bRxBusyTraffic;
147 bool bHigherBusyTraffic;
148 bool bHigherBusyRxTraffic;
149 bool bHigherBusyTxTraffic;
150
151 u8 TrafficTransitionCount;
152 u32 LowPowerTransitionCount;
153}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
154
155struct profile_info {
156 u8 ssidlen;
157 u8 ssid[ WLAN_SSID_MAXLEN ];
158 u8 peermac[ ETH_ALEN ];
159};
160
161struct tx_invite_req_info{
162 u8 token;
163 u8 benable;
164 u8 go_ssid[ WLAN_SSID_MAXLEN ];
165 u8 ssidlen;
166 u8 go_bssid[ ETH_ALEN ];
167 u8 peer_macaddr[ ETH_ALEN ];
168 u8 operating_ch;
169 u8 peer_ch;
170
171};
172
173struct tx_invite_resp_info{
174 u8 token;
175};
176
177struct tx_provdisc_req_info{
178 u16 wps_config_method_request;
179 u16 peer_channel_num[2];
180 struct ndis_802_11_ssid ssid;
181 u8 peerDevAddr[ ETH_ALEN ];
182 u8 peerIFAddr[ ETH_ALEN ];
183 u8 benable;
184};
185
186struct rx_provdisc_req_info{
187 u8 peerDevAddr[ ETH_ALEN ];
188 u8 strconfig_method_desc_of_prov_disc_req[4];
189
190};
191
192struct tx_nego_req_info{
193 u16 peer_channel_num[2];
194 u8 peerDevAddr[ ETH_ALEN ];
195 u8 benable;
196};
197
198struct group_id_info{
199 u8 go_device_addr[ ETH_ALEN ];
200 u8 ssid[ WLAN_SSID_MAXLEN ];
201};
202
203struct scan_limit_info{
204 u8 scan_op_ch_only;
205 u8 operation_ch[2];
206};
207
208struct cfg80211_wifidirect_info{
209 _timer remain_on_ch_timer;
210 u8 restore_channel;
211 struct ieee80211_channel remain_on_ch_channel;
212 enum nl80211_channel_type remain_on_ch_type;
213 u64 remain_on_ch_cookie;
214 bool is_ro_ch;
215 unsigned long last_ro_ch_time;
216};
217
218struct wifidirect_info{
219 struct adapter * padapter;
220 _timer find_phase_timer;
221 _timer restore_p2p_state_timer;
222
223
224 _timer pre_tx_scan_timer;
225 _timer reset_ch_sitesurvey;
226 _timer reset_ch_sitesurvey2;
227 struct tx_provdisc_req_info tx_prov_disc_info;
228 struct rx_provdisc_req_info rx_prov_disc_info;
229 struct tx_invite_req_info invitereq_info;
230 struct profile_info profileinfo[ P2P_MAX_PERSISTENT_GROUP_NUM ];
231 struct tx_invite_resp_info inviteresp_info;
232 struct tx_nego_req_info nego_req_info;
233 struct group_id_info groupid_info;
234 struct scan_limit_info rx_invitereq_info;
235 struct scan_limit_info p2p_info;
236 enum P2P_ROLE role;
237 enum P2P_STATE pre_p2p_state;
238 enum P2P_STATE p2p_state;
239 u8 device_addr[ETH_ALEN];
240 u8 interface_addr[ETH_ALEN];
241 u8 social_chan[4];
242 u8 listen_channel;
243 u8 operating_channel;
244 u8 listen_dwell;
245 u8 support_rate[8];
246 u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
247 u8 intent;
248 u8 p2p_peer_interface_addr[ ETH_ALEN ];
249 u8 p2p_peer_device_addr[ ETH_ALEN ];
250 u8 peer_intent;
251 u8 device_name[ WPS_MAX_DEVICE_NAME_LEN ];
252 u8 device_name_len;
253 u8 profileindex;
254 u8 peer_operating_ch;
255 u8 find_phase_state_exchange_cnt;
256 u16 device_password_id_for_nego;
257 u8 negotiation_dialog_token;
258 u8 nego_ssid[ WLAN_SSID_MAXLEN ];
259 u8 nego_ssidlen;
260 u8 p2p_group_ssid[WLAN_SSID_MAXLEN];
261 u8 p2p_group_ssid_len;
262 u8 persistent_supported;
263
264
265
266 u8 session_available;
267
268
269
270
271 u8 wfd_tdls_enable;
272
273
274 u8 wfd_tdls_weaksec;
275
276
277
278
279
280
281 enum P2P_WPSINFO ui_got_wps_info;
282 u16 supported_wps_cm;
283
284 u8 external_uuid;
285 u8 uuid[16];
286 uint channel_list_attr_len;
287 u8 channel_list_attr[100];
288
289 u8 driver_interface;
290};
291
292struct tdls_ss_record{
293 u8 macaddr[ETH_ALEN];
294 u8 rx_pwd_ba11;
295 u8 is_tdls_sta;
296};
297
298struct tdls_info{
299 u8 ap_prohibited;
300 u8 link_established;
301 u8 sta_cnt;
302 u8 sta_maximum;
303 struct tdls_ss_record ss_record;
304 u8 ch_sensing;
305 u8 cur_channel;
306 u8 candidate_ch;
307 u8 collect_pkt_num[MAX_CHANNEL_NUM];
308 _lock cmd_lock;
309 _lock hdl_lock;
310 u8 watchdog_count;
311 u8 dev_discovered;
312 u8 tdls_enable;
313 u8 external_setup;
314};
315
316struct tdls_txmgmt {
317 u8 peer[ETH_ALEN];
318 u8 action_code;
319 u8 dialog_token;
320 u16 status_code;
321 u8 *buf;
322 size_t len;
323 u8 external_support;
324};
325
326
327enum {
328 RTW_ROAM_ON_EXPIRED = BIT0,
329 RTW_ROAM_ON_RESUME = BIT1,
330 RTW_ROAM_ACTIVE = BIT2,
331};
332
333struct mlme_priv {
334
335 _lock lock;
336 sint fw_state;
337 u8 bScanInProcess;
338 u8 to_join;
339
340 u8 to_roam;
341 struct wlan_network *roam_network;
342 u8 roam_flags;
343 u8 roam_rssi_diff_th;
344 u32 roam_scan_int_ms;
345 u32 roam_scanr_exp_ms;
346 u8 roam_tgt_addr[ETH_ALEN];
347
348 u8 *nic_hdl;
349
350 u8 not_indic_disco;
351 struct list_head *pscanned;
352 struct __queue free_bss_pool;
353 struct __queue scanned_queue;
354 u8 *free_bss_buf;
355 u32 num_of_scanned;
356
357 struct ndis_802_11_ssid assoc_ssid;
358 u8 assoc_bssid[6];
359
360 struct wlan_network cur_network;
361 struct wlan_network *cur_network_scanned;
362
363
364
365 u32 auto_scan_int_ms;
366
367 _timer assoc_timer;
368
369 uint assoc_by_bssid;
370 uint assoc_by_rssi;
371
372 _timer scan_to_timer;
373 unsigned long scan_start_time;
374
375 _timer set_scan_deny_timer;
376 atomic_t set_scan_deny;
377
378 struct qos_priv qospriv;
379
380
381 int num_sta_no_ht;
382
383
384
385
386
387 int num_FortyMHzIntolerant;
388
389 struct ht_priv htpriv;
390
391 RT_LINK_DETECT_T LinkDetectInfo;
392 _timer dynamic_chk_timer;
393
394 u8 acm_mask;
395 u8 ChannelPlan;
396 RT_SCAN_TYPE scan_mode;
397
398 u8 *wps_probe_req_ie;
399 u32 wps_probe_req_ie_len;
400
401
402
403 int num_sta_non_erp;
404
405
406 int num_sta_no_short_slot_time;
407
408
409 int num_sta_no_short_preamble;
410
411 int olbc;
412
413
414 int num_sta_ht_no_gf;
415
416
417
418
419
420 int num_sta_ht_20mhz;
421
422
423 int olbc_ht;
424
425 u16 ht_op_mode;
426
427 u8 *assoc_req;
428 u32 assoc_req_len;
429 u8 *assoc_rsp;
430 u32 assoc_rsp_len;
431
432 u8 *wps_beacon_ie;
433
434 u8 *wps_probe_resp_ie;
435 u8 *wps_assoc_resp_ie;
436
437 u32 wps_beacon_ie_len;
438
439 u32 wps_probe_resp_ie_len;
440 u32 wps_assoc_resp_ie_len;
441
442 u8 *p2p_beacon_ie;
443 u8 *p2p_probe_req_ie;
444 u8 *p2p_probe_resp_ie;
445 u8 *p2p_go_probe_resp_ie;
446 u8 *p2p_assoc_req_ie;
447
448 u32 p2p_beacon_ie_len;
449 u32 p2p_probe_req_ie_len;
450 u32 p2p_probe_resp_ie_len;
451 u32 p2p_go_probe_resp_ie_len;
452 u32 p2p_assoc_req_ie_len;
453
454 _lock bcn_update_lock;
455 u8 update_bcn;
456
457#ifdef CONFIG_INTEL_WIDI
458 int widi_state;
459 int listen_state;
460 _timer listen_timer;
461 atomic_t rx_probe_rsp;
462 u8 *l2sdTaBuffer;
463 u8 channel_idx;
464 u8 group_cnt;
465 u8 sa_ext[L2SDTA_SERVICE_VE_LEN];
466
467 u8 widi_enable;
468
469
470
471
472
473
474
475 u16 p2p_pdt_cid;
476 u16 p2p_pdt_scid;
477 u8 num_p2p_sdt;
478 u16 p2p_sdt_cid[MAX_NUM_P2P_SDT];
479 u16 p2p_sdt_scid[MAX_NUM_P2P_SDT];
480 u8 p2p_reject_disable;
481
482#endif
483
484 u8 NumOfBcnInfoChkFail;
485 unsigned long timeBcnInfoChkStart;
486};
487
488#define rtw_mlme_set_auto_scan_int(adapter, ms) \
489 do { \
490 adapter->mlmepriv.auto_scan_int_ms = ms; \
491 while (0)
492
493void rtw_mlme_reset_auto_scan_int(struct adapter *adapter);
494
495struct hostapd_priv
496{
497 struct adapter *padapter;
498};
499
500extern int hostapd_mode_init(struct adapter *padapter);
501extern void hostapd_mode_unload(struct adapter *padapter);
502
503extern void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf);
504extern void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf);
505extern void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
506extern void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
507extern void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
508extern void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
509extern void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf);
510extern void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf);
511extern void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf);
512
513extern void rtw_join_timeout_handler(struct timer_list *t);
514extern void _rtw_scan_timeout_handler(struct timer_list *t);
515
516int event_thread(void *context);
517
518extern void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall);
519extern int rtw_init_mlme_priv(struct adapter *adapter);
520
521extern void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv);
522
523
524extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
525extern sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue);
526extern sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
527
528__inline static u8 *get_bssid(struct mlme_priv *pmlmepriv)
529{
530
531 return pmlmepriv->cur_network.network.MacAddress;
532}
533
534__inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
535{
536 if (pmlmepriv->fw_state & state)
537 return true;
538
539 return false;
540}
541
542__inline static sint get_fwstate(struct mlme_priv *pmlmepriv)
543{
544 return pmlmepriv->fw_state;
545}
546
547
548
549
550
551
552
553
554__inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
555{
556 pmlmepriv->fw_state |= state;
557
558 if (_FW_UNDER_SURVEY ==state) {
559 pmlmepriv->bScanInProcess = true;
560 }
561}
562
563__inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
564{
565 pmlmepriv->fw_state &= ~state;
566
567 if (_FW_UNDER_SURVEY ==state) {
568 pmlmepriv->bScanInProcess = false;
569 }
570}
571
572
573
574
575
576__inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
577{
578 spin_lock_bh(&pmlmepriv->lock);
579 if (check_fwstate(pmlmepriv, state) == true)
580 pmlmepriv->fw_state ^= state;
581 spin_unlock_bh(&pmlmepriv->lock);
582}
583
584__inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
585{
586 spin_lock_bh(&pmlmepriv->lock);
587 pmlmepriv->num_of_scanned = val;
588 spin_unlock_bh(&pmlmepriv->lock);
589}
590
591extern u16 rtw_get_capability(struct wlan_bssid_ex *bss);
592extern void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target);
593extern void rtw_disconnect_hdl_under_linked(struct adapter * adapter, struct sta_info *psta, u8 free_assoc);
594extern void rtw_generate_random_ibss(u8 *pibss);
595extern struct wlan_network* rtw_find_network(struct __queue *scanned_queue, u8 *addr);
596extern struct wlan_network* rtw_get_oldest_wlan_network(struct __queue *scanned_queue);
597struct wlan_network *_rtw_find_same_network(struct __queue *scanned_queue, struct wlan_network *network);
598
599extern void rtw_free_assoc_resources(struct adapter * adapter, int lock_scanned_queue);
600extern void rtw_indicate_disconnect(struct adapter * adapter);
601extern void rtw_indicate_connect(struct adapter * adapter);
602void rtw_indicate_scan_done(struct adapter *padapter, bool aborted);
603void rtw_scan_abort(struct adapter *adapter);
604
605extern int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len);
606extern int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len);
607extern void rtw_init_registrypriv_dev_network(struct adapter *adapter);
608
609extern void rtw_update_registrypriv_dev_network(struct adapter *adapter);
610
611extern void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
612
613extern void _rtw_join_timeout_handler(struct timer_list *t);
614extern void rtw_scan_timeout_handler(struct timer_list *t);
615
616extern void rtw_dynamic_check_timer_handler(struct adapter *adapter);
617bool rtw_is_scan_deny(struct adapter *adapter);
618void rtw_clear_scan_deny(struct adapter *adapter);
619void rtw_set_scan_deny_timer_hdl(struct adapter *adapter);
620void rtw_set_scan_deny(struct adapter *adapter, u32 ms);
621
622extern int _rtw_init_mlme_priv(struct adapter *padapter);
623
624void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
625
626extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
627
628
629
630extern struct wlan_network* _rtw_alloc_network(struct mlme_priv *pmlmepriv);
631
632
633extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
634extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
635
636
637extern struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, u8 *addr);
638
639extern void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall);
640
641extern sint rtw_if_up(struct adapter *padapter);
642
643sint rtw_linked_check(struct adapter *padapter);
644
645u8 *rtw_get_capability_from_ie(u8 *ie);
646u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
647
648
649void rtw_joinbss_reset(struct adapter *padapter);
650
651void rtw_ht_use_default_setting(struct adapter *padapter);
652void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len);
653unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel);
654void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channel);
655void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitframe);
656void rtw_append_exented_cap(struct adapter *padapter, u8 *out_ie, uint *pout_len);
657
658int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork);
659int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 feature);
660
661#define rtw_roam_flags(adapter) ((adapter)->mlmepriv.roam_flags)
662#define rtw_chk_roam_flags(adapter, flags) ((adapter)->mlmepriv.roam_flags & flags)
663#define rtw_clr_roam_flags(adapter, flags) \
664 do { \
665 ((adapter)->mlmepriv.roam_flags &= ~flags); \
666 } while (0)
667
668#define rtw_set_roam_flags(adapter, flags) \
669 do { \
670 ((adapter)->mlmepriv.roam_flags |= flags); \
671 } while (0)
672
673#define rtw_assign_roam_flags(adapter, flags) \
674 do { \
675 ((adapter)->mlmepriv.roam_flags = flags); \
676 } while (0)
677
678void _rtw_roaming(struct adapter *adapter, struct wlan_network *tgt_network);
679void rtw_roaming(struct adapter *adapter, struct wlan_network *tgt_network);
680void rtw_set_to_roam(struct adapter *adapter, u8 to_roam);
681u8 rtw_dec_to_roam(struct adapter *adapter);
682u8 rtw_to_roam(struct adapter *adapter);
683int rtw_select_roaming_candidate(struct mlme_priv *pmlmepriv);
684
685void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u32 mstatus);
686
687#endif
688