]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/staging/rtl8192e/rtllib.h
staging: rtl8192e: Convert typedef HT_AGGRE_SIZE_E to enum ht_aggre_size
[mirror_ubuntu-hirsute-kernel.git] / drivers / staging / rtl8192e / rtllib.h
CommitLineData
94a79942
LF
1/*
2 * Merged with mainline rtllib.h in Aug 2004. Original ieee802_11
3 * remains copyright by the original authors
4 *
5 * Portions of the merged code are based on Host AP (software wireless
6 * LAN access point) driver for Intersil Prism2/2.5/3.
7 *
8 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
9 * <jkmaline@cc.hut.fi>
10 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
11 *
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004, Intel Corporation
15 *
16 * Modified for Realtek's wi-fi cards by Andrea Merello
17 * <andreamrl@tiscali.it>
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License version 2 as
21 * published by the Free Software Foundation. See README and COPYING for
22 * more details.
23 */
24#ifndef RTLLIB_H
25#define RTLLIB_H
26#include <linux/if_ether.h> /* ETH_ALEN */
27#include <linux/kernel.h> /* ARRAY_SIZE */
28#include <linux/version.h>
29#include <linux/module.h>
30#include <linux/interrupt.h>
94a79942 31#include <linux/jiffies.h>
94a79942
LF
32#include <linux/timer.h>
33#include <linux/sched.h>
34
35#include <linux/delay.h>
36#include <linux/wireless.h>
37
94a79942
LF
38#include "rtl819x_HT.h"
39#include "rtl819x_BA.h"
40#include "rtl819x_TS.h"
41
42#include <linux/netdevice.h>
43#include <linux/if_arp.h> /* ARPHRD_ETHER */
44
45#ifndef WIRELESS_SPY
46#define WIRELESS_SPY
47#endif
48#include <net/iw_handler.h>
49
94a79942
LF
50#ifndef IW_MODE_MONITOR
51#define IW_MODE_MONITOR 6
52#endif
53
54#ifndef IWEVCUSTOM
55#define IWEVCUSTOM 0x8c02
56#endif
57
58#ifndef IW_CUSTOM_MAX
59/* Max number of char in custom event - use multiple of them if needed */
60#define IW_CUSTOM_MAX 256 /* In bytes */
61#endif
62
94a79942
LF
63#ifndef container_of
64/**
65 * container_of - cast a member of a structure out to the containing structure
66 *
67 * @ptr: the pointer to the member.
68 * @type: the type of the container struct this is embedded in.
69 * @member: the name of the member within the struct.
70 *
71 */
72#define container_of(ptr, type, member) ({ \
73 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
74 (type *)( (char *)__mptr - offsetof(type,member) );})
75#endif
76
94a79942 77#define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
94a79942 78
cb762154 79#define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x)
94a79942 80
94a79942 81
94a79942
LF
82 #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z)
83 #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y)
94a79942 84
94a79942
LF
85 #define queue_work_rsl(x,y) queue_work(x,y)
86 #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y)
94a79942 87
94a79942
LF
88 #define container_of_work_rsl(x,y,z) container_of(x,y,z)
89 #define container_of_dwork_rsl(x,y,z) container_of(container_of(x, struct delayed_work, work), y, z)
94a79942 90
94a79942 91 #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(info,start,stop,iwe,len)
94a79942 92
94a79942 93 #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(info,start,stop,iwe,p)
94a79942 94
94a79942
LF
95 #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x,y)
96 #define usb_submit_urb_rsl(x,y) usb_submit_urb(x,y)
94a79942
LF
97
98static inline void *netdev_priv_rsl(struct net_device *dev)
99{
94a79942 100 return netdev_priv(dev);
94a79942
LF
101}
102
103#define KEY_TYPE_NA 0x0
104#define KEY_TYPE_WEP40 0x1
105#define KEY_TYPE_TKIP 0x2
106#define KEY_TYPE_CCMP 0x4
107#define KEY_TYPE_WEP104 0x5
108/* added for rtl819x tx procedure */
109#define MAX_QUEUE_SIZE 0x10
110
94a79942
LF
111#define BK_QUEUE 0
112#define BE_QUEUE 1
113#define VI_QUEUE 2
114#define VO_QUEUE 3
115#define HCCA_QUEUE 4
116#define TXCMD_QUEUE 5
117#define MGNT_QUEUE 6
118#define HIGH_QUEUE 7
119#define BEACON_QUEUE 8
94a79942
LF
120
121#define LOW_QUEUE BE_QUEUE
122#define NORMAL_QUEUE MGNT_QUEUE
123
124#ifndef IW_MODE_MESH
125#define IW_MODE_MESH 7
126#endif
127#define AMSDU_SUBHEADER_LEN 14
128#define SWRF_TIMEOUT 50
129
130#define IE_CISCO_FLAG_POSITION 0x08
131#define SUPPORT_CKIP_MIC 0x08
132#define SUPPORT_CKIP_PK 0x10
133#define RT_RF_OFF_LEVL_ASPM BIT0
134#define RT_RF_OFF_LEVL_CLK_REQ BIT1
135#define RT_RF_OFF_LEVL_PCI_D3 BIT2
136#define RT_RF_OFF_LEVL_HALT_NIC BIT3
137#define RT_RF_OFF_LEVL_FREE_FW BIT4
138#define RT_RF_OFF_LEVL_FW_32K BIT5
139#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6
140#define RT_RF_LPS_DISALBE_2R BIT30
141#define RT_RF_LPS_LEVEL_ASPM BIT31
142#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
143#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG)))
144#define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
145
146/* defined for skb cb field */
147/* At most 28 byte */
3b83db43 148struct cb_desc {
94a79942
LF
149 /* Tx Desc Related flags (8-9) */
150 u8 bLastIniPkt:1;
151 u8 bCmdOrInit:1;
152 u8 bFirstSeg:1;
153 u8 bLastSeg:1;
154 u8 bEncrypt:1;
155 u8 bTxDisableRateFallBack:1;
156 u8 bTxUseDriverAssingedRate:1;
157 u8 bHwSec:1;
158
159 u8 nStuckCount;
160
161 /* Tx Firmware Relaged flags (10-11)*/
162 u8 bCTSEnable:1;
163 u8 bRTSEnable:1;
164 u8 bUseShortGI:1;
165 u8 bUseShortPreamble:1;
166 u8 bTxEnableFwCalcDur:1;
167 u8 bAMPDUEnable:1;
168 u8 bRTSSTBC:1;
169 u8 RTSSC:1;
170
171 u8 bRTSBW:1;
172 u8 bPacketBW:1;
173 u8 bRTSUseShortPreamble:1;
174 u8 bRTSUseShortGI:1;
175 u8 bMulticast:1;
176 u8 bBroadcast:1;
177 u8 drv_agg_enable:1;
178 u8 reserved2:1;
179
180 /* Tx Desc related element(12-19) */
181 u8 rata_index;
182 u8 queue_index;
183 u16 txbuf_size;
184 u8 RATRIndex;
185 u8 bAMSDU:1;
186 u8 bFromAggrQ:1;
187 u8 reserved6:6;
188 u8 macId;
189 u8 priority;
190
191 /* Tx firmware related element(20-27) */
192 u8 data_rate;
193 u8 rts_rate;
194 u8 ampdu_factor;
195 u8 ampdu_density;
196 u8 DrvAggrNum;
197 u8 bdhcp;
198 u16 pkt_size;
199 u8 bIsSpecialDataFrame;
200
201 u8 bBTTxPacket;
202 u8 bIsBTProbRsp;
d3b2c172 203};
94a79942
LF
204
205/*--------------------------Define -------------------------------------------*/
206#define MGN_1M 0x02
207#define MGN_2M 0x04
208#define MGN_5_5M 0x0b
209#define MGN_11M 0x16
210
211#define MGN_6M 0x0c
212#define MGN_9M 0x12
213#define MGN_12M 0x18
214#define MGN_18M 0x24
215#define MGN_24M 0x30
216#define MGN_36M 0x48
217#define MGN_48M 0x60
218#define MGN_54M 0x6c
219
220#define MGN_MCS0 0x80
221#define MGN_MCS1 0x81
222#define MGN_MCS2 0x82
223#define MGN_MCS3 0x83
224#define MGN_MCS4 0x84
225#define MGN_MCS5 0x85
226#define MGN_MCS6 0x86
227#define MGN_MCS7 0x87
228#define MGN_MCS8 0x88
229#define MGN_MCS9 0x89
230#define MGN_MCS10 0x8a
231#define MGN_MCS11 0x8b
232#define MGN_MCS12 0x8c
233#define MGN_MCS13 0x8d
234#define MGN_MCS14 0x8e
235#define MGN_MCS15 0x8f
236#define MGN_MCS0_SG 0x90
237#define MGN_MCS1_SG 0x91
238#define MGN_MCS2_SG 0x92
239#define MGN_MCS3_SG 0x93
240#define MGN_MCS4_SG 0x94
241#define MGN_MCS5_SG 0x95
242#define MGN_MCS6_SG 0x96
243#define MGN_MCS7_SG 0x97
244#define MGN_MCS8_SG 0x98
245#define MGN_MCS9_SG 0x99
246#define MGN_MCS10_SG 0x9a
247#define MGN_MCS11_SG 0x9b
248#define MGN_MCS12_SG 0x9c
249#define MGN_MCS13_SG 0x9d
250#define MGN_MCS14_SG 0x9e
251#define MGN_MCS15_SG 0x9f
252
253
254enum _ReasonCode{
255 unspec_reason = 0x1,
256 auth_not_valid = 0x2,
257 deauth_lv_ss = 0x3,
258 inactivity = 0x4,
259 ap_overload = 0x5,
260 class2_err = 0x6,
261 class3_err = 0x7,
262 disas_lv_ss = 0x8,
263 asoc_not_auth = 0x9,
264
265 mic_failure = 0xe,
266
267 invalid_IE = 0x0d,
268 four_way_tmout = 0x0f,
269 two_way_tmout = 0x10,
270 IE_dismatch = 0x11,
271 invalid_Gcipher = 0x12,
272 invalid_Pcipher = 0x13,
273 invalid_AKMP = 0x14,
274 unsup_RSNIEver = 0x15,
275 invalid_RSNIE = 0x16,
276 auth_802_1x_fail= 0x17,
277 ciper_reject = 0x18,
278
279 QoS_unspec = 0x20,
280 QAP_bandwidth = 0x21,
281 poor_condition = 0x22,
282 no_facility = 0x23,
283 req_declined = 0x25,
284 invalid_param = 0x26,
285 req_not_honored= 0x27,
286 TS_not_created = 0x2F,
287 DL_not_allowed = 0x30,
288 dest_not_exist = 0x31,
289 dest_not_QSTA = 0x32,
290};
291
839370c5 292enum hal_def_variable {
94a79942
LF
293 HAL_DEF_TPC_ENABLE,
294 HAL_DEF_INIT_GAIN,
295 HAL_DEF_PROT_IMP_MODE,
296 HAL_DEF_HIGH_POWER_MECHANISM,
297 HAL_DEF_RATE_ADAPTIVE_MECHANISM,
298 HAL_DEF_ANTENNA_DIVERSITY_MECHANISM,
299 HAL_DEF_LED,
300 HAL_DEF_CW_MAX_MIN,
301
302 HAL_DEF_WOWLAN,
303 HAL_DEF_ENDPOINTS,
304 HAL_DEF_MIN_TX_POWER_DBM,
305 HAL_DEF_MAX_TX_POWER_DBM,
306 HW_DEF_EFUSE_REPG_SECTION1_FLAG,
307 HW_DEF_EFUSE_REPG_DATA,
308 HW_DEF_GPIO,
309 HAL_DEF_PCI_SUPPORT_ASPM,
310 HAL_DEF_THERMAL_VALUE,
311 HAL_DEF_USB_IN_TOKEN_REV,
839370c5 312};
94a79942
LF
313
314
bb5e4822 315enum hw_variables {
94a79942
LF
316 HW_VAR_ETHER_ADDR,
317 HW_VAR_MULTICAST_REG,
318 HW_VAR_BASIC_RATE,
319 HW_VAR_BSSID,
320 HW_VAR_MEDIA_STATUS,
321 HW_VAR_SECURITY_CONF,
322 HW_VAR_BEACON_INTERVAL,
323 HW_VAR_ATIM_WINDOW,
324 HW_VAR_LISTEN_INTERVAL,
325 HW_VAR_CS_COUNTER,
326 HW_VAR_DEFAULTKEY0,
327 HW_VAR_DEFAULTKEY1,
328 HW_VAR_DEFAULTKEY2,
329 HW_VAR_DEFAULTKEY3,
330 HW_VAR_SIFS,
331 HW_VAR_DIFS,
332 HW_VAR_EIFS,
333 HW_VAR_SLOT_TIME,
334 HW_VAR_ACK_PREAMBLE,
335 HW_VAR_CW_CONFIG,
336 HW_VAR_CW_VALUES,
337 HW_VAR_RATE_FALLBACK_CONTROL,
338 HW_VAR_CONTENTION_WINDOW,
339 HW_VAR_RETRY_COUNT,
340 HW_VAR_TR_SWITCH,
341 HW_VAR_COMMAND,
342 HW_VAR_WPA_CONFIG,
343 HW_VAR_AMPDU_MIN_SPACE,
344 HW_VAR_SHORTGI_DENSITY,
345 HW_VAR_AMPDU_FACTOR,
346 HW_VAR_MCS_RATE_AVAILABLE,
347 HW_VAR_AC_PARAM,
348 HW_VAR_ACM_CTRL,
349 HW_VAR_DIS_Req_Qsize,
350 HW_VAR_CCX_CHNL_LOAD,
351 HW_VAR_CCX_NOISE_HISTOGRAM,
352 HW_VAR_CCX_CLM_NHM,
353 HW_VAR_TxOPLimit,
354 HW_VAR_TURBO_MODE,
355 HW_VAR_RF_STATE,
356 HW_VAR_RF_OFF_BY_HW,
357 HW_VAR_BUS_SPEED,
358 HW_VAR_SET_DEV_POWER,
359
360 HW_VAR_RCR,
361 HW_VAR_RATR_0,
362 HW_VAR_RRSR,
363 HW_VAR_CPU_RST,
364 HW_VAR_CECHK_BSSID,
365 HW_VAR_LBK_MODE,
366 HW_VAR_AES_11N_FIX,
367 HW_VAR_USB_RX_AGGR,
368 HW_VAR_USER_CONTROL_TURBO_MODE,
369 HW_VAR_RETRY_LIMIT,
370 HW_VAR_INIT_TX_RATE,
371 HW_VAR_TX_RATE_REG,
372 HW_VAR_EFUSE_USAGE,
373 HW_VAR_EFUSE_BYTES,
374 HW_VAR_AUTOLOAD_STATUS,
375 HW_VAR_RF_2R_DISABLE,
376 HW_VAR_SET_RPWM,
377 HW_VAR_H2C_FW_PWRMODE,
378 HW_VAR_H2C_FW_JOINBSSRPT,
379 HW_VAR_1X1_RECV_COMBINE,
380 HW_VAR_STOP_SEND_BEACON,
381 HW_VAR_TSF_TIMER,
382 HW_VAR_IO_CMD,
383
384 HW_VAR_RF_RECOVERY,
385 HW_VAR_H2C_FW_UPDATE_GTK,
386 HW_VAR_WF_MASK,
387 HW_VAR_WF_CRC,
388 HW_VAR_WF_IS_MAC_ADDR,
389 HW_VAR_H2C_FW_OFFLOAD,
390 HW_VAR_RESET_WFCRC,
391
392 HW_VAR_HANDLE_FW_C2H,
393 HW_VAR_DL_FW_RSVD_PAGE,
394 HW_VAR_AID,
395 HW_VAR_HW_SEQ_ENABLE,
396 HW_VAR_CORRECT_TSF,
397 HW_VAR_BCN_VALID,
398 HW_VAR_FWLPS_RF_ON,
399 HW_VAR_DUAL_TSF_RST,
400 HW_VAR_SWITCH_EPHY_WoWLAN,
401 HW_VAR_INT_MIGRATION,
402 HW_VAR_INT_AC,
403 HW_VAR_RF_TIMING,
bb5e4822 404};
94a79942 405
e93e0f6a 406enum rt_op_mode {
94a79942
LF
407 RT_OP_MODE_AP,
408 RT_OP_MODE_INFRASTRUCTURE,
409 RT_OP_MODE_IBSS,
410 RT_OP_MODE_NO_LINK,
e93e0f6a 411};
94a79942
LF
412
413
414#define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10)
415
416#define MGMT_QUEUE_NUM 5
417
418#define IEEE_CMD_SET_WPA_PARAM 1
419#define IEEE_CMD_SET_WPA_IE 2
420#define IEEE_CMD_SET_ENCRYPTION 3
421#define IEEE_CMD_MLME 4
422
423#define IEEE_PARAM_WPA_ENABLED 1
424#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
425#define IEEE_PARAM_DROP_UNENCRYPTED 3
426#define IEEE_PARAM_PRIVACY_INVOKED 4
427#define IEEE_PARAM_AUTH_ALGS 5
428#define IEEE_PARAM_IEEE_802_1X 6
429#define IEEE_PARAM_WPAX_SELECT 7
430#define IEEE_PROTO_WPA 1
431#define IEEE_PROTO_RSN 2
432#define IEEE_WPAX_USEGROUP 0
433#define IEEE_WPAX_WEP40 1
434#define IEEE_WPAX_TKIP 2
435#define IEEE_WPAX_WRAP 3
436#define IEEE_WPAX_CCMP 4
437#define IEEE_WPAX_WEP104 5
438
439#define IEEE_KEY_MGMT_IEEE8021X 1
440#define IEEE_KEY_MGMT_PSK 2
441
442#define IEEE_MLME_STA_DEAUTH 1
443#define IEEE_MLME_STA_DISASSOC 2
444
445
446#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
447#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
448#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
449#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
450#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
451#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
452#define IEEE_CRYPT_ALG_NAME_LEN 16
453
454#define MAX_IE_LEN 0xff
94a79942
LF
455#define RT_ASSERT_RET(_Exp) do {} while(0)
456#define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0)
94a79942 457
65dab9a0 458struct ieee_param {
94a79942
LF
459 u32 cmd;
460 u8 sta_addr[ETH_ALEN];
461 union {
462 struct {
463 u8 name;
464 u32 value;
465 } wpa_param;
466 struct {
467 u32 len;
468 u8 reserved[32];
469 u8 data[0];
470 } wpa_ie;
471 struct{
472 int command;
473 int reason_code;
474 } mlme;
475 struct {
476 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
477 u8 set_tx;
478 u32 err;
479 u8 idx;
480 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
481 u16 key_len;
482 u8 key[0];
483 } crypt;
484 } u;
d3b2c172 485};
94a79942
LF
486
487
488#if WIRELESS_EXT < 17
489#define IW_QUAL_QUAL_INVALID 0x10
490#define IW_QUAL_LEVEL_INVALID 0x20
491#define IW_QUAL_NOISE_INVALID 0x40
492#define IW_QUAL_QUAL_UPDATED 0x1
493#define IW_QUAL_LEVEL_UPDATED 0x2
494#define IW_QUAL_NOISE_UPDATED 0x4
495#endif
496
94a79942
LF
497#define MSECS(t) msecs_to_jiffies(t)
498#define msleep_interruptible_rsl msleep_interruptible
94a79942
LF
499
500#define RTLLIB_DATA_LEN 2304
501/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
502 6.2.1.1.2.
503
504 The figure in section 7.1.2 suggests a body size of up to 2312
505 bytes is allowed, which is a bit confusing, I suspect this
506 represents the 2304 bytes of real data, plus a possible 8 bytes of
507 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
508#define RTLLIB_1ADDR_LEN 10
509#define RTLLIB_2ADDR_LEN 16
510#define RTLLIB_3ADDR_LEN 24
511#define RTLLIB_4ADDR_LEN 30
512#define RTLLIB_FCS_LEN 4
513#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN)
514#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN)
515#define RTLLIB_MGMT_HDR_LEN 24
516#define RTLLIB_DATA_HDR3_LEN 24
517#define RTLLIB_DATA_HDR4_LEN 30
518
519#define RTLLIB_SKBBUFFER_SIZE 2500
520
521#define MIN_FRAG_THRESHOLD 256U
522#define MAX_FRAG_THRESHOLD 2346U
523#define MAX_HT_DATA_FRAG_THRESHOLD 0x2000
524
525#define HT_AMSDU_SIZE_4K 3839
526#define HT_AMSDU_SIZE_8K 7935
527
528/* Frame control field constants */
529#define RTLLIB_FCTL_VERS 0x0003
530#define RTLLIB_FCTL_FTYPE 0x000c
531#define RTLLIB_FCTL_STYPE 0x00f0
532#define RTLLIB_FCTL_FRAMETYPE 0x00fc
533#define RTLLIB_FCTL_TODS 0x0100
534#define RTLLIB_FCTL_FROMDS 0x0200
535#define RTLLIB_FCTL_DSTODS 0x0300
536#define RTLLIB_FCTL_MOREFRAGS 0x0400
537#define RTLLIB_FCTL_RETRY 0x0800
538#define RTLLIB_FCTL_PM 0x1000
539#define RTLLIB_FCTL_MOREDATA 0x2000
540#define RTLLIB_FCTL_WEP 0x4000
541#define RTLLIB_FCTL_ORDER 0x8000
542
543#define RTLLIB_FTYPE_MGMT 0x0000
544#define RTLLIB_FTYPE_CTL 0x0004
545#define RTLLIB_FTYPE_DATA 0x0008
546
547/* management */
548#define RTLLIB_STYPE_ASSOC_REQ 0x0000
549#define RTLLIB_STYPE_ASSOC_RESP 0x0010
550#define RTLLIB_STYPE_REASSOC_REQ 0x0020
551#define RTLLIB_STYPE_REASSOC_RESP 0x0030
552#define RTLLIB_STYPE_PROBE_REQ 0x0040
553#define RTLLIB_STYPE_PROBE_RESP 0x0050
554#define RTLLIB_STYPE_BEACON 0x0080
555#define RTLLIB_STYPE_ATIM 0x0090
556#define RTLLIB_STYPE_DISASSOC 0x00A0
557#define RTLLIB_STYPE_AUTH 0x00B0
558#define RTLLIB_STYPE_DEAUTH 0x00C0
559#define RTLLIB_STYPE_MANAGE_ACT 0x00D0
560
561/* control */
562#define RTLLIB_STYPE_PSPOLL 0x00A0
563#define RTLLIB_STYPE_RTS 0x00B0
564#define RTLLIB_STYPE_CTS 0x00C0
565#define RTLLIB_STYPE_ACK 0x00D0
566#define RTLLIB_STYPE_CFEND 0x00E0
567#define RTLLIB_STYPE_CFENDACK 0x00F0
568#define RTLLIB_STYPE_BLOCKACK 0x0094
569
570/* data */
571#define RTLLIB_STYPE_DATA 0x0000
572#define RTLLIB_STYPE_DATA_CFACK 0x0010
573#define RTLLIB_STYPE_DATA_CFPOLL 0x0020
574#define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
575#define RTLLIB_STYPE_NULLFUNC 0x0040
576#define RTLLIB_STYPE_CFACK 0x0050
577#define RTLLIB_STYPE_CFPOLL 0x0060
578#define RTLLIB_STYPE_CFACKPOLL 0x0070
579#define RTLLIB_STYPE_QOS_DATA 0x0080
580#define RTLLIB_STYPE_QOS_NULL 0x00C0
581
582#define RTLLIB_SCTL_FRAG 0x000F
583#define RTLLIB_SCTL_SEQ 0xFFF0
584
585/* QOS control */
586#define RTLLIB_QCTL_TID 0x000F
587
588#define FC_QOS_BIT BIT7
589#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false )
590#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) )
591#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
592#define Frame_Order(pframe) (*(u16*)pframe&RTLLIB_FCTL_ORDER)
593#define SN_LESS(a, b) (((a-b)&0x800)!=0)
594#define SN_EQUAL(a, b) (a == b)
595#define MAX_DEV_ADDR_SIZE 8
596
09ced23d 597enum act_category {
94a79942
LF
598 ACT_CAT_QOS = 1,
599 ACT_CAT_DLS = 2,
600 ACT_CAT_BA = 3,
601 ACT_CAT_HT = 7,
602 ACT_CAT_WMM = 17,
09ced23d 603};
94a79942 604
5a604053 605enum ts_action {
94a79942
LF
606 ACT_ADDTSREQ = 0,
607 ACT_ADDTSRSP = 1,
608 ACT_DELTS = 2,
609 ACT_SCHEDULE = 3,
5a604053 610};
94a79942 611
07276bac 612enum ba_action {
94a79942
LF
613 ACT_ADDBAREQ = 0,
614 ACT_ADDBARSP = 1,
615 ACT_DELBA = 2,
07276bac 616};
94a79942 617
062de0a9 618enum init_gain_op_type {
94a79942
LF
619 IG_Backup=0,
620 IG_Restore,
621 IG_Max
062de0a9 622};
d3b2c172 623
4fd7cedc 624enum led_ctl_mode {
94a79942
LF
625 LED_CTL_POWER_ON = 1,
626 LED_CTL_LINK = 2,
627 LED_CTL_NO_LINK = 3,
628 LED_CTL_TX = 4,
629 LED_CTL_RX = 5,
630 LED_CTL_SITE_SURVEY = 6,
631 LED_CTL_POWER_OFF = 7,
632 LED_CTL_START_TO_LINK = 8,
633 LED_CTL_START_WPS = 9,
634 LED_CTL_STOP_WPS = 10,
635 LED_CTL_START_WPS_BOTTON = 11,
636 LED_CTL_STOP_WPS_FAIL = 12,
637 LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
4fd7cedc 638};
94a79942 639
e6080633 640enum rt_rf_type_def {
94a79942
LF
641 RF_1T2R = 0,
642 RF_2T4R,
643 RF_2T2R,
644 RF_1T1R,
645 RF_2T2R_GREEN,
646 RF_819X_MAX_TYPE
e6080633 647};
94a79942 648
dc20a326 649enum wireless_mode {
94a79942
LF
650 WIRELESS_MODE_UNKNOWN = 0x00,
651 WIRELESS_MODE_A = 0x01,
652 WIRELESS_MODE_B = 0x02,
653 WIRELESS_MODE_G = 0x04,
654 WIRELESS_MODE_AUTO = 0x08,
655 WIRELESS_MODE_N_24G = 0x10,
656 WIRELESS_MODE_N_5G = 0x20
dc20a326 657};
94a79942 658
80f839d4 659enum wireless_network_type {
94a79942
LF
660 WIRELESS_11B = 1,
661 WIRELESS_11G = 2,
662 WIRELESS_11A = 4,
663 WIRELESS_11N = 8
80f839d4 664};
94a79942
LF
665
666#define OUI_SUBTYPE_WMM_INFO 0
667#define OUI_SUBTYPE_WMM_PARAM 1
668#define OUI_SUBTYPE_QOS_CAPABI 5
669
670/* debug macros */
94a79942
LF
671extern u32 rtllib_debug_level;
672#define RTLLIB_DEBUG(level, fmt, args...) \
673do { if (rtllib_debug_level & (level)) \
674 printk(KERN_DEBUG "rtllib: " fmt, ## args); } while (0)
675#define RTLLIB_DEBUG_DATA(level, data, datalen) \
676 do{ if ((rtllib_debug_level & (level)) == (level)) \
677 { \
678 int i; \
679 u8* pdata = (u8*) data; \
680 printk(KERN_DEBUG "rtllib: %s()\n", __func__); \
681 for (i=0; i<(int)(datalen); i++) \
682 { \
683 printk("%2.2x ", pdata[i]); \
684 if ((i+1)%16 == 0) printk("\n"); \
685 } \
686 printk("\n"); \
687 } \
688 } while (0)
94a79942
LF
689
690#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
691#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
692
693/*
694 * To use the debug system;
695 *
696 * If you are defining a new debug classification, simply add it to the #define
697 * list here in the form of:
698 *
699 * #define RTLLIB_DL_xxxx VALUE
700 *
701 * shifting value to the left one bit from the previous entry. xxxx should be
702 * the name of the classification (for example, WEP)
703 *
704 * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your
705 * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want
706 * to send output to that classification.
707 *
708 * To add your debug level to the list of levels seen when you perform
709 *
710 * % cat /proc/net/ipw/debug_level
711 *
712 * you simply need to add your entry to the ipw_debug_levels array.
713 *
94a79942
LF
714 *
715 */
716
717#define RTLLIB_DL_INFO (1<<0)
718#define RTLLIB_DL_WX (1<<1)
719#define RTLLIB_DL_SCAN (1<<2)
720#define RTLLIB_DL_STATE (1<<3)
721#define RTLLIB_DL_MGMT (1<<4)
722#define RTLLIB_DL_FRAG (1<<5)
723#define RTLLIB_DL_EAP (1<<6)
724#define RTLLIB_DL_DROP (1<<7)
725
726#define RTLLIB_DL_TX (1<<8)
727#define RTLLIB_DL_RX (1<<9)
728
729#define RTLLIB_DL_HT (1<<10)
730#define RTLLIB_DL_BA (1<<11)
731#define RTLLIB_DL_TS (1<<12)
732#define RTLLIB_DL_QOS (1<<13)
733#define RTLLIB_DL_REORDER (1<<14)
734#define RTLLIB_DL_IOT (1<<15)
735#define RTLLIB_DL_IPS (1<<16)
736#define RTLLIB_DL_TRACE (1<<29)
737#define RTLLIB_DL_DATA (1<<30)
738#define RTLLIB_DL_ERR (1<<31)
739#define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a)
740#define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a)
741#define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
742
743#define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
744#define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
745#define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
746#define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
747#define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
748#define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a)
749#define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a)
750#define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a)
751#define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
752#define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
753
94a79942
LF
754/* Added by Annie, 2005-11-22. */
755#define MAX_STR_LEN 64
756/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/
757#define PRINTABLE(_ch) (_ch>'!' && _ch<'~')
758#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
759 if ((_Comp) & level) \
760 { \
761 int __i; \
fc22c052 762 u8 struct buffer[MAX_STR_LEN]; \
94a79942 763 int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \
fc22c052
LF
764 memset(struct buffer, 0, MAX_STR_LEN); \
765 memcpy(struct buffer, (u8 *)_Ptr, length ); \
94a79942
LF
766 for ( __i=0; __i<MAX_STR_LEN; __i++ ) \
767 { \
fc22c052 768 if ( !PRINTABLE(struct buffer[__i]) ) struct buffer[__i] = '?'; \
94a79942 769 } \
fc22c052 770 struct buffer[length] = '\0'; \
94a79942
LF
771 printk("Rtl819x: "); \
772 printk(_TitleString); \
fc22c052 773 printk(": %d, <%s>\n", _Len, struct buffer); \
94a79942 774 }
94a79942
LF
775#ifndef ETH_P_PAE
776#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
777#define ETH_P_IP 0x0800 /* Internet Protocol packet */
778#define ETH_P_ARP 0x0806 /* Address Resolution packet */
779#endif /* ETH_P_PAE */
780
781#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
782
783#ifndef ETH_P_80211_RAW
784#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
785#endif
786
787/* IEEE 802.11 defines */
788
789#define P80211_OUI_LEN 3
790
791struct rtllib_snap_hdr {
792
793 u8 dsap; /* always 0xAA */
794 u8 ssap; /* always 0xAA */
795 u8 ctrl; /* always 0x03 */
796 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
797
798} __attribute__ ((packed));
799
800enum _REG_PREAMBLE_MODE{
801 PREAMBLE_LONG = 1,
802 PREAMBLE_AUTO = 2,
803 PREAMBLE_SHORT= 3,
804};
805
806#define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
807
808#define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS)
809#define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
810#define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
811#define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
812
813#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
814#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
815#define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
816
94a79942
LF
817/* Authentication algorithms */
818#define WLAN_AUTH_OPEN 0
819#define WLAN_AUTH_SHARED_KEY 1
820#define WLAN_AUTH_LEAP 128
821
822#define WLAN_AUTH_CHALLENGE_LEN 128
823
824#define WLAN_CAPABILITY_ESS (1<<0)
825#define WLAN_CAPABILITY_IBSS (1<<1)
826#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
827#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
828#define WLAN_CAPABILITY_PRIVACY (1<<4)
829#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
830#define WLAN_CAPABILITY_PBCC (1<<6)
831#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
832#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
833#define WLAN_CAPABILITY_QOS (1<<9)
834#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
835#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
836
837/* 802.11g ERP information element */
838#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
839#define WLAN_ERP_USE_PROTECTION (1<<1)
840#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
841
842/* Status codes */
843enum rtllib_statuscode {
844 WLAN_STATUS_SUCCESS = 0,
845 WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
846 WLAN_STATUS_CAPS_UNSUPPORTED = 10,
847 WLAN_STATUS_REASSOC_NO_ASSOC = 11,
848 WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
849 WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
850 WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
851 WLAN_STATUS_CHALLENGE_FAIL = 15,
852 WLAN_STATUS_AUTH_TIMEOUT = 16,
853 WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
854 WLAN_STATUS_ASSOC_DENIED_RATES = 18,
855 /* 802.11b */
856 WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
857 WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
858 WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
859 /* 802.11h */
860 WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
861 WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
862 WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
863 /* 802.11g */
864 WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
865 WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
866 /* 802.11i */
867 WLAN_STATUS_INVALID_IE = 40,
868 WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
869 WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
870 WLAN_STATUS_INVALID_AKMP = 43,
871 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
872 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
873 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
874};
875
876/* Reason codes */
877enum rtllib_reasoncode {
878 WLAN_REASON_UNSPECIFIED = 1,
879 WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
880 WLAN_REASON_DEAUTH_LEAVING = 3,
881 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
882 WLAN_REASON_DISASSOC_AP_BUSY = 5,
883 WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
884 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
885 WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
886 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
887 /* 802.11h */
888 WLAN_REASON_DISASSOC_BAD_POWER = 10,
889 WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
890 /* 802.11i */
891 WLAN_REASON_INVALID_IE = 13,
892 WLAN_REASON_MIC_FAILURE = 14,
893 WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
894 WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
895 WLAN_REASON_IE_DIFFERENT = 17,
896 WLAN_REASON_INVALID_GROUP_CIPHER = 18,
897 WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
898 WLAN_REASON_INVALID_AKMP = 20,
899 WLAN_REASON_UNSUPP_RSN_VERSION = 21,
900 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
901 WLAN_REASON_IEEE8021X_FAILED = 23,
902 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
903};
94a79942
LF
904
905#define RTLLIB_STATMASK_SIGNAL (1<<0)
906#define RTLLIB_STATMASK_RSSI (1<<1)
907#define RTLLIB_STATMASK_NOISE (1<<2)
908#define RTLLIB_STATMASK_RATE (1<<3)
909#define RTLLIB_STATMASK_WEMASK 0x7
910
911#define RTLLIB_CCK_MODULATION (1<<0)
912#define RTLLIB_OFDM_MODULATION (1<<1)
913
914#define RTLLIB_24GHZ_BAND (1<<0)
915#define RTLLIB_52GHZ_BAND (1<<1)
916
917#define RTLLIB_CCK_RATE_LEN 4
918#define RTLLIB_CCK_RATE_1MB 0x02
919#define RTLLIB_CCK_RATE_2MB 0x04
920#define RTLLIB_CCK_RATE_5MB 0x0B
921#define RTLLIB_CCK_RATE_11MB 0x16
922#define RTLLIB_OFDM_RATE_LEN 8
923#define RTLLIB_OFDM_RATE_6MB 0x0C
924#define RTLLIB_OFDM_RATE_9MB 0x12
925#define RTLLIB_OFDM_RATE_12MB 0x18
926#define RTLLIB_OFDM_RATE_18MB 0x24
927#define RTLLIB_OFDM_RATE_24MB 0x30
928#define RTLLIB_OFDM_RATE_36MB 0x48
929#define RTLLIB_OFDM_RATE_48MB 0x60
930#define RTLLIB_OFDM_RATE_54MB 0x6C
931#define RTLLIB_BASIC_RATE_MASK 0x80
932
933#define RTLLIB_CCK_RATE_1MB_MASK (1<<0)
934#define RTLLIB_CCK_RATE_2MB_MASK (1<<1)
935#define RTLLIB_CCK_RATE_5MB_MASK (1<<2)
936#define RTLLIB_CCK_RATE_11MB_MASK (1<<3)
937#define RTLLIB_OFDM_RATE_6MB_MASK (1<<4)
938#define RTLLIB_OFDM_RATE_9MB_MASK (1<<5)
939#define RTLLIB_OFDM_RATE_12MB_MASK (1<<6)
940#define RTLLIB_OFDM_RATE_18MB_MASK (1<<7)
941#define RTLLIB_OFDM_RATE_24MB_MASK (1<<8)
942#define RTLLIB_OFDM_RATE_36MB_MASK (1<<9)
943#define RTLLIB_OFDM_RATE_48MB_MASK (1<<10)
944#define RTLLIB_OFDM_RATE_54MB_MASK (1<<11)
945
946#define RTLLIB_CCK_RATES_MASK 0x0000000F
947#define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \
948 RTLLIB_CCK_RATE_2MB_MASK)
949#define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \
950 RTLLIB_CCK_RATE_5MB_MASK | \
951 RTLLIB_CCK_RATE_11MB_MASK)
952
953#define RTLLIB_OFDM_RATES_MASK 0x00000FF0
954#define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \
955 RTLLIB_OFDM_RATE_12MB_MASK | \
956 RTLLIB_OFDM_RATE_24MB_MASK)
957#define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \
958 RTLLIB_OFDM_RATE_9MB_MASK | \
959 RTLLIB_OFDM_RATE_18MB_MASK | \
960 RTLLIB_OFDM_RATE_36MB_MASK | \
961 RTLLIB_OFDM_RATE_48MB_MASK | \
962 RTLLIB_OFDM_RATE_54MB_MASK)
963#define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \
964 RTLLIB_CCK_DEFAULT_RATES_MASK)
965
966#define RTLLIB_NUM_OFDM_RATES 8
967#define RTLLIB_NUM_CCK_RATES 4
968#define RTLLIB_OFDM_SHIFT_MASK_A 4
969
970
971/* this is stolen and modified from the madwifi driver*/
972#define RTLLIB_FC0_TYPE_MASK 0x0c
973#define RTLLIB_FC0_TYPE_DATA 0x08
974#define RTLLIB_FC0_SUBTYPE_MASK 0xB0
975#define RTLLIB_FC0_SUBTYPE_QOS 0x80
976
977#define RTLLIB_QOS_HAS_SEQ(fc) \
978 (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
979 (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
980
981/* this is stolen from ipw2200 driver */
982#define IEEE_IBSS_MAC_HASH_SIZE 31
983struct ieee_ibss_seq {
984 u8 mac[ETH_ALEN];
985 u16 seq_num[17];
986 u16 frag_num[17];
987 unsigned long packet_time[17];
988 struct list_head list;
989};
990
991/* NOTE: This data is for statistical purposes; not all hardware provides this
992 * information for frames received. Not setting these will not cause
993 * any adverse affects. */
994struct rtllib_rx_stats {
995#if 1
996 u32 mac_time[2];
997 s8 rssi;
998 u8 signal;
999 u8 noise;
1000 u16 rate; /* in 100 kbps */
1001 u8 received_channel;
1002 u8 control;
1003 u8 mask;
1004 u8 freq;
1005 u16 len;
1006 u64 tsf;
1007 u32 beacon_time;
1008 u8 nic_type;
1009 u16 Length;
1010 u8 SignalQuality;
1011 s32 RecvSignalPower;
1012 s8 RxPower;
1013 u8 SignalStrength;
1014 u16 bHwError:1;
1015 u16 bCRC:1;
1016 u16 bICV:1;
1017 u16 bShortPreamble:1;
1018 u16 Antenna:1;
1019 u16 Decrypted:1;
1020 u16 Wakeup:1;
1021 u16 Reserved0:1;
1022 u8 AGC;
1023 u32 TimeStampLow;
1024 u32 TimeStampHigh;
1025 bool bShift;
1026 bool bIsQosData;
1027 u8 UserPriority;
1028
1029 u8 RxDrvInfoSize;
1030 u8 RxBufShift;
1031 bool bIsAMPDU;
1032 bool bFirstMPDU;
1033 bool bContainHTC;
1034 bool RxIs40MHzPacket;
1035 u32 RxPWDBAll;
1036 u8 RxMIMOSignalStrength[4];
1037 s8 RxMIMOSignalQuality[2];
1038 bool bPacketMatchBSSID;
1039 bool bIsCCK;
1040 bool bPacketToSelf;
1041 u8* virtual_address;
1042 u16 packetlength;
1043 u16 fraglength;
1044 u16 fragoffset;
1045 u16 ntotalfrag;
1046 bool bisrxaggrsubframe;
1047 bool bPacketBeacon;
1048 bool bToSelfBA;
1049 char cck_adc_pwdb[4];
1050 u16 Seq_Num;
1051 u8 nTotalAggPkt;
94a79942
LF
1052#endif
1053
1054};
1055
1056/* IEEE 802.11 requires that STA supports concurrent reception of at least
1057 * three fragmented frames. This define can be increased to support more
1058 * concurrent frames, but it should be noted that each entry can consume about
1059 * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
1060#define RTLLIB_FRAG_CACHE_LEN 4
1061
1062struct rtllib_frag_entry {
1063 unsigned long first_frag_time;
1064 unsigned int seq;
1065 unsigned int last_frag;
1066 struct sk_buff *skb;
1067 u8 src_addr[ETH_ALEN];
1068 u8 dst_addr[ETH_ALEN];
1069};
1070
1071struct rtllib_stats {
1072 unsigned int tx_unicast_frames;
1073 unsigned int tx_multicast_frames;
1074 unsigned int tx_fragments;
1075 unsigned int tx_unicast_octets;
1076 unsigned int tx_multicast_octets;
1077 unsigned int tx_deferred_transmissions;
1078 unsigned int tx_single_retry_frames;
1079 unsigned int tx_multiple_retry_frames;
1080 unsigned int tx_retry_limit_exceeded;
1081 unsigned int tx_discards;
1082 unsigned int rx_unicast_frames;
1083 unsigned int rx_multicast_frames;
1084 unsigned int rx_fragments;
1085 unsigned int rx_unicast_octets;
1086 unsigned int rx_multicast_octets;
1087 unsigned int rx_fcs_errors;
1088 unsigned int rx_discards_no_buffer;
1089 unsigned int tx_discards_wrong_sa;
1090 unsigned int rx_discards_undecryptable;
1091 unsigned int rx_message_in_msg_fragments;
1092 unsigned int rx_message_in_bad_msg_fragments;
1093};
1094
1095struct rtllib_device;
1096
1097#include "rtllib_crypt.h"
1098
1099#define SEC_KEY_1 (1<<0)
1100#define SEC_KEY_2 (1<<1)
1101#define SEC_KEY_3 (1<<2)
1102#define SEC_KEY_4 (1<<3)
1103#define SEC_ACTIVE_KEY (1<<4)
1104#define SEC_AUTH_MODE (1<<5)
1105#define SEC_UNICAST_GROUP (1<<6)
1106#define SEC_LEVEL (1<<7)
1107#define SEC_ENABLED (1<<8)
1108#define SEC_ENCRYPT (1<<9)
1109
1110#define SEC_LEVEL_0 0 /* None */
1111#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
1112#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
1113#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
1114#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
1115
1116#define SEC_ALG_NONE 0
1117#define SEC_ALG_WEP 1
1118#define SEC_ALG_TKIP 2
1119#define SEC_ALG_CCMP 4
1120
1121#define WEP_KEYS 4
1122#define WEP_KEY_LEN 13
1123#define SCM_KEY_LEN 32
1124#define SCM_TEMPORAL_KEY_LENGTH 16
1125
1126struct rtllib_security {
1127 u16 active_key:2,
1128 enabled:1,
1129 auth_mode:2,
1130 auth_algo:4,
1131 unicast_uses_group:1,
1132 encrypt:1;
1133 u8 key_sizes[WEP_KEYS];
1134 u8 keys[WEP_KEYS][SCM_KEY_LEN];
1135 u8 level;
1136 u16 flags;
1137} __attribute__ ((packed));
1138
1139
1140/*
1141 802.11 data frame from AP
1142 ,-------------------------------------------------------------------.
1143Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
1144 |------|------|---------|---------|---------|------|---------|------|
1145Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
1146 | | tion | (BSSID) | | | ence | data | |
1147 `-------------------------------------------------------------------'
1148Total: 28-2340 bytes
1149*/
1150
1151/* Management Frame Information Element Types */
1152enum rtllib_mfie {
1153 MFIE_TYPE_SSID = 0,
1154 MFIE_TYPE_RATES = 1,
1155 MFIE_TYPE_FH_SET = 2,
1156 MFIE_TYPE_DS_SET = 3,
1157 MFIE_TYPE_CF_SET = 4,
1158 MFIE_TYPE_TIM = 5,
1159 MFIE_TYPE_IBSS_SET = 6,
1160 MFIE_TYPE_COUNTRY = 7,
1161 MFIE_TYPE_HOP_PARAMS = 8,
1162 MFIE_TYPE_HOP_TABLE = 9,
1163 MFIE_TYPE_REQUEST = 10,
1164 MFIE_TYPE_CHALLENGE = 16,
1165 MFIE_TYPE_POWER_CONSTRAINT = 32,
1166 MFIE_TYPE_POWER_CAPABILITY = 33,
1167 MFIE_TYPE_TPC_REQUEST = 34,
1168 MFIE_TYPE_TPC_REPORT = 35,
1169 MFIE_TYPE_SUPP_CHANNELS = 36,
1170 MFIE_TYPE_CSA = 37,
1171 MFIE_TYPE_MEASURE_REQUEST = 38,
1172 MFIE_TYPE_MEASURE_REPORT = 39,
1173 MFIE_TYPE_QUIET = 40,
1174 MFIE_TYPE_IBSS_DFS = 41,
1175 MFIE_TYPE_ERP = 42,
1176 MFIE_TYPE_HT_CAP= 45,
1177 MFIE_TYPE_RSN = 48,
1178 MFIE_TYPE_RATES_EX = 50,
1179 MFIE_TYPE_HT_INFO= 61,
1180 MFIE_TYPE_AIRONET=133,
1181 MFIE_TYPE_GENERIC = 221,
1182 MFIE_TYPE_QOS_PARAMETER = 222,
1183};
1184
1185/* Minimal header; can be used for passing 802.11 frames with sufficient
1186 * information to determine what type of underlying data type is actually
1187 * stored in the data. */
1188struct rtllib_pspoll_hdr {
1189 __le16 frame_ctl;
1190 __le16 aid;
1191 u8 bssid[ETH_ALEN];
1192 u8 ta[ETH_ALEN];
1193} __attribute__ ((packed));
1194
1195struct rtllib_hdr {
1196 __le16 frame_ctl;
1197 __le16 duration_id;
1198 u8 payload[0];
1199} __attribute__ ((packed));
1200
1201struct rtllib_hdr_1addr {
1202 __le16 frame_ctl;
1203 __le16 duration_id;
1204 u8 addr1[ETH_ALEN];
1205 u8 payload[0];
1206} __attribute__ ((packed));
1207
1208struct rtllib_hdr_2addr {
1209 __le16 frame_ctl;
1210 __le16 duration_id;
1211 u8 addr1[ETH_ALEN];
1212 u8 addr2[ETH_ALEN];
1213 u8 payload[0];
1214} __attribute__ ((packed));
1215
1216struct rtllib_hdr_3addr {
1217 __le16 frame_ctl;
1218 __le16 duration_id;
1219 u8 addr1[ETH_ALEN];
1220 u8 addr2[ETH_ALEN];
1221 u8 addr3[ETH_ALEN];
1222 __le16 seq_ctl;
1223 u8 payload[0];
1224} __attribute__ ((packed));
1225
1226struct rtllib_hdr_4addr {
1227 __le16 frame_ctl;
1228 __le16 duration_id;
1229 u8 addr1[ETH_ALEN];
1230 u8 addr2[ETH_ALEN];
1231 u8 addr3[ETH_ALEN];
1232 __le16 seq_ctl;
1233 u8 addr4[ETH_ALEN];
1234 u8 payload[0];
1235} __attribute__ ((packed));
1236
1237struct rtllib_hdr_3addrqos {
1238 __le16 frame_ctl;
1239 __le16 duration_id;
1240 u8 addr1[ETH_ALEN];
1241 u8 addr2[ETH_ALEN];
1242 u8 addr3[ETH_ALEN];
1243 __le16 seq_ctl;
1244 __le16 qos_ctl;
1245 u8 payload[0];
1246} __attribute__ ((packed));
1247
1248struct rtllib_hdr_4addrqos {
1249 __le16 frame_ctl;
1250 __le16 duration_id;
1251 u8 addr1[ETH_ALEN];
1252 u8 addr2[ETH_ALEN];
1253 u8 addr3[ETH_ALEN];
1254 __le16 seq_ctl;
1255 u8 addr4[ETH_ALEN];
1256 __le16 qos_ctl;
1257 u8 payload[0];
1258} __attribute__ ((packed));
1259
1260struct rtllib_info_element {
1261 u8 id;
1262 u8 len;
1263 u8 data[0];
1264} __attribute__ ((packed));
1265
1266struct rtllib_authentication {
1267 struct rtllib_hdr_3addr header;
1268 __le16 algorithm;
1269 __le16 transaction;
1270 __le16 status;
1271 /*challenge*/
1272 struct rtllib_info_element info_element[0];
1273} __attribute__ ((packed));
1274
1275struct rtllib_disauth {
1276 struct rtllib_hdr_3addr header;
1277 __le16 reason;
1278} __attribute__ ((packed));
1279
1280struct rtllib_disassoc {
1281 struct rtllib_hdr_3addr header;
1282 __le16 reason;
1283} __attribute__ ((packed));
1284
1285struct rtllib_probe_request {
1286 struct rtllib_hdr_3addr header;
1287 /* SSID, supported rates */
1288 struct rtllib_info_element info_element[0];
1289} __attribute__ ((packed));
1290
1291struct rtllib_probe_response {
1292 struct rtllib_hdr_3addr header;
1293 u32 time_stamp[2];
1294 __le16 beacon_interval;
1295 __le16 capability;
1296 /* SSID, supported rates, FH params, DS params,
1297 * CF params, IBSS params, TIM (if beacon), RSN */
1298 struct rtllib_info_element info_element[0];
1299} __attribute__ ((packed));
1300
1301/* Alias beacon for probe_response */
1302#define rtllib_beacon rtllib_probe_response
1303
1304struct rtllib_assoc_request_frame {
1305 struct rtllib_hdr_3addr header;
1306 __le16 capability;
1307 __le16 listen_interval;
1308 /* SSID, supported rates, RSN */
1309 struct rtllib_info_element info_element[0];
1310} __attribute__ ((packed));
1311
1312struct rtllib_reassoc_request_frame {
1313 struct rtllib_hdr_3addr header;
1314 __le16 capability;
1315 __le16 listen_interval;
1316 u8 current_ap[ETH_ALEN];
1317 /* SSID, supported rates, RSN */
1318 struct rtllib_info_element info_element[0];
1319} __attribute__ ((packed));
1320
1321struct rtllib_assoc_response_frame {
1322 struct rtllib_hdr_3addr header;
1323 __le16 capability;
1324 __le16 status;
1325 __le16 aid;
1326 struct rtllib_info_element info_element[0]; /* supported rates */
1327} __attribute__ ((packed));
1328
1329struct rtllib_txb {
1330 u8 nr_frags;
1331 u8 encrypted;
1332 u8 queue_index;
1333 u8 rts_included;
1334 u16 reserved;
1335 __le16 frag_size;
1336 __le16 payload_size;
1337 struct sk_buff *fragments[0];
1338};
1339
1340#define MAX_TX_AGG_COUNT 16
1341struct rtllib_drv_agg_txb {
1342 u8 nr_drv_agg_frames;
1343 struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
1344}__attribute__((packed));
1345
1346#define MAX_SUBFRAME_COUNT 64
1347struct rtllib_rxb {
1348 u8 nr_subframes;
1349 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
1350 u8 dst[ETH_ALEN];
1351 u8 src[ETH_ALEN];
94a79942
LF
1352}__attribute__((packed));
1353
66ba443a 1354union frameqos {
94a79942
LF
1355 u16 shortdata;
1356 u8 chardata[2];
1357 struct {
1358 u16 tid:4;
1359 u16 eosp:1;
1360 u16 ack_policy:2;
1361 u16 reserved:1;
1362 u16 txop:8;
1363 }field;
66ba443a 1364};
94a79942
LF
1365
1366/* SWEEP TABLE ENTRIES NUMBER*/
1367#define MAX_SWEEP_TAB_ENTRIES 42
1368#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
1369/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
1370 * only use 8, and then use extended rates for the remaining supported
1371 * rates. Other APs, however, stick all of their supported rates on the
1372 * main rates information element... */
1373#define MAX_RATES_LENGTH ((u8)12)
1374#define MAX_RATES_EX_LENGTH ((u8)16)
94a79942 1375#define MAX_NETWORK_COUNT 96
94a79942
LF
1376
1377#define MAX_CHANNEL_NUMBER 161
1378#define RTLLIB_SOFTMAC_SCAN_TIME 100
1379#define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1380
1381#define CRC_LENGTH 4U
1382
1383#define MAX_WPA_IE_LEN 64
1384#define MAX_WZC_IE_LEN 256
1385
1386#define NETWORK_EMPTY_ESSID (1<<0)
1387#define NETWORK_HAS_OFDM (1<<1)
1388#define NETWORK_HAS_CCK (1<<2)
1389
1390/* QoS structure */
1391#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1392#define NETWORK_HAS_QOS_INFORMATION (1<<4)
1393#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1394 NETWORK_HAS_QOS_INFORMATION)
1395/* 802.11h */
1396#define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
1397#define NETWORK_HAS_CSA (1<<6)
1398#define NETWORK_HAS_QUIET (1<<7)
1399#define NETWORK_HAS_IBSS_DFS (1<<8)
1400#define NETWORK_HAS_TPC_REPORT (1<<9)
1401
1402#define NETWORK_HAS_ERP_VALUE (1<<10)
1403
1404#define QOS_QUEUE_NUM 4
1405#define QOS_OUI_LEN 3
1406#define QOS_OUI_TYPE 2
1407#define QOS_ELEMENT_ID 221
1408#define QOS_OUI_INFO_SUB_TYPE 0
1409#define QOS_OUI_PARAM_SUB_TYPE 1
1410#define QOS_VERSION_1 1
1411#define QOS_AIFSN_MIN_VALUE 2
1412#if 1
1413struct rtllib_qos_information_element {
1414 u8 elementID;
1415 u8 length;
1416 u8 qui[QOS_OUI_LEN];
1417 u8 qui_type;
1418 u8 qui_subtype;
1419 u8 version;
1420 u8 ac_info;
1421} __attribute__ ((packed));
1422
1423struct rtllib_qos_ac_parameter {
1424 u8 aci_aifsn;
1425 u8 ecw_min_max;
1426 __le16 tx_op_limit;
1427} __attribute__ ((packed));
1428
1429struct rtllib_qos_parameter_info {
1430 struct rtllib_qos_information_element info_element;
1431 u8 reserved;
1432 struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1433} __attribute__ ((packed));
1434
1435struct rtllib_qos_parameters {
1436 __le16 cw_min[QOS_QUEUE_NUM];
1437 __le16 cw_max[QOS_QUEUE_NUM];
1438 u8 aifs[QOS_QUEUE_NUM];
1439 u8 flag[QOS_QUEUE_NUM];
1440 __le16 tx_op_limit[QOS_QUEUE_NUM];
1441} __attribute__ ((packed));
1442
1443struct rtllib_qos_data {
1444 struct rtllib_qos_parameters parameters;
1445 unsigned int wmm_acm;
1446 int active;
1447 int supported;
1448 u8 param_count;
1449 u8 old_param_count;
1450};
1451
1452struct rtllib_tim_parameters {
1453 u8 tim_count;
1454 u8 tim_period;
1455} __attribute__ ((packed));
1456
1457struct rtllib_wmm_ac_param {
1458 u8 ac_aci_acm_aifsn;
1459 u8 ac_ecwmin_ecwmax;
1460 u16 ac_txop_limit;
1461};
1462
1463struct rtllib_wmm_ts_info {
1464 u8 ac_dir_tid;
1465 u8 ac_up_psb;
1466 u8 reserved;
1467} __attribute__ ((packed));
1468
1469struct rtllib_wmm_tspec_elem {
1470 struct rtllib_wmm_ts_info ts_info;
1471 u16 norm_msdu_size;
1472 u16 max_msdu_size;
1473 u32 min_serv_inter;
1474 u32 max_serv_inter;
1475 u32 inact_inter;
1476 u32 suspen_inter;
1477 u32 serv_start_time;
1478 u32 min_data_rate;
1479 u32 mean_data_rate;
1480 u32 peak_data_rate;
1481 u32 max_burst_size;
1482 u32 delay_bound;
1483 u32 min_phy_rate;
1484 u16 surp_band_allow;
1485 u16 medium_time;
1486}__attribute__((packed));
1487#endif
1488enum eap_type {
1489 EAP_PACKET = 0,
1490 EAPOL_START,
1491 EAPOL_LOGOFF,
1492 EAPOL_KEY,
1493 EAPOL_ENCAP_ASF_ALERT
1494};
1495
1496static const char *eap_types[] = {
1497 [EAP_PACKET] = "EAP-Packet",
1498 [EAPOL_START] = "EAPOL-Start",
1499 [EAPOL_LOGOFF] = "EAPOL-Logoff",
1500 [EAPOL_KEY] = "EAPOL-Key",
1501 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1502};
1503
1504static inline const char *eap_get_type(int type)
1505{
1506 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
1507}
1508static inline u8 Frame_QoSTID(u8* buf)
1509{
1510 struct rtllib_hdr_3addr *hdr;
1511 u16 fc;
1512 hdr = (struct rtllib_hdr_3addr *)buf;
1513 fc = le16_to_cpu(hdr->frame_ctl);
66ba443a 1514 return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid;
94a79942
LF
1515}
1516
1517
1518struct eapol {
1519 u8 snap[6];
1520 u16 ethertype;
1521 u8 version;
1522 u8 type;
1523 u16 length;
1524} __attribute__ ((packed));
1525
1526struct rtllib_softmac_stats{
1527 unsigned int rx_ass_ok;
1528 unsigned int rx_ass_err;
1529 unsigned int rx_probe_rq;
1530 unsigned int tx_probe_rs;
1531 unsigned int tx_beacons;
1532 unsigned int rx_auth_rq;
1533 unsigned int rx_auth_rs_ok;
1534 unsigned int rx_auth_rs_err;
1535 unsigned int tx_auth_rq;
1536 unsigned int no_auth_rs;
1537 unsigned int no_ass_rs;
1538 unsigned int tx_ass_rq;
1539 unsigned int rx_ass_rq;
1540 unsigned int tx_probe_rq;
1541 unsigned int reassoc;
1542 unsigned int swtxstop;
1543 unsigned int swtxawake;
1544 unsigned char CurrentShowTxate;
1545 unsigned char last_packet_rate;
1546 unsigned int txretrycount;
1547};
1548
1549#define BEACON_PROBE_SSID_ID_POSITION 12
1550
1551struct rtllib_info_element_hdr {
1552 u8 id;
1553 u8 len;
1554} __attribute__ ((packed));
1555
1556/*
1557 * These are the data types that can make up management packets
1558 *
1559 u16 auth_algorithm;
1560 u16 auth_sequence;
1561 u16 beacon_interval;
1562 u16 capability;
1563 u8 current_ap[ETH_ALEN];
1564 u16 listen_interval;
1565 struct {
1566 u16 association_id:14, reserved:2;
1567 } __attribute__ ((packed));
1568 u32 time_stamp[2];
1569 u16 reason;
1570 u16 status;
1571*/
1572
1573#define RTLLIB_DEFAULT_TX_ESSID "Penguin"
1574#define RTLLIB_DEFAULT_BASIC_RATE 2
1575
1576enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1577#define MAX_SP_Len (WMM_all_frame << 4)
1578#define RTLLIB_QOS_TID 0x0f
1579#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1580
1581#define RTLLIB_DTIM_MBCAST 4
1582#define RTLLIB_DTIM_UCAST 2
1583#define RTLLIB_DTIM_VALID 1
1584#define RTLLIB_DTIM_INVALID 0
1585
1586#define RTLLIB_PS_DISABLED 0
1587#define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
1588#define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
1589
94a79942
LF
1590#define WME_AC_BK 0x00
1591#define WME_AC_BE 0x01
1592#define WME_AC_VI 0x02
1593#define WME_AC_VO 0x03
1594#define WME_ACI_MASK 0x03
1595#define WME_AIFSN_MASK 0x03
1596#define WME_AC_PRAM_LEN 16
1597
1598#define MAX_RECEIVE_BUFFER_SIZE 9100
1599
94a79942
LF
1600#define UP2AC(up) ( \
1601 ((up) < 1) ? WME_AC_BE : \
1602 ((up) < 3) ? WME_AC_BK : \
1603 ((up) < 4) ? WME_AC_BE : \
1604 ((up) < 6) ? WME_AC_VI : \
1605 WME_AC_VO)
eccf634f 1606
94a79942
LF
1607#define AC2UP(_ac) ( \
1608 ((_ac) == WME_AC_VO) ? 6 : \
1609 ((_ac) == WME_AC_VI) ? 5 : \
1610 ((_ac) == WME_AC_BK) ? 1 : \
1611 0)
1612
1613#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
1614#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/
1615
1616struct ether_header {
1617 u8 ether_dhost[ETHER_ADDR_LEN];
1618 u8 ether_shost[ETHER_ADDR_LEN];
1619 u16 ether_type;
1620} __attribute__((packed));
1621
1622#ifndef ETHERTYPE_PAE
1623#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
1624#endif
1625#ifndef ETHERTYPE_IP
1626#define ETHERTYPE_IP 0x0800 /* IP protocol */
1627#endif
1628
1629
3b45eb83 1630enum erp_t {
94a79942
LF
1631 ERP_NonERPpresent = 0x01,
1632 ERP_UseProtection = 0x02,
1633 ERP_BarkerPreambleMode = 0x04,
3b45eb83 1634};
94a79942
LF
1635
1636struct rtllib_network {
1637 /* These entries are used to identify a unique network */
1638 u8 bssid[ETH_ALEN];
1639 u8 channel;
1640 /* Ensure null-terminated for any debug msgs */
1641 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1642 u8 ssid_len;
1643 u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
1644 u8 hidden_ssid_len;
1645 struct rtllib_qos_data qos_data;
1646
1647 bool bWithAironetIE;
1648 bool bCkipSupported;
1649 bool bCcxRmEnable;
1650 u16 CcxRmState[2];
1651 bool bMBssidValid;
1652 u8 MBssidMask;
1653 u8 MBssid[6];
1654 bool bWithCcxVerNum;
1655 u8 BssCcxVerNumber;
1656 /* These are network statistics */
1657 struct rtllib_rx_stats stats;
1658 u16 capability;
1659 u8 rates[MAX_RATES_LENGTH];
1660 u8 rates_len;
1661 u8 rates_ex[MAX_RATES_EX_LENGTH];
1662 u8 rates_ex_len;
1663 unsigned long last_scanned;
1664 u8 mode;
1665 u32 flags;
1666 u32 last_associate;
1667 u32 time_stamp[2];
1668 u16 beacon_interval;
1669 u16 listen_interval;
1670 u16 atim_window;
1671 u8 erp_value;
1672 u8 wpa_ie[MAX_WPA_IE_LEN];
1673 size_t wpa_ie_len;
1674 u8 rsn_ie[MAX_WPA_IE_LEN];
1675 size_t rsn_ie_len;
1676 u8 wzc_ie[MAX_WZC_IE_LEN];
1677 size_t wzc_ie_len;
1678
1679 struct rtllib_tim_parameters tim;
1680 u8 dtim_period;
1681 u8 dtim_data;
1682 u32 last_dtim_sta_time[2];
1683
1684 u8 wmm_info;
1685 struct rtllib_wmm_ac_param wmm_param[4];
1686 u8 Turbo_Enable;
94a79942
LF
1687 u16 CountryIeLen;
1688 u8 CountryIeBuf[MAX_IE_LEN];
a15e76ad 1689 struct bss_ht bssht;
94a79942
LF
1690 bool broadcom_cap_exist;
1691 bool realtek_cap_exit;
1692 bool marvell_cap_exist;
1693 bool ralink_cap_exist;
1694 bool atheros_cap_exist;
1695 bool cisco_cap_exist;
1696 bool airgo_cap_exist;
1697 bool unknown_cap_exist;
1698 bool berp_info_valid;
1699 bool buseprotection;
1700 bool bIsNetgear854T;
1701 u8 SignalStrength;
1702 u8 RSSI;
1703 struct list_head list;
1704};
1705
1706#if 1
1707enum rtllib_state {
1708
1709 /* the card is not linked at all */
1710 RTLLIB_NOLINK = 0,
1711
1712 /* RTLLIB_ASSOCIATING* are for BSS client mode
1713 * the driver shall not perform RX filtering unless
1714 * the state is LINKED.
1715 * The driver shall just check for the state LINKED and
1716 * defaults to NOLINK for ALL the other states (including
1717 * LINKED_SCANNING)
1718 */
1719
1720 /* the association procedure will start (wq scheduling)*/
1721 RTLLIB_ASSOCIATING,
1722 RTLLIB_ASSOCIATING_RETRY,
1723
1724 /* the association procedure is sending AUTH request*/
1725 RTLLIB_ASSOCIATING_AUTHENTICATING,
1726
1727 /* the association procedure has successfully authentcated
1728 * and is sending association request
1729 */
1730 RTLLIB_ASSOCIATING_AUTHENTICATED,
1731
1732 /* the link is ok. the card associated to a BSS or linked
1733 * to a ibss cell or acting as an AP and creating the bss
1734 */
1735 RTLLIB_LINKED,
1736
1737 /* same as LINKED, but the driver shall apply RX filter
1738 * rules as we are in NO_LINK mode. As the card is still
1739 * logically linked, but it is doing a syncro site survey
1740 * then it will be back to LINKED state.
1741 */
1742 RTLLIB_LINKED_SCANNING,
1743};
1744#else
1745enum rtllib_state {
1746 RTLLIB_UNINITIALIZED = 0,
1747 RTLLIB_INITIALIZED,
1748 RTLLIB_ASSOCIATING,
1749 RTLLIB_ASSOCIATED,
1750 RTLLIB_AUTHENTICATING,
1751 RTLLIB_AUTHENTICATED,
1752 RTLLIB_SHUTDOWN
1753};
1754#endif
1755
1756#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1757#define DEFAULT_FTS 2346
1758
1759#define CFG_RTLLIB_RESERVE_FCS (1<<0)
1760#define CFG_RTLLIB_COMPUTE_FCS (1<<1)
1761#define CFG_RTLLIB_RTS (1<<2)
1762
1763#define RTLLIB_24GHZ_MIN_CHANNEL 1
1764#define RTLLIB_24GHZ_MAX_CHANNEL 14
1765#define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \
1766 RTLLIB_24GHZ_MIN_CHANNEL + 1)
1767
1768#define RTLLIB_52GHZ_MIN_CHANNEL 34
1769#define RTLLIB_52GHZ_MAX_CHANNEL 165
1770#define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \
1771 RTLLIB_52GHZ_MIN_CHANNEL + 1)
94a79942
LF
1772#ifndef eqMacAddr
1773#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
1774#endif
0ce60045 1775struct tx_pending {
94a79942
LF
1776 int frag;
1777 struct rtllib_txb *txb;
d3b2c172 1778};
94a79942 1779
dca0eb1e 1780struct bandwidth_autoswitch {
94a79942
LF
1781 long threshold_20Mhzto40Mhz;
1782 long threshold_40Mhzto20Mhz;
1783 bool bforced_tx20Mhz;
1784 bool bautoswitch_enable;
d3b2c172 1785};
94a79942
LF
1786
1787
1788
1789#define REORDER_WIN_SIZE 128
1790#define REORDER_ENTRY_NUM 128
8cba1432 1791struct rx_reorder_entry {
94a79942
LF
1792 struct list_head List;
1793 u16 SeqNum;
1794 struct rtllib_rxb* prxb;
8cba1432 1795};
3c093c2b 1796enum fsync_state {
94a79942
LF
1797 Default_Fsync,
1798 HW_Fsync,
1799 SW_Fsync
3c093c2b 1800};
94a79942 1801
f6e3d4f4 1802enum rt_ps_mode {
94a79942
LF
1803 eActive,
1804 eMaxPs,
1805 eFastPs,
1806 eAutoPs,
f6e3d4f4 1807};
94a79942 1808
8304cc64 1809enum ips_callback_function {
94a79942
LF
1810 IPS_CALLBACK_NONE = 0,
1811 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1812 IPS_CALLBACK_JOIN_REQUEST = 2,
8304cc64 1813};
94a79942 1814
f6ce577e 1815enum rt_join_action {
94a79942
LF
1816 RT_JOIN_INFRA = 1,
1817 RT_JOIN_IBSS = 2,
1818 RT_START_IBSS = 3,
1819 RT_NO_ACTION = 4,
f6ce577e 1820};
94a79942 1821
7152e7ec 1822struct ibss_parms {
94a79942 1823 u16 atimWin;
d3b2c172 1824};
94a79942
LF
1825#define MAX_NUM_RATES 264
1826
de7c885a 1827enum rt_rf_power_state {
94a79942
LF
1828 eRfOn,
1829 eRfSleep,
1830 eRfOff
de7c885a 1831};
94a79942
LF
1832
1833#define MAX_SUPPORT_WOL_PATTERN_NUM 8
1834
1835#define MAX_WOL_BIT_MASK_SIZE 16
1836#define MAX_WOL_PATTERN_SIZE 128
1837
d45c88a6 1838enum wol_pattern_type {
94a79942
LF
1839 eNetBIOS = 0,
1840 eIPv4IPv6ARP,
1841 eIPv4IPv6TCPSYN,
1842 eMACIDOnly,
1843 eNoDefined,
d45c88a6 1844};
94a79942 1845
628c30e8 1846struct rt_pm_wol_info {
94a79942
LF
1847 u32 PatternId;
1848 u32 Mask[4];
1849 u16 CrcRemainder;
1850 u8 WFMIndex;
d45c88a6 1851 enum wol_pattern_type PatternType;
d3b2c172 1852};
94a79942 1853
ca990011 1854struct rt_pwr_save_ctrl {
94a79942
LF
1855
1856 bool bInactivePs;
1857 bool bIPSModeBackup;
1858 bool bHaltAdapterClkRQ;
1859 bool bSwRfProcessing;
de7c885a 1860 enum rt_rf_power_state eInactivePowerState;
edc4b2c5 1861 struct work_struct InactivePsWorkItem;
94a79942
LF
1862 struct timer_list InactivePsTimer;
1863
8304cc64 1864 enum ips_callback_function ReturnPoint;
94a79942
LF
1865
1866 bool bTmpBssDesc;
f6ce577e 1867 enum rt_join_action tmpJoinAction;
94a79942
LF
1868 struct rtllib_network tmpBssDesc;
1869
1870 bool bTmpScanOnly;
1871 bool bTmpActiveScan;
1872 bool bTmpFilterHiddenAP;
1873 bool bTmpUpdateParms;
1874 u8 tmpSsidBuf[33];
8310b6c0 1875 struct octet_string tmpSsid2Scan;
94a79942
LF
1876 bool bTmpSsid2Scan;
1877 u8 tmpNetworkType;
1878 u8 tmpChannelNumber;
1879 u16 tmpBcnPeriod;
1880 u8 tmpDtimPeriod;
1881 u16 tmpmCap;
8310b6c0 1882 struct octet_string tmpSuppRateSet;
94a79942
LF
1883 u8 tmpSuppRateBuf[MAX_NUM_RATES];
1884 bool bTmpSuppRate;
7152e7ec 1885 struct ibss_parms tmpIbpm;
94a79942
LF
1886 bool bTmpIbpm;
1887
1888 bool bLeisurePs;
1889 u32 PowerProfile;
1890 u8 LpsIdleCount;
1891 u8 RegMaxLPSAwakeIntvl;
1892 u8 LPSAwakeIntvl;
1893
1894 u32 CurPsLevel;
1895 u32 RegRfPsLevel;
1896
1897 bool bFwCtrlLPS;
1898 u8 FWCtrlPSMode;
1899
1900 bool LinkReqInIPSRFOffPgs;
1901 bool BufConnectinfoBefore;
1902
1903
1904 bool bGpioRfSw;
1905
1906 u8 RegAMDPciASPM;
1907
1908 u8 oWLANMode;
628c30e8 1909 struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM];
94a79942 1910
d3b2c172 1911};
94a79942
LF
1912
1913typedef u32 RT_RF_CHANGE_SOURCE;
1914#define RF_CHANGE_BY_SW BIT31
1915#define RF_CHANGE_BY_HW BIT30
1916#define RF_CHANGE_BY_PS BIT29
1917#define RF_CHANGE_BY_IPS BIT28
1918#define RF_CHANGE_BY_INIT 0
1919
569e5959 1920enum country_code_type {
94a79942
LF
1921 COUNTRY_CODE_FCC = 0,
1922 COUNTRY_CODE_IC = 1,
1923 COUNTRY_CODE_ETSI = 2,
1924 COUNTRY_CODE_SPAIN = 3,
1925 COUNTRY_CODE_FRANCE = 4,
1926 COUNTRY_CODE_MKK = 5,
1927 COUNTRY_CODE_MKK1 = 6,
1928 COUNTRY_CODE_ISRAEL = 7,
1929 COUNTRY_CODE_TELEC = 8,
1930 COUNTRY_CODE_MIC = 9,
1931 COUNTRY_CODE_GLOBAL_DOMAIN = 10,
1932 COUNTRY_CODE_WORLD_WIDE_13 = 11,
1933 COUNTRY_CODE_TELEC_NETGEAR = 12,
1934 COUNTRY_CODE_MAX
569e5959 1935};
94a79942 1936
472ba326 1937enum scan_op_backup_opt {
94a79942
LF
1938 SCAN_OPT_BACKUP=0,
1939 SCAN_OPT_RESTORE,
1940 SCAN_OPT_MAX
472ba326 1941};
94a79942 1942
74082c92 1943enum fw_cmd_io_type {
94a79942
LF
1944 FW_CMD_DIG_ENABLE = 0,
1945 FW_CMD_DIG_DISABLE = 1,
1946 FW_CMD_DIG_HALT = 2,
1947 FW_CMD_DIG_RESUME = 3,
1948 FW_CMD_HIGH_PWR_ENABLE = 4,
1949 FW_CMD_HIGH_PWR_DISABLE = 5,
1950 FW_CMD_RA_RESET = 6,
1951 FW_CMD_RA_ACTIVE= 7,
1952 FW_CMD_RA_REFRESH_N= 8,
1953 FW_CMD_RA_REFRESH_BG= 9,
1954 FW_CMD_RA_INIT= 10,
1955 FW_CMD_IQK_ENABLE = 11,
1956 FW_CMD_TXPWR_TRACK_ENABLE = 12,
1957 FW_CMD_TXPWR_TRACK_DISABLE = 13,
1958 FW_CMD_TXPWR_TRACK_THERMAL = 14,
1959 FW_CMD_PAUSE_DM_BY_SCAN = 15,
1960 FW_CMD_RESUME_DM_BY_SCAN = 16,
1961 FW_CMD_RA_REFRESH_N_COMB = 17,
1962 FW_CMD_RA_REFRESH_BG_COMB = 18,
1963 FW_CMD_ANTENNA_SW_ENABLE = 19,
1964 FW_CMD_ANTENNA_SW_DISABLE = 20,
1965 FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
1966 FW_CMD_LPS_ENTER = 22,
1967 FW_CMD_LPS_LEAVE = 23,
1968 FW_CMD_DIG_MODE_SS = 24,
1969 FW_CMD_DIG_MODE_FA = 25,
1970 FW_CMD_ADD_A2_ENTRY = 26,
1971 FW_CMD_CTRL_DM_BY_DRIVER = 27,
1972 FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28,
1973 FW_CMD_PAPE_CONTROL = 29,
1974 FW_CMD_CHAN_SET = 30,
74082c92 1975};
94a79942
LF
1976
1977#define RT_MAX_LD_SLOT_NUM 10
0e86753f 1978struct rt_link_detect {
94a79942
LF
1979
1980 u32 NumRecvBcnInPeriod;
1981 u32 NumRecvDataInPeriod;
1982
1983 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
1984 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
1985 u16 SlotNum;
1986 u16 SlotIndex;
1987
1988 u32 NumTxOkInPeriod;
1989 u32 NumRxOkInPeriod;
1990 u32 NumRxUnicastOkInPeriod;
1991 bool bBusyTraffic;
1992 bool bHigherBusyTraffic;
1993 bool bHigherBusyRxTraffic;
1994 u8 IdleCount;
1995 u32 NumTxUnicastOkInPeriod;
1996 u32 LastNumTxUnicast;
1997 u32 LastNumRxUnicast;
d3b2c172 1998};
94a79942 1999
5ea04480 2000struct sw_cam_table {
94a79942
LF
2001
2002 u8 macaddr[6];
2003 bool bused;
2004 u8 key_buf[16];
2005 u16 key_type;
2006 u8 useDK;
2007 u8 key_index;
2008
d3b2c172 2009};
94a79942 2010#define TOTAL_CAM_ENTRY 32
9be6f10e 2011struct rate_adaptive {
94a79942
LF
2012 u8 rate_adaptive_disabled;
2013 u8 ratr_state;
2014 u16 reserve;
2015
2016 u32 high_rssi_thresh_for_ra;
2017 u32 high2low_rssi_thresh_for_ra;
2018 u8 low2high_rssi_thresh_for_ra40M;
2019 u32 low_rssi_thresh_for_ra40M;
2020 u8 low2high_rssi_thresh_for_ra20M;
2021 u32 low_rssi_thresh_for_ra20M;
2022 u32 upper_rssi_threshold_ratr;
2023 u32 middle_rssi_threshold_ratr;
2024 u32 low_rssi_threshold_ratr;
2025 u32 low_rssi_threshold_ratr_40M;
2026 u32 low_rssi_threshold_ratr_20M;
2027 u8 ping_rssi_enable;
2028 u32 ping_rssi_ratr;
2029 u32 ping_rssi_thresh_for_ra;
2030 u32 last_ratr;
2031 u8 PreRATRState;
2032
9be6f10e 2033};
d0df2813 2034enum ratr_table_mode_8192s {
94a79942
LF
2035 RATR_INX_WIRELESS_NGB = 0,
2036 RATR_INX_WIRELESS_NG = 1,
2037 RATR_INX_WIRELESS_NB = 2,
2038 RATR_INX_WIRELESS_N = 3,
2039 RATR_INX_WIRELESS_GB = 4,
2040 RATR_INX_WIRELESS_G = 5,
2041 RATR_INX_WIRELESS_B = 6,
2042 RATR_INX_WIRELESS_MC = 7,
2043 RATR_INX_WIRELESS_A = 8,
d0df2813 2044};
94a79942
LF
2045
2046#define NUM_PMKID_CACHE 16
74d0497b 2047struct rt_pmkid_list {
94a79942
LF
2048 u8 bUsed;
2049 u8 Bssid[6];
2050 u8 PMKID[16];
2051 u8 SsidBuf[33];
2052 u8* ssid_octet;
2053 u16 ssid_length;
74d0497b 2054};
94a79942 2055
ca394055 2056struct rt_intel_promisc_mode {
94a79942
LF
2057 bool bPromiscuousOn;
2058 bool bFilterSourceStationFrame;
ca394055 2059};
94a79942
LF
2060
2061
2062/*************** DRIVER STATUS *****/
2063#define STATUS_SCANNING 0
2064#define STATUS_SCAN_HW 1
2065#define STATUS_SCAN_ABORTING 2
2066#define STATUS_SETTING_CHAN 3
2067/*************** DRIVER STATUS *****/
2068
2069enum {
2070 NO_USE = 0,
2071 USED = 1,
2072 HW_SEC = 2,
2073 SW_SEC = 3,
2074};
2075
2076enum {
2077 LPS_IS_WAKE = 0,
2078 LPS_IS_SLEEP = 1,
2079 LPS_WAIT_NULL_DATA_SEND =2,
2080};
2081
2082struct rtllib_device {
2083 struct pci_dev *pdev;
2084 struct net_device *dev;
2085 struct rtllib_security sec;
2086
2087 bool disable_mgnt_queue;
2088
2089 unsigned long status;
2090 short hwscan_ch_bk;
b678bd1f 2091 enum ht_extchnl_offset chan_offset_bk;
6e579119 2092 enum ht_channel_width bandwidth_bk;
94a79942 2093 u8 hwscan_sem_up;
94a79942
LF
2094 u8 CntAfterLink;
2095
e93e0f6a 2096 enum rt_op_mode OpMode;
94a79942
LF
2097
2098 u8 VersionID;
2099 /* The last AssocReq/Resp IEs */
2100 u8 *assocreq_ies, *assocresp_ies;
2101 size_t assocreq_ies_len, assocresp_ies_len;
2102
2103 bool b_customer_lenovo_id;
2104 bool bForcedShowRxRate;
2105 bool bForcedShowRateStill;
2106 u8 SystemQueryDataRateCount;
2107 bool bForcedBgMode;
2108 bool bUseRAMask;
2109 bool b1x1RecvCombine;
2110 u8 RF_Type;
2111 bool b1SSSupport;
2112
2113 u8 hwsec_active;
2114 bool is_silent_reset;
2115 bool force_mic_error;
2116 bool is_roaming;
2117 bool ieee_up;
2118 bool cannot_notify;
2119 bool bSupportRemoteWakeUp;
f6e3d4f4 2120 enum rt_ps_mode dot11PowerSaveMode;
94a79942
LF
2121 bool actscanning;
2122 bool FirstIe_InScan;
2123 bool be_scan_inprogress;
2124 bool beinretry;
de7c885a 2125 enum rt_rf_power_state eRFPowerState;
94a79942
LF
2126 RT_RF_CHANGE_SOURCE RfOffReason;
2127 bool is_set_key;
2128 bool wx_set_enc;
7796d93e 2129 struct rt_hi_throughput *pHTInfo;
94a79942
LF
2130 spinlock_t bw_spinlock;
2131
2132 spinlock_t reorder_spinlock;
2133 u8 Regdot11HTOperationalRateSet[16];
2134 u8 Regdot11TxHTOperationalRateSet[16];
2135 u8 dot11HTOperationalRateSet[16];
2136 u8 RegHTSuppRateSet[16];
2137 u8 HTCurrentOperaRate;
2138 u8 HTHighestOperaRate;
2139 u8 MinSpaceCfg;
2140 u8 MaxMssDensity;
2141 u8 bTxDisableRateFallBack;
2142 u8 bTxUseDriverAssingedRate;
2143 u8 bTxEnableFwCalcDur;
2144 atomic_t atm_chnlop;
2145 atomic_t atm_swbw;
2146
2147 struct list_head Tx_TS_Admit_List;
2148 struct list_head Tx_TS_Pending_List;
2149 struct list_head Tx_TS_Unused_List;
60554f2b 2150 struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
94a79942
LF
2151 struct list_head Rx_TS_Admit_List;
2152 struct list_head Rx_TS_Pending_List;
2153 struct list_head Rx_TS_Unused_List;
2c47ae28 2154 struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
8cba1432 2155 struct rx_reorder_entry RxReorderEntry[128];
94a79942
LF
2156 struct list_head RxReorder_Unused_List;
2157 u8 ForcedPriority;
2158
2159
2160 /* Bookkeeping structures */
2161 struct net_device_stats stats;
2162 struct rtllib_stats ieee_stats;
2163 struct rtllib_softmac_stats softmac_stats;
2164
2165 /* Probe / Beacon management */
2166 struct list_head network_free_list;
2167 struct list_head network_list;
94a79942
LF
2168 struct rtllib_network *networks;
2169 int scans;
2170 int scan_age;
2171
2172 int iw_mode; /* operating mode (IW_MODE_*) */
2173 bool bNetPromiscuousMode;
ca394055 2174 struct rt_intel_promisc_mode IntelPromiscuousModeInfo;
94a79942
LF
2175
2176 struct iw_spy_data spy_data;
2177
2178 spinlock_t lock;
2179 spinlock_t wpax_suitlist_lock;
2180
2181 int tx_headroom; /* Set to size of any additional room needed at front
2182 * of allocated Tx SKBs */
2183 u32 config;
2184
2185 /* WEP and other encryption related settings at the device level */
2186 int open_wep; /* Set to 1 to allow unencrypted frames */
2187 int auth_mode;
2188 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
2189 * WEP key changes */
2190
2191 /* If the host performs {en,de}cryption, then set to 1 */
2192 int host_encrypt;
2193 int host_encrypt_msdu;
2194 int host_decrypt;
2195 /* host performs multicast decryption */
2196 int host_mc_decrypt;
2197
2198 /* host should strip IV and ICV from protected frames */
2199 /* meaningful only when hardware decryption is being used */
2200 int host_strip_iv_icv;
2201
2202 int host_open_frag;
2203 int host_build_iv;
2204 int ieee802_1x; /* is IEEE 802.1X used */
2205
2206 /* WPA data */
2207 bool bHalfNMode;
2208 bool bHalfWirelessN24GMode;
2209 int wpa_enabled;
2210 int drop_unencrypted;
2211 int tkip_countermeasures;
2212 int privacy_invoked;
2213 size_t wpa_ie_len;
2214 u8 *wpa_ie;
2215 size_t wps_ie_len;
2216 u8 *wps_ie;
2217 u8 ap_mac_addr[6];
2218 u16 pairwise_key_type;
2219 u16 group_key_type;
2220 struct list_head crypt_deinit_list;
2221 struct rtllib_crypt_data *crypt[WEP_KEYS];
2222
2223 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
5ea04480 2224 struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
94a79942
LF
2225 struct timer_list crypt_deinit_timer;
2226 int crypt_quiesced;
2227
2228 int bcrx_sta_key; /* use individual keys to override default keys even
2229 * with RX of broad/multicast frames */
2230
74d0497b 2231 struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
94a79942
LF
2232
2233 /* Fragmentation structures */
2234 struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
2235 unsigned int frag_next_idx[17];
2236 u16 fts; /* Fragmentation Threshold */
2237#define DEFAULT_RTS_THRESHOLD 2346U
2238#define MIN_RTS_THRESHOLD 1
2239#define MAX_RTS_THRESHOLD 2346U
2240 u16 rts; /* RTS threshold */
2241
2242 /* Association info */
2243 u8 bssid[ETH_ALEN];
2244
2245 /* This stores infos for the current network.
2246 * Either the network we are associated in INFRASTRUCTURE
2247 * or the network that we are creating in MASTER mode.
2248 * ad-hoc is a mixture ;-).
2249 * Note that in infrastructure mode, even when not associated,
2250 * fields bssid and essid may be valid (if wpa_set and essid_set
2251 * are true) as thy carry the value set by the user via iwconfig
2252 */
2253 struct rtllib_network current_network;
2254
2255 enum rtllib_state state;
2256
2257 int short_slot;
2258 int reg_mode;
2259 int mode; /* A, B, G */
2260 int modulation; /* CCK, OFDM */
2261 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
2262 int abg_true; /* ABG flag */
2263
2264 /* used for forcing the ibss workqueue to terminate
2265 * without wait for the syncro scan to terminate
2266 */
2267 short sync_scan_hurryup;
2268 u16 scan_watch_dog;
2269 int perfect_rssi;
2270 int worst_rssi;
2271
2272 u16 prev_seq_ctl; /* used to drop duplicate frames */
2273
2274 /* map of allowed channels. 0 is dummy */
94a79942
LF
2275 void* pDot11dInfo;
2276 bool bGlobalDomain;
94a79942
LF
2277 u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
2278
2279 u8 IbssStartChnl;
2280 u8 ibss_maxjoin_chal;
2281
2282 int rate; /* current rate */
2283 int basic_rate;
2284 u32 currentRate;
2285
2286 short active_scan;
2287
2288 /* this contains flags for selectively enable softmac support */
2289 u16 softmac_features;
2290
2291 /* if the sequence control field is not filled by HW */
2292 u16 seq_ctrl[5];
2293
2294 /* association procedure transaction sequence number */
2295 u16 associate_seq;
2296
2297 /* AID for RTXed association responses */
2298 u16 assoc_id;
2299
2300 /* power save mode related*/
2301 u8 ack_tx_to_ieee;
2302 short ps;
2303 short sta_sleep;
2304 int ps_timeout;
2305 int ps_period;
2306 struct tasklet_struct ps_task;
2307 u32 ps_th;
2308 u32 ps_tl;
2309 bool polling;
2310
2311 short raw_tx;
2312 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2313 short queue_stop;
2314 short scanning_continue ;
2315 short proto_started;
2316 short proto_stoppping;
2317
2318 struct semaphore wx_sem;
2319 struct semaphore scan_sem;
2320 struct semaphore ips_sem;
2321
2322 spinlock_t mgmt_tx_lock;
2323 spinlock_t beacon_lock;
2324
2325 short beacon_txing;
2326
2327 short wap_set;
2328 short ssid_set;
2329
2330 /* set on initialization */
2331 u8 qos_support;
2332 unsigned int wmm_acm;
2333
2334 /* for discarding duplicated packets in IBSS */
2335 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
2336
2337 /* for discarding duplicated packets in BSS */
2338 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
2339 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
2340 unsigned long last_packet_time[17];
2341
2342 /* for PS mode */
2343 unsigned long last_rx_ps_time;
2344 bool bAwakePktSent;
2345 u8 LPSDelayCnt;
2346
2347 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
2348 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
2349 int mgmt_queue_head;
2350 int mgmt_queue_tail;
2351#define RTLLIB_QUEUE_LIMIT 128
2352 u8 AsocRetryCount;
2353 unsigned int hw_header;
2354 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
2355 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
2356 struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
2357 u32 sta_edca_param[4];
2358 bool aggregation;
2359 bool enable_rx_imm_BA;
2360 bool bibsscoordinator;
2361
2362 bool bdynamic_txpower_enable;
2363
2364 bool bCTSToSelfEnable;
2365 u8 CTSToSelfTH;
2366
2367 u32 fsync_time_interval;
2368 u32 fsync_rate_bitmap;
2369 u8 fsync_rssi_threshold;
2370 bool bfsync_enable;
2371
2372 u8 fsync_multiple_timeinterval;
2373 u32 fsync_firstdiff_ratethreshold;
2374 u32 fsync_seconddiff_ratethreshold;
3c093c2b 2375 enum fsync_state fsync_state;
94a79942 2376 bool bis_any_nonbepkts;
dca0eb1e 2377 struct bandwidth_autoswitch bandwidth_auto_switch;
94a79942
LF
2378 bool FwRWRF;
2379
0e86753f 2380 struct rt_link_detect LinkDetectInfo;
94a79942 2381 bool bIsAggregateFrame;
ca990011 2382 struct rt_pwr_save_ctrl PowerSaveControl;
94a79942
LF
2383 u8 amsdu_in_process;
2384
2385 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
0ce60045 2386 struct tx_pending tx_pending;
94a79942
LF
2387
2388 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
2389 struct timer_list associate_timer;
2390
2391 /* used if IEEE_SOFTMAC_BEACONS is set */
2392 struct timer_list beacon_timer;
2393 u8 need_sw_enc;
edc4b2c5
LF
2394 struct work_struct associate_complete_wq;
2395 struct work_struct ips_leave_wq;
2396 struct delayed_work associate_procedure_wq;
2397 struct delayed_work softmac_scan_wq;
2398 struct delayed_work softmac_hint11d_wq;
2399 struct delayed_work associate_retry_wq;
2400 struct delayed_work start_ibss_wq;
2401 struct delayed_work hw_wakeup_wq;
2402 struct delayed_work hw_sleep_wq;
2403 struct delayed_work link_change_wq;
2404 struct work_struct wx_sync_scan_wq;
94a79942
LF
2405
2406 struct workqueue_struct *wq;
2407
2408 /* Callback functions */
2409 void (*set_security)(struct net_device *dev,
2410 struct rtllib_security *sec);
2411
2412 /* Used to TX data frame by using txb structs.
2413 * this is not used if in the softmac_features
2414 * is set the flag IEEE_SOFTMAC_TX_QUEUE
2415 */
2416 int (*hard_start_xmit)(struct rtllib_txb *txb,
2417 struct net_device *dev);
2418
2419 int (*reset_port)(struct net_device *dev);
2420 int (*is_queue_full) (struct net_device * dev, int pri);
2421
2422 int (*handle_management) (struct net_device * dev,
2423 struct rtllib_network * network, u16 type);
2424 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
2425
2426 /* Softmac-generated frames (mamagement) are TXed via this
2427 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
2428 * not set. As some cards may have different HW queues that
2429 * one might want to use for data and management frames
2430 * the option to have two callbacks might be useful.
2431 * This fucntion can't sleep.
2432 */
2433 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
2434 struct net_device *dev);
2435
2436 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
2437 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
2438 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
2439 * then also management frames are sent via this callback.
2440 * This function can't sleep.
2441 */
2442 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
2443 struct net_device *dev,int rate);
2444
2445 /* stops the HW queue for DATA frames. Useful to avoid
2446 * waste time to TX data frame when we are reassociating
2447 * This function can sleep.
2448 */
2449 void (*data_hard_stop)(struct net_device *dev);
2450
2451 /* OK this is complementar to data_poll_hard_stop */
2452 void (*data_hard_resume)(struct net_device *dev);
2453
2454 /* ask to the driver to retune the radio .
2455 * This function can sleep. the driver should ensure
2456 * the radio has been swithced before return.
2457 */
2458 void (*set_chan)(struct net_device *dev,short ch);
2459
2460 /* These are not used if the ieee stack takes care of
2461 * scanning (IEEE_SOFTMAC_SCAN feature set).
2462 * In this case only the set_chan is used.
2463 *
2464 * The syncro version is similar to the start_scan but
2465 * does not return until all channels has been scanned.
2466 * this is called in user context and should sleep,
2467 * it is called in a work_queue when swithcing to ad-hoc mode
2468 * or in behalf of iwlist scan when the card is associated
2469 * and root user ask for a scan.
2470 * the fucntion stop_scan should stop both the syncro and
2471 * background scanning and can sleep.
2472 * The fucntion start_scan should initiate the background
2473 * scanning and can't sleep.
2474 */
2475 void (*scan_syncro)(struct net_device *dev);
2476 void (*start_scan)(struct net_device *dev);
2477 void (*stop_scan)(struct net_device *dev);
2478
2479 void (*rtllib_start_hw_scan)(struct net_device *dev);
2480 void (*rtllib_stop_hw_scan)(struct net_device *dev);
2481
2482 /* indicate the driver that the link state is changed
2483 * for example it may indicate the card is associated now.
2484 * Driver might be interested in this to apply RX filter
2485 * rules or simply light the LINK led
2486 */
2487 void (*link_change)(struct net_device *dev);
2488
2489 /* these two function indicates to the HW when to start
2490 * and stop to send beacons. This is used when the
2491 * IEEE_SOFTMAC_BEACONS is not set. For now the
2492 * stop_send_bacons is NOT guaranteed to be called only
2493 * after start_send_beacons.
2494 */
2495 void (*start_send_beacons) (struct net_device *dev);
2496 void (*stop_send_beacons) (struct net_device *dev);
2497
2498 /* power save mode related */
2499 void (*sta_wake_up) (struct net_device *dev);
2500 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
2501 short (*ps_is_queue_empty) (struct net_device *dev);
2502 int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network);
2503 int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network);
2504
2505
2506 /* check whether Tx hw resouce available */
2507 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
2508 short (*get_nic_desc_num)(struct net_device *dev, int queue_index);
b678bd1f 2509 void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset);
94a79942
LF
2510 bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
2511 void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
2512 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
2513 u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
2514 void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value);
2515 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
74082c92 2516 bool (*SetFwCmdHandler)(struct net_device *dev, enum fw_cmd_io_type FwCmdIO);
94a79942
LF
2517 void (*UpdateHalRAMaskHandler)(struct net_device* dev, bool bMulticast, u8 macId, u8 MimoPs, u8 WirelessMode, u8 bCurTxBW40MHz, u8 rssi_level);
2518 void (*UpdateBeaconInterruptHandler)(struct net_device* dev, bool start);
2519 void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR);
2520 u16 (*rtl_11n_user_show_rates)(struct net_device *dev);
2521 void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation);
4fd7cedc 2522 void (*LedControlHandler)(struct net_device * dev, enum led_ctl_mode LedAction);
94a79942
LF
2523 void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val);
2524 void (*GetHwRegHandler)(struct net_device *dev,u8 variable,u8* val);
2525
2526 void (*AllowAllDestAddrHandler)(struct net_device *dev, bool bAllowAllDA, bool WriteIntoReg);
2527
2528 void (*rtllib_ips_leave_wq) (struct net_device *dev);
2529 void (*rtllib_ips_leave)(struct net_device *dev);
2530 void (*LeisurePSLeave)(struct net_device *dev);
2531 void (*rtllib_rfkill_poll)(struct net_device *dev);
2532
2533 /* This must be the last item so that it points to the data
2534 * allocated beyond this structure by alloc_rtllib */
2535 u8 priv[0];
2536};
2537
2538#define IEEE_A (1<<0)
2539#define IEEE_B (1<<1)
2540#define IEEE_G (1<<2)
2541#define IEEE_N_24G (1<<4)
2542#define IEEE_N_5G (1<<5)
2543#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
2544
2545/* Generate a 802.11 header */
2546
2547/* Uses the channel change callback directly
2548 * instead of [start/stop] scan callbacks
2549 */
2550#define IEEE_SOFTMAC_SCAN (1<<2)
2551
2552/* Perform authentication and association handshake */
2553#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2554
2555/* Generate probe requests */
2556#define IEEE_SOFTMAC_PROBERQ (1<<4)
2557
2558/* Generate respones to probe requests */
2559#define IEEE_SOFTMAC_PROBERS (1<<5)
2560
2561/* The ieee802.11 stack will manages the netif queue
2562 * wake/stop for the driver, taking care of 802.11
2563 * fragmentation. See softmac.c for details. */
2564#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
2565
2566/* Uses only the softmac_data_hard_start_xmit
2567 * even for TX management frames.
2568 */
2569#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2570
2571/* Generate beacons. The stack will enqueue beacons
2572 * to the card
2573 */
2574#define IEEE_SOFTMAC_BEACONS (1<<6)
2575
2576
2577static inline void *rtllib_priv(struct net_device *dev)
2578{
2579 return ((struct rtllib_device *)netdev_priv(dev))->priv;
2580}
2581
2582extern inline int rtllib_is_empty_essid(const char *essid, int essid_len)
2583{
2584 /* Single white space is for Linksys APs */
2585 if (essid_len == 1 && essid[0] == ' ')
2586 return 1;
2587
2588 /* Otherwise, if the entire essid is 0, we assume it is hidden */
2589 while (essid_len) {
2590 essid_len--;
2591 if (essid[essid_len] != '\0')
2592 return 0;
2593 }
2594
2595 return 1;
2596}
2597
2598extern inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode)
2599{
2600 /*
2601 * It is possible for both access points and our device to support
2602 * combinations of modes, so as long as there is one valid combination
2603 * of ap/device supported modes, then return success
2604 *
2605 */
2606 if ((mode & IEEE_A) &&
2607 (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2608 (ieee->freq_band & RTLLIB_52GHZ_BAND))
2609 return 1;
2610
2611 if ((mode & IEEE_G) &&
2612 (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2613 (ieee->freq_band & RTLLIB_24GHZ_BAND))
2614 return 1;
2615
2616 if ((mode & IEEE_B) &&
2617 (ieee->modulation & RTLLIB_CCK_MODULATION) &&
2618 (ieee->freq_band & RTLLIB_24GHZ_BAND))
2619 return 1;
2620
2621 return 0;
2622}
2623
2624extern inline int rtllib_get_hdrlen(u16 fc)
2625{
2626 int hdrlen = RTLLIB_3ADDR_LEN;
2627
2628 switch (WLAN_FC_GET_TYPE(fc)) {
2629 case RTLLIB_FTYPE_DATA:
2630 if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
2631 hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
2632 if (RTLLIB_QOS_HAS_SEQ(fc))
2633 hdrlen += 2; /* QOS ctrl*/
2634 break;
2635 case RTLLIB_FTYPE_CTL:
2636 switch (WLAN_FC_GET_STYPE(fc)) {
2637 case RTLLIB_STYPE_CTS:
2638 case RTLLIB_STYPE_ACK:
2639 hdrlen = RTLLIB_1ADDR_LEN;
2640 break;
2641 default:
2642 hdrlen = RTLLIB_2ADDR_LEN;
2643 break;
2644 }
2645 break;
2646 }
2647
2648 return hdrlen;
2649}
2650
2651static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
2652{
2653 switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2654 case RTLLIB_1ADDR_LEN:
2655 return ((struct rtllib_hdr_1addr *)hdr)->payload;
2656 case RTLLIB_2ADDR_LEN:
2657 return ((struct rtllib_hdr_2addr *)hdr)->payload;
2658 case RTLLIB_3ADDR_LEN:
2659 return ((struct rtllib_hdr_3addr *)hdr)->payload;
2660 case RTLLIB_4ADDR_LEN:
2661 return ((struct rtllib_hdr_4addr *)hdr)->payload;
2662 }
2663 return NULL;
2664}
2665
2666static inline int rtllib_is_ofdm_rate(u8 rate)
2667{
2668 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2669 case RTLLIB_OFDM_RATE_6MB:
2670 case RTLLIB_OFDM_RATE_9MB:
2671 case RTLLIB_OFDM_RATE_12MB:
2672 case RTLLIB_OFDM_RATE_18MB:
2673 case RTLLIB_OFDM_RATE_24MB:
2674 case RTLLIB_OFDM_RATE_36MB:
2675 case RTLLIB_OFDM_RATE_48MB:
2676 case RTLLIB_OFDM_RATE_54MB:
2677 return 1;
2678 }
2679 return 0;
2680}
2681
2682static inline int rtllib_is_cck_rate(u8 rate)
2683{
2684 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2685 case RTLLIB_CCK_RATE_1MB:
2686 case RTLLIB_CCK_RATE_2MB:
2687 case RTLLIB_CCK_RATE_5MB:
2688 case RTLLIB_CCK_RATE_11MB:
2689 return 1;
2690 }
2691 return 0;
2692}
2693
2694
94a79942
LF
2695/* rtllib.c */
2696extern void free_rtllib(struct net_device *dev);
2697extern struct net_device *alloc_rtllib(int sizeof_priv);
2698
2699extern int rtllib_set_encryption(struct rtllib_device *ieee);
2700
2701/* rtllib_tx.c */
2702
2703extern int rtllib_encrypt_fragment(
2704 struct rtllib_device *ieee,
2705 struct sk_buff *frag,
2706 int hdr_len);
2707
2708extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
2709extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
2710extern void rtllib_txb_free(struct rtllib_txb *);
2711
2712/* rtllib_rx.c */
2713extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
2714 struct rtllib_rx_stats *rx_stats);
2715extern void rtllib_rx_mgt(struct rtllib_device *ieee,
2716 struct sk_buff *skb,
2717 struct rtllib_rx_stats *stats);
2718extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
2719 struct sk_buff *skb);
2720extern int IsLegalChannel( struct rtllib_device *rtllib, u8 channel);
2721
2722/* rtllib_wx.c */
2723extern int rtllib_wx_get_scan(struct rtllib_device *ieee,
2724 struct iw_request_info *info,
2725 union iwreq_data *wrqu, char *key);
2726extern int rtllib_wx_set_encode(struct rtllib_device *ieee,
2727 struct iw_request_info *info,
2728 union iwreq_data *wrqu, char *key);
2729extern int rtllib_wx_get_encode(struct rtllib_device *ieee,
2730 struct iw_request_info *info,
2731 union iwreq_data *wrqu, char *key);
2732#if WIRELESS_EXT >= 18
2733extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee,
2734 struct iw_request_info *info,
2735 union iwreq_data* wrqu, char *extra);
2736extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
2737 struct iw_request_info *info,
2738 union iwreq_data* wrqu, char *extra);
2739#endif
2740extern int rtllib_wx_set_auth(struct rtllib_device *ieee,
2741 struct iw_request_info *info,
2742 struct iw_param *data, char *extra);
2743extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
2744 struct iw_request_info *info,
2745 union iwreq_data *wrqu, char *extra);
2746extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
2747
2748/* rtllib_softmac.c */
2749extern short rtllib_is_54g(struct rtllib_network *net);
2750extern short rtllib_is_shortslot(struct rtllib_network net);
2751extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb,
2752 struct rtllib_rx_stats *rx_stats, u16 type,
2753 u16 stype);
2754extern void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net);
2755
2756void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
2757extern void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee);
2758
2759extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2760extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2761extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
2762extern void rtllib_start_bss(struct rtllib_device *ieee);
2763extern void rtllib_start_master_bss(struct rtllib_device *ieee);
2764extern void rtllib_start_ibss(struct rtllib_device *ieee);
2765extern void rtllib_softmac_init(struct rtllib_device *ieee);
2766extern void rtllib_softmac_free(struct rtllib_device *ieee);
2767extern void rtllib_associate_abort(struct rtllib_device *ieee);
2768extern void rtllib_disassociate(struct rtllib_device *ieee);
2769extern void rtllib_stop_scan(struct rtllib_device *ieee);
2770extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
2771extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
2772extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2773extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee);
2774extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee);
2775extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr);
2776extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
2777extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
2778extern void rtllib_check_all_nets(struct rtllib_device *ieee);
2779extern void rtllib_start_protocol(struct rtllib_device *ieee);
2780extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
2781
2782extern void rtllib_EnableNetMonitorMode(struct net_device* dev, bool bInitState);
2783extern void rtllib_DisableNetMonitorMode(struct net_device* dev, bool bInitState);
2784extern void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, bool bInitState);
2785extern void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, bool bInitState);
2786extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
2787
2788extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown);
2789extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,u8 mesh_flag);
2790
2791extern void rtllib_reset_queue(struct rtllib_device *ieee);
2792extern void rtllib_wake_queue(struct rtllib_device *ieee);
2793extern void rtllib_stop_queue(struct rtllib_device *ieee);
2794extern void rtllib_wake_all_queues(struct rtllib_device *ieee);
2795extern void rtllib_stop_all_queues(struct rtllib_device *ieee);
2796extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
2797extern void rtllib_start_send_beacons(struct rtllib_device *ieee);
2798extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2799extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh);
2800
2801extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2802extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
2803
2804extern void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee);
2805extern u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst);
2806extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
2807
2808/* rtllib_crypt_ccmp&tkip&wep.c */
2809extern void rtllib_tkip_null(void);
2810extern void rtllib_wep_null(void);
2811extern void rtllib_ccmp_null(void);
2812
2813/* rtllib_softmac_wx.c */
2814
2815extern int rtllib_wx_get_wap(struct rtllib_device *ieee,
2816 struct iw_request_info *info,
2817 union iwreq_data *wrqu, char *ext);
2818
2819extern int rtllib_wx_set_wap(struct rtllib_device *ieee,
2820 struct iw_request_info *info,
2821 union iwreq_data *awrq,
2822 char *extra);
2823
2824extern int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
2825
2826extern int rtllib_wx_set_rate(struct rtllib_device *ieee,
2827 struct iw_request_info *info,
2828 union iwreq_data *wrqu, char *extra);
2829
2830extern int rtllib_wx_get_rate(struct rtllib_device *ieee,
2831 struct iw_request_info *info,
2832 union iwreq_data *wrqu, char *extra);
2833
2834extern int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a,
2835 union iwreq_data *wrqu, char *b);
2836
2837extern int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a,
2838 union iwreq_data *wrqu, char *b);
2839
2840extern int rtllib_wx_set_essid(struct rtllib_device *ieee,
2841 struct iw_request_info *a,
2842 union iwreq_data *wrqu, char *extra);
2843
2844extern int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a,
2845 union iwreq_data *wrqu, char *b);
2846
2847extern int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
2848 union iwreq_data *wrqu, char *b);
2849
2850extern int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a,
2851 union iwreq_data *wrqu, char *b);
2852extern void rtllib_wx_sync_scan_wq(void *data);
2853
2854extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
2855 struct iw_request_info *info,
2856 union iwreq_data *wrqu, char *extra);
2857
2858extern int rtllib_wx_get_name(struct rtllib_device *ieee,
2859 struct iw_request_info *info,
2860 union iwreq_data *wrqu, char *extra);
2861
2862extern int rtllib_wx_set_power(struct rtllib_device *ieee,
2863 struct iw_request_info *info,
2864 union iwreq_data *wrqu, char *extra);
2865
2866extern int rtllib_wx_get_power(struct rtllib_device *ieee,
2867 struct iw_request_info *info,
2868 union iwreq_data *wrqu, char *extra);
2869
2870extern int rtllib_wx_set_rts(struct rtllib_device *ieee,
2871 struct iw_request_info *info,
2872 union iwreq_data *wrqu, char *extra);
2873
2874extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
2875 struct iw_request_info *info,
2876 union iwreq_data *wrqu, char *extra);
2877#define MAX_RECEIVE_BUFFER_SIZE 9100
2878extern void HTDebugHTCapability(u8* CapIE, u8* TitleString );
2879extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString);
2880
b678bd1f 2881void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset);
94a79942
LF
2882extern void HTUpdateDefaultSetting(struct rtllib_device* ieee);
2883extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc);
2884extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt);
2885extern void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len);
2886extern void HTOnAssocRsp(struct rtllib_device *ieee);
2887extern void HTInitializeHTInfo(struct rtllib_device* ieee);
a15e76ad 2888extern void HTInitializeBssDesc(struct bss_ht *pBssHT);
94a79942
LF
2889extern void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork);
2890extern void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork);
2891extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter);
2892extern u8 MCS_FILTER_ALL[];
2893extern u16 MCS_DATA_RATE[2][2][77] ;
2894extern u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame);
7796d93e 2895extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
94a79942
LF
2896extern bool IsHTHalfNmodeAPs(struct rtllib_device* ieee);
2897extern u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate);
2898extern u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate);
2899extern u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate);
2900extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb);
2901extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb);
2902extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb);
60554f2b 2903extern void TsInitAddBA( struct rtllib_device* ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending);
39b2a4ae 2904extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect);
94a79942
LF
2905extern void BaSetupTimeOut(unsigned long data);
2906extern void TxBaInactTimeout(unsigned long data);
2907extern void RxBaInactTimeout(unsigned long data);
8cf33316 2908extern void ResetBaEntry( struct ba_record *pBA);
94a79942
LF
2909extern bool GetTs(
2910 struct rtllib_device* ieee,
74724de1 2911 struct ts_common_info **ppTS,
94a79942
LF
2912 u8* Addr,
2913 u8 TID,
39b2a4ae 2914 enum tr_select TxRxSelect,
94a79942
LF
2915 bool bAddNewTs
2916 );
2917extern void TSInitialize(struct rtllib_device *ieee);
60554f2b 2918extern void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS);
94a79942
LF
2919extern void RemovePeerTS(struct rtllib_device* ieee, u8* Addr);
2920extern void RemoveAllTS(struct rtllib_device* ieee);
2921void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2922
2923extern const long rtllib_wlan_frequencies[];
2924
2925extern inline void rtllib_increment_scans(struct rtllib_device *ieee)
2926{
2927 ieee->scans++;
2928}
2929
2930extern inline int rtllib_get_scans(struct rtllib_device *ieee)
2931{
2932 return ieee->scans;
2933}
2934
2935static inline const char *escape_essid(const char *essid, u8 essid_len) {
2936 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2937 const char *s = essid;
2938 char *d = escaped;
2939
2940 if (rtllib_is_empty_essid(essid, essid_len)) {
2941 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2942 return escaped;
2943 }
2944
2945 essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
2946 while (essid_len--) {
2947 if (*s == '\0') {
2948 *d++ = '\\';
2949 *d++ = '0';
2950 s++;
2951 } else {
2952 *d++ = *s++;
2953 }
2954 }
2955 *d = '\0';
2956 return escaped;
2957}
2958
2959#define CONVERT_RATE(_ieee, _MGN_RATE) (_MGN_RATE<MGN_MCS0)?(_MGN_RATE):(HTMcsToDataRate(_ieee, (u8)_MGN_RATE))
2960
2961/* fun with the built-in rtllib stack... */
2962int rtllib_init(void);
2963void rtllib_exit(void);
2964int rtllib_crypto_init(void);
2965void rtllib_crypto_deinit(void);
2966int rtllib_crypto_tkip_init(void);
2967void rtllib_crypto_tkip_exit(void);
2968int rtllib_crypto_ccmp_init(void);
2969void rtllib_crypto_ccmp_exit(void);
2970int rtllib_crypto_wep_init(void);
2971void rtllib_crypto_wep_exit(void);
2972
2973void rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib);
2974void rtllib_MlmeDisassociateRequest(struct rtllib_device* rtllib, u8* asSta,u8 asRsn);
2975void rtllib_MgntDisconnectAP(struct rtllib_device* rtllib, u8 asRsn);
2976bool rtllib_MgntDisconnect(struct rtllib_device* rtllib,u8 asRsn);
2977
2978
2979/* For the function is more related to hardware setting, it's better to use the
2980 * ieee handler to refer to it.
2981 */
2982extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
2c47ae28 2983extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS);
94a79942
LF
2984extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev);
2985extern int rtllib_parse_info_param(struct rtllib_device *ieee,
2986 struct rtllib_info_element *info_element,
2987 u16 length,
2988 struct rtllib_network *network,
2989 struct rtllib_rx_stats *stats);
2990
2991void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prxbIndicateArray,u8 index);
94a79942
LF
2992extern u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS);
2993extern void HTUseDefaultSetting(struct rtllib_device* ieee);
2994#define RT_ASOC_RETRY_LIMIT 5
2995u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
2996extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
2997#ifndef ENABLE_LOCK_DEBUG
2998#define SPIN_LOCK_IEEE(plock) spin_lock_irqsave((plock), flags)
2999#define SPIN_UNLOCK_IEEE(plock) spin_unlock_irqrestore((plock), flags)
3000#define SPIN_LOCK_IEEE_REORDER(plock) spin_lock_irqsave((plock), flags)
3001#define SPIN_UNLOCK_IEEE_REORDER(plock) spin_unlock_irqrestore((plock), flags)
3002#define SPIN_LOCK_IEEE_WPAX(plock) spin_lock_irqsave((plock), flags)
3003#define SPIN_UNLOCK_IEEE_WPAX(plock) spin_unlock_irqrestore((plock), flags)
3004#define SPIN_LOCK_IEEE_MGNTTX(plock) spin_lock_irqsave((plock), flags)
3005#define SPIN_UNLOCK_IEEE_MGNTTX(plock) spin_unlock_irqrestore((plock), flags)
3006#define SPIN_LOCK_IEEE_BCN(plock) spin_lock_irqsave((plock), flags)
3007#define SPIN_UNLOCK_IEEE_BCN(plock) spin_unlock_irqrestore((plock), flags)
3008#define SPIN_LOCK_MSH_STAINFO(plock) spin_lock_irqsave((plock), flags)
3009#define SPIN_UNLOCK_MSH_STAINFO(plock) spin_unlock_irqrestore((plock), flags)
3010#define SPIN_LOCK_MSH_PREQ(plock) spin_lock_irqsave((plock), flags)
3011#define SPIN_UNLOCK_MSH_PREQ(plock) spin_unlock_irqrestore((plock), flags)
3012#define SPIN_LOCK_MSH_QUEUE(plock) spin_lock_irqsave((plock), flags)
3013#define SPIN_UNLOCK_MSH_QUEUE(plock) spin_unlock_irqrestore((plock), flags)
3014#define SPIN_LOCK_PRIV_RFPS(plock) spin_lock_irqsave((plock), flags)
3015#define SPIN_UNLOCK_PRIV_RFPS(plock) spin_unlock_irqrestore((plock), flags)
3016#define SPIN_LOCK_PRIV_IRQTH(plock) spin_lock_irqsave((plock), flags)
3017#define SPIN_UNLOCK_PRIV_IRQTH(plock) spin_unlock_irqrestore((plock), flags)
3018#define SPIN_LOCK_PRIV_TX(plock) spin_lock_irqsave((plock), flags)
3019#define SPIN_UNLOCK_PRIV_TX(plock) spin_unlock_irqrestore((plock), flags)
3020#define SPIN_LOCK_PRIV_D3(plock) spin_lock_irqsave((plock), flags)
3021#define SPIN_UNLOCK_PRIV_D3(plock) spin_unlock_irqrestore((plock), flags)
3022#define SPIN_LOCK_PRIV_RF(plock) spin_lock_irqsave((plock), flags)
3023#define SPIN_UNLOCK_PRIV_RF(plock) spin_unlock_irqrestore((plock), flags)
3024#define SPIN_LOCK_PRIV_PS(plock) spin_lock_irqsave((plock), flags)
3025#define SPIN_UNLOCK_PRIV_PS(plock) spin_unlock_irqrestore((plock), flags)
3026#define SEM_DOWN_IEEE_WX(psem) down(psem)
3027#define SEM_UP_IEEE_WX(psem) up(psem)
3028#define SEM_DOWN_IEEE_SCAN(psem) down(psem)
3029#define SEM_UP_IEEE_SCAN(psem) up(psem)
3030#define SEM_DOWN_IEEE_IPS(psem) down(psem)
3031#define SEM_UP_IEEE_IPS(psem) up(psem)
3032#define SEM_DOWN_PRIV_WX(psem) down(psem)
3033#define SEM_UP_PRIV_WX(psem) up(psem)
3034#define SEM_DOWN_PRIV_RF(psem) down(psem)
3035#define SEM_UP_PRIV_RF(psem) up(psem)
3036#define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex)
3037#define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex)
3038#endif
3039static inline void dump_buf(u8 *buf, u32 len)
3040{
3041 u32 i;
3042 printk("-----------------Len %d----------------\n", len);
3043 for (i=0; i<len; i++)
3044 printk("%2.2x-", *(buf+i));
3045 printk("\n");
3046}
3047#endif /* RTLLIB_H */