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