1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2019 Realtek Corporation.
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 *****************************************************************************/
15 #ifndef __RTW_MLME_H_
16 #define __RTW_MLME_H_
17
18
19 #define MAX_BSS_CNT 128
20 /* #define MAX_JOIN_TIMEOUT 2000 */
21 /* #define MAX_JOIN_TIMEOUT 2500 */
22 #define MAX_JOIN_TIMEOUT 6500
23
24 /* Commented by Albert 20101105
25 * Increase the scanning timeout because of increasing the SURVEY_TO value. */
26 #define SCANQUEUE_LIFETIME 20000 /* 20sec, unit:msec */
27
28 #define MAX_UNASSOC_STA_CNT 128
29 #define UNASSOC_STA_LIFETIME_MS 60000
30
31 /*pmlmepriv->fw_state*/
32 #define WIFI_NULL_STATE 0x00000000
33 #define WIFI_ASOC_STATE 0x00000001 /* Linked */
34 #define WIFI_REASOC_STATE 0x00000002
35 #define WIFI_SLEEP_STATE 0x00000004
36 #define WIFI_STATION_STATE 0x00000008
37 #define WIFI_AP_STATE 0x00000010
38 #define WIFI_ADHOC_STATE 0x00000020
39 #define WIFI_ADHOC_MASTER_STATE 0x00000040
40 #define WIFI_UNDER_LINKING 0x00000080
41 #define WIFI_UNDER_WPS 0x00000100
42 #define WIFI_MESH_STATE 0x00000200
43 #define WIFI_STA_ALIVE_CHK_STATE 0x00000400
44 #define WIFI_UNDER_SURVEY 0x00000800 /* under site surveying */
45 /*#define WIFI_UNDEFINED_STATE 0x00001000*/
46 /*#define WIFI_UNDEFINED_STATE 0x00002000*/
47 /*#define WIFI_UNDEFINED_STATE 0x00004000*/
48 /*#define WIFI_UNDEFINED_STATE 0x00008000*/
49 #define WIFI_MP_STATE 0x00010000
50 /*#define WIFI_UNDEFINED_STATE 0x00020000*/
51 /*#define WIFI_UNDEFINED_STATE 0x00040000*/
52 /*#define WIFI_UNDEFINED_STATE 0x00080000*/
53 /*#define WIFI_UNDEFINED_STATE 0x00100000*/
54 /*#define WIFI_UNDEFINED_STATE 0x00200000*/
55 /*#define WIFI_UNDEFINED_STATE 0x00400000*/
56 #define WIFI_OP_CH_SWITCHING 0x00800000
57 #define WIFI_UNDER_KEY_HANDSHAKE 0x01000000
58 /*#define WIFI_UNDEFINED_STATE 0x02000000*/
59 /*#define WIFI_UNDEFINED_STATE 0x04000000*/
60 /*#define WIFI_UNDEFINED_STATE 0x08000000*/
61 /*#define WIFI_UNDEFINED_STATE 0x10000000*/
62 /*#define WIFI_UNDEFINED_STATE 0x20000000*/
63 #define WIFI_CSA_UPDATE_BEACON 0x40000000
64 #define WIFI_MONITOR_STATE 0x80000000
65
66
67 #define MIRACAST_DISABLED 0
68 #define MIRACAST_SOURCE BIT0
69 #define MIRACAST_SINK BIT1
70
71 #define MIRACAST_MODE_REVERSE(mode) \
72 ((((mode) & MIRACAST_SOURCE) ? MIRACAST_SINK : 0) | (((mode) & MIRACAST_SINK) ? MIRACAST_SOURCE : 0))
73
74 bool is_miracast_enabled(_adapter *adapter);
75 bool rtw_chk_miracast_mode(_adapter *adapter, u8 mode);
76 const char *get_miracast_mode_str(int mode);
77 void rtw_wfd_st_switch(struct sta_info *sta, bool on);
78
79 #define MLME_STATE(adapter) get_fwstate(&((adapter)->mlmepriv))
80 #define CHK_MLME_STATE(adapter, state) check_fwstate(&((adapter)->mlmepriv), (state))
81
82 #define MLME_IS_NULL(adapter) CHK_MLME_STATE(adapter, WIFI_NULL_STATE)
83 #define MLME_IS_STA(adapter) CHK_MLME_STATE(adapter, WIFI_STATION_STATE)
84 #define MLME_IS_AP(adapter) CHK_MLME_STATE(adapter, WIFI_AP_STATE)
85 #define MLME_IS_ADHOC(adapter) CHK_MLME_STATE(adapter, WIFI_ADHOC_STATE)
86 #define MLME_IS_ADHOC_MASTER(adapter) CHK_MLME_STATE(adapter, WIFI_ADHOC_MASTER_STATE)
87 #define MLME_IS_MESH(adapter) CHK_MLME_STATE(adapter, WIFI_MESH_STATE)
88 #define MLME_IS_MONITOR(adapter) CHK_MLME_STATE(adapter, WIFI_MONITOR_STATE)
89 #define MLME_IS_MP(adapter) CHK_MLME_STATE(adapter, WIFI_MP_STATE)
90 #ifdef CONFIG_P2P
91 #define MLME_IS_PD(adapter) rtw_p2p_chk_role(&(adapter)->wdinfo, P2P_ROLE_DEVICE)
92 #define MLME_IS_GC(adapter) rtw_p2p_chk_role(&(adapter)->wdinfo, P2P_ROLE_CLIENT)
93 #define MLME_IS_GO(adapter) rtw_p2p_chk_role(&(adapter)->wdinfo, P2P_ROLE_GO)
94 #else /* !CONFIG_P2P */
95 #define MLME_IS_PD(adapter) 0
96 #define MLME_IS_GC(adapter) 0
97 #define MLME_IS_GO(adapter) 0
98 #endif /* !CONFIG_P2P */
99
100 #define MLME_IS_MSRC(adapter) rtw_chk_miracast_mode((adapter), MIRACAST_SOURCE)
101 #define MLME_IS_MSINK(adapter) rtw_chk_miracast_mode((adapter), MIRACAST_SINK)
102
103 #define MLME_IS_SCAN(adapter) CHK_MLME_STATE(adapter, WIFI_UNDER_SURVEY)
104 #define MLME_IS_LINKING(adapter) CHK_MLME_STATE(adapter, WIFI_UNDER_LINKING)
105 #define MLME_IS_ASOC(adapter) CHK_MLME_STATE(adapter, WIFI_ASOC_STATE)
106 #define MLME_IS_OPCH_SW(adapter) CHK_MLME_STATE(adapter, WIFI_OP_CH_SWITCHING)
107 #define MLME_IS_WPS(adapter) CHK_MLME_STATE(adapter, WIFI_UNDER_WPS)
108
109 #ifdef CONFIG_IOCTL_CFG80211
110 #define MLME_IS_ROCH(adapter) (rtw_cfg80211_get_is_roch(adapter) == _TRUE)
111 #else
112 #define MLME_IS_ROCH(adapter) 0
113 #endif
114
115 #ifdef CONFIG_IOCTL_CFG80211
116 #define MLME_IS_MGMT_TX(adapter) rtw_cfg80211_get_is_mgmt_tx(adapter)
117 #else
118 #define MLME_IS_MGMT_TX(adapter) 0
119 #endif
120
121 #define MLME_STATE_FMT "%s%s%s%s%s%s%s%s%s%s%s%s"
122 #define MLME_STATE_ARG(adapter) \
123 MLME_IS_STA((adapter)) ? (MLME_IS_GC((adapter)) ? " GC" : " STA") : \
124 MLME_IS_AP((adapter)) ? (MLME_IS_GO((adapter)) ? " GO" : " AP") : \
125 MLME_IS_ADHOC((adapter)) ? " ADHOC" : \
126 MLME_IS_ADHOC_MASTER((adapter)) ? " ADHOC_M" : \
127 MLME_IS_MESH((adapter)) ? " MESH" : \
128 MLME_IS_MONITOR((adapter)) ? " MONITOR" : \
129 MLME_IS_MP((adapter)) ? " MP" : "", \
130 MLME_IS_PD((adapter)) ? " PD" : "", \
131 MLME_IS_MSRC((adapter)) ? " MSRC" : "", \
132 MLME_IS_MSINK((adapter)) ? " MSINK" : "", \
133 MLME_IS_SCAN((adapter)) ? " SCAN" : "", \
134 MLME_IS_LINKING((adapter)) ? " LINKING" : "", \
135 MLME_IS_ASOC((adapter)) ? " ASOC" : "", \
136 MLME_IS_OPCH_SW((adapter)) ? " OPCH_SW" : "", \
137 MLME_IS_WPS((adapter)) ? " WPS" : "", \
138 MLME_IS_ROCH((adapter)) ? " ROCH" : "", \
139 MLME_IS_MGMT_TX((adapter)) ? " MGMT_TX" : "", \
140 (MLME_STATE((adapter)) & WIFI_SLEEP_STATE) ? " SLEEP" : ""
141
142 enum {
143 MLME_ACTION_UNKNOWN,
144 MLME_ACTION_NONE,
145 MLME_SCAN_ENABLE, /* WIFI_UNDER_SURVEY */
146 MLME_SCAN_ENTER, /* WIFI_UNDER_SURVEY && !SCAN_DISABLE && !SCAN_BACK_OP */
147 MLME_SCAN_DONE, /* WIFI_UNDER_SURVEY && (SCAN_DISABLE || SCAN_BACK_OP) */
148 MLME_SCAN_DISABLE, /* WIFI_UNDER_SURVEY is going to be cleared */
149 MLME_STA_CONNECTING,
150 MLME_STA_CONNECTED,
151 MLME_STA_DISCONNECTED,
152 MLME_TDLS_LINKED,
153 MLME_TDLS_NOLINK,
154 MLME_AP_STARTED,
155 MLME_AP_STOPPED,
156 MLME_ADHOC_STARTED,
157 MLME_ADHOC_STOPPED,
158 MLME_MESH_STARTED,
159 MLME_MESH_STOPPED,
160 MLME_OPCH_SWITCH,
161 };
162
163 enum dot11AuthAlgrthmNum {
164 dot11AuthAlgrthm_Open = 0,
165 dot11AuthAlgrthm_Shared,
166 dot11AuthAlgrthm_8021X,
167 dot11AuthAlgrthm_Auto,
168 dot11AuthAlgrthm_WAPI,
169 dot11AuthAlgrthm_MaxNum
170 };
171
172 /**
173 * enum mlme_auth_type - AuthenticationType
174 *
175 * @MLME_AUTHTYPE_OPEN_SYSTEM: Open System authentication
176 * @MLME_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
177 * @MLME_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
178 * @MLME_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
179 * @MLME_AUTHTYPE_SAE: Simultaneous authentication of equals
180 * @MLME_AUTHTYPE_FILS_SK: Fast Initial Link Setup shared key
181 * @MLME_AUTHTYPE_FILS_SK_PFS: Fast Initial Link Setup shared key with PFS
182 * @MLME_AUTHTYPE_FILS_PK: Fast Initial Link Setup public key
183 * @__MLME_AUTHTYPE_NUM: internal
184 * @MLME_AUTHTYPE_MAX: maximum valid auth algorithm
185 * @MLME_AUTHTYPE_AUTOMATIC: determine automatically (if necessary by trying
186 * multiple times); this is invalid in netlink -- leave out the attribute
187 * for this on CONNECT commands.
188 */
189 enum mlme_auth_type {
190 MLME_AUTHTYPE_OPEN_SYSTEM,
191 MLME_AUTHTYPE_SHARED_KEY,
192 MLME_AUTHTYPE_FT,
193 MLME_AUTHTYPE_NETWORK_EAP,
194 MLME_AUTHTYPE_SAE,
195 MLME_AUTHTYPE_FILS_SK,
196 MLME_AUTHTYPE_FILS_SK_PFS,
197 MLME_AUTHTYPE_FILS_PK,
198
199 /* keep last */
200 __MLME_AUTHTYPE_NUM,
201 MLME_AUTHTYPE_MAX = __MLME_AUTHTYPE_NUM - 1,
202 MLME_AUTHTYPE_AUTOMATIC
203 };
204
205 /* Scan type including active and passive scan. */
206 typedef enum _RT_SCAN_TYPE {
207 SCAN_PASSIVE,
208 SCAN_ACTIVE,
209 SCAN_MIX,
210 } RT_SCAN_TYPE, *PRT_SCAN_TYPE;
211
212 #define WIFI_FREQUENCY_BAND_AUTO 0
213 #define WIFI_FREQUENCY_BAND_5GHZ 1
214 #define WIFI_FREQUENCY_BAND_2GHZ 2
215
216 #define rtw_band_valid(band) ((band) <= WIFI_FREQUENCY_BAND_2GHZ)
217
218 enum DriverInterface {
219 DRIVER_WEXT = 1,
220 DRIVER_CFG80211 = 2
221 };
222
223 enum SCAN_RESULT_TYPE {
224 SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */
225 SCAN_RESULT_ALL = 1, /* Will return all the scanned device, include AP. */
226 SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD device. */
227 /* If this device is Miracast sink device, it will just return all the Miracast source devices. */
228 };
229
230 /*
231
232 there are several "locks" in mlme_priv,
233 since mlme_priv is a shared resource between many threads,
234 like ISR/Call-Back functions, the OID handlers, and even timer functions.
235
236
237 Each _queue has its own locks, already.
238 Other items are protected by mlme_priv.lock.
239
240 To avoid possible dead lock, any thread trying to modifiying mlme_priv
241 SHALL not lock up more than one locks at a time!
242
243 */
244
245
246 #define traffic_threshold 10
247 #define traffic_scan_period 500
248
249 typedef struct _RT_LINK_DETECT_T {
250 u32 NumTxOkInPeriod;
251 u32 NumRxOkInPeriod;
252 u32 NumRxUnicastOkInPeriod;
253 BOOLEAN bBusyTraffic;
254 BOOLEAN bTxBusyTraffic;
255 BOOLEAN bRxBusyTraffic;
256 BOOLEAN bHigherBusyTraffic; /* For interrupt migration purpose. */
257 BOOLEAN bHigherBusyRxTraffic; /* We may disable Tx interrupt according as Rx traffic. */
258 BOOLEAN bHigherBusyTxTraffic; /* We may disable Tx interrupt according as Tx traffic. */
259 /* u8 TrafficBusyState; */
260 u8 TrafficTransitionCount;
261 u32 LowPowerTransitionCount;
262 } RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
263
264 struct profile_info {
265 u8 ssidlen;
266 u8 ssid[WLAN_SSID_MAXLEN];
267 u8 peermac[ETH_ALEN];
268 };
269
270 struct tx_invite_req_info {
271 u8 token;
272 u8 benable;
273 u8 go_ssid[WLAN_SSID_MAXLEN];
274 u8 ssidlen;
275 u8 go_bssid[ETH_ALEN];
276 u8 peer_macaddr[ETH_ALEN];
277 u8 operating_ch; /* This information will be set by using the p2p_set op_ch=x */
278 u8 peer_ch; /* The listen channel for peer P2P device */
279
280 };
281
282 struct tx_invite_resp_info {
283 u8 token; /* Used to record the dialog token of p2p invitation request frame. */
284 };
285
286 #ifdef CONFIG_WFD
287
288 struct wifi_display_info {
289 u16 wfd_enable; /* Eanble/Disable the WFD function. */
290 u16 init_rtsp_ctrlport; /* init value of rtsp_ctrlport when WFD enable */
291 u16 rtsp_ctrlport; /* TCP port number at which the this WFD device listens for RTSP messages, 0 when WFD disable */
292 u16 tdls_rtsp_ctrlport; /* rtsp_ctrlport used by tdls, will sync when rtsp_ctrlport is changed by user */
293 u16 peer_rtsp_ctrlport; /* TCP port number at which the peer WFD device listens for RTSP messages */
294 /* This filed should be filled when receiving the gropu negotiation request */
295
296 u8 peer_session_avail; /* WFD session is available or not for the peer wfd device. */
297 /* This variable will be set when sending the provisioning discovery request to peer WFD device. */
298 /* And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command. */
299 u8 ip_address[4];
300 u8 peer_ip_address[4];
301 u8 wfd_pc; /* WFD preferred connection */
302 /* 0 -> Prefer to use the P2P for WFD connection on peer side. */
303 /* 1 -> Prefer to use the TDLS for WFD connection on peer side. */
304
305 u8 wfd_device_type; /* WFD Device Type */
306 /* 0 -> WFD Source Device */
307 /* 1 -> WFD Primary Sink Device */
308 enum SCAN_RESULT_TYPE scan_result_type; /* Used when P2P is enable. This parameter will impact the scan result. */
309 u8 op_wfd_mode;
310 u8 stack_wfd_mode;
311 };
312 #endif /* CONFIG_WFD */
313
314 struct tx_provdisc_req_info {
315 u16 wps_config_method_request; /* Used when sending the provisioning request frame */
316 u16 peer_channel_num[2]; /* The channel number which the receiver stands. */
317 NDIS_802_11_SSID ssid;
318 u8 peerDevAddr[ETH_ALEN]; /* Peer device address */
319 u8 peerIFAddr[ETH_ALEN]; /* Peer interface address */
320 u8 benable; /* This provision discovery request frame is trigger to send or not */
321 };
322
323 struct rx_provdisc_req_info { /* When peer device issue prov_disc_req first, we should store the following informations */
324 u8 peerDevAddr[ETH_ALEN]; /* Peer device address */
325 u8 strconfig_method_desc_of_prov_disc_req[4]; /* description for the config method located in the provisioning discovery request frame. */
326 /* The UI must know this information to know which config method the remote p2p device is requiring. */
327 };
328
329 struct tx_nego_req_info {
330 u16 peer_channel_num[2]; /* The channel number which the receiver stands. */
331 u8 peerDevAddr[ETH_ALEN]; /* Peer device address */
332 u8 benable; /* This negoitation request frame is trigger to send or not */
333 u8 peer_ch; /* The listen channel for peer P2P device */
334 };
335
336 struct group_id_info {
337 u8 go_device_addr[ETH_ALEN]; /* The GO's device address of this P2P group */
338 u8 ssid[WLAN_SSID_MAXLEN]; /* The SSID of this P2P group */
339 };
340
341 struct scan_limit_info {
342 u8 scan_op_ch_only; /* When this flag is set, the driver should just scan the operation channel */
343 #ifndef CONFIG_P2P_OP_CHK_SOCIAL_CH
344 u8 operation_ch[2]; /* Store the operation channel of invitation request frame */
345 #else
346 u8 operation_ch[5]; /* Store additional channel 1,6,11 for Android 4.2 IOT & Nexus 4 */
347 #endif /* CONFIG_P2P_OP_CHK_SOCIAL_CH */
348 };
349
350 #ifdef CONFIG_P2P_WOWLAN
351
352 enum P2P_WOWLAN_RECV_FRAME_TYPE {
353 P2P_WOWLAN_RECV_NEGO_REQ = 0,
354 P2P_WOWLAN_RECV_INVITE_REQ = 1,
355 P2P_WOWLAN_RECV_PROVISION_REQ = 2,
356 };
357
358 struct p2p_wowlan_info {
359
360 u8 is_trigger;
361 enum P2P_WOWLAN_RECV_FRAME_TYPE wowlan_recv_frame_type;
362 u8 wowlan_peer_addr[ETH_ALEN];
363 u16 wowlan_peer_wpsconfig;
364 u8 wowlan_peer_is_persistent;
365 u8 wowlan_peer_invitation_type;
366 };
367
368 #endif /* CONFIG_P2P_WOWLAN */
369
370 struct wifidirect_info {
371 _adapter *padapter;
372 _timer find_phase_timer;
373 _timer restore_p2p_state_timer;
374
375 /* Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer. */
376 _timer pre_tx_scan_timer;
377 _timer reset_ch_sitesurvey;
378 _timer reset_ch_sitesurvey2; /* Just for resetting the scan limit function by using p2p nego */
379
380 struct tx_provdisc_req_info tx_prov_disc_info;
381 struct rx_provdisc_req_info rx_prov_disc_info;
382 struct tx_invite_req_info invitereq_info;
383 struct profile_info profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM]; /* Store the profile information of persistent group */
384 struct tx_invite_resp_info inviteresp_info;
385 struct tx_nego_req_info nego_req_info;
386 struct group_id_info groupid_info; /* Store the group id information when doing the group negotiation handshake. */
387 struct scan_limit_info rx_invitereq_info; /* Used for get the limit scan channel from the Invitation procedure */
388 struct scan_limit_info p2p_info; /* Used for get the limit scan channel from the P2P negotiation handshake */
389 #ifdef CONFIG_WFD
390 struct wifi_display_info *wfd_info;
391 #endif
392
393 #ifdef CONFIG_P2P_WOWLAN
394 struct p2p_wowlan_info p2p_wow_info;
395 #endif /* CONFIG_P2P_WOWLAN */
396
397 enum P2P_ROLE role;
398 enum P2P_STATE pre_p2p_state;
399 enum P2P_STATE p2p_state;
400 u8 device_addr[ETH_ALEN]; /* The device address should be the mac address of this device. */
401 u8 interface_addr[ETH_ALEN];
402 u8 social_chan[4];
403 u8 listen_channel;
404 u8 operating_channel;
405 u8 listen_dwell; /* This value should be between 1 and 3 */
406 u8 support_rate[8];
407 u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
408 u8 intent; /* should only include the intent value. */
409 u8 p2p_peer_interface_addr[ETH_ALEN];
410 u8 p2p_peer_device_addr[ETH_ALEN];
411 u8 peer_intent; /* Included the intent value and tie breaker value. */
412 u8 device_name[WPS_MAX_DEVICE_NAME_LEN]; /* Device name for displaying on searching device screen */
413 u16 device_name_len;
414 u8 profileindex; /* Used to point to the index of profileinfo array */
415 u8 peer_operating_ch;
416 u8 find_phase_state_exchange_cnt;
417 u16 device_password_id_for_nego; /* The device password ID for group negotation */
418 u8 negotiation_dialog_token;
419 u8 nego_ssid[WLAN_SSID_MAXLEN]; /* SSID information for group negotitation */
420 u8 nego_ssidlen;
421 u8 p2p_group_ssid[WLAN_SSID_MAXLEN];
422 u8 p2p_group_ssid_len;
423 u8 persistent_supported; /* Flag to know the persistent function should be supported or not. */
424 /* In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI. */
425 /* 0: disable */
426 /* 1: enable */
427 u8 session_available; /* Flag to set the WFD session available to enable or disable "by Sigma" */
428 /* In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI. */
429 /* 0: disable */
430 /* 1: enable */
431
432 u8 wfd_tdls_enable; /* Flag to enable or disable the TDLS by WFD Sigma */
433 /* 0: disable */
434 /* 1: enable */
435 u8 wfd_tdls_weaksec; /* Flag to enable or disable the weak security function for TDLS by WFD Sigma */
436 /* 0: disable */
437 /* In this case, the driver can't issue the tdsl setup request frame. */
438 /* 1: enable */
439 /* In this case, the driver can issue the tdls setup request frame */
440 /* even the current security is weak security. */
441
442 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. */
443 u16 supported_wps_cm; /* This field describes the WPS config method which this driver supported. */
444 /* The value should be the combination of config method defined in page104 of WPS v2.0 spec. */
445 u8 external_uuid; /* UUID flag */
446 u8 uuid[16]; /* UUID */
447 uint channel_list_attr_len; /* This field will contain the length of body of P2P Channel List attribute of group negotitation response frame. */
448 u8 channel_list_attr[100]; /* This field will contain the body of P2P Channel List attribute of group negotitation response frame. */
449 /* We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame. */
450 u8 driver_interface; /* Indicate DRIVER_WEXT or DRIVER_CFG80211 */
451
452 #ifdef CONFIG_CONCURRENT_MODE
453 u16 ext_listen_interval; /* The interval to be available with legacy AP (ms) */
454 u16 ext_listen_period; /* The time period to be available for P2P listen state (ms) */
455 #endif
456 #ifdef CONFIG_P2P_PS
457 enum P2P_PS_MODE p2p_ps_mode; /* indicate p2p ps mode */
458 enum P2P_PS_STATE p2p_ps_state; /* indicate p2p ps state */
459 u8 noa_index; /* Identifies and instance of Notice of Absence timing. */
460 u8 ctwindow; /* Client traffic window. A period of time in TU after TBTT. */
461 u8 opp_ps; /* opportunistic power save. */
462 u8 noa_num; /* number of NoA descriptor in P2P IE. */
463 u8 noa_count[P2P_MAX_NOA_NUM]; /* Count for owner, Type of client. */
464 u32 noa_duration[P2P_MAX_NOA_NUM]; /* Max duration for owner, preferred or min acceptable duration for client. */
465 u32 noa_interval[P2P_MAX_NOA_NUM]; /* Length of interval for owner, preferred or max acceptable interval of client. */
466 u32 noa_start_time[P2P_MAX_NOA_NUM]; /* schedule expressed in terms of the lower 4 bytes of the TSF timer. */
467 #endif /* CONFIG_P2P_PS */
468 };
469
470 struct tdls_ss_record { /* signal strength record */
471 u8 macaddr[ETH_ALEN];
472 u8 RxPWDBAll;
473 u8 is_tdls_sta; /* _TRUE: direct link sta, _FALSE: else */
474 };
475
476 struct tdls_temp_mgmt {
477 u8 initiator; /* 0: None, 1: we initiate, 2: peer initiate */
478 u8 peer_addr[ETH_ALEN];
479 };
480
481 #ifdef CONFIG_TDLS_CH_SW
482 struct tdls_ch_switch {
483 u32 ch_sw_state;
484 ATOMIC_T chsw_on;
485 u8 addr[ETH_ALEN];
486 u8 off_ch_num;
487 u8 ch_offset;
488 u32 cur_time;
489 u8 delay_switch_back;
490 u8 dump_stack;
491 struct submit_ctx chsw_sctx;
492 };
493 #endif
494
495 struct tdls_info {
496 u8 ap_prohibited;
497 u8 ch_switch_prohibited;
498 u8 link_established;
499 u8 sta_cnt;
500 u8 sta_maximum; /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */
501 struct tdls_ss_record ss_record;
502 #ifdef CONFIG_TDLS_CH_SW
503 struct tdls_ch_switch chsw_info;
504 #endif
505
506 u8 ch_sensing;
507 u8 cur_channel;
508 u8 collect_pkt_num[MAX_CHANNEL_NUM];
509 _lock cmd_lock;
510 _lock hdl_lock;
511 u8 watchdog_count;
512 u8 dev_discovered; /* WFD_TDLS: for sigma test */
513
514 /* Let wpa_supplicant to setup*/
515 u8 driver_setup;
516 #ifdef CONFIG_WFD
517 struct wifi_display_info *wfd_info;
518 #endif
519
520 struct submit_ctx *tdls_sctx;
521 };
522
523 struct tdls_txmgmt {
524 u8 peer[ETH_ALEN];
525 u8 action_code;
526 u8 dialog_token;
527 u16 status_code;
528 u8 *buf;
529 size_t len;
530 };
531
532 /* used for mlme_priv.roam_flags */
533 enum {
534 RTW_ROAM_ON_EXPIRED = BIT0,
535 RTW_ROAM_ON_RESUME = BIT1,
536 RTW_ROAM_ACTIVE = BIT2,
537 };
538
539 #define UNASOC_STA_SRC_RX_BMC 0
540 #define UNASOC_STA_SRC_RX_NMY_UC 1
541 #define UNASOC_STA_SRC_NUM 2
542
543 #define UNASOC_STA_MODE_DISABLED 0
544 #define UNASOC_STA_MODE_INTERESTED 1
545 #define UNASOC_STA_MODE_ALL 2
546 #define UNASOC_STA_MODE_NUM 3
547
548 #define UNASOC_STA_DEL_CHK_SKIP 0
549 #define UNASOC_STA_DEL_CHK_ALIVE 1
550 #define UNASOC_STA_DEL_CHK_DELETED 2
551
552 struct mlme_priv {
553
554 _lock lock;
555 sint fw_state; /* shall we protect this variable? maybe not necessarily... */
556 u8 to_join; /* flag */
557 u16 join_status;
558 #ifdef CONFIG_LAYER2_ROAMING
559 u8 to_roam; /* roaming trying times */
560 struct wlan_network *roam_network; /* the target of active roam */
561 u8 roam_flags;
562 u8 roam_rssi_diff_th; /* rssi difference threshold for active scan candidate selection */
563 u32 roam_scan_int; /* scan interval for active roam (Unit:2 second)*/
564 u32 roam_scanr_exp_ms; /* scan result expire time in ms for roam */
565 u8 roam_tgt_addr[ETH_ALEN]; /* request to roam to speicific target without other consideration */
566 u8 roam_rssi_threshold;
567 systime last_roaming;
568 bool need_to_roam;
569 #endif
570
571 u32 defs_lmt_sta;
572 u32 defs_lmt_time;
573
574 u8 *nic_hdl;
575 u32 max_bss_cnt; /* The size of scan queue */
576 _list *pscanned;
577 _queue free_bss_pool;
578 _queue scanned_queue;
579 u8 *free_bss_buf;
580 u32 num_of_scanned;
581
582 NDIS_802_11_SSID assoc_ssid;
583 u8 assoc_bssid[6];
584 u16 assoc_ch; /* 0 reserved for no specific channel */
585
586 struct wlan_network cur_network;
587 struct wlan_network *cur_network_scanned;
588
589 /* bcn check info */
590 struct beacon_keys cur_beacon_keys; /* save current beacon keys */
591 #ifdef CONFIG_BCN_CNT_CONFIRM_HDL
592 struct beacon_keys new_beacon_keys; /* save new beacon keys */
593 u8 new_beacon_cnts; /* if new_beacon_cnts >= threshold, ap beacon is changed */
594 #endif
595
596 #ifdef CONFIG_ARP_KEEP_ALIVE
597 /* for arp offload keep alive */
598 u8 bGetGateway;
599 u8 GetGatewayTryCnt;
600 u8 gw_mac_addr[ETH_ALEN];
601 u8 gw_ip[4];
602 #endif
603
604 /* uint wireless_mode; no used, remove it */
605
606 u32 auto_scan_int_ms;
607
608 _timer assoc_timer;
609
610 uint assoc_by_bssid;
611 uint assoc_by_rssi;
612
613 _timer scan_to_timer; /* driver itself handles scan_timeout status. */
614 systime scan_start_time; /* used to evaluate the time spent in scanning */
615
616 #ifdef CONFIG_SET_SCAN_DENY_TIMER
617 _timer set_scan_deny_timer;
618 ATOMIC_T set_scan_deny; /* 0: allowed, 1: deny */
619 #endif
620 u8 wpa_phase;/*wpa_phase after wps finished*/
621
622 struct qos_priv qospriv;
623
624 #ifdef CONFIG_80211N_HT
625
626 /* Number of non-HT AP/stations */
627 int num_sta_no_ht;
628
629 /* Number of HT AP/stations 20 MHz */
630 /* int num_sta_ht_20mhz; */
631
632
633 int num_FortyMHzIntolerant;
634
635 struct ht_priv htpriv;
636
637 #endif
638
639 #ifdef CONFIG_80211AC_VHT
640 struct vht_priv vhtpriv;
641 #ifdef ROKU_PRIVATE
642 /*infra mode, used to store AP's info*/
643 struct vht_priv_infra_ap vhtpriv_infra_ap;
644 #endif /* ROKU_PRIVATE */
645 #endif
646
647 #ifdef ROKU_PRIVATE
648 struct ht_priv_infra_ap htpriv_infra_ap;
649 #endif /* ROKU_PRIVATE */
650
651 #ifdef CONFIG_RTW_80211R
652 struct ft_roam_info ft_roam;
653 #endif
654 #if defined(CONFIG_RTW_WNM) || defined(CONFIG_RTW_80211K)
655 struct roam_nb_info nb_info;
656 u8 ch_cnt;
657 #endif
658
659 RT_LINK_DETECT_T LinkDetectInfo;
660
661 u8 acm_mask; /* for wmm acm mask */
662 RT_SCAN_TYPE scan_mode; /* active: 1, passive: 0 */
663
664 u8 *wps_probe_req_ie;
665 u32 wps_probe_req_ie_len;
666
667 u8 ext_capab_ie_data[8];/*currently for ap mode only*/
668 u8 ext_capab_ie_len;
669
670 #if defined(CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
671 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
672 * in 802.11g BSS) */
673 int num_sta_non_erp;
674
675 /* Number of associated stations that do not support Short Slot Time */
676 int num_sta_no_short_slot_time;
677
678 /* Number of associated stations that do not support Short Preamble */
679 int num_sta_no_short_preamble;
680
681 ATOMIC_T olbc; /* Overlapping Legacy BSS Condition (Legacy b/g)*/
682
683 /* Number of HT associated stations that do not support greenfield */
684 int num_sta_ht_no_gf;
685
686 /* Number of associated non-HT stations */
687 /* int num_sta_no_ht; */
688
689 /* Number of HT associated stations 20 MHz */
690 int num_sta_ht_20mhz;
691
692 /* number of associated stations 40MHz intolerant */
693 int num_sta_40mhz_intolerant;
694
695 /* Overlapping BSS information */
696 ATOMIC_T olbc_ht;
697
698 #ifdef CONFIG_80211N_HT
699 int ht_20mhz_width_req;
700 int ht_intolerant_ch_reported;
701 u16 ht_op_mode;
702 u8 sw_to_20mhz; /*switch to 20Mhz BW*/
703 #endif /* CONFIG_80211N_HT */
704
705 #ifdef CONFIG_RTW_80211R
706 u8 *auth_rsp;
707 u32 auth_rsp_len;
708 #endif
709 #endif /* CONFIG_AP_MODE and CONFIG_NATIVEAP_MLME */
710
711 u8 *assoc_req;
712 u32 assoc_req_len;
713 u8 *assoc_rsp;
714 u32 assoc_rsp_len;
715
716 #if defined(CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
717 /* u8 *wps_probe_req_ie; */
718 /* u32 wps_probe_req_ie_len; */
719
720 u8 *wps_beacon_ie;
721 u32 wps_beacon_ie_len;
722
723 u8 *wps_probe_resp_ie;
724 u32 wps_probe_resp_ie_len;
725
726 u8 *wps_assoc_resp_ie;
727 u32 wps_assoc_resp_ie_len;
728
729 u8 *p2p_beacon_ie;
730 u32 p2p_beacon_ie_len;
731
732 u8 *p2p_probe_req_ie;
733 u32 p2p_probe_req_ie_len;
734
735 u8 *p2p_probe_resp_ie;
736 u32 p2p_probe_resp_ie_len;
737
738 u8 *p2p_go_probe_resp_ie; /* for GO */
739 u32 p2p_go_probe_resp_ie_len; /* for GO */
740
741 u8 *p2p_assoc_req_ie;
742 u32 p2p_assoc_req_ie_len;
743
744 u8 *p2p_assoc_resp_ie;
745 u32 p2p_assoc_resp_ie_len;
746
747 _lock bcn_update_lock;
748 u8 update_bcn;
749
750 u8 ori_ch;
751 u8 ori_bw;
752 u8 ori_offset;
753 #ifdef CONFIG_80211AC_VHT
754 u8 ori_vht_en;
755 #endif
756
757 u8 ap_isolate;
758 #endif /* #if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME) */
759
760 #if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
761 u8 *wfd_beacon_ie;
762 u32 wfd_beacon_ie_len;
763
764 u8 *wfd_probe_req_ie;
765 u32 wfd_probe_req_ie_len;
766
767 u8 *wfd_probe_resp_ie;
768 u32 wfd_probe_resp_ie_len;
769
770 u8 *wfd_go_probe_resp_ie; /* for GO */
771 u32 wfd_go_probe_resp_ie_len; /* for GO */
772
773 u8 *wfd_assoc_req_ie;
774 u32 wfd_assoc_req_ie_len;
775
776 u8 *wfd_assoc_resp_ie;
777 u32 wfd_assoc_resp_ie_len;
778 #endif
779
780 #ifdef CONFIG_RTW_MBO
781 u8 *pcell_data_cap_ie;
782 u32 cell_data_cap_len;
783 #endif
784
785 #ifdef RTK_DMP_PLATFORM
786 /* DMP kobject_hotplug function signal need in passive level */
787 _workitem Linkup_workitem;
788 _workitem Linkdown_workitem;
789 #endif
790
791 #ifdef RTW_BUSY_DENY_SCAN
792 systime lastscantime;
793 #endif
794
795 #ifdef CONFIG_CONCURRENT_MODE
796 u8 scanning_via_buddy_intf;
797 #endif
798
799 #ifdef CONFIG_APPEND_VENDOR_IE_ENABLE
800 u32 vendor_ie_mask[WLAN_MAX_VENDOR_IE_NUM];
801 u8 vendor_ie[WLAN_MAX_VENDOR_IE_NUM][WLAN_MAX_VENDOR_IE_LEN];
802 u32 vendor_ielen[WLAN_MAX_VENDOR_IE_NUM];
803 #endif
804 #ifdef CONFIG_RTW_MULTI_AP
805 u8 unassoc_sta_mode_of_stype[UNASOC_STA_SRC_NUM];
806 _queue unassoc_sta_queue;
807 _queue free_unassoc_sta_queue;
808 u8 *free_unassoc_sta_buf;
809 u32 interested_unassoc_sta_cnt;
810 u32 max_unassoc_sta_cnt;
811 #endif
812 };
813
814 #ifdef CONFIG_RTW_MULTI_AP
815 struct unassoc_sta_info {
816 _list list;
817 u8 addr[ETH_ALEN];
818 u8 interested;
819 s8 recv_signal_power;
820 systime time;
821 };
822 #endif
823
824 #define mlme_set_scan_to_timer(mlme, ms) \
825 do { \
826 /* RTW_INFO("%s set_scan_to_timer(%p, %d)\n", __FUNCTION__, (mlme), (ms)); */ \
827 _set_timer(&(mlme)->scan_to_timer, (ms)); \
828 } while (0)
829
830 #define rtw_mlme_set_auto_scan_int(adapter, ms) \
831 do { \
832 adapter->mlmepriv.auto_scan_int_ms = ms; \
833 } while (0)
834
835 #define RTW_AUTO_SCAN_REASON_UNSPECIFIED 0
836 #define RTW_AUTO_SCAN_REASON_2040_BSS BIT0
837 #define RTW_AUTO_SCAN_REASON_ACS BIT1
838 #define RTW_AUTO_SCAN_REASON_ROAM BIT2
839 #define RTW_AUTO_SCAN_REASON_MESH_OFFCH_CAND BIT3
840
841 void rtw_mlme_reset_auto_scan_int(_adapter *adapter, u8 *reason);
842
843 #ifdef CONFIG_AP_MODE
844
845 struct hostapd_priv {
846 _adapter *padapter;
847
848 #ifdef CONFIG_HOSTAPD_MLME
849 struct net_device *pmgnt_netdev;
850 struct usb_anchor anchored;
851 #endif
852
853 };
854
855 extern int hostapd_mode_init(_adapter *padapter);
856 extern void hostapd_mode_unload(_adapter *padapter);
857 #endif
858
859
860 extern void rtw_joinbss_event_prehandle(_adapter *adapter, u8 *pbuf, u16 status);
861 extern void rtw_survey_event_callback(_adapter *adapter, u8 *pbuf);
862 extern void rtw_surveydone_event_callback(_adapter *adapter, u8 *pbuf);
863 extern void rtw_joinbss_event_callback(_adapter *adapter, u8 *pbuf);
864 extern void rtw_stassoc_event_callback(_adapter *adapter, u8 *pbuf);
865 extern void rtw_stadel_event_callback(_adapter *adapter, u8 *pbuf);
866 void rtw_sta_mstatus_disc_rpt(_adapter *adapter, u8 mac_id);
867 void rtw_sta_mstatus_report(_adapter *adapter);
868 extern void rtw_wmm_event_callback(PADAPTER padapter, u8 *pbuf);
869 #ifdef CONFIG_IEEE80211W
870 void rtw_sta_timeout_event_callback(_adapter *adapter, u8 *pbuf);
871 #endif /* CONFIG_IEEE80211W */
872 thread_return event_thread(thread_context context);
873
874 extern void rtw_free_network_queue(_adapter *adapter, u8 isfreeall);
875 extern int rtw_init_mlme_priv(_adapter *adapter);/* (struct mlme_priv *pmlmepriv); */
876
877 extern void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
878
879
880 extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
881 extern sint rtw_set_key(_adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue);
882 extern sint rtw_set_auth(_adapter *adapter, struct security_priv *psecuritypriv);
883
get_bssid(struct mlme_priv * pmlmepriv)884 __inline static u8 *get_bssid(struct mlme_priv *pmlmepriv)
885 {
886 /* if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid */
887 /* if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address */
888 return pmlmepriv->cur_network.network.MacAddress;
889 }
890
check_fwstate(struct mlme_priv * pmlmepriv,sint state)891 __inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
892 {
893 if ((state == WIFI_NULL_STATE) &&
894 (pmlmepriv->fw_state == WIFI_NULL_STATE))
895 return _TRUE;
896
897 if (pmlmepriv->fw_state & state)
898 return _TRUE;
899
900 return _FALSE;
901 }
902
get_fwstate(struct mlme_priv * pmlmepriv)903 __inline static sint get_fwstate(struct mlme_priv *pmlmepriv)
904 {
905 return pmlmepriv->fw_state;
906 }
907
908 /*
909 * No Limit on the calling context,
910 * therefore set it to be the critical section...
911 *
912 * ### NOTE:#### (!!!!)
913 * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
914 */
915 extern void rtw_mi_update_iface_status(struct mlme_priv *pmlmepriv, sint state);
916
set_fwstate(struct mlme_priv * pmlmepriv,sint state)917 static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
918 {
919 pmlmepriv->fw_state |= state;
920 rtw_mi_update_iface_status(pmlmepriv, state);
921 }
init_fwstate(struct mlme_priv * pmlmepriv,sint state)922 static inline void init_fwstate(struct mlme_priv *pmlmepriv, sint state)
923 {
924 pmlmepriv->fw_state = state;
925 rtw_mi_update_iface_status(pmlmepriv, state);
926 }
927
_clr_fwstate_(struct mlme_priv * pmlmepriv,sint state)928 static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
929 {
930 pmlmepriv->fw_state &= ~state;
931 rtw_mi_update_iface_status(pmlmepriv, state);
932 }
933
934 /*
935 * No Limit on the calling context,
936 * therefore set it to be the critical section...
937 */
clr_fwstate(struct mlme_priv * pmlmepriv,sint state)938 static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
939 {
940 _irqL irqL;
941
942 _enter_critical_bh(&pmlmepriv->lock, &irqL);
943 _clr_fwstate_(pmlmepriv, state);
944 _exit_critical_bh(&pmlmepriv->lock, &irqL);
945 }
946
up_scanned_network(struct mlme_priv * pmlmepriv)947 static inline void up_scanned_network(struct mlme_priv *pmlmepriv)
948 {
949 _irqL irqL;
950
951 _enter_critical_bh(&pmlmepriv->lock, &irqL);
952 pmlmepriv->num_of_scanned++;
953 _exit_critical_bh(&pmlmepriv->lock, &irqL);
954 }
955 u8 rtw_is_adapter_up(_adapter *padapter);
956
down_scanned_network(struct mlme_priv * pmlmepriv)957 __inline static void down_scanned_network(struct mlme_priv *pmlmepriv)
958 {
959 _irqL irqL;
960
961 _enter_critical_bh(&pmlmepriv->lock, &irqL);
962 pmlmepriv->num_of_scanned--;
963 _exit_critical_bh(&pmlmepriv->lock, &irqL);
964 }
965
set_scanned_network_val(struct mlme_priv * pmlmepriv,sint val)966 __inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
967 {
968 _irqL irqL;
969
970 _enter_critical_bh(&pmlmepriv->lock, &irqL);
971 pmlmepriv->num_of_scanned = val;
972 _exit_critical_bh(&pmlmepriv->lock, &irqL);
973 }
974
975 extern u16 rtw_get_capability(WLAN_BSSID_EX *bss);
976 extern bool rtw_update_scanned_network(_adapter *adapter, WLAN_BSSID_EX *target);
977 extern void rtw_disconnect_hdl_under_linked(_adapter *adapter, struct sta_info *psta, u8 free_assoc);
978 extern void rtw_generate_random_ibss(u8 *pibss);
979 struct wlan_network *_rtw_find_network(_queue *scanned_queue, const u8 *addr);
980 struct wlan_network *rtw_find_network(_queue *scanned_queue, const u8 *addr);
981 extern struct wlan_network *rtw_get_oldest_wlan_network(_queue *scanned_queue);
982 struct wlan_network *_rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
983 struct wlan_network *rtw_find_same_network(_queue *scanned_queue, struct wlan_network *network);
984
985 extern void rtw_free_assoc_resources(_adapter *adapter, u8 lock_scanned_queue);
986 extern void rtw_indicate_disconnect(_adapter *adapter, u16 reason, u8 locally_generated);
987 extern void rtw_indicate_connect(_adapter *adapter);
988 void rtw_indicate_scan_done(_adapter *padapter, bool aborted);
989
990 void rtw_drv_scan_by_self(_adapter *padapter, u8 reason);
991 void rtw_scan_wait_completed(_adapter *adapter);
992 u32 rtw_scan_abort_timeout(_adapter *adapter, u32 timeout_ms);
993 void rtw_scan_abort_no_wait(_adapter *adapter);
994 void rtw_scan_abort(_adapter *adapter);
995 u32 rtw_join_abort_timeout(_adapter *adapter, u32 timeout_ms);
996
997 int rtw_cached_pmkid(_adapter *Adapter, u8 *bssid);
998 int rtw_rsn_sync_pmkid(_adapter *adapter, u8 *ie, uint ie_len, int i_ent);
999
1000 extern int rtw_restruct_sec_ie(_adapter *adapter, u8 *out_ie);
1001 #ifdef CONFIG_WMMPS_STA
1002 void rtw_uapsd_use_default_setting(_adapter *padapter);
1003 bool rtw_is_wmmps_mode(_adapter *padapter);
1004 #endif /* CONFIG_WMMPS_STA */
1005 extern int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len);
1006 extern void rtw_init_registrypriv_dev_network(_adapter *adapter);
1007
1008 extern void rtw_update_registrypriv_dev_network(_adapter *adapter);
1009
1010 extern void rtw_get_encrypt_decrypt_from_registrypriv(_adapter *adapter);
1011
1012 extern void rtw_join_timeout_handler(void *ctx);
1013 extern void rtw_scan_timeout_handler(void *ctx);
1014
1015 extern void rtw_dynamic_check_timer_handlder(void *ctx);
1016 extern void rtw_iface_dynamic_check_timer_handlder(_adapter *adapter);
1017
1018 enum {
1019 SS_DENY_MP_MODE,
1020 SS_DENY_RSON_SCANING,
1021 SS_DENY_BLOCK_SCAN,
1022 SS_DENY_BY_DRV,
1023 SS_DENY_SELF_AP_UNDER_WPS,
1024 SS_DENY_SELF_AP_UNDER_LINKING,
1025 SS_DENY_SELF_AP_UNDER_SURVEY,
1026 /*SS_DENY_SELF_STA_UNDER_WPS,*/
1027 SS_DENY_SELF_STA_UNDER_LINKING,
1028 SS_DENY_SELF_STA_UNDER_SURVEY,
1029 SS_DENY_BUDDY_UNDER_LINK_WPS,
1030 SS_DENY_BUDDY_UNDER_SURVEY,
1031 SS_DENY_BUSY_TRAFFIC,
1032 SS_ALLOW,
1033 #ifdef DBG_LA_MODE
1034 SS_DENY_LA_MODE,
1035 #endif
1036 SS_DENY_ADAPTIVITY,
1037 };
1038
1039 u8 _rtw_sitesurvey_condition_check(const char *caller, _adapter *adapter, bool check_sc_interval);
1040 #define rtw_sitesurvey_condition_check(adapter, check_sc_interval) _rtw_sitesurvey_condition_check(__func__, adapter, check_sc_interval)
1041
1042 #ifdef CONFIG_SET_SCAN_DENY_TIMER
1043 bool rtw_is_scan_deny(_adapter *adapter);
1044 void rtw_clear_scan_deny(_adapter *adapter);
1045 void rtw_set_scan_deny_timer_hdl(void *ctx);
1046 void rtw_set_scan_deny(_adapter *adapter, u32 ms);
1047 #else
1048 #define rtw_is_scan_deny(adapter) _FALSE
1049 #define rtw_clear_scan_deny(adapter) do {} while (0)
1050 #define rtw_set_scan_deny(adapter, ms) do {} while (0)
1051 #endif
1052
1053 void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
1054
1055 #define MLME_BEACON_IE 0
1056 #define MLME_PROBE_REQ_IE 1
1057 #define MLME_PROBE_RESP_IE 2
1058 #define MLME_GO_PROBE_RESP_IE 3
1059 #define MLME_ASSOC_REQ_IE 4
1060 #define MLME_ASSOC_RESP_IE 5
1061
1062 #if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
1063 int rtw_mlme_update_wfd_ie_data(struct mlme_priv *mlme, u8 type, u8 *ie, u32 ie_len);
1064 #endif
1065
1066
1067 /* extern struct wlan_network* _rtw_dequeue_network(_queue *queue); */
1068
1069 extern struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv);
1070
1071
1072 extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
1073 extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
1074
1075 extern void _rtw_free_network_queue(_adapter *padapter, u8 isfreeall);
1076
1077 extern sint rtw_if_up(_adapter *padapter);
1078
1079 sint rtw_linked_check(_adapter *padapter);
1080
1081 u8 *rtw_get_capability_from_ie(u8 *ie);
1082 u8 *rtw_get_timestampe_from_ie(u8 *ie);
1083 u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
1084
1085
1086 void rtw_joinbss_reset(_adapter *padapter);
1087
1088 #ifdef CONFIG_80211N_HT
1089 void rtw_ht_use_default_setting(_adapter *padapter);
1090 void rtw_build_wmm_ie_ht(_adapter *padapter, u8 *out_ie, uint *pout_len);
1091 unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel);
1092 void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel);
1093 void rtw_issue_addbareq_cmd(_adapter *padapter, struct xmit_frame *pxmitframe, u8 issue_when_busy);
1094 void rtw_append_exented_cap(_adapter *padapter, u8 *out_ie, uint *pout_len);
1095 #endif
1096
1097 int rtw_is_same_ibss(_adapter *adapter, struct wlan_network *pnetwork);
1098 int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst, u8 feature);
1099
1100 #ifdef CONFIG_LAYER2_ROAMING
1101 #define rtw_roam_flags(adapter) ((adapter)->mlmepriv.roam_flags)
1102 #define rtw_chk_roam_flags(adapter, flags) ((adapter)->mlmepriv.roam_flags & flags)
1103 #define rtw_clr_roam_flags(adapter, flags) \
1104 do { \
1105 ((adapter)->mlmepriv.roam_flags &= ~flags); \
1106 } while (0)
1107
1108 #define rtw_set_roam_flags(adapter, flags) \
1109 do { \
1110 ((adapter)->mlmepriv.roam_flags |= flags); \
1111 } while (0)
1112
1113 #define rtw_assign_roam_flags(adapter, flags) \
1114 do { \
1115 ((adapter)->mlmepriv.roam_flags = flags); \
1116 } while (0)
1117
1118 void _rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
1119 void rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
1120 void rtw_set_to_roam(_adapter *adapter, u8 to_roam);
1121 u8 rtw_dec_to_roam(_adapter *adapter);
1122 u8 rtw_to_roam(_adapter *adapter);
1123 int rtw_select_roaming_candidate(struct mlme_priv *pmlmepriv);
1124 #else
1125 #define rtw_roam_flags(adapter) 0
1126 #define rtw_chk_roam_flags(adapter, flags) 0
1127 #define rtw_clr_roam_flags(adapter, flags) do {} while (0)
1128 #define rtw_set_roam_flags(adapter, flags) do {} while (0)
1129 #define rtw_assign_roam_flags(adapter, flags) do {} while (0)
1130 #define _rtw_roaming(adapter, tgt_network) do {} while (0)
1131 #define rtw_roaming(adapter, tgt_network) do {} while (0)
1132 #define rtw_set_to_roam(adapter, to_roam) do {} while (0)
1133 #define rtw_dec_to_roam(adapter) 0
1134 #define rtw_to_roam(adapter) 0
1135 #define rtw_select_roaming_candidate(mlme) _FAIL
1136 #endif /* CONFIG_LAYER2_ROAMING */
1137
1138 bool rtw_adjust_chbw(_adapter *adapter, u8 req_ch, u8 *req_bw, u8 *req_offset);
1139
1140 struct sta_media_status_rpt_cmd_parm {
1141 struct sta_info *sta;
1142 bool connected;
1143 };
1144
1145 #ifdef CONFIG_RTW_MULTI_AP
1146 void rtw_unassoc_sta_set_mode(_adapter *adapter, u8 stype, u8 mode);
1147 bool rtw_unassoc_sta_src_chk(_adapter *adapter, u8 stype);
1148 void dump_unassoc_sta(void *sel, _adapter *adapter);
1149 void rtw_del_unassoc_sta_queue(_adapter *adapter);
1150 void rtw_del_unassoc_sta(_adapter *adapter, u8 *addr);
1151 void rtw_rx_add_unassoc_sta(_adapter *adapter, u8 stype, u8 *addr, s8 recv_signal_power);
1152 void rtw_add_interested_unassoc_sta(_adapter *adapter, u8 *addr);
1153 void rtw_undo_interested_unassoc_sta(_adapter *adapter, u8 *addr);
1154 void rtw_undo_all_interested_unassoc_sta(_adapter *adapter);
1155 #endif
1156
1157 void rtw_sta_media_status_rpt(_adapter *adapter, struct sta_info *sta, bool connected);
1158 u8 rtw_sta_media_status_rpt_cmd(_adapter *adapter, struct sta_info *sta, bool connected);
1159 void rtw_sta_media_status_rpt_cmd_hdl(_adapter *adapter, struct sta_media_status_rpt_cmd_parm *parm);
1160 void rtw_sta_traffic_info(void *sel, _adapter *adapter);
1161
1162 #define GET_ARP_HTYPE(_arp) BE_BITS_TO_2BYTE(((u8 *)(_arp)) + 0, 0, 16)
1163 #define GET_ARP_PTYPE(_arp) BE_BITS_TO_2BYTE(((u8 *)(_arp)) + 2, 0, 16)
1164 #define GET_ARP_HLEN(_arp) BE_BITS_TO_1BYTE(((u8 *)(_arp)) + 4, 0, 8)
1165 #define GET_ARP_PLEN(_arp) BE_BITS_TO_1BYTE(((u8 *)(_arp)) + 5, 0, 8)
1166 #define GET_ARP_OPER(_arp) BE_BITS_TO_2BYTE(((u8 *)(_arp)) + 6, 0, 16)
1167
1168 #define SET_ARP_HTYPE(_arp, _val) SET_BITS_TO_BE_2BYTE(((u8 *)(_arp)) + 0, 0, 16, _val)
1169 #define SET_ARP_PTYPE(_arp, _val) SET_BITS_TO_BE_2BYTE(((u8 *)(_arp)) + 2, 0, 16, _val)
1170 #define SET_ARP_HLEN(_arp, _val) SET_BITS_TO_BE_1BYTE(((u8 *)(_arp)) + 4, 0, 8, _val)
1171 #define SET_ARP_PLEN(_arp, _val) SET_BITS_TO_BE_1BYTE(((u8 *)(_arp)) + 5, 0, 8, _val)
1172 #define SET_ARP_OPER(_arp, _val) SET_BITS_TO_BE_2BYTE(((u8 *)(_arp)) + 6, 0, 16, _val)
1173
1174 #define ARP_SHA(_arp, _hlen, _plen) (((u8 *)(_arp)) + 8)
1175 #define ARP_SPA(_arp, _hlen, _plen) (((u8 *)(_arp)) + 8 + (_hlen))
1176 #define ARP_THA(_arp, _hlen, _plen) (((u8 *)(_arp)) + 8 + (_hlen) + (_plen))
1177 #define ARP_TPA(_arp, _hlen, _plen) (((u8 *)(_arp)) + 8 + 2 * (_hlen) + (_plen))
1178
1179 #define ARP_SENDER_MAC_ADDR(_arp) ARP_SHA(_arp, ETH_ALEN, RTW_IP_ADDR_LEN)
1180 #define ARP_SENDER_IP_ADDR(_arp) ARP_SPA(_arp, ETH_ALEN, RTW_IP_ADDR_LEN)
1181 #define ARP_TARGET_MAC_ADDR(_arp) ARP_THA(_arp, ETH_ALEN, RTW_IP_ADDR_LEN)
1182 #define ARP_TARGET_IP_ADDR(_arp) ARP_TPA(_arp, ETH_ALEN, RTW_IP_ADDR_LEN)
1183
1184 #define GET_ARP_SENDER_MAC_ADDR(_arp, _val) _rtw_memcpy(_val, ARP_SENDER_MAC_ADDR(_arp), ETH_ALEN)
1185 #define GET_ARP_SENDER_IP_ADDR(_arp, _val) _rtw_memcpy(_val, ARP_SENDER_IP_ADDR(_arp), RTW_IP_ADDR_LEN)
1186 #define GET_ARP_TARGET_MAC_ADDR(_arp, _val) _rtw_memcpy(_val, ARP_TARGET_MAC_ADDR(_arp), ETH_ALEN)
1187 #define GET_ARP_TARGET_IP_ADDR(_arp, _val) _rtw_memcpy(_val, ARP_TARGET_IP_ADDR(_arp), RTW_IP_ADDR_LEN)
1188
1189 #define SET_ARP_SENDER_MAC_ADDR(_arp, _val) _rtw_memcpy(ARP_SENDER_MAC_ADDR(_arp), _val, ETH_ALEN)
1190 #define SET_ARP_SENDER_IP_ADDR(_arp, _val) _rtw_memcpy(ARP_SENDER_IP_ADDR(_arp), _val, RTW_IP_ADDR_LEN)
1191 #define SET_ARP_TARGET_MAC_ADDR(_arp, _val) _rtw_memcpy(ARP_TARGET_MAC_ADDR(_arp), _val, ETH_ALEN)
1192 #define SET_ARP_TARGET_IP_ADDR(_arp, _val) _rtw_memcpy(ARP_TARGET_IP_ADDR(_arp), _val, RTW_IP_ADDR_LEN)
1193
1194 void dump_arp_pkt(void *sel, u8 *da, u8 *sa, u8 *arp, bool tx);
1195
1196 #define IPV4_SRC(_iphdr) (((u8 *)(_iphdr)) + 12)
1197 #define IPV4_DST(_iphdr) (((u8 *)(_iphdr)) + 16)
1198 #define GET_IPV4_IHL(_iphdr) BE_BITS_TO_1BYTE(((u8 *)(_iphdr)) + 0, 0, 4)
1199 #define GET_IPV4_PROTOCOL(_iphdr) BE_BITS_TO_1BYTE(((u8 *)(_iphdr)) + 9, 0, 8)
1200 #define GET_IPV4_SRC(_iphdr) BE_BITS_TO_4BYTE(((u8 *)(_iphdr)) + 12, 0, 32)
1201 #define GET_IPV4_DST(_iphdr) BE_BITS_TO_4BYTE(((u8 *)(_iphdr)) + 16, 0, 32)
1202
1203 #define GET_UDP_SRC(_udphdr) BE_BITS_TO_2BYTE(((u8 *)(_udphdr)) + 0, 0, 16)
1204 #define GET_UDP_DST(_udphdr) BE_BITS_TO_2BYTE(((u8 *)(_udphdr)) + 2, 0, 16)
1205 #define GET_UDP_SIG1(_udphdr) BE_BITS_TO_1BYTE(((u8 *)(_udphdr)) + 8, 0, 8)
1206 #define GET_UDP_SIG2(_udphdr) BE_BITS_TO_1BYTE(((u8 *)(_udphdr)) + 23, 0, 8)
1207
1208 #define TCP_SRC(_tcphdr) (((u8 *)(_tcphdr)) + 0)
1209 #define TCP_DST(_tcphdr) (((u8 *)(_tcphdr)) + 2)
1210 #define GET_TCP_SRC(_tcphdr) BE_BITS_TO_2BYTE(((u8 *)(_tcphdr)) + 0, 0, 16)
1211 #define GET_TCP_DST(_tcphdr) BE_BITS_TO_2BYTE(((u8 *)(_tcphdr)) + 2, 0, 16)
1212 #define GET_TCP_SEQ(_tcphdr) BE_BITS_TO_4BYTE(((u8 *)(_tcphdr)) + 4, 0, 32)
1213 #define GET_TCP_ACK_SEQ(_tcphdr) BE_BITS_TO_4BYTE(((u8 *)(_tcphdr)) + 8, 0, 32)
1214 #define GET_TCP_DOFF(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 12, 4, 4)
1215 #define GET_TCP_FIN(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 0, 1)
1216 #define GET_TCP_SYN(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 1, 1)
1217 #define GET_TCP_RST(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 2, 1)
1218 #define GET_TCP_PSH(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 3, 1)
1219 #define GET_TCP_ACK(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 4, 1)
1220 #define GET_TCP_URG(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 5, 1)
1221 #define GET_TCP_ECE(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 6, 1)
1222 #define GET_TCP_CWR(_tcphdr) BE_BITS_TO_1BYTE(((u8 *)(_tcphdr)) + 13, 7, 1)
1223
1224 #endif /* __RTL871X_MLME_H_ */
1225