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