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().
48 #if !defined(__TMACRO_H__)
51 #if !defined(__CARD_H__)
54 #if !defined(__TBIT_H__)
57 #if !defined(__BASEBAND_H__)
60 #if !defined(__MAC_H__)
63 #if !defined(__DESC_H__)
66 #if !defined(__RF_H__)
69 #if !defined(__VNTWIFI_H__)
72 #if !defined(__POWER_H__)
75 #if !defined(__KEY_H__)
78 #if !defined(__RC4_H__)
81 #if !defined(__COUNTRY_H__)
84 #if !defined(__UMEM_H__)
90 /*--------------------- Static Definitions -------------------------*/
92 //static int msglevel =MSG_LEVEL_DEBUG;
93 static int msglevel =MSG_LEVEL_INFO;
95 #define C_SIFS_A 16 // micro sec.
98 #define C_EIFS 80 // micro sec.
101 #define C_SLOT_SHORT 9 // micro sec.
102 #define C_SLOT_LONG 20
104 #define C_CWMIN_A 15 // slot time
107 #define C_CWMAX 1023 // slot time
109 #define CARD_MAX_CHANNEL_TBL 56
111 #define WAIT_BEACON_TX_DOWN_TMO 3 // Times
113 typedef struct tagSChannelTblElement {
114 BYTE byChannelNumber;
118 }SChannelTblElement, DEF* PSChannelTblElement;
120 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
121 static BYTE abyDefaultSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
123 static BYTE abyDefaultExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
124 //6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M
125 static BYTE abyDefaultSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
127 static BYTE abyDefaultSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
131 /*--------------------- Static Classes ----------------------------*/
133 /*--------------------- Static Variables --------------------------*/
136 const WORD cwRXBCNTSFOff[MAX_RATE] =
137 {17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
139 static SChannelTblElement sChannelTbl[CARD_MAX_CHANNEL_TBL+1] =
156 {183, 4915, TRUE, 0},
157 {184, 4920, TRUE, 0},
158 {185, 4925, TRUE, 0},
159 {187, 4935, TRUE, 0},
160 {188, 4940, TRUE, 0},
161 {189, 4945, TRUE, 0},
162 {192, 4960, TRUE, 0},
163 {196, 4980, TRUE, 0},
182 {100, 5500, TRUE, 0},
183 {104, 5520, TRUE, 0},
184 {108, 5540, TRUE, 0},
185 {112, 5560, TRUE, 0},
186 {116, 5580, TRUE, 0},
187 {120, 5600, TRUE, 0},
188 {124, 5620, TRUE, 0},
189 {128, 5640, TRUE, 0},
190 {132, 5660, TRUE, 0},
191 {136, 5680, TRUE, 0},
192 {140, 5700, TRUE, 0},
193 {149, 5745, TRUE, 0},
194 {153, 5765, TRUE, 0},
195 {157, 5785, TRUE, 0},
196 {161, 5805, TRUE, 0},
201 /************************************************************************
202 * The Radar regulation rules for each country
203 ************************************************************************/
204 SCountryTable ChannelRuleTab[CCODE_MAX+1] =
206 /************************************************************************
207 * This table is based on Athero driver rules
208 ************************************************************************/
209 /* Country Available channels, ended with 0 */
210 /* 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */
211 {CCODE_FCC, {'U','S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
212 , { 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 17, 0, 17, 0, 17, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
213 {CCODE_TELEC, {'J','P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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
286 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
287 {CCODE_CZECH, {'C','Z'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
288 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
289 {CCODE_DENMARK, {'D','K'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
290 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
291 {CCODE_DOMINICAN_REPUBLIC, {'D','O'}, { 1, 1, 1, 1, 1, 1, 1,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
303 {CCODE_FRANCE, {'F','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
304 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
305 {CCODE_GERMANY, {'D','E'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
306 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
307 {CCODE_GREECE, {'G','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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ANIA, {'L','T'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
348 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
349 {CCODE_LUXEMBURG, {'L','U'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
350 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
351 {CCODE_MACAU, {'M','O'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}
352 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 23, 0, 23, 0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, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
403 {CCODE_SOUTH_AFRICA, {'Z','A'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
404 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
405 {CCODE_SOUTH_KOREA, {'K','R'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
406 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 23, 23, 0} },
407 {CCODE_SPAIN, {'E','S'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}
408 , { 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 0, 0,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
448 , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }
449 /* 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */
453 /*--------------------- Static Functions --------------------------*/
457 s_vCaculateOFDMRParameter(
459 IN CARD_PHY_TYPE ePHYType,
465 /*--------------------- Export Variables --------------------------*/
467 /*--------------------- Export Functions --------------------------*/
470 /*--------------------- Export function -------------------------*/
471 /************************************************************************
472 * Country Channel Valid
473 * Input: CountryCode, ChannelNum
474 * ChanneIndex is defined as VT3253 MAC channel:
478 * 14 = 2.4G channel 14
479 * 15 = 4.9G channel 183
480 * 16 = 4.9G channel 184
482 * Output: TRUE if the specified 5GHz band is allowed to be used.
484 // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
486 // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
487 // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
488 ************************************************************************/
489 //2008-8-4 <add> by chester
491 ChannelValid(UINT CountryCode, UINT ChannelIndex)
497 * If Channel Index is invalid, return invalid
499 if ((ChannelIndex > CB_MAX_CHANNEL) ||
506 bValid = sChannelTbl[ChannelIndex].bValid;
511 } /* end ChannelValid */
515 * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode.
520 * byPktType - Tx Packet type
522 * pbyTxRate - pointer to RSPINF TxRate field
523 * pbyRsvTime - pointer to RSPINF RsvTime field
530 s_vCaculateOFDMRParameter (
532 IN CARD_PHY_TYPE ePHYType,
539 if (ePHYType == PHY_TYPE_11A) {//5GHZ
550 if (ePHYType == PHY_TYPE_11A) {//5GHZ
561 if (ePHYType == PHY_TYPE_11A) {//5GHZ
572 if (ePHYType == PHY_TYPE_11A) {//5GHZ
583 if (ePHYType == PHY_TYPE_11A) {//5GHZ
594 if (ePHYType == PHY_TYPE_11A) {//5GHZ
605 if (ePHYType == PHY_TYPE_11A) {//5GHZ
617 if (ePHYType == PHY_TYPE_11A) {//5GHZ
632 * Description: Set RSPINF
636 * pDevice - The adapter to be set
640 * Return Value: None.
645 s_vSetRSPINF (PSDevice pDevice, CARD_PHY_TYPE ePHYType, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs)
647 BYTE byServ = 0, bySignal = 0; // For CCK
649 BYTE byTxRate = 0, byRsvTime = 0; // For OFDM
652 MACvSelectPage1(pDevice->PortOffset);
655 BBvCaculateParameter(pDevice,
657 VNTWIFIbyGetACKTxRate(RATE_1M, pvSupportRateIEs, pvExtSupportRateIEs),
664 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
666 BBvCaculateParameter(pDevice,
668 VNTWIFIbyGetACKTxRate(RATE_2M, pvSupportRateIEs, pvExtSupportRateIEs),
675 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
677 BBvCaculateParameter(pDevice,
679 VNTWIFIbyGetACKTxRate(RATE_5M, pvSupportRateIEs, pvExtSupportRateIEs),
686 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
688 BBvCaculateParameter(pDevice,
690 VNTWIFIbyGetACKTxRate(RATE_11M, pvSupportRateIEs, pvExtSupportRateIEs),
697 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
699 s_vCaculateOFDMRParameter(RATE_6M,
703 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
705 s_vCaculateOFDMRParameter(RATE_9M,
709 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
711 s_vCaculateOFDMRParameter(RATE_12M,
715 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
717 s_vCaculateOFDMRParameter(RATE_18M,
721 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
723 s_vCaculateOFDMRParameter(RATE_24M,
727 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
729 s_vCaculateOFDMRParameter(
730 VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs),
734 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
736 s_vCaculateOFDMRParameter(
737 VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs),
741 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
743 s_vCaculateOFDMRParameter(
744 VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs),
748 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
750 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
752 MACvSelectPage0(pDevice->PortOffset);
758 /*--------------------- Export Variables --------------------------*/
760 /*--------------------- Export Functions --------------------------*/
761 BYTE CARDbyGetChannelMapping (PVOID pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType)
765 if ((ePhyType == PHY_TYPE_11B) || (ePhyType == PHY_TYPE_11G)) {
766 return (byChannelNumber);
769 for(ii = (CB_MAX_CHANNEL_24G + 1); ii <= CB_MAX_CHANNEL; ) {
770 if (sChannelTbl[ii].byChannelNumber == byChannelNumber) {
779 BYTE CARDbyGetChannelNumber (PVOID pDeviceHandler, BYTE byChannelIndex)
781 // PSDevice pDevice = (PSDevice) pDeviceHandler;
782 return(sChannelTbl[byChannelIndex].byChannelNumber);
786 * Description: Set NIC media channel
790 * pDeviceHandler - The adapter to be set
791 * uConnectionChannel - Channel to be set
795 * Return Value: TRUE if succeeded; FALSE if failed.
798 BOOL CARDbSetChannel (PVOID pDeviceHandler, UINT uConnectionChannel)
800 PSDevice pDevice = (PSDevice) pDeviceHandler;
804 if (pDevice->byCurrentCh == uConnectionChannel) {
808 if (sChannelTbl[uConnectionChannel].bValid == FALSE) {
812 if ((uConnectionChannel > CB_MAX_CHANNEL_24G) &&
813 (pDevice->eCurrentPHYType != PHY_TYPE_11A)) {
814 CARDbSetPhyParameter(pDevice, PHY_TYPE_11A, 0, 0, NULL, NULL);
815 } else if ((uConnectionChannel <= CB_MAX_CHANNEL_24G) &&
816 (pDevice->eCurrentPHYType == PHY_TYPE_11A)) {
817 CARDbSetPhyParameter(pDevice, PHY_TYPE_11G, 0, 0, NULL, NULL);
820 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
822 //{{ RobertYu: 20041202
823 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
825 if ( pDevice->byRFType == RF_AIROHA7230 )
827 RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (BYTE)uConnectionChannel);
832 pDevice->byCurrentCh = (BYTE)uConnectionChannel;
833 bResult &= RFbSelectChannel(pDevice->PortOffset, pDevice->byRFType, (BYTE)uConnectionChannel);
835 // Init Synthesizer Table
836 if (pDevice->bEnablePSMode == TRUE)
837 RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel);
840 //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDbSetMediaChannel: %d\n", (BYTE)uConnectionChannel);
841 BBvSoftwareReset(pDevice->PortOffset);
843 if (pDevice->byLocalID > REV_ID_VT3253_B1) {
844 // set HW default power register
845 MACvSelectPage1(pDevice->PortOffset);
846 RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
847 VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK, pDevice->byCurPwr);
848 RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
849 VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWROFDM, pDevice->byCurPwr);
850 MACvSelectPage0(pDevice->PortOffset);
853 if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
855 //printk("Func:CARDbSetChannel:call RFbSetPower:11B\n");
857 RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
860 //printk("Func:CARDbSetChannel:call RFbSetPower\n");
862 RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
871 * Description: Card Send packet function
875 * pDeviceHandler - The adapter to be set
876 * pPacket - Packet buffer pointer
877 * ePktType - Packet type
878 * uLength - Packet length
882 * Return Value: TRUE if succeeded; FALSE if failed.
886 BOOL CARDbSendPacket (PVOID pDeviceHandler, PVOID pPacket, CARD_PKT_TYPE ePktType, UINT uLength)
888 PSDevice pDevice = (PSDevice) pDeviceHandler;
889 if (ePktType == PKT_TYPE_802_11_MNG) {
890 return TXbTD0Send(pDevice, pPacket, uLength);
891 } else if (ePktType == PKT_TYPE_802_11_BCN) {
892 return TXbBeaconSend(pDevice, pPacket, uLength);
893 } if (ePktType == PKT_TYPE_802_11_DATA) {
894 return TXbTD1Send(pDevice, pPacket, uLength);
903 * Description: Get Card short preamble option value
907 * pDevice - The adapter to be set
911 * Return Value: TRUE if short preamble; otherwise FALSE
914 BOOL CARDbIsShortPreamble (PVOID pDeviceHandler)
916 PSDevice pDevice = (PSDevice) pDeviceHandler;
917 if (pDevice->byPreambleType == 0) {
924 * Description: Get Card short slot time option value
928 * pDevice - The adapter to be set
932 * Return Value: TRUE if short slot time; otherwise FALSE
935 BOOL CARDbIsShorSlotTime (PVOID pDeviceHandler)
937 PSDevice pDevice = (PSDevice) pDeviceHandler;
938 return(pDevice->bShortSlotTime);
943 * Description: Update IFS
947 * pDevice - The adapter to be set
951 * Return Value: None.
954 BOOL CARDbSetPhyParameter (PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType, WORD wCapInfo, BYTE byERPField, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs)
956 PSDevice pDevice = (PSDevice) pDeviceHandler;
962 // PWLAN_IE_SUPP_RATES pRates = NULL;
963 PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs;
964 PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs;
967 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
968 if (ePHYType == PHY_TYPE_11A) {
969 if (pSupportRates == NULL) {
970 pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA;
972 if (pDevice->byRFType == RF_AIROHA7230) {
973 // AL7230 use single PAPE and connect to PAPE_2.4G
974 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
975 pDevice->abyBBVGA[0] = 0x20;
976 pDevice->abyBBVGA[2] = 0x10;
977 pDevice->abyBBVGA[3] = 0x10;
978 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
979 if (byData == 0x1C) {
980 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
982 } else if (pDevice->byRFType == RF_UW2452) {
983 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A);
984 pDevice->abyBBVGA[0] = 0x18;
985 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
986 if (byData == 0x14) {
987 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
988 BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0x57);
991 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A);
993 BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x03);
994 bySlot = C_SLOT_SHORT;
996 byDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
998 } else if (ePHYType == PHY_TYPE_11B) {
999 if (pSupportRates == NULL) {
1000 pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesB;
1002 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B);
1003 if (pDevice->byRFType == RF_AIROHA7230) {
1004 pDevice->abyBBVGA[0] = 0x1C;
1005 pDevice->abyBBVGA[2] = 0x00;
1006 pDevice->abyBBVGA[3] = 0x00;
1007 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
1008 if (byData == 0x20) {
1009 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
1011 } else if (pDevice->byRFType == RF_UW2452) {
1012 pDevice->abyBBVGA[0] = 0x14;
1013 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
1014 if (byData == 0x18) {
1015 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
1016 BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0xD3);
1019 BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x02);
1020 bySlot = C_SLOT_LONG;
1022 byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
1024 } else {// PK_TYPE_11GA & PK_TYPE_11GB
1025 if (pSupportRates == NULL) {
1026 pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesG;
1027 pExtSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultExtSuppRatesG;
1029 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
1030 if (pDevice->byRFType == RF_AIROHA7230) {
1031 pDevice->abyBBVGA[0] = 0x1C;
1032 pDevice->abyBBVGA[2] = 0x00;
1033 pDevice->abyBBVGA[3] = 0x00;
1034 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
1035 if (byData == 0x20) {
1036 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
1038 } else if (pDevice->byRFType == RF_UW2452) {
1039 pDevice->abyBBVGA[0] = 0x14;
1040 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
1041 if (byData == 0x18) {
1042 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
1043 BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0xD3);
1046 BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x08);
1048 if(VNTWIFIbIsShortSlotTime(wCapInfo)) {
1049 bySlot = C_SLOT_SHORT;
1050 byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT;
1052 bySlot = C_SLOT_LONG;
1053 byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
1055 if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) {
1060 if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) {
1061 pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField);
1062 if (pDevice->bProtectMode) {
1063 MACvEnableProtectMD(pDevice->PortOffset);
1065 MACvDisableProtectMD(pDevice->PortOffset);
1068 if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) {
1069 pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField);
1070 if (pDevice->bBarkerPreambleMd) {
1071 MACvEnableBarkerPreambleMd(pDevice->PortOffset);
1073 MACvDisableBarkerPreambleMd(pDevice->PortOffset);
1078 if (pDevice->byRFType == RF_RFMD2959) {
1079 // bcs TX_PE will reserve 3 us
1080 // hardware's processing time here is 2 us.
1083 //{{ RobertYu: 20041202
1084 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
1085 //// MAC will need 2 us to process, so the SIFS, DIFS can be shorter by 2 us.
1088 if (pDevice->bySIFS != bySIFS) {
1089 pDevice->bySIFS = bySIFS;
1090 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, pDevice->bySIFS);
1092 if (pDevice->byDIFS != byDIFS) {
1093 pDevice->byDIFS = byDIFS;
1094 VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, pDevice->byDIFS);
1096 if (pDevice->byEIFS != C_EIFS) {
1097 pDevice->byEIFS = C_EIFS;
1098 VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, pDevice->byEIFS);
1100 if (pDevice->bySlot != bySlot) {
1101 pDevice->bySlot = bySlot;
1102 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot);
1103 if (pDevice->bySlot == C_SLOT_SHORT) {
1104 pDevice->bShortSlotTime = TRUE;
1106 pDevice->bShortSlotTime = FALSE;
1108 BBvSetShortSlotTime(pDevice);
1110 if (pDevice->byCWMaxMin != byCWMaxMin) {
1111 pDevice->byCWMaxMin = byCWMaxMin;
1112 VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin);
1114 if (VNTWIFIbIsShortPreamble(wCapInfo)) {
1115 pDevice->byPreambleType = pDevice->byShortPreamble;
1117 pDevice->byPreambleType = 0;
1119 s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates);
1120 pDevice->eCurrentPHYType = ePHYType;
1121 // set for NDIS OID_802_11SUPPORTED_RATES
1126 * Description: Sync. TSF counter to BSS
1127 * Get TSF offset and write to HW
1131 * pDevice - The adapter to be sync.
1132 * byRxRate - data rate of receive beacon
1133 * qwBSSTimestamp - Rx BCN's TSF
1134 * qwLocalTSF - Local TSF
1138 * Return Value: none
1141 BOOL CARDbUpdateTSF (PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF)
1143 PSDevice pDevice = (PSDevice) pDeviceHandler;
1146 HIDWORD(qwTSFOffset) = 0;
1147 LODWORD(qwTSFOffset) = 0;
1149 if ((HIDWORD(qwBSSTimestamp) != HIDWORD(qwLocalTSF)) ||
1150 (LODWORD(qwBSSTimestamp) != LODWORD(qwLocalTSF))) {
1151 qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
1153 // HW's TSF add TSF Offset reg
1154 VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST, LODWORD(qwTSFOffset));
1155 VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST + 4, HIDWORD(qwTSFOffset));
1156 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN);
1163 * Description: Set NIC TSF counter for first Beacon time
1164 * Get NEXTTBTT from adjusted TSF and Beacon Interval
1168 * pDevice - The adapter to be set.
1169 * wBeaconInterval - Beacon Interval
1173 * Return Value: TRUE if succeed; otherwise FALSE
1176 BOOL CARDbSetBeaconPeriod (PVOID pDeviceHandler, WORD wBeaconInterval)
1178 PSDevice pDevice = (PSDevice) pDeviceHandler;
1179 UINT uBeaconInterval = 0;
1180 UINT uLowNextTBTT = 0;
1181 UINT uHighRemain = 0;
1182 UINT uLowRemain = 0;
1185 HIDWORD(qwNextTBTT) = 0;
1186 LODWORD(qwNextTBTT) = 0;
1187 CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); //Get Local TSF counter
1188 uBeaconInterval = wBeaconInterval * 1024;
1189 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
1190 uLowNextTBTT = (LODWORD(qwNextTBTT) >> 10) << 10;
1191 uLowRemain = (uLowNextTBTT) % uBeaconInterval;
1192 // high dword (mod) bcn
1193 uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * HIDWORD(qwNextTBTT))
1195 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
1196 uLowRemain = uBeaconInterval - uLowRemain;
1198 // check if carry when add one beacon interval
1199 if ((~uLowNextTBTT) < uLowRemain) {
1200 HIDWORD(qwNextTBTT) ++ ;
1202 LODWORD(qwNextTBTT) = uLowNextTBTT + uLowRemain;
1204 // set HW beacon interval
1205 VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, wBeaconInterval);
1206 pDevice->wBeaconInterval = wBeaconInterval;
1208 VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT, LODWORD(qwNextTBTT));
1209 VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT + 4, HIDWORD(qwNextTBTT));
1210 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
1218 * Description: Card Stop Hardware Tx
1222 * pDeviceHandler - The adapter to be set
1223 * ePktType - Packet type to stop
1227 * Return Value: TRUE if all data packet complete; otherwise FALSE.
1230 BOOL CARDbStopTxPacket (PVOID pDeviceHandler, CARD_PKT_TYPE ePktType)
1232 PSDevice pDevice = (PSDevice) pDeviceHandler;
1235 if (ePktType == PKT_TYPE_802_11_ALL) {
1236 pDevice->bStopBeacon = TRUE;
1237 pDevice->bStopTx0Pkt = TRUE;
1238 pDevice->bStopDataPkt = TRUE;
1239 } else if (ePktType == PKT_TYPE_802_11_BCN) {
1240 pDevice->bStopBeacon = TRUE;
1241 } else if (ePktType == PKT_TYPE_802_11_MNG) {
1242 pDevice->bStopTx0Pkt = TRUE;
1243 } else if (ePktType == PKT_TYPE_802_11_DATA) {
1244 pDevice->bStopDataPkt = TRUE;
1247 if (pDevice->bStopBeacon == TRUE) {
1248 if (pDevice->bIsBeaconBufReadySet == TRUE) {
1249 if (pDevice->cbBeaconBufReadySetCnt < WAIT_BEACON_TX_DOWN_TMO) {
1250 pDevice->cbBeaconBufReadySetCnt ++;
1254 pDevice->bIsBeaconBufReadySet = FALSE;
1255 pDevice->cbBeaconBufReadySetCnt = 0;
1256 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
1258 // wait all TD0 complete
1259 if (pDevice->bStopTx0Pkt == TRUE) {
1260 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
1264 // wait all Data TD complete
1265 if (pDevice->bStopDataPkt == TRUE) {
1266 if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
1276 * Description: Card Start Hardware Tx
1280 * pDeviceHandler - The adapter to be set
1281 * ePktType - Packet type to start
1285 * Return Value: TRUE if success; FALSE if failed.
1288 BOOL CARDbStartTxPacket (PVOID pDeviceHandler, CARD_PKT_TYPE ePktType)
1290 PSDevice pDevice = (PSDevice) pDeviceHandler;
1293 if (ePktType == PKT_TYPE_802_11_ALL) {
1294 pDevice->bStopBeacon = FALSE;
1295 pDevice->bStopTx0Pkt = FALSE;
1296 pDevice->bStopDataPkt = FALSE;
1297 } else if (ePktType == PKT_TYPE_802_11_BCN) {
1298 pDevice->bStopBeacon = FALSE;
1299 } else if (ePktType == PKT_TYPE_802_11_MNG) {
1300 pDevice->bStopTx0Pkt = FALSE;
1301 } else if (ePktType == PKT_TYPE_802_11_DATA) {
1302 pDevice->bStopDataPkt = FALSE;
1305 if ((pDevice->bStopBeacon == FALSE) &&
1306 (pDevice->bBeaconBufReady == TRUE) &&
1307 (pDevice->eOPMode == OP_MODE_ADHOC)) {
1308 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
1317 * Description: Card Set BSSID value
1321 * pDeviceHandler - The adapter to be set
1322 * pbyBSSID - pointer to BSSID field
1323 * bAdhoc - flag to indicate IBSS
1327 * Return Value: TRUE if success; FALSE if failed.
1330 BOOL CARDbSetBSSID(PVOID pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode)
1332 PSDevice pDevice = (PSDevice) pDeviceHandler;
1334 MACvWriteBSSIDAddress(pDevice->PortOffset, pbyBSSID);
1335 MEMvCopy(pDevice->abyBSSID, pbyBSSID, WLAN_BSSID_LEN);
1336 if (eOPMode == OP_MODE_ADHOC) {
1337 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
1339 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
1341 if (eOPMode == OP_MODE_AP) {
1342 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
1344 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
1346 if (eOPMode == OP_MODE_UNKNOWN) {
1347 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
1348 pDevice->bBSSIDFilter = FALSE;
1349 pDevice->byRxMode &= ~RCR_BSSID;
1350 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
1352 if (IS_NULL_ADDRESS(pDevice->abyBSSID) == FALSE) {
1353 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
1354 pDevice->bBSSIDFilter = TRUE;
1355 pDevice->byRxMode |= RCR_BSSID;
1357 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: rx_mode = %x\n", pDevice->byRxMode );
1359 // Adopt BSS state in Adapter Device Object
1360 pDevice->eOPMode = eOPMode;
1366 * Description: Card indicate status
1370 * pDeviceHandler - The adapter to be set
1375 * Return Value: TRUE if success; FALSE if failed.
1383 * Description: Save Assoc info. contain in assoc. response frame
1387 * pDevice - The adapter to be set
1388 * wCapabilityInfo - Capability information
1389 * wStatus - Status code
1391 * uLen - Length of IEs
1392 * pbyIEs - pointer to IEs
1396 * Return Value: TRUE if succeed; otherwise FALSE
1399 BOOL CARDbSetTxDataRate(
1400 PVOID pDeviceHandler,
1404 PSDevice pDevice = (PSDevice) pDeviceHandler;
1406 pDevice->wCurrentRate = wDataRate;
1412 * Routine Description:
1413 * Consider to power down when no more packets to tx or rx.
1417 * pDevice - The adapter to be set
1421 * Return Value: TRUE if power down success; otherwise FALSE
1426 PVOID pDeviceHandler
1429 PSDevice pDevice = (PSDevice)pDeviceHandler;
1432 // check if already in Doze mode
1433 if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
1437 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
1439 // check if all TD are empty,
1441 for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx ++) {
1442 if (pDevice->iTDUsed[uIdx] != 0)
1446 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
1447 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Go to Doze ZZZZZZZZZZZZZZZ\n");
1452 * Description: Turn off Radio power
1456 * pDevice - The adapter to be turned off
1460 * Return Value: TRUE if success; otherwise FALSE
1463 BOOL CARDbRadioPowerOff (PVOID pDeviceHandler)
1465 PSDevice pDevice = (PSDevice) pDeviceHandler;
1466 BOOL bResult = TRUE;
1468 if (pDevice->bRadioOff == TRUE)
1472 switch (pDevice->byRFType) {
1475 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
1476 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
1481 case RF_AIROHA7230: //RobertYu:20050104
1482 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2);
1483 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
1488 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
1490 BBvSetDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
1492 pDevice->bRadioOff = TRUE;
1493 //2007-0409-03,<Add> by chester
1494 printk("chester power off\n");
1495 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue
1501 * Description: Turn on Radio power
1505 * pDevice - The adapter to be turned on
1509 * Return Value: TRUE if success; otherwise FALSE
1512 BOOL CARDbRadioPowerOn (PVOID pDeviceHandler)
1514 PSDevice pDevice = (PSDevice) pDeviceHandler;
1515 BOOL bResult = TRUE;
1516 printk("chester power on\n");
1517 if (pDevice->bRadioControlOff == TRUE){
1518 if (pDevice->bHWRadioOff == TRUE) printk("chester bHWRadioOff\n");
1519 if (pDevice->bRadioControlOff == TRUE) printk("chester bRadioControlOff\n");
1522 if (pDevice->bRadioOff == FALSE)
1524 printk("chester pbRadioOff\n");
1527 BBvExitDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
1529 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
1531 switch (pDevice->byRFType) {
1534 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
1535 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
1540 case RF_AIROHA7230: //RobertYu:20050104
1541 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 |
1547 pDevice->bRadioOff = FALSE;
1548 // 2007-0409-03,<Add> by chester
1549 printk("chester power on\n");
1550 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue
1556 BOOL CARDbRemoveKey (PVOID pDeviceHandler, PBYTE pbyBSSID)
1558 PSDevice pDevice = (PSDevice) pDeviceHandler;
1560 KeybRemoveAllKey(&(pDevice->sKey), pbyBSSID, pDevice->PortOffset);
1568 * Add BSSID in PMKID Candidate list.
1572 * hDeviceContext - device structure point
1573 * pbyBSSID - BSSID address for adding
1574 * wRSNCap - BSS's RSN capability
1578 * Return Value: none.
1582 CARDbAdd_PMKID_Candidate (
1583 IN PVOID pDeviceHandler,
1585 IN BOOL bRSNCapExist,
1589 PSDevice pDevice = (PSDevice) pDeviceHandler;
1590 PPMKID_CANDIDATE pCandidateList;
1593 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
1595 if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) {
1596 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFlush_PMKID_Candidate: 3\n");
1597 ZERO_MEMORY(&pDevice->gsPMKIDCandidate, sizeof(SPMKIDCandidateEvent));
1600 for (ii = 0; ii < 6; ii++) {
1601 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02X ", *(pbyBSSID + ii));
1603 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
1606 // Update Old Candidate
1607 for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) {
1608 pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii];
1609 if (MEMEqualMemory(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN)) {
1610 if ((bRSNCapExist == TRUE) && (wRSNCap & BIT0)) {
1611 pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
1613 pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
1620 pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
1621 if ((bRSNCapExist == TRUE) && (wRSNCap & BIT0)) {
1622 pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
1624 pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
1626 MEMvCopy(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN);
1627 pDevice->gsPMKIDCandidate.NumCandidates++;
1628 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
1633 CARDpGetCurrentAddress (
1634 IN PVOID pDeviceHandler
1637 PSDevice pDevice = (PSDevice) pDeviceHandler;
1639 return (pDevice->abyCurrentNetAddr);
1644 VOID CARDvInitChannelTable (PVOID pDeviceHandler)
1646 PSDevice pDevice = (PSDevice) pDeviceHandler;
1647 BOOL bMultiBand = FALSE;
1650 for(ii=1;ii<=CARD_MAX_CHANNEL_TBL;ii++) {
1651 sChannelTbl[ii].bValid = FALSE;
1654 switch (pDevice->byRFType) {
1660 // printk("chester-false\n");
1663 case RF_AIROHA7230 :
1671 if ((pDevice->dwDiagRefCount != 0) ||
1672 (pDevice->b11hEnable == TRUE)) {
1673 if (bMultiBand == TRUE) {
1674 for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
1675 sChannelTbl[ii+1].bValid = TRUE;
1676 pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1677 pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1679 for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
1680 pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1681 pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1684 for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
1685 //2008-8-4 <add> by chester
1686 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
1687 sChannelTbl[ii+1].bValid = TRUE;
1688 pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1689 pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1693 } else if (pDevice->byZoneType <= CCODE_MAX) {
1694 if (bMultiBand == TRUE) {
1695 for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
1696 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
1697 sChannelTbl[ii+1].bValid = TRUE;
1698 pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1699 pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1703 for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
1704 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
1705 sChannelTbl[ii+1].bValid = TRUE;
1706 pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1707 pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1712 DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO"Zone=[%d][%c][%c]!!\n",pDevice->byZoneType,ChannelRuleTab[pDevice->byZoneType].chCountryCode[0],ChannelRuleTab[pDevice->byZoneType].chCountryCode[1]);
1713 for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
1714 if (pDevice->abyRegPwr[ii+1] == 0) {
1715 pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1717 if (pDevice->abyLocalPwr[ii+1] == 0) {
1718 pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1728 * Start Spectrum Measure defined in 802.11h
1732 * hDeviceContext - device structure point
1736 * Return Value: none.
1741 IN PVOID pDeviceHandler,
1742 IN PVOID pvMeasureEIDs,
1743 IN UINT uNumOfMeasureEIDs
1746 PSDevice pDevice = (PSDevice) pDeviceHandler;
1747 PWLAN_IE_MEASURE_REQ pEID = (PWLAN_IE_MEASURE_REQ) pvMeasureEIDs;
1750 BOOL bExpired = TRUE;
1753 if ((pEID == NULL) ||
1754 (uNumOfMeasureEIDs == 0)) {
1757 CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
1758 if (pDevice->bMeasureInProgress == TRUE) {
1759 pDevice->bMeasureInProgress = FALSE;
1760 VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR);
1761 MACvSelectPage1(pDevice->PortOffset);
1762 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0);
1763 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4);
1764 // clear measure control
1765 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
1766 MACvSelectPage0(pDevice->PortOffset);
1767 CARDbSetChannel(pDevice, pDevice->byOrgChannel);
1768 MACvSelectPage1(pDevice->PortOffset);
1769 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
1770 MACvSelectPage0(pDevice->PortOffset);
1772 pDevice->uNumOfMeasureEIDs = uNumOfMeasureEIDs;
1775 pDevice->pCurrMeasureEID = pEID;
1777 pDevice->uNumOfMeasureEIDs--;
1779 if (pDevice->byLocalID > REV_ID_VT3253_B1) {
1780 HIDWORD(qwStartTSF) = HIDWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime)));
1781 LODWORD(qwStartTSF) = LODWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime)));
1782 wDuration = *((PWORD) (pDevice->pCurrMeasureEID->sReq.abyDuration));
1783 wDuration += 1; // 1 TU for channel switching
1785 if ((LODWORD(qwStartTSF) == 0) && (HIDWORD(qwStartTSF) == 0)) {
1786 // start imediately by setting start TSF == current TSF + 2 TU
1787 LODWORD(qwStartTSF) = LODWORD(qwCurrTSF) + 2048;
1788 HIDWORD(qwStartTSF) = HIDWORD(qwCurrTSF);
1789 if (LODWORD(qwCurrTSF) > LODWORD(qwStartTSF)) {
1790 HIDWORD(qwStartTSF)++;
1795 // start at setting start TSF - 1TU(for channel switching)
1796 if (LODWORD(qwStartTSF) < 1024) {
1797 HIDWORD(qwStartTSF)--;
1799 LODWORD(qwStartTSF) -= 1024;
1802 if ((HIDWORD(qwCurrTSF) < HIDWORD(qwStartTSF)) ||
1803 ((HIDWORD(qwCurrTSF) == HIDWORD(qwStartTSF)) &&
1804 (LODWORD(qwCurrTSF) < LODWORD(qwStartTSF)))
1809 VNTWIFIbMeasureReport( pDevice->pMgmt,
1811 pDevice->pCurrMeasureEID,
1813 pDevice->byBasicMap,
1814 pDevice->byCCAFraction,
1818 // hardware do not support measure
1819 VNTWIFIbMeasureReport( pDevice->pMgmt,
1821 pDevice->pCurrMeasureEID,
1822 MEASURE_MODE_INCAPABLE,
1823 pDevice->byBasicMap,
1824 pDevice->byCCAFraction,
1828 } while (pDevice->uNumOfMeasureEIDs != 0);
1830 if (bExpired == FALSE) {
1831 MACvSelectPage1(pDevice->PortOffset);
1832 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART, LODWORD(qwStartTSF));
1833 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART + 4, HIDWORD(qwStartTSF));
1834 VNSvOutPortW(pDevice->PortOffset + MAC_REG_MSRDURATION, wDuration);
1835 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
1836 MACvSelectPage0(pDevice->PortOffset);
1838 // all measure start time expired we should complete action
1839 VNTWIFIbMeasureReport( pDevice->pMgmt,
1843 pDevice->byBasicMap,
1844 pDevice->byCCAFraction,
1855 * Do Channel Switch defined in 802.11h
1859 * hDeviceContext - device structure point
1863 * Return Value: none.
1867 CARDbChannelSwitch (
1868 IN PVOID pDeviceHandler,
1870 IN BYTE byNewChannel,
1874 PSDevice pDevice = (PSDevice) pDeviceHandler;
1875 BOOL bResult = TRUE;
1878 bResult = CARDbSetChannel(pDevice, byNewChannel);
1879 VNTWIFIbChannelSwitch(pDevice->pMgmt, byNewChannel);
1880 MACvSelectPage1(pDevice->PortOffset);
1881 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
1882 MACvSelectPage0(pDevice->PortOffset);
1885 pDevice->byChannelSwitchCount = byCount;
1886 pDevice->byNewChannel = byNewChannel;
1887 pDevice->bChannelSwitch = TRUE;
1889 bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
1898 * Handle Quiet EID defined in 802.11h
1902 * hDeviceContext - device structure point
1906 * Return Value: none.
1911 IN PVOID pDeviceHandler,
1912 IN BOOL bResetQuiet,
1913 IN BYTE byQuietCount,
1914 IN BYTE byQuietPeriod,
1915 IN WORD wQuietDuration,
1916 IN WORD wQuietOffset
1919 PSDevice pDevice = (PSDevice) pDeviceHandler;
1922 if (bResetQuiet == TRUE) {
1923 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
1924 for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
1925 pDevice->sQuiet[ii].bEnable = FALSE;
1927 pDevice->uQuietEnqueue = 0;
1928 pDevice->bEnableFirstQuiet = FALSE;
1929 pDevice->bQuietEnable = FALSE;
1930 pDevice->byQuietStartCount = byQuietCount;
1932 if (pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable == FALSE) {
1933 pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable = TRUE;
1934 pDevice->sQuiet[pDevice->uQuietEnqueue].byPeriod = byQuietPeriod;
1935 pDevice->sQuiet[pDevice->uQuietEnqueue].wDuration = wQuietDuration;
1936 pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime = (DWORD) byQuietCount;
1937 pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime *= pDevice->wBeaconInterval;
1938 pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime += wQuietOffset;
1939 pDevice->uQuietEnqueue++;
1940 pDevice->uQuietEnqueue %= MAX_QUIET_COUNT;
1941 if (pDevice->byQuietStartCount < byQuietCount) {
1942 pDevice->byQuietStartCount = byQuietCount;
1945 // we can not handle Quiet EID more
1954 * Do Quiet, It will called by either ISR (after start) or VNTWIFI (before start) so do not need SPINLOCK
1958 * hDeviceContext - device structure point
1962 * Return Value: none.
1967 IN PVOID pDeviceHandler
1970 PSDevice pDevice = (PSDevice) pDeviceHandler;
1972 DWORD dwStartTime = 0xFFFFFFFF;
1973 UINT uCurrentQuietIndex = 0;
1974 DWORD dwNextTime = 0;
1976 DWORD dwDuration = 0;
1978 for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
1979 if ((pDevice->sQuiet[ii].bEnable == TRUE) &&
1980 (dwStartTime > pDevice->sQuiet[ii].dwStartTime)) {
1981 dwStartTime = pDevice->sQuiet[ii].dwStartTime;
1982 uCurrentQuietIndex = ii;
1985 if (dwStartTime == 0xFFFFFFFF) {
1987 pDevice->bQuietEnable = FALSE;
1988 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
1990 if (pDevice->bQuietEnable == FALSE) {
1992 pDevice->byQuietStartCount--;
1993 dwNextTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
1994 dwNextTime %= pDevice->wBeaconInterval;
1995 MACvSelectPage1(pDevice->PortOffset);
1996 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETINIT, (WORD) dwNextTime);
1997 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (WORD) pDevice->sQuiet[uCurrentQuietIndex].wDuration);
1998 if (pDevice->byQuietStartCount == 0) {
1999 pDevice->bEnableFirstQuiet = FALSE;
2000 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
2002 pDevice->bEnableFirstQuiet = TRUE;
2004 MACvSelectPage0(pDevice->PortOffset);
2006 if (pDevice->dwCurrentQuietEndTime > pDevice->sQuiet[uCurrentQuietIndex].dwStartTime) {
2007 // overlap with previous Quiet
2008 dwGap = pDevice->dwCurrentQuietEndTime - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
2009 if (dwGap >= pDevice->sQuiet[uCurrentQuietIndex].wDuration) {
2010 // return FALSE to indicate next quiet expired, should call this function again
2013 dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap;
2016 dwGap = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime - pDevice->dwCurrentQuietEndTime;
2017 dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration;
2019 // set GAP and Next duration
2020 MACvSelectPage1(pDevice->PortOffset);
2021 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETGAP, (WORD) dwGap);
2022 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (WORD) dwDuration);
2023 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_QUIETRPT);
2024 MACvSelectPage0(pDevice->PortOffset);
2026 pDevice->bQuietEnable = TRUE;
2027 pDevice->dwCurrentQuietEndTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
2028 pDevice->dwCurrentQuietEndTime += pDevice->sQuiet[uCurrentQuietIndex].wDuration;
2029 if (pDevice->sQuiet[uCurrentQuietIndex].byPeriod == 0) {
2030 // not period disable current quiet element
2031 pDevice->sQuiet[uCurrentQuietIndex].bEnable = FALSE;
2033 // set next period start time
2034 dwNextTime = (DWORD) pDevice->sQuiet[uCurrentQuietIndex].byPeriod;
2035 dwNextTime *= pDevice->wBeaconInterval;
2036 pDevice->sQuiet[uCurrentQuietIndex].dwStartTime = dwNextTime;
2038 if (pDevice->dwCurrentQuietEndTime > 0x80010000) {
2039 // decreament all time to avoid wrap around
2040 for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
2041 if (pDevice->sQuiet[ii].bEnable == TRUE) {
2042 pDevice->sQuiet[ii].dwStartTime -= 0x80000000;
2045 pDevice->dwCurrentQuietEndTime -= 0x80000000;
2055 * Set Channel Info of Country
2059 * hDeviceContext - device structure point
2063 * Return Value: none.
2067 CARDvSetCountryInfo (
2068 IN PVOID pDeviceHandler,
2069 IN CARD_PHY_TYPE ePHYType,
2073 PSDevice pDevice = (PSDevice) pDeviceHandler;
2077 UINT uNumOfCountryInfo = 0;
2079 PWLAN_IE_COUNTRY pIE_Country = (PWLAN_IE_COUNTRY) pIE;
2082 uNumOfCountryInfo = (pIE_Country->len - 3);
2083 uNumOfCountryInfo /= 3;
2085 if (ePHYType == PHY_TYPE_11A) {
2086 pDevice->bCountryInfo5G = TRUE;
2087 for(ii=CB_MAX_CHANNEL_24G+1;ii<=CARD_MAX_CHANNEL_TBL;ii++) {
2088 sChannelTbl[ii].bValid = FALSE;
2092 pDevice->bCountryInfo24G = TRUE;
2093 for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
2094 sChannelTbl[ii].bValid = FALSE;
2098 pDevice->abyCountryCode[0] = pIE_Country->abyCountryString[0];
2099 pDevice->abyCountryCode[1] = pIE_Country->abyCountryString[1];
2100 pDevice->abyCountryCode[2] = pIE_Country->abyCountryString[2];
2102 for(ii=0;ii<uNumOfCountryInfo;ii++) {
2103 for(uu=0;uu<pIE_Country->abyCountryInfo[ii*3+1];uu++) {
2104 byCh = CARDbyGetChannelMapping(pDevice, (BYTE)(pIE_Country->abyCountryInfo[ii*3]+step*uu), ePHYType);
2105 sChannelTbl[byCh].bValid = TRUE;
2106 pDevice->abyRegPwr[byCh] = pIE_Country->abyCountryInfo[ii*3+2];
2114 * Set Local Power Constraint
2118 * hDeviceContext - device structure point
2122 * Return Value: none.
2126 CARDvSetPowerConstraint (
2127 IN PVOID pDeviceHandler,
2132 PSDevice pDevice = (PSDevice) pDeviceHandler;
2134 if (byChannel > CB_MAX_CHANNEL_24G) {
2135 if (pDevice->bCountryInfo5G == TRUE) {
2136 pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
2139 if (pDevice->bCountryInfo24G == TRUE) {
2140 pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
2149 * Set Local Power Constraint
2153 * hDeviceContext - device structure point
2157 * Return Value: none.
2161 CARDvGetPowerCapability (
2162 IN PVOID pDeviceHandler,
2163 OUT PBYTE pbyMinPower,
2164 OUT PBYTE pbyMaxPower
2167 PSDevice pDevice = (PSDevice) pDeviceHandler;
2170 *pbyMaxPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh];
2171 byDec = pDevice->abyOFDMPwrTbl[pDevice->byCurrentCh];
2172 if (pDevice->byRFType == RF_UW2452) {
2178 *pbyMinPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh] - byDec;
2185 * Set Support Channels IE defined in 802.11h
2189 * hDeviceContext - device structure point
2193 * Return Value: none.
2197 CARDbySetSupportChannels (
2198 IN PVOID pDeviceHandler,
2202 PSDevice pDevice = (PSDevice) pDeviceHandler;
2205 PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs;
2210 pIE->byElementID = WLAN_EID_SUPP_CH;
2212 pbyChTupple = pIE->abyChannelTuple;
2216 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == TRUE) {
2217 for (ii=28;ii<36;ii+=2) {
2218 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2222 *pbyChTupple++ = 34;
2223 *pbyChTupple++ = byCount;
2225 } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[29] == TRUE) {
2226 for (ii=29;ii<36;ii+=2) {
2227 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2231 *pbyChTupple++ = 36;
2232 *pbyChTupple++ = byCount;
2237 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == TRUE) {
2238 for (ii=36;ii<40;ii++) {
2239 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2243 *pbyChTupple++ = 52;
2244 *pbyChTupple++ = byCount;
2249 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == TRUE) {
2250 for (ii=40;ii<51;ii++) {
2251 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2255 *pbyChTupple++ = 100;
2256 *pbyChTupple++ = byCount;
2258 } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[51] == TRUE) {
2259 for (ii=51;ii<56;ii++) {
2260 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2264 *pbyChTupple++ = 149;
2265 *pbyChTupple++ = byCount;
2268 pIE->len += (byLen - 2);
2276 * Get Current Tx Power
2280 * hDeviceContext - device structure point
2284 * Return Value: none.
2288 CARDbyGetTransmitPower (
2289 IN PVOID pDeviceHandler
2292 PSDevice pDevice = (PSDevice) pDeviceHandler;
2294 return (pDevice->byCurPwrdBm);
2299 CARDbChannelGetList (
2300 IN UINT uCountryCodeIdx,
2301 OUT PBYTE pbyChannelTable
2304 if (uCountryCodeIdx >= CCODE_MAX) {
2307 MEMvCopy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL);
2314 IN PVOID pDeviceHandler,
2318 PSDevice pDevice = (PSDevice) pDeviceHandler;
2320 PWLAN_IE_COUNTRY pIECountry = (PWLAN_IE_COUNTRY) pIE;
2322 pIECountry->byElementID = WLAN_EID_COUNTRY;
2323 pIECountry->len = 0;
2324 pIECountry->abyCountryString[0] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[0];
2325 pIECountry->abyCountryString[1] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[1];
2326 pIECountry->abyCountryString[2] = ' ';
2327 for (ii = CB_MAX_CHANNEL_24G; ii < CB_MAX_CHANNEL; ii++ ) {
2328 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
2329 pIECountry->abyCountryInfo[pIECountry->len++] = sChannelTbl[ii+1].byChannelNumber;
2330 pIECountry->abyCountryInfo[pIECountry->len++] = 1;
2331 pIECountry->abyCountryInfo[pIECountry->len++] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
2334 pIECountry->len += 3;
2339 CARDbGetChannelMapInfo(
2340 IN PVOID pDeviceHandler,
2341 IN UINT uChannelIndex,
2342 OUT PBYTE pbyChannelNumber,
2346 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2348 if (uChannelIndex > CB_MAX_CHANNEL) {
2351 *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber;
2352 *pbyMap = sChannelTbl[uChannelIndex].byMAP;
2353 return sChannelTbl[uChannelIndex].bValid;
2358 CARDvSetChannelMapInfo(
2359 IN PVOID pDeviceHandler,
2360 IN UINT uChannelIndex,
2364 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2366 if (uChannelIndex > CB_MAX_CHANNEL) {
2369 sChannelTbl[uChannelIndex].byMAP |= byMap;
2374 CARDvClearChannelMapInfo(
2375 IN PVOID pDeviceHandler
2378 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2381 for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) {
2382 sChannelTbl[ii].byMAP = 0;
2388 CARDbyAutoChannelSelect(
2389 IN PVOID pDeviceHandler,
2390 CARD_PHY_TYPE ePHYType
2393 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2395 BYTE byOptionChannel = 0;
2396 INT aiWeight[CB_MAX_CHANNEL_24G+1] = {-1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
2398 if (ePHYType == PHY_TYPE_11A) {
2399 for(ii=CB_MAX_CHANNEL_24G+1;ii<=CB_MAX_CHANNEL;ii++) {
2400 if (sChannelTbl[ii].bValid == TRUE) {
2401 if (byOptionChannel == 0) {
2402 byOptionChannel = (BYTE) ii;
2404 if (sChannelTbl[ii].byMAP == 0) {
2406 } else if (BITbIsBitOff(sChannelTbl[ii].byMAP, 0x08)) {
2407 byOptionChannel = (BYTE) ii;
2412 byOptionChannel = 0;
2413 for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
2414 if (sChannelTbl[ii].bValid == TRUE) {
2415 if (sChannelTbl[ii].byMAP == 0) {
2416 aiWeight[ii] += 100;
2417 } else if (BITbIsBitOn(sChannelTbl[ii].byMAP, 0x01)) {
2419 aiWeight[ii-3] -= 10;
2422 aiWeight[ii-2] -= 20;
2425 aiWeight[ii-1] -= 40;
2428 if (ii < CB_MAX_CHANNEL_24G) {
2429 aiWeight[ii+1] -= 40;
2431 if (ii < (CB_MAX_CHANNEL_24G - 1)) {
2432 aiWeight[ii+2] -= 20;
2434 if (ii < (CB_MAX_CHANNEL_24G - 2)) {
2435 aiWeight[ii+3] -= 10;
2440 for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
2441 if ((sChannelTbl[ii].bValid == TRUE) &&
2442 (aiWeight[ii] > aiWeight[byOptionChannel])) {
2443 byOptionChannel = (BYTE) ii;
2447 return (byOptionChannel);
2455 IN PVOID pDeviceHandler
2458 PSDevice pDevice = (PSDevice) pDeviceHandler;
2462 // initialize TD index
2463 pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]);
2464 pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]);
2466 for (uu = 0; uu < TYPE_MAXTD; uu ++)
2467 pDevice->iTDUsed[uu] = 0;
2469 for (uu = 0; uu < pDevice->sOpts.nTxDescs[0]; uu++) {
2470 pCurrTD = &(pDevice->apTD0Rings[uu]);
2471 pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
2472 // init all Tx Packet pointer to NULL
2474 for (uu = 0; uu < pDevice->sOpts.nTxDescs[1]; uu++) {
2475 pCurrTD = &(pDevice->apTD1Rings[uu]);
2476 pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
2477 // init all Tx Packet pointer to NULL
2480 // set MAC TD pointer
2481 MACvSetCurrTXDescAddr(TYPE_TXDMA0, pDevice->PortOffset,
2482 (pDevice->td0_pool_dma));
2484 MACvSetCurrTXDescAddr(TYPE_AC0DMA, pDevice->PortOffset,
2485 (pDevice->td1_pool_dma));
2487 // set MAC Beacon TX pointer
2488 MACvSetCurrBCNTxDescAddr(pDevice->PortOffset,
2489 (pDevice->tx_beacon_dma));
2502 * pDevice - Pointer to the adapter
2506 * Return Value: none
2511 IN PVOID pDeviceHandler
2514 PSDevice pDevice = (PSDevice) pDeviceHandler;
2520 // initialize RD index
2521 pDevice->pCurrRD[0]=&(pDevice->aRD0Ring[0]);
2522 pDevice->pCurrRD[1]=&(pDevice->aRD1Ring[0]);
2524 // init state, all RD is chip's
2525 for (uu = 0; uu < pDevice->sOpts.nRxDescs0; uu++) {
2526 pDesc =&(pDevice->aRD0Ring[uu]);
2527 pDesc->m_rd0RD0.wResCount = (WORD)(pDevice->rx_buf_sz);
2528 pDesc->m_rd0RD0.f1Owner=OWNED_BY_NIC;
2529 pDesc->m_rd1RD1.wReqCount = (WORD)(pDevice->rx_buf_sz);
2532 // init state, all RD is chip's
2533 for (uu = 0; uu < pDevice->sOpts.nRxDescs1; uu++) {
2534 pDesc =&(pDevice->aRD1Ring[uu]);
2535 pDesc->m_rd0RD0.wResCount = (WORD)(pDevice->rx_buf_sz);
2536 pDesc->m_rd0RD0.f1Owner=OWNED_BY_NIC;
2537 pDesc->m_rd1RD1.wReqCount = (WORD)(pDevice->rx_buf_sz);
2540 pDevice->cbDFCB = CB_MAX_RX_FRAG;
2541 pDevice->cbFreeDFCB = pDevice->cbDFCB;
2544 MACvRx0PerPktMode(pDevice->PortOffset);
2545 MACvRx1PerPktMode(pDevice->PortOffset);
2546 // set MAC RD pointer
2547 MACvSetCurrRx0DescAddr(pDevice->PortOffset,
2548 pDevice->rd0_pool_dma);
2550 MACvSetCurrRx1DescAddr(pDevice->PortOffset,
2551 pDevice->rd1_pool_dma);
2558 * Description: Get response Control frame rate in CCK mode
2562 * pDevice - The adapter to be set
2563 * wRateIdx - Receiving data rate
2567 * Return Value: response Control frame rate
2570 WORD CARDwGetCCKControlRate(PVOID pDeviceHandler, WORD wRateIdx)
2572 PSDevice pDevice = (PSDevice) pDeviceHandler;
2573 UINT ui = (UINT)wRateIdx;
2575 while (ui > RATE_1M) {
2576 if (pDevice->wBasicRate & ((WORD)1 << ui)) {
2581 return (WORD)RATE_1M;
2585 * Description: Get response Control frame rate in OFDM mode
2589 * pDevice - The adapter to be set
2590 * wRateIdx - Receiving data rate
2594 * Return Value: response Control frame rate
2597 WORD CARDwGetOFDMControlRate (PVOID pDeviceHandler, WORD wRateIdx)
2599 PSDevice pDevice = (PSDevice) pDeviceHandler;
2600 UINT ui = (UINT)wRateIdx;
2602 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate);
2604 if (!CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
2605 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
2606 if (wRateIdx > RATE_24M)
2607 wRateIdx = RATE_24M;
2610 while (ui > RATE_11M) {
2611 if (pDevice->wBasicRate & ((WORD)1 << ui)) {
2612 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate : %d\n", ui);
2617 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate: 6M\n");
2618 return (WORD)RATE_24M;
2623 * Description: Set RSPINF
2627 * pDevice - The adapter to be set
2631 * Return Value: None.
2634 void CARDvSetRSPINF (PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType)
2636 PSDevice pDevice = (PSDevice) pDeviceHandler;
2637 BYTE byServ = 0x00, bySignal = 0x00; //For CCK
2639 BYTE byTxRate, byRsvTime; //For OFDM
2642 MACvSelectPage1(pDevice->PortOffset);
2645 BBvCaculateParameter(pDevice,
2647 CARDwGetCCKControlRate((PVOID)pDevice, RATE_1M),
2654 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2656 BBvCaculateParameter(pDevice,
2658 CARDwGetCCKControlRate((PVOID)pDevice, RATE_2M),
2665 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2667 BBvCaculateParameter(pDevice,
2669 CARDwGetCCKControlRate((PVOID)pDevice, RATE_5M),
2676 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2678 BBvCaculateParameter(pDevice,
2680 CARDwGetCCKControlRate((PVOID)pDevice, RATE_11M),
2687 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2689 s_vCaculateOFDMRParameter(RATE_6M,
2693 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
2695 s_vCaculateOFDMRParameter(RATE_9M,
2699 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
2701 s_vCaculateOFDMRParameter(RATE_12M,
2705 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
2707 s_vCaculateOFDMRParameter(RATE_18M,
2711 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
2713 s_vCaculateOFDMRParameter(RATE_24M,
2717 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
2719 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_36M),
2723 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
2725 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_48M),
2729 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
2731 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
2735 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
2738 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
2742 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
2744 MACvSelectPage0(pDevice->PortOffset);
2748 * Description: Update IFS
2752 * pDevice - The adapter to be set
2756 * Return Value: None.
2759 void vUpdateIFS (PVOID pDeviceHandler)
2761 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
2762 PSDevice pDevice = (PSDevice) pDeviceHandler;
2765 if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a
2766 pDevice->uSlot = C_SLOT_SHORT;
2767 pDevice->uSIFS = C_SIFS_A;
2768 pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
2769 pDevice->uCwMin = C_CWMIN_A;
2772 else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b
2773 pDevice->uSlot = C_SLOT_LONG;
2774 pDevice->uSIFS = C_SIFS_BG;
2775 pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
2776 pDevice->uCwMin = C_CWMIN_B;
2779 else { // PK_TYPE_11GA & PK_TYPE_11GB
2780 pDevice->uSIFS = C_SIFS_BG;
2781 if (pDevice->bShortSlotTime) {
2782 pDevice->uSlot = C_SLOT_SHORT;
2784 pDevice->uSlot = C_SLOT_LONG;
2786 pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
2787 if (pDevice->wBasicRate & 0x0150) { //0000 0001 0101 0000,24M,12M,6M
2788 pDevice->uCwMin = C_CWMIN_A;
2792 pDevice->uCwMin = C_CWMIN_B;
2797 pDevice->uCwMax = C_CWMAX;
2798 pDevice->uEIFS = C_EIFS;
2799 if (pDevice->byRFType == RF_RFMD2959) {
2800 // bcs TX_PE will reserve 3 us
2801 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (BYTE)(pDevice->uSIFS - 3));
2802 VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (BYTE)(pDevice->uDIFS - 3));
2804 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (BYTE)pDevice->uSIFS);
2805 VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (BYTE)pDevice->uDIFS);
2807 VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, (BYTE)pDevice->uEIFS);
2808 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, (BYTE)pDevice->uSlot);
2809 byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
2810 VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, (BYTE)byMaxMin);
2813 void CARDvUpdateBasicTopRate (PVOID pDeviceHandler)
2815 PSDevice pDevice = (PSDevice) pDeviceHandler;
2816 BYTE byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
2819 //Determines the highest basic rate.
2820 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
2821 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
2825 pDevice->byTopOFDMBasicRate = byTopOFDM;
2827 for (ii = RATE_11M;; ii --) {
2828 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
2834 pDevice->byTopCCKBasicRate = byTopCCK;
2839 * Description: Set NIC Tx Basic Rate
2843 * pDevice - The adapter to be set
2844 * wBasicRate - Basic Rate to be set
2848 * Return Value: TRUE if succeeded; FALSE if failed.
2851 BOOL CARDbAddBasicRate (PVOID pDeviceHandler, WORD wRateIdx)
2853 PSDevice pDevice = (PSDevice) pDeviceHandler;
2854 WORD wRate = (WORD)(1<<wRateIdx);
2856 pDevice->wBasicRate |= wRate;
2858 //Determines the highest basic rate.
2859 CARDvUpdateBasicTopRate((PVOID)pDevice);
2864 BOOL CARDbIsOFDMinBasicRate (PVOID pDeviceHandler)
2866 PSDevice pDevice = (PSDevice) pDeviceHandler;
2869 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
2870 if ((pDevice->wBasicRate) & ((WORD)(1<<ii)))
2876 BYTE CARDbyGetPktType (PVOID pDeviceHandler)
2878 PSDevice pDevice = (PSDevice) pDeviceHandler;
2880 if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) {
2881 return (BYTE)pDevice->byBBType;
2883 else if (CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
2884 return PK_TYPE_11GA;
2887 return PK_TYPE_11GB;
2892 * Description: Set NIC Loopback mode
2896 * pDevice - The adapter to be set
2897 * wLoopbackMode - Loopback mode to be set
2901 * Return Value: none
2904 void CARDvSetLoopbackMode (DWORD_PTR dwIoBase, WORD wLoopbackMode)
2906 switch(wLoopbackMode) {
2916 MACvSetLoopbackMode(dwIoBase, LOBYTE(wLoopbackMode));
2917 // set Baseband loopback
2922 * Description: Software Reset NIC
2926 * pDevice - The adapter to be reset
2930 * Return Value: none
2933 BOOL CARDbSoftwareReset (PVOID pDeviceHandler)
2935 PSDevice pDevice = (PSDevice) pDeviceHandler;
2938 if (!MACbSafeSoftwareReset(pDevice->PortOffset))
2946 * Description: Caculate TSF offset of two TSF input
2947 * Get TSF Offset from RxBCN's TSF and local TSF
2951 * pDevice - The adapter to be sync.
2952 * qwTSF1 - Rx BCN's TSF
2953 * qwTSF2 - Local TSF
2957 * Return Value: TSF Offset value
2960 QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2)
2963 WORD wRxBcnTSFOffst= 0;;
2965 HIDWORD(qwTSFOffset) = 0;
2966 LODWORD(qwTSFOffset) = 0;
2967 wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE];
2968 (qwTSF2).u.dwLowDword += (DWORD)(wRxBcnTSFOffst);
2969 if ((qwTSF2).u.dwLowDword < (DWORD)(wRxBcnTSFOffst)) {
2970 (qwTSF2).u.dwHighDword++;
2972 LODWORD(qwTSFOffset) = LODWORD(qwTSF1) - LODWORD(qwTSF2);
2973 if (LODWORD(qwTSF1) < LODWORD(qwTSF2)) {
2975 HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2) - 1 ;
2978 HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2);
2980 return (qwTSFOffset);
2985 * Description: Read NIC TSF counter
2986 * Get local TSF counter
2990 * pDevice - The adapter to be read
2992 * qwCurrTSF - Current TSF counter
2994 * Return Value: TRUE if success; otherwise FALSE
2997 BOOL CARDbGetCurrentTSF (DWORD_PTR dwIoBase, PQWORD pqwCurrTSF)
3002 MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
3003 for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
3004 VNSvInPortB(dwIoBase + MAC_REG_TFTCTL, &byData);
3005 if (BITbIsBitOff(byData, TFTCTL_TSFCNTRRD))
3008 if (ww == W_MAX_TIMEOUT)
3010 VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR, &LODWORD(*pqwCurrTSF));
3011 VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR + 4, &HIDWORD(*pqwCurrTSF));
3018 * Description: Read NIC TSF counter
3019 * Get NEXTTBTT from adjusted TSF and Beacon Interval
3023 * qwTSF - Current TSF counter
3024 * wbeaconInterval - Beacon Interval
3026 * qwCurrTSF - Current TSF counter
3028 * Return Value: TSF value of next Beacon
3031 QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval)
3035 UINT uHighRemain, uLowRemain;
3036 UINT uBeaconInterval;
3038 uBeaconInterval = wBeaconInterval * 1024;
3039 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
3040 uLowNextTBTT = (LODWORD(qwTSF) >> 10) << 10;
3041 // low dword (mod) bcn
3042 uLowRemain = (uLowNextTBTT) % uBeaconInterval;
3043 // uHighRemain = ((0x80000000 % uBeaconInterval)* 2 * HIDWORD(qwTSF))
3044 // % uBeaconInterval;
3045 // high dword (mod) bcn
3046 uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * HIDWORD(qwTSF))
3048 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
3049 uLowRemain = uBeaconInterval - uLowRemain;
3051 // check if carry when add one beacon interval
3052 if ((~uLowNextTBTT) < uLowRemain)
3055 LODWORD(qwTSF) = uLowNextTBTT + uLowRemain;
3062 * Description: Set NIC TSF counter for first Beacon time
3063 * Get NEXTTBTT from adjusted TSF and Beacon Interval
3067 * dwIoBase - IO Base
3068 * wBeaconInterval - Beacon Interval
3072 * Return Value: none
3075 void CARDvSetFirstNextTBTT (DWORD_PTR dwIoBase, WORD wBeaconInterval)
3080 HIDWORD(qwNextTBTT) = 0;
3081 LODWORD(qwNextTBTT) = 0;
3082 CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); //Get Local TSF counter
3083 qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
3085 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwNextTBTT));
3086 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwNextTBTT));
3087 MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
3088 //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:First Next TBTT[%8xh:%8xh] \n", HIDWORD(qwNextTBTT), LODWORD(qwNextTBTT));
3094 * Description: Sync NIC TSF counter for Beacon time
3095 * Get NEXTTBTT and write to HW
3099 * pDevice - The adapter to be set
3100 * qwTSF - Current TSF counter
3101 * wBeaconInterval - Beacon Interval
3105 * Return Value: none
3108 void CARDvUpdateNextTBTT (DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval)
3111 qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
3113 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwTSF));
3114 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwTSF));
3115 MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
3116 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n",(UINT)HIDWORD(qwTSF), (UINT)LODWORD(qwTSF));