rtw_mlme.h 40 KB

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