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