[ARM] pxa: update defconfig for Verdex Pro
[linux-2.6/verdex.git] / drivers / staging / vt6655 / card.c
blobdb786142717fbf3c1f7217ba2645b0f7b0fcf29e
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 #include "tmacro.h"
49 #include "card.h"
50 #include "baseband.h"
51 #include "mac.h"
52 #include "desc.h"
53 #include "rf.h"
54 #include "vntwifi.h"
55 #include "power.h"
56 #include "key.h"
57 #include "rc4.h"
58 #include "country.h"
60 /*--------------------- Static Definitions -------------------------*/
62 //static int msglevel =MSG_LEVEL_DEBUG;
63 static int msglevel =MSG_LEVEL_INFO;
65 #define C_SIFS_A 16 // micro sec.
66 #define C_SIFS_BG 10
68 #define C_EIFS 80 // micro sec.
71 #define C_SLOT_SHORT 9 // micro sec.
72 #define C_SLOT_LONG 20
74 #define C_CWMIN_A 15 // slot time
75 #define C_CWMIN_B 31
77 #define C_CWMAX 1023 // slot time
79 #define CARD_MAX_CHANNEL_TBL 56
81 #define WAIT_BEACON_TX_DOWN_TMO 3 // Times
83 typedef struct tagSChannelTblElement {
84 BYTE byChannelNumber;
85 UINT uFrequency;
86 BOOL bValid;
87 BYTE byMAP;
88 }SChannelTblElement, *PSChannelTblElement;
90 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
91 static BYTE abyDefaultSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
92 //6M, 9M, 12M, 48M
93 static BYTE abyDefaultExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
94 //6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M
95 static BYTE abyDefaultSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
96 //1M, 2M, 5M, 11M,
97 static BYTE abyDefaultSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
101 /*--------------------- Static Classes ----------------------------*/
103 /*--------------------- Static Variables --------------------------*/
106 const WORD cwRXBCNTSFOff[MAX_RATE] =
107 {17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
109 static SChannelTblElement sChannelTbl[CARD_MAX_CHANNEL_TBL+1] =
111 {0, 0, FALSE, 0},
112 {1, 2412, TRUE, 0},
113 {2, 2417, TRUE, 0},
114 {3, 2422, TRUE, 0},
115 {4, 2427, TRUE, 0},
116 {5, 2432, TRUE, 0},
117 {6, 2437, TRUE, 0},
118 {7, 2442, TRUE, 0},
119 {8, 2447, TRUE, 0},
120 {9, 2452, TRUE, 0},
121 {10, 2457, TRUE, 0},
122 {11, 2462, TRUE, 0},
123 {12, 2467, TRUE, 0},
124 {13, 2472, TRUE, 0},
125 {14, 2484, TRUE, 0},
126 {183, 4915, TRUE, 0},
127 {184, 4920, TRUE, 0},
128 {185, 4925, TRUE, 0},
129 {187, 4935, TRUE, 0},
130 {188, 4940, TRUE, 0},
131 {189, 4945, TRUE, 0},
132 {192, 4960, TRUE, 0},
133 {196, 4980, TRUE, 0},
134 {7, 5035, TRUE, 0},
135 {8, 5040, TRUE, 0},
136 {9, 5045, TRUE, 0},
137 {11, 5055, TRUE, 0},
138 {12, 5060, TRUE, 0},
139 {16, 5080, TRUE, 0},
140 {34, 5170, TRUE, 0},
141 {36, 5180, TRUE, 0},
142 {38, 5190, TRUE, 0},
143 {40, 5200, TRUE, 0},
144 {42, 5210, TRUE, 0},
145 {44, 5220, TRUE, 0},
146 {46, 5230, TRUE, 0},
147 {48, 5240, TRUE, 0},
148 {52, 5260, TRUE, 0},
149 {56, 5280, TRUE, 0},
150 {60, 5300, TRUE, 0},
151 {64, 5320, TRUE, 0},
152 {100, 5500, TRUE, 0},
153 {104, 5520, TRUE, 0},
154 {108, 5540, TRUE, 0},
155 {112, 5560, TRUE, 0},
156 {116, 5580, TRUE, 0},
157 {120, 5600, TRUE, 0},
158 {124, 5620, TRUE, 0},
159 {128, 5640, TRUE, 0},
160 {132, 5660, TRUE, 0},
161 {136, 5680, TRUE, 0},
162 {140, 5700, TRUE, 0},
163 {149, 5745, TRUE, 0},
164 {153, 5765, TRUE, 0},
165 {157, 5785, TRUE, 0},
166 {161, 5805, TRUE, 0},
167 {165, 5825, TRUE, 0}
171 /************************************************************************
172 * The Radar regulation rules for each country
173 ************************************************************************/
174 SCountryTable ChannelRuleTab[CCODE_MAX+1] =
176 /************************************************************************
177 * This table is based on Athero driver rules
178 ************************************************************************/
179 /* Country Available channels, ended with 0 */
180 /* 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 */
181 {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}
182 , { 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} },
183 {CCODE_TELEC, {'J','P'}, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 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, 0}
184 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 23, 0, 0, 23, 0, 23, 23, 0, 23, 0, 0, 23, 23, 23, 0, 23, 0, 23, 0, 23, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
241 {CCODE_BULGARIA, {'B','G'}, { 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, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
242 , { 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, 23, 23, 23, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0} },
243 {CCODE_CANADA, {'C','A'}, { 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}
244 , { 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} },
245 {CCODE_CHILE, {'C','L'}, { 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, 1}
246 , { 20, 20, 20, 20, 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, 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}
258 , { 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} },
259 {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}
260 , { 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} },
261 {CCODE_DOMINICAN_REPUBLIC, {'D','O'}, { 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}
262 , { 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
297 {CCODE_IRELAND, {'I','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}
298 , { 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} },
299 {CCODE_ITALY, {'I','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}
300 , { 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} },
301 {CCODE_ISRAEL, {'I','L'}, { 0, 0, 0, 0, 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, 0, 0, 0, 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, 20, 20, 20, 20, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 0, 0, 0, 0, 0} },
319 {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}
320 , { 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} },
321 {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}
322 , { 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, 23, 23, 23, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30} },
323 {CCODE_MACEDONIA, {'M','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, 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}
324 , { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 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, 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} },
353 {CCODE_POLAND, {'P','L'}, { 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}
354 , { 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} },
355 {CCODE_PORTUGAL, {'P','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}
356 , { 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} },
357 {CCODE_PUERTO_RICO, {'P','R'}, { 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,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, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20} },
369 {CCODE_SLOVAKIA, {'S','K'}, { 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, 0}
370 , { 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, 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} },
371 {CCODE_SLOVENIA, {'S','I'}, { 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}
372 , { 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} },
373 {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}
374 , { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }
419 /* 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 */
423 /*--------------------- Static Functions --------------------------*/
425 static
426 VOID
427 s_vCaculateOFDMRParameter(
428 IN BYTE byRate,
429 IN CARD_PHY_TYPE ePHYType,
430 OUT PBYTE pbyTxRate,
431 OUT PBYTE pbyRsvTime
435 /*--------------------- Export Variables --------------------------*/
437 /*--------------------- Export Functions --------------------------*/
440 /*--------------------- Export function -------------------------*/
441 /************************************************************************
442 * Country Channel Valid
443 * Input: CountryCode, ChannelNum
444 * ChanneIndex is defined as VT3253 MAC channel:
445 * 1 = 2.4G channel 1
446 * 2 = 2.4G channel 2
447 * ...
448 * 14 = 2.4G channel 14
449 * 15 = 4.9G channel 183
450 * 16 = 4.9G channel 184
451 * .....
452 * Output: TRUE if the specified 5GHz band is allowed to be used.
453 False otherwise.
454 // 4.9G => Ch 183, 184, 185, 187, 188, 189, 192, 196 (Value:15 ~ 22)
456 // 5G => Ch 7, 8, 9, 11, 12, 16, 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64,
457 // 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 (Value 23 ~ 56)
458 ************************************************************************/
459 //2008-8-4 <add> by chester
460 BOOL
461 ChannelValid(UINT CountryCode, UINT ChannelIndex)
463 BOOL bValid;
465 bValid = FALSE;
467 * If Channel Index is invalid, return invalid
469 if ((ChannelIndex > CB_MAX_CHANNEL) ||
470 (ChannelIndex == 0))
472 bValid = FALSE;
473 goto exit;
476 bValid = sChannelTbl[ChannelIndex].bValid;
478 exit:
479 return (bValid);
481 } /* end ChannelValid */
485 * Description: Caculate TxRate and RsvTime fields for RSPINF in OFDM mode.
487 * Parameters:
488 * In:
489 * wRate - Tx Rate
490 * byPktType - Tx Packet type
491 * Out:
492 * pbyTxRate - pointer to RSPINF TxRate field
493 * pbyRsvTime - pointer to RSPINF RsvTime field
495 * Return Value: none
498 static
499 VOID
500 s_vCaculateOFDMRParameter (
501 IN BYTE byRate,
502 IN CARD_PHY_TYPE ePHYType,
503 OUT PBYTE pbyTxRate,
504 OUT PBYTE pbyRsvTime
507 switch (byRate) {
508 case RATE_6M :
509 if (ePHYType == PHY_TYPE_11A) {//5GHZ
510 *pbyTxRate = 0x9B;
511 *pbyRsvTime = 44;
513 else {
514 *pbyTxRate = 0x8B;
515 *pbyRsvTime = 50;
517 break;
519 case RATE_9M :
520 if (ePHYType == PHY_TYPE_11A) {//5GHZ
521 *pbyTxRate = 0x9F;
522 *pbyRsvTime = 36;
524 else {
525 *pbyTxRate = 0x8F;
526 *pbyRsvTime = 42;
528 break;
530 case RATE_12M :
531 if (ePHYType == PHY_TYPE_11A) {//5GHZ
532 *pbyTxRate = 0x9A;
533 *pbyRsvTime = 32;
535 else {
536 *pbyTxRate = 0x8A;
537 *pbyRsvTime = 38;
539 break;
541 case RATE_18M :
542 if (ePHYType == PHY_TYPE_11A) {//5GHZ
543 *pbyTxRate = 0x9E;
544 *pbyRsvTime = 28;
546 else {
547 *pbyTxRate = 0x8E;
548 *pbyRsvTime = 34;
550 break;
552 case RATE_36M :
553 if (ePHYType == PHY_TYPE_11A) {//5GHZ
554 *pbyTxRate = 0x9D;
555 *pbyRsvTime = 24;
557 else {
558 *pbyTxRate = 0x8D;
559 *pbyRsvTime = 30;
561 break;
563 case RATE_48M :
564 if (ePHYType == PHY_TYPE_11A) {//5GHZ
565 *pbyTxRate = 0x98;
566 *pbyRsvTime = 24;
568 else {
569 *pbyTxRate = 0x88;
570 *pbyRsvTime = 30;
572 break;
574 case RATE_54M :
575 if (ePHYType == PHY_TYPE_11A) {//5GHZ
576 *pbyTxRate = 0x9C;
577 *pbyRsvTime = 24;
579 else {
580 *pbyTxRate = 0x8C;
581 *pbyRsvTime = 30;
583 break;
585 case RATE_24M :
586 default :
587 if (ePHYType == PHY_TYPE_11A) {//5GHZ
588 *pbyTxRate = 0x99;
589 *pbyRsvTime = 28;
591 else {
592 *pbyTxRate = 0x89;
593 *pbyRsvTime = 34;
595 break;
602 * Description: Set RSPINF
604 * Parameters:
605 * In:
606 * pDevice - The adapter to be set
607 * Out:
608 * none
610 * Return Value: None.
613 static
614 VOID
615 s_vSetRSPINF (PSDevice pDevice, CARD_PHY_TYPE ePHYType, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs)
617 BYTE byServ = 0, bySignal = 0; // For CCK
618 WORD wLen = 0;
619 BYTE byTxRate = 0, byRsvTime = 0; // For OFDM
621 //Set to Page1
622 MACvSelectPage1(pDevice->PortOffset);
624 //RSPINF_b_1
625 BBvCaculateParameter(pDevice,
627 VNTWIFIbyGetACKTxRate(RATE_1M, pvSupportRateIEs, pvExtSupportRateIEs),
628 PK_TYPE_11B,
629 &wLen,
630 &byServ,
631 &bySignal
634 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
635 ///RSPINF_b_2
636 BBvCaculateParameter(pDevice,
638 VNTWIFIbyGetACKTxRate(RATE_2M, pvSupportRateIEs, pvExtSupportRateIEs),
639 PK_TYPE_11B,
640 &wLen,
641 &byServ,
642 &bySignal
645 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
646 //RSPINF_b_5
647 BBvCaculateParameter(pDevice,
649 VNTWIFIbyGetACKTxRate(RATE_5M, pvSupportRateIEs, pvExtSupportRateIEs),
650 PK_TYPE_11B,
651 &wLen,
652 &byServ,
653 &bySignal
656 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
657 //RSPINF_b_11
658 BBvCaculateParameter(pDevice,
660 VNTWIFIbyGetACKTxRate(RATE_11M, pvSupportRateIEs, pvExtSupportRateIEs),
661 PK_TYPE_11B,
662 &wLen,
663 &byServ,
664 &bySignal
667 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
668 //RSPINF_a_6
669 s_vCaculateOFDMRParameter(RATE_6M,
670 ePHYType,
671 &byTxRate,
672 &byRsvTime);
673 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
674 //RSPINF_a_9
675 s_vCaculateOFDMRParameter(RATE_9M,
676 ePHYType,
677 &byTxRate,
678 &byRsvTime);
679 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
680 //RSPINF_a_12
681 s_vCaculateOFDMRParameter(RATE_12M,
682 ePHYType,
683 &byTxRate,
684 &byRsvTime);
685 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
686 //RSPINF_a_18
687 s_vCaculateOFDMRParameter(RATE_18M,
688 ePHYType,
689 &byTxRate,
690 &byRsvTime);
691 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
692 //RSPINF_a_24
693 s_vCaculateOFDMRParameter(RATE_24M,
694 ePHYType,
695 &byTxRate,
696 &byRsvTime);
697 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
698 //RSPINF_a_36
699 s_vCaculateOFDMRParameter(
700 VNTWIFIbyGetACKTxRate(RATE_36M, pvSupportRateIEs, pvExtSupportRateIEs),
701 ePHYType,
702 &byTxRate,
703 &byRsvTime);
704 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
705 //RSPINF_a_48
706 s_vCaculateOFDMRParameter(
707 VNTWIFIbyGetACKTxRate(RATE_48M, pvSupportRateIEs, pvExtSupportRateIEs),
708 ePHYType,
709 &byTxRate,
710 &byRsvTime);
711 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
712 //RSPINF_a_54
713 s_vCaculateOFDMRParameter(
714 VNTWIFIbyGetACKTxRate(RATE_54M, pvSupportRateIEs, pvExtSupportRateIEs),
715 ePHYType,
716 &byTxRate,
717 &byRsvTime);
718 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
719 //RSPINF_a_72
720 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
721 //Set to Page0
722 MACvSelectPage0(pDevice->PortOffset);
728 /*--------------------- Export Variables --------------------------*/
730 /*--------------------- Export Functions --------------------------*/
731 BYTE CARDbyGetChannelMapping (PVOID pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType)
733 UINT ii;
735 if ((ePhyType == PHY_TYPE_11B) || (ePhyType == PHY_TYPE_11G)) {
736 return (byChannelNumber);
739 for(ii = (CB_MAX_CHANNEL_24G + 1); ii <= CB_MAX_CHANNEL; ) {
740 if (sChannelTbl[ii].byChannelNumber == byChannelNumber) {
741 return ((BYTE) ii);
743 ii++;
745 return (0);
749 BYTE CARDbyGetChannelNumber (PVOID pDeviceHandler, BYTE byChannelIndex)
751 // PSDevice pDevice = (PSDevice) pDeviceHandler;
752 return(sChannelTbl[byChannelIndex].byChannelNumber);
756 * Description: Set NIC media channel
758 * Parameters:
759 * In:
760 * pDeviceHandler - The adapter to be set
761 * uConnectionChannel - Channel to be set
762 * Out:
763 * none
765 * Return Value: TRUE if succeeded; FALSE if failed.
768 BOOL CARDbSetChannel (PVOID pDeviceHandler, UINT uConnectionChannel)
770 PSDevice pDevice = (PSDevice) pDeviceHandler;
771 BOOL bResult = TRUE;
774 if (pDevice->byCurrentCh == uConnectionChannel) {
775 return bResult;
778 if (sChannelTbl[uConnectionChannel].bValid == FALSE) {
779 return (FALSE);
782 if ((uConnectionChannel > CB_MAX_CHANNEL_24G) &&
783 (pDevice->eCurrentPHYType != PHY_TYPE_11A)) {
784 CARDbSetPhyParameter(pDevice, PHY_TYPE_11A, 0, 0, NULL, NULL);
785 } else if ((uConnectionChannel <= CB_MAX_CHANNEL_24G) &&
786 (pDevice->eCurrentPHYType == PHY_TYPE_11A)) {
787 CARDbSetPhyParameter(pDevice, PHY_TYPE_11G, 0, 0, NULL, NULL);
789 // clear NAV
790 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
792 //{{ RobertYu: 20041202
793 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
795 if ( pDevice->byRFType == RF_AIROHA7230 )
797 RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (BYTE)uConnectionChannel);
799 //}} RobertYu
802 pDevice->byCurrentCh = (BYTE)uConnectionChannel;
803 bResult &= RFbSelectChannel(pDevice->PortOffset, pDevice->byRFType, (BYTE)uConnectionChannel);
805 // Init Synthesizer Table
806 if (pDevice->bEnablePSMode == TRUE)
807 RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel);
810 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDbSetMediaChannel: %d\n", (BYTE)uConnectionChannel);
811 BBvSoftwareReset(pDevice->PortOffset);
813 if (pDevice->byLocalID > REV_ID_VT3253_B1) {
814 // set HW default power register
815 MACvSelectPage1(pDevice->PortOffset);
816 RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
817 VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK, pDevice->byCurPwr);
818 RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
819 VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWROFDM, pDevice->byCurPwr);
820 MACvSelectPage0(pDevice->PortOffset);
823 if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
824 #ifdef PLICE_DEBUG
825 //printk("Func:CARDbSetChannel:call RFbSetPower:11B\n");
826 #endif
827 RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
828 } else {
829 #ifdef PLICE_DEBUG
830 //printk("Func:CARDbSetChannel:call RFbSetPower\n");
831 #endif
832 RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
835 return(bResult);
841 * Description: Card Send packet function
843 * Parameters:
844 * In:
845 * pDeviceHandler - The adapter to be set
846 * pPacket - Packet buffer pointer
847 * ePktType - Packet type
848 * uLength - Packet length
849 * Out:
850 * none
852 * Return Value: TRUE if succeeded; FALSE if failed.
856 BOOL CARDbSendPacket (PVOID pDeviceHandler, PVOID pPacket, CARD_PKT_TYPE ePktType, UINT uLength)
858 PSDevice pDevice = (PSDevice) pDeviceHandler;
859 if (ePktType == PKT_TYPE_802_11_MNG) {
860 return TXbTD0Send(pDevice, pPacket, uLength);
861 } else if (ePktType == PKT_TYPE_802_11_BCN) {
862 return TXbBeaconSend(pDevice, pPacket, uLength);
863 } if (ePktType == PKT_TYPE_802_11_DATA) {
864 return TXbTD1Send(pDevice, pPacket, uLength);
867 return (TRUE);
873 * Description: Get Card short preamble option value
875 * Parameters:
876 * In:
877 * pDevice - The adapter to be set
878 * Out:
879 * none
881 * Return Value: TRUE if short preamble; otherwise FALSE
884 BOOL CARDbIsShortPreamble (PVOID pDeviceHandler)
886 PSDevice pDevice = (PSDevice) pDeviceHandler;
887 if (pDevice->byPreambleType == 0) {
888 return(FALSE);
890 return(TRUE);
894 * Description: Get Card short slot time option value
896 * Parameters:
897 * In:
898 * pDevice - The adapter to be set
899 * Out:
900 * none
902 * Return Value: TRUE if short slot time; otherwise FALSE
905 BOOL CARDbIsShorSlotTime (PVOID pDeviceHandler)
907 PSDevice pDevice = (PSDevice) pDeviceHandler;
908 return(pDevice->bShortSlotTime);
913 * Description: Update IFS
915 * Parameters:
916 * In:
917 * pDevice - The adapter to be set
918 * Out:
919 * none
921 * Return Value: None.
924 BOOL CARDbSetPhyParameter (PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType, WORD wCapInfo, BYTE byERPField, PVOID pvSupportRateIEs, PVOID pvExtSupportRateIEs)
926 PSDevice pDevice = (PSDevice) pDeviceHandler;
927 BYTE byCWMaxMin = 0;
928 BYTE bySlot = 0;
929 BYTE bySIFS = 0;
930 BYTE byDIFS = 0;
931 BYTE byData;
932 // PWLAN_IE_SUPP_RATES pRates = NULL;
933 PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs;
934 PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs;
937 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
938 if (ePHYType == PHY_TYPE_11A) {
939 if (pSupportRates == NULL) {
940 pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA;
942 if (pDevice->byRFType == RF_AIROHA7230) {
943 // AL7230 use single PAPE and connect to PAPE_2.4G
944 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
945 pDevice->abyBBVGA[0] = 0x20;
946 pDevice->abyBBVGA[2] = 0x10;
947 pDevice->abyBBVGA[3] = 0x10;
948 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
949 if (byData == 0x1C) {
950 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
952 } else if (pDevice->byRFType == RF_UW2452) {
953 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A);
954 pDevice->abyBBVGA[0] = 0x18;
955 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
956 if (byData == 0x14) {
957 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
958 BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0x57);
960 } else {
961 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A);
963 BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x03);
964 bySlot = C_SLOT_SHORT;
965 bySIFS = C_SIFS_A;
966 byDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
967 byCWMaxMin = 0xA4;
968 } else if (ePHYType == PHY_TYPE_11B) {
969 if (pSupportRates == NULL) {
970 pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesB;
972 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B);
973 if (pDevice->byRFType == RF_AIROHA7230) {
974 pDevice->abyBBVGA[0] = 0x1C;
975 pDevice->abyBBVGA[2] = 0x00;
976 pDevice->abyBBVGA[3] = 0x00;
977 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
978 if (byData == 0x20) {
979 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
981 } else if (pDevice->byRFType == RF_UW2452) {
982 pDevice->abyBBVGA[0] = 0x14;
983 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
984 if (byData == 0x18) {
985 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
986 BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0xD3);
989 BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x02);
990 bySlot = C_SLOT_LONG;
991 bySIFS = C_SIFS_BG;
992 byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
993 byCWMaxMin = 0xA5;
994 } else {// PK_TYPE_11GA & PK_TYPE_11GB
995 if (pSupportRates == NULL) {
996 pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesG;
997 pExtSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultExtSuppRatesG;
999 MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G);
1000 if (pDevice->byRFType == RF_AIROHA7230) {
1001 pDevice->abyBBVGA[0] = 0x1C;
1002 pDevice->abyBBVGA[2] = 0x00;
1003 pDevice->abyBBVGA[3] = 0x00;
1004 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
1005 if (byData == 0x20) {
1006 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
1008 } else if (pDevice->byRFType == RF_UW2452) {
1009 pDevice->abyBBVGA[0] = 0x14;
1010 BBbReadEmbeded(pDevice->PortOffset, 0xE7, &byData);
1011 if (byData == 0x18) {
1012 BBbWriteEmbeded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]);
1013 BBbWriteEmbeded(pDevice->PortOffset, 0xE1, 0xD3);
1016 BBbWriteEmbeded(pDevice->PortOffset, 0x88, 0x08);
1017 bySIFS = C_SIFS_BG;
1018 if(VNTWIFIbIsShortSlotTime(wCapInfo)) {
1019 bySlot = C_SLOT_SHORT;
1020 byDIFS = C_SIFS_BG + 2*C_SLOT_SHORT;
1021 } else {
1022 bySlot = C_SLOT_LONG;
1023 byDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
1025 if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) {
1026 byCWMaxMin = 0xA4;
1027 } else {
1028 byCWMaxMin = 0xA5;
1030 if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) {
1031 pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField);
1032 if (pDevice->bProtectMode) {
1033 MACvEnableProtectMD(pDevice->PortOffset);
1034 } else {
1035 MACvDisableProtectMD(pDevice->PortOffset);
1038 if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) {
1039 pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField);
1040 if (pDevice->bBarkerPreambleMd) {
1041 MACvEnableBarkerPreambleMd(pDevice->PortOffset);
1042 } else {
1043 MACvDisableBarkerPreambleMd(pDevice->PortOffset);
1048 if (pDevice->byRFType == RF_RFMD2959) {
1049 // bcs TX_PE will reserve 3 us
1050 // hardware's processing time here is 2 us.
1051 bySIFS -= 3;
1052 byDIFS -= 3;
1053 //{{ RobertYu: 20041202
1054 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
1055 //// MAC will need 2 us to process, so the SIFS, DIFS can be shorter by 2 us.
1058 if (pDevice->bySIFS != bySIFS) {
1059 pDevice->bySIFS = bySIFS;
1060 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, pDevice->bySIFS);
1062 if (pDevice->byDIFS != byDIFS) {
1063 pDevice->byDIFS = byDIFS;
1064 VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, pDevice->byDIFS);
1066 if (pDevice->byEIFS != C_EIFS) {
1067 pDevice->byEIFS = C_EIFS;
1068 VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, pDevice->byEIFS);
1070 if (pDevice->bySlot != bySlot) {
1071 pDevice->bySlot = bySlot;
1072 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot);
1073 if (pDevice->bySlot == C_SLOT_SHORT) {
1074 pDevice->bShortSlotTime = TRUE;
1075 } else {
1076 pDevice->bShortSlotTime = FALSE;
1078 BBvSetShortSlotTime(pDevice);
1080 if (pDevice->byCWMaxMin != byCWMaxMin) {
1081 pDevice->byCWMaxMin = byCWMaxMin;
1082 VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin);
1084 if (VNTWIFIbIsShortPreamble(wCapInfo)) {
1085 pDevice->byPreambleType = pDevice->byShortPreamble;
1086 } else {
1087 pDevice->byPreambleType = 0;
1089 s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates);
1090 pDevice->eCurrentPHYType = ePHYType;
1091 // set for NDIS OID_802_11SUPPORTED_RATES
1092 return (TRUE);
1096 * Description: Sync. TSF counter to BSS
1097 * Get TSF offset and write to HW
1099 * Parameters:
1100 * In:
1101 * pDevice - The adapter to be sync.
1102 * byRxRate - data rate of receive beacon
1103 * qwBSSTimestamp - Rx BCN's TSF
1104 * qwLocalTSF - Local TSF
1105 * Out:
1106 * none
1108 * Return Value: none
1111 BOOL CARDbUpdateTSF (PVOID pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, QWORD qwLocalTSF)
1113 PSDevice pDevice = (PSDevice) pDeviceHandler;
1114 QWORD qwTSFOffset;
1116 HIDWORD(qwTSFOffset) = 0;
1117 LODWORD(qwTSFOffset) = 0;
1119 if ((HIDWORD(qwBSSTimestamp) != HIDWORD(qwLocalTSF)) ||
1120 (LODWORD(qwBSSTimestamp) != LODWORD(qwLocalTSF))) {
1121 qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
1122 // adjust TSF
1123 // HW's TSF add TSF Offset reg
1124 VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST, LODWORD(qwTSFOffset));
1125 VNSvOutPortD(pDevice->PortOffset + MAC_REG_TSFOFST + 4, HIDWORD(qwTSFOffset));
1126 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TSFSYNCEN);
1128 return(TRUE);
1133 * Description: Set NIC TSF counter for first Beacon time
1134 * Get NEXTTBTT from adjusted TSF and Beacon Interval
1136 * Parameters:
1137 * In:
1138 * pDevice - The adapter to be set.
1139 * wBeaconInterval - Beacon Interval
1140 * Out:
1141 * none
1143 * Return Value: TRUE if succeed; otherwise FALSE
1146 BOOL CARDbSetBeaconPeriod (PVOID pDeviceHandler, WORD wBeaconInterval)
1148 PSDevice pDevice = (PSDevice) pDeviceHandler;
1149 UINT uBeaconInterval = 0;
1150 UINT uLowNextTBTT = 0;
1151 UINT uHighRemain = 0;
1152 UINT uLowRemain = 0;
1153 QWORD qwNextTBTT;
1155 HIDWORD(qwNextTBTT) = 0;
1156 LODWORD(qwNextTBTT) = 0;
1157 CARDbGetCurrentTSF(pDevice->PortOffset, &qwNextTBTT); //Get Local TSF counter
1158 uBeaconInterval = wBeaconInterval * 1024;
1159 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
1160 uLowNextTBTT = (LODWORD(qwNextTBTT) >> 10) << 10;
1161 uLowRemain = (uLowNextTBTT) % uBeaconInterval;
1162 // high dword (mod) bcn
1163 uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * HIDWORD(qwNextTBTT))
1164 % uBeaconInterval;
1165 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
1166 uLowRemain = uBeaconInterval - uLowRemain;
1168 // check if carry when add one beacon interval
1169 if ((~uLowNextTBTT) < uLowRemain) {
1170 HIDWORD(qwNextTBTT) ++ ;
1172 LODWORD(qwNextTBTT) = uLowNextTBTT + uLowRemain;
1174 // set HW beacon interval
1175 VNSvOutPortW(pDevice->PortOffset + MAC_REG_BI, wBeaconInterval);
1176 pDevice->wBeaconInterval = wBeaconInterval;
1177 // Set NextTBTT
1178 VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT, LODWORD(qwNextTBTT));
1179 VNSvOutPortD(pDevice->PortOffset + MAC_REG_NEXTTBTT + 4, HIDWORD(qwNextTBTT));
1180 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
1182 return(TRUE);
1188 * Description: Card Stop Hardware Tx
1190 * Parameters:
1191 * In:
1192 * pDeviceHandler - The adapter to be set
1193 * ePktType - Packet type to stop
1194 * Out:
1195 * none
1197 * Return Value: TRUE if all data packet complete; otherwise FALSE.
1200 BOOL CARDbStopTxPacket (PVOID pDeviceHandler, CARD_PKT_TYPE ePktType)
1202 PSDevice pDevice = (PSDevice) pDeviceHandler;
1205 if (ePktType == PKT_TYPE_802_11_ALL) {
1206 pDevice->bStopBeacon = TRUE;
1207 pDevice->bStopTx0Pkt = TRUE;
1208 pDevice->bStopDataPkt = TRUE;
1209 } else if (ePktType == PKT_TYPE_802_11_BCN) {
1210 pDevice->bStopBeacon = TRUE;
1211 } else if (ePktType == PKT_TYPE_802_11_MNG) {
1212 pDevice->bStopTx0Pkt = TRUE;
1213 } else if (ePktType == PKT_TYPE_802_11_DATA) {
1214 pDevice->bStopDataPkt = TRUE;
1217 if (pDevice->bStopBeacon == TRUE) {
1218 if (pDevice->bIsBeaconBufReadySet == TRUE) {
1219 if (pDevice->cbBeaconBufReadySetCnt < WAIT_BEACON_TX_DOWN_TMO) {
1220 pDevice->cbBeaconBufReadySetCnt ++;
1221 return(FALSE);
1224 pDevice->bIsBeaconBufReadySet = FALSE;
1225 pDevice->cbBeaconBufReadySetCnt = 0;
1226 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
1228 // wait all TD0 complete
1229 if (pDevice->bStopTx0Pkt == TRUE) {
1230 if (pDevice->iTDUsed[TYPE_TXDMA0] != 0){
1231 return(FALSE);
1234 // wait all Data TD complete
1235 if (pDevice->bStopDataPkt == TRUE) {
1236 if (pDevice->iTDUsed[TYPE_AC0DMA] != 0){
1237 return(FALSE);
1241 return(TRUE);
1246 * Description: Card Start Hardware Tx
1248 * Parameters:
1249 * In:
1250 * pDeviceHandler - The adapter to be set
1251 * ePktType - Packet type to start
1252 * Out:
1253 * none
1255 * Return Value: TRUE if success; FALSE if failed.
1258 BOOL CARDbStartTxPacket (PVOID pDeviceHandler, CARD_PKT_TYPE ePktType)
1260 PSDevice pDevice = (PSDevice) pDeviceHandler;
1263 if (ePktType == PKT_TYPE_802_11_ALL) {
1264 pDevice->bStopBeacon = FALSE;
1265 pDevice->bStopTx0Pkt = FALSE;
1266 pDevice->bStopDataPkt = FALSE;
1267 } else if (ePktType == PKT_TYPE_802_11_BCN) {
1268 pDevice->bStopBeacon = FALSE;
1269 } else if (ePktType == PKT_TYPE_802_11_MNG) {
1270 pDevice->bStopTx0Pkt = FALSE;
1271 } else if (ePktType == PKT_TYPE_802_11_DATA) {
1272 pDevice->bStopDataPkt = FALSE;
1275 if ((pDevice->bStopBeacon == FALSE) &&
1276 (pDevice->bBeaconBufReady == TRUE) &&
1277 (pDevice->eOPMode == OP_MODE_ADHOC)) {
1278 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
1281 return(TRUE);
1287 * Description: Card Set BSSID value
1289 * Parameters:
1290 * In:
1291 * pDeviceHandler - The adapter to be set
1292 * pbyBSSID - pointer to BSSID field
1293 * bAdhoc - flag to indicate IBSS
1294 * Out:
1295 * none
1297 * Return Value: TRUE if success; FALSE if failed.
1300 BOOL CARDbSetBSSID(PVOID pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode)
1302 PSDevice pDevice = (PSDevice) pDeviceHandler;
1304 MACvWriteBSSIDAddress(pDevice->PortOffset, pbyBSSID);
1305 memcpy(pDevice->abyBSSID, pbyBSSID, WLAN_BSSID_LEN);
1306 if (eOPMode == OP_MODE_ADHOC) {
1307 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
1308 } else {
1309 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC);
1311 if (eOPMode == OP_MODE_AP) {
1312 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
1313 } else {
1314 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP);
1316 if (eOPMode == OP_MODE_UNKNOWN) {
1317 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
1318 pDevice->bBSSIDFilter = FALSE;
1319 pDevice->byRxMode &= ~RCR_BSSID;
1320 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode );
1321 } else {
1322 if (IS_NULL_ADDRESS(pDevice->abyBSSID) == FALSE) {
1323 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID);
1324 pDevice->bBSSIDFilter = TRUE;
1325 pDevice->byRxMode |= RCR_BSSID;
1327 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wmgr: rx_mode = %x\n", pDevice->byRxMode );
1329 // Adopt BSS state in Adapter Device Object
1330 pDevice->eOPMode = eOPMode;
1331 return(TRUE);
1336 * Description: Card indicate status
1338 * Parameters:
1339 * In:
1340 * pDeviceHandler - The adapter to be set
1341 * eStatus - Status
1342 * Out:
1343 * none
1345 * Return Value: TRUE if success; FALSE if failed.
1353 * Description: Save Assoc info. contain in assoc. response frame
1355 * Parameters:
1356 * In:
1357 * pDevice - The adapter to be set
1358 * wCapabilityInfo - Capability information
1359 * wStatus - Status code
1360 * wAID - Assoc. ID
1361 * uLen - Length of IEs
1362 * pbyIEs - pointer to IEs
1363 * Out:
1364 * none
1366 * Return Value: TRUE if succeed; otherwise FALSE
1369 BOOL CARDbSetTxDataRate(
1370 PVOID pDeviceHandler,
1371 WORD wDataRate
1374 PSDevice pDevice = (PSDevice) pDeviceHandler;
1376 pDevice->wCurrentRate = wDataRate;
1377 return(TRUE);
1382 * Routine Description:
1383 * Consider to power down when no more packets to tx or rx.
1385 * Parameters:
1386 * In:
1387 * pDevice - The adapter to be set
1388 * Out:
1389 * none
1391 * Return Value: TRUE if power down success; otherwise FALSE
1394 BOOL
1395 CARDbPowerDown(
1396 PVOID pDeviceHandler
1399 PSDevice pDevice = (PSDevice)pDeviceHandler;
1400 UINT uIdx;
1402 // check if already in Doze mode
1403 if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS))
1404 return TRUE;
1406 // Froce PSEN on
1407 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN);
1409 // check if all TD are empty,
1411 for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx ++) {
1412 if (pDevice->iTDUsed[uIdx] != 0)
1413 return FALSE;
1416 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_GO2DOZE);
1417 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Go to Doze ZZZZZZZZZZZZZZZ\n");
1418 return TRUE;
1422 * Description: Turn off Radio power
1424 * Parameters:
1425 * In:
1426 * pDevice - The adapter to be turned off
1427 * Out:
1428 * none
1430 * Return Value: TRUE if success; otherwise FALSE
1433 BOOL CARDbRadioPowerOff (PVOID pDeviceHandler)
1435 PSDevice pDevice = (PSDevice) pDeviceHandler;
1436 BOOL bResult = TRUE;
1438 if (pDevice->bRadioOff == TRUE)
1439 return TRUE;
1442 switch (pDevice->byRFType) {
1444 case RF_RFMD2959:
1445 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
1446 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
1447 break;
1449 case RF_AIROHA:
1450 case RF_AL2230S:
1451 case RF_AIROHA7230: //RobertYu:20050104
1452 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE2);
1453 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE3);
1454 break;
1458 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
1460 BBvSetDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
1462 pDevice->bRadioOff = TRUE;
1463 //2007-0409-03,<Add> by chester
1464 printk("chester power off\n");
1465 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue
1466 return bResult;
1471 * Description: Turn on Radio power
1473 * Parameters:
1474 * In:
1475 * pDevice - The adapter to be turned on
1476 * Out:
1477 * none
1479 * Return Value: TRUE if success; otherwise FALSE
1482 BOOL CARDbRadioPowerOn (PVOID pDeviceHandler)
1484 PSDevice pDevice = (PSDevice) pDeviceHandler;
1485 BOOL bResult = TRUE;
1486 printk("chester power on\n");
1487 if (pDevice->bRadioControlOff == TRUE){
1488 if (pDevice->bHWRadioOff == TRUE) printk("chester bHWRadioOff\n");
1489 if (pDevice->bRadioControlOff == TRUE) printk("chester bRadioControlOff\n");
1490 return FALSE;}
1492 if (pDevice->bRadioOff == FALSE)
1494 printk("chester pbRadioOff\n");
1495 return TRUE;}
1497 BBvExitDeepSleep(pDevice->PortOffset, pDevice->byLocalID);
1499 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_RXON);
1501 switch (pDevice->byRFType) {
1503 case RF_RFMD2959:
1504 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_TXPEINV);
1505 MACvWordRegBitsOff(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPE1);
1506 break;
1508 case RF_AIROHA:
1509 case RF_AL2230S:
1510 case RF_AIROHA7230: //RobertYu:20050104
1511 MACvWordRegBitsOn(pDevice->PortOffset, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 |
1512 SOFTPWRCTL_SWPE3));
1513 break;
1517 pDevice->bRadioOff = FALSE;
1518 // 2007-0409-03,<Add> by chester
1519 printk("chester power on\n");
1520 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue
1521 return bResult;
1526 BOOL CARDbRemoveKey (PVOID pDeviceHandler, PBYTE pbyBSSID)
1528 PSDevice pDevice = (PSDevice) pDeviceHandler;
1530 KeybRemoveAllKey(&(pDevice->sKey), pbyBSSID, pDevice->PortOffset);
1531 return (TRUE);
1537 * Description:
1538 * Add BSSID in PMKID Candidate list.
1540 * Parameters:
1541 * In:
1542 * hDeviceContext - device structure point
1543 * pbyBSSID - BSSID address for adding
1544 * wRSNCap - BSS's RSN capability
1545 * Out:
1546 * none
1548 * Return Value: none.
1551 BOOL
1552 CARDbAdd_PMKID_Candidate (
1553 IN PVOID pDeviceHandler,
1554 IN PBYTE pbyBSSID,
1555 IN BOOL bRSNCapExist,
1556 IN WORD wRSNCap
1559 PSDevice pDevice = (PSDevice) pDeviceHandler;
1560 PPMKID_CANDIDATE pCandidateList;
1561 UINT ii = 0;
1563 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
1565 if (pDevice->gsPMKIDCandidate.NumCandidates >= MAX_PMKIDLIST) {
1566 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFlush_PMKID_Candidate: 3\n");
1567 memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent));
1570 for (ii = 0; ii < 6; ii++) {
1571 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02X ", *(pbyBSSID + ii));
1573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
1576 // Update Old Candidate
1577 for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) {
1578 pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii];
1579 if ( !memcmp(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN)) {
1580 if ((bRSNCapExist == TRUE) && (wRSNCap & BIT0)) {
1581 pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
1582 } else {
1583 pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
1585 return TRUE;
1589 // New Candidate
1590 pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates];
1591 if ((bRSNCapExist == TRUE) && (wRSNCap & BIT0)) {
1592 pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED;
1593 } else {
1594 pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED);
1596 memcpy(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN);
1597 pDevice->gsPMKIDCandidate.NumCandidates++;
1598 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
1599 return TRUE;
1602 PVOID
1603 CARDpGetCurrentAddress (
1604 IN PVOID pDeviceHandler
1607 PSDevice pDevice = (PSDevice) pDeviceHandler;
1609 return (pDevice->abyCurrentNetAddr);
1614 VOID CARDvInitChannelTable (PVOID pDeviceHandler)
1616 PSDevice pDevice = (PSDevice) pDeviceHandler;
1617 BOOL bMultiBand = FALSE;
1618 UINT ii;
1620 for(ii=1;ii<=CARD_MAX_CHANNEL_TBL;ii++) {
1621 sChannelTbl[ii].bValid = FALSE;
1624 switch (pDevice->byRFType) {
1625 case RF_RFMD2959 :
1626 case RF_AIROHA :
1627 case RF_AL2230S:
1628 case RF_UW2451 :
1629 case RF_VT3226 :
1630 // printk("chester-false\n");
1631 bMultiBand = FALSE;
1632 break;
1633 case RF_AIROHA7230 :
1634 case RF_UW2452 :
1635 case RF_NOTHING :
1636 default :
1637 bMultiBand = TRUE;
1638 break;
1641 if ((pDevice->dwDiagRefCount != 0) ||
1642 (pDevice->b11hEnable == TRUE)) {
1643 if (bMultiBand == TRUE) {
1644 for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
1645 sChannelTbl[ii+1].bValid = TRUE;
1646 pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1647 pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1649 for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
1650 pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1651 pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1653 } else {
1654 for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
1655 //2008-8-4 <add> by chester
1656 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
1657 sChannelTbl[ii+1].bValid = TRUE;
1658 pDevice->abyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1659 pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1];
1663 } else if (pDevice->byZoneType <= CCODE_MAX) {
1664 if (bMultiBand == TRUE) {
1665 for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
1666 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
1667 sChannelTbl[ii+1].bValid = TRUE;
1668 pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1669 pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1672 } else {
1673 for(ii=0;ii<CHANNEL_MAX_24G;ii++) {
1674 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
1675 sChannelTbl[ii+1].bValid = TRUE;
1676 pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1677 pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
1682 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO"Zone=[%d][%c][%c]!!\n",pDevice->byZoneType,ChannelRuleTab[pDevice->byZoneType].chCountryCode[0],ChannelRuleTab[pDevice->byZoneType].chCountryCode[1]);
1683 for(ii=0;ii<CARD_MAX_CHANNEL_TBL;ii++) {
1684 if (pDevice->abyRegPwr[ii+1] == 0) {
1685 pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1687 if (pDevice->abyLocalPwr[ii+1] == 0) {
1688 pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1];
1697 * Description:
1698 * Start Spectrum Measure defined in 802.11h
1700 * Parameters:
1701 * In:
1702 * hDeviceContext - device structure point
1703 * Out:
1704 * none
1706 * Return Value: none.
1709 BOOL
1710 CARDbStartMeasure (
1711 IN PVOID pDeviceHandler,
1712 IN PVOID pvMeasureEIDs,
1713 IN UINT uNumOfMeasureEIDs
1716 PSDevice pDevice = (PSDevice) pDeviceHandler;
1717 PWLAN_IE_MEASURE_REQ pEID = (PWLAN_IE_MEASURE_REQ) pvMeasureEIDs;
1718 QWORD qwCurrTSF;
1719 QWORD qwStartTSF;
1720 BOOL bExpired = TRUE;
1721 WORD wDuration = 0;
1723 if ((pEID == NULL) ||
1724 (uNumOfMeasureEIDs == 0)) {
1725 return (TRUE);
1727 CARDbGetCurrentTSF(pDevice->PortOffset, &qwCurrTSF);
1728 if (pDevice->bMeasureInProgress == TRUE) {
1729 pDevice->bMeasureInProgress = FALSE;
1730 VNSvOutPortB(pDevice->PortOffset + MAC_REG_RCR, pDevice->byOrgRCR);
1731 MACvSelectPage1(pDevice->PortOffset);
1732 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR0, pDevice->dwOrgMAR0);
1733 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MAR4, pDevice->dwOrgMAR4);
1734 // clear measure control
1735 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
1736 MACvSelectPage0(pDevice->PortOffset);
1737 CARDbSetChannel(pDevice, pDevice->byOrgChannel);
1738 MACvSelectPage1(pDevice->PortOffset);
1739 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
1740 MACvSelectPage0(pDevice->PortOffset);
1742 pDevice->uNumOfMeasureEIDs = uNumOfMeasureEIDs;
1744 do {
1745 pDevice->pCurrMeasureEID = pEID;
1746 pEID++;
1747 pDevice->uNumOfMeasureEIDs--;
1749 if (pDevice->byLocalID > REV_ID_VT3253_B1) {
1750 HIDWORD(qwStartTSF) = HIDWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime)));
1751 LODWORD(qwStartTSF) = LODWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime)));
1752 wDuration = *((PWORD) (pDevice->pCurrMeasureEID->sReq.abyDuration));
1753 wDuration += 1; // 1 TU for channel switching
1755 if ((LODWORD(qwStartTSF) == 0) && (HIDWORD(qwStartTSF) == 0)) {
1756 // start imediately by setting start TSF == current TSF + 2 TU
1757 LODWORD(qwStartTSF) = LODWORD(qwCurrTSF) + 2048;
1758 HIDWORD(qwStartTSF) = HIDWORD(qwCurrTSF);
1759 if (LODWORD(qwCurrTSF) > LODWORD(qwStartTSF)) {
1760 HIDWORD(qwStartTSF)++;
1762 bExpired = FALSE;
1763 break;
1764 } else {
1765 // start at setting start TSF - 1TU(for channel switching)
1766 if (LODWORD(qwStartTSF) < 1024) {
1767 HIDWORD(qwStartTSF)--;
1769 LODWORD(qwStartTSF) -= 1024;
1772 if ((HIDWORD(qwCurrTSF) < HIDWORD(qwStartTSF)) ||
1773 ((HIDWORD(qwCurrTSF) == HIDWORD(qwStartTSF)) &&
1774 (LODWORD(qwCurrTSF) < LODWORD(qwStartTSF)))
1776 bExpired = FALSE;
1777 break;
1779 VNTWIFIbMeasureReport( pDevice->pMgmt,
1780 FALSE,
1781 pDevice->pCurrMeasureEID,
1782 MEASURE_MODE_LATE,
1783 pDevice->byBasicMap,
1784 pDevice->byCCAFraction,
1785 pDevice->abyRPIs
1787 } else {
1788 // hardware do not support measure
1789 VNTWIFIbMeasureReport( pDevice->pMgmt,
1790 FALSE,
1791 pDevice->pCurrMeasureEID,
1792 MEASURE_MODE_INCAPABLE,
1793 pDevice->byBasicMap,
1794 pDevice->byCCAFraction,
1795 pDevice->abyRPIs
1798 } while (pDevice->uNumOfMeasureEIDs != 0);
1800 if (bExpired == FALSE) {
1801 MACvSelectPage1(pDevice->PortOffset);
1802 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART, LODWORD(qwStartTSF));
1803 VNSvOutPortD(pDevice->PortOffset + MAC_REG_MSRSTART + 4, HIDWORD(qwStartTSF));
1804 VNSvOutPortW(pDevice->PortOffset + MAC_REG_MSRDURATION, wDuration);
1805 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN);
1806 MACvSelectPage0(pDevice->PortOffset);
1807 } else {
1808 // all measure start time expired we should complete action
1809 VNTWIFIbMeasureReport( pDevice->pMgmt,
1810 TRUE,
1811 NULL,
1813 pDevice->byBasicMap,
1814 pDevice->byCCAFraction,
1815 pDevice->abyRPIs
1818 return (TRUE);
1824 * Description:
1825 * Do Channel Switch defined in 802.11h
1827 * Parameters:
1828 * In:
1829 * hDeviceContext - device structure point
1830 * Out:
1831 * none
1833 * Return Value: none.
1836 BOOL
1837 CARDbChannelSwitch (
1838 IN PVOID pDeviceHandler,
1839 IN BYTE byMode,
1840 IN BYTE byNewChannel,
1841 IN BYTE byCount
1844 PSDevice pDevice = (PSDevice) pDeviceHandler;
1845 BOOL bResult = TRUE;
1847 if (byCount == 0) {
1848 bResult = CARDbSetChannel(pDevice, byNewChannel);
1849 VNTWIFIbChannelSwitch(pDevice->pMgmt, byNewChannel);
1850 MACvSelectPage1(pDevice->PortOffset);
1851 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE);
1852 MACvSelectPage0(pDevice->PortOffset);
1853 return(bResult);
1855 pDevice->byChannelSwitchCount = byCount;
1856 pDevice->byNewChannel = byNewChannel;
1857 pDevice->bChannelSwitch = TRUE;
1858 if (byMode == 1) {
1859 bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
1861 return (bResult);
1867 * Description:
1868 * Handle Quiet EID defined in 802.11h
1870 * Parameters:
1871 * In:
1872 * hDeviceContext - device structure point
1873 * Out:
1874 * none
1876 * Return Value: none.
1879 BOOL
1880 CARDbSetQuiet (
1881 IN PVOID pDeviceHandler,
1882 IN BOOL bResetQuiet,
1883 IN BYTE byQuietCount,
1884 IN BYTE byQuietPeriod,
1885 IN WORD wQuietDuration,
1886 IN WORD wQuietOffset
1889 PSDevice pDevice = (PSDevice) pDeviceHandler;
1890 UINT ii = 0;
1892 if (bResetQuiet == TRUE) {
1893 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
1894 for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
1895 pDevice->sQuiet[ii].bEnable = FALSE;
1897 pDevice->uQuietEnqueue = 0;
1898 pDevice->bEnableFirstQuiet = FALSE;
1899 pDevice->bQuietEnable = FALSE;
1900 pDevice->byQuietStartCount = byQuietCount;
1902 if (pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable == FALSE) {
1903 pDevice->sQuiet[pDevice->uQuietEnqueue].bEnable = TRUE;
1904 pDevice->sQuiet[pDevice->uQuietEnqueue].byPeriod = byQuietPeriod;
1905 pDevice->sQuiet[pDevice->uQuietEnqueue].wDuration = wQuietDuration;
1906 pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime = (DWORD) byQuietCount;
1907 pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime *= pDevice->wBeaconInterval;
1908 pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime += wQuietOffset;
1909 pDevice->uQuietEnqueue++;
1910 pDevice->uQuietEnqueue %= MAX_QUIET_COUNT;
1911 if (pDevice->byQuietStartCount < byQuietCount) {
1912 pDevice->byQuietStartCount = byQuietCount;
1914 } else {
1915 // we can not handle Quiet EID more
1917 return (TRUE);
1923 * Description:
1924 * Do Quiet, It will called by either ISR (after start) or VNTWIFI (before start) so do not need SPINLOCK
1926 * Parameters:
1927 * In:
1928 * hDeviceContext - device structure point
1929 * Out:
1930 * none
1932 * Return Value: none.
1935 BOOL
1936 CARDbStartQuiet (
1937 IN PVOID pDeviceHandler
1940 PSDevice pDevice = (PSDevice) pDeviceHandler;
1941 UINT ii = 0;
1942 DWORD dwStartTime = 0xFFFFFFFF;
1943 UINT uCurrentQuietIndex = 0;
1944 DWORD dwNextTime = 0;
1945 DWORD dwGap = 0;
1946 DWORD dwDuration = 0;
1948 for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
1949 if ((pDevice->sQuiet[ii].bEnable == TRUE) &&
1950 (dwStartTime > pDevice->sQuiet[ii].dwStartTime)) {
1951 dwStartTime = pDevice->sQuiet[ii].dwStartTime;
1952 uCurrentQuietIndex = ii;
1955 if (dwStartTime == 0xFFFFFFFF) {
1956 // no more quiet
1957 pDevice->bQuietEnable = FALSE;
1958 MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
1959 } else {
1960 if (pDevice->bQuietEnable == FALSE) {
1961 // first quiet
1962 pDevice->byQuietStartCount--;
1963 dwNextTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
1964 dwNextTime %= pDevice->wBeaconInterval;
1965 MACvSelectPage1(pDevice->PortOffset);
1966 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETINIT, (WORD) dwNextTime);
1967 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (WORD) pDevice->sQuiet[uCurrentQuietIndex].wDuration);
1968 if (pDevice->byQuietStartCount == 0) {
1969 pDevice->bEnableFirstQuiet = FALSE;
1970 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN));
1971 } else {
1972 pDevice->bEnableFirstQuiet = TRUE;
1974 MACvSelectPage0(pDevice->PortOffset);
1975 } else {
1976 if (pDevice->dwCurrentQuietEndTime > pDevice->sQuiet[uCurrentQuietIndex].dwStartTime) {
1977 // overlap with previous Quiet
1978 dwGap = pDevice->dwCurrentQuietEndTime - pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
1979 if (dwGap >= pDevice->sQuiet[uCurrentQuietIndex].wDuration) {
1980 // return FALSE to indicate next quiet expired, should call this function again
1981 return (FALSE);
1983 dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration - dwGap;
1984 dwGap = 0;
1985 } else {
1986 dwGap = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime - pDevice->dwCurrentQuietEndTime;
1987 dwDuration = pDevice->sQuiet[uCurrentQuietIndex].wDuration;
1989 // set GAP and Next duration
1990 MACvSelectPage1(pDevice->PortOffset);
1991 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETGAP, (WORD) dwGap);
1992 VNSvOutPortW(pDevice->PortOffset + MAC_REG_QUIETDUR, (WORD) dwDuration);
1993 MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_QUIETRPT);
1994 MACvSelectPage0(pDevice->PortOffset);
1996 pDevice->bQuietEnable = TRUE;
1997 pDevice->dwCurrentQuietEndTime = pDevice->sQuiet[uCurrentQuietIndex].dwStartTime;
1998 pDevice->dwCurrentQuietEndTime += pDevice->sQuiet[uCurrentQuietIndex].wDuration;
1999 if (pDevice->sQuiet[uCurrentQuietIndex].byPeriod == 0) {
2000 // not period disable current quiet element
2001 pDevice->sQuiet[uCurrentQuietIndex].bEnable = FALSE;
2002 } else {
2003 // set next period start time
2004 dwNextTime = (DWORD) pDevice->sQuiet[uCurrentQuietIndex].byPeriod;
2005 dwNextTime *= pDevice->wBeaconInterval;
2006 pDevice->sQuiet[uCurrentQuietIndex].dwStartTime = dwNextTime;
2008 if (pDevice->dwCurrentQuietEndTime > 0x80010000) {
2009 // decreament all time to avoid wrap around
2010 for(ii=0;ii<MAX_QUIET_COUNT;ii++) {
2011 if (pDevice->sQuiet[ii].bEnable == TRUE) {
2012 pDevice->sQuiet[ii].dwStartTime -= 0x80000000;
2015 pDevice->dwCurrentQuietEndTime -= 0x80000000;
2018 return (TRUE);
2024 * Description:
2025 * Set Channel Info of Country
2027 * Parameters:
2028 * In:
2029 * hDeviceContext - device structure point
2030 * Out:
2031 * none
2033 * Return Value: none.
2036 VOID
2037 CARDvSetCountryInfo (
2038 IN PVOID pDeviceHandler,
2039 IN CARD_PHY_TYPE ePHYType,
2040 IN PVOID pIE
2043 PSDevice pDevice = (PSDevice) pDeviceHandler;
2044 UINT ii = 0;
2045 UINT uu = 0;
2046 UINT step = 0;
2047 UINT uNumOfCountryInfo = 0;
2048 BYTE byCh = 0;
2049 PWLAN_IE_COUNTRY pIE_Country = (PWLAN_IE_COUNTRY) pIE;
2052 uNumOfCountryInfo = (pIE_Country->len - 3);
2053 uNumOfCountryInfo /= 3;
2055 if (ePHYType == PHY_TYPE_11A) {
2056 pDevice->bCountryInfo5G = TRUE;
2057 for(ii=CB_MAX_CHANNEL_24G+1;ii<=CARD_MAX_CHANNEL_TBL;ii++) {
2058 sChannelTbl[ii].bValid = FALSE;
2060 step = 4;
2061 } else {
2062 pDevice->bCountryInfo24G = TRUE;
2063 for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
2064 sChannelTbl[ii].bValid = FALSE;
2066 step = 1;
2068 pDevice->abyCountryCode[0] = pIE_Country->abyCountryString[0];
2069 pDevice->abyCountryCode[1] = pIE_Country->abyCountryString[1];
2070 pDevice->abyCountryCode[2] = pIE_Country->abyCountryString[2];
2072 for(ii=0;ii<uNumOfCountryInfo;ii++) {
2073 for(uu=0;uu<pIE_Country->abyCountryInfo[ii*3+1];uu++) {
2074 byCh = CARDbyGetChannelMapping(pDevice, (BYTE)(pIE_Country->abyCountryInfo[ii*3]+step*uu), ePHYType);
2075 sChannelTbl[byCh].bValid = TRUE;
2076 pDevice->abyRegPwr[byCh] = pIE_Country->abyCountryInfo[ii*3+2];
2083 * Description:
2084 * Set Local Power Constraint
2086 * Parameters:
2087 * In:
2088 * hDeviceContext - device structure point
2089 * Out:
2090 * none
2092 * Return Value: none.
2095 VOID
2096 CARDvSetPowerConstraint (
2097 IN PVOID pDeviceHandler,
2098 IN BYTE byChannel,
2099 IN I8 byPower
2102 PSDevice pDevice = (PSDevice) pDeviceHandler;
2104 if (byChannel > CB_MAX_CHANNEL_24G) {
2105 if (pDevice->bCountryInfo5G == TRUE) {
2106 pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
2108 } else {
2109 if (pDevice->bCountryInfo24G == TRUE) {
2110 pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower;
2118 * Description:
2119 * Set Local Power Constraint
2121 * Parameters:
2122 * In:
2123 * hDeviceContext - device structure point
2124 * Out:
2125 * none
2127 * Return Value: none.
2130 VOID
2131 CARDvGetPowerCapability (
2132 IN PVOID pDeviceHandler,
2133 OUT PBYTE pbyMinPower,
2134 OUT PBYTE pbyMaxPower
2137 PSDevice pDevice = (PSDevice) pDeviceHandler;
2138 BYTE byDec = 0;
2140 *pbyMaxPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh];
2141 byDec = pDevice->abyOFDMPwrTbl[pDevice->byCurrentCh];
2142 if (pDevice->byRFType == RF_UW2452) {
2143 byDec *= 3;
2144 byDec >>= 1;
2145 } else {
2146 byDec <<= 1;
2148 *pbyMinPower = pDevice->abyOFDMDefaultPwr[pDevice->byCurrentCh] - byDec;
2154 * Description:
2155 * Set Support Channels IE defined in 802.11h
2157 * Parameters:
2158 * In:
2159 * hDeviceContext - device structure point
2160 * Out:
2161 * none
2163 * Return Value: none.
2166 BYTE
2167 CARDbySetSupportChannels (
2168 IN PVOID pDeviceHandler,
2169 IN OUT PBYTE pbyIEs
2172 PSDevice pDevice = (PSDevice) pDeviceHandler;
2173 UINT ii;
2174 BYTE byCount;
2175 PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs;
2176 PBYTE pbyChTupple;
2177 BYTE byLen = 0;
2180 pIE->byElementID = WLAN_EID_SUPP_CH;
2181 pIE->len = 0;
2182 pbyChTupple = pIE->abyChannelTuple;
2183 byLen = 2;
2184 // lower band
2185 byCount = 0;
2186 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == TRUE) {
2187 for (ii=28;ii<36;ii+=2) {
2188 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2189 byCount++;
2192 *pbyChTupple++ = 34;
2193 *pbyChTupple++ = byCount;
2194 byLen += 2;
2195 } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[29] == TRUE) {
2196 for (ii=29;ii<36;ii+=2) {
2197 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2198 byCount++;
2201 *pbyChTupple++ = 36;
2202 *pbyChTupple++ = byCount;
2203 byLen += 2;
2205 // middle band
2206 byCount = 0;
2207 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == TRUE) {
2208 for (ii=36;ii<40;ii++) {
2209 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2210 byCount++;
2213 *pbyChTupple++ = 52;
2214 *pbyChTupple++ = byCount;
2215 byLen += 2;
2217 // higher band
2218 byCount = 0;
2219 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == TRUE) {
2220 for (ii=40;ii<51;ii++) {
2221 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2222 byCount++;
2225 *pbyChTupple++ = 100;
2226 *pbyChTupple++ = byCount;
2227 byLen += 2;
2228 } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[51] == TRUE) {
2229 for (ii=51;ii<56;ii++) {
2230 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == TRUE) {
2231 byCount++;
2234 *pbyChTupple++ = 149;
2235 *pbyChTupple++ = byCount;
2236 byLen += 2;
2238 pIE->len += (byLen - 2);
2239 return (byLen);
2245 * Description:
2246 * Get Current Tx Power
2248 * Parameters:
2249 * In:
2250 * hDeviceContext - device structure point
2251 * Out:
2252 * none
2254 * Return Value: none.
2258 CARDbyGetTransmitPower (
2259 IN PVOID pDeviceHandler
2262 PSDevice pDevice = (PSDevice) pDeviceHandler;
2264 return (pDevice->byCurPwrdBm);
2268 BOOL
2269 CARDbChannelGetList (
2270 IN UINT uCountryCodeIdx,
2271 OUT PBYTE pbyChannelTable
2274 if (uCountryCodeIdx >= CCODE_MAX) {
2275 return (FALSE);
2277 memcpy(pbyChannelTable, ChannelRuleTab[uCountryCodeIdx].bChannelIdxList, CB_MAX_CHANNEL);
2278 return (TRUE);
2282 VOID
2283 CARDvSetCountryIE(
2284 IN PVOID pDeviceHandler,
2285 IN PVOID pIE
2288 PSDevice pDevice = (PSDevice) pDeviceHandler;
2289 UINT ii;
2290 PWLAN_IE_COUNTRY pIECountry = (PWLAN_IE_COUNTRY) pIE;
2292 pIECountry->byElementID = WLAN_EID_COUNTRY;
2293 pIECountry->len = 0;
2294 pIECountry->abyCountryString[0] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[0];
2295 pIECountry->abyCountryString[1] = ChannelRuleTab[pDevice->byZoneType].chCountryCode[1];
2296 pIECountry->abyCountryString[2] = ' ';
2297 for (ii = CB_MAX_CHANNEL_24G; ii < CB_MAX_CHANNEL; ii++ ) {
2298 if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) {
2299 pIECountry->abyCountryInfo[pIECountry->len++] = sChannelTbl[ii+1].byChannelNumber;
2300 pIECountry->abyCountryInfo[pIECountry->len++] = 1;
2301 pIECountry->abyCountryInfo[pIECountry->len++] = ChannelRuleTab[pDevice->byZoneType].byPower[ii];
2304 pIECountry->len += 3;
2308 BOOL
2309 CARDbGetChannelMapInfo(
2310 IN PVOID pDeviceHandler,
2311 IN UINT uChannelIndex,
2312 OUT PBYTE pbyChannelNumber,
2313 OUT PBYTE pbyMap
2316 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2318 if (uChannelIndex > CB_MAX_CHANNEL) {
2319 return FALSE;
2321 *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber;
2322 *pbyMap = sChannelTbl[uChannelIndex].byMAP;
2323 return sChannelTbl[uChannelIndex].bValid;
2327 VOID
2328 CARDvSetChannelMapInfo(
2329 IN PVOID pDeviceHandler,
2330 IN UINT uChannelIndex,
2331 IN BYTE byMap
2334 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2336 if (uChannelIndex > CB_MAX_CHANNEL) {
2337 return;
2339 sChannelTbl[uChannelIndex].byMAP |= byMap;
2343 VOID
2344 CARDvClearChannelMapInfo(
2345 IN PVOID pDeviceHandler
2348 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2349 UINT ii = 0;
2351 for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) {
2352 sChannelTbl[ii].byMAP = 0;
2357 BYTE
2358 CARDbyAutoChannelSelect(
2359 IN PVOID pDeviceHandler,
2360 CARD_PHY_TYPE ePHYType
2363 // PSDevice pDevice = (PSDevice) pDeviceHandler;
2364 UINT ii = 0;
2365 BYTE byOptionChannel = 0;
2366 INT aiWeight[CB_MAX_CHANNEL_24G+1] = {-1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
2368 if (ePHYType == PHY_TYPE_11A) {
2369 for(ii=CB_MAX_CHANNEL_24G+1;ii<=CB_MAX_CHANNEL;ii++) {
2370 if (sChannelTbl[ii].bValid == TRUE) {
2371 if (byOptionChannel == 0) {
2372 byOptionChannel = (BYTE) ii;
2374 if (sChannelTbl[ii].byMAP == 0) {
2375 return ((BYTE) ii);
2376 } else if ( !(sChannelTbl[ii].byMAP & 0x08)) {
2377 byOptionChannel = (BYTE) ii;
2381 } else {
2382 byOptionChannel = 0;
2383 for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
2384 if (sChannelTbl[ii].bValid == TRUE) {
2385 if (sChannelTbl[ii].byMAP == 0) {
2386 aiWeight[ii] += 100;
2387 } else if (sChannelTbl[ii].byMAP & 0x01) {
2388 if (ii > 3) {
2389 aiWeight[ii-3] -= 10;
2391 if (ii > 2) {
2392 aiWeight[ii-2] -= 20;
2394 if (ii > 1) {
2395 aiWeight[ii-1] -= 40;
2397 aiWeight[ii] -= 80;
2398 if (ii < CB_MAX_CHANNEL_24G) {
2399 aiWeight[ii+1] -= 40;
2401 if (ii < (CB_MAX_CHANNEL_24G - 1)) {
2402 aiWeight[ii+2] -= 20;
2404 if (ii < (CB_MAX_CHANNEL_24G - 2)) {
2405 aiWeight[ii+3] -= 10;
2410 for(ii=1;ii<=CB_MAX_CHANNEL_24G;ii++) {
2411 if ((sChannelTbl[ii].bValid == TRUE) &&
2412 (aiWeight[ii] > aiWeight[byOptionChannel])) {
2413 byOptionChannel = (BYTE) ii;
2417 return (byOptionChannel);
2422 //xxx
2423 VOID
2424 CARDvSafeResetTx (
2425 IN PVOID pDeviceHandler
2428 PSDevice pDevice = (PSDevice) pDeviceHandler;
2429 UINT uu;
2430 PSTxDesc pCurrTD;
2432 // initialize TD index
2433 pDevice->apTailTD[0] = pDevice->apCurrTD[0] = &(pDevice->apTD0Rings[0]);
2434 pDevice->apTailTD[1] = pDevice->apCurrTD[1] = &(pDevice->apTD1Rings[0]);
2436 for (uu = 0; uu < TYPE_MAXTD; uu ++)
2437 pDevice->iTDUsed[uu] = 0;
2439 for (uu = 0; uu < pDevice->sOpts.nTxDescs[0]; uu++) {
2440 pCurrTD = &(pDevice->apTD0Rings[uu]);
2441 pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
2442 // init all Tx Packet pointer to NULL
2444 for (uu = 0; uu < pDevice->sOpts.nTxDescs[1]; uu++) {
2445 pCurrTD = &(pDevice->apTD1Rings[uu]);
2446 pCurrTD->m_td0TD0.f1Owner = OWNED_BY_HOST;
2447 // init all Tx Packet pointer to NULL
2450 // set MAC TD pointer
2451 MACvSetCurrTXDescAddr(TYPE_TXDMA0, pDevice->PortOffset,
2452 (pDevice->td0_pool_dma));
2454 MACvSetCurrTXDescAddr(TYPE_AC0DMA, pDevice->PortOffset,
2455 (pDevice->td1_pool_dma));
2457 // set MAC Beacon TX pointer
2458 MACvSetCurrBCNTxDescAddr(pDevice->PortOffset,
2459 (pDevice->tx_beacon_dma));
2467 * Description:
2468 * Reset Rx
2470 * Parameters:
2471 * In:
2472 * pDevice - Pointer to the adapter
2473 * Out:
2474 * none
2476 * Return Value: none
2479 VOID
2480 CARDvSafeResetRx (
2481 IN PVOID pDeviceHandler
2484 PSDevice pDevice = (PSDevice) pDeviceHandler;
2485 UINT uu;
2486 PSRxDesc pDesc;
2490 // initialize RD index
2491 pDevice->pCurrRD[0]=&(pDevice->aRD0Ring[0]);
2492 pDevice->pCurrRD[1]=&(pDevice->aRD1Ring[0]);
2494 // init state, all RD is chip's
2495 for (uu = 0; uu < pDevice->sOpts.nRxDescs0; uu++) {
2496 pDesc =&(pDevice->aRD0Ring[uu]);
2497 pDesc->m_rd0RD0.wResCount = (WORD)(pDevice->rx_buf_sz);
2498 pDesc->m_rd0RD0.f1Owner=OWNED_BY_NIC;
2499 pDesc->m_rd1RD1.wReqCount = (WORD)(pDevice->rx_buf_sz);
2502 // init state, all RD is chip's
2503 for (uu = 0; uu < pDevice->sOpts.nRxDescs1; uu++) {
2504 pDesc =&(pDevice->aRD1Ring[uu]);
2505 pDesc->m_rd0RD0.wResCount = (WORD)(pDevice->rx_buf_sz);
2506 pDesc->m_rd0RD0.f1Owner=OWNED_BY_NIC;
2507 pDesc->m_rd1RD1.wReqCount = (WORD)(pDevice->rx_buf_sz);
2510 pDevice->cbDFCB = CB_MAX_RX_FRAG;
2511 pDevice->cbFreeDFCB = pDevice->cbDFCB;
2513 // set perPkt mode
2514 MACvRx0PerPktMode(pDevice->PortOffset);
2515 MACvRx1PerPktMode(pDevice->PortOffset);
2516 // set MAC RD pointer
2517 MACvSetCurrRx0DescAddr(pDevice->PortOffset,
2518 pDevice->rd0_pool_dma);
2520 MACvSetCurrRx1DescAddr(pDevice->PortOffset,
2521 pDevice->rd1_pool_dma);
2528 * Description: Get response Control frame rate in CCK mode
2530 * Parameters:
2531 * In:
2532 * pDevice - The adapter to be set
2533 * wRateIdx - Receiving data rate
2534 * Out:
2535 * none
2537 * Return Value: response Control frame rate
2540 WORD CARDwGetCCKControlRate(PVOID pDeviceHandler, WORD wRateIdx)
2542 PSDevice pDevice = (PSDevice) pDeviceHandler;
2543 UINT ui = (UINT)wRateIdx;
2545 while (ui > RATE_1M) {
2546 if (pDevice->wBasicRate & ((WORD)1 << ui)) {
2547 return (WORD)ui;
2549 ui --;
2551 return (WORD)RATE_1M;
2555 * Description: Get response Control frame rate in OFDM mode
2557 * Parameters:
2558 * In:
2559 * pDevice - The adapter to be set
2560 * wRateIdx - Receiving data rate
2561 * Out:
2562 * none
2564 * Return Value: response Control frame rate
2567 WORD CARDwGetOFDMControlRate (PVOID pDeviceHandler, WORD wRateIdx)
2569 PSDevice pDevice = (PSDevice) pDeviceHandler;
2570 UINT ui = (UINT)wRateIdx;
2572 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate);
2574 if (!CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
2575 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
2576 if (wRateIdx > RATE_24M)
2577 wRateIdx = RATE_24M;
2578 return wRateIdx;
2580 while (ui > RATE_11M) {
2581 if (pDevice->wBasicRate & ((WORD)1 << ui)) {
2582 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate : %d\n", ui);
2583 return (WORD)ui;
2585 ui --;
2587 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CARDwGetOFDMControlRate: 6M\n");
2588 return (WORD)RATE_24M;
2593 * Description: Set RSPINF
2595 * Parameters:
2596 * In:
2597 * pDevice - The adapter to be set
2598 * Out:
2599 * none
2601 * Return Value: None.
2604 void CARDvSetRSPINF (PVOID pDeviceHandler, CARD_PHY_TYPE ePHYType)
2606 PSDevice pDevice = (PSDevice) pDeviceHandler;
2607 BYTE byServ = 0x00, bySignal = 0x00; //For CCK
2608 WORD wLen = 0x0000;
2609 BYTE byTxRate, byRsvTime; //For OFDM
2611 //Set to Page1
2612 MACvSelectPage1(pDevice->PortOffset);
2614 //RSPINF_b_1
2615 BBvCaculateParameter(pDevice,
2617 CARDwGetCCKControlRate((PVOID)pDevice, RATE_1M),
2618 PK_TYPE_11B,
2619 &wLen,
2620 &byServ,
2621 &bySignal
2624 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_1, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2625 ///RSPINF_b_2
2626 BBvCaculateParameter(pDevice,
2628 CARDwGetCCKControlRate((PVOID)pDevice, RATE_2M),
2629 PK_TYPE_11B,
2630 &wLen,
2631 &byServ,
2632 &bySignal
2635 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_2, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2636 //RSPINF_b_5
2637 BBvCaculateParameter(pDevice,
2639 CARDwGetCCKControlRate((PVOID)pDevice, RATE_5M),
2640 PK_TYPE_11B,
2641 &wLen,
2642 &byServ,
2643 &bySignal
2646 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_5, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2647 //RSPINF_b_11
2648 BBvCaculateParameter(pDevice,
2650 CARDwGetCCKControlRate((PVOID)pDevice, RATE_11M),
2651 PK_TYPE_11B,
2652 &wLen,
2653 &byServ,
2654 &bySignal
2657 VNSvOutPortD(pDevice->PortOffset + MAC_REG_RSPINF_B_11, MAKEDWORD(wLen,MAKEWORD(bySignal,byServ)));
2658 //RSPINF_a_6
2659 s_vCaculateOFDMRParameter(RATE_6M,
2660 ePHYType,
2661 &byTxRate,
2662 &byRsvTime);
2663 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_6, MAKEWORD(byTxRate,byRsvTime));
2664 //RSPINF_a_9
2665 s_vCaculateOFDMRParameter(RATE_9M,
2666 ePHYType,
2667 &byTxRate,
2668 &byRsvTime);
2669 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_9, MAKEWORD(byTxRate,byRsvTime));
2670 //RSPINF_a_12
2671 s_vCaculateOFDMRParameter(RATE_12M,
2672 ePHYType,
2673 &byTxRate,
2674 &byRsvTime);
2675 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_12, MAKEWORD(byTxRate,byRsvTime));
2676 //RSPINF_a_18
2677 s_vCaculateOFDMRParameter(RATE_18M,
2678 ePHYType,
2679 &byTxRate,
2680 &byRsvTime);
2681 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_18, MAKEWORD(byTxRate,byRsvTime));
2682 //RSPINF_a_24
2683 s_vCaculateOFDMRParameter(RATE_24M,
2684 ePHYType,
2685 &byTxRate,
2686 &byRsvTime);
2687 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate,byRsvTime));
2688 //RSPINF_a_36
2689 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_36M),
2690 ePHYType,
2691 &byTxRate,
2692 &byRsvTime);
2693 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate,byRsvTime));
2694 //RSPINF_a_48
2695 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_48M),
2696 ePHYType,
2697 &byTxRate,
2698 &byRsvTime);
2699 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate,byRsvTime));
2700 //RSPINF_a_54
2701 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
2702 ePHYType,
2703 &byTxRate,
2704 &byRsvTime);
2705 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate,byRsvTime));
2707 //RSPINF_a_72
2708 s_vCaculateOFDMRParameter(CARDwGetOFDMControlRate((PVOID)pDevice, RATE_54M),
2709 ePHYType,
2710 &byTxRate,
2711 &byRsvTime);
2712 VNSvOutPortW(pDevice->PortOffset + MAC_REG_RSPINF_A_72, MAKEWORD(byTxRate,byRsvTime));
2713 //Set to Page0
2714 MACvSelectPage0(pDevice->PortOffset);
2718 * Description: Update IFS
2720 * Parameters:
2721 * In:
2722 * pDevice - The adapter to be set
2723 * Out:
2724 * none
2726 * Return Value: None.
2729 void vUpdateIFS (PVOID pDeviceHandler)
2731 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
2732 PSDevice pDevice = (PSDevice) pDeviceHandler;
2734 BYTE byMaxMin = 0;
2735 if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a
2736 pDevice->uSlot = C_SLOT_SHORT;
2737 pDevice->uSIFS = C_SIFS_A;
2738 pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
2739 pDevice->uCwMin = C_CWMIN_A;
2740 byMaxMin = 4;
2742 else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b
2743 pDevice->uSlot = C_SLOT_LONG;
2744 pDevice->uSIFS = C_SIFS_BG;
2745 pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
2746 pDevice->uCwMin = C_CWMIN_B;
2747 byMaxMin = 5;
2749 else { // PK_TYPE_11GA & PK_TYPE_11GB
2750 pDevice->uSIFS = C_SIFS_BG;
2751 if (pDevice->bShortSlotTime) {
2752 pDevice->uSlot = C_SLOT_SHORT;
2753 } else {
2754 pDevice->uSlot = C_SLOT_LONG;
2756 pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
2757 if (pDevice->wBasicRate & 0x0150) { //0000 0001 0101 0000,24M,12M,6M
2758 pDevice->uCwMin = C_CWMIN_A;
2759 byMaxMin = 4;
2761 else {
2762 pDevice->uCwMin = C_CWMIN_B;
2763 byMaxMin = 5;
2767 pDevice->uCwMax = C_CWMAX;
2768 pDevice->uEIFS = C_EIFS;
2769 if (pDevice->byRFType == RF_RFMD2959) {
2770 // bcs TX_PE will reserve 3 us
2771 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (BYTE)(pDevice->uSIFS - 3));
2772 VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (BYTE)(pDevice->uDIFS - 3));
2773 } else {
2774 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SIFS, (BYTE)pDevice->uSIFS);
2775 VNSvOutPortB(pDevice->PortOffset + MAC_REG_DIFS, (BYTE)pDevice->uDIFS);
2777 VNSvOutPortB(pDevice->PortOffset + MAC_REG_EIFS, (BYTE)pDevice->uEIFS);
2778 VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, (BYTE)pDevice->uSlot);
2779 byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
2780 VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, (BYTE)byMaxMin);
2783 void CARDvUpdateBasicTopRate (PVOID pDeviceHandler)
2785 PSDevice pDevice = (PSDevice) pDeviceHandler;
2786 BYTE byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
2787 BYTE ii;
2789 //Determines the highest basic rate.
2790 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
2791 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
2792 byTopOFDM = ii;
2793 break;
2795 pDevice->byTopOFDMBasicRate = byTopOFDM;
2797 for (ii = RATE_11M;; ii --) {
2798 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) )
2799 byTopCCK = ii;
2800 break;
2801 if (ii == RATE_1M)
2802 break;
2804 pDevice->byTopCCKBasicRate = byTopCCK;
2809 * Description: Set NIC Tx Basic Rate
2811 * Parameters:
2812 * In:
2813 * pDevice - The adapter to be set
2814 * wBasicRate - Basic Rate to be set
2815 * Out:
2816 * none
2818 * Return Value: TRUE if succeeded; FALSE if failed.
2821 BOOL CARDbAddBasicRate (PVOID pDeviceHandler, WORD wRateIdx)
2823 PSDevice pDevice = (PSDevice) pDeviceHandler;
2824 WORD wRate = (WORD)(1<<wRateIdx);
2826 pDevice->wBasicRate |= wRate;
2828 //Determines the highest basic rate.
2829 CARDvUpdateBasicTopRate((PVOID)pDevice);
2831 return(TRUE);
2834 BOOL CARDbIsOFDMinBasicRate (PVOID pDeviceHandler)
2836 PSDevice pDevice = (PSDevice) pDeviceHandler;
2837 int ii;
2839 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
2840 if ((pDevice->wBasicRate) & ((WORD)(1<<ii)))
2841 return TRUE;
2843 return FALSE;
2846 BYTE CARDbyGetPktType (PVOID pDeviceHandler)
2848 PSDevice pDevice = (PSDevice) pDeviceHandler;
2850 if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) {
2851 return (BYTE)pDevice->byBBType;
2853 else if (CARDbIsOFDMinBasicRate((PVOID)pDevice)) {
2854 return PK_TYPE_11GA;
2856 else {
2857 return PK_TYPE_11GB;
2862 * Description: Set NIC Loopback mode
2864 * Parameters:
2865 * In:
2866 * pDevice - The adapter to be set
2867 * wLoopbackMode - Loopback mode to be set
2868 * Out:
2869 * none
2871 * Return Value: none
2874 void CARDvSetLoopbackMode (DWORD_PTR dwIoBase, WORD wLoopbackMode)
2876 switch(wLoopbackMode) {
2877 case CARD_LB_NONE:
2878 case CARD_LB_MAC:
2879 case CARD_LB_PHY:
2880 break;
2881 default:
2882 ASSERT(FALSE);
2883 break;
2885 // set MAC loopback
2886 MACvSetLoopbackMode(dwIoBase, LOBYTE(wLoopbackMode));
2887 // set Baseband loopback
2892 * Description: Software Reset NIC
2894 * Parameters:
2895 * In:
2896 * pDevice - The adapter to be reset
2897 * Out:
2898 * none
2900 * Return Value: none
2903 BOOL CARDbSoftwareReset (PVOID pDeviceHandler)
2905 PSDevice pDevice = (PSDevice) pDeviceHandler;
2907 // reset MAC
2908 if (!MACbSafeSoftwareReset(pDevice->PortOffset))
2909 return FALSE;
2911 return TRUE;
2916 * Description: Caculate TSF offset of two TSF input
2917 * Get TSF Offset from RxBCN's TSF and local TSF
2919 * Parameters:
2920 * In:
2921 * pDevice - The adapter to be sync.
2922 * qwTSF1 - Rx BCN's TSF
2923 * qwTSF2 - Local TSF
2924 * Out:
2925 * none
2927 * Return Value: TSF Offset value
2930 QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2)
2932 QWORD qwTSFOffset;
2933 WORD wRxBcnTSFOffst= 0;;
2935 HIDWORD(qwTSFOffset) = 0;
2936 LODWORD(qwTSFOffset) = 0;
2937 wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE];
2938 (qwTSF2).u.dwLowDword += (DWORD)(wRxBcnTSFOffst);
2939 if ((qwTSF2).u.dwLowDword < (DWORD)(wRxBcnTSFOffst)) {
2940 (qwTSF2).u.dwHighDword++;
2942 LODWORD(qwTSFOffset) = LODWORD(qwTSF1) - LODWORD(qwTSF2);
2943 if (LODWORD(qwTSF1) < LODWORD(qwTSF2)) {
2944 // if borrow needed
2945 HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2) - 1 ;
2947 else {
2948 HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2);
2950 return (qwTSFOffset);
2955 * Description: Read NIC TSF counter
2956 * Get local TSF counter
2958 * Parameters:
2959 * In:
2960 * pDevice - The adapter to be read
2961 * Out:
2962 * qwCurrTSF - Current TSF counter
2964 * Return Value: TRUE if success; otherwise FALSE
2967 BOOL CARDbGetCurrentTSF (DWORD_PTR dwIoBase, PQWORD pqwCurrTSF)
2969 WORD ww;
2970 BYTE byData;
2972 MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
2973 for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
2974 VNSvInPortB(dwIoBase + MAC_REG_TFTCTL, &byData);
2975 if ( !(byData & TFTCTL_TSFCNTRRD))
2976 break;
2978 if (ww == W_MAX_TIMEOUT)
2979 return(FALSE);
2980 VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR, &LODWORD(*pqwCurrTSF));
2981 VNSvInPortD(dwIoBase + MAC_REG_TSFCNTR + 4, &HIDWORD(*pqwCurrTSF));
2983 return(TRUE);
2988 * Description: Read NIC TSF counter
2989 * Get NEXTTBTT from adjusted TSF and Beacon Interval
2991 * Parameters:
2992 * In:
2993 * qwTSF - Current TSF counter
2994 * wbeaconInterval - Beacon Interval
2995 * Out:
2996 * qwCurrTSF - Current TSF counter
2998 * Return Value: TSF value of next Beacon
3001 QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval)
3004 UINT uLowNextTBTT;
3005 UINT uHighRemain, uLowRemain;
3006 UINT uBeaconInterval;
3008 uBeaconInterval = wBeaconInterval * 1024;
3009 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
3010 uLowNextTBTT = (LODWORD(qwTSF) >> 10) << 10;
3011 // low dword (mod) bcn
3012 uLowRemain = (uLowNextTBTT) % uBeaconInterval;
3013 // uHighRemain = ((0x80000000 % uBeaconInterval)* 2 * HIDWORD(qwTSF))
3014 // % uBeaconInterval;
3015 // high dword (mod) bcn
3016 uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * HIDWORD(qwTSF))
3017 % uBeaconInterval;
3018 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
3019 uLowRemain = uBeaconInterval - uLowRemain;
3021 // check if carry when add one beacon interval
3022 if ((~uLowNextTBTT) < uLowRemain)
3023 HIDWORD(qwTSF) ++ ;
3025 LODWORD(qwTSF) = uLowNextTBTT + uLowRemain;
3027 return (qwTSF);
3032 * Description: Set NIC TSF counter for first Beacon time
3033 * Get NEXTTBTT from adjusted TSF and Beacon Interval
3035 * Parameters:
3036 * In:
3037 * dwIoBase - IO Base
3038 * wBeaconInterval - Beacon Interval
3039 * Out:
3040 * none
3042 * Return Value: none
3045 void CARDvSetFirstNextTBTT (DWORD_PTR dwIoBase, WORD wBeaconInterval)
3048 QWORD qwNextTBTT;
3050 HIDWORD(qwNextTBTT) = 0;
3051 LODWORD(qwNextTBTT) = 0;
3052 CARDbGetCurrentTSF(dwIoBase, &qwNextTBTT); //Get Local TSF counter
3053 qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
3054 // Set NextTBTT
3055 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwNextTBTT));
3056 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwNextTBTT));
3057 MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
3058 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:First Next TBTT[%8xh:%8xh] \n", HIDWORD(qwNextTBTT), LODWORD(qwNextTBTT));
3059 return;
3064 * Description: Sync NIC TSF counter for Beacon time
3065 * Get NEXTTBTT and write to HW
3067 * Parameters:
3068 * In:
3069 * pDevice - The adapter to be set
3070 * qwTSF - Current TSF counter
3071 * wBeaconInterval - Beacon Interval
3072 * Out:
3073 * none
3075 * Return Value: none
3078 void CARDvUpdateNextTBTT (DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval)
3081 qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
3082 // Set NextTBTT
3083 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwTSF));
3084 VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwTSF));
3085 MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN);
3086 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n",(UINT)HIDWORD(qwTSF), (UINT)LODWORD(qwTSF));
3088 return;