]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/rtl8192su/ieee80211/ieee80211.h
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / drivers / staging / rtl8192su / ieee80211 / ieee80211.h
1 /*
2  * Merged with mainline ieee80211.h in Aug 2004.  Original ieee802_11
3  * remains copyright by the original authors
4  *
5  * Portions of the merged code are based on Host AP (software wireless
6  * LAN access point) driver for Intersil Prism2/2.5/3.
7  *
8  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
9  * <jkmaline@cc.hut.fi>
10  * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
11  *
12  * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13  * <jketreno@linux.intel.com>
14  * Copyright (c) 2004, Intel Corporation
15  *
16  * Modified for Realtek's wi-fi cards by Andrea Merello
17  * <andreamrl@tiscali.it>
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License version 2 as
21  * published by the Free Software Foundation. See README and COPYING for
22  * more details.
23  */
24 #ifndef IEEE80211_H
25 #define IEEE80211_H
26 #include <linux/if_ether.h> /* ETH_ALEN */
27 #include <linux/kernel.h>   /* ARRAY_SIZE */
28 #include <linux/version.h>
29 #include <linux/module.h>
30 #include <linux/jiffies.h>
31 #include <linux/timer.h>
32 #include <linux/sched.h>
33 #include <linux/semaphore.h>
34
35 #include <linux/delay.h>
36 #include <linux/wireless.h>
37 #include <linux/ieee80211.h>
38
39 #include "rtl819x_HT.h"
40 #include "rtl819x_BA.h"
41 #include "rtl819x_TS.h"
42
43 #define KEY_TYPE_NA             0x0
44 #define KEY_TYPE_WEP40          0x1
45 #define KEY_TYPE_TKIP           0x2
46 #define KEY_TYPE_CCMP           0x4
47 #define KEY_TYPE_WEP104         0x5
48
49 #define aSifsTime (((priv->ieee80211->current_network.mode == IEEE_A) || \
50                     (priv->ieee80211->current_network.mode == IEEE_N_24G) || \
51                     (priv->ieee80211->current_network.mode == IEEE_N_5G)) \
52                    ? 16 : 10)
53
54 #define MGMT_QUEUE_NUM 5
55
56 #define IEEE_CMD_SET_WPA_PARAM                  1
57 #define IEEE_CMD_SET_WPA_IE                     2
58 #define IEEE_CMD_SET_ENCRYPTION                 3
59 #define IEEE_CMD_MLME                           4
60
61 #define IEEE_PARAM_WPA_ENABLED                  1
62 #define IEEE_PARAM_TKIP_COUNTERMEASURES         2
63 #define IEEE_PARAM_DROP_UNENCRYPTED             3
64 #define IEEE_PARAM_PRIVACY_INVOKED              4
65 #define IEEE_PARAM_AUTH_ALGS                    5
66 #define IEEE_PARAM_IEEE_802_1X                  6
67 //It should consistent with the driver_XXX.c
68 //   David, 2006.9.26
69 #define IEEE_PARAM_WPAX_SELECT                  7
70 //Added for notify the encryption type selection
71 //   David, 2006.9.26
72 #define IEEE_PROTO_WPA                          1
73 #define IEEE_PROTO_RSN                          2
74 //Added for notify the encryption type selection
75 //   David, 2006.9.26
76 #define IEEE_WPAX_USEGROUP                      0
77 #define IEEE_WPAX_WEP40                         1
78 #define IEEE_WPAX_TKIP                          2
79 #define IEEE_WPAX_WRAP                          3
80 #define IEEE_WPAX_CCMP                          4
81 #define IEEE_WPAX_WEP104                        5
82
83 #define IEEE_KEY_MGMT_IEEE8021X                 1
84 #define IEEE_KEY_MGMT_PSK                       2
85
86 #define IEEE_MLME_STA_DEAUTH                    1
87 #define IEEE_MLME_STA_DISASSOC                  2
88
89
90 #define IEEE_CRYPT_ERR_UNKNOWN_ALG              2
91 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR             3
92 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED        4
93 #define IEEE_CRYPT_ERR_KEY_SET_FAILED           5
94 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED        6
95 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED         7
96
97
98 #define IEEE_CRYPT_ALG_NAME_LEN                 16
99
100 #define MAX_IE_LEN  0xff
101
102 typedef struct ieee_param {
103         u32 cmd;
104         u8 sta_addr[ETH_ALEN];
105         union {
106                 struct {
107                         u8 name;
108                         u32 value;
109                 } wpa_param;
110                 struct {
111                         u32 len;
112                         u8 reserved[32];
113                         u8 data[0];
114                 } wpa_ie;
115                 struct{
116                         int command;
117                         int reason_code;
118                 } mlme;
119                 struct {
120                         u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
121                         u8 set_tx;
122                         u32 err;
123                         u8 idx;
124                         u8 seq[8]; /* sequence counter (set: RX, get: TX) */
125                         u16 key_len;
126                         u8 key[0];
127                 } crypt;
128         } u;
129 }ieee_param;
130
131 #define MSECS(t) msecs_to_jiffies(t)
132 #define msleep_interruptible_rsl  msleep_interruptible
133
134 #define IEEE80211_DATA_LEN              2304
135 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
136    6.2.1.1.2.
137
138    The figure in section 7.1.2 suggests a body size of up to 2312
139    bytes is allowed, which is a bit confusing, I suspect this
140    represents the 2304 bytes of real data, plus a possible 8 bytes of
141    WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
142 #define IEEE80211_1ADDR_LEN 10
143 #define IEEE80211_2ADDR_LEN 16
144 #define IEEE80211_3ADDR_LEN 24
145 #define IEEE80211_4ADDR_LEN 30
146 #define IEEE80211_FCS_LEN    4
147 #define IEEE80211_HLEN                  IEEE80211_4ADDR_LEN
148 #define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
149 #define IEEE80211_MGMT_HDR_LEN 24
150 #define IEEE80211_DATA_HDR3_LEN 24
151 #define IEEE80211_DATA_HDR4_LEN 30
152
153 #define MIN_FRAG_THRESHOLD     256U
154 #define MAX_FRAG_THRESHOLD     2346U
155
156
157 /* Frame control field constants */
158 #define IEEE80211_FCTL_FRAMETYPE        0x00fc
159 #define IEEE80211_FCTL_DSTODS           0x0300 //added by david
160 #define IEEE80211_FCTL_WEP              0x4000
161
162 /* management */
163 #define IEEE80211_STYPE_MANAGE_ACT      0x00D0
164
165 /* control */
166 #define IEEE80211_STYPE_BLOCKACK   0x0094
167
168 /* QOS control */
169 #define IEEE80211_QCTL_TID              0x000F
170
171 /* debug macros */
172 #define CONFIG_IEEE80211_DEBUG
173 #ifdef CONFIG_IEEE80211_DEBUG
174 extern u32 ieee80211_debug_level;
175 #define IEEE80211_DEBUG(level, fmt, args...) \
176         do { \
177                 if (ieee80211_debug_level & (level)) \
178                         printk(KERN_DEBUG "ieee80211: " fmt, ## args); \
179         } while (0)
180 #define IEEE80211_DEBUG_DATA(level, data, datalen) \
181         do { \
182                 if ((ieee80211_debug_level & (level)) == (level)) { \
183                         u8 *pdata = (u8 *)data; \
184                         int i; \
185                         printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \
186                         for (i = 0; i < (int)(datalen); i++) { \
187                                 printk("%2x ", pdata[i]); \
188                                 if ((i + 1) % 16 == 0) \
189                                         printk("\n"); \
190                         } \
191                         printk("\n"); \
192                 } \
193         } while (0)
194 #else
195 #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
196 #define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0)
197 #endif  /* CONFIG_IEEE80211_DEBUG */
198
199 /*
200  * To use the debug system;
201  *
202  * If you are defining a new debug classification, simply add it to the #define
203  * list here in the form of:
204  *
205  * #define IEEE80211_DL_xxxx VALUE
206  *
207  * shifting value to the left one bit from the previous entry.  xxxx should be
208  * the name of the classification (for example, WEP)
209  *
210  * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
211  * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
212  * to send output to that classification.
213  *
214  * To add your debug level to the list of levels seen when you perform
215  *
216  * % cat /proc/net/ipw/debug_level
217  *
218  * you simply need to add your entry to the ipw_debug_levels array.
219  *
220  * If you do not see debug_level in /proc/net/ipw then you do not have
221  * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
222  *
223  */
224
225 #define IEEE80211_DL_INFO          (1<<0)
226 #define IEEE80211_DL_WX            (1<<1)
227 #define IEEE80211_DL_SCAN          (1<<2)
228 #define IEEE80211_DL_STATE         (1<<3)
229 #define IEEE80211_DL_MGMT          (1<<4)
230 #define IEEE80211_DL_FRAG          (1<<5)
231 #define IEEE80211_DL_EAP           (1<<6)
232 #define IEEE80211_DL_DROP          (1<<7)
233
234 #define IEEE80211_DL_TX            (1<<8)
235 #define IEEE80211_DL_RX            (1<<9)
236
237 #define IEEE80211_DL_HT            (1 << 10)
238 #define IEEE80211_DL_BA            (1 << 11)
239 #define IEEE80211_DL_TS            (1 << 12)
240 #define IEEE80211_DL_QOS           (1 << 13)
241 #define IEEE80211_DL_REORDER       (1 << 14)
242 #define IEEE80211_DL_IOT           (1 << 15)
243 #define IEEE80211_DL_IPS           (1 << 16)
244 #define IEEE80211_DL_TRACE         (1 << 29)
245 #define IEEE80211_DL_DATA          (1 << 30)
246 #define IEEE80211_DL_ERR           (1 << 31)
247
248 #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
249 #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
250 #define IEEE80211_DEBUG_INFO(f, a...)   IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
251
252 #define IEEE80211_DEBUG_WX(f, a...)     IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
253 #define IEEE80211_DEBUG_SCAN(f, a...)   IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
254 #define IEEE80211_DEBUG_STATE(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
255 #define IEEE80211_DEBUG_MGMT(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
256 #define IEEE80211_DEBUG_FRAG(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
257 #define IEEE80211_DEBUG_EAP(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
258 #define IEEE80211_DEBUG_DROP(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
259 #define IEEE80211_DEBUG_TX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
260 #define IEEE80211_DEBUG_RX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
261 #define IEEE80211_DEBUG_QOS(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
262
263 #include <linux/netdevice.h>
264 #include <linux/if_arp.h> /* ARPHRD_ETHER */
265
266 #ifndef WIRELESS_SPY
267 #define WIRELESS_SPY            // enable iwspy support
268 #endif
269 #include <net/iw_handler.h>     // new driver API
270
271 #ifndef ETH_P_PAE
272 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
273 #endif /* ETH_P_PAE */
274
275 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
276
277 #ifndef ETH_P_80211_RAW
278 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
279 #endif
280
281 /* IEEE 802.11 defines */
282
283 #define P80211_OUI_LEN 3
284
285 struct ieee80211_snap_hdr {
286
287         u8    dsap;   /* always 0xAA */
288         u8    ssap;   /* always 0xAA */
289         u8    ctrl;   /* always 0x03 */
290         u8    oui[P80211_OUI_LEN];    /* organizational universal id */
291
292 } __attribute__ ((packed));
293
294 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
295
296 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
297 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
298 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
299
300 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
301 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
302 #define WLAN_GET_SEQ_SEQ(seq)  (((seq) & IEEE80211_SCTL_SEQ) >> 4)
303
304 #define RTL_WLAN_AUTH_LEAP 2
305
306 #define WLAN_CAPABILITY_BSS (1<<0)
307 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
308
309 #define IEEE80211_STATMASK_SIGNAL (1<<0)
310 #define IEEE80211_STATMASK_RSSI (1<<1)
311 #define IEEE80211_STATMASK_NOISE (1<<2)
312 #define IEEE80211_STATMASK_RATE (1<<3)
313 #define IEEE80211_STATMASK_WEMASK 0x7
314
315 #define IEEE80211_CCK_MODULATION    (1<<0)
316 #define IEEE80211_OFDM_MODULATION   (1<<1)
317
318 #define IEEE80211_24GHZ_BAND     (1<<0)
319 #define IEEE80211_52GHZ_BAND     (1<<1)
320
321 #define IEEE80211_CCK_RATE_LEN                  4
322 #define IEEE80211_CCK_RATE_1MB                  0x02
323 #define IEEE80211_CCK_RATE_2MB                  0x04
324 #define IEEE80211_CCK_RATE_5MB                  0x0B
325 #define IEEE80211_CCK_RATE_11MB                 0x16
326 #define IEEE80211_OFDM_RATE_LEN                 8
327 #define IEEE80211_OFDM_RATE_6MB                 0x0C
328 #define IEEE80211_OFDM_RATE_9MB                 0x12
329 #define IEEE80211_OFDM_RATE_12MB                0x18
330 #define IEEE80211_OFDM_RATE_18MB                0x24
331 #define IEEE80211_OFDM_RATE_24MB                0x30
332 #define IEEE80211_OFDM_RATE_36MB                0x48
333 #define IEEE80211_OFDM_RATE_48MB                0x60
334 #define IEEE80211_OFDM_RATE_54MB                0x6C
335 #define IEEE80211_BASIC_RATE_MASK               0x80
336
337 #define IEEE80211_CCK_RATE_1MB_MASK             (1<<0)
338 #define IEEE80211_CCK_RATE_2MB_MASK             (1<<1)
339 #define IEEE80211_CCK_RATE_5MB_MASK             (1<<2)
340 #define IEEE80211_CCK_RATE_11MB_MASK            (1<<3)
341 #define IEEE80211_OFDM_RATE_6MB_MASK            (1<<4)
342 #define IEEE80211_OFDM_RATE_9MB_MASK            (1<<5)
343 #define IEEE80211_OFDM_RATE_12MB_MASK           (1<<6)
344 #define IEEE80211_OFDM_RATE_18MB_MASK           (1<<7)
345 #define IEEE80211_OFDM_RATE_24MB_MASK           (1<<8)
346 #define IEEE80211_OFDM_RATE_36MB_MASK           (1<<9)
347 #define IEEE80211_OFDM_RATE_48MB_MASK           (1<<10)
348 #define IEEE80211_OFDM_RATE_54MB_MASK           (1<<11)
349
350 #define IEEE80211_CCK_RATES_MASK                0x0000000F
351 #define IEEE80211_CCK_BASIC_RATES_MASK  (IEEE80211_CCK_RATE_1MB_MASK | \
352         IEEE80211_CCK_RATE_2MB_MASK)
353 #define IEEE80211_CCK_DEFAULT_RATES_MASK        (IEEE80211_CCK_BASIC_RATES_MASK | \
354         IEEE80211_CCK_RATE_5MB_MASK | \
355         IEEE80211_CCK_RATE_11MB_MASK)
356
357 #define IEEE80211_OFDM_RATES_MASK               0x00000FF0
358 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
359         IEEE80211_OFDM_RATE_12MB_MASK | \
360         IEEE80211_OFDM_RATE_24MB_MASK)
361 #define IEEE80211_OFDM_DEFAULT_RATES_MASK       (IEEE80211_OFDM_BASIC_RATES_MASK | \
362         IEEE80211_OFDM_RATE_9MB_MASK  | \
363         IEEE80211_OFDM_RATE_18MB_MASK | \
364         IEEE80211_OFDM_RATE_36MB_MASK | \
365         IEEE80211_OFDM_RATE_48MB_MASK | \
366         IEEE80211_OFDM_RATE_54MB_MASK)
367 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
368                                 IEEE80211_CCK_DEFAULT_RATES_MASK)
369
370 #define IEEE80211_NUM_OFDM_RATES            8
371 #define IEEE80211_NUM_CCK_RATES             4
372 #define IEEE80211_OFDM_SHIFT_MASK_A         4
373
374
375 /* this is stolen and modified from the madwifi driver*/
376 #define IEEE80211_FC0_TYPE_MASK         0x0c
377 #define IEEE80211_FC0_TYPE_DATA         0x08
378 #define IEEE80211_FC0_SUBTYPE_MASK      0xB0
379 #define IEEE80211_FC0_SUBTYPE_QOS       0x80
380
381 #define IEEE80211_QOS_HAS_SEQ(fc) \
382         (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
383          (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
384
385 /* this is stolen from ipw2200 driver */
386 #define IEEE_IBSS_MAC_HASH_SIZE 31
387 struct ieee_ibss_seq {
388         u8 mac[ETH_ALEN];
389         u16 seq_num[17];
390         u16 frag_num[17];
391         unsigned long packet_time[17];
392         struct list_head list;
393 };
394
395 /* NOTE: This data is for statistical purposes; not all hardware provides this
396  *       information for frames received.  Not setting these will not cause
397  *       any adverse affects. */
398 struct ieee80211_rx_stats {
399         u32 mac_time[2];
400         s8 rssi;
401         u8 signal;
402         u8 noise;
403         u16 rate; /* in 100 kbps */
404         u8 received_channel;
405         u8 control;
406         u8 mask;
407         u8 freq;
408         u16 len;
409         u64 tsf;
410         u32 beacon_time;
411         u8 nic_type;
412
413         u16       Length;
414         u8        SignalQuality;        /* in 0-100 index */
415         /* real power in dBm for this packet, no beautification & aggregation */
416         s32       RecvSignalPower;
417         s8        RxPower;              /* in dBm Translate from PWdB */
418         u8        SignalStrength;       /* in 0-100 index */
419         u16       bHwError:1;
420         u16       bCRC:1;
421         u16       bICV:1;
422         u16       bShortPreamble:1;
423         u16       Antenna:1;            /* RTL8185 */
424         u16       Decrypted:1;          /* RTL8185, RTL8187 */
425         u16       Wakeup:1;             /* RTL8185 */
426         u16       Reserved0:1;          /* RTL8185 */
427         u8        AGC;
428         u32       TimeStampLow;
429         u32       TimeStampHigh;
430         bool      bShift;
431         bool      bIsQosData;
432         u8        UserPriority;
433
434         /* < 11n or 8190 specific code */
435         u8        RxDrvInfoSize;
436         u8        RxBufShift;
437         bool      bIsAMPDU;
438         bool      bFirstMPDU;
439         bool      bContainHTC;
440         bool      RxIs40MHzPacket;
441         u32       RxPWDBAll;
442         u8        RxMIMOSignalStrength[4]; /* in 0~100 index */
443         s8        RxMIMOSignalQuality[2];
444         bool      bPacketMatchBSSID;
445         bool      bIsCCK;
446         bool      bPacketToSelf;
447
448         u8        *virtual_address;
449         /* total packet length: must equal to sum of all FragLength */
450         u16       packetlength;
451         /* FragLength should equal to PacketLength in non-fragment case */
452         u16       fraglength;
453         u16       fragoffset;           /* data offset for this fragment */
454         u16       ntotalfrag;
455         bool      bisrxaggrsubframe;
456         bool      bPacketBeacon;        /* for rssi */
457         bool      bToSelfBA;            /* for rssi */
458         char      cck_adc_pwdb[4];      /* for rx path selection */
459         u16       Seq_Num;
460         u8        nTotalAggPkt;         /* number of aggregated packets */
461 };
462
463 /* IEEE 802.11 requires that STA supports concurrent reception of at least
464  * three fragmented frames. This define can be increased to support more
465  * concurrent frames, but it should be noted that each entry can consume about
466  * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
467 #define IEEE80211_FRAG_CACHE_LEN 4
468
469 struct ieee80211_frag_entry {
470         unsigned long first_frag_time;
471         unsigned int seq;
472         unsigned int last_frag;
473         struct sk_buff *skb;
474         u8 src_addr[ETH_ALEN];
475         u8 dst_addr[ETH_ALEN];
476 };
477
478 struct ieee80211_stats {
479         unsigned int tx_unicast_frames;
480         unsigned int tx_multicast_frames;
481         unsigned int tx_fragments;
482         unsigned int tx_unicast_octets;
483         unsigned int tx_multicast_octets;
484         unsigned int tx_deferred_transmissions;
485         unsigned int tx_single_retry_frames;
486         unsigned int tx_multiple_retry_frames;
487         unsigned int tx_retry_limit_exceeded;
488         unsigned int tx_discards;
489         unsigned int rx_unicast_frames;
490         unsigned int rx_multicast_frames;
491         unsigned int rx_fragments;
492         unsigned int rx_unicast_octets;
493         unsigned int rx_multicast_octets;
494         unsigned int rx_fcs_errors;
495         unsigned int rx_discards_no_buffer;
496         unsigned int tx_discards_wrong_sa;
497         unsigned int rx_discards_undecryptable;
498         unsigned int rx_message_in_msg_fragments;
499         unsigned int rx_message_in_bad_msg_fragments;
500 };
501
502 struct ieee80211_device;
503
504 #include "ieee80211_crypt.h"
505
506 #define SEC_KEY_1         (1<<0)
507 #define SEC_KEY_2         (1<<1)
508 #define SEC_KEY_3         (1<<2)
509 #define SEC_KEY_4         (1<<3)
510 #define SEC_ACTIVE_KEY    (1<<4)
511 #define SEC_AUTH_MODE     (1<<5)
512 #define SEC_UNICAST_GROUP (1<<6)
513 #define SEC_LEVEL         (1<<7)
514 #define SEC_ENABLED       (1<<8)
515
516 #define SEC_LEVEL_0      0 /* None */
517 #define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
518 #define SEC_LEVEL_2      2 /* Level 1 + TKIP */
519 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
520 #define SEC_LEVEL_3      4 /* Level 2 + CCMP */
521
522 #define WEP_KEYS                4
523 #define WEP_KEY_LEN             13
524 #define SCM_KEY_LEN             32
525
526 struct ieee80211_security {
527         u16 active_key:2,
528             enabled:1,
529             auth_mode:2,
530             auth_algo:4,
531             unicast_uses_group:1,
532             encrypt:1;
533         u8 key_sizes[WEP_KEYS];
534         u8 keys[WEP_KEYS][SCM_KEY_LEN];
535         u8 level;
536         u16 flags;
537 } __attribute__ ((packed));
538
539
540 /*
541  802.11 data frame from AP
542       ,-------------------------------------------------------------------.
543 Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
544       |------|------|---------|---------|---------|------|---------|------|
545 Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
546       |      | tion | (BSSID) |         |         | ence |  data   |      |
547       `-------------------------------------------------------------------'
548 Total: 28-2340 bytes
549 */
550
551 /* Management Frame Information Element Types */
552 enum {
553         MFIE_TYPE_SSID = 0,
554         MFIE_TYPE_RATES = 1,
555         MFIE_TYPE_FH_SET = 2,
556         MFIE_TYPE_DS_SET = 3,
557         MFIE_TYPE_CF_SET = 4,
558         MFIE_TYPE_TIM = 5,
559         MFIE_TYPE_IBSS_SET = 6,
560         MFIE_TYPE_COUNTRY = 7,
561         MFIE_TYPE_HOP_PARAMS = 8,
562         MFIE_TYPE_HOP_TABLE = 9,
563         MFIE_TYPE_REQUEST = 10,
564         MFIE_TYPE_CHALLENGE = 16,
565         MFIE_TYPE_POWER_CONSTRAINT = 32,
566         MFIE_TYPE_POWER_CAPABILITY = 33,
567         MFIE_TYPE_TPC_REQUEST = 34,
568         MFIE_TYPE_TPC_REPORT = 35,
569         MFIE_TYPE_SUPP_CHANNELS = 36,
570         MFIE_TYPE_CSA = 37,
571         MFIE_TYPE_MEASURE_REQUEST = 38,
572         MFIE_TYPE_MEASURE_REPORT = 39,
573         MFIE_TYPE_QUIET = 40,
574         MFIE_TYPE_IBSS_DFS = 41,
575         MFIE_TYPE_ERP = 42,
576         MFIE_TYPE_RSN = 48,
577         MFIE_TYPE_RATES_EX = 50,
578         MFIE_TYPE_HT_CAP= 45,
579          MFIE_TYPE_HT_INFO= 61,
580          MFIE_TYPE_AIRONET=133,
581         MFIE_TYPE_GENERIC = 221,
582         MFIE_TYPE_QOS_PARAMETER = 222,
583 };
584
585 /* Minimal header; can be used for passing 802.11 frames with sufficient
586  * information to determine what type of underlying data type is actually
587  * stored in the data. */
588 struct rtl_ieee80211_hdr {
589         __le16 frame_ctl;
590         __le16 duration_id;
591         u8 payload[0];
592 } __attribute__ ((packed));
593
594 struct ieee80211_hdr_1addr {
595         __le16 frame_ctl;
596         __le16 duration_id;
597         u8 addr1[ETH_ALEN];
598         u8 payload[0];
599 } __attribute__ ((packed));
600
601 struct ieee80211_hdr_2addr {
602         __le16 frame_ctl;
603         __le16 duration_id;
604         u8 addr1[ETH_ALEN];
605         u8 addr2[ETH_ALEN];
606         u8 payload[0];
607 } __attribute__ ((packed));
608
609 struct ieee80211_hdr_4addr {
610         __le16 frame_ctl;
611         __le16 duration_id;
612         u8 addr1[ETH_ALEN];
613         u8 addr2[ETH_ALEN];
614         u8 addr3[ETH_ALEN];
615         __le16 seq_ctl;
616         u8 addr4[ETH_ALEN];
617         u8 payload[0];
618 } __attribute__ ((packed));
619
620 struct ieee80211_hdr_3addrqos {
621         __le16 frame_ctl;
622         __le16 duration_id;
623         u8 addr1[ETH_ALEN];
624         u8 addr2[ETH_ALEN];
625         u8 addr3[ETH_ALEN];
626         __le16 seq_ctl;
627         u8 payload[0];
628         __le16 qos_ctl;
629 } __attribute__ ((packed));
630
631 struct ieee80211_hdr_4addrqos {
632         __le16 frame_ctl;
633         __le16 duration_id;
634         u8 addr1[ETH_ALEN];
635         u8 addr2[ETH_ALEN];
636         u8 addr3[ETH_ALEN];
637         __le16 seq_ctl;
638         u8 addr4[ETH_ALEN];
639         u8 payload[0];
640         __le16 qos_ctl;
641 } __attribute__ ((packed));
642
643 struct ieee80211_info_element {
644         u8 id;
645         u8 len;
646         u8 data[0];
647 } __attribute__ ((packed));
648
649 struct ieee80211_authentication {
650         struct ieee80211_hdr_3addr header;
651         __le16 algorithm;
652         __le16 transaction;
653         __le16 status;
654         /* challenge */
655         struct ieee80211_info_element info_element[0];
656 } __attribute__ ((packed));
657
658 struct ieee80211_disassoc {
659         struct ieee80211_hdr_3addr header;
660         __le16 reason;
661 } __attribute__ ((packed));
662
663 struct ieee80211_probe_request {
664         struct ieee80211_hdr_3addr header;
665         /* SSID, supported rates */
666         struct ieee80211_info_element info_element[0];
667 } __attribute__ ((packed));
668
669 struct ieee80211_probe_response {
670         struct ieee80211_hdr_3addr header;
671         u32 time_stamp[2];
672         __le16 beacon_interval;
673         __le16 capability;
674         /* SSID, supported rates, FH params, DS params,
675          * CF params, IBSS params, TIM (if beacon), RSN */
676         struct ieee80211_info_element info_element[0];
677 } __attribute__ ((packed));
678
679 struct ieee80211_assoc_request_frame {
680         struct ieee80211_hdr_3addr header;
681         __le16 capability;
682         __le16 listen_interval;
683         /* SSID, supported rates, RSN */
684         struct ieee80211_info_element info_element[0];
685 } __attribute__ ((packed));
686
687 struct ieee80211_reassoc_request_frame {
688         struct ieee80211_hdr_3addr header;
689         __le16 capability;
690         __le16 listen_interval;
691         u8 current_ap[ETH_ALEN];
692         /* SSID, supported rates, RSN */
693         struct ieee80211_info_element info_element[0];
694 } __attribute__ ((packed));
695
696 struct ieee80211_assoc_response_frame {
697         struct ieee80211_hdr_3addr header;
698         __le16 capability;
699         __le16 status;
700         __le16 aid;
701         struct ieee80211_info_element info_element[0]; /* supported rates */
702 } __attribute__ ((packed));
703
704 struct ieee80211_txb {
705         u8 nr_frags;
706         u8 encrypted;
707         u8 queue_index;
708         u8 rts_included;
709         u16 reserved;
710         __le16 frag_size;
711         __le16 payload_size;
712         struct sk_buff *fragments[0];
713 };
714
715 #define MAX_SUBFRAME_COUNT                64
716 struct ieee80211_rxb {
717         u8 nr_subframes;
718         struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
719         u8 dst[ETH_ALEN];
720         u8 src[ETH_ALEN];
721 }__attribute__((packed));
722
723 /* SWEEP TABLE ENTRIES NUMBER */
724 #define MAX_SWEEP_TAB_ENTRIES             42
725 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET  7
726 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
727  * only use 8, and then use extended rates for the remaining supported
728  * rates.  Other APs, however, stick all of their supported rates on the
729  * main rates information element... */
730 #define MAX_RATES_LENGTH                  ((u8)12)
731 #define MAX_RATES_EX_LENGTH               ((u8)16)
732 #define MAX_NETWORK_COUNT                  128
733
734 #define MAX_CHANNEL_NUMBER                 161
735
736 #define IEEE80211_SOFTMAC_SCAN_TIME        100 /* (HZ / 2) */
737 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
738
739 #define CRC_LENGTH                 4U
740
741 #define MAX_WPA_IE_LEN 64
742
743 #define NETWORK_EMPTY_ESSID     (1 << 0)
744 #define NETWORK_HAS_OFDM        (1 << 1)
745 #define NETWORK_HAS_CCK         (1 << 2)
746
747 /* QoS structure */
748 #define NETWORK_HAS_QOS_PARAMETERS      (1 << 3)
749 #define NETWORK_HAS_QOS_INFORMATION     (1 << 4)
750 #define NETWORK_HAS_QOS_MASK            (NETWORK_HAS_QOS_PARAMETERS | \
751                                          NETWORK_HAS_QOS_INFORMATION)
752
753 #define NETWORK_HAS_ERP_VALUE           (1 << 10)
754
755 #define QOS_QUEUE_NUM                   4
756 #define QOS_OUI_LEN                     3
757 #define QOS_OUI_TYPE                    2
758 #define QOS_ELEMENT_ID                  221
759 #define QOS_OUI_INFO_SUB_TYPE           0
760 #define QOS_OUI_PARAM_SUB_TYPE          1
761 #define QOS_VERSION_1                   1
762 #define QOS_AIFSN_MIN_VALUE             2
763
764 struct ieee80211_qos_information_element {
765         u8 elementID;
766         u8 length;
767         u8 qui[QOS_OUI_LEN];
768         u8 qui_type;
769         u8 qui_subtype;
770         u8 version;
771         u8 ac_info;
772 } __attribute__ ((packed));
773
774 struct ieee80211_qos_ac_parameter {
775         u8 aci_aifsn;
776         u8 ecw_min_max;
777         __le16 tx_op_limit;
778 } __attribute__ ((packed));
779
780 struct ieee80211_qos_parameter_info {
781         struct ieee80211_qos_information_element info_element;
782         u8 reserved;
783         struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
784 } __attribute__ ((packed));
785
786 struct ieee80211_qos_parameters {
787         __le16 cw_min[QOS_QUEUE_NUM];
788         __le16 cw_max[QOS_QUEUE_NUM];
789         u8 aifs[QOS_QUEUE_NUM];
790         u8 flag[QOS_QUEUE_NUM];
791         __le16 tx_op_limit[QOS_QUEUE_NUM];
792 } __attribute__ ((packed));
793
794 struct ieee80211_qos_data {
795         struct ieee80211_qos_parameters parameters;
796         int active;
797         int supported;
798         u8 param_count;
799         u8 old_param_count;
800 };
801
802 struct ieee80211_tim_parameters {
803         u8 tim_count;
804         u8 tim_period;
805 } __attribute__ ((packed));
806
807 struct ieee80211_wmm_ac_param {
808         u8 ac_aci_acm_aifsn;
809         u8 ac_ecwmin_ecwmax;
810         u16 ac_txop_limit;
811 };
812
813 struct ieee80211_wmm_ts_info {
814         u8 ac_dir_tid;
815         u8 ac_up_psb;
816         u8 reserved;
817 } __attribute__ ((packed));
818
819 struct ieee80211_wmm_tspec_elem {
820         struct ieee80211_wmm_ts_info ts_info;
821         u16 norm_msdu_size;
822         u16 max_msdu_size;
823         u32 min_serv_inter;
824         u32 max_serv_inter;
825         u32 inact_inter;
826         u32 suspen_inter;
827         u32 serv_start_time;
828         u32 min_data_rate;
829         u32 mean_data_rate;
830         u32 peak_data_rate;
831         u32 max_burst_size;
832         u32 delay_bound;
833         u32 min_phy_rate;
834         u16 surp_band_allow;
835         u16 medium_time;
836 }__attribute__((packed));
837
838 enum eap_type {
839         EAP_PACKET = 0,
840         EAPOL_START,
841         EAPOL_LOGOFF,
842         EAPOL_KEY,
843         EAPOL_ENCAP_ASF_ALERT
844 };
845
846 static const char *eap_types[] = {
847         [EAP_PACKET]            = "EAP-Packet",
848         [EAPOL_START]           = "EAPOL-Start",
849         [EAPOL_LOGOFF]          = "EAPOL-Logoff",
850         [EAPOL_KEY]             = "EAPOL-Key",
851         [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
852 };
853
854 static inline const char *eap_get_type(int type)
855 {
856         return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
857 }
858
859 struct eapol {
860         u8 snap[6];
861         u16 ethertype;
862         u8 version;
863         u8 type;
864         u16 length;
865 } __attribute__ ((packed));
866
867 struct ieee80211_softmac_stats {
868         unsigned int rx_ass_ok;
869         unsigned int rx_ass_err;
870         unsigned int rx_probe_rq;
871         unsigned int tx_probe_rs;
872         unsigned int tx_beacons;
873         unsigned int rx_auth_rq;
874         unsigned int rx_auth_rs_ok;
875         unsigned int rx_auth_rs_err;
876         unsigned int tx_auth_rq;
877         unsigned int no_auth_rs;
878         unsigned int no_ass_rs;
879         unsigned int tx_ass_rq;
880         unsigned int rx_ass_rq;
881         unsigned int tx_probe_rq;
882         unsigned int reassoc;
883         unsigned int swtxstop;
884         unsigned int swtxawake;
885         unsigned char CurrentShowTxate;
886         unsigned char last_packet_rate;
887         unsigned int txretrycount;
888 };
889
890 #define BEACON_PROBE_SSID_ID_POSITION 12
891
892 struct ieee80211_info_element_hdr {
893         u8 id;
894         u8 len;
895 } __attribute__ ((packed));
896
897 /*
898  * These are the data types that can make up management packets
899  *
900         u16 auth_algorithm;
901         u16 auth_sequence;
902         u16 beacon_interval;
903         u16 capability;
904         u8 current_ap[ETH_ALEN];
905         u16 listen_interval;
906         struct {
907                 u16 association_id:14, reserved:2;
908         } __attribute__ ((packed));
909         u32 time_stamp[2];
910         u16 reason;
911         u16 status;
912 */
913
914 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
915 #define IEEE80211_DEFAULT_BASIC_RATE 2 /* 1Mbps */
916
917 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
918 #define MAX_SP_Len  (WMM_all_frame << 4)
919 #define IEEE80211_QOS_TID 0x0f
920 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
921
922 #define IEEE80211_DTIM_MBCAST 4
923 #define IEEE80211_DTIM_UCAST 2
924 #define IEEE80211_DTIM_VALID 1
925 #define IEEE80211_DTIM_INVALID 0
926
927 #define IEEE80211_PS_DISABLED 0
928 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
929 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
930
931 //added by David for QoS 2006/6/30
932 //#define WMM_Hang_8187
933 #ifdef WMM_Hang_8187
934 #undef WMM_Hang_8187
935 #endif
936
937 #define WME_AC_BK   0x00
938 #define WME_AC_BE   0x01
939 #define WME_AC_VI   0x02
940 #define WME_AC_VO   0x03
941 #define WME_ACI_MASK 0x03
942 #define WME_AIFSN_MASK 0x03
943 #define WME_AC_PRAM_LEN 16
944
945 //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
946 //#define UP2AC(up)     ((up<3) ? ((up==0)?1:0) : (up>>1))
947 #define UP2AC(up) (                \
948         ((up) < 1) ? WME_AC_BE : \
949         ((up) < 3) ? WME_AC_BK : \
950         ((up) < 4) ? WME_AC_BE : \
951         ((up) < 6) ? WME_AC_VI : \
952         WME_AC_VO)
953
954 //AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
955 #define AC2UP(_ac)      (       \
956         ((_ac) == WME_AC_VO) ? 6 : \
957         ((_ac) == WME_AC_VI) ? 5 : \
958         ((_ac) == WME_AC_BK) ? 1 : \
959         0)
960
961 #define ETHER_ADDR_LEN          6       /* length of an Ethernet address */
962
963 /* length of two Ethernet address plus ether type */
964 #define ETHERNET_HEADER_SIZE    14
965
966 struct  ether_header {
967         u8 ether_dhost[ETHER_ADDR_LEN];
968         u8 ether_shost[ETHER_ADDR_LEN];
969         u16 ether_type;
970 } __attribute__((packed));
971
972 #ifndef ETHERTYPE_PAE
973 #define ETHERTYPE_PAE   0x888e          /* EAPOL PAE/802.1x */
974 #endif
975 #ifndef ETHERTYPE_IP
976 #define ETHERTYPE_IP    0x0800          /* IP protocol */
977 #endif
978
979 struct ieee80211_network {
980         /* These entries are used to identify a unique network */
981         u8 bssid[ETH_ALEN];
982         u8 channel;
983         /* Ensure null-terminated for any debug msgs */
984         u8 ssid[IW_ESSID_MAX_SIZE + 1];
985         u8 ssid_len;
986
987         struct ieee80211_qos_data qos_data;
988
989         /* for LEAP */
990         bool    bWithAironetIE;
991         bool    bCkipSupported;
992         bool    bCcxRmEnable;
993         u16     CcxRmState[2];
994
995         /* CCXv4 S59, MBSSID. */
996         bool    bMBssidValid;
997         u8      MBssidMask;
998         u8      MBssid[6];
999
1000         /* CCX 2 S38, WLAN Device Version Number element. */
1001         bool    bWithCcxVerNum;
1002         u8      BssCcxVerNumber;
1003
1004         /* These are network statistics */
1005         struct ieee80211_rx_stats stats;
1006         u16 capability;
1007         u8  rates[MAX_RATES_LENGTH];
1008         u8  rates_len;
1009         u8  rates_ex[MAX_RATES_EX_LENGTH];
1010         u8  rates_ex_len;
1011         unsigned long last_scanned;
1012         u8  mode;
1013         u32 flags;
1014         u32 last_associate;
1015         u32 time_stamp[2];
1016         u16 beacon_interval;
1017         u16 listen_interval;
1018         u16 atim_window;
1019         u8  erp_value;
1020         u8  wpa_ie[MAX_WPA_IE_LEN];
1021         size_t wpa_ie_len;
1022         u8  rsn_ie[MAX_WPA_IE_LEN];
1023         size_t rsn_ie_len;
1024
1025         struct ieee80211_tim_parameters tim;
1026         u8  dtim_period;
1027         u8  dtim_data;
1028         u32 last_dtim_sta_time[2];
1029
1030         //appeded for QoS
1031         u8 wmm_info;
1032         struct ieee80211_wmm_ac_param wmm_param[4];
1033         u8 QoS_Enable;
1034         u8 Turbo_Enable;//enable turbo mode, added by thomas
1035         u16 CountryIeLen;
1036         u8 CountryIeBuf[MAX_IE_LEN];
1037
1038         /* HT Related */
1039         BSS_HT  bssht;
1040         /* Added to handle broadcom AP management frame CCK rate. */
1041         bool broadcom_cap_exist;
1042         bool realtek_cap_exit;
1043         bool marvell_cap_exist;
1044         bool ralink_cap_exist;
1045         bool atheros_cap_exist;
1046         bool cisco_cap_exist;
1047         bool unknown_cap_exist;
1048         bool berp_info_valid;
1049         bool buseprotection;
1050
1051         struct list_head list;  /* put at the end of the structure */
1052 };
1053
1054 enum ieee80211_state {
1055
1056         /* the card is not linked at all */
1057         IEEE80211_NOLINK = 0,
1058
1059         /* IEEE80211_ASSOCIATING* are for BSS client mode
1060          * the driver shall not perform RX filtering unless
1061          * the state is LINKED.
1062          * The driver shall just check for the state LINKED and
1063          * defaults to NOLINK for ALL the other states (including
1064          * LINKED_SCANNING)
1065          */
1066
1067         /* the association procedure will start (wq scheduling)*/
1068         IEEE80211_ASSOCIATING,
1069         IEEE80211_ASSOCIATING_RETRY,
1070
1071         /* the association procedure is sending AUTH request*/
1072         IEEE80211_ASSOCIATING_AUTHENTICATING,
1073
1074         /* the association procedure has successfully authentcated
1075          * and is sending association request
1076          */
1077         IEEE80211_ASSOCIATING_AUTHENTICATED,
1078
1079         /* the link is ok. the card associated to a BSS or linked
1080          * to a ibss cell or acting as an AP and creating the bss
1081          */
1082         IEEE80211_LINKED,
1083
1084         /* same as LINKED, but the driver shall apply RX filter
1085          * rules as we are in NO_LINK mode. As the card is still
1086          * logically linked, but it is doing a syncro site survey
1087          * then it will be back to LINKED state.
1088          */
1089         IEEE80211_LINKED_SCANNING,
1090
1091 };
1092
1093 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1094 #define DEFAULT_FTS 2346
1095
1096 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
1097 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1098
1099 #define IEEE80211_24GHZ_MIN_CHANNEL 1
1100 #define IEEE80211_24GHZ_MAX_CHANNEL 14
1101 #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
1102                                   IEEE80211_24GHZ_MIN_CHANNEL + 1)
1103
1104 #define IEEE80211_52GHZ_MIN_CHANNEL 34
1105 #define IEEE80211_52GHZ_MAX_CHANNEL 165
1106 #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
1107                                   IEEE80211_52GHZ_MIN_CHANNEL + 1)
1108
1109 typedef struct tx_pending_t{
1110         int frag;
1111         struct ieee80211_txb *txb;
1112 }tx_pending_t;
1113
1114 enum {
1115         COUNTRY_CODE_FCC = 0,
1116         COUNTRY_CODE_IC = 1,
1117         COUNTRY_CODE_ETSI = 2,
1118         COUNTRY_CODE_SPAIN = 3,
1119         COUNTRY_CODE_FRANCE = 4,
1120         COUNTRY_CODE_MKK = 5,
1121         COUNTRY_CODE_MKK1 = 6,
1122         COUNTRY_CODE_ISRAEL = 7,
1123         COUNTRY_CODE_TELEC,
1124         COUNTRY_CODE_MIC,
1125         COUNTRY_CODE_GLOBAL_DOMAIN
1126 };
1127
1128 #include "ieee80211_r8192s.h"
1129
1130 struct ieee80211_device {
1131         struct net_device *dev;
1132         struct ieee80211_security sec;
1133
1134         /* hw security related */
1135         u8 hwsec_active;
1136         bool is_silent_reset;
1137         bool is_roaming;
1138         bool ieee_up;
1139         bool bSupportRemoteWakeUp;
1140         RT_PS_MODE dot11PowerSaveMode;
1141         bool actscanning;
1142         bool be_scan_inprogress;
1143         bool beinretry;
1144         RT_RF_POWER_STATE eRFPowerState;
1145         u32 RfOffReason;
1146         bool is_set_key;
1147
1148         /* 11n HT below */
1149         PRT_HIGH_THROUGHPUT pHTInfo;
1150         spinlock_t bw_spinlock;
1151
1152         spinlock_t reorder_spinlock;
1153         /*
1154          * for HT operation rate set, we use this one for HT data rate to
1155          * seperate different descriptors the way fill this is the same as
1156          * in the IE
1157          */
1158         u8      Regdot11HTOperationalRateSet[16];       /* use RATR format */
1159         u8      dot11HTOperationalRateSet[16];          /* use RATR format */
1160         u8      RegHTSuppRateSet[16];
1161         u8      HTCurrentOperaRate;
1162         u8      HTHighestOperaRate;
1163         /* for rate operation mode to firmware */
1164         u8      bTxDisableRateFallBack;
1165         u8      bTxUseDriverAssingedRate;
1166         atomic_t        atm_chnlop;
1167         atomic_t        atm_swbw;
1168
1169         /* 802.11e and WMM Traffic Stream Info (TX) */
1170         struct list_head        Tx_TS_Admit_List;
1171         struct list_head        Tx_TS_Pending_List;
1172         struct list_head        Tx_TS_Unused_List;
1173         TX_TS_RECORD            TxTsRecord[TOTAL_TS_NUM];
1174         /* 802.11e and WMM Traffic Stream Info (RX) */
1175         struct list_head        Rx_TS_Admit_List;
1176         struct list_head        Rx_TS_Pending_List;
1177         struct list_head        Rx_TS_Unused_List;
1178         RX_TS_RECORD            RxTsRecord[TOTAL_TS_NUM];
1179
1180         RX_REORDER_ENTRY        RxReorderEntry[128];
1181         struct list_head        RxReorder_Unused_List;
1182
1183         /* Qos related */
1184         /* Force per-packet priority 1~7. (default: 0, not to force it.) */
1185         u8 ForcedPriority;
1186
1187         /* Bookkeeping structures */
1188         struct net_device_stats stats;
1189         struct ieee80211_stats ieee_stats;
1190         struct ieee80211_softmac_stats softmac_stats;
1191
1192         /* Probe / Beacon management */
1193         struct list_head network_free_list;
1194         struct list_head network_list;
1195         struct ieee80211_network *networks;
1196         int scans;
1197         int scan_age;
1198
1199         int iw_mode; /* operating mode (IW_MODE_*) */
1200         struct iw_spy_data spy_data;
1201
1202         spinlock_t lock;
1203         spinlock_t wpax_suitlist_lock;
1204
1205         int tx_headroom; /* Set to size of any additional room needed at front
1206                           * of allocated Tx SKBs */
1207         u32 config;
1208
1209         /* WEP and other encryption related settings at the device level */
1210         int open_wep; /* Set to 1 to allow unencrypted frames */
1211         int auth_mode;
1212         int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
1213                                  * WEP key changes */
1214
1215         /* If the host performs {en,de}cryption, then set to 1 */
1216         int host_encrypt;
1217         int host_encrypt_msdu;
1218         int host_decrypt;
1219         /* host performs multicast decryption */
1220         int host_mc_decrypt;
1221
1222         /* host should strip IV and ICV from protected frames */
1223         /* meaningful only when hardware decryption is being used */
1224         int host_strip_iv_icv;
1225
1226         int host_open_frag;
1227         int host_build_iv;
1228         int ieee802_1x; /* is IEEE 802.1X used */
1229
1230         /* WPA data */
1231         bool bHalfWirelessN24GMode;
1232         int wpa_enabled;
1233         int drop_unencrypted;
1234         int tkip_countermeasures;
1235         int privacy_invoked;
1236         size_t wpa_ie_len;
1237         u8 *wpa_ie;
1238         u8 ap_mac_addr[6];
1239         u16 pairwise_key_type;
1240         u16 group_key_type;
1241         struct list_head crypt_deinit_list;
1242         struct ieee80211_crypt_data *crypt[WEP_KEYS];
1243         int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
1244         struct timer_list crypt_deinit_timer;
1245         int crypt_quiesced;
1246
1247         int bcrx_sta_key; /* use individual keys to override default keys even
1248                            * with RX of broad/multicast frames */
1249
1250         /* Fragmentation structures */
1251         // each streaming contain a entry
1252         struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
1253         unsigned int frag_next_idx[17];
1254         u16 fts; /* Fragmentation Threshold */
1255 #define DEFAULT_RTS_THRESHOLD 2346U
1256 #define MIN_RTS_THRESHOLD 1
1257 #define MAX_RTS_THRESHOLD 2346U
1258         u16 rts; /* RTS threshold */
1259
1260         /* Association info */
1261         u8 bssid[ETH_ALEN];
1262
1263         /* This stores infos for the current network.
1264          * Either the network we are associated in INFRASTRUCTURE
1265          * or the network that we are creating in MASTER mode.
1266          * ad-hoc is a mixture ;-).
1267          * Note that in infrastructure mode, even when not associated,
1268          * fields bssid and essid may be valid (if wpa_set and essid_set
1269          * are true) as thy carry the value set by the user via iwconfig
1270          */
1271         struct ieee80211_network current_network;
1272
1273         enum ieee80211_state state;
1274
1275         int short_slot;
1276         int reg_mode;
1277         int mode;       /* A, B, G */
1278         int modulation; /* CCK, OFDM */
1279         int freq_band;  /* 2.4Ghz, 5.2Ghz, Mixed */
1280         int abg_true;   /* ABG flag              */
1281
1282         /* used for forcing the ibss workqueue to terminate
1283          * without wait for the syncro scan to terminate
1284          */
1285         short sync_scan_hurryup;
1286         u16 scan_watch_dog;
1287         int perfect_rssi;
1288         int worst_rssi;
1289
1290         u16 prev_seq_ctl;       /* used to drop duplicate frames */
1291
1292         /*
1293          * map of allowed channels. 0 is dummy, FIXME: remeber to default to
1294          * a basic channel plan depending of the PHY type
1295          */
1296         void *pDot11dInfo;
1297         bool bGlobalDomain;
1298         int rate;       /* current rate */
1299         int basic_rate;
1300         //FIXME: pleace callback, see if redundant with softmac_features
1301         short active_scan;
1302
1303         /* this contains flags for selectively enable softmac support */
1304         u16 softmac_features;
1305
1306         /* if the sequence control field is not filled by HW */
1307         u16 seq_ctrl[5];
1308
1309         /* association procedure transaction sequence number */
1310         u16 associate_seq;
1311
1312         /* AID for RTXed association responses */
1313         u16 assoc_id;
1314
1315         /* power save mode related*/
1316         u8 ack_tx_to_ieee;
1317         short ps;
1318         short sta_sleep;
1319         int ps_timeout;
1320         int ps_period;
1321         struct tasklet_struct ps_task;
1322         u32 ps_th;
1323         u32 ps_tl;
1324
1325         short raw_tx;
1326         /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1327         short queue_stop;
1328         short scanning;
1329         short proto_started;
1330
1331         struct semaphore wx_sem;
1332         struct semaphore scan_sem;
1333
1334         spinlock_t mgmt_tx_lock;
1335         spinlock_t beacon_lock;
1336
1337         short beacon_txing;
1338
1339         short wap_set;
1340         short ssid_set;
1341
1342         u8  wpax_type_set;    //{added by David, 2006.9.28}
1343         u32 wpax_type_notify; //{added by David, 2006.9.26}
1344
1345         /* QoS related flag */
1346         char init_wmmparam_flag;
1347         /* set on initialization */
1348         u8  qos_support;
1349
1350         /* for discarding duplicated packets in IBSS */
1351         struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1352
1353         /* for discarding duplicated packets in BSS */
1354         u16 last_rxseq_num[17]; /* rx seq previous per-tid */
1355         u16 last_rxfrag_num[17];/* tx frag previous per-tid */
1356         unsigned long last_packet_time[17];
1357
1358         /* for PS mode */
1359         unsigned long last_rx_ps_time;
1360
1361         /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
1362         struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1363         int mgmt_queue_head;
1364         int mgmt_queue_tail;
1365
1366 /* rtl819x start */
1367         u8 AsocRetryCount;
1368         unsigned int hw_header;
1369         struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1370         struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
1371         struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
1372         u32 sta_edca_param[4];
1373         bool aggregation;
1374         /* Enable/Disable Rx immediate BA capability. */
1375         bool enable_rx_imm_BA;
1376         bool bibsscoordinator;
1377
1378         /* Dynamic Tx power for near/far range enable/disable. */
1379         bool bdynamic_txpower_enable;
1380
1381         bool bCTSToSelfEnable;
1382         u8 CTSToSelfTH;
1383
1384         u32     fsync_time_interval;
1385         u32     fsync_rate_bitmap;
1386         u8      fsync_rssi_threshold;
1387         bool    bfsync_enable;
1388
1389         u8      fsync_multiple_timeinterval;    /* value * FsyncTimeInterval */
1390         u32     fsync_firstdiff_ratethreshold;  /* low threshold */
1391         u32     fsync_seconddiff_ratethreshold; /* decrease threshold */
1392         Fsync_State     fsync_state;
1393         bool            bis_any_nonbepkts;
1394         /* 20Mhz 40Mhz AutoSwitch Threshold */
1395         struct bandwidth_autoswitch bandwidth_auto_switch;
1396         /* for txpower tracking */
1397         bool FwRWRF;
1398
1399         /* for AP roaming */
1400         struct rt_link_detect LinkDetectInfo;
1401
1402         struct rt_power_save_control PowerSaveControl;
1403 /* rtl819x end */
1404
1405         /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1406         struct  tx_pending_t tx_pending;
1407
1408         /* used if IEEE_SOFTMAC_ASSOCIATE is set */
1409         struct timer_list associate_timer;
1410
1411         /* used if IEEE_SOFTMAC_BEACONS is set */
1412         struct timer_list beacon_timer;
1413         struct work_struct associate_complete_wq;
1414         struct work_struct associate_procedure_wq;
1415         struct delayed_work softmac_scan_wq;
1416         struct delayed_work associate_retry_wq;
1417         struct delayed_work start_ibss_wq;
1418         struct delayed_work hw_wakeup_wq;
1419         struct delayed_work hw_sleep_wq;
1420         struct delayed_work link_change_wq;
1421         struct work_struct wx_sync_scan_wq;
1422         struct workqueue_struct *wq;
1423
1424         /* Callback functions */
1425         void (*set_security)(struct net_device *dev,
1426                              struct ieee80211_security *sec);
1427
1428         /* Used to TX data frame by using txb structs.
1429          * this is not used if in the softmac_features
1430          * is set the flag IEEE_SOFTMAC_TX_QUEUE
1431          */
1432         int (*hard_start_xmit)(struct ieee80211_txb *txb,
1433                                struct net_device *dev);
1434
1435         int (*reset_port)(struct net_device *dev);
1436         int (*is_queue_full)(struct net_device *dev, int pri);
1437
1438         int (*handle_management)(struct net_device *dev,
1439                                  struct ieee80211_network *network, u16 type);
1440         int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
1441
1442         /* Softmac-generated frames (mamagement) are TXed via this
1443          * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
1444          * not set. As some cards may have different HW queues that
1445          * one might want to use for data and management frames
1446          * the option to have two callbacks might be useful.
1447          * This fucntion can't sleep.
1448          */
1449         int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1450                                struct net_device *dev);
1451
1452         /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
1453          * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
1454          * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
1455          * then also management frames are sent via this callback.
1456          * This function can't sleep.
1457          */
1458         void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1459                                struct net_device *dev,int rate);
1460
1461         /* stops the HW queue for DATA frames. Useful to avoid
1462          * waste time to TX data frame when we are reassociating
1463          * This function can sleep.
1464          */
1465         void (*data_hard_stop)(struct net_device *dev);
1466
1467         /* OK this is complementar to data_poll_hard_stop */
1468         void (*data_hard_resume)(struct net_device *dev);
1469
1470         /* ask to the driver to retune the radio .
1471          * This function can sleep. the driver should ensure
1472          * the radio has been swithced before return.
1473          */
1474         void (*set_chan)(struct net_device *dev,short ch);
1475
1476         /* These are not used if the ieee stack takes care of
1477          * scanning (IEEE_SOFTMAC_SCAN feature set).
1478          * In this case only the set_chan is used.
1479          *
1480          * The syncro version is similar to the start_scan but
1481          * does not return until all channels has been scanned.
1482          * this is called in user context and should sleep,
1483          * it is called in a work_queue when swithcing to ad-hoc mode
1484          * or in behalf of iwlist scan when the card is associated
1485          * and root user ask for a scan.
1486          * the fucntion stop_scan should stop both the syncro and
1487          * background scanning and can sleep.
1488          * The fucntion start_scan should initiate the background
1489          * scanning and can't sleep.
1490          */
1491         void (*scan_syncro)(struct net_device *dev);
1492         void (*start_scan)(struct net_device *dev);
1493         void (*stop_scan)(struct net_device *dev);
1494
1495         /* indicate the driver that the link state is changed
1496          * for example it may indicate the card is associated now.
1497          * Driver might be interested in this to apply RX filter
1498          * rules or simply light the LINK led
1499          */
1500         void (*link_change)(struct net_device *dev);
1501
1502         /* these two function indicates to the HW when to start
1503          * and stop to send beacons. This is used when the
1504          * IEEE_SOFTMAC_BEACONS is not set. For now the
1505          * stop_send_bacons is NOT guaranteed to be called only
1506          * after start_send_beacons.
1507          */
1508         void (*start_send_beacons) (struct net_device *dev);
1509         void (*stop_send_beacons) (struct net_device *dev);
1510
1511         /* power save mode related */
1512         void (*sta_wake_up) (struct net_device *dev);
1513         void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
1514         short (*ps_is_queue_empty) (struct net_device *dev);
1515
1516         int (*handle_beacon)(struct net_device *dev,
1517                              struct ieee80211_probe_response *beacon,
1518                              struct ieee80211_network *network);
1519         int (*handle_assoc_response)(struct net_device *dev,
1520                                 struct ieee80211_assoc_response_frame *resp,
1521                                 struct ieee80211_network *network);
1522
1523         /* check whether Tx hw resouce available */
1524         short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1525         /* HT related */
1526         void (*SetBWModeHandler)(struct net_device *dev,
1527                                  HT_CHANNEL_WIDTH Bandwidth,
1528                                  HT_EXTCHNL_OFFSET Offset);
1529         bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
1530         void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
1531         bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
1532         bool (*is_ap_in_wep_tkip)(struct net_device* dev);
1533         void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
1534         bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO);
1535         void (*LedControlHandler)(struct net_device *dev,
1536                                   LED_CTL_MODE LedAction);
1537         /* This must be the last item so that it points to the data
1538          * allocated beyond this structure by alloc_ieee80211 */
1539         u8 priv[0];
1540 };
1541
1542 #define IEEE_A            (1<<0)
1543 #define IEEE_B            (1<<1)
1544 #define IEEE_G            (1<<2)
1545 #define IEEE_N_24G                (1<<4)
1546 #define IEEE_N_5G                 (1<<5)
1547 #define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
1548
1549 /* Generate a 802.11 header */
1550
1551 /* Uses the channel change callback directly
1552  * instead of [start/stop] scan callbacks
1553  */
1554 #define IEEE_SOFTMAC_SCAN (1<<2)
1555
1556 /* Perform authentication and association handshake */
1557 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1558
1559 /* Generate probe requests */
1560 #define IEEE_SOFTMAC_PROBERQ (1<<4)
1561
1562 /* Generate respones to probe requests */
1563 #define IEEE_SOFTMAC_PROBERS (1<<5)
1564
1565 /* The ieee802.11 stack will manages the netif queue
1566  * wake/stop for the driver, taking care of 802.11
1567  * fragmentation. See softmac.c for details. */
1568 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1569
1570 /* Uses only the softmac_data_hard_start_xmit
1571  * even for TX management frames.
1572  */
1573 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1574
1575 /* Generate beacons.  The stack will enqueue beacons
1576  * to the card
1577  */
1578 #define IEEE_SOFTMAC_BEACONS (1<<6)
1579
1580 static inline void *ieee80211_priv(struct net_device *dev)
1581 {
1582         return ((struct ieee80211_device *)netdev_priv(dev))->priv;
1583 }
1584
1585 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
1586 {
1587         /* Single white space is for Linksys APs */
1588         if (essid_len == 1 && essid[0] == ' ')
1589                 return 1;
1590
1591         /* Otherwise, if the entire essid is 0, we assume it is hidden */
1592         while (essid_len) {
1593                 essid_len--;
1594                 if (essid[essid_len] != '\0')
1595                         return 0;
1596         }
1597
1598         return 1;
1599 }
1600
1601 extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
1602 {
1603         /*
1604          * It is possible for both access points and our device to support
1605          * combinations of modes, so as long as there is one valid combination
1606          * of ap/device supported modes, then return success
1607          *
1608          */
1609         if ((mode & IEEE_A) &&
1610             (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1611             (ieee->freq_band & IEEE80211_52GHZ_BAND))
1612                 return 1;
1613
1614         if ((mode & IEEE_G) &&
1615             (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1616             (ieee->freq_band & IEEE80211_24GHZ_BAND))
1617                 return 1;
1618
1619         if ((mode & IEEE_B) &&
1620             (ieee->modulation & IEEE80211_CCK_MODULATION) &&
1621             (ieee->freq_band & IEEE80211_24GHZ_BAND))
1622                 return 1;
1623
1624         return 0;
1625 }
1626
1627 extern inline int ieee80211_get_hdrlen(u16 fc)
1628 {
1629         int hdrlen = IEEE80211_3ADDR_LEN;
1630
1631         switch (WLAN_FC_GET_TYPE(fc)) {
1632         case IEEE80211_FTYPE_DATA:
1633                 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
1634                         hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
1635                 if(IEEE80211_QOS_HAS_SEQ(fc))
1636                         hdrlen += 2; /* QOS ctrl*/
1637                 break;
1638         case IEEE80211_FTYPE_CTL:
1639                 switch (WLAN_FC_GET_STYPE(fc)) {
1640                 case IEEE80211_STYPE_CTS:
1641                 case IEEE80211_STYPE_ACK:
1642                         hdrlen = IEEE80211_1ADDR_LEN;
1643                         break;
1644                 default:
1645                         hdrlen = IEEE80211_2ADDR_LEN;
1646                         break;
1647                 }
1648                 break;
1649         }
1650
1651         return hdrlen;
1652 }
1653
1654 static inline u8 *ieee80211_get_payload(struct rtl_ieee80211_hdr *hdr)
1655 {
1656         switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
1657         case IEEE80211_1ADDR_LEN:
1658                 return ((struct ieee80211_hdr_1addr *)hdr)->payload;
1659         case IEEE80211_2ADDR_LEN:
1660                 return ((struct ieee80211_hdr_2addr *)hdr)->payload;
1661         case IEEE80211_3ADDR_LEN:
1662                 return (void *)hdr+sizeof(struct ieee80211_hdr_3addr);
1663         case IEEE80211_4ADDR_LEN:
1664                 return ((struct ieee80211_hdr_4addr *)hdr)->payload;
1665         }
1666         return NULL;
1667 }
1668
1669 static inline int ieee80211_is_ofdm_rate(u8 rate)
1670 {
1671         switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
1672         case IEEE80211_OFDM_RATE_6MB:
1673         case IEEE80211_OFDM_RATE_9MB:
1674         case IEEE80211_OFDM_RATE_12MB:
1675         case IEEE80211_OFDM_RATE_18MB:
1676         case IEEE80211_OFDM_RATE_24MB:
1677         case IEEE80211_OFDM_RATE_36MB:
1678         case IEEE80211_OFDM_RATE_48MB:
1679         case IEEE80211_OFDM_RATE_54MB:
1680                 return 1;
1681         }
1682         return 0;
1683 }
1684
1685 static inline int ieee80211_is_cck_rate(u8 rate)
1686 {
1687         switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
1688         case IEEE80211_CCK_RATE_1MB:
1689         case IEEE80211_CCK_RATE_2MB:
1690         case IEEE80211_CCK_RATE_5MB:
1691         case IEEE80211_CCK_RATE_11MB:
1692                 return 1;
1693         }
1694         return 0;
1695 }
1696
1697
1698 /* ieee80211.c */
1699 extern void free_ieee80211(struct net_device *dev);
1700 extern struct net_device *alloc_ieee80211(int sizeof_priv);
1701
1702 extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
1703
1704 /* ieee80211_tx.c */
1705
1706 extern int ieee80211_encrypt_fragment(
1707         struct ieee80211_device *ieee,
1708         struct sk_buff *frag,
1709         int hdr_len);
1710
1711 extern int rtl8192_ieee80211_rtl_xmit(struct sk_buff *skb,
1712                           struct net_device *dev);
1713 extern void ieee80211_txb_free(struct ieee80211_txb *);
1714
1715
1716 /* ieee80211_rx.c */
1717 extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
1718                         struct ieee80211_rx_stats *rx_stats);
1719 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1720                              struct ieee80211_hdr_4addr *header,
1721                              struct ieee80211_rx_stats *stats);
1722
1723 /* ieee80211_wx.c */
1724 extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
1725                                  struct iw_request_info *info,
1726                                  union iwreq_data *wrqu, char *key);
1727 extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
1728                                    struct iw_request_info *info,
1729                                    union iwreq_data *wrqu, char *key);
1730 extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
1731                                    struct iw_request_info *info,
1732                                    union iwreq_data *wrqu, char *key);
1733 extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
1734                             struct iw_request_info *info,
1735                             union iwreq_data* wrqu, char *extra);
1736 extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
1737                                struct iw_request_info *info,
1738                                struct iw_param *data, char *extra);
1739 extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
1740                                struct iw_request_info *info,
1741                                union iwreq_data *wrqu, char *extra);
1742 extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
1743
1744 /* ieee80211_softmac.c */
1745 extern short ieee80211_is_54g(struct ieee80211_network net);
1746 extern short ieee80211_is_shortslot(struct ieee80211_network net);
1747 extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
1748                         struct ieee80211_rx_stats *rx_stats, u16 type,
1749                         u16 stype);
1750 extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
1751
1752 void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn);
1753 extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
1754
1755 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
1756 extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
1757 extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
1758 extern void ieee80211_start_bss(struct ieee80211_device *ieee);
1759 extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
1760 extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
1761 extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
1762 extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
1763 extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
1764 extern void ieee80211_disassociate(struct ieee80211_device *ieee);
1765 extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
1766 extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
1767 extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
1768 extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
1769 extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
1770 extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
1771 extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
1772 extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
1773 extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
1774 extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
1775 extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
1776 extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
1777 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
1778 extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
1779 extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
1780 extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
1781
1782 extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
1783
1784 /* ieee80211_crypt_ccmp&tkip&wep.c */
1785 extern void ieee80211_tkip_null(void);
1786 extern void ieee80211_wep_null(void);
1787 extern void ieee80211_ccmp_null(void);
1788
1789 /* ieee80211_softmac_wx.c */
1790
1791 extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
1792                             struct iw_request_info *info,
1793                             union iwreq_data *wrqu, char *ext);
1794
1795 extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
1796                          struct iw_request_info *info,
1797                          union iwreq_data *awrq,
1798                          char *extra);
1799
1800 extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
1801
1802 extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
1803                              struct iw_request_info *info,
1804                              union iwreq_data *wrqu, char *extra);
1805
1806 extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
1807                              struct iw_request_info *info,
1808                              union iwreq_data *wrqu, char *extra);
1809
1810 extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1811                              union iwreq_data *wrqu, char *b);
1812
1813 extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
1814                              union iwreq_data *wrqu, char *b);
1815
1816 extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
1817                               struct iw_request_info *a,
1818                               union iwreq_data *wrqu, char *extra);
1819
1820 extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1821                              union iwreq_data *wrqu, char *b);
1822
1823 extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1824                              union iwreq_data *wrqu, char *b);
1825
1826 extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1827                              union iwreq_data *wrqu, char *b);
1828
1829 extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
1830
1831 extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
1832                                struct iw_request_info *info,
1833                                union iwreq_data *wrqu, char *extra);
1834
1835 extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
1836                              struct iw_request_info *info,
1837                              union iwreq_data *wrqu, char *extra);
1838
1839 extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
1840                                  struct iw_request_info *info,
1841                                  union iwreq_data *wrqu, char *extra);
1842
1843 extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
1844                                  struct iw_request_info *info,
1845                                  union iwreq_data *wrqu, char *extra);
1846
1847 extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
1848                              struct iw_request_info *info,
1849                              union iwreq_data *wrqu, char *extra);
1850
1851 extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
1852                              struct iw_request_info *info,
1853                              union iwreq_data *wrqu, char *extra);
1854
1855 extern void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
1856
1857 extern const long ieee80211_wlan_frequencies[];
1858
1859 extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
1860 {
1861         ieee->scans++;
1862 }
1863
1864 extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
1865 {
1866         return ieee->scans;
1867 }
1868
1869 static inline const char *escape_essid(const char *essid, u8 essid_len) {
1870         static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
1871         const char *s = essid;
1872         char *d = escaped;
1873
1874         if (ieee80211_is_empty_essid(essid, essid_len)) {
1875                 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
1876                 return escaped;
1877         }
1878
1879         essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
1880         while (essid_len--) {
1881                 if (*s == '\0') {
1882                         *d++ = '\\';
1883                         *d++ = '0';
1884                         s++;
1885                 } else {
1886                         *d++ = *s++;
1887                 }
1888         }
1889         *d = '\0';
1890         return escaped;
1891 }
1892
1893 /* For the function is more related to hardware setting, it's better to use the
1894  * ieee handler to refer to it.
1895  */
1896 extern short check_nic_enough_desc(struct net_device *dev, int queue_index);
1897 extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
1898 extern int ieee80211_parse_info_param(struct ieee80211_device *ieee,
1899                 struct ieee80211_info_element *info_element,
1900                 u16 length,
1901                 struct ieee80211_network *network,
1902                 struct ieee80211_rx_stats *stats);
1903
1904 extern void ieee80211_indicate_packets(struct ieee80211_device *ieee,
1905                                        struct ieee80211_rxb **prxbIndicateArray,
1906                                        u8 index);
1907 #define RT_ASOC_RETRY_LIMIT     5
1908 #endif /* IEEE80211_H */