2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * Purpose: Provide functions to setup NIC operation mode
22 * s_vSafeResetTx - Rest Tx
23 * CARDvSetRSPINF - Set RSPINF
24 * vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS
25 * CARDvUpdateBasicTopRate - Update BasicTopRate
26 * CARDbAddBasicRate - Add to BasicRateSet
27 * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet
28 * CARDvSetLoopbackMode - Set Loopback mode
29 * CARDbSoftwareReset - Sortware reset NIC
30 * CARDqGetTSFOffset - Calculate TSFOffset
31 * CARDbGetCurrentTSF - Read Current NIC TSF counter
32 * CARDqGetNextTBTT - Calculate Next Beacon TSF counter
33 * CARDvSetFirstNextTBTT - Set NIC Beacon time
34 * CARDvUpdateNextTBTT - Sync. NIC Beacon time
35 * CARDbRadioPowerOff - Turn Off NIC Radio Power
36 * CARDbRadioPowerOn - Turn On NIC Radio Power
37 * CARDbSetWEPMode - Set NIC Wep mode
38 * CARDbSetTxPower - Set NIC tx power
41 * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec.
42 * 08-26-2003 Kyle Hsu: Modify the defination type of dwIoBase.
43 * 09-01-2003 Bryan YC Fan: Add vUpdateIFS().
60 /*--------------------- Static Definitions -------------------------*/
62 static int msglevel
= MSG_LEVEL_INFO
;
64 #define C_SIFS_A 16 // micro sec.
67 #define C_EIFS 80 // micro sec.
69 #define C_SLOT_SHORT 9 // micro sec.
70 #define C_SLOT_LONG 20
72 #define C_CWMIN_A 15 // slot time
75 #define C_CWMAX 1023 // slot time
77 #define WAIT_BEACON_TX_DOWN_TMO 3 // Times
79 //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
80 static unsigned char abyDefaultSuppRatesG
[] = {WLAN_EID_SUPP_RATES
, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
82 static unsigned char abyDefaultExtSuppRatesG
[] = {WLAN_EID_EXTSUPP_RATES
, 4, 0x0C, 0x12, 0x18, 0x60};
83 //6M, 9M, 12M, 18M, 24M, 36M, 48M, 54M
84 static unsigned char abyDefaultSuppRatesA
[] = {WLAN_EID_SUPP_RATES
, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
86 static unsigned char abyDefaultSuppRatesB
[] = {WLAN_EID_SUPP_RATES
, 4, 0x02, 0x04, 0x0B, 0x16};
88 /*--------------------- Static Variables --------------------------*/
90 const unsigned short cwRXBCNTSFOff
[MAX_RATE
] =
91 {17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
93 /*--------------------- Static Functions --------------------------*/
97 s_vCalculateOFDMRParameter(
99 CARD_PHY_TYPE ePHYType
,
100 unsigned char *pbyTxRate
,
101 unsigned char *pbyRsvTime
104 /*--------------------- Export Functions --------------------------*/
107 * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode.
112 * byPktType - Tx Packet type
114 * pbyTxRate - pointer to RSPINF TxRate field
115 * pbyRsvTime - pointer to RSPINF RsvTime field
122 s_vCalculateOFDMRParameter(
123 unsigned char byRate
,
124 CARD_PHY_TYPE ePHYType
,
125 unsigned char *pbyTxRate
,
126 unsigned char *pbyRsvTime
131 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
141 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
151 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
161 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
171 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
181 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
191 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
202 if (ePHYType
== PHY_TYPE_11A
) {//5GHZ
214 * Description: Set RSPINF
218 * pDevice - The adapter to be set
222 * Return Value: None.
227 s_vSetRSPINF(PSDevice pDevice
, CARD_PHY_TYPE ePHYType
, void *pvSupportRateIEs
, void *pvExtSupportRateIEs
)
229 unsigned char byServ
= 0, bySignal
= 0; // For CCK
230 unsigned short wLen
= 0;
231 unsigned char byTxRate
= 0, byRsvTime
= 0; // For OFDM
234 MACvSelectPage1(pDevice
->PortOffset
);
237 BBvCalculateParameter(pDevice
,
239 VNTWIFIbyGetACKTxRate(RATE_1M
, pvSupportRateIEs
, pvExtSupportRateIEs
),
246 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_1
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
248 BBvCalculateParameter(pDevice
,
250 VNTWIFIbyGetACKTxRate(RATE_2M
, pvSupportRateIEs
, pvExtSupportRateIEs
),
257 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_2
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
259 BBvCalculateParameter(pDevice
,
261 VNTWIFIbyGetACKTxRate(RATE_5M
, pvSupportRateIEs
, pvExtSupportRateIEs
),
268 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_5
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
270 BBvCalculateParameter(pDevice
,
272 VNTWIFIbyGetACKTxRate(RATE_11M
, pvSupportRateIEs
, pvExtSupportRateIEs
),
279 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_11
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
281 s_vCalculateOFDMRParameter(RATE_6M
,
285 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_6
, MAKEWORD(byTxRate
, byRsvTime
));
287 s_vCalculateOFDMRParameter(RATE_9M
,
291 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_9
, MAKEWORD(byTxRate
, byRsvTime
));
293 s_vCalculateOFDMRParameter(RATE_12M
,
297 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_12
, MAKEWORD(byTxRate
, byRsvTime
));
299 s_vCalculateOFDMRParameter(RATE_18M
,
303 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_18
, MAKEWORD(byTxRate
, byRsvTime
));
305 s_vCalculateOFDMRParameter(RATE_24M
,
309 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_24
, MAKEWORD(byTxRate
, byRsvTime
));
311 s_vCalculateOFDMRParameter(
312 VNTWIFIbyGetACKTxRate(RATE_36M
, pvSupportRateIEs
, pvExtSupportRateIEs
),
316 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_36
, MAKEWORD(byTxRate
, byRsvTime
));
318 s_vCalculateOFDMRParameter(
319 VNTWIFIbyGetACKTxRate(RATE_48M
, pvSupportRateIEs
, pvExtSupportRateIEs
),
323 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_48
, MAKEWORD(byTxRate
, byRsvTime
));
325 s_vCalculateOFDMRParameter(
326 VNTWIFIbyGetACKTxRate(RATE_54M
, pvSupportRateIEs
, pvExtSupportRateIEs
),
330 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_54
, MAKEWORD(byTxRate
, byRsvTime
));
332 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_72
, MAKEWORD(byTxRate
, byRsvTime
));
334 MACvSelectPage0(pDevice
->PortOffset
);
337 /*--------------------- Export Functions --------------------------*/
340 * Description: Get Card short preamble option value
344 * pDevice - The adapter to be set
348 * Return Value: true if short preamble; otherwise false
351 bool CARDbIsShortPreamble(void *pDeviceHandler
)
353 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
354 if (pDevice
->byPreambleType
== 0)
361 * Description: Get Card short slot time option value
365 * pDevice - The adapter to be set
369 * Return Value: true if short slot time; otherwise false
372 bool CARDbIsShorSlotTime(void *pDeviceHandler
)
374 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
375 return pDevice
->bShortSlotTime
;
379 * Description: Update IFS
383 * pDevice - The adapter to be set
387 * Return Value: None.
390 bool CARDbSetPhyParameter(void *pDeviceHandler
, CARD_PHY_TYPE ePHYType
, unsigned short wCapInfo
, unsigned char byERPField
, void *pvSupportRateIEs
, void *pvExtSupportRateIEs
)
392 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
393 unsigned char byCWMaxMin
= 0;
394 unsigned char bySlot
= 0;
395 unsigned char bySIFS
= 0;
396 unsigned char byDIFS
= 0;
397 unsigned char byData
;
398 PWLAN_IE_SUPP_RATES pSupportRates
= (PWLAN_IE_SUPP_RATES
) pvSupportRateIEs
;
399 PWLAN_IE_SUPP_RATES pExtSupportRates
= (PWLAN_IE_SUPP_RATES
) pvExtSupportRateIEs
;
401 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
402 if (ePHYType
== PHY_TYPE_11A
) {
403 if (pSupportRates
== NULL
)
404 pSupportRates
= (PWLAN_IE_SUPP_RATES
) abyDefaultSuppRatesA
;
406 if (pDevice
->byRFType
== RF_AIROHA7230
) {
407 // AL7230 use single PAPE and connect to PAPE_2.4G
408 MACvSetBBType(pDevice
->PortOffset
, BB_TYPE_11G
);
409 pDevice
->abyBBVGA
[0] = 0x20;
410 pDevice
->abyBBVGA
[2] = 0x10;
411 pDevice
->abyBBVGA
[3] = 0x10;
412 BBbReadEmbedded(pDevice
->PortOffset
, 0xE7, &byData
);
414 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE7, pDevice
->abyBBVGA
[0]);
416 } else if (pDevice
->byRFType
== RF_UW2452
) {
417 MACvSetBBType(pDevice
->PortOffset
, BB_TYPE_11A
);
418 pDevice
->abyBBVGA
[0] = 0x18;
419 BBbReadEmbedded(pDevice
->PortOffset
, 0xE7, &byData
);
420 if (byData
== 0x14) {
421 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE7, pDevice
->abyBBVGA
[0]);
422 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE1, 0x57);
425 MACvSetBBType(pDevice
->PortOffset
, BB_TYPE_11A
);
427 BBbWriteEmbedded(pDevice
->PortOffset
, 0x88, 0x03);
428 bySlot
= C_SLOT_SHORT
;
430 byDIFS
= C_SIFS_A
+ 2*C_SLOT_SHORT
;
432 } else if (ePHYType
== PHY_TYPE_11B
) {
433 if (pSupportRates
== NULL
)
434 pSupportRates
= (PWLAN_IE_SUPP_RATES
) abyDefaultSuppRatesB
;
436 MACvSetBBType(pDevice
->PortOffset
, BB_TYPE_11B
);
437 if (pDevice
->byRFType
== RF_AIROHA7230
) {
438 pDevice
->abyBBVGA
[0] = 0x1C;
439 pDevice
->abyBBVGA
[2] = 0x00;
440 pDevice
->abyBBVGA
[3] = 0x00;
441 BBbReadEmbedded(pDevice
->PortOffset
, 0xE7, &byData
);
443 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE7, pDevice
->abyBBVGA
[0]);
445 } else if (pDevice
->byRFType
== RF_UW2452
) {
446 pDevice
->abyBBVGA
[0] = 0x14;
447 BBbReadEmbedded(pDevice
->PortOffset
, 0xE7, &byData
);
448 if (byData
== 0x18) {
449 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE7, pDevice
->abyBBVGA
[0]);
450 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE1, 0xD3);
453 BBbWriteEmbedded(pDevice
->PortOffset
, 0x88, 0x02);
454 bySlot
= C_SLOT_LONG
;
456 byDIFS
= C_SIFS_BG
+ 2*C_SLOT_LONG
;
458 } else {// PK_TYPE_11GA & PK_TYPE_11GB
459 if (pSupportRates
== NULL
) {
460 pSupportRates
= (PWLAN_IE_SUPP_RATES
) abyDefaultSuppRatesG
;
461 pExtSupportRates
= (PWLAN_IE_SUPP_RATES
) abyDefaultExtSuppRatesG
;
463 MACvSetBBType(pDevice
->PortOffset
, BB_TYPE_11G
);
464 if (pDevice
->byRFType
== RF_AIROHA7230
) {
465 pDevice
->abyBBVGA
[0] = 0x1C;
466 pDevice
->abyBBVGA
[2] = 0x00;
467 pDevice
->abyBBVGA
[3] = 0x00;
468 BBbReadEmbedded(pDevice
->PortOffset
, 0xE7, &byData
);
470 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE7, pDevice
->abyBBVGA
[0]);
472 } else if (pDevice
->byRFType
== RF_UW2452
) {
473 pDevice
->abyBBVGA
[0] = 0x14;
474 BBbReadEmbedded(pDevice
->PortOffset
, 0xE7, &byData
);
475 if (byData
== 0x18) {
476 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE7, pDevice
->abyBBVGA
[0]);
477 BBbWriteEmbedded(pDevice
->PortOffset
, 0xE1, 0xD3);
480 BBbWriteEmbedded(pDevice
->PortOffset
, 0x88, 0x08);
482 if (VNTWIFIbIsShortSlotTime(wCapInfo
)) {
483 bySlot
= C_SLOT_SHORT
;
484 byDIFS
= C_SIFS_BG
+ 2*C_SLOT_SHORT
;
486 bySlot
= C_SLOT_LONG
;
487 byDIFS
= C_SIFS_BG
+ 2*C_SLOT_LONG
;
489 if (VNTWIFIbyGetMaxSupportRate(pSupportRates
, pExtSupportRates
) > RATE_11M
)
494 if (pDevice
->bProtectMode
!= VNTWIFIbIsProtectMode(byERPField
)) {
495 pDevice
->bProtectMode
= VNTWIFIbIsProtectMode(byERPField
);
496 if (pDevice
->bProtectMode
)
497 MACvEnableProtectMD(pDevice
->PortOffset
);
499 MACvDisableProtectMD(pDevice
->PortOffset
);
502 if (pDevice
->bBarkerPreambleMd
!= VNTWIFIbIsBarkerMode(byERPField
)) {
503 pDevice
->bBarkerPreambleMd
= VNTWIFIbIsBarkerMode(byERPField
);
504 if (pDevice
->bBarkerPreambleMd
)
505 MACvEnableBarkerPreambleMd(pDevice
->PortOffset
);
507 MACvDisableBarkerPreambleMd(pDevice
->PortOffset
);
511 if (pDevice
->byRFType
== RF_RFMD2959
) {
512 // bcs TX_PE will reserve 3 us
513 // hardware's processing time here is 2 us.
516 //{{ RobertYu: 20041202
517 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput
518 //// MAC will need 2 us to process, so the SIFS, DIFS can be shorter by 2 us.
521 if (pDevice
->bySIFS
!= bySIFS
) {
522 pDevice
->bySIFS
= bySIFS
;
523 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_SIFS
, pDevice
->bySIFS
);
525 if (pDevice
->byDIFS
!= byDIFS
) {
526 pDevice
->byDIFS
= byDIFS
;
527 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_DIFS
, pDevice
->byDIFS
);
529 if (pDevice
->byEIFS
!= C_EIFS
) {
530 pDevice
->byEIFS
= C_EIFS
;
531 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_EIFS
, pDevice
->byEIFS
);
533 if (pDevice
->bySlot
!= bySlot
) {
534 pDevice
->bySlot
= bySlot
;
535 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_SLOT
, pDevice
->bySlot
);
536 if (pDevice
->bySlot
== C_SLOT_SHORT
)
537 pDevice
->bShortSlotTime
= true;
539 pDevice
->bShortSlotTime
= false;
541 BBvSetShortSlotTime(pDevice
);
543 if (pDevice
->byCWMaxMin
!= byCWMaxMin
) {
544 pDevice
->byCWMaxMin
= byCWMaxMin
;
545 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_CWMAXMIN0
, pDevice
->byCWMaxMin
);
547 if (VNTWIFIbIsShortPreamble(wCapInfo
))
548 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
550 pDevice
->byPreambleType
= 0;
552 s_vSetRSPINF(pDevice
, ePHYType
, pSupportRates
, pExtSupportRates
);
553 pDevice
->eCurrentPHYType
= ePHYType
;
554 // set for NDIS OID_802_11SUPPORTED_RATES
559 * Description: Sync. TSF counter to BSS
560 * Get TSF offset and write to HW
564 * pDevice - The adapter to be sync.
565 * byRxRate - data rate of receive beacon
566 * qwBSSTimestamp - Rx BCN's TSF
567 * qwLocalTSF - Local TSF
574 bool CARDbUpdateTSF(void *pDeviceHandler
, unsigned char byRxRate
, QWORD qwBSSTimestamp
, QWORD qwLocalTSF
)
576 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
579 HIDWORD(qwTSFOffset
) = 0;
580 LODWORD(qwTSFOffset
) = 0;
582 if ((HIDWORD(qwBSSTimestamp
) != HIDWORD(qwLocalTSF
)) ||
583 (LODWORD(qwBSSTimestamp
) != LODWORD(qwLocalTSF
))) {
584 qwTSFOffset
= CARDqGetTSFOffset(byRxRate
, qwBSSTimestamp
, qwLocalTSF
);
586 // HW's TSF add TSF Offset reg
587 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_TSFOFST
, LODWORD(qwTSFOffset
));
588 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_TSFOFST
+ 4, HIDWORD(qwTSFOffset
));
589 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_TSFSYNCEN
);
595 * Description: Set NIC TSF counter for first Beacon time
596 * Get NEXTTBTT from adjusted TSF and Beacon Interval
600 * pDevice - The adapter to be set.
601 * wBeaconInterval - Beacon Interval
605 * Return Value: true if succeed; otherwise false
608 bool CARDbSetBeaconPeriod(void *pDeviceHandler
, unsigned short wBeaconInterval
)
610 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
611 unsigned int uBeaconInterval
= 0;
612 unsigned int uLowNextTBTT
= 0;
613 unsigned int uHighRemain
= 0;
614 unsigned int uLowRemain
= 0;
617 HIDWORD(qwNextTBTT
) = 0;
618 LODWORD(qwNextTBTT
) = 0;
619 CARDbGetCurrentTSF(pDevice
->PortOffset
, &qwNextTBTT
); //Get Local TSF counter
620 uBeaconInterval
= wBeaconInterval
* 1024;
621 // Next TBTT = ((local_current_TSF / beacon_interval) + 1) * beacon_interval
622 uLowNextTBTT
= (LODWORD(qwNextTBTT
) >> 10) << 10;
623 uLowRemain
= (uLowNextTBTT
) % uBeaconInterval
;
624 // high dword (mod) bcn
625 uHighRemain
= (((0xffffffff % uBeaconInterval
) + 1) * HIDWORD(qwNextTBTT
))
627 uLowRemain
= (uHighRemain
+ uLowRemain
) % uBeaconInterval
;
628 uLowRemain
= uBeaconInterval
- uLowRemain
;
630 // check if carry when add one beacon interval
631 if ((~uLowNextTBTT
) < uLowRemain
)
632 HIDWORD(qwNextTBTT
)++;
634 LODWORD(qwNextTBTT
) = uLowNextTBTT
+ uLowRemain
;
636 // set HW beacon interval
637 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_BI
, wBeaconInterval
);
638 pDevice
->wBeaconInterval
= wBeaconInterval
;
640 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_NEXTTBTT
, LODWORD(qwNextTBTT
));
641 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_NEXTTBTT
+ 4, HIDWORD(qwNextTBTT
));
642 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_TFTCTL
, TFTCTL_TBTTSYNCEN
);
648 * Description: Card Stop Hardware Tx
652 * pDeviceHandler - The adapter to be set
653 * ePktType - Packet type to stop
657 * Return Value: true if all data packet complete; otherwise false.
660 bool CARDbStopTxPacket(void *pDeviceHandler
, CARD_PKT_TYPE ePktType
)
662 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
664 if (ePktType
== PKT_TYPE_802_11_ALL
) {
665 pDevice
->bStopBeacon
= true;
666 pDevice
->bStopTx0Pkt
= true;
667 pDevice
->bStopDataPkt
= true;
668 } else if (ePktType
== PKT_TYPE_802_11_BCN
) {
669 pDevice
->bStopBeacon
= true;
670 } else if (ePktType
== PKT_TYPE_802_11_MNG
) {
671 pDevice
->bStopTx0Pkt
= true;
672 } else if (ePktType
== PKT_TYPE_802_11_DATA
) {
673 pDevice
->bStopDataPkt
= true;
676 if (pDevice
->bStopBeacon
== true) {
677 if (pDevice
->bIsBeaconBufReadySet
== true) {
678 if (pDevice
->cbBeaconBufReadySetCnt
< WAIT_BEACON_TX_DOWN_TMO
) {
679 pDevice
->cbBeaconBufReadySetCnt
++;
683 pDevice
->bIsBeaconBufReadySet
= false;
684 pDevice
->cbBeaconBufReadySetCnt
= 0;
685 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
687 // wait all TD0 complete
688 if (pDevice
->bStopTx0Pkt
== true) {
689 if (pDevice
->iTDUsed
[TYPE_TXDMA0
] != 0)
692 // wait all Data TD complete
693 if (pDevice
->bStopDataPkt
== true) {
694 if (pDevice
->iTDUsed
[TYPE_AC0DMA
] != 0)
702 * Description: Card Start Hardware Tx
706 * pDeviceHandler - The adapter to be set
707 * ePktType - Packet type to start
711 * Return Value: true if success; false if failed.
714 bool CARDbStartTxPacket(void *pDeviceHandler
, CARD_PKT_TYPE ePktType
)
716 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
718 if (ePktType
== PKT_TYPE_802_11_ALL
) {
719 pDevice
->bStopBeacon
= false;
720 pDevice
->bStopTx0Pkt
= false;
721 pDevice
->bStopDataPkt
= false;
722 } else if (ePktType
== PKT_TYPE_802_11_BCN
) {
723 pDevice
->bStopBeacon
= false;
724 } else if (ePktType
== PKT_TYPE_802_11_MNG
) {
725 pDevice
->bStopTx0Pkt
= false;
726 } else if (ePktType
== PKT_TYPE_802_11_DATA
) {
727 pDevice
->bStopDataPkt
= false;
730 if ((pDevice
->bStopBeacon
== false) &&
731 (pDevice
->bBeaconBufReady
== true) &&
732 (pDevice
->eOPMode
== OP_MODE_ADHOC
)) {
733 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
740 * Description: Card Set BSSID value
744 * pDeviceHandler - The adapter to be set
745 * pbyBSSID - pointer to BSSID field
746 * bAdhoc - flag to indicate IBSS
750 * Return Value: true if success; false if failed.
753 bool CARDbSetBSSID(void *pDeviceHandler
, unsigned char *pbyBSSID
, CARD_OP_MODE eOPMode
)
755 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
757 MACvWriteBSSIDAddress(pDevice
->PortOffset
, pbyBSSID
);
758 memcpy(pDevice
->abyBSSID
, pbyBSSID
, WLAN_BSSID_LEN
);
759 if (eOPMode
== OP_MODE_ADHOC
)
760 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
762 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_HOSTCR
, HOSTCR_ADHOC
);
764 if (eOPMode
== OP_MODE_AP
)
765 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_HOSTCR
, HOSTCR_AP
);
767 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_HOSTCR
, HOSTCR_AP
);
769 if (eOPMode
== OP_MODE_UNKNOWN
) {
770 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_RCR
, RCR_BSSID
);
771 pDevice
->bBSSIDFilter
= false;
772 pDevice
->byRxMode
&= ~RCR_BSSID
;
773 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wcmd: rx_mode = %x\n", pDevice
->byRxMode
);
775 if (is_zero_ether_addr(pDevice
->abyBSSID
) == false) {
776 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_RCR
, RCR_BSSID
);
777 pDevice
->bBSSIDFilter
= true;
778 pDevice
->byRxMode
|= RCR_BSSID
;
780 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wmgr: rx_mode = %x\n", pDevice
->byRxMode
);
782 // Adopt BSS state in Adapter Device Object
783 pDevice
->eOPMode
= eOPMode
;
788 * Description: Card indicate status
792 * pDeviceHandler - The adapter to be set
797 * Return Value: true if success; false if failed.
802 * Description: Save Assoc info. contain in assoc. response frame
806 * pDevice - The adapter to be set
807 * wCapabilityInfo - Capability information
808 * wStatus - Status code
810 * uLen - Length of IEs
811 * pbyIEs - pointer to IEs
815 * Return Value: true if succeed; otherwise false
818 bool CARDbSetTxDataRate(
819 void *pDeviceHandler
,
820 unsigned short wDataRate
823 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
825 pDevice
->wCurrentRate
= wDataRate
;
831 * Routine Description:
832 * Consider to power down when no more packets to tx or rx.
836 * pDevice - The adapter to be set
840 * Return Value: true if power down success; otherwise false
848 PSDevice pDevice
= (PSDevice
)pDeviceHandler
;
851 // check if already in Doze mode
852 if (MACbIsRegBitsOn(pDevice
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PS
))
856 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PSEN
);
858 // check if all TD are empty,
860 for (uIdx
= 0; uIdx
< TYPE_MAXTD
; uIdx
++) {
861 if (pDevice
->iTDUsed
[uIdx
] != 0)
865 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_PSCTL
, PSCTL_GO2DOZE
);
866 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Go to Doze ZZZZZZZZZZZZZZZ\n");
871 * Description: Turn off Radio power
875 * pDevice - The adapter to be turned off
879 * Return Value: true if success; otherwise false
882 bool CARDbRadioPowerOff(void *pDeviceHandler
)
884 PSDevice pDevice
= (PSDevice
)pDeviceHandler
;
887 if (pDevice
->bRadioOff
== true)
890 switch (pDevice
->byRFType
) {
892 MACvWordRegBitsOff(pDevice
->PortOffset
, MAC_REG_SOFTPWRCTL
, SOFTPWRCTL_TXPEINV
);
893 MACvWordRegBitsOn(pDevice
->PortOffset
, MAC_REG_SOFTPWRCTL
, SOFTPWRCTL_SWPE1
);
898 case RF_AIROHA7230
: //RobertYu:20050104
899 MACvWordRegBitsOff(pDevice
->PortOffset
, MAC_REG_SOFTPWRCTL
, SOFTPWRCTL_SWPE2
);
900 MACvWordRegBitsOff(pDevice
->PortOffset
, MAC_REG_SOFTPWRCTL
, SOFTPWRCTL_SWPE3
);
905 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
907 BBvSetDeepSleep(pDevice
->PortOffset
, pDevice
->byLocalID
);
909 pDevice
->bRadioOff
= true;
910 //2007-0409-03,<Add> by chester
911 printk("chester power off\n");
912 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_GPIOCTL0
, LED_ACTSET
); //LED issue
917 * Description: Turn on Radio power
921 * pDevice - The adapter to be turned on
925 * Return Value: true if success; otherwise false
928 bool CARDbRadioPowerOn(void *pDeviceHandler
)
930 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
932 printk("chester power on\n");
933 if (pDevice
->bRadioControlOff
== true) {
934 if (pDevice
->bHWRadioOff
== true) printk("chester bHWRadioOff\n");
935 if (pDevice
->bRadioControlOff
== true) printk("chester bRadioControlOff\n");
938 if (pDevice
->bRadioOff
== false) {
939 printk("chester pbRadioOff\n");
942 BBvExitDeepSleep(pDevice
->PortOffset
, pDevice
->byLocalID
);
944 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
946 switch (pDevice
->byRFType
) {
948 MACvWordRegBitsOn(pDevice
->PortOffset
, MAC_REG_SOFTPWRCTL
, SOFTPWRCTL_TXPEINV
);
949 MACvWordRegBitsOff(pDevice
->PortOffset
, MAC_REG_SOFTPWRCTL
, SOFTPWRCTL_SWPE1
);
954 case RF_AIROHA7230
: //RobertYu:20050104
955 MACvWordRegBitsOn(pDevice
->PortOffset
, MAC_REG_SOFTPWRCTL
, (SOFTPWRCTL_SWPE2
|
961 pDevice
->bRadioOff
= false;
962 // 2007-0409-03,<Add> by chester
963 printk("chester power on\n");
964 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_GPIOCTL0
, LED_ACTSET
); //LED issue
968 bool CARDbRemoveKey(void *pDeviceHandler
, unsigned char *pbyBSSID
)
970 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
972 KeybRemoveAllKey(&(pDevice
->sKey
), pbyBSSID
, pDevice
->PortOffset
);
979 * Add BSSID in PMKID Candidate list.
983 * hDeviceContext - device structure point
984 * pbyBSSID - BSSID address for adding
985 * wRSNCap - BSS's RSN capability
989 * Return Value: none.
993 CARDbAdd_PMKID_Candidate(
994 void *pDeviceHandler
,
995 unsigned char *pbyBSSID
,
997 unsigned short wRSNCap
1000 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1001 PPMKID_CANDIDATE pCandidateList
;
1002 unsigned int ii
= 0;
1004 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
1006 if (pDevice
->gsPMKIDCandidate
.NumCandidates
>= MAX_PMKIDLIST
) {
1007 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"vFlush_PMKID_Candidate: 3\n");
1008 memset(&pDevice
->gsPMKIDCandidate
, 0, sizeof(SPMKIDCandidateEvent
));
1011 for (ii
= 0; ii
< 6; ii
++)
1012 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"%02X ", *(pbyBSSID
+ ii
));
1014 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"\n");
1016 // Update Old Candidate
1017 for (ii
= 0; ii
< pDevice
->gsPMKIDCandidate
.NumCandidates
; ii
++) {
1018 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[ii
];
1019 if (!memcmp(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
)) {
1020 if (bRSNCapExist
&& (wRSNCap
& BIT0
))
1021 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
1023 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
1030 pCandidateList
= &pDevice
->gsPMKIDCandidate
.CandidateList
[pDevice
->gsPMKIDCandidate
.NumCandidates
];
1031 if (bRSNCapExist
&& (wRSNCap
& BIT0
))
1032 pCandidateList
->Flags
|= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
;
1034 pCandidateList
->Flags
&= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED
);
1036 memcpy(pCandidateList
->BSSID
, pbyBSSID
, ETH_ALEN
);
1037 pDevice
->gsPMKIDCandidate
.NumCandidates
++;
1038 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"NumCandidates:%d\n", (int)pDevice
->gsPMKIDCandidate
.NumCandidates
);
1043 CARDpGetCurrentAddress(
1044 void *pDeviceHandler
1047 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1049 return pDevice
->abyCurrentNetAddr
;
1055 * Start Spectrum Measure defined in 802.11h
1059 * hDeviceContext - device structure point
1063 * Return Value: none.
1068 void *pDeviceHandler
,
1069 void *pvMeasureEIDs
,
1070 unsigned int uNumOfMeasureEIDs
1073 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1074 PWLAN_IE_MEASURE_REQ pEID
= (PWLAN_IE_MEASURE_REQ
) pvMeasureEIDs
;
1077 bool bExpired
= true;
1078 unsigned short wDuration
= 0;
1080 if ((pEID
== NULL
) ||
1081 (uNumOfMeasureEIDs
== 0)) {
1084 CARDbGetCurrentTSF(pDevice
->PortOffset
, &qwCurrTSF
);
1085 if (pDevice
->bMeasureInProgress
== true) {
1086 pDevice
->bMeasureInProgress
= false;
1087 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_RCR
, pDevice
->byOrgRCR
);
1088 MACvSelectPage1(pDevice
->PortOffset
);
1089 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_MAR0
, pDevice
->dwOrgMAR0
);
1090 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_MAR4
, pDevice
->dwOrgMAR4
);
1091 // clear measure control
1092 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_MSRCTL
, MSRCTL_EN
);
1093 MACvSelectPage0(pDevice
->PortOffset
);
1094 set_channel(pDevice
, pDevice
->byOrgChannel
);
1095 MACvSelectPage1(pDevice
->PortOffset
);
1096 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_MSRCTL
+1, MSRCTL1_TXPAUSE
);
1097 MACvSelectPage0(pDevice
->PortOffset
);
1099 pDevice
->uNumOfMeasureEIDs
= uNumOfMeasureEIDs
;
1102 pDevice
->pCurrMeasureEID
= pEID
;
1104 pDevice
->uNumOfMeasureEIDs
--;
1106 if (pDevice
->byLocalID
> REV_ID_VT3253_B1
) {
1107 HIDWORD(qwStartTSF
) = HIDWORD(*((PQWORD
)(pDevice
->pCurrMeasureEID
->sReq
.abyStartTime
)));
1108 LODWORD(qwStartTSF
) = LODWORD(*((PQWORD
)(pDevice
->pCurrMeasureEID
->sReq
.abyStartTime
)));
1109 wDuration
= *((unsigned short *)(pDevice
->pCurrMeasureEID
->sReq
.abyDuration
));
1110 wDuration
+= 1; // 1 TU for channel switching
1112 if ((LODWORD(qwStartTSF
) == 0) && (HIDWORD(qwStartTSF
) == 0)) {
1113 // start immediately by setting start TSF == current TSF + 2 TU
1114 LODWORD(qwStartTSF
) = LODWORD(qwCurrTSF
) + 2048;
1115 HIDWORD(qwStartTSF
) = HIDWORD(qwCurrTSF
);
1116 if (LODWORD(qwCurrTSF
) > LODWORD(qwStartTSF
))
1117 HIDWORD(qwStartTSF
)++;
1122 // start at setting start TSF - 1TU(for channel switching)
1123 if (LODWORD(qwStartTSF
) < 1024)
1124 HIDWORD(qwStartTSF
)--;
1126 LODWORD(qwStartTSF
) -= 1024;
1129 if ((HIDWORD(qwCurrTSF
) < HIDWORD(qwStartTSF
)) ||
1130 ((HIDWORD(qwCurrTSF
) == HIDWORD(qwStartTSF
)) &&
1131 (LODWORD(qwCurrTSF
) < LODWORD(qwStartTSF
)))
1136 VNTWIFIbMeasureReport(pDevice
->pMgmt
,
1138 pDevice
->pCurrMeasureEID
,
1140 pDevice
->byBasicMap
,
1141 pDevice
->byCCAFraction
,
1145 // hardware do not support measure
1146 VNTWIFIbMeasureReport(pDevice
->pMgmt
,
1148 pDevice
->pCurrMeasureEID
,
1149 MEASURE_MODE_INCAPABLE
,
1150 pDevice
->byBasicMap
,
1151 pDevice
->byCCAFraction
,
1155 } while (pDevice
->uNumOfMeasureEIDs
!= 0);
1158 MACvSelectPage1(pDevice
->PortOffset
);
1159 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_MSRSTART
, LODWORD(qwStartTSF
));
1160 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_MSRSTART
+ 4, HIDWORD(qwStartTSF
));
1161 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_MSRDURATION
, wDuration
);
1162 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_MSRCTL
, MSRCTL_EN
);
1163 MACvSelectPage0(pDevice
->PortOffset
);
1165 // all measure start time expired we should complete action
1166 VNTWIFIbMeasureReport(pDevice
->pMgmt
,
1170 pDevice
->byBasicMap
,
1171 pDevice
->byCCAFraction
,
1181 * Do Channel Switch defined in 802.11h
1185 * hDeviceContext - device structure point
1189 * Return Value: none.
1194 void *pDeviceHandler
,
1195 unsigned char byMode
,
1196 unsigned char byNewChannel
,
1197 unsigned char byCount
1200 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1201 bool bResult
= true;
1204 bResult
= set_channel(pDevice
, byNewChannel
);
1205 VNTWIFIbChannelSwitch(pDevice
->pMgmt
, byNewChannel
);
1206 MACvSelectPage1(pDevice
->PortOffset
);
1207 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_MSRCTL
+1, MSRCTL1_TXPAUSE
);
1208 MACvSelectPage0(pDevice
->PortOffset
);
1211 pDevice
->byChannelSwitchCount
= byCount
;
1212 pDevice
->byNewChannel
= byNewChannel
;
1213 pDevice
->bChannelSwitch
= true;
1215 bResult
= CARDbStopTxPacket(pDevice
, PKT_TYPE_802_11_ALL
);
1223 * Handle Quiet EID defined in 802.11h
1227 * hDeviceContext - device structure point
1231 * Return Value: none.
1236 void *pDeviceHandler
,
1238 unsigned char byQuietCount
,
1239 unsigned char byQuietPeriod
,
1240 unsigned short wQuietDuration
,
1241 unsigned short wQuietOffset
1244 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1245 unsigned int ii
= 0;
1248 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_MSRCTL
, (MSRCTL_QUIETTXCHK
| MSRCTL_QUIETEN
));
1249 for (ii
= 0; ii
< MAX_QUIET_COUNT
; ii
++)
1250 pDevice
->sQuiet
[ii
].bEnable
= false;
1252 pDevice
->uQuietEnqueue
= 0;
1253 pDevice
->bEnableFirstQuiet
= false;
1254 pDevice
->bQuietEnable
= false;
1255 pDevice
->byQuietStartCount
= byQuietCount
;
1257 if (pDevice
->sQuiet
[pDevice
->uQuietEnqueue
].bEnable
== false) {
1258 pDevice
->sQuiet
[pDevice
->uQuietEnqueue
].bEnable
= true;
1259 pDevice
->sQuiet
[pDevice
->uQuietEnqueue
].byPeriod
= byQuietPeriod
;
1260 pDevice
->sQuiet
[pDevice
->uQuietEnqueue
].wDuration
= wQuietDuration
;
1261 pDevice
->sQuiet
[pDevice
->uQuietEnqueue
].dwStartTime
= (unsigned long) byQuietCount
;
1262 pDevice
->sQuiet
[pDevice
->uQuietEnqueue
].dwStartTime
*= pDevice
->wBeaconInterval
;
1263 pDevice
->sQuiet
[pDevice
->uQuietEnqueue
].dwStartTime
+= wQuietOffset
;
1264 pDevice
->uQuietEnqueue
++;
1265 pDevice
->uQuietEnqueue
%= MAX_QUIET_COUNT
;
1266 if (pDevice
->byQuietStartCount
< byQuietCount
)
1267 pDevice
->byQuietStartCount
= byQuietCount
;
1275 * Do Quiet, It will be called by either ISR(after start)
1276 * or VNTWIFI(before start) so we do not need a SPINLOCK
1280 * hDeviceContext - device structure point
1284 * Return Value: none.
1289 void *pDeviceHandler
1292 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1293 unsigned int ii
= 0;
1294 unsigned long dwStartTime
= 0xFFFFFFFF;
1295 unsigned int uCurrentQuietIndex
= 0;
1296 unsigned long dwNextTime
= 0;
1297 unsigned long dwGap
= 0;
1298 unsigned long dwDuration
= 0;
1300 for (ii
= 0; ii
< MAX_QUIET_COUNT
; ii
++) {
1301 if ((pDevice
->sQuiet
[ii
].bEnable
== true) &&
1302 (dwStartTime
> pDevice
->sQuiet
[ii
].dwStartTime
)) {
1303 dwStartTime
= pDevice
->sQuiet
[ii
].dwStartTime
;
1304 uCurrentQuietIndex
= ii
;
1307 if (dwStartTime
== 0xFFFFFFFF) {
1309 pDevice
->bQuietEnable
= false;
1310 MACvRegBitsOff(pDevice
->PortOffset
, MAC_REG_MSRCTL
, (MSRCTL_QUIETTXCHK
| MSRCTL_QUIETEN
));
1312 if (pDevice
->bQuietEnable
== false) {
1314 pDevice
->byQuietStartCount
--;
1315 dwNextTime
= pDevice
->sQuiet
[uCurrentQuietIndex
].dwStartTime
;
1316 dwNextTime
%= pDevice
->wBeaconInterval
;
1317 MACvSelectPage1(pDevice
->PortOffset
);
1318 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_QUIETINIT
, (unsigned short) dwNextTime
);
1319 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_QUIETDUR
, (unsigned short) pDevice
->sQuiet
[uCurrentQuietIndex
].wDuration
);
1320 if (pDevice
->byQuietStartCount
== 0) {
1321 pDevice
->bEnableFirstQuiet
= false;
1322 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_MSRCTL
, (MSRCTL_QUIETTXCHK
| MSRCTL_QUIETEN
));
1324 pDevice
->bEnableFirstQuiet
= true;
1326 MACvSelectPage0(pDevice
->PortOffset
);
1328 if (pDevice
->dwCurrentQuietEndTime
> pDevice
->sQuiet
[uCurrentQuietIndex
].dwStartTime
) {
1329 // overlap with previous Quiet
1330 dwGap
= pDevice
->dwCurrentQuietEndTime
- pDevice
->sQuiet
[uCurrentQuietIndex
].dwStartTime
;
1331 if (dwGap
>= pDevice
->sQuiet
[uCurrentQuietIndex
].wDuration
) {
1332 // return false to indicate next quiet expired, should call this function again
1335 dwDuration
= pDevice
->sQuiet
[uCurrentQuietIndex
].wDuration
- dwGap
;
1338 dwGap
= pDevice
->sQuiet
[uCurrentQuietIndex
].dwStartTime
- pDevice
->dwCurrentQuietEndTime
;
1339 dwDuration
= pDevice
->sQuiet
[uCurrentQuietIndex
].wDuration
;
1341 // set GAP and Next duration
1342 MACvSelectPage1(pDevice
->PortOffset
);
1343 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_QUIETGAP
, (unsigned short) dwGap
);
1344 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_QUIETDUR
, (unsigned short) dwDuration
);
1345 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_MSRCTL
, MSRCTL_QUIETRPT
);
1346 MACvSelectPage0(pDevice
->PortOffset
);
1348 pDevice
->bQuietEnable
= true;
1349 pDevice
->dwCurrentQuietEndTime
= pDevice
->sQuiet
[uCurrentQuietIndex
].dwStartTime
;
1350 pDevice
->dwCurrentQuietEndTime
+= pDevice
->sQuiet
[uCurrentQuietIndex
].wDuration
;
1351 if (pDevice
->sQuiet
[uCurrentQuietIndex
].byPeriod
== 0) {
1352 // not period disable current quiet element
1353 pDevice
->sQuiet
[uCurrentQuietIndex
].bEnable
= false;
1355 // set next period start time
1356 dwNextTime
= (unsigned long) pDevice
->sQuiet
[uCurrentQuietIndex
].byPeriod
;
1357 dwNextTime
*= pDevice
->wBeaconInterval
;
1358 pDevice
->sQuiet
[uCurrentQuietIndex
].dwStartTime
= dwNextTime
;
1360 if (pDevice
->dwCurrentQuietEndTime
> 0x80010000) {
1361 // decreament all time to avoid wrap around
1362 for (ii
= 0; ii
< MAX_QUIET_COUNT
; ii
++) {
1363 if (pDevice
->sQuiet
[ii
].bEnable
== true)
1364 pDevice
->sQuiet
[ii
].dwStartTime
-= 0x80000000;
1367 pDevice
->dwCurrentQuietEndTime
-= 0x80000000;
1376 * Set Local Power Constraint
1380 * hDeviceContext - device structure point
1384 * Return Value: none.
1388 CARDvSetPowerConstraint(
1389 void *pDeviceHandler
,
1390 unsigned char byChannel
,
1394 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1396 if (byChannel
> CB_MAX_CHANNEL_24G
) {
1397 if (pDevice
->bCountryInfo5G
== true)
1398 pDevice
->abyLocalPwr
[byChannel
] = pDevice
->abyRegPwr
[byChannel
] - byPower
;
1401 if (pDevice
->bCountryInfo24G
== true)
1402 pDevice
->abyLocalPwr
[byChannel
] = pDevice
->abyRegPwr
[byChannel
] - byPower
;
1410 * Set Local Power Constraint
1414 * hDeviceContext - device structure point
1418 * Return Value: none.
1422 CARDvGetPowerCapability(
1423 void *pDeviceHandler
,
1424 unsigned char *pbyMinPower
,
1425 unsigned char *pbyMaxPower
1428 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1429 unsigned char byDec
= 0;
1431 *pbyMaxPower
= pDevice
->abyOFDMDefaultPwr
[pDevice
->byCurrentCh
];
1432 byDec
= pDevice
->abyOFDMPwrTbl
[pDevice
->byCurrentCh
];
1433 if (pDevice
->byRFType
== RF_UW2452
) {
1439 *pbyMinPower
= pDevice
->abyOFDMDefaultPwr
[pDevice
->byCurrentCh
] - byDec
;
1445 * Get Current Tx Power
1449 * hDeviceContext - device structure point
1453 * Return Value: none.
1457 CARDbyGetTransmitPower(
1458 void *pDeviceHandler
1461 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1463 return pDevice
->byCurPwrdBm
;
1469 void *pDeviceHandler
1472 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1476 // initialize TD index
1477 pDevice
->apTailTD
[0] = pDevice
->apCurrTD
[0] = &(pDevice
->apTD0Rings
[0]);
1478 pDevice
->apTailTD
[1] = pDevice
->apCurrTD
[1] = &(pDevice
->apTD1Rings
[0]);
1480 for (uu
= 0; uu
< TYPE_MAXTD
; uu
++)
1481 pDevice
->iTDUsed
[uu
] = 0;
1483 for (uu
= 0; uu
< pDevice
->sOpts
.nTxDescs
[0]; uu
++) {
1484 pCurrTD
= &(pDevice
->apTD0Rings
[uu
]);
1485 pCurrTD
->m_td0TD0
.f1Owner
= OWNED_BY_HOST
;
1486 // init all Tx Packet pointer to NULL
1488 for (uu
= 0; uu
< pDevice
->sOpts
.nTxDescs
[1]; uu
++) {
1489 pCurrTD
= &(pDevice
->apTD1Rings
[uu
]);
1490 pCurrTD
->m_td0TD0
.f1Owner
= OWNED_BY_HOST
;
1491 // init all Tx Packet pointer to NULL
1494 // set MAC TD pointer
1495 MACvSetCurrTXDescAddr(TYPE_TXDMA0
, pDevice
->PortOffset
,
1496 (pDevice
->td0_pool_dma
));
1498 MACvSetCurrTXDescAddr(TYPE_AC0DMA
, pDevice
->PortOffset
,
1499 (pDevice
->td1_pool_dma
));
1501 // set MAC Beacon TX pointer
1502 MACvSetCurrBCNTxDescAddr(pDevice
->PortOffset
,
1503 (pDevice
->tx_beacon_dma
));
1513 * pDevice - Pointer to the adapter
1517 * Return Value: none
1522 void *pDeviceHandler
1525 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1529 // initialize RD index
1530 pDevice
->pCurrRD
[0] = &(pDevice
->aRD0Ring
[0]);
1531 pDevice
->pCurrRD
[1] = &(pDevice
->aRD1Ring
[0]);
1533 // init state, all RD is chip's
1534 for (uu
= 0; uu
< pDevice
->sOpts
.nRxDescs0
; uu
++) {
1535 pDesc
= &(pDevice
->aRD0Ring
[uu
]);
1536 pDesc
->m_rd0RD0
.wResCount
= (unsigned short)(pDevice
->rx_buf_sz
);
1537 pDesc
->m_rd0RD0
.f1Owner
= OWNED_BY_NIC
;
1538 pDesc
->m_rd1RD1
.wReqCount
= (unsigned short)(pDevice
->rx_buf_sz
);
1541 // init state, all RD is chip's
1542 for (uu
= 0; uu
< pDevice
->sOpts
.nRxDescs1
; uu
++) {
1543 pDesc
= &(pDevice
->aRD1Ring
[uu
]);
1544 pDesc
->m_rd0RD0
.wResCount
= (unsigned short)(pDevice
->rx_buf_sz
);
1545 pDesc
->m_rd0RD0
.f1Owner
= OWNED_BY_NIC
;
1546 pDesc
->m_rd1RD1
.wReqCount
= (unsigned short)(pDevice
->rx_buf_sz
);
1549 pDevice
->cbDFCB
= CB_MAX_RX_FRAG
;
1550 pDevice
->cbFreeDFCB
= pDevice
->cbDFCB
;
1553 MACvRx0PerPktMode(pDevice
->PortOffset
);
1554 MACvRx1PerPktMode(pDevice
->PortOffset
);
1555 // set MAC RD pointer
1556 MACvSetCurrRx0DescAddr(pDevice
->PortOffset
,
1557 pDevice
->rd0_pool_dma
);
1559 MACvSetCurrRx1DescAddr(pDevice
->PortOffset
,
1560 pDevice
->rd1_pool_dma
);
1564 * Description: Get response Control frame rate in CCK mode
1568 * pDevice - The adapter to be set
1569 * wRateIdx - Receiving data rate
1573 * Return Value: response Control frame rate
1576 unsigned short CARDwGetCCKControlRate(void *pDeviceHandler
, unsigned short wRateIdx
)
1578 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1579 unsigned int ui
= (unsigned int) wRateIdx
;
1581 while (ui
> RATE_1M
) {
1582 if (pDevice
->wBasicRate
& ((unsigned short)1 << ui
))
1583 return (unsigned short)ui
;
1587 return (unsigned short)RATE_1M
;
1591 * Description: Get response Control frame rate in OFDM mode
1595 * pDevice - The adapter to be set
1596 * wRateIdx - Receiving data rate
1600 * Return Value: response Control frame rate
1603 unsigned short CARDwGetOFDMControlRate(void *pDeviceHandler
, unsigned short wRateIdx
)
1605 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1606 unsigned int ui
= (unsigned int) wRateIdx
;
1608 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BASIC RATE: %X\n", pDevice
->wBasicRate
);
1610 if (!CARDbIsOFDMinBasicRate((void *)pDevice
)) {
1611 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"CARDwGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx
);
1612 if (wRateIdx
> RATE_24M
)
1613 wRateIdx
= RATE_24M
;
1616 while (ui
> RATE_11M
) {
1617 if (pDevice
->wBasicRate
& ((unsigned short)1 << ui
)) {
1618 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"CARDwGetOFDMControlRate : %d\n", ui
);
1619 return (unsigned short)ui
;
1623 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"CARDwGetOFDMControlRate: 6M\n");
1624 return (unsigned short)RATE_24M
;
1628 * Description: Set RSPINF
1632 * pDevice - The adapter to be set
1636 * Return Value: None.
1639 void CARDvSetRSPINF(void *pDeviceHandler
, CARD_PHY_TYPE ePHYType
)
1641 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1642 unsigned char byServ
= 0x00, bySignal
= 0x00; //For CCK
1643 unsigned short wLen
= 0x0000;
1644 unsigned char byTxRate
, byRsvTime
; //For OFDM
1647 MACvSelectPage1(pDevice
->PortOffset
);
1650 BBvCalculateParameter(pDevice
,
1652 CARDwGetCCKControlRate((void *)pDevice
, RATE_1M
),
1659 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_1
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
1661 BBvCalculateParameter(pDevice
,
1663 CARDwGetCCKControlRate((void *)pDevice
, RATE_2M
),
1670 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_2
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
1672 BBvCalculateParameter(pDevice
,
1674 CARDwGetCCKControlRate((void *)pDevice
, RATE_5M
),
1681 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_5
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
1683 BBvCalculateParameter(pDevice
,
1685 CARDwGetCCKControlRate((void *)pDevice
, RATE_11M
),
1692 VNSvOutPortD(pDevice
->PortOffset
+ MAC_REG_RSPINF_B_11
, MAKEDWORD(wLen
, MAKEWORD(bySignal
, byServ
)));
1694 s_vCalculateOFDMRParameter(RATE_6M
,
1698 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_6
, MAKEWORD(byTxRate
, byRsvTime
));
1700 s_vCalculateOFDMRParameter(RATE_9M
,
1704 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_9
, MAKEWORD(byTxRate
, byRsvTime
));
1706 s_vCalculateOFDMRParameter(RATE_12M
,
1710 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_12
, MAKEWORD(byTxRate
, byRsvTime
));
1712 s_vCalculateOFDMRParameter(RATE_18M
,
1716 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_18
, MAKEWORD(byTxRate
, byRsvTime
));
1718 s_vCalculateOFDMRParameter(RATE_24M
,
1722 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_24
, MAKEWORD(byTxRate
, byRsvTime
));
1724 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice
, RATE_36M
),
1728 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_36
, MAKEWORD(byTxRate
, byRsvTime
));
1730 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice
, RATE_48M
),
1734 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_48
, MAKEWORD(byTxRate
, byRsvTime
));
1736 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice
, RATE_54M
),
1740 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_54
, MAKEWORD(byTxRate
, byRsvTime
));
1743 s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)pDevice
, RATE_54M
),
1747 VNSvOutPortW(pDevice
->PortOffset
+ MAC_REG_RSPINF_A_72
, MAKEWORD(byTxRate
, byRsvTime
));
1749 MACvSelectPage0(pDevice
->PortOffset
);
1753 * Description: Update IFS
1757 * pDevice - The adapter to be set
1761 * Return Value: None.
1764 void vUpdateIFS(void *pDeviceHandler
)
1766 //Set SIFS, DIFS, EIFS, SlotTime, CwMin
1767 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1769 unsigned char byMaxMin
= 0;
1770 if (pDevice
->byPacketType
== PK_TYPE_11A
) {//0000 0000 0000 0000,11a
1771 pDevice
->uSlot
= C_SLOT_SHORT
;
1772 pDevice
->uSIFS
= C_SIFS_A
;
1773 pDevice
->uDIFS
= C_SIFS_A
+ 2*C_SLOT_SHORT
;
1774 pDevice
->uCwMin
= C_CWMIN_A
;
1776 } else if (pDevice
->byPacketType
== PK_TYPE_11B
) {//0000 0001 0000 0000,11b
1777 pDevice
->uSlot
= C_SLOT_LONG
;
1778 pDevice
->uSIFS
= C_SIFS_BG
;
1779 pDevice
->uDIFS
= C_SIFS_BG
+ 2*C_SLOT_LONG
;
1780 pDevice
->uCwMin
= C_CWMIN_B
;
1782 } else { // PK_TYPE_11GA & PK_TYPE_11GB
1783 pDevice
->uSIFS
= C_SIFS_BG
;
1784 if (pDevice
->bShortSlotTime
)
1785 pDevice
->uSlot
= C_SLOT_SHORT
;
1787 pDevice
->uSlot
= C_SLOT_LONG
;
1789 pDevice
->uDIFS
= C_SIFS_BG
+ 2*pDevice
->uSlot
;
1790 if (pDevice
->wBasicRate
& 0x0150) { //0000 0001 0101 0000,24M,12M,6M
1791 pDevice
->uCwMin
= C_CWMIN_A
;
1794 pDevice
->uCwMin
= C_CWMIN_B
;
1799 pDevice
->uCwMax
= C_CWMAX
;
1800 pDevice
->uEIFS
= C_EIFS
;
1801 if (pDevice
->byRFType
== RF_RFMD2959
) {
1802 // bcs TX_PE will reserve 3 us
1803 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_SIFS
, (unsigned char)(pDevice
->uSIFS
- 3));
1804 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_DIFS
, (unsigned char)(pDevice
->uDIFS
- 3));
1806 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_SIFS
, (unsigned char)pDevice
->uSIFS
);
1807 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_DIFS
, (unsigned char)pDevice
->uDIFS
);
1809 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_EIFS
, (unsigned char)pDevice
->uEIFS
);
1810 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_SLOT
, (unsigned char)pDevice
->uSlot
);
1811 byMaxMin
|= 0xA0;//1010 1111,C_CWMAX = 1023
1812 VNSvOutPortB(pDevice
->PortOffset
+ MAC_REG_CWMAXMIN0
, (unsigned char)byMaxMin
);
1815 void CARDvUpdateBasicTopRate(void *pDeviceHandler
)
1817 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1818 unsigned char byTopOFDM
= RATE_24M
, byTopCCK
= RATE_1M
;
1821 //Determines the highest basic rate.
1822 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
1823 if ((pDevice
->wBasicRate
) & ((unsigned short)(1<<ii
))) {
1828 pDevice
->byTopOFDMBasicRate
= byTopOFDM
;
1830 for (ii
= RATE_11M
;; ii
--) {
1831 if ((pDevice
->wBasicRate
) & ((unsigned short)(1<<ii
))) {
1838 pDevice
->byTopCCKBasicRate
= byTopCCK
;
1841 bool CARDbAddBasicRate(void *pDeviceHandler
, unsigned short wRateIdx
)
1843 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1844 unsigned short wRate
= (unsigned short)(1<<wRateIdx
);
1846 pDevice
->wBasicRate
|= wRate
;
1848 //Determines the highest basic rate.
1849 CARDvUpdateBasicTopRate((void *)pDevice
);
1854 bool CARDbIsOFDMinBasicRate(void *pDeviceHandler
)
1856 PSDevice pDevice
= (PSDevice
)pDeviceHandler
;
1859 for (ii
= RATE_54M
; ii
>= RATE_6M
; ii
--) {
1860 if ((pDevice
->wBasicRate
) & ((unsigned short)(1 << ii
)))
1866 unsigned char CARDbyGetPktType(void *pDeviceHandler
)
1868 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1870 if (pDevice
->byBBType
== BB_TYPE_11A
|| pDevice
->byBBType
== BB_TYPE_11B
)
1871 return (unsigned char)pDevice
->byBBType
;
1872 else if (CARDbIsOFDMinBasicRate((void *)pDevice
))
1873 return PK_TYPE_11GA
;
1875 return PK_TYPE_11GB
;
1879 * Description: Set NIC Loopback mode
1883 * pDevice - The adapter to be set
1884 * wLoopbackMode - Loopback mode to be set
1888 * Return Value: none
1891 void CARDvSetLoopbackMode(unsigned long dwIoBase
, unsigned short wLoopbackMode
)
1893 switch (wLoopbackMode
) {
1903 MACvSetLoopbackMode(dwIoBase
, LOBYTE(wLoopbackMode
));
1904 // set Baseband loopback
1908 * Description: Software Reset NIC
1912 * pDevice - The adapter to be reset
1916 * Return Value: none
1919 bool CARDbSoftwareReset(void *pDeviceHandler
)
1921 PSDevice pDevice
= (PSDevice
) pDeviceHandler
;
1924 if (!MACbSafeSoftwareReset(pDevice
->PortOffset
))
1931 * Description: Calculate TSF offset of two TSF input
1932 * Get TSF Offset from RxBCN's TSF and local TSF
1936 * pDevice - The adapter to be sync.
1937 * qwTSF1 - Rx BCN's TSF
1938 * qwTSF2 - Local TSF
1942 * Return Value: TSF Offset value
1945 QWORD
CARDqGetTSFOffset(unsigned char byRxRate
, QWORD qwTSF1
, QWORD qwTSF2
)
1948 unsigned short wRxBcnTSFOffst
= 0;
1950 HIDWORD(qwTSFOffset
) = 0;
1951 LODWORD(qwTSFOffset
) = 0;
1952 wRxBcnTSFOffst
= cwRXBCNTSFOff
[byRxRate
%MAX_RATE
];
1953 (qwTSF2
).u
.dwLowDword
+= (unsigned long)(wRxBcnTSFOffst
);
1954 if ((qwTSF2
).u
.dwLowDword
< (unsigned long)(wRxBcnTSFOffst
))
1955 (qwTSF2
).u
.dwHighDword
++;
1957 LODWORD(qwTSFOffset
) = LODWORD(qwTSF1
) - LODWORD(qwTSF2
);
1958 if (LODWORD(qwTSF1
) < LODWORD(qwTSF2
)) {
1960 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
) - 1;
1962 HIDWORD(qwTSFOffset
) = HIDWORD(qwTSF1
) - HIDWORD(qwTSF2
);
1968 * Description: Read NIC TSF counter
1969 * Get local TSF counter
1973 * pDevice - The adapter to be read
1975 * qwCurrTSF - Current TSF counter
1977 * Return Value: true if success; otherwise false
1980 bool CARDbGetCurrentTSF(unsigned long dwIoBase
, PQWORD pqwCurrTSF
)
1983 unsigned char byData
;
1985 MACvRegBitsOn(dwIoBase
, MAC_REG_TFTCTL
, TFTCTL_TSFCNTRRD
);
1986 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1987 VNSvInPortB(dwIoBase
+ MAC_REG_TFTCTL
, &byData
);
1988 if (!(byData
& TFTCTL_TSFCNTRRD
))
1991 if (ww
== W_MAX_TIMEOUT
)
1993 VNSvInPortD(dwIoBase
+ MAC_REG_TSFCNTR
, &LODWORD(*pqwCurrTSF
));
1994 VNSvInPortD(dwIoBase
+ MAC_REG_TSFCNTR
+ 4, &HIDWORD(*pqwCurrTSF
));
2000 * Description: Read NIC TSF counter
2001 * Get NEXTTBTT from adjusted TSF and Beacon Interval
2005 * qwTSF - Current TSF counter
2006 * wbeaconInterval - Beacon Interval
2008 * qwCurrTSF - Current TSF counter
2010 * Return Value: TSF value of next Beacon
2013 QWORD
CARDqGetNextTBTT(QWORD qwTSF
, unsigned short wBeaconInterval
)
2015 unsigned int uLowNextTBTT
;
2016 unsigned int uHighRemain
, uLowRemain
;
2017 unsigned int uBeaconInterval
;
2019 uBeaconInterval
= wBeaconInterval
* 1024;
2020 // Next TBTT = ((local_current_TSF / beacon_interval) + 1) * beacon_interval
2021 uLowNextTBTT
= (LODWORD(qwTSF
) >> 10) << 10;
2022 // low dword (mod) bcn
2023 uLowRemain
= (uLowNextTBTT
) % uBeaconInterval
;
2024 // high dword (mod) bcn
2025 uHighRemain
= (((0xffffffff % uBeaconInterval
) + 1) * HIDWORD(qwTSF
))
2027 uLowRemain
= (uHighRemain
+ uLowRemain
) % uBeaconInterval
;
2028 uLowRemain
= uBeaconInterval
- uLowRemain
;
2030 // check if carry when add one beacon interval
2031 if ((~uLowNextTBTT
) < uLowRemain
)
2034 LODWORD(qwTSF
) = uLowNextTBTT
+ uLowRemain
;
2040 * Description: Set NIC TSF counter for first Beacon time
2041 * Get NEXTTBTT from adjusted TSF and Beacon Interval
2045 * dwIoBase - IO Base
2046 * wBeaconInterval - Beacon Interval
2050 * Return Value: none
2053 void CARDvSetFirstNextTBTT(unsigned long dwIoBase
, unsigned short wBeaconInterval
)
2057 HIDWORD(qwNextTBTT
) = 0;
2058 LODWORD(qwNextTBTT
) = 0;
2059 CARDbGetCurrentTSF(dwIoBase
, &qwNextTBTT
); //Get Local TSF counter
2060 qwNextTBTT
= CARDqGetNextTBTT(qwNextTBTT
, wBeaconInterval
);
2062 VNSvOutPortD(dwIoBase
+ MAC_REG_NEXTTBTT
, LODWORD(qwNextTBTT
));
2063 VNSvOutPortD(dwIoBase
+ MAC_REG_NEXTTBTT
+ 4, HIDWORD(qwNextTBTT
));
2064 MACvRegBitsOn(dwIoBase
, MAC_REG_TFTCTL
, TFTCTL_TBTTSYNCEN
);
2070 * Description: Sync NIC TSF counter for Beacon time
2071 * Get NEXTTBTT and write to HW
2075 * pDevice - The adapter to be set
2076 * qwTSF - Current TSF counter
2077 * wBeaconInterval - Beacon Interval
2081 * Return Value: none
2084 void CARDvUpdateNextTBTT(unsigned long dwIoBase
, QWORD qwTSF
, unsigned short wBeaconInterval
)
2086 qwTSF
= CARDqGetNextTBTT(qwTSF
, wBeaconInterval
);
2088 VNSvOutPortD(dwIoBase
+ MAC_REG_NEXTTBTT
, LODWORD(qwTSF
));
2089 VNSvOutPortD(dwIoBase
+ MAC_REG_NEXTTBTT
+ 4, HIDWORD(qwTSF
));
2090 MACvRegBitsOn(dwIoBase
, MAC_REG_TFTCTL
, TFTCTL_TBTTSYNCEN
);
2091 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Card:Update Next TBTT[%8xh:%8xh] \n",
2092 (unsigned int) HIDWORD(qwTSF
), (unsigned int) LODWORD(qwTSF
));