1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 *
19 ******************************************************************************/
20 #ifndef __RTW_MLME_H_
21 #define __RTW_MLME_H_
22
23
24 #define MAX_BSS_CNT 128
25 //#define MAX_JOIN_TIMEOUT 2000
26 //#define MAX_JOIN_TIMEOUT 2500
27 #define MAX_JOIN_TIMEOUT 6500
28
29 // Commented by Albert 20101105
30 // Increase the scanning timeout because of increasing the SURVEY_TO value.
31
32 #define SCANNING_TIMEOUT 8000
33 #ifdef CONFIG_SCAN_BACKOP
34 #define CONC_SCANNING_TIMEOUT_SINGLE_BAND 10000
35 #define CONC_SCANNING_TIMEOUT_DUAL_BAND 15000
36 #endif
37
38 #ifdef PALTFORM_OS_WINCE
39 #define SCANQUEUE_LIFETIME 12000000 // unit:us
40 #else
41 #define SCANQUEUE_LIFETIME 20000 // 20sec, unit:msec
42 #endif
43
44 #define WIFI_NULL_STATE 0x00000000
45 #define WIFI_ASOC_STATE 0x00000001 /* Linked */
46 #define WIFI_REASOC_STATE 0x00000002
47 #define WIFI_SLEEP_STATE 0x00000004
48 #define WIFI_STATION_STATE 0x00000008
49 #define WIFI_AP_STATE 0x00000010
50 #define WIFI_ADHOC_STATE 0x00000020
51 #define WIFI_ADHOC_MASTER_STATE 0x00000040
52 #define WIFI_UNDER_LINKING 0x00000080
53 #define WIFI_UNDER_WPS 0x00000100
54 /*#define WIFI_UNDEFINED_STATE 0x00000200*/
55 #define WIFI_STA_ALIVE_CHK_STATE 0x00000400
56 #define WIFI_SITE_MONITOR 0x00000800 /* under site surveying */
57 #define WIFI_WDS 0x00001000
58 #define WIFI_WDS_RX_BEACON 0x00002000 /* already rx WDS AP beacon */
59 #define WIFI_AUTOCONF 0x00004000
60 #define WIFI_AUTOCONF_IND 0x00008000
61 #define WIFI_MP_STATE 0x00010000
62 #define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continuous tx background */
63 #define WIFI_MP_CTX_ST 0x00040000 /* in continuous tx with single-tone */
64 #define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continuous tx background due to out of skb */
65 #define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continuous tx */
66 #define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continuous tx with carrier suppression */
67 #define WIFI_MP_LPBK_STATE 0x00400000
68 #define WIFI_OP_CH_SWITCHING 0x00800000
69 /*#define WIFI_UNDEFINED_STATE 0x01000000*/
70 /*#define WIFI_UNDEFINED_STATE 0x02000000*/
71 /*#define WIFI_UNDEFINED_STATE 0x04000000*/
72 /*#define WIFI_UNDEFINED_STATE 0x08000000*/
73 /*#define WIFI_UNDEFINED_STATE 0x10000000*/
74 /*#define WIFI_UNDEFINED_STATE 0x20000000*/
75 /*#define WIFI_UNDEFINED_STATE 0x40000000*/
76 #define WIFI_MONITOR_STATE 0x80000000
77
78 #define MLME_STATE_FMT "%s%s%s%s%s%s%s%s%s%s%s%s"
79 #define MLME_STATE_ARG(state) \
80 ((state) & WIFI_STATION_STATE)?" STA":"", \
81 ((state) & WIFI_AP_STATE)?" AP":"", \
82 ((state) & WIFI_ADHOC_STATE)?" ADHOC":"", \
83 ((state) & WIFI_ADHOC_MASTER_STATE)?" ADHOC_M":"", \
84 ((state) & WIFI_MONITOR_STATE)?" MONITOR":"", \
85 ((state) & WIFI_MP_STATE)?" MP":"", \
86 ((state) & WIFI_SITE_MONITOR)?" SCAN":"", \
87 ((state) & WIFI_UNDER_LINKING)?" LINKING":"", \
88 ((state) & WIFI_ASOC_STATE)?" ASOC":"", \
89 ((state) & WIFI_OP_CH_SWITCHING)?" OP_CH_SW":"", \
90 ((state) & WIFI_UNDER_WPS)?" WPS":"", \
91 ((state) & WIFI_SLEEP_STATE)?" SLEEP":""
92
93 #define ADPT_MLME_S_ARG(adapter) MLME_STATE_ARG(get_fwstate(&((adapter)->mlmepriv)))
94
95 #define _FW_UNDER_LINKING WIFI_UNDER_LINKING
96 #define _FW_LINKED WIFI_ASOC_STATE
97 #define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
98
99
100 enum dot11AuthAlgrthmNum {
101 dot11AuthAlgrthm_Open = 0,
102 dot11AuthAlgrthm_Shared,
103 dot11AuthAlgrthm_8021X,
104 dot11AuthAlgrthm_Auto,
105 dot11AuthAlgrthm_WAPI,
106 dot11AuthAlgrthm_MaxNum
107 };
108
109 // Scan type including active and passive scan.
110 typedef enum _RT_SCAN_TYPE
111 {
112 SCAN_PASSIVE,
113 SCAN_ACTIVE,
114 SCAN_MIX,
115 }RT_SCAN_TYPE, *PRT_SCAN_TYPE;
116
117 #define WIFI_FREQUENCY_BAND_AUTO 0
118 #define WIFI_FREQUENCY_BAND_5GHZ 1
119 #define WIFI_FREQUENCY_BAND_2GHZ 2
120
121 #define rtw_band_valid(band) ((band) <= WIFI_FREQUENCY_BAND_2GHZ)
122
123 enum DriverInterface {
124 DRIVER_WEXT = 1,
125 DRIVER_CFG80211 = 2
126 };
127
128 enum SCAN_RESULT_TYPE
129 {
130 SCAN_RESULT_P2P_ONLY = 0, // Will return all the P2P devices.
131 SCAN_RESULT_ALL = 1, // Will return all the scanned device, include AP.
132 SCAN_RESULT_WFD_TYPE = 2 // Will just return the correct WFD device.
133 // If this device is Miracast sink device, it will just return all the Miracast source devices.
134 };
135
136 /*
137
138 there are several "locks" in mlme_priv,
139 since mlme_priv is a shared resource between many threads,
140 like ISR/Call-Back functions, the OID handlers, and even timer functions.
141
142
143 Each _queue has its own locks, already.
144 Other items are protected by mlme_priv.lock.
145
146 To avoid possible dead lock, any thread trying to modifiying mlme_priv
147 SHALL not lock up more than one locks at a time!
148
149 */
150
151
152 #define traffic_threshold 10
153 #define traffic_scan_period 500
154
155 struct sitesurvey_ctrl {
156 u64 last_tx_pkts;
157 uint last_rx_pkts;
158 sint traffic_busy;
159 _timer sitesurvey_ctrl_timer;
160 };
161
162 typedef struct _RT_LINK_DETECT_T{
163 u32 NumTxOkInPeriod;
164 u32 NumRxOkInPeriod;
165 u32 NumRxUnicastOkInPeriod;
166 BOOLEAN bBusyTraffic;
167 BOOLEAN bTxBusyTraffic;
168 BOOLEAN bRxBusyTraffic;
169 BOOLEAN bHigherBusyTraffic; // For interrupt migration purpose.
170 BOOLEAN bHigherBusyRxTraffic; // We may disable Tx interrupt according as Rx traffic.
171 BOOLEAN bHigherBusyTxTraffic; // We may disable Tx interrupt according as Tx traffic.
172 //u8 TrafficBusyState;
173 u8 TrafficTransitionCount;
174 u32 LowPowerTransitionCount;
175 }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
176
177 struct profile_info {
178 u8 ssidlen;
179 u8 ssid[ WLAN_SSID_MAXLEN ];
180 u8 peermac[ ETH_ALEN ];
181 };
182
183 struct tx_invite_req_info{
184 u8 token;
185 u8 benable;
186 u8 go_ssid[ WLAN_SSID_MAXLEN ];
187 u8 ssidlen;
188 u8 go_bssid[ ETH_ALEN ];
189 u8 peer_macaddr[ ETH_ALEN ];
190 u8 operating_ch; // This information will be set by using the p2p_set op_ch=x
191 u8 peer_ch; // The listen channel for peer P2P device
192
193 };
194
195 struct tx_invite_resp_info{
196 u8 token; // Used to record the dialog token of p2p invitation request frame.
197 };
198
199 #define MIRACAST_DISABLED 0
200 #define MIRACAST_SOURCE 1
201 #define MIRACAST_SINK 2
202 #define MIRACAST_INVALID 3
203
204 #define is_miracast_enabled(mode) \
205 (mode == MIRACAST_SOURCE || mode == MIRACAST_SINK)
206
207 const char *get_miracast_mode_str(int mode);
208
209 #ifdef CONFIG_WFD
210
211 struct wifi_display_info{
212 u16 wfd_enable; // Eanble/Disable the WFD function.
213 u16 rtsp_ctrlport; // TCP port number at which the this WFD device listens for RTSP messages
214 u16 peer_rtsp_ctrlport; // TCP port number at which the peer WFD device listens for RTSP messages
215 // This filed should be filled when receiving the gropu negotiation request
216
217 u8 peer_session_avail; // WFD session is available or not for the peer wfd device.
218 // This variable will be set when sending the provisioning discovery request to peer WFD device.
219 // And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command.
220 u8 ip_address[4];
221 u8 peer_ip_address[4];
222 u8 wfd_pc; // WFD preferred connection
223 // 0 -> Prefer to use the P2P for WFD connection on peer side.
224 // 1 -> Prefer to use the TDLS for WFD connection on peer side.
225
226 u8 wfd_device_type; // WFD Device Type
227 // 0 -> WFD Source Device
228 // 1 -> WFD Primary Sink Device
229 enum SCAN_RESULT_TYPE scan_result_type; // Used when P2P is enable. This parameter will impact the scan result.
230 u8 stack_wfd_mode;
231 };
232 #endif //CONFIG_WFD
233
234 struct tx_provdisc_req_info{
235 u16 wps_config_method_request; // Used when sending the provisioning request frame
236 u16 peer_channel_num[2]; // The channel number which the receiver stands.
237 NDIS_802_11_SSID ssid;
238 u8 peerDevAddr[ ETH_ALEN ]; // Peer device address
239 u8 peerIFAddr[ ETH_ALEN ]; // Peer interface address
240 u8 benable; // This provision discovery request frame is trigger to send or not
241 };
242
243 struct rx_provdisc_req_info{ //When peer device issue prov_disc_req first, we should store the following informations
244 u8 peerDevAddr[ ETH_ALEN ]; // Peer device address
245 u8 strconfig_method_desc_of_prov_disc_req[4]; // description for the config method located in the provisioning discovery request frame.
246 // The UI must know this information to know which config method the remote p2p device is requiring.
247 };
248
249 struct tx_nego_req_info{
250 u16 peer_channel_num[2]; // The channel number which the receiver stands.
251 u8 peerDevAddr[ ETH_ALEN ]; // Peer device address
252 u8 benable; // This negoitation request frame is trigger to send or not
253 u8 peer_ch; /* The listen channel for peer P2P device */
254 };
255
256 struct group_id_info{
257 u8 go_device_addr[ ETH_ALEN ]; // The GO's device address of this P2P group
258 u8 ssid[ WLAN_SSID_MAXLEN ]; // The SSID of this P2P group
259 };
260
261 struct scan_limit_info{
262 u8 scan_op_ch_only; // When this flag is set, the driver should just scan the operation channel
263 #ifndef CONFIG_P2P_OP_CHK_SOCIAL_CH
264 u8 operation_ch[2]; // Store the operation channel of invitation request frame
265 #else
266 u8 operation_ch[5]; // Store additional channel 1,6,11 for Android 4.2 IOT & Nexus 4
267 #endif //CONFIG_P2P_OP_CHK_SOCIAL_CH
268 };
269
270 #ifdef CONFIG_IOCTL_CFG80211
271 struct cfg80211_wifidirect_info{
272 _timer remain_on_ch_timer;
273 u8 restore_channel;
274 struct ieee80211_channel remain_on_ch_channel;
275 enum nl80211_channel_type remain_on_ch_type;
276 ATOMIC_T ro_ch_cookie_gen;
277 u64 remain_on_ch_cookie;
278 bool is_ro_ch;
279 u32 last_ro_ch_time; /* this will be updated at the beginning and end of ro_ch */
280 };
281 #endif //CONFIG_IOCTL_CFG80211
282
283 #ifdef CONFIG_P2P_WOWLAN
284
285 enum P2P_WOWLAN_RECV_FRAME_TYPE
286 {
287 P2P_WOWLAN_RECV_NEGO_REQ = 0,
288 P2P_WOWLAN_RECV_INVITE_REQ = 1,
289 P2P_WOWLAN_RECV_PROVISION_REQ = 2,
290 };
291
292 struct p2p_wowlan_info{
293
294 u8 is_trigger;
295 enum P2P_WOWLAN_RECV_FRAME_TYPE wowlan_recv_frame_type;
296 u8 wowlan_peer_addr[ETH_ALEN];
297 u16 wowlan_peer_wpsconfig;
298 u8 wowlan_peer_is_persistent;
299 u8 wowlan_peer_invitation_type;
300 };
301
302 #endif //CONFIG_P2P_WOWLAN
303
304 struct wifidirect_info{
305 _adapter* padapter;
306 _timer find_phase_timer;
307 _timer restore_p2p_state_timer;
308
309 // Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer.
310 _timer pre_tx_scan_timer;
311 _timer reset_ch_sitesurvey;
312 _timer reset_ch_sitesurvey2; // Just for resetting the scan limit function by using p2p nego
313 #ifdef CONFIG_CONCURRENT_MODE
314 // Used to switch the channel between legacy AP and listen state.
315 _timer ap_p2p_switch_timer;
316 #endif
317 struct tx_provdisc_req_info tx_prov_disc_info;
318 struct rx_provdisc_req_info rx_prov_disc_info;
319 struct tx_invite_req_info invitereq_info;
320 struct profile_info profileinfo[ P2P_MAX_PERSISTENT_GROUP_NUM ]; // Store the profile information of persistent group
321 struct tx_invite_resp_info inviteresp_info;
322 struct tx_nego_req_info nego_req_info;
323 struct group_id_info groupid_info; // Store the group id information when doing the group negotiation handshake.
324 struct scan_limit_info rx_invitereq_info; // Used for get the limit scan channel from the Invitation procedure
325 struct scan_limit_info p2p_info; // Used for get the limit scan channel from the P2P negotiation handshake
326 #ifdef CONFIG_WFD
327 struct wifi_display_info *wfd_info;
328 #endif
329
330 #ifdef CONFIG_P2P_WOWLAN
331 struct p2p_wowlan_info p2p_wow_info;
332 #endif //CONFIG_P2P_WOWLAN
333
334 enum P2P_ROLE role;
335 enum P2P_STATE pre_p2p_state;
336 enum P2P_STATE p2p_state;
337 u8 device_addr[ETH_ALEN]; // The device address should be the mac address of this device.
338 u8 interface_addr[ETH_ALEN];
339 u8 social_chan[4];
340 u8 listen_channel;
341 u8 operating_channel;
342 u8 listen_dwell; // This value should be between 1 and 3
343 u8 support_rate[8];
344 u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
345 u8 intent; // should only include the intent value.
346 u8 p2p_peer_interface_addr[ ETH_ALEN ];
347 u8 p2p_peer_device_addr[ ETH_ALEN ];
348 u8 peer_intent; // Included the intent value and tie breaker value.
349 u8 device_name[ WPS_MAX_DEVICE_NAME_LEN ]; // Device name for displaying on searching device screen
350 u8 device_name_len;
351 u8 profileindex; // Used to point to the index of profileinfo array
352 u8 peer_operating_ch;
353 u8 find_phase_state_exchange_cnt;
354 u16 device_password_id_for_nego; // The device password ID for group negotation
355 u8 negotiation_dialog_token;
356 u8 nego_ssid[ WLAN_SSID_MAXLEN ]; // SSID information for group negotitation
357 u8 nego_ssidlen;
358 u8 p2p_group_ssid[WLAN_SSID_MAXLEN];
359 u8 p2p_group_ssid_len;
360 u8 persistent_supported; // Flag to know the persistent function should be supported or not.
361 // In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI.
362 // 0: disable
363 // 1: enable
364 u8 session_available; // Flag to set the WFD session available to enable or disable "by Sigma"
365 // In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI.
366 // 0: disable
367 // 1: enable
368
369 u8 wfd_tdls_enable; // Flag to enable or disable the TDLS by WFD Sigma
370 // 0: disable
371 // 1: enable
372 u8 wfd_tdls_weaksec; // Flag to enable or disable the weak security function for TDLS by WFD Sigma
373 // 0: disable
374 // In this case, the driver can't issue the tdsl setup request frame.
375 // 1: enable
376 // In this case, the driver can issue the tdls setup request frame
377 // even the current security is weak security.
378
379 enum P2P_WPSINFO ui_got_wps_info; // This field will store the WPS value (PIN value or PBC) that UI had got from the user.
380 u16 supported_wps_cm; // This field describes the WPS config method which this driver supported.
381 // The value should be the combination of config method defined in page104 of WPS v2.0 spec.
382 u8 external_uuid; // UUID flag
383 u8 uuid[16]; // UUID
384 uint channel_list_attr_len; // This field will contain the length of body of P2P Channel List attribute of group negotitation response frame.
385 u8 channel_list_attr[100]; // This field will contain the body of P2P Channel List attribute of group negotitation response frame.
386 // We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame.
387 u8 driver_interface; // Indicate DRIVER_WEXT or DRIVER_CFG80211
388
389 #ifdef CONFIG_CONCURRENT_MODE
390 u16 ext_listen_interval; // The interval to be available with legacy AP (ms)
391 u16 ext_listen_period; // The time period to be available for P2P listen state (ms)
392 #endif
393 #ifdef CONFIG_P2P_PS
394 enum P2P_PS_MODE p2p_ps_mode; // indicate p2p ps mode
395 enum P2P_PS_STATE p2p_ps_state; // indicate p2p ps state
396 u8 noa_index; // Identifies and instance of Notice of Absence timing.
397 u8 ctwindow; // Client traffic window. A period of time in TU after TBTT.
398 u8 opp_ps; // opportunistic power save.
399 u8 noa_num; // number of NoA descriptor in P2P IE.
400 u8 noa_count[P2P_MAX_NOA_NUM]; // Count for owner, Type of client.
401 u32 noa_duration[P2P_MAX_NOA_NUM]; // Max duration for owner, preferred or min acceptable duration for client.
402 u32 noa_interval[P2P_MAX_NOA_NUM]; // Length of interval for owner, preferred or max acceptable interval of client.
403 u32 noa_start_time[P2P_MAX_NOA_NUM]; // schedule expressed in terms of the lower 4 bytes of the TSF timer.
404 #endif // CONFIG_P2P_PS
405 };
406
407 struct tdls_ss_record{ //signal strength record
408 u8 macaddr[ETH_ALEN];
409 u8 RxPWDBAll;
410 u8 is_tdls_sta; // _TRUE: direct link sta, _FALSE: else
411 };
412
413 struct tdls_temp_mgmt{
414 u8 initiator; // 0: None, 1: we initiate, 2: peer initiate
415 u8 peer_addr[ETH_ALEN];
416 };
417
418 #ifdef CONFIG_TDLS_CH_SW
419 struct tdls_ch_switch{
420 u32 ch_sw_state;
421 ATOMIC_T chsw_on;
422 u8 addr[ETH_ALEN];
423 u8 off_ch_num;
424 u8 ch_offset;
425 u32 cur_time;
426 u8 delay_switch_back;
427 u8 dump_stack;
428 };
429 #endif
430
431 struct tdls_info{
432 u8 ap_prohibited;
433 u8 ch_switch_prohibited;
434 u8 link_established;
435 u8 sta_cnt;
436 u8 sta_maximum; /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */
437 struct tdls_ss_record ss_record;
438 #ifdef CONFIG_TDLS_CH_SW
439 struct tdls_ch_switch chsw_info;
440 #endif
441
442 u8 ch_sensing;
443 u8 cur_channel;
444 u8 collect_pkt_num[MAX_CHANNEL_NUM];
445 _lock cmd_lock;
446 _lock hdl_lock;
447 u8 watchdog_count;
448 u8 dev_discovered; /* WFD_TDLS: for sigma test */
449 u8 tdls_enable;
450
451 /* Let wpa_supplicant to setup*/
452 u8 driver_setup;
453 #ifdef CONFIG_WFD
454 struct wifi_display_info *wfd_info;
455 #endif
456 };
457
458 struct tdls_txmgmt {
459 u8 peer[ETH_ALEN];
460 u8 action_code;
461 u8 dialog_token;
462 u16 status_code;
463 u8 *buf;
464 size_t len;
465 };
466
467 /* used for mlme_priv.roam_flags */
468 enum {
469 RTW_ROAM_ON_EXPIRED = BIT0,
470 RTW_ROAM_ON_RESUME = BIT1,
471 RTW_ROAM_ACTIVE = BIT2,
472 };
473
474 struct beacon_keys {
475 u8 ssid[IW_ESSID_MAX_SIZE];
476 u32 ssid_len;
477 u8 bcn_channel;
478 u16 ht_cap_info;
479 u8 ht_info_infos_0_sco; // bit0 & bit1 in infos[0] is second channel offset
480 int encryp_protocol;
481 int pairwise_cipher;
482 int group_cipher;
483 int is_8021x;
484 };
485
486 struct mlme_priv {
487
488 _lock lock;
489 sint fw_state; //shall we protect this variable? maybe not necessarily...
490 u8 bScanInProcess;
491 u8 to_join; //flag
492 #ifdef CONFIG_LAYER2_ROAMING
493 u8 to_roam; /* roaming trying times */
494 struct wlan_network *roam_network; /* the target of active roam */
495 u8 roam_flags;
496 u8 roam_rssi_diff_th; /* rssi difference threshold for active scan candidate selection */
497 u32 roam_scan_int_ms; /* scan interval for active roam */
498 u32 roam_scanr_exp_ms; /* scan result expire time in ms for roam */
499 u8 roam_tgt_addr[ETH_ALEN]; /* request to roam to speicific target without other consideration */
500 #endif
501
502 u8 *nic_hdl;
503 #ifdef SUPPLICANT_RTK_VERSION_LOWER_THAN_JB42
504 u8 not_indic_disco;
505 #endif
506 _list *pscanned;
507 _queue free_bss_pool;
508 _queue scanned_queue;
509 u8 *free_bss_buf;
510 u32 num_of_scanned;
511
512 NDIS_802_11_SSID assoc_ssid;
513 u8 assoc_bssid[6];
514
515 struct wlan_network cur_network;
516 struct wlan_network *cur_network_scanned;
517
518 // bcn check info
519 struct beacon_keys cur_beacon_keys; // save current beacon keys
520 struct beacon_keys new_beacon_keys; // save new beacon keys
521 u8 new_beacon_cnts; // if new_beacon_cnts >= threshold, ap beacon is changed
522
523 #ifdef CONFIG_ARP_KEEP_ALIVE
524 // for arp offload keep alive
525 u8 bGetGateway;
526 u8 gw_mac_addr[6];
527 u8 gw_ip[4];
528 #endif
529
530 //uint wireless_mode; no used, remove it
531
532 u32 auto_scan_int_ms;
533
534 _timer assoc_timer;
535
536 uint assoc_by_bssid;
537 uint assoc_by_rssi;
538
539 _timer scan_to_timer; // driver itself handles scan_timeout status.
540 u32 scan_start_time; // used to evaluate the time spent in scanning
541
542 #ifdef CONFIG_SET_SCAN_DENY_TIMER
543 _timer set_scan_deny_timer;
544 ATOMIC_T set_scan_deny; //0: allowed, 1: deny
545 #endif
546
547 struct qos_priv qospriv;
548
549 #ifdef CONFIG_80211N_HT
550
551 /* Number of non-HT AP/stations */
552 int num_sta_no_ht;
553
554 /* Number of HT AP/stations 20 MHz */
555 //int num_sta_ht_20mhz;
556
557
558 int num_FortyMHzIntolerant;
559
560 struct ht_priv htpriv;
561
562 #endif
563
564 #ifdef CONFIG_80211AC_VHT
565 struct vht_priv vhtpriv;
566 #endif
567 #ifdef CONFIG_BEAMFORMING
568 struct beamforming_info beamforming_info;
569 #endif
570
571 #ifdef CONFIG_DFS
572 u8 handle_dfs;
573 #endif
574 #ifdef CONFIG_DFS_MASTER
575 /* TODO: move to rfctl */
576 _timer dfs_master_timer;
577 #endif
578
579 RT_LINK_DETECT_T LinkDetectInfo;
580 _timer dynamic_chk_timer; //dynamic/periodic check timer
581
582 u8 acm_mask; // for wmm acm mask
583 u8 ChannelPlan;
584 RT_SCAN_TYPE scan_mode; // active: 1, passive: 0
585
586 u8 *wps_probe_req_ie;
587 u32 wps_probe_req_ie_len;
588
589 u8 ext_capab_ie_data[8];/*currently for ap mode only*/
590 u8 ext_capab_ie_len;
591
592 u8 *assoc_req;
593 u32 assoc_req_len;
594 u8 *assoc_rsp;
595 u32 assoc_rsp_len;
596
597 #ifdef CONFIG_P2P
598 u8 *p2p_probe_req_ie;
599 u8 *p2p_assoc_req_ie;
600 u32 p2p_probe_req_ie_len;
601 u32 p2p_assoc_req_ie_len;
602 #endif
603
604 #if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
605 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
606 * in 802.11g BSS) */
607 int num_sta_non_erp;
608
609 /* Number of associated stations that do not support Short Slot Time */
610 int num_sta_no_short_slot_time;
611
612 /* Number of associated stations that do not support Short Preamble */
613 int num_sta_no_short_preamble;
614
615 int olbc; /* Overlapping Legacy BSS Condition (Legacy b/g)*/
616
617 /* Number of HT associated stations that do not support greenfield */
618 int num_sta_ht_no_gf;
619
620 /* Number of associated non-HT stations */
621 //int num_sta_no_ht;
622
623 /* Number of HT associated stations 20 MHz */
624 int num_sta_ht_20mhz;
625
626 /* number of associated stations 40MHz intolerant */
627 int num_sta_40mhz_intolerant;
628
629 /* Overlapping BSS information */
630 int olbc_ht;
631
632 #ifdef CONFIG_80211N_HT
633 int ht_20mhz_width_req;
634 int ht_intolerant_ch_reported;
635 u16 ht_op_mode;
636 u8 sw_to_20mhz; /*switch to 20Mhz BW*/
637 #endif /* CONFIG_80211N_HT */
638
639 u8 *wps_beacon_ie;
640 //u8 *wps_probe_req_ie;
641 u8 *wps_probe_resp_ie;
642 u8 *wps_assoc_resp_ie; // for CONFIG_IOCTL_CFG80211, this IE could include p2p ie / wfd ie
643
644 u32 wps_beacon_ie_len;
645 //u32 wps_probe_req_ie_len;
646 u32 wps_probe_resp_ie_len;
647 u32 wps_assoc_resp_ie_len; // for CONFIG_IOCTL_CFG80211, this IE len could include p2p ie / wfd ie
648
649 u8 *p2p_beacon_ie;
650 u8 *p2p_probe_resp_ie;
651 u8 *p2p_go_probe_resp_ie; //for GO
652
653 u32 p2p_beacon_ie_len;
654 u32 p2p_probe_resp_ie_len;
655 u32 p2p_go_probe_resp_ie_len; //for GO
656 /*
657 #if defined(CONFIG_P2P) && defined(CONFIG_IOCTL_CFG80211)
658 //u8 *wps_p2p_beacon_ie;
659 u8 *p2p_beacon_ie;
660 u8 *wps_p2p_probe_resp_ie;
661 u8 *wps_p2p_assoc_resp_ie;
662 //u32 wps_p2p_beacon_ie_len;
663 u32 p2p_beacon_ie_len;
664 u32 wps_p2p_probe_resp_ie_len;
665 u32 wps_p2p_assoc_resp_ie_len;
666 #endif
667 */
668
669 _lock bcn_update_lock;
670 u8 update_bcn;
671
672 u8 ori_ch;
673 u8 ori_bw;
674 u8 ori_offset;
675 #endif //#if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
676
677 #if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
678
679 u8 *wfd_beacon_ie;
680 u8 *wfd_probe_req_ie;
681 u8 *wfd_probe_resp_ie;
682 u8 *wfd_go_probe_resp_ie; //for GO
683 u8 *wfd_assoc_req_ie;
684
685 u32 wfd_beacon_ie_len;
686 u32 wfd_probe_req_ie_len;
687 u32 wfd_probe_resp_ie_len;
688 u32 wfd_go_probe_resp_ie_len; //for GO
689 u32 wfd_assoc_req_ie_len;
690
691 #endif
692
693 #ifdef RTK_DMP_PLATFORM
694 // DMP kobject_hotplug function signal need in passive level
695 _workitem Linkup_workitem;
696 _workitem Linkdown_workitem;
697 #endif
698
699 #ifdef CONFIG_INTEL_WIDI
700 int widi_state;
701 int listen_state;
702 _timer listen_timer;
703 ATOMIC_T rx_probe_rsp; // 1:receive probe respone from RDS source.
704 u8 *l2sdTaBuffer;
705 u8 channel_idx;
706 u8 group_cnt; //In WiDi 3.5, they specified another scan algo. for WFD/RDS co-existed
707 u8 sa_ext[L2SDTA_SERVICE_VE_LEN];
708
709 u8 widi_enable;
710 /**
711 * For WiDi 4; upper layer would set
712 * p2p_primary_device_type_category_id
713 * p2p_primary_device_type_sub_category_id
714 * p2p_secondary_device_type_category_id
715 * p2p_secondary_device_type_sub_category_id
716 */
717 u16 p2p_pdt_cid;
718 u16 p2p_pdt_scid;
719 u8 num_p2p_sdt;
720 u16 p2p_sdt_cid[MAX_NUM_P2P_SDT];
721 u16 p2p_sdt_scid[MAX_NUM_P2P_SDT];
722 u8 p2p_reject_disable; //When starting NL80211 wpa_supplicant/hostapd, it will call netdev_close
723 //such that it will cause p2p disabled. Use this flag to reject.
724 #endif // CONFIG_INTEL_WIDI
725
726 #ifdef CONFIG_CONCURRENT_MODE
727 u8 scanning_via_buddy_intf;
728 #endif
729
730 // u8 NumOfBcnInfoChkFail;
731 // u32 timeBcnInfoChkStart;
732 };
733
734 #define mlme_set_scan_to_timer(mlme, ms) \
735 do { \
736 /* DBG_871X("%s set_scan_to_timer(%p, %d)\n", __FUNCTION__, (mlme), (ms)); */ \
737 _set_timer(&(mlme)->scan_to_timer, (ms)); \
738 } while(0)
739
740 #define rtw_mlme_set_auto_scan_int(adapter, ms) \
741 do { \
742 adapter->mlmepriv.auto_scan_int_ms = ms; \
743 } while (0)
744
745 void rtw_mlme_reset_auto_scan_int(_adapter *adapter);
746
747 #ifdef CONFIG_AP_MODE
748
749 struct hostapd_priv
750 {
751 _adapter *padapter;
752
753 #ifdef CONFIG_HOSTAPD_MLME
754 struct net_device *pmgnt_netdev;
755 struct usb_anchor anchored;
756 #endif
757
758 };
759
760 extern int hostapd_mode_init(_adapter *padapter);
761 extern void hostapd_mode_unload(_adapter *padapter);
762 #endif
763
764
765 extern void rtw_joinbss_event_prehandle(_adapter *adapter, u8 *pbuf);
766 extern void rtw_survey_event_callback(_adapter *adapter, u8 *pbuf);
767 extern void rtw_surveydone_event_callback(_adapter *adapter, u8 *pbuf);
768 extern void rtw_joinbss_event_callback(_adapter *adapter, u8 *pbuf);
769 extern void rtw_stassoc_event_callback(_adapter *adapter, u8 *pbuf);
770 extern void rtw_stadel_event_callback(_adapter *adapter, u8 *pbuf);
771 extern void rtw_atimdone_event_callback(_adapter *adapter, u8 *pbuf);
772 extern void rtw_cpwm_event_callback(_adapter *adapter, u8 *pbuf);
773 extern void rtw_wmm_event_callback(PADAPTER padapter, u8 *pbuf);
774 #ifdef CONFIG_IEEE80211W
775 void rtw_sta_timeout_event_callback(_adapter *adapter, u8 *pbuf);
776 #endif /* CONFIG_IEEE80211W */
777 extern void rtw_join_timeout_handler(RTW_TIMER_HDL_ARGS);
778 extern void _rtw_scan_timeout_handler(RTW_TIMER_HDL_ARGS);
779
780 thread_return event_thread(thread_context context);
781
782 extern void rtw_free_network_queue(_adapter *adapter,u8 isfreeall);
783 extern int rtw_init_mlme_priv(_adapter *adapter);// (struct mlme_priv *pmlmepriv);
784
785 extern void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv);
786
787
788 extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
789 extern sint rtw_set_key(_adapter *adapter,struct security_priv *psecuritypriv,sint keyid, u8 set_tx, bool enqueue);
790 extern sint rtw_set_auth(_adapter *adapter,struct security_priv *psecuritypriv);
791
get_bssid(struct mlme_priv * pmlmepriv)792 __inline static u8 *get_bssid(struct mlme_priv *pmlmepriv)
793 { //if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid
794 // if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address
795 return pmlmepriv->cur_network.network.MacAddress;
796 }
797
check_fwstate(struct mlme_priv * pmlmepriv,sint state)798 __inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
799 {
800 if (pmlmepriv->fw_state & state)
801 return _TRUE;
802
803 return _FALSE;
804 }
805
get_fwstate(struct mlme_priv * pmlmepriv)806 __inline static sint get_fwstate(struct mlme_priv *pmlmepriv)
807 {
808 return pmlmepriv->fw_state;
809 }
810
811 /*
812 * No Limit on the calling context,
813 * therefore set it to be the critical section...
814 *
815 * ### NOTE:#### (!!!!)
816 * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
817 */
set_fwstate(struct mlme_priv * pmlmepriv,sint state)818 __inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
819 {
820 pmlmepriv->fw_state |= state;
821 //FOR HW integration
822 if(_FW_UNDER_SURVEY==state){
823 pmlmepriv->bScanInProcess = _TRUE;
824 }
825 }
826
_clr_fwstate_(struct mlme_priv * pmlmepriv,sint state)827 __inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
828 {
829 pmlmepriv->fw_state &= ~state;
830 //FOR HW integration
831 if(_FW_UNDER_SURVEY==state){
832 pmlmepriv->bScanInProcess = _FALSE;
833 }
834 }
835
836 /*
837 * No Limit on the calling context,
838 * therefore set it to be the critical section...
839 */
clr_fwstate(struct mlme_priv * pmlmepriv,sint state)840 __inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
841 {
842 _irqL irqL;
843
844 _enter_critical_bh(&pmlmepriv->lock, &irqL);
845 _clr_fwstate_(pmlmepriv, state);
846 _exit_critical_bh(&pmlmepriv->lock, &irqL);
847 }
848
up_scanned_network(struct mlme_priv * pmlmepriv)849 __inline static void up_scanned_network(struct mlme_priv *pmlmepriv)
850 {
851 _irqL irqL;
852
853 _enter_critical_bh(&pmlmepriv->lock, &irqL);
854 pmlmepriv->num_of_scanned++;
855 _exit_critical_bh(&pmlmepriv->lock, &irqL);
856 }
857
858 #ifdef CONFIG_CONCURRENT_MODE
859 sint rtw_buddy_adapter_up(_adapter *padapter);
860 sint check_buddy_fwstate(_adapter *padapter, sint state);
861 u8 rtw_get_buddy_bBusyTraffic(_adapter *padapter);
862 #endif //CONFIG_CONCURRENT_MODE
863
down_scanned_network(struct mlme_priv * pmlmepriv)864 __inline static void down_scanned_network(struct mlme_priv *pmlmepriv)
865 {
866 _irqL irqL;
867
868 _enter_critical_bh(&pmlmepriv->lock, &irqL);
869 pmlmepriv->num_of_scanned--;
870 _exit_critical_bh(&pmlmepriv->lock, &irqL);
871 }
872
set_scanned_network_val(struct mlme_priv * pmlmepriv,sint val)873 __inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
874 {
875 _irqL irqL;
876
877 _enter_critical_bh(&pmlmepriv->lock, &irqL);
878 pmlmepriv->num_of_scanned = val;
879 _exit_critical_bh(&pmlmepriv->lock, &irqL);
880 }
881
882 extern u16 rtw_get_capability(WLAN_BSSID_EX *bss);
883 extern void rtw_update_scanned_network(_adapter *adapter, WLAN_BSSID_EX *target);
884 extern void rtw_disconnect_hdl_under_linked(_adapter* adapter, struct sta_info *psta, u8 free_assoc);
885 extern void rtw_generate_random_ibss(u8 *pibss);
886 extern struct wlan_network* rtw_find_network(_queue *scanned_queue, u8 *addr);
887 extern struct wlan_network* rtw_get_oldest_wlan_network(_queue *scanned_queue);
888 struct wlan_network *_rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
889 struct wlan_network *rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
890
891 extern void rtw_free_assoc_resources(_adapter* adapter, int lock_scanned_queue);
892 extern void rtw_indicate_disconnect(_adapter* adapter);
893 extern void rtw_indicate_connect(_adapter* adapter);
894 void rtw_indicate_scan_done( _adapter *padapter, bool aborted);
895
896 void rtw_drv_scan_by_self(_adapter *padapter);
897 void rtw_scan_wait_completed(_adapter *adapter);
898 u32 rtw_scan_abort_timeout(_adapter *adapter, u32 timeout_ms);
899 void rtw_scan_abort_no_wait(_adapter *adapter);
900 void rtw_scan_abort(_adapter *adapter);
901
902 extern int rtw_restruct_sec_ie(_adapter *adapter,u8 *in_ie,u8 *out_ie,uint in_len);
903 extern int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len);
904 extern void rtw_init_registrypriv_dev_network(_adapter *adapter);
905
906 extern void rtw_update_registrypriv_dev_network(_adapter *adapter);
907
908 extern void rtw_get_encrypt_decrypt_from_registrypriv(_adapter *adapter);
909
910 extern void _rtw_join_timeout_handler(_adapter *adapter);
911 extern void rtw_scan_timeout_handler(_adapter *adapter);
912
913 extern void rtw_dynamic_check_timer_handlder(_adapter *adapter);
914 #ifdef CONFIG_SET_SCAN_DENY_TIMER
915 bool rtw_is_scan_deny(_adapter *adapter);
916 void rtw_clear_scan_deny(_adapter *adapter);
917 void rtw_set_scan_deny_timer_hdl(_adapter *adapter);
918 void rtw_set_scan_deny(_adapter *adapter, u32 ms);
919 #else
920 #define rtw_is_scan_deny(adapter) _FALSE
921 #define rtw_clear_scan_deny(adapter) do {} while (0)
922 #define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
923 #define rtw_set_scan_deny(adapter, ms) do {} while (0)
924 #endif
925
926
927 extern int _rtw_init_mlme_priv(_adapter *padapter);
928
929 void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
930
931 extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
932
933 extern int _rtw_enqueue_network(_queue *queue, struct wlan_network *pnetwork);
934
935 //extern struct wlan_network* _rtw_dequeue_network(_queue *queue);
936
937 extern struct wlan_network* _rtw_alloc_network(struct mlme_priv *pmlmepriv);
938
939
940 extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
941 extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
942
943
944 extern struct wlan_network* _rtw_find_network(_queue *scanned_queue, u8 *addr);
945
946 extern void _rtw_free_network_queue(_adapter* padapter, u8 isfreeall);
947
948 extern sint rtw_if_up(_adapter *padapter);
949
950 sint rtw_linked_check(_adapter *padapter);
951
952 u8 *rtw_get_capability_from_ie(u8 *ie);
953 u8 *rtw_get_timestampe_from_ie(u8 *ie);
954 u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
955
956
957 void rtw_joinbss_reset(_adapter *padapter);
958
959 #ifdef CONFIG_80211N_HT
960 void rtw_ht_use_default_setting(_adapter *padapter);
961 void rtw_build_wmm_ie_ht(_adapter *padapter, u8 *out_ie, uint *pout_len);
962 unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel);
963 void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel);
964 void rtw_issue_addbareq_cmd(_adapter *padapter, struct xmit_frame *pxmitframe);
965 void rtw_append_exented_cap(_adapter *padapter, u8 *out_ie, uint *pout_len);
966 #endif
967
968 int rtw_is_same_ibss(_adapter *adapter, struct wlan_network *pnetwork);
969 int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst, u8 feature);
970
971 #ifdef CONFIG_LAYER2_ROAMING
972 #define rtw_roam_flags(adapter) ((adapter)->mlmepriv.roam_flags)
973 #define rtw_chk_roam_flags(adapter, flags) ((adapter)->mlmepriv.roam_flags & flags)
974 #define rtw_clr_roam_flags(adapter, flags) \
975 do { \
976 ((adapter)->mlmepriv.roam_flags &= ~flags); \
977 } while (0)
978
979 #define rtw_set_roam_flags(adapter, flags) \
980 do { \
981 ((adapter)->mlmepriv.roam_flags |= flags); \
982 } while (0)
983
984 #define rtw_assign_roam_flags(adapter, flags) \
985 do { \
986 ((adapter)->mlmepriv.roam_flags = flags); \
987 } while (0)
988
989 void _rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
990 void rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
991 void rtw_set_to_roam(_adapter *adapter, u8 to_roam);
992 u8 rtw_dec_to_roam(_adapter *adapter);
993 u8 rtw_to_roam(_adapter *adapter);
994 int rtw_select_roaming_candidate(struct mlme_priv *pmlmepriv);
995 #else
996 #define rtw_roam_flags(adapter) 0
997 #define rtw_chk_roam_flags(adapter, flags) 0
998 #define rtw_clr_roam_flags(adapter, flags) do {} while (0)
999 #define rtw_set_roam_flags(adapter, flags) do {} while (0)
1000 #define rtw_assign_roam_flags(adapter, flags) do {} while (0)
1001 #define _rtw_roaming(adapter, tgt_network) do {} while(0)
1002 #define rtw_roaming(adapter, tgt_network) do {} while(0)
1003 #define rtw_set_to_roam(adapter, to_roam) do {} while(0)
1004 #define rtw_dec_to_roam(adapter) 0
1005 #define rtw_to_roam(adapter) 0
1006 #define rtw_select_roaming_candidate(mlme) _FAIL
1007 #endif /* CONFIG_LAYER2_ROAMING */
1008
1009 void rtw_sta_media_status_rpt(_adapter *adapter,struct sta_info *psta, u32 mstatus);
1010
1011 #ifdef CONFIG_INTEL_PROXIM
1012 void rtw_proxim_enable(_adapter *padapter);
1013 void rtw_proxim_disable(_adapter *padapter);
1014 void rtw_proxim_send_packet(_adapter *padapter,u8 *pbuf,u16 len,u8 hw_rate);
1015 #endif //CONFIG_INTEL_PROXIM
1016 #endif //__RTL871X_MLME_H_
1017
1018