2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
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.
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.
20 * Purpose: Provide functions to setup NIC operation mode
22 * s_vSafeResetTx - Rest Tx
23 * CARDvSetRSPINF - Set RSPINF
24 * vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS
25 * CARDvUpdateBasicTopRate - Update BasicTopRate
26 * CARDbAddBasicRate - Add to BasicRateSet
27 * CARDbSetBasicRate - Set Basic Tx Rate
28 * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet
29 * CARDvSetLoopbackMode - Set Loopback mode
30 * CARDbSoftwareReset - Sortware reset NIC
31 * CARDqGetTSFOffset - Caculate TSFOffset
32 * CARDbGetCurrentTSF - Read Current NIC TSF counter
33 * CARDqGetNextTBTT - Caculate Next Beacon TSF counter
34 * CARDvSetFirstNextTBTT - Set NIC Beacon time
35 * CARDvUpdateNextTBTT - Sync. NIC Beacon time
36 * CARDbRadioPowerOff - Turn Off NIC Radio Power
37 * CARDbRadioPowerOn - Turn On NIC Radio Power
38 * CARDbSetWEPMode - Set NIC Wep mode
39 * CARDbSetTxPower - Set NIC tx power
42 * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
43 * 08-26-2003 Kyle Hsu: Modify the defination type of dwIoBase.
44 * 09-01-2003 Bryan YC Fan: Add vUpdateIFS().
62 /*--------------------- Static Definitions -------------------------*/
64 //static int msglevel =MSG_LEVEL_DEBUG;
65 static int msglevel
=MSG_LEVEL_INFO
;
68 /*--------------------- Static Definitions -------------------------*/
69 #define CB_TXPOWER_LEVEL 6
71 /*--------------------- Static Classes ----------------------------*/
73 /*--------------------- Static Variables --------------------------*/
74 //const WORD cwRXBCNTSFOff[MAX_RATE] =
75 //{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
77 const WORD cwRXBCNTSFOff
[MAX_RATE
] =
78 {192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
80 /*--------------------- Static Functions --------------------------*/
82 /*--------------------- Export Variables --------------------------*/
84 /*--------------------- Export Functions --------------------------*/
86 * Description: Set NIC media channel
90 * pDevice - The adapter to be set
91 * uConnectionChannel - Channel to be set
95 void CARDbSetMediaChannel(void *pDeviceHandler
, unsigned int uConnectionChannel
)
97 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
99 if (pDevice
->byBBType
== BB_TYPE_11A
) { // 15 ~ 38
100 if ((uConnectionChannel
< (CB_MAX_CHANNEL_24G
+1)) || (uConnectionChannel
> CB_MAX_CHANNEL
))
101 uConnectionChannel
= (CB_MAX_CHANNEL_24G
+1);
103 if ((uConnectionChannel
> CB_MAX_CHANNEL_24G
) || (uConnectionChannel
== 0)) // 1 ~ 14
104 uConnectionChannel
= 1;
108 MACvRegBitsOn(pDevice
, MAC_REG_MACCR
, MACCR_CLRNAV
);
110 // Set Channel[7] = 0 to tell H/W channel is changing now.
111 MACvRegBitsOff(pDevice
, MAC_REG_CHANNEL
, 0x80);
113 //if (pMgmt->uCurrChannel == uConnectionChannel)
116 CONTROLnsRequestOut(pDevice
,
117 MESSAGE_TYPE_SELECT_CHANNLE
,
118 (WORD
) uConnectionChannel
,
124 //{{ RobertYu: 20041202
125 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
127 if (pDevice
->byBBType
== BB_TYPE_11A
) {
128 pDevice
->byCurPwr
= 0xFF;
129 RFbRawSetPower(pDevice
, pDevice
->abyOFDMAPwrTbl
[uConnectionChannel
-15], RATE_54M
);
130 } else if (pDevice
->byBBType
== BB_TYPE_11G
) {
131 pDevice
->byCurPwr
= 0xFF;
132 RFbRawSetPower(pDevice
, pDevice
->abyOFDMPwrTbl
[uConnectionChannel
-1], RATE_54M
);
134 pDevice
->byCurPwr
= 0xFF;
135 RFbRawSetPower(pDevice
, pDevice
->abyCCKPwrTbl
[uConnectionChannel
-1], RATE_1M
);
137 ControlvWriteByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_CHANNEL
,(BYTE
)(uConnectionChannel
|0x80));
141 * Description: Get CCK mode basic rate
145 * pDevice - The adapter to be set
146 * wRateIdx - Receiving data rate
150 * Return Value: response Control frame rate
153 static WORD
swGetCCKControlRate(void *pDeviceHandler
, WORD wRateIdx
)
155 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
156 unsigned int ui
= (unsigned int)wRateIdx
;
157 while (ui
> RATE_1M
) {
158 if (pDevice
->wBasicRate
& ((WORD
)1 << ui
)) {
163 return (WORD
)RATE_1M
;
167 * Description: Get OFDM mode basic rate
171 * pDevice - The adapter to be set
172 * wRateIdx - Receiving data rate
176 * Return Value: response Control frame rate
179 static WORD
swGetOFDMControlRate(void *pDeviceHandler
, WORD wRateIdx
)
181 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
182 unsigned int ui
= (unsigned int)wRateIdx
;
184 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BASIC RATE: %X\n", pDevice
->wBasicRate
);
186 if (!CARDbIsOFDMinBasicRate(pDevice
)) {
187 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx
);
188 if (wRateIdx
> RATE_24M
)
192 while (ui
> RATE_11M
) {
193 if (pDevice
->wBasicRate
& ((WORD
)1 << ui
)) {
194 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate : %d\n", ui
);
199 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate: 6M\n");
200 return (WORD
)RATE_24M
;
204 * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode.
209 * byPktType - Tx Packet type
211 * pbyTxRate - pointer to RSPINF TxRate field
212 * pbyRsvTime - pointer to RSPINF RsvTime field
218 CARDvCaculateOFDMRParameter (
227 if (byBBType
== BB_TYPE_11A
) {//5GHZ
238 if (byBBType
== BB_TYPE_11A
) {//5GHZ
249 if (byBBType
== BB_TYPE_11A
) {//5GHZ
260 if (byBBType
== BB_TYPE_11A
) {//5GHZ
271 if (byBBType
== BB_TYPE_11A
) {//5GHZ
282 if (byBBType
== BB_TYPE_11A
) {//5GHZ
293 if (byBBType
== BB_TYPE_11A
) {//5GHZ
305 if (byBBType
== BB_TYPE_11A
) {//5GHZ
318 * Description: Set RSPINF
322 * pDevice - The adapter to be set
326 * Return Value: None.
329 void CARDvSetRSPINF(void *pDeviceHandler
, BYTE byBBType
)
331 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
332 BYTE abyServ
[4] = {0,0,0,0}; // For CCK
333 BYTE abySignal
[4] = {0,0,0,0};
334 WORD awLen
[4] = {0,0,0,0};
335 BYTE abyTxRate
[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM
336 BYTE abyRsvTime
[9] = {0,0,0,0,0,0,0,0,0};
341 BBvCaculateParameter(pDevice
,
343 swGetCCKControlRate(pDevice
, RATE_1M
),
351 BBvCaculateParameter(pDevice
,
353 swGetCCKControlRate(pDevice
, RATE_2M
),
361 BBvCaculateParameter(pDevice
,
363 swGetCCKControlRate(pDevice
, RATE_5M
),
371 BBvCaculateParameter(pDevice
,
373 swGetCCKControlRate(pDevice
, RATE_11M
),
381 CARDvCaculateOFDMRParameter (RATE_6M
,
387 CARDvCaculateOFDMRParameter (RATE_9M
,
393 CARDvCaculateOFDMRParameter (RATE_12M
,
399 CARDvCaculateOFDMRParameter (RATE_18M
,
405 CARDvCaculateOFDMRParameter (RATE_24M
,
411 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_36M
),
417 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_48M
),
423 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_54M
),
429 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_54M
),
434 abyData
[0] = (BYTE
)(awLen
[0]&0xFF);
435 abyData
[1] = (BYTE
)(awLen
[0]>>8);
436 abyData
[2] = abySignal
[0];
437 abyData
[3] = abyServ
[0];
439 abyData
[4] = (BYTE
)(awLen
[1]&0xFF);
440 abyData
[5] = (BYTE
)(awLen
[1]>>8);
441 abyData
[6] = abySignal
[1];
442 abyData
[7] = abyServ
[1];
444 abyData
[8] = (BYTE
)(awLen
[2]&0xFF);
445 abyData
[9] = (BYTE
)(awLen
[2]>>8);
446 abyData
[10] = abySignal
[2];
447 abyData
[11] = abyServ
[2];
449 abyData
[12] = (BYTE
)(awLen
[3]&0xFF);
450 abyData
[13] = (BYTE
)(awLen
[3]>>8);
451 abyData
[14] = abySignal
[3];
452 abyData
[15] = abyServ
[3];
454 for (i
= 0; i
< 9; i
++) {
455 abyData
[16+i
*2] = abyTxRate
[i
];
456 abyData
[16+i
*2+1] = abyRsvTime
[i
];
459 CONTROLnsRequestOut(pDevice
,
462 MESSAGE_REQUEST_MACREG
,
469 * Description: Update IFS
473 * pDevice - The adapter to be set
477 * Return Value: None.
480 void vUpdateIFS(void *pDeviceHandler
)
482 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
483 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
487 if (pDevice
->byPacketType
==PK_TYPE_11A
) {//0000 0000 0000 0000,11a
488 pDevice
->uSlot
= C_SLOT_SHORT
;
489 pDevice
->uSIFS
= C_SIFS_A
;
490 pDevice
->uDIFS
= C_SIFS_A
+ 2*C_SLOT_SHORT
;
491 pDevice
->uCwMin
= C_CWMIN_A
;
494 else if (pDevice
->byPacketType
==PK_TYPE_11B
) {//0000 0001 0000 0000,11b
495 pDevice
->uSlot
= C_SLOT_LONG
;
496 pDevice
->uSIFS
= C_SIFS_BG
;
497 pDevice
->uDIFS
= C_SIFS_BG
+ 2*C_SLOT_LONG
;
498 pDevice
->uCwMin
= C_CWMIN_B
;
501 else {// PK_TYPE_11GA & PK_TYPE_11GB
503 BOOL bOFDMRate
= FALSE
;
505 PWLAN_IE_SUPP_RATES pItemRates
= NULL
;
507 pDevice
->uSIFS
= C_SIFS_BG
;
508 if (pDevice
->bShortSlotTime
) {
509 pDevice
->uSlot
= C_SLOT_SHORT
;
511 pDevice
->uSlot
= C_SLOT_LONG
;
513 pDevice
->uDIFS
= C_SIFS_BG
+ 2*pDevice
->uSlot
;
515 pItemRates
= (PWLAN_IE_SUPP_RATES
)pDevice
->sMgmtObj
.abyCurrSuppRates
;
516 for (ii
= 0; ii
< pItemRates
->len
; ii
++) {
517 byRate
= (BYTE
)(pItemRates
->abyRates
[ii
]&0x7F);
518 if (RATEwGetRateIdx(byRate
) > RATE_11M
) {
523 if (bOFDMRate
== FALSE
) {
524 pItemRates
= (PWLAN_IE_SUPP_RATES
)pDevice
->sMgmtObj
.abyCurrExtSuppRates
;
525 for (ii
= 0; ii
< pItemRates
->len
; ii
++) {
526 byRate
= (BYTE
)(pItemRates
->abyRates
[ii
]&0x7F);
527 if (RATEwGetRateIdx(byRate
) > RATE_11M
) {
533 if (bOFDMRate
== TRUE
) {
534 pDevice
->uCwMin
= C_CWMIN_A
;
537 pDevice
->uCwMin
= C_CWMIN_B
;
542 pDevice
->uCwMax
= C_CWMAX
;
543 pDevice
->uEIFS
= C_EIFS
;
545 byData
[0] = (BYTE
)pDevice
->uSIFS
;
546 byData
[1] = (BYTE
)pDevice
->uDIFS
;
547 byData
[2] = (BYTE
)pDevice
->uEIFS
;
548 byData
[3] = (BYTE
)pDevice
->uSlot
;
549 CONTROLnsRequestOut(pDevice
,
552 MESSAGE_REQUEST_MACREG
,
556 byMaxMin
|= 0xA0;//1010 1111,C_CWMAX = 1023
557 CONTROLnsRequestOut(pDevice
,
560 MESSAGE_REQUEST_MACREG
,
565 void CARDvUpdateBasicTopRate(void *pDeviceHandler
)
567 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
568 BYTE byTopOFDM
= RATE_24M
, byTopCCK
= RATE_1M
;
571 //Determines the highest basic rate.
572 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
573 if ( (pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)) ) {
578 pDevice
->byTopOFDMBasicRate
= byTopOFDM
;
580 for (ii
= RATE_11M
;; ii
--) {
581 if ( (pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)) ) {
588 pDevice
->byTopCCKBasicRate
= byTopCCK
;
592 * Description: Set NIC Tx Basic Rate
596 * pDevice - The adapter to be set
597 * wBasicRate - Basic Rate to be set
601 * Return Value: TRUE if succeeded; FALSE if failed.
604 void CARDbAddBasicRate(void *pDeviceHandler
, WORD wRateIdx
)
606 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
607 WORD wRate
= (WORD
)(1<<wRateIdx
);
609 pDevice
->wBasicRate
|= wRate
;
611 //Determines the highest basic rate.
612 CARDvUpdateBasicTopRate(pDevice
);
615 BOOL
CARDbIsOFDMinBasicRate(void *pDeviceHandler
)
617 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
620 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
621 if ((pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)))
627 BYTE
CARDbyGetPktType(void *pDeviceHandler
)
629 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
631 if (pDevice
->byBBType
== BB_TYPE_11A
|| pDevice
->byBBType
== BB_TYPE_11B
) {
632 return (BYTE
)pDevice
->byBBType
;
634 else if (CARDbIsOFDMinBasicRate(pDevice
)) {
644 * Description: Caculate TSF offset of two TSF input
645 * Get TSF Offset from RxBCN's TSF and local TSF
649 * pDevice - The adapter to be sync.
650 * qwTSF1 - Rx BCN's TSF
655 * Return Value: TSF Offset value
658 QWORD
CARDqGetTSFOffset (BYTE byRxRate
, QWORD qwTSF1
, QWORD qwTSF2
)
661 WORD wRxBcnTSFOffst
= 0;
663 HIDWORD(qwTSFOffset
) = 0;
664 LODWORD(qwTSFOffset
) = 0;
666 wRxBcnTSFOffst
= cwRXBCNTSFOff
[byRxRate
%MAX_RATE
];
667 (qwTSF2
).u
.dwLowDword
+= (DWORD
)(wRxBcnTSFOffst
);
668 if ((qwTSF2
).u
.dwLowDword
< (DWORD
)(wRxBcnTSFOffst
)) {
669 (qwTSF2
).u
.dwHighDword
++;
671 LODWORD(qwTSFOffset
) = LODWORD(qwTSF1
) - LODWORD(qwTSF2
);
672 if (LODWORD(qwTSF1
) < LODWORD(qwTSF2
)) {
674 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
) - 1 ;
677 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
);
679 return (qwTSFOffset
);
685 * Description: Sync. TSF counter to BSS
686 * Get TSF offset and write to HW
690 * pDevice - The adapter to be sync.
691 * qwBSSTimestamp - Rx BCN's TSF
692 * qwLocalTSF - Local TSF
699 void CARDvAdjustTSF(void *pDeviceHandler
, BYTE byRxRate
,
700 QWORD qwBSSTimestamp
, QWORD qwLocalTSF
)
703 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
705 DWORD dwTSFOffset1
,dwTSFOffset2
;
708 HIDWORD(qwTSFOffset
) = 0;
709 LODWORD(qwTSFOffset
) = 0;
711 qwTSFOffset
= CARDqGetTSFOffset(byRxRate
, qwBSSTimestamp
, qwLocalTSF
);
713 // HW's TSF add TSF Offset reg
714 dwTSFOffset1
= LODWORD(qwTSFOffset
);
715 dwTSFOffset2
= HIDWORD(qwTSFOffset
);
718 pbyData
[0] = (BYTE
)dwTSFOffset1
;
719 pbyData
[1] = (BYTE
)(dwTSFOffset1
>>8);
720 pbyData
[2] = (BYTE
)(dwTSFOffset1
>>16);
721 pbyData
[3] = (BYTE
)(dwTSFOffset1
>>24);
722 pbyData
[4] = (BYTE
)dwTSFOffset2
;
723 pbyData
[5] = (BYTE
)(dwTSFOffset2
>>8);
724 pbyData
[6] = (BYTE
)(dwTSFOffset2
>>16);
725 pbyData
[7] = (BYTE
)(dwTSFOffset2
>>24);
727 CONTROLnsRequestOut(pDevice
,
728 MESSAGE_TYPE_SET_TSFTBTT
,
737 * Description: Read NIC TSF counter
738 * Get local TSF counter
742 * pDevice - The adapter to be read
744 * qwCurrTSF - Current TSF counter
746 * Return Value: TRUE if success; otherwise FALSE
749 BOOL
CARDbGetCurrentTSF(void *pDeviceHandler
, PQWORD pqwCurrTSF
)
751 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
753 LODWORD(*pqwCurrTSF
) = LODWORD(pDevice
->qwCurrTSF
);
754 HIDWORD(*pqwCurrTSF
) = HIDWORD(pDevice
->qwCurrTSF
);
761 * Description: Clear NIC TSF counter
762 * Clear local TSF counter
766 * pDevice - The adapter to be read
768 * Return Value: TRUE if success; otherwise FALSE
771 BOOL
CARDbClearCurrentTSF(void *pDeviceHandler
)
773 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
775 MACvRegBitsOn(pDevice
,MAC_REG_TFTCTL
,TFTCTL_TSFCNTRST
);
777 LODWORD(pDevice
->qwCurrTSF
) = 0;
778 HIDWORD(pDevice
->qwCurrTSF
) = 0;
784 * Description: Read NIC TSF counter
785 * Get NEXTTBTT from adjusted TSF and Beacon Interval
789 * qwTSF - Current TSF counter
790 * wbeaconInterval - Beacon Interval
792 * qwCurrTSF - Current TSF counter
794 * Return Value: TSF value of next Beacon
797 QWORD
CARDqGetNextTBTT (QWORD qwTSF
, WORD wBeaconInterval
)
800 unsigned int uLowNextTBTT
;
801 unsigned int uHighRemain
, uLowRemain
;
802 unsigned int uBeaconInterval
;
804 uBeaconInterval
= wBeaconInterval
* 1024;
805 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
806 uLowNextTBTT
= (LODWORD(qwTSF
) >> 10) << 10;
807 uLowRemain
= (uLowNextTBTT
) % uBeaconInterval
;
808 uHighRemain
= ((0x80000000 % uBeaconInterval
)* 2 * HIDWORD(qwTSF
))
810 uLowRemain
= (uHighRemain
+ uLowRemain
) % uBeaconInterval
;
811 uLowRemain
= uBeaconInterval
- uLowRemain
;
813 // check if carry when add one beacon interval
814 if ((~uLowNextTBTT
) < uLowRemain
)
817 LODWORD(qwTSF
) = uLowNextTBTT
+ uLowRemain
;
824 * Description: Set NIC TSF counter for first Beacon time
825 * Get NEXTTBTT from adjusted TSF and Beacon Interval
830 * wBeaconInterval - Beacon Interval
837 void CARDvSetFirstNextTBTT(void *pDeviceHandler
, WORD wBeaconInterval
)
840 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
842 DWORD dwLoTBTT
,dwHiTBTT
;
845 HIDWORD(qwNextTBTT
) = 0;
846 LODWORD(qwNextTBTT
) = 0;
847 CARDbClearCurrentTSF(pDevice
);
848 //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
849 qwNextTBTT
= CARDqGetNextTBTT(qwNextTBTT
, wBeaconInterval
);
852 dwLoTBTT
= LODWORD(qwNextTBTT
);
853 dwHiTBTT
= HIDWORD(qwNextTBTT
);
855 pbyData
[0] = (BYTE
)dwLoTBTT
;
856 pbyData
[1] = (BYTE
)(dwLoTBTT
>>8);
857 pbyData
[2] = (BYTE
)(dwLoTBTT
>>16);
858 pbyData
[3] = (BYTE
)(dwLoTBTT
>>24);
859 pbyData
[4] = (BYTE
)dwHiTBTT
;
860 pbyData
[5] = (BYTE
)(dwHiTBTT
>>8);
861 pbyData
[6] = (BYTE
)(dwHiTBTT
>>16);
862 pbyData
[7] = (BYTE
)(dwHiTBTT
>>24);
864 CONTROLnsRequestOut(pDevice
,
865 MESSAGE_TYPE_SET_TSFTBTT
,
866 MESSAGE_REQUEST_TBTT
,
877 * Description: Sync NIC TSF counter for Beacon time
878 * Get NEXTTBTT and write to HW
882 * pDevice - The adapter to be set
883 * qwTSF - Current TSF counter
884 * wBeaconInterval - Beacon Interval
891 void CARDvUpdateNextTBTT(void *pDeviceHandler
, QWORD qwTSF
,
892 WORD wBeaconInterval
)
894 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
895 DWORD dwLoTBTT
,dwHiTBTT
;
898 qwTSF
= CARDqGetNextTBTT(qwTSF
, wBeaconInterval
);
901 dwLoTBTT
= LODWORD(qwTSF
);
902 dwHiTBTT
= HIDWORD(qwTSF
);
904 pbyData
[0] = (BYTE
)dwLoTBTT
;
905 pbyData
[1] = (BYTE
)(dwLoTBTT
>>8);
906 pbyData
[2] = (BYTE
)(dwLoTBTT
>>16);
907 pbyData
[3] = (BYTE
)(dwLoTBTT
>>24);
908 pbyData
[4] = (BYTE
)dwHiTBTT
;
909 pbyData
[5] = (BYTE
)(dwHiTBTT
>>8);
910 pbyData
[6] = (BYTE
)(dwHiTBTT
>>16);
911 pbyData
[7] = (BYTE
)(dwHiTBTT
>>24);
913 CONTROLnsRequestOut(pDevice
,
914 MESSAGE_TYPE_SET_TSFTBTT
,
915 MESSAGE_REQUEST_TBTT
,
922 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Card:Update Next TBTT[%8xh:%8xh] \n",(int)HIDWORD(qwTSF
), (int)LODWORD(qwTSF
));
928 * Description: Turn off Radio power
932 * pDevice - The adapter to be turned off
936 * Return Value: TRUE if success; otherwise FALSE
939 BOOL
CARDbRadioPowerOff(void *pDeviceHandler
)
941 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
944 //if (pDevice->bRadioOff == TRUE)
947 pDevice
->bRadioOff
= TRUE
;
949 switch (pDevice
->byRFType
) {
953 case RF_VT3226
: //RobertYu:20051111
955 case RF_VT3342A0
: //RobertYu:20060609
956 MACvRegBitsOff(pDevice
, MAC_REG_SOFTPWRCTL
, (SOFTPWRCTL_SWPE2
| SOFTPWRCTL_SWPE3
));
960 MACvRegBitsOff(pDevice
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
962 BBvSetDeepSleep(pDevice
);
969 * Description: Turn on Radio power
973 * pDevice - The adapter to be turned on
977 * Return Value: TRUE if success; otherwise FALSE
980 BOOL
CARDbRadioPowerOn(void *pDeviceHandler
)
982 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
986 if ((pDevice
->bHWRadioOff
== TRUE
) || (pDevice
->bRadioControlOff
== TRUE
)) {
990 //if (pDevice->bRadioOff == FALSE)
993 pDevice
->bRadioOff
= FALSE
;
995 BBvExitDeepSleep(pDevice
);
997 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
999 switch (pDevice
->byRFType
) {
1003 case RF_VT3226
: //RobertYu:20051111
1005 case RF_VT3342A0
: //RobertYu:20060609
1006 MACvRegBitsOn(pDevice
, MAC_REG_SOFTPWRCTL
, (SOFTPWRCTL_SWPE2
| SOFTPWRCTL_SWPE3
));
1013 void CARDvSetBSSMode(void *pDeviceHandler
)
1015 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1016 // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
1017 // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
1018 if( (pDevice
->byRFType
== RF_AIROHA7230
) && (pDevice
->byBBType
== BB_TYPE_11A
) )
1020 MACvSetBBType(pDevice
, BB_TYPE_11G
);
1024 MACvSetBBType(pDevice
, pDevice
->byBBType
);
1026 pDevice
->byPacketType
= CARDbyGetPktType(pDevice
);
1028 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1029 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x03);
1030 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
1031 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x02);
1032 } else if (pDevice
->byBBType
== BB_TYPE_11G
) {
1033 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x08);
1036 vUpdateIFS(pDevice
);
1037 CARDvSetRSPINF(pDevice
, (BYTE
)pDevice
->byBBType
);
1039 if ( pDevice
->byBBType
== BB_TYPE_11A
) {
1040 //request by Jack 2005-04-26
1041 if (pDevice
->byRFType
== RF_AIROHA7230
) {
1042 pDevice
->abyBBVGA
[0] = 0x20;
1043 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0xE7, pDevice
->abyBBVGA
[0]);
1045 pDevice
->abyBBVGA
[2] = 0x10;
1046 pDevice
->abyBBVGA
[3] = 0x10;
1048 //request by Jack 2005-04-26
1049 if (pDevice
->byRFType
== RF_AIROHA7230
) {
1050 pDevice
->abyBBVGA
[0] = 0x1C;
1051 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0xE7, pDevice
->abyBBVGA
[0]);
1053 pDevice
->abyBBVGA
[2] = 0x0;
1054 pDevice
->abyBBVGA
[3] = 0x0;
1061 * Do Channel Switch defined in 802.11h
1065 * hDeviceContext - device structure point
1069 * Return Value: none.
1073 CARDbChannelSwitch (
1074 void *pDeviceHandler
,
1080 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1081 BOOL bResult
= TRUE
;
1084 pDevice
->sMgmtObj
.uCurrChannel
= byNewChannel
;
1085 CARDbSetMediaChannel(pDevice
, byNewChannel
);
1089 pDevice
->byChannelSwitchCount
= byCount
;
1090 pDevice
->byNewChannel
= byNewChannel
;
1091 pDevice
->bChannelSwitch
= TRUE
;
1094 //bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
1095 pDevice
->bStopDataPkt
= TRUE
;