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(void *pDeviceHandler
, unsigned int 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
159 static WORD
swGetCCKControlRate(void *pDeviceHandler
, WORD wRateIdx
)
161 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
162 unsigned int ui
= (unsigned int)wRateIdx
;
163 while (ui
> RATE_1M
) {
164 if (pDevice
->wBasicRate
& ((WORD
)1 << ui
)) {
169 return (WORD
)RATE_1M
;
173 * Description: Get OFDM mode basic rate
177 * pDevice - The adapter to be set
178 * wRateIdx - Receiving data rate
182 * Return Value: response Control frame rate
185 static WORD
swGetOFDMControlRate(void *pDeviceHandler
, WORD wRateIdx
)
187 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
188 unsigned int ui
= (unsigned int)wRateIdx
;
190 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BASIC RATE: %X\n", pDevice
->wBasicRate
);
192 if (!CARDbIsOFDMinBasicRate(pDevice
)) {
193 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx
);
194 if (wRateIdx
> RATE_24M
)
198 while (ui
> RATE_11M
) {
199 if (pDevice
->wBasicRate
& ((WORD
)1 << ui
)) {
200 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate : %d\n", ui
);
205 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"swGetOFDMControlRate: 6M\n");
206 return (WORD
)RATE_24M
;
210 * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode.
215 * byPktType - Tx Packet type
217 * pbyTxRate - pointer to RSPINF TxRate field
218 * pbyRsvTime - pointer to RSPINF RsvTime field
224 CARDvCaculateOFDMRParameter (
233 if (byBBType
== BB_TYPE_11A
) {//5GHZ
244 if (byBBType
== BB_TYPE_11A
) {//5GHZ
255 if (byBBType
== BB_TYPE_11A
) {//5GHZ
266 if (byBBType
== BB_TYPE_11A
) {//5GHZ
277 if (byBBType
== BB_TYPE_11A
) {//5GHZ
288 if (byBBType
== BB_TYPE_11A
) {//5GHZ
299 if (byBBType
== BB_TYPE_11A
) {//5GHZ
311 if (byBBType
== BB_TYPE_11A
) {//5GHZ
324 * Description: Set RSPINF
328 * pDevice - The adapter to be set
332 * Return Value: None.
335 void CARDvSetRSPINF(void *pDeviceHandler
, BYTE byBBType
)
337 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
338 BYTE abyServ
[4] = {0,0,0,0}; // For CCK
339 BYTE abySignal
[4] = {0,0,0,0};
340 WORD awLen
[4] = {0,0,0,0};
341 BYTE abyTxRate
[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM
342 BYTE abyRsvTime
[9] = {0,0,0,0,0,0,0,0,0};
347 BBvCaculateParameter(pDevice
,
349 swGetCCKControlRate(pDevice
, RATE_1M
),
357 BBvCaculateParameter(pDevice
,
359 swGetCCKControlRate(pDevice
, RATE_2M
),
367 BBvCaculateParameter(pDevice
,
369 swGetCCKControlRate(pDevice
, RATE_5M
),
377 BBvCaculateParameter(pDevice
,
379 swGetCCKControlRate(pDevice
, RATE_11M
),
387 CARDvCaculateOFDMRParameter (RATE_6M
,
393 CARDvCaculateOFDMRParameter (RATE_9M
,
399 CARDvCaculateOFDMRParameter (RATE_12M
,
405 CARDvCaculateOFDMRParameter (RATE_18M
,
411 CARDvCaculateOFDMRParameter (RATE_24M
,
417 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_36M
),
423 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_48M
),
429 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_54M
),
435 CARDvCaculateOFDMRParameter (swGetOFDMControlRate(pDevice
, RATE_54M
),
440 abyData
[0] = (BYTE
)(awLen
[0]&0xFF);
441 abyData
[1] = (BYTE
)(awLen
[0]>>8);
442 abyData
[2] = abySignal
[0];
443 abyData
[3] = abyServ
[0];
445 abyData
[4] = (BYTE
)(awLen
[1]&0xFF);
446 abyData
[5] = (BYTE
)(awLen
[1]>>8);
447 abyData
[6] = abySignal
[1];
448 abyData
[7] = abyServ
[1];
450 abyData
[8] = (BYTE
)(awLen
[2]&0xFF);
451 abyData
[9] = (BYTE
)(awLen
[2]>>8);
452 abyData
[10] = abySignal
[2];
453 abyData
[11] = abyServ
[2];
455 abyData
[12] = (BYTE
)(awLen
[3]&0xFF);
456 abyData
[13] = (BYTE
)(awLen
[3]>>8);
457 abyData
[14] = abySignal
[3];
458 abyData
[15] = abyServ
[3];
460 for (i
= 0; i
< 9; i
++) {
461 abyData
[16+i
*2] = abyTxRate
[i
];
462 abyData
[16+i
*2+1] = abyRsvTime
[i
];
465 CONTROLnsRequestOut(pDevice
,
468 MESSAGE_REQUEST_MACREG
,
475 * Description: Update IFS
479 * pDevice - The adapter to be set
483 * Return Value: None.
486 void vUpdateIFS(void *pDeviceHandler
)
488 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
489 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
493 if (pDevice
->byPacketType
==PK_TYPE_11A
) {//0000 0000 0000 0000,11a
494 pDevice
->uSlot
= C_SLOT_SHORT
;
495 pDevice
->uSIFS
= C_SIFS_A
;
496 pDevice
->uDIFS
= C_SIFS_A
+ 2*C_SLOT_SHORT
;
497 pDevice
->uCwMin
= C_CWMIN_A
;
500 else if (pDevice
->byPacketType
==PK_TYPE_11B
) {//0000 0001 0000 0000,11b
501 pDevice
->uSlot
= C_SLOT_LONG
;
502 pDevice
->uSIFS
= C_SIFS_BG
;
503 pDevice
->uDIFS
= C_SIFS_BG
+ 2*C_SLOT_LONG
;
504 pDevice
->uCwMin
= C_CWMIN_B
;
507 else {// PK_TYPE_11GA & PK_TYPE_11GB
509 BOOL bOFDMRate
= FALSE
;
511 PWLAN_IE_SUPP_RATES pItemRates
= NULL
;
513 pDevice
->uSIFS
= C_SIFS_BG
;
514 if (pDevice
->bShortSlotTime
) {
515 pDevice
->uSlot
= C_SLOT_SHORT
;
517 pDevice
->uSlot
= C_SLOT_LONG
;
519 pDevice
->uDIFS
= C_SIFS_BG
+ 2*pDevice
->uSlot
;
521 pItemRates
= (PWLAN_IE_SUPP_RATES
)pDevice
->sMgmtObj
.abyCurrSuppRates
;
522 for (ii
= 0; ii
< pItemRates
->len
; ii
++) {
523 byRate
= (BYTE
)(pItemRates
->abyRates
[ii
]&0x7F);
524 if (RATEwGetRateIdx(byRate
) > RATE_11M
) {
529 if (bOFDMRate
== FALSE
) {
530 pItemRates
= (PWLAN_IE_SUPP_RATES
)pDevice
->sMgmtObj
.abyCurrExtSuppRates
;
531 for (ii
= 0; ii
< pItemRates
->len
; ii
++) {
532 byRate
= (BYTE
)(pItemRates
->abyRates
[ii
]&0x7F);
533 if (RATEwGetRateIdx(byRate
) > RATE_11M
) {
539 if (bOFDMRate
== TRUE
) {
540 pDevice
->uCwMin
= C_CWMIN_A
;
543 pDevice
->uCwMin
= C_CWMIN_B
;
548 pDevice
->uCwMax
= C_CWMAX
;
549 pDevice
->uEIFS
= C_EIFS
;
551 byData
[0] = (BYTE
)pDevice
->uSIFS
;
552 byData
[1] = (BYTE
)pDevice
->uDIFS
;
553 byData
[2] = (BYTE
)pDevice
->uEIFS
;
554 byData
[3] = (BYTE
)pDevice
->uSlot
;
555 CONTROLnsRequestOut(pDevice
,
558 MESSAGE_REQUEST_MACREG
,
562 byMaxMin
|= 0xA0;//1010 1111,C_CWMAX = 1023
563 CONTROLnsRequestOut(pDevice
,
566 MESSAGE_REQUEST_MACREG
,
571 void CARDvUpdateBasicTopRate(void *pDeviceHandler
)
573 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
574 BYTE byTopOFDM
= RATE_24M
, byTopCCK
= RATE_1M
;
577 //Determines the highest basic rate.
578 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
579 if ( (pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)) ) {
584 pDevice
->byTopOFDMBasicRate
= byTopOFDM
;
586 for (ii
= RATE_11M
;; ii
--) {
587 if ( (pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)) ) {
594 pDevice
->byTopCCKBasicRate
= byTopCCK
;
598 * Description: Set NIC Tx Basic Rate
602 * pDevice - The adapter to be set
603 * wBasicRate - Basic Rate to be set
607 * Return Value: TRUE if succeeded; FALSE if failed.
610 BOOL
CARDbAddBasicRate(void *pDeviceHandler
, WORD wRateIdx
)
612 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
613 WORD wRate
= (WORD
)(1<<wRateIdx
);
615 pDevice
->wBasicRate
|= wRate
;
617 //Determines the highest basic rate.
618 CARDvUpdateBasicTopRate(pDevice
);
623 BOOL
CARDbIsOFDMinBasicRate(void *pDeviceHandler
)
625 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
628 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
629 if ((pDevice
->wBasicRate
) & ((WORD
)(1<<ii
)))
635 BYTE
CARDbyGetPktType(void *pDeviceHandler
)
637 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
639 if (pDevice
->byBBType
== BB_TYPE_11A
|| pDevice
->byBBType
== BB_TYPE_11B
) {
640 return (BYTE
)pDevice
->byBBType
;
642 else if (CARDbIsOFDMinBasicRate(pDevice
)) {
652 * Description: Caculate TSF offset of two TSF input
653 * Get TSF Offset from RxBCN's TSF and local TSF
657 * pDevice - The adapter to be sync.
658 * qwTSF1 - Rx BCN's TSF
663 * Return Value: TSF Offset value
666 QWORD
CARDqGetTSFOffset (BYTE byRxRate
, QWORD qwTSF1
, QWORD qwTSF2
)
669 WORD wRxBcnTSFOffst
= 0;
671 HIDWORD(qwTSFOffset
) = 0;
672 LODWORD(qwTSFOffset
) = 0;
674 wRxBcnTSFOffst
= cwRXBCNTSFOff
[byRxRate
%MAX_RATE
];
675 (qwTSF2
).u
.dwLowDword
+= (DWORD
)(wRxBcnTSFOffst
);
676 if ((qwTSF2
).u
.dwLowDword
< (DWORD
)(wRxBcnTSFOffst
)) {
677 (qwTSF2
).u
.dwHighDword
++;
679 LODWORD(qwTSFOffset
) = LODWORD(qwTSF1
) - LODWORD(qwTSF2
);
680 if (LODWORD(qwTSF1
) < LODWORD(qwTSF2
)) {
682 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
) - 1 ;
685 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
);
687 return (qwTSFOffset
);
693 * Description: Sync. TSF counter to BSS
694 * Get TSF offset and write to HW
698 * pDevice - The adapter to be sync.
699 * qwBSSTimestamp - Rx BCN's TSF
700 * qwLocalTSF - Local TSF
707 void CARDvAdjustTSF(void *pDeviceHandler
, BYTE byRxRate
,
708 QWORD qwBSSTimestamp
, QWORD qwLocalTSF
)
711 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
713 DWORD dwTSFOffset1
,dwTSFOffset2
;
716 HIDWORD(qwTSFOffset
) = 0;
717 LODWORD(qwTSFOffset
) = 0;
719 qwTSFOffset
= CARDqGetTSFOffset(byRxRate
, qwBSSTimestamp
, qwLocalTSF
);
721 // HW's TSF add TSF Offset reg
722 dwTSFOffset1
= LODWORD(qwTSFOffset
);
723 dwTSFOffset2
= HIDWORD(qwTSFOffset
);
726 pbyData
[0] = (BYTE
)dwTSFOffset1
;
727 pbyData
[1] = (BYTE
)(dwTSFOffset1
>>8);
728 pbyData
[2] = (BYTE
)(dwTSFOffset1
>>16);
729 pbyData
[3] = (BYTE
)(dwTSFOffset1
>>24);
730 pbyData
[4] = (BYTE
)dwTSFOffset2
;
731 pbyData
[5] = (BYTE
)(dwTSFOffset2
>>8);
732 pbyData
[6] = (BYTE
)(dwTSFOffset2
>>16);
733 pbyData
[7] = (BYTE
)(dwTSFOffset2
>>24);
735 CONTROLnsRequestOut(pDevice
,
736 MESSAGE_TYPE_SET_TSFTBTT
,
745 * Description: Read NIC TSF counter
746 * Get local TSF counter
750 * pDevice - The adapter to be read
752 * qwCurrTSF - Current TSF counter
754 * Return Value: TRUE if success; otherwise FALSE
757 BOOL
CARDbGetCurrentTSF(void *pDeviceHandler
, PQWORD pqwCurrTSF
)
759 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
761 LODWORD(*pqwCurrTSF
) = LODWORD(pDevice
->qwCurrTSF
);
762 HIDWORD(*pqwCurrTSF
) = HIDWORD(pDevice
->qwCurrTSF
);
769 * Description: Clear NIC TSF counter
770 * Clear local TSF counter
774 * pDevice - The adapter to be read
776 * Return Value: TRUE if success; otherwise FALSE
779 BOOL
CARDbClearCurrentTSF(void *pDeviceHandler
)
781 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
783 MACvRegBitsOn(pDevice
,MAC_REG_TFTCTL
,TFTCTL_TSFCNTRST
);
785 LODWORD(pDevice
->qwCurrTSF
) = 0;
786 HIDWORD(pDevice
->qwCurrTSF
) = 0;
792 * Description: Read NIC TSF counter
793 * Get NEXTTBTT from adjusted TSF and Beacon Interval
797 * qwTSF - Current TSF counter
798 * wbeaconInterval - Beacon Interval
800 * qwCurrTSF - Current TSF counter
802 * Return Value: TSF value of next Beacon
805 QWORD
CARDqGetNextTBTT (QWORD qwTSF
, WORD wBeaconInterval
)
808 unsigned int uLowNextTBTT
;
809 unsigned int uHighRemain
, uLowRemain
;
810 unsigned int uBeaconInterval
;
812 uBeaconInterval
= wBeaconInterval
* 1024;
813 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
814 uLowNextTBTT
= (LODWORD(qwTSF
) >> 10) << 10;
815 uLowRemain
= (uLowNextTBTT
) % uBeaconInterval
;
816 uHighRemain
= ((0x80000000 % uBeaconInterval
)* 2 * HIDWORD(qwTSF
))
818 uLowRemain
= (uHighRemain
+ uLowRemain
) % uBeaconInterval
;
819 uLowRemain
= uBeaconInterval
- uLowRemain
;
821 // check if carry when add one beacon interval
822 if ((~uLowNextTBTT
) < uLowRemain
)
825 LODWORD(qwTSF
) = uLowNextTBTT
+ uLowRemain
;
832 * Description: Set NIC TSF counter for first Beacon time
833 * Get NEXTTBTT from adjusted TSF and Beacon Interval
838 * wBeaconInterval - Beacon Interval
845 void CARDvSetFirstNextTBTT(void *pDeviceHandler
, WORD wBeaconInterval
)
848 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
850 DWORD dwLoTBTT
,dwHiTBTT
;
853 HIDWORD(qwNextTBTT
) = 0;
854 LODWORD(qwNextTBTT
) = 0;
855 CARDbClearCurrentTSF(pDevice
);
856 //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
857 qwNextTBTT
= CARDqGetNextTBTT(qwNextTBTT
, wBeaconInterval
);
860 dwLoTBTT
= LODWORD(qwNextTBTT
);
861 dwHiTBTT
= HIDWORD(qwNextTBTT
);
863 pbyData
[0] = (BYTE
)dwLoTBTT
;
864 pbyData
[1] = (BYTE
)(dwLoTBTT
>>8);
865 pbyData
[2] = (BYTE
)(dwLoTBTT
>>16);
866 pbyData
[3] = (BYTE
)(dwLoTBTT
>>24);
867 pbyData
[4] = (BYTE
)dwHiTBTT
;
868 pbyData
[5] = (BYTE
)(dwHiTBTT
>>8);
869 pbyData
[6] = (BYTE
)(dwHiTBTT
>>16);
870 pbyData
[7] = (BYTE
)(dwHiTBTT
>>24);
872 CONTROLnsRequestOut(pDevice
,
873 MESSAGE_TYPE_SET_TSFTBTT
,
874 MESSAGE_REQUEST_TBTT
,
885 * Description: Sync NIC TSF counter for Beacon time
886 * Get NEXTTBTT and write to HW
890 * pDevice - The adapter to be set
891 * qwTSF - Current TSF counter
892 * wBeaconInterval - Beacon Interval
899 void CARDvUpdateNextTBTT(void *pDeviceHandler
, QWORD qwTSF
,
900 WORD wBeaconInterval
)
902 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
903 DWORD dwLoTBTT
,dwHiTBTT
;
906 qwTSF
= CARDqGetNextTBTT(qwTSF
, wBeaconInterval
);
909 dwLoTBTT
= LODWORD(qwTSF
);
910 dwHiTBTT
= HIDWORD(qwTSF
);
912 pbyData
[0] = (BYTE
)dwLoTBTT
;
913 pbyData
[1] = (BYTE
)(dwLoTBTT
>>8);
914 pbyData
[2] = (BYTE
)(dwLoTBTT
>>16);
915 pbyData
[3] = (BYTE
)(dwLoTBTT
>>24);
916 pbyData
[4] = (BYTE
)dwHiTBTT
;
917 pbyData
[5] = (BYTE
)(dwHiTBTT
>>8);
918 pbyData
[6] = (BYTE
)(dwHiTBTT
>>16);
919 pbyData
[7] = (BYTE
)(dwHiTBTT
>>24);
921 CONTROLnsRequestOut(pDevice
,
922 MESSAGE_TYPE_SET_TSFTBTT
,
923 MESSAGE_REQUEST_TBTT
,
930 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Card:Update Next TBTT[%8xh:%8xh] \n",(int)HIDWORD(qwTSF
), (int)LODWORD(qwTSF
));
936 * Description: Turn off Radio power
940 * pDevice - The adapter to be turned off
944 * Return Value: TRUE if success; otherwise FALSE
947 BOOL
CARDbRadioPowerOff(void *pDeviceHandler
)
949 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
952 //if (pDevice->bRadioOff == TRUE)
955 pDevice
->bRadioOff
= TRUE
;
957 switch (pDevice
->byRFType
) {
961 case RF_VT3226
: //RobertYu:20051111
963 case RF_VT3342A0
: //RobertYu:20060609
964 MACvRegBitsOff(pDevice
, MAC_REG_SOFTPWRCTL
, (SOFTPWRCTL_SWPE2
| SOFTPWRCTL_SWPE3
));
968 MACvRegBitsOff(pDevice
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
970 BBvSetDeepSleep(pDevice
);
977 * Description: Turn on Radio power
981 * pDevice - The adapter to be turned on
985 * Return Value: TRUE if success; otherwise FALSE
988 BOOL
CARDbRadioPowerOn(void *pDeviceHandler
)
990 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
994 if ((pDevice
->bHWRadioOff
== TRUE
) || (pDevice
->bRadioControlOff
== TRUE
)) {
998 //if (pDevice->bRadioOff == FALSE)
1001 pDevice
->bRadioOff
= FALSE
;
1003 BBvExitDeepSleep(pDevice
);
1005 MACvRegBitsOn(pDevice
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
1007 switch (pDevice
->byRFType
) {
1011 case RF_VT3226
: //RobertYu:20051111
1013 case RF_VT3342A0
: //RobertYu:20060609
1014 MACvRegBitsOn(pDevice
, MAC_REG_SOFTPWRCTL
, (SOFTPWRCTL_SWPE2
| SOFTPWRCTL_SWPE3
));
1021 void CARDvSetBSSMode(void *pDeviceHandler
)
1023 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1024 // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
1025 // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
1026 if( (pDevice
->byRFType
== RF_AIROHA7230
) && (pDevice
->byBBType
== BB_TYPE_11A
) )
1028 MACvSetBBType(pDevice
, BB_TYPE_11G
);
1032 MACvSetBBType(pDevice
, pDevice
->byBBType
);
1034 pDevice
->byPacketType
= CARDbyGetPktType(pDevice
);
1036 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1037 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x03);
1038 } else if (pDevice
->byBBType
== BB_TYPE_11B
) {
1039 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x02);
1040 } else if (pDevice
->byBBType
== BB_TYPE_11G
) {
1041 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0x88, 0x08);
1044 vUpdateIFS(pDevice
);
1045 CARDvSetRSPINF(pDevice
, (BYTE
)pDevice
->byBBType
);
1047 if ( pDevice
->byBBType
== BB_TYPE_11A
) {
1048 //request by Jack 2005-04-26
1049 if (pDevice
->byRFType
== RF_AIROHA7230
) {
1050 pDevice
->abyBBVGA
[0] = 0x20;
1051 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0xE7, pDevice
->abyBBVGA
[0]);
1053 pDevice
->abyBBVGA
[2] = 0x10;
1054 pDevice
->abyBBVGA
[3] = 0x10;
1056 //request by Jack 2005-04-26
1057 if (pDevice
->byRFType
== RF_AIROHA7230
) {
1058 pDevice
->abyBBVGA
[0] = 0x1C;
1059 ControlvWriteByte(pDevice
, MESSAGE_REQUEST_BBREG
, 0xE7, pDevice
->abyBBVGA
[0]);
1061 pDevice
->abyBBVGA
[2] = 0x0;
1062 pDevice
->abyBBVGA
[3] = 0x0;
1069 * Do Channel Switch defined in 802.11h
1073 * hDeviceContext - device structure point
1077 * Return Value: none.
1081 CARDbChannelSwitch (
1082 void *pDeviceHandler
,
1088 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1089 BOOL bResult
= TRUE
;
1092 pDevice
->sMgmtObj
.uCurrChannel
= byNewChannel
;
1093 bResult
= CARDbSetMediaChannel(pDevice
, byNewChannel
);
1097 pDevice
->byChannelSwitchCount
= byCount
;
1098 pDevice
->byNewChannel
= byNewChannel
;
1099 pDevice
->bChannelSwitch
= TRUE
;
1102 //bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
1103 pDevice
->bStopDataPkt
= TRUE
;