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 * Return Value: TRUE if succeeded; FALSE if failed.
98 BOOL
CARDbSetMediaChannel (PVOID pDeviceHandler
, UINT uConnectionChannel
)
100 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
104 if (pDevice
->byBBType
== BB_TYPE_11A
) { // 15 ~ 38
105 if ((uConnectionChannel
< (CB_MAX_CHANNEL_24G
+1)) || (uConnectionChannel
> CB_MAX_CHANNEL
))
106 uConnectionChannel
= (CB_MAX_CHANNEL_24G
+1);
108 if ((uConnectionChannel
> CB_MAX_CHANNEL_24G
) || (uConnectionChannel
== 0)) // 1 ~ 14
109 uConnectionChannel
= 1;
113 MACvRegBitsOn(pDevice
, MAC_REG_MACCR
, MACCR_CLRNAV
);
115 // Set Channel[7] = 0 to tell H/W channel is changing now.
116 MACvRegBitsOff(pDevice
, MAC_REG_CHANNEL
, 0x80);
118 //if (pMgmt->uCurrChannel == uConnectionChannel)
121 CONTROLnsRequestOut(pDevice
,
122 MESSAGE_TYPE_SELECT_CHANNLE
,
123 (WORD
) uConnectionChannel
,
129 //{{ RobertYu: 20041202
130 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
132 if (pDevice
->byBBType
== BB_TYPE_11A
) {
133 pDevice
->byCurPwr
= 0xFF;
134 RFbRawSetPower(pDevice
, pDevice
->abyOFDMAPwrTbl
[uConnectionChannel
-15], RATE_54M
);
135 } else if (pDevice
->byBBType
== BB_TYPE_11G
) {
136 pDevice
->byCurPwr
= 0xFF;
137 RFbRawSetPower(pDevice
, pDevice
->abyOFDMPwrTbl
[uConnectionChannel
-1], RATE_54M
);
139 pDevice
->byCurPwr
= 0xFF;
140 RFbRawSetPower(pDevice
, pDevice
->abyCCKPwrTbl
[uConnectionChannel
-1], RATE_1M
);
142 ControlvWriteByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_CHANNEL
,(BYTE
)(uConnectionChannel
|0x80));
147 * Description: Get CCK mode basic rate
151 * pDevice - The adapter to be set
152 * wRateIdx - Receiving data rate
156 * Return Value: response Control frame rate
160 WORD
swGetCCKControlRate(PVOID pDeviceHandler
, WORD wRateIdx
)
162 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
163 UINT ui
= (UINT
)wRateIdx
;
164 while (ui
> RATE_1M
) {
165 if (pDevice
->wBasicRate
& ((WORD
)1 << ui
)) {
170 return (WORD
)RATE_1M
;
174 * Description: Get OFDM mode basic rate
178 * pDevice - The adapter to be set
179 * wRateIdx - Receiving data rate
183 * Return Value: response Control frame rate
187 WORD
swGetOFDMControlRate (PVOID pDeviceHandler
, WORD wRateIdx
)
189 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
190 UINT ui
= (UINT
)wRateIdx
;
192 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BASIC RATE: %X\n", pDevice
->wBasicRate
);
194 if (!CARDbIsOFDMinBasicRate(pDevice
)) {
195 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx
);
196 if (wRateIdx
> RATE_24M
)
200 while (ui
> RATE_11M
) {
201 if (pDevice
->wBasicRate
& ((WORD
)1 << ui
)) {
202 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate : %d\n", ui
);
207 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate: 6M\n");
208 return (WORD
)RATE_24M
;
212 * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode.
217 * byPktType - Tx Packet type
219 * pbyTxRate - pointer to RSPINF TxRate field
220 * pbyRsvTime - pointer to RSPINF RsvTime field
226 CARDvCaculateOFDMRParameter (
235 if (byBBType
== BB_TYPE_11A
) {//5GHZ
246 if (byBBType
== BB_TYPE_11A
) {//5GHZ
257 if (byBBType
== BB_TYPE_11A
) {//5GHZ
268 if (byBBType
== BB_TYPE_11A
) {//5GHZ
279 if (byBBType
== BB_TYPE_11A
) {//5GHZ
290 if (byBBType
== BB_TYPE_11A
) {//5GHZ
301 if (byBBType
== BB_TYPE_11A
) {//5GHZ
313 if (byBBType
== BB_TYPE_11A
) {//5GHZ
326 * Description: Set RSPINF
330 * pDevice - The adapter to be set
334 * Return Value: None.
337 void CARDvSetRSPINF (PVOID pDeviceHandler
, BYTE byBBType
)
339 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
340 BYTE abyServ
[4] = {0,0,0,0}; // For CCK
341 BYTE abySignal
[4] = {0,0,0,0};
342 WORD awLen
[4] = {0,0,0,0};
343 BYTE abyTxRate
[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM
344 BYTE abyRsvTime
[9] = {0,0,0,0,0,0,0,0,0};
349 BBvCaculateParameter(pDevice
,
351 swGetCCKControlRate(pDevice
, RATE_1M
),
359 BBvCaculateParameter(pDevice
,
361 swGetCCKControlRate(pDevice
, RATE_2M
),
369 BBvCaculateParameter(pDevice
,
371 swGetCCKControlRate(pDevice
, RATE_5M
),
379 BBvCaculateParameter(pDevice
,
381 swGetCCKControlRate(pDevice
, RATE_11M
),
389 CARDvCaculateOFDMRParameter (RATE_6M
,
395 CARDvCaculateOFDMRParameter (RATE_9M
,
401 CARDvCaculateOFDMRParameter (RATE_12M
,
407 CARDvCaculateOFDMRParameter (RATE_18M
,
413 CARDvCaculateOFDMRParameter (RATE_24M
,
419 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_36M
),
425 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_48M
),
431 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_54M
),
437 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_54M
),
442 abyData
[0] = (BYTE
)(awLen
[0]&0xFF);
443 abyData
[1] = (BYTE
)(awLen
[0]>>8);
444 abyData
[2] = abySignal
[0];
445 abyData
[3] = abyServ
[0];
447 abyData
[4] = (BYTE
)(awLen
[1]&0xFF);
448 abyData
[5] = (BYTE
)(awLen
[1]>>8);
449 abyData
[6] = abySignal
[1];
450 abyData
[7] = abyServ
[1];
452 abyData
[8] = (BYTE
)(awLen
[2]&0xFF);
453 abyData
[9] = (BYTE
)(awLen
[2]>>8);
454 abyData
[10] = abySignal
[2];
455 abyData
[11] = abyServ
[2];
457 abyData
[12] = (BYTE
)(awLen
[3]&0xFF);
458 abyData
[13] = (BYTE
)(awLen
[3]>>8);
459 abyData
[14] = abySignal
[3];
460 abyData
[15] = abyServ
[3];
463 abyData
[16+i
*2] = abyTxRate
[i
];
464 abyData
[16+i
*2+1] = abyRsvTime
[i
];
468 CONTROLnsRequestOut(pDevice
,
471 MESSAGE_REQUEST_MACREG
,
478 * Description: Update IFS
482 * pDevice - The adapter to be set
486 * Return Value: None.
489 void vUpdateIFS (PVOID pDeviceHandler
)
491 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
492 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
496 if (pDevice
->byPacketType
==PK_TYPE_11A
) {//0000 0000 0000 0000,11a
497 pDevice
->uSlot
= C_SLOT_SHORT
;
498 pDevice
->uSIFS
= C_SIFS_A
;
499 pDevice
->uDIFS
= C_SIFS_A
+ 2*C_SLOT_SHORT
;
500 pDevice
->uCwMin
= C_CWMIN_A
;
503 else if (pDevice
->byPacketType
==PK_TYPE_11B
) {//0000 0001 0000 0000,11b
504 pDevice
->uSlot
= C_SLOT_LONG
;
505 pDevice
->uSIFS
= C_SIFS_BG
;
506 pDevice
->uDIFS
= C_SIFS_BG
+ 2*C_SLOT_LONG
;
507 pDevice
->uCwMin
= C_CWMIN_B
;
510 else {// PK_TYPE_11GA & PK_TYPE_11GB
512 BOOL bOFDMRate
= FALSE
;
514 PWLAN_IE_SUPP_RATES pItemRates
= NULL
;
516 pDevice
->uSIFS
= C_SIFS_BG
;
517 if (pDevice
->bShortSlotTime
) {
518 pDevice
->uSlot
= C_SLOT_SHORT
;
520 pDevice
->uSlot
= C_SLOT_LONG
;
522 pDevice
->uDIFS
= C_SIFS_BG
+ 2*pDevice
->uSlot
;
524 pItemRates
= (PWLAN_IE_SUPP_RATES
)pDevice
->sMgmtObj
.abyCurrSuppRates
;
525 for (ii
= 0; ii
< pItemRates
->len
; ii
++) {
526 byRate
= (BYTE
)(pItemRates
->abyRates
[ii
]&0x7F);
527 if (RATEwGetRateIdx(byRate
) > RATE_11M
) {
532 if (bOFDMRate
== FALSE
) {
533 pItemRates
= (PWLAN_IE_SUPP_RATES
)pDevice
->sMgmtObj
.abyCurrExtSuppRates
;
534 for (ii
= 0; ii
< pItemRates
->len
; ii
++) {
535 byRate
= (BYTE
)(pItemRates
->abyRates
[ii
]&0x7F);
536 if (RATEwGetRateIdx(byRate
) > RATE_11M
) {
542 if (bOFDMRate
== TRUE
) {
543 pDevice
->uCwMin
= C_CWMIN_A
;
546 pDevice
->uCwMin
= C_CWMIN_B
;
551 pDevice
->uCwMax
= C_CWMAX
;
552 pDevice
->uEIFS
= C_EIFS
;
554 byData
[0] = (BYTE
)pDevice
->uSIFS
;
555 byData
[1] = (BYTE
)pDevice
->uDIFS
;
556 byData
[2] = (BYTE
)pDevice
->uEIFS
;
557 byData
[3] = (BYTE
)pDevice
->uSlot
;
558 CONTROLnsRequestOut(pDevice
,
561 MESSAGE_REQUEST_MACREG
,
565 byMaxMin
|= 0xA0;//1010 1111,C_CWMAX = 1023
566 CONTROLnsRequestOut(pDevice
,
569 MESSAGE_REQUEST_MACREG
,
574 void CARDvUpdateBasicTopRate (PVOID pDeviceHandler
)
576 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
577 BYTE byTopOFDM
= RATE_24M
, byTopCCK
= RATE_1M
;
580 //Determines the highest basic rate.
581 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
582 if ( (pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)) ) {
587 pDevice
->byTopOFDMBasicRate
= byTopOFDM
;
589 for (ii
= RATE_11M
;; ii
--) {
590 if ( (pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)) ) {
597 pDevice
->byTopCCKBasicRate
= byTopCCK
;
601 * Description: Set NIC Tx Basic Rate
605 * pDevice - The adapter to be set
606 * wBasicRate - Basic Rate to be set
610 * Return Value: TRUE if succeeded; FALSE if failed.
613 BOOL
CARDbAddBasicRate (PVOID pDeviceHandler
, WORD wRateIdx
)
615 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
616 WORD wRate
= (WORD
)(1<<wRateIdx
);
618 pDevice
->wBasicRate
|= wRate
;
620 //Determines the highest basic rate.
621 CARDvUpdateBasicTopRate(pDevice
);
626 BOOL
CARDbIsOFDMinBasicRate (PVOID pDeviceHandler
)
628 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
631 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
632 if ((pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)))
638 BYTE
CARDbyGetPktType (PVOID pDeviceHandler
)
640 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
642 if (pDevice
->byBBType
== BB_TYPE_11A
|| pDevice
->byBBType
== BB_TYPE_11B
) {
643 return (BYTE
)pDevice
->byBBType
;
645 else if (CARDbIsOFDMinBasicRate(pDevice
)) {
655 * Description: Caculate TSF offset of two TSF input
656 * Get TSF Offset from RxBCN's TSF and local TSF
660 * pDevice - The adapter to be sync.
661 * qwTSF1 - Rx BCN's TSF
666 * Return Value: TSF Offset value
669 QWORD
CARDqGetTSFOffset (BYTE byRxRate
, QWORD qwTSF1
, QWORD qwTSF2
)
672 WORD wRxBcnTSFOffst
= 0;
674 HIDWORD(qwTSFOffset
) = 0;
675 LODWORD(qwTSFOffset
) = 0;
677 wRxBcnTSFOffst
= cwRXBCNTSFOff
[byRxRate
%MAX_RATE
];
678 (qwTSF2
).u
.dwLowDword
+= (DWORD
)(wRxBcnTSFOffst
);
679 if ((qwTSF2
).u
.dwLowDword
< (DWORD
)(wRxBcnTSFOffst
)) {
680 (qwTSF2
).u
.dwHighDword
++;
682 LODWORD(qwTSFOffset
) = LODWORD(qwTSF1
) - LODWORD(qwTSF2
);
683 if (LODWORD(qwTSF1
) < LODWORD(qwTSF2
)) {
685 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
) - 1 ;
688 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
);
690 return (qwTSFOffset
);
696 * Description: Sync. TSF counter to BSS
697 * Get TSF offset and write to HW
701 * pDevice - The adapter to be sync.
702 * qwBSSTimestamp - Rx BCN's TSF
703 * qwLocalTSF - Local TSF
710 void CARDvAdjustTSF (PVOID pDeviceHandler
, BYTE byRxRate
, QWORD qwBSSTimestamp
, QWORD qwLocalTSF
)
713 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
715 DWORD dwTSFOffset1
,dwTSFOffset2
;
718 HIDWORD(qwTSFOffset
) = 0;
719 LODWORD(qwTSFOffset
) = 0;
721 qwTSFOffset
= CARDqGetTSFOffset(byRxRate
, qwBSSTimestamp
, qwLocalTSF
);
723 // HW's TSF add TSF Offset reg
724 dwTSFOffset1
= LODWORD(qwTSFOffset
);
725 dwTSFOffset2
= HIDWORD(qwTSFOffset
);
728 pbyData
[0] = (BYTE
)dwTSFOffset1
;
729 pbyData
[1] = (BYTE
)(dwTSFOffset1
>>8);
730 pbyData
[2] = (BYTE
)(dwTSFOffset1
>>16);
731 pbyData
[3] = (BYTE
)(dwTSFOffset1
>>24);
732 pbyData
[4] = (BYTE
)dwTSFOffset2
;
733 pbyData
[5] = (BYTE
)(dwTSFOffset2
>>8);
734 pbyData
[6] = (BYTE
)(dwTSFOffset2
>>16);
735 pbyData
[7] = (BYTE
)(dwTSFOffset2
>>24);
737 CONTROLnsRequestOut(pDevice
,
738 MESSAGE_TYPE_SET_TSFTBTT
,
747 * Description: Read NIC TSF counter
748 * Get local TSF counter
752 * pDevice - The adapter to be read
754 * qwCurrTSF - Current TSF counter
756 * Return Value: TRUE if success; otherwise FALSE
759 BOOL
CARDbGetCurrentTSF (PVOID pDeviceHandler
, PQWORD pqwCurrTSF
)
761 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
763 LODWORD(*pqwCurrTSF
) = LODWORD(pDevice
->qwCurrTSF
);
764 HIDWORD(*pqwCurrTSF
) = HIDWORD(pDevice
->qwCurrTSF
);
771 * Description: Clear NIC TSF counter
772 * Clear local TSF counter
776 * pDevice - The adapter to be read
778 * Return Value: TRUE if success; otherwise FALSE
781 BOOL
CARDbClearCurrentTSF(PVOID pDeviceHandler
)
783 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
785 MACvRegBitsOn(pDevice
,MAC_REG_TFTCTL
,TFTCTL_TSFCNTRST
);
787 LODWORD(pDevice
->qwCurrTSF
) = 0;
788 HIDWORD(pDevice
->qwCurrTSF
) = 0;
794 * Description: Read NIC TSF counter
795 * Get NEXTTBTT from adjusted TSF and Beacon Interval
799 * qwTSF - Current TSF counter
800 * wbeaconInterval - Beacon Interval
802 * qwCurrTSF - Current TSF counter
804 * Return Value: TSF value of next Beacon
807 QWORD
CARDqGetNextTBTT (QWORD qwTSF
, WORD wBeaconInterval
)
811 UINT uHighRemain
, uLowRemain
;
812 UINT uBeaconInterval
;
814 uBeaconInterval
= wBeaconInterval
* 1024;
815 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
816 uLowNextTBTT
= (LODWORD(qwTSF
) >> 10) << 10;
817 uLowRemain
= (uLowNextTBTT
) % uBeaconInterval
;
818 uHighRemain
= ((0x80000000 % uBeaconInterval
)* 2 * HIDWORD(qwTSF
))
820 uLowRemain
= (uHighRemain
+ uLowRemain
) % uBeaconInterval
;
821 uLowRemain
= uBeaconInterval
- uLowRemain
;
823 // check if carry when add one beacon interval
824 if ((~uLowNextTBTT
) < uLowRemain
)
827 LODWORD(qwTSF
) = uLowNextTBTT
+ uLowRemain
;
834 * Description: Set NIC TSF counter for first Beacon time
835 * Get NEXTTBTT from adjusted TSF and Beacon Interval
840 * wBeaconInterval - Beacon Interval
847 void CARDvSetFirstNextTBTT (PVOID pDeviceHandler
, WORD wBeaconInterval
)
850 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
852 DWORD dwLoTBTT
,dwHiTBTT
;
855 HIDWORD(qwNextTBTT
) = 0;
856 LODWORD(qwNextTBTT
) = 0;
857 CARDbClearCurrentTSF(pDevice
);
858 //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
859 qwNextTBTT
= CARDqGetNextTBTT(qwNextTBTT
, wBeaconInterval
);
862 dwLoTBTT
= LODWORD(qwNextTBTT
);
863 dwHiTBTT
= HIDWORD(qwNextTBTT
);
865 pbyData
[0] = (BYTE
)dwLoTBTT
;
866 pbyData
[1] = (BYTE
)(dwLoTBTT
>>8);
867 pbyData
[2] = (BYTE
)(dwLoTBTT
>>16);
868 pbyData
[3] = (BYTE
)(dwLoTBTT
>>24);
869 pbyData
[4] = (BYTE
)dwHiTBTT
;
870 pbyData
[5] = (BYTE
)(dwHiTBTT
>>8);
871 pbyData
[6] = (BYTE
)(dwHiTBTT
>>16);
872 pbyData
[7] = (BYTE
)(dwHiTBTT
>>24);
874 CONTROLnsRequestOut(pDevice
,
875 MESSAGE_TYPE_SET_TSFTBTT
,
876 MESSAGE_REQUEST_TBTT
,
887 * Description: Sync NIC TSF counter for Beacon time
888 * Get NEXTTBTT and write to HW
892 * pDevice - The adapter to be set
893 * qwTSF - Current TSF counter
894 * wBeaconInterval - Beacon Interval
901 void CARDvUpdateNextTBTT (PVOID pDeviceHandler
, QWORD qwTSF
, WORD wBeaconInterval
)
903 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
904 DWORD dwLoTBTT
,dwHiTBTT
;
907 qwTSF
= CARDqGetNextTBTT(qwTSF
, wBeaconInterval
);
910 dwLoTBTT
= LODWORD(qwTSF
);
911 dwHiTBTT
= HIDWORD(qwTSF
);
913 pbyData
[0] = (BYTE
)dwLoTBTT
;
914 pbyData
[1] = (BYTE
)(dwLoTBTT
>>8);
915 pbyData
[2] = (BYTE
)(dwLoTBTT
>>16);
916 pbyData
[3] = (BYTE
)(dwLoTBTT
>>24);
917 pbyData
[4] = (BYTE
)dwHiTBTT
;
918 pbyData
[5] = (BYTE
)(dwHiTBTT
>>8);
919 pbyData
[6] = (BYTE
)(dwHiTBTT
>>16);
920 pbyData
[7] = (BYTE
)(dwHiTBTT
>>24);
922 CONTROLnsRequestOut(pDevice
,
923 MESSAGE_TYPE_SET_TSFTBTT
,
924 MESSAGE_REQUEST_TBTT
,
931 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Card:Update Next TBTT[%8xh:%8xh] \n",(int)HIDWORD(qwTSF
), (int)LODWORD(qwTSF
));
937 * Description: Turn off Radio power
941 * pDevice - The adapter to be turned off
945 * Return Value: TRUE if success; otherwise FALSE
948 BOOL
CARDbRadioPowerOff (PVOID pDeviceHandler
)
950 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
953 //if (pDevice->bRadioOff == TRUE)
956 pDevice
->bRadioOff
= TRUE
;
958 switch (pDevice
->byRFType
) {
962 case RF_VT3226
: //RobertYu:20051111
964 case RF_VT3342A0
: //RobertYu:20060609
965 MACvRegBitsOff(pDevice
, MAC_REG_SOFTPWRCTL
, (SOFTPWRCTL_SWPE2
| SOFTPWRCTL_SWPE3
));
969 MACvRegBitsOff(pDevice
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
971 BBvSetDeepSleep(pDevice
);
978 * Description: Turn on Radio power
982 * pDevice - The adapter to be turned on
986 * Return Value: TRUE if success; otherwise FALSE
989 BOOL
CARDbRadioPowerOn (PVOID pDeviceHandler
)
991 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
995 if ((pDevice
->bHWRadioOff
== TRUE
) || (pDevice
->bRadioControlOff
== TRUE
)) {
999 //if (pDevice->bRadioOff == FALSE)
1002 pDevice
->bRadioOff
= FALSE
;
1004 BBvExitDeepSleep(pDevice
);
1006 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
1008 switch (pDevice
->byRFType
) {
1012 case RF_VT3226
: //RobertYu:20051111
1014 case RF_VT3342A0
: //RobertYu:20060609
1015 MACvRegBitsOn(pDevice
, MAC_REG_SOFTPWRCTL
, (SOFTPWRCTL_SWPE2
| SOFTPWRCTL_SWPE3
));
1022 void CARDvSetBSSMode (PVOID pDeviceHandler
)
1024 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1025 // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
1026 // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
1027 if( (pDevice
->byRFType
== RF_AIROHA7230
) && (pDevice
->byBBType
== BB_TYPE_11A
) )
1029 MACvSetBBType(pDevice
, BB_TYPE_11G
);
1033 MACvSetBBType(pDevice
, pDevice
->byBBType
);
1035 pDevice
->byPacketType
= CARDbyGetPktType(pDevice
);
1037 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1038 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x03);
1039 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
1040 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x02);
1041 } else if (pDevice
->byBBType
== BB_TYPE_11G
) {
1042 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x08);
1045 vUpdateIFS(pDevice
);
1046 CARDvSetRSPINF(pDevice
, (BYTE
)pDevice
->byBBType
);
1048 if ( pDevice
->byBBType
== BB_TYPE_11A
) {
1049 //request by Jack 2005-04-26
1050 if (pDevice
->byRFType
== RF_AIROHA7230
) {
1051 pDevice
->abyBBVGA
[0] = 0x20;
1052 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0xE7, pDevice
->abyBBVGA
[0]);
1054 pDevice
->abyBBVGA
[2] = 0x10;
1055 pDevice
->abyBBVGA
[3] = 0x10;
1057 //request by Jack 2005-04-26
1058 if (pDevice
->byRFType
== RF_AIROHA7230
) {
1059 pDevice
->abyBBVGA
[0] = 0x1C;
1060 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0xE7, pDevice
->abyBBVGA
[0]);
1062 pDevice
->abyBBVGA
[2] = 0x0;
1063 pDevice
->abyBBVGA
[3] = 0x0;
1070 * Do Channel Switch defined in 802.11h
1074 * hDeviceContext - device structure point
1078 * Return Value: none.
1082 CARDbChannelSwitch (
1083 IN PVOID pDeviceHandler
,
1085 IN BYTE byNewChannel
,
1089 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1090 BOOL bResult
= TRUE
;
1093 pDevice
->sMgmtObj
.uCurrChannel
= byNewChannel
;
1094 bResult
= CARDbSetMediaChannel(pDevice
, byNewChannel
);
1098 pDevice
->byChannelSwitchCount
= byCount
;
1099 pDevice
->byNewChannel
= byNewChannel
;
1100 pDevice
->bChannelSwitch
= TRUE
;
1103 //bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
1104 pDevice
->bStopDataPkt
= TRUE
;