linux/drivers/staging/rtl8188eu/include/rtw_mlme_ext.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 * 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_EXT_H_
  21#define __RTW_MLME_EXT_H_
  22
  23#include <osdep_service.h>
  24#include <drv_types.h>
  25#include <wlan_bssdef.h>
  26
  27
  28/*      Commented by Albert 20101105 */
  29/*      Increase the SURVEY_TO value from 100 to 150  ( 100ms to 150ms ) */
  30/*      The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */
  31/*      So, this driver tried to extend the dwell time for each scanning channel. */
  32/*      This will increase the chance to receive the probe response from SoftAP. */
  33
  34#define SURVEY_TO               (100)
  35#define REAUTH_TO               (300) /* 50) */
  36#define REASSOC_TO              (300) /* 50) */
  37/* define DISCONNECT_TO (3000) */
  38#define ADDBA_TO                        (2000)
  39
  40#define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */
  41
  42#define REAUTH_LIMIT    (4)
  43#define REASSOC_LIMIT   (4)
  44#define READDBA_LIMIT   (2)
  45
  46#define ROAMING_LIMIT   8
  47
  48#define DYNAMIC_FUNC_DISABLE                    (0x0)
  49
  50/*  ====== ODM_ABILITY_E ======== */
  51/*  BB ODM section BIT 0-15 */
  52#define DYNAMIC_BB_DIG                          BIT(0)
  53#define DYNAMIC_BB_RA_MASK                      BIT(1)
  54#define DYNAMIC_BB_DYNAMIC_TXPWR        BIT(2)
  55#define DYNAMIC_BB_BB_FA_CNT                    BIT(3)
  56
  57#define         DYNAMIC_BB_RSSI_MONITOR         BIT(4)
  58#define         DYNAMIC_BB_CCK_PD                       BIT(5)
  59#define         DYNAMIC_BB_ANT_DIV                      BIT(6)
  60#define         DYNAMIC_BB_PWR_SAVE                     BIT(7)
  61#define         DYNAMIC_BB_PWR_TRA                      BIT(8)
  62#define         DYNAMIC_BB_RATE_ADAPTIVE                BIT(9)
  63#define         DYNAMIC_BB_PATH_DIV                     BIT(10)
  64#define         DYNAMIC_BB_PSD                          BIT(11)
  65
  66/*  MAC DM section BIT 16-23 */
  67#define         DYNAMIC_MAC_EDCA_TURBO          BIT(16)
  68#define         DYNAMIC_MAC_EARLY_MODE          BIT(17)
  69
  70/*  RF ODM section BIT 24-31 */
  71#define         DYNAMIC_RF_TX_PWR_TRACK         BIT(24)
  72#define         DYNAMIC_RF_RX_GAIN_TRACK                BIT(25)
  73#define         DYNAMIC_RF_CALIBRATION          BIT(26)
  74
  75#define         DYNAMIC_ALL_FUNC_ENABLE         0xFFFFFFF
  76
  77#define _HW_STATE_NOLINK_               0x00
  78#define _HW_STATE_ADHOC_                0x01
  79#define _HW_STATE_STATION_      0x02
  80#define _HW_STATE_AP_                   0x03
  81
  82
  83#define         _1M_RATE_       0
  84#define         _2M_RATE_       1
  85#define         _5M_RATE_       2
  86#define         _11M_RATE_      3
  87#define         _6M_RATE_       4
  88#define         _9M_RATE_       5
  89#define         _12M_RATE_      6
  90#define         _18M_RATE_      7
  91#define         _24M_RATE_      8
  92#define         _36M_RATE_      9
  93#define         _48M_RATE_      10
  94#define         _54M_RATE_      11
  95
  96
  97extern unsigned char RTW_WPA_OUI[];
  98extern unsigned char WMM_OUI[];
  99extern unsigned char WPS_OUI[];
 100extern unsigned char WFD_OUI[];
 101extern unsigned char P2P_OUI[];
 102
 103extern unsigned char WMM_INFO_OUI[];
 104extern unsigned char WMM_PARA_OUI[];
 105
 106/*  Channel Plan Type. */
 107/*  Note: */
 108/*      We just add new channel plan when the new channel plan is different
 109 *      from any of the following channel plan. */
 110/*      If you just want to customize the actions(scan period or join actions)
 111 *      about one of the channel plan, */
 112/*      customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */
 113enum RT_CHANNEL_DOMAIN {
 114        /*  old channel plan mapping =====  */
 115        RT_CHANNEL_DOMAIN_FCC = 0x00,
 116        RT_CHANNEL_DOMAIN_IC = 0x01,
 117        RT_CHANNEL_DOMAIN_ETSI = 0x02,
 118        RT_CHANNEL_DOMAIN_SPAIN = 0x03,
 119        RT_CHANNEL_DOMAIN_FRANCE = 0x04,
 120        RT_CHANNEL_DOMAIN_MKK = 0x05,
 121        RT_CHANNEL_DOMAIN_MKK1 = 0x06,
 122        RT_CHANNEL_DOMAIN_ISRAEL = 0x07,
 123        RT_CHANNEL_DOMAIN_TELEC = 0x08,
 124        RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09,
 125        RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A,
 126        RT_CHANNEL_DOMAIN_TAIWAN = 0x0B,
 127        RT_CHANNEL_DOMAIN_CHINA = 0x0C,
 128        RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D,
 129        RT_CHANNEL_DOMAIN_KOREA = 0x0E,
 130        RT_CHANNEL_DOMAIN_TURKEY = 0x0F,
 131        RT_CHANNEL_DOMAIN_JAPAN = 0x10,
 132        RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11,
 133        RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12,
 134        RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13,
 135        RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14,
 136
 137        /*  new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */
 138        RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20,
 139        RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21,
 140        RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22,
 141        RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23,
 142        RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24,
 143        RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25,
 144        RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26,
 145        RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27,
 146        RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28,
 147        RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29,
 148        RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30,
 149        RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31,
 150        RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32,
 151        RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33,
 152        RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34,
 153        RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35,
 154        RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36,
 155        RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37,
 156        RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38,
 157        RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39,
 158        RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40,
 159        RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41,
 160        /*  Add new channel plan above this line=============== */
 161        RT_CHANNEL_DOMAIN_MAX,
 162        RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
 163};
 164
 165enum RT_CHANNEL_DOMAIN_2G {
 166        RT_CHANNEL_DOMAIN_2G_WORLD = 0x00,              /* Worldwide 13 */
 167        RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01,              /* Europe */
 168        RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02,               /* US */
 169        RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03,               /* Japan */
 170        RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04,              /* France */
 171        RT_CHANNEL_DOMAIN_2G_NULL = 0x05,
 172        /*  Add new channel plan above this line=============== */
 173        RT_CHANNEL_DOMAIN_2G_MAX,
 174};
 175
 176#define rtw_is_channel_plan_valid(chplan)                       \
 177        (chplan < RT_CHANNEL_DOMAIN_MAX ||                      \
 178         chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
 179
 180struct rt_channel_plan {
 181        unsigned char   Channel[MAX_CHANNEL_NUM];
 182        unsigned char   Len;
 183};
 184
 185struct rt_channel_plan_2g {
 186        unsigned char   Channel[MAX_CHANNEL_NUM_2G];
 187        unsigned char   Len;
 188};
 189
 190struct rt_channel_plan_map {
 191        unsigned char   Index2G;
 192};
 193
 194static const struct {
 195        int channel_plan;
 196        char *name;
 197} channel_table[] = { { RT_CHANNEL_DOMAIN_FCC, "US" },
 198        { RT_CHANNEL_DOMAIN_ETSI, "EU" },
 199        { RT_CHANNEL_DOMAIN_MKK, "JP" },
 200        { RT_CHANNEL_DOMAIN_CHINA, "CN"} };
 201
 202enum Associated_AP {
 203        atherosAP       = 0,
 204        broadcomAP      = 1,
 205        ciscoAP         = 2,
 206        marvellAP       = 3,
 207        ralinkAP        = 4,
 208        realtekAP       = 5,
 209        airgocapAP      = 6,
 210        unknownAP       = 7,
 211        maxAP,
 212};
 213
 214enum HT_IOT_PEER {
 215        HT_IOT_PEER_UNKNOWN             = 0,
 216        HT_IOT_PEER_REALTEK             = 1,
 217        HT_IOT_PEER_REALTEK_92SE        = 2,
 218        HT_IOT_PEER_BROADCOM            = 3,
 219        HT_IOT_PEER_RALINK              = 4,
 220        HT_IOT_PEER_ATHEROS             = 5,
 221        HT_IOT_PEER_CISCO               = 6,
 222        HT_IOT_PEER_MERU                = 7,
 223        HT_IOT_PEER_MARVELL             = 8,
 224        HT_IOT_PEER_REALTEK_SOFTAP      = 9,/*  peer is RealTek SOFT_AP */
 225        HT_IOT_PEER_SELF_SOFTAP         = 10, /*  Self is SoftAP */
 226        HT_IOT_PEER_AIRGO               = 11,
 227        HT_IOT_PEER_INTEL               = 12,
 228        HT_IOT_PEER_RTK_APCLIENT        = 13,
 229        HT_IOT_PEER_REALTEK_81XX        = 14,
 230        HT_IOT_PEER_REALTEK_WOW         = 15,
 231        HT_IOT_PEER_TENDA               = 16,
 232        HT_IOT_PEER_MAX                 = 17
 233};
 234
 235enum SCAN_STATE {
 236        SCAN_DISABLE = 0,
 237        SCAN_START = 1,
 238        SCAN_TXNULL = 2,
 239        SCAN_PROCESS = 3,
 240        SCAN_COMPLETE = 4,
 241        SCAN_STATE_MAX,
 242};
 243
 244struct mlme_handler {
 245        unsigned int   num;
 246        char *str;
 247        unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame);
 248};
 249
 250struct action_handler {
 251        unsigned int   num;
 252        char *str;
 253        unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame);
 254};
 255
 256struct  ss_res {
 257        int     state;
 258        int     bss_cnt;
 259        int     channel_idx;
 260        int     scan_mode;
 261        u8 ssid_num;
 262        u8 ch_num;
 263        struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
 264        struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
 265};
 266
 267/* define AP_MODE                               0x0C */
 268/* define STATION_MODE  0x08 */
 269/* define AD_HOC_MODE           0x04 */
 270/* define NO_LINK_MODE  0x00 */
 271
 272#define WIFI_FW_NULL_STATE              _HW_STATE_NOLINK_
 273#define WIFI_FW_STATION_STATE           _HW_STATE_STATION_
 274#define WIFI_FW_AP_STATE                _HW_STATE_AP_
 275#define WIFI_FW_ADHOC_STATE             _HW_STATE_ADHOC_
 276
 277#define WIFI_FW_AUTH_NULL               0x00000100
 278#define WIFI_FW_AUTH_STATE              0x00000200
 279#define WIFI_FW_AUTH_SUCCESS            0x00000400
 280
 281#define WIFI_FW_ASSOC_STATE             0x00002000
 282#define WIFI_FW_ASSOC_SUCCESS           0x00004000
 283
 284#define WIFI_FW_LINKING_STATE           (WIFI_FW_AUTH_NULL |            \
 285                                        WIFI_FW_AUTH_STATE |            \
 286                                        WIFI_FW_AUTH_SUCCESS |          \
 287                                        WIFI_FW_ASSOC_STATE)
 288
 289struct FW_Sta_Info {
 290        struct sta_info *psta;
 291        u32     status;
 292        u32     rx_pkt;
 293        u32     retry;
 294        unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
 295};
 296
 297/*
 298 * Usage:
 299 * When one iface acted as AP mode and the other iface is STA mode and scanning,
 300 * it should switch back to AP's operating channel periodically.
 301 * Parameters info:
 302 * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to
 303 * AP's operating channel for
 304 * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
 305 * Example:
 306 * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1,
 307 * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MS is 3 and SURVEY_TO is 100.
 308 * When it's STA mode gets set_scan command,
 309 * it would
 310 * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
 311 * 2. Back to channel 1 for 300 milliseconds
 312 * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52
 313 * 4. Back to channel 1 for 300 milliseconds
 314 * 5. ... and so on, till survey done.
 315 */
 316
 317struct mlme_ext_info {
 318        u32     state;
 319        u32     reauth_count;
 320        u32     reassoc_count;
 321        u32     link_count;
 322        u32     auth_seq;
 323        u32     auth_algo;      /*  802.11 auth, could be open, shared, auto */
 324        u32     authModeToggle;
 325        u32     enc_algo;/* encrypt algorithm; */
 326        u32     key_index;      /*  this is only valid for legacy wep,
 327                                 *  0~3 for key id. */
 328        u32     iv;
 329        u8      chg_txt[128];
 330        u16     aid;
 331        u16     bcn_interval;
 332        u16     capability;
 333        u8      assoc_AP_vendor;
 334        u8      slotTime;
 335        u8      preamble_mode;
 336        u8      WMM_enable;
 337        u8      ERP_enable;
 338        u8      ERP_IE;
 339        u8      HT_enable;
 340        u8      HT_caps_enable;
 341        u8      HT_info_enable;
 342        u8      HT_protection;
 343        u8      turboMode_cts2self;
 344        u8      turboMode_rtsen;
 345        u8      SM_PS;
 346        u8      agg_enable_bitmap;
 347        u8      ADDBA_retry_count;
 348        u8      candidate_tid_bitmap;
 349        u8      dialogToken;
 350        /*  Accept ADDBA Request */
 351        bool accept_addba_req;
 352        u8      bwmode_updated;
 353        u8      hidden_ssid_mode;
 354
 355        struct ADDBA_request    ADDBA_req;
 356        struct WMM_para_element WMM_param;
 357        struct HT_caps_element  HT_caps;
 358        struct HT_info_element  HT_info;
 359        struct wlan_bssid_ex    network;/* join network or bss_network,
 360                                         * if in ap mode, it is the same
 361                                         * as cur_network.network */
 362        struct FW_Sta_Info      FW_sta_info[NUM_STA];
 363};
 364
 365/*  The channel information about this channel including joining,
 366 *  scanning, and power constraints. */
 367struct rt_channel_info {
 368        u8      ChannelNum;     /*  The channel number. */
 369        enum rt_scan_type ScanType;     /*  Scan type such as passive
 370                                         *  or active scan. */
 371        u32     rx_count;
 372};
 373
 374int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch);
 375
 376/*  P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
 377#define P2P_MAX_REG_CLASSES 10
 378
 379/*  P2P_MAX_REG_CLASS_CHANNELS - Maximum number of chan per regulatory class */
 380#define P2P_MAX_REG_CLASS_CHANNELS 20
 381
 382/*   struct p2p_channels - List of supported channels */
 383struct p2p_channels {
 384        /*  struct p2p_reg_class - Supported regulatory class */
 385        struct p2p_reg_class {
 386                /*  reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */
 387                u8 reg_class;
 388
 389                /*  channel - Supported channels */
 390                u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
 391
 392                /*  channels - Number of channel entries in use */
 393                size_t channels;
 394        } reg_class[P2P_MAX_REG_CLASSES];
 395
 396        /*  reg_classes - Number of reg_class entries in use */
 397        size_t reg_classes;
 398};
 399
 400struct p2p_oper_class_map {
 401        enum hw_mode {IEEE80211G} mode;
 402        u8 op_class;
 403        u8 min_chan;
 404        u8 max_chan;
 405        u8 inc;
 406        enum {BW20, BW40PLUS, BW40MINUS} bw;
 407};
 408
 409struct mlme_ext_priv {
 410        struct adapter  *padapter;
 411        u8      mlmeext_init;
 412        atomic_t        event_seq;
 413        u16     mgnt_seq;
 414
 415        unsigned char   cur_channel;
 416        unsigned char   cur_bwmode;
 417        unsigned char   cur_ch_offset;/* PRIME_CHNL_OFFSET */
 418        unsigned char   cur_wireless_mode;      /*  NETWORK_TYPE */
 419
 420        unsigned char   oper_channel; /* saved chan info when call
 421                                       * set_channel_bw */
 422        unsigned char   oper_bwmode;
 423        unsigned char   oper_ch_offset;/* PRIME_CHNL_OFFSET */
 424
 425        unsigned char   max_chan_nums;
 426        struct rt_channel_info channel_set[MAX_CHANNEL_NUM];
 427        struct p2p_channels channel_list;
 428        unsigned char   basicrate[NumRates];
 429        unsigned char   datarate[NumRates];
 430
 431        struct ss_res           sitesurvey_res;
 432        struct mlme_ext_info    mlmext_info;/* for sta/adhoc mode, including
 433                                             * current scan/connecting/connected
 434                                             * related info. For ap mode,
 435                                             * network includes ap's cap_info*/
 436        struct timer_list survey_timer;
 437        struct timer_list link_timer;
 438        u16     chan_scan_time;
 439
 440        u8      scan_abort;
 441        u8      tx_rate; /*  TXRATE when USERATE is set. */
 442
 443        u32     retry; /* retry for issue probereq */
 444
 445        u64 TSFValue;
 446
 447#ifdef CONFIG_88EU_AP_MODE
 448        unsigned char bstart_bss;
 449#endif
 450        u8 update_channel_plan_by_ap_done;
 451        /* recv_decache check for Action_public frame */
 452        u8 action_public_dialog_token;
 453        u16      action_public_rxseq;
 454        u8 active_keep_alive_check;
 455};
 456
 457int init_mlme_ext_priv(struct adapter *adapter);
 458int init_hw_mlme_ext(struct adapter *padapter);
 459void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext);
 460void init_mlme_ext_timer(struct adapter *padapter);
 461void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta);
 462struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv);
 463
 464unsigned char networktype_to_raid(unsigned char network_type);
 465u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int len);
 466void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len);
 467void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS);
 468void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen);
 469
 470void Save_DM_Func_Flag(struct adapter *padapter);
 471void Restore_DM_Func_Flag(struct adapter *padapter);
 472void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable);
 473
 474void Set_MSR(struct adapter *padapter, u8 type);
 475
 476u8 rtw_get_oper_ch(struct adapter *adapter);
 477void rtw_set_oper_ch(struct adapter *adapter, u8 ch);
 478u8 rtw_get_oper_bw(struct adapter *adapter);
 479void rtw_set_oper_bw(struct adapter *adapter, u8 bw);
 480u8 rtw_get_oper_choffset(struct adapter *adapter);
 481void rtw_set_oper_choffset(struct adapter *adapter, u8 offset);
 482
 483void set_channel_bwmode(struct adapter *padapter, unsigned char channel,
 484                        unsigned char channel_offset, unsigned short bwmode);
 485void SelectChannel(struct adapter *padapter, unsigned char channel);
 486void SetBWMode(struct adapter *padapter, unsigned short bwmode,
 487               unsigned char channel_offset);
 488
 489unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval);
 490
 491void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key);
 492void clear_cam_entry(struct adapter *padapter, u8 entry);
 493
 494void invalidate_cam_all(struct adapter *padapter);
 495void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex);
 496
 497int allocate_fw_sta_entry(struct adapter *padapter);
 498void flush_all_cam_entry(struct adapter *padapter);
 499
 500void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
 501                    struct adapter *adapter, bool update_ie);
 502
 503int get_bsstype(unsigned short capability);
 504u16 get_beacon_interval(struct wlan_bssid_ex *bss);
 505
 506int is_client_associated_to_ap(struct adapter *padapter);
 507int is_client_associated_to_ibss(struct adapter *padapter);
 508int is_IBSS_empty(struct adapter *padapter);
 509
 510unsigned char check_assoc_AP(u8 *pframe, uint len);
 511
 512int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
 513void WMMOnAssocRsp(struct adapter *padapter);
 514
 515void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
 516void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
 517void HTOnAssocRsp(struct adapter *padapter);
 518
 519void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
 520void VCS_update(struct adapter *padapter, struct sta_info *psta);
 521
 522void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len,
 523                        struct sta_info *psta);
 524int rtw_check_bcn_info(struct adapter  *Adapter, u8 *pframe, u32 packet_len);
 525void update_IOT_info(struct adapter *padapter);
 526void update_capinfo(struct adapter *adapter, u16 updatecap);
 527void update_wireless_mode(struct adapter *padapter);
 528void update_tx_basic_rate(struct adapter *padapter, u8 modulation);
 529void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id);
 530int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie,
 531                            uint var_ie_len, int cam_idx);
 532
 533/* for sta/adhoc mode */
 534void update_sta_info(struct adapter *padapter, struct sta_info *psta);
 535unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz);
 536unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz);
 537unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps);
 538void Update_RA_Entry(struct adapter *padapter, u32 mac_id);
 539void set_sta_rate(struct adapter *padapter, struct sta_info *psta);
 540
 541unsigned char get_highest_rate_idx(u32 mask);
 542int support_short_GI(struct adapter *padapter, struct HT_caps_element *caps);
 543unsigned int is_ap_in_tkip(struct adapter *padapter);
 544unsigned int is_ap_in_wep(struct adapter *padapter);
 545unsigned int should_forbid_n_rate(struct adapter *padapter);
 546
 547void report_join_res(struct adapter *padapter, int res);
 548void report_survey_event(struct adapter *padapter,
 549                         struct recv_frame *precv_frame);
 550void report_surveydone_event(struct adapter *padapter);
 551void report_del_sta_event(struct adapter *padapter,
 552                          unsigned char *addr, unsigned short reason);
 553void report_add_sta_event(struct adapter *padapter, unsigned char *addr,
 554                          int cam_idx);
 555
 556void beacon_timing_control(struct adapter *padapter);
 557u8 set_tx_beacon_cmd(struct adapter *padapter);
 558unsigned int setup_beacon_frame(struct adapter *padapter,
 559                                unsigned char *beacon_frame);
 560void update_mgnt_tx_rate(struct adapter *padapter, u8 rate);
 561void update_mgntframe_attrib(struct adapter *padapter,
 562                             struct pkt_attrib *pattrib);
 563
 564int issue_nulldata(struct adapter *padapter, unsigned char *da,
 565                   unsigned int power_mode, int try_cnt, int wait_ms);
 566int issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
 567                       u16 tid, int try_cnt, int wait_ms);
 568int issue_deauth(struct adapter *padapter, unsigned char *da,
 569                 unsigned short reason);
 570void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch,
 571                                 u8 ch_offset);
 572unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr);
 573unsigned int send_beacon(struct adapter *padapter);
 574
 575void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res);
 576void mlmeext_sta_del_event_callback(struct adapter *padapter);
 577void mlmeext_sta_add_event_callback(struct adapter *padapter,
 578                                    struct sta_info *psta);
 579
 580void linked_status_chk(struct adapter *padapter);
 581
 582void survey_timer_hdl(unsigned long data);
 583void link_timer_hdl(unsigned long data);
 584void addba_timer_hdl(unsigned long data);
 585
 586#define set_survey_timer(mlmeext, ms) \
 587        mod_timer(&mlmeext->survey_timer, jiffies +     \
 588                  msecs_to_jiffies(ms))
 589
 590#define set_link_timer(mlmeext, ms) \
 591        mod_timer(&mlmeext->link_timer, jiffies +       \
 592                  msecs_to_jiffies(ms))
 593
 594int cckrates_included(unsigned char *rate, int ratelen);
 595int cckratesonly_included(unsigned char *rate, int ratelen);
 596
 597void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr);
 598
 599void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
 600void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext);
 601
 602struct cmd_hdl {
 603        uint    parmsize;
 604        u8 (*h2cfuns)(struct adapter  *padapter, u8 *pbuf);
 605};
 606
 607u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf);
 608u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf);
 609u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
 610u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
 611u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
 612u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
 613u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf);
 614u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf);
 615u8 createbss_hdl(struct adapter *padapter, u8 *pbuf);
 616u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf);
 617u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf);
 618u8 setauth_hdl(struct adapter *padapter, u8 *pbuf);
 619u8 setkey_hdl(struct adapter *padapter, u8 *pbuf);
 620u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf);
 621u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
 622u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
 623u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf);
 624
 625u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf);
 626u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf);
 627u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf);
 628u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf);
 629u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf);
 630u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf);
 631/* Handling DFS channel switch announcement ie. */
 632u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf);
 633u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
 634
 635#define GEN_DRV_CMD_HANDLER(size, cmd)  {size, &cmd ## _hdl},
 636#define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd},
 637
 638#ifdef _RTW_CMD_C_
 639
 640static struct cmd_hdl wlancmds[] = {
 641        GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), join_cmd_hdl)
 642        GEN_MLME_EXT_HANDLER(sizeof(struct disconnect_parm), disconnect_hdl)
 643        GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), createbss_hdl)
 644        GEN_MLME_EXT_HANDLER(sizeof(struct setopmode_parm), setopmode_hdl)
 645        GEN_MLME_EXT_HANDLER(sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl)
 646        GEN_MLME_EXT_HANDLER(sizeof(struct setauth_parm), setauth_hdl)
 647        GEN_MLME_EXT_HANDLER(sizeof(struct setkey_parm), setkey_hdl)
 648        GEN_MLME_EXT_HANDLER(sizeof(struct set_stakey_parm), set_stakey_hdl)
 649        GEN_MLME_EXT_HANDLER(sizeof(struct set_assocsta_parm), NULL)
 650        GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl)
 651        GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl)
 652        GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), tx_beacon_hdl)
 653        GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl)
 654        GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl)
 655        GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), set_chplan_hdl)
 656};
 657
 658#endif
 659
 660struct C2HEvent_Header {
 661#ifdef __LITTLE_ENDIAN
 662        unsigned int len:16;
 663        unsigned int ID:8;
 664        unsigned int seq:8;
 665#elif defined(__BIG_ENDIAN)
 666        unsigned int seq:8;
 667        unsigned int ID:8;
 668        unsigned int len:16;
 669#endif
 670        unsigned int rsvd;
 671};
 672
 673void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf);
 674void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf);
 675
 676enum rtw_c2h_event {
 677        GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
 678        GEN_EVT_CODE(_Read_BBREG),
 679        GEN_EVT_CODE(_Read_RFREG),
 680        GEN_EVT_CODE(_Read_EEPROM),
 681        GEN_EVT_CODE(_Read_EFUSE),
 682        GEN_EVT_CODE(_Read_CAM),        /*5*/
 683        GEN_EVT_CODE(_Get_BasicRate),
 684        GEN_EVT_CODE(_Get_DataRate),
 685        GEN_EVT_CODE(_Survey),   /*8*/
 686        GEN_EVT_CODE(_SurveyDone),       /*9*/
 687
 688        GEN_EVT_CODE(_JoinBss), /*10*/
 689        GEN_EVT_CODE(_AddSTA),
 690        GEN_EVT_CODE(_DelSTA),
 691        GEN_EVT_CODE(_AtimDone),
 692        GEN_EVT_CODE(_TX_Report),
 693        GEN_EVT_CODE(_CCX_Report),              /*15*/
 694        GEN_EVT_CODE(_DTM_Report),
 695        GEN_EVT_CODE(_TX_Rate_Statistics),
 696        GEN_EVT_CODE(_C2HLBK),
 697        GEN_EVT_CODE(_FWDBG),
 698        GEN_EVT_CODE(_C2HFEEDBACK),             /*20*/
 699        GEN_EVT_CODE(_ADDBA),
 700        GEN_EVT_CODE(_C2HBCN),
 701        GEN_EVT_CODE(_ReportPwrState),  /* filen: only for PCIE, USB */
 702        GEN_EVT_CODE(_CloseRF),         /* filen: only for PCIE,
 703                                         * work around ASPM */
 704        MAX_C2HEVT
 705};
 706
 707
 708#ifdef _RTW_MLME_EXT_C_
 709
 710static struct fwevent wlanevents[] = {
 711        {0, rtw_dummy_event_callback},  /*0*/
 712        {0, NULL},
 713        {0, NULL},
 714        {0, NULL},
 715        {0, NULL},
 716        {0, NULL},
 717        {0, NULL},
 718        {0, NULL},
 719        {0, &rtw_survey_event_callback},                /*8*/
 720        {sizeof(struct surveydone_event), &rtw_surveydone_event_callback},/*9*/
 721        {0, &rtw_joinbss_event_callback},               /*10*/
 722        {sizeof(struct stassoc_event), &rtw_stassoc_event_callback},
 723        {sizeof(struct stadel_event), &rtw_stadel_event_callback},
 724        {0, &rtw_atimdone_event_callback},
 725        {0, rtw_dummy_event_callback},
 726        {0, NULL},      /*15*/
 727        {0, NULL},
 728        {0, NULL},
 729        {0, NULL},
 730        {0, rtw_fwdbg_event_callback},
 731        {0, NULL},       /*20*/
 732        {0, NULL},
 733        {0, NULL},
 734        {0, &rtw_cpwm_event_callback},
 735        {0, NULL},
 736};
 737
 738#endif/* _RTL_MLME_EXT_C_ */
 739
 740#endif /* __RTW_MLME_EXT_H_ */
 741