1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef IEEE80211_H
25#define IEEE80211_H
26#include <linux/if_ether.h>
27#include <linux/kernel.h>
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
68
69#define IEEE_PARAM_WPAX_SELECT 7
70
71
72#define IEEE_PROTO_WPA 1
73#define IEEE_PROTO_RSN 2
74
75
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];
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
136
137
138
139
140
141
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
158#define IEEE80211_FCTL_FRAMETYPE 0x00fc
159#define IEEE80211_FCTL_DSTODS 0x0300
160#define IEEE80211_FCTL_WEP 0x4000
161
162
163#define IEEE80211_STYPE_MANAGE_ACT 0x00D0
164
165
166#define IEEE80211_STYPE_BLOCKACK 0x0094
167
168
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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229#define IEEE80211_DL_INFO (1<<0)
230#define IEEE80211_DL_WX (1<<1)
231#define IEEE80211_DL_SCAN (1<<2)
232#define IEEE80211_DL_STATE (1<<3)
233#define IEEE80211_DL_MGMT (1<<4)
234#define IEEE80211_DL_FRAG (1<<5)
235#define IEEE80211_DL_EAP (1<<6)
236#define IEEE80211_DL_DROP (1<<7)
237
238#define IEEE80211_DL_TX (1<<8)
239#define IEEE80211_DL_RX (1<<9)
240
241#define IEEE80211_DL_HT (1 << 10)
242#define IEEE80211_DL_BA (1 << 11)
243#define IEEE80211_DL_TS (1 << 12)
244#define IEEE80211_DL_QOS (1 << 13)
245#define IEEE80211_DL_REORDER (1 << 14)
246#define IEEE80211_DL_IOT (1 << 15)
247#define IEEE80211_DL_IPS (1 << 16)
248#define IEEE80211_DL_TRACE (1 << 29)
249#define IEEE80211_DL_DATA (1 << 30)
250#define IEEE80211_DL_ERR (1 << 31)
251
252#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
253#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
254#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
255
256#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
257#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
258#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
259#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
260#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
261#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
262#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
263#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
264#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
265#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
266
267#include <linux/netdevice.h>
268#include <linux/if_arp.h>
269
270#ifndef WIRELESS_SPY
271#define WIRELESS_SPY
272#endif
273#include <net/iw_handler.h>
274
275#ifndef ETH_P_PAE
276#define ETH_P_PAE 0x888E
277#endif
278
279#define ETH_P_PREAUTH 0x88C7
280
281#ifndef ETH_P_80211_RAW
282#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
283#endif
284
285
286
287#define P80211_OUI_LEN 3
288
289struct ieee80211_snap_hdr {
290
291 u8 dsap;
292 u8 ssap;
293 u8 ctrl;
294 u8 oui[P80211_OUI_LEN];
295
296} __attribute__ ((packed));
297
298#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
299
300#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
301#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
302#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
303
304#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
305#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
306#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
307
308#define RTL_WLAN_AUTH_LEAP 2
309
310#define WLAN_CAPABILITY_BSS (1<<0)
311#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
312
313#define IEEE80211_STATMASK_SIGNAL (1<<0)
314#define IEEE80211_STATMASK_RSSI (1<<1)
315#define IEEE80211_STATMASK_NOISE (1<<2)
316#define IEEE80211_STATMASK_RATE (1<<3)
317#define IEEE80211_STATMASK_WEMASK 0x7
318
319#define IEEE80211_CCK_MODULATION (1<<0)
320#define IEEE80211_OFDM_MODULATION (1<<1)
321
322#define IEEE80211_24GHZ_BAND (1<<0)
323#define IEEE80211_52GHZ_BAND (1<<1)
324
325#define IEEE80211_CCK_RATE_LEN 4
326#define IEEE80211_CCK_RATE_1MB 0x02
327#define IEEE80211_CCK_RATE_2MB 0x04
328#define IEEE80211_CCK_RATE_5MB 0x0B
329#define IEEE80211_CCK_RATE_11MB 0x16
330#define IEEE80211_OFDM_RATE_LEN 8
331#define IEEE80211_OFDM_RATE_6MB 0x0C
332#define IEEE80211_OFDM_RATE_9MB 0x12
333#define IEEE80211_OFDM_RATE_12MB 0x18
334#define IEEE80211_OFDM_RATE_18MB 0x24
335#define IEEE80211_OFDM_RATE_24MB 0x30
336#define IEEE80211_OFDM_RATE_36MB 0x48
337#define IEEE80211_OFDM_RATE_48MB 0x60
338#define IEEE80211_OFDM_RATE_54MB 0x6C
339#define IEEE80211_BASIC_RATE_MASK 0x80
340
341#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
342#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
343#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
344#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
345#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
346#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
347#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
348#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
349#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
350#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
351#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
352#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
353
354#define IEEE80211_CCK_RATES_MASK 0x0000000F
355#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
356 IEEE80211_CCK_RATE_2MB_MASK)
357#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
358 IEEE80211_CCK_RATE_5MB_MASK | \
359 IEEE80211_CCK_RATE_11MB_MASK)
360
361#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
362#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
363 IEEE80211_OFDM_RATE_12MB_MASK | \
364 IEEE80211_OFDM_RATE_24MB_MASK)
365#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
366 IEEE80211_OFDM_RATE_9MB_MASK | \
367 IEEE80211_OFDM_RATE_18MB_MASK | \
368 IEEE80211_OFDM_RATE_36MB_MASK | \
369 IEEE80211_OFDM_RATE_48MB_MASK | \
370 IEEE80211_OFDM_RATE_54MB_MASK)
371#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
372 IEEE80211_CCK_DEFAULT_RATES_MASK)
373
374#define IEEE80211_NUM_OFDM_RATES 8
375#define IEEE80211_NUM_CCK_RATES 4
376#define IEEE80211_OFDM_SHIFT_MASK_A 4
377
378
379
380#define IEEE80211_FC0_TYPE_MASK 0x0c
381#define IEEE80211_FC0_TYPE_DATA 0x08
382#define IEEE80211_FC0_SUBTYPE_MASK 0xB0
383#define IEEE80211_FC0_SUBTYPE_QOS 0x80
384
385#define IEEE80211_QOS_HAS_SEQ(fc) \
386 (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
387 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
388
389
390#define IEEE_IBSS_MAC_HASH_SIZE 31
391struct ieee_ibss_seq {
392 u8 mac[ETH_ALEN];
393 u16 seq_num[17];
394 u16 frag_num[17];
395 unsigned long packet_time[17];
396 struct list_head list;
397};
398
399
400
401
402struct ieee80211_rx_stats {
403 u32 mac_time[2];
404 s8 rssi;
405 u8 signal;
406 u8 noise;
407 u16 rate;
408 u8 received_channel;
409 u8 control;
410 u8 mask;
411 u8 freq;
412 u16 len;
413 u64 tsf;
414 u32 beacon_time;
415 u8 nic_type;
416
417 u16 Length;
418 u8 SignalQuality;
419
420 s32 RecvSignalPower;
421 s8 RxPower;
422 u8 SignalStrength;
423 u16 bHwError:1;
424 u16 bCRC:1;
425 u16 bICV:1;
426 u16 bShortPreamble:1;
427 u16 Antenna:1;
428 u16 Decrypted:1;
429 u16 Wakeup:1;
430 u16 Reserved0:1;
431 u8 AGC;
432 u32 TimeStampLow;
433 u32 TimeStampHigh;
434 bool bShift;
435 bool bIsQosData;
436 u8 UserPriority;
437
438
439 u8 RxDrvInfoSize;
440 u8 RxBufShift;
441 bool bIsAMPDU;
442 bool bFirstMPDU;
443 bool bContainHTC;
444 bool RxIs40MHzPacket;
445 u32 RxPWDBAll;
446 u8 RxMIMOSignalStrength[4];
447 s8 RxMIMOSignalQuality[2];
448 bool bPacketMatchBSSID;
449 bool bIsCCK;
450 bool bPacketToSelf;
451
452 u8 *virtual_address;
453
454 u16 packetlength;
455
456 u16 fraglength;
457 u16 fragoffset;
458 u16 ntotalfrag;
459 bool bisrxaggrsubframe;
460 bool bPacketBeacon;
461 bool bToSelfBA;
462 char cck_adc_pwdb[4];
463 u16 Seq_Num;
464 u8 nTotalAggPkt;
465};
466
467
468
469
470
471#define IEEE80211_FRAG_CACHE_LEN 4
472
473struct ieee80211_frag_entry {
474 unsigned long first_frag_time;
475 unsigned int seq;
476 unsigned int last_frag;
477 struct sk_buff *skb;
478 u8 src_addr[ETH_ALEN];
479 u8 dst_addr[ETH_ALEN];
480};
481
482struct ieee80211_stats {
483 unsigned int tx_unicast_frames;
484 unsigned int tx_multicast_frames;
485 unsigned int tx_fragments;
486 unsigned int tx_unicast_octets;
487 unsigned int tx_multicast_octets;
488 unsigned int tx_deferred_transmissions;
489 unsigned int tx_single_retry_frames;
490 unsigned int tx_multiple_retry_frames;
491 unsigned int tx_retry_limit_exceeded;
492 unsigned int tx_discards;
493 unsigned int rx_unicast_frames;
494 unsigned int rx_multicast_frames;
495 unsigned int rx_fragments;
496 unsigned int rx_unicast_octets;
497 unsigned int rx_multicast_octets;
498 unsigned int rx_fcs_errors;
499 unsigned int rx_discards_no_buffer;
500 unsigned int tx_discards_wrong_sa;
501 unsigned int rx_discards_undecryptable;
502 unsigned int rx_message_in_msg_fragments;
503 unsigned int rx_message_in_bad_msg_fragments;
504};
505
506struct ieee80211_device;
507
508#include "ieee80211_crypt.h"
509
510#define SEC_KEY_1 (1<<0)
511#define SEC_KEY_2 (1<<1)
512#define SEC_KEY_3 (1<<2)
513#define SEC_KEY_4 (1<<3)
514#define SEC_ACTIVE_KEY (1<<4)
515#define SEC_AUTH_MODE (1<<5)
516#define SEC_UNICAST_GROUP (1<<6)
517#define SEC_LEVEL (1<<7)
518#define SEC_ENABLED (1<<8)
519
520#define SEC_LEVEL_0 0
521#define SEC_LEVEL_1 1
522#define SEC_LEVEL_2 2
523#define SEC_LEVEL_2_CKIP 3
524#define SEC_LEVEL_3 4
525
526#define WEP_KEYS 4
527#define WEP_KEY_LEN 13
528#define SCM_KEY_LEN 32
529
530struct ieee80211_security {
531 u16 active_key:2,
532 enabled:1,
533 auth_mode:2,
534 auth_algo:4,
535 unicast_uses_group:1,
536 encrypt:1;
537 u8 key_sizes[WEP_KEYS];
538 u8 keys[WEP_KEYS][SCM_KEY_LEN];
539 u8 level;
540 u16 flags;
541} __attribute__ ((packed));
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556enum {
557 MFIE_TYPE_SSID = 0,
558 MFIE_TYPE_RATES = 1,
559 MFIE_TYPE_FH_SET = 2,
560 MFIE_TYPE_DS_SET = 3,
561 MFIE_TYPE_CF_SET = 4,
562 MFIE_TYPE_TIM = 5,
563 MFIE_TYPE_IBSS_SET = 6,
564 MFIE_TYPE_COUNTRY = 7,
565 MFIE_TYPE_HOP_PARAMS = 8,
566 MFIE_TYPE_HOP_TABLE = 9,
567 MFIE_TYPE_REQUEST = 10,
568 MFIE_TYPE_CHALLENGE = 16,
569 MFIE_TYPE_POWER_CONSTRAINT = 32,
570 MFIE_TYPE_POWER_CAPABILITY = 33,
571 MFIE_TYPE_TPC_REQUEST = 34,
572 MFIE_TYPE_TPC_REPORT = 35,
573 MFIE_TYPE_SUPP_CHANNELS = 36,
574 MFIE_TYPE_CSA = 37,
575 MFIE_TYPE_MEASURE_REQUEST = 38,
576 MFIE_TYPE_MEASURE_REPORT = 39,
577 MFIE_TYPE_QUIET = 40,
578 MFIE_TYPE_IBSS_DFS = 41,
579 MFIE_TYPE_ERP = 42,
580 MFIE_TYPE_RSN = 48,
581 MFIE_TYPE_RATES_EX = 50,
582 MFIE_TYPE_HT_CAP= 45,
583 MFIE_TYPE_HT_INFO= 61,
584 MFIE_TYPE_AIRONET=133,
585 MFIE_TYPE_GENERIC = 221,
586 MFIE_TYPE_QOS_PARAMETER = 222,
587};
588
589
590
591
592struct rtl_ieee80211_hdr {
593 __le16 frame_ctl;
594 __le16 duration_id;
595 u8 payload[0];
596} __attribute__ ((packed));
597
598struct ieee80211_hdr_1addr {
599 __le16 frame_ctl;
600 __le16 duration_id;
601 u8 addr1[ETH_ALEN];
602 u8 payload[0];
603} __attribute__ ((packed));
604
605struct ieee80211_hdr_2addr {
606 __le16 frame_ctl;
607 __le16 duration_id;
608 u8 addr1[ETH_ALEN];
609 u8 addr2[ETH_ALEN];
610 u8 payload[0];
611} __attribute__ ((packed));
612
613struct ieee80211_hdr_4addr {
614 __le16 frame_ctl;
615 __le16 duration_id;
616 u8 addr1[ETH_ALEN];
617 u8 addr2[ETH_ALEN];
618 u8 addr3[ETH_ALEN];
619 __le16 seq_ctl;
620 u8 addr4[ETH_ALEN];
621 u8 payload[0];
622} __attribute__ ((packed));
623
624struct ieee80211_hdr_3addrqos {
625 __le16 frame_ctl;
626 __le16 duration_id;
627 u8 addr1[ETH_ALEN];
628 u8 addr2[ETH_ALEN];
629 u8 addr3[ETH_ALEN];
630 __le16 seq_ctl;
631 u8 payload[0];
632 __le16 qos_ctl;
633} __attribute__ ((packed));
634
635struct ieee80211_hdr_4addrqos {
636 __le16 frame_ctl;
637 __le16 duration_id;
638 u8 addr1[ETH_ALEN];
639 u8 addr2[ETH_ALEN];
640 u8 addr3[ETH_ALEN];
641 __le16 seq_ctl;
642 u8 addr4[ETH_ALEN];
643 u8 payload[0];
644 __le16 qos_ctl;
645} __attribute__ ((packed));
646
647struct ieee80211_info_element {
648 u8 id;
649 u8 len;
650 u8 data[0];
651} __attribute__ ((packed));
652
653struct ieee80211_authentication {
654 struct ieee80211_hdr_3addr header;
655 __le16 algorithm;
656 __le16 transaction;
657 __le16 status;
658
659 struct ieee80211_info_element info_element[0];
660} __attribute__ ((packed));
661
662struct ieee80211_disassoc {
663 struct ieee80211_hdr_3addr header;
664 __le16 reason;
665} __attribute__ ((packed));
666
667struct ieee80211_probe_request {
668 struct ieee80211_hdr_3addr header;
669
670 struct ieee80211_info_element info_element[0];
671} __attribute__ ((packed));
672
673struct ieee80211_probe_response {
674 struct ieee80211_hdr_3addr header;
675 u32 time_stamp[2];
676 __le16 beacon_interval;
677 __le16 capability;
678
679
680 struct ieee80211_info_element info_element[0];
681} __attribute__ ((packed));
682
683struct ieee80211_assoc_request_frame {
684 struct ieee80211_hdr_3addr header;
685 __le16 capability;
686 __le16 listen_interval;
687
688 struct ieee80211_info_element info_element[0];
689} __attribute__ ((packed));
690
691struct ieee80211_reassoc_request_frame {
692 struct ieee80211_hdr_3addr header;
693 __le16 capability;
694 __le16 listen_interval;
695 u8 current_ap[ETH_ALEN];
696
697 struct ieee80211_info_element info_element[0];
698} __attribute__ ((packed));
699
700struct ieee80211_assoc_response_frame {
701 struct ieee80211_hdr_3addr header;
702 __le16 capability;
703 __le16 status;
704 __le16 aid;
705 struct ieee80211_info_element info_element[0];
706} __attribute__ ((packed));
707
708struct ieee80211_txb {
709 u8 nr_frags;
710 u8 encrypted;
711 u8 queue_index;
712 u8 rts_included;
713 u16 reserved;
714 __le16 frag_size;
715 __le16 payload_size;
716 struct sk_buff *fragments[0];
717};
718
719#define MAX_SUBFRAME_COUNT 64
720struct ieee80211_rxb {
721 u8 nr_subframes;
722 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
723 u8 dst[ETH_ALEN];
724 u8 src[ETH_ALEN];
725}__attribute__((packed));
726
727
728#define MAX_SWEEP_TAB_ENTRIES 42
729#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
730
731
732
733
734#define MAX_RATES_LENGTH ((u8)12)
735#define MAX_RATES_EX_LENGTH ((u8)16)
736#define MAX_NETWORK_COUNT 128
737
738#define MAX_CHANNEL_NUMBER 161
739
740#define IEEE80211_SOFTMAC_SCAN_TIME 100
741#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
742
743#define CRC_LENGTH 4U
744
745#define MAX_WPA_IE_LEN 64
746
747#define NETWORK_EMPTY_ESSID (1 << 0)
748#define NETWORK_HAS_OFDM (1 << 1)
749#define NETWORK_HAS_CCK (1 << 2)
750
751
752#define NETWORK_HAS_QOS_PARAMETERS (1 << 3)
753#define NETWORK_HAS_QOS_INFORMATION (1 << 4)
754#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
755 NETWORK_HAS_QOS_INFORMATION)
756
757#define NETWORK_HAS_ERP_VALUE (1 << 10)
758
759#define QOS_QUEUE_NUM 4
760#define QOS_OUI_LEN 3
761#define QOS_OUI_TYPE 2
762#define QOS_ELEMENT_ID 221
763#define QOS_OUI_INFO_SUB_TYPE 0
764#define QOS_OUI_PARAM_SUB_TYPE 1
765#define QOS_VERSION_1 1
766#define QOS_AIFSN_MIN_VALUE 2
767
768struct ieee80211_qos_information_element {
769 u8 elementID;
770 u8 length;
771 u8 qui[QOS_OUI_LEN];
772 u8 qui_type;
773 u8 qui_subtype;
774 u8 version;
775 u8 ac_info;
776} __attribute__ ((packed));
777
778struct ieee80211_qos_ac_parameter {
779 u8 aci_aifsn;
780 u8 ecw_min_max;
781 __le16 tx_op_limit;
782} __attribute__ ((packed));
783
784struct ieee80211_qos_parameter_info {
785 struct ieee80211_qos_information_element info_element;
786 u8 reserved;
787 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
788} __attribute__ ((packed));
789
790struct ieee80211_qos_parameters {
791 __le16 cw_min[QOS_QUEUE_NUM];
792 __le16 cw_max[QOS_QUEUE_NUM];
793 u8 aifs[QOS_QUEUE_NUM];
794 u8 flag[QOS_QUEUE_NUM];
795 __le16 tx_op_limit[QOS_QUEUE_NUM];
796} __attribute__ ((packed));
797
798struct ieee80211_qos_data {
799 struct ieee80211_qos_parameters parameters;
800 int active;
801 int supported;
802 u8 param_count;
803 u8 old_param_count;
804};
805
806struct ieee80211_tim_parameters {
807 u8 tim_count;
808 u8 tim_period;
809} __attribute__ ((packed));
810
811struct ieee80211_wmm_ac_param {
812 u8 ac_aci_acm_aifsn;
813 u8 ac_ecwmin_ecwmax;
814 u16 ac_txop_limit;
815};
816
817struct ieee80211_wmm_ts_info {
818 u8 ac_dir_tid;
819 u8 ac_up_psb;
820 u8 reserved;
821} __attribute__ ((packed));
822
823struct ieee80211_wmm_tspec_elem {
824 struct ieee80211_wmm_ts_info ts_info;
825 u16 norm_msdu_size;
826 u16 max_msdu_size;
827 u32 min_serv_inter;
828 u32 max_serv_inter;
829 u32 inact_inter;
830 u32 suspen_inter;
831 u32 serv_start_time;
832 u32 min_data_rate;
833 u32 mean_data_rate;
834 u32 peak_data_rate;
835 u32 max_burst_size;
836 u32 delay_bound;
837 u32 min_phy_rate;
838 u16 surp_band_allow;
839 u16 medium_time;
840}__attribute__((packed));
841
842enum eap_type {
843 EAP_PACKET = 0,
844 EAPOL_START,
845 EAPOL_LOGOFF,
846 EAPOL_KEY,
847 EAPOL_ENCAP_ASF_ALERT
848};
849
850static const char *eap_types[] = {
851 [EAP_PACKET] = "EAP-Packet",
852 [EAPOL_START] = "EAPOL-Start",
853 [EAPOL_LOGOFF] = "EAPOL-Logoff",
854 [EAPOL_KEY] = "EAPOL-Key",
855 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
856};
857
858static inline const char *eap_get_type(int type)
859{
860 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
861}
862
863struct eapol {
864 u8 snap[6];
865 u16 ethertype;
866 u8 version;
867 u8 type;
868 u16 length;
869} __attribute__ ((packed));
870
871struct ieee80211_softmac_stats {
872 unsigned int rx_ass_ok;
873 unsigned int rx_ass_err;
874 unsigned int rx_probe_rq;
875 unsigned int tx_probe_rs;
876 unsigned int tx_beacons;
877 unsigned int rx_auth_rq;
878 unsigned int rx_auth_rs_ok;
879 unsigned int rx_auth_rs_err;
880 unsigned int tx_auth_rq;
881 unsigned int no_auth_rs;
882 unsigned int no_ass_rs;
883 unsigned int tx_ass_rq;
884 unsigned int rx_ass_rq;
885 unsigned int tx_probe_rq;
886 unsigned int reassoc;
887 unsigned int swtxstop;
888 unsigned int swtxawake;
889 unsigned char CurrentShowTxate;
890 unsigned char last_packet_rate;
891 unsigned int txretrycount;
892};
893
894#define BEACON_PROBE_SSID_ID_POSITION 12
895
896struct ieee80211_info_element_hdr {
897 u8 id;
898 u8 len;
899} __attribute__ ((packed));
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
919#define IEEE80211_DEFAULT_BASIC_RATE 2
920
921enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
922#define MAX_SP_Len (WMM_all_frame << 4)
923#define IEEE80211_QOS_TID 0x0f
924#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
925
926#define IEEE80211_DTIM_MBCAST 4
927#define IEEE80211_DTIM_UCAST 2
928#define IEEE80211_DTIM_VALID 1
929#define IEEE80211_DTIM_INVALID 0
930
931#define IEEE80211_PS_DISABLED 0
932#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
933#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
934
935
936
937#ifdef WMM_Hang_8187
938#undef WMM_Hang_8187
939#endif
940
941#define WME_AC_BK 0x00
942#define WME_AC_BE 0x01
943#define WME_AC_VI 0x02
944#define WME_AC_VO 0x03
945#define WME_ACI_MASK 0x03
946#define WME_AIFSN_MASK 0x03
947#define WME_AC_PRAM_LEN 16
948
949
950
951#define UP2AC(up) ( \
952 ((up) < 1) ? WME_AC_BE : \
953 ((up) < 3) ? WME_AC_BK : \
954 ((up) < 4) ? WME_AC_BE : \
955 ((up) < 6) ? WME_AC_VI : \
956 WME_AC_VO)
957
958
959#define AC2UP(_ac) ( \
960 ((_ac) == WME_AC_VO) ? 6 : \
961 ((_ac) == WME_AC_VI) ? 5 : \
962 ((_ac) == WME_AC_BK) ? 1 : \
963 0)
964
965#define ETHER_ADDR_LEN 6
966
967
968#define ETHERNET_HEADER_SIZE 14
969
970struct ether_header {
971 u8 ether_dhost[ETHER_ADDR_LEN];
972 u8 ether_shost[ETHER_ADDR_LEN];
973 u16 ether_type;
974} __attribute__((packed));
975
976#ifndef ETHERTYPE_PAE
977#define ETHERTYPE_PAE 0x888e
978#endif
979#ifndef ETHERTYPE_IP
980#define ETHERTYPE_IP 0x0800
981#endif
982
983struct ieee80211_network {
984
985 u8 bssid[ETH_ALEN];
986 u8 channel;
987
988 u8 ssid[IW_ESSID_MAX_SIZE + 1];
989 u8 ssid_len;
990
991 struct ieee80211_qos_data qos_data;
992
993
994 bool bWithAironetIE;
995 bool bCkipSupported;
996 bool bCcxRmEnable;
997 u16 CcxRmState[2];
998
999
1000 bool bMBssidValid;
1001 u8 MBssidMask;
1002 u8 MBssid[6];
1003
1004
1005 bool bWithCcxVerNum;
1006 u8 BssCcxVerNumber;
1007
1008
1009 struct ieee80211_rx_stats stats;
1010 u16 capability;
1011 u8 rates[MAX_RATES_LENGTH];
1012 u8 rates_len;
1013 u8 rates_ex[MAX_RATES_EX_LENGTH];
1014 u8 rates_ex_len;
1015 unsigned long last_scanned;
1016 u8 mode;
1017 u32 flags;
1018 u32 last_associate;
1019 u32 time_stamp[2];
1020 u16 beacon_interval;
1021 u16 listen_interval;
1022 u16 atim_window;
1023 u8 erp_value;
1024 u8 wpa_ie[MAX_WPA_IE_LEN];
1025 size_t wpa_ie_len;
1026 u8 rsn_ie[MAX_WPA_IE_LEN];
1027 size_t rsn_ie_len;
1028
1029 struct ieee80211_tim_parameters tim;
1030 u8 dtim_period;
1031 u8 dtim_data;
1032 u32 last_dtim_sta_time[2];
1033
1034
1035 u8 wmm_info;
1036 struct ieee80211_wmm_ac_param wmm_param[4];
1037 u8 QoS_Enable;
1038 u8 Turbo_Enable;
1039 u16 CountryIeLen;
1040 u8 CountryIeBuf[MAX_IE_LEN];
1041
1042
1043 BSS_HT bssht;
1044
1045 bool broadcom_cap_exist;
1046 bool realtek_cap_exit;
1047 bool marvell_cap_exist;
1048 bool ralink_cap_exist;
1049 bool atheros_cap_exist;
1050 bool cisco_cap_exist;
1051 bool unknown_cap_exist;
1052 bool berp_info_valid;
1053 bool buseprotection;
1054
1055 struct list_head list;
1056};
1057
1058enum ieee80211_state {
1059
1060
1061 IEEE80211_NOLINK = 0,
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072 IEEE80211_ASSOCIATING,
1073 IEEE80211_ASSOCIATING_RETRY,
1074
1075
1076 IEEE80211_ASSOCIATING_AUTHENTICATING,
1077
1078
1079
1080
1081 IEEE80211_ASSOCIATING_AUTHENTICATED,
1082
1083
1084
1085
1086 IEEE80211_LINKED,
1087
1088
1089
1090
1091
1092
1093 IEEE80211_LINKED_SCANNING,
1094
1095};
1096
1097#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1098#define DEFAULT_FTS 2346
1099
1100#define CFG_IEEE80211_RESERVE_FCS (1<<0)
1101#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1102
1103#define IEEE80211_24GHZ_MIN_CHANNEL 1
1104#define IEEE80211_24GHZ_MAX_CHANNEL 14
1105#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
1106 IEEE80211_24GHZ_MIN_CHANNEL + 1)
1107
1108#define IEEE80211_52GHZ_MIN_CHANNEL 34
1109#define IEEE80211_52GHZ_MAX_CHANNEL 165
1110#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
1111 IEEE80211_52GHZ_MIN_CHANNEL + 1)
1112
1113typedef struct tx_pending_t{
1114 int frag;
1115 struct ieee80211_txb *txb;
1116}tx_pending_t;
1117
1118enum {
1119 COUNTRY_CODE_FCC = 0,
1120 COUNTRY_CODE_IC = 1,
1121 COUNTRY_CODE_ETSI = 2,
1122 COUNTRY_CODE_SPAIN = 3,
1123 COUNTRY_CODE_FRANCE = 4,
1124 COUNTRY_CODE_MKK = 5,
1125 COUNTRY_CODE_MKK1 = 6,
1126 COUNTRY_CODE_ISRAEL = 7,
1127 COUNTRY_CODE_TELEC = 8,
1128 COUNTRY_CODE_MIC = 9,
1129 COUNTRY_CODE_GLOBAL_DOMAIN = 10,
1130 COUNTRY_CODE_WORLD_WIDE_13 = 11,
1131 COUNTRY_CODE_TELEC_NETGEAR = 12,
1132 COUNTRY_CODE_MAX
1133};
1134
1135#define NUM_PMKID_CACHE 16
1136
1137typedef struct _RT_PMKID_LIST
1138{
1139 u8 bUsed;
1140 u8 Bssid[6];
1141 u8 PMKID[16];
1142 u8 SsidBuf[33];
1143 u8* ssid_octet;
1144 u16 ssid_length;
1145} RT_PMKID_LIST, *PRT_PMKID_LIST;
1146
1147
1148#include "ieee80211_r8192s.h"
1149
1150struct ieee80211_device {
1151 struct net_device *dev;
1152 struct ieee80211_security sec;
1153
1154
1155 u8 hwsec_active;
1156 bool is_silent_reset;
1157 bool force_mic_error;
1158 bool is_roaming;
1159 bool ieee_up;
1160 bool bSupportRemoteWakeUp;
1161 RT_PS_MODE dot11PowerSaveMode;
1162 bool actscanning;
1163 bool be_scan_inprogress;
1164 bool beinretry;
1165 RT_RF_POWER_STATE eRFPowerState;
1166 u32 RfOffReason;
1167 bool is_set_key;
1168
1169
1170 PRT_HIGH_THROUGHPUT pHTInfo;
1171 spinlock_t bw_spinlock;
1172
1173 spinlock_t reorder_spinlock;
1174
1175
1176
1177
1178
1179 u8 Regdot11HTOperationalRateSet[16];
1180 u8 dot11HTOperationalRateSet[16];
1181 u8 RegHTSuppRateSet[16];
1182 u8 HTCurrentOperaRate;
1183 u8 HTHighestOperaRate;
1184
1185 u8 bTxDisableRateFallBack;
1186 u8 bTxUseDriverAssingedRate;
1187 atomic_t atm_chnlop;
1188 atomic_t atm_swbw;
1189
1190
1191 struct list_head Tx_TS_Admit_List;
1192 struct list_head Tx_TS_Pending_List;
1193 struct list_head Tx_TS_Unused_List;
1194 TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM];
1195
1196 struct list_head Rx_TS_Admit_List;
1197 struct list_head Rx_TS_Pending_List;
1198 struct list_head Rx_TS_Unused_List;
1199 RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM];
1200
1201 RX_REORDER_ENTRY RxReorderEntry[128];
1202 struct list_head RxReorder_Unused_List;
1203
1204
1205
1206 u8 ForcedPriority;
1207
1208
1209 struct net_device_stats stats;
1210 struct ieee80211_stats ieee_stats;
1211 struct ieee80211_softmac_stats softmac_stats;
1212
1213
1214 struct list_head network_free_list;
1215 struct list_head network_list;
1216 struct ieee80211_network *networks;
1217 int scans;
1218 int scan_age;
1219
1220 int iw_mode;
1221 struct iw_spy_data spy_data;
1222
1223 spinlock_t lock;
1224 spinlock_t wpax_suitlist_lock;
1225
1226 int tx_headroom;
1227
1228 u32 config;
1229
1230
1231 int open_wep;
1232 int auth_mode;
1233 int reset_on_keychange;
1234
1235
1236
1237 int host_encrypt;
1238 int host_encrypt_msdu;
1239 int host_decrypt;
1240
1241 int host_mc_decrypt;
1242
1243
1244
1245 int host_strip_iv_icv;
1246
1247 int host_open_frag;
1248 int host_build_iv;
1249 int ieee802_1x;
1250
1251
1252 bool bHalfWirelessN24GMode;
1253 int wpa_enabled;
1254 int drop_unencrypted;
1255 int tkip_countermeasures;
1256 int privacy_invoked;
1257 size_t wpa_ie_len;
1258 u8 *wpa_ie;
1259 u8 ap_mac_addr[6];
1260 u16 pairwise_key_type;
1261 u16 group_key_type;
1262 struct list_head crypt_deinit_list;
1263 struct ieee80211_crypt_data *crypt[WEP_KEYS];
1264 int tx_keyidx;
1265 struct timer_list crypt_deinit_timer;
1266 int crypt_quiesced;
1267
1268 int bcrx_sta_key;
1269
1270
1271 RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE];
1272
1273
1274 struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
1275 unsigned int frag_next_idx[17];
1276 u16 fts;
1277#define DEFAULT_RTS_THRESHOLD 2346U
1278#define MIN_RTS_THRESHOLD 1
1279#define MAX_RTS_THRESHOLD 2346U
1280 u16 rts;
1281
1282
1283 u8 bssid[ETH_ALEN];
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293 struct ieee80211_network current_network;
1294
1295 enum ieee80211_state state;
1296
1297 int short_slot;
1298 int reg_mode;
1299 int mode;
1300 int modulation;
1301 int freq_band;
1302 int abg_true;
1303
1304
1305
1306
1307 short sync_scan_hurryup;
1308 u16 scan_watch_dog;
1309 int perfect_rssi;
1310 int worst_rssi;
1311
1312 u16 prev_seq_ctl;
1313
1314
1315
1316
1317
1318 void *pDot11dInfo;
1319 bool bGlobalDomain;
1320
1321 u8 IbssStartChnl;
1322 u8 ibss_maxjoin_chal;
1323
1324 int rate;
1325 int basic_rate;
1326
1327 short active_scan;
1328
1329
1330 u16 softmac_features;
1331
1332
1333 u16 seq_ctrl[5];
1334
1335
1336 u16 associate_seq;
1337
1338
1339 u16 assoc_id;
1340
1341
1342 u8 ack_tx_to_ieee;
1343 short ps;
1344 short sta_sleep;
1345 int ps_timeout;
1346 int ps_period;
1347 struct tasklet_struct ps_task;
1348 u32 ps_th;
1349 u32 ps_tl;
1350
1351 short raw_tx;
1352
1353 short queue_stop;
1354 short scanning;
1355 short proto_started;
1356
1357 struct semaphore wx_sem;
1358 struct semaphore scan_sem;
1359
1360 spinlock_t mgmt_tx_lock;
1361 spinlock_t beacon_lock;
1362
1363 short beacon_txing;
1364
1365 short wap_set;
1366 short ssid_set;
1367
1368 u8 wpax_type_set;
1369 u32 wpax_type_notify;
1370
1371
1372 char init_wmmparam_flag;
1373
1374 u8 qos_support;
1375
1376
1377 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1378
1379
1380 u16 last_rxseq_num[17];
1381 u16 last_rxfrag_num[17];
1382 unsigned long last_packet_time[17];
1383
1384
1385 unsigned long last_rx_ps_time;
1386
1387
1388 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1389 int mgmt_queue_head;
1390 int mgmt_queue_tail;
1391
1392
1393 u8 AsocRetryCount;
1394 unsigned int hw_header;
1395 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1396 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
1397 struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
1398 u32 sta_edca_param[4];
1399 bool aggregation;
1400
1401 bool enable_rx_imm_BA;
1402 bool bibsscoordinator;
1403
1404
1405 bool bdynamic_txpower_enable;
1406
1407 bool bCTSToSelfEnable;
1408 u8 CTSToSelfTH;
1409
1410 u32 fsync_time_interval;
1411 u32 fsync_rate_bitmap;
1412 u8 fsync_rssi_threshold;
1413 bool bfsync_enable;
1414
1415 u8 fsync_multiple_timeinterval;
1416 u32 fsync_firstdiff_ratethreshold;
1417 u32 fsync_seconddiff_ratethreshold;
1418 Fsync_State fsync_state;
1419 bool bis_any_nonbepkts;
1420
1421 struct bandwidth_autoswitch bandwidth_auto_switch;
1422
1423 bool FwRWRF;
1424
1425
1426 struct rt_link_detect LinkDetectInfo;
1427
1428 struct rt_power_save_control PowerSaveControl;
1429
1430
1431
1432 struct tx_pending_t tx_pending;
1433
1434
1435 struct timer_list associate_timer;
1436
1437
1438 struct timer_list beacon_timer;
1439 struct work_struct associate_complete_wq;
1440 struct work_struct associate_procedure_wq;
1441 struct delayed_work softmac_scan_wq;
1442 struct delayed_work associate_retry_wq;
1443 struct delayed_work start_ibss_wq;
1444 struct delayed_work hw_wakeup_wq;
1445 struct delayed_work hw_sleep_wq;
1446 struct delayed_work link_change_wq;
1447 struct work_struct wx_sync_scan_wq;
1448 struct workqueue_struct *wq;
1449
1450
1451 void (*set_security)(struct net_device *dev,
1452 struct ieee80211_security *sec);
1453
1454
1455
1456
1457
1458 int (*hard_start_xmit)(struct ieee80211_txb *txb,
1459 struct net_device *dev);
1460
1461 int (*reset_port)(struct net_device *dev);
1462 int (*is_queue_full)(struct net_device *dev, int pri);
1463
1464 int (*handle_management)(struct net_device *dev,
1465 struct ieee80211_network *network, u16 type);
1466 int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
1467
1468
1469
1470
1471
1472
1473
1474
1475 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1476 struct net_device *dev);
1477
1478
1479
1480
1481
1482
1483
1484 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1485 struct net_device *dev,int rate);
1486
1487
1488
1489
1490
1491 void (*data_hard_stop)(struct net_device *dev);
1492
1493
1494 void (*data_hard_resume)(struct net_device *dev);
1495
1496
1497
1498
1499
1500 void (*set_chan)(struct net_device *dev,short ch);
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517 void (*scan_syncro)(struct net_device *dev);
1518 void (*start_scan)(struct net_device *dev);
1519 void (*stop_scan)(struct net_device *dev);
1520
1521
1522
1523
1524
1525
1526 void (*link_change)(struct net_device *dev);
1527
1528
1529
1530
1531
1532
1533
1534 void (*start_send_beacons) (struct net_device *dev);
1535 void (*stop_send_beacons) (struct net_device *dev);
1536
1537
1538 void (*sta_wake_up) (struct net_device *dev);
1539 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
1540 short (*ps_is_queue_empty) (struct net_device *dev);
1541
1542 int (*handle_beacon)(struct net_device *dev,
1543 struct ieee80211_probe_response *beacon,
1544 struct ieee80211_network *network);
1545 int (*handle_assoc_response)(struct net_device *dev,
1546 struct ieee80211_assoc_response_frame *resp,
1547 struct ieee80211_network *network);
1548
1549
1550 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1551
1552 void (*SetBWModeHandler)(struct net_device *dev,
1553 HT_CHANNEL_WIDTH Bandwidth,
1554 HT_EXTCHNL_OFFSET Offset);
1555 bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
1556 void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
1557 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
1558 bool (*is_ap_in_wep_tkip)(struct net_device* dev);
1559 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
1560 bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO);
1561 void (*LedControlHandler)(struct net_device *dev,
1562 LED_CTL_MODE LedAction);
1563
1564
1565 u8 priv[0];
1566};
1567
1568#define IEEE_A (1<<0)
1569#define IEEE_B (1<<1)
1570#define IEEE_G (1<<2)
1571#define IEEE_N_24G (1<<4)
1572#define IEEE_N_5G (1<<5)
1573#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
1574
1575
1576
1577
1578
1579
1580#define IEEE_SOFTMAC_SCAN (1<<2)
1581
1582
1583#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1584
1585
1586#define IEEE_SOFTMAC_PROBERQ (1<<4)
1587
1588
1589#define IEEE_SOFTMAC_PROBERS (1<<5)
1590
1591
1592
1593
1594#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1595
1596
1597
1598
1599#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1600
1601
1602
1603
1604#define IEEE_SOFTMAC_BEACONS (1<<6)
1605
1606static inline void *ieee80211_priv(struct net_device *dev)
1607{
1608 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
1609}
1610
1611extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
1612{
1613
1614 if (essid_len == 1 && essid[0] == ' ')
1615 return 1;
1616
1617
1618 while (essid_len) {
1619 essid_len--;
1620 if (essid[essid_len] != '\0')
1621 return 0;
1622 }
1623
1624 return 1;
1625}
1626
1627extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
1628{
1629
1630
1631
1632
1633
1634
1635 if ((mode & IEEE_A) &&
1636 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1637 (ieee->freq_band & IEEE80211_52GHZ_BAND))
1638 return 1;
1639
1640 if ((mode & IEEE_G) &&
1641 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
1642 (ieee->freq_band & IEEE80211_24GHZ_BAND))
1643 return 1;
1644
1645 if ((mode & IEEE_B) &&
1646 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
1647 (ieee->freq_band & IEEE80211_24GHZ_BAND))
1648 return 1;
1649
1650 return 0;
1651}
1652
1653extern inline int ieee80211_get_hdrlen(u16 fc)
1654{
1655 int hdrlen = IEEE80211_3ADDR_LEN;
1656
1657 switch (WLAN_FC_GET_TYPE(fc)) {
1658 case IEEE80211_FTYPE_DATA:
1659 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
1660 hdrlen = IEEE80211_4ADDR_LEN;
1661 if(IEEE80211_QOS_HAS_SEQ(fc))
1662 hdrlen += 2;
1663 break;
1664 case IEEE80211_FTYPE_CTL:
1665 switch (WLAN_FC_GET_STYPE(fc)) {
1666 case IEEE80211_STYPE_CTS:
1667 case IEEE80211_STYPE_ACK:
1668 hdrlen = IEEE80211_1ADDR_LEN;
1669 break;
1670 default:
1671 hdrlen = IEEE80211_2ADDR_LEN;
1672 break;
1673 }
1674 break;
1675 }
1676
1677 return hdrlen;
1678}
1679
1680static inline u8 *ieee80211_get_payload(struct rtl_ieee80211_hdr *hdr)
1681{
1682 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
1683 case IEEE80211_1ADDR_LEN:
1684 return ((struct ieee80211_hdr_1addr *)hdr)->payload;
1685 case IEEE80211_2ADDR_LEN:
1686 return ((struct ieee80211_hdr_2addr *)hdr)->payload;
1687 case IEEE80211_3ADDR_LEN:
1688 return (void *)hdr+sizeof(struct ieee80211_hdr_3addr);
1689 case IEEE80211_4ADDR_LEN:
1690 return ((struct ieee80211_hdr_4addr *)hdr)->payload;
1691 }
1692 return NULL;
1693}
1694
1695static inline int ieee80211_is_ofdm_rate(u8 rate)
1696{
1697 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
1698 case IEEE80211_OFDM_RATE_6MB:
1699 case IEEE80211_OFDM_RATE_9MB:
1700 case IEEE80211_OFDM_RATE_12MB:
1701 case IEEE80211_OFDM_RATE_18MB:
1702 case IEEE80211_OFDM_RATE_24MB:
1703 case IEEE80211_OFDM_RATE_36MB:
1704 case IEEE80211_OFDM_RATE_48MB:
1705 case IEEE80211_OFDM_RATE_54MB:
1706 return 1;
1707 }
1708 return 0;
1709}
1710
1711static inline int ieee80211_is_cck_rate(u8 rate)
1712{
1713 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
1714 case IEEE80211_CCK_RATE_1MB:
1715 case IEEE80211_CCK_RATE_2MB:
1716 case IEEE80211_CCK_RATE_5MB:
1717 case IEEE80211_CCK_RATE_11MB:
1718 return 1;
1719 }
1720 return 0;
1721}
1722
1723
1724
1725extern void free_ieee80211(struct net_device *dev);
1726extern struct net_device *alloc_ieee80211(int sizeof_priv);
1727
1728extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
1729
1730
1731
1732extern int ieee80211_encrypt_fragment(
1733 struct ieee80211_device *ieee,
1734 struct sk_buff *frag,
1735 int hdr_len);
1736
1737extern int rtl8192_ieee80211_rtl_xmit(struct sk_buff *skb,
1738 struct net_device *dev);
1739extern void ieee80211_txb_free(struct ieee80211_txb *);
1740
1741
1742
1743extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
1744 struct ieee80211_rx_stats *rx_stats);
1745extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1746 struct ieee80211_hdr_4addr *header,
1747 struct ieee80211_rx_stats *stats);
1748
1749
1750extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
1751 struct iw_request_info *info,
1752 union iwreq_data *wrqu, char *key);
1753extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
1754 struct iw_request_info *info,
1755 union iwreq_data *wrqu, char *key);
1756extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
1757 struct iw_request_info *info,
1758 union iwreq_data *wrqu, char *key);
1759extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
1760 struct iw_request_info *info,
1761 union iwreq_data* wrqu, char *extra);
1762extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
1763 struct iw_request_info *info,
1764 struct iw_param *data, char *extra);
1765extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
1766 struct iw_request_info *info,
1767 union iwreq_data *wrqu, char *extra);
1768extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
1769
1770
1771extern short ieee80211_is_54g(struct ieee80211_network net);
1772extern short ieee80211_is_shortslot(struct ieee80211_network net);
1773extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
1774 struct ieee80211_rx_stats *rx_stats, u16 type,
1775 u16 stype);
1776extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
1777
1778void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn);
1779extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
1780
1781extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
1782extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
1783extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
1784extern void ieee80211_start_bss(struct ieee80211_device *ieee);
1785extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
1786extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
1787extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
1788extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
1789extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
1790extern void ieee80211_disassociate(struct ieee80211_device *ieee);
1791extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
1792extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
1793extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
1794extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
1795extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
1796extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
1797extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
1798extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
1799extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
1800extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
1801extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
1802extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
1803extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
1804extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
1805extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
1806extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
1807
1808extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
1809
1810
1811extern void ieee80211_tkip_null(void);
1812extern void ieee80211_wep_null(void);
1813extern void ieee80211_ccmp_null(void);
1814
1815
1816
1817extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
1818 struct iw_request_info *info,
1819 union iwreq_data *wrqu, char *ext);
1820
1821extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
1822 struct iw_request_info *info,
1823 union iwreq_data *awrq,
1824 char *extra);
1825
1826extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
1827
1828extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
1829 struct iw_request_info *info,
1830 union iwreq_data *wrqu, char *extra);
1831
1832extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
1833 struct iw_request_info *info,
1834 union iwreq_data *wrqu, char *extra);
1835
1836extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1837 union iwreq_data *wrqu, char *b);
1838
1839extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
1840 union iwreq_data *wrqu, char *b);
1841
1842extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
1843 struct iw_request_info *a,
1844 union iwreq_data *wrqu, char *extra);
1845
1846extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
1847 union iwreq_data *wrqu, char *b);
1848
1849extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1850 union iwreq_data *wrqu, char *b);
1851
1852extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
1853 union iwreq_data *wrqu, char *b);
1854
1855extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
1856
1857extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
1858 struct iw_request_info *info,
1859 union iwreq_data *wrqu, char *extra);
1860
1861extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
1862 struct iw_request_info *info,
1863 union iwreq_data *wrqu, char *extra);
1864
1865extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
1866 struct iw_request_info *info,
1867 union iwreq_data *wrqu, char *extra);
1868
1869extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
1870 struct iw_request_info *info,
1871 union iwreq_data *wrqu, char *extra);
1872
1873extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
1874 struct iw_request_info *info,
1875 union iwreq_data *wrqu, char *extra);
1876
1877extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
1878 struct iw_request_info *info,
1879 union iwreq_data *wrqu, char *extra);
1880
1881extern void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
1882
1883extern const long ieee80211_wlan_frequencies[];
1884
1885extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
1886{
1887 ieee->scans++;
1888}
1889
1890extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
1891{
1892 return ieee->scans;
1893}
1894
1895static inline const char *escape_essid(const char *essid, u8 essid_len) {
1896 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
1897 const char *s = essid;
1898 char *d = escaped;
1899
1900 if (ieee80211_is_empty_essid(essid, essid_len)) {
1901 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
1902 return escaped;
1903 }
1904
1905 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
1906 while (essid_len--) {
1907 if (*s == '\0') {
1908 *d++ = '\\';
1909 *d++ = '0';
1910 s++;
1911 } else {
1912 *d++ = *s++;
1913 }
1914 }
1915 *d = '\0';
1916 return escaped;
1917}
1918
1919
1920
1921
1922extern short check_nic_enough_desc(struct net_device *dev, int queue_index);
1923extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
1924extern int ieee80211_parse_info_param(struct ieee80211_device *ieee,
1925 struct ieee80211_info_element *info_element,
1926 u16 length,
1927 struct ieee80211_network *network,
1928 struct ieee80211_rx_stats *stats);
1929
1930extern void ieee80211_indicate_packets(struct ieee80211_device *ieee,
1931 struct ieee80211_rxb **prxbIndicateArray,
1932 u8 index);
1933#define RT_ASOC_RETRY_LIMIT 5
1934#endif
1935