staging: rtl8192e: Remove softmac_hint11d_wq queue
[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
559a4c31 17 * <andrea.merello@gmail.com>
94a79942
LF
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 */
94a79942
LF
28#include <linux/module.h>
29#include <linux/interrupt.h>
94a79942 30#include <linux/jiffies.h>
94a79942
LF
31#include <linux/timer.h>
32#include <linux/sched.h>
93916157 33#include <linux/semaphore.h>
94a79942
LF
34
35#include <linux/delay.h>
36#include <linux/wireless.h>
37
ea74fedc 38#include "rtllib_debug.h"
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 */
184f1938 45#include <net/lib80211.h>
94a79942 46
2eed3dee
LF
47#define MAX_PRECMD_CNT 16
48#define MAX_RFDEPENDCMD_CNT 16
49#define MAX_POSTCMD_CNT 16
50
94a79942
LF
51#ifndef WIRELESS_SPY
52#define WIRELESS_SPY
53#endif
54#include <net/iw_handler.h>
55
94a79942
LF
56#ifndef IW_MODE_MONITOR
57#define IW_MODE_MONITOR 6
58#endif
59
60#ifndef IWEVCUSTOM
61#define IWEVCUSTOM 0x8c02
62#endif
63
64#ifndef IW_CUSTOM_MAX
65/* Max number of char in custom event - use multiple of them if needed */
66#define IW_CUSTOM_MAX 256 /* In bytes */
67#endif
68
94a79942 69#define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
94a79942 70
8567829a
LF
71#define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z)
72#define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y)
94a79942 73
8567829a
LF
74#define queue_work_rsl(x, y) queue_work(x, y)
75#define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y)
94a79942 76
8567829a
LF
77#define container_of_work_rsl(x, y, z) container_of(x, y, z)
78#define container_of_dwork_rsl(x, y, z) \
79 container_of(container_of(x, struct delayed_work, work), y, z)
94a79942 80
8567829a
LF
81#define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \
82 iwe_stream_add_event(info, start, stop, iwe, len)
94a79942 83
8567829a
LF
84#define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \
85 iwe_stream_add_point(info, start, stop, iwe, p)
94a79942 86
8567829a
LF
87#define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y)
88#define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y)
94a79942
LF
89
90static inline void *netdev_priv_rsl(struct net_device *dev)
91{
94a79942 92 return netdev_priv(dev);
94a79942
LF
93}
94
95#define KEY_TYPE_NA 0x0
96#define KEY_TYPE_WEP40 0x1
97#define KEY_TYPE_TKIP 0x2
98#define KEY_TYPE_CCMP 0x4
99#define KEY_TYPE_WEP104 0x5
100/* added for rtl819x tx procedure */
101#define MAX_QUEUE_SIZE 0x10
102
8567829a
LF
103#define BK_QUEUE 0
104#define BE_QUEUE 1
105#define VI_QUEUE 2
106#define VO_QUEUE 3
107#define HCCA_QUEUE 4
108#define TXCMD_QUEUE 5
109#define MGNT_QUEUE 6
110#define HIGH_QUEUE 7
111#define BEACON_QUEUE 8
94a79942 112
8567829a
LF
113#define LOW_QUEUE BE_QUEUE
114#define NORMAL_QUEUE MGNT_QUEUE
94a79942
LF
115
116#ifndef IW_MODE_MESH
117#define IW_MODE_MESH 7
118#endif
119#define AMSDU_SUBHEADER_LEN 14
120#define SWRF_TIMEOUT 50
121
122#define IE_CISCO_FLAG_POSITION 0x08
123#define SUPPORT_CKIP_MIC 0x08
124#define SUPPORT_CKIP_PK 0x10
125#define RT_RF_OFF_LEVL_ASPM BIT0
126#define RT_RF_OFF_LEVL_CLK_REQ BIT1
127#define RT_RF_OFF_LEVL_PCI_D3 BIT2
128#define RT_RF_OFF_LEVL_HALT_NIC BIT3
129#define RT_RF_OFF_LEVL_FREE_FW BIT4
130#define RT_RF_OFF_LEVL_FW_32K BIT5
131#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6
132#define RT_RF_LPS_DISALBE_2R BIT30
133#define RT_RF_LPS_LEVEL_ASPM BIT31
8567829a
LF
134#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \
135 ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
136#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \
137 (pPSC->CurPsLevel &= (~(_PS_FLAG)))
94a79942
LF
138#define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
139
140/* defined for skb cb field */
141/* At most 28 byte */
3b83db43 142struct cb_desc {
94a79942
LF
143 /* Tx Desc Related flags (8-9) */
144 u8 bLastIniPkt:1;
145 u8 bCmdOrInit:1;
146 u8 bFirstSeg:1;
147 u8 bLastSeg:1;
148 u8 bEncrypt:1;
149 u8 bTxDisableRateFallBack:1;
150 u8 bTxUseDriverAssingedRate:1;
151 u8 bHwSec:1;
152
153 u8 nStuckCount;
154
cd017123 155 /* Tx Firmware Related flags (10-11)*/
94a79942
LF
156 u8 bCTSEnable:1;
157 u8 bRTSEnable:1;
158 u8 bUseShortGI:1;
159 u8 bUseShortPreamble:1;
160 u8 bTxEnableFwCalcDur:1;
161 u8 bAMPDUEnable:1;
162 u8 bRTSSTBC:1;
163 u8 RTSSC:1;
164
165 u8 bRTSBW:1;
166 u8 bPacketBW:1;
167 u8 bRTSUseShortPreamble:1;
168 u8 bRTSUseShortGI:1;
169 u8 bMulticast:1;
170 u8 bBroadcast:1;
171 u8 drv_agg_enable:1;
172 u8 reserved2:1;
173
174 /* Tx Desc related element(12-19) */
175 u8 rata_index;
176 u8 queue_index;
177 u16 txbuf_size;
178 u8 RATRIndex;
179 u8 bAMSDU:1;
180 u8 bFromAggrQ:1;
181 u8 reserved6:6;
182 u8 macId;
183 u8 priority;
184
185 /* Tx firmware related element(20-27) */
186 u8 data_rate;
187 u8 rts_rate;
188 u8 ampdu_factor;
189 u8 ampdu_density;
190 u8 DrvAggrNum;
191 u8 bdhcp;
192 u16 pkt_size;
193 u8 bIsSpecialDataFrame;
194
195 u8 bBTTxPacket;
196 u8 bIsBTProbRsp;
d3b2c172 197};
94a79942 198
2eed3dee
LF
199enum sw_chnl_cmd_id {
200 CmdID_End,
201 CmdID_SetTxPowerLevel,
202 CmdID_BBRegWrite10,
203 CmdID_WritePortUlong,
204 CmdID_WritePortUshort,
205 CmdID_WritePortUchar,
206 CmdID_RF_WriteReg,
207};
208
209struct sw_chnl_cmd {
210 enum sw_chnl_cmd_id CmdID;
211 u32 Para1;
212 u32 Para2;
213 u32 msDelay;
214} __packed;
215
94a79942 216/*--------------------------Define -------------------------------------------*/
8567829a
LF
217#define MGN_1M 0x02
218#define MGN_2M 0x04
219#define MGN_5_5M 0x0b
220#define MGN_11M 0x16
221
222#define MGN_6M 0x0c
223#define MGN_9M 0x12
224#define MGN_12M 0x18
225#define MGN_18M 0x24
226#define MGN_24M 0x30
227#define MGN_36M 0x48
228#define MGN_48M 0x60
229#define MGN_54M 0x6c
230
231#define MGN_MCS0 0x80
232#define MGN_MCS1 0x81
233#define MGN_MCS2 0x82
234#define MGN_MCS3 0x83
235#define MGN_MCS4 0x84
236#define MGN_MCS5 0x85
237#define MGN_MCS6 0x86
238#define MGN_MCS7 0x87
239#define MGN_MCS8 0x88
240#define MGN_MCS9 0x89
241#define MGN_MCS10 0x8a
242#define MGN_MCS11 0x8b
243#define MGN_MCS12 0x8c
244#define MGN_MCS13 0x8d
245#define MGN_MCS14 0x8e
246#define MGN_MCS15 0x8f
94a79942
LF
247#define MGN_MCS0_SG 0x90
248#define MGN_MCS1_SG 0x91
249#define MGN_MCS2_SG 0x92
250#define MGN_MCS3_SG 0x93
251#define MGN_MCS4_SG 0x94
252#define MGN_MCS5_SG 0x95
253#define MGN_MCS6_SG 0x96
254#define MGN_MCS7_SG 0x97
255#define MGN_MCS8_SG 0x98
256#define MGN_MCS9_SG 0x99
257#define MGN_MCS10_SG 0x9a
258#define MGN_MCS11_SG 0x9b
259#define MGN_MCS12_SG 0x9c
260#define MGN_MCS13_SG 0x9d
261#define MGN_MCS14_SG 0x9e
262#define MGN_MCS15_SG 0x9f
263
bb5e4822 264enum hw_variables {
94a79942
LF
265 HW_VAR_ETHER_ADDR,
266 HW_VAR_MULTICAST_REG,
267 HW_VAR_BASIC_RATE,
268 HW_VAR_BSSID,
269 HW_VAR_MEDIA_STATUS,
270 HW_VAR_SECURITY_CONF,
271 HW_VAR_BEACON_INTERVAL,
272 HW_VAR_ATIM_WINDOW,
273 HW_VAR_LISTEN_INTERVAL,
274 HW_VAR_CS_COUNTER,
275 HW_VAR_DEFAULTKEY0,
276 HW_VAR_DEFAULTKEY1,
277 HW_VAR_DEFAULTKEY2,
278 HW_VAR_DEFAULTKEY3,
279 HW_VAR_SIFS,
280 HW_VAR_DIFS,
281 HW_VAR_EIFS,
282 HW_VAR_SLOT_TIME,
283 HW_VAR_ACK_PREAMBLE,
284 HW_VAR_CW_CONFIG,
285 HW_VAR_CW_VALUES,
286 HW_VAR_RATE_FALLBACK_CONTROL,
287 HW_VAR_CONTENTION_WINDOW,
288 HW_VAR_RETRY_COUNT,
289 HW_VAR_TR_SWITCH,
290 HW_VAR_COMMAND,
291 HW_VAR_WPA_CONFIG,
292 HW_VAR_AMPDU_MIN_SPACE,
293 HW_VAR_SHORTGI_DENSITY,
294 HW_VAR_AMPDU_FACTOR,
295 HW_VAR_MCS_RATE_AVAILABLE,
296 HW_VAR_AC_PARAM,
297 HW_VAR_ACM_CTRL,
298 HW_VAR_DIS_Req_Qsize,
299 HW_VAR_CCX_CHNL_LOAD,
300 HW_VAR_CCX_NOISE_HISTOGRAM,
301 HW_VAR_CCX_CLM_NHM,
302 HW_VAR_TxOPLimit,
303 HW_VAR_TURBO_MODE,
304 HW_VAR_RF_STATE,
305 HW_VAR_RF_OFF_BY_HW,
306 HW_VAR_BUS_SPEED,
8567829a 307 HW_VAR_SET_DEV_POWER,
94a79942
LF
308
309 HW_VAR_RCR,
310 HW_VAR_RATR_0,
311 HW_VAR_RRSR,
312 HW_VAR_CPU_RST,
313 HW_VAR_CECHK_BSSID,
8567829a 314 HW_VAR_LBK_MODE,
94a79942
LF
315 HW_VAR_AES_11N_FIX,
316 HW_VAR_USB_RX_AGGR,
317 HW_VAR_USER_CONTROL_TURBO_MODE,
318 HW_VAR_RETRY_LIMIT,
319 HW_VAR_INIT_TX_RATE,
320 HW_VAR_TX_RATE_REG,
321 HW_VAR_EFUSE_USAGE,
322 HW_VAR_EFUSE_BYTES,
323 HW_VAR_AUTOLOAD_STATUS,
324 HW_VAR_RF_2R_DISABLE,
325 HW_VAR_SET_RPWM,
326 HW_VAR_H2C_FW_PWRMODE,
327 HW_VAR_H2C_FW_JOINBSSRPT,
328 HW_VAR_1X1_RECV_COMBINE,
329 HW_VAR_STOP_SEND_BEACON,
330 HW_VAR_TSF_TIMER,
331 HW_VAR_IO_CMD,
332
333 HW_VAR_RF_RECOVERY,
334 HW_VAR_H2C_FW_UPDATE_GTK,
335 HW_VAR_WF_MASK,
336 HW_VAR_WF_CRC,
337 HW_VAR_WF_IS_MAC_ADDR,
338 HW_VAR_H2C_FW_OFFLOAD,
339 HW_VAR_RESET_WFCRC,
340
341 HW_VAR_HANDLE_FW_C2H,
342 HW_VAR_DL_FW_RSVD_PAGE,
343 HW_VAR_AID,
344 HW_VAR_HW_SEQ_ENABLE,
345 HW_VAR_CORRECT_TSF,
346 HW_VAR_BCN_VALID,
347 HW_VAR_FWLPS_RF_ON,
348 HW_VAR_DUAL_TSF_RST,
349 HW_VAR_SWITCH_EPHY_WoWLAN,
350 HW_VAR_INT_MIGRATION,
351 HW_VAR_INT_AC,
8567829a 352 HW_VAR_RF_TIMING,
bb5e4822 353};
94a79942 354
e93e0f6a 355enum rt_op_mode {
94a79942
LF
356 RT_OP_MODE_AP,
357 RT_OP_MODE_INFRASTRUCTURE,
358 RT_OP_MODE_IBSS,
359 RT_OP_MODE_NO_LINK,
e93e0f6a 360};
94a79942
LF
361
362
8567829a
LF
363#define aSifsTime \
364 (((priv->rtllib->current_network.mode == IEEE_A) \
365 || (priv->rtllib->current_network.mode == IEEE_N_24G) \
366 || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10)
94a79942
LF
367
368#define MGMT_QUEUE_NUM 5
369
370#define IEEE_CMD_SET_WPA_PARAM 1
371#define IEEE_CMD_SET_WPA_IE 2
372#define IEEE_CMD_SET_ENCRYPTION 3
373#define IEEE_CMD_MLME 4
374
375#define IEEE_PARAM_WPA_ENABLED 1
376#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
377#define IEEE_PARAM_DROP_UNENCRYPTED 3
378#define IEEE_PARAM_PRIVACY_INVOKED 4
379#define IEEE_PARAM_AUTH_ALGS 5
380#define IEEE_PARAM_IEEE_802_1X 6
381#define IEEE_PARAM_WPAX_SELECT 7
94a79942
LF
382
383#define IEEE_MLME_STA_DEAUTH 1
384#define IEEE_MLME_STA_DISASSOC 2
385
386
387#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
94a79942
LF
388#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
389#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
94a79942
LF
390#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
391#define IEEE_CRYPT_ALG_NAME_LEN 16
392
393#define MAX_IE_LEN 0xff
94a79942 394
65dab9a0 395struct ieee_param {
94a79942
LF
396 u32 cmd;
397 u8 sta_addr[ETH_ALEN];
8567829a 398 union {
94a79942
LF
399 struct {
400 u8 name;
401 u32 value;
402 } wpa_param;
403 struct {
404 u32 len;
405 u8 reserved[32];
406 u8 data[0];
407 } wpa_ie;
8567829a 408 struct {
94a79942
LF
409 int command;
410 int reason_code;
411 } mlme;
412 struct {
413 u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
414 u8 set_tx;
415 u32 err;
416 u8 idx;
417 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
418 u16 key_len;
419 u8 key[0];
420 } crypt;
421 } u;
d3b2c172 422};
94a79942 423
94a79942 424#define msleep_interruptible_rsl msleep_interruptible
94a79942 425
94a79942 426/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
14b40d92
MK
427 * 6.2.1.1.2.
428 *
429 * The figure in section 7.1.2 suggests a body size of up to 2312
430 * bytes is allowed, which is a bit confusing, I suspect this
431 * represents the 2304 bytes of real data, plus a possible 8 bytes of
432 * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
433 */
94a79942
LF
434#define RTLLIB_1ADDR_LEN 10
435#define RTLLIB_2ADDR_LEN 16
436#define RTLLIB_3ADDR_LEN 24
437#define RTLLIB_4ADDR_LEN 30
438#define RTLLIB_FCS_LEN 4
94a79942
LF
439
440#define RTLLIB_SKBBUFFER_SIZE 2500
441
442#define MIN_FRAG_THRESHOLD 256U
443#define MAX_FRAG_THRESHOLD 2346U
94a79942
LF
444
445/* Frame control field constants */
94a79942
LF
446#define RTLLIB_FCTL_FTYPE 0x000c
447#define RTLLIB_FCTL_STYPE 0x00f0
448#define RTLLIB_FCTL_FRAMETYPE 0x00fc
449#define RTLLIB_FCTL_TODS 0x0100
450#define RTLLIB_FCTL_FROMDS 0x0200
451#define RTLLIB_FCTL_DSTODS 0x0300
452#define RTLLIB_FCTL_MOREFRAGS 0x0400
453#define RTLLIB_FCTL_RETRY 0x0800
454#define RTLLIB_FCTL_PM 0x1000
455#define RTLLIB_FCTL_MOREDATA 0x2000
456#define RTLLIB_FCTL_WEP 0x4000
457#define RTLLIB_FCTL_ORDER 0x8000
458
459#define RTLLIB_FTYPE_MGMT 0x0000
460#define RTLLIB_FTYPE_CTL 0x0004
461#define RTLLIB_FTYPE_DATA 0x0008
462
463/* management */
464#define RTLLIB_STYPE_ASSOC_REQ 0x0000
465#define RTLLIB_STYPE_ASSOC_RESP 0x0010
466#define RTLLIB_STYPE_REASSOC_REQ 0x0020
467#define RTLLIB_STYPE_REASSOC_RESP 0x0030
468#define RTLLIB_STYPE_PROBE_REQ 0x0040
469#define RTLLIB_STYPE_PROBE_RESP 0x0050
470#define RTLLIB_STYPE_BEACON 0x0080
471#define RTLLIB_STYPE_ATIM 0x0090
472#define RTLLIB_STYPE_DISASSOC 0x00A0
473#define RTLLIB_STYPE_AUTH 0x00B0
474#define RTLLIB_STYPE_DEAUTH 0x00C0
475#define RTLLIB_STYPE_MANAGE_ACT 0x00D0
476
477/* control */
478#define RTLLIB_STYPE_PSPOLL 0x00A0
479#define RTLLIB_STYPE_RTS 0x00B0
480#define RTLLIB_STYPE_CTS 0x00C0
481#define RTLLIB_STYPE_ACK 0x00D0
94a79942
LF
482
483/* data */
484#define RTLLIB_STYPE_DATA 0x0000
485#define RTLLIB_STYPE_DATA_CFACK 0x0010
486#define RTLLIB_STYPE_DATA_CFPOLL 0x0020
487#define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
488#define RTLLIB_STYPE_NULLFUNC 0x0040
94a79942
LF
489#define RTLLIB_STYPE_QOS_DATA 0x0080
490#define RTLLIB_STYPE_QOS_NULL 0x00C0
491
492#define RTLLIB_SCTL_FRAG 0x000F
493#define RTLLIB_SCTL_SEQ 0xFFF0
494
495/* QOS control */
8567829a 496#define RTLLIB_QCTL_TID 0x000F
94a79942
LF
497
498#define FC_QOS_BIT BIT7
8567829a
LF
499#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
500#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
501#define IsQoSDataFrame(pframe) \
502 ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \
503 (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
504#define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER)
505#define SN_LESS(a, b) (((a-b)&0x800) != 0)
94a79942
LF
506#define SN_EQUAL(a, b) (a == b)
507#define MAX_DEV_ADDR_SIZE 8
508
09ced23d 509enum act_category {
8567829a
LF
510 ACT_CAT_QOS = 1,
511 ACT_CAT_DLS = 2,
512 ACT_CAT_BA = 3,
513 ACT_CAT_HT = 7,
514 ACT_CAT_WMM = 17,
09ced23d 515};
94a79942 516
07276bac 517enum ba_action {
8567829a
LF
518 ACT_ADDBAREQ = 0,
519 ACT_ADDBARSP = 1,
520 ACT_DELBA = 2,
07276bac 521};
94a79942 522
062de0a9 523enum init_gain_op_type {
8567829a 524 IG_Backup = 0,
94a79942
LF
525 IG_Restore,
526 IG_Max
062de0a9 527};
d3b2c172 528
4fd7cedc 529enum led_ctl_mode {
8567829a
LF
530 LED_CTL_POWER_ON = 1,
531 LED_CTL_LINK = 2,
532 LED_CTL_NO_LINK = 3,
533 LED_CTL_TX = 4,
534 LED_CTL_RX = 5,
535 LED_CTL_SITE_SURVEY = 6,
536 LED_CTL_POWER_OFF = 7,
537 LED_CTL_START_TO_LINK = 8,
4fd7cedc 538};
94a79942 539
e6080633 540enum rt_rf_type_def {
94a79942
LF
541 RF_1T2R = 0,
542 RF_2T4R,
e6080633 543};
94a79942 544
dc20a326 545enum wireless_mode {
94a79942
LF
546 WIRELESS_MODE_UNKNOWN = 0x00,
547 WIRELESS_MODE_A = 0x01,
548 WIRELESS_MODE_B = 0x02,
549 WIRELESS_MODE_G = 0x04,
550 WIRELESS_MODE_AUTO = 0x08,
551 WIRELESS_MODE_N_24G = 0x10,
552 WIRELESS_MODE_N_5G = 0x20
dc20a326 553};
94a79942 554
94a79942
LF
555#ifndef ETH_P_PAE
556#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
557#define ETH_P_IP 0x0800 /* Internet Protocol packet */
558#define ETH_P_ARP 0x0806 /* Address Resolution packet */
559#endif /* ETH_P_PAE */
560
94a79942
LF
561#ifndef ETH_P_80211_RAW
562#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
563#endif
564
565/* IEEE 802.11 defines */
566
567#define P80211_OUI_LEN 3
568
569struct rtllib_snap_hdr {
570
8567829a
LF
571 u8 dsap; /* always 0xAA */
572 u8 ssap; /* always 0xAA */
573 u8 ctrl; /* always 0x03 */
574 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
94a79942 575
8567829a 576} __packed;
94a79942 577
8567829a 578enum _REG_PREAMBLE_MODE {
94a79942
LF
579 PREAMBLE_LONG = 1,
580 PREAMBLE_AUTO = 2,
8567829a 581 PREAMBLE_SHORT = 3,
94a79942
LF
582};
583
584#define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
585
94a79942
LF
586#define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
587#define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
588#define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
589
590#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
591#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
592#define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
593
94a79942
LF
594/* Authentication algorithms */
595#define WLAN_AUTH_OPEN 0
596#define WLAN_AUTH_SHARED_KEY 1
597#define WLAN_AUTH_LEAP 128
598
94a79942
LF
599#define WLAN_CAPABILITY_ESS (1<<0)
600#define WLAN_CAPABILITY_IBSS (1<<1)
94a79942
LF
601#define WLAN_CAPABILITY_PRIVACY (1<<4)
602#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
94a79942 603#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
94a79942 604
94a79942
LF
605#define RTLLIB_STATMASK_SIGNAL (1<<0)
606#define RTLLIB_STATMASK_RSSI (1<<1)
607#define RTLLIB_STATMASK_NOISE (1<<2)
94a79942
LF
608#define RTLLIB_STATMASK_WEMASK 0x7
609
610#define RTLLIB_CCK_MODULATION (1<<0)
611#define RTLLIB_OFDM_MODULATION (1<<1)
612
613#define RTLLIB_24GHZ_BAND (1<<0)
614#define RTLLIB_52GHZ_BAND (1<<1)
615
616#define RTLLIB_CCK_RATE_LEN 4
8567829a
LF
617#define RTLLIB_CCK_RATE_1MB 0x02
618#define RTLLIB_CCK_RATE_2MB 0x04
619#define RTLLIB_CCK_RATE_5MB 0x0B
620#define RTLLIB_CCK_RATE_11MB 0x16
94a79942 621#define RTLLIB_OFDM_RATE_LEN 8
8567829a
LF
622#define RTLLIB_OFDM_RATE_6MB 0x0C
623#define RTLLIB_OFDM_RATE_9MB 0x12
94a79942
LF
624#define RTLLIB_OFDM_RATE_12MB 0x18
625#define RTLLIB_OFDM_RATE_18MB 0x24
626#define RTLLIB_OFDM_RATE_24MB 0x30
627#define RTLLIB_OFDM_RATE_36MB 0x48
628#define RTLLIB_OFDM_RATE_48MB 0x60
629#define RTLLIB_OFDM_RATE_54MB 0x6C
630#define RTLLIB_BASIC_RATE_MASK 0x80
631
94a79942
LF
632/* this is stolen and modified from the madwifi driver*/
633#define RTLLIB_FC0_TYPE_MASK 0x0c
634#define RTLLIB_FC0_TYPE_DATA 0x08
635#define RTLLIB_FC0_SUBTYPE_MASK 0xB0
636#define RTLLIB_FC0_SUBTYPE_QOS 0x80
637
638#define RTLLIB_QOS_HAS_SEQ(fc) \
639 (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
640 (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
641
642/* this is stolen from ipw2200 driver */
643#define IEEE_IBSS_MAC_HASH_SIZE 31
644struct ieee_ibss_seq {
645 u8 mac[ETH_ALEN];
646 u16 seq_num[17];
647 u16 frag_num[17];
648 unsigned long packet_time[17];
649 struct list_head list;
650};
651
652/* NOTE: This data is for statistical purposes; not all hardware provides this
653 * information for frames received. Not setting these will not cause
654 * any adverse affects. */
655struct rtllib_rx_stats {
0dd56506 656 u64 mac_time;
94a79942
LF
657 s8 rssi;
658 u8 signal;
659 u8 noise;
660 u16 rate; /* in 100 kbps */
661 u8 received_channel;
662 u8 control;
663 u8 mask;
664 u8 freq;
665 u16 len;
666 u64 tsf;
667 u32 beacon_time;
668 u8 nic_type;
669 u16 Length;
670 u8 SignalQuality;
671 s32 RecvSignalPower;
672 s8 RxPower;
673 u8 SignalStrength;
674 u16 bHwError:1;
675 u16 bCRC:1;
676 u16 bICV:1;
677 u16 bShortPreamble:1;
678 u16 Antenna:1;
679 u16 Decrypted:1;
680 u16 Wakeup:1;
681 u16 Reserved0:1;
682 u8 AGC;
683 u32 TimeStampLow;
684 u32 TimeStampHigh;
685 bool bShift;
686 bool bIsQosData;
94a79942
LF
687
688 u8 RxDrvInfoSize;
689 u8 RxBufShift;
690 bool bIsAMPDU;
691 bool bFirstMPDU;
692 bool bContainHTC;
693 bool RxIs40MHzPacket;
694 u32 RxPWDBAll;
695 u8 RxMIMOSignalStrength[4];
696 s8 RxMIMOSignalQuality[2];
697 bool bPacketMatchBSSID;
698 bool bIsCCK;
699 bool bPacketToSelf;
94a79942
LF
700 u16 packetlength;
701 u16 fraglength;
702 u16 fragoffset;
703 u16 ntotalfrag;
94a79942
LF
704 bool bPacketBeacon;
705 bool bToSelfBA;
94a79942 706 u16 Seq_Num;
94a79942
LF
707};
708
709/* IEEE 802.11 requires that STA supports concurrent reception of at least
710 * three fragmented frames. This define can be increased to support more
711 * concurrent frames, but it should be noted that each entry can consume about
14b40d92
MK
712 * 2 kB of RAM and increasing cache size will slow down frame reassembly.
713 */
94a79942
LF
714#define RTLLIB_FRAG_CACHE_LEN 4
715
716struct rtllib_frag_entry {
717 unsigned long first_frag_time;
718 unsigned int seq;
719 unsigned int last_frag;
720 struct sk_buff *skb;
721 u8 src_addr[ETH_ALEN];
722 u8 dst_addr[ETH_ALEN];
723};
724
725struct rtllib_stats {
726 unsigned int tx_unicast_frames;
727 unsigned int tx_multicast_frames;
728 unsigned int tx_fragments;
729 unsigned int tx_unicast_octets;
730 unsigned int tx_multicast_octets;
731 unsigned int tx_deferred_transmissions;
732 unsigned int tx_single_retry_frames;
733 unsigned int tx_multiple_retry_frames;
734 unsigned int tx_retry_limit_exceeded;
735 unsigned int tx_discards;
736 unsigned int rx_unicast_frames;
737 unsigned int rx_multicast_frames;
738 unsigned int rx_fragments;
739 unsigned int rx_unicast_octets;
740 unsigned int rx_multicast_octets;
741 unsigned int rx_fcs_errors;
742 unsigned int rx_discards_no_buffer;
743 unsigned int tx_discards_wrong_sa;
744 unsigned int rx_discards_undecryptable;
745 unsigned int rx_message_in_msg_fragments;
746 unsigned int rx_message_in_bad_msg_fragments;
747};
748
749struct rtllib_device;
750
8567829a
LF
751#define SEC_KEY_1 (1<<0)
752#define SEC_KEY_2 (1<<1)
753#define SEC_KEY_3 (1<<2)
754#define SEC_KEY_4 (1<<3)
94a79942
LF
755#define SEC_ACTIVE_KEY (1<<4)
756#define SEC_AUTH_MODE (1<<5)
757#define SEC_UNICAST_GROUP (1<<6)
8567829a 758#define SEC_LEVEL (1<<7)
94a79942
LF
759#define SEC_ENABLED (1<<8)
760#define SEC_ENCRYPT (1<<9)
761
762#define SEC_LEVEL_0 0 /* None */
763#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
764#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
765#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
766#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
767
8567829a
LF
768#define SEC_ALG_NONE 0
769#define SEC_ALG_WEP 1
770#define SEC_ALG_TKIP 2
771#define SEC_ALG_CCMP 4
94a79942 772
94a79942 773#define WEP_KEY_LEN 13
8567829a 774#define SCM_KEY_LEN 32
94a79942
LF
775#define SCM_TEMPORAL_KEY_LENGTH 16
776
777struct rtllib_security {
778 u16 active_key:2,
8567829a 779 enabled:1,
94a79942 780 auth_mode:2,
8567829a
LF
781 auth_algo:4,
782 unicast_uses_group:1,
94a79942 783 encrypt:1;
184f1938
SM
784 u8 key_sizes[NUM_WEP_KEYS];
785 u8 keys[NUM_WEP_KEYS][SCM_KEY_LEN];
94a79942
LF
786 u8 level;
787 u16 flags;
8567829a 788} __packed;
94a79942
LF
789
790
14b40d92
MK
791/* 802.11 data frame from AP
792 * ,-------------------------------------------------------------------.
793 * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
794 * |------|------|---------|---------|---------|------|---------|------|
795 * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
796 * | | tion | (BSSID) | | | ence | data | |
797 * `-------------------------------------------------------------------'
798 * Total: 28-2340 bytes
799 */
94a79942
LF
800
801/* Management Frame Information Element Types */
802enum rtllib_mfie {
8567829a
LF
803 MFIE_TYPE_SSID = 0,
804 MFIE_TYPE_RATES = 1,
805 MFIE_TYPE_FH_SET = 2,
806 MFIE_TYPE_DS_SET = 3,
807 MFIE_TYPE_CF_SET = 4,
808 MFIE_TYPE_TIM = 5,
809 MFIE_TYPE_IBSS_SET = 6,
810 MFIE_TYPE_COUNTRY = 7,
811 MFIE_TYPE_HOP_PARAMS = 8,
812 MFIE_TYPE_HOP_TABLE = 9,
813 MFIE_TYPE_REQUEST = 10,
814 MFIE_TYPE_CHALLENGE = 16,
815 MFIE_TYPE_POWER_CONSTRAINT = 32,
816 MFIE_TYPE_POWER_CAPABILITY = 33,
817 MFIE_TYPE_TPC_REQUEST = 34,
818 MFIE_TYPE_TPC_REPORT = 35,
819 MFIE_TYPE_SUPP_CHANNELS = 36,
820 MFIE_TYPE_CSA = 37,
821 MFIE_TYPE_MEASURE_REQUEST = 38,
822 MFIE_TYPE_MEASURE_REPORT = 39,
823 MFIE_TYPE_QUIET = 40,
824 MFIE_TYPE_IBSS_DFS = 41,
825 MFIE_TYPE_ERP = 42,
826 MFIE_TYPE_HT_CAP = 45,
94a79942
LF
827 MFIE_TYPE_RSN = 48,
828 MFIE_TYPE_RATES_EX = 50,
8567829a
LF
829 MFIE_TYPE_HT_INFO = 61,
830 MFIE_TYPE_AIRONET = 133,
94a79942 831 MFIE_TYPE_GENERIC = 221,
8567829a 832 MFIE_TYPE_QOS_PARAMETER = 222,
94a79942
LF
833};
834
835/* Minimal header; can be used for passing 802.11 frames with sufficient
836 * information to determine what type of underlying data type is actually
14b40d92
MK
837 * stored in the data.
838 */
94a79942 839struct rtllib_pspoll_hdr {
8567829a
LF
840 __le16 frame_ctl;
841 __le16 aid;
94a79942 842 u8 bssid[ETH_ALEN];
8567829a
LF
843 u8 ta[ETH_ALEN];
844} __packed;
94a79942
LF
845
846struct rtllib_hdr {
8567829a
LF
847 __le16 frame_ctl;
848 __le16 duration_id;
849 u8 payload[0];
850} __packed;
94a79942
LF
851
852struct rtllib_hdr_1addr {
8567829a
LF
853 __le16 frame_ctl;
854 __le16 duration_id;
855 u8 addr1[ETH_ALEN];
856 u8 payload[0];
857} __packed;
94a79942
LF
858
859struct rtllib_hdr_2addr {
8567829a
LF
860 __le16 frame_ctl;
861 __le16 duration_id;
862 u8 addr1[ETH_ALEN];
863 u8 addr2[ETH_ALEN];
864 u8 payload[0];
865} __packed;
94a79942
LF
866
867struct rtllib_hdr_3addr {
868 __le16 frame_ctl;
869 __le16 duration_id;
870 u8 addr1[ETH_ALEN];
871 u8 addr2[ETH_ALEN];
872 u8 addr3[ETH_ALEN];
873 __le16 seq_ctl;
8567829a
LF
874 u8 payload[0];
875} __packed;
94a79942
LF
876
877struct rtllib_hdr_4addr {
878 __le16 frame_ctl;
879 __le16 duration_id;
880 u8 addr1[ETH_ALEN];
881 u8 addr2[ETH_ALEN];
882 u8 addr3[ETH_ALEN];
883 __le16 seq_ctl;
884 u8 addr4[ETH_ALEN];
8567829a
LF
885 u8 payload[0];
886} __packed;
94a79942
LF
887
888struct rtllib_hdr_3addrqos {
889 __le16 frame_ctl;
890 __le16 duration_id;
891 u8 addr1[ETH_ALEN];
892 u8 addr2[ETH_ALEN];
893 u8 addr3[ETH_ALEN];
894 __le16 seq_ctl;
895 __le16 qos_ctl;
896 u8 payload[0];
8567829a 897} __packed;
94a79942
LF
898
899struct rtllib_hdr_4addrqos {
900 __le16 frame_ctl;
901 __le16 duration_id;
902 u8 addr1[ETH_ALEN];
903 u8 addr2[ETH_ALEN];
904 u8 addr3[ETH_ALEN];
905 __le16 seq_ctl;
906 u8 addr4[ETH_ALEN];
907 __le16 qos_ctl;
908 u8 payload[0];
8567829a 909} __packed;
94a79942
LF
910
911struct rtllib_info_element {
912 u8 id;
913 u8 len;
914 u8 data[0];
8567829a 915} __packed;
94a79942
LF
916
917struct rtllib_authentication {
918 struct rtllib_hdr_3addr header;
919 __le16 algorithm;
920 __le16 transaction;
921 __le16 status;
922 /*challenge*/
923 struct rtllib_info_element info_element[0];
8567829a 924} __packed;
94a79942
LF
925
926struct rtllib_disauth {
8567829a
LF
927 struct rtllib_hdr_3addr header;
928 __le16 reason;
929} __packed;
94a79942
LF
930
931struct rtllib_disassoc {
8567829a
LF
932 struct rtllib_hdr_3addr header;
933 __le16 reason;
934} __packed;
94a79942
LF
935
936struct rtllib_probe_request {
937 struct rtllib_hdr_3addr header;
938 /* SSID, supported rates */
8567829a
LF
939 struct rtllib_info_element info_element[0];
940} __packed;
94a79942
LF
941
942struct rtllib_probe_response {
943 struct rtllib_hdr_3addr header;
944 u32 time_stamp[2];
945 __le16 beacon_interval;
946 __le16 capability;
8567829a 947 /* SSID, supported rates, FH params, DS params,
14b40d92
MK
948 * CF params, IBSS params, TIM (if beacon), RSN
949 */
8567829a
LF
950 struct rtllib_info_element info_element[0];
951} __packed;
94a79942
LF
952
953/* Alias beacon for probe_response */
954#define rtllib_beacon rtllib_probe_response
955
956struct rtllib_assoc_request_frame {
957 struct rtllib_hdr_3addr header;
958 __le16 capability;
959 __le16 listen_interval;
960 /* SSID, supported rates, RSN */
8567829a
LF
961 struct rtllib_info_element info_element[0];
962} __packed;
94a79942 963
94a79942
LF
964struct rtllib_assoc_response_frame {
965 struct rtllib_hdr_3addr header;
966 __le16 capability;
967 __le16 status;
968 __le16 aid;
969 struct rtllib_info_element info_element[0]; /* supported rates */
8567829a 970} __packed;
94a79942
LF
971
972struct rtllib_txb {
973 u8 nr_frags;
974 u8 encrypted;
975 u8 queue_index;
976 u8 rts_included;
977 u16 reserved;
978 __le16 frag_size;
979 __le16 payload_size;
980 struct sk_buff *fragments[0];
981};
982
94a79942
LF
983#define MAX_SUBFRAME_COUNT 64
984struct rtllib_rxb {
985 u8 nr_subframes;
986 struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
987 u8 dst[ETH_ALEN];
988 u8 src[ETH_ALEN];
8567829a 989} __packed;
94a79942 990
66ba443a 991union frameqos {
94a79942
LF
992 u16 shortdata;
993 u8 chardata[2];
994 struct {
995 u16 tid:4;
996 u16 eosp:1;
997 u16 ack_policy:2;
998 u16 reserved:1;
999 u16 txop:8;
8567829a 1000 } field;
66ba443a 1001};
94a79942 1002
94a79942
LF
1003/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
1004 * only use 8, and then use extended rates for the remaining supported
1005 * rates. Other APs, however, stick all of their supported rates on the
14b40d92
MK
1006 * main rates information element...
1007 */
8567829a
LF
1008#define MAX_RATES_LENGTH ((u8)12)
1009#define MAX_RATES_EX_LENGTH ((u8)16)
1010#define MAX_NETWORK_COUNT 96
94a79942 1011
8567829a 1012#define MAX_CHANNEL_NUMBER 161
94a79942
LF
1013#define RTLLIB_SOFTMAC_SCAN_TIME 100
1014#define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1015
94a79942
LF
1016#define MAX_WPA_IE_LEN 64
1017#define MAX_WZC_IE_LEN 256
1018
1019#define NETWORK_EMPTY_ESSID (1<<0)
1020#define NETWORK_HAS_OFDM (1<<1)
1021#define NETWORK_HAS_CCK (1<<2)
1022
1023/* QoS structure */
1024#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1025#define NETWORK_HAS_QOS_INFORMATION (1<<4)
8567829a
LF
1026#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1027 NETWORK_HAS_QOS_INFORMATION)
94a79942 1028/* 802.11h */
8567829a
LF
1029#define NETWORK_HAS_ERP_VALUE (1<<10)
1030
1031#define QOS_QUEUE_NUM 4
1032#define QOS_OUI_LEN 3
1033#define QOS_OUI_TYPE 2
1034#define QOS_ELEMENT_ID 221
1035#define QOS_OUI_INFO_SUB_TYPE 0
1036#define QOS_OUI_PARAM_SUB_TYPE 1
1037#define QOS_VERSION_1 1
8567829a 1038
94a79942 1039struct rtllib_qos_information_element {
8567829a
LF
1040 u8 elementID;
1041 u8 length;
1042 u8 qui[QOS_OUI_LEN];
1043 u8 qui_type;
1044 u8 qui_subtype;
1045 u8 version;
1046 u8 ac_info;
1047} __packed;
94a79942
LF
1048
1049struct rtllib_qos_ac_parameter {
8567829a
LF
1050 u8 aci_aifsn;
1051 u8 ecw_min_max;
1052 __le16 tx_op_limit;
1053} __packed;
94a79942
LF
1054
1055struct rtllib_qos_parameter_info {
8567829a
LF
1056 struct rtllib_qos_information_element info_element;
1057 u8 reserved;
1058 struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
1059} __packed;
94a79942
LF
1060
1061struct rtllib_qos_parameters {
8567829a
LF
1062 __le16 cw_min[QOS_QUEUE_NUM];
1063 __le16 cw_max[QOS_QUEUE_NUM];
1064 u8 aifs[QOS_QUEUE_NUM];
1065 u8 flag[QOS_QUEUE_NUM];
1066 __le16 tx_op_limit[QOS_QUEUE_NUM];
1067} __packed;
94a79942
LF
1068
1069struct rtllib_qos_data {
8567829a 1070 struct rtllib_qos_parameters parameters;
94a79942 1071 unsigned int wmm_acm;
8567829a
LF
1072 int active;
1073 int supported;
1074 u8 param_count;
1075 u8 old_param_count;
94a79942
LF
1076};
1077
1078struct rtllib_tim_parameters {
8567829a
LF
1079 u8 tim_count;
1080 u8 tim_period;
1081} __packed;
94a79942
LF
1082
1083struct rtllib_wmm_ac_param {
1084 u8 ac_aci_acm_aifsn;
1085 u8 ac_ecwmin_ecwmax;
1086 u16 ac_txop_limit;
1087};
1088
94a79942
LF
1089enum eap_type {
1090 EAP_PACKET = 0,
1091 EAPOL_START,
1092 EAPOL_LOGOFF,
1093 EAPOL_KEY,
1094 EAPOL_ENCAP_ASF_ALERT
1095};
1096
84780ecd 1097static const char * const eap_types[] = {
94a79942
LF
1098 [EAP_PACKET] = "EAP-Packet",
1099 [EAPOL_START] = "EAPOL-Start",
1100 [EAPOL_LOGOFF] = "EAPOL-Logoff",
1101 [EAPOL_KEY] = "EAPOL-Key",
1102 [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1103};
1104
1105static inline const char *eap_get_type(int type)
1106{
8567829a
LF
1107 return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
1108 eap_types[type];
94a79942 1109}
8567829a 1110static inline u8 Frame_QoSTID(u8 *buf)
94a79942
LF
1111{
1112 struct rtllib_hdr_3addr *hdr;
1113 u16 fc;
3a6b70c3 1114
94a79942
LF
1115 hdr = (struct rtllib_hdr_3addr *)buf;
1116 fc = le16_to_cpu(hdr->frame_ctl);
8567829a
LF
1117 return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) &&
1118 (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
94a79942
LF
1119}
1120
1121
1122struct eapol {
1123 u8 snap[6];
1124 u16 ethertype;
1125 u8 version;
1126 u8 type;
1127 u16 length;
8567829a 1128} __packed;
94a79942 1129
8567829a 1130struct rtllib_softmac_stats {
94a79942
LF
1131 unsigned int rx_ass_ok;
1132 unsigned int rx_ass_err;
1133 unsigned int rx_probe_rq;
1134 unsigned int tx_probe_rs;
1135 unsigned int tx_beacons;
1136 unsigned int rx_auth_rq;
1137 unsigned int rx_auth_rs_ok;
1138 unsigned int rx_auth_rs_err;
1139 unsigned int tx_auth_rq;
1140 unsigned int no_auth_rs;
1141 unsigned int no_ass_rs;
1142 unsigned int tx_ass_rq;
1143 unsigned int rx_ass_rq;
1144 unsigned int tx_probe_rq;
1145 unsigned int reassoc;
1146 unsigned int swtxstop;
1147 unsigned int swtxawake;
1148 unsigned char CurrentShowTxate;
1149 unsigned char last_packet_rate;
1150 unsigned int txretrycount;
1151};
1152
14b40d92 1153/* These are the data types that can make up management packets
94a79942 1154 *
14b40d92
MK
1155 * u16 auth_algorithm;
1156 * u16 auth_sequence;
1157 * u16 beacon_interval;
1158 * u16 capability;
1159 * u8 current_ap[ETH_ALEN];
1160 * u16 listen_interval;
1161 * struct {
1162 * u16 association_id:14, reserved:2;
1163 * } __packed;
1164 * u32 time_stamp[2];
1165 * u16 reason;
1166 * u16 status;
1167 */
94a79942
LF
1168
1169#define RTLLIB_DEFAULT_TX_ESSID "Penguin"
1170#define RTLLIB_DEFAULT_BASIC_RATE 2
1171
1172enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
1173#define MAX_SP_Len (WMM_all_frame << 4)
1174#define RTLLIB_QOS_TID 0x0f
1175#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1176
1177#define RTLLIB_DTIM_MBCAST 4
1178#define RTLLIB_DTIM_UCAST 2
1179#define RTLLIB_DTIM_VALID 1
1180#define RTLLIB_DTIM_INVALID 0
1181
1182#define RTLLIB_PS_DISABLED 0
1183#define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
1184#define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
1185
94a79942
LF
1186#define WME_AC_BK 0x00
1187#define WME_AC_BE 0x01
1188#define WME_AC_VI 0x02
1189#define WME_AC_VO 0x03
1190#define WME_ACI_MASK 0x03
1191#define WME_AIFSN_MASK 0x03
1192#define WME_AC_PRAM_LEN 16
1193
1194#define MAX_RECEIVE_BUFFER_SIZE 9100
1195
94a79942
LF
1196#define UP2AC(up) ( \
1197 ((up) < 1) ? WME_AC_BE : \
1198 ((up) < 3) ? WME_AC_BK : \
1199 ((up) < 4) ? WME_AC_BE : \
1200 ((up) < 6) ? WME_AC_VI : \
1201 WME_AC_VO)
eccf634f 1202
94a79942 1203#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
8567829a
LF
1204#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
1205 * plus ether type*/
94a79942
LF
1206
1207struct ether_header {
1208 u8 ether_dhost[ETHER_ADDR_LEN];
1209 u8 ether_shost[ETHER_ADDR_LEN];
1210 u16 ether_type;
8567829a 1211} __packed;
94a79942 1212
3b45eb83 1213enum erp_t {
94a79942
LF
1214 ERP_NonERPpresent = 0x01,
1215 ERP_UseProtection = 0x02,
1216 ERP_BarkerPreambleMode = 0x04,
3b45eb83 1217};
94a79942
LF
1218
1219struct rtllib_network {
1220 /* These entries are used to identify a unique network */
1221 u8 bssid[ETH_ALEN];
1222 u8 channel;
1223 /* Ensure null-terminated for any debug msgs */
1224 u8 ssid[IW_ESSID_MAX_SIZE + 1];
1225 u8 ssid_len;
1226 u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
1227 u8 hidden_ssid_len;
1228 struct rtllib_qos_data qos_data;
1229
1230 bool bWithAironetIE;
1231 bool bCkipSupported;
1232 bool bCcxRmEnable;
1233 u16 CcxRmState[2];
1234 bool bMBssidValid;
1235 u8 MBssidMask;
06c11107 1236 u8 MBssid[ETH_ALEN];
94a79942
LF
1237 bool bWithCcxVerNum;
1238 u8 BssCcxVerNumber;
1239 /* These are network statistics */
1240 struct rtllib_rx_stats stats;
1241 u16 capability;
1242 u8 rates[MAX_RATES_LENGTH];
1243 u8 rates_len;
1244 u8 rates_ex[MAX_RATES_EX_LENGTH];
1245 u8 rates_ex_len;
1246 unsigned long last_scanned;
1247 u8 mode;
1248 u32 flags;
94a79942
LF
1249 u32 time_stamp[2];
1250 u16 beacon_interval;
1251 u16 listen_interval;
1252 u16 atim_window;
1253 u8 erp_value;
1254 u8 wpa_ie[MAX_WPA_IE_LEN];
1255 size_t wpa_ie_len;
1256 u8 rsn_ie[MAX_WPA_IE_LEN];
1257 size_t rsn_ie_len;
1258 u8 wzc_ie[MAX_WZC_IE_LEN];
1259 size_t wzc_ie_len;
1260
8567829a 1261 struct rtllib_tim_parameters tim;
94a79942
LF
1262 u8 dtim_period;
1263 u8 dtim_data;
0dd56506 1264 u64 last_dtim_sta_time;
94a79942 1265
8567829a
LF
1266 u8 wmm_info;
1267 struct rtllib_wmm_ac_param wmm_param[4];
94a79942 1268 u8 Turbo_Enable;
94a79942
LF
1269 u16 CountryIeLen;
1270 u8 CountryIeBuf[MAX_IE_LEN];
a15e76ad 1271 struct bss_ht bssht;
94a79942
LF
1272 bool broadcom_cap_exist;
1273 bool realtek_cap_exit;
1274 bool marvell_cap_exist;
1275 bool ralink_cap_exist;
1276 bool atheros_cap_exist;
1277 bool cisco_cap_exist;
1278 bool airgo_cap_exist;
1279 bool unknown_cap_exist;
1280 bool berp_info_valid;
1281 bool buseprotection;
94a79942
LF
1282 u8 SignalStrength;
1283 u8 RSSI;
1284 struct list_head list;
1285};
1286
94a79942
LF
1287enum rtllib_state {
1288
1289 /* the card is not linked at all */
1290 RTLLIB_NOLINK = 0,
1291
1292 /* RTLLIB_ASSOCIATING* are for BSS client mode
1293 * the driver shall not perform RX filtering unless
1294 * the state is LINKED.
1295 * The driver shall just check for the state LINKED and
1296 * defaults to NOLINK for ALL the other states (including
1297 * LINKED_SCANNING)
1298 */
1299
1300 /* the association procedure will start (wq scheduling)*/
1301 RTLLIB_ASSOCIATING,
1302 RTLLIB_ASSOCIATING_RETRY,
1303
1304 /* the association procedure is sending AUTH request*/
1305 RTLLIB_ASSOCIATING_AUTHENTICATING,
1306
cd017123 1307 /* the association procedure has successfully authenticated
94a79942
LF
1308 * and is sending association request
1309 */
1310 RTLLIB_ASSOCIATING_AUTHENTICATED,
1311
1312 /* the link is ok. the card associated to a BSS or linked
1313 * to a ibss cell or acting as an AP and creating the bss
1314 */
1315 RTLLIB_LINKED,
1316
1317 /* same as LINKED, but the driver shall apply RX filter
1318 * rules as we are in NO_LINK mode. As the card is still
1319 * logically linked, but it is doing a syncro site survey
1320 * then it will be back to LINKED state.
1321 */
1322 RTLLIB_LINKED_SCANNING,
1323};
94a79942
LF
1324
1325#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1326#define DEFAULT_FTS 2346
1327
1328#define CFG_RTLLIB_RESERVE_FCS (1<<0)
1329#define CFG_RTLLIB_COMPUTE_FCS (1<<1)
94a79942 1330
0ce60045 1331struct tx_pending {
94a79942
LF
1332 int frag;
1333 struct rtllib_txb *txb;
d3b2c172 1334};
94a79942 1335
dca0eb1e 1336struct bandwidth_autoswitch {
94a79942
LF
1337 long threshold_20Mhzto40Mhz;
1338 long threshold_40Mhzto20Mhz;
1339 bool bforced_tx20Mhz;
1340 bool bautoswitch_enable;
d3b2c172 1341};
94a79942
LF
1342
1343
1344
1345#define REORDER_WIN_SIZE 128
1346#define REORDER_ENTRY_NUM 128
8cba1432 1347struct rx_reorder_entry {
94a79942
LF
1348 struct list_head List;
1349 u16 SeqNum;
8567829a 1350 struct rtllib_rxb *prxb;
8cba1432 1351};
3c093c2b 1352enum fsync_state {
94a79942
LF
1353 Default_Fsync,
1354 HW_Fsync,
1355 SW_Fsync
3c093c2b 1356};
94a79942 1357
f6e3d4f4 1358enum rt_ps_mode {
94a79942
LF
1359 eActive,
1360 eMaxPs,
1361 eFastPs,
1362 eAutoPs,
f6e3d4f4 1363};
94a79942 1364
8304cc64 1365enum ips_callback_function {
94a79942
LF
1366 IPS_CALLBACK_NONE = 0,
1367 IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1368 IPS_CALLBACK_JOIN_REQUEST = 2,
8304cc64 1369};
94a79942 1370
de7c885a 1371enum rt_rf_power_state {
94a79942
LF
1372 eRfOn,
1373 eRfSleep,
1374 eRfOff
de7c885a 1375};
94a79942 1376
ca990011 1377struct rt_pwr_save_ctrl {
94a79942
LF
1378
1379 bool bInactivePs;
1380 bool bIPSModeBackup;
94a79942 1381 bool bSwRfProcessing;
de7c885a 1382 enum rt_rf_power_state eInactivePowerState;
8304cc64 1383 enum ips_callback_function ReturnPoint;
94a79942 1384
94a79942 1385 bool bLeisurePs;
94a79942
LF
1386 u8 LpsIdleCount;
1387 u8 RegMaxLPSAwakeIntvl;
1388 u8 LPSAwakeIntvl;
1389
1390 u32 CurPsLevel;
1391 u32 RegRfPsLevel;
1392
1393 bool bFwCtrlLPS;
94a79942 1394
d3b2c172 1395};
94a79942 1396
9de9f962
LF
1397#define RT_RF_CHANGE_SOURCE u32
1398
94a79942
LF
1399#define RF_CHANGE_BY_SW BIT31
1400#define RF_CHANGE_BY_HW BIT30
1401#define RF_CHANGE_BY_PS BIT29
1402#define RF_CHANGE_BY_IPS BIT28
1403#define RF_CHANGE_BY_INIT 0
1404
569e5959 1405enum country_code_type {
94a79942
LF
1406 COUNTRY_CODE_FCC = 0,
1407 COUNTRY_CODE_IC = 1,
1408 COUNTRY_CODE_ETSI = 2,
1409 COUNTRY_CODE_SPAIN = 3,
1410 COUNTRY_CODE_FRANCE = 4,
1411 COUNTRY_CODE_MKK = 5,
1412 COUNTRY_CODE_MKK1 = 6,
1413 COUNTRY_CODE_ISRAEL = 7,
1414 COUNTRY_CODE_TELEC = 8,
1415 COUNTRY_CODE_MIC = 9,
1416 COUNTRY_CODE_GLOBAL_DOMAIN = 10,
1417 COUNTRY_CODE_WORLD_WIDE_13 = 11,
1418 COUNTRY_CODE_TELEC_NETGEAR = 12,
1419 COUNTRY_CODE_MAX
569e5959 1420};
94a79942 1421
472ba326 1422enum scan_op_backup_opt {
8567829a 1423 SCAN_OPT_BACKUP = 0,
94a79942
LF
1424 SCAN_OPT_RESTORE,
1425 SCAN_OPT_MAX
472ba326 1426};
94a79942 1427
74082c92 1428enum fw_cmd_io_type {
94a79942
LF
1429 FW_CMD_DIG_ENABLE = 0,
1430 FW_CMD_DIG_DISABLE = 1,
1431 FW_CMD_DIG_HALT = 2,
1432 FW_CMD_DIG_RESUME = 3,
1433 FW_CMD_HIGH_PWR_ENABLE = 4,
1434 FW_CMD_HIGH_PWR_DISABLE = 5,
1435 FW_CMD_RA_RESET = 6,
8567829a
LF
1436 FW_CMD_RA_ACTIVE = 7,
1437 FW_CMD_RA_REFRESH_N = 8,
1438 FW_CMD_RA_REFRESH_BG = 9,
1439 FW_CMD_RA_INIT = 10,
94a79942
LF
1440 FW_CMD_IQK_ENABLE = 11,
1441 FW_CMD_TXPWR_TRACK_ENABLE = 12,
1442 FW_CMD_TXPWR_TRACK_DISABLE = 13,
1443 FW_CMD_TXPWR_TRACK_THERMAL = 14,
1444 FW_CMD_PAUSE_DM_BY_SCAN = 15,
1445 FW_CMD_RESUME_DM_BY_SCAN = 16,
1446 FW_CMD_RA_REFRESH_N_COMB = 17,
1447 FW_CMD_RA_REFRESH_BG_COMB = 18,
1448 FW_CMD_ANTENNA_SW_ENABLE = 19,
1449 FW_CMD_ANTENNA_SW_DISABLE = 20,
1450 FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
1451 FW_CMD_LPS_ENTER = 22,
1452 FW_CMD_LPS_LEAVE = 23,
74082c92 1453};
94a79942
LF
1454
1455#define RT_MAX_LD_SLOT_NUM 10
0e86753f 1456struct rt_link_detect {
94a79942
LF
1457
1458 u32 NumRecvBcnInPeriod;
1459 u32 NumRecvDataInPeriod;
1460
1461 u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
1462 u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
1463 u16 SlotNum;
1464 u16 SlotIndex;
1465
1466 u32 NumTxOkInPeriod;
1467 u32 NumRxOkInPeriod;
1468 u32 NumRxUnicastOkInPeriod;
1469 bool bBusyTraffic;
1470 bool bHigherBusyTraffic;
1471 bool bHigherBusyRxTraffic;
d3b2c172 1472};
94a79942 1473
5ea04480 1474struct sw_cam_table {
94a79942 1475
06c11107 1476 u8 macaddr[ETH_ALEN];
94a79942
LF
1477 bool bused;
1478 u8 key_buf[16];
1479 u16 key_type;
1480 u8 useDK;
1481 u8 key_index;
1482
d3b2c172 1483};
94a79942 1484#define TOTAL_CAM_ENTRY 32
9be6f10e 1485struct rate_adaptive {
94a79942
LF
1486 u8 rate_adaptive_disabled;
1487 u8 ratr_state;
1488 u16 reserve;
1489
1490 u32 high_rssi_thresh_for_ra;
1491 u32 high2low_rssi_thresh_for_ra;
1492 u8 low2high_rssi_thresh_for_ra40M;
1493 u32 low_rssi_thresh_for_ra40M;
1494 u8 low2high_rssi_thresh_for_ra20M;
1495 u32 low_rssi_thresh_for_ra20M;
1496 u32 upper_rssi_threshold_ratr;
1497 u32 middle_rssi_threshold_ratr;
1498 u32 low_rssi_threshold_ratr;
1499 u32 low_rssi_threshold_ratr_40M;
1500 u32 low_rssi_threshold_ratr_20M;
1501 u8 ping_rssi_enable;
1502 u32 ping_rssi_ratr;
1503 u32 ping_rssi_thresh_for_ra;
1504 u32 last_ratr;
1505 u8 PreRATRState;
1506
9be6f10e 1507};
94a79942
LF
1508
1509#define NUM_PMKID_CACHE 16
74d0497b 1510struct rt_pmkid_list {
06c11107 1511 u8 Bssid[ETH_ALEN];
8567829a
LF
1512 u8 PMKID[16];
1513 u8 SsidBuf[33];
06c11107 1514 u8 bUsed;
74d0497b 1515};
94a79942 1516
ca394055 1517struct rt_intel_promisc_mode {
8567829a
LF
1518 bool bPromiscuousOn;
1519 bool bFilterSourceStationFrame;
ca394055 1520};
94a79942
LF
1521
1522
1523/*************** DRIVER STATUS *****/
1524#define STATUS_SCANNING 0
94a79942
LF
1525/*************** DRIVER STATUS *****/
1526
94a79942
LF
1527enum {
1528 LPS_IS_WAKE = 0,
1529 LPS_IS_SLEEP = 1,
8567829a 1530 LPS_WAIT_NULL_DATA_SEND = 2,
94a79942
LF
1531};
1532
1533struct rtllib_device {
1534 struct pci_dev *pdev;
1535 struct net_device *dev;
1536 struct rtllib_security sec;
1537
1538 bool disable_mgnt_queue;
1539
1540 unsigned long status;
94a79942
LF
1541 u8 CntAfterLink;
1542
e93e0f6a 1543 enum rt_op_mode OpMode;
94a79942 1544
94a79942
LF
1545 /* The last AssocReq/Resp IEs */
1546 u8 *assocreq_ies, *assocresp_ies;
1547 size_t assocreq_ies_len, assocresp_ies_len;
1548
94a79942 1549 bool bForcedBgMode;
94a79942 1550 u8 RF_Type;
94a79942
LF
1551
1552 u8 hwsec_active;
1553 bool is_silent_reset;
94a79942
LF
1554 bool is_roaming;
1555 bool ieee_up;
1556 bool cannot_notify;
1557 bool bSupportRemoteWakeUp;
94a79942
LF
1558 bool actscanning;
1559 bool FirstIe_InScan;
1560 bool be_scan_inprogress;
1561 bool beinretry;
de7c885a 1562 enum rt_rf_power_state eRFPowerState;
94a79942
LF
1563 RT_RF_CHANGE_SOURCE RfOffReason;
1564 bool is_set_key;
1565 bool wx_set_enc;
7796d93e 1566 struct rt_hi_throughput *pHTInfo;
94a79942
LF
1567
1568 spinlock_t reorder_spinlock;
1569 u8 Regdot11HTOperationalRateSet[16];
1570 u8 Regdot11TxHTOperationalRateSet[16];
1571 u8 dot11HTOperationalRateSet[16];
1572 u8 RegHTSuppRateSet[16];
8567829a
LF
1573 u8 HTCurrentOperaRate;
1574 u8 HTHighestOperaRate;
94a79942
LF
1575 u8 bTxDisableRateFallBack;
1576 u8 bTxUseDriverAssingedRate;
1577 u8 bTxEnableFwCalcDur;
94a79942
LF
1578 atomic_t atm_swbw;
1579
1580 struct list_head Tx_TS_Admit_List;
1581 struct list_head Tx_TS_Pending_List;
1582 struct list_head Tx_TS_Unused_List;
60554f2b 1583 struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
94a79942
LF
1584 struct list_head Rx_TS_Admit_List;
1585 struct list_head Rx_TS_Pending_List;
1586 struct list_head Rx_TS_Unused_List;
2c47ae28 1587 struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
8cba1432 1588 struct rx_reorder_entry RxReorderEntry[128];
94a79942 1589 struct list_head RxReorder_Unused_List;
94a79942
LF
1590
1591
1592 /* Bookkeeping structures */
1593 struct net_device_stats stats;
1594 struct rtllib_stats ieee_stats;
1595 struct rtllib_softmac_stats softmac_stats;
1596
1597 /* Probe / Beacon management */
1598 struct list_head network_free_list;
1599 struct list_head network_list;
94a79942
LF
1600 struct rtllib_network *networks;
1601 int scans;
1602 int scan_age;
1603
1604 int iw_mode; /* operating mode (IW_MODE_*) */
1605 bool bNetPromiscuousMode;
ca394055 1606 struct rt_intel_promisc_mode IntelPromiscuousModeInfo;
94a79942 1607
94a79942
LF
1608 spinlock_t lock;
1609 spinlock_t wpax_suitlist_lock;
1610
1611 int tx_headroom; /* Set to size of any additional room needed at front
14b40d92
MK
1612 * of allocated Tx SKBs
1613 */
94a79942
LF
1614 u32 config;
1615
1616 /* WEP and other encryption related settings at the device level */
1617 int open_wep; /* Set to 1 to allow unencrypted frames */
1618 int auth_mode;
1619 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
14b40d92
MK
1620 * WEP key changes
1621 */
94a79942
LF
1622
1623 /* If the host performs {en,de}cryption, then set to 1 */
1624 int host_encrypt;
94a79942 1625 int host_decrypt;
94a79942 1626
94a79942
LF
1627 int ieee802_1x; /* is IEEE 802.1X used */
1628
1629 /* WPA data */
94a79942
LF
1630 bool bHalfWirelessN24GMode;
1631 int wpa_enabled;
1632 int drop_unencrypted;
1633 int tkip_countermeasures;
1634 int privacy_invoked;
1635 size_t wpa_ie_len;
1636 u8 *wpa_ie;
1637 size_t wps_ie_len;
1638 u8 *wps_ie;
06c11107 1639 u8 ap_mac_addr[ETH_ALEN];
94a79942
LF
1640 u16 pairwise_key_type;
1641 u16 group_key_type;
94a79942 1642
0ddcf5fd 1643 struct lib80211_crypt_info crypt_info;
94a79942 1644
0ddcf5fd 1645 struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
94a79942 1646
74d0497b 1647 struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
94a79942
LF
1648
1649 /* Fragmentation structures */
1650 struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
1651 unsigned int frag_next_idx[17];
1652 u16 fts; /* Fragmentation Threshold */
1653#define DEFAULT_RTS_THRESHOLD 2346U
1654#define MIN_RTS_THRESHOLD 1
1655#define MAX_RTS_THRESHOLD 2346U
8567829a 1656 u16 rts; /* RTS threshold */
94a79942 1657
8567829a
LF
1658 /* Association info */
1659 u8 bssid[ETH_ALEN];
94a79942
LF
1660
1661 /* This stores infos for the current network.
1662 * Either the network we are associated in INFRASTRUCTURE
1663 * or the network that we are creating in MASTER mode.
1664 * ad-hoc is a mixture ;-).
1665 * Note that in infrastructure mode, even when not associated,
1666 * fields bssid and essid may be valid (if wpa_set and essid_set
1667 * are true) as thy carry the value set by the user via iwconfig
1668 */
1669 struct rtllib_network current_network;
1670
1671 enum rtllib_state state;
1672
1673 int short_slot;
94a79942
LF
1674 int mode; /* A, B, G */
1675 int modulation; /* CCK, OFDM */
1676 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
94a79942
LF
1677
1678 /* used for forcing the ibss workqueue to terminate
1679 * without wait for the syncro scan to terminate
1680 */
1681 short sync_scan_hurryup;
1682 u16 scan_watch_dog;
94a79942
LF
1683
1684 /* map of allowed channels. 0 is dummy */
8567829a 1685 void *pDot11dInfo;
94a79942 1686 bool bGlobalDomain;
94a79942
LF
1687 u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
1688
1689 u8 IbssStartChnl;
1690 u8 ibss_maxjoin_chal;
1691
1692 int rate; /* current rate */
1693 int basic_rate;
94a79942
LF
1694
1695 short active_scan;
1696
1697 /* this contains flags for selectively enable softmac support */
1698 u16 softmac_features;
1699
1700 /* if the sequence control field is not filled by HW */
1701 u16 seq_ctrl[5];
1702
1703 /* association procedure transaction sequence number */
1704 u16 associate_seq;
1705
1706 /* AID for RTXed association responses */
1707 u16 assoc_id;
1708
1709 /* power save mode related*/
1710 u8 ack_tx_to_ieee;
1711 short ps;
1712 short sta_sleep;
1713 int ps_timeout;
1714 int ps_period;
1715 struct tasklet_struct ps_task;
0dd56506 1716 u64 ps_time;
94a79942
LF
1717 bool polling;
1718
1719 short raw_tx;
1720 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1721 short queue_stop;
dc986e3e 1722 short scanning_continue;
94a79942
LF
1723 short proto_started;
1724 short proto_stoppping;
1725
1726 struct semaphore wx_sem;
1727 struct semaphore scan_sem;
1728 struct semaphore ips_sem;
1729
1730 spinlock_t mgmt_tx_lock;
1731 spinlock_t beacon_lock;
1732
1733 short beacon_txing;
1734
1735 short wap_set;
1736 short ssid_set;
1737
1738 /* set on initialization */
94a79942
LF
1739 unsigned int wmm_acm;
1740
1741 /* for discarding duplicated packets in IBSS */
1742 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1743
1744 /* for discarding duplicated packets in BSS */
1745 u16 last_rxseq_num[17]; /* rx seq previous per-tid */
1746 u16 last_rxfrag_num[17];/* tx frag previous per-tid */
1747 unsigned long last_packet_time[17];
1748
1749 /* for PS mode */
1750 unsigned long last_rx_ps_time;
1751 bool bAwakePktSent;
1752 u8 LPSDelayCnt;
1753
1754 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
1755 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1756 int mgmt_queue_head;
1757 int mgmt_queue_tail;
94a79942 1758 u8 AsocRetryCount;
94a79942
LF
1759 struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1760 struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
94a79942 1761 bool aggregation;
94a79942
LF
1762
1763 bool bdynamic_txpower_enable;
1764
1765 bool bCTSToSelfEnable;
94a79942
LF
1766
1767 u32 fsync_time_interval;
1768 u32 fsync_rate_bitmap;
1769 u8 fsync_rssi_threshold;
1770 bool bfsync_enable;
1771
1772 u8 fsync_multiple_timeinterval;
1773 u32 fsync_firstdiff_ratethreshold;
1774 u32 fsync_seconddiff_ratethreshold;
3c093c2b 1775 enum fsync_state fsync_state;
94a79942 1776 bool bis_any_nonbepkts;
dca0eb1e 1777 struct bandwidth_autoswitch bandwidth_auto_switch;
94a79942
LF
1778 bool FwRWRF;
1779
0e86753f 1780 struct rt_link_detect LinkDetectInfo;
94a79942 1781 bool bIsAggregateFrame;
ca990011 1782 struct rt_pwr_save_ctrl PowerSaveControl;
94a79942
LF
1783
1784 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
0ce60045 1785 struct tx_pending tx_pending;
94a79942
LF
1786
1787 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
1788 struct timer_list associate_timer;
1789
1790 /* used if IEEE_SOFTMAC_BEACONS is set */
1791 struct timer_list beacon_timer;
1792 u8 need_sw_enc;
edc4b2c5
LF
1793 struct work_struct associate_complete_wq;
1794 struct work_struct ips_leave_wq;
1795 struct delayed_work associate_procedure_wq;
1796 struct delayed_work softmac_scan_wq;
edc4b2c5
LF
1797 struct delayed_work associate_retry_wq;
1798 struct delayed_work start_ibss_wq;
1799 struct delayed_work hw_wakeup_wq;
1800 struct delayed_work hw_sleep_wq;
1801 struct delayed_work link_change_wq;
1802 struct work_struct wx_sync_scan_wq;
94a79942
LF
1803
1804 struct workqueue_struct *wq;
2eed3dee
LF
1805 union {
1806 struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE];
1807 struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
1808 struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE];
1809 struct {
1810 struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT];
1811 struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT];
1812 struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
1813 };
1814 };
94a79942
LF
1815
1816 /* Callback functions */
1817 void (*set_security)(struct net_device *dev,
1818 struct rtllib_security *sec);
1819
1820 /* Used to TX data frame by using txb structs.
1821 * this is not used if in the softmac_features
1822 * is set the flag IEEE_SOFTMAC_TX_QUEUE
1823 */
1824 int (*hard_start_xmit)(struct rtllib_txb *txb,
1825 struct net_device *dev);
1826
1827 int (*reset_port)(struct net_device *dev);
94a79942 1828
db2c8da0 1829 /* Softmac-generated frames (management) are TXed via this
94a79942
LF
1830 * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
1831 * not set. As some cards may have different HW queues that
1832 * one might want to use for data and management frames
1833 * the option to have two callbacks might be useful.
db2c8da0 1834 * This function can't sleep.
94a79942
LF
1835 */
1836 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1837 struct net_device *dev);
1838
1839 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
1840 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
cd017123 1841 * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
94a79942
LF
1842 * then also management frames are sent via this callback.
1843 * This function can't sleep.
1844 */
1845 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
8567829a 1846 struct net_device *dev, int rate);
94a79942
LF
1847
1848 /* stops the HW queue for DATA frames. Useful to avoid
1849 * waste time to TX data frame when we are reassociating
1850 * This function can sleep.
1851 */
1852 void (*data_hard_stop)(struct net_device *dev);
1853
cd017123 1854 /* OK this is complementing to data_poll_hard_stop */
94a79942
LF
1855 void (*data_hard_resume)(struct net_device *dev);
1856
14b40d92 1857 /* ask to the driver to retune the radio.
94a79942 1858 * This function can sleep. the driver should ensure
cd017123 1859 * the radio has been switched before return.
94a79942 1860 */
8567829a 1861 void (*set_chan)(struct net_device *dev, short ch);
94a79942 1862
94a79942
LF
1863 void (*rtllib_start_hw_scan)(struct net_device *dev);
1864 void (*rtllib_stop_hw_scan)(struct net_device *dev);
1865
1866 /* indicate the driver that the link state is changed
1867 * for example it may indicate the card is associated now.
1868 * Driver might be interested in this to apply RX filter
1869 * rules or simply light the LINK led
1870 */
1871 void (*link_change)(struct net_device *dev);
1872
1873 /* these two function indicates to the HW when to start
1874 * and stop to send beacons. This is used when the
1875 * IEEE_SOFTMAC_BEACONS is not set. For now the
1876 * stop_send_bacons is NOT guaranteed to be called only
1877 * after start_send_beacons.
1878 */
8567829a
LF
1879 void (*start_send_beacons)(struct net_device *dev);
1880 void (*stop_send_beacons)(struct net_device *dev);
94a79942
LF
1881
1882 /* power save mode related */
8567829a
LF
1883 void (*sta_wake_up)(struct net_device *dev);
1884 void (*enter_sleep_state)(struct net_device *dev, u64 time);
1885 short (*ps_is_queue_empty)(struct net_device *dev);
1886 int (*handle_beacon)(struct net_device *dev,
1887 struct rtllib_beacon *beacon,
1888 struct rtllib_network *network);
1889 int (*handle_assoc_response)(struct net_device *dev,
1890 struct rtllib_assoc_response_frame *resp,
1891 struct rtllib_network *network);
94a79942
LF
1892
1893
cd017123 1894 /* check whether Tx hw resource available */
94a79942 1895 short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
8567829a
LF
1896 void (*SetBWModeHandler)(struct net_device *dev,
1897 enum ht_channel_width Bandwidth,
1898 enum ht_extchnl_offset Offset);
1899 bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
1900 void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode);
1901 bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
94a79942 1902 u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
94a79942 1903 void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
8567829a
LF
1904 bool (*SetFwCmdHandler)(struct net_device *dev,
1905 enum fw_cmd_io_type FwCmdIO);
8567829a
LF
1906 void (*UpdateBeaconInterruptHandler)(struct net_device *dev,
1907 bool start);
8567829a
LF
1908 void (*ScanOperationBackupHandler)(struct net_device *dev,
1909 u8 Operation);
1910 void (*LedControlHandler)(struct net_device *dev,
1911 enum led_ctl_mode LedAction);
1912 void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
8567829a
LF
1913
1914 void (*AllowAllDestAddrHandler)(struct net_device *dev,
1915 bool bAllowAllDA, bool WriteIntoReg);
1916
042b623c 1917 void (*rtllib_ips_leave_wq)(struct net_device *dev);
8567829a 1918 void (*rtllib_ips_leave)(struct net_device *dev);
94a79942 1919 void (*LeisurePSLeave)(struct net_device *dev);
94a79942
LF
1920
1921 /* This must be the last item so that it points to the data
14b40d92
MK
1922 * allocated beyond this structure by alloc_rtllib
1923 */
94a79942
LF
1924 u8 priv[0];
1925};
1926
8567829a
LF
1927#define IEEE_A (1<<0)
1928#define IEEE_B (1<<1)
1929#define IEEE_G (1<<2)
94a79942
LF
1930#define IEEE_N_24G (1<<4)
1931#define IEEE_N_5G (1<<5)
1932#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
1933
1934/* Generate a 802.11 header */
1935
1936/* Uses the channel change callback directly
1937 * instead of [start/stop] scan callbacks
1938 */
1939#define IEEE_SOFTMAC_SCAN (1<<2)
1940
1941/* Perform authentication and association handshake */
1942#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1943
1944/* Generate probe requests */
1945#define IEEE_SOFTMAC_PROBERQ (1<<4)
1946
cd017123 1947/* Generate response to probe requests */
94a79942
LF
1948#define IEEE_SOFTMAC_PROBERS (1<<5)
1949
cd017123 1950/* The ieee802.11 stack will manage the netif queue
94a79942 1951 * wake/stop for the driver, taking care of 802.11
14b40d92
MK
1952 * fragmentation. See softmac.c for details.
1953 */
94a79942
LF
1954#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1955
1956/* Uses only the softmac_data_hard_start_xmit
1957 * even for TX management frames.
1958 */
1959#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1960
1961/* Generate beacons. The stack will enqueue beacons
1962 * to the card
1963 */
1964#define IEEE_SOFTMAC_BEACONS (1<<6)
1965
1966
1967static inline void *rtllib_priv(struct net_device *dev)
1968{
1969 return ((struct rtllib_device *)netdev_priv(dev))->priv;
1970}
1971
9d8a20a5 1972static inline int rtllib_is_empty_essid(const char *essid, int essid_len)
94a79942
LF
1973{
1974 /* Single white space is for Linksys APs */
1975 if (essid_len == 1 && essid[0] == ' ')
1976 return 1;
1977
1978 /* Otherwise, if the entire essid is 0, we assume it is hidden */
1979 while (essid_len) {
1980 essid_len--;
1981 if (essid[essid_len] != '\0')
1982 return 0;
1983 }
1984
1985 return 1;
1986}
1987
9d8a20a5 1988static inline int rtllib_get_hdrlen(u16 fc)
94a79942
LF
1989{
1990 int hdrlen = RTLLIB_3ADDR_LEN;
1991
1992 switch (WLAN_FC_GET_TYPE(fc)) {
1993 case RTLLIB_FTYPE_DATA:
1994 if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
1995 hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
1996 if (RTLLIB_QOS_HAS_SEQ(fc))
1997 hdrlen += 2; /* QOS ctrl*/
1998 break;
1999 case RTLLIB_FTYPE_CTL:
2000 switch (WLAN_FC_GET_STYPE(fc)) {
2001 case RTLLIB_STYPE_CTS:
2002 case RTLLIB_STYPE_ACK:
2003 hdrlen = RTLLIB_1ADDR_LEN;
2004 break;
2005 default:
2006 hdrlen = RTLLIB_2ADDR_LEN;
2007 break;
2008 }
2009 break;
2010 }
2011
2012 return hdrlen;
2013}
2014
2015static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
2016{
8567829a
LF
2017 switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2018 case RTLLIB_1ADDR_LEN:
2019 return ((struct rtllib_hdr_1addr *)hdr)->payload;
2020 case RTLLIB_2ADDR_LEN:
2021 return ((struct rtllib_hdr_2addr *)hdr)->payload;
2022 case RTLLIB_3ADDR_LEN:
2023 return ((struct rtllib_hdr_3addr *)hdr)->payload;
2024 case RTLLIB_4ADDR_LEN:
2025 return ((struct rtllib_hdr_4addr *)hdr)->payload;
2026 }
2027 return NULL;
94a79942
LF
2028}
2029
2030static inline int rtllib_is_ofdm_rate(u8 rate)
2031{
8567829a
LF
2032 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2033 case RTLLIB_OFDM_RATE_6MB:
2034 case RTLLIB_OFDM_RATE_9MB:
2035 case RTLLIB_OFDM_RATE_12MB:
2036 case RTLLIB_OFDM_RATE_18MB:
2037 case RTLLIB_OFDM_RATE_24MB:
2038 case RTLLIB_OFDM_RATE_36MB:
2039 case RTLLIB_OFDM_RATE_48MB:
2040 case RTLLIB_OFDM_RATE_54MB:
2041 return 1;
2042 }
2043 return 0;
94a79942
LF
2044}
2045
2046static inline int rtllib_is_cck_rate(u8 rate)
2047{
8567829a
LF
2048 switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2049 case RTLLIB_CCK_RATE_1MB:
2050 case RTLLIB_CCK_RATE_2MB:
2051 case RTLLIB_CCK_RATE_5MB:
2052 case RTLLIB_CCK_RATE_11MB:
2053 return 1;
2054 }
2055 return 0;
94a79942
LF
2056}
2057
2058
94a79942
LF
2059/* rtllib.c */
2060extern void free_rtllib(struct net_device *dev);
2061extern struct net_device *alloc_rtllib(int sizeof_priv);
2062
94a79942
LF
2063/* rtllib_tx.c */
2064
2065extern int rtllib_encrypt_fragment(
2066 struct rtllib_device *ieee,
2067 struct sk_buff *frag,
2068 int hdr_len);
2069
2070extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
2071extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
2072extern void rtllib_txb_free(struct rtllib_txb *);
2073
2074/* rtllib_rx.c */
2075extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
2076 struct rtllib_rx_stats *rx_stats);
2077extern void rtllib_rx_mgt(struct rtllib_device *ieee,
2078 struct sk_buff *skb,
2079 struct rtllib_rx_stats *stats);
2080extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
8567829a 2081 struct sk_buff *skb);
976d5341 2082extern int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
94a79942
LF
2083
2084/* rtllib_wx.c */
2085extern int rtllib_wx_get_scan(struct rtllib_device *ieee,
2086 struct iw_request_info *info,
2087 union iwreq_data *wrqu, char *key);
2088extern int rtllib_wx_set_encode(struct rtllib_device *ieee,
2089 struct iw_request_info *info,
2090 union iwreq_data *wrqu, char *key);
2091extern int rtllib_wx_get_encode(struct rtllib_device *ieee,
2092 struct iw_request_info *info,
2093 union iwreq_data *wrqu, char *key);
94a79942 2094extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
8567829a
LF
2095 struct iw_request_info *info,
2096 union iwreq_data *wrqu, char *extra);
94a79942 2097extern int rtllib_wx_set_auth(struct rtllib_device *ieee,
8567829a
LF
2098 struct iw_request_info *info,
2099 struct iw_param *data, char *extra);
94a79942 2100extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
8567829a
LF
2101 struct iw_request_info *info,
2102 union iwreq_data *wrqu, char *extra);
94a79942
LF
2103extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
2104
2105/* rtllib_softmac.c */
2106extern short rtllib_is_54g(struct rtllib_network *net);
8567829a
LF
2107extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
2108 struct sk_buff *skb,
2109 struct rtllib_rx_stats *rx_stats, u16 type,
2110 u16 stype);
2111extern void rtllib_softmac_new_net(struct rtllib_device *ieee,
2112 struct rtllib_network *net);
94a79942
LF
2113
2114void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
8567829a
LF
2115extern void rtllib_softmac_xmit(struct rtllib_txb *txb,
2116 struct rtllib_device *ieee);
94a79942
LF
2117
2118extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2119extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2120extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
2121extern void rtllib_start_bss(struct rtllib_device *ieee);
2122extern void rtllib_start_master_bss(struct rtllib_device *ieee);
2123extern void rtllib_start_ibss(struct rtllib_device *ieee);
2124extern void rtllib_softmac_init(struct rtllib_device *ieee);
2125extern void rtllib_softmac_free(struct rtllib_device *ieee);
2126extern void rtllib_associate_abort(struct rtllib_device *ieee);
2127extern void rtllib_disassociate(struct rtllib_device *ieee);
2128extern void rtllib_stop_scan(struct rtllib_device *ieee);
2129extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
2130extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
2131extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
8567829a
LF
2132extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee,
2133 short pwr);
94a79942
LF
2134extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
2135extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
94a79942
LF
2136extern void rtllib_start_protocol(struct rtllib_device *ieee);
2137extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
2138
8567829a
LF
2139extern void rtllib_EnableNetMonitorMode(struct net_device *dev,
2140 bool bInitState);
2141extern void rtllib_DisableNetMonitorMode(struct net_device *dev,
2142 bool bInitState);
2143extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
2144 bool bInitState);
2145extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
2146 bool bInitState);
94a79942
LF
2147extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
2148
8567829a
LF
2149extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee,
2150 u8 mesh_flag, u8 shutdown);
2151extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,
2152 u8 mesh_flag);
94a79942
LF
2153
2154extern void rtllib_reset_queue(struct rtllib_device *ieee);
94a79942
LF
2155extern void rtllib_wake_all_queues(struct rtllib_device *ieee);
2156extern void rtllib_stop_all_queues(struct rtllib_device *ieee);
2157extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
2158extern void rtllib_start_send_beacons(struct rtllib_device *ieee);
2159extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
8567829a
LF
2160extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee,
2161 struct iw_point *p, u8 is_mesh);
94a79942
LF
2162
2163extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2164extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
2165
8567829a
LF
2166extern void softmac_mgmt_xmit(struct sk_buff *skb,
2167 struct rtllib_device *ieee);
2168extern u16 rtllib_query_seqnum(struct rtllib_device *ieee,
2169 struct sk_buff *skb, u8 *dst);
94a79942
LF
2170extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
2171
94a79942
LF
2172/* rtllib_softmac_wx.c */
2173
2174extern int rtllib_wx_get_wap(struct rtllib_device *ieee,
8567829a
LF
2175 struct iw_request_info *info,
2176 union iwreq_data *wrqu, char *ext);
94a79942
LF
2177
2178extern int rtllib_wx_set_wap(struct rtllib_device *ieee,
8567829a
LF
2179 struct iw_request_info *info,
2180 union iwreq_data *awrq,
2181 char *extra);
94a79942 2182
8567829a
LF
2183extern int rtllib_wx_get_essid(struct rtllib_device *ieee,
2184 struct iw_request_info *a,
2185 union iwreq_data *wrqu, char *b);
94a79942
LF
2186
2187extern int rtllib_wx_set_rate(struct rtllib_device *ieee,
8567829a
LF
2188 struct iw_request_info *info,
2189 union iwreq_data *wrqu, char *extra);
94a79942
LF
2190
2191extern int rtllib_wx_get_rate(struct rtllib_device *ieee,
8567829a
LF
2192 struct iw_request_info *info,
2193 union iwreq_data *wrqu, char *extra);
94a79942 2194
8567829a
LF
2195extern int rtllib_wx_set_mode(struct rtllib_device *ieee,
2196 struct iw_request_info *a,
2197 union iwreq_data *wrqu, char *b);
94a79942 2198
8567829a
LF
2199extern int rtllib_wx_set_scan(struct rtllib_device *ieee,
2200 struct iw_request_info *a,
2201 union iwreq_data *wrqu, char *b);
94a79942
LF
2202
2203extern int rtllib_wx_set_essid(struct rtllib_device *ieee,
2204 struct iw_request_info *a,
2205 union iwreq_data *wrqu, char *extra);
2206
8567829a
LF
2207extern int rtllib_wx_get_mode(struct rtllib_device *ieee,
2208 struct iw_request_info *a,
2209 union iwreq_data *wrqu, char *b);
94a79942 2210
8567829a
LF
2211extern int rtllib_wx_set_freq(struct rtllib_device *ieee,
2212 struct iw_request_info *a,
2213 union iwreq_data *wrqu, char *b);
94a79942 2214
8567829a
LF
2215extern int rtllib_wx_get_freq(struct rtllib_device *ieee,
2216 struct iw_request_info *a,
2217 union iwreq_data *wrqu, char *b);
94a79942
LF
2218extern void rtllib_wx_sync_scan_wq(void *data);
2219
2220extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
2221 struct iw_request_info *info,
2222 union iwreq_data *wrqu, char *extra);
2223
2224extern int rtllib_wx_get_name(struct rtllib_device *ieee,
2225 struct iw_request_info *info,
2226 union iwreq_data *wrqu, char *extra);
2227
2228extern int rtllib_wx_set_power(struct rtllib_device *ieee,
2229 struct iw_request_info *info,
2230 union iwreq_data *wrqu, char *extra);
2231
2232extern int rtllib_wx_get_power(struct rtllib_device *ieee,
2233 struct iw_request_info *info,
2234 union iwreq_data *wrqu, char *extra);
2235
2236extern int rtllib_wx_set_rts(struct rtllib_device *ieee,
2237 struct iw_request_info *info,
2238 union iwreq_data *wrqu, char *extra);
2239
2240extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
2241 struct iw_request_info *info,
2242 union iwreq_data *wrqu, char *extra);
2243#define MAX_RECEIVE_BUFFER_SIZE 9100
8567829a
LF
2244
2245void HTSetConnectBwMode(struct rtllib_device *ieee,
2246 enum ht_channel_width Bandwidth,
2247 enum ht_extchnl_offset Offset);
2248extern void HTUpdateDefaultSetting(struct rtllib_device *ieee);
2249extern void HTConstructCapabilityElement(struct rtllib_device *ieee,
2250 u8 *posHTCap, u8 *len,
2251 u8 isEncrypt, bool bAssoc);
2252extern void HTConstructInfoElement(struct rtllib_device *ieee,
2253 u8 *posHTInfo, u8 *len, u8 isEncrypt);
2254extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee,
a0711c4d 2255 u8 *posRT2RTAgg, u8 *len);
94a79942 2256extern void HTOnAssocRsp(struct rtllib_device *ieee);
8567829a 2257extern void HTInitializeHTInfo(struct rtllib_device *ieee);
a15e76ad 2258extern void HTInitializeBssDesc(struct bss_ht *pBssHT);
8567829a
LF
2259extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
2260 struct rtllib_network *pNetwork);
976d5341
SM
2261extern void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
2262 struct rtllib_network *pNetwork);
8567829a
LF
2263extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
2264 u8 *pMCSFilter);
94a79942 2265extern u8 MCS_FILTER_ALL[];
dc986e3e 2266extern u16 MCS_DATA_RATE[2][2][77];
8567829a 2267extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
7796d93e 2268extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
8567829a 2269extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
8567829a
LF
2270extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
2271extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
2272extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
2273extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
2274extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
2275extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
2276 u8 Policy, u8 bOverwritePending);
2277extern void TsInitDelBA(struct rtllib_device *ieee,
2278 struct ts_common_info *pTsCommonInfo,
2279 enum tr_select TxRxSelect);
94a79942
LF
2280extern void BaSetupTimeOut(unsigned long data);
2281extern void TxBaInactTimeout(unsigned long data);
2282extern void RxBaInactTimeout(unsigned long data);
8567829a 2283extern void ResetBaEntry(struct ba_record *pBA);
94a79942 2284extern bool GetTs(
8567829a
LF
2285 struct rtllib_device *ieee,
2286 struct ts_common_info **ppTS,
2287 u8 *Addr,
2288 u8 TID,
2289 enum tr_select TxRxSelect,
2290 bool bAddNewTs
2291);
94a79942 2292extern void TSInitialize(struct rtllib_device *ieee);
8567829a
LF
2293extern void TsStartAddBaProcess(struct rtllib_device *ieee,
2294 struct tx_ts_record *pTxTS);
2295extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
2296extern void RemoveAllTS(struct rtllib_device *ieee);
94a79942
LF
2297void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2298
2299extern const long rtllib_wlan_frequencies[];
2300
8567829a
LF
2301static inline const char *escape_essid(const char *essid, u8 essid_len)
2302{
94a79942 2303 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
94a79942
LF
2304
2305 if (rtllib_is_empty_essid(essid, essid_len)) {
2306 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2307 return escaped;
2308 }
2309
50d5e53d 2310 snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
94a79942
LF
2311 return escaped;
2312}
2313
94a79942 2314/* fun with the built-in rtllib stack... */
8567829a 2315bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
94a79942
LF
2316
2317
2318/* For the function is more related to hardware setting, it's better to use the
2319 * ieee handler to refer to it.
2320 */
2321extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
8567829a
LF
2322extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
2323 struct rx_ts_record *pTS);
94a79942
LF
2324extern int rtllib_parse_info_param(struct rtllib_device *ieee,
2325 struct rtllib_info_element *info_element,
2326 u16 length,
2327 struct rtllib_network *network,
2328 struct rtllib_rx_stats *stats);
2329
8567829a
LF
2330void rtllib_indicate_packets(struct rtllib_device *ieee,
2331 struct rtllib_rxb **prxbIndicateArray, u8 index);
2332extern u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
2333 u8 *pOperateMCS);
2334extern void HTUseDefaultSetting(struct rtllib_device *ieee);
94a79942
LF
2335#define RT_ASOC_RETRY_LIMIT 5
2336u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
2337extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
94a79942
LF
2338#define SEM_DOWN_IEEE_WX(psem) down(psem)
2339#define SEM_UP_IEEE_WX(psem) up(psem)
3b148be0 2340
94a79942 2341#endif /* RTLLIB_H */