1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#ifndef __DEVICE_H__
30#define __DEVICE_H__
31
32#include <linux/module.h>
33#include <linux/types.h>
34#include <linux/init.h>
35#include <linux/mm.h>
36#include <linux/errno.h>
37#include <linux/ioport.h>
38#include <linux/pci.h>
39#include <linux/kernel.h>
40#include <linux/netdevice.h>
41#include <linux/etherdevice.h>
42#include <linux/skbuff.h>
43#include <linux/delay.h>
44#include <linux/timer.h>
45#include <linux/slab.h>
46#include <linux/interrupt.h>
47#include <linux/string.h>
48#include <linux/wait.h>
49#include <linux/if_arp.h>
50#include <linux/sched.h>
51#include <linux/io.h>
52#include <linux/if.h>
53
54#include <linux/uaccess.h>
55#include <linux/proc_fs.h>
56#include <linux/inetdevice.h>
57#include <linux/reboot.h>
58#ifdef SIOCETHTOOL
59#define DEVICE_ETHTOOL_IOCTL_SUPPORT
60#include <linux/ethtool.h>
61#else
62#undef DEVICE_ETHTOOL_IOCTL_SUPPORT
63#endif
64
65#include <linux/wireless.h>
66#include <net/iw_handler.h>
67
68
69#ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
70#define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
71#endif
72
73
74
75
76
77
78
79
80
81#include "device_cfg.h"
82#include "ttype.h"
83#include "80211hdr.h"
84#include "tether.h"
85#include "wmgr.h"
86#include "wcmd.h"
87#include "mib.h"
88#include "srom.h"
89#include "rc4.h"
90#include "desc.h"
91#include "key.h"
92#include "mac.h"
93
94
95
96
97
98
99
100
101
102
103#define MAC_MAX_CONTEXT_REG (256+128)
104
105#define MAX_MULTICAST_ADDRESS_NUM 32
106#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN)
107
108
109
110
111
112
113#define DUPLICATE_RX_CACHE_LENGTH 5
114
115#define NUM_KEY_ENTRY 11
116
117#define TX_WEP_NONE 0
118#define TX_WEP_OTF 1
119#define TX_WEP_SW 2
120#define TX_WEP_SWOTP 3
121#define TX_WEP_OTPSW 4
122#define TX_WEP_SW232 5
123
124#define KEYSEL_WEP40 0
125#define KEYSEL_WEP104 1
126#define KEYSEL_TKIP 2
127#define KEYSEL_CCMP 3
128
129
130
131#define AUTO_FB_NONE 0
132#define AUTO_FB_0 1
133#define AUTO_FB_1 2
134
135#define FB_RATE0 0
136#define FB_RATE1 1
137
138
139#define ANT_A 0
140#define ANT_B 1
141#define ANT_DIVERSITY 2
142#define ANT_RXD_TXA 3
143#define ANT_RXD_TXB 4
144#define ANT_UNKNOWN 0xFF
145
146#define MAXCHECKHANGCNT 4
147
148#define BB_VGA_LEVEL 4
149#define BB_VGA_CHANGE_THRESHOLD 16
150
151
152
153#ifndef RUN_AT
154#define RUN_AT(x) (jiffies+(x))
155#endif
156
157
158#define RESERV_AC0DMA 4
159
160
161
162
163
164#define AVAIL_TD(p,q) ((p)->sOpts.nTxDescs[(q)]-((p)->iTDUsed[(q)]))
165
166
167#define NUM 64
168
169
170
171
172#define PRIVATE_Message 0
173
174
175
176
177#define DBG_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
178#define PRINT_K(p, args...) {if (PRIVATE_Message) printk( p ,##args);}
179
180
181typedef enum _VIA_BB_TYPE
182{
183 BB_TYPE_11A=0,
184 BB_TYPE_11B,
185 BB_TYPE_11G
186} VIA_BB_TYPE, *PVIA_BB_TYPE;
187
188
189typedef enum _VIA_PKT_TYPE
190{
191 PK_TYPE_11A=0,
192 PK_TYPE_11B,
193 PK_TYPE_11GB,
194 PK_TYPE_11GA
195} VIA_PKT_TYPE, *PVIA_PKT_TYPE;
196
197
198typedef enum __device_msg_level {
199 MSG_LEVEL_ERR=0,
200 MSG_LEVEL_NOTICE=1,
201 MSG_LEVEL_INFO=2,
202 MSG_LEVEL_VERBOSE=3,
203 MSG_LEVEL_DEBUG=4
204} DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
205
206typedef enum __device_init_type {
207 DEVICE_INIT_COLD=0,
208 DEVICE_INIT_RESET,
209 DEVICE_INIT_DXPL
210} DEVICE_INIT_TYPE, *PDEVICE_INIT_TYPE;
211
212
213
214
215#define MAX_BSSIDINFO_4_PMKID 16
216#define MAX_PMKIDLIST 5
217
218#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
219
220
221typedef unsigned char NDIS_802_11_PMKID_VALUE[16];
222
223
224typedef enum _NDIS_802_11_WEP_STATUS
225{
226 Ndis802_11WEPEnabled,
227 Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
228 Ndis802_11WEPDisabled,
229 Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
230 Ndis802_11WEPKeyAbsent,
231 Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
232 Ndis802_11WEPNotSupported,
233 Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
234 Ndis802_11Encryption2Enabled,
235 Ndis802_11Encryption2KeyAbsent,
236 Ndis802_11Encryption3Enabled,
237 Ndis802_11Encryption3KeyAbsent
238} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
239 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
240
241
242typedef enum _NDIS_802_11_STATUS_TYPE
243{
244 Ndis802_11StatusType_Authentication,
245 Ndis802_11StatusType_MediaStreamMode,
246 Ndis802_11StatusType_PMKID_CandidateList,
247 Ndis802_11StatusTypeMax
248} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
249
250
251typedef struct _PMKID_CANDIDATE {
252 NDIS_802_11_MAC_ADDRESS BSSID;
253 unsigned long Flags;
254} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
255
256
257typedef struct _BSSID_INFO
258{
259 NDIS_802_11_MAC_ADDRESS BSSID;
260 NDIS_802_11_PMKID_VALUE PMKID;
261} BSSID_INFO, *PBSSID_INFO;
262
263typedef struct tagSPMKID {
264 unsigned long Length;
265 unsigned long BSSIDInfoCount;
266 BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
267} SPMKID, *PSPMKID;
268
269typedef struct tagSPMKIDCandidateEvent {
270 NDIS_802_11_STATUS_TYPE StatusType;
271 unsigned long Version;
272 unsigned long NumCandidates;
273 PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
274} SPMKIDCandidateEvent, *PSPMKIDCandidateEvent;
275
276
277
278
279#define MAX_QUIET_COUNT 8
280
281typedef struct tagSQuietControl {
282 bool bEnable;
283 unsigned long dwStartTime;
284 unsigned char byPeriod;
285 unsigned short wDuration;
286} SQuietControl, *PSQuietControl;
287
288
289typedef struct __chip_info_tbl{
290 CHIP_TYPE chip_id;
291 char* name;
292 int io_size;
293 int nTxQueue;
294 u32 flags;
295} CHIP_INFO, *PCHIP_INFO;
296
297
298typedef enum {
299 OWNED_BY_HOST=0,
300 OWNED_BY_NIC=1
301} DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
302
303
304
305typedef struct tagSCacheEntry{
306 unsigned short wFmSequence;
307 unsigned char abyAddr2[ETH_ALEN];
308} SCacheEntry, *PSCacheEntry;
309
310typedef struct tagSCache{
311
312
313
314 unsigned int uInPtr;
315 SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
316} SCache, *PSCache;
317
318#define CB_MAX_RX_FRAG 64
319
320typedef struct tagSDeFragControlBlock
321{
322 unsigned short wSequence;
323 unsigned short wFragNum;
324 unsigned char abyAddr2[ETH_ALEN];
325 unsigned int uLifetime;
326 struct sk_buff* skb;
327 unsigned char *pbyRxBuffer;
328 unsigned int cbFrameLength;
329 bool bInUse;
330} SDeFragControlBlock, *PSDeFragControlBlock;
331
332
333
334
335#define DEVICE_FLAGS_IP_ALIGN 0x00000001UL
336#define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL
337#define DEVICE_FLAGS_OP_MODE 0x00000004UL
338#define DEVICE_FLAGS_PS_MODE 0x00000008UL
339#define DEVICE_FLAGS_80211h_MODE 0x00000010UL
340#define DEVICE_FLAGS_DiversityANT 0x00000020UL
341
342
343#define DEVICE_FLAGS_OPENED 0x00010000UL
344#define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL
345
346#define DEVICE_FLAGS_TX_ALIGN 0x01000000UL
347#define DEVICE_FLAGS_HAVE_CAM 0x02000000UL
348#define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL
349
350
351#define DEVICE_LINK_FAIL 0x00000001UL
352#define DEVICE_SPEED_10 0x00000002UL
353#define DEVICE_SPEED_100 0x00000004UL
354#define DEVICE_SPEED_1000 0x00000008UL
355#define DEVICE_DUPLEX_FULL 0x00000010UL
356#define DEVICE_AUTONEG_ENABLE 0x00000020UL
357#define DEVICE_FORCED_BY_EEPROM 0x00000040UL
358
359#define DEVICE_LINK_CHANGE 0x00000001UL
360
361
362
363
364
365typedef struct _RxManagementQueue
366{
367 int packet_num;
368 int head,tail;
369 PSRxMgmtPacket Q[NUM];
370} RxManagementQueue,*PSRxManagementQueue;
371
372
373
374
375
376
377typedef struct __device_opt {
378 int nRxDescs0;
379 int nRxDescs1;
380 int nTxDescs[2];
381 int int_works;
382 int rts_thresh;
383 int frag_thresh;
384 int data_rate;
385 int channel_num;
386 int short_retry;
387 int long_retry;
388 int bbp_type;
389 u32 flags;
390} OPTIONS, *POPTIONS;
391
392
393typedef struct __device_info {
394 struct __device_info* next;
395 struct __device_info* prev;
396
397 struct pci_dev* pcid;
398
399#ifdef CONFIG_PM
400 u32 pci_state[16];
401#endif
402
403
404 struct net_device* dev;
405 struct net_device* next_module;
406 struct net_device_stats stats;
407
408
409 dma_addr_t pool_dma;
410 dma_addr_t rd0_pool_dma;
411 dma_addr_t rd1_pool_dma;
412
413 dma_addr_t td0_pool_dma;
414 dma_addr_t td1_pool_dma;
415
416 dma_addr_t tx_bufs_dma0;
417 dma_addr_t tx_bufs_dma1;
418 dma_addr_t tx_beacon_dma;
419
420 unsigned char *tx0_bufs;
421 unsigned char *tx1_bufs;
422 unsigned char *tx_beacon_bufs;
423
424 CHIP_TYPE chip_id;
425
426 unsigned long PortOffset;
427 unsigned long dwIsr;
428 u32 memaddr;
429 u32 ioaddr;
430 u32 io_size;
431
432 unsigned char byRevId;
433 unsigned short SubSystemID;
434 unsigned short SubVendorID;
435
436 int nTxQueues;
437 volatile int iTDUsed[TYPE_MAXTD];
438
439 volatile PSTxDesc apCurrTD[TYPE_MAXTD];
440 volatile PSTxDesc apTailTD[TYPE_MAXTD];
441
442 volatile PSTxDesc apTD0Rings;
443 volatile PSTxDesc apTD1Rings;
444
445 volatile PSRxDesc aRD0Ring;
446 volatile PSRxDesc aRD1Ring;
447 volatile PSRxDesc pCurrRD[TYPE_MAXRD];
448 SCache sDupRxCache;
449
450 SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG];
451 unsigned int cbDFCB;
452 unsigned int cbFreeDFCB;
453 unsigned int uCurrentDFCBIdx;
454
455 OPTIONS sOpts;
456
457 u32 flags;
458
459 u32 rx_buf_sz;
460 int multicast_limit;
461 unsigned char byRxMode;
462
463 spinlock_t lock;
464
465 struct tasklet_struct RxMngWorkItem;
466 RxManagementQueue rxManeQueue;
467
468
469 pid_t MLMEThr_pid;
470 struct completion notify;
471 struct semaphore mlme_semaphore;
472
473
474
475 u32 rx_bytes;
476
477
478 unsigned char byLocalID;
479 unsigned char byRFType;
480
481 unsigned char byMaxPwrLevel;
482 unsigned char byZoneType;
483 bool bZoneRegExist;
484 unsigned char byOriginalZonetype;
485 unsigned char abyMacContext[MAC_MAX_CONTEXT_REG];
486 bool bLinkPass;
487 unsigned char abyCurrentNetAddr[ETH_ALEN];
488
489
490 SStatCounter scStatistic;
491
492 SDot11Counters s802_11Counter;
493
494
495
496 PSMgmtObject pMgmt;
497 SMgmtObject sMgmtObj;
498
499
500 unsigned int uCurrRSSI;
501 unsigned char byCurrSQ;
502
503 unsigned long dwTxAntennaSel;
504 unsigned long dwRxAntennaSel;
505 unsigned char byAntennaCount;
506 unsigned char byRxAntennaMode;
507 unsigned char byTxAntennaMode;
508 bool bTxRxAntInv;
509
510 unsigned char *pbyTmpBuff;
511 unsigned int uSIFS;
512 unsigned int uDIFS;
513 unsigned int uEIFS;
514 unsigned int uSlot;
515 unsigned int uCwMin;
516 unsigned int uCwMax;
517
518 unsigned char bySIFS;
519 unsigned char byDIFS;
520 unsigned char byEIFS;
521 unsigned char bySlot;
522 unsigned char byCWMaxMin;
523 CARD_PHY_TYPE eCurrentPHYType;
524
525
526 VIA_BB_TYPE byBBType;
527 VIA_PKT_TYPE byPacketType;
528 unsigned short wBasicRate;
529 unsigned char byACKRate;
530 unsigned char byTopOFDMBasicRate;
531 unsigned char byTopCCKBasicRate;
532
533 unsigned char byMinChannel;
534 unsigned char byMaxChannel;
535 unsigned int uConnectionRate;
536
537 unsigned char byPreambleType;
538 unsigned char byShortPreamble;
539
540 unsigned short wCurrentRate;
541 unsigned short wRTSThreshold;
542 unsigned short wFragmentationThreshold;
543 unsigned char byShortRetryLimit;
544 unsigned char byLongRetryLimit;
545 CARD_OP_MODE eOPMode;
546 unsigned char byOpMode;
547 bool bBSSIDFilter;
548 unsigned short wMaxTransmitMSDULifetime;
549 unsigned char abyBSSID[ETH_ALEN];
550 unsigned char abyDesireBSSID[ETH_ALEN];
551 unsigned short wCTSDuration;
552 unsigned short wACKDuration;
553 unsigned short wRTSTransmitLen;
554 unsigned char byRTSServiceField;
555 unsigned char byRTSSignalField;
556
557 unsigned long dwMaxReceiveLifetime;
558
559 bool bCCK;
560 bool bEncryptionEnable;
561 bool bLongHeader;
562 bool bShortSlotTime;
563 bool bProtectMode;
564 bool bNonERPPresent;
565 bool bBarkerPreambleMd;
566
567 unsigned char byERPFlag;
568 unsigned short wUseProtectCntDown;
569
570 bool bRadioControlOff;
571 bool bRadioOff;
572 bool bEnablePSMode;
573 unsigned short wListenInterval;
574 bool bPWBitOn;
575 WMAC_POWER_MODE ePSMode;
576
577
578
579 unsigned char byRadioCtl;
580 unsigned char byGPIO;
581 bool bHWRadioOff;
582 bool bPrvActive4RadioOFF;
583 bool bGPIOBlockRead;
584
585
586 unsigned short wSeqCounter;
587 unsigned short wBCNBufLen;
588 bool bBeaconBufReady;
589 bool bBeaconSent;
590 bool bIsBeaconBufReadySet;
591 unsigned int cbBeaconBufReadySetCnt;
592 bool bFixRate;
593 unsigned char byCurrentCh;
594 unsigned int uScanTime;
595
596 CMD_STATE eCommandState;
597
598 CMD_CODE eCommand;
599 bool bBeaconTx;
600
601 bool bStopBeacon;
602 bool bStopDataPkt;
603 bool bStopTx0Pkt;
604 unsigned int uAutoReConnectTime;
605
606
607
608 CMD_ITEM eCmdQueue[CMD_Q_SIZE];
609 unsigned int uCmdDequeueIdx;
610 unsigned int uCmdEnqueueIdx;
611 unsigned int cbFreeCmdQueue;
612 bool bCmdRunning;
613 bool bCmdClear;
614
615
616
617 bool bRoaming;
618
619 unsigned char abyIPAddr[4];
620
621 unsigned long ulTxPower;
622 NDIS_802_11_WEP_STATUS eEncryptionStatus;
623 bool bTransmitKey;
624
625
626 NDIS_802_11_WEP_STATUS eOldEncryptionStatus;
627
628 SKeyManagement sKey;
629 unsigned long dwIVCounter;
630
631 QWORD qwPacketNumber;
632 unsigned int uCurrentWEPMode;
633
634 RC4Ext SBox;
635 unsigned char abyPRNG[WLAN_WEPMAX_KEYLEN+3];
636 unsigned char byKeyIndex;
637 unsigned int uKeyLength;
638 unsigned char abyKey[WLAN_WEP232_KEYLEN];
639
640 bool bAES;
641 unsigned char byCntMeasure;
642
643
644 unsigned int uAssocCount;
645 bool bMoreData;
646
647
648 bool bGrpAckPolicy;
649
650
651 bool bAssocInfoSet;
652
653
654 unsigned char byAutoFBCtrl;
655
656 bool bTxMICFail;
657 bool bRxMICFail;
658
659
660 unsigned int uRATEIdx;
661
662
663
664 bool bUpdateBBVGA;
665 unsigned int uBBVGADiffCount;
666 unsigned char byBBVGANew;
667 unsigned char byBBVGACurrent;
668 unsigned char abyBBVGA[BB_VGA_LEVEL];
669 long ldBmThreshold[BB_VGA_LEVEL];
670
671 unsigned char byBBPreEDRSSI;
672 unsigned char byBBPreEDIndex;
673
674
675 bool bRadioCmd;
676 unsigned long dwDiagRefCount;
677
678
679 unsigned char byFOETuning;
680
681
682
683 unsigned char byAutoPwrTunning;
684 short sPSetPointCCK;
685 short sPSetPointOFDMG;
686 short sPSetPointOFDMA;
687 long lPFormulaOffset;
688 short sPThreshold;
689 char cAdjustStep;
690 char cMinTxAGC;
691
692
693 unsigned char byCCKPwr;
694 unsigned char byOFDMPwrG;
695 unsigned char byCurPwr;
696 char byCurPwrdBm;
697 unsigned char abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1];
698 unsigned char abyOFDMPwrTbl[CB_MAX_CHANNEL+1];
699 char abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1];
700 char abyOFDMDefaultPwr[CB_MAX_CHANNEL+1];
701 char abyRegPwr[CB_MAX_CHANNEL+1];
702 char abyLocalPwr[CB_MAX_CHANNEL+1];
703
704
705
706 unsigned char byBBCR4d;
707 unsigned char byBBCRc9;
708 unsigned char byBBCR88;
709 unsigned char byBBCR09;
710
711
712 struct timer_list sTimerCommand;
713#ifdef TxInSleep
714 struct timer_list sTimerTxData;
715 unsigned long nTxDataTimeCout;
716 bool fTxDataInSleep;
717 bool IsTxDataTrigger;
718#endif
719
720#ifdef WPA_SM_Transtatus
721 bool fWPA_Authened;
722#endif
723 unsigned char byReAssocCount;
724 unsigned char byLinkWaitCount;
725
726
727 unsigned char abyNodeName[17];
728
729 bool bDiversityRegCtlON;
730 bool bDiversityEnable;
731 unsigned long ulDiversityNValue;
732 unsigned long ulDiversityMValue;
733 unsigned char byTMax;
734 unsigned char byTMax2;
735 unsigned char byTMax3;
736 unsigned long ulSQ3TH;
737
738
739 unsigned long uDiversityCnt;
740 unsigned char byAntennaState;
741 unsigned long ulRatio_State0;
742 unsigned long ulRatio_State1;
743
744
745 struct timer_list TimerSQ3Tmax1;
746 struct timer_list TimerSQ3Tmax2;
747 struct timer_list TimerSQ3Tmax3;
748
749
750 unsigned long uNumSQ3[MAX_RATE];
751 unsigned short wAntDiversityMaxRate;
752
753
754 SEthernetHeader sTxEthHeader;
755 SEthernetHeader sRxEthHeader;
756 unsigned char abyBroadcastAddr[ETH_ALEN];
757 unsigned char abySNAP_RFC1042[ETH_ALEN];
758 unsigned char abySNAP_Bridgetunnel[ETH_ALEN];
759 unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE];
760
761 SPMKID gsPMKID;
762 SPMKIDCandidateEvent gsPMKIDCandidate;
763
764
765
766 bool b11hEnable;
767 unsigned char abyCountryCode[3];
768
769 unsigned int uNumOfMeasureEIDs;
770 PWLAN_IE_MEASURE_REQ pCurrMeasureEID;
771 bool bMeasureInProgress;
772 unsigned char byOrgChannel;
773 unsigned char byOrgRCR;
774 unsigned long dwOrgMAR0;
775 unsigned long dwOrgMAR4;
776 unsigned char byBasicMap;
777 unsigned char byCCAFraction;
778 unsigned char abyRPIs[8];
779 unsigned long dwRPIs[8];
780 bool bChannelSwitch;
781 unsigned char byNewChannel;
782 unsigned char byChannelSwitchCount;
783 bool bQuietEnable;
784 bool bEnableFirstQuiet;
785 unsigned char byQuietStartCount;
786 unsigned int uQuietEnqueue;
787 unsigned long dwCurrentQuietEndTime;
788 SQuietControl sQuiet[MAX_QUIET_COUNT];
789
790 bool bCountryInfo5G;
791 bool bCountryInfo24G;
792
793 unsigned short wBeaconInterval;
794
795
796 struct net_device *wpadev;
797 bool bWPADEVUp;
798 struct sk_buff *skb;
799#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
800
801
802
803
804
805
806 unsigned int bwextcount;
807 bool bWPASuppWextEnabled;
808#endif
809
810
811#ifdef HOSTAP
812
813 bool bEnableHostapd;
814 bool bEnable8021x;
815 bool bEnableHostWEP;
816 struct net_device *apdev;
817 int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
818#endif
819 unsigned int uChannel;
820 bool bMACSuspend;
821
822 struct iw_statistics wstats;
823 bool bCommit;
824
825} DEVICE_INFO, *PSDevice;
826
827
828
829
830
831 inline static void EnQueue (PSDevice pDevice,PSRxMgmtPacket pRxMgmtPacket)
832{
833
834 if ((pDevice->rxManeQueue.tail+1) % NUM == pDevice->rxManeQueue.head)
835 {
836
837 return ;
838 }
839 else
840 {
841 pDevice->rxManeQueue.tail = (pDevice->rxManeQueue.tail+1)% NUM;
842 pDevice->rxManeQueue.Q[pDevice->rxManeQueue.tail] = pRxMgmtPacket;
843 pDevice->rxManeQueue.packet_num++;
844
845 }
846}
847
848
849
850
851 inline static PSRxMgmtPacket DeQueue (PSDevice pDevice)
852{
853 PSRxMgmtPacket pRxMgmtPacket;
854 if (pDevice->rxManeQueue.tail == pDevice->rxManeQueue.head)
855 {
856 printk("Queue is Empty\n");
857 return NULL;
858 }
859 else
860 {
861 int x;
862
863 pDevice->rxManeQueue.head = (pDevice->rxManeQueue.head+1)%NUM;
864 x = pDevice->rxManeQueue.head;
865
866 pRxMgmtPacket = pDevice->rxManeQueue.Q[x];
867 pDevice->rxManeQueue.packet_num--;
868 return pRxMgmtPacket;
869 }
870}
871
872void InitRxManagementQueue(PSDevice pDevice);
873
874
875
876
877
878
879
880
881
882
883inline static bool device_get_ip(PSDevice pInfo) {
884 struct in_device* in_dev=(struct in_device*) pInfo->dev->ip_ptr;
885 struct in_ifaddr* ifa;
886
887 if (in_dev!=NULL) {
888 ifa=(struct in_ifaddr*) in_dev->ifa_list;
889 if (ifa!=NULL) {
890 memcpy(pInfo->abyIPAddr,&ifa->ifa_address,4);
891 return true;
892 }
893 }
894 return false;
895}
896
897
898
899static inline PDEVICE_RD_INFO alloc_rd_info(void) {
900 PDEVICE_RD_INFO ptr;
901 ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC);
902 if (ptr == NULL)
903 return NULL;
904 else {
905 memset(ptr,0,sizeof(DEVICE_RD_INFO));
906 return ptr;
907 }
908}
909
910static inline PDEVICE_TD_INFO alloc_td_info(void) {
911 PDEVICE_TD_INFO ptr;
912 ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC);
913 if (ptr == NULL)
914 return NULL;
915 else {
916 memset(ptr,0,sizeof(DEVICE_TD_INFO));
917 return ptr;
918 }
919}
920
921
922
923bool device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeIndex);
924bool device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF);
925int Config_FileOperation(PSDevice pDevice, bool fwrite, unsigned char *Parameter);
926#endif
927
928
929