root/drivers/staging/rtl8188eu/include/rtw_mlme.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. get_bssid
  2. check_fwstate
  3. get_fwstate
  4. set_fwstate
  5. _clr_fwstate_
  6. clr_fwstate
  7. clr_fwstate_ex

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 /******************************************************************************
   3  *
   4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   5  *
   6  ******************************************************************************/
   7 #ifndef __RTW_MLME_H_
   8 #define __RTW_MLME_H_
   9 
  10 #include <osdep_service.h>
  11 #include <mlme_osdep.h>
  12 #include <drv_types.h>
  13 #include <wlan_bssdef.h>
  14 
  15 #define MAX_BSS_CNT     128
  16 #define   MAX_JOIN_TIMEOUT      6500
  17 
  18 /* Increase the scanning timeout because of increasing the SURVEY_TO value. */
  19 
  20 #define         SCANNING_TIMEOUT        8000
  21 
  22 #define SCAN_INTERVAL   (30) /*  unit:2sec, 30*2=60sec */
  23 
  24 #define SCANQUEUE_LIFETIME 20 /*  unit:sec */
  25 
  26 #define WIFI_NULL_STATE                 0x00000000
  27 
  28 #define WIFI_ASOC_STATE                 0x00000001      /* Under Linked state */
  29 #define WIFI_REASOC_STATE               0x00000002
  30 #define WIFI_SLEEP_STATE                0x00000004
  31 #define WIFI_STATION_STATE              0x00000008
  32 
  33 #define WIFI_AP_STATE                   0x00000010
  34 #define WIFI_ADHOC_STATE                0x00000020
  35 #define WIFI_ADHOC_MASTER_STATE         0x00000040
  36 #define WIFI_UNDER_LINKING              0x00000080
  37 
  38 #define WIFI_UNDER_WPS                  0x00000100
  39 #define WIFI_STA_ALIVE_CHK_STATE        0x00000400
  40 #define WIFI_SITE_MONITOR               0x00000800      /* to indicate the station is under site surveying */
  41 
  42 #define _FW_UNDER_LINKING       WIFI_UNDER_LINKING
  43 #define _FW_LINKED                      WIFI_ASOC_STATE
  44 #define _FW_UNDER_SURVEY        WIFI_SITE_MONITOR
  45 
  46 enum dot11AuthAlgrthmNum {
  47         dot11AuthAlgrthm_Open = 0, /* open system */
  48         dot11AuthAlgrthm_Shared,
  49         dot11AuthAlgrthm_8021X,
  50         dot11AuthAlgrthm_Auto,
  51         dot11AuthAlgrthm_WAPI,
  52         dot11AuthAlgrthm_MaxNum
  53 };
  54 
  55 /*  Scan type including active and passive scan. */
  56 enum rt_scan_type {
  57         SCAN_PASSIVE,
  58         SCAN_ACTIVE,
  59         SCAN_MIX,
  60 };
  61 
  62 enum SCAN_RESULT_TYPE {
  63         SCAN_RESULT_P2P_ONLY = 0,       /* Will return all the P2P devices. */
  64         SCAN_RESULT_ALL = 1,            /* Will return all the scanned device,
  65                                          * include AP.
  66                                          */
  67         SCAN_RESULT_WFD_TYPE = 2        /* Will just return the correct WFD
  68                                          * device.
  69                                          */
  70                                         /* If this device is Miracast sink
  71                                          * device, it will just return all the
  72                                          * Miracast source devices.
  73                                          */
  74 };
  75 
  76 /*
  77  * there are several "locks" in mlme_priv,
  78  * since mlme_priv is a shared resource between many threads,
  79  * like ISR/Call-Back functions, the OID handlers, and even timer functions.
  80  *
  81  * Each _queue has its own locks, already.
  82  * Other items are protected by mlme_priv.lock.
  83  *
  84  * To avoid possible dead lock, any thread trying to modifiying mlme_priv
  85  * SHALL not lock up more than one lock at a time!
  86  */
  87 
  88 #define traffic_threshold       10
  89 #define traffic_scan_period     500
  90 
  91 struct rt_link_detect {
  92         u32     NumTxOkInPeriod;
  93         u32     NumRxOkInPeriod;
  94         u32     NumRxUnicastOkInPeriod;
  95         bool    bBusyTraffic;
  96         bool    bTxBusyTraffic;
  97         bool    bRxBusyTraffic;
  98         bool    bHigherBusyTraffic; /*  For interrupt migration purpose. */
  99         bool    bHigherBusyRxTraffic; /* We may disable Tx interrupt according
 100                                        * to Rx traffic.
 101                                        */
 102         bool    bHigherBusyTxTraffic; /* We may disable Tx interrupt according
 103                                        * to Tx traffic.
 104                                        */
 105 };
 106 
 107 struct mlme_priv {
 108         spinlock_t lock;
 109         int fw_state;   /* shall we protect this variable? maybe not necessarily... */
 110         u8 bScanInProcess;
 111         u8 to_join; /* flag */
 112         u8 to_roaming; /*  roaming trying times */
 113 
 114         u8 *nic_hdl;
 115 
 116         struct list_head *pscanned;
 117         struct __queue free_bss_pool;
 118         struct __queue scanned_queue;
 119         u8 *free_bss_buf;
 120 
 121         struct ndis_802_11_ssid assoc_ssid;
 122         u8      assoc_bssid[6];
 123 
 124         struct wlan_network     cur_network;
 125 
 126         u32     scan_interval;
 127 
 128         struct timer_list assoc_timer;
 129 
 130         uint assoc_by_bssid;
 131 
 132         struct timer_list scan_to_timer; /*  driver itself handles scan_timeout status. */
 133 
 134         struct qos_priv qospriv;
 135 
 136         /* Number of non-HT AP/stations */
 137         int num_sta_no_ht;
 138 
 139         /* Number of HT AP/stations 20 MHz */
 140         /* int num_sta_ht_20mhz; */
 141 
 142         int num_FortyMHzIntolerant;
 143         struct ht_priv  htpriv;
 144         struct rt_link_detect LinkDetectInfo;
 145         struct timer_list dynamic_chk_timer; /* dynamic/periodic check timer */
 146 
 147         u8      key_mask; /* use for ips to set wep key after ips_leave */
 148         u8      acm_mask; /*  for wmm acm mask */
 149         u8      ChannelPlan;
 150         enum rt_scan_type scan_mode; /*  active: 1, passive: 0 */
 151 
 152         /* u8 probereq_wpsie[MAX_WPS_IE_LEN];added in probe req */
 153         /* int probereq_wpsie_len; */
 154         u8 *wps_probe_req_ie;
 155         u32 wps_probe_req_ie_len;
 156 
 157         u8 *assoc_req;
 158         u32 assoc_req_len;
 159         u8 *assoc_rsp;
 160         u32 assoc_rsp_len;
 161 
 162 #if defined(CONFIG_88EU_AP_MODE)
 163         /* Number of associated Non-ERP stations (i.e., stations using 802.11b
 164          * in 802.11g BSS)
 165          */
 166         int num_sta_non_erp;
 167 
 168         /* Number of associated stations that do not support Short Slot Time */
 169         int num_sta_no_short_slot_time;
 170 
 171         /* Number of associated stations that do not support Short Preamble */
 172         int num_sta_no_short_preamble;
 173 
 174         int olbc; /* Overlapping Legacy BSS Condition */
 175 
 176         /* Number of HT assoc sta that do not support greenfield */
 177         int num_sta_ht_no_gf;
 178 
 179         /* Number of associated non-HT stations */
 180         /* int num_sta_no_ht; */
 181 
 182         /* Number of HT associated stations 20 MHz */
 183         int num_sta_ht_20mhz;
 184 
 185         /* Overlapping BSS information */
 186         int olbc_ht;
 187 
 188         u16 ht_op_mode;
 189 
 190         u8 *wps_beacon_ie;
 191         /* u8 *wps_probe_req_ie; */
 192         u8 *wps_probe_resp_ie;
 193         u8 *wps_assoc_resp_ie;
 194 
 195         u32 wps_beacon_ie_len;
 196         u32 wps_probe_resp_ie_len;
 197         u32 wps_assoc_resp_ie_len;
 198 
 199         spinlock_t bcn_update_lock;
 200         u8              update_bcn;
 201 #endif /* if defined (CONFIG_88EU_AP_MODE) */
 202 };
 203 
 204 #ifdef CONFIG_88EU_AP_MODE
 205 
 206 struct hostapd_priv {
 207         struct adapter *padapter;
 208 };
 209 
 210 int hostapd_mode_init(struct adapter *padapter);
 211 void hostapd_mode_unload(struct adapter *padapter);
 212 #endif
 213 
 214 extern const u8 WPA_TKIP_CIPHER[4];
 215 extern const u8 RSN_TKIP_CIPHER[4];
 216 extern u8 REALTEK_96B_IE[];
 217 extern const u8 MCS_rate_1R[16];
 218 
 219 void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf);
 220 void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf);
 221 void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
 222 void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
 223 void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
 224 void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
 225 void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf);
 226 void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf);
 227 void indicate_wx_scan_complete_event(struct adapter *padapter);
 228 void rtw_indicate_wx_assoc_event(struct adapter *padapter);
 229 void rtw_indicate_wx_disassoc_event(struct adapter *padapter);
 230 int event_thread(void *context);
 231 void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall);
 232 int rtw_init_mlme_priv(struct adapter *adapter);
 233 void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv);
 234 int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv);
 235 int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv,
 236                 int keyid, u8 set_tx);
 237 int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv);
 238 
 239 static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
 240 {       /* if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid */
 241         /*  if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address */
 242         return pmlmepriv->cur_network.network.MacAddress;
 243 }
 244 
 245 static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state)
 246 {
 247         if (pmlmepriv->fw_state & state)
 248                 return true;
 249 
 250         return false;
 251 }
 252 
 253 static inline int get_fwstate(struct mlme_priv *pmlmepriv)
 254 {
 255         return pmlmepriv->fw_state;
 256 }
 257 
 258 /*
 259  * No Limit on the calling context,
 260  * therefore set it to be the critical section...
 261  *
 262  * ### NOTE:#### (!!!!)
 263  * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
 264  */
 265 static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state)
 266 {
 267         pmlmepriv->fw_state |= state;
 268         /* FOR HW integration */
 269         if (_FW_UNDER_SURVEY == state)
 270                 pmlmepriv->bScanInProcess = true;
 271 }
 272 
 273 static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state)
 274 {
 275         pmlmepriv->fw_state &= ~state;
 276         /* FOR HW integration */
 277         if (_FW_UNDER_SURVEY == state)
 278                 pmlmepriv->bScanInProcess = false;
 279 }
 280 
 281 /*
 282  * No Limit on the calling context,
 283  * therefore set it to be the critical section...
 284  */
 285 static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state)
 286 {
 287         spin_lock_bh(&pmlmepriv->lock);
 288         if (check_fwstate(pmlmepriv, state))
 289                 pmlmepriv->fw_state ^= state;
 290         spin_unlock_bh(&pmlmepriv->lock);
 291 }
 292 
 293 static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state)
 294 {
 295         spin_lock_bh(&pmlmepriv->lock);
 296         _clr_fwstate_(pmlmepriv, state);
 297         spin_unlock_bh(&pmlmepriv->lock);
 298 }
 299 
 300 u16 rtw_get_capability(struct wlan_bssid_ex *bss);
 301 void rtw_update_scanned_network(struct adapter *adapter,
 302                                 struct wlan_bssid_ex *target);
 303 void rtw_disconnect_hdl_under_linked(struct adapter *adapter,
 304                                      struct sta_info *psta, u8 free_assoc);
 305 void rtw_generate_random_ibss(u8 *pibss);
 306 struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr);
 307 struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue);
 308 
 309 void rtw_free_assoc_resources(struct adapter *adapter);
 310 void rtw_free_assoc_resources_locked(struct adapter *adapter);
 311 void rtw_indicate_disconnect(struct adapter *adapter);
 312 void rtw_indicate_connect(struct adapter *adapter);
 313 void rtw_indicate_scan_done(struct adapter *padapter, bool aborted);
 314 
 315 int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
 316                         uint in_len);
 317 int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie,
 318                         uint in_len, uint initial_out_len);
 319 void rtw_init_registrypriv_dev_network(struct adapter *adapter);
 320 
 321 void rtw_update_registrypriv_dev_network(struct adapter *adapter);
 322 
 323 void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
 324 
 325 void _rtw_join_timeout_handler(struct timer_list *t);
 326 void rtw_scan_timeout_handler(struct timer_list *t);
 327 
 328 void rtw_dynamic_check_timer_handlder(struct timer_list *t);
 329 #define rtw_is_scan_deny(adapter) false
 330 #define rtw_clear_scan_deny(adapter) do {} while (0)
 331 #define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
 332 #define rtw_set_scan_deny(adapter, ms) do {} while (0)
 333 
 334 void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv);
 335 
 336 struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv);
 337 
 338 int rtw_if_up(struct adapter *padapter);
 339 
 340 u8 *rtw_get_capability_from_ie(u8 *ie);
 341 u8 *rtw_get_beacon_interval_from_ie(u8 *ie);
 342 
 343 void rtw_joinbss_reset(struct adapter *padapter);
 344 
 345 unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie,
 346                                    u8 *out_ie, uint in_len, uint *pout_len);
 347 void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len);
 348 void rtw_issue_addbareq_cmd(struct adapter *padapter,
 349                             struct xmit_frame *pxmitframe);
 350 
 351 int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork);
 352 int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst);
 353 
 354 void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
 355 void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network);
 356 
 357 void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta);
 358 
 359 #endif /* __RTL871X_MLME_H_ */

/* [<][>][^][v][top][bottom][index][help] */