0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef IEEE80211_H
0021 #define IEEE80211_H
0022 #include <linux/if_ether.h> /* ETH_ALEN */
0023 #include <linux/kernel.h>
0024 #include <linux/module.h>
0025 #include <linux/jiffies.h>
0026 #include <linux/timer.h>
0027 #include <linux/sched.h>
0028 #include <linux/semaphore.h>
0029 #include <linux/interrupt.h>
0030
0031 #include <linux/delay.h>
0032 #include <linux/wireless.h>
0033 #include <linux/ieee80211.h>
0034
0035 #include "rtl819x_HT.h"
0036 #include "rtl819x_BA.h"
0037 #include "rtl819x_TS.h"
0038
0039
0040 #ifndef IW_MODE_MONITOR
0041 #define IW_MODE_MONITOR 6
0042 #endif
0043
0044 #ifndef IWEVCUSTOM
0045 #define IWEVCUSTOM 0x8c02
0046 #endif
0047
0048 #define KEY_TYPE_NA 0x0
0049 #define KEY_TYPE_WEP40 0x1
0050 #define KEY_TYPE_TKIP 0x2
0051 #define KEY_TYPE_CCMP 0x4
0052 #define KEY_TYPE_WEP104 0x5
0053
0054
0055 #define MAX_QUEUE_SIZE 0x10
0056
0057
0058
0059
0060 #define BK_QUEUE 0
0061 #define BE_QUEUE 1
0062 #define VI_QUEUE 2
0063 #define VO_QUEUE 3
0064 #define HCCA_QUEUE 4
0065 #define TXCMD_QUEUE 5
0066 #define MGNT_QUEUE 6
0067 #define HIGH_QUEUE 7
0068 #define BEACON_QUEUE 8
0069
0070 #define LOW_QUEUE BE_QUEUE
0071 #define NORMAL_QUEUE MGNT_QUEUE
0072
0073
0074 #define SWRF_TIMEOUT 50
0075
0076
0077 #define IE_CISCO_FLAG_POSITION 0x08
0078 #define SUPPORT_CKIP_MIC 0x08
0079 #define SUPPORT_CKIP_PK 0x10
0080
0081
0082 struct cb_desc {
0083
0084 u8 bLastIniPkt:1;
0085 u8 bCmdOrInit:1;
0086 u8 bFirstSeg:1;
0087 u8 bLastSeg:1;
0088 u8 bEncrypt:1;
0089 u8 bTxDisableRateFallBack:1;
0090 u8 bTxUseDriverAssingedRate:1;
0091 u8 bHwSec:1;
0092
0093 u8 reserved1;
0094
0095
0096 u8 bCTSEnable:1;
0097 u8 bRTSEnable:1;
0098 u8 bUseShortGI:1;
0099 u8 bUseShortPreamble:1;
0100 u8 bTxEnableFwCalcDur:1;
0101 u8 bAMPDUEnable:1;
0102 u8 bRTSSTBC:1;
0103 u8 RTSSC:1;
0104
0105 u8 bRTSBW:1;
0106 u8 bPacketBW:1;
0107 u8 bRTSUseShortPreamble:1;
0108 u8 bRTSUseShortGI:1;
0109 u8 bMulticast:1;
0110 u8 bBroadcast:1;
0111
0112 u8 drv_agg_enable:1;
0113 u8 reserved2:1;
0114
0115
0116 u8 rata_index;
0117 u8 queue_index;
0118
0119
0120 u16 txbuf_size;
0121
0122 u8 RATRIndex;
0123 u8 reserved6;
0124 u8 reserved7;
0125 u8 reserved8;
0126
0127
0128 u8 data_rate;
0129 u8 rts_rate;
0130 u8 ampdu_factor;
0131 u8 ampdu_density;
0132
0133
0134
0135 u8 DrvAggrNum;
0136 u16 pkt_size;
0137 u8 reserved12;
0138 };
0139
0140
0141 #define MGN_1M 0x02
0142 #define MGN_2M 0x04
0143 #define MGN_5_5M 0x0b
0144 #define MGN_11M 0x16
0145
0146 #define MGN_6M 0x0c
0147 #define MGN_9M 0x12
0148 #define MGN_12M 0x18
0149 #define MGN_18M 0x24
0150 #define MGN_24M 0x30
0151 #define MGN_36M 0x48
0152 #define MGN_48M 0x60
0153 #define MGN_54M 0x6c
0154
0155 #define MGN_MCS0 0x80
0156 #define MGN_MCS1 0x81
0157 #define MGN_MCS2 0x82
0158 #define MGN_MCS3 0x83
0159 #define MGN_MCS4 0x84
0160 #define MGN_MCS5 0x85
0161 #define MGN_MCS6 0x86
0162 #define MGN_MCS7 0x87
0163 #define MGN_MCS8 0x88
0164 #define MGN_MCS9 0x89
0165 #define MGN_MCS10 0x8a
0166 #define MGN_MCS11 0x8b
0167 #define MGN_MCS12 0x8c
0168 #define MGN_MCS13 0x8d
0169 #define MGN_MCS14 0x8e
0170 #define MGN_MCS15 0x8f
0171
0172 #define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A || \
0173 priv->ieee80211->current_network.mode == IEEE_N_24G || \
0174 priv->ieee80211->current_network.mode == IEEE_N_5G) ? \
0175 16 : 10)
0176
0177 #define MGMT_QUEUE_NUM 5
0178
0179 #define IEEE_CMD_SET_WPA_PARAM 1
0180 #define IEEE_CMD_SET_WPA_IE 2
0181 #define IEEE_CMD_SET_ENCRYPTION 3
0182 #define IEEE_CMD_MLME 4
0183
0184 #define IEEE_PARAM_WPA_ENABLED 1
0185 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
0186 #define IEEE_PARAM_DROP_UNENCRYPTED 3
0187 #define IEEE_PARAM_PRIVACY_INVOKED 4
0188 #define IEEE_PARAM_AUTH_ALGS 5
0189 #define IEEE_PARAM_IEEE_802_1X 6
0190
0191
0192 #define IEEE_PARAM_WPAX_SELECT 7
0193
0194
0195 #define IEEE_PROTO_WPA 1
0196 #define IEEE_PROTO_RSN 2
0197
0198
0199 #define IEEE_WPAX_USEGROUP 0
0200 #define IEEE_WPAX_WEP40 1
0201 #define IEEE_WPAX_TKIP 2
0202 #define IEEE_WPAX_WRAP 3
0203 #define IEEE_WPAX_CCMP 4
0204 #define IEEE_WPAX_WEP104 5
0205
0206 #define IEEE_KEY_MGMT_IEEE8021X 1
0207 #define IEEE_KEY_MGMT_PSK 2
0208
0209 #define IEEE_MLME_STA_DEAUTH 1
0210 #define IEEE_MLME_STA_DISASSOC 2
0211
0212
0213 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
0214 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
0215 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
0216 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
0217 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
0218 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
0219
0220
0221 #define IEEE_CRYPT_ALG_NAME_LEN 16
0222
0223 #define MAX_IE_LEN 0xff
0224
0225
0226 #define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl
0227 #define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl
0228 #define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl
0229 #define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl
0230 #define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl
0231 #define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl
0232
0233 #define ieee80211_ccmp_null ieee80211_ccmp_null_rsl
0234
0235 #define ieee80211_tkip_null ieee80211_tkip_null_rsl
0236
0237 #define free_ieee80211 free_ieee80211_rsl
0238 #define alloc_ieee80211 alloc_ieee80211_rsl
0239
0240 #define ieee80211_rx ieee80211_rx_rsl
0241 #define ieee80211_rx_mgt ieee80211_rx_mgt_rsl
0242
0243 #define ieee80211_get_beacon ieee80211_get_beacon_rsl
0244 #define ieee80211_wake_queue ieee80211_wake_queue_rsl
0245 #define ieee80211_stop_queue ieee80211_stop_queue_rsl
0246 #define ieee80211_reset_queue ieee80211_reset_queue_rsl
0247 #define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rsl
0248 #define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
0249 #define ieee80211_is_shortslot ieee80211_is_shortslot_rsl
0250 #define ieee80211_is_54g ieee80211_is_54g_rsl
0251 #define ieee80211_wpa_supplicant_ioctl ieee80211_wpa_supplicant_ioctl_rsl
0252 #define ieee80211_ps_tx_ack ieee80211_ps_tx_ack_rsl
0253 #define ieee80211_softmac_xmit ieee80211_softmac_xmit_rsl
0254 #define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rsl
0255 #define notify_wx_assoc_event notify_wx_assoc_event_rsl
0256 #define SendDisassociation SendDisassociation_rsl
0257 #define ieee80211_disassociate ieee80211_disassociate_rsl
0258 #define ieee80211_start_send_beacons ieee80211_start_send_beacons_rsl
0259 #define ieee80211_stop_scan ieee80211_stop_scan_rsl
0260 #define ieee80211_send_probe_requests ieee80211_send_probe_requests_rsl
0261 #define ieee80211_softmac_scan_syncro ieee80211_softmac_scan_syncro_rsl
0262 #define ieee80211_start_scan_syncro ieee80211_start_scan_syncro_rsl
0263
0264 #define ieee80211_wx_get_essid ieee80211_wx_get_essid_rsl
0265 #define ieee80211_wx_set_essid ieee80211_wx_set_essid_rsl
0266 #define ieee80211_wx_set_rate ieee80211_wx_set_rate_rsl
0267 #define ieee80211_wx_get_rate ieee80211_wx_get_rate_rsl
0268 #define ieee80211_wx_set_wap ieee80211_wx_set_wap_rsl
0269 #define ieee80211_wx_get_wap ieee80211_wx_get_wap_rsl
0270 #define ieee80211_wx_set_mode ieee80211_wx_set_mode_rsl
0271 #define ieee80211_wx_get_mode ieee80211_wx_get_mode_rsl
0272 #define ieee80211_wx_set_scan ieee80211_wx_set_scan_rsl
0273 #define ieee80211_wx_get_freq ieee80211_wx_get_freq_rsl
0274 #define ieee80211_wx_set_freq ieee80211_wx_set_freq_rsl
0275 #define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rsl
0276 #define ieee80211_wx_get_name ieee80211_wx_get_name_rsl
0277 #define ieee80211_wx_set_power ieee80211_wx_set_power_rsl
0278 #define ieee80211_wx_get_power ieee80211_wx_get_power_rsl
0279 #define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rsl
0280 #define ieee80211_wx_set_rts ieee80211_wx_set_rts_rsl
0281 #define ieee80211_wx_get_rts ieee80211_wx_get_rts_rsl
0282
0283 #define ieee80211_txb_free ieee80211_txb_free_rsl
0284
0285 #define ieee80211_wx_set_gen_ie ieee80211_wx_set_gen_ie_rsl
0286 #define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl
0287 #define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl
0288 #define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl
0289 #define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl
0290 #define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl
0291 #define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl
0292 #define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl
0293
0294
0295 struct ieee_param {
0296 u32 cmd;
0297 u8 sta_addr[ETH_ALEN];
0298 union {
0299 struct {
0300 u8 name;
0301 u32 value;
0302 } wpa_param;
0303 struct {
0304 u32 len;
0305 u8 reserved[32];
0306 u8 data[];
0307 } wpa_ie;
0308 struct{
0309 int command;
0310 int reason_code;
0311 } mlme;
0312 struct {
0313 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
0314 u8 set_tx;
0315 u32 err;
0316 u8 idx;
0317 u8 seq[8];
0318 u16 key_len;
0319 u8 key[];
0320 } crypt;
0321 } u;
0322 };
0323
0324
0325
0326 #define IEEE80211_DATA_LEN 2304
0327
0328
0329
0330
0331
0332
0333
0334
0335 #define IEEE80211_1ADDR_LEN 10
0336 #define IEEE80211_2ADDR_LEN 16
0337 #define IEEE80211_3ADDR_LEN 24
0338 #define IEEE80211_4ADDR_LEN 30
0339 #define IEEE80211_FCS_LEN 4
0340 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
0341 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
0342 #define IEEE80211_MGMT_HDR_LEN 24
0343 #define IEEE80211_DATA_HDR3_LEN 24
0344 #define IEEE80211_DATA_HDR4_LEN 30
0345
0346 #define MIN_FRAG_THRESHOLD 256U
0347 #define MAX_FRAG_THRESHOLD 2346U
0348
0349
0350
0351 #define IEEE80211_FCTL_VERS 0x0003
0352 #define IEEE80211_FCTL_FTYPE 0x000c
0353 #define IEEE80211_FCTL_STYPE 0x00f0
0354 #define IEEE80211_FCTL_FRAMETYPE 0x00fc
0355 #define IEEE80211_FCTL_TODS 0x0100
0356 #define IEEE80211_FCTL_FROMDS 0x0200
0357 #define IEEE80211_FCTL_DSTODS 0x0300
0358 #define IEEE80211_FCTL_MOREFRAGS 0x0400
0359 #define IEEE80211_FCTL_RETRY 0x0800
0360 #define IEEE80211_FCTL_PM 0x1000
0361 #define IEEE80211_FCTL_MOREDATA 0x2000
0362 #define IEEE80211_FCTL_WEP 0x4000
0363 #define IEEE80211_FCTL_ORDER 0x8000
0364
0365 #define IEEE80211_FTYPE_MGMT 0x0000
0366 #define IEEE80211_FTYPE_CTL 0x0004
0367 #define IEEE80211_FTYPE_DATA 0x0008
0368
0369
0370 #define IEEE80211_STYPE_ASSOC_REQ 0x0000
0371 #define IEEE80211_STYPE_ASSOC_RESP 0x0010
0372 #define IEEE80211_STYPE_REASSOC_REQ 0x0020
0373 #define IEEE80211_STYPE_REASSOC_RESP 0x0030
0374 #define IEEE80211_STYPE_PROBE_REQ 0x0040
0375 #define IEEE80211_STYPE_PROBE_RESP 0x0050
0376 #define IEEE80211_STYPE_BEACON 0x0080
0377 #define IEEE80211_STYPE_ATIM 0x0090
0378 #define IEEE80211_STYPE_DISASSOC 0x00A0
0379 #define IEEE80211_STYPE_AUTH 0x00B0
0380 #define IEEE80211_STYPE_DEAUTH 0x00C0
0381 #define IEEE80211_STYPE_MANAGE_ACT 0x00D0
0382
0383
0384 #define IEEE80211_STYPE_PSPOLL 0x00A0
0385 #define IEEE80211_STYPE_RTS 0x00B0
0386 #define IEEE80211_STYPE_CTS 0x00C0
0387 #define IEEE80211_STYPE_ACK 0x00D0
0388 #define IEEE80211_STYPE_CFEND 0x00E0
0389 #define IEEE80211_STYPE_CFENDACK 0x00F0
0390 #define IEEE80211_STYPE_BLOCKACK 0x0094
0391
0392
0393 #define IEEE80211_STYPE_DATA 0x0000
0394 #define IEEE80211_STYPE_DATA_CFACK 0x0010
0395 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
0396 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
0397 #define IEEE80211_STYPE_NULLFUNC 0x0040
0398 #define IEEE80211_STYPE_CFACK 0x0050
0399 #define IEEE80211_STYPE_CFPOLL 0x0060
0400 #define IEEE80211_STYPE_CFACKPOLL 0x0070
0401 #define IEEE80211_STYPE_QOS_DATA 0x0080
0402 #define IEEE80211_STYPE_QOS_NULL 0x00C0
0403
0404 #define IEEE80211_SCTL_FRAG 0x000F
0405 #define IEEE80211_SCTL_SEQ 0xFFF0
0406
0407
0408 #define IEEE80211_QCTL_TID 0x000F
0409
0410 #define FC_QOS_BIT BIT(7)
0411 #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
0412 #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0] & FC_QOS_BIT)))
0413
0414 #define IsQoSDataFrame(pframe) ((*(u16 *)pframe & (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA))
0415 #define Frame_Order(pframe) (*(u16 *)pframe & IEEE80211_FCTL_ORDER)
0416 #define SN_LESS(a, b) (((a - b) & 0x800) != 0)
0417 #define SN_EQUAL(a, b) (a == b)
0418 #define MAX_DEV_ADDR_SIZE 8
0419 typedef enum _ACT_CATEGORY {
0420 ACT_CAT_QOS = 1,
0421 ACT_CAT_DLS = 2,
0422 ACT_CAT_BA = 3,
0423 ACT_CAT_HT = 7,
0424 ACT_CAT_WMM = 17,
0425 } ACT_CATEGORY, *PACT_CATEGORY;
0426
0427 typedef enum _TS_ACTION {
0428 ACT_ADDTSREQ = 0,
0429 ACT_ADDTSRSP = 1,
0430 ACT_DELTS = 2,
0431 ACT_SCHEDULE = 3,
0432 } TS_ACTION, *PTS_ACTION;
0433
0434 typedef enum _BA_ACTION {
0435 ACT_ADDBAREQ = 0,
0436 ACT_ADDBARSP = 1,
0437 ACT_DELBA = 2,
0438 } BA_ACTION, *PBA_ACTION;
0439
0440 typedef enum _InitialGainOpType {
0441 IG_Backup = 0,
0442 IG_Restore,
0443 IG_Max
0444 } InitialGainOpType;
0445
0446
0447 #define CONFIG_IEEE80211_DEBUG
0448 #ifdef CONFIG_IEEE80211_DEBUG
0449 extern u32 ieee80211_debug_level;
0450 #define IEEE80211_DEBUG(level, fmt, args...) \
0451 do { if (ieee80211_debug_level & (level)) \
0452 printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0)
0453
0454
0455 #define IEEE80211_DEBUG_DATA(level, data, datalen) \
0456 do { if ((ieee80211_debug_level & (level)) == (level)) \
0457 { \
0458 int i; \
0459 u8 *pdata = (u8 *)data; \
0460 printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \
0461 for (i = 0; i < (int)(datalen); i++) { \
0462 printk("%2x ", pdata[i]); \
0463 if ((i + 1) % 16 == 0) \
0464 printk("\n"); \
0465 } \
0466 printk("\n"); \
0467 } \
0468 } while (0)
0469 #else
0470 #define IEEE80211_DEBUG(level, fmt, args...)
0471 #define IEEE80211_DEBUG_DATA(level, data, datalen)
0472 #endif
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502 #define IEEE80211_DL_INFO (1<<0)
0503 #define IEEE80211_DL_WX (1<<1)
0504 #define IEEE80211_DL_SCAN (1<<2)
0505 #define IEEE80211_DL_STATE (1<<3)
0506 #define IEEE80211_DL_MGMT (1<<4)
0507 #define IEEE80211_DL_FRAG (1<<5)
0508 #define IEEE80211_DL_EAP (1<<6)
0509 #define IEEE80211_DL_DROP (1<<7)
0510
0511 #define IEEE80211_DL_TX (1<<8)
0512 #define IEEE80211_DL_RX (1<<9)
0513
0514 #define IEEE80211_DL_HT (1<<10)
0515 #define IEEE80211_DL_BA (1<<11)
0516 #define IEEE80211_DL_TS (1<<12)
0517 #define IEEE80211_DL_QOS (1<<13)
0518 #define IEEE80211_DL_REORDER (1<<14)
0519 #define IEEE80211_DL_IOT (1<<15)
0520 #define IEEE80211_DL_IPS (1<<16)
0521 #define IEEE80211_DL_TRACE (1<<29)
0522 #define IEEE80211_DL_DATA (1<<30)
0523 #define IEEE80211_DL_ERR (1<<31)
0524 #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
0525 #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
0526 #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
0527
0528 #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
0529 #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
0530 #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
0531 #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
0532 #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
0533 #define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
0534 #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
0535 #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
0536 #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
0537 #define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
0538
0539 #include <linux/if_arp.h> /* ARPHRD_ETHER */
0540
0541 #ifndef WIRELESS_SPY
0542 #define WIRELESS_SPY
0543 #endif
0544 #include <net/iw_handler.h> // new driver API
0545
0546 #ifndef ETH_P_PAE
0547 #define ETH_P_PAE 0x888E
0548 #endif
0549
0550 #define ETH_P_PREAUTH 0x88C7
0551
0552 #ifndef ETH_P_80211_RAW
0553 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
0554 #endif
0555
0556
0557
0558 #define P80211_OUI_LEN 3
0559
0560 struct ieee80211_snap_hdr {
0561
0562 u8 dsap;
0563 u8 ssap;
0564 u8 ctrl;
0565 u8 oui[P80211_OUI_LEN];
0566
0567 } __packed;
0568
0569 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
0570
0571 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
0572 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
0573 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
0574
0575 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
0576 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
0577 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
0578
0579 #define WLAN_CAPABILITY_BSS (1<<0)
0580 #define WLAN_CAPABILITY_IBSS (1<<1)
0581 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
0582 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
0583 #define WLAN_CAPABILITY_PRIVACY (1<<4)
0584 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
0585 #define WLAN_CAPABILITY_PBCC (1<<6)
0586 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
0587 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
0588 #define WLAN_CAPABILITY_QOS (1<<9)
0589 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
0590 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
0591
0592
0593 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
0594 #define WLAN_ERP_USE_PROTECTION (1<<1)
0595 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
0596
0597 #define IEEE80211_STATMASK_SIGNAL (1<<0)
0598 #define IEEE80211_STATMASK_RSSI (1<<1)
0599 #define IEEE80211_STATMASK_NOISE (1<<2)
0600 #define IEEE80211_STATMASK_RATE (1<<3)
0601 #define IEEE80211_STATMASK_WEMASK 0x7
0602
0603 #define IEEE80211_CCK_MODULATION (1<<0)
0604 #define IEEE80211_OFDM_MODULATION (1<<1)
0605
0606 #define IEEE80211_24GHZ_BAND (1<<0)
0607 #define IEEE80211_52GHZ_BAND (1<<1)
0608
0609 #define IEEE80211_CCK_RATE_LEN 4
0610 #define IEEE80211_CCK_RATE_1MB 0x02
0611 #define IEEE80211_CCK_RATE_2MB 0x04
0612 #define IEEE80211_CCK_RATE_5MB 0x0B
0613 #define IEEE80211_CCK_RATE_11MB 0x16
0614 #define IEEE80211_OFDM_RATE_LEN 8
0615 #define IEEE80211_OFDM_RATE_6MB 0x0C
0616 #define IEEE80211_OFDM_RATE_9MB 0x12
0617 #define IEEE80211_OFDM_RATE_12MB 0x18
0618 #define IEEE80211_OFDM_RATE_18MB 0x24
0619 #define IEEE80211_OFDM_RATE_24MB 0x30
0620 #define IEEE80211_OFDM_RATE_36MB 0x48
0621 #define IEEE80211_OFDM_RATE_48MB 0x60
0622 #define IEEE80211_OFDM_RATE_54MB 0x6C
0623 #define IEEE80211_BASIC_RATE_MASK 0x80
0624
0625 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
0626 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
0627 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
0628 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
0629 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
0630 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
0631 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
0632 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
0633 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
0634 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
0635 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
0636 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
0637
0638 #define IEEE80211_CCK_RATES_MASK 0x0000000F
0639 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
0640 IEEE80211_CCK_RATE_2MB_MASK)
0641 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
0642 IEEE80211_CCK_RATE_5MB_MASK | \
0643 IEEE80211_CCK_RATE_11MB_MASK)
0644
0645 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
0646 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
0647 IEEE80211_OFDM_RATE_12MB_MASK | \
0648 IEEE80211_OFDM_RATE_24MB_MASK)
0649 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
0650 IEEE80211_OFDM_RATE_9MB_MASK | \
0651 IEEE80211_OFDM_RATE_18MB_MASK | \
0652 IEEE80211_OFDM_RATE_36MB_MASK | \
0653 IEEE80211_OFDM_RATE_48MB_MASK | \
0654 IEEE80211_OFDM_RATE_54MB_MASK)
0655 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
0656 IEEE80211_CCK_DEFAULT_RATES_MASK)
0657
0658 #define IEEE80211_NUM_OFDM_RATES 8
0659 #define IEEE80211_NUM_CCK_RATES 4
0660 #define IEEE80211_OFDM_SHIFT_MASK_A 4
0661
0662
0663
0664 #define IEEE80211_FC0_TYPE_MASK 0x0c
0665 #define IEEE80211_FC0_TYPE_DATA 0x08
0666 #define IEEE80211_FC0_SUBTYPE_MASK 0xB0
0667 #define IEEE80211_FC0_SUBTYPE_QOS 0x80
0668
0669 #define IEEE80211_QOS_HAS_SEQ(fc) \
0670 (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
0671 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
0672
0673
0674 #define IEEE_IBSS_MAC_HASH_SIZE 31
0675 struct ieee_ibss_seq {
0676 u8 mac[ETH_ALEN];
0677 u16 seq_num[17];
0678 u16 frag_num[17];
0679 unsigned long packet_time[17];
0680 struct list_head list;
0681 };
0682
0683
0684
0685
0686
0687 struct ieee80211_rx_stats {
0688 u32 mac_time[2];
0689 s8 rssi;
0690 u8 signal;
0691 u8 noise;
0692 u16 rate;
0693 u8 received_channel;
0694 u8 control;
0695 u8 mask;
0696 u8 freq;
0697 u16 len;
0698 u64 tsf;
0699 u32 beacon_time;
0700 u8 nic_type;
0701 u16 Length;
0702
0703 u8 SignalQuality;
0704 s32 RecvSignalPower;
0705 s8 RxPower;
0706 u8 SignalStrength;
0707 u16 bHwError:1;
0708 u16 bCRC:1;
0709 u16 bICV:1;
0710 u16 bShortPreamble:1;
0711 u16 Antenna:1;
0712 u16 Decrypted:1;
0713 u16 Wakeup:1;
0714 u16 Reserved0:1;
0715 u8 AGC;
0716 u32 TimeStampLow;
0717 u32 TimeStampHigh;
0718 bool bShift;
0719 bool bIsQosData;
0720 u8 UserPriority;
0721
0722
0723
0724
0725
0726 u8 RxDrvInfoSize;
0727 u8 RxBufShift;
0728 bool bIsAMPDU;
0729 bool bFirstMPDU;
0730 bool bContainHTC;
0731 bool RxIs40MHzPacket;
0732 u32 RxPWDBAll;
0733 u8 RxMIMOSignalStrength[4];
0734 s8 RxMIMOSignalQuality[2];
0735 bool bPacketMatchBSSID;
0736 bool bIsCCK;
0737 bool bPacketToSelf;
0738
0739 u8 *virtual_address;
0740 u16 packetlength;
0741 u16 fraglength;
0742 u16 fragoffset;
0743 u16 ntotalfrag;
0744 bool bisrxaggrsubframe;
0745 bool bPacketBeacon;
0746 bool bToSelfBA;
0747 s8 cck_adc_pwdb[4];
0748 u16 Seq_Num;
0749
0750 };
0751
0752
0753
0754
0755
0756
0757 #define IEEE80211_FRAG_CACHE_LEN 4
0758
0759 struct ieee80211_frag_entry {
0760 unsigned long first_frag_time;
0761 unsigned int seq;
0762 unsigned int last_frag;
0763 struct sk_buff *skb;
0764 u8 src_addr[ETH_ALEN];
0765 u8 dst_addr[ETH_ALEN];
0766 };
0767
0768 struct ieee80211_stats {
0769 unsigned int tx_unicast_frames;
0770 unsigned int tx_multicast_frames;
0771 unsigned int tx_fragments;
0772 unsigned int tx_unicast_octets;
0773 unsigned int tx_multicast_octets;
0774 unsigned int tx_deferred_transmissions;
0775 unsigned int tx_single_retry_frames;
0776 unsigned int tx_multiple_retry_frames;
0777 unsigned int tx_retry_limit_exceeded;
0778 unsigned int tx_discards;
0779 unsigned int rx_unicast_frames;
0780 unsigned int rx_multicast_frames;
0781 unsigned int rx_fragments;
0782 unsigned int rx_unicast_octets;
0783 unsigned int rx_multicast_octets;
0784 unsigned int rx_fcs_errors;
0785 unsigned int rx_discards_no_buffer;
0786 unsigned int tx_discards_wrong_sa;
0787 unsigned int rx_discards_undecryptable;
0788 unsigned int rx_message_in_msg_fragments;
0789 unsigned int rx_message_in_bad_msg_fragments;
0790 };
0791
0792 struct ieee80211_device;
0793
0794 #include "ieee80211_crypt.h"
0795
0796 #define SEC_KEY_1 (1<<0)
0797 #define SEC_KEY_2 (1<<1)
0798 #define SEC_KEY_3 (1<<2)
0799 #define SEC_KEY_4 (1<<3)
0800 #define SEC_ACTIVE_KEY (1<<4)
0801 #define SEC_AUTH_MODE (1<<5)
0802 #define SEC_UNICAST_GROUP (1<<6)
0803 #define SEC_LEVEL (1<<7)
0804 #define SEC_ENABLED (1<<8)
0805 #define SEC_ENCRYPT (1<<9)
0806
0807 #define SEC_LEVEL_0 0
0808 #define SEC_LEVEL_1 1
0809 #define SEC_LEVEL_2 2
0810 #define SEC_LEVEL_2_CKIP 3
0811 #define SEC_LEVEL_3 4
0812
0813 #define SEC_ALG_NONE 0
0814 #define SEC_ALG_WEP 1
0815 #define SEC_ALG_TKIP 2
0816 #define SEC_ALG_CCMP 3
0817
0818 #define WEP_KEYS 4
0819 #define WEP_KEY_LEN 13
0820 #define SCM_KEY_LEN 32
0821 #define SCM_TEMPORAL_KEY_LENGTH 16
0822
0823 struct ieee80211_security {
0824 u16 active_key:2,
0825 enabled:1,
0826 auth_algo:4,
0827 unicast_uses_group:1,
0828 encrypt:1;
0829 u8 auth_mode;
0830 u8 key_sizes[WEP_KEYS];
0831 u8 keys[WEP_KEYS][SCM_KEY_LEN];
0832 u8 level;
0833 u16 flags;
0834 } __packed;
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849 enum ieee80211_mfie {
0850 MFIE_TYPE_SSID = 0,
0851 MFIE_TYPE_RATES = 1,
0852 MFIE_TYPE_FH_SET = 2,
0853 MFIE_TYPE_DS_SET = 3,
0854 MFIE_TYPE_CF_SET = 4,
0855 MFIE_TYPE_TIM = 5,
0856 MFIE_TYPE_IBSS_SET = 6,
0857 MFIE_TYPE_COUNTRY = 7,
0858 MFIE_TYPE_HOP_PARAMS = 8,
0859 MFIE_TYPE_HOP_TABLE = 9,
0860 MFIE_TYPE_REQUEST = 10,
0861 MFIE_TYPE_CHALLENGE = 16,
0862 MFIE_TYPE_POWER_CONSTRAINT = 32,
0863 MFIE_TYPE_POWER_CAPABILITY = 33,
0864 MFIE_TYPE_TPC_REQUEST = 34,
0865 MFIE_TYPE_TPC_REPORT = 35,
0866 MFIE_TYPE_SUPP_CHANNELS = 36,
0867 MFIE_TYPE_CSA = 37,
0868 MFIE_TYPE_MEASURE_REQUEST = 38,
0869 MFIE_TYPE_MEASURE_REPORT = 39,
0870 MFIE_TYPE_QUIET = 40,
0871 MFIE_TYPE_IBSS_DFS = 41,
0872 MFIE_TYPE_ERP = 42,
0873 MFIE_TYPE_RSN = 48,
0874 MFIE_TYPE_RATES_EX = 50,
0875 MFIE_TYPE_HT_CAP = 45,
0876 MFIE_TYPE_HT_INFO = 61,
0877 MFIE_TYPE_AIRONET = 133,
0878 MFIE_TYPE_GENERIC = 221,
0879 MFIE_TYPE_QOS_PARAMETER = 222,
0880 };
0881
0882
0883
0884
0885
0886 struct rtl_80211_hdr {
0887 __le16 frame_ctl;
0888 __le16 duration_id;
0889 u8 payload[];
0890 } __packed;
0891
0892 struct rtl_80211_hdr_1addr {
0893 __le16 frame_ctl;
0894 __le16 duration_id;
0895 u8 addr1[ETH_ALEN];
0896 u8 payload[];
0897 } __packed;
0898
0899 struct rtl_80211_hdr_2addr {
0900 __le16 frame_ctl;
0901 __le16 duration_id;
0902 u8 addr1[ETH_ALEN];
0903 u8 addr2[ETH_ALEN];
0904 u8 payload[];
0905 } __packed;
0906
0907 struct rtl_80211_hdr_3addr {
0908 __le16 frame_ctl;
0909 __le16 duration_id;
0910 u8 addr1[ETH_ALEN];
0911 u8 addr2[ETH_ALEN];
0912 u8 addr3[ETH_ALEN];
0913 __le16 seq_ctl;
0914 u8 payload[];
0915 } __packed;
0916
0917 struct rtl_80211_hdr_4addr {
0918 __le16 frame_ctl;
0919 __le16 duration_id;
0920 u8 addr1[ETH_ALEN];
0921 u8 addr2[ETH_ALEN];
0922 u8 addr3[ETH_ALEN];
0923 __le16 seq_ctl;
0924 u8 addr4[ETH_ALEN];
0925 u8 payload[];
0926 } __packed;
0927
0928 struct rtl_80211_hdr_3addrqos {
0929 __le16 frame_ctl;
0930 __le16 duration_id;
0931 u8 addr1[ETH_ALEN];
0932 u8 addr2[ETH_ALEN];
0933 u8 addr3[ETH_ALEN];
0934 __le16 seq_ctl;
0935 u8 payload[0];
0936 __le16 qos_ctl;
0937 } __packed;
0938
0939 struct rtl_80211_hdr_4addrqos {
0940 __le16 frame_ctl;
0941 __le16 duration_id;
0942 u8 addr1[ETH_ALEN];
0943 u8 addr2[ETH_ALEN];
0944 u8 addr3[ETH_ALEN];
0945 __le16 seq_ctl;
0946 u8 addr4[ETH_ALEN];
0947 u8 payload[0];
0948 __le16 qos_ctl;
0949 } __packed;
0950
0951 struct ieee80211_info_element {
0952 u8 id;
0953 u8 len;
0954 u8 data[];
0955 } __packed;
0956
0957 struct ieee80211_authentication {
0958 struct rtl_80211_hdr_3addr header;
0959 __le16 algorithm;
0960 __le16 transaction;
0961 __le16 status;
0962
0963 struct ieee80211_info_element info_element[];
0964 } __packed;
0965
0966 struct ieee80211_disassoc {
0967 struct rtl_80211_hdr_3addr header;
0968 __le16 reason;
0969 } __packed;
0970
0971 struct ieee80211_probe_request {
0972 struct rtl_80211_hdr_3addr header;
0973
0974 struct ieee80211_info_element info_element[];
0975 } __packed;
0976
0977 struct ieee80211_probe_response {
0978 struct rtl_80211_hdr_3addr header;
0979 __le32 time_stamp[2];
0980 __le16 beacon_interval;
0981 __le16 capability;
0982
0983
0984
0985 struct ieee80211_info_element info_element[];
0986 } __packed;
0987
0988
0989 #define ieee80211_beacon ieee80211_probe_response
0990
0991 struct ieee80211_assoc_request_frame {
0992 struct rtl_80211_hdr_3addr header;
0993 __le16 capability;
0994 __le16 listen_interval;
0995
0996 struct ieee80211_info_element info_element[];
0997 } __packed;
0998
0999 struct ieee80211_reassoc_request_frame {
1000 struct rtl_80211_hdr_3addr header;
1001 __le16 capability;
1002 __le16 listen_interval;
1003 u8 current_ap[ETH_ALEN];
1004
1005 struct ieee80211_info_element info_element[];
1006 } __packed;
1007
1008 struct ieee80211_assoc_response_frame {
1009 struct rtl_80211_hdr_3addr header;
1010 __le16 capability;
1011 __le16 status;
1012 __le16 aid;
1013 struct ieee80211_info_element info_element[];
1014 } __packed;
1015
1016 struct ieee80211_txb {
1017 u8 nr_frags;
1018 u8 encrypted;
1019 u8 queue_index;
1020 u8 rts_included;
1021 u16 reserved;
1022 __le16 frag_size;
1023 __le16 payload_size;
1024 struct sk_buff *fragments[];
1025 };
1026
1027 #define MAX_TX_AGG_COUNT 16
1028 struct ieee80211_drv_agg_txb {
1029 u8 nr_drv_agg_frames;
1030 struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
1031 } __packed;
1032
1033 #define MAX_SUBFRAME_COUNT 64
1034 struct ieee80211_rxb {
1035 u8 nr_subframes;
1036 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
1037 u8 dst[ETH_ALEN];
1038 u8 src[ETH_ALEN];
1039 } __packed;
1040
1041 typedef union _frameqos {
1042 u16 shortdata;
1043 u8 chardata[2];
1044 struct {
1045 u16 tid:4;
1046 u16 eosp:1;
1047 u16 ack_policy:2;
1048 u16 reserved:1;
1049 u16 txop:8;
1050 } field;
1051 } frameqos, *pframeqos;
1052
1053
1054 #define MAX_SWEEP_TAB_ENTRIES 42
1055 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
1056
1057
1058
1059
1060
1061 #define MAX_RATES_LENGTH ((u8)12)
1062 #define MAX_RATES_EX_LENGTH ((u8)16)
1063 #define MAX_NETWORK_COUNT 128
1064
1065 #define MAX_CHANNEL_NUMBER 161
1066 #define IEEE80211_SOFTMAC_SCAN_TIME 100
1067
1068 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1069
1070 #define CRC_LENGTH 4U
1071
1072 #define MAX_WPA_IE_LEN 64
1073
1074 #define NETWORK_EMPTY_ESSID (1<<0)
1075 #define NETWORK_HAS_OFDM (1<<1)
1076 #define NETWORK_HAS_CCK (1<<2)
1077
1078
1079 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1080 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
1081 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1082 NETWORK_HAS_QOS_INFORMATION)
1083
1084 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
1085 #define NETWORK_HAS_CSA (1<<6)
1086 #define NETWORK_HAS_QUIET (1<<7)
1087 #define NETWORK_HAS_IBSS_DFS (1<<8)
1088 #define NETWORK_HAS_TPC_REPORT (1<<9)
1089
1090 #define NETWORK_HAS_ERP_VALUE (1<<10)
1091
1092 #define QOS_QUEUE_NUM 4
1093 #define QOS_OUI_LEN 3
1094 #define QOS_OUI_TYPE 2
1095 #define QOS_ELEMENT_ID 221
1096 #define QOS_OUI_INFO_SUB_TYPE 0
1097 #define QOS_OUI_PARAM_SUB_TYPE 1
1098 #define QOS_VERSION_1 1
1099 #define QOS_AIFSN_MIN_VALUE 2
1100 struct ieee80211_qos_information_element {
1101 u8 elementID;
1102 u8 length;
1103 u8 qui[QOS_OUI_LEN];
1104 u8 qui_type;
1105 u8 qui_subtype;
1106 u8 version;
1107 u8 ac_info;
1108 } __packed;
1109
1110 struct ieee80211_qos_ac_parameter {
1111 u8 aci_aifsn;
1112 u8 ecw_min_max;
1113 __le16 tx_op_limit;
1114 } __packed;
1115
1116 struct ieee80211_qos_parameter_info {
1117 struct ieee80211_qos_information_element info_element;
1118 u8 reserved;
1119 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1120 } __packed;
1121
1122 struct ieee80211_qos_parameters {
1123 __le16 cw_min[QOS_QUEUE_NUM];
1124 __le16 cw_max[QOS_QUEUE_NUM];
1125 u8 aifs[QOS_QUEUE_NUM];
1126 u8 flag[QOS_QUEUE_NUM];
1127 __le16 tx_op_limit[QOS_QUEUE_NUM];
1128 } __packed;
1129
1130 struct ieee80211_qos_data {
1131 struct ieee80211_qos_parameters parameters;
1132 int active;
1133 int supported;
1134 u8 param_count;
1135 u8 old_param_count;
1136 };
1137
1138 struct ieee80211_tim_parameters {
1139 u8 tim_count;
1140 u8 tim_period;
1141 } __packed;
1142
1143
1144 struct ieee80211_wmm_ts_info {
1145 u8 ac_dir_tid;
1146 u8 ac_up_psb;
1147 u8 reserved;
1148 } __packed;
1149
1150 struct ieee80211_wmm_tspec_elem {
1151 struct ieee80211_wmm_ts_info ts_info;
1152 u16 norm_msdu_size;
1153 u16 max_msdu_size;
1154 u32 min_serv_inter;
1155 u32 max_serv_inter;
1156 u32 inact_inter;
1157 u32 suspen_inter;
1158 u32 serv_start_time;
1159 u32 min_data_rate;
1160 u32 mean_data_rate;
1161 u32 peak_data_rate;
1162 u32 max_burst_size;
1163 u32 delay_bound;
1164 u32 min_phy_rate;
1165 u16 surp_band_allow;
1166 u16 medium_time;
1167 } __packed;
1168 enum eap_type {
1169 EAP_PACKET = 0,
1170 EAPOL_START,
1171 EAPOL_LOGOFF,
1172 EAPOL_KEY,
1173 EAPOL_ENCAP_ASF_ALERT
1174 };
1175
1176 static const char *eap_types[] = {
1177 [EAP_PACKET] = "EAP-Packet",
1178 [EAPOL_START] = "EAPOL-Start",
1179 [EAPOL_LOGOFF] = "EAPOL-Logoff",
1180 [EAPOL_KEY] = "EAPOL-Key",
1181 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1182 };
1183
1184 static inline const char *eap_get_type(int type)
1185 {
1186 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
1187 }
1188
1189 static inline u8 Frame_QoSTID(u8 *buf)
1190 {
1191 struct rtl_80211_hdr_3addr *hdr;
1192 u16 fc;
1193 hdr = (struct rtl_80211_hdr_3addr *)buf;
1194 fc = le16_to_cpu(hdr->frame_ctl);
1195 return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) && (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
1196 }
1197
1198
1199
1200 struct eapol {
1201 u8 snap[6];
1202 u16 ethertype;
1203 u8 version;
1204 u8 type;
1205 u16 length;
1206 } __packed;
1207
1208 struct ieee80211_softmac_stats {
1209 unsigned int rx_ass_ok;
1210 unsigned int rx_ass_err;
1211 unsigned int rx_probe_rq;
1212 unsigned int tx_probe_rs;
1213 unsigned int tx_beacons;
1214 unsigned int rx_auth_rq;
1215 unsigned int rx_auth_rs_ok;
1216 unsigned int rx_auth_rs_err;
1217 unsigned int tx_auth_rq;
1218 unsigned int no_auth_rs;
1219 unsigned int no_ass_rs;
1220 unsigned int tx_ass_rq;
1221 unsigned int rx_ass_rq;
1222 unsigned int tx_probe_rq;
1223 unsigned int reassoc;
1224 unsigned int swtxstop;
1225 unsigned int swtxawake;
1226 unsigned char CurrentShowTxate;
1227 unsigned char last_packet_rate;
1228 unsigned int txretrycount;
1229 };
1230
1231 #define BEACON_PROBE_SSID_ID_POSITION 12
1232
1233 struct ieee80211_info_element_hdr {
1234 u8 id;
1235 u8 len;
1236 } __packed;
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
1256 #define IEEE80211_DEFAULT_BASIC_RATE 2
1257
1258 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1259 #define MAX_SP_Len (WMM_all_frame << 4)
1260 #define IEEE80211_QOS_TID 0x0f
1261 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1262
1263 #define IEEE80211_DTIM_MBCAST 4
1264 #define IEEE80211_DTIM_UCAST 2
1265 #define IEEE80211_DTIM_VALID 1
1266 #define IEEE80211_DTIM_INVALID 0
1267
1268 #define IEEE80211_PS_DISABLED 0
1269 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
1270 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
1271
1272
1273
1274 #ifdef WMM_Hang_8187
1275 #undef WMM_Hang_8187
1276 #endif
1277
1278 #define WME_AC_BK 0x00
1279 #define WME_AC_BE 0x01
1280 #define WME_AC_VI 0x02
1281 #define WME_AC_VO 0x03
1282 #define WME_ACI_MASK 0x03
1283 #define WME_AIFSN_MASK 0x03
1284 #define WME_AC_PRAM_LEN 16
1285
1286 #define MAX_RECEIVE_BUFFER_SIZE 9100
1287
1288
1289
1290 #define UP2AC(up) ( \
1291 ((up) < 1) ? WME_AC_BE : \
1292 ((up) < 3) ? WME_AC_BK : \
1293 ((up) < 4) ? WME_AC_BE : \
1294 ((up) < 6) ? WME_AC_VI : \
1295 WME_AC_VO)
1296
1297 #define AC2UP(_ac) ( \
1298 ((_ac) == WME_AC_VO) ? 6 : \
1299 ((_ac) == WME_AC_VI) ? 5 : \
1300 ((_ac) == WME_AC_BK) ? 1 : \
1301 0)
1302
1303 #define ETHER_ADDR_LEN 6
1304 #define ETHERNET_HEADER_SIZE 14
1305
1306 struct ether_header {
1307 u8 ether_dhost[ETHER_ADDR_LEN];
1308 u8 ether_shost[ETHER_ADDR_LEN];
1309 u16 ether_type;
1310 } __packed;
1311
1312 #ifndef ETHERTYPE_PAE
1313 #define ETHERTYPE_PAE 0x888e
1314 #endif
1315 #ifndef ETHERTYPE_IP
1316 #define ETHERTYPE_IP 0x0800
1317 #endif
1318
1319 typedef enum _erp_t {
1320 ERP_NonERPpresent = 0x01,
1321 ERP_UseProtection = 0x02,
1322 ERP_BarkerPreambleMode = 0x04,
1323 } erp_t;
1324
1325
1326 struct ieee80211_network {
1327
1328 u8 bssid[ETH_ALEN];
1329 u8 channel;
1330
1331
1332 bool bMBssidValid;
1333 u8 MBssid[ETH_ALEN];
1334 u8 MBssidMask;
1335
1336 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1337 u8 ssid_len;
1338 struct ieee80211_qos_data qos_data;
1339
1340
1341 bool bWithAironetIE;
1342 bool bCkipSupported;
1343 bool bCcxRmEnable;
1344 u16 CcxRmState[2];
1345
1346 bool bWithCcxVerNum;
1347 u8 BssCcxVerNumber;
1348
1349 struct ieee80211_rx_stats stats;
1350 u16 capability;
1351 u8 rates[MAX_RATES_LENGTH];
1352 u8 rates_len;
1353 u8 rates_ex[MAX_RATES_EX_LENGTH];
1354 u8 rates_ex_len;
1355 unsigned long last_scanned;
1356 u8 mode;
1357 u32 flags;
1358 u32 last_associate;
1359 u32 time_stamp[2];
1360 u16 beacon_interval;
1361 u16 listen_interval;
1362 u16 atim_window;
1363 u8 erp_value;
1364 u8 wpa_ie[MAX_WPA_IE_LEN];
1365 size_t wpa_ie_len;
1366 u8 rsn_ie[MAX_WPA_IE_LEN];
1367 size_t rsn_ie_len;
1368
1369 struct ieee80211_tim_parameters tim;
1370 u8 dtim_period;
1371 u8 dtim_data;
1372 u32 last_dtim_sta_time[2];
1373
1374
1375 u8 wmm_info;
1376 struct ieee80211_wmm_ac_param wmm_param[4];
1377 u8 QoS_Enable;
1378 #ifdef THOMAS_TURBO
1379 u8 Turbo_Enable;
1380 #endif
1381 u16 CountryIeLen;
1382 u8 CountryIeBuf[MAX_IE_LEN];
1383
1384 BSS_HT bssht;
1385
1386 bool broadcom_cap_exist;
1387 bool ralink_cap_exist;
1388 bool atheros_cap_exist;
1389 bool cisco_cap_exist;
1390 bool unknown_cap_exist;
1391
1392 bool berp_info_valid;
1393 bool buseprotection;
1394
1395 struct list_head list;
1396 };
1397
1398 enum ieee80211_state {
1399
1400
1401 IEEE80211_NOLINK = 0,
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412 IEEE80211_ASSOCIATING,
1413 IEEE80211_ASSOCIATING_RETRY,
1414
1415
1416 IEEE80211_ASSOCIATING_AUTHENTICATING,
1417
1418
1419
1420
1421 IEEE80211_ASSOCIATING_AUTHENTICATED,
1422
1423
1424
1425
1426 IEEE80211_LINKED,
1427
1428
1429
1430
1431
1432
1433 IEEE80211_LINKED_SCANNING,
1434
1435 };
1436
1437 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1438 #define DEFAULT_FTS 2346
1439
1440 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
1441 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1442 #define CFG_IEEE80211_RTS (1<<2)
1443
1444 #define IEEE80211_24GHZ_MIN_CHANNEL 1
1445 #define IEEE80211_24GHZ_MAX_CHANNEL 14
1446 #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
1447 IEEE80211_24GHZ_MIN_CHANNEL + 1)
1448
1449 #define IEEE80211_52GHZ_MIN_CHANNEL 34
1450 #define IEEE80211_52GHZ_MAX_CHANNEL 165
1451 #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
1452 IEEE80211_52GHZ_MIN_CHANNEL + 1)
1453
1454
1455
1456 struct tx_pending {
1457 int frag;
1458 struct ieee80211_txb *txb;
1459 };
1460
1461 struct bandwidth_autoswitch {
1462 long threshold_20Mhzto40Mhz;
1463 long threshold_40Mhzto20Mhz;
1464 bool bforced_tx20Mhz;
1465 bool bautoswitch_enable;
1466 };
1467
1468
1469
1470
1471 #define REORDER_WIN_SIZE 128
1472 #define REORDER_ENTRY_NUM 128
1473 struct rx_reorder_entry {
1474 struct list_head List;
1475 u16 SeqNum;
1476 struct ieee80211_rxb *prxb;
1477 };
1478
1479 typedef enum _Fsync_State {
1480 Default_Fsync,
1481 HW_Fsync,
1482 SW_Fsync
1483 } Fsync_State;
1484
1485
1486 typedef enum _RT_PS_MODE {
1487 eActive,
1488 eMaxPs,
1489 eFastPs
1490 } RT_PS_MODE;
1491
1492 typedef enum _IPS_CALLBACK_FUNCION {
1493 IPS_CALLBACK_NONE = 0,
1494 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1495 IPS_CALLBACK_JOIN_REQUEST = 2,
1496 } IPS_CALLBACK_FUNCION;
1497
1498 typedef enum _RT_JOIN_ACTION {
1499 RT_JOIN_INFRA = 1,
1500 RT_JOIN_IBSS = 2,
1501 RT_START_IBSS = 3,
1502 RT_NO_ACTION = 4,
1503 } RT_JOIN_ACTION;
1504
1505 struct ibss_parms {
1506 u16 atimWin;
1507 };
1508 #define MAX_NUM_RATES 264
1509
1510
1511 typedef enum _RT_RF_POWER_STATE {
1512 eRfOn,
1513 eRfSleep,
1514 eRfOff
1515 } RT_RF_POWER_STATE;
1516
1517 struct rt_power_save_control {
1518
1519
1520
1521
1522 bool bInactivePs;
1523 bool bIPSModeBackup;
1524 bool bSwRfProcessing;
1525 RT_RF_POWER_STATE eInactivePowerState;
1526 struct work_struct InactivePsWorkItem;
1527 struct timer_list InactivePsTimer;
1528
1529
1530 IPS_CALLBACK_FUNCION ReturnPoint;
1531
1532
1533 bool bTmpBssDesc;
1534 RT_JOIN_ACTION tmpJoinAction;
1535 struct ieee80211_network tmpBssDesc;
1536
1537
1538 bool bTmpScanOnly;
1539 bool bTmpActiveScan;
1540 bool bTmpFilterHiddenAP;
1541 bool bTmpUpdateParms;
1542 u8 tmpSsidBuf[33];
1543 struct octet_string tmpSsid2Scan;
1544 bool bTmpSsid2Scan;
1545 u8 tmpNetworkType;
1546 u8 tmpChannelNumber;
1547 u16 tmpBcnPeriod;
1548 u8 tmpDtimPeriod;
1549 u16 tmpmCap;
1550 struct octet_string tmpSuppRateSet;
1551 u8 tmpSuppRateBuf[MAX_NUM_RATES];
1552 bool bTmpSuppRate;
1553 struct ibss_parms tmpIbpm;
1554 bool bTmpIbpm;
1555
1556
1557
1558
1559 bool bLeisurePs;
1560
1561 };
1562
1563 typedef u32 RT_RF_CHANGE_SOURCE;
1564 #define RF_CHANGE_BY_SW BIT(31)
1565 #define RF_CHANGE_BY_HW BIT(30)
1566 #define RF_CHANGE_BY_PS BIT(29)
1567 #define RF_CHANGE_BY_IPS BIT(28)
1568 #define RF_CHANGE_BY_INIT 0
1569
1570 typedef enum {
1571 COUNTRY_CODE_FCC = 0,
1572 COUNTRY_CODE_IC = 1,
1573 COUNTRY_CODE_ETSI = 2,
1574 COUNTRY_CODE_SPAIN = 3,
1575 COUNTRY_CODE_FRANCE = 4,
1576 COUNTRY_CODE_MKK = 5,
1577 COUNTRY_CODE_MKK1 = 6,
1578 COUNTRY_CODE_ISRAEL = 7,
1579 COUNTRY_CODE_TELEC,
1580 COUNTRY_CODE_MIC,
1581 COUNTRY_CODE_GLOBAL_DOMAIN
1582 } country_code_type_t;
1583
1584 #define RT_MAX_LD_SLOT_NUM 10
1585 struct rt_link_detect {
1586
1587 u32 NumRecvBcnInPeriod;
1588 u32 NumRecvDataInPeriod;
1589
1590 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
1591 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
1592 u16 SlotNum;
1593 u16 SlotIndex;
1594
1595 u32 NumTxOkInPeriod;
1596 u32 NumRxOkInPeriod;
1597 bool bBusyTraffic;
1598 };
1599
1600
1601 struct ieee80211_device {
1602 struct net_device *dev;
1603 struct ieee80211_security sec;
1604
1605
1606
1607 u8 hwsec_active;
1608 bool is_silent_reset;
1609 bool ieee_up;
1610
1611 bool bSupportRemoteWakeUp;
1612 RT_PS_MODE dot11PowerSaveMode;
1613 bool actscanning;
1614 bool beinretry;
1615 RT_RF_POWER_STATE eRFPowerState;
1616 RT_RF_CHANGE_SOURCE RfOffReason;
1617 bool is_set_key;
1618
1619
1620
1621 PRT_HIGH_THROUGHPUT pHTInfo;
1622
1623
1624 spinlock_t bw_spinlock;
1625
1626 spinlock_t reorder_spinlock;
1627
1628
1629 u8 Regdot11HTOperationalRateSet[16];
1630 u8 dot11HTOperationalRateSet[16];
1631 u8 RegHTSuppRateSet[16];
1632 u8 HTCurrentOperaRate;
1633 u8 HTHighestOperaRate;
1634
1635 u8 bTxDisableRateFallBack;
1636 u8 bTxUseDriverAssingedRate;
1637 atomic_t atm_chnlop;
1638 atomic_t atm_swbw;
1639
1640
1641
1642
1643 struct list_head Tx_TS_Admit_List;
1644 struct list_head Tx_TS_Pending_List;
1645 struct list_head Tx_TS_Unused_List;
1646 struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
1647
1648 struct list_head Rx_TS_Admit_List;
1649 struct list_head Rx_TS_Pending_List;
1650 struct list_head Rx_TS_Unused_List;
1651 struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
1652 struct rx_reorder_entry RxReorderEntry[128];
1653 struct list_head RxReorder_Unused_List;
1654
1655
1656 u8 ForcedPriority;
1657
1658
1659
1660 struct net_device_stats stats;
1661 struct ieee80211_stats ieee_stats;
1662 struct ieee80211_softmac_stats softmac_stats;
1663
1664
1665 struct list_head network_free_list;
1666 struct list_head network_list;
1667 struct ieee80211_network *networks;
1668 int scans;
1669 int scan_age;
1670
1671 int iw_mode;
1672 struct iw_spy_data spy_data;
1673
1674 spinlock_t lock;
1675 spinlock_t wpax_suitlist_lock;
1676
1677 int tx_headroom;
1678
1679
1680 u32 config;
1681
1682
1683 int open_wep;
1684 int auth_mode;
1685 int reset_on_keychange;
1686
1687
1688
1689
1690 int host_encrypt;
1691 int host_encrypt_msdu;
1692 int host_decrypt;
1693
1694 int host_mc_decrypt;
1695
1696
1697
1698 int host_strip_iv_icv;
1699
1700 int host_open_frag;
1701 int host_build_iv;
1702 int ieee802_1x;
1703
1704
1705 bool bHalfWirelessN24GMode;
1706 int wpa_enabled;
1707 int drop_unencrypted;
1708 int tkip_countermeasures;
1709 int privacy_invoked;
1710 size_t wpa_ie_len;
1711 u8 *wpa_ie;
1712 u8 ap_mac_addr[6];
1713 u16 pairwise_key_type;
1714 u16 group_key_type;
1715 struct list_head crypt_deinit_list;
1716 struct ieee80211_crypt_data *crypt[WEP_KEYS];
1717 int tx_keyidx;
1718 struct timer_list crypt_deinit_timer;
1719 int crypt_quiesced;
1720
1721 int bcrx_sta_key;
1722
1723
1724
1725
1726
1727 struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
1728 unsigned int frag_next_idx[17];
1729 u16 fts;
1730 #define DEFAULT_RTS_THRESHOLD 2346U
1731 #define MIN_RTS_THRESHOLD 1
1732 #define MAX_RTS_THRESHOLD 2346U
1733 u16 rts;
1734
1735
1736 u8 bssid[ETH_ALEN];
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746 struct ieee80211_network current_network;
1747
1748 enum ieee80211_state state;
1749
1750 int short_slot;
1751 int reg_mode;
1752 int mode;
1753 int modulation;
1754 int freq_band;
1755 int abg_true;
1756
1757
1758
1759
1760 short sync_scan_hurryup;
1761
1762 int perfect_rssi;
1763 int worst_rssi;
1764
1765 u16 prev_seq_ctl;
1766
1767
1768
1769 void *dot11d_info;
1770 bool bGlobalDomain;
1771 int rate;
1772 int basic_rate;
1773
1774 short active_scan;
1775
1776
1777 u16 softmac_features;
1778
1779
1780 u16 seq_ctrl[5];
1781
1782
1783 u16 associate_seq;
1784
1785
1786 u16 assoc_id;
1787
1788
1789 short ps;
1790 short sta_sleep;
1791 int ps_timeout;
1792 int ps_period;
1793 struct work_struct ps_task;
1794 u32 ps_th;
1795 u32 ps_tl;
1796
1797 short raw_tx;
1798
1799 short queue_stop;
1800 short scanning;
1801 short proto_started;
1802
1803 struct mutex wx_mutex;
1804 struct mutex scan_mutex;
1805
1806 spinlock_t mgmt_tx_lock;
1807 spinlock_t beacon_lock;
1808
1809 short beacon_txing;
1810
1811 short wap_set;
1812 short ssid_set;
1813
1814 u8 wpax_type_set;
1815 u32 wpax_type_notify;
1816
1817
1818 s8 init_wmmparam_flag;
1819
1820 u8 qos_support;
1821
1822
1823 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1824
1825
1826 u16 last_rxseq_num[17];
1827 u16 last_rxfrag_num[17];
1828 unsigned long last_packet_time[17];
1829
1830
1831 unsigned long last_rx_ps_time;
1832
1833
1834 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1835 int mgmt_queue_head;
1836 int mgmt_queue_tail;
1837
1838 #define IEEE80211_QUEUE_LIMIT 128
1839 u8 AsocRetryCount;
1840 unsigned int hw_header;
1841 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1842 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
1843 struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
1844 u32 sta_edca_param[4];
1845 bool aggregation;
1846
1847 bool enable_rx_imm_BA;
1848 bool bibsscoordinator;
1849
1850
1851
1852 bool bdynamic_txpower_enable;
1853
1854 bool bCTSToSelfEnable;
1855 u8 CTSToSelfTH;
1856
1857 u32 fsync_time_interval;
1858 u32 fsync_rate_bitmap;
1859 u8 fsync_rssi_threshold;
1860 bool bfsync_enable;
1861
1862 u8 fsync_multiple_timeinterval;
1863 u32 fsync_firstdiff_ratethreshold;
1864 u32 fsync_seconddiff_ratethreshold;
1865 Fsync_State fsync_state;
1866 bool bis_any_nonbepkts;
1867
1868 struct bandwidth_autoswitch bandwidth_auto_switch;
1869
1870 bool FwRWRF;
1871
1872
1873 struct rt_link_detect LinkDetectInfo;
1874
1875 struct rt_power_save_control PowerSaveControl;
1876
1877
1878 struct tx_pending tx_pending;
1879
1880
1881 struct timer_list associate_timer;
1882
1883
1884 struct timer_list beacon_timer;
1885 struct work_struct associate_complete_wq;
1886 struct work_struct associate_procedure_wq;
1887 struct delayed_work softmac_scan_wq;
1888 struct delayed_work associate_retry_wq;
1889 struct delayed_work start_ibss_wq;
1890 struct work_struct wx_sync_scan_wq;
1891 struct workqueue_struct *wq;
1892
1893
1894
1895
1896
1897
1898 struct ieee80211_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
1899
1900
1901 void (*set_security)(struct net_device *dev,
1902 struct ieee80211_security *sec);
1903
1904
1905
1906
1907
1908 int (*hard_start_xmit)(struct ieee80211_txb *txb,
1909 struct net_device *dev);
1910
1911 int (*reset_port)(struct net_device *dev);
1912 int (*is_queue_full)(struct net_device *dev, int pri);
1913
1914 int (*handle_management)(struct net_device *dev,
1915 struct ieee80211_network *network, u16 type);
1916 int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
1917
1918
1919
1920
1921
1922
1923
1924
1925 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1926 struct net_device *dev);
1927
1928
1929
1930
1931
1932
1933
1934 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1935 struct net_device *dev, int rate);
1936
1937
1938
1939
1940
1941 void (*data_hard_stop)(struct net_device *dev);
1942
1943
1944 void (*data_hard_resume)(struct net_device *dev);
1945
1946
1947
1948
1949
1950 void (*set_chan)(struct net_device *dev, short ch);
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967 void (*scan_syncro)(struct net_device *dev);
1968 void (*start_scan)(struct net_device *dev);
1969 void (*stop_scan)(struct net_device *dev);
1970
1971
1972
1973
1974
1975
1976 void (*link_change)(struct net_device *dev);
1977
1978
1979
1980
1981
1982
1983
1984 void (*start_send_beacons)(struct net_device *dev, u16 tx_rate);
1985 void (*stop_send_beacons)(struct net_device *dev);
1986
1987
1988 void (*sta_wake_up)(struct net_device *dev);
1989 void (*ps_request_tx_ack)(struct net_device *dev);
1990 void (*enter_sleep_state)(struct net_device *dev, u32 th, u32 tl);
1991 short (*ps_is_queue_empty)(struct net_device *dev);
1992 int (*handle_beacon)(struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network);
1993 int (*handle_assoc_response)(struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network);
1994
1995
1996
1997 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1998
1999
2000 void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset);
2001
2002 bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
2003 void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
2004 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
2005 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
2006
2007
2008
2009
2010 u8 priv[];
2011 };
2012
2013 #define IEEE_A (1<<0)
2014 #define IEEE_B (1<<1)
2015 #define IEEE_G (1<<2)
2016 #define IEEE_N_24G (1<<4)
2017 #define IEEE_N_5G (1<<5)
2018 #define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G)
2019
2020
2021
2022
2023
2024
2025 #define IEEE_SOFTMAC_SCAN (1<<2)
2026
2027
2028 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2029
2030
2031 #define IEEE_SOFTMAC_PROBERQ (1<<4)
2032
2033
2034 #define IEEE_SOFTMAC_PROBERS (1<<5)
2035
2036
2037
2038
2039
2040 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
2041
2042
2043
2044
2045 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2046
2047
2048
2049
2050 #define IEEE_SOFTMAC_BEACONS (1<<6)
2051
2052 static inline void *ieee80211_priv(struct net_device *dev)
2053 {
2054 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
2055 }
2056
2057 static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
2058 {
2059
2060 if (essid_len == 1 && essid[0] == ' ')
2061 return 1;
2062
2063
2064 while (essid_len) {
2065 essid_len--;
2066 if (essid[essid_len] != '\0')
2067 return 0;
2068 }
2069
2070 return 1;
2071 }
2072
2073 static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
2074 {
2075
2076
2077
2078
2079
2080
2081 if ((mode & IEEE_A) &&
2082 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2083 (ieee->freq_band & IEEE80211_52GHZ_BAND))
2084 return 1;
2085
2086 if ((mode & IEEE_G) &&
2087 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2088 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2089 return 1;
2090
2091 if ((mode & IEEE_B) &&
2092 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
2093 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2094 return 1;
2095
2096 return 0;
2097 }
2098
2099 static inline int ieee80211_get_hdrlen(u16 fc)
2100 {
2101 int hdrlen = IEEE80211_3ADDR_LEN;
2102
2103 switch (WLAN_FC_GET_TYPE(fc)) {
2104 case IEEE80211_FTYPE_DATA:
2105 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
2106 hdrlen = IEEE80211_4ADDR_LEN;
2107 if (IEEE80211_QOS_HAS_SEQ(fc))
2108 hdrlen += 2;
2109 break;
2110 case IEEE80211_FTYPE_CTL:
2111 switch (WLAN_FC_GET_STYPE(fc)) {
2112 case IEEE80211_STYPE_CTS:
2113 case IEEE80211_STYPE_ACK:
2114 hdrlen = IEEE80211_1ADDR_LEN;
2115 break;
2116 default:
2117 hdrlen = IEEE80211_2ADDR_LEN;
2118 break;
2119 }
2120 break;
2121 }
2122
2123 return hdrlen;
2124 }
2125
2126 static inline u8 *ieee80211_get_payload(struct rtl_80211_hdr *hdr)
2127 {
2128 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2129 case IEEE80211_1ADDR_LEN:
2130 return ((struct rtl_80211_hdr_1addr *)hdr)->payload;
2131 case IEEE80211_2ADDR_LEN:
2132 return ((struct rtl_80211_hdr_2addr *)hdr)->payload;
2133 case IEEE80211_3ADDR_LEN:
2134 return ((struct rtl_80211_hdr_3addr *)hdr)->payload;
2135 case IEEE80211_4ADDR_LEN:
2136 return ((struct rtl_80211_hdr_4addr *)hdr)->payload;
2137 }
2138 return NULL;
2139 }
2140
2141 static inline int ieee80211_is_ofdm_rate(u8 rate)
2142 {
2143 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2144 case IEEE80211_OFDM_RATE_6MB:
2145 case IEEE80211_OFDM_RATE_9MB:
2146 case IEEE80211_OFDM_RATE_12MB:
2147 case IEEE80211_OFDM_RATE_18MB:
2148 case IEEE80211_OFDM_RATE_24MB:
2149 case IEEE80211_OFDM_RATE_36MB:
2150 case IEEE80211_OFDM_RATE_48MB:
2151 case IEEE80211_OFDM_RATE_54MB:
2152 return 1;
2153 }
2154 return 0;
2155 }
2156
2157 static inline int ieee80211_is_cck_rate(u8 rate)
2158 {
2159 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2160 case IEEE80211_CCK_RATE_1MB:
2161 case IEEE80211_CCK_RATE_2MB:
2162 case IEEE80211_CCK_RATE_5MB:
2163 case IEEE80211_CCK_RATE_11MB:
2164 return 1;
2165 }
2166 return 0;
2167 }
2168
2169
2170
2171 void free_ieee80211(struct net_device *dev);
2172 struct net_device *alloc_ieee80211(int sizeof_priv);
2173
2174 int ieee80211_set_encryption(struct ieee80211_device *ieee);
2175
2176
2177
2178 int ieee80211_encrypt_fragment(struct ieee80211_device *ieee,
2179 struct sk_buff *frag, int hdr_len);
2180
2181 int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
2182 void ieee80211_txb_free(struct ieee80211_txb *txb);
2183
2184
2185
2186 int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
2187 struct ieee80211_rx_stats *rx_stats);
2188 void ieee80211_rx_mgt(struct ieee80211_device *ieee,
2189 struct rtl_80211_hdr_4addr *header,
2190 struct ieee80211_rx_stats *stats);
2191
2192
2193 int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
2194 struct iw_request_info *info,
2195 union iwreq_data *wrqu, char *key);
2196 int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
2197 struct iw_request_info *info,
2198 union iwreq_data *wrqu, char *key);
2199 int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
2200 struct iw_request_info *info,
2201 union iwreq_data *wrqu, char *key);
2202 int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
2203 struct iw_request_info *info,
2204 union iwreq_data *wrqu, char *extra);
2205 int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
2206 struct iw_request_info *info,
2207 union iwreq_data *wrqu, char *extra);
2208 int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
2209 struct iw_request_info *info,
2210 struct iw_param *data, char *extra);
2211 int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
2212 struct iw_request_info *info,
2213 union iwreq_data *wrqu, char *extra);
2214 int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
2215
2216
2217 short ieee80211_is_54g(const struct ieee80211_network *net);
2218 short ieee80211_is_shortslot(const struct ieee80211_network *net);
2219 int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee,
2220 struct sk_buff *skb,
2221 struct ieee80211_rx_stats *rx_stats,
2222 u16 type, u16 stype);
2223 void ieee80211_softmac_new_net(struct ieee80211_device *ieee,
2224 struct ieee80211_network *net);
2225
2226 void SendDisassociation(struct ieee80211_device *ieee, u8 *asSta, u8 asRsn);
2227 void ieee80211_softmac_xmit(struct ieee80211_txb *txb,
2228 struct ieee80211_device *ieee);
2229
2230 void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2231 void notify_wx_assoc_event(struct ieee80211_device *ieee);
2232 void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
2233 void ieee80211_start_bss(struct ieee80211_device *ieee);
2234 void ieee80211_start_master_bss(struct ieee80211_device *ieee);
2235 void ieee80211_start_ibss(struct ieee80211_device *ieee);
2236 void ieee80211_softmac_init(struct ieee80211_device *ieee);
2237 void ieee80211_softmac_free(struct ieee80211_device *ieee);
2238 void ieee80211_associate_abort(struct ieee80211_device *ieee);
2239 void ieee80211_disassociate(struct ieee80211_device *ieee);
2240 void ieee80211_stop_scan(struct ieee80211_device *ieee);
2241 void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
2242 void ieee80211_check_all_nets(struct ieee80211_device *ieee);
2243 void ieee80211_start_protocol(struct ieee80211_device *ieee);
2244 void ieee80211_stop_protocol(struct ieee80211_device *ieee);
2245 void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
2246 void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
2247 void ieee80211_reset_queue(struct ieee80211_device *ieee);
2248 void ieee80211_wake_queue(struct ieee80211_device *ieee);
2249 void ieee80211_stop_queue(struct ieee80211_device *ieee);
2250 struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
2251 void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
2252 int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee,
2253 struct iw_point *p);
2254 void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
2255
2256 void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
2257
2258
2259 void ieee80211_tkip_null(void);
2260
2261 int ieee80211_crypto_init(void);
2262 void ieee80211_crypto_deinit(void);
2263 int ieee80211_crypto_tkip_init(void);
2264 void ieee80211_crypto_tkip_exit(void);
2265 int ieee80211_crypto_ccmp_init(void);
2266 void ieee80211_crypto_ccmp_exit(void);
2267 int ieee80211_crypto_wep_init(void);
2268 void ieee80211_crypto_wep_exit(void);
2269
2270
2271
2272 int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
2273 struct iw_request_info *info,
2274 union iwreq_data *wrqu, char *ext);
2275
2276 int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
2277 struct iw_request_info *info,
2278 union iwreq_data *awrq,
2279 char *extra);
2280
2281 int ieee80211_wx_get_essid(struct ieee80211_device *ieee,
2282 struct iw_request_info *a,
2283 union iwreq_data *wrqu, char *b);
2284
2285 int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
2286 struct iw_request_info *info,
2287 union iwreq_data *wrqu, char *extra);
2288
2289 int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
2290 struct iw_request_info *info,
2291 union iwreq_data *wrqu, char *extra);
2292
2293 int ieee80211_wx_set_mode(struct ieee80211_device *ieee,
2294 struct iw_request_info *a,
2295 union iwreq_data *wrqu, char *b);
2296
2297 int ieee80211_wx_set_scan(struct ieee80211_device *ieee,
2298 struct iw_request_info *a,
2299 union iwreq_data *wrqu, char *b);
2300
2301 int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
2302 struct iw_request_info *a,
2303 union iwreq_data *wrqu, char *extra);
2304
2305 int ieee80211_wx_get_mode(struct ieee80211_device *ieee,
2306 struct iw_request_info *a,
2307 union iwreq_data *wrqu, char *b);
2308
2309 int ieee80211_wx_set_freq(struct ieee80211_device *ieee,
2310 struct iw_request_info *a,
2311 union iwreq_data *wrqu, char *b);
2312
2313 int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
2314 struct iw_request_info *a,
2315 union iwreq_data *wrqu, char *b);
2316
2317
2318 #ifdef CONFIG_IEEE80211_DEBUG
2319 int ieee80211_debug_init(void);
2320 void ieee80211_debug_exit(void);
2321 #else
2322 static inline int ieee80211_debug_init(void) { return 0; }
2323 static inline void ieee80211_debug_exit(void) { }
2324 #endif
2325
2326
2327 void ieee80211_wx_sync_scan_wq(struct work_struct *work);
2328
2329
2330 int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
2331 struct iw_request_info *info,
2332 union iwreq_data *wrqu, char *extra);
2333
2334 int ieee80211_wx_get_name(struct ieee80211_device *ieee,
2335 struct iw_request_info *info,
2336 union iwreq_data *wrqu, char *extra);
2337
2338 int ieee80211_wx_set_power(struct ieee80211_device *ieee,
2339 struct iw_request_info *info,
2340 union iwreq_data *wrqu, char *extra);
2341
2342 int ieee80211_wx_get_power(struct ieee80211_device *ieee,
2343 struct iw_request_info *info,
2344 union iwreq_data *wrqu, char *extra);
2345
2346 int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
2347 struct iw_request_info *info,
2348 union iwreq_data *wrqu, char *extra);
2349
2350 int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
2351 struct iw_request_info *info,
2352 union iwreq_data *wrqu, char *extra);
2353
2354 #define MAX_RECEIVE_BUFFER_SIZE 9100
2355 void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
2356 void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
2357
2358 void HTSetConnectBwMode(struct ieee80211_device *ieee,
2359 enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset);
2360 void HTUpdateDefaultSetting(struct ieee80211_device *ieee);
2361 void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap,
2362 u8 *len, u8 isEncrypt);
2363 void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo,
2364 u8 *len, u8 isEncrypt);
2365 void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg,
2366 u8 *len);
2367 void HTOnAssocRsp(struct ieee80211_device *ieee);
2368 void HTInitializeHTInfo(struct ieee80211_device *ieee);
2369 void HTInitializeBssDesc(PBSS_HT pBssHT);
2370 void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee,
2371 struct ieee80211_network *pNetwork);
2372 void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee,
2373 struct ieee80211_network *pNetwork);
2374 u8 HTGetHighestMCSRate(struct ieee80211_device *ieee,
2375 u8 *pMCSRateSet, u8 *pMCSFilter);
2376 extern u8 MCS_FILTER_ALL[];
2377 extern u16 MCS_DATA_RATE[2][2][77];
2378 u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame);
2379 void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
2380 bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee);
2381 u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate);
2382
2383 int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb);
2384 int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb);
2385 int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb);
2386 void TsInitAddBA(struct ieee80211_device *ieee, struct tx_ts_record *pTS,
2387 u8 Policy, u8 bOverwritePending);
2388 void TsInitDelBA(struct ieee80211_device *ieee,
2389 struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect);
2390 void BaSetupTimeOut(struct timer_list *t);
2391 void TxBaInactTimeout(struct timer_list *t);
2392 void RxBaInactTimeout(struct timer_list *t);
2393 void ResetBaEntry(struct ba_record *pBA);
2394
2395 bool GetTs(
2396 struct ieee80211_device *ieee,
2397 struct ts_common_info **ppTS,
2398 u8 *Addr,
2399 u8 TID,
2400 enum tr_select TxRxSelect,
2401 bool bAddNewTs
2402 );
2403 void TSInitialize(struct ieee80211_device *ieee);
2404 void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTxTS);
2405 void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr);
2406 void RemoveAllTS(struct ieee80211_device *ieee);
2407 void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
2408
2409 extern const long ieee80211_wlan_frequencies[];
2410
2411 static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
2412 {
2413 ieee->scans++;
2414 }
2415
2416 static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
2417 {
2418 return ieee->scans;
2419 }
2420
2421 static inline const char *escape_essid(const char *essid, u8 essid_len)
2422 {
2423 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2424
2425 if (ieee80211_is_empty_essid(essid, essid_len)) {
2426 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2427 return escaped;
2428 }
2429
2430 snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
2431 return escaped;
2432 }
2433
2434
2435
2436
2437 short check_nic_enough_desc(struct net_device *dev, int queue_index);
2438 int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
2439 int ieee80211_parse_info_param(struct ieee80211_device *ieee,
2440 struct ieee80211_info_element *info_element,
2441 u16 length,
2442 struct ieee80211_network *network,
2443 struct ieee80211_rx_stats *stats);
2444
2445 void ieee80211_indicate_packets(struct ieee80211_device *ieee,
2446 struct ieee80211_rxb **prxbIndicateArray,
2447 u8 index);
2448 #define RT_ASOC_RETRY_LIMIT 5
2449 #endif