rtw_mlme.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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. #define SCAN_INTERVAL (30) // unit:2sec, 30*2=60sec
  30. #ifdef PALTFORM_OS_WINCE
  31. #define SCANQUEUE_LIFETIME 12000000 // unit:us
  32. #else
  33. #define SCANQUEUE_LIFETIME 20000 // 20sec, unit:msec
  34. #endif
  35. #define WIFI_NULL_STATE 0x00000000
  36. #define WIFI_ASOC_STATE 0x00000001 // Under Linked state...
  37. #define WIFI_REASOC_STATE 0x00000002
  38. #define WIFI_SLEEP_STATE 0x00000004
  39. #define WIFI_STATION_STATE 0x00000008
  40. #define WIFI_AP_STATE 0x00000010
  41. #define WIFI_ADHOC_STATE 0x00000020
  42. #define WIFI_ADHOC_MASTER_STATE 0x00000040
  43. #define WIFI_UNDER_LINKING 0x00000080
  44. #define WIFI_UNDER_WPS 0x00000100
  45. //#define WIFI_UNDER_CMD 0x00000200
  46. //#define WIFI_UNDER_P2P 0x00000400
  47. #define WIFI_STA_ALIVE_CHK_STATE 0x00000400
  48. #define WIFI_SITE_MONITOR 0x00000800 //to indicate the station is under site surveying
  49. #ifdef WDS
  50. #define WIFI_WDS 0x00001000
  51. #define WIFI_WDS_RX_BEACON 0x00002000 // already rx WDS AP beacon
  52. #endif
  53. #ifdef AUTO_CONFIG
  54. #define WIFI_AUTOCONF 0x00004000
  55. #define WIFI_AUTOCONF_IND 0x00008000
  56. #endif
  57. /*
  58. // ========== P2P Section Start ===============
  59. #define WIFI_P2P_LISTEN_STATE 0x00010000
  60. #define WIFI_P2P_GROUP_FORMATION_STATE 0x00020000
  61. // ========== P2P Section End ===============
  62. */
  63. //#ifdef UNDER_MPTEST
  64. #define WIFI_MP_STATE 0x00010000
  65. #define WIFI_MP_CTX_BACKGROUND 0x00020000 // in continous tx background
  66. #define WIFI_MP_CTX_ST 0x00040000 // in continous tx with single-tone
  67. #define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 // pending in continous tx background due to out of skb
  68. #define WIFI_MP_CTX_CCK_HW 0x00100000 // in continous tx
  69. #define WIFI_MP_CTX_CCK_CS 0x00200000 // in continous tx with carrier suppression
  70. #define WIFI_MP_LPBK_STATE 0x00400000
  71. //#endif
  72. //#define _FW_UNDER_CMD WIFI_UNDER_CMD
  73. #define _FW_UNDER_LINKING WIFI_UNDER_LINKING
  74. #define _FW_LINKED WIFI_ASOC_STATE
  75. #define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
  76. enum dot11AuthAlgrthmNum {
  77. dot11AuthAlgrthm_Open = 0,
  78. dot11AuthAlgrthm_Shared,
  79. dot11AuthAlgrthm_8021X,
  80. dot11AuthAlgrthm_Auto,
  81. dot11AuthAlgrthm_WAPI,
  82. dot11AuthAlgrthm_MaxNum
  83. };
  84. // Scan type including active and passive scan.
  85. typedef enum _RT_SCAN_TYPE
  86. {
  87. SCAN_PASSIVE,
  88. SCAN_ACTIVE,
  89. SCAN_MIX,
  90. }RT_SCAN_TYPE, *PRT_SCAN_TYPE;
  91. enum _BAND
  92. {
  93. GHZ24_50 = 0,
  94. GHZ_50,
  95. GHZ_24,
  96. };
  97. enum DriverInterface {
  98. DRIVER_WEXT = 1,
  99. DRIVER_CFG80211 = 2
  100. };
  101. enum SCAN_RESULT_TYPE
  102. {
  103. SCAN_RESULT_P2P_ONLY = 0, // Will return all the P2P devices.
  104. SCAN_RESULT_ALL = 1, // Will return all the scanned device, include AP.
  105. SCAN_RESULT_WFD_TYPE = 2 // Will just return the correct WFD device.
  106. // If this device is Miracast sink device, it will just return all the Miracast source devices.
  107. };
  108. /*
  109. there are several "locks" in mlme_priv,
  110. since mlme_priv is a shared resource between many threads,
  111. like ISR/Call-Back functions, the OID handlers, and even timer functions.
  112. Each _queue has its own locks, already.
  113. Other items are protected by mlme_priv.lock.
  114. To avoid possible dead lock, any thread trying to modifiying mlme_priv
  115. SHALL not lock up more than one locks at a time!
  116. */
  117. #define traffic_threshold 10
  118. #define traffic_scan_period 500
  119. struct sitesurvey_ctrl {
  120. u64 last_tx_pkts;
  121. uint last_rx_pkts;
  122. sint traffic_busy;
  123. _timer sitesurvey_ctrl_timer;
  124. };
  125. typedef struct _RT_LINK_DETECT_T{
  126. u32 NumTxOkInPeriod;
  127. u32 NumRxOkInPeriod;
  128. u32 NumRxUnicastOkInPeriod;
  129. BOOLEAN bBusyTraffic;
  130. BOOLEAN bTxBusyTraffic;
  131. BOOLEAN bRxBusyTraffic;
  132. BOOLEAN bHigherBusyTraffic; // For interrupt migration purpose.
  133. BOOLEAN bHigherBusyRxTraffic; // We may disable Tx interrupt according as Rx traffic.
  134. BOOLEAN bHigherBusyTxTraffic; // We may disable Tx interrupt according as Tx traffic.
  135. }RT_LINK_DETECT_T, *PRT_LINK_DETECT_T;
  136. struct profile_info {
  137. u8 ssidlen;
  138. u8 ssid[ WLAN_SSID_MAXLEN ];
  139. u8 peermac[ ETH_ALEN ];
  140. };
  141. struct tx_invite_req_info{
  142. u8 token;
  143. u8 benable;
  144. u8 go_ssid[ WLAN_SSID_MAXLEN ];
  145. u8 ssidlen;
  146. u8 go_bssid[ ETH_ALEN ];
  147. u8 peer_macaddr[ ETH_ALEN ];
  148. u8 operating_ch; // This information will be set by using the p2p_set op_ch=x
  149. u8 peer_ch; // The listen channel for peer P2P device
  150. };
  151. struct tx_invite_resp_info{
  152. u8 token; // Used to record the dialog token of p2p invitation request frame.
  153. };
  154. #ifdef CONFIG_WFD
  155. struct wifi_display_info{
  156. u16 wfd_enable; // Eanble/Disable the WFD function.
  157. u16 rtsp_ctrlport; // TCP port number at which the this WFD device listens for RTSP messages
  158. u16 peer_rtsp_ctrlport; // TCP port number at which the peer WFD device listens for RTSP messages
  159. // This filed should be filled when receiving the gropu negotiation request
  160. u8 peer_session_avail; // WFD session is available or not for the peer wfd device.
  161. // This variable will be set when sending the provisioning discovery request to peer WFD device.
  162. // And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command.
  163. u8 ip_address[4];
  164. u8 peer_ip_address[4];
  165. u8 wfd_pc; // WFD preferred connection
  166. // 0 -> Prefer to use the P2P for WFD connection on peer side.
  167. // 1 -> Prefer to use the TDLS for WFD connection on peer side.
  168. u8 wfd_device_type; // WFD Device Type
  169. // 0 -> WFD Source Device
  170. // 1 -> WFD Primary Sink Device
  171. enum SCAN_RESULT_TYPE scan_result_type; // Used when P2P is enable. This parameter will impact the scan result.
  172. };
  173. #endif //CONFIG_WFD
  174. struct tx_provdisc_req_info{
  175. u16 wps_config_method_request; // Used when sending the provisioning request frame
  176. u16 peer_channel_num[2]; // The channel number which the receiver stands.
  177. NDIS_802_11_SSID ssid;
  178. u8 peerDevAddr[ ETH_ALEN ]; // Peer device address
  179. u8 peerIFAddr[ ETH_ALEN ]; // Peer interface address
  180. u8 benable; // This provision discovery request frame is trigger to send or not
  181. };
  182. struct rx_provdisc_req_info{ //When peer device issue prov_disc_req first, we should store the following informations
  183. u8 peerDevAddr[ ETH_ALEN ]; // Peer device address
  184. u8 strconfig_method_desc_of_prov_disc_req[4]; // description for the config method located in the provisioning discovery request frame.
  185. // The UI must know this information to know which config method the remote p2p device is requiring.
  186. };
  187. struct tx_nego_req_info{
  188. u16 peer_channel_num[2]; // The channel number which the receiver stands.
  189. u8 peerDevAddr[ ETH_ALEN ]; // Peer device address
  190. u8 benable; // This negoitation request frame is trigger to send or not
  191. };
  192. struct group_id_info{
  193. u8 go_device_addr[ ETH_ALEN ]; // The GO's device address of this P2P group
  194. u8 ssid[ WLAN_SSID_MAXLEN ]; // The SSID of this P2P group
  195. };
  196. struct scan_limit_info{
  197. u8 scan_op_ch_only; // When this flag is set, the driver should just scan the operation channel
  198. u8 operation_ch[2]; // Store the operation channel of invitation request frame
  199. };
  200. #ifdef CONFIG_IOCTL_CFG80211
  201. struct cfg80211_wifidirect_info{
  202. _timer remain_on_ch_timer;
  203. u8 restore_channel;
  204. struct ieee80211_channel remain_on_ch_channel;
  205. enum nl80211_channel_type remain_on_ch_type;
  206. u64 remain_on_ch_cookie;
  207. bool is_ro_ch;
  208. };
  209. #endif //CONFIG_IOCTL_CFG80211
  210. struct wifidirect_info{
  211. _adapter* padapter;
  212. _timer find_phase_timer;
  213. _timer restore_p2p_state_timer;
  214. // Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer.
  215. _timer pre_tx_scan_timer;
  216. _timer reset_ch_sitesurvey;
  217. _timer reset_ch_sitesurvey2; // Just for resetting the scan limit function by using p2p nego
  218. #ifdef CONFIG_CONCURRENT_MODE
  219. // Used to switch the channel between legacy AP and listen state.
  220. _timer ap_p2p_switch_timer;
  221. #endif
  222. struct tx_provdisc_req_info tx_prov_disc_info;
  223. struct rx_provdisc_req_info rx_prov_disc_info;
  224. struct tx_invite_req_info invitereq_info;
  225. struct profile_info profileinfo[ P2P_MAX_PERSISTENT_GROUP_NUM ]; // Store the profile information of persistent group
  226. struct tx_invite_resp_info inviteresp_info;
  227. struct tx_nego_req_info nego_req_info;
  228. struct group_id_info groupid_info; // Store the group id information when doing the group negotiation handshake.
  229. struct scan_limit_info rx_invitereq_info; // Used for get the limit scan channel from the Invitation procedure
  230. struct scan_limit_info p2p_info; // Used for get the limit scan channel from the P2P negotiation handshake
  231. #ifdef CONFIG_WFD
  232. struct wifi_display_info *wfd_info;
  233. #endif
  234. enum P2P_ROLE role;
  235. enum P2P_STATE pre_p2p_state;
  236. enum P2P_STATE p2p_state;
  237. u8 device_addr[ETH_ALEN]; // The device address should be the mac address of this device.
  238. u8 interface_addr[ETH_ALEN];
  239. u8 social_chan[4];
  240. u8 listen_channel;
  241. u8 operating_channel;
  242. u8 listen_dwell; // This value should be between 1 and 3
  243. u8 support_rate[8];
  244. u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN];
  245. u8 intent; // should only include the intent value.
  246. u8 p2p_peer_interface_addr[ ETH_ALEN ];
  247. u8 p2p_peer_device_addr[ ETH_ALEN ];
  248. u8 peer_intent; // Included the intent value and tie breaker value.
  249. u8 device_name[ WPS_MAX_DEVICE_NAME_LEN ]; // Device name for displaying on searching device screen
  250. u8 device_name_len;
  251. u8 profileindex; // Used to point to the index of profileinfo array
  252. u8 peer_operating_ch;
  253. u8 find_phase_state_exchange_cnt;
  254. u16 device_password_id_for_nego; // The device password ID for group negotation
  255. u8 negotiation_dialog_token;
  256. u8 nego_ssid[ WLAN_SSID_MAXLEN ]; // SSID information for group negotitation
  257. u8 nego_ssidlen;
  258. u8 p2p_group_ssid[WLAN_SSID_MAXLEN];
  259. u8 p2p_group_ssid_len;
  260. u8 persistent_supported; // Flag to know the persistent function should be supported or not.
  261. // In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI.
  262. // 0: disable
  263. // 1: enable
  264. u8 session_available; // Flag to set the WFD session available to enable or disable "by Sigma"
  265. // In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI.
  266. // 0: disable
  267. // 1: enable
  268. u8 wfd_tdls_enable; // Flag to enable or disable the TDLS by WFD Sigma
  269. // 0: disable
  270. // 1: enable
  271. u8 wfd_tdls_weaksec; // Flag to enable or disable the weak security function for TDLS by WFD Sigma
  272. // 0: disable
  273. // In this case, the driver can't issue the tdsl setup request frame.
  274. // 1: enable
  275. // In this case, the driver can issue the tdls setup request frame
  276. // even the current security is weak security.
  277. 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.
  278. u16 supported_wps_cm; // This field describes the WPS config method which this driver supported.
  279. // The value should be the combination of config method defined in page104 of WPS v2.0 spec.
  280. uint channel_list_attr_len; // This field will contain the length of body of P2P Channel List attribute of group negotitation response frame.
  281. u8 channel_list_attr[100]; // This field will contain the body of P2P Channel List attribute of group negotitation response frame.
  282. // We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame.
  283. u8 driver_interface; // Indicate DRIVER_WEXT or DRIVER_CFG80211
  284. #ifdef CONFIG_CONCURRENT_MODE
  285. u16 ext_listen_interval; // The interval to be available with legacy AP (ms)
  286. u16 ext_listen_period; // The time period to be available for P2P listen state (ms)
  287. #endif
  288. #ifdef CONFIG_P2P_PS
  289. enum P2P_PS_MODE p2p_ps_mode; // indicate p2p ps mode
  290. enum P2P_PS_STATE p2p_ps_state; // indicate p2p ps state
  291. u8 noa_index; // Identifies and instance of Notice of Absence timing.
  292. u8 ctwindow; // Client traffic window. A period of time in TU after TBTT.
  293. u8 opp_ps; // opportunistic power save.
  294. u8 noa_num; // number of NoA descriptor in P2P IE.
  295. u8 noa_count[P2P_MAX_NOA_NUM]; // Count for owner, Type of client.
  296. u32 noa_duration[P2P_MAX_NOA_NUM]; // Max duration for owner, preferred or min acceptable duration for client.
  297. u32 noa_interval[P2P_MAX_NOA_NUM]; // Length of interval for owner, preferred or max acceptable interval of client.
  298. u32 noa_start_time[P2P_MAX_NOA_NUM]; // schedule expressed in terms of the lower 4 bytes of the TSF timer.
  299. #endif // CONFIG_P2P_PS
  300. };
  301. struct tdls_ss_record{ //signal strength record
  302. u8 macaddr[ETH_ALEN];
  303. u8 RxPWDBAll;
  304. u8 is_tdls_sta; // _TRUE: direct link sta, _FALSE: else
  305. };
  306. struct tdls_info{
  307. u8 ap_prohibited;
  308. uint setup_state;
  309. u8 sta_cnt;
  310. u8 sta_maximum; // 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else;
  311. struct tdls_ss_record ss_record;
  312. u8 macid_index; //macid entry that is ready to write
  313. u8 clear_cam; //cam entry that is trying to clear, using it in direct link teardown
  314. u8 ch_sensing;
  315. u8 cur_channel;
  316. u8 candidate_ch;
  317. u8 collect_pkt_num[MAX_CHANNEL_NUM];
  318. _lock cmd_lock;
  319. _lock hdl_lock;
  320. u8 watchdog_count;
  321. u8 dev_discovered; //WFD_TDLS: for sigma test
  322. u8 enable;
  323. #ifdef CONFIG_WFD
  324. struct wifi_display_info *wfd_info;
  325. #endif
  326. };
  327. struct mlme_priv {
  328. _lock lock;
  329. sint fw_state; //shall we protect this variable? maybe not necessarily...
  330. u8 bScanInProcess;
  331. u8 to_join; //flag
  332. #ifdef CONFIG_LAYER2_ROAMING
  333. u8 to_roaming; // roaming trying times
  334. #endif
  335. u8 *nic_hdl;
  336. u8 not_indic_disco;
  337. _list *pscanned;
  338. _queue free_bss_pool;
  339. _queue scanned_queue;
  340. u8 *free_bss_buf;
  341. u32 num_of_scanned;
  342. NDIS_802_11_SSID assoc_ssid;
  343. u8 assoc_bssid[6];
  344. struct wlan_network cur_network;
  345. //uint wireless_mode; no used, remove it
  346. u32 scan_interval;
  347. _timer assoc_timer;
  348. uint assoc_by_bssid;
  349. uint assoc_by_rssi;
  350. _timer scan_to_timer; // driver itself handles scan_timeout status.
  351. u32 scan_start_time; // used to evaluate the time spent in scanning
  352. #ifdef CONFIG_SET_SCAN_DENY_TIMER
  353. _timer set_scan_deny_timer;
  354. ATOMIC_T set_scan_deny; //0: allowed, 1: deny
  355. #endif
  356. struct qos_priv qospriv;
  357. #ifdef CONFIG_80211N_HT
  358. /* Number of non-HT AP/stations */
  359. int num_sta_no_ht;
  360. /* Number of HT AP/stations 20 MHz */
  361. //int num_sta_ht_20mhz;
  362. int num_FortyMHzIntolerant;
  363. struct ht_priv htpriv;
  364. #endif
  365. #ifdef CONFIG_80211AC_VHT
  366. struct vht_priv vhtpriv;
  367. #endif
  368. RT_LINK_DETECT_T LinkDetectInfo;
  369. _timer dynamic_chk_timer; //dynamic/periodic check timer
  370. u8 key_mask; //use for ips to set wep key after ips_leave
  371. u8 acm_mask; // for wmm acm mask
  372. u8 ChannelPlan;
  373. RT_SCAN_TYPE scan_mode; // active: 1, passive: 0
  374. //u8 probereq_wpsie[MAX_WPS_IE_LEN];//added in probe req
  375. //int probereq_wpsie_len;
  376. u8 *wps_probe_req_ie;
  377. u32 wps_probe_req_ie_len;
  378. #if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
  379. /* Number of associated Non-ERP stations (i.e., stations using 802.11b
  380. * in 802.11g BSS) */
  381. int num_sta_non_erp;
  382. /* Number of associated stations that do not support Short Slot Time */
  383. int num_sta_no_short_slot_time;
  384. /* Number of associated stations that do not support Short Preamble */
  385. int num_sta_no_short_preamble;
  386. int olbc; /* Overlapping Legacy BSS Condition */
  387. /* Number of HT associated stations that do not support greenfield */
  388. int num_sta_ht_no_gf;
  389. /* Number of associated non-HT stations */
  390. //int num_sta_no_ht;
  391. /* Number of HT associated stations 20 MHz */
  392. int num_sta_ht_20mhz;
  393. /* Overlapping BSS information */
  394. int olbc_ht;
  395. #ifdef CONFIG_80211N_HT
  396. u16 ht_op_mode;
  397. #endif /* CONFIG_80211N_HT */
  398. u8 *assoc_req;
  399. u32 assoc_req_len;
  400. u8 *assoc_rsp;
  401. u32 assoc_rsp_len;
  402. u8 *wps_beacon_ie;
  403. //u8 *wps_probe_req_ie;
  404. u8 *wps_probe_resp_ie;
  405. u8 *wps_assoc_resp_ie; // for CONFIG_IOCTL_CFG80211, this IE could include p2p ie / wfd ie
  406. u32 wps_beacon_ie_len;
  407. //u32 wps_probe_req_ie_len;
  408. u32 wps_probe_resp_ie_len;
  409. u32 wps_assoc_resp_ie_len; // for CONFIG_IOCTL_CFG80211, this IE len could include p2p ie / wfd ie
  410. u8 *p2p_beacon_ie;
  411. u8 *p2p_probe_req_ie;
  412. u8 *p2p_probe_resp_ie;
  413. u8 *p2p_go_probe_resp_ie; //for GO
  414. u8 *p2p_assoc_req_ie;
  415. u32 p2p_beacon_ie_len;
  416. u32 p2p_probe_req_ie_len;
  417. u32 p2p_probe_resp_ie_len;
  418. u32 p2p_go_probe_resp_ie_len; //for GO
  419. u32 p2p_assoc_req_ie_len;
  420. /*
  421. #if defined(CONFIG_P2P) && defined(CONFIG_IOCTL_CFG80211)
  422. //u8 *wps_p2p_beacon_ie;
  423. u8 *p2p_beacon_ie;
  424. u8 *wps_p2p_probe_resp_ie;
  425. u8 *wps_p2p_assoc_resp_ie;
  426. //u32 wps_p2p_beacon_ie_len;
  427. u32 p2p_beacon_ie_len;
  428. u32 wps_p2p_probe_resp_ie_len;
  429. u32 wps_p2p_assoc_resp_ie_len;
  430. #endif
  431. */
  432. _lock bcn_update_lock;
  433. u8 update_bcn;
  434. #endif //#if defined (CONFIG_AP_MODE) && defined (CONFIG_NATIVEAP_MLME)
  435. #if defined(CONFIG_WFD) && defined(CONFIG_IOCTL_CFG80211)
  436. u8 *wfd_beacon_ie;
  437. u8 *wfd_probe_req_ie;
  438. u8 *wfd_probe_resp_ie;
  439. u8 *wfd_go_probe_resp_ie; //for GO
  440. u8 *wfd_assoc_req_ie;
  441. u32 wfd_beacon_ie_len;
  442. u32 wfd_probe_req_ie_len;
  443. u32 wfd_probe_resp_ie_len;
  444. u32 wfd_go_probe_resp_ie_len; //for GO
  445. u32 wfd_assoc_req_ie_len;
  446. #endif
  447. #ifdef RTK_DMP_PLATFORM
  448. // DMP kobject_hotplug function signal need in passive level
  449. _workitem Linkup_workitem;
  450. _workitem Linkdown_workitem;
  451. #endif
  452. #ifdef CONFIG_INTEL_WIDI
  453. int widi_state;
  454. int listen_state;
  455. _timer listen_timer;
  456. ATOMIC_T rx_probe_rsp; // 1:receive probe respone from RDS source.
  457. u8 *l2sdTaBuffer;
  458. u8 channel_idx;
  459. u8 group_cnt; //In WiDi 3.5, they specified another scan algo. for WFD/RDS co-existed
  460. u8 sa_ext[L2SDTA_SERVICE_VE_LEN];
  461. #endif // CONFIG_INTEL_WIDI
  462. #ifdef CONFIG_CONCURRENT_MODE
  463. u8 scanning_via_buddy_intf;
  464. #endif
  465. #ifdef CONFIG_FTP_PROTECT
  466. u8 ftp_lock_flag;
  467. #endif //CONFIG_FTP_PROTECT
  468. };
  469. #ifdef CONFIG_AP_MODE
  470. struct hostapd_priv
  471. {
  472. _adapter *padapter;
  473. #ifdef CONFIG_HOSTAPD_MLME
  474. struct net_device *pmgnt_netdev;
  475. struct usb_anchor anchored;
  476. #endif
  477. };
  478. extern int hostapd_mode_init(_adapter *padapter);
  479. extern void hostapd_mode_unload(_adapter *padapter);
  480. #endif
  481. extern void rtw_joinbss_event_prehandle(_adapter *adapter, u8 *pbuf);
  482. extern void rtw_survey_event_callback(_adapter *adapter, u8 *pbuf);
  483. extern void rtw_surveydone_event_callback(_adapter *adapter, u8 *pbuf);
  484. extern void rtw_joinbss_event_callback(_adapter *adapter, u8 *pbuf);
  485. extern void rtw_stassoc_event_callback(_adapter *adapter, u8 *pbuf);
  486. extern void rtw_stadel_event_callback(_adapter *adapter, u8 *pbuf);
  487. extern void rtw_atimdone_event_callback(_adapter *adapter, u8 *pbuf);
  488. extern void rtw_cpwm_event_callback(_adapter *adapter, u8 *pbuf);
  489. extern void rtw_join_timeout_handler(RTW_TIMER_HDL_ARGS);
  490. extern void _rtw_scan_timeout_handler(RTW_TIMER_HDL_ARGS);
  491. thread_return event_thread(thread_context context);
  492. extern void rtw_free_network_queue(_adapter *adapter,u8 isfreeall);
  493. extern int rtw_init_mlme_priv(_adapter *adapter);// (struct mlme_priv *pmlmepriv);
  494. extern void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv);
  495. extern sint rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
  496. extern sint rtw_set_key(_adapter *adapter,struct security_priv *psecuritypriv,sint keyid, u8 set_tx);
  497. extern sint rtw_set_auth(_adapter *adapter,struct security_priv *psecuritypriv);
  498. __inline static u8 *get_bssid(struct mlme_priv *pmlmepriv)
  499. { //if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid
  500. // if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address
  501. return pmlmepriv->cur_network.network.MacAddress;
  502. }
  503. __inline static sint check_fwstate(struct mlme_priv *pmlmepriv, sint state)
  504. {
  505. if (pmlmepriv->fw_state & state)
  506. return _TRUE;
  507. return _FALSE;
  508. }
  509. __inline static sint get_fwstate(struct mlme_priv *pmlmepriv)
  510. {
  511. return pmlmepriv->fw_state;
  512. }
  513. /*
  514. * No Limit on the calling context,
  515. * therefore set it to be the critical section...
  516. *
  517. * ### NOTE:#### (!!!!)
  518. * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
  519. */
  520. __inline static void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
  521. {
  522. pmlmepriv->fw_state |= state;
  523. //FOR HW integration
  524. if(_FW_UNDER_SURVEY==state){
  525. pmlmepriv->bScanInProcess = _TRUE;
  526. }
  527. }
  528. __inline static void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
  529. {
  530. pmlmepriv->fw_state &= ~state;
  531. //FOR HW integration
  532. if(_FW_UNDER_SURVEY==state){
  533. pmlmepriv->bScanInProcess = _FALSE;
  534. }
  535. }
  536. /*
  537. * No Limit on the calling context,
  538. * therefore set it to be the critical section...
  539. */
  540. __inline static void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
  541. {
  542. _irqL irqL;
  543. _enter_critical_bh(&pmlmepriv->lock, &irqL);
  544. if (check_fwstate(pmlmepriv, state) == _TRUE)
  545. pmlmepriv->fw_state ^= state;
  546. _exit_critical_bh(&pmlmepriv->lock, &irqL);
  547. }
  548. __inline static void clr_fwstate_ex(struct mlme_priv *pmlmepriv, sint state)
  549. {
  550. _irqL irqL;
  551. _enter_critical_bh(&pmlmepriv->lock, &irqL);
  552. _clr_fwstate_(pmlmepriv, state);
  553. _exit_critical_bh(&pmlmepriv->lock, &irqL);
  554. }
  555. __inline static void up_scanned_network(struct mlme_priv *pmlmepriv)
  556. {
  557. _irqL irqL;
  558. _enter_critical_bh(&pmlmepriv->lock, &irqL);
  559. pmlmepriv->num_of_scanned++;
  560. _exit_critical_bh(&pmlmepriv->lock, &irqL);
  561. }
  562. #ifdef CONFIG_CONCURRENT_MODE
  563. sint rtw_buddy_adapter_up(_adapter *padapter);
  564. sint check_buddy_fwstate(_adapter *padapter, sint state);
  565. #endif //CONFIG_CONCURRENT_MODE
  566. __inline static void down_scanned_network(struct mlme_priv *pmlmepriv)
  567. {
  568. _irqL irqL;
  569. _enter_critical_bh(&pmlmepriv->lock, &irqL);
  570. pmlmepriv->num_of_scanned--;
  571. _exit_critical_bh(&pmlmepriv->lock, &irqL);
  572. }
  573. __inline static void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val)
  574. {
  575. _irqL irqL;
  576. _enter_critical_bh(&pmlmepriv->lock, &irqL);
  577. pmlmepriv->num_of_scanned = val;
  578. _exit_critical_bh(&pmlmepriv->lock, &irqL);
  579. }
  580. extern u16 rtw_get_capability(WLAN_BSSID_EX *bss);
  581. extern void rtw_update_scanned_network(_adapter *adapter, WLAN_BSSID_EX *target);
  582. extern void rtw_disconnect_hdl_under_linked(_adapter* adapter, struct sta_info *psta, u8 free_assoc);
  583. extern void rtw_generate_random_ibss(u8 *pibss);
  584. extern struct wlan_network* rtw_find_network(_queue *scanned_queue, u8 *addr);
  585. extern struct wlan_network* rtw_get_oldest_wlan_network(_queue *scanned_queue);
  586. extern void rtw_free_assoc_resources(_adapter* adapter, int lock_scanned_queue);
  587. extern void rtw_indicate_disconnect(_adapter* adapter);
  588. extern void rtw_indicate_connect(_adapter* adapter);
  589. void rtw_indicate_scan_done( _adapter *padapter, bool aborted);
  590. void rtw_scan_abort(_adapter *adapter);
  591. extern int rtw_restruct_sec_ie(_adapter *adapter,u8 *in_ie,u8 *out_ie,uint in_len);
  592. extern int rtw_restruct_wmm_ie(_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len);
  593. extern void rtw_init_registrypriv_dev_network(_adapter *adapter);
  594. extern void rtw_update_registrypriv_dev_network(_adapter *adapter);
  595. extern void rtw_get_encrypt_decrypt_from_registrypriv(_adapter *adapter);
  596. extern void _rtw_join_timeout_handler(_adapter *adapter);
  597. extern void rtw_scan_timeout_handler(_adapter *adapter);
  598. extern void rtw_dynamic_check_timer_handlder(_adapter *adapter);
  599. #ifdef CONFIG_SET_SCAN_DENY_TIMER
  600. bool rtw_is_scan_deny(_adapter *adapter);
  601. void rtw_clear_scan_deny(_adapter *adapter);
  602. void rtw_set_scan_deny_timer_hdl(_adapter *adapter);
  603. void rtw_set_scan_deny(_adapter *adapter, u32 ms);
  604. #else
  605. #define rtw_is_scan_deny(adapter) _FALSE
  606. #define rtw_clear_scan_deny(adapter) do {} while (0)
  607. #define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
  608. #define rtw_set_scan_deny(adapter, ms) do {} while (0)
  609. #endif
  610. extern int _rtw_init_mlme_priv(_adapter *padapter);
  611. void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
  612. extern void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
  613. extern int _rtw_enqueue_network(_queue *queue, struct wlan_network *pnetwork);
  614. //extern struct wlan_network* _rtw_dequeue_network(_queue *queue);
  615. extern struct wlan_network* _rtw_alloc_network(struct mlme_priv *pmlmepriv);
  616. extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall);
  617. extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork);
  618. extern struct wlan_network* _rtw_find_network(_queue *scanned_queue, u8 *addr);
  619. extern void _rtw_free_network_queue(_adapter* padapter, u8 isfreeall);
  620. extern sint rtw_if_up(_adapter *padapter);
  621. sint rtw_linked_check(_adapter *padapter);
  622. u8 *rtw_get_capability_from_ie(u8 *ie);
  623. u8 *rtw_get_timestampe_from_ie(u8 *ie);
  624. u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
  625. void rtw_joinbss_reset(_adapter *padapter);
  626. #ifdef CONFIG_80211N_HT
  627. unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len);
  628. void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel);
  629. void rtw_issue_addbareq_cmd(_adapter *padapter, struct xmit_frame *pxmitframe);
  630. #endif
  631. int rtw_is_same_ibss(_adapter *adapter, struct wlan_network *pnetwork);
  632. int is_same_network(WLAN_BSSID_EX *src, WLAN_BSSID_EX *dst);
  633. #ifdef CONFIG_LAYER2_ROAMING
  634. void _rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
  635. void rtw_roaming(_adapter *adapter, struct wlan_network *tgt_network);
  636. void rtw_set_roaming(_adapter *adapter, u8 to_roaming);
  637. u8 rtw_to_roaming(_adapter *adapter);
  638. #else
  639. #define _rtw_roaming(adapter, tgt_network) do {} while(0)
  640. #define rtw_roaming(adapter, tgt_network) do {} while(0)
  641. #define rtw_set_roaming(adapter, to_roaming) do {} while(0)
  642. #define rtw_to_roaming(adapter) 0
  643. #endif
  644. void rtw_stassoc_hw_rpt(_adapter *adapter,struct sta_info *psta);
  645. #ifdef CONFIG_INTEL_PROXIM
  646. void rtw_proxim_enable(_adapter *padapter);
  647. void rtw_proxim_disable(_adapter *padapter);
  648. void rtw_proxim_send_packet(_adapter *padapter,u8 *pbuf,u16 len,u8 hw_rate);
  649. #endif //CONFIG_INTEL_PROXIM
  650. #endif //__RTL871X_MLME_H_