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