]> Git Repo - linux.git/blob - drivers/staging/rtl8192e/rtllib.h
md: fix missing flush of sync_work
[linux.git] / drivers / staging / rtl8192e / rtllib.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Merged with mainline rtllib.h in Aug 2004.  Original ieee802_11
4  * remains copyright by the original authors
5  *
6  * Portions of the merged code are based on Host AP (software wireless
7  * LAN access point) driver for Intersil Prism2/2.5/3.
8  *
9  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10  * <[email protected]>
11  * Copyright (c) 2002-2003, Jouni Malinen <[email protected]>
12  *
13  * Adaption to a generic IEEE 802.11 stack by James Ketrenos
14  * <[email protected]>
15  * Copyright (c) 2004, Intel Corporation
16  *
17  * Modified for Realtek's wi-fi cards by Andrea Merello
18  * <[email protected]>
19  */
20 #ifndef RTLLIB_H
21 #define RTLLIB_H
22 #include <linux/if_ether.h> /* ETH_ALEN */
23 #include <linux/kernel.h>   /* ARRAY_SIZE */
24 #include <linux/module.h>
25 #include <linux/interrupt.h>
26 #include <linux/jiffies.h>
27 #include <linux/timer.h>
28 #include <linux/sched.h>
29 #include <linux/mutex.h>
30
31 #include <linux/delay.h>
32 #include <linux/wireless.h>
33
34 #include "rtl819x_HT.h"
35 #include "rtl819x_BA.h"
36 #include "rtl819x_TS.h"
37
38 #include <linux/netdevice.h>
39 #include <linux/if_arp.h> /* ARPHRD_ETHER */
40 #include <net/cfg80211.h>
41 #include <net/lib80211.h>
42
43 #define MAX_PRECMD_CNT 16
44 #define MAX_RFDEPENDCMD_CNT 16
45 #define MAX_POSTCMD_CNT 16
46
47 #ifndef WIRELESS_SPY
48 #define WIRELESS_SPY
49 #endif
50 #include <net/iw_handler.h>
51
52 #ifndef IW_MODE_MONITOR
53 #define IW_MODE_MONITOR 6
54 #endif
55
56 #ifndef IWEVCUSTOM
57 #define IWEVCUSTOM 0x8c02
58 #endif
59
60 #ifndef IW_CUSTOM_MAX
61 /* Max number of char in custom event - use multiple of them if needed */
62 #define IW_CUSTOM_MAX   256     /* In bytes */
63 #endif
64
65 #define container_of_dwork_rsl(x, y, z)                         \
66         container_of(to_delayed_work(x), y, z)
67
68 static inline void *netdev_priv_rsl(struct net_device *dev)
69 {
70         return netdev_priv(dev);
71 }
72
73 #define KEY_TYPE_NA             0x0
74 #define KEY_TYPE_WEP40          0x1
75 #define KEY_TYPE_TKIP           0x2
76 #define KEY_TYPE_CCMP           0x4
77 #define KEY_TYPE_WEP104         0x5
78 /* added for rtl819x tx procedure */
79 #define MAX_QUEUE_SIZE          0x10
80
81 #define BK_QUEUE                               0
82 #define BE_QUEUE                               1
83 #define VI_QUEUE                               2
84 #define VO_QUEUE                               3
85 #define HCCA_QUEUE                           4
86 #define TXCMD_QUEUE                         5
87 #define MGNT_QUEUE                           6
88 #define HIGH_QUEUE                           7
89 #define BEACON_QUEUE                       8
90
91 #define IE_CISCO_FLAG_POSITION          0x08
92 #define SUPPORT_CKIP_MIC                        0x08
93 #define SUPPORT_CKIP_PK                 0x10
94 #define RT_RF_OFF_LEVL_HALT_NIC         BIT(3)
95 #define RT_IN_PS_LEVEL(psc, _PS_FLAG)           \
96         ((psc->CurPsLevel & _PS_FLAG) ? true : false)
97 #define RT_CLEAR_PS_LEVEL(psc, _PS_FLAG)        \
98         (psc->CurPsLevel &= (~(_PS_FLAG)))
99
100 /* defined for skb cb field */
101 /* At most 28 byte */
102 struct cb_desc {
103         /* Tx Desc Related flags (8-9) */
104         u8 bLastIniPkt:1;
105         u8 bCmdOrInit:1;
106         u8 bFirstSeg:1;
107         u8 bLastSeg:1;
108         u8 bEncrypt:1;
109         u8 tx_dis_rate_fallback:1;
110         u8 tx_use_drv_assinged_rate:1;
111         u8 bHwSec:1;
112
113         u8 nStuckCount;
114
115         /* Tx Firmware Related flags (10-11)*/
116         u8 bCTSEnable:1;
117         u8 bRTSEnable:1;
118         u8 bUseShortGI:1;
119         u8 bUseShortPreamble:1;
120         u8 bTxEnableFwCalcDur:1;
121         u8 bAMPDUEnable:1;
122         u8 bRTSSTBC:1;
123         u8 RTSSC:1;
124
125         u8 bRTSBW:1;
126         u8 bPacketBW:1;
127         u8 bRTSUseShortPreamble:1;
128         u8 bRTSUseShortGI:1;
129         u8 bMulticast:1;
130         u8 bBroadcast:1;
131         u8 drv_agg_enable:1;
132         u8 reserved2:1;
133
134         /* Tx Desc related element(12-19) */
135         u8 rata_index;
136         u8 queue_index;
137         u16 txbuf_size;
138         u8 ratr_index;
139         u8 bAMSDU:1;
140         u8 bFromAggrQ:1;
141         u8 reserved6:6;
142         u8 macId;
143         u8 priority;
144
145         /* Tx firmware related element(20-27) */
146         u8 data_rate;
147         u8 rts_rate;
148         u8 ampdu_factor;
149         u8 ampdu_density;
150         u8 DrvAggrNum;
151         u8 bdhcp;
152         u16 pkt_size;
153         u8 bIsSpecialDataFrame;
154
155         u8 bBTTxPacket;
156         u8 bIsBTProbRsp;
157 };
158
159 enum sw_chnl_cmd_id {
160         CmdID_End,
161         CmdID_SetTxPowerLevel,
162         CmdID_BBRegWrite10,
163         CmdID_WritePortUlong,
164         CmdID_WritePortUshort,
165         CmdID_WritePortUchar,
166         CmdID_RF_WriteReg,
167 };
168
169 struct sw_chnl_cmd {
170         enum sw_chnl_cmd_id CmdID;
171         u32                     Para1;
172         u32                     Para2;
173         u32                     msDelay;
174 };
175
176 /*--------------------------Define -------------------------------------------*/
177 #define MGN_1M            0x02
178 #define MGN_2M            0x04
179 #define MGN_5_5M                0x0b
180 #define MGN_11M          0x16
181
182 #define MGN_6M            0x0c
183 #define MGN_9M            0x12
184 #define MGN_12M          0x18
185 #define MGN_18M          0x24
186 #define MGN_24M          0x30
187 #define MGN_36M          0x48
188 #define MGN_48M          0x60
189 #define MGN_54M          0x6c
190
191 #define MGN_MCS0                0x80
192 #define MGN_MCS1                0x81
193 #define MGN_MCS2                0x82
194 #define MGN_MCS3                0x83
195 #define MGN_MCS4                0x84
196 #define MGN_MCS5                0x85
197 #define MGN_MCS6                0x86
198 #define MGN_MCS7                0x87
199 #define MGN_MCS8                0x88
200 #define MGN_MCS9                0x89
201 #define MGN_MCS10              0x8a
202 #define MGN_MCS11              0x8b
203 #define MGN_MCS12              0x8c
204 #define MGN_MCS13              0x8d
205 #define MGN_MCS14              0x8e
206 #define MGN_MCS15              0x8f
207
208 enum hw_variables {
209         HW_VAR_ETHER_ADDR,
210         HW_VAR_MULTICAST_REG,
211         HW_VAR_BASIC_RATE,
212         HW_VAR_BSSID,
213         HW_VAR_MEDIA_STATUS,
214         HW_VAR_SECURITY_CONF,
215         HW_VAR_BEACON_INTERVAL,
216         HW_VAR_ATIM_WINDOW,
217         HW_VAR_LISTEN_INTERVAL,
218         HW_VAR_CS_COUNTER,
219         HW_VAR_DEFAULTKEY0,
220         HW_VAR_DEFAULTKEY1,
221         HW_VAR_DEFAULTKEY2,
222         HW_VAR_DEFAULTKEY3,
223         HW_VAR_SIFS,
224         HW_VAR_DIFS,
225         HW_VAR_EIFS,
226         HW_VAR_SLOT_TIME,
227         HW_VAR_ACK_PREAMBLE,
228         HW_VAR_CW_CONFIG,
229         HW_VAR_CW_VALUES,
230         HW_VAR_RATE_FALLBACK_CONTROL,
231         HW_VAR_CONTENTION_WINDOW,
232         HW_VAR_RETRY_COUNT,
233         HW_VAR_TR_SWITCH,
234         HW_VAR_COMMAND,
235         HW_VAR_WPA_CONFIG,
236         HW_VAR_AMPDU_MIN_SPACE,
237         HW_VAR_SHORTGI_DENSITY,
238         HW_VAR_AMPDU_FACTOR,
239         HW_VAR_MCS_RATE_AVAILABLE,
240         HW_VAR_AC_PARAM,
241         HW_VAR_ACM_CTRL,
242         HW_VAR_DIS_Req_Qsize,
243         HW_VAR_CCX_CHNL_LOAD,
244         HW_VAR_CCX_NOISE_HISTOGRAM,
245         HW_VAR_CCX_CLM_NHM,
246         HW_VAR_TxOPLimit,
247         HW_VAR_TURBO_MODE,
248         HW_VAR_RF_STATE,
249         HW_VAR_RF_OFF_BY_HW,
250         HW_VAR_BUS_SPEED,
251         HW_VAR_SET_DEV_POWER,
252
253         HW_VAR_RCR,
254         HW_VAR_RATR_0,
255         HW_VAR_RRSR,
256         HW_VAR_CPU_RST,
257         HW_VAR_CECHK_BSSID,
258         HW_VAR_LBK_MODE,
259         HW_VAR_AES_11N_FIX,
260         HW_VAR_USB_RX_AGGR,
261         HW_VAR_USER_CONTROL_TURBO_MODE,
262         HW_VAR_RETRY_LIMIT,
263         HW_VAR_INIT_TX_RATE,
264         HW_VAR_TX_RATE_REG,
265         HW_VAR_EFUSE_USAGE,
266         HW_VAR_EFUSE_BYTES,
267         HW_VAR_AUTOLOAD_STATUS,
268         HW_VAR_RF_2R_DISABLE,
269         HW_VAR_SET_RPWM,
270         HW_VAR_H2C_FW_PWRMODE,
271         HW_VAR_H2C_FW_JOINBSSRPT,
272         HW_VAR_1X1_RECV_COMBINE,
273         HW_VAR_STOP_SEND_BEACON,
274         HW_VAR_TSF_TIMER,
275         HW_VAR_IO_CMD,
276
277         HW_VAR_RF_RECOVERY,
278         HW_VAR_H2C_FW_UPDATE_GTK,
279         HW_VAR_WF_MASK,
280         HW_VAR_WF_CRC,
281         HW_VAR_WF_IS_MAC_ADDR,
282         HW_VAR_H2C_FW_OFFLOAD,
283         HW_VAR_RESET_WFCRC,
284
285         HW_VAR_HANDLE_FW_C2H,
286         HW_VAR_DL_FW_RSVD_PAGE,
287         HW_VAR_AID,
288         HW_VAR_HW_SEQ_ENABLE,
289         HW_VAR_CORRECT_TSF,
290         HW_VAR_BCN_VALID,
291         HW_VAR_FWLPS_RF_ON,
292         HW_VAR_DUAL_TSF_RST,
293         HW_VAR_SWITCH_EPHY_WoWLAN,
294         HW_VAR_INT_MIGRATION,
295         HW_VAR_INT_AC,
296         HW_VAR_RF_TIMING,
297 };
298
299 enum rt_op_mode {
300         RT_OP_MODE_AP,
301         RT_OP_MODE_INFRASTRUCTURE,
302         RT_OP_MODE_IBSS,
303         RT_OP_MODE_NO_LINK,
304 };
305
306 #define aSifsTime                                               \
307          ((priv->rtllib->current_network.mode == WIRELESS_MODE_N_24G) ? 16 : 10)
308
309 #define MGMT_QUEUE_NUM 5
310
311 #define MAX_IE_LEN  0xff
312
313 #define msleep_interruptible_rsl  msleep_interruptible
314
315 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
316  * 6.2.1.1.2.
317  *
318  * The figure in section 7.1.2 suggests a body size of up to 2312
319  * bytes is allowed, which is a bit confusing, I suspect this
320  * represents the 2304 bytes of real data, plus a possible 8 bytes of
321  * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
322  */
323 #define RTLLIB_1ADDR_LEN 10
324 #define RTLLIB_2ADDR_LEN 16
325 #define RTLLIB_3ADDR_LEN 24
326 #define RTLLIB_4ADDR_LEN 30
327 #define RTLLIB_FCS_LEN    4
328
329 #define RTLLIB_SKBBUFFER_SIZE 2500
330
331 #define MIN_FRAG_THRESHOLD     256U
332 #define MAX_FRAG_THRESHOLD     2346U
333
334 #define RTLLIB_FTYPE_MGMT               0x0000
335 #define RTLLIB_FTYPE_CTL                0x0004
336 #define RTLLIB_FTYPE_DATA               0x0008
337
338 #define RTLLIB_SCTL_FRAG                0x000F
339 #define RTLLIB_SCTL_SEQ         0xFFF0
340
341 /* QOS control */
342 #define RTLLIB_QCTL_TID       0x000F
343
344 #define FC_QOS_BIT                                      BIT(7)
345 #define IsDataFrame(pdu)        (((pdu[0] & 0x0C) == 0x08) ? true : false)
346 #define IsLegacyDataFrame(pdu)  (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
347 #define IsQoSDataFrame(pframe)                  \
348         ((*(u16 *)pframe&(IEEE80211_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) ==       \
349         (IEEE80211_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
350 #define Frame_Order(pframe)     (*(u16 *)pframe&IEEE80211_FCTL_ORDER)
351 #define SN_LESS(a, b)           (((a-b)&0x800) != 0)
352 #define SN_EQUAL(a, b)  (a == b)
353 #define MAX_DEV_ADDR_SIZE 8
354
355 enum act_category {
356         ACT_CAT_QOS = 1,
357         ACT_CAT_DLS = 2,
358         ACT_CAT_BA  = 3,
359         ACT_CAT_HT  = 7,
360         ACT_CAT_WMM = 17,
361 };
362
363 enum ba_action {
364         ACT_ADDBAREQ = 0,
365         ACT_ADDBARSP = 1,
366         ACT_DELBA    = 2,
367 };
368
369 enum init_gain_op_type {
370         IG_Backup = 0,
371         IG_Restore,
372         IG_Max
373 };
374
375 enum wireless_mode {
376         WIRELESS_MODE_UNKNOWN = 0x00,
377         WIRELESS_MODE_A = 0x01,
378         WIRELESS_MODE_B = 0x02,
379         WIRELESS_MODE_G = 0x04,
380         WIRELESS_MODE_AUTO = 0x08,
381         WIRELESS_MODE_N_24G = 0x10,
382 };
383
384 #ifndef ETH_P_PAE
385 #define ETH_P_PAE       0x888E          /* Port Access Entity (IEEE 802.1X) */
386 #define ETH_P_IP        0x0800          /* Internet Protocol packet     */
387 #define ETH_P_ARP       0x0806          /* Address Resolution packet    */
388 #endif /* ETH_P_PAE */
389
390 #ifndef ETH_P_80211_RAW
391 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
392 #endif
393
394 /* IEEE 802.11 defines */
395
396 #define P80211_OUI_LEN 3
397
398 struct rtllib_snap_hdr {
399         u8    dsap;   /* always 0xAA */
400         u8    ssap;   /* always 0xAA */
401         u8    ctrl;   /* always 0x03 */
402         u8    oui[P80211_OUI_LEN];    /* organizational universal id */
403
404 } __packed;
405
406 enum _REG_PREAMBLE_MODE {
407         PREAMBLE_LONG = 1,
408         PREAMBLE_AUTO = 2,
409         PREAMBLE_SHORT = 3,
410 };
411
412 #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
413
414 #define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
415 #define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
416 #define WLAN_FC_MORE_DATA(fc) ((fc) & IEEE80211_FCTL_MOREDATA)
417
418 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
419 #define WLAN_GET_SEQ_SEQ(seq)  (((seq) & RTLLIB_SCTL_SEQ) >> 4)
420
421 /* Authentication algorithms */
422 #define WLAN_AUTH_OPEN 0
423 #define WLAN_AUTH_SHARED_KEY 1
424 #define WLAN_AUTH_LEAP 128
425
426 #define WLAN_CAPABILITY_ESS (1<<0)
427 #define WLAN_CAPABILITY_IBSS (1<<1)
428 #define WLAN_CAPABILITY_PRIVACY (1<<4)
429 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
430 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
431
432 #define RTLLIB_STATMASK_SIGNAL (1<<0)
433 #define RTLLIB_STATMASK_RSSI (1<<1)
434 #define RTLLIB_STATMASK_NOISE (1<<2)
435 #define RTLLIB_STATMASK_WEMASK 0x7
436
437 #define RTLLIB_CCK_MODULATION    (1<<0)
438 #define RTLLIB_OFDM_MODULATION   (1<<1)
439
440 #define RTLLIB_CCK_RATE_LEN             4
441 #define RTLLIB_CCK_RATE_1MB                     0x02
442 #define RTLLIB_CCK_RATE_2MB                     0x04
443 #define RTLLIB_CCK_RATE_5MB                     0x0B
444 #define RTLLIB_CCK_RATE_11MB                    0x16
445 #define RTLLIB_OFDM_RATE_LEN            8
446 #define RTLLIB_OFDM_RATE_6MB                    0x0C
447 #define RTLLIB_OFDM_RATE_9MB                    0x12
448 #define RTLLIB_OFDM_RATE_12MB           0x18
449 #define RTLLIB_OFDM_RATE_18MB           0x24
450 #define RTLLIB_OFDM_RATE_24MB           0x30
451 #define RTLLIB_OFDM_RATE_36MB           0x48
452 #define RTLLIB_OFDM_RATE_48MB           0x60
453 #define RTLLIB_OFDM_RATE_54MB           0x6C
454 #define RTLLIB_BASIC_RATE_MASK          0x80
455
456 /* this is stolen and modified from the madwifi driver*/
457 #define RTLLIB_FC0_TYPE_MASK            0x0c
458 #define RTLLIB_FC0_TYPE_DATA            0x08
459 #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
460 #define RTLLIB_FC0_SUBTYPE_QOS  0x80
461
462 #define RTLLIB_QOS_HAS_SEQ(fc) \
463         (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
464          (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
465
466 /* this is stolen from ipw2200 driver */
467 #define IEEE_IBSS_MAC_HASH_SIZE 31
468
469 /* NOTE: This data is for statistical purposes; not all hardware provides this
470  *       information for frames received.  Not setting these will not cause
471  *       any adverse affects.
472  */
473 struct rtllib_rx_stats {
474         u64 mac_time;
475         s8  rssi;
476         u8  signal;
477         u8  noise;
478         u16 rate; /* in 100 kbps */
479         u8  control;
480         u8  mask;
481         u16 len;
482         u64 tsf;
483         u32 beacon_time;
484         u8  nic_type;
485         u16 Length;
486         u8  SignalQuality;
487         s32 RecvSignalPower;
488         s8  RxPower;
489         u8  SignalStrength;
490         u16 bHwError:1;
491         u16 bCRC:1;
492         u16 bICV:1;
493         u16 bShortPreamble:1;
494         u16 Antenna:1;
495         u16 Decrypted:1;
496         u16 Wakeup:1;
497         u16 Reserved0:1;
498         u8  AGC;
499         u32 TimeStampLow;
500         u32 TimeStampHigh;
501         bool bShift;
502         bool bIsQosData;
503
504         u8    RxDrvInfoSize;
505         u8    RxBufShift;
506         bool  bIsAMPDU;
507         bool  bFirstMPDU;
508         bool  bContainHTC;
509         bool  RxIs40MHzPacket;
510         u32   RxPWDBAll;
511         u8    RxMIMOSignalStrength[4];
512         s8    RxMIMOSignalQuality[2];
513         bool  bPacketMatchBSSID;
514         bool  bIsCCK;
515         bool  bPacketToSelf;
516         u16    packetlength;
517         u16    fraglength;
518         u16    fragoffset;
519         u16    ntotalfrag;
520         bool   bPacketBeacon;
521         bool   bToSelfBA;
522         u16    Seq_Num;
523 };
524
525 /* IEEE 802.11 requires that STA supports concurrent reception of at least
526  * three fragmented frames. This define can be increased to support more
527  * concurrent frames, but it should be noted that each entry can consume about
528  * 2 kB of RAM and increasing cache size will slow down frame reassembly.
529  */
530 #define RTLLIB_FRAG_CACHE_LEN 4
531
532 struct rtllib_frag_entry {
533         unsigned long first_frag_time;
534         unsigned int seq;
535         unsigned int last_frag;
536         struct sk_buff *skb;
537         u8 src_addr[ETH_ALEN];
538         u8 dst_addr[ETH_ALEN];
539 };
540
541 struct rtllib_device;
542
543 #define SEC_ACTIVE_KEY    (1<<4)
544 #define SEC_AUTH_MODE     (1<<5)
545 #define SEC_UNICAST_GROUP (1<<6)
546 #define SEC_LEVEL        (1<<7)
547 #define SEC_ENABLED       (1<<8)
548
549 #define SEC_LEVEL_0      0 /* None */
550 #define SEC_LEVEL_1      1 /* WEP 40 and 104 bit */
551 #define SEC_LEVEL_2      2 /* Level 1 + TKIP */
552 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
553 #define SEC_LEVEL_3      4 /* Level 2 + CCMP */
554
555 #define SEC_ALG_NONE            0
556 #define SEC_ALG_WEP             1
557 #define SEC_ALG_TKIP            2
558 #define SEC_ALG_CCMP            4
559
560 #define WEP_KEY_LEN             13
561 #define SCM_KEY_LEN             32
562
563 struct rtllib_security {
564         u16 active_key:2,
565             enabled:1,
566             auth_mode:2,
567             auth_algo:4,
568             unicast_uses_group:1,
569             encrypt:1;
570         u8 key_sizes[NUM_WEP_KEYS];
571         u8 keys[NUM_WEP_KEYS][SCM_KEY_LEN];
572         u8 level;
573         u16 flags;
574 } __packed;
575
576 /* 802.11 data frame from AP
577  *       ,-------------------------------------------------------------------.
578  * Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
579  *       |------|------|---------|---------|---------|------|---------|------|
580  * Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
581  *       |      | tion | (BSSID) |         |         | ence |  data   |      |
582  *       `-------------------------------------------------------------------'
583  * Total: 28-2340 bytes
584  */
585
586 /* Management Frame Information Element Types */
587 enum rtllib_mfie {
588         MFIE_TYPE_SSID = 0,
589         MFIE_TYPE_RATES = 1,
590         MFIE_TYPE_FH_SET = 2,
591         MFIE_TYPE_DS_SET = 3,
592         MFIE_TYPE_CF_SET = 4,
593         MFIE_TYPE_TIM = 5,
594         MFIE_TYPE_IBSS_SET = 6,
595         MFIE_TYPE_COUNTRY = 7,
596         MFIE_TYPE_HOP_PARAMS = 8,
597         MFIE_TYPE_HOP_TABLE = 9,
598         MFIE_TYPE_REQUEST = 10,
599         MFIE_TYPE_CHALLENGE = 16,
600         MFIE_TYPE_POWER_CONSTRAINT = 32,
601         MFIE_TYPE_POWER_CAPABILITY = 33,
602         MFIE_TYPE_TPC_REQUEST = 34,
603         MFIE_TYPE_TPC_REPORT = 35,
604         MFIE_TYPE_SUPP_CHANNELS = 36,
605         MFIE_TYPE_CSA = 37,
606         MFIE_TYPE_MEASURE_REQUEST = 38,
607         MFIE_TYPE_MEASURE_REPORT = 39,
608         MFIE_TYPE_QUIET = 40,
609         MFIE_TYPE_IBSS_DFS = 41,
610         MFIE_TYPE_ERP = 42,
611         MFIE_TYPE_HT_CAP = 45,
612         MFIE_TYPE_RSN = 48,
613         MFIE_TYPE_RATES_EX = 50,
614         MFIE_TYPE_HT_INFO = 61,
615         MFIE_TYPE_AIRONET = 133,
616         MFIE_TYPE_GENERIC = 221,
617         MFIE_TYPE_QOS_PARAMETER = 222,
618 };
619
620 /* Minimal header; can be used for passing 802.11 frames with sufficient
621  * information to determine what type of underlying data type is actually
622  * stored in the data.
623  */
624 struct rtllib_info_element {
625         u8 id;
626         u8 len;
627         u8 data[];
628 } __packed;
629
630 struct rtllib_authentication {
631         struct ieee80211_hdr_3addr header;
632         __le16 algorithm;
633         __le16 transaction;
634         __le16 status;
635         /*challenge*/
636         struct rtllib_info_element info_element[];
637 } __packed __aligned(2);
638
639 struct rtllib_disauth {
640         struct ieee80211_hdr_3addr header;
641         __le16 reason;
642 } __packed __aligned(2);
643
644 struct rtllib_disassoc {
645         struct ieee80211_hdr_3addr header;
646         __le16 reason;
647 } __packed __aligned(2);
648
649 struct rtllib_probe_request {
650         struct ieee80211_hdr_3addr header;
651         /* SSID, supported rates */
652         struct rtllib_info_element info_element[];
653 } __packed __aligned(2);
654
655 struct rtllib_probe_response {
656         struct ieee80211_hdr_3addr header;
657         u32 time_stamp[2];
658         __le16 beacon_interval;
659         __le16 capability;
660         /* SSID, supported rates, FH params, DS params,
661          * CF params, IBSS params, TIM (if beacon), RSN
662          */
663         struct rtllib_info_element info_element[];
664 } __packed __aligned(2);
665
666 /* Alias beacon for probe_response */
667 #define rtllib_beacon rtllib_probe_response
668
669 struct rtllib_assoc_request_frame {
670         struct ieee80211_hdr_3addr header;
671         __le16 capability;
672         __le16 listen_interval;
673         /* SSID, supported rates, RSN */
674         struct rtllib_info_element info_element[];
675 } __packed __aligned(2);
676
677 struct rtllib_assoc_response_frame {
678         struct ieee80211_hdr_3addr header;
679         __le16 capability;
680         __le16 status;
681         __le16 aid;
682         struct rtllib_info_element info_element[]; /* supported rates */
683 } __packed __aligned(2);
684
685 struct rtllib_txb {
686         u8 nr_frags;
687         u8 encrypted;
688         u8 queue_index;
689         u8 rts_included;
690         u16 reserved;
691         __le16 frag_size;
692         __le16 payload_size;
693         struct sk_buff *fragments[] __counted_by(nr_frags);
694 };
695
696 #define MAX_SUBFRAME_COUNT                64
697 struct rtllib_rxb {
698         u8 nr_subframes;
699         struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
700         u8 dst[ETH_ALEN];
701         u8 src[ETH_ALEN];
702 };
703
704 union frameqos {
705         u16 shortdata;
706         u8  chardata[2];
707         struct {
708                 u16 tid:4;
709                 u16 eosp:1;
710                 u16 ack_policy:2;
711                 u16 reserved:1;
712                 u16 txop:8;
713         } field;
714 };
715
716 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
717  * only use 8, and then use extended rates for the remaining supported
718  * rates.  Other APs, however, stick all of their supported rates on the
719  * main rates information element...
720  */
721 #define MAX_RATES_LENGTH                  ((u8)12)
722 #define MAX_RATES_EX_LENGTH            ((u8)16)
723 #define MAX_NETWORK_COUNT                 96
724
725 #define MAX_CHANNEL_NUMBER               161
726 #define RTLLIB_SOFTMAC_SCAN_TIME           100
727 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
728
729 #define MAX_WPA_IE_LEN 64
730 #define MAX_WZC_IE_LEN 256
731
732 #define NETWORK_EMPTY_ESSID (1<<0)
733 #define NETWORK_HAS_OFDM    (1<<1)
734 #define NETWORK_HAS_CCK     (1<<2)
735
736 /* QoS structure */
737 #define NETWORK_HAS_QOS_PARAMETERS      (1<<3)
738 #define NETWORK_HAS_QOS_INFORMATION     (1<<4)
739 #define NETWORK_HAS_QOS_MASK        (NETWORK_HAS_QOS_PARAMETERS | \
740                                          NETWORK_HAS_QOS_INFORMATION)
741 /* 802.11h */
742 #define NETWORK_HAS_ERP_VALUE      (1<<10)
743
744 #define QOS_QUEUE_NUM              4
745 #define QOS_OUI_LEN                  3
746 #define QOS_OUI_TYPE                2
747 #define QOS_ELEMENT_ID            221
748 #define QOS_OUI_INFO_SUB_TYPE      0
749 #define QOS_OUI_PARAM_SUB_TYPE    1
750 #define QOS_VERSION_1              1
751
752 struct rtllib_qos_information_element {
753         u8 elementID;
754         u8 length;
755         u8 qui[QOS_OUI_LEN];
756         u8 qui_type;
757         u8 qui_subtype;
758         u8 version;
759         u8 ac_info;
760 } __packed;
761
762 struct rtllib_qos_ac_parameter {
763         u8 aci_aifsn;
764         u8 ecw_min_max;
765         __le16 tx_op_limit;
766 } __packed;
767
768 struct rtllib_qos_parameter_info {
769         struct rtllib_qos_information_element info_element;
770         u8 reserved;
771         struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
772 } __packed;
773
774 struct rtllib_qos_parameters {
775         __le16 cw_min[QOS_QUEUE_NUM];
776         __le16 cw_max[QOS_QUEUE_NUM];
777         u8 aifs[QOS_QUEUE_NUM];
778         u8 flag[QOS_QUEUE_NUM];
779         __le16 tx_op_limit[QOS_QUEUE_NUM];
780 } __packed;
781
782 struct rtllib_qos_data {
783         struct rtllib_qos_parameters parameters;
784         unsigned int wmm_acm;
785         int active;
786         int supported;
787         u8 param_count;
788         u8 old_param_count;
789 };
790
791 struct rtllib_tim_parameters {
792         u8 tim_count;
793         u8 tim_period;
794 } __packed;
795
796 struct rtllib_wmm_ac_param {
797         u8 ac_aci_acm_aifsn;
798         u8 ac_ecwmin_ecwmax;
799         u16 ac_txop_limit;
800 };
801
802 enum eap_type {
803         EAP_PACKET = 0,
804         EAPOL_START,
805         EAPOL_LOGOFF,
806         EAPOL_KEY,
807         EAPOL_ENCAP_ASF_ALERT
808 };
809
810 static const char * const eap_types[] = {
811         [EAP_PACKET]            = "EAP-Packet",
812         [EAPOL_START]           = "EAPOL-Start",
813         [EAPOL_LOGOFF]          = "EAPOL-Logoff",
814         [EAPOL_KEY]             = "EAPOL-Key",
815         [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
816 };
817
818 static inline const char *eap_get_type(int type)
819 {
820         return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
821                  eap_types[type];
822 }
823
824 static inline u8 Frame_QoSTID(u8 *buf)
825 {
826         struct ieee80211_hdr_3addr *hdr;
827         u16 fc;
828
829         hdr = (struct ieee80211_hdr_3addr *)buf;
830         fc = le16_to_cpu(hdr->frame_control);
831         return (u8)((union frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) &&
832                     (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
833 }
834
835 struct eapol {
836         u8 snap[6];
837         u16 ethertype;
838         u8 version;
839         u8 type;
840         u16 length;
841 } __packed;
842
843 struct rtllib_softmac_stats {
844         unsigned int rx_ass_ok;
845         unsigned int rx_ass_err;
846         unsigned int rx_probe_rq;
847         unsigned int tx_probe_rs;
848         unsigned int tx_beacons;
849         unsigned int rx_auth_rq;
850         unsigned int rx_auth_rs_ok;
851         unsigned int rx_auth_rs_err;
852         unsigned int tx_auth_rq;
853         unsigned int no_auth_rs;
854         unsigned int no_ass_rs;
855         unsigned int tx_ass_rq;
856         unsigned int rx_ass_rq;
857         unsigned int tx_probe_rq;
858         unsigned int reassoc;
859         unsigned int swtxstop;
860         unsigned int swtxawake;
861         unsigned char CurrentShowTxate;
862         unsigned char last_packet_rate;
863         unsigned int txretrycount;
864 };
865
866 /* These are the data types that can make up management packets
867  *
868  * u16 auth_algorithm;
869  * u16 auth_sequence;
870  * u16 beacon_interval;
871  * u16 capability;
872  * u8 current_ap[ETH_ALEN];
873  * u16 listen_interval;
874  * struct {
875  *   u16 association_id:14, reserved:2;
876  * } __packed;
877  * u32 time_stamp[2];
878  * u16 reason;
879  * u16 status;
880  */
881
882 #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
883 #define RTLLIB_DEFAULT_BASIC_RATE 2
884
885 enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
886 #define MAX_SP_Len  (WMM_all_frame << 4)
887 #define RTLLIB_QOS_TID 0x0f
888 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
889
890 #define RTLLIB_DTIM_MBCAST 4
891 #define RTLLIB_DTIM_UCAST 2
892 #define RTLLIB_DTIM_VALID 1
893 #define RTLLIB_DTIM_INVALID 0
894
895 #define RTLLIB_PS_DISABLED 0
896 #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
897 #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
898
899 #define WME_AC_BK   0x00
900 #define WME_AC_BE   0x01
901 #define WME_AC_VI   0x02
902 #define WME_AC_VO   0x03
903 #define WME_AC_PRAM_LEN 16
904
905 #define MAX_RECEIVE_BUFFER_SIZE 9100
906
907 #define UP2AC(up) (                \
908         ((up) < 1) ? WME_AC_BE : \
909         ((up) < 3) ? WME_AC_BK : \
910         ((up) < 4) ? WME_AC_BE : \
911         ((up) < 6) ? WME_AC_VI : \
912         WME_AC_VO)
913
914 #define ETHERNET_HEADER_SIZE    14      /* length of two Ethernet address
915                                          * plus ether type
916                                          */
917
918 enum erp_t {
919         ERP_NonERPpresent       = 0x01,
920         ERP_UseProtection       = 0x02,
921         ERP_BarkerPreambleMode = 0x04,
922 };
923
924 struct rtllib_network {
925         /* These entries are used to identify a unique network */
926         u8 bssid[ETH_ALEN];
927         u8 channel;
928         /* Ensure null-terminated for any debug msgs */
929         u8 ssid[IW_ESSID_MAX_SIZE + 1];
930         u8 ssid_len;
931         u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
932         u8 hidden_ssid_len;
933         struct rtllib_qos_data qos_data;
934
935         bool    bWithAironetIE;
936         bool    bCkipSupported;
937         bool    bCcxRmEnable;
938         u8      CcxRmState[2];
939         bool    bMBssidValid;
940         u8      MBssidMask;
941         u8      MBssid[ETH_ALEN];
942         bool    bWithCcxVerNum;
943         u8      BssCcxVerNumber;
944         /* These are network statistics */
945         struct rtllib_rx_stats stats;
946         u16 capability;
947         u8  rates[MAX_RATES_LENGTH];
948         u8  rates_len;
949         u8  rates_ex[MAX_RATES_EX_LENGTH];
950         u8  rates_ex_len;
951         unsigned long last_scanned;
952         u8  mode;
953         u32 flags;
954         u32 time_stamp[2];
955         u16 beacon_interval;
956         u16 listen_interval;
957         u16 atim_window;
958         u8  erp_value;
959         u8  wpa_ie[MAX_WPA_IE_LEN];
960         size_t wpa_ie_len;
961         u8  rsn_ie[MAX_WPA_IE_LEN];
962         size_t rsn_ie_len;
963         u8  wzc_ie[MAX_WZC_IE_LEN];
964         size_t wzc_ie_len;
965
966         struct rtllib_tim_parameters tim;
967         u8  dtim_period;
968         u8  dtim_data;
969         u64 last_dtim_sta_time;
970
971         u8 wmm_info;
972         struct rtllib_wmm_ac_param wmm_param[4];
973         u8 Turbo_Enable;
974         u16 CountryIeLen;
975         u8 CountryIeBuf[MAX_IE_LEN];
976         struct bss_ht bssht;
977         bool broadcom_cap_exist;
978         bool realtek_cap_exit;
979         bool marvell_cap_exist;
980         bool ralink_cap_exist;
981         bool atheros_cap_exist;
982         bool cisco_cap_exist;
983         bool airgo_cap_exist;
984         bool unknown_cap_exist;
985         bool    berp_info_valid;
986         bool buseprotection;
987         u8 SignalStrength;
988         u8 RSSI;
989         struct list_head list;
990 };
991
992 enum rtl_link_state {
993         /* the card is not linked at all */
994         MAC80211_NOLINK = 0,
995
996         /* RTLLIB_ASSOCIATING* are for BSS client mode
997          * the driver shall not perform RX filtering unless
998          * the state is LINKED.
999          * The driver shall just check for the state LINKED and
1000          * defaults to NOLINK for ALL the other states (including
1001          * LINKED_SCANNING)
1002          */
1003
1004         /* the association procedure will start (wq scheduling)*/
1005         RTLLIB_ASSOCIATING,
1006         RTLLIB_ASSOCIATING_RETRY,
1007
1008         /* the association procedure is sending AUTH request*/
1009         RTLLIB_ASSOCIATING_AUTHENTICATING,
1010
1011         /* the association procedure has successfully authenticated
1012          * and is sending association request
1013          */
1014         RTLLIB_ASSOCIATING_AUTHENTICATED,
1015
1016         /* the link is ok. the card associated to a BSS or linked
1017          * to a ibss cell or acting as an AP and creating the bss
1018          */
1019         MAC80211_LINKED,
1020
1021         /* same as LINKED, but the driver shall apply RX filter
1022          * rules as we are in NO_LINK mode. As the card is still
1023          * logically linked, but it is doing a syncro site survey
1024          * then it will be back to LINKED state.
1025          */
1026         MAC80211_LINKED_SCANNING,
1027 };
1028
1029 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1030 #define DEFAULT_FTS 2346
1031
1032 #define CFG_RTLLIB_RESERVE_FCS (1<<0)
1033 #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
1034
1035 struct tx_pending {
1036         int frag;
1037         struct rtllib_txb *txb;
1038 };
1039
1040 struct bandwidth_autoswitch {
1041         long threshold_20Mhzto40Mhz;
1042         long    threshold_40Mhzto20Mhz;
1043         bool bforced_tx20Mhz;
1044         bool bautoswitch_enable;
1045 };
1046
1047 #define REORDER_WIN_SIZE        128
1048 #define REORDER_ENTRY_NUM       128
1049 struct rx_reorder_entry {
1050         struct list_head        List;
1051         u16                     SeqNum;
1052         struct rtllib_rxb *prxb;
1053 };
1054
1055 enum fsync_state {
1056         Default_Fsync,
1057         HW_Fsync,
1058         SW_Fsync
1059 };
1060
1061 enum ips_callback_function {
1062         IPS_CALLBACK_NONE = 0,
1063         IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
1064         IPS_CALLBACK_JOIN_REQUEST = 2,
1065 };
1066
1067 enum rt_rf_power_state {
1068         rf_on,
1069         rf_sleep,
1070         rf_off
1071 };
1072
1073 struct rt_pwr_save_ctrl {
1074         bool                            bSwRfProcessing;
1075         enum rt_rf_power_state eInactivePowerState;
1076         enum ips_callback_function ReturnPoint;
1077
1078         bool                            bLeisurePs;
1079         u8                              LpsIdleCount;
1080         u8                              LPSAwakeIntvl;
1081
1082         u32                             CurPsLevel;
1083 };
1084
1085 #define RT_RF_CHANGE_SOURCE u32
1086
1087 #define RF_CHANGE_BY_SW BIT(31)
1088 #define RF_CHANGE_BY_HW BIT(30)
1089 #define RF_CHANGE_BY_PS BIT(29)
1090 #define RF_CHANGE_BY_IPS BIT(28)
1091 #define RF_CHANGE_BY_INIT       0
1092
1093 enum country_code_type {
1094         COUNTRY_CODE_FCC = 0,
1095         COUNTRY_CODE_IC = 1,
1096         COUNTRY_CODE_ETSI = 2,
1097         COUNTRY_CODE_SPAIN = 3,
1098         COUNTRY_CODE_FRANCE = 4,
1099         COUNTRY_CODE_MKK = 5,
1100         COUNTRY_CODE_MKK1 = 6,
1101         COUNTRY_CODE_ISRAEL = 7,
1102         COUNTRY_CODE_TELEC = 8,
1103         COUNTRY_CODE_MIC = 9,
1104         COUNTRY_CODE_GLOBAL_DOMAIN = 10,
1105         COUNTRY_CODE_WORLD_WIDE_13 = 11,
1106         COUNTRY_CODE_TELEC_NETGEAR = 12,
1107         COUNTRY_CODE_MAX
1108 };
1109
1110 enum scan_op_backup_opt {
1111         SCAN_OPT_BACKUP = 0,
1112         SCAN_OPT_RESTORE,
1113         SCAN_OPT_MAX
1114 };
1115
1116 #define RT_MAX_LD_SLOT_NUM      10
1117 struct rt_link_detect {
1118         u32                             NumRecvBcnInPeriod;
1119         u32                             NumRecvDataInPeriod;
1120
1121         u32                             RxBcnNum[RT_MAX_LD_SLOT_NUM];
1122         u32                             RxDataNum[RT_MAX_LD_SLOT_NUM];
1123         u16                             SlotNum;
1124         u16                             SlotIndex;
1125
1126         u32                             NumTxOkInPeriod;
1127         u32                             NumRxOkInPeriod;
1128         u32                             NumRxUnicastOkInPeriod;
1129         bool                            bBusyTraffic;
1130         bool                            bHigherBusyTraffic;
1131         bool                            bHigherBusyRxTraffic;
1132 };
1133
1134 struct sw_cam_table {
1135         u8                              macaddr[ETH_ALEN];
1136         bool                            bused;
1137         u8                              key_buf[16];
1138         u16                             key_type;
1139         u8                              useDK;
1140         u8                              key_index;
1141
1142 };
1143
1144 #define   TOTAL_CAM_ENTRY                               32
1145 struct rate_adaptive {
1146         u8                              ratr_state;
1147         u16                             reserve;
1148
1149         u32                             high_rssi_thresh_for_ra;
1150         u32                             high2low_rssi_thresh_for_ra;
1151         u8                              low2high_rssi_thresh_for_ra40M;
1152         u32                             low_rssi_thresh_for_ra40M;
1153         u8                              low2high_rssi_thresh_for_ra20M;
1154         u32                             low_rssi_thresh_for_ra20M;
1155         u32                             upper_rssi_threshold_ratr;
1156         u32                             middle_rssi_threshold_ratr;
1157         u32                             low_rssi_threshold_ratr;
1158         u32                             low_rssi_threshold_ratr_40M;
1159         u32                             low_rssi_threshold_ratr_20M;
1160         u8                              ping_rssi_enable;
1161         u32                             ping_rssi_ratr;
1162         u32                             ping_rssi_thresh_for_ra;
1163         u8                              PreRATRState;
1164
1165 };
1166
1167 #define NUM_PMKID_CACHE         16
1168 struct rt_pmkid_list {
1169         u8 Bssid[ETH_ALEN];
1170         u8 PMKID[16];
1171         u8 SsidBuf[33];
1172         u8 bUsed;
1173 };
1174
1175 /*************** DRIVER STATUS   *****/
1176 #define STATUS_SCANNING                 0
1177 /*************** DRIVER STATUS   *****/
1178
1179 enum {
1180         LPS_IS_WAKE = 0,
1181         LPS_IS_SLEEP = 1,
1182         LPS_WAIT_NULL_DATA_SEND = 2,
1183 };
1184
1185 struct rtllib_device {
1186         struct pci_dev *pdev;
1187         struct net_device *dev;
1188         struct rtllib_security sec;
1189
1190         bool disable_mgnt_queue;
1191
1192         unsigned long status;
1193         u8      CntAfterLink;
1194
1195         enum rt_op_mode OpMode;
1196
1197         /* The last AssocReq/Resp IEs */
1198         u8 *assocreq_ies, *assocresp_ies;
1199         size_t assocreq_ies_len, assocresp_ies_len;
1200
1201         bool    bForcedBgMode;
1202
1203         u8 hwsec_active;
1204         bool is_roaming;
1205         bool ieee_up;
1206         bool cannot_notify;
1207         bool bSupportRemoteWakeUp;
1208         bool actscanning;
1209         bool FirstIe_InScan;
1210         bool be_scan_inprogress;
1211         bool beinretry;
1212         enum rt_rf_power_state rf_power_state;
1213         RT_RF_CHANGE_SOURCE rf_off_reason;
1214         bool is_set_key;
1215         bool wx_set_enc;
1216         struct rt_hi_throughput *ht_info;
1217
1218         spinlock_t reorder_spinlock;
1219         u8      reg_dot11ht_oper_rate_set[16];
1220         u8      reg_dot11tx_ht_oper_rate_set[16];
1221         u8      dot11ht_oper_rate_set[16];
1222         u8      reg_ht_supp_rate_set[16];
1223         u8      HTCurrentOperaRate;
1224         u8      HTHighestOperaRate;
1225         u8      tx_dis_rate_fallback;
1226         u8      tx_use_drv_assinged_rate;
1227         u8      bTxEnableFwCalcDur;
1228         atomic_t        atm_swbw;
1229
1230         struct list_head                Tx_TS_Admit_List;
1231         struct list_head                Tx_TS_Pending_List;
1232         struct list_head                Tx_TS_Unused_List;
1233         struct tx_ts_record TxTsRecord[TOTAL_TS_NUM];
1234         struct list_head                Rx_TS_Admit_List;
1235         struct list_head                Rx_TS_Pending_List;
1236         struct list_head                Rx_TS_Unused_List;
1237         struct rx_ts_record RxTsRecord[TOTAL_TS_NUM];
1238         struct rx_reorder_entry RxReorderEntry[128];
1239         struct list_head                RxReorder_Unused_List;
1240
1241         /* Bookkeeping structures */
1242         struct net_device_stats stats;
1243         struct rtllib_softmac_stats softmac_stats;
1244
1245         /* Probe / Beacon management */
1246         struct list_head network_free_list;
1247         struct list_head network_list;
1248         struct rtllib_network *networks;
1249         int scans;
1250         int scan_age;
1251
1252         int iw_mode; /* operating mode (IW_MODE_*) */
1253
1254         spinlock_t lock;
1255         spinlock_t wpax_suitlist_lock;
1256
1257         int tx_headroom; /* Set to size of any additional room needed at front
1258                           * of allocated Tx SKBs
1259                           */
1260         u32 config;
1261
1262         /* WEP and other encryption related settings at the device level */
1263         int open_wep; /* Set to 1 to allow unencrypted frames */
1264         int auth_mode;
1265         int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
1266                                  * WEP key changes
1267                                  */
1268
1269         int ieee802_1x; /* is IEEE 802.1X used */
1270
1271         /* WPA data */
1272         bool bHalfWirelessN24GMode;
1273         int wpa_enabled;
1274         int drop_unencrypted;
1275         int tkip_countermeasures;
1276         int privacy_invoked;
1277         size_t wpa_ie_len;
1278         u8 *wpa_ie;
1279         size_t wps_ie_len;
1280         u8 *wps_ie;
1281         u8 ap_mac_addr[ETH_ALEN];
1282         u16 pairwise_key_type;
1283         u16 group_key_type;
1284
1285         struct lib80211_crypt_info crypt_info;
1286
1287         struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY];
1288
1289         struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE];
1290
1291         /* Fragmentation structures */
1292         struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN];
1293         unsigned int frag_next_idx[17];
1294         u16 fts; /* Fragmentation Threshold */
1295 #define DEFAULT_RTS_THRESHOLD 2346U
1296 #define MIN_RTS_THRESHOLD 1
1297 #define MAX_RTS_THRESHOLD 2346U
1298         u16 rts; /* RTS threshold */
1299
1300         /* Association info */
1301         u8 bssid[ETH_ALEN];
1302
1303         /* This stores infos for the current network.
1304          * Either the network we are associated in INFRASTRUCTURE
1305          * or the network that we are creating in MASTER mode.
1306          * ad-hoc is a mixture ;-).
1307          * Note that in infrastructure mode, even when not associated,
1308          * fields bssid and essid may be valid (if wpa_set and essid_set
1309          * are true) as thy carry the value set by the user via iwconfig
1310          */
1311         struct rtllib_network current_network;
1312
1313         enum rtl_link_state link_state;
1314
1315         int mode;       /* A, B, G */
1316
1317         /* used for forcing the ibss workqueue to terminate
1318          * without wait for the syncro scan to terminate
1319          */
1320         short sync_scan_hurryup;
1321         u16 scan_watch_dog;
1322
1323         /* map of allowed channels. 0 is dummy */
1324         void *dot11d_info;
1325         bool global_domain;
1326         u8 active_channel_map[MAX_CHANNEL_NUMBER+1];
1327
1328         u8   bss_start_channel;
1329
1330         int rate;       /* current rate */
1331         int basic_rate;
1332
1333         /* this contains flags for selectively enable softmac support */
1334         u16 softmac_features;
1335
1336         /* if the sequence control field is not filled by HW */
1337         u16 seq_ctrl[5];
1338
1339         /* association procedure transaction sequence number */
1340         u16 associate_seq;
1341
1342         /* AID for RTXed association responses */
1343         u16 assoc_id;
1344
1345         /* power save mode related*/
1346         u8 ack_tx_to_ieee;
1347         short ps;
1348         short sta_sleep;
1349         int ps_timeout;
1350         int ps_period;
1351         struct work_struct ps_task;
1352         u64 ps_time;
1353         bool polling;
1354
1355         /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1356         short queue_stop;
1357         short scanning_continue;
1358         short proto_started;
1359         short proto_stoppping;
1360
1361         struct mutex wx_mutex;
1362         struct mutex scan_mutex;
1363         struct mutex ips_mutex;
1364
1365         spinlock_t mgmt_tx_lock;
1366         spinlock_t beacon_lock;
1367
1368         short beacon_txing;
1369
1370         short wap_set;
1371         short ssid_set;
1372
1373         /* set on initialization */
1374         unsigned int wmm_acm;
1375
1376         /* for discarding duplicated packets in IBSS */
1377         struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
1378
1379         /* for discarding duplicated packets in BSS */
1380         u16 last_rxseq_num[17]; /* rx seq previous per-tid */
1381         u16 last_rxfrag_num[17];/* tx frag previous per-tid */
1382         unsigned long last_packet_time[17];
1383
1384         /* for PS mode */
1385         unsigned long last_rx_ps_time;
1386         bool                    bAwakePktSent;
1387         u8                      LPSDelayCnt;
1388
1389         /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
1390         struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
1391         int mgmt_queue_head;
1392         int mgmt_queue_tail;
1393         u8 AsocRetryCount;
1394         struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
1395
1396         bool    bdynamic_txpower_enable;
1397
1398         bool bCTSToSelfEnable;
1399
1400         u32     fsync_time_interval;
1401         u32     fsync_rate_bitmap;
1402         u8      fsync_rssi_threshold;
1403         bool    bfsync_enable;
1404
1405         u8      fsync_multiple_timeinterval;
1406         u32     fsync_firstdiff_ratethreshold;
1407         u32     fsync_seconddiff_ratethreshold;
1408         enum fsync_state fsync_state;
1409         bool            bis_any_nonbepkts;
1410         struct bandwidth_autoswitch bandwidth_auto_switch;
1411         bool FwRWRF;
1412
1413         struct rt_link_detect link_detect_info;
1414         bool bIsAggregateFrame;
1415         struct rt_pwr_save_ctrl pwr_save_ctrl;
1416
1417         /* used if IEEE_SOFTMAC_TX_QUEUE is set */
1418         struct tx_pending tx_pending;
1419
1420         /* used if IEEE_SOFTMAC_ASSOCIATE is set */
1421         struct timer_list associate_timer;
1422
1423         /* used if IEEE_SOFTMAC_BEACONS is set */
1424         struct timer_list beacon_timer;
1425         u8 need_sw_enc;
1426         struct work_struct associate_complete_wq;
1427         struct work_struct ips_leave_wq;
1428         struct delayed_work associate_procedure_wq;
1429         struct delayed_work softmac_scan_wq;
1430         struct delayed_work associate_retry_wq;
1431         struct delayed_work hw_wakeup_wq;
1432         struct delayed_work hw_sleep_wq;
1433         struct delayed_work link_change_wq;
1434         struct work_struct wx_sync_scan_wq;
1435
1436         union {
1437                 struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE];
1438                 struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
1439                 struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE];
1440                 struct {
1441                         struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT];
1442                         struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT];
1443                         struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
1444                 };
1445         };
1446
1447         /* Callback functions */
1448
1449         /* Softmac-generated frames (management) are TXed via this
1450          * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
1451          * not set. As some cards may have different HW queues that
1452          * one might want to use for data and management frames
1453          * the option to have two callbacks might be useful.
1454          * This function can't sleep.
1455          */
1456         int (*softmac_hard_start_xmit)(struct sk_buff *skb,
1457                                struct net_device *dev);
1458
1459         /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
1460          * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
1461          * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
1462          * then also management frames are sent via this callback.
1463          * This function can't sleep.
1464          */
1465         void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
1466                                struct net_device *dev, int rate);
1467
1468         /* ask to the driver to retune the radio.
1469          * This function can sleep. the driver should ensure
1470          * the radio has been switched before return.
1471          */
1472         void (*set_chan)(struct net_device *dev, short ch);
1473
1474         /* indicate the driver that the link state is changed
1475          * for example it may indicate the card is associated now.
1476          * Driver might be interested in this to apply RX filter
1477          * rules or simply light the LINK led
1478          */
1479         void (*link_change)(struct net_device *dev);
1480
1481         /* power save mode related */
1482         void (*sta_wake_up)(struct net_device *dev);
1483         void (*enter_sleep_state)(struct net_device *dev, u64 time);
1484         short (*ps_is_queue_empty)(struct net_device *dev);
1485         int (*handle_beacon)(struct net_device *dev,
1486                              struct rtllib_beacon *beacon,
1487                              struct rtllib_network *network);
1488         int (*handle_assoc_response)(struct net_device *dev,
1489                                      struct rtllib_assoc_response_frame *resp,
1490                                      struct rtllib_network *network);
1491
1492         /* check whether Tx hw resource available */
1493         short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
1494         void (*set_bw_mode_handler)(struct net_device *dev,
1495                                     enum ht_channel_width bandwidth,
1496                                     enum ht_extchnl_offset Offset);
1497         bool (*GetNmodeSupportBySecCfg)(struct net_device *dev);
1498         void (*set_wireless_mode)(struct net_device *dev, u8 wireless_mode);
1499         bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev);
1500         u8   (*rtllib_ap_sec_type)(struct rtllib_device *ieee);
1501         void (*init_gain_handler)(struct net_device *dev, u8 Operation);
1502         void (*ScanOperationBackupHandler)(struct net_device *dev,
1503                                            u8 Operation);
1504         void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val);
1505
1506         void (*AllowAllDestAddrHandler)(struct net_device *dev,
1507                                         bool bAllowAllDA, bool WriteIntoReg);
1508
1509         void (*rtllib_ips_leave_wq)(struct net_device *dev);
1510         void (*rtllib_ips_leave)(struct net_device *dev);
1511         void (*leisure_ps_leave)(struct net_device *dev);
1512
1513         /* This must be the last item so that it points to the data
1514          * allocated beyond this structure by alloc_rtllib
1515          */
1516         u8 priv[];
1517 };
1518
1519 #define IEEE_MODE_MASK    (WIRELESS_MODE_B | WIRELESS_MODE_G)
1520
1521 /* Generate a 802.11 header */
1522
1523 /* Uses the channel change callback directly
1524  * instead of [start/stop] scan callbacks
1525  */
1526 #define IEEE_SOFTMAC_SCAN (1<<2)
1527
1528 /* Perform authentication and association handshake */
1529 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
1530
1531 /* Generate probe requests */
1532 #define IEEE_SOFTMAC_PROBERQ (1<<4)
1533
1534 /* Generate response to probe requests */
1535 #define IEEE_SOFTMAC_PROBERS (1<<5)
1536
1537 /* The ieee802.11 stack will manage the netif queue
1538  * wake/stop for the driver, taking care of 802.11
1539  * fragmentation. See softmac.c for details.
1540  */
1541 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
1542
1543 /* Uses only the softmac_data_hard_start_xmit
1544  * even for TX management frames.
1545  */
1546 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
1547
1548 /* Generate beacons.  The stack will enqueue beacons
1549  * to the card
1550  */
1551 #define IEEE_SOFTMAC_BEACONS (1<<6)
1552
1553 static inline void *rtllib_priv(struct net_device *dev)
1554 {
1555         return ((struct rtllib_device *)netdev_priv(dev))->priv;
1556 }
1557
1558 static inline int rtllib_is_empty_essid(const char *essid, int essid_len)
1559 {
1560         /* Single white space is for Linksys APs */
1561         if (essid_len == 1 && essid[0] == ' ')
1562                 return 1;
1563
1564         /* Otherwise, if the entire essid is 0, we assume it is hidden */
1565         while (essid_len) {
1566                 essid_len--;
1567                 if (essid[essid_len] != '\0')
1568                         return 0;
1569         }
1570
1571         return 1;
1572 }
1573
1574 static inline int rtllib_get_hdrlen(u16 fc)
1575 {
1576         int hdrlen = RTLLIB_3ADDR_LEN;
1577
1578         switch (WLAN_FC_GET_TYPE(fc)) {
1579         case RTLLIB_FTYPE_DATA:
1580                 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
1581                         hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
1582                 if (RTLLIB_QOS_HAS_SEQ(fc))
1583                         hdrlen += 2; /* QOS ctrl*/
1584                 break;
1585         case RTLLIB_FTYPE_CTL:
1586                 switch (WLAN_FC_GET_STYPE(fc)) {
1587                 case IEEE80211_STYPE_CTS:
1588                 case IEEE80211_STYPE_ACK:
1589                         hdrlen = RTLLIB_1ADDR_LEN;
1590                         break;
1591                 default:
1592                         hdrlen = RTLLIB_2ADDR_LEN;
1593                         break;
1594                 }
1595                 break;
1596         }
1597
1598         return hdrlen;
1599 }
1600
1601 static inline int rtllib_is_ofdm_rate(u8 rate)
1602 {
1603         switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
1604         case RTLLIB_OFDM_RATE_6MB:
1605         case RTLLIB_OFDM_RATE_9MB:
1606         case RTLLIB_OFDM_RATE_12MB:
1607         case RTLLIB_OFDM_RATE_18MB:
1608         case RTLLIB_OFDM_RATE_24MB:
1609         case RTLLIB_OFDM_RATE_36MB:
1610         case RTLLIB_OFDM_RATE_48MB:
1611         case RTLLIB_OFDM_RATE_54MB:
1612                 return 1;
1613         }
1614         return 0;
1615 }
1616
1617 static inline int rtllib_is_cck_rate(u8 rate)
1618 {
1619         switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
1620         case RTLLIB_CCK_RATE_1MB:
1621         case RTLLIB_CCK_RATE_2MB:
1622         case RTLLIB_CCK_RATE_5MB:
1623         case RTLLIB_CCK_RATE_11MB:
1624                 return 1;
1625         }
1626         return 0;
1627 }
1628
1629 /* rtllib.c */
1630 void free_rtllib(struct net_device *dev);
1631 struct net_device *alloc_rtllib(int sizeof_priv);
1632
1633 /* rtllib_tx.c */
1634
1635 int rtllib_encrypt_fragment(struct rtllib_device *ieee,
1636                             struct sk_buff *frag,
1637                             int hdr_len);
1638
1639 netdev_tx_t rtllib_xmit(struct sk_buff *skb,  struct net_device *dev);
1640 void rtllib_txb_free(struct rtllib_txb *txb);
1641
1642 /* rtllib_rx.c */
1643 int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
1644               struct rtllib_rx_stats *rx_stats);
1645 int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
1646
1647 /* rtllib_wx.c */
1648 int rtllib_wx_get_scan(struct rtllib_device *ieee,
1649                        struct iw_request_info *info,
1650                        union iwreq_data *wrqu, char *key);
1651 int rtllib_wx_set_encode(struct rtllib_device *ieee,
1652                          struct iw_request_info *info,
1653                          union iwreq_data *wrqu, char *key);
1654 int rtllib_wx_get_encode(struct rtllib_device *ieee,
1655                          struct iw_request_info *info,
1656                          union iwreq_data *wrqu, char *key);
1657 int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
1658                              struct iw_request_info *info,
1659                              union iwreq_data *wrqu, char *extra);
1660 int rtllib_wx_set_auth(struct rtllib_device *ieee,
1661                        struct iw_request_info *info,
1662                        struct iw_param *data, char *extra);
1663 int rtllib_wx_set_mlme(struct rtllib_device *ieee,
1664                        struct iw_request_info *info,
1665                        union iwreq_data *wrqu, char *extra);
1666 int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
1667
1668 /* rtllib_softmac.c */
1669 int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb,
1670                             struct rtllib_rx_stats *rx_stats, u16 type,
1671                             u16 stype);
1672 void rtllib_softmac_new_net(struct rtllib_device *ieee,
1673                             struct rtllib_network *net);
1674
1675 void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
1676 void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee);
1677
1678 int rtllib_softmac_init(struct rtllib_device *ieee);
1679 void rtllib_softmac_free(struct rtllib_device *ieee);
1680 void rtllib_disassociate(struct rtllib_device *ieee);
1681 void rtllib_stop_scan(struct rtllib_device *ieee);
1682 bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
1683 void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
1684 void rtllib_start_scan_syncro(struct rtllib_device *ieee);
1685 void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr);
1686 void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
1687 void rtllib_start_protocol(struct rtllib_device *ieee);
1688 void rtllib_stop_protocol(struct rtllib_device *ieee);
1689
1690 void rtllib_EnableNetMonitorMode(struct net_device *dev, bool bInitState);
1691 void rtllib_DisableNetMonitorMode(struct net_device *dev, bool bInitState);
1692
1693 void rtllib_softmac_stop_protocol(struct rtllib_device *ieee);
1694 void rtllib_softmac_start_protocol(struct rtllib_device *ieee);
1695
1696 void rtllib_reset_queue(struct rtllib_device *ieee);
1697 void rtllib_wake_all_queues(struct rtllib_device *ieee);
1698 void rtllib_stop_all_queues(struct rtllib_device *ieee);
1699 struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
1700
1701 void notify_wx_assoc_event(struct rtllib_device *ieee);
1702 void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
1703
1704 void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee);
1705 u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
1706
1707 /* rtllib_softmac_wx.c */
1708
1709 int rtllib_wx_get_wap(struct rtllib_device *ieee, struct iw_request_info *info,
1710                       union iwreq_data *wrqu, char *ext);
1711
1712 int rtllib_wx_set_wap(struct rtllib_device *ieee, struct iw_request_info *info,
1713                       union iwreq_data *awrq, char *extra);
1714
1715 int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,
1716                         union iwreq_data *wrqu, char *b);
1717
1718 int rtllib_wx_set_rate(struct rtllib_device *ieee, struct iw_request_info *info,
1719                        union iwreq_data *wrqu, char *extra);
1720
1721 int rtllib_wx_get_rate(struct rtllib_device *ieee, struct iw_request_info *info,
1722                        union iwreq_data *wrqu, char *extra);
1723
1724 int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a,
1725                        union iwreq_data *wrqu, char *b);
1726
1727 int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a,
1728                        union iwreq_data *wrqu, char *b);
1729
1730 int rtllib_wx_set_essid(struct rtllib_device *ieee, struct iw_request_info *a,
1731                         union iwreq_data *wrqu, char *extra);
1732
1733 int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a,
1734                        union iwreq_data *wrqu, char *b);
1735
1736 int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a,
1737                        union iwreq_data *wrqu, char *b);
1738
1739 int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a,
1740                        union iwreq_data *wrqu, char *b);
1741 void rtllib_wx_sync_scan_wq(void *data);
1742
1743 int rtllib_wx_get_name(struct rtllib_device *ieee, struct iw_request_info *info,
1744                        union iwreq_data *wrqu, char *extra);
1745
1746 int rtllib_wx_set_power(struct rtllib_device *ieee,
1747                         struct iw_request_info *info,
1748                         union iwreq_data *wrqu, char *extra);
1749
1750 int rtllib_wx_get_power(struct rtllib_device *ieee,
1751                         struct iw_request_info *info,
1752                         union iwreq_data *wrqu, char *extra);
1753
1754 int rtllib_wx_set_rts(struct rtllib_device *ieee, struct iw_request_info *info,
1755                       union iwreq_data *wrqu, char *extra);
1756
1757 int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info,
1758                       union iwreq_data *wrqu, char *extra);
1759 #define MAX_RECEIVE_BUFFER_SIZE 9100
1760
1761 void HTSetConnectBwMode(struct rtllib_device *ieee,
1762                         enum ht_channel_width bandwidth,
1763                         enum ht_extchnl_offset Offset);
1764 void ht_update_default_setting(struct rtllib_device *ieee);
1765 void HTConstructCapabilityElement(struct rtllib_device *ieee,
1766                                   u8 *posHTCap, u8 *len,
1767                                   u8 isEncrypt, bool bAssoc);
1768 void HTConstructInfoElement(struct rtllib_device *ieee,
1769                             u8 *posHTInfo, u8 *len, u8 isEncrypt);
1770 void HTConstructRT2RTAggElement(struct rtllib_device *ieee,
1771                                 u8 *posRT2RTAgg, u8 *len);
1772 void HTOnAssocRsp(struct rtllib_device *ieee);
1773 void HTInitializeHTInfo(struct rtllib_device *ieee);
1774 void HTInitializeBssDesc(struct bss_ht *pBssHT);
1775 void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
1776                                    struct rtllib_network *pNetwork);
1777 void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
1778                                      struct rtllib_network *pNetwork);
1779 u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
1780                        u8 *pMCSFilter);
1781 extern u8 MCS_FILTER_ALL[];
1782 extern u16 MCS_DATA_RATE[2][2][77];
1783 u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
1784 void HTResetIOTSetting(struct rt_hi_throughput *ht_info);
1785 bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
1786 u16  TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
1787 int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
1788 int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
1789 int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
1790 void rtllib_ts_init_add_ba(struct rtllib_device *ieee, struct tx_ts_record *ts,
1791                            u8 policy, u8 bOverwritePending);
1792 void rtllib_ts_init_del_ba(struct rtllib_device *ieee,
1793                            struct ts_common_info *pTsCommonInfo,
1794                            enum tr_select TxRxSelect);
1795 void rtllib_ba_setup_timeout(struct timer_list *t);
1796 void rtllib_tx_ba_inact_timeout(struct timer_list *t);
1797 void rtllib_rx_ba_inact_timeout(struct timer_list *t);
1798 void rtllib_reset_ba_entry(struct ba_record *ba);
1799 bool rtllib_get_ts(struct rtllib_device *ieee, struct ts_common_info **ppTS, u8 *addr,
1800            u8 TID, enum tr_select TxRxSelect, bool bAddNewTs);
1801 void rtllib_ts_init(struct rtllib_device *ieee);
1802 void TsStartAddBaProcess(struct rtllib_device *ieee,
1803                          struct tx_ts_record *pTxTS);
1804 void RemovePeerTS(struct rtllib_device *ieee, u8 *addr);
1805 void RemoveAllTS(struct rtllib_device *ieee);
1806
1807 static inline const char *escape_essid(const char *essid, u8 essid_len)
1808 {
1809         static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
1810
1811         if (rtllib_is_empty_essid(essid, essid_len)) {
1812                 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
1813                 return escaped;
1814         }
1815
1816         snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
1817         return escaped;
1818 }
1819
1820 /* fun with the built-in rtllib stack... */
1821 bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
1822
1823 /* For the function is more related to hardware setting, it's better to use the
1824  * ieee handler to refer to it.
1825  */
1826 void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
1827                                  struct rx_ts_record *ts);
1828 int rtllib_parse_info_param(struct rtllib_device *ieee,
1829                             struct rtllib_info_element *info_element,
1830                             u16 length,
1831                             struct rtllib_network *network,
1832                             struct rtllib_rx_stats *stats);
1833
1834 void rtllib_indicate_packets(struct rtllib_device *ieee,
1835                              struct rtllib_rxb **prxbIndicateArray, u8  index);
1836 #define RT_ASOC_RETRY_LIMIT     5
1837 u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee);
1838
1839 #endif /* RTLLIB_H */
This page took 0.129782 seconds and 4 git commands to generate.