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 struct list_head *pscanned;
115 struct __queue free_bss_pool;
116 struct __queue scanned_queue;
117 u8 *free_bss_buf;
118
119 struct ndis_802_11_ssid assoc_ssid;
120 u8 assoc_bssid[6];
121
122 struct wlan_network cur_network;
123
124 u32 scan_interval;
125
126 struct timer_list assoc_timer;
127
128 uint assoc_by_bssid;
129
130 struct timer_list scan_to_timer;
131
132 struct qos_priv qospriv;
133
134
135 int num_sta_no_ht;
136
137
138
139
140 int num_FortyMHzIntolerant;
141 struct ht_priv htpriv;
142 struct rt_link_detect LinkDetectInfo;
143 struct timer_list dynamic_chk_timer;
144
145 u8 key_mask;
146 u8 acm_mask;
147 u8 ChannelPlan;
148 enum rt_scan_type scan_mode;
149
150
151
152 u8 *wps_probe_req_ie;
153 u32 wps_probe_req_ie_len;
154
155 u8 *assoc_req;
156 u32 assoc_req_len;
157 u8 *assoc_rsp;
158 u32 assoc_rsp_len;
159
160#if defined(CONFIG_88EU_AP_MODE)
161
162
163
164 int num_sta_non_erp;
165
166
167 int num_sta_no_short_slot_time;
168
169
170 int num_sta_no_short_preamble;
171
172 int olbc;
173
174
175 int num_sta_ht_no_gf;
176
177
178
179
180
181 int num_sta_ht_20mhz;
182
183
184 int olbc_ht;
185
186 u16 ht_op_mode;
187
188 u8 *wps_beacon_ie;
189
190 u8 *wps_probe_resp_ie;
191 u8 *wps_assoc_resp_ie;
192
193 u32 wps_beacon_ie_len;
194 u32 wps_probe_resp_ie_len;
195 u32 wps_assoc_resp_ie_len;
196
197 spinlock_t bcn_update_lock;
198 u8 update_bcn;
199#endif
200};
201
202#ifdef CONFIG_88EU_AP_MODE
203
204struct hostapd_priv {
205 struct adapter *padapter;
206};
207
208int hostapd_mode_init(struct adapter *padapter);
209void hostapd_mode_unload(struct adapter *padapter);
210#endif
211
212extern const u8 WPA_TKIP_CIPHER[4];
213extern const u8 RSN_TKIP_CIPHER[4];
214extern u8 REALTEK_96B_IE[];
215extern const u8 MCS_rate_1R[16];
216
217void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf);
218void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf);
219void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
220void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
221void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
222void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
223void indicate_wx_scan_complete_event(struct adapter *padapter);
224void rtw_indicate_wx_assoc_event(struct adapter *padapter);
225void rtw_indicate_wx_disassoc_event(struct adapter *padapter);
226int event_thread(void *context);
227void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall);
228int rtw_init_mlme_priv(struct adapter *adapter);
229void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
230int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
231int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv,
232 int keyid, u8 set_tx);
233int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
234
235static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
236{
237
238 return pmlmepriv->cur_network.network.MacAddress;
239}
240
241static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state)
242{
243 if (pmlmepriv->fw_state & state)
244 return true;
245
246 return false;
247}
248
249static inline int get_fwstate(struct mlme_priv *pmlmepriv)
250{
251 return pmlmepriv->fw_state;
252}
253
254
255
256
257
258
259
260
261static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state)
262{
263 pmlmepriv->fw_state |= state;
264
265 if (state == _FW_UNDER_SURVEY)
266 pmlmepriv->bScanInProcess = true;
267}
268
269static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state)
270{
271 pmlmepriv->fw_state &= ~state;
272
273 if (state == _FW_UNDER_SURVEY)
274 pmlmepriv->bScanInProcess = false;
275}
276
277
278
279
280
281static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state)
282{
283 spin_lock_bh(&pmlmepriv->lock);
284 if (check_fwstate(pmlmepriv, state))
285 pmlmepriv->fw_state ^= state;
286 spin_unlock_bh(&pmlmepriv->lock);
287}
288
289static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state)
290{
291 spin_lock_bh(&pmlmepriv->lock);
292 _clr_fwstate_(pmlmepriv, state);
293 spin_unlock_bh(&pmlmepriv->lock);
294}
295
296u16 rtw_get_capability(struct wlan_bssid_ex *bss);
297void rtw_update_scanned_network(struct adapter *adapter,
298 struct wlan_bssid_ex *target);
299void rtw_disconnect_hdl_under_linked(struct adapter *adapter,
300 struct sta_info *psta, u8 free_assoc);
301void rtw_generate_random_ibss(u8 *pibss);
302struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr);
303struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue);
304
305void rtw_free_assoc_resources(struct adapter *adapter);
306void rtw_free_assoc_resources_locked(struct adapter *adapter);
307void rtw_indicate_disconnect(struct adapter *adapter);
308void rtw_indicate_connect(struct adapter *adapter);
309void rtw_indicate_scan_done(struct adapter *padapter, bool aborted);
310
311int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
312 uint in_len);
313int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
314 uint in_len, uint initial_out_len);
315void rtw_init_registrypriv_dev_network(struct adapter *adapter);
316
317void rtw_update_registrypriv_dev_network(struct adapter *adapter);
318
319void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
320
321void _rtw_join_timeout_handler(struct timer_list *t);
322void rtw_scan_timeout_handler(struct timer_list *t);
323
324void rtw_dynamic_check_timer_handlder(struct timer_list *t);
325#define rtw_is_scan_deny(adapter) false
326#define rtw_clear_scan_deny(adapter) do {} while (0)
327#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
328#define rtw_set_scan_deny(adapter, ms) do {} while (0)
329
330void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
331
332struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv);
333
334int rtw_if_up(struct adapter *padapter);
335
336u8 *rtw_get_capability_from_ie(u8 *ie);
337u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
338
339void rtw_joinbss_reset(struct adapter *padapter);
340
341unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie,
342 u8 *out_ie, uint in_len, uint *pout_len);
343void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len);
344void rtw_issue_addbareq_cmd(struct adapter *padapter,
345 struct xmit_frame *pxmitframe);
346
347int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork);
348int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst);
349
350void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
351void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
352
353void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta);
354
355#endif
356