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