linux/drivers/staging/rtl8723bs/include/ieee80211.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 __IEEE80211_H
  16#define __IEEE80211_H
  17
  18#include <linux/ieee80211.h>
  19
  20#define MGMT_QUEUE_NUM 5
  21
  22#define ETH_ALEN        6
  23#define ETH_TYPE_LEN            2
  24#define PAYLOAD_TYPE_LEN        1
  25
  26#define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28)
  27
  28/* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */
  29enum {
  30        RTL871X_HOSTAPD_FLUSH = 1,
  31        RTL871X_HOSTAPD_ADD_STA = 2,
  32        RTL871X_HOSTAPD_REMOVE_STA = 3,
  33        RTL871X_HOSTAPD_GET_INFO_STA = 4,
  34        /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
  35        RTL871X_HOSTAPD_GET_WPAIE_STA = 5,
  36        RTL871X_SET_ENCRYPTION = 6,
  37        RTL871X_GET_ENCRYPTION = 7,
  38        RTL871X_HOSTAPD_SET_FLAGS_STA = 8,
  39        RTL871X_HOSTAPD_GET_RID = 9,
  40        RTL871X_HOSTAPD_SET_RID = 10,
  41        RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
  42        RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12,
  43        RTL871X_HOSTAPD_MLME = 13,
  44        RTL871X_HOSTAPD_SCAN_REQ = 14,
  45        RTL871X_HOSTAPD_STA_CLEAR_STATS = 15,
  46        RTL871X_HOSTAPD_SET_BEACON = 16,
  47        RTL871X_HOSTAPD_SET_WPS_BEACON = 17,
  48        RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18,
  49        RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19,
  50        RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20,
  51        RTL871X_HOSTAPD_SET_MACADDR_ACL = 21,
  52        RTL871X_HOSTAPD_ACL_ADD_STA = 22,
  53        RTL871X_HOSTAPD_ACL_REMOVE_STA = 23,
  54};
  55
  56/* STA flags */
  57#define WLAN_STA_AUTH BIT(0)
  58#define WLAN_STA_ASSOC BIT(1)
  59#define WLAN_STA_PS BIT(2)
  60#define WLAN_STA_TIM BIT(3)
  61#define WLAN_STA_PERM BIT(4)
  62#define WLAN_STA_AUTHORIZED BIT(5)
  63#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
  64#define WLAN_STA_SHORT_PREAMBLE BIT(7)
  65#define WLAN_STA_PREAUTH BIT(8)
  66#define WLAN_STA_WME BIT(9)
  67#define WLAN_STA_MFP BIT(10)
  68#define WLAN_STA_HT BIT(11)
  69#define WLAN_STA_WPS BIT(12)
  70#define WLAN_STA_MAYBE_WPS BIT(13)
  71#define WLAN_STA_VHT BIT(14)
  72#define WLAN_STA_NONERP BIT(31)
  73
  74#define IEEE_CMD_SET_WPA_PARAM                  1
  75#define IEEE_CMD_SET_WPA_IE                             2
  76#define IEEE_CMD_SET_ENCRYPTION                 3
  77#define IEEE_CMD_MLME                                           4
  78
  79#define IEEE_PARAM_WPA_ENABLED                          1
  80#define IEEE_PARAM_TKIP_COUNTERMEASURES         2
  81#define IEEE_PARAM_DROP_UNENCRYPTED                     3
  82#define IEEE_PARAM_PRIVACY_INVOKED                      4
  83#define IEEE_PARAM_AUTH_ALGS                                    5
  84#define IEEE_PARAM_IEEE_802_1X                          6
  85#define IEEE_PARAM_WPAX_SELECT                          7
  86
  87#define AUTH_ALG_OPEN_SYSTEM                    0x1
  88#define AUTH_ALG_SHARED_KEY                     0x2
  89#define AUTH_ALG_LEAP                           0x00000004
  90
  91#define IEEE_MLME_STA_DEAUTH                            1
  92#define IEEE_MLME_STA_DISASSOC                  2
  93
  94#define IEEE_CRYPT_ERR_UNKNOWN_ALG                      2
  95#define IEEE_CRYPT_ERR_UNKNOWN_ADDR                     3
  96#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED                4
  97#define IEEE_CRYPT_ERR_KEY_SET_FAILED                   5
  98#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED                6
  99#define IEEE_CRYPT_ERR_CARD_CONF_FAILED         7
 100
 101
 102#define IEEE_CRYPT_ALG_NAME_LEN                 16
 103
 104#define WPA_CIPHER_NONE         BIT(0)
 105#define WPA_CIPHER_WEP40        BIT(1)
 106#define WPA_CIPHER_WEP104 BIT(2)
 107#define WPA_CIPHER_TKIP         BIT(3)
 108#define WPA_CIPHER_CCMP         BIT(4)
 109
 110
 111
 112#define WPA_SELECTOR_LEN 4
 113extern u8 RTW_WPA_OUI_TYPE[] ;
 114extern u16 RTW_WPA_VERSION ;
 115extern u8 WPA_AUTH_KEY_MGMT_NONE[];
 116extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
 117extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
 118extern u8 WPA_CIPHER_SUITE_NONE[];
 119extern u8 WPA_CIPHER_SUITE_WEP40[];
 120extern u8 WPA_CIPHER_SUITE_TKIP[];
 121extern u8 WPA_CIPHER_SUITE_WRAP[];
 122extern u8 WPA_CIPHER_SUITE_CCMP[];
 123extern u8 WPA_CIPHER_SUITE_WEP104[];
 124
 125
 126#define RSN_HEADER_LEN 4
 127#define RSN_SELECTOR_LEN 4
 128
 129extern u16 RSN_VERSION_BSD;
 130extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[];
 131extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
 132extern u8 RSN_CIPHER_SUITE_NONE[];
 133extern u8 RSN_CIPHER_SUITE_WEP40[];
 134extern u8 RSN_CIPHER_SUITE_TKIP[];
 135extern u8 RSN_CIPHER_SUITE_WRAP[];
 136extern u8 RSN_CIPHER_SUITE_CCMP[];
 137extern u8 RSN_CIPHER_SUITE_WEP104[];
 138
 139
 140typedef enum _RATEID_IDX_ {
 141        RATEID_IDX_BGN_40M_2SS = 0,
 142        RATEID_IDX_BGN_40M_1SS = 1,
 143        RATEID_IDX_BGN_20M_2SS_BN = 2,
 144        RATEID_IDX_BGN_20M_1SS_BN = 3,
 145        RATEID_IDX_GN_N2SS = 4,
 146        RATEID_IDX_GN_N1SS = 5,
 147        RATEID_IDX_BG = 6,
 148        RATEID_IDX_G = 7,
 149        RATEID_IDX_B = 8,
 150        RATEID_IDX_VHT_2SS = 9,
 151        RATEID_IDX_VHT_1SS = 10,
 152} RATEID_IDX, *PRATEID_IDX;
 153
 154typedef enum _RATR_TABLE_MODE{
 155        RATR_INX_WIRELESS_NGB = 0,      /*  BGN 40 Mhz 2SS 1SS */
 156        RATR_INX_WIRELESS_NG = 1,               /*  GN or N */
 157        RATR_INX_WIRELESS_NB = 2,               /*  BGN 20 Mhz 2SS 1SS  or BN */
 158        RATR_INX_WIRELESS_N = 3,
 159        RATR_INX_WIRELESS_GB = 4,
 160        RATR_INX_WIRELESS_G = 5,
 161        RATR_INX_WIRELESS_B = 6,
 162        RATR_INX_WIRELESS_MC = 7,
 163        RATR_INX_WIRELESS_AC_N = 8,
 164}RATR_TABLE_MODE, *PRATR_TABLE_MODE;
 165
 166
 167enum NETWORK_TYPE
 168{
 169        WIRELESS_INVALID = 0,
 170        /* Sub-Element */
 171        WIRELESS_11B = BIT(0), /*  tx: cck only , rx: cck only, hw: cck */
 172        WIRELESS_11G = BIT(1), /*  tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */
 173        WIRELESS_11A = BIT(2), /*  tx: ofdm only, rx: ofdm only, hw: ofdm only */
 174        WIRELESS_11_24N = BIT(3), /*  tx: MCS only, rx: MCS & cck, hw: MCS & cck */
 175        WIRELESS_11_5N = BIT(4), /*  tx: MCS only, rx: MCS & ofdm, hw: ofdm only */
 176        WIRELESS_AUTO = BIT(5),
 177        WIRELESS_11AC = BIT(6),
 178
 179        /* Combination */
 180        /* Type for current wireless mode */
 181        WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G), /*  tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */
 182        WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N), /*  tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */
 183        WIRELESS_11A_5N = (WIRELESS_11A|WIRELESS_11_5N), /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
 184        WIRELESS_11B_24N = (WIRELESS_11B|WIRELESS_11_24N), /*  tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
 185        WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N), /*  tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */
 186        WIRELESS_11_24AC = (WIRELESS_11G|WIRELESS_11AC),
 187        WIRELESS_11_5AC = (WIRELESS_11A|WIRELESS_11AC),
 188
 189
 190        /* Type for registry default wireless mode */
 191        WIRELESS_11AGN = (WIRELESS_11A|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), /*  tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */
 192        WIRELESS_11ABGN = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N),
 193        WIRELESS_MODE_24G = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11AC),
 194        WIRELESS_MODE_MAX = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N|WIRELESS_11AC),
 195};
 196
 197#define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N)
 198
 199#define IsLegacyOnly(NetType)  ((NetType) == ((NetType) & (WIRELESS_11BG|WIRELESS_11A)))
 200
 201#define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false)
 202
 203#define IsEnableHWCCK(NetType) IsSupported24G(NetType)
 204#define IsEnableHWOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11_24N)) ? true : false)
 205
 206#define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType)
 207#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType)
 208#define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType)
 209
 210#define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false)
 211#define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11A)) ? true : false)
 212#define IsSupportedHT(NetType) (((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N)) ? true : false)
 213
 214#define IsSupportedVHT(NetType) (((NetType) & (WIRELESS_11AC)) ? true : false)
 215
 216
 217typedef struct ieee_param {
 218        u32 cmd;
 219        u8 sta_addr[ETH_ALEN];
 220        union {
 221                struct {
 222                        u8 name;
 223                        u32 value;
 224                } wpa_param;
 225                struct {
 226                        u32 len;
 227                        u8 reserved[32];
 228                        u8 data[0];
 229                } wpa_ie;
 230                struct{
 231                        int command;
 232                        int reason_code;
 233                } mlme;
 234                struct {
 235                        u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
 236                        u8 set_tx;
 237                        u32 err;
 238                        u8 idx;
 239                        u8 seq[8]; /* sequence counter (set: RX, get: TX) */
 240                        u16 key_len;
 241                        u8 key[0];
 242                } crypt;
 243                struct {
 244                        u16 aid;
 245                        u16 capability;
 246                        int flags;
 247                        u8 tx_supp_rates[16];
 248                        struct rtw_ieee80211_ht_cap ht_cap;
 249                } add_sta;
 250                struct {
 251                        u8 reserved[2];/* for set max_num_sta */
 252                        u8 buf[0];
 253                } bcn_ie;
 254        } u;
 255}ieee_param;
 256
 257typedef struct ieee_param_ex {
 258        u32 cmd;
 259        u8 sta_addr[ETH_ALEN];
 260        u8 data[0];
 261}ieee_param_ex;
 262
 263struct sta_data{
 264        u16 aid;
 265        u16 capability;
 266        int flags;
 267        u32 sta_set;
 268        u8 tx_supp_rates[16];
 269        u32 tx_supp_rates_len;
 270        struct rtw_ieee80211_ht_cap ht_cap;
 271        u64     rx_pkts;
 272        u64     rx_bytes;
 273        u64     rx_drops;
 274        u64     tx_pkts;
 275        u64     tx_bytes;
 276        u64     tx_drops;
 277};
 278
 279#define IEEE80211_DATA_LEN              2304
 280/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
 281   6.2.1.1.2.
 282
 283   The figure in section 7.1.2 suggests a body size of up to 2312
 284   bytes is allowed, which is a bit confusing, I suspect this
 285   represents the 2304 bytes of real data, plus a possible 8 bytes of
 286   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
 287
 288
 289#define IEEE80211_HLEN                  30
 290#define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
 291
 292
 293/* this is stolen from ipw2200 driver */
 294#define IEEE_IBSS_MAC_HASH_SIZE 31
 295
 296struct ieee_ibss_seq {
 297        u8 mac[ETH_ALEN];
 298        u16 seq_num;
 299        u16 frag_num;
 300        unsigned long packet_time;
 301        struct list_head        list;
 302};
 303
 304struct eapol {
 305        u8 snap[6];
 306        u16 ethertype;
 307        u8 version;
 308        u8 type;
 309        u16 length;
 310} __attribute__ ((packed));
 311
 312enum eap_type {
 313        EAP_PACKET = 0,
 314        EAPOL_START,
 315        EAPOL_LOGOFF,
 316        EAPOL_KEY,
 317        EAPOL_ENCAP_ASF_ALERT
 318};
 319
 320#define IEEE80211_3ADDR_LEN 24
 321#define IEEE80211_4ADDR_LEN 30
 322#define IEEE80211_FCS_LEN    4
 323
 324#define MIN_FRAG_THRESHOLD     256U
 325#define MAX_FRAG_THRESHOLD     2346U
 326
 327/* Frame control field constants */
 328#define RTW_IEEE80211_FCTL_VERS         0x0003
 329#define RTW_IEEE80211_FCTL_FTYPE                0x000c
 330#define RTW_IEEE80211_FCTL_STYPE                0x00f0
 331#define RTW_IEEE80211_FCTL_TODS         0x0100
 332#define RTW_IEEE80211_FCTL_FROMDS       0x0200
 333#define RTW_IEEE80211_FCTL_MOREFRAGS    0x0400
 334#define RTW_IEEE80211_FCTL_RETRY                0x0800
 335#define RTW_IEEE80211_FCTL_PM           0x1000
 336#define RTW_IEEE80211_FCTL_MOREDATA     0x2000
 337#define RTW_IEEE80211_FCTL_PROTECTED    0x4000
 338#define RTW_IEEE80211_FCTL_ORDER                0x8000
 339#define RTW_IEEE80211_FCTL_CTL_EXT      0x0f00
 340
 341#define RTW_IEEE80211_FTYPE_MGMT                0x0000
 342#define RTW_IEEE80211_FTYPE_CTL         0x0004
 343#define RTW_IEEE80211_FTYPE_DATA                0x0008
 344#define RTW_IEEE80211_FTYPE_EXT         0x000c
 345
 346/* management */
 347#define RTW_IEEE80211_STYPE_ASSOC_REQ   0x0000
 348#define RTW_IEEE80211_STYPE_ASSOC_RESP  0x0010
 349#define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020
 350#define RTW_IEEE80211_STYPE_REASSOC_RESP        0x0030
 351#define RTW_IEEE80211_STYPE_PROBE_REQ   0x0040
 352#define RTW_IEEE80211_STYPE_PROBE_RESP  0x0050
 353#define RTW_IEEE80211_STYPE_BEACON              0x0080
 354#define RTW_IEEE80211_STYPE_ATIM                0x0090
 355#define RTW_IEEE80211_STYPE_DISASSOC    0x00A0
 356#define RTW_IEEE80211_STYPE_AUTH                0x00B0
 357#define RTW_IEEE80211_STYPE_DEAUTH              0x00C0
 358#define RTW_IEEE80211_STYPE_ACTION              0x00D0
 359
 360/* control */
 361#define RTW_IEEE80211_STYPE_CTL_EXT             0x0060
 362#define RTW_IEEE80211_STYPE_BACK_REQ            0x0080
 363#define RTW_IEEE80211_STYPE_BACK                0x0090
 364#define RTW_IEEE80211_STYPE_PSPOLL              0x00A0
 365#define RTW_IEEE80211_STYPE_RTS         0x00B0
 366#define RTW_IEEE80211_STYPE_CTS         0x00C0
 367#define RTW_IEEE80211_STYPE_ACK         0x00D0
 368#define RTW_IEEE80211_STYPE_CFEND               0x00E0
 369#define RTW_IEEE80211_STYPE_CFENDACK            0x00F0
 370
 371/* data */
 372#define RTW_IEEE80211_STYPE_DATA                0x0000
 373#define RTW_IEEE80211_STYPE_DATA_CFACK  0x0010
 374#define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020
 375#define RTW_IEEE80211_STYPE_DATA_CFACKPOLL      0x0030
 376#define RTW_IEEE80211_STYPE_NULLFUNC    0x0040
 377#define RTW_IEEE80211_STYPE_CFACK               0x0050
 378#define RTW_IEEE80211_STYPE_CFPOLL              0x0060
 379#define RTW_IEEE80211_STYPE_CFACKPOLL   0x0070
 380#define RTW_IEEE80211_STYPE_QOS_DATA            0x0080
 381#define RTW_IEEE80211_STYPE_QOS_DATA_CFACK              0x0090
 382#define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL             0x00A0
 383#define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL  0x00B0
 384#define RTW_IEEE80211_STYPE_QOS_NULLFUNC        0x00C0
 385#define RTW_IEEE80211_STYPE_QOS_CFACK           0x00D0
 386#define RTW_IEEE80211_STYPE_QOS_CFPOLL          0x00E0
 387#define RTW_IEEE80211_STYPE_QOS_CFACKPOLL       0x00F0
 388
 389/* sequence control field */
 390#define RTW_IEEE80211_SCTL_FRAG 0x000F
 391#define RTW_IEEE80211_SCTL_SEQ  0xFFF0
 392
 393
 394#define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0)
 395#define RTW_ERP_INFO_USE_PROTECTION BIT(1)
 396#define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2)
 397
 398/* QoS, QOS */
 399#define NORMAL_ACK                      0
 400#define NO_ACK                          1
 401#define NON_EXPLICIT_ACK        2
 402#define BLOCK_ACK                       3
 403
 404#ifndef ETH_P_PAE
 405#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
 406#endif /* ETH_P_PAE */
 407
 408#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
 409
 410#define ETH_P_ECONET    0x0018
 411
 412#ifndef ETH_P_80211_RAW
 413#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
 414#endif
 415
 416/* IEEE 802.11 defines */
 417
 418#define P80211_OUI_LEN 3
 419
 420struct ieee80211_snap_hdr {
 421        u8    dsap;   /* always 0xAA */
 422        u8    ssap;   /* always 0xAA */
 423        u8    ctrl;   /* always 0x03 */
 424        u8    oui[P80211_OUI_LEN];    /* organizational universal id */
 425} __attribute__ ((packed));
 426
 427#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
 428
 429#define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE)
 430#define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE)
 431
 432#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
 433
 434#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG)
 435#define WLAN_GET_SEQ_SEQ(seq)  ((seq) & RTW_IEEE80211_SCTL_SEQ)
 436
 437/* Authentication algorithms */
 438#define WLAN_AUTH_OPEN 0
 439#define WLAN_AUTH_SHARED_KEY 1
 440
 441#define WLAN_AUTH_CHALLENGE_LEN 128
 442
 443#define WLAN_CAPABILITY_BSS (1<<0)
 444#define WLAN_CAPABILITY_IBSS (1<<1)
 445#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
 446#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
 447#define WLAN_CAPABILITY_PRIVACY (1<<4)
 448#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
 449#define WLAN_CAPABILITY_PBCC (1<<6)
 450#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
 451#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
 452
 453/* Status codes */
 454#define WLAN_STATUS_SUCCESS 0
 455#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
 456#define WLAN_STATUS_CAPS_UNSUPPORTED 10
 457#define WLAN_STATUS_REASSOC_NO_ASSOC 11
 458#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
 459#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
 460#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
 461#define WLAN_STATUS_CHALLENGE_FAIL 15
 462#define WLAN_STATUS_AUTH_TIMEOUT 16
 463#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
 464#define WLAN_STATUS_ASSOC_DENIED_RATES 18
 465/* 802.11b */
 466#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
 467#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
 468#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
 469
 470/* Reason codes */
 471#define WLAN_REASON_UNSPECIFIED 1
 472#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
 473#define WLAN_REASON_DEAUTH_LEAVING 3
 474#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
 475#define WLAN_REASON_DISASSOC_AP_BUSY 5
 476#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
 477#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
 478#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
 479#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
 480#define WLAN_REASON_ACTIVE_ROAM 65533
 481#define WLAN_REASON_JOIN_WRONG_CHANNEL       65534
 482#define WLAN_REASON_EXPIRATION_CHK 65535
 483
 484/* Information Element IDs */
 485#define WLAN_EID_SSID 0
 486#define WLAN_EID_SUPP_RATES 1
 487#define WLAN_EID_FH_PARAMS 2
 488#define WLAN_EID_DS_PARAMS 3
 489#define WLAN_EID_CF_PARAMS 4
 490#define WLAN_EID_TIM 5
 491#define WLAN_EID_IBSS_PARAMS 6
 492#define WLAN_EID_CHALLENGE 16
 493/* EIDs defined by IEEE 802.11h - START */
 494#define WLAN_EID_PWR_CONSTRAINT 32
 495#define WLAN_EID_PWR_CAPABILITY 33
 496#define WLAN_EID_TPC_REQUEST 34
 497#define WLAN_EID_TPC_REPORT 35
 498#define WLAN_EID_SUPPORTED_CHANNELS 36
 499#define WLAN_EID_CHANNEL_SWITCH 37
 500#define WLAN_EID_MEASURE_REQUEST 38
 501#define WLAN_EID_MEASURE_REPORT 39
 502#define WLAN_EID_QUITE 40
 503#define WLAN_EID_IBSS_DFS 41
 504/* EIDs defined by IEEE 802.11h - END */
 505#define WLAN_EID_ERP_INFO 42
 506#define WLAN_EID_HT_CAP 45
 507#define WLAN_EID_RSN 48
 508#define WLAN_EID_EXT_SUPP_RATES 50
 509#define WLAN_EID_MOBILITY_DOMAIN 54
 510#define WLAN_EID_FAST_BSS_TRANSITION 55
 511#define WLAN_EID_TIMEOUT_INTERVAL 56
 512#define WLAN_EID_RIC_DATA 57
 513#define WLAN_EID_HT_OPERATION 61
 514#define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62
 515#define WLAN_EID_20_40_BSS_COEXISTENCE 72
 516#define WLAN_EID_20_40_BSS_INTOLERANT 73
 517#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74
 518#define WLAN_EID_MMIE 76
 519#define WLAN_EID_VENDOR_SPECIFIC 221
 520#define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC)
 521#define WLAN_EID_VHT_CAPABILITY 191
 522#define WLAN_EID_VHT_OPERATION 192
 523#define WLAN_EID_VHT_OP_MODE_NOTIFY 199
 524
 525#define IEEE80211_MGMT_HDR_LEN 24
 526#define IEEE80211_DATA_HDR3_LEN 24
 527#define IEEE80211_DATA_HDR4_LEN 30
 528
 529
 530#define IEEE80211_STATMASK_SIGNAL (1<<0)
 531#define IEEE80211_STATMASK_RSSI (1<<1)
 532#define IEEE80211_STATMASK_NOISE (1<<2)
 533#define IEEE80211_STATMASK_RATE (1<<3)
 534#define IEEE80211_STATMASK_WEMASK 0x7
 535
 536
 537#define IEEE80211_CCK_MODULATION    (1<<0)
 538#define IEEE80211_OFDM_MODULATION   (1<<1)
 539
 540#define IEEE80211_24GHZ_BAND     (1<<0)
 541#define IEEE80211_52GHZ_BAND     (1<<1)
 542
 543#define IEEE80211_CCK_RATE_LEN                  4
 544#define IEEE80211_NUM_OFDM_RATESLEN     8
 545
 546
 547#define IEEE80211_CCK_RATE_1MB                  0x02
 548#define IEEE80211_CCK_RATE_2MB                  0x04
 549#define IEEE80211_CCK_RATE_5MB                  0x0B
 550#define IEEE80211_CCK_RATE_11MB                 0x16
 551#define IEEE80211_OFDM_RATE_LEN                 8
 552#define IEEE80211_OFDM_RATE_6MB                 0x0C
 553#define IEEE80211_OFDM_RATE_9MB                 0x12
 554#define IEEE80211_OFDM_RATE_12MB                0x18
 555#define IEEE80211_OFDM_RATE_18MB                0x24
 556#define IEEE80211_OFDM_RATE_24MB                0x30
 557#define IEEE80211_OFDM_RATE_36MB                0x48
 558#define IEEE80211_OFDM_RATE_48MB                0x60
 559#define IEEE80211_OFDM_RATE_54MB                0x6C
 560#define IEEE80211_BASIC_RATE_MASK               0x80
 561
 562#define IEEE80211_CCK_RATE_1MB_MASK             (1<<0)
 563#define IEEE80211_CCK_RATE_2MB_MASK             (1<<1)
 564#define IEEE80211_CCK_RATE_5MB_MASK             (1<<2)
 565#define IEEE80211_CCK_RATE_11MB_MASK            (1<<3)
 566#define IEEE80211_OFDM_RATE_6MB_MASK            (1<<4)
 567#define IEEE80211_OFDM_RATE_9MB_MASK            (1<<5)
 568#define IEEE80211_OFDM_RATE_12MB_MASK           (1<<6)
 569#define IEEE80211_OFDM_RATE_18MB_MASK           (1<<7)
 570#define IEEE80211_OFDM_RATE_24MB_MASK           (1<<8)
 571#define IEEE80211_OFDM_RATE_36MB_MASK           (1<<9)
 572#define IEEE80211_OFDM_RATE_48MB_MASK           (1<<10)
 573#define IEEE80211_OFDM_RATE_54MB_MASK           (1<<11)
 574
 575#define IEEE80211_CCK_RATES_MASK                0x0000000F
 576#define IEEE80211_CCK_BASIC_RATES_MASK  (IEEE80211_CCK_RATE_1MB_MASK | \
 577        IEEE80211_CCK_RATE_2MB_MASK)
 578#define IEEE80211_CCK_DEFAULT_RATES_MASK        (IEEE80211_CCK_BASIC_RATES_MASK | \
 579        IEEE80211_CCK_RATE_5MB_MASK | \
 580        IEEE80211_CCK_RATE_11MB_MASK)
 581
 582#define IEEE80211_OFDM_RATES_MASK               0x00000FF0
 583#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
 584        IEEE80211_OFDM_RATE_12MB_MASK | \
 585        IEEE80211_OFDM_RATE_24MB_MASK)
 586#define IEEE80211_OFDM_DEFAULT_RATES_MASK       (IEEE80211_OFDM_BASIC_RATES_MASK | \
 587        IEEE80211_OFDM_RATE_9MB_MASK  | \
 588        IEEE80211_OFDM_RATE_18MB_MASK | \
 589        IEEE80211_OFDM_RATE_36MB_MASK | \
 590        IEEE80211_OFDM_RATE_48MB_MASK | \
 591        IEEE80211_OFDM_RATE_54MB_MASK)
 592#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
 593                                IEEE80211_CCK_DEFAULT_RATES_MASK)
 594
 595#define IEEE80211_NUM_OFDM_RATES            8
 596#define IEEE80211_NUM_CCK_RATES             4
 597#define IEEE80211_OFDM_SHIFT_MASK_A         4
 598
 599
 600enum MGN_RATE{
 601        MGN_1M          = 0x02,
 602        MGN_2M          = 0x04,
 603        MGN_5_5M        = 0x0B,
 604        MGN_6M          = 0x0C,
 605        MGN_9M          = 0x12,
 606        MGN_11M         = 0x16,
 607        MGN_12M = 0x18,
 608        MGN_18M = 0x24,
 609        MGN_24M = 0x30,
 610        MGN_36M = 0x48,
 611        MGN_48M = 0x60,
 612        MGN_54M = 0x6C,
 613        MGN_MCS32       = 0x7F,
 614        MGN_MCS0,
 615        MGN_MCS1,
 616        MGN_MCS2,
 617        MGN_MCS3,
 618        MGN_MCS4,
 619        MGN_MCS5,
 620        MGN_MCS6,
 621        MGN_MCS7,
 622        MGN_MCS8,
 623        MGN_MCS9,
 624        MGN_MCS10,
 625        MGN_MCS11,
 626        MGN_MCS12,
 627        MGN_MCS13,
 628        MGN_MCS14,
 629        MGN_MCS15,
 630        MGN_MCS16,
 631        MGN_MCS17,
 632        MGN_MCS18,
 633        MGN_MCS19,
 634        MGN_MCS20,
 635        MGN_MCS21,
 636        MGN_MCS22,
 637        MGN_MCS23,
 638        MGN_MCS24,
 639        MGN_MCS25,
 640        MGN_MCS26,
 641        MGN_MCS27,
 642        MGN_MCS28,
 643        MGN_MCS29,
 644        MGN_MCS30,
 645        MGN_MCS31,
 646        MGN_VHT1SS_MCS0,
 647        MGN_VHT1SS_MCS1,
 648        MGN_VHT1SS_MCS2,
 649        MGN_VHT1SS_MCS3,
 650        MGN_VHT1SS_MCS4,
 651        MGN_VHT1SS_MCS5,
 652        MGN_VHT1SS_MCS6,
 653        MGN_VHT1SS_MCS7,
 654        MGN_VHT1SS_MCS8,
 655        MGN_VHT1SS_MCS9,
 656        MGN_VHT2SS_MCS0,
 657        MGN_VHT2SS_MCS1,
 658        MGN_VHT2SS_MCS2,
 659        MGN_VHT2SS_MCS3,
 660        MGN_VHT2SS_MCS4,
 661        MGN_VHT2SS_MCS5,
 662        MGN_VHT2SS_MCS6,
 663        MGN_VHT2SS_MCS7,
 664        MGN_VHT2SS_MCS8,
 665        MGN_VHT2SS_MCS9,
 666        MGN_VHT3SS_MCS0,
 667        MGN_VHT3SS_MCS1,
 668        MGN_VHT3SS_MCS2,
 669        MGN_VHT3SS_MCS3,
 670        MGN_VHT3SS_MCS4,
 671        MGN_VHT3SS_MCS5,
 672        MGN_VHT3SS_MCS6,
 673        MGN_VHT3SS_MCS7,
 674        MGN_VHT3SS_MCS8,
 675        MGN_VHT3SS_MCS9,
 676        MGN_VHT4SS_MCS0,
 677        MGN_VHT4SS_MCS1,
 678        MGN_VHT4SS_MCS2,
 679        MGN_VHT4SS_MCS3,
 680        MGN_VHT4SS_MCS4,
 681        MGN_VHT4SS_MCS5,
 682        MGN_VHT4SS_MCS6,
 683        MGN_VHT4SS_MCS7,
 684        MGN_VHT4SS_MCS8,
 685        MGN_VHT4SS_MCS9,
 686        MGN_UNKNOWN
 687};
 688
 689#define IS_HT_RATE(_rate)                               (_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
 690#define IS_VHT_RATE(_rate)                              (_rate >= MGN_VHT1SS_MCS0 && _rate <= MGN_VHT4SS_MCS9)
 691#define IS_CCK_RATE(_rate)                              (MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
 692#define IS_OFDM_RATE(_rate)                             (MGN_6M <= _rate && _rate <= MGN_54M  && _rate != MGN_11M)
 693
 694
 695/* NOTE: This data is for statistical purposes; not all hardware provides this
 696 *       information for frames received.  Not setting these will not cause
 697 *       any adverse affects. */
 698struct ieee80211_rx_stats {
 699        s8 rssi;
 700        u8 signal;
 701        u8 noise;
 702        u8 received_channel;
 703        u16 rate; /* in 100 kbps */
 704        u8 mask;
 705        u8 freq;
 706        u16 len;
 707};
 708
 709/* IEEE 802.11 requires that STA supports concurrent reception of at least
 710 * three fragmented frames. This define can be increased to support more
 711 * concurrent frames, but it should be noted that each entry can consume about
 712 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
 713#define IEEE80211_FRAG_CACHE_LEN 4
 714
 715struct ieee80211_frag_entry {
 716        u32 first_frag_time;
 717        uint seq;
 718        uint last_frag;
 719        uint qos;   /* jackson */
 720        uint tid;       /* jackson */
 721        struct sk_buff *skb;
 722        u8 src_addr[ETH_ALEN];
 723        u8 dst_addr[ETH_ALEN];
 724};
 725
 726struct ieee80211_stats {
 727        uint tx_unicast_frames;
 728        uint tx_multicast_frames;
 729        uint tx_fragments;
 730        uint tx_unicast_octets;
 731        uint tx_multicast_octets;
 732        uint tx_deferred_transmissions;
 733        uint tx_single_retry_frames;
 734        uint tx_multiple_retry_frames;
 735        uint tx_retry_limit_exceeded;
 736        uint tx_discards;
 737        uint rx_unicast_frames;
 738        uint rx_multicast_frames;
 739        uint rx_fragments;
 740        uint rx_unicast_octets;
 741        uint rx_multicast_octets;
 742        uint rx_fcs_errors;
 743        uint rx_discards_no_buffer;
 744        uint tx_discards_wrong_sa;
 745        uint rx_discards_undecryptable;
 746        uint rx_message_in_msg_fragments;
 747        uint rx_message_in_bad_msg_fragments;
 748};
 749
 750struct ieee80211_softmac_stats {
 751        uint rx_ass_ok;
 752        uint rx_ass_err;
 753        uint rx_probe_rq;
 754        uint tx_probe_rs;
 755        uint tx_beacons;
 756        uint rx_auth_rq;
 757        uint rx_auth_rs_ok;
 758        uint rx_auth_rs_err;
 759        uint tx_auth_rq;
 760        uint no_auth_rs;
 761        uint no_ass_rs;
 762        uint tx_ass_rq;
 763        uint rx_ass_rq;
 764        uint tx_probe_rq;
 765        uint reassoc;
 766        uint swtxstop;
 767        uint swtxawake;
 768};
 769
 770#define SEC_KEY_1         (1<<0)
 771#define SEC_KEY_2         (1<<1)
 772#define SEC_KEY_3         (1<<2)
 773#define SEC_KEY_4         (1<<3)
 774#define SEC_ACTIVE_KEY    (1<<4)
 775#define SEC_AUTH_MODE     (1<<5)
 776#define SEC_UNICAST_GROUP (1<<6)
 777#define SEC_LEVEL         (1<<7)
 778#define SEC_ENABLED       (1<<8)
 779
 780#define SEC_LEVEL_0      0 /* None */
 781#define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
 782#define SEC_LEVEL_2      2 /* Level 1 + TKIP */
 783#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
 784#define SEC_LEVEL_3      4 /* Level 2 + CCMP */
 785
 786#define WEP_KEYS 4
 787#define WEP_KEY_LEN 13
 788
 789#define BIP_MAX_KEYID 5
 790#define BIP_AAD_SIZE  20
 791
 792struct ieee80211_security {
 793        u16 active_key:2,
 794            enabled:1,
 795            auth_mode:2,
 796            auth_algo:4,
 797            unicast_uses_group:1;
 798        u8 key_sizes[WEP_KEYS];
 799        u8 keys[WEP_KEYS][WEP_KEY_LEN];
 800        u8 level;
 801        u16 flags;
 802} __attribute__ ((packed));
 803
 804/*
 805
 806 802.11 data frame from AP
 807
 808      ,-------------------------------------------------------------------.
 809Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
 810      |------|------|---------|---------|---------|------|---------|------|
 811Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
 812      |      | tion | (BSSID) |         |         | ence |  data   |      |
 813      `-------------------------------------------------------------------'
 814
 815Total: 28-2340 bytes
 816
 817*/
 818
 819struct ieee80211_header_data {
 820        u16 frame_ctl;
 821        u16 duration_id;
 822        u8 addr1[6];
 823        u8 addr2[6];
 824        u8 addr3[6];
 825        u16 seq_ctrl;
 826};
 827
 828#define BEACON_PROBE_SSID_ID_POSITION 12
 829
 830/* Management Frame Information Element Types */
 831#define MFIE_TYPE_SSID       0
 832#define MFIE_TYPE_RATES      1
 833#define MFIE_TYPE_FH_SET     2
 834#define MFIE_TYPE_DS_SET     3
 835#define MFIE_TYPE_CF_SET     4
 836#define MFIE_TYPE_TIM        5
 837#define MFIE_TYPE_IBSS_SET   6
 838#define MFIE_TYPE_CHALLENGE  16
 839#define MFIE_TYPE_ERP        42
 840#define MFIE_TYPE_RSN        48
 841#define MFIE_TYPE_RATES_EX   50
 842#define MFIE_TYPE_GENERIC    221
 843
 844struct ieee80211_info_element_hdr {
 845        u8 id;
 846        u8 len;
 847} __attribute__ ((packed));
 848
 849struct ieee80211_info_element {
 850        u8 id;
 851        u8 len;
 852        u8 data[0];
 853} __attribute__ ((packed));
 854
 855/*
 856 * These are the data types that can make up management packets
 857 *
 858        u16 auth_algorithm;
 859        u16 auth_sequence;
 860        u16 beacon_interval;
 861        u16 capability;
 862        u8 current_ap[ETH_ALEN];
 863        u16 listen_interval;
 864        struct {
 865                u16 association_id:14, reserved:2;
 866        } __attribute__ ((packed));
 867        u32 time_stamp[2];
 868        u16 reason;
 869        u16 status;
 870*/
 871
 872#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
 873#define IEEE80211_DEFAULT_BASIC_RATE 10
 874
 875
 876struct ieee80211_authentication {
 877        struct ieee80211_header_data header;
 878        u16 algorithm;
 879        u16 transaction;
 880        u16 status;
 881        /* struct ieee80211_info_element_hdr info_element; */
 882} __attribute__ ((packed));
 883
 884
 885struct ieee80211_probe_response {
 886        struct ieee80211_header_data header;
 887        u32 time_stamp[2];
 888        u16 beacon_interval;
 889        u16 capability;
 890        struct ieee80211_info_element info_element;
 891} __attribute__ ((packed));
 892
 893struct ieee80211_probe_request {
 894        struct ieee80211_header_data header;
 895        /*struct ieee80211_info_element info_element;*/
 896} __attribute__ ((packed));
 897
 898struct ieee80211_assoc_request_frame {
 899        struct ieee80211_hdr_3addr header;
 900        u16 capability;
 901        u16 listen_interval;
 902        /* u8 current_ap[ETH_ALEN]; */
 903        struct ieee80211_info_element_hdr info_element;
 904} __attribute__ ((packed));
 905
 906struct ieee80211_assoc_response_frame {
 907        struct ieee80211_hdr_3addr header;
 908        u16 capability;
 909        u16 status;
 910        u16 aid;
 911} __attribute__ ((packed));
 912
 913struct ieee80211_txb {
 914        u8 nr_frags;
 915        u8 encrypted;
 916        u16 reserved;
 917        u16 frag_size;
 918        u16 payload_size;
 919        struct sk_buff *fragments[0];
 920};
 921
 922
 923/* SWEEP TABLE ENTRIES NUMBER*/
 924#define MAX_SWEEP_TAB_ENTRIES             42
 925#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
 926/* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
 927 * only use 8, and then use extended rates for the remaining supported
 928 * rates.  Other APs, however, stick all of their supported rates on the
 929 * main rates information element... */
 930#define MAX_RATES_LENGTH                  ((u8)12)
 931#define MAX_RATES_EX_LENGTH               ((u8)16)
 932#define MAX_NETWORK_COUNT                  128
 933#define MAX_CHANNEL_NUMBER                 161
 934#define IEEE80211_SOFTMAC_SCAN_TIME       400
 935/* HZ / 2) */
 936#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
 937
 938#define CRC_LENGTH                 4U
 939
 940#define MAX_WPA_IE_LEN (256)
 941#define MAX_WPS_IE_LEN (512)
 942#define MAX_P2P_IE_LEN (256)
 943#define MAX_WFD_IE_LEN (128)
 944
 945#define NETWORK_EMPTY_ESSID (1<<0)
 946#define NETWORK_HAS_OFDM    (1<<1)
 947#define NETWORK_HAS_CCK     (1<<2)
 948
 949#define IEEE80211_DTIM_MBCAST 4
 950#define IEEE80211_DTIM_UCAST 2
 951#define IEEE80211_DTIM_VALID 1
 952#define IEEE80211_DTIM_INVALID 0
 953
 954#define IEEE80211_PS_DISABLED 0
 955#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
 956#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
 957#define IW_ESSID_MAX_SIZE 32
 958/*
 959join_res:
 960-1: authentication fail
 961-2: association fail
 962> 0: TID
 963*/
 964
 965enum ieee80211_state {
 966
 967        /* the card is not linked at all */
 968        IEEE80211_NOLINK = 0,
 969
 970        /* IEEE80211_ASSOCIATING* are for BSS client mode
 971         * the driver shall not perform RX filtering unless
 972         * the state is LINKED.
 973         * The driver shall just check for the state LINKED and
 974         * defaults to NOLINK for ALL the other states (including
 975         * LINKED_SCANNING)
 976         */
 977
 978        /* the association procedure will start (wq scheduling)*/
 979        IEEE80211_ASSOCIATING,
 980        IEEE80211_ASSOCIATING_RETRY,
 981
 982        /* the association procedure is sending AUTH request*/
 983        IEEE80211_ASSOCIATING_AUTHENTICATING,
 984
 985        /* the association procedure has successfully authentcated
 986         * and is sending association request
 987         */
 988        IEEE80211_ASSOCIATING_AUTHENTICATED,
 989
 990        /* the link is ok. the card associated to a BSS or linked
 991         * to a ibss cell or acting as an AP and creating the bss
 992         */
 993        IEEE80211_LINKED,
 994
 995        /* same as LINKED, but the driver shall apply RX filter
 996         * rules as we are in NO_LINK mode. As the card is still
 997         * logically linked, but it is doing a syncro site survey
 998         * then it will be back to LINKED state.
 999         */
1000        IEEE80211_LINKED_SCANNING,
1001
1002};
1003
1004#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1005#define DEFAULT_FTS 2346
1006#define MAC_FMT "%pM"
1007#define MAC_ARG(x) (x)
1008#define IP_FMT "%pI4"
1009#define IP_ARG(x) (x)
1010
1011extern __inline int is_multicast_mac_addr(const u8 *addr)
1012{
1013        return ((addr[0] != 0xff) && (0x01 & addr[0]));
1014}
1015
1016extern __inline int is_broadcast_mac_addr(const u8 *addr)
1017{
1018        return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&   \
1019                (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
1020}
1021
1022extern __inline int is_zero_mac_addr(const u8 *addr)
1023{
1024        return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) &&   \
1025                (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00));
1026}
1027
1028#define CFG_IEEE80211_RESERVE_FCS (1<<0)
1029#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1030
1031typedef struct tx_pending_t{
1032        int frag;
1033        struct ieee80211_txb *txb;
1034}tx_pending_t;
1035
1036
1037
1038#define MAXTID  16
1039
1040#define IEEE_A            (1<<0)
1041#define IEEE_B            (1<<1)
1042#define IEEE_G            (1<<2)
1043#define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
1044
1045/* Action category code */
1046enum rtw_ieee80211_category {
1047        RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0,
1048        RTW_WLAN_CATEGORY_QOS = 1,
1049        RTW_WLAN_CATEGORY_DLS = 2,
1050        RTW_WLAN_CATEGORY_BACK = 3,
1051        RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */
1052        RTW_WLAN_CATEGORY_RADIO_MEASUREMENT  = 5,
1053        RTW_WLAN_CATEGORY_FT = 6,
1054        RTW_WLAN_CATEGORY_HT = 7,
1055        RTW_WLAN_CATEGORY_SA_QUERY = 8,
1056        RTW_WLAN_CATEGORY_UNPROTECTED_WNM = 11, /*  add for CONFIG_IEEE80211W, none 11w also can use */
1057        RTW_WLAN_CATEGORY_TDLS = 12,
1058        RTW_WLAN_CATEGORY_SELF_PROTECTED = 15, /*  add for CONFIG_IEEE80211W, none 11w also can use */
1059        RTW_WLAN_CATEGORY_WMM = 17,
1060        RTW_WLAN_CATEGORY_VHT = 21,
1061        RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */
1062};
1063
1064/* SPECTRUM_MGMT action code */
1065enum rtw_ieee80211_spectrum_mgmt_actioncode {
1066        RTW_WLAN_ACTION_SPCT_MSR_REQ = 0,
1067        RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1,
1068        RTW_WLAN_ACTION_SPCT_TPC_REQ = 2,
1069        RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3,
1070        RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4,
1071        RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5,
1072};
1073
1074enum _PUBLIC_ACTION{
1075        ACT_PUBLIC_BSSCOEXIST = 0, /*  20/40 BSS Coexistence */
1076        ACT_PUBLIC_DSE_ENABLE = 1,
1077        ACT_PUBLIC_DSE_DEENABLE = 2,
1078        ACT_PUBLIC_DSE_REG_LOCATION = 3,
1079        ACT_PUBLIC_EXT_CHL_SWITCH = 4,
1080        ACT_PUBLIC_DSE_MSR_REQ = 5,
1081        ACT_PUBLIC_DSE_MSR_RPRT = 6,
1082        ACT_PUBLIC_MP = 7, /*  Measurement Pilot */
1083        ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8,
1084        ACT_PUBLIC_VENDOR = 9, /*  for WIFI_DIRECT */
1085        ACT_PUBLIC_GAS_INITIAL_REQ = 10,
1086        ACT_PUBLIC_GAS_INITIAL_RSP = 11,
1087        ACT_PUBLIC_GAS_COMEBACK_REQ = 12,
1088        ACT_PUBLIC_GAS_COMEBACK_RSP = 13,
1089        ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14,
1090        ACT_PUBLIC_LOCATION_TRACK = 15,
1091        ACT_PUBLIC_MAX
1092};
1093
1094/* BACK action code */
1095enum rtw_ieee80211_back_actioncode {
1096        RTW_WLAN_ACTION_ADDBA_REQ = 0,
1097        RTW_WLAN_ACTION_ADDBA_RESP = 1,
1098        RTW_WLAN_ACTION_DELBA = 2,
1099};
1100
1101/* HT features action code */
1102enum rtw_ieee80211_ht_actioncode {
1103        RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0,
1104       RTW_WLAN_ACTION_HT_SM_PS = 1,
1105       RTW_WLAN_ACTION_HT_PSMP = 2,
1106       RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3,
1107       RTW_WLAN_ACTION_HT_CSI = 4,
1108       RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5,
1109       RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6,
1110       RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7,
1111};
1112
1113/* BACK (block-ack) parties */
1114enum rtw_ieee80211_back_parties {
1115        RTW_WLAN_BACK_RECIPIENT = 0,
1116        RTW_WLAN_BACK_INITIATOR = 1,
1117        RTW_WLAN_BACK_TIMER = 2,
1118};
1119
1120/* VHT features action code */
1121enum rtw_ieee80211_vht_actioncode{
1122        RTW_WLAN_ACTION_VHT_COMPRESSED_BEAMFORMING = 0,
1123       RTW_WLAN_ACTION_VHT_GROUPID_MANAGEMENT = 1,
1124       RTW_WLAN_ACTION_VHT_OPMODE_NOTIFICATION = 2,
1125};
1126
1127
1128#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs)
1129                                * 00:50:F2 */
1130#define WME_OUI_TYPE 2
1131#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
1132#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
1133#define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
1134#define WME_VERSION 1
1135
1136#define WME_ACTION_CODE_SETUP_REQUEST 0
1137#define WME_ACTION_CODE_SETUP_RESPONSE 1
1138#define WME_ACTION_CODE_TEARDOWN 2
1139
1140#define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
1141#define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
1142#define WME_SETUP_RESPONSE_STATUS_REFUSED 3
1143
1144#define WME_TSPEC_DIRECTION_UPLINK 0
1145#define WME_TSPEC_DIRECTION_DOWNLINK 1
1146#define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
1147
1148
1149#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */
1150
1151#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */
1152
1153/**
1154 * enum rtw_ieee80211_channel_flags - channel flags
1155 *
1156 * Channel flags set by the regulatory control code.
1157 *
1158 * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled.
1159 * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
1160 *      on this channel.
1161 * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
1162 * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
1163 * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
1164 *      is not permitted.
1165 * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
1166 *      is not permitted.
1167 */
1168  enum rtw_ieee80211_channel_flags {
1169          RTW_IEEE80211_CHAN_DISABLED         = 1<<0,
1170          RTW_IEEE80211_CHAN_PASSIVE_SCAN     = 1<<1,
1171          RTW_IEEE80211_CHAN_NO_IBSS          = 1<<2,
1172          RTW_IEEE80211_CHAN_RADAR            = 1<<3,
1173          RTW_IEEE80211_CHAN_NO_HT40PLUS      = 1<<4,
1174          RTW_IEEE80211_CHAN_NO_HT40MINUS     = 1<<5,
1175  };
1176
1177  #define RTW_IEEE80211_CHAN_NO_HT40 \
1178          (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS)
1179
1180/* Represent channel details, subset of ieee80211_channel */
1181struct rtw_ieee80211_channel {
1182        /* enum nl80211_band band; */
1183        /* u16 center_freq; */
1184        u16 hw_value;
1185        u32 flags;
1186        /* int max_antenna_gain; */
1187        /* int max_power; */
1188        /* int max_reg_power; */
1189        /* bool beacon_found; */
1190        /* u32 orig_flags; */
1191        /* int orig_mag; */
1192        /* int orig_mpwr; */
1193};
1194
1195#define CHAN_FMT \
1196        /*"band:%d, "*/ \
1197        /*"center_freq:%u, "*/ \
1198        "hw_value:%u, " \
1199        "flags:0x%08x" \
1200        /*"max_antenna_gain:%d\n"*/ \
1201        /*"max_power:%d\n"*/ \
1202        /*"max_reg_power:%d\n"*/ \
1203        /*"beacon_found:%u\n"*/ \
1204        /*"orig_flags:0x%08x\n"*/ \
1205        /*"orig_mag:%d\n"*/ \
1206        /*"orig_mpwr:%d\n"*/
1207
1208#define CHAN_ARG(channel) \
1209        /*(channel)->band*/ \
1210        /*, (channel)->center_freq*/ \
1211        (channel)->hw_value \
1212        , (channel)->flags \
1213        /*, (channel)->max_antenna_gain*/ \
1214        /*, (channel)->max_power*/ \
1215        /*, (channel)->max_reg_power*/ \
1216        /*, (channel)->beacon_found*/ \
1217        /*, (channel)->orig_flags*/ \
1218        /*, (channel)->orig_mag*/ \
1219        /*, (channel)->orig_mpwr*/ \
1220
1221/* Parsed Information Elements */
1222struct rtw_ieee802_11_elems {
1223        u8 *ssid;
1224        u8 ssid_len;
1225        u8 *supp_rates;
1226        u8 supp_rates_len;
1227        u8 *fh_params;
1228        u8 fh_params_len;
1229        u8 *ds_params;
1230        u8 ds_params_len;
1231        u8 *cf_params;
1232        u8 cf_params_len;
1233        u8 *tim;
1234        u8 tim_len;
1235        u8 *ibss_params;
1236        u8 ibss_params_len;
1237        u8 *challenge;
1238        u8 challenge_len;
1239        u8 *erp_info;
1240        u8 erp_info_len;
1241        u8 *ext_supp_rates;
1242        u8 ext_supp_rates_len;
1243        u8 *wpa_ie;
1244        u8 wpa_ie_len;
1245        u8 *rsn_ie;
1246        u8 rsn_ie_len;
1247        u8 *wme;
1248        u8 wme_len;
1249        u8 *wme_tspec;
1250        u8 wme_tspec_len;
1251        u8 *wps_ie;
1252        u8 wps_ie_len;
1253        u8 *power_cap;
1254        u8 power_cap_len;
1255        u8 *supp_channels;
1256        u8 supp_channels_len;
1257        u8 *mdie;
1258        u8 mdie_len;
1259        u8 *ftie;
1260        u8 ftie_len;
1261        u8 *timeout_int;
1262        u8 timeout_int_len;
1263        u8 *ht_capabilities;
1264        u8 ht_capabilities_len;
1265        u8 *ht_operation;
1266        u8 ht_operation_len;
1267        u8 *vendor_ht_cap;
1268        u8 vendor_ht_cap_len;
1269        u8 *vht_capabilities;
1270        u8 vht_capabilities_len;
1271        u8 *vht_operation;
1272        u8 vht_operation_len;
1273        u8 *vht_op_mode_notify;
1274        u8 vht_op_mode_notify_len;
1275};
1276
1277typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
1278
1279ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len,
1280                                struct rtw_ieee802_11_elems *elems,
1281                                int show_errors);
1282
1283u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen);
1284u8 *rtw_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
1285
1286enum secondary_ch_offset {
1287        SCN = 0, /* no secondary channel */
1288        SCA = 1, /* secondary channel above */
1289        SCB = 3,  /* secondary channel below */
1290};
1291
1292u8 *rtw_get_ie(u8*pbuf, sint index, sint *len, sint limit);
1293u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen);
1294int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len);
1295
1296void rtw_set_supported_rate(u8 *SupportedRates, uint mode) ;
1297
1298unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit);
1299unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
1300int rtw_get_wpa_cipher_suite(u8 *s);
1301int rtw_get_wpa2_cipher_suite(u8 *s);
1302int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len);
1303int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
1304int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x);
1305
1306int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len);
1307
1308u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen);
1309u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
1310u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr);
1311u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content);
1312
1313/**
1314 * for_each_ie - iterate over continuous IEs
1315 * @ie:
1316 * @buf:
1317 * @buf_len:
1318 */
1319#define for_each_ie(ie, buf, buf_len) \
1320        for (ie = (void*)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; ie = (void*)(((u8 *)ie) + *(((u8 *)ie)+1) + 2))
1321
1322uint    rtw_get_rateset_len(u8 *rateset);
1323
1324struct registry_priv;
1325int rtw_generate_ie(struct registry_priv *pregistrypriv);
1326
1327
1328int rtw_get_bit_value_from_ieee_value(u8 val);
1329
1330uint    rtw_is_cckrates_included(u8 *rate);
1331
1332uint    rtw_is_cckratesonly_included(u8 *rate);
1333
1334int rtw_check_network_type(unsigned char *rate, int ratelen, int channel);
1335
1336void rtw_get_bcn_info(struct wlan_network *pnetwork);
1337
1338void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr);
1339
1340u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate);
1341
1342int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action);
1343const char *action_public_str(u8 action);
1344
1345#endif /* IEEE80211_H */
1346