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