Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6] / drivers / staging / vt6655 / device.h
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * File: device.h
20  *
21  * Purpose: MAC Data structure
22  *
23  * Author: Tevin Chen
24  *
25  * Date: Mar 17, 1997
26  *
27  */
28
29 #ifndef __DEVICE_H__
30 #define __DEVICE_H__
31
32 #ifdef MODULE
33 #ifdef MODVERSIONS
34 #include <linux/modversions.h>
35 #endif /* MODVERSIONS */
36 #include <linux/module.h>
37 #endif /* MODULE */
38
39 #include <linux/types.h>
40 #include <linux/init.h>
41 #include <linux/mm.h>
42 #include <linux/errno.h>
43 #include <linux/ioport.h>
44 #include <linux/pci.h>
45 #include <linux/kernel.h>
46 #include <linux/netdevice.h>
47 #include <linux/etherdevice.h>
48 #include <linux/skbuff.h>
49 #include <linux/delay.h>
50 #include <linux/timer.h>
51 #include <linux/slab.h>
52 #include <linux/interrupt.h>
53 #include <linux/version.h>
54 #include <linux/string.h>
55 #include <linux/wait.h>
56 #include <linux/if_arp.h>
57 #include <linux/sched.h>
58 #include <asm/io.h>
59 #include <linux/if.h>
60 //#include <linux/config.h>
61 #include <asm/uaccess.h>
62 #include <linux/proc_fs.h>
63 #include <linux/inetdevice.h>
64 #include <linux/reboot.h>
65 #ifdef SIOCETHTOOL
66 #define DEVICE_ETHTOOL_IOCTL_SUPPORT
67 #include <linux/ethtool.h>
68 #else
69 #undef DEVICE_ETHTOOL_IOCTL_SUPPORT
70 #endif
71 /* Include Wireless Extension definition and check version - Jean II */
72 #include <linux/wireless.h>
73 #if WIRELESS_EXT > 12
74 #include <net/iw_handler.h>     // New driver API
75 #endif  /* WIRELESS_EXT > 12 */
76
77 //2008-0409-07, <Add> by Einsn Liu
78 #if WIRELESS_EXT > 17
79 #ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
80 #define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
81 #endif
82 #endif
83 //2008-4-14<add> by chester for led issue
84 //#define FOR_LED_ON_NOTEBOOK
85 //
86
87
88
89 //  device specific
90 //
91 #if !defined(_KCOMPAT_H)
92 #include "kcompat.h"
93 #endif
94
95 #if !defined(__DEVICE_CONFIG_H)
96 #include "device_cfg.h"
97 #endif
98
99 #if !defined(__TTYPE_H__)
100 #include "ttype.h"
101 #endif
102 #if !defined(__80211HDR_H__)
103 #include "80211hdr.h"
104 #endif
105 #if !defined(__TETHER_H__)
106 #include "tether.h"
107 #endif
108 #if !defined(__WMGR_H__)
109 #include "wmgr.h"
110 #endif
111 #if !defined(__WCMD_H__)
112 #include "wcmd.h"
113 #endif
114 #if !defined(__MIB_H__)
115 #include "mib.h"
116 #endif
117 #if !defined(__SROM_H__)
118 #include "srom.h"
119 #endif
120 #if !defined(__RC4_H__)
121 #include "rc4.h"
122 #endif
123 #if !defined(__TPCI_H__)
124 #include "tpci.h"
125 #endif
126 #if !defined(__DESC_H__)
127 #include "desc.h"
128 #endif
129
130 #if !defined(__KEY_H__)
131 #include "key.h"
132 #endif
133
134 #if !defined(__MAC_H__)
135 #include "mac.h"
136 #endif
137
138 //PLICE_DEBUG->
139 //#define               THREAD
140
141 //#define       TASK_LET
142 //PLICE_DEBUG<-
143
144 // #ifdef PRIVATE_OBJ
145 //#if !defined(__DEVICE_MODULE_H)
146 //#include "device_module.h"
147 //#endif
148
149
150 /*---------------------  Export Definitions -------------------------*/
151
152 #define MAC_MAX_CONTEXT_REG     (256+128)
153
154 #define MAX_MULTICAST_ADDRESS_NUM       32
155 #define MULTICAST_ADDRESS_LIST_SIZE     (MAX_MULTICAST_ADDRESS_NUM * U_ETHER_ADDR_LEN)
156
157
158 //#define OP_MODE_INFRASTRUCTURE  0
159 //#define OP_MODE_ADHOC           1
160 //#define OP_MODE_AP              2
161
162 #define DUPLICATE_RX_CACHE_LENGTH       5
163
164 #define NUM_KEY_ENTRY                   11
165
166 #define TX_WEP_NONE                     0
167 #define TX_WEP_OTF                      1
168 #define TX_WEP_SW                       2
169 #define TX_WEP_SWOTP                    3
170 #define TX_WEP_OTPSW                    4
171 #define TX_WEP_SW232                    5
172
173 #define KEYSEL_WEP40                    0
174 #define KEYSEL_WEP104                   1
175 #define KEYSEL_TKIP                     2
176 #define KEYSEL_CCMP                     3
177
178
179
180 #define AUTO_FB_NONE            0
181 #define AUTO_FB_0               1
182 #define AUTO_FB_1               2
183
184 #define FB_RATE0                0
185 #define FB_RATE1                1
186
187 // Antenna Mode
188 #define ANT_A                   0
189 #define ANT_B                   1
190 #define ANT_DIVERSITY           2
191 #define ANT_RXD_TXA             3
192 #define ANT_RXD_TXB             4
193 #define ANT_UNKNOWN             0xFF
194
195 #define MAXCHECKHANGCNT         4
196
197 #define BB_VGA_LEVEL            4
198 #define BB_VGA_CHANGE_THRESHOLD 16
199
200
201 #ifndef RUN_AT
202 #define RUN_AT(x)                       (jiffies+(x))
203 #endif
204
205 // DMA related
206 #define RESERV_AC0DMA                   4
207
208
209 // BUILD OBJ mode
210 #ifdef PRIVATE_OBJ
211
212 #undef dev_kfree_skb
213 #undef dev_kfree_skb_irq
214 #undef dev_alloc_skb
215 #undef kfree
216 #undef del_timer
217 #undef init_timer
218 #undef add_timer
219 #undef kmalloc
220 #undef netif_stop_queue
221 #undef netif_start_queue
222 #undef netif_wake_queue
223 #undef netif_queue_stopped
224 #undef netif_rx
225 #undef netif_running
226 #undef udelay
227 #undef mdelay
228 #undef eth_type_trans
229 #undef skb_put
230 #undef HZ
231 #undef RUN_AT
232 #undef pci_alloc_consistent
233 #undef pci_free_consistent
234 #undef register_netdevice
235 #undef register_netdev
236 #undef unregister_netdevice
237 #undef unregister_netdev
238 #undef skb_queue_head_init
239 #undef skb_queue_tail
240 #undef skb_queue_empty
241 #undef free_irq
242 #undef copy_from_user
243 #undef copy_to_user
244 #undef spin_lock_init
245 #undef pci_map_single
246 #undef pci_unmap_single
247
248 // redefine kernel dependent fucntion
249 #define dev_kfree_skb       ref_dev_kfree_skb
250 #define dev_kfree_skb_irq   ref_dev_kfree_skb_irq
251 #define dev_alloc_skb       ref_dev_alloc_skb
252 #define kfree               ref_kfree
253 #define del_timer           ref_del_timer
254 #define init_timer          ref_init_timer
255 #define add_timer           ref_add_timer
256 #define kmalloc             ref_kmalloc
257 #define netif_stop_queue    ref_netif_stop_queue
258 #define netif_start_queue   ref_netif_start_queue
259 #define netif_wake_queue    ref_netif_wake_queue
260 #define netif_queue_stopped ref_netif_queue_stopped
261 #define netif_rx            ref_netif_rx
262 #define netif_running       ref_netif_running
263 #define udelay              ref_udelay
264 #define mdelay              ref_mdelay
265 #define get_jiffies()       ref_get_jiffies()
266 #define RUN_AT(x)           (get_jiffies()+(x))
267 #define HZ                  ref_HZ_tick()
268 #define eth_type_trans      ref_eth_type_trans
269 #define skb_put             ref_skb_put
270 #define skb_queue_head_init ref_skb_queue_head_init
271 #define skb_queue_tail      ref_skb_queue_tail
272 #define skb_queue_empty     ref_skb_queue_empty
273
274 #define pci_alloc_consistent    ref_pci_alloc_consistent
275 #define pci_free_consistent     ref_pci_free_consistent
276 #define register_netdevice      ref_register_netdevice
277 #define register_netdev         ref_register_netdev
278 #define unregister_netdevice    ref_unregister_netdevice
279 #define unregister_netdev       ref_unregister_netdev
280
281 #define free_irq                ref_free_irq
282 #define copy_from_user          ref_copy_from_user
283 #define copy_to_user            ref_copy_to_user
284 #define spin_lock_init          ref_spin_lock_init
285 #define pci_map_single          ref_pci_map_single
286 #define pci_unmap_single        ref_pci_unmap_single
287 #endif
288
289
290 #ifdef PRIVATE_OBJ
291 #undef  printk
292 #define DEVICE_PRT(l, p, args...) {if (l<=msglevel) do {} while (0);}
293 //#define DEVICE_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
294 #else
295 #define DEVICE_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
296 #endif
297
298
299 #define AVAIL_TD(p,q)   ((p)->sOpts.nTxDescs[(q)]-((p)->iTDUsed[(q)]))
300
301 //PLICE_DEBUG ->
302 #define NUM                             64
303 //PLICE_DEUBG <-
304
305
306
307 /*---------------------  Export Types  ------------------------------*/
308
309
310 //0:11A 1:11B 2:11G
311 typedef enum _VIA_BB_TYPE
312 {
313     BB_TYPE_11A=0,
314     BB_TYPE_11B,
315     BB_TYPE_11G
316 } VIA_BB_TYPE, *PVIA_BB_TYPE;
317
318 //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
319 typedef enum _VIA_PKT_TYPE
320 {
321     PK_TYPE_11A=0,
322     PK_TYPE_11B,
323     PK_TYPE_11GB,
324     PK_TYPE_11GA
325 } VIA_PKT_TYPE, *PVIA_PKT_TYPE;
326
327
328 typedef enum __device_msg_level {
329     MSG_LEVEL_ERR=0,            //Errors that will cause abnormal operation.
330     MSG_LEVEL_NOTICE=1,         //Some errors need users to be notified.
331     MSG_LEVEL_INFO=2,           //Normal message.
332     MSG_LEVEL_VERBOSE=3,        //Will report all trival errors.
333     MSG_LEVEL_DEBUG=4           //Only for debug purpose.
334 } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
335
336 typedef enum __device_init_type {
337     DEVICE_INIT_COLD=0,         // cold init
338     DEVICE_INIT_RESET,          // reset init or Dx to D0 power remain init
339     DEVICE_INIT_DXPL            // Dx to D0 power lost init
340 } DEVICE_INIT_TYPE, *PDEVICE_INIT_TYPE;
341
342
343 //++ NDIS related
344
345 #define MAX_BSSIDINFO_4_PMKID   16
346 #define MAX_PMKIDLIST           5
347 //Flags for PMKID Candidate list structure
348 #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED     0x01
349
350 // PMKID Structures
351 typedef UCHAR   NDIS_802_11_PMKID_VALUE[16];
352
353
354 typedef enum _NDIS_802_11_WEP_STATUS
355 {
356     Ndis802_11WEPEnabled,
357     Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
358     Ndis802_11WEPDisabled,
359     Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
360     Ndis802_11WEPKeyAbsent,
361     Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
362     Ndis802_11WEPNotSupported,
363     Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
364     Ndis802_11Encryption2Enabled,
365     Ndis802_11Encryption2KeyAbsent,
366     Ndis802_11Encryption3Enabled,
367     Ndis802_11Encryption3KeyAbsent
368 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
369   NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
370
371
372 typedef enum _NDIS_802_11_STATUS_TYPE
373 {
374     Ndis802_11StatusType_Authentication,
375     Ndis802_11StatusType_MediaStreamMode,
376     Ndis802_11StatusType_PMKID_CandidateList,
377     Ndis802_11StatusTypeMax    // not a real type, defined as an upper bound
378 } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
379
380 //Added new types for PMKID Candidate lists.
381 typedef struct _PMKID_CANDIDATE {
382     NDIS_802_11_MAC_ADDRESS BSSID;
383     ULONG Flags;
384 } PMKID_CANDIDATE, *PPMKID_CANDIDATE;
385
386
387 typedef struct _BSSID_INFO
388 {
389     NDIS_802_11_MAC_ADDRESS BSSID;
390     NDIS_802_11_PMKID_VALUE PMKID;
391 } BSSID_INFO, *PBSSID_INFO;
392
393 typedef struct tagSPMKID {
394     ULONG Length;
395     ULONG BSSIDInfoCount;
396     BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
397 } SPMKID, *PSPMKID;
398
399 typedef struct tagSPMKIDCandidateEvent {
400     NDIS_802_11_STATUS_TYPE     StatusType;
401     ULONG Version;       // Version of the structure
402     ULONG NumCandidates; // No. of pmkid candidates
403     PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
404 } SPMKIDCandidateEvent, DEF* PSPMKIDCandidateEvent;
405
406
407 //--
408
409 //++ 802.11h related
410 #define MAX_QUIET_COUNT     8
411
412 typedef struct tagSQuietControl {
413     BOOL        bEnable;
414     DWORD       dwStartTime;
415     BYTE        byPeriod;
416     WORD        wDuration;
417 } SQuietControl, DEF* PSQuietControl;
418
419 //--
420 typedef struct __chip_info_tbl{
421     CHIP_TYPE   chip_id;
422     char*       name;
423     int         io_size;
424     int         nTxQueue;
425     U32         flags;
426 } CHIP_INFO, *PCHIP_INFO;
427
428
429 typedef enum {
430     OWNED_BY_HOST=0,
431     OWNED_BY_NIC=1
432 } DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
433
434
435 // The receive duplicate detection cache entry
436 typedef struct tagSCacheEntry{
437     WORD        wFmSequence;
438     BYTE        abyAddr2[U_ETHER_ADDR_LEN];
439 } SCacheEntry, *PSCacheEntry;
440
441
442 typedef struct tagSCache{
443 /* The receive cache is updated circularly.  The next entry to be written is
444  * indexed by the "InPtr".
445 */
446     UINT            uInPtr;         // Place to use next
447     SCacheEntry     asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
448 } SCache, *PSCache;
449
450 #define CB_MAX_RX_FRAG                 64
451 // DeFragment Control Block, used for collecting fragments prior to reassembly
452 typedef struct tagSDeFragControlBlock
453 {
454     WORD            wSequence;
455     WORD            wFragNum;
456     BYTE            abyAddr2[U_ETHER_ADDR_LEN];
457         UINT            uLifetime;
458     struct sk_buff* skb;
459 #ifdef PRIVATE_OBJ
460     ref_sk_buff     ref_skb;
461 #endif
462     PBYTE           pbyRxBuffer;
463     UINT            cbFrameLength;
464     BOOL            bInUse;
465 } SDeFragControlBlock, DEF* PSDeFragControlBlock;
466
467
468
469
470 //flags for options
471 #define     DEVICE_FLAGS_IP_ALIGN        0x00000001UL
472 #define     DEVICE_FLAGS_PREAMBLE_TYPE   0x00000002UL
473 #define     DEVICE_FLAGS_OP_MODE         0x00000004UL
474 #define     DEVICE_FLAGS_PS_MODE         0x00000008UL
475 #define         DEVICE_FLAGS_80211h_MODE         0x00000010UL
476 #define         DEVICE_FLAGS_DiversityANT        0x00000020UL
477
478 //flags for driver status
479 #define     DEVICE_FLAGS_OPENED          0x00010000UL
480 #define     DEVICE_FLAGS_WOL_ENABLED     0x00080000UL
481 //flags for capbilities
482 #define     DEVICE_FLAGS_TX_ALIGN        0x01000000UL
483 #define     DEVICE_FLAGS_HAVE_CAM        0x02000000UL
484 #define     DEVICE_FLAGS_FLOW_CTRL       0x04000000UL
485
486 //flags for MII status
487 #define     DEVICE_LINK_FAIL             0x00000001UL
488 #define     DEVICE_SPEED_10              0x00000002UL
489 #define     DEVICE_SPEED_100             0x00000004UL
490 #define     DEVICE_SPEED_1000            0x00000008UL
491 #define     DEVICE_DUPLEX_FULL           0x00000010UL
492 #define     DEVICE_AUTONEG_ENABLE        0x00000020UL
493 #define     DEVICE_FORCED_BY_EEPROM      0x00000040UL
494 //for device_set_media_duplex
495 #define     DEVICE_LINK_CHANGE           0x00000001UL
496
497
498 //PLICE_DEBUG->
499
500
501 typedef struct _RxManagementQueue
502 {
503         int     packet_num;
504         int     head,tail;
505         PSRxMgmtPacket  Q[NUM];
506 } RxManagementQueue,*PSRxManagementQueue;
507
508
509
510 //PLICE_DEBUG<-
511
512
513 typedef struct __device_opt {
514     int         nRxDescs0;      //Number of RX descriptors0
515     int         nRxDescs1;      //Number of RX descriptors1
516     int         nTxDescs[2];    //Number of TX descriptors 0, 1
517     int         int_works;      //interrupt limits
518     int         rts_thresh;     //rts threshold
519     int         frag_thresh;
520     int         data_rate;
521     int         channel_num;
522     int         short_retry;
523     int         long_retry;
524     int         bbp_type;
525     U32         flags;
526 } OPTIONS, *POPTIONS;
527
528
529 typedef struct __device_info {
530     struct __device_info*        next;
531     struct __device_info*        prev;
532
533     struct pci_dev*             pcid;
534
535 #if CONFIG_PM
536     u32                         pci_state[16];
537 #endif
538
539 // netdev
540     struct net_device*          dev;
541     struct net_device*          next_module;
542     struct net_device_stats     stats;
543
544 //dma addr, rx/tx pool
545     dma_addr_t                  pool_dma;
546     dma_addr_t                  rd0_pool_dma;
547     dma_addr_t                  rd1_pool_dma;
548
549     dma_addr_t                  td0_pool_dma;
550     dma_addr_t                  td1_pool_dma;
551
552     dma_addr_t                  tx_bufs_dma0;
553     dma_addr_t                  tx_bufs_dma1;
554     dma_addr_t                  tx_beacon_dma;
555
556     PBYTE                       tx0_bufs;
557     PBYTE                       tx1_bufs;
558     PBYTE                       tx_beacon_bufs;
559
560     CHIP_TYPE                   chip_id;
561
562     U32                         PortOffset;
563     DWORD                       dwIsr;
564     U32                         memaddr;
565     U32                         ioaddr;
566     U32                         io_size;
567
568     BYTE                        byRevId;
569     WORD                        SubSystemID;
570     WORD                        SubVendorID;
571
572     int                         nTxQueues;
573     volatile int                iTDUsed[TYPE_MAXTD];
574
575     volatile PSTxDesc           apCurrTD[TYPE_MAXTD];
576     volatile PSTxDesc           apTailTD[TYPE_MAXTD];
577
578     volatile PSTxDesc           apTD0Rings;
579     volatile PSTxDesc           apTD1Rings;
580
581     volatile PSRxDesc           aRD0Ring;
582     volatile PSRxDesc           aRD1Ring;
583     volatile PSRxDesc           pCurrRD[TYPE_MAXRD];
584     SCache                      sDupRxCache;
585
586     SDeFragControlBlock         sRxDFCB[CB_MAX_RX_FRAG];
587     UINT                        cbDFCB;
588     UINT                        cbFreeDFCB;
589     UINT                        uCurrentDFCBIdx;
590
591     OPTIONS                     sOpts;
592
593     U32                         flags;
594
595     U32                         rx_buf_sz;
596     int                         multicast_limit;
597     BYTE                        byRxMode;
598
599     spinlock_t                  lock;
600 //PLICE_DEBUG->
601         struct  tasklet_struct          RxMngWorkItem;
602         RxManagementQueue       rxManeQueue;
603 //PLICE_DEBUG<-
604 //PLICE_DEBUG ->
605         pid_t                           MLMEThr_pid;
606         struct  completion      notify;
607         struct  semaphore       mlme_semaphore;
608 //PLICE_DEBUG <-
609
610
611     U32                         rx_bytes;
612
613     // Version control
614     BYTE                        byLocalID;
615     BYTE                        byRFType;
616
617     BYTE                        byMaxPwrLevel;
618     BYTE                        byZoneType;
619     BOOL                        bZoneRegExist;
620    BYTE                        byOriginalZonetype;
621     BYTE                        abyMacContext[MAC_MAX_CONTEXT_REG];
622     BOOL                        bLinkPass;          // link status: OK or fail
623     BYTE                        abyCurrentNetAddr[U_ETHER_ADDR_LEN];
624
625     // Adapter statistics
626     SStatCounter                scStatistic;
627     // 802.11 counter
628     SDot11Counters              s802_11Counter;
629
630
631     // 802.11 management
632     PSMgmtObject                pMgmt;
633     SMgmtObject                 sMgmtObj;
634
635     // 802.11 MAC specific
636     UINT                        uCurrRSSI;
637     BYTE                        byCurrSQ;
638
639     DWORD                       dwTxAntennaSel;
640     DWORD                       dwRxAntennaSel;
641     BYTE                        byAntennaCount;
642     BYTE                        byRxAntennaMode;
643     BYTE                        byTxAntennaMode;
644     BOOL                        bTxRxAntInv;
645
646     PBYTE                       pbyTmpBuff;
647     UINT                        uSIFS;    //Current SIFS
648     UINT                        uDIFS;    //Current DIFS
649     UINT                        uEIFS;    //Current EIFS
650     UINT                        uSlot;    //Current SlotTime
651     UINT                        uCwMin;   //Current CwMin
652     UINT                        uCwMax;   //CwMax is fixed on 1023.
653     // PHY parameter
654     BYTE                        bySIFS;
655     BYTE                        byDIFS;
656     BYTE                        byEIFS;
657     BYTE                        bySlot;
658     BYTE                        byCWMaxMin;
659     CARD_PHY_TYPE               eCurrentPHYType;
660
661
662     VIA_BB_TYPE                 byBBType; //0: 11A, 1:11B, 2:11G
663     VIA_PKT_TYPE                byPacketType; //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
664     WORD                        wBasicRate;
665     BYTE                        byACKRate;
666     BYTE                        byTopOFDMBasicRate;
667     BYTE                        byTopCCKBasicRate;
668
669     BYTE                        byMinChannel;
670     BYTE                        byMaxChannel;
671     UINT                        uConnectionRate;
672
673     BYTE                        byPreambleType;
674     BYTE                        byShortPreamble;
675
676     WORD                        wCurrentRate;
677     WORD                        wRTSThreshold;
678     WORD                        wFragmentationThreshold;
679     BYTE                        byShortRetryLimit;
680     BYTE                        byLongRetryLimit;
681     CARD_OP_MODE                eOPMode;
682     BYTE                        byOpMode;
683     BOOL                        bBSSIDFilter;
684     WORD                        wMaxTransmitMSDULifetime;
685     BYTE                        abyBSSID[U_ETHER_ADDR_LEN];
686     BYTE                        abyDesireBSSID[U_ETHER_ADDR_LEN];
687     WORD                        wCTSDuration;       // update while speed change
688     WORD                        wACKDuration;       // update while speed change
689     WORD                        wRTSTransmitLen;    // update while speed change
690     BYTE                        byRTSServiceField;  // update while speed change
691     BYTE                        byRTSSignalField;   // update while speed change
692
693     DWORD                       dwMaxReceiveLifetime;       // dot11MaxReceiveLifetime
694
695     BOOL                        bCCK;
696     BOOL                        bEncryptionEnable;
697     BOOL                        bLongHeader;
698     BOOL                        bShortSlotTime;
699     BOOL                        bProtectMode;
700     BOOL                        bNonERPPresent;
701     BOOL                        bBarkerPreambleMd;
702
703     BYTE                        byERPFlag;
704     WORD                        wUseProtectCntDown;
705
706     BOOL                    bRadioControlOff;
707     BOOL                    bRadioOff;
708     BOOL                    bEnablePSMode;
709     WORD                    wListenInterval;
710     BOOL                    bPWBitOn;
711     WMAC_POWER_MODE         ePSMode;
712
713
714     // GPIO Radio Control
715     BYTE                    byRadioCtl;
716     BYTE                    byGPIO;
717     BOOL                    bHWRadioOff;
718     BOOL                    bPrvActive4RadioOFF;
719     BOOL                    bGPIOBlockRead;
720
721     // Beacon releated
722     WORD                    wSeqCounter;
723     WORD                    wBCNBufLen;
724     BOOL                    bBeaconBufReady;
725     BOOL                    bBeaconSent;
726     BOOL                    bIsBeaconBufReadySet;
727     UINT                    cbBeaconBufReadySetCnt;
728     BOOL                    bFixRate;
729     BYTE                    byCurrentCh;
730     UINT                    uScanTime;
731
732     CMD_STATE               eCommandState;
733
734     CMD_CODE                eCommand;
735     BOOL                    bBeaconTx;
736
737     BOOL                    bStopBeacon;
738     BOOL                    bStopDataPkt;
739     BOOL                    bStopTx0Pkt;
740     UINT                    uAutoReConnectTime;
741
742     // 802.11 counter
743
744     CMD_ITEM                eCmdQueue[CMD_Q_SIZE];
745     UINT                    uCmdDequeueIdx;
746     UINT                    uCmdEnqueueIdx;
747     UINT                    cbFreeCmdQueue;
748     BOOL                    bCmdRunning;
749     BOOL                    bCmdClear;
750
751
752
753     BOOL                    bRoaming;
754     //WOW
755     BYTE                    abyIPAddr[4];
756
757     ULONG                   ulTxPower;
758     NDIS_802_11_WEP_STATUS  eEncryptionStatus;
759     BOOL                    bTransmitKey;
760 //2007-0925-01<Add>by MikeLiu
761 //mike add :save old Encryption
762     NDIS_802_11_WEP_STATUS  eOldEncryptionStatus;
763     SKeyManagement          sKey;
764     DWORD                   dwIVCounter;
765
766     QWORD                   qwPacketNumber; //For CCMP and TKIP as TSC(6 bytes)
767     UINT                    uCurrentWEPMode;
768
769     RC4Ext                  SBox;
770     BYTE                    abyPRNG[WLAN_WEPMAX_KEYLEN+3];
771
772     BYTE                    byKeyIndex;
773     UINT                    uKeyLength;
774     BYTE                    abyKey[WLAN_WEP232_KEYLEN];
775
776     BOOL                    bAES;
777     BYTE                    byCntMeasure;
778
779     // for AP mode
780     UINT                    uAssocCount;
781     BOOL                    bMoreData;
782
783     // QoS
784     BOOL                    bGrpAckPolicy;
785
786     // for OID_802_11_ASSOCIATION_INFORMATION
787     BOOL                    bAssocInfoSet;
788
789
790     BYTE                    byAutoFBCtrl;
791
792     BOOL                    bTxMICFail;
793     BOOL                    bRxMICFail;
794
795
796     UINT                    uRATEIdx;
797
798
799     // For Update BaseBand VGA Gain Offset
800     BOOL                    bUpdateBBVGA;
801     UINT                    uBBVGADiffCount;
802     BYTE                    byBBVGANew;
803     BYTE                    byBBVGACurrent;
804     BYTE                    abyBBVGA[BB_VGA_LEVEL];
805     LONG                    ldBmThreshold[BB_VGA_LEVEL];
806
807     BYTE                    byBBPreEDRSSI;
808     BYTE                    byBBPreEDIndex;
809
810     BOOL                    bRadioCmd;
811     DWORD                   dwDiagRefCount;
812
813     // For FOE Tuning
814     BYTE                    byFOETuning;
815
816     // For Auto Power Tunning
817
818     BYTE                    byAutoPwrTunning;
819     SHORT                   sPSetPointCCK;
820     SHORT                   sPSetPointOFDMG;
821     SHORT                   sPSetPointOFDMA;
822     LONG                    lPFormulaOffset;
823     SHORT                   sPThreshold;
824     CHAR                    cAdjustStep;
825     CHAR                    cMinTxAGC;
826
827     // For RF Power table
828     BYTE                    byCCKPwr;
829     BYTE                    byOFDMPwrG;
830     BYTE                    byCurPwr;
831     I8                      byCurPwrdBm;
832     BYTE                    abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1];
833     BYTE                    abyOFDMPwrTbl[CB_MAX_CHANNEL+1];
834     I8                      abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1];
835     I8                      abyOFDMDefaultPwr[CB_MAX_CHANNEL+1];
836     I8                      abyRegPwr[CB_MAX_CHANNEL+1];
837     I8                      abyLocalPwr[CB_MAX_CHANNEL+1];
838
839
840     // BaseBand Loopback Use
841     BYTE                    byBBCR4d;
842     BYTE                    byBBCRc9;
843     BYTE                    byBBCR88;
844     BYTE                    byBBCR09;
845
846     // command timer
847     struct timer_list       sTimerCommand;
848 #ifdef TxInSleep
849      struct timer_list       sTimerTxData;
850      ULONG                       nTxDataTimeCout;
851      BOOL  fTxDataInSleep;
852      BOOL  IsTxDataTrigger;
853 #endif
854
855 #ifdef WPA_SM_Transtatus
856     BOOL  fWPA_Authened;           //is WPA/WPA-PSK or WPA2/WPA2-PSK authen??
857 #endif
858     BYTE            byReAssocCount;   //mike add:re-association retry times!
859     BYTE            byLinkWaitCount;
860
861
862     BYTE                    abyNodeName[17];
863
864     BOOL                    bDiversityRegCtlON;
865     BOOL                    bDiversityEnable;
866     ULONG                   ulDiversityNValue;
867     ULONG                   ulDiversityMValue;
868     BYTE                    byTMax;
869     BYTE                    byTMax2;
870     BYTE                    byTMax3;
871     ULONG                   ulSQ3TH;
872
873 // ANT diversity
874     ULONG                   uDiversityCnt;
875     BYTE                    byAntennaState;
876     ULONG                   ulRatio_State0;
877     ULONG                   ulRatio_State1;
878
879     //SQ3 functions for antenna diversity
880     struct timer_list           TimerSQ3Tmax1;
881     struct timer_list           TimerSQ3Tmax2;
882     struct timer_list           TimerSQ3Tmax3;
883
884
885     ULONG                   uNumSQ3[MAX_RATE];
886     WORD                    wAntDiversityMaxRate;
887
888
889     SEthernetHeader         sTxEthHeader;
890     SEthernetHeader         sRxEthHeader;
891     BYTE                    abyBroadcastAddr[U_ETHER_ADDR_LEN];
892     BYTE                    abySNAP_RFC1042[U_ETHER_ADDR_LEN];
893     BYTE                    abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN];
894      BYTE                        abyEEPROM[EEP_MAX_CONTEXT_SIZE];  //DWORD alignment
895     // Pre-Authentication & PMK cache
896     SPMKID                  gsPMKID;
897     SPMKIDCandidateEvent    gsPMKIDCandidate;
898
899
900     // for 802.11h
901     BOOL                    b11hEnable;
902     BYTE                    abyCountryCode[3];
903     // for 802.11h DFS
904     UINT                    uNumOfMeasureEIDs;
905     PWLAN_IE_MEASURE_REQ    pCurrMeasureEID;
906     BOOL                    bMeasureInProgress;
907     BYTE                    byOrgChannel;
908     BYTE                    byOrgRCR;
909     DWORD                   dwOrgMAR0;
910     DWORD                   dwOrgMAR4;
911     BYTE                    byBasicMap;
912     BYTE                    byCCAFraction;
913     BYTE                    abyRPIs[8];
914     DWORD                   dwRPIs[8];
915     BOOL                    bChannelSwitch;
916     BYTE                    byNewChannel;
917     BYTE                    byChannelSwitchCount;
918     BOOL                    bQuietEnable;
919     BOOL                    bEnableFirstQuiet;
920     BYTE                    byQuietStartCount;
921     UINT                    uQuietEnqueue;
922     DWORD                   dwCurrentQuietEndTime;
923     SQuietControl           sQuiet[MAX_QUIET_COUNT];
924     // for 802.11h TPC
925     BOOL                    bCountryInfo5G;
926     BOOL                    bCountryInfo24G;
927
928     WORD                    wBeaconInterval;
929
930     //WPA supplicant deamon
931         struct net_device       *wpadev;
932         BOOL                    bWPADEVUp;
933     struct sk_buff          *skb;
934 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
935 /*
936         BOOL                 bwextstep0;
937         BOOL                 bwextstep1;
938         BOOL                 bwextstep2;
939         BOOL                 bwextstep3;
940         */
941         UINT                   bwextcount;
942         BOOL                 bWPASuppWextEnabled;
943 #endif
944
945     //--
946 #ifdef HOSTAP
947     // user space daemon: hostapd, is used for HOSTAP
948         BOOL                    bEnableHostapd;
949         BOOL                    bEnable8021x;
950         BOOL                    bEnableHostWEP;
951         struct net_device       *apdev;
952         int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
953 #endif
954     UINT                    uChannel;
955     BOOL                    bMACSuspend;
956
957 #ifdef WIRELESS_EXT
958         struct iw_statistics    wstats;         // wireless stats
959 #endif /* WIRELESS_EXT */
960     BOOL                    bCommit;
961
962 } DEVICE_INFO, *PSDevice;
963
964
965 //PLICE_DEBUG->
966
967
968  inline  static VOID   EnQueue (PSDevice pDevice,PSRxMgmtPacket  pRxMgmtPacket)
969 {
970         //printk("Enter EnQueue:tail is %d\n",pDevice->rxManeQueue.tail);
971         if ((pDevice->rxManeQueue.tail+1) % NUM == pDevice->rxManeQueue.head)
972         {
973                 //printk("Queue is Full,tail is %d\n",pDevice->rxManeQueue.tail);
974                 return ;
975         }
976         else
977         {
978                 pDevice->rxManeQueue.tail = (pDevice->rxManeQueue.tail+1)% NUM;
979                 pDevice->rxManeQueue.Q[pDevice->rxManeQueue.tail] = pRxMgmtPacket;
980                 pDevice->rxManeQueue.packet_num++;
981                 //printk("packet num is %d\n",pDevice->rxManeQueue.packet_num);
982         }
983 }
984
985
986
987
988         inline  static  PSRxMgmtPacket DeQueue (PSDevice pDevice)
989 {
990         PSRxMgmtPacket  pRxMgmtPacket;
991         if (pDevice->rxManeQueue.tail == pDevice->rxManeQueue.head)
992         {
993                 printk("Queue is Empty\n");
994                 return NULL;
995         }
996         else
997         {
998                 int     x;
999                 //x=pDevice->rxManeQueue.head = (pDevice->rxManeQueue.head+1)%NUM;
1000                 pDevice->rxManeQueue.head = (pDevice->rxManeQueue.head+1)%NUM;
1001                 x = pDevice->rxManeQueue.head;
1002                 //printk("Enter DeQueue:head is %d\n",x);
1003                 pRxMgmtPacket = pDevice->rxManeQueue.Q[x];
1004                 pDevice->rxManeQueue.packet_num--;
1005                 return pRxMgmtPacket;
1006         }
1007 }
1008
1009 VOID    InitRxManagementQueue(PSDevice   pDevice);
1010
1011
1012
1013 //PLICE_DEBUG<-
1014
1015
1016
1017
1018
1019
1020 inline static BOOL device_get_ip(PSDevice pInfo) {
1021     struct in_device* in_dev=(struct in_device*) pInfo->dev->ip_ptr;
1022     struct in_ifaddr* ifa;
1023
1024     if (in_dev!=NULL) {
1025         ifa=(struct in_ifaddr*) in_dev->ifa_list;
1026         if (ifa!=NULL) {
1027             memcpy(pInfo->abyIPAddr,&ifa->ifa_address,4);
1028             return TRUE;
1029         }
1030     }
1031     return FALSE;
1032 }
1033
1034
1035
1036 static inline PDEVICE_RD_INFO alloc_rd_info(void) {
1037     PDEVICE_RD_INFO  ptr;
1038     if ((ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC)) == NULL)
1039         return NULL;
1040     else {
1041         memset(ptr,0,sizeof(DEVICE_RD_INFO));
1042         return ptr;
1043     }
1044 }
1045
1046 static inline PDEVICE_TD_INFO alloc_td_info(void) {
1047     PDEVICE_TD_INFO  ptr;
1048     if ((ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC))==NULL)
1049         return NULL;
1050     else {
1051         memset(ptr,0,sizeof(DEVICE_TD_INFO));
1052         return ptr;
1053     }
1054 }
1055
1056 /*---------------------  Export Functions  --------------------------*/
1057
1058 BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex);
1059 BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF);
1060 int Config_FileOperation(PSDevice pDevice,BOOL fwrite,unsigned char *Parameter);
1061 #endif
1062
1063