Merge branch 'fix/pcm-hwptr' into for-linus
[linux/fpc-iii.git] / drivers / staging / vt6655 / card.c
blob723f44e0bbae0b1ea5ffa54b2c0e242f793bd73b
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
19 * File: card.c
20 * Purpose: Provide functions to setup NIC operation mode
21 * Functions:
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
41 * Revision History:
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__)
49 #include "tmacro.h"
50 #endif
51 #if !defined(__CARD_H__)
52 #include "card.h"
53 #endif
54 #if !defined(__TBIT_H__)
55 #include "tbit.h"
56 #endif
57 #if !defined(__BASEBAND_H__)
58 #include "baseband.h"
59 #endif
60 #if !defined(__MAC_H__)
61 #include "mac.h"
62 #endif
63 #if !defined(__DESC_H__)
64 #include "desc.h"
65 #endif
66 #if !defined(__RF_H__)
67 #include "rf.h"
68 #endif
69 #if !defined(__VNTWIFI_H__)
70 #include "vntwifi.h"
71 #endif
72 #if !defined(__POWER_H__)
73 #include "power.h"
74 #endif
75 #if !defined(__KEY_H__)
76 #include "key.h"
77 #endif
78 #if !defined(__RC4_H__)
79 #include "rc4.h"
80 #endif
81 #if !defined(__COUNTRY_H__)
82 #include "country.h"
83 #endif
84 #if !defined(__UMEM_H__)
85 #include "umem.h"
86 #endif
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.
96 #define C_SIFS_BG 10
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
105 #define C_CWMIN_B 31
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;
115 UINT uFrequency;
116 BOOL bValid;
117 BYTE byMAP;
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};
122 //6M, 9M, 12M, 48M
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};
126 //1M, 2M, 5M, 11M,
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] =
141 {0, 0, FALSE, 0},
142 {1, 2412, TRUE, 0},
143 {2, 2417, TRUE, 0},
144 {3, 2422, TRUE, 0},
145 {4, 2427, TRUE, 0},
146 {5, 2432, TRUE, 0},
147 {6, 2437, TRUE, 0},
148 {7, 2442, TRUE, 0},
149 {8, 2447, TRUE, 0},
150 {9, 2452, TRUE, 0},
151 {10, 2457, TRUE, 0},
152 {11, 2462, TRUE, 0},
153 {12, 2467, TRUE, 0},
154 {13, 2472, TRUE, 0},
155 {14, 2484, TRUE, 0},
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},
164 {7, 5035, TRUE, 0},
165 {8, 5040, TRUE, 0},
166 {9, 5045, TRUE, 0},
167 {11, 5055, TRUE, 0},
168 {12, 5060, TRUE, 0},
169 {16, 5080, TRUE, 0},
170 {34, 5170, TRUE, 0},
171 {36, 5180, TRUE, 0},
172 {38, 5190, TRUE, 0},
173 {40, 5200, TRUE, 0},
174 {42, 5210, TRUE, 0},
175 {44, 5220, TRUE, 0},
176 {46, 5230, TRUE, 0},
177 {48, 5240, TRUE, 0},
178 {52, 5260, TRUE, 0},
179 {56, 5280, TRUE, 0},
180 {60, 5300, TRUE, 0},
181 {64, 5320, 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},
197 {165, 5825, 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,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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}
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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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} },
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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
347 {CCODE_LITHUANIA, {'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,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 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} },
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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 0, 16, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0} },
409 {CCODE_SWEDEN, {'S','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}
410 , { 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} },
411 {CCODE_SWITZERLAND, {'C','H'}, { 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
412 , { 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, 18, 0, 18, 0, 18, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
413 {CCODE_SYRIA, {'S','Y'}, { 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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0, 0} },
447 {CCODE_MAX, {'U','N'}, { 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, 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 --------------------------*/
455 static
456 VOID
457 s_vCaculateOFDMRParameter(
458 IN BYTE byRate,
459 IN CARD_PHY_TYPE ePHYType,
460 OUT PBYTE pbyTxRate,
461 OUT PBYTE pbyRsvTime
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:
475 * 1 = 2.4G channel 1
476 * 2 = 2.4G channel 2
477 * ...
478 * 14 = 2.4G channel 14
479 * 15 = 4.9G channel 183
480 * 16 = 4.9G channel 184
481 * .....
482 * Output: TRUE if the specified 5GHz band is allowed to be used.
483 False otherwise.
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
490 BOOL
491 ChannelValid(UINT CountryCode, UINT ChannelIndex)
493 BOOL bValid;
495 bValid = FALSE;
497 * If Channel Index is invalid, return invalid
499 if ((ChannelIndex > CB_MAX_CHANNEL) ||
500 (ChannelIndex == 0))
502 bValid = FALSE;
503 goto exit;
506 bValid = sChannelTbl[ChannelIndex].bValid;
508 exit:
509 return (bValid);
511 } /* end ChannelValid */
515 * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode.
517 * Parameters:
518 * In:
519 * wRate - Tx Rate
520 * byPktType - Tx Packet type
521 * Out:
522 * pbyTxRate - pointer to RSPINF TxRate field
523 * pbyRsvTime - pointer to RSPINF RsvTime field
525 * Return Value: none
528 static
529 VOID
530 s_vCaculateOFDMRParameter (
531 IN BYTE byRate,
532 IN CARD_PHY_TYPE ePHYType,
533 OUT PBYTE pbyTxRate,
534 OUT PBYTE pbyRsvTime
537 switch (byRate) {
538 case RATE_6M :
539 if (ePHYType == PHY_TYPE_11A) {//5GHZ
540 *pbyTxRate = 0x9B;
541 *pbyRsvTime = 44;
543 else {
544 *pbyTxRate = 0x8B;
545 *pbyRsvTime = 50;
547 break;
549 case RATE_9M :
550 if (ePHYType == PHY_TYPE_11A) {//5GHZ
551 *pbyTxRate = 0x9F;
552 *pbyRsvTime = 36;
554 else {
555 *pbyTxRate = 0x8F;
556 *pbyRsvTime = 42;
558 break;
560 case RATE_12M :
561 if (ePHYType == PHY_TYPE_11A) {//5GHZ
562 *pbyTxRate = 0x9A;
563 *pbyRsvTime = 32;
565 else {
566 *pbyTxRate = 0x8A;
567 *pbyRsvTime = 38;
569 break;
571 case RATE_18M :
572 if (ePHYType == PHY_TYPE_11A) {//5GHZ
573 *pbyTxRate = 0x9E;
574 *pbyRsvTime = 28;
576 else {
577 *pbyTxRate = 0x8E;
578 *pbyRsvTime = 34;
580 break;
582 case RATE_36M :
583 if (ePHYType == PHY_TYPE_11A) {//5GHZ
584 *pbyTxRate = 0x9D;
585 *pbyRsvTime = 24;
587 else {
588 *pbyTxRate = 0x8D;
589 *pbyRsvTime = 30;
591 break;
593 case RATE_48M :
594 if (ePHYType == PHY_TYPE_11A) {//5GHZ
595 *pbyTxRate = 0x98;
596 *pbyRsvTime = 24;
598 else {
599 *pbyTxRate = 0x88;
600 *pbyRsvTime = 30;
602 break;
604 case RATE_54M :
605 if (ePHYType == PHY_TYPE_11A) {//5GHZ
606 *pbyTxRate = 0x9C;
607 *pbyRsvTime = 24;
609 else {
610 *pbyTxRate = 0x8C;
611 *pbyRsvTime = 30;
613 break;
615 case RATE_24M :
616 default :
617 if (ePHYType == PHY_TYPE_11A) {//5GHZ
618 *pbyTxRate = 0x99;
619 *pbyRsvTime = 28;
621 else {
622 *pbyTxRate = 0x89;
623 *pbyRsvTime = 34;
625 break;
632 * Description: Set RSPINF
634 * Parameters:
635 * In:
636 * pDevice - The adapter to be set
637 * Out:
638 * none
640 * Return Value: None.
643 static
644 VOID
645 s_vSetRSPINF (PSDevice pDevice, CARD_PHY_TYPE ePHYType, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs)
647 BYTE byServ = 0, bySignal = 0; // For CCK
648 WORD wLen = 0;
649 BYTE byTxRate = 0, byRsvTime = 0; // For OFDM
651 //Set to Page1
652 MACvSelectPage1(pDevice->PortOffset);
654 //RSPINF_b_1
655 BBvCaculateParameter(pDevice,
657 VNTWIFIbyGetACKTxRate(RATE_1M, pvSupportRateIEs, pvExtSupportRateIEs),
658 PK_TYPE_11B,
659 &wLen,
660 &byServ,
661 &bySignal
664 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
665 ///RSPINF_b_2
666 BBvCaculateParameter(pDevice,
668 VNTWIFIbyGetACKTxRate(RATE_2M, pvSupportRateIEs, pvExtSupportRateIEs),
669 PK_TYPE_11B,
670 &wLen,
671 &byServ,
672 &bySignal
675 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
676 //RSPINF_b_5
677 BBvCaculateParameter(pDevice,
679 VNTWIFIbyGetACKTxRate(RATE_5M, pvSupportRateIEs, pvExtSupportRateIEs),
680 PK_TYPE_11B,
681 &wLen,
682 &byServ,
683 &bySignal
686 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
687 //RSPINF_b_11
688 BBvCaculateParameter(pDevice,
690 VNTWIFIbyGetACKTxRate(RATE_11M, pvSupportRateIEs, pvExtSupportRateIEs),
691 PK_TYPE_11B,
692 &wLen,
693 &byServ,
694 &bySignal
697 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
698 //RSPINF_a_6
699 s_vCaculateOFDMRParameter(RATE_6M,
700 ePHYType,
701 &byTxRate,
702 &byRsvTime);
703 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
704 //RSPINF_a_9
705 s_vCaculateOFDMRParameter(RATE_9M,
706 ePHYType,
707 &byTxRate,
708 &byRsvTime);
709 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
710 //RSPINF_a_12
711 s_vCaculateOFDMRParameter(RATE_12M,
712 ePHYType,
713 &byTxRate,
714 &byRsvTime);
715 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
716 //RSPINF_a_18
717 s_vCaculateOFDMRParameter(RATE_18M,
718 ePHYType,
719 &byTxRate,
720 &byRsvTime);
721 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
722 //RSPINF_a_24
723 s_vCaculateOFDMRParameter(RATE_24M,
724 ePHYType,
725 &byTxRate,
726 &byRsvTime);
727 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
728 //RSPINF_a_36
729 s_vCaculateOFDMRParameter(
730 VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs),
731 ePHYType,
732 &byTxRate,
733 &byRsvTime);
734 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
735 //RSPINF_a_48
736 s_vCaculateOFDMRParameter(
737 VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs),
738 ePHYType,
739 &byTxRate,
740 &byRsvTime);
741 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
742 //RSPINF_a_54
743 s_vCaculateOFDMRParameter(
744 VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs),
745 ePHYType,
746 &byTxRate,
747 &byRsvTime);
748 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
749 //RSPINF_a_72
750 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
751 //Set to Page0
752 MACvSelectPage0(pDevice->PortOffset);
758 /*--------------------- Export Variables --------------------------*/
760 /*--------------------- Export Functions --------------------------*/
761 BYTE CARDbyGetChannelMapping (PVOID pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType)
763 UINT ii;
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) {
771 return ((BYTE) ii);
773 ii++;
775 return (0);
779 BYTE CARDbyGetChannelNumber (PVOID pDeviceHandler, BYTE byChannelIndex)
781 // PSDevice pDevice = (PSDevice) pDeviceHandler;
782 return(sChannelTbl[byChannelIndex].byChannelNumber);
786 * Description: Set NIC media channel
788 * Parameters:
789 * In:
790 * pDeviceHandler - The adapter to be set
791 * uConnectionChannel - Channel to be set
792 * Out:
793 * none
795 * Return Value: TRUE if succeeded; FALSE if failed.
798 BOOL CARDbSetChannel (PVOID pDeviceHandler, UINT uConnectionChannel)
800 PSDevice pDevice = (PSDevice) pDeviceHandler;
801 BOOL bResult = TRUE;
804 if (pDevice->byCurrentCh == uConnectionChannel) {
805 return bResult;
808 if (sChannelTbl[uConnectionChannel].bValid == FALSE) {
809 return (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);
819 // clear NAV
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);
829 //}} RobertYu
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) {
854 #ifdef PLICE_DEBUG
855 //printk("Func:CARDbSetChannel:call RFbSetPower:11B\n");
856 #endif
857 RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
858 } else {
859 #ifdef PLICE_DEBUG
860 //printk("Func:CARDbSetChannel:call RFbSetPower\n");
861 #endif
862 RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
865 return(bResult);
871 * Description: Card Send packet function
873 * Parameters:
874 * In:
875 * pDeviceHandler - The adapter to be set
876 * pPacket - Packet buffer pointer
877 * ePktType - Packet type
878 * uLength - Packet length
879 * Out:
880 * none
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);
897 return (TRUE);
903 * Description: Get Card short preamble option value
905 * Parameters:
906 * In:
907 * pDevice - The adapter to be set
908 * Out:
909 * none
911 * Return Value: TRUE if short preamble; otherwise FALSE
914 BOOL CARDbIsShortPreamble (PVOID pDeviceHandler)
916 PSDevice pDevice = (PSDevice) pDeviceHandler;
917 if (pDevice->byPreambleType == 0) {
918 return(FALSE);
920 return(TRUE);
924 * Description: Get Card short slot time option value
926 * Parameters:
927 * In:
928 * pDevice - The adapter to be set
929 * Out:
930 * none
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
945 * Parameters:
946 * In:
947 * pDevice - The adapter to be set
948 * Out:
949 * none
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;
957 BYTE byCWMaxMin = 0;
958 BYTE bySlot = 0;
959 BYTE bySIFS = 0;
960 BYTE byDIFS = 0;
961 BYTE byData;
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);
990 } else {
991 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A);
993 BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x03);
994 bySlot = C_SLOT_SHORT;
995 bySIFS = C_SIFS_A;
996 byDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
997 byCWMaxMin = 0xA4;
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;
1021 bySIFS = C_SIFS_BG;
1022 byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
1023 byCWMaxMin = 0xA5;
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);
1047 bySIFS = C_SIFS_BG;
1048 if(VNTWIFIbIsShortSlotTime(wCapInfo)) {
1049 bySlot = C_SLOT_SHORT;
1050 byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT;
1051 } else {
1052 bySlot = C_SLOT_LONG;
1053 byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
1055 if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) {
1056 byCWMaxMin = 0xA4;
1057 } else {
1058 byCWMaxMin = 0xA5;
1060 if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) {
1061 pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField);
1062 if (pDevice->bProtectMode) {
1063 MACvEnableProtectMD(pDevice->PortOffset);
1064 } else {
1065 MACvDisableProtectMD(pDevice->PortOffset);
1068 if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) {
1069 pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField);
1070 if (pDevice->bBarkerPreambleMd) {
1071 MACvEnableBarkerPreambleMd(pDevice->PortOffset);
1072 } else {
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.
1081 bySIFS -= 3;
1082 byDIFS -= 3;
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;
1105 } else {
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;
1116 } else {
1117 pDevice->byPreambleType = 0;
1119 s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates);
1120 pDevice->eCurrentPHYType = ePHYType;
1121 // set for NDIS OID_802_11SUPPORTED_RATES
1122 return (TRUE);
1126 * Description: Sync. TSF counter to BSS
1127 * Get TSF offset and write to HW
1129 * Parameters:
1130 * In:
1131 * pDevice - The adapter to be sync.
1132 * byRxRate - data rate of receive beacon
1133 * qwBSSTimestamp - Rx BCN's TSF
1134 * qwLocalTSF - Local TSF
1135 * Out:
1136 * none
1138 * Return Value: none
1141 BOOL CARDbUpdateTSF (PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF)
1143 PSDevice pDevice = (PSDevice) pDeviceHandler;
1144 QWORD qwTSFOffset;
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);
1152 // adjust TSF
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);
1158 return(TRUE);
1163 * Description: Set NIC TSF counter for first Beacon time
1164 * Get NEXTTBTT from adjusted TSF and Beacon Interval
1166 * Parameters:
1167 * In:
1168 * pDevice - The adapter to be set.
1169 * wBeaconInterval - Beacon Interval
1170 * Out:
1171 * none
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;
1183 QWORD qwNextTBTT;
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))
1194 % uBeaconInterval;
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;
1207 // Set NextTBTT
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);
1212 return(TRUE);
1218 * Description: Card Stop Hardware Tx
1220 * Parameters:
1221 * In:
1222 * pDeviceHandler - The adapter to be set
1223 * ePktType - Packet type to stop
1224 * Out:
1225 * none
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 ++;
1251 return(FALSE);
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){
1261 return(FALSE);
1264 // wait all Data TD complete
1265 if (pDevice->bStopDataPkt == TRUE) {
1266 if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
1267 return(FALSE);
1271 return(TRUE);
1276 * Description: Card Start Hardware Tx
1278 * Parameters:
1279 * In:
1280 * pDeviceHandler - The adapter to be set
1281 * ePktType - Packet type to start
1282 * Out:
1283 * none
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);
1311 return(TRUE);
1317 * Description: Card Set BSSID value
1319 * Parameters:
1320 * In:
1321 * pDeviceHandler - The adapter to be set
1322 * pbyBSSID - pointer to BSSID field
1323 * bAdhoc - flag to indicate IBSS
1324 * Out:
1325 * none
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);
1338 } else {
1339 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
1341 if (eOPMode == OP_MODE_AP) {
1342 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
1343 } else {
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 );
1351 } else {
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;
1361 return(TRUE);
1366 * Description: Card indicate status
1368 * Parameters:
1369 * In:
1370 * pDeviceHandler - The adapter to be set
1371 * eStatus - Status
1372 * Out:
1373 * none
1375 * Return Value: TRUE if success; FALSE if failed.
1383 * Description: Save Assoc info. contain in assoc. response frame
1385 * Parameters:
1386 * In:
1387 * pDevice - The adapter to be set
1388 * wCapabilityInfo - Capability information
1389 * wStatus - Status code
1390 * wAID - Assoc. ID
1391 * uLen - Length of IEs
1392 * pbyIEs - pointer to IEs
1393 * Out:
1394 * none
1396 * Return Value: TRUE if succeed; otherwise FALSE
1399 BOOL CARDbSetTxDataRate(
1400 PVOID pDeviceHandler,
1401 WORD wDataRate
1404 PSDevice pDevice = (PSDevice) pDeviceHandler;
1406 pDevice->wCurrentRate = wDataRate;
1407 return(TRUE);
1412 * Routine Description:
1413 * Consider to power down when no more packets to tx or rx.
1415 * Parameters:
1416 * In:
1417 * pDevice - The adapter to be set
1418 * Out:
1419 * none
1421 * Return Value: TRUE if power down success; otherwise FALSE
1424 BOOL
1425 CARDbPowerDown(
1426 PVOID pDeviceHandler
1429 PSDevice pDevice = (PSDevice)pDeviceHandler;
1430 UINT uIdx;
1432 // check if already in Doze mode
1433 if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
1434 return TRUE;
1436 // Froce PSEN on
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)
1443 return FALSE;
1446 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
1447 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Go to Doze ZZZZZZZZZZZZZZZ\n");
1448 return TRUE;
1452 * Description: Turn off Radio power
1454 * Parameters:
1455 * In:
1456 * pDevice - The adapter to be turned off
1457 * Out:
1458 * none
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)
1469 return TRUE;
1472 switch (pDevice->byRFType) {
1474 case RF_RFMD2959:
1475 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
1476 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
1477 break;
1479 case RF_AIROHA:
1480 case RF_AL2230S:
1481 case RF_AIROHA7230: //RobertYu:20050104
1482 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2);
1483 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
1484 break;
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
1496 return bResult;
1501 * Description: Turn on Radio power
1503 * Parameters:
1504 * In:
1505 * pDevice - The adapter to be turned on
1506 * Out:
1507 * none
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");
1520 return FALSE;}
1522 if (pDevice->bRadioOff == FALSE)
1524 printk("chester pbRadioOff\n");
1525 return TRUE;}
1527 BBvExitDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
1529 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
1531 switch (pDevice->byRFType) {
1533 case RF_RFMD2959:
1534 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
1535 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
1536 break;
1538 case RF_AIROHA:
1539 case RF_AL2230S:
1540 case RF_AIROHA7230: //RobertYu:20050104
1541 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 |
1542 SOFTPWRCTL_SWPE3));
1543 break;
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
1551 return bResult;
1556 BOOL CARDbRemoveKey (PVOID pDeviceHandler, PBYTE pbyBSSID)
1558 PSDevice pDevice = (PSDevice) pDeviceHandler;
1560 KeybRemoveAllKey(&(pDevice->sKey), pbyBSSID, pDevice->PortOffset);
1561 return (TRUE);
1567 * Description:
1568 * Add BSSID in PMKID Candidate list.
1570 * Parameters:
1571 * In:
1572 * hDeviceContext - device structure point
1573 * pbyBSSID - BSSID address for adding
1574 * wRSNCap - BSS's RSN capability
1575 * Out:
1576 * none
1578 * Return Value: none.
1581 BOOL
1582 CARDbAdd_PMKID_Candidate (
1583 IN PVOID pDeviceHandler,
1584 IN PBYTE pbyBSSID,
1585 IN BOOL bRSNCapExist,
1586 IN WORD wRSNCap
1589 PSDevice pDevice = (PSDevice) pDeviceHandler;
1590 PPMKID_CANDIDATE pCandidateList;
1591 UINT ii = 0;
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;
1612 } else {
1613 pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
1615 return TRUE;
1619 // New Candidate
1620 pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
1621 if ((bRSNCapExist == TRUE) && (wRSNCap & BIT0)) {
1622 pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
1623 } else {
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);
1629 return TRUE;
1632 PVOID
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;
1648 UINT ii;
1650 for(ii=1;ii<=CARD_MAX_CHANNEL_TBL;ii++) {
1651 sChannelTbl[ii].bValid = FALSE;
1654 switch (pDevice->byRFType) {
1655 case RF_RFMD2959 :
1656 case RF_AIROHA :
1657 case RF_AL2230S:
1658 case RF_UW2451 :
1659 case RF_VT3226 :
1660 // printk("chester-false\n");
1661 bMultiBand = FALSE;
1662 break;
1663 case RF_AIROHA7230 :
1664 case RF_UW2452 :
1665 case RF_NOTHING :
1666 default :
1667 bMultiBand = TRUE;
1668 break;
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];
1683 } else {
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];
1702 } else {
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];
1727 * Description:
1728 * Start Spectrum Measure defined in 802.11h
1730 * Parameters:
1731 * In:
1732 * hDeviceContext - device structure point
1733 * Out:
1734 * none
1736 * Return Value: none.
1739 BOOL
1740 CARDbStartMeasure (
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;
1748 QWORD qwCurrTSF;
1749 QWORD qwStartTSF;
1750 BOOL bExpired = TRUE;
1751 WORD wDuration = 0;
1753 if ((pEID == NULL) ||
1754 (uNumOfMeasureEIDs == 0)) {
1755 return (TRUE);
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;
1774 do {
1775 pDevice->pCurrMeasureEID = pEID;
1776 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)++;
1792 bExpired = FALSE;
1793 break;
1794 } else {
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)))
1806 bExpired = FALSE;
1807 break;
1809 VNTWIFIbMeasureReport( pDevice->pMgmt,
1810 FALSE,
1811 pDevice->pCurrMeasureEID,
1812 MEASURE_MODE_LATE,
1813 pDevice->byBasicMap,
1814 pDevice->byCCAFraction,
1815 pDevice->abyRPIs
1817 } else {
1818 // hardware do not support measure
1819 VNTWIFIbMeasureReport( pDevice->pMgmt,
1820 FALSE,
1821 pDevice->pCurrMeasureEID,
1822 MEASURE_MODE_INCAPABLE,
1823 pDevice->byBasicMap,
1824 pDevice->byCCAFraction,
1825 pDevice->abyRPIs
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);
1837 } else {
1838 // all measure start time expired we should complete action
1839 VNTWIFIbMeasureReport( pDevice->pMgmt,
1840 TRUE,
1841 NULL,
1843 pDevice->byBasicMap,
1844 pDevice->byCCAFraction,
1845 pDevice->abyRPIs
1848 return (TRUE);
1854 * Description:
1855 * Do Channel Switch defined in 802.11h
1857 * Parameters:
1858 * In:
1859 * hDeviceContext - device structure point
1860 * Out:
1861 * none
1863 * Return Value: none.
1866 BOOL
1867 CARDbChannelSwitch (
1868 IN PVOID pDeviceHandler,
1869 IN BYTE byMode,
1870 IN BYTE byNewChannel,
1871 IN BYTE byCount
1874 PSDevice pDevice = (PSDevice) pDeviceHandler;
1875 BOOL bResult = TRUE;
1877 if (byCount == 0) {
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);
1883 return(bResult);
1885 pDevice->byChannelSwitchCount = byCount;
1886 pDevice->byNewChannel = byNewChannel;
1887 pDevice->bChannelSwitch = TRUE;
1888 if (byMode == 1) {
1889 bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
1891 return (bResult);
1897 * Description:
1898 * Handle Quiet EID defined in 802.11h
1900 * Parameters:
1901 * In:
1902 * hDeviceContext - device structure point
1903 * Out:
1904 * none
1906 * Return Value: none.
1909 BOOL
1910 CARDbSetQuiet (
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;
1920 UINT ii = 0;
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;
1944 } else {
1945 // we can not handle Quiet EID more
1947 return (TRUE);
1953 * Description:
1954 * Do Quiet, It will called by either ISR (after start) or VNTWIFI (before start) so do not need SPINLOCK
1956 * Parameters:
1957 * In:
1958 * hDeviceContext - device structure point
1959 * Out:
1960 * none
1962 * Return Value: none.
1965 BOOL
1966 CARDbStartQuiet (
1967 IN PVOID pDeviceHandler
1970 PSDevice pDevice = (PSDevice) pDeviceHandler;
1971 UINT ii = 0;
1972 DWORD dwStartTime = 0xFFFFFFFF;
1973 UINT uCurrentQuietIndex = 0;
1974 DWORD dwNextTime = 0;
1975 DWORD dwGap = 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) {
1986 // no more quiet
1987 pDevice->bQuietEnable = FALSE;
1988 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
1989 } else {
1990 if (pDevice->bQuietEnable == FALSE) {
1991 // first quiet
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));
2001 } else {
2002 pDevice->bEnableFirstQuiet = TRUE;
2004 MACvSelectPage0(pDevice->PortOffset);
2005 } else {
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
2011 return (FALSE);
2013 dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap;
2014 dwGap = 0;
2015 } else {
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;
2032 } else {
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;
2048 return (TRUE);
2054 * Description:
2055 * Set Channel Info of Country
2057 * Parameters:
2058 * In:
2059 * hDeviceContext - device structure point
2060 * Out:
2061 * none
2063 * Return Value: none.
2066 VOID
2067 CARDvSetCountryInfo (
2068 IN PVOID pDeviceHandler,
2069 IN CARD_PHY_TYPE ePHYType,
2070 IN PVOID pIE
2073 PSDevice pDevice = (PSDevice) pDeviceHandler;
2074 UINT ii = 0;
2075 UINT uu = 0;
2076 UINT step = 0;
2077 UINT uNumOfCountryInfo = 0;
2078 BYTE byCh = 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;
2090 step = 4;
2091 } else {
2092 pDevice->bCountryInfo24G = TRUE;
2093 for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
2094 sChannelTbl[ii].bValid = FALSE;
2096 step = 1;
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];
2113 * Description:
2114 * Set Local Power Constraint
2116 * Parameters:
2117 * In:
2118 * hDeviceContext - device structure point
2119 * Out:
2120 * none
2122 * Return Value: none.
2125 VOID
2126 CARDvSetPowerConstraint (
2127 IN PVOID pDeviceHandler,
2128 IN BYTE byChannel,
2129 IN I8 byPower
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;
2138 } else {
2139 if (pDevice->bCountryInfo24G == TRUE) {
2140 pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
2148 * Description:
2149 * Set Local Power Constraint
2151 * Parameters:
2152 * In:
2153 * hDeviceContext - device structure point
2154 * Out:
2155 * none
2157 * Return Value: none.
2160 VOID
2161 CARDvGetPowerCapability (
2162 IN PVOID pDeviceHandler,
2163 OUT PBYTE pbyMinPower,
2164 OUT PBYTE pbyMaxPower
2167 PSDevice pDevice = (PSDevice) pDeviceHandler;
2168 BYTE byDec = 0;
2170 *pbyMaxPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh];
2171 byDec = pDevice->abyOFDMPwrTbl[pDevice->byCurrentCh];
2172 if (pDevice->byRFType == RF_UW2452) {
2173 byDec *= 3;
2174 byDec >>= 1;
2175 } else {
2176 byDec <<= 1;
2178 *pbyMinPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh] - byDec;
2184 * Description:
2185 * Set Support Channels IE defined in 802.11h
2187 * Parameters:
2188 * In:
2189 * hDeviceContext - device structure point
2190 * Out:
2191 * none
2193 * Return Value: none.
2196 BYTE
2197 CARDbySetSupportChannels (
2198 IN PVOID pDeviceHandler,
2199 IN OUT PBYTE pbyIEs
2202 PSDevice pDevice = (PSDevice) pDeviceHandler;
2203 UINT ii;
2204 BYTE byCount;
2205 PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs;
2206 PBYTE pbyChTupple;
2207 BYTE byLen = 0;
2210 pIE->byElementID = WLAN_EID_SUPP_CH;
2211 pIE->len = 0;
2212 pbyChTupple = pIE->abyChannelTuple;
2213 byLen = 2;
2214 // lower band
2215 byCount = 0;
2216 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == TRUE) {
2217 for (ii=28;ii<36;ii+=2) {
2218 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2219 byCount++;
2222 *pbyChTupple++ = 34;
2223 *pbyChTupple++ = byCount;
2224 byLen += 2;
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) {
2228 byCount++;
2231 *pbyChTupple++ = 36;
2232 *pbyChTupple++ = byCount;
2233 byLen += 2;
2235 // middle band
2236 byCount = 0;
2237 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == TRUE) {
2238 for (ii=36;ii<40;ii++) {
2239 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2240 byCount++;
2243 *pbyChTupple++ = 52;
2244 *pbyChTupple++ = byCount;
2245 byLen += 2;
2247 // higher band
2248 byCount = 0;
2249 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == TRUE) {
2250 for (ii=40;ii<51;ii++) {
2251 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2252 byCount++;
2255 *pbyChTupple++ = 100;
2256 *pbyChTupple++ = byCount;
2257 byLen += 2;
2258 } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[51] == TRUE) {
2259 for (ii=51;ii<56;ii++) {
2260 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2261 byCount++;
2264 *pbyChTupple++ = 149;
2265 *pbyChTupple++ = byCount;
2266 byLen += 2;
2268 pIE->len += (byLen - 2);
2269 return (byLen);
2275 * Description:
2276 * Get Current Tx Power
2278 * Parameters:
2279 * In:
2280 * hDeviceContext - device structure point
2281 * Out:
2282 * none
2284 * Return Value: none.
2288 CARDbyGetTransmitPower (
2289 IN PVOID pDeviceHandler
2292 PSDevice pDevice = (PSDevice) pDeviceHandler;
2294 return (pDevice->byCurPwrdBm);
2298 BOOL
2299 CARDbChannelGetList (
2300 IN UINT uCountryCodeIdx,
2301 OUT PBYTE pbyChannelTable
2304 if (uCountryCodeIdx >= CCODE_MAX) {
2305 return (FALSE);
2307 MEMvCopy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL);
2308 return (TRUE);
2312 VOID
2313 CARDvSetCountryIE(
2314 IN PVOID pDeviceHandler,
2315 IN PVOID pIE
2318 PSDevice pDevice = (PSDevice) pDeviceHandler;
2319 UINT ii;
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;
2338 BOOL
2339 CARDbGetChannelMapInfo(
2340 IN PVOID pDeviceHandler,
2341 IN UINT uChannelIndex,
2342 OUT PBYTE pbyChannelNumber,
2343 OUT PBYTE pbyMap
2346 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2348 if (uChannelIndex > CB_MAX_CHANNEL) {
2349 return FALSE;
2351 *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber;
2352 *pbyMap = sChannelTbl[uChannelIndex].byMAP;
2353 return sChannelTbl[uChannelIndex].bValid;
2357 VOID
2358 CARDvSetChannelMapInfo(
2359 IN PVOID pDeviceHandler,
2360 IN UINT uChannelIndex,
2361 IN BYTE byMap
2364 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2366 if (uChannelIndex > CB_MAX_CHANNEL) {
2367 return;
2369 sChannelTbl[uChannelIndex].byMAP |= byMap;
2373 VOID
2374 CARDvClearChannelMapInfo(
2375 IN PVOID pDeviceHandler
2378 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2379 UINT ii = 0;
2381 for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) {
2382 sChannelTbl[ii].byMAP = 0;
2387 BYTE
2388 CARDbyAutoChannelSelect(
2389 IN PVOID pDeviceHandler,
2390 CARD_PHY_TYPE ePHYType
2393 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2394 UINT ii = 0;
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) {
2405 return ((BYTE) ii);
2406 } else if (BITbIsBitOff(sChannelTbl[ii].byMAP, 0x08)) {
2407 byOptionChannel = (BYTE) ii;
2411 } else {
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)) {
2418 if (ii > 3) {
2419 aiWeight[ii-3] -= 10;
2421 if (ii > 2) {
2422 aiWeight[ii-2] -= 20;
2424 if (ii > 1) {
2425 aiWeight[ii-1] -= 40;
2427 aiWeight[ii] -= 80;
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);
2452 //xxx
2453 VOID
2454 CARDvSafeResetTx (
2455 IN PVOID pDeviceHandler
2458 PSDevice pDevice = (PSDevice) pDeviceHandler;
2459 UINT uu;
2460 PSTxDesc pCurrTD;
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));
2497 * Description:
2498 * Reset Rx
2500 * Parameters:
2501 * In:
2502 * pDevice - Pointer to the adapter
2503 * Out:
2504 * none
2506 * Return Value: none
2509 VOID
2510 CARDvSafeResetRx (
2511 IN PVOID pDeviceHandler
2514 PSDevice pDevice = (PSDevice) pDeviceHandler;
2515 UINT uu;
2516 PSRxDesc pDesc;
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;
2543 // set perPkt mode
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
2560 * Parameters:
2561 * In:
2562 * pDevice - The adapter to be set
2563 * wRateIdx - Receiving data rate
2564 * Out:
2565 * none
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)) {
2577 return (WORD)ui;
2579 ui --;
2581 return (WORD)RATE_1M;
2585 * Description: Get response Control frame rate in OFDM mode
2587 * Parameters:
2588 * In:
2589 * pDevice - The adapter to be set
2590 * wRateIdx - Receiving data rate
2591 * Out:
2592 * none
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;
2608 return wRateIdx;
2610 while (ui > RATE_11M) {
2611 if (pDevice->wBasicRate & ((WORD)1 << ui)) {
2612 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate : %d\n", ui);
2613 return (WORD)ui;
2615 ui --;
2617 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate: 6M\n");
2618 return (WORD)RATE_24M;
2623 * Description: Set RSPINF
2625 * Parameters:
2626 * In:
2627 * pDevice - The adapter to be set
2628 * Out:
2629 * none
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
2638 WORD wLen = 0x0000;
2639 BYTE byTxRate, byRsvTime; //For OFDM
2641 //Set to Page1
2642 MACvSelectPage1(pDevice->PortOffset);
2644 //RSPINF_b_1
2645 BBvCaculateParameter(pDevice,
2647 CARDwGetCCKControlRate((PVOID)pDevice, RATE_1M),
2648 PK_TYPE_11B,
2649 &wLen,
2650 &byServ,
2651 &bySignal
2654 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2655 ///RSPINF_b_2
2656 BBvCaculateParameter(pDevice,
2658 CARDwGetCCKControlRate((PVOID)pDevice, RATE_2M),
2659 PK_TYPE_11B,
2660 &wLen,
2661 &byServ,
2662 &bySignal
2665 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2666 //RSPINF_b_5
2667 BBvCaculateParameter(pDevice,
2669 CARDwGetCCKControlRate((PVOID)pDevice, RATE_5M),
2670 PK_TYPE_11B,
2671 &wLen,
2672 &byServ,
2673 &bySignal
2676 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2677 //RSPINF_b_11
2678 BBvCaculateParameter(pDevice,
2680 CARDwGetCCKControlRate((PVOID)pDevice, RATE_11M),
2681 PK_TYPE_11B,
2682 &wLen,
2683 &byServ,
2684 &bySignal
2687 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2688 //RSPINF_a_6
2689 s_vCaculateOFDMRParameter(RATE_6M,
2690 ePHYType,
2691 &byTxRate,
2692 &byRsvTime);
2693 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
2694 //RSPINF_a_9
2695 s_vCaculateOFDMRParameter(RATE_9M,
2696 ePHYType,
2697 &byTxRate,
2698 &byRsvTime);
2699 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
2700 //RSPINF_a_12
2701 s_vCaculateOFDMRParameter(RATE_12M,
2702 ePHYType,
2703 &byTxRate,
2704 &byRsvTime);
2705 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
2706 //RSPINF_a_18
2707 s_vCaculateOFDMRParameter(RATE_18M,
2708 ePHYType,
2709 &byTxRate,
2710 &byRsvTime);
2711 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
2712 //RSPINF_a_24
2713 s_vCaculateOFDMRParameter(RATE_24M,
2714 ePHYType,
2715 &byTxRate,
2716 &byRsvTime);
2717 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
2718 //RSPINF_a_36
2719 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_36M),
2720 ePHYType,
2721 &byTxRate,
2722 &byRsvTime);
2723 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
2724 //RSPINF_a_48
2725 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_48M),
2726 ePHYType,
2727 &byTxRate,
2728 &byRsvTime);
2729 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
2730 //RSPINF_a_54
2731 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
2732 ePHYType,
2733 &byTxRate,
2734 &byRsvTime);
2735 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
2737 //RSPINF_a_72
2738 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
2739 ePHYType,
2740 &byTxRate,
2741 &byRsvTime);
2742 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
2743 //Set to Page0
2744 MACvSelectPage0(pDevice->PortOffset);
2748 * Description: Update IFS
2750 * Parameters:
2751 * In:
2752 * pDevice - The adapter to be set
2753 * Out:
2754 * none
2756 * Return Value: None.
2759 void vUpdateIFS (PVOID pDeviceHandler)
2761 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
2762 PSDevice pDevice = (PSDevice) pDeviceHandler;
2764 BYTE byMaxMin = 0;
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;
2770 byMaxMin = 4;
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;
2777 byMaxMin = 5;
2779 else { // PK_TYPE_11GA & PK_TYPE_11GB
2780 pDevice->uSIFS = C_SIFS_BG;
2781 if (pDevice->bShortSlotTime) {
2782 pDevice->uSlot = C_SLOT_SHORT;
2783 } else {
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;
2789 byMaxMin = 4;
2791 else {
2792 pDevice->uCwMin = C_CWMIN_B;
2793 byMaxMin = 5;
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));
2803 } else {
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;
2817 BYTE ii;
2819 //Determines the highest basic rate.
2820 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
2821 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
2822 byTopOFDM = ii;
2823 break;
2825 pDevice->byTopOFDMBasicRate = byTopOFDM;
2827 for (ii = RATE_11M;; ii --) {
2828 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
2829 byTopCCK = ii;
2830 break;
2831 if (ii == RATE_1M)
2832 break;
2834 pDevice->byTopCCKBasicRate = byTopCCK;
2839 * Description: Set NIC Tx Basic Rate
2841 * Parameters:
2842 * In:
2843 * pDevice - The adapter to be set
2844 * wBasicRate - Basic Rate to be set
2845 * Out:
2846 * none
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);
2861 return(TRUE);
2864 BOOL CARDbIsOFDMinBasicRate (PVOID pDeviceHandler)
2866 PSDevice pDevice = (PSDevice) pDeviceHandler;
2867 int ii;
2869 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
2870 if ((pDevice->wBasicRate) & ((WORD)(1<<ii)))
2871 return TRUE;
2873 return FALSE;
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;
2886 else {
2887 return PK_TYPE_11GB;
2892 * Description: Set NIC Loopback mode
2894 * Parameters:
2895 * In:
2896 * pDevice - The adapter to be set
2897 * wLoopbackMode - Loopback mode to be set
2898 * Out:
2899 * none
2901 * Return Value: none
2904 void CARDvSetLoopbackMode (DWORD_PTR dwIoBase, WORD wLoopbackMode)
2906 switch(wLoopbackMode) {
2907 case CARD_LB_NONE:
2908 case CARD_LB_MAC:
2909 case CARD_LB_PHY:
2910 break;
2911 default:
2912 ASSERT(FALSE);
2913 break;
2915 // set MAC loopback
2916 MACvSetLoopbackMode(dwIoBase, LOBYTE(wLoopbackMode));
2917 // set Baseband loopback
2922 * Description: Software Reset NIC
2924 * Parameters:
2925 * In:
2926 * pDevice - The adapter to be reset
2927 * Out:
2928 * none
2930 * Return Value: none
2933 BOOL CARDbSoftwareReset (PVOID pDeviceHandler)
2935 PSDevice pDevice = (PSDevice) pDeviceHandler;
2937 // reset MAC
2938 if (!MACbSafeSoftwareReset(pDevice->PortOffset))
2939 return FALSE;
2941 return TRUE;
2946 * Description: Caculate TSF offset of two TSF input
2947 * Get TSF Offset from RxBCN's TSF and local TSF
2949 * Parameters:
2950 * In:
2951 * pDevice - The adapter to be sync.
2952 * qwTSF1 - Rx BCN's TSF
2953 * qwTSF2 - Local TSF
2954 * Out:
2955 * none
2957 * Return Value: TSF Offset value
2960 QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2)
2962 QWORD qwTSFOffset;
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)) {
2974 // if borrow needed
2975 HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2) - 1 ;
2977 else {
2978 HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2);
2980 return (qwTSFOffset);
2985 * Description: Read NIC TSF counter
2986 * Get local TSF counter
2988 * Parameters:
2989 * In:
2990 * pDevice - The adapter to be read
2991 * Out:
2992 * qwCurrTSF - Current TSF counter
2994 * Return Value: TRUE if success; otherwise FALSE
2997 BOOL CARDbGetCurrentTSF (DWORD_PTR dwIoBase, PQWORD pqwCurrTSF)
2999 WORD ww;
3000 BYTE byData;
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))
3006 break;
3008 if (ww == W_MAX_TIMEOUT)
3009 return(FALSE);
3010 VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR, &LODWORD(*pqwCurrTSF));
3011 VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR + 4, &HIDWORD(*pqwCurrTSF));
3013 return(TRUE);
3018 * Description: Read NIC TSF counter
3019 * Get NEXTTBTT from adjusted TSF and Beacon Interval
3021 * Parameters:
3022 * In:
3023 * qwTSF - Current TSF counter
3024 * wbeaconInterval - Beacon Interval
3025 * Out:
3026 * qwCurrTSF - Current TSF counter
3028 * Return Value: TSF value of next Beacon
3031 QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval)
3034 UINT uLowNextTBTT;
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))
3047 % uBeaconInterval;
3048 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
3049 uLowRemain = uBeaconInterval - uLowRemain;
3051 // check if carry when add one beacon interval
3052 if ((~uLowNextTBTT) < uLowRemain)
3053 HIDWORD(qwTSF) ++ ;
3055 LODWORD(qwTSF) = uLowNextTBTT + uLowRemain;
3057 return (qwTSF);
3062 * Description: Set NIC TSF counter for first Beacon time
3063 * Get NEXTTBTT from adjusted TSF and Beacon Interval
3065 * Parameters:
3066 * In:
3067 * dwIoBase - IO Base
3068 * wBeaconInterval - Beacon Interval
3069 * Out:
3070 * none
3072 * Return Value: none
3075 void CARDvSetFirstNextTBTT (DWORD_PTR dwIoBase, WORD wBeaconInterval)
3078 QWORD qwNextTBTT;
3080 HIDWORD(qwNextTBTT) = 0;
3081 LODWORD(qwNextTBTT) = 0;
3082 CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); //Get Local TSF counter
3083 qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
3084 // Set NextTBTT
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));
3089 return;
3094 * Description: Sync NIC TSF counter for Beacon time
3095 * Get NEXTTBTT and write to HW
3097 * Parameters:
3098 * In:
3099 * pDevice - The adapter to be set
3100 * qwTSF - Current TSF counter
3101 * wBeaconInterval - Beacon Interval
3102 * Out:
3103 * none
3105 * Return Value: none
3108 void CARDvUpdateNextTBTT (DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval)
3111 qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
3112 // Set NextTBTT
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));
3118 return;