blob: 2cd120ba4576d74377e060caa9dcd9c4f2ab6644 [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
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.
9 *
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.
14 *
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.
18 *
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
Justin P. Mattocka0a1f612012-08-26 08:16:43 -070031 * CARDqGetTSFOffset - Calculate TSFOffset
Forest Bond92b96792009-06-13 07:38:31 -040032 * CARDbGetCurrentTSF - Read Current NIC TSF counter
Justin P. Mattocka0a1f612012-08-26 08:16:43 -070033 * CARDqGetNextTBTT - Calculate Next Beacon TSF counter
Forest Bond92b96792009-06-13 07:38:31 -040034 * 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
40 *
41 * Revision History:
42 * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
Justin P. Mattocka0a1f612012-08-26 08:16:43 -070043 * 08-26-2003 Kyle Hsu: Modify the definition type of dwIoBase.
Forest Bond92b96792009-06-13 07:38:31 -040044 * 09-01-2003 Bryan YC Fan: Add vUpdateIFS().
45 *
46 */
47
Malcolm Priestleydd0a7742012-12-10 21:59:10 +000048#include "device.h"
Forest Bond92b96792009-06-13 07:38:31 -040049#include "tmacro.h"
Forest Bond92b96792009-06-13 07:38:31 -040050#include "card.h"
Forest Bond92b96792009-06-13 07:38:31 -040051#include "baseband.h"
Forest Bond92b96792009-06-13 07:38:31 -040052#include "mac.h"
Forest Bond92b96792009-06-13 07:38:31 -040053#include "desc.h"
Forest Bond92b96792009-06-13 07:38:31 -040054#include "rf.h"
Forest Bond92b96792009-06-13 07:38:31 -040055#include "power.h"
Forest Bond92b96792009-06-13 07:38:31 -040056#include "key.h"
Forest Bond92b96792009-06-13 07:38:31 -040057#include "rc4.h"
Forest Bond92b96792009-06-13 07:38:31 -040058#include "country.h"
Forest Bond92b96792009-06-13 07:38:31 -040059#include "datarate.h"
Forest Bond92b96792009-06-13 07:38:31 -040060#include "rndis.h"
Forest Bond92b96792009-06-13 07:38:31 -040061#include "control.h"
Forest Bond92b96792009-06-13 07:38:31 -040062
63/*--------------------- Static Definitions -------------------------*/
64
65//static int msglevel =MSG_LEVEL_DEBUG;
66static int msglevel =MSG_LEVEL_INFO;
67
68
69/*--------------------- Static Definitions -------------------------*/
Forest Bond92b96792009-06-13 07:38:31 -040070
71/*--------------------- Static Classes ----------------------------*/
72
73/*--------------------- Static Variables --------------------------*/
74//const WORD cwRXBCNTSFOff[MAX_RATE] =
75//{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
76
77const WORD cwRXBCNTSFOff[MAX_RATE] =
78{192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
79
80/*--------------------- Static Functions --------------------------*/
81
82/*--------------------- Export Variables --------------------------*/
83
84/*--------------------- Export Functions --------------------------*/
85/*
86 * Description: Set NIC media channel
87 *
88 * Parameters:
89 * In:
90 * pDevice - The adapter to be set
91 * uConnectionChannel - Channel to be set
92 * Out:
93 * none
Forest Bond92b96792009-06-13 07:38:31 -040094 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +000095void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel)
Forest Bond92b96792009-06-13 07:38:31 -040096{
Forest Bond92b96792009-06-13 07:38:31 -040097
98 if (pDevice->byBBType == BB_TYPE_11A) { // 15 ~ 38
99 if ((uConnectionChannel < (CB_MAX_CHANNEL_24G+1)) || (uConnectionChannel > CB_MAX_CHANNEL))
100 uConnectionChannel = (CB_MAX_CHANNEL_24G+1);
101 } else {
102 if ((uConnectionChannel > CB_MAX_CHANNEL_24G) || (uConnectionChannel == 0)) // 1 ~ 14
103 uConnectionChannel = 1;
104 }
105
106 // clear NAV
107 MACvRegBitsOn(pDevice, MAC_REG_MACCR, MACCR_CLRNAV);
108
109 // Set Channel[7] = 0 to tell H/W channel is changing now.
110 MACvRegBitsOff(pDevice, MAC_REG_CHANNEL, 0x80);
111
112 //if (pMgmt->uCurrChannel == uConnectionChannel)
113 // return bResult;
114
115 CONTROLnsRequestOut(pDevice,
116 MESSAGE_TYPE_SELECT_CHANNLE,
117 (WORD) uConnectionChannel,
118 0,
119 0,
120 NULL
121 );
122
123 //{{ RobertYu: 20041202
124 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
125
126 if (pDevice->byBBType == BB_TYPE_11A) {
127 pDevice->byCurPwr = 0xFF;
128 RFbRawSetPower(pDevice, pDevice->abyOFDMAPwrTbl[uConnectionChannel-15], RATE_54M);
129 } else if (pDevice->byBBType == BB_TYPE_11G) {
130 pDevice->byCurPwr = 0xFF;
131 RFbRawSetPower(pDevice, pDevice->abyOFDMPwrTbl[uConnectionChannel-1], RATE_54M);
132 } else {
133 pDevice->byCurPwr = 0xFF;
134 RFbRawSetPower(pDevice, pDevice->abyCCKPwrTbl[uConnectionChannel-1], RATE_1M);
135 }
Andres Moreb902fbf2013-02-25 20:32:51 -0500136 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_CHANNEL,(u8)(uConnectionChannel|0x80));
Forest Bond92b96792009-06-13 07:38:31 -0400137}
138
139/*
140 * Description: Get CCK mode basic rate
141 *
142 * Parameters:
143 * In:
144 * pDevice - The adapter to be set
145 * wRateIdx - Receiving data rate
146 * Out:
147 * none
148 *
149 * Return Value: response Control frame rate
150 *
151 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000152static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx)
Forest Bond92b96792009-06-13 07:38:31 -0400153{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000154 u16 ui = wRateIdx;
155
156 while (ui > RATE_1M) {
157 if (pDevice->wBasicRate & (1 << ui))
158 return ui;
159 ui--;
160 }
161
162 return RATE_1M;
Forest Bond92b96792009-06-13 07:38:31 -0400163}
164
165/*
166 * Description: Get OFDM mode basic rate
167 *
168 * Parameters:
169 * In:
170 * pDevice - The adapter to be set
171 * wRateIdx - Receiving data rate
172 * Out:
173 * none
174 *
175 * Return Value: response Control frame rate
176 *
177 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000178static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx)
Forest Bond92b96792009-06-13 07:38:31 -0400179{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000180 u16 ui = wRateIdx;
Forest Bond92b96792009-06-13 07:38:31 -0400181
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000182 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n",
183 pDevice->wBasicRate);
Forest Bond92b96792009-06-13 07:38:31 -0400184
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000185 if (!CARDbIsOFDMinBasicRate(pDevice)) {
186 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
187 "swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
188 if (wRateIdx > RATE_24M)
189 wRateIdx = RATE_24M;
190 return wRateIdx;
191 }
192
193 while (ui > RATE_11M) {
194 if (pDevice->wBasicRate & (1 << ui)) {
195 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
196 "swGetOFDMControlRate: %d\n", ui);
197 return ui;
198 }
199 ui--;
200 }
201
202 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n");
203
204 return RATE_24M;
Forest Bond92b96792009-06-13 07:38:31 -0400205}
206
207/*
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700208 * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
Forest Bond92b96792009-06-13 07:38:31 -0400209 *
210 * Parameters:
211 * In:
212 * wRate - Tx Rate
213 * byPktType - Tx Packet type
214 * Out:
215 * pbyTxRate - pointer to RSPINF TxRate field
216 * pbyRsvTime - pointer to RSPINF RsvTime field
217 *
218 * Return Value: none
219 *
220 */
Andres More8611a292010-05-01 14:25:00 -0300221void
Justin P. Mattockbda79782012-08-26 08:16:44 -0700222CARDvCalculateOFDMRParameter (
Andres More592ccfe2010-04-17 12:07:42 -0300223 WORD wRate,
Andres Moreb902fbf2013-02-25 20:32:51 -0500224 u8 byBBType,
225 u8 * pbyTxRate,
226 u8 * pbyRsvTime
Forest Bond92b96792009-06-13 07:38:31 -0400227 )
228{
229 switch (wRate) {
230 case RATE_6M :
231 if (byBBType == BB_TYPE_11A) {//5GHZ
232 *pbyTxRate = 0x9B;
233 *pbyRsvTime = 24;
234 }
235 else {
236 *pbyTxRate = 0x8B;
237 *pbyRsvTime = 30;
238 }
239 break;
240
241 case RATE_9M :
242 if (byBBType == BB_TYPE_11A) {//5GHZ
243 *pbyTxRate = 0x9F;
244 *pbyRsvTime = 16;
245 }
246 else {
247 *pbyTxRate = 0x8F;
248 *pbyRsvTime = 22;
249 }
250 break;
251
252 case RATE_12M :
253 if (byBBType == BB_TYPE_11A) {//5GHZ
254 *pbyTxRate = 0x9A;
255 *pbyRsvTime = 12;
256 }
257 else {
258 *pbyTxRate = 0x8A;
259 *pbyRsvTime = 18;
260 }
261 break;
262
263 case RATE_18M :
264 if (byBBType == BB_TYPE_11A) {//5GHZ
265 *pbyTxRate = 0x9E;
266 *pbyRsvTime = 8;
267 }
268 else {
269 *pbyTxRate = 0x8E;
270 *pbyRsvTime = 14;
271 }
272 break;
273
274 case RATE_36M :
275 if (byBBType == BB_TYPE_11A) {//5GHZ
276 *pbyTxRate = 0x9D;
277 *pbyRsvTime = 4;
278 }
279 else {
280 *pbyTxRate = 0x8D;
281 *pbyRsvTime = 10;
282 }
283 break;
284
285 case RATE_48M :
286 if (byBBType == BB_TYPE_11A) {//5GHZ
287 *pbyTxRate = 0x98;
288 *pbyRsvTime = 4;
289 }
290 else {
291 *pbyTxRate = 0x88;
292 *pbyRsvTime = 10;
293 }
294 break;
295
296 case RATE_54M :
297 if (byBBType == BB_TYPE_11A) {//5GHZ
298 *pbyTxRate = 0x9C;
299 *pbyRsvTime = 4;
300 }
301 else {
302 *pbyTxRate = 0x8C;
303 *pbyRsvTime = 10;
304 }
305 break;
306
307 case RATE_24M :
308 default :
309 if (byBBType == BB_TYPE_11A) {//5GHZ
310 *pbyTxRate = 0x99;
311 *pbyRsvTime = 8;
312 }
313 else {
314 *pbyTxRate = 0x89;
315 *pbyRsvTime = 14;
316 }
317 break;
318 }
319}
320
321/*
322 * Description: Set RSPINF
323 *
324 * Parameters:
325 * In:
326 * pDevice - The adapter to be set
327 * Out:
328 * none
329 *
330 * Return Value: None.
331 *
332 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000333void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType)
Forest Bond92b96792009-06-13 07:38:31 -0400334{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000335 u8 abyServ[4] = {0, 0, 0, 0}; /* For CCK */
336 u8 abySignal[4] = {0, 0, 0, 0};
337 u16 awLen[4] = {0, 0, 0, 0};
338 u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */
339 u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
340 u8 abyData[34];
341 int i;
Forest Bond92b96792009-06-13 07:38:31 -0400342
343 //RSPINF_b_1
Justin P. Mattockbda79782012-08-26 08:16:44 -0700344 BBvCalculateParameter(pDevice,
Forest Bond92b96792009-06-13 07:38:31 -0400345 14,
346 swGetCCKControlRate(pDevice, RATE_1M),
347 PK_TYPE_11B,
348 &awLen[0],
349 &abyServ[0],
350 &abySignal[0]
351 );
352
353 ///RSPINF_b_2
Justin P. Mattockbda79782012-08-26 08:16:44 -0700354 BBvCalculateParameter(pDevice,
Forest Bond92b96792009-06-13 07:38:31 -0400355 14,
356 swGetCCKControlRate(pDevice, RATE_2M),
357 PK_TYPE_11B,
358 &awLen[1],
359 &abyServ[1],
360 &abySignal[1]
361 );
362
363 //RSPINF_b_5
Justin P. Mattockbda79782012-08-26 08:16:44 -0700364 BBvCalculateParameter(pDevice,
Forest Bond92b96792009-06-13 07:38:31 -0400365 14,
366 swGetCCKControlRate(pDevice, RATE_5M),
367 PK_TYPE_11B,
368 &awLen[2],
369 &abyServ[2],
370 &abySignal[2]
371 );
372
373 //RSPINF_b_11
Justin P. Mattockbda79782012-08-26 08:16:44 -0700374 BBvCalculateParameter(pDevice,
Forest Bond92b96792009-06-13 07:38:31 -0400375 14,
376 swGetCCKControlRate(pDevice, RATE_11M),
377 PK_TYPE_11B,
378 &awLen[3],
379 &abyServ[3],
380 &abySignal[3]
381 );
382
383 //RSPINF_a_6
Justin P. Mattockbda79782012-08-26 08:16:44 -0700384 CARDvCalculateOFDMRParameter (RATE_6M,
Forest Bond92b96792009-06-13 07:38:31 -0400385 byBBType,
386 &abyTxRate[0],
387 &abyRsvTime[0]);
388
389 //RSPINF_a_9
Justin P. Mattockbda79782012-08-26 08:16:44 -0700390 CARDvCalculateOFDMRParameter (RATE_9M,
Forest Bond92b96792009-06-13 07:38:31 -0400391 byBBType,
392 &abyTxRate[1],
393 &abyRsvTime[1]);
394
395 //RSPINF_a_12
Justin P. Mattockbda79782012-08-26 08:16:44 -0700396 CARDvCalculateOFDMRParameter (RATE_12M,
Forest Bond92b96792009-06-13 07:38:31 -0400397 byBBType,
398 &abyTxRate[2],
399 &abyRsvTime[2]);
400
401 //RSPINF_a_18
Justin P. Mattockbda79782012-08-26 08:16:44 -0700402 CARDvCalculateOFDMRParameter (RATE_18M,
Forest Bond92b96792009-06-13 07:38:31 -0400403 byBBType,
404 &abyTxRate[3],
405 &abyRsvTime[3]);
406
407 //RSPINF_a_24
Justin P. Mattockbda79782012-08-26 08:16:44 -0700408 CARDvCalculateOFDMRParameter (RATE_24M,
Forest Bond92b96792009-06-13 07:38:31 -0400409 byBBType,
410 &abyTxRate[4],
411 &abyRsvTime[4]);
412
413 //RSPINF_a_36
Justin P. Mattockbda79782012-08-26 08:16:44 -0700414 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_36M),
Forest Bond92b96792009-06-13 07:38:31 -0400415 byBBType,
416 &abyTxRate[5],
417 &abyRsvTime[5]);
418
419 //RSPINF_a_48
Justin P. Mattockbda79782012-08-26 08:16:44 -0700420 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_48M),
Forest Bond92b96792009-06-13 07:38:31 -0400421 byBBType,
422 &abyTxRate[6],
423 &abyRsvTime[6]);
424
425 //RSPINF_a_54
Justin P. Mattockbda79782012-08-26 08:16:44 -0700426 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
Forest Bond92b96792009-06-13 07:38:31 -0400427 byBBType,
428 &abyTxRate[7],
429 &abyRsvTime[7]);
430
431 //RSPINF_a_72
Justin P. Mattockbda79782012-08-26 08:16:44 -0700432 CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M),
Forest Bond92b96792009-06-13 07:38:31 -0400433 byBBType,
434 &abyTxRate[8],
435 &abyRsvTime[8]);
436
Andres Moreb902fbf2013-02-25 20:32:51 -0500437 abyData[0] = (u8)(awLen[0]&0xFF);
438 abyData[1] = (u8)(awLen[0]>>8);
Forest Bond92b96792009-06-13 07:38:31 -0400439 abyData[2] = abySignal[0];
440 abyData[3] = abyServ[0];
441
Andres Moreb902fbf2013-02-25 20:32:51 -0500442 abyData[4] = (u8)(awLen[1]&0xFF);
443 abyData[5] = (u8)(awLen[1]>>8);
Forest Bond92b96792009-06-13 07:38:31 -0400444 abyData[6] = abySignal[1];
445 abyData[7] = abyServ[1];
446
Andres Moreb902fbf2013-02-25 20:32:51 -0500447 abyData[8] = (u8)(awLen[2]&0xFF);
448 abyData[9] = (u8)(awLen[2]>>8);
Forest Bond92b96792009-06-13 07:38:31 -0400449 abyData[10] = abySignal[2];
450 abyData[11] = abyServ[2];
451
Andres Moreb902fbf2013-02-25 20:32:51 -0500452 abyData[12] = (u8)(awLen[3]&0xFF);
453 abyData[13] = (u8)(awLen[3]>>8);
Forest Bond92b96792009-06-13 07:38:31 -0400454 abyData[14] = abySignal[3];
455 abyData[15] = abyServ[3];
456
Andres More33d33e422010-05-19 23:50:00 -0300457 for (i = 0; i < 9; i++) {
458 abyData[16+i*2] = abyTxRate[i];
459 abyData[16+i*2+1] = abyRsvTime[i];
Forest Bond92b96792009-06-13 07:38:31 -0400460 }
461
Forest Bond92b96792009-06-13 07:38:31 -0400462 CONTROLnsRequestOut(pDevice,
463 MESSAGE_TYPE_WRITE,
464 MAC_REG_RSPINF_B_1,
465 MESSAGE_REQUEST_MACREG,
466 34,
467 &abyData[0]);
468
469}
470
471/*
472 * Description: Update IFS
473 *
474 * Parameters:
475 * In:
476 * pDevice - The adapter to be set
477 * Out:
478 * none
479 *
480 * Return Value: None.
481 *
482 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000483void vUpdateIFS(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400484{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000485 u8 byMaxMin = 0;
486 u8 byData[4];
Forest Bond92b96792009-06-13 07:38:31 -0400487
488 if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a
489 pDevice->uSlot = C_SLOT_SHORT;
490 pDevice->uSIFS = C_SIFS_A;
491 pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT;
492 pDevice->uCwMin = C_CWMIN_A;
493 byMaxMin = 4;
494 }
495 else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b
496 pDevice->uSlot = C_SLOT_LONG;
497 pDevice->uSIFS = C_SIFS_BG;
498 pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG;
499 pDevice->uCwMin = C_CWMIN_B;
500 byMaxMin = 5;
501 }
502 else {// PK_TYPE_11GA & PK_TYPE_11GB
Andres Moreb902fbf2013-02-25 20:32:51 -0500503 u8 byRate = 0;
Andres Moree269fc22013-02-12 20:36:29 -0500504 bool bOFDMRate = false;
Andres Morecc856e62010-05-17 21:34:01 -0300505 unsigned int ii = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400506 PWLAN_IE_SUPP_RATES pItemRates = NULL;
507
508 pDevice->uSIFS = C_SIFS_BG;
509 if (pDevice->bShortSlotTime) {
510 pDevice->uSlot = C_SLOT_SHORT;
511 } else {
512 pDevice->uSlot = C_SLOT_LONG;
513 }
514 pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
515
Malcolm Priestley14c5ef52013-01-17 23:19:37 +0000516 pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt.abyCurrSuppRates;
Forest Bond92b96792009-06-13 07:38:31 -0400517 for (ii = 0; ii < pItemRates->len; ii++) {
Andres Moreb902fbf2013-02-25 20:32:51 -0500518 byRate = (u8)(pItemRates->abyRates[ii]&0x7F);
Forest Bond92b96792009-06-13 07:38:31 -0400519 if (RATEwGetRateIdx(byRate) > RATE_11M) {
Andres More4e9b5e22013-02-12 20:36:30 -0500520 bOFDMRate = true;
Forest Bond92b96792009-06-13 07:38:31 -0400521 break;
522 }
523 }
Andres Moree269fc22013-02-12 20:36:29 -0500524 if (bOFDMRate == false) {
Malcolm Priestley14c5ef52013-01-17 23:19:37 +0000525 pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt
526 .abyCurrExtSuppRates;
Forest Bond92b96792009-06-13 07:38:31 -0400527 for (ii = 0; ii < pItemRates->len; ii++) {
Andres Moreb902fbf2013-02-25 20:32:51 -0500528 byRate = (u8)(pItemRates->abyRates[ii]&0x7F);
Forest Bond92b96792009-06-13 07:38:31 -0400529 if (RATEwGetRateIdx(byRate) > RATE_11M) {
Andres More4e9b5e22013-02-12 20:36:30 -0500530 bOFDMRate = true;
Forest Bond92b96792009-06-13 07:38:31 -0400531 break;
532 }
533 }
534 }
Andres More4e9b5e22013-02-12 20:36:30 -0500535 if (bOFDMRate == true) {
Forest Bond92b96792009-06-13 07:38:31 -0400536 pDevice->uCwMin = C_CWMIN_A;
537 byMaxMin = 4;
538 } else {
539 pDevice->uCwMin = C_CWMIN_B;
540 byMaxMin = 5;
541 }
542 }
543
544 pDevice->uCwMax = C_CWMAX;
545 pDevice->uEIFS = C_EIFS;
546
Andres Moreb902fbf2013-02-25 20:32:51 -0500547 byData[0] = (u8)pDevice->uSIFS;
548 byData[1] = (u8)pDevice->uDIFS;
549 byData[2] = (u8)pDevice->uEIFS;
550 byData[3] = (u8)pDevice->uSlot;
Forest Bond92b96792009-06-13 07:38:31 -0400551 CONTROLnsRequestOut(pDevice,
552 MESSAGE_TYPE_WRITE,
553 MAC_REG_SIFS,
554 MESSAGE_REQUEST_MACREG,
555 4,
556 &byData[0]);
557
558 byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023
559 CONTROLnsRequestOut(pDevice,
560 MESSAGE_TYPE_WRITE,
561 MAC_REG_CWMAXMIN0,
562 MESSAGE_REQUEST_MACREG,
563 1,
564 &byMaxMin);
565}
566
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000567void CARDvUpdateBasicTopRate(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400568{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000569 u8 byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
570 u8 ii;
Forest Bond92b96792009-06-13 07:38:31 -0400571
572 //Determines the highest basic rate.
573 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
574 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) ) {
575 byTopOFDM = ii;
576 break;
577 }
578 }
579 pDevice->byTopOFDMBasicRate = byTopOFDM;
580
581 for (ii = RATE_11M;; ii --) {
582 if ( (pDevice->wBasicRate) & ((WORD)(1<<ii)) ) {
583 byTopCCK = ii;
584 break;
585 }
586 if (ii == RATE_1M)
587 break;
588 }
589 pDevice->byTopCCKBasicRate = byTopCCK;
590 }
591
592/*
593 * Description: Set NIC Tx Basic Rate
594 *
595 * Parameters:
596 * In:
597 * pDevice - The adapter to be set
598 * wBasicRate - Basic Rate to be set
599 * Out:
600 * none
601 *
Andres More4e9b5e22013-02-12 20:36:30 -0500602 * Return Value: true if succeeded; false if failed.
Forest Bond92b96792009-06-13 07:38:31 -0400603 *
604 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000605void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx)
Forest Bond92b96792009-06-13 07:38:31 -0400606{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000607 u16 wRate = (1 << wRateIdx);
Forest Bond92b96792009-06-13 07:38:31 -0400608
609 pDevice->wBasicRate |= wRate;
610
611 //Determines the highest basic rate.
612 CARDvUpdateBasicTopRate(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400613}
614
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000615int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400616{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000617 int ii;
Forest Bond92b96792009-06-13 07:38:31 -0400618
619 for (ii = RATE_54M; ii >= RATE_6M; ii --) {
620 if ((pDevice->wBasicRate) & ((WORD)(1<<ii)))
Andres More4e9b5e22013-02-12 20:36:30 -0500621 return true;
Forest Bond92b96792009-06-13 07:38:31 -0400622 }
Andres Moree269fc22013-02-12 20:36:29 -0500623 return false;
Forest Bond92b96792009-06-13 07:38:31 -0400624}
625
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000626u8 CARDbyGetPktType(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400627{
Forest Bond92b96792009-06-13 07:38:31 -0400628
629 if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) {
Andres Moreb902fbf2013-02-25 20:32:51 -0500630 return (u8)pDevice->byBBType;
Forest Bond92b96792009-06-13 07:38:31 -0400631 }
632 else if (CARDbIsOFDMinBasicRate(pDevice)) {
633 return PK_TYPE_11GA;
634 }
635 else {
636 return PK_TYPE_11GB;
637 }
638}
639
640
641/*
Justin P. Mattocka0a1f612012-08-26 08:16:43 -0700642 * Description: Calculate TSF offset of two TSF input
Forest Bond92b96792009-06-13 07:38:31 -0400643 * Get TSF Offset from RxBCN's TSF and local TSF
644 *
645 * Parameters:
646 * In:
647 * pDevice - The adapter to be sync.
648 * qwTSF1 - Rx BCN's TSF
649 * qwTSF2 - Local TSF
650 * Out:
651 * none
652 *
653 * Return Value: TSF Offset value
654 *
655 */
Andres Moreb902fbf2013-02-25 20:32:51 -0500656u64 CARDqGetTSFOffset(u8 byRxRate, u64 qwTSF1, u64 qwTSF2)
Forest Bond92b96792009-06-13 07:38:31 -0400657{
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000658 u64 qwTSFOffset = 0;
659 WORD wRxBcnTSFOffst = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400660
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000661 wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE];
Forest Bond92b96792009-06-13 07:38:31 -0400662
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000663 qwTSF2 += (u64)wRxBcnTSFOffst;
664
665 qwTSFOffset = qwTSF1 - qwTSF2;
666
667 return qwTSFOffset;
Forest Bond92b96792009-06-13 07:38:31 -0400668}
669
670
671
672/*
673 * Description: Sync. TSF counter to BSS
674 * Get TSF offset and write to HW
675 *
676 * Parameters:
677 * In:
678 * pDevice - The adapter to be sync.
679 * qwBSSTimestamp - Rx BCN's TSF
680 * qwLocalTSF - Local TSF
681 * Out:
682 * none
683 *
684 * Return Value: none
685 *
686 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000687void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate,
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000688 u64 qwBSSTimestamp, u64 qwLocalTSF)
Forest Bond92b96792009-06-13 07:38:31 -0400689{
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000690 u64 qwTSFOffset = 0;
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000691 u8 pbyData[8];
Forest Bond92b96792009-06-13 07:38:31 -0400692
Forest Bond92b96792009-06-13 07:38:31 -0400693
694 qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
695 // adjust TSF
696 // HW's TSF add TSF Offset reg
Forest Bond92b96792009-06-13 07:38:31 -0400697
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000698 pbyData[0] = (u8)qwTSFOffset;
699 pbyData[1] = (u8)(qwTSFOffset >> 8);
700 pbyData[2] = (u8)(qwTSFOffset >> 16);
701 pbyData[3] = (u8)(qwTSFOffset >> 24);
702 pbyData[4] = (u8)(qwTSFOffset >> 32);
703 pbyData[5] = (u8)(qwTSFOffset >> 40);
704 pbyData[6] = (u8)(qwTSFOffset >> 48);
705 pbyData[7] = (u8)(qwTSFOffset >> 56);
Forest Bond92b96792009-06-13 07:38:31 -0400706
707 CONTROLnsRequestOut(pDevice,
708 MESSAGE_TYPE_SET_TSFTBTT,
709 MESSAGE_REQUEST_TSF,
710 0,
711 8,
712 pbyData
713 );
714
715}
716/*
717 * Description: Read NIC TSF counter
718 * Get local TSF counter
719 *
720 * Parameters:
721 * In:
722 * pDevice - The adapter to be read
723 * Out:
724 * qwCurrTSF - Current TSF counter
725 *
Andres More4e9b5e22013-02-12 20:36:30 -0500726 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400727 *
728 */
Andres Moredfdcc422013-02-12 20:36:28 -0500729bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF)
Forest Bond92b96792009-06-13 07:38:31 -0400730{
Forest Bond92b96792009-06-13 07:38:31 -0400731
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000732 *pqwCurrTSF = pDevice->qwCurrTSF;
Forest Bond92b96792009-06-13 07:38:31 -0400733
Andres More4e9b5e22013-02-12 20:36:30 -0500734 return true;
Forest Bond92b96792009-06-13 07:38:31 -0400735}
736
737
738/*
739 * Description: Clear NIC TSF counter
740 * Clear local TSF counter
741 *
742 * Parameters:
743 * In:
744 * pDevice - The adapter to be read
745 *
Andres More4e9b5e22013-02-12 20:36:30 -0500746 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400747 *
748 */
Andres Moredfdcc422013-02-12 20:36:28 -0500749bool CARDbClearCurrentTSF(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400750{
Forest Bond92b96792009-06-13 07:38:31 -0400751
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000752 MACvRegBitsOn(pDevice, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
Forest Bond92b96792009-06-13 07:38:31 -0400753
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000754 pDevice->qwCurrTSF = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400755
Andres More4e9b5e22013-02-12 20:36:30 -0500756 return true;
Forest Bond92b96792009-06-13 07:38:31 -0400757}
758
759/*
760 * Description: Read NIC TSF counter
761 * Get NEXTTBTT from adjusted TSF and Beacon Interval
762 *
763 * Parameters:
764 * In:
765 * qwTSF - Current TSF counter
766 * wbeaconInterval - Beacon Interval
767 * Out:
768 * qwCurrTSF - Current TSF counter
769 *
770 * Return Value: TSF value of next Beacon
771 *
772 */
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000773u64 CARDqGetNextTBTT(u64 qwTSF, WORD wBeaconInterval)
Forest Bond92b96792009-06-13 07:38:31 -0400774{
775
Andres Morecc856e62010-05-17 21:34:01 -0300776 unsigned int uLowNextTBTT;
777 unsigned int uHighRemain, uLowRemain;
778 unsigned int uBeaconInterval;
Forest Bond92b96792009-06-13 07:38:31 -0400779
780 uBeaconInterval = wBeaconInterval * 1024;
781 // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000782 uLowNextTBTT = ((qwTSF & 0xffffffffU) >> 10) << 10;
783 uLowRemain = (uLowNextTBTT) % uBeaconInterval;
784 uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32))
785 % uBeaconInterval;
786 uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
787 uLowRemain = uBeaconInterval - uLowRemain;
Forest Bond92b96792009-06-13 07:38:31 -0400788
789 // check if carry when add one beacon interval
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000790 if ((~uLowNextTBTT) < uLowRemain)
791 qwTSF = ((qwTSF >> 32) + 1) << 32;
Forest Bond92b96792009-06-13 07:38:31 -0400792
Peter Huewec7b7cad2013-02-05 23:31:37 +0100793 qwTSF = (qwTSF & 0xffffffff00000000UL) |
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000794 (u64)(uLowNextTBTT + uLowRemain);
Forest Bond92b96792009-06-13 07:38:31 -0400795
796 return (qwTSF);
797}
798
799
800/*
801 * Description: Set NIC TSF counter for first Beacon time
802 * Get NEXTTBTT from adjusted TSF and Beacon Interval
803 *
804 * Parameters:
805 * In:
806 * dwIoBase - IO Base
807 * wBeaconInterval - Beacon Interval
808 * Out:
809 * none
810 *
811 * Return Value: none
812 *
813 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000814void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, WORD wBeaconInterval)
Forest Bond92b96792009-06-13 07:38:31 -0400815{
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000816 u64 qwNextTBTT = 0;
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000817 u8 pbyData[8];
Forest Bond92b96792009-06-13 07:38:31 -0400818
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000819 CARDbClearCurrentTSF(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400820 //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000821 qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
Forest Bond92b96792009-06-13 07:38:31 -0400822 // Set NextTBTT
823
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000824 pbyData[0] = (u8)qwNextTBTT;
825 pbyData[1] = (u8)(qwNextTBTT >> 8);
826 pbyData[2] = (u8)(qwNextTBTT >> 16);
827 pbyData[3] = (u8)(qwNextTBTT >> 24);
828 pbyData[4] = (u8)(qwNextTBTT >> 32);
829 pbyData[5] = (u8)(qwNextTBTT >> 40);
830 pbyData[6] = (u8)(qwNextTBTT >> 48);
831 pbyData[7] = (u8)(qwNextTBTT >> 56);
Forest Bond92b96792009-06-13 07:38:31 -0400832
833 CONTROLnsRequestOut(pDevice,
834 MESSAGE_TYPE_SET_TSFTBTT,
835 MESSAGE_REQUEST_TBTT,
836 0,
837 8,
838 pbyData
839 );
840
841 return;
842}
843
844
845/*
846 * Description: Sync NIC TSF counter for Beacon time
847 * Get NEXTTBTT and write to HW
848 *
849 * Parameters:
850 * In:
851 * pDevice - The adapter to be set
852 * qwTSF - Current TSF counter
853 * wBeaconInterval - Beacon Interval
854 * Out:
855 * none
856 *
857 * Return Value: none
858 *
859 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000860void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF,
861 u16 wBeaconInterval)
Forest Bond92b96792009-06-13 07:38:31 -0400862{
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000863 u8 pbyData[8];
Forest Bond92b96792009-06-13 07:38:31 -0400864
865 qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
866
867 // Set NextTBTT
Forest Bond92b96792009-06-13 07:38:31 -0400868
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000869 pbyData[0] = (u8)qwTSF;
870 pbyData[1] = (u8)(qwTSF >> 8);
871 pbyData[2] = (u8)(qwTSF >> 16);
872 pbyData[3] = (u8)(qwTSF >> 24);
873 pbyData[4] = (u8)(qwTSF >> 32);
874 pbyData[5] = (u8)(qwTSF >> 40);
875 pbyData[6] = (u8)(qwTSF >> 48);
876 pbyData[7] = (u8)(qwTSF >> 56);
Forest Bond92b96792009-06-13 07:38:31 -0400877
878 CONTROLnsRequestOut(pDevice,
879 MESSAGE_TYPE_SET_TSFTBTT,
880 MESSAGE_REQUEST_TBTT,
881 0,
882 8,
883 pbyData
884 );
885
886
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000887 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
888 "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF);
Forest Bond92b96792009-06-13 07:38:31 -0400889
890 return;
891}
892
893/*
894 * Description: Turn off Radio power
895 *
896 * Parameters:
897 * In:
898 * pDevice - The adapter to be turned off
899 * Out:
900 * none
901 *
Andres More4e9b5e22013-02-12 20:36:30 -0500902 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400903 *
904 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000905int CARDbRadioPowerOff(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400906{
Andres More4e9b5e22013-02-12 20:36:30 -0500907 int bResult = true;
Forest Bond92b96792009-06-13 07:38:31 -0400908
Andres More4e9b5e22013-02-12 20:36:30 -0500909 //if (pDevice->bRadioOff == true)
910 // return true;
Forest Bond92b96792009-06-13 07:38:31 -0400911
Andres More4e9b5e22013-02-12 20:36:30 -0500912 pDevice->bRadioOff = true;
Forest Bond92b96792009-06-13 07:38:31 -0400913
914 switch (pDevice->byRFType) {
915 case RF_AL2230:
916 case RF_AL2230S:
917 case RF_AIROHA7230:
918 case RF_VT3226: //RobertYu:20051111
919 case RF_VT3226D0:
920 case RF_VT3342A0: //RobertYu:20060609
921 MACvRegBitsOff(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
922 break;
923 }
924
925 MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
926
927 BBvSetDeepSleep(pDevice);
928
929 return bResult;
930}
931
932
933/*
934 * Description: Turn on Radio power
935 *
936 * Parameters:
937 * In:
938 * pDevice - The adapter to be turned on
939 * Out:
940 * none
941 *
Andres More4e9b5e22013-02-12 20:36:30 -0500942 * Return Value: true if success; otherwise false
Forest Bond92b96792009-06-13 07:38:31 -0400943 *
944 */
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000945int CARDbRadioPowerOn(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400946{
Andres More4e9b5e22013-02-12 20:36:30 -0500947 int bResult = true;
Forest Bond92b96792009-06-13 07:38:31 -0400948
Andres More4e9b5e22013-02-12 20:36:30 -0500949 if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) {
Andres Moree269fc22013-02-12 20:36:29 -0500950 return false;
Forest Bond92b96792009-06-13 07:38:31 -0400951 }
952
Andres Moree269fc22013-02-12 20:36:29 -0500953 //if (pDevice->bRadioOff == false)
Andres More4e9b5e22013-02-12 20:36:30 -0500954 // return true;
Forest Bond92b96792009-06-13 07:38:31 -0400955
Andres Moree269fc22013-02-12 20:36:29 -0500956 pDevice->bRadioOff = false;
Forest Bond92b96792009-06-13 07:38:31 -0400957
958 BBvExitDeepSleep(pDevice);
959
960 MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON);
961
962 switch (pDevice->byRFType) {
963 case RF_AL2230:
964 case RF_AL2230S:
965 case RF_AIROHA7230:
966 case RF_VT3226: //RobertYu:20051111
967 case RF_VT3226D0:
968 case RF_VT3342A0: //RobertYu:20060609
969 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
970 break;
971 }
972
973 return bResult;
974}
975
Malcolm Priestleydd0a7742012-12-10 21:59:10 +0000976void CARDvSetBSSMode(struct vnt_private *pDevice)
Forest Bond92b96792009-06-13 07:38:31 -0400977{
Forest Bond92b96792009-06-13 07:38:31 -0400978 // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
979 // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
980 if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) )
981 {
982 MACvSetBBType(pDevice, BB_TYPE_11G);
983 }
984 else
985 {
986 MACvSetBBType(pDevice, pDevice->byBBType);
987 }
988 pDevice->byPacketType = CARDbyGetPktType(pDevice);
989
990 if (pDevice->byBBType == BB_TYPE_11A) {
991 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03);
992 } else if (pDevice->byBBType == BB_TYPE_11B) {
993 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02);
994 } else if (pDevice->byBBType == BB_TYPE_11G) {
995 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x08);
996 }
997
998 vUpdateIFS(pDevice);
Andres Moreb902fbf2013-02-25 20:32:51 -0500999 CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType);
Forest Bond92b96792009-06-13 07:38:31 -04001000
1001 if ( pDevice->byBBType == BB_TYPE_11A ) {
1002 //request by Jack 2005-04-26
1003 if (pDevice->byRFType == RF_AIROHA7230) {
1004 pDevice->abyBBVGA[0] = 0x20;
1005 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
1006 }
1007 pDevice->abyBBVGA[2] = 0x10;
1008 pDevice->abyBBVGA[3] = 0x10;
1009 } else {
1010 //request by Jack 2005-04-26
1011 if (pDevice->byRFType == RF_AIROHA7230) {
1012 pDevice->abyBBVGA[0] = 0x1C;
1013 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]);
1014 }
1015 pDevice->abyBBVGA[2] = 0x0;
1016 pDevice->abyBBVGA[3] = 0x0;
1017 }
1018}
1019
1020/*
1021 *
1022 * Description:
1023 * Do Channel Switch defined in 802.11h
1024 *
1025 * Parameters:
1026 * In:
1027 * hDeviceContext - device structure point
1028 * Out:
1029 * none
1030 *
1031 * Return Value: none.
1032 *
1033-*/
Malcolm Priestleydd0a7742012-12-10 21:59:10 +00001034int CARDbChannelSwitch(struct vnt_private *pDevice, u8 byMode,
1035 u8 byNewChannel, u8 byCount)
Forest Bond92b96792009-06-13 07:38:31 -04001036{
Andres More4e9b5e22013-02-12 20:36:30 -05001037 int bResult = true;
Forest Bond92b96792009-06-13 07:38:31 -04001038
Malcolm Priestley14c5ef52013-01-17 23:19:37 +00001039 if (byCount == 0) {
1040 pDevice->vnt_mgmt.uCurrChannel = byNewChannel;
1041 CARDbSetMediaChannel(pDevice, byNewChannel);
1042 return bResult;
1043 }
Forest Bond92b96792009-06-13 07:38:31 -04001044 pDevice->byChannelSwitchCount = byCount;
1045 pDevice->byNewChannel = byNewChannel;
Andres More4e9b5e22013-02-12 20:36:30 -05001046 pDevice->bChannelSwitch = true;
Forest Bond92b96792009-06-13 07:38:31 -04001047
1048 if (byMode == 1) {
1049 //bResult=CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL);
Andres More4e9b5e22013-02-12 20:36:30 -05001050 pDevice->bStopDataPkt = true;
Forest Bond92b96792009-06-13 07:38:31 -04001051 }
matiascd74ea32010-09-16 15:11:28 -03001052 return bResult;
Forest Bond92b96792009-06-13 07:38:31 -04001053}
1054
1055
1056
1057
1058
1059