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 _FW_UNDER_LINKING WIFI_UNDER_LINKING
51#define _FW_LINKED WIFI_ASOC_STATE
52#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
53
54enum dot11AuthAlgrthmNum {
55 dot11AuthAlgrthm_Open = 0,
56 dot11AuthAlgrthm_Shared,
57 dot11AuthAlgrthm_8021X,
58 dot11AuthAlgrthm_Auto,
59 dot11AuthAlgrthm_WAPI,
60 dot11AuthAlgrthm_MaxNum
61};
62
63
64enum rt_scan_type {
65 SCAN_PASSIVE,
66 SCAN_ACTIVE,
67 SCAN_MIX,
68};
69
70enum SCAN_RESULT_TYPE {
71 SCAN_RESULT_P2P_ONLY = 0,
72 SCAN_RESULT_ALL = 1,
73
74
75 SCAN_RESULT_WFD_TYPE = 2
76
77
78
79
80
81
82};
83
84
85
86
87
88
89
90
91
92
93
94
95
96#define traffic_threshold 10
97#define traffic_scan_period 500
98
99struct rt_link_detect {
100 u32 NumTxOkInPeriod;
101 u32 NumRxOkInPeriod;
102 u32 NumRxUnicastOkInPeriod;
103 bool bBusyTraffic;
104 bool bTxBusyTraffic;
105 bool bRxBusyTraffic;
106 bool bHigherBusyTraffic;
107 bool bHigherBusyRxTraffic;
108
109
110 bool bHigherBusyTxTraffic;
111
112
113};
114
115struct mlme_priv {
116 spinlock_t lock;
117 int fw_state;
118 u8 bScanInProcess;
119 u8 to_join;
120 u8 to_roaming;
121
122 u8 *nic_hdl;
123
124 struct list_head *pscanned;
125 struct __queue free_bss_pool;
126 struct __queue scanned_queue;
127 u8 *free_bss_buf;
128
129 struct ndis_802_11_ssid assoc_ssid;
130 u8 assoc_bssid[6];
131
132 struct wlan_network cur_network;
133
134 u32 scan_interval;
135
136 struct timer_list assoc_timer;
137
138 uint assoc_by_bssid;
139
140 struct timer_list scan_to_timer;
141
142 struct qos_priv qospriv;
143
144
145 int num_sta_no_ht;
146
147
148
149
150 int num_FortyMHzIntolerant;
151 struct ht_priv htpriv;
152 struct rt_link_detect LinkDetectInfo;
153 struct timer_list dynamic_chk_timer;
154
155 u8 key_mask;
156 u8 acm_mask;
157 u8 ChannelPlan;
158 enum rt_scan_type scan_mode;
159
160
161
162 u8 *wps_probe_req_ie;
163 u32 wps_probe_req_ie_len;
164
165 u8 *assoc_req;
166 u32 assoc_req_len;
167 u8 *assoc_rsp;
168 u32 assoc_rsp_len;
169
170#if defined(CONFIG_88EU_AP_MODE)
171
172
173
174 int num_sta_non_erp;
175
176
177 int num_sta_no_short_slot_time;
178
179
180 int num_sta_no_short_preamble;
181
182 int olbc;
183
184
185 int num_sta_ht_no_gf;
186
187
188
189
190
191 int num_sta_ht_20mhz;
192
193
194 int olbc_ht;
195
196 u16 ht_op_mode;
197
198 u8 *wps_beacon_ie;
199
200 u8 *wps_probe_resp_ie;
201 u8 *wps_assoc_resp_ie;
202
203 u32 wps_beacon_ie_len;
204 u32 wps_probe_resp_ie_len;
205 u32 wps_assoc_resp_ie_len;
206
207 spinlock_t bcn_update_lock;
208 u8 update_bcn;
209#endif
210};
211
212#ifdef CONFIG_88EU_AP_MODE
213
214struct hostapd_priv {
215 struct adapter *padapter;
216};
217
218int hostapd_mode_init(struct adapter *padapter);
219void hostapd_mode_unload(struct adapter *padapter);
220#endif
221
222extern unsigned char WPA_TKIP_CIPHER[4];
223extern unsigned char RSN_TKIP_CIPHER[4];
224extern unsigned char REALTEK_96B_IE[];
225extern unsigned char MCS_rate_1R[16];
226
227void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf);
228void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf);
229void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
230void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
231void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
232void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
233void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf);
234void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf);
235void indicate_wx_scan_complete_event(struct adapter *padapter);
236void rtw_indicate_wx_assoc_event(struct adapter *padapter);
237void rtw_indicate_wx_disassoc_event(struct adapter *padapter);
238int event_thread(void *context);
239void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall);
240int rtw_init_mlme_priv(struct adapter *adapter);
241void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
242int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
243int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv,
244 int keyid, u8 set_tx);
245int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
246
247static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
248{
249
250 return pmlmepriv->cur_network.network.MacAddress;
251}
252
253static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state)
254{
255 if (pmlmepriv->fw_state & state)
256 return true;
257
258 return false;
259}
260
261static inline int get_fwstate(struct mlme_priv *pmlmepriv)
262{
263 return pmlmepriv->fw_state;
264}
265
266
267
268
269
270
271
272
273static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state)
274{
275 pmlmepriv->fw_state |= state;
276
277 if (_FW_UNDER_SURVEY == state)
278 pmlmepriv->bScanInProcess = true;
279}
280
281static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state)
282{
283 pmlmepriv->fw_state &= ~state;
284
285 if (_FW_UNDER_SURVEY == state)
286 pmlmepriv->bScanInProcess = false;
287}
288
289
290
291
292
293static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state)
294{
295 spin_lock_bh(&pmlmepriv->lock);
296 if (check_fwstate(pmlmepriv, state) == true)
297 pmlmepriv->fw_state ^= state;
298 spin_unlock_bh(&pmlmepriv->lock);
299}
300
301static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state)
302{
303 spin_lock_bh(&pmlmepriv->lock);
304 _clr_fwstate_(pmlmepriv, state);
305 spin_unlock_bh(&pmlmepriv->lock);
306}
307
308u16 rtw_get_capability(struct wlan_bssid_ex *bss);
309void rtw_update_scanned_network(struct adapter *adapter,
310 struct wlan_bssid_ex *target);
311void rtw_disconnect_hdl_under_linked(struct adapter *adapter,
312 struct sta_info *psta, u8 free_assoc);
313void rtw_generate_random_ibss(u8 *pibss);
314struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr);
315struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue);
316
317void rtw_free_assoc_resources(struct adapter *adapter);
318void rtw_free_assoc_resources_locked(struct adapter *adapter);
319void rtw_indicate_disconnect(struct adapter *adapter);
320void rtw_indicate_connect(struct adapter *adapter);
321void rtw_indicate_scan_done(struct adapter *padapter, bool aborted);
322void rtw_scan_abort(struct adapter *adapter);
323
324int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
325 uint in_len);
326int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
327 uint in_len, uint initial_out_len);
328void rtw_init_registrypriv_dev_network(struct adapter *adapter);
329
330void rtw_update_registrypriv_dev_network(struct adapter *adapter);
331
332void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
333
334void _rtw_join_timeout_handler(struct timer_list *t);
335void rtw_scan_timeout_handler(struct timer_list *t);
336
337void rtw_dynamic_check_timer_handlder(struct timer_list *t);
338#define rtw_is_scan_deny(adapter) false
339#define rtw_clear_scan_deny(adapter) do {} while (0)
340#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
341#define rtw_set_scan_deny(adapter, ms) do {} while (0)
342
343void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
344
345struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv);
346
347void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv,
348 struct wlan_network *pnetwork);
349
350int rtw_if_up(struct adapter *padapter);
351
352u8 *rtw_get_capability_from_ie(u8 *ie);
353u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
354
355void rtw_joinbss_reset(struct adapter *padapter);
356
357unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie,
358 u8 *out_ie, uint in_len, uint *pout_len);
359void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len);
360void rtw_issue_addbareq_cmd(struct adapter *padapter,
361 struct xmit_frame *pxmitframe);
362
363int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork);
364int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst);
365
366void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
367void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
368
369void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta);
370
371#endif
372