This source file includes following definitions.
- eap_get_type
- Frame_QoSTID
- ieee80211_priv
- ieee80211_is_empty_essid
- ieee80211_is_valid_mode
- ieee80211_get_hdrlen
- ieee80211_get_payload
- ieee80211_is_ofdm_rate
- ieee80211_is_cck_rate
- ieee80211_increment_scans
- ieee80211_get_scans
- escape_essid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #ifndef IEEE80211_H
21 #define IEEE80211_H
22 #include <linux/if_ether.h>
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/jiffies.h>
26 #include <linux/timer.h>
27 #include <linux/sched.h>
28 #include <linux/semaphore.h>
29 #include <linux/interrupt.h>
30
31 #include <linux/delay.h>
32 #include <linux/wireless.h>
33 #include <linux/ieee80211.h>
34
35 #include "rtl819x_HT.h"
36 #include "rtl819x_BA.h"
37 #include "rtl819x_TS.h"
38
39
40 #ifndef IW_MODE_MONITOR
41 #define IW_MODE_MONITOR 6
42 #endif
43
44 #ifndef IWEVCUSTOM
45 #define IWEVCUSTOM 0x8c02
46 #endif
47
48 #define KEY_TYPE_NA 0x0
49 #define KEY_TYPE_WEP40 0x1
50 #define KEY_TYPE_TKIP 0x2
51 #define KEY_TYPE_CCMP 0x4
52 #define KEY_TYPE_WEP104 0x5
53
54
55 #define MAX_QUEUE_SIZE 0x10
56
57
58
59
60 #define BK_QUEUE 0
61 #define BE_QUEUE 1
62 #define VI_QUEUE 2
63 #define VO_QUEUE 3
64 #define HCCA_QUEUE 4
65 #define TXCMD_QUEUE 5
66 #define MGNT_QUEUE 6
67 #define HIGH_QUEUE 7
68 #define BEACON_QUEUE 8
69
70 #define LOW_QUEUE BE_QUEUE
71 #define NORMAL_QUEUE MGNT_QUEUE
72
73
74 #define SWRF_TIMEOUT 50
75
76
77 #define IE_CISCO_FLAG_POSITION 0x08
78 #define SUPPORT_CKIP_MIC 0x08
79 #define SUPPORT_CKIP_PK 0x10
80
81
82 struct cb_desc {
83
84 u8 bLastIniPkt:1;
85 u8 bCmdOrInit:1;
86 u8 bFirstSeg:1;
87 u8 bLastSeg:1;
88 u8 bEncrypt:1;
89 u8 bTxDisableRateFallBack:1;
90 u8 bTxUseDriverAssingedRate:1;
91 u8 bHwSec:1;
92
93 u8 reserved1;
94
95
96 u8 bCTSEnable:1;
97 u8 bRTSEnable:1;
98 u8 bUseShortGI:1;
99 u8 bUseShortPreamble:1;
100 u8 bTxEnableFwCalcDur:1;
101 u8 bAMPDUEnable:1;
102 u8 bRTSSTBC:1;
103 u8 RTSSC:1;
104
105 u8 bRTSBW:1;
106 u8 bPacketBW:1;
107 u8 bRTSUseShortPreamble:1;
108 u8 bRTSUseShortGI:1;
109 u8 bMulticast:1;
110 u8 bBroadcast:1;
111
112 u8 drv_agg_enable:1;
113 u8 reserved2:1;
114
115
116 u8 rata_index;
117 u8 queue_index;
118
119
120 u16 txbuf_size;
121
122 u8 RATRIndex;
123 u8 reserved6;
124 u8 reserved7;
125 u8 reserved8;
126
127
128 u8 data_rate;
129 u8 rts_rate;
130 u8 ampdu_factor;
131 u8 ampdu_density;
132
133
134
135 u8 DrvAggrNum;
136 u16 pkt_size;
137 u8 reserved12;
138 };
139
140
141 #define MGN_1M 0x02
142 #define MGN_2M 0x04
143 #define MGN_5_5M 0x0b
144 #define MGN_11M 0x16
145
146 #define MGN_6M 0x0c
147 #define MGN_9M 0x12
148 #define MGN_12M 0x18
149 #define MGN_18M 0x24
150 #define MGN_24M 0x30
151 #define MGN_36M 0x48
152 #define MGN_48M 0x60
153 #define MGN_54M 0x6c
154
155 #define MGN_MCS0 0x80
156 #define MGN_MCS1 0x81
157 #define MGN_MCS2 0x82
158 #define MGN_MCS3 0x83
159 #define MGN_MCS4 0x84
160 #define MGN_MCS5 0x85
161 #define MGN_MCS6 0x86
162 #define MGN_MCS7 0x87
163 #define MGN_MCS8 0x88
164 #define MGN_MCS9 0x89
165 #define MGN_MCS10 0x8a
166 #define MGN_MCS11 0x8b
167 #define MGN_MCS12 0x8c
168 #define MGN_MCS13 0x8d
169 #define MGN_MCS14 0x8e
170 #define MGN_MCS15 0x8f
171
172 #define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A || \
173 priv->ieee80211->current_network.mode == IEEE_N_24G || \
174 priv->ieee80211->current_network.mode == IEEE_N_5G) ? \
175 16 : 10)
176
177 #define MGMT_QUEUE_NUM 5
178
179 #define IEEE_CMD_SET_WPA_PARAM 1
180 #define IEEE_CMD_SET_WPA_IE 2
181 #define IEEE_CMD_SET_ENCRYPTION 3
182 #define IEEE_CMD_MLME 4
183
184 #define IEEE_PARAM_WPA_ENABLED 1
185 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
186 #define IEEE_PARAM_DROP_UNENCRYPTED 3
187 #define IEEE_PARAM_PRIVACY_INVOKED 4
188 #define IEEE_PARAM_AUTH_ALGS 5
189 #define IEEE_PARAM_IEEE_802_1X 6
190
191
192 #define IEEE_PARAM_WPAX_SELECT 7
193
194
195 #define IEEE_PROTO_WPA 1
196 #define IEEE_PROTO_RSN 2
197
198
199 #define IEEE_WPAX_USEGROUP 0
200 #define IEEE_WPAX_WEP40 1
201 #define IEEE_WPAX_TKIP 2
202 #define IEEE_WPAX_WRAP 3
203 #define IEEE_WPAX_CCMP 4
204 #define IEEE_WPAX_WEP104 5
205
206 #define IEEE_KEY_MGMT_IEEE8021X 1
207 #define IEEE_KEY_MGMT_PSK 2
208
209 #define IEEE_MLME_STA_DEAUTH 1
210 #define IEEE_MLME_STA_DISASSOC 2
211
212
213 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
214 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
215 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
216 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
217 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
218 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
219
220
221 #define IEEE_CRYPT_ALG_NAME_LEN 16
222
223 #define MAX_IE_LEN 0xff
224
225
226 #define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl
227 #define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl
228 #define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl
229 #define ieee80211_register_crypto_ops ieee80211_register_crypto_ops_rsl
230 #define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl
231 #define ieee80211_get_crypto_ops ieee80211_get_crypto_ops_rsl
232
233 #define ieee80211_ccmp_null ieee80211_ccmp_null_rsl
234
235 #define ieee80211_tkip_null ieee80211_tkip_null_rsl
236
237 #define free_ieee80211 free_ieee80211_rsl
238 #define alloc_ieee80211 alloc_ieee80211_rsl
239
240 #define ieee80211_rx ieee80211_rx_rsl
241 #define ieee80211_rx_mgt ieee80211_rx_mgt_rsl
242
243 #define ieee80211_get_beacon ieee80211_get_beacon_rsl
244 #define ieee80211_wake_queue ieee80211_wake_queue_rsl
245 #define ieee80211_stop_queue ieee80211_stop_queue_rsl
246 #define ieee80211_reset_queue ieee80211_reset_queue_rsl
247 #define ieee80211_softmac_stop_protocol ieee80211_softmac_stop_protocol_rsl
248 #define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
249 #define ieee80211_is_shortslot ieee80211_is_shortslot_rsl
250 #define ieee80211_is_54g ieee80211_is_54g_rsl
251 #define ieee80211_wpa_supplicant_ioctl ieee80211_wpa_supplicant_ioctl_rsl
252 #define ieee80211_ps_tx_ack ieee80211_ps_tx_ack_rsl
253 #define ieee80211_softmac_xmit ieee80211_softmac_xmit_rsl
254 #define ieee80211_stop_send_beacons ieee80211_stop_send_beacons_rsl
255 #define notify_wx_assoc_event notify_wx_assoc_event_rsl
256 #define SendDisassociation SendDisassociation_rsl
257 #define ieee80211_disassociate ieee80211_disassociate_rsl
258 #define ieee80211_start_send_beacons ieee80211_start_send_beacons_rsl
259 #define ieee80211_stop_scan ieee80211_stop_scan_rsl
260 #define ieee80211_send_probe_requests ieee80211_send_probe_requests_rsl
261 #define ieee80211_softmac_scan_syncro ieee80211_softmac_scan_syncro_rsl
262 #define ieee80211_start_scan_syncro ieee80211_start_scan_syncro_rsl
263
264 #define ieee80211_wx_get_essid ieee80211_wx_get_essid_rsl
265 #define ieee80211_wx_set_essid ieee80211_wx_set_essid_rsl
266 #define ieee80211_wx_set_rate ieee80211_wx_set_rate_rsl
267 #define ieee80211_wx_get_rate ieee80211_wx_get_rate_rsl
268 #define ieee80211_wx_set_wap ieee80211_wx_set_wap_rsl
269 #define ieee80211_wx_get_wap ieee80211_wx_get_wap_rsl
270 #define ieee80211_wx_set_mode ieee80211_wx_set_mode_rsl
271 #define ieee80211_wx_get_mode ieee80211_wx_get_mode_rsl
272 #define ieee80211_wx_set_scan ieee80211_wx_set_scan_rsl
273 #define ieee80211_wx_get_freq ieee80211_wx_get_freq_rsl
274 #define ieee80211_wx_set_freq ieee80211_wx_set_freq_rsl
275 #define ieee80211_wx_set_rawtx ieee80211_wx_set_rawtx_rsl
276 #define ieee80211_wx_get_name ieee80211_wx_get_name_rsl
277 #define ieee80211_wx_set_power ieee80211_wx_set_power_rsl
278 #define ieee80211_wx_get_power ieee80211_wx_get_power_rsl
279 #define ieee80211_wlan_frequencies ieee80211_wlan_frequencies_rsl
280 #define ieee80211_wx_set_rts ieee80211_wx_set_rts_rsl
281 #define ieee80211_wx_get_rts ieee80211_wx_get_rts_rsl
282
283 #define ieee80211_txb_free ieee80211_txb_free_rsl
284
285 #define ieee80211_wx_set_gen_ie ieee80211_wx_set_gen_ie_rsl
286 #define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl
287 #define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl
288 #define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl
289 #define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl
290 #define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl
291 #define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl
292 #define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl
293
294
295 struct ieee_param {
296 u32 cmd;
297 u8 sta_addr[ETH_ALEN];
298 union {
299 struct {
300 u8 name;
301 u32 value;
302 } wpa_param;
303 struct {
304 u32 len;
305 u8 reserved[32];
306 u8 data[0];
307 } wpa_ie;
308 struct{
309 int command;
310 int reason_code;
311 } mlme;
312 struct {
313 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
314 u8 set_tx;
315 u32 err;
316 u8 idx;
317 u8 seq[8];
318 u16 key_len;
319 u8 key[0];
320 } crypt;
321 } u;
322 };
323
324
325
326 #define IEEE80211_DATA_LEN 2304
327
328
329
330
331
332
333
334
335 #define IEEE80211_1ADDR_LEN 10
336 #define IEEE80211_2ADDR_LEN 16
337 #define IEEE80211_3ADDR_LEN 24
338 #define IEEE80211_4ADDR_LEN 30
339 #define IEEE80211_FCS_LEN 4
340 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
341 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
342 #define IEEE80211_MGMT_HDR_LEN 24
343 #define IEEE80211_DATA_HDR3_LEN 24
344 #define IEEE80211_DATA_HDR4_LEN 30
345
346 #define MIN_FRAG_THRESHOLD 256U
347 #define MAX_FRAG_THRESHOLD 2346U
348
349
350
351 #define IEEE80211_FCTL_VERS 0x0003
352 #define IEEE80211_FCTL_FTYPE 0x000c
353 #define IEEE80211_FCTL_STYPE 0x00f0
354 #define IEEE80211_FCTL_FRAMETYPE 0x00fc
355 #define IEEE80211_FCTL_TODS 0x0100
356 #define IEEE80211_FCTL_FROMDS 0x0200
357 #define IEEE80211_FCTL_DSTODS 0x0300
358 #define IEEE80211_FCTL_MOREFRAGS 0x0400
359 #define IEEE80211_FCTL_RETRY 0x0800
360 #define IEEE80211_FCTL_PM 0x1000
361 #define IEEE80211_FCTL_MOREDATA 0x2000
362 #define IEEE80211_FCTL_WEP 0x4000
363 #define IEEE80211_FCTL_ORDER 0x8000
364
365 #define IEEE80211_FTYPE_MGMT 0x0000
366 #define IEEE80211_FTYPE_CTL 0x0004
367 #define IEEE80211_FTYPE_DATA 0x0008
368
369
370 #define IEEE80211_STYPE_ASSOC_REQ 0x0000
371 #define IEEE80211_STYPE_ASSOC_RESP 0x0010
372 #define IEEE80211_STYPE_REASSOC_REQ 0x0020
373 #define IEEE80211_STYPE_REASSOC_RESP 0x0030
374 #define IEEE80211_STYPE_PROBE_REQ 0x0040
375 #define IEEE80211_STYPE_PROBE_RESP 0x0050
376 #define IEEE80211_STYPE_BEACON 0x0080
377 #define IEEE80211_STYPE_ATIM 0x0090
378 #define IEEE80211_STYPE_DISASSOC 0x00A0
379 #define IEEE80211_STYPE_AUTH 0x00B0
380 #define IEEE80211_STYPE_DEAUTH 0x00C0
381 #define IEEE80211_STYPE_MANAGE_ACT 0x00D0
382
383
384 #define IEEE80211_STYPE_PSPOLL 0x00A0
385 #define IEEE80211_STYPE_RTS 0x00B0
386 #define IEEE80211_STYPE_CTS 0x00C0
387 #define IEEE80211_STYPE_ACK 0x00D0
388 #define IEEE80211_STYPE_CFEND 0x00E0
389 #define IEEE80211_STYPE_CFENDACK 0x00F0
390 #define IEEE80211_STYPE_BLOCKACK 0x0094
391
392
393 #define IEEE80211_STYPE_DATA 0x0000
394 #define IEEE80211_STYPE_DATA_CFACK 0x0010
395 #define IEEE80211_STYPE_DATA_CFPOLL 0x0020
396 #define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
397 #define IEEE80211_STYPE_NULLFUNC 0x0040
398 #define IEEE80211_STYPE_CFACK 0x0050
399 #define IEEE80211_STYPE_CFPOLL 0x0060
400 #define IEEE80211_STYPE_CFACKPOLL 0x0070
401 #define IEEE80211_STYPE_QOS_DATA 0x0080
402 #define IEEE80211_STYPE_QOS_NULL 0x00C0
403
404 #define IEEE80211_SCTL_FRAG 0x000F
405 #define IEEE80211_SCTL_SEQ 0xFFF0
406
407
408 #define IEEE80211_QCTL_TID 0x000F
409
410 #define FC_QOS_BIT BIT(7)
411 #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
412 #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0] & FC_QOS_BIT)))
413
414 #define IsQoSDataFrame(pframe) ((*(u16 *)pframe & (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA))
415 #define Frame_Order(pframe) (*(u16 *)pframe & IEEE80211_FCTL_ORDER)
416 #define SN_LESS(a, b) (((a - b) & 0x800) != 0)
417 #define SN_EQUAL(a, b) (a == b)
418 #define MAX_DEV_ADDR_SIZE 8
419 typedef enum _ACT_CATEGORY {
420 ACT_CAT_QOS = 1,
421 ACT_CAT_DLS = 2,
422 ACT_CAT_BA = 3,
423 ACT_CAT_HT = 7,
424 ACT_CAT_WMM = 17,
425 } ACT_CATEGORY, *PACT_CATEGORY;
426
427 typedef enum _TS_ACTION {
428 ACT_ADDTSREQ = 0,
429 ACT_ADDTSRSP = 1,
430 ACT_DELTS = 2,
431 ACT_SCHEDULE = 3,
432 } TS_ACTION, *PTS_ACTION;
433
434 typedef enum _BA_ACTION {
435 ACT_ADDBAREQ = 0,
436 ACT_ADDBARSP = 1,
437 ACT_DELBA = 2,
438 } BA_ACTION, *PBA_ACTION;
439
440 typedef enum _InitialGainOpType {
441 IG_Backup = 0,
442 IG_Restore,
443 IG_Max
444 } InitialGainOpType;
445
446
447 #define CONFIG_IEEE80211_DEBUG
448 #ifdef CONFIG_IEEE80211_DEBUG
449 extern u32 ieee80211_debug_level;
450 #define IEEE80211_DEBUG(level, fmt, args...) \
451 do { if (ieee80211_debug_level & (level)) \
452 printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0)
453
454
455 #define IEEE80211_DEBUG_DATA(level, data, datalen) \
456 do { if ((ieee80211_debug_level & (level)) == (level)) \
457 { \
458 int i; \
459 u8 *pdata = (u8 *)data; \
460 printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \
461 for (i = 0; i < (int)(datalen); i++) { \
462 printk("%2x ", pdata[i]); \
463 if ((i + 1) % 16 == 0) \
464 printk("\n"); \
465 } \
466 printk("\n"); \
467 } \
468 } while (0)
469 #else
470 #define IEEE80211_DEBUG (level, fmt, args...) do {} while (0)
471 #define IEEE80211_DEBUG_DATA (level, data, datalen) do {} while (0)
472 #endif
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502 #define IEEE80211_DL_INFO (1<<0)
503 #define IEEE80211_DL_WX (1<<1)
504 #define IEEE80211_DL_SCAN (1<<2)
505 #define IEEE80211_DL_STATE (1<<3)
506 #define IEEE80211_DL_MGMT (1<<4)
507 #define IEEE80211_DL_FRAG (1<<5)
508 #define IEEE80211_DL_EAP (1<<6)
509 #define IEEE80211_DL_DROP (1<<7)
510
511 #define IEEE80211_DL_TX (1<<8)
512 #define IEEE80211_DL_RX (1<<9)
513
514 #define IEEE80211_DL_HT (1<<10)
515 #define IEEE80211_DL_BA (1<<11)
516 #define IEEE80211_DL_TS (1<<12)
517 #define IEEE80211_DL_QOS (1<<13)
518 #define IEEE80211_DL_REORDER (1<<14)
519 #define IEEE80211_DL_IOT (1<<15)
520 #define IEEE80211_DL_IPS (1<<16)
521 #define IEEE80211_DL_TRACE (1<<29)
522 #define IEEE80211_DL_DATA (1<<30)
523 #define IEEE80211_DL_ERR (1<<31)
524 #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
525 #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
526 #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
527
528 #define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
529 #define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
530 #define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
531 #define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
532 #define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
533 #define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
534 #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
535 #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
536 #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
537 #define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
538
539 #include <linux/if_arp.h>
540
541 #ifndef WIRELESS_SPY
542 #define WIRELESS_SPY
543 #endif
544 #include <net/iw_handler.h>
545
546 #ifndef ETH_P_PAE
547 #define ETH_P_PAE 0x888E
548 #endif
549
550 #define ETH_P_PREAUTH 0x88C7
551
552 #ifndef ETH_P_80211_RAW
553 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
554 #endif
555
556
557
558 #define P80211_OUI_LEN 3
559
560 struct ieee80211_snap_hdr {
561
562 u8 dsap;
563 u8 ssap;
564 u8 ctrl;
565 u8 oui[P80211_OUI_LEN];
566
567 } __packed;
568
569 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
570
571 #define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
572 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
573 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
574
575 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
576 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
577 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
578
579 #define WLAN_CAPABILITY_BSS (1<<0)
580 #define WLAN_CAPABILITY_IBSS (1<<1)
581 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
582 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
583 #define WLAN_CAPABILITY_PRIVACY (1<<4)
584 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
585 #define WLAN_CAPABILITY_PBCC (1<<6)
586 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
587 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
588 #define WLAN_CAPABILITY_QOS (1<<9)
589 #define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
590 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
591
592
593 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
594 #define WLAN_ERP_USE_PROTECTION (1<<1)
595 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
596
597 #define IEEE80211_STATMASK_SIGNAL (1<<0)
598 #define IEEE80211_STATMASK_RSSI (1<<1)
599 #define IEEE80211_STATMASK_NOISE (1<<2)
600 #define IEEE80211_STATMASK_RATE (1<<3)
601 #define IEEE80211_STATMASK_WEMASK 0x7
602
603 #define IEEE80211_CCK_MODULATION (1<<0)
604 #define IEEE80211_OFDM_MODULATION (1<<1)
605
606 #define IEEE80211_24GHZ_BAND (1<<0)
607 #define IEEE80211_52GHZ_BAND (1<<1)
608
609 #define IEEE80211_CCK_RATE_LEN 4
610 #define IEEE80211_CCK_RATE_1MB 0x02
611 #define IEEE80211_CCK_RATE_2MB 0x04
612 #define IEEE80211_CCK_RATE_5MB 0x0B
613 #define IEEE80211_CCK_RATE_11MB 0x16
614 #define IEEE80211_OFDM_RATE_LEN 8
615 #define IEEE80211_OFDM_RATE_6MB 0x0C
616 #define IEEE80211_OFDM_RATE_9MB 0x12
617 #define IEEE80211_OFDM_RATE_12MB 0x18
618 #define IEEE80211_OFDM_RATE_18MB 0x24
619 #define IEEE80211_OFDM_RATE_24MB 0x30
620 #define IEEE80211_OFDM_RATE_36MB 0x48
621 #define IEEE80211_OFDM_RATE_48MB 0x60
622 #define IEEE80211_OFDM_RATE_54MB 0x6C
623 #define IEEE80211_BASIC_RATE_MASK 0x80
624
625 #define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
626 #define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
627 #define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
628 #define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
629 #define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
630 #define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
631 #define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
632 #define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
633 #define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
634 #define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
635 #define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
636 #define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
637
638 #define IEEE80211_CCK_RATES_MASK 0x0000000F
639 #define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
640 IEEE80211_CCK_RATE_2MB_MASK)
641 #define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
642 IEEE80211_CCK_RATE_5MB_MASK | \
643 IEEE80211_CCK_RATE_11MB_MASK)
644
645 #define IEEE80211_OFDM_RATES_MASK 0x00000FF0
646 #define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
647 IEEE80211_OFDM_RATE_12MB_MASK | \
648 IEEE80211_OFDM_RATE_24MB_MASK)
649 #define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
650 IEEE80211_OFDM_RATE_9MB_MASK | \
651 IEEE80211_OFDM_RATE_18MB_MASK | \
652 IEEE80211_OFDM_RATE_36MB_MASK | \
653 IEEE80211_OFDM_RATE_48MB_MASK | \
654 IEEE80211_OFDM_RATE_54MB_MASK)
655 #define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
656 IEEE80211_CCK_DEFAULT_RATES_MASK)
657
658 #define IEEE80211_NUM_OFDM_RATES 8
659 #define IEEE80211_NUM_CCK_RATES 4
660 #define IEEE80211_OFDM_SHIFT_MASK_A 4
661
662
663
664 #define IEEE80211_FC0_TYPE_MASK 0x0c
665 #define IEEE80211_FC0_TYPE_DATA 0x08
666 #define IEEE80211_FC0_SUBTYPE_MASK 0xB0
667 #define IEEE80211_FC0_SUBTYPE_QOS 0x80
668
669 #define IEEE80211_QOS_HAS_SEQ(fc) \
670 (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
671 (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
672
673
674 #define IEEE_IBSS_MAC_HASH_SIZE 31
675 struct ieee_ibss_seq {
676 u8 mac[ETH_ALEN];
677 u16 seq_num[17];
678 u16 frag_num[17];
679 unsigned long packet_time[17];
680 struct list_head list;
681 };
682
683
684
685
686
687 struct ieee80211_rx_stats {
688 u32 mac_time[2];
689 s8 rssi;
690 u8 signal;
691 u8 noise;
692 u16 rate;
693 u8 received_channel;
694 u8 control;
695 u8 mask;
696 u8 freq;
697 u16 len;
698 u64 tsf;
699 u32 beacon_time;
700 u8 nic_type;
701 u16 Length;
702
703 u8 SignalQuality;
704 s32 RecvSignalPower;
705 s8 RxPower;
706 u8 SignalStrength;
707 u16 bHwError:1;
708 u16 bCRC:1;
709 u16 bICV:1;
710 u16 bShortPreamble:1;
711 u16 Antenna:1;
712 u16 Decrypted:1;
713 u16 Wakeup:1;
714 u16 Reserved0:1;
715 u8 AGC;
716 u32 TimeStampLow;
717 u32 TimeStampHigh;
718 bool bShift;
719 bool bIsQosData;
720 u8 UserPriority;
721
722
723
724
725
726 u8 RxDrvInfoSize;
727 u8 RxBufShift;
728 bool bIsAMPDU;
729 bool bFirstMPDU;
730 bool bContainHTC;
731 bool RxIs40MHzPacket;
732 u32 RxPWDBAll;
733 u8 RxMIMOSignalStrength[4];
734 s8 RxMIMOSignalQuality[2];
735 bool bPacketMatchBSSID;
736 bool bIsCCK;
737 bool bPacketToSelf;
738
739 u8 *virtual_address;
740 u16 packetlength;
741 u16 fraglength;
742 u16 fragoffset;
743 u16 ntotalfrag;
744 bool bisrxaggrsubframe;
745 bool bPacketBeacon;
746 bool bToSelfBA;
747 s8 cck_adc_pwdb[4];
748 u16 Seq_Num;
749
750 };
751
752
753
754
755
756
757 #define IEEE80211_FRAG_CACHE_LEN 4
758
759 struct ieee80211_frag_entry {
760 unsigned long first_frag_time;
761 unsigned int seq;
762 unsigned int last_frag;
763 struct sk_buff *skb;
764 u8 src_addr[ETH_ALEN];
765 u8 dst_addr[ETH_ALEN];
766 };
767
768 struct ieee80211_stats {
769 unsigned int tx_unicast_frames;
770 unsigned int tx_multicast_frames;
771 unsigned int tx_fragments;
772 unsigned int tx_unicast_octets;
773 unsigned int tx_multicast_octets;
774 unsigned int tx_deferred_transmissions;
775 unsigned int tx_single_retry_frames;
776 unsigned int tx_multiple_retry_frames;
777 unsigned int tx_retry_limit_exceeded;
778 unsigned int tx_discards;
779 unsigned int rx_unicast_frames;
780 unsigned int rx_multicast_frames;
781 unsigned int rx_fragments;
782 unsigned int rx_unicast_octets;
783 unsigned int rx_multicast_octets;
784 unsigned int rx_fcs_errors;
785 unsigned int rx_discards_no_buffer;
786 unsigned int tx_discards_wrong_sa;
787 unsigned int rx_discards_undecryptable;
788 unsigned int rx_message_in_msg_fragments;
789 unsigned int rx_message_in_bad_msg_fragments;
790 };
791
792 struct ieee80211_device;
793
794 #include "ieee80211_crypt.h"
795
796 #define SEC_KEY_1 (1<<0)
797 #define SEC_KEY_2 (1<<1)
798 #define SEC_KEY_3 (1<<2)
799 #define SEC_KEY_4 (1<<3)
800 #define SEC_ACTIVE_KEY (1<<4)
801 #define SEC_AUTH_MODE (1<<5)
802 #define SEC_UNICAST_GROUP (1<<6)
803 #define SEC_LEVEL (1<<7)
804 #define SEC_ENABLED (1<<8)
805 #define SEC_ENCRYPT (1<<9)
806
807 #define SEC_LEVEL_0 0
808 #define SEC_LEVEL_1 1
809 #define SEC_LEVEL_2 2
810 #define SEC_LEVEL_2_CKIP 3
811 #define SEC_LEVEL_3 4
812
813 #define SEC_ALG_NONE 0
814 #define SEC_ALG_WEP 1
815 #define SEC_ALG_TKIP 2
816 #define SEC_ALG_CCMP 3
817
818 #define WEP_KEYS 4
819 #define WEP_KEY_LEN 13
820 #define SCM_KEY_LEN 32
821 #define SCM_TEMPORAL_KEY_LENGTH 16
822
823 struct ieee80211_security {
824 u16 active_key:2,
825 enabled:1,
826 auth_algo:4,
827 unicast_uses_group:1,
828 encrypt:1;
829 u8 auth_mode;
830 u8 key_sizes[WEP_KEYS];
831 u8 keys[WEP_KEYS][SCM_KEY_LEN];
832 u8 level;
833 u16 flags;
834 } __packed;
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849 enum ieee80211_mfie {
850 MFIE_TYPE_SSID = 0,
851 MFIE_TYPE_RATES = 1,
852 MFIE_TYPE_FH_SET = 2,
853 MFIE_TYPE_DS_SET = 3,
854 MFIE_TYPE_CF_SET = 4,
855 MFIE_TYPE_TIM = 5,
856 MFIE_TYPE_IBSS_SET = 6,
857 MFIE_TYPE_COUNTRY = 7,
858 MFIE_TYPE_HOP_PARAMS = 8,
859 MFIE_TYPE_HOP_TABLE = 9,
860 MFIE_TYPE_REQUEST = 10,
861 MFIE_TYPE_CHALLENGE = 16,
862 MFIE_TYPE_POWER_CONSTRAINT = 32,
863 MFIE_TYPE_POWER_CAPABILITY = 33,
864 MFIE_TYPE_TPC_REQUEST = 34,
865 MFIE_TYPE_TPC_REPORT = 35,
866 MFIE_TYPE_SUPP_CHANNELS = 36,
867 MFIE_TYPE_CSA = 37,
868 MFIE_TYPE_MEASURE_REQUEST = 38,
869 MFIE_TYPE_MEASURE_REPORT = 39,
870 MFIE_TYPE_QUIET = 40,
871 MFIE_TYPE_IBSS_DFS = 41,
872 MFIE_TYPE_ERP = 42,
873 MFIE_TYPE_RSN = 48,
874 MFIE_TYPE_RATES_EX = 50,
875 MFIE_TYPE_HT_CAP = 45,
876 MFIE_TYPE_HT_INFO = 61,
877 MFIE_TYPE_AIRONET = 133,
878 MFIE_TYPE_GENERIC = 221,
879 MFIE_TYPE_QOS_PARAMETER = 222,
880 };
881
882
883
884
885
886 struct rtl_80211_hdr {
887 __le16 frame_ctl;
888 __le16 duration_id;
889 u8 payload[0];
890 } __packed;
891
892 struct rtl_80211_hdr_1addr {
893 __le16 frame_ctl;
894 __le16 duration_id;
895 u8 addr1[ETH_ALEN];
896 u8 payload[0];
897 } __packed;
898
899 struct rtl_80211_hdr_2addr {
900 __le16 frame_ctl;
901 __le16 duration_id;
902 u8 addr1[ETH_ALEN];
903 u8 addr2[ETH_ALEN];
904 u8 payload[0];
905 } __packed;
906
907 struct rtl_80211_hdr_3addr {
908 __le16 frame_ctl;
909 __le16 duration_id;
910 u8 addr1[ETH_ALEN];
911 u8 addr2[ETH_ALEN];
912 u8 addr3[ETH_ALEN];
913 __le16 seq_ctl;
914 u8 payload[0];
915 } __packed;
916
917 struct rtl_80211_hdr_4addr {
918 __le16 frame_ctl;
919 __le16 duration_id;
920 u8 addr1[ETH_ALEN];
921 u8 addr2[ETH_ALEN];
922 u8 addr3[ETH_ALEN];
923 __le16 seq_ctl;
924 u8 addr4[ETH_ALEN];
925 u8 payload[0];
926 } __packed;
927
928 struct rtl_80211_hdr_3addrqos {
929 __le16 frame_ctl;
930 __le16 duration_id;
931 u8 addr1[ETH_ALEN];
932 u8 addr2[ETH_ALEN];
933 u8 addr3[ETH_ALEN];
934 __le16 seq_ctl;
935 u8 payload[0];
936 __le16 qos_ctl;
937 } __packed;
938
939 struct rtl_80211_hdr_4addrqos {
940 __le16 frame_ctl;
941 __le16 duration_id;
942 u8 addr1[ETH_ALEN];
943 u8 addr2[ETH_ALEN];
944 u8 addr3[ETH_ALEN];
945 __le16 seq_ctl;
946 u8 addr4[ETH_ALEN];
947 u8 payload[0];
948 __le16 qos_ctl;
949 } __packed;
950
951 struct ieee80211_info_element {
952 u8 id;
953 u8 len;
954 u8 data[0];
955 } __packed;
956
957 struct ieee80211_authentication {
958 struct rtl_80211_hdr_3addr header;
959 __le16 algorithm;
960 __le16 transaction;
961 __le16 status;
962
963 struct ieee80211_info_element info_element[0];
964 } __packed;
965
966 struct ieee80211_disassoc {
967 struct rtl_80211_hdr_3addr header;
968 __le16 reason;
969 } __packed;
970
971 struct ieee80211_probe_request {
972 struct rtl_80211_hdr_3addr header;
973
974 struct ieee80211_info_element info_element[0];
975 } __packed;
976
977 struct ieee80211_probe_response {
978 struct rtl_80211_hdr_3addr header;
979 __le32 time_stamp[2];
980 __le16 beacon_interval;
981 __le16 capability;
982
983
984
985 struct ieee80211_info_element info_element[0];
986 } __packed;
987
988
989 #define ieee80211_beacon ieee80211_probe_response
990
991 struct ieee80211_assoc_request_frame {
992 struct rtl_80211_hdr_3addr header;
993 __le16 capability;
994 __le16 listen_interval;
995
996 struct ieee80211_info_element info_element[0];
997 } __packed;
998
999 struct ieee80211_reassoc_request_frame {
1000 struct rtl_80211_hdr_3addr header;
1001 __le16 capability;
1002 __le16 listen_interval;
1003 u8 current_ap[ETH_ALEN];
1004
1005 struct ieee80211_info_element info_element[0];
1006 } __packed;
1007
1008 struct ieee80211_assoc_response_frame {
1009 struct rtl_80211_hdr_3addr header;
1010 __le16 capability;
1011 __le16 status;
1012 __le16 aid;
1013 struct ieee80211_info_element info_element[0];
1014 } __packed;
1015
1016 struct ieee80211_txb {
1017 u8 nr_frags;
1018 u8 encrypted;
1019 u8 queue_index;
1020 u8 rts_included;
1021 u16 reserved;
1022 __le16 frag_size;
1023 __le16 payload_size;
1024 struct sk_buff *fragments[0];
1025 };
1026
1027 #define MAX_TX_AGG_COUNT 16
1028 struct ieee80211_drv_agg_txb {
1029 u8 nr_drv_agg_frames;
1030 struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
1031 } __packed;
1032
1033 #define MAX_SUBFRAME_COUNT 64
1034 struct ieee80211_rxb {
1035 u8 nr_subframes;
1036 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
1037 u8 dst[ETH_ALEN];
1038 u8 src[ETH_ALEN];
1039 } __packed;
1040
1041 typedef union _frameqos {
1042 u16 shortdata;
1043 u8 chardata[2];
1044 struct {
1045 u16 tid:4;
1046 u16 eosp:1;
1047 u16 ack_policy:2;
1048 u16 reserved:1;
1049 u16 txop:8;
1050 } field;
1051 } frameqos, *pframeqos;
1052
1053
1054 #define MAX_SWEEP_TAB_ENTRIES 42
1055 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
1056
1057
1058
1059
1060
1061 #define MAX_RATES_LENGTH ((u8)12)
1062 #define MAX_RATES_EX_LENGTH ((u8)16)
1063 #define MAX_NETWORK_COUNT 128
1064
1065 #define MAX_CHANNEL_NUMBER 161
1066 #define IEEE80211_SOFTMAC_SCAN_TIME 100
1067
1068 #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1069
1070 #define CRC_LENGTH 4U
1071
1072 #define MAX_WPA_IE_LEN 64
1073
1074 #define NETWORK_EMPTY_ESSID (1<<0)
1075 #define NETWORK_HAS_OFDM (1<<1)
1076 #define NETWORK_HAS_CCK (1<<2)
1077
1078
1079 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1080 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
1081 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1082 NETWORK_HAS_QOS_INFORMATION)
1083
1084 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
1085 #define NETWORK_HAS_CSA (1<<6)
1086 #define NETWORK_HAS_QUIET (1<<7)
1087 #define NETWORK_HAS_IBSS_DFS (1<<8)
1088 #define NETWORK_HAS_TPC_REPORT (1<<9)
1089
1090 #define NETWORK_HAS_ERP_VALUE (1<<10)
1091
1092 #define QOS_QUEUE_NUM 4
1093 #define QOS_OUI_LEN 3
1094 #define QOS_OUI_TYPE 2
1095 #define QOS_ELEMENT_ID 221
1096 #define QOS_OUI_INFO_SUB_TYPE 0
1097 #define QOS_OUI_PARAM_SUB_TYPE 1
1098 #define QOS_VERSION_1 1
1099 #define QOS_AIFSN_MIN_VALUE 2
1100 struct ieee80211_qos_information_element {
1101 u8 elementID;
1102 u8 length;
1103 u8 qui[QOS_OUI_LEN];
1104 u8 qui_type;
1105 u8 qui_subtype;
1106 u8 version;
1107 u8 ac_info;
1108 } __packed;
1109
1110 struct ieee80211_qos_ac_parameter {
1111 u8 aci_aifsn;
1112 u8 ecw_min_max;
1113 __le16 tx_op_limit;
1114 } __packed;
1115
1116 struct ieee80211_qos_parameter_info {
1117 struct ieee80211_qos_information_element info_element;
1118 u8 reserved;
1119 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1120 } __packed;
1121
1122 struct ieee80211_qos_parameters {
1123 __le16 cw_min[QOS_QUEUE_NUM];
1124 __le16 cw_max[QOS_QUEUE_NUM];
1125 u8 aifs[QOS_QUEUE_NUM];
1126 u8 flag[QOS_QUEUE_NUM];
1127 __le16 tx_op_limit[QOS_QUEUE_NUM];
1128 } __packed;
1129
1130 struct ieee80211_qos_data {
1131 struct ieee80211_qos_parameters parameters;
1132 int active;
1133 int supported;
1134 u8 param_count;
1135 u8 old_param_count;
1136 };
1137
1138 struct ieee80211_tim_parameters {
1139 u8 tim_count;
1140 u8 tim_period;
1141 } __packed;
1142
1143
1144 struct ieee80211_wmm_ts_info {
1145 u8 ac_dir_tid;
1146 u8 ac_up_psb;
1147 u8 reserved;
1148 } __packed;
1149
1150 struct ieee80211_wmm_tspec_elem {
1151 struct ieee80211_wmm_ts_info ts_info;
1152 u16 norm_msdu_size;
1153 u16 max_msdu_size;
1154 u32 min_serv_inter;
1155 u32 max_serv_inter;
1156 u32 inact_inter;
1157 u32 suspen_inter;
1158 u32 serv_start_time;
1159 u32 min_data_rate;
1160 u32 mean_data_rate;
1161 u32 peak_data_rate;
1162 u32 max_burst_size;
1163 u32 delay_bound;
1164 u32 min_phy_rate;
1165 u16 surp_band_allow;
1166 u16 medium_time;
1167 } __packed;
1168 enum eap_type {
1169 EAP_PACKET = 0,
1170 EAPOL_START,
1171 EAPOL_LOGOFF,
1172 EAPOL_KEY,
1173 EAPOL_ENCAP_ASF_ALERT
1174 };
1175
1176 static const char *eap_types[] = {
1177 [EAP_PACKET] = "EAP-Packet",
1178 [EAPOL_START] = "EAPOL-Start",
1179 [EAPOL_LOGOFF] = "EAPOL-Logoff",
1180 [EAPOL_KEY] = "EAPOL-Key",
1181 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1182 };
1183
1184 static inline const char *eap_get_type(int type)
1185 {
1186 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
1187 }
1188
1189 static inline u8 Frame_QoSTID(u8 *buf)
1190 {
1191 struct rtl_80211_hdr_3addr *hdr;
1192 u16 fc;
1193 hdr = (struct rtl_80211_hdr_3addr *)buf;
1194 fc = le16_to_cpu(hdr->frame_ctl);
1195 return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) && (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
1196 }
1197
1198
1199
1200 struct eapol {
1201 u8 snap[6];
1202 u16 ethertype;
1203 u8 version;
1204 u8 type;
1205 u16 length;
1206 } __packed;
1207
1208 struct ieee80211_softmac_stats {
1209 unsigned int rx_ass_ok;
1210 unsigned int rx_ass_err;
1211 unsigned int rx_probe_rq;
1212 unsigned int tx_probe_rs;
1213 unsigned int tx_beacons;
1214 unsigned int rx_auth_rq;
1215 unsigned int rx_auth_rs_ok;
1216 unsigned int rx_auth_rs_err;
1217 unsigned int tx_auth_rq;
1218 unsigned int no_auth_rs;
1219 unsigned int no_ass_rs;
1220 unsigned int tx_ass_rq;
1221 unsigned int rx_ass_rq;
1222 unsigned int tx_probe_rq;
1223 unsigned int reassoc;
1224 unsigned int swtxstop;
1225 unsigned int swtxawake;
1226 unsigned char CurrentShowTxate;
1227 unsigned char last_packet_rate;
1228 unsigned int txretrycount;
1229 };
1230
1231 #define BEACON_PROBE_SSID_ID_POSITION 12
1232
1233 struct ieee80211_info_element_hdr {
1234 u8 id;
1235 u8 len;
1236 } __packed;
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255 #define IEEE80211_DEFAULT_TX_ESSID "Penguin"
1256 #define IEEE80211_DEFAULT_BASIC_RATE 2
1257
1258 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1259 #define MAX_SP_Len (WMM_all_frame << 4)
1260 #define IEEE80211_QOS_TID 0x0f
1261 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1262
1263 #define IEEE80211_DTIM_MBCAST 4
1264 #define IEEE80211_DTIM_UCAST 2
1265 #define IEEE80211_DTIM_VALID 1
1266 #define IEEE80211_DTIM_INVALID 0
1267
1268 #define IEEE80211_PS_DISABLED 0
1269 #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
1270 #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
1271
1272
1273
1274 #ifdef WMM_Hang_8187
1275 #undef WMM_Hang_8187
1276 #endif
1277
1278 #define WME_AC_BK 0x00
1279 #define WME_AC_BE 0x01
1280 #define WME_AC_VI 0x02
1281 #define WME_AC_VO 0x03
1282 #define WME_ACI_MASK 0x03
1283 #define WME_AIFSN_MASK 0x03
1284 #define WME_AC_PRAM_LEN 16
1285
1286 #define MAX_RECEIVE_BUFFER_SIZE 9100
1287
1288
1289
1290 #define UP2AC(up) ( \
1291 ((up) < 1) ? WME_AC_BE : \
1292 ((up) < 3) ? WME_AC_BK : \
1293 ((up) < 4) ? WME_AC_BE : \
1294 ((up) < 6) ? WME_AC_VI : \
1295 WME_AC_VO)
1296
1297 #define AC2UP(_ac) ( \
1298 ((_ac) == WME_AC_VO) ? 6 : \
1299 ((_ac) == WME_AC_VI) ? 5 : \
1300 ((_ac) == WME_AC_BK) ? 1 : \
1301 0)
1302
1303 #define ETHER_ADDR_LEN 6
1304 #define ETHERNET_HEADER_SIZE 14
1305
1306 struct ether_header {
1307 u8 ether_dhost[ETHER_ADDR_LEN];
1308 u8 ether_shost[ETHER_ADDR_LEN];
1309 u16 ether_type;
1310 } __packed;
1311
1312 #ifndef ETHERTYPE_PAE
1313 #define ETHERTYPE_PAE 0x888e
1314 #endif
1315 #ifndef ETHERTYPE_IP
1316 #define ETHERTYPE_IP 0x0800
1317 #endif
1318
1319 typedef enum _erp_t {
1320 ERP_NonERPpresent = 0x01,
1321 ERP_UseProtection = 0x02,
1322 ERP_BarkerPreambleMode = 0x04,
1323 } erp_t;
1324
1325
1326 struct ieee80211_network {
1327
1328 u8 bssid[ETH_ALEN];
1329 u8 channel;
1330
1331
1332 bool bMBssidValid;
1333 u8 MBssid[ETH_ALEN];
1334 u8 MBssidMask;
1335
1336 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1337 u8 ssid_len;
1338 struct ieee80211_qos_data qos_data;
1339
1340
1341 bool bWithAironetIE;
1342 bool bCkipSupported;
1343 bool bCcxRmEnable;
1344 u16 CcxRmState[2];
1345
1346 bool bWithCcxVerNum;
1347 u8 BssCcxVerNumber;
1348
1349 struct ieee80211_rx_stats stats;
1350 u16 capability;
1351 u8 rates[MAX_RATES_LENGTH];
1352 u8 rates_len;
1353 u8 rates_ex[MAX_RATES_EX_LENGTH];
1354 u8 rates_ex_len;
1355 unsigned long last_scanned;
1356 u8 mode;
1357 u32 flags;
1358 u32 last_associate;
1359 u32 time_stamp[2];
1360 u16 beacon_interval;
1361 u16 listen_interval;
1362 u16 atim_window;
1363 u8 erp_value;
1364 u8 wpa_ie[MAX_WPA_IE_LEN];
1365 size_t wpa_ie_len;
1366 u8 rsn_ie[MAX_WPA_IE_LEN];
1367 size_t rsn_ie_len;
1368
1369 struct ieee80211_tim_parameters tim;
1370 u8 dtim_period;
1371 u8 dtim_data;
1372 u32 last_dtim_sta_time[2];
1373
1374
1375 u8 wmm_info;
1376 struct ieee80211_wmm_ac_param wmm_param[4];
1377 u8 QoS_Enable;
1378 #ifdef THOMAS_TURBO
1379 u8 Turbo_Enable;
1380 #endif
1381 u16 CountryIeLen;
1382 u8 CountryIeBuf[MAX_IE_LEN];
1383
1384 BSS_HT bssht;
1385
1386 bool broadcom_cap_exist;
1387 bool ralink_cap_exist;
1388 bool atheros_cap_exist;
1389 bool cisco_cap_exist;
1390 bool unknown_cap_exist;
1391
1392 bool berp_info_valid;
1393 bool buseprotection;
1394
1395 struct list_head list;
1396 };
1397
1398 enum ieee80211_state {
1399
1400
1401 IEEE80211_NOLINK = 0,
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412 IEEE80211_ASSOCIATING,
1413 IEEE80211_ASSOCIATING_RETRY,
1414
1415
1416 IEEE80211_ASSOCIATING_AUTHENTICATING,
1417
1418
1419
1420
1421 IEEE80211_ASSOCIATING_AUTHENTICATED,
1422
1423
1424
1425
1426 IEEE80211_LINKED,
1427
1428
1429
1430
1431
1432
1433 IEEE80211_LINKED_SCANNING,
1434
1435 };
1436
1437 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1438 #define DEFAULT_FTS 2346
1439
1440 #define CFG_IEEE80211_RESERVE_FCS (1<<0)
1441 #define CFG_IEEE80211_COMPUTE_FCS (1<<1)
1442 #define CFG_IEEE80211_RTS (1<<2)
1443
1444 #define IEEE80211_24GHZ_MIN_CHANNEL 1
1445 #define IEEE80211_24GHZ_MAX_CHANNEL 14
1446 #define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
1447 IEEE80211_24GHZ_MIN_CHANNEL + 1)
1448
1449 #define IEEE80211_52GHZ_MIN_CHANNEL 34
1450 #define IEEE80211_52GHZ_MAX_CHANNEL 165
1451 #define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
1452 IEEE80211_52GHZ_MIN_CHANNEL + 1)
1453
1454
1455
1456 struct tx_pending {
1457 int frag;
1458 struct ieee80211_txb *txb;
1459 };
1460
1461 struct bandwidth_autoswitch {
1462 long threshold_20Mhzto40Mhz;
1463 long threshold_40Mhzto20Mhz;
1464 bool bforced_tx20Mhz;
1465 bool bautoswitch_enable;
1466 };
1467
1468
1469
1470
1471 #define REORDER_WIN_SIZE 128
1472 #define REORDER_ENTRY_NUM 128
1473 struct rx_reorder_entry {
1474 struct list_head List;
1475 u16 SeqNum;
1476 struct ieee80211_rxb *prxb;
1477 };
1478
1479 typedef enum _Fsync_State {
1480 Default_Fsync,
1481 HW_Fsync,
1482 SW_Fsync
1483 } Fsync_State;
1484
1485
1486 typedef enum _RT_PS_MODE {
1487 eActive,
1488 eMaxPs,
1489 eFastPs
1490 } RT_PS_MODE;
1491
1492 typedef enum _IPS_CALLBACK_FUNCION {
1493 IPS_CALLBACK_NONE = 0,
1494 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1495 IPS_CALLBACK_JOIN_REQUEST = 2,
1496 } IPS_CALLBACK_FUNCION;
1497
1498 typedef enum _RT_JOIN_ACTION {
1499 RT_JOIN_INFRA = 1,
1500 RT_JOIN_IBSS = 2,
1501 RT_START_IBSS = 3,
1502 RT_NO_ACTION = 4,
1503 } RT_JOIN_ACTION;
1504
1505 struct ibss_parms {
1506 u16 atimWin;
1507 };
1508 #define MAX_NUM_RATES 264
1509
1510
1511 typedef enum _RT_RF_POWER_STATE {
1512 eRfOn,
1513 eRfSleep,
1514 eRfOff
1515 } RT_RF_POWER_STATE;
1516
1517 struct rt_power_save_control {
1518
1519
1520
1521
1522 bool bInactivePs;
1523 bool bIPSModeBackup;
1524 bool bSwRfProcessing;
1525 RT_RF_POWER_STATE eInactivePowerState;
1526 struct work_struct InactivePsWorkItem;
1527 struct timer_list InactivePsTimer;
1528
1529
1530 IPS_CALLBACK_FUNCION ReturnPoint;
1531
1532
1533 bool bTmpBssDesc;
1534 RT_JOIN_ACTION tmpJoinAction;
1535 struct ieee80211_network tmpBssDesc;
1536
1537
1538 bool bTmpScanOnly;
1539 bool bTmpActiveScan;
1540 bool bTmpFilterHiddenAP;
1541 bool bTmpUpdateParms;
1542 u8 tmpSsidBuf[33];
1543 struct octet_string tmpSsid2Scan;
1544 bool bTmpSsid2Scan;
1545 u8 tmpNetworkType;
1546 u8 tmpChannelNumber;
1547 u16 tmpBcnPeriod;
1548 u8 tmpDtimPeriod;
1549 u16 tmpmCap;
1550 struct octet_string tmpSuppRateSet;
1551 u8 tmpSuppRateBuf[MAX_NUM_RATES];
1552 bool bTmpSuppRate;
1553 struct ibss_parms tmpIbpm;
1554 bool bTmpIbpm;
1555
1556
1557
1558
1559 bool bLeisurePs;
1560
1561 };
1562
1563 typedef u32 RT_RF_CHANGE_SOURCE;
1564 #define RF_CHANGE_BY_SW BIT(31)
1565 #define RF_CHANGE_BY_HW BIT(30)
1566 #define RF_CHANGE_BY_PS BIT(29)
1567 #define RF_CHANGE_BY_IPS BIT(28)
1568 #define RF_CHANGE_BY_INIT 0
1569
1570 typedef enum {
1571 COUNTRY_CODE_FCC = 0,
1572 COUNTRY_CODE_IC = 1,
1573 COUNTRY_CODE_ETSI = 2,
1574 COUNTRY_CODE_SPAIN = 3,
1575 COUNTRY_CODE_FRANCE = 4,
1576 COUNTRY_CODE_MKK = 5,
1577 COUNTRY_CODE_MKK1 = 6,
1578 COUNTRY_CODE_ISRAEL = 7,
1579 COUNTRY_CODE_TELEC,
1580 COUNTRY_CODE_MIC,
1581 COUNTRY_CODE_GLOBAL_DOMAIN
1582 } country_code_type_t;
1583
1584 #define RT_MAX_LD_SLOT_NUM 10
1585 struct rt_link_detect {
1586
1587 u32 NumRecvBcnInPeriod;
1588 u32 NumRecvDataInPeriod;
1589
1590 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
1591 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
1592 u16 SlotNum;
1593 u16 SlotIndex;
1594
1595 u32 NumTxOkInPeriod;
1596 u32 NumRxOkInPeriod;
1597 bool bBusyTraffic;
1598 };
1599
1600
1601 struct ieee80211_device {
1602 struct net_device *dev;
1603 struct ieee80211_security sec;
1604
1605
1606
1607 u8 hwsec_active;
1608 bool is_silent_reset;
1609 bool ieee_up;
1610
1611 bool bSupportRemoteWakeUp;
1612 RT_PS_MODE dot11PowerSaveMode;
1613 bool actscanning;
1614 bool beinretry;
1615 RT_RF_POWER_STATE eRFPowerState;
1616 RT_RF_CHANGE_SOURCE RfOffReason;
1617 bool is_set_key;
1618
1619
1620
1621 PRT_HIGH_THROUGHPUT pHTInfo;
1622
1623
1624 spinlock_t bw_spinlock;
1625
1626 spinlock_t reorder_spinlock;
1627
1628
1629 u8 Regdot11HTOperationalRateSet[16];
1630 u8 dot11HTOperationalRateSet[16];
1631 u8 RegHTSuppRateSet[16];
1632 u8 HTCurrentOperaRate;
1633 u8 HTHighestOperaRate;
1634
1635 u8 bTxDisableRateFallBack;
1636 u8 bTxUseDriverAssingedRate;
1637 atomic_t atm_chnlop;
1638 atomic_t atm_swbw;
1639
1640
1641
1642
1643 struct list_head Tx_TS_Admit_List;
1644 struct list_head Tx_TS_Pending_List;
1645 struct list_head Tx_TS_Unused_List;
1646 struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
1647
1648 struct list_head Rx_TS_Admit_List;
1649 struct list_head Rx_TS_Pending_List;
1650 struct list_head Rx_TS_Unused_List;
1651 struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
1652 struct rx_reorder_entry RxReorderEntry[128];
1653 struct list_head RxReorder_Unused_List;
1654
1655
1656 u8 ForcedPriority;
1657
1658
1659
1660 struct net_device_stats stats;
1661 struct ieee80211_stats ieee_stats;
1662 struct ieee80211_softmac_stats softmac_stats;
1663
1664
1665 struct list_head network_free_list;
1666 struct list_head network_list;
1667 struct ieee80211_network *networks;
1668 int scans;
1669 int scan_age;
1670
1671 int iw_mode;
1672 struct iw_spy_data spy_data;
1673
1674 spinlock_t lock;
1675 spinlock_t wpax_suitlist_lock;
1676
1677 int tx_headroom;
1678
1679
1680 u32 config;
1681
1682
1683 int open_wep;
1684 int auth_mode;
1685 int reset_on_keychange;
1686
1687
1688
1689
1690 int host_encrypt;
1691 int host_encrypt_msdu;
1692 int host_decrypt;
1693
1694 int host_mc_decrypt;
1695
1696
1697
1698 int host_strip_iv_icv;
1699
1700 int host_open_frag;
1701 int host_build_iv;
1702 int ieee802_1x;
1703
1704
1705 bool bHalfWirelessN24GMode;
1706 int wpa_enabled;
1707 int drop_unencrypted;
1708 int tkip_countermeasures;
1709 int privacy_invoked;
1710 size_t wpa_ie_len;
1711 u8 *wpa_ie;
1712 u8 ap_mac_addr[6];
1713 u16 pairwise_key_type;
1714 u16 group_key_type;
1715 struct list_head crypt_deinit_list;
1716 struct ieee80211_crypt_data *crypt[WEP_KEYS];
1717 int tx_keyidx;
1718 struct timer_list crypt_deinit_timer;
1719 int crypt_quiesced;
1720
1721 int bcrx_sta_key;
1722
1723
1724
1725
1726
1727 struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
1728 unsigned int frag_next_idx[17];
1729 u16 fts;
1730 #define DEFAULT_RTS_THRESHOLD 2346U
1731 #define MIN_RTS_THRESHOLD 1
1732 #define MAX_RTS_THRESHOLD 2346U
1733 u16 rts;
1734
1735
1736 u8 bssid[ETH_ALEN];
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746 struct ieee80211_network current_network;
1747
1748 enum ieee80211_state state;
1749
1750 int short_slot;
1751 int reg_mode;
1752 int mode;
1753 int modulation;
1754 int freq_band;
1755 int abg_true;
1756
1757
1758
1759
1760 short sync_scan_hurryup;
1761
1762 int perfect_rssi;
1763 int worst_rssi;
1764
1765 u16 prev_seq_ctl;
1766
1767
1768
1769 void *dot11d_info;
1770 bool bGlobalDomain;
1771 int rate;
1772 int basic_rate;
1773
1774 short active_scan;
1775
1776
1777 u16 softmac_features;
1778
1779
1780 u16 seq_ctrl[5];
1781
1782
1783 u16 associate_seq;
1784
1785
1786 u16 assoc_id;
1787
1788
1789 short ps;
1790 short sta_sleep;
1791 int ps_timeout;
1792 int ps_period;
1793 struct tasklet_struct ps_task;
1794 u32 ps_th;
1795 u32 ps_tl;
1796
1797 short raw_tx;
1798
1799 short queue_stop;
1800 short scanning;
1801 short proto_started;
1802
1803 struct mutex wx_mutex;
1804 struct mutex scan_mutex;
1805
1806 spinlock_t mgmt_tx_lock;
1807 spinlock_t beacon_lock;
1808
1809 short beacon_txing;
1810
1811 short wap_set;
1812 short ssid_set;
1813
1814 u8 wpax_type_set;
1815 u32 wpax_type_notify;
1816
1817
1818 s8 init_wmmparam_flag;
1819
1820 u8 qos_support;
1821
1822
1823 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1824
1825
1826 u16 last_rxseq_num[17];
1827 u16 last_rxfrag_num[17];
1828 unsigned long last_packet_time[17];
1829
1830
1831 unsigned long last_rx_ps_time;
1832
1833
1834 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1835 int mgmt_queue_head;
1836 int mgmt_queue_tail;
1837
1838 #define IEEE80211_QUEUE_LIMIT 128
1839 u8 AsocRetryCount;
1840 unsigned int hw_header;
1841 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1842 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
1843 struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
1844 u32 sta_edca_param[4];
1845 bool aggregation;
1846
1847 bool enable_rx_imm_BA;
1848 bool bibsscoordinator;
1849
1850
1851
1852 bool bdynamic_txpower_enable;
1853
1854 bool bCTSToSelfEnable;
1855 u8 CTSToSelfTH;
1856
1857 u32 fsync_time_interval;
1858 u32 fsync_rate_bitmap;
1859 u8 fsync_rssi_threshold;
1860 bool bfsync_enable;
1861
1862 u8 fsync_multiple_timeinterval;
1863 u32 fsync_firstdiff_ratethreshold;
1864 u32 fsync_seconddiff_ratethreshold;
1865 Fsync_State fsync_state;
1866 bool bis_any_nonbepkts;
1867
1868 struct bandwidth_autoswitch bandwidth_auto_switch;
1869
1870 bool FwRWRF;
1871
1872
1873 struct rt_link_detect LinkDetectInfo;
1874
1875 struct rt_power_save_control PowerSaveControl;
1876
1877
1878 struct tx_pending tx_pending;
1879
1880
1881 struct timer_list associate_timer;
1882
1883
1884 struct timer_list beacon_timer;
1885 struct work_struct associate_complete_wq;
1886 struct work_struct associate_procedure_wq;
1887 struct delayed_work softmac_scan_wq;
1888 struct delayed_work associate_retry_wq;
1889 struct delayed_work start_ibss_wq;
1890 struct work_struct wx_sync_scan_wq;
1891 struct workqueue_struct *wq;
1892
1893
1894
1895
1896
1897
1898 struct ieee80211_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
1899
1900
1901 void (*set_security)(struct net_device *dev,
1902 struct ieee80211_security *sec);
1903
1904
1905
1906
1907
1908 int (*hard_start_xmit)(struct ieee80211_txb *txb,
1909 struct net_device *dev);
1910
1911 int (*reset_port)(struct net_device *dev);
1912 int (*is_queue_full)(struct net_device *dev, int pri);
1913
1914 int (*handle_management)(struct net_device *dev,
1915 struct ieee80211_network *network, u16 type);
1916 int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
1917
1918
1919
1920
1921
1922
1923
1924
1925 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1926 struct net_device *dev);
1927
1928
1929
1930
1931
1932
1933
1934 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1935 struct net_device *dev, int rate);
1936
1937
1938
1939
1940
1941 void (*data_hard_stop)(struct net_device *dev);
1942
1943
1944 void (*data_hard_resume)(struct net_device *dev);
1945
1946
1947
1948
1949
1950 void (*set_chan)(struct net_device *dev, short ch);
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967 void (*scan_syncro)(struct net_device *dev);
1968 void (*start_scan)(struct net_device *dev);
1969 void (*stop_scan)(struct net_device *dev);
1970
1971
1972
1973
1974
1975
1976 void (*link_change)(struct net_device *dev);
1977
1978
1979
1980
1981
1982
1983
1984 void (*start_send_beacons)(struct net_device *dev, u16 tx_rate);
1985 void (*stop_send_beacons)(struct net_device *dev);
1986
1987
1988 void (*sta_wake_up)(struct net_device *dev);
1989 void (*ps_request_tx_ack)(struct net_device *dev);
1990 void (*enter_sleep_state)(struct net_device *dev, u32 th, u32 tl);
1991 short (*ps_is_queue_empty)(struct net_device *dev);
1992 int (*handle_beacon)(struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network);
1993 int (*handle_assoc_response)(struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network);
1994
1995
1996
1997 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1998
1999
2000 void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset);
2001
2002 bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
2003 void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
2004 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
2005 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
2006
2007
2008
2009
2010 u8 priv[0];
2011 };
2012
2013 #define IEEE_A (1<<0)
2014 #define IEEE_B (1<<1)
2015 #define IEEE_G (1<<2)
2016 #define IEEE_N_24G (1<<4)
2017 #define IEEE_N_5G (1<<5)
2018 #define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G)
2019
2020
2021
2022
2023
2024
2025 #define IEEE_SOFTMAC_SCAN (1<<2)
2026
2027
2028 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2029
2030
2031 #define IEEE_SOFTMAC_PROBERQ (1<<4)
2032
2033
2034 #define IEEE_SOFTMAC_PROBERS (1<<5)
2035
2036
2037
2038
2039
2040 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
2041
2042
2043
2044
2045 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2046
2047
2048
2049
2050 #define IEEE_SOFTMAC_BEACONS (1<<6)
2051
2052 static inline void *ieee80211_priv(struct net_device *dev)
2053 {
2054 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
2055 }
2056
2057 static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
2058 {
2059
2060 if (essid_len == 1 && essid[0] == ' ')
2061 return 1;
2062
2063
2064 while (essid_len) {
2065 essid_len--;
2066 if (essid[essid_len] != '\0')
2067 return 0;
2068 }
2069
2070 return 1;
2071 }
2072
2073 static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
2074 {
2075
2076
2077
2078
2079
2080
2081 if ((mode & IEEE_A) &&
2082 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2083 (ieee->freq_band & IEEE80211_52GHZ_BAND))
2084 return 1;
2085
2086 if ((mode & IEEE_G) &&
2087 (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
2088 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2089 return 1;
2090
2091 if ((mode & IEEE_B) &&
2092 (ieee->modulation & IEEE80211_CCK_MODULATION) &&
2093 (ieee->freq_band & IEEE80211_24GHZ_BAND))
2094 return 1;
2095
2096 return 0;
2097 }
2098
2099 static inline int ieee80211_get_hdrlen(u16 fc)
2100 {
2101 int hdrlen = IEEE80211_3ADDR_LEN;
2102
2103 switch (WLAN_FC_GET_TYPE(fc)) {
2104 case IEEE80211_FTYPE_DATA:
2105 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
2106 hdrlen = IEEE80211_4ADDR_LEN;
2107 if (IEEE80211_QOS_HAS_SEQ(fc))
2108 hdrlen += 2;
2109 break;
2110 case IEEE80211_FTYPE_CTL:
2111 switch (WLAN_FC_GET_STYPE(fc)) {
2112 case IEEE80211_STYPE_CTS:
2113 case IEEE80211_STYPE_ACK:
2114 hdrlen = IEEE80211_1ADDR_LEN;
2115 break;
2116 default:
2117 hdrlen = IEEE80211_2ADDR_LEN;
2118 break;
2119 }
2120 break;
2121 }
2122
2123 return hdrlen;
2124 }
2125
2126 static inline u8 *ieee80211_get_payload(struct rtl_80211_hdr *hdr)
2127 {
2128 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2129 case IEEE80211_1ADDR_LEN:
2130 return ((struct rtl_80211_hdr_1addr *)hdr)->payload;
2131 case IEEE80211_2ADDR_LEN:
2132 return ((struct rtl_80211_hdr_2addr *)hdr)->payload;
2133 case IEEE80211_3ADDR_LEN:
2134 return ((struct rtl_80211_hdr_3addr *)hdr)->payload;
2135 case IEEE80211_4ADDR_LEN:
2136 return ((struct rtl_80211_hdr_4addr *)hdr)->payload;
2137 }
2138 return NULL;
2139 }
2140
2141 static inline int ieee80211_is_ofdm_rate(u8 rate)
2142 {
2143 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2144 case IEEE80211_OFDM_RATE_6MB:
2145 case IEEE80211_OFDM_RATE_9MB:
2146 case IEEE80211_OFDM_RATE_12MB:
2147 case IEEE80211_OFDM_RATE_18MB:
2148 case IEEE80211_OFDM_RATE_24MB:
2149 case IEEE80211_OFDM_RATE_36MB:
2150 case IEEE80211_OFDM_RATE_48MB:
2151 case IEEE80211_OFDM_RATE_54MB:
2152 return 1;
2153 }
2154 return 0;
2155 }
2156
2157 static inline int ieee80211_is_cck_rate(u8 rate)
2158 {
2159 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
2160 case IEEE80211_CCK_RATE_1MB:
2161 case IEEE80211_CCK_RATE_2MB:
2162 case IEEE80211_CCK_RATE_5MB:
2163 case IEEE80211_CCK_RATE_11MB:
2164 return 1;
2165 }
2166 return 0;
2167 }
2168
2169
2170
2171 void free_ieee80211(struct net_device *dev);
2172 struct net_device *alloc_ieee80211(int sizeof_priv);
2173
2174 int ieee80211_set_encryption(struct ieee80211_device *ieee);
2175
2176
2177
2178 int ieee80211_encrypt_fragment(struct ieee80211_device *ieee,
2179 struct sk_buff *frag, int hdr_len);
2180
2181 int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
2182 void ieee80211_txb_free(struct ieee80211_txb *txb);
2183
2184
2185
2186 int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
2187 struct ieee80211_rx_stats *rx_stats);
2188 void ieee80211_rx_mgt(struct ieee80211_device *ieee,
2189 struct rtl_80211_hdr_4addr *header,
2190 struct ieee80211_rx_stats *stats);
2191
2192
2193 int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
2194 struct iw_request_info *info,
2195 union iwreq_data *wrqu, char *key);
2196 int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
2197 struct iw_request_info *info,
2198 union iwreq_data *wrqu, char *key);
2199 int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
2200 struct iw_request_info *info,
2201 union iwreq_data *wrqu, char *key);
2202 int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee,
2203 struct iw_request_info *info,
2204 union iwreq_data *wrqu, char *extra);
2205 int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
2206 struct iw_request_info *info,
2207 union iwreq_data *wrqu, char *extra);
2208 int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
2209 struct iw_request_info *info,
2210 struct iw_param *data, char *extra);
2211 int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
2212 struct iw_request_info *info,
2213 union iwreq_data *wrqu, char *extra);
2214 int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
2215
2216
2217 short ieee80211_is_54g(const struct ieee80211_network *net);
2218 short ieee80211_is_shortslot(const struct ieee80211_network *net);
2219 int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee,
2220 struct sk_buff *skb,
2221 struct ieee80211_rx_stats *rx_stats,
2222 u16 type, u16 stype);
2223 void ieee80211_softmac_new_net(struct ieee80211_device *ieee,
2224 struct ieee80211_network *net);
2225
2226 void SendDisassociation(struct ieee80211_device *ieee, u8 *asSta, u8 asRsn);
2227 void ieee80211_softmac_xmit(struct ieee80211_txb *txb,
2228 struct ieee80211_device *ieee);
2229
2230 void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2231 void notify_wx_assoc_event(struct ieee80211_device *ieee);
2232 void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
2233 void ieee80211_start_bss(struct ieee80211_device *ieee);
2234 void ieee80211_start_master_bss(struct ieee80211_device *ieee);
2235 void ieee80211_start_ibss(struct ieee80211_device *ieee);
2236 void ieee80211_softmac_init(struct ieee80211_device *ieee);
2237 void ieee80211_softmac_free(struct ieee80211_device *ieee);
2238 void ieee80211_associate_abort(struct ieee80211_device *ieee);
2239 void ieee80211_disassociate(struct ieee80211_device *ieee);
2240 void ieee80211_stop_scan(struct ieee80211_device *ieee);
2241 void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
2242 void ieee80211_check_all_nets(struct ieee80211_device *ieee);
2243 void ieee80211_start_protocol(struct ieee80211_device *ieee);
2244 void ieee80211_stop_protocol(struct ieee80211_device *ieee);
2245 void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
2246 void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
2247 void ieee80211_reset_queue(struct ieee80211_device *ieee);
2248 void ieee80211_wake_queue(struct ieee80211_device *ieee);
2249 void ieee80211_stop_queue(struct ieee80211_device *ieee);
2250 struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
2251 void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
2252 void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
2253 int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee,
2254 struct iw_point *p);
2255 void notify_wx_assoc_event(struct ieee80211_device *ieee);
2256 void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
2257
2258 void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
2259
2260
2261 void ieee80211_tkip_null(void);
2262
2263 int ieee80211_crypto_init(void);
2264 void ieee80211_crypto_deinit(void);
2265 int ieee80211_crypto_tkip_init(void);
2266 void ieee80211_crypto_tkip_exit(void);
2267 int ieee80211_crypto_ccmp_init(void);
2268 void ieee80211_crypto_ccmp_exit(void);
2269 int ieee80211_crypto_wep_init(void);
2270 void ieee80211_crypto_wep_exit(void);
2271
2272
2273
2274 int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
2275 struct iw_request_info *info,
2276 union iwreq_data *wrqu, char *ext);
2277
2278 int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
2279 struct iw_request_info *info,
2280 union iwreq_data *awrq,
2281 char *extra);
2282
2283 int ieee80211_wx_get_essid(struct ieee80211_device *ieee,
2284 struct iw_request_info *a,
2285 union iwreq_data *wrqu, char *b);
2286
2287 int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
2288 struct iw_request_info *info,
2289 union iwreq_data *wrqu, char *extra);
2290
2291 int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
2292 struct iw_request_info *info,
2293 union iwreq_data *wrqu, char *extra);
2294
2295 int ieee80211_wx_set_mode(struct ieee80211_device *ieee,
2296 struct iw_request_info *a,
2297 union iwreq_data *wrqu, char *b);
2298
2299 int ieee80211_wx_set_scan(struct ieee80211_device *ieee,
2300 struct iw_request_info *a,
2301 union iwreq_data *wrqu, char *b);
2302
2303 int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
2304 struct iw_request_info *a,
2305 union iwreq_data *wrqu, char *extra);
2306
2307 int ieee80211_wx_get_mode(struct ieee80211_device *ieee,
2308 struct iw_request_info *a,
2309 union iwreq_data *wrqu, char *b);
2310
2311 int ieee80211_wx_set_freq(struct ieee80211_device *ieee,
2312 struct iw_request_info *a,
2313 union iwreq_data *wrqu, char *b);
2314
2315 int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
2316 struct iw_request_info *a,
2317 union iwreq_data *wrqu, char *b);
2318
2319
2320 int ieee80211_debug_init(void);
2321 void ieee80211_debug_exit(void);
2322
2323
2324 void ieee80211_wx_sync_scan_wq(struct work_struct *work);
2325
2326
2327 int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
2328 struct iw_request_info *info,
2329 union iwreq_data *wrqu, char *extra);
2330
2331 int ieee80211_wx_get_name(struct ieee80211_device *ieee,
2332 struct iw_request_info *info,
2333 union iwreq_data *wrqu, char *extra);
2334
2335 int ieee80211_wx_set_power(struct ieee80211_device *ieee,
2336 struct iw_request_info *info,
2337 union iwreq_data *wrqu, char *extra);
2338
2339 int ieee80211_wx_get_power(struct ieee80211_device *ieee,
2340 struct iw_request_info *info,
2341 union iwreq_data *wrqu, char *extra);
2342
2343 int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
2344 struct iw_request_info *info,
2345 union iwreq_data *wrqu, char *extra);
2346
2347 int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
2348 struct iw_request_info *info,
2349 union iwreq_data *wrqu, char *extra);
2350
2351 #define MAX_RECEIVE_BUFFER_SIZE 9100
2352 void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
2353 void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
2354
2355 void HTSetConnectBwMode(struct ieee80211_device *ieee,
2356 enum ht_channel_width Bandwidth, enum ht_extension_chan_offset Offset);
2357 void HTUpdateDefaultSetting(struct ieee80211_device *ieee);
2358 void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap,
2359 u8 *len, u8 isEncrypt);
2360 void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo,
2361 u8 *len, u8 isEncrypt);
2362 void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg,
2363 u8 *len);
2364 void HTOnAssocRsp(struct ieee80211_device *ieee);
2365 void HTInitializeHTInfo(struct ieee80211_device *ieee);
2366 void HTInitializeBssDesc(PBSS_HT pBssHT);
2367 void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee,
2368 struct ieee80211_network *pNetwork);
2369 void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee,
2370 struct ieee80211_network *pNetwork);
2371 u8 HTGetHighestMCSRate(struct ieee80211_device *ieee,
2372 u8 *pMCSRateSet, u8 *pMCSFilter);
2373 extern u8 MCS_FILTER_ALL[];
2374 extern u16 MCS_DATA_RATE[2][2][77];
2375 u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame);
2376 void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
2377 bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee);
2378 u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate);
2379
2380 int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb);
2381 int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb);
2382 int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb);
2383 void TsInitAddBA(struct ieee80211_device *ieee, struct tx_ts_record *pTS,
2384 u8 Policy, u8 bOverwritePending);
2385 void TsInitDelBA(struct ieee80211_device *ieee,
2386 struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect);
2387 void BaSetupTimeOut(struct timer_list *t);
2388 void TxBaInactTimeout(struct timer_list *t);
2389 void RxBaInactTimeout(struct timer_list *t);
2390 void ResetBaEntry(struct ba_record *pBA);
2391
2392 bool GetTs(
2393 struct ieee80211_device *ieee,
2394 struct ts_common_info **ppTS,
2395 u8 *Addr,
2396 u8 TID,
2397 enum tr_select TxRxSelect,
2398 bool bAddNewTs
2399 );
2400 void TSInitialize(struct ieee80211_device *ieee);
2401 void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTxTS);
2402 void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr);
2403 void RemoveAllTS(struct ieee80211_device *ieee);
2404 void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
2405
2406 extern const long ieee80211_wlan_frequencies[];
2407
2408 static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
2409 {
2410 ieee->scans++;
2411 }
2412
2413 static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
2414 {
2415 return ieee->scans;
2416 }
2417
2418 static inline const char *escape_essid(const char *essid, u8 essid_len)
2419 {
2420 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2421
2422 if (ieee80211_is_empty_essid(essid, essid_len)) {
2423 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2424 return escaped;
2425 }
2426
2427 snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
2428 return escaped;
2429 }
2430
2431
2432
2433
2434 short check_nic_enough_desc(struct net_device *dev, int queue_index);
2435 int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
2436 int ieee80211_parse_info_param(struct ieee80211_device *ieee,
2437 struct ieee80211_info_element *info_element,
2438 u16 length,
2439 struct ieee80211_network *network,
2440 struct ieee80211_rx_stats *stats);
2441
2442 void ieee80211_indicate_packets(struct ieee80211_device *ieee,
2443 struct ieee80211_rxb **prxbIndicateArray,
2444 u8 index);
2445 #define RT_ASOC_RETRY_LIMIT 5
2446 #endif