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