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