blob: b3136773b5da694693d022c154d4a82164d73730 [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 *
20 * File: power.c
21 *
Uwe Kleine-König0d743952010-06-11 12:17:04 +020022 * Purpose: Handles 802.11 power management functions
Forest Bond92b96792009-06-13 07:38:31 -040023 *
24 * Author: Lyndon Chen
25 *
26 * Date: July 17, 2002
27 *
28 * Functions:
29 * PSvEnablePowerSaving - Enable Power Saving Mode
30 * PSvDiasblePowerSaving - Disable Power Saving Mode
31 * PSbConsiderPowerDown - Decide if we can Power Down
32 * PSvSendPSPOLL - Send PS-POLL packet
33 * PSbSendNullPacket - Send Null packet
34 * PSbIsNextTBTTWakeUp - Decide if we need to wake up at next Beacon
35 *
36 * Revision History:
37 *
38 */
39
Forest Bond92b96792009-06-13 07:38:31 -040040#include "ttype.h"
Forest Bond92b96792009-06-13 07:38:31 -040041#include "mac.h"
Forest Bond92b96792009-06-13 07:38:31 -040042#include "device.h"
Forest Bond92b96792009-06-13 07:38:31 -040043#include "wmgr.h"
Forest Bond92b96792009-06-13 07:38:31 -040044#include "power.h"
Forest Bond92b96792009-06-13 07:38:31 -040045#include "wcmd.h"
Forest Bond92b96792009-06-13 07:38:31 -040046#include "rxtx.h"
Forest Bond92b96792009-06-13 07:38:31 -040047#include "card.h"
Forest Bond92b96792009-06-13 07:38:31 -040048#include "control.h"
Forest Bond92b96792009-06-13 07:38:31 -040049#include "rndis.h"
Forest Bond92b96792009-06-13 07:38:31 -040050
51/*--------------------- Static Definitions -------------------------*/
52
Forest Bond92b96792009-06-13 07:38:31 -040053/*--------------------- Static Classes ----------------------------*/
54
55/*--------------------- Static Variables --------------------------*/
Philip Worrallf9cfbe92011-03-02 14:34:39 +000056static int msglevel = MSG_LEVEL_INFO;
Forest Bond92b96792009-06-13 07:38:31 -040057/*--------------------- Static Functions --------------------------*/
58
Forest Bond92b96792009-06-13 07:38:31 -040059/*--------------------- Export Variables --------------------------*/
60
Forest Bond92b96792009-06-13 07:38:31 -040061/*--------------------- Export Functions --------------------------*/
62
Philip Worrall7404eab2011-03-02 14:34:40 +000063/*
Forest Bond92b96792009-06-13 07:38:31 -040064 *
65 * Routine Description:
66 * Enable hw power saving functions
67 *
68 * Return Value:
69 * None.
70 *
Philip Worrall7404eab2011-03-02 14:34:40 +000071 */
Forest Bond92b96792009-06-13 07:38:31 -040072
Andres More0cbd8d92010-05-06 20:34:29 -030073void PSvEnablePowerSaving(void *hDeviceContext,
74 WORD wListenInterval)
Forest Bond92b96792009-06-13 07:38:31 -040075{
Philip Worrallf9cfbe92011-03-02 14:34:39 +000076 PSDevice pDevice = (PSDevice)hDeviceContext;
77 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
78 WORD wAID = pMgmt->wCurrAID | BIT14 | BIT15;
Forest Bond92b96792009-06-13 07:38:31 -040079
Philip Worrallf9cfbe92011-03-02 14:34:39 +000080 /* set period of power up before TBTT */
81 MACvWriteWord(pDevice, MAC_REG_PWBT, C_PWBT);
Forest Bond92b96792009-06-13 07:38:31 -040082
Philip Worrallf9cfbe92011-03-02 14:34:39 +000083 if (pDevice->eOPMode != OP_MODE_ADHOC) {
84 /* set AID */
85 MACvWriteWord(pDevice, MAC_REG_AIDATIM, wAID);
86 } else {
Philip Worrall7404eab2011-03-02 14:34:40 +000087 /* set ATIM Window */
88 /* MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow); */
Philip Worrallf9cfbe92011-03-02 14:34:39 +000089 }
Forest Bond92b96792009-06-13 07:38:31 -040090
Philip Worrall7404eab2011-03-02 14:34:40 +000091 /* Warren:06-18-2004,the sequence must follow PSEN->AUTOSLEEP->GO2DOZE */
92 /* enable power saving hw function */
Philip Worrallf9cfbe92011-03-02 14:34:39 +000093 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_PSEN);
Forest Bond92b96792009-06-13 07:38:31 -040094
Philip Worrall7404eab2011-03-02 14:34:40 +000095 /* Set AutoSleep */
Philip Worrallf9cfbe92011-03-02 14:34:39 +000096 MACvRegBitsOn(pDevice, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
Forest Bond92b96792009-06-13 07:38:31 -040097
Philip Worrall7404eab2011-03-02 14:34:40 +000098 /* Warren:MUST turn on this once before turn on AUTOSLEEP ,or the AUTOSLEEP doesn't work */
Philip Worrallf9cfbe92011-03-02 14:34:39 +000099 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_GO2DOZE);
Forest Bond92b96792009-06-13 07:38:31 -0400100
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000101 if (wListenInterval >= 2) {
Forest Bond92b96792009-06-13 07:38:31 -0400102
Philip Worrall7404eab2011-03-02 14:34:40 +0000103 /* clear always listen beacon */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000104 MACvRegBitsOff(pDevice, MAC_REG_PSCTL, PSCTL_ALBCN);
Forest Bond92b96792009-06-13 07:38:31 -0400105
Philip Worrall7404eab2011-03-02 14:34:40 +0000106 /* first time set listen next beacon */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000107 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_LNBCN);
Forest Bond92b96792009-06-13 07:38:31 -0400108
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000109 pMgmt->wCountToWakeUp = wListenInterval;
Forest Bond92b96792009-06-13 07:38:31 -0400110
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000111 } else {
Forest Bond92b96792009-06-13 07:38:31 -0400112
Philip Worrall7404eab2011-03-02 14:34:40 +0000113 /* always listen beacon */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000114 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_ALBCN);
Forest Bond92b96792009-06-13 07:38:31 -0400115
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000116 pMgmt->wCountToWakeUp = 0;
117 }
Forest Bond92b96792009-06-13 07:38:31 -0400118
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000119 pDevice->bEnablePSMode = TRUE;
120
Philip Worrall7404eab2011-03-02 14:34:40 +0000121 /* We don't send null pkt in ad hoc mode since beacon will handle this. */
Philip Worrall8c811612011-03-02 14:34:45 +0000122 if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE)
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000123 PSbSendNullPacket(pDevice);
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000124
125 pDevice->bPWBitOn = TRUE;
Philip Worrallc5b0b5f2011-03-02 14:34:43 +0000126 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS:Power Saving Mode Enable...\n");
Forest Bond92b96792009-06-13 07:38:31 -0400127}
128
Philip Worrall7404eab2011-03-02 14:34:40 +0000129/*
Forest Bond92b96792009-06-13 07:38:31 -0400130 *
131 * Routine Description:
132 * Disable hw power saving functions
133 *
134 * Return Value:
135 * None.
136 *
Philip Worrall7404eab2011-03-02 14:34:40 +0000137 */
Forest Bond92b96792009-06-13 07:38:31 -0400138
Andres More0cbd8d92010-05-06 20:34:29 -0300139void PSvDisablePowerSaving(void *hDeviceContext)
Forest Bond92b96792009-06-13 07:38:31 -0400140{
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000141 PSDevice pDevice = (PSDevice)hDeviceContext;
Philip Worrall7404eab2011-03-02 14:34:40 +0000142 /* PSMgmtObject pMgmt = &(pDevice->sMgmtObj); */
Forest Bond92b96792009-06-13 07:38:31 -0400143
Philip Worrall7404eab2011-03-02 14:34:40 +0000144 /* disable power saving hw function */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000145 CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_DISABLE_PS, 0,
146 0, 0, NULL);
Forest Bond92b96792009-06-13 07:38:31 -0400147
Philip Worrall7404eab2011-03-02 14:34:40 +0000148 /* clear AutoSleep */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000149 MACvRegBitsOff(pDevice, MAC_REG_PSCFG, PSCFG_AUTOSLEEP);
Forest Bond92b96792009-06-13 07:38:31 -0400150
Philip Worrall7404eab2011-03-02 14:34:40 +0000151 /* set always listen beacon */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000152 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_ALBCN);
153 pDevice->bEnablePSMode = FALSE;
Forest Bond92b96792009-06-13 07:38:31 -0400154
Philip Worrall036dba12011-03-02 14:34:41 +0000155 if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE)
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000156 PSbSendNullPacket(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400157
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000158 pDevice->bPWBitOn = FALSE;
Forest Bond92b96792009-06-13 07:38:31 -0400159}
160
Philip Worrall7404eab2011-03-02 14:34:40 +0000161/*
Forest Bond92b96792009-06-13 07:38:31 -0400162 *
163 * Routine Description:
164 * Consider to power down when no more packets to tx or rx.
165 *
166 * Return Value:
167 * TRUE, if power down success
168 * FALSE, if fail
Philip Worrall7404eab2011-03-02 14:34:40 +0000169 */
Forest Bond92b96792009-06-13 07:38:31 -0400170
Andres More0cbd8d92010-05-06 20:34:29 -0300171BOOL PSbConsiderPowerDown(void *hDeviceContext,
172 BOOL bCheckRxDMA,
173 BOOL bCheckCountToWakeUp)
Forest Bond92b96792009-06-13 07:38:31 -0400174{
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000175 PSDevice pDevice = (PSDevice)hDeviceContext;
176 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
177 BYTE byData;
Forest Bond92b96792009-06-13 07:38:31 -0400178
Philip Worrall7404eab2011-03-02 14:34:40 +0000179 /* check if already in Doze mode */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000180 ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG,
181 MAC_REG_PSCTL, &byData);
Forest Bond92b96792009-06-13 07:38:31 -0400182
Philip Worrallc5b0b5f2011-03-02 14:34:43 +0000183 if ((byData & PSCTL_PS) != 0)
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000184 return TRUE;
Forest Bond92b96792009-06-13 07:38:31 -0400185
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000186 if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
Philip Worrall7404eab2011-03-02 14:34:40 +0000187 /* check if in TIM wake period */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000188 if (pMgmt->bInTIMWake)
189 return FALSE;
190 }
Forest Bond92b96792009-06-13 07:38:31 -0400191
Philip Worrall7404eab2011-03-02 14:34:40 +0000192 /* check scan state */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000193 if (pDevice->bCmdRunning)
194 return FALSE;
Forest Bond92b96792009-06-13 07:38:31 -0400195
Philip Worrall7404eab2011-03-02 14:34:40 +0000196 /* Tx Burst */
Philip Worrallc5b0b5f2011-03-02 14:34:43 +0000197 if (pDevice->bPSModeTxBurst)
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000198 return FALSE;
Forest Bond92b96792009-06-13 07:38:31 -0400199
Philip Worrall7404eab2011-03-02 14:34:40 +0000200 /* Froce PSEN on */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000201 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_PSEN);
Forest Bond92b96792009-06-13 07:38:31 -0400202
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000203 if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) {
204 if (bCheckCountToWakeUp && (pMgmt->wCountToWakeUp == 0
205 || pMgmt->wCountToWakeUp == 1)) {
206 return FALSE;
207 }
208 }
Forest Bond92b96792009-06-13 07:38:31 -0400209
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000210 pDevice->bPSRxBeacon = TRUE;
Forest Bond92b96792009-06-13 07:38:31 -0400211
Philip Worrall7404eab2011-03-02 14:34:40 +0000212 /* no Tx, no Rx isr, now go to Doze */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000213 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_GO2DOZE);
214 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Go to Doze ZZZZZZZZZZZZZZZ\n");
215 return TRUE;
Forest Bond92b96792009-06-13 07:38:31 -0400216}
217
Philip Worrall7404eab2011-03-02 14:34:40 +0000218/*
Forest Bond92b96792009-06-13 07:38:31 -0400219 *
220 * Routine Description:
221 * Send PS-POLL packet
222 *
223 * Return Value:
224 * None.
225 *
Philip Worrall7404eab2011-03-02 14:34:40 +0000226 */
Forest Bond92b96792009-06-13 07:38:31 -0400227
Andres More0cbd8d92010-05-06 20:34:29 -0300228void PSvSendPSPOLL(void *hDeviceContext)
Forest Bond92b96792009-06-13 07:38:31 -0400229{
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000230 PSDevice pDevice = (PSDevice)hDeviceContext;
231 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
232 PSTxMgmtPacket pTxPacket = NULL;
Forest Bond92b96792009-06-13 07:38:31 -0400233
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000234 memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN);
235 pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
236 pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
237 pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16(
238 (
239 WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) |
240 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PSPOLL) |
241 WLAN_SET_FC_PWRMGT(0)
242 ));
Forest Bond92b96792009-06-13 07:38:31 -0400243
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000244 pTxPacket->p80211Header->sA2.wDurationID = pMgmt->wCurrAID | BIT14 | BIT15;
245 memcpy(pTxPacket->p80211Header->sA2.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
246 memcpy(pTxPacket->p80211Header->sA2.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
247 pTxPacket->cbMPDULen = WLAN_HDR_ADDR2_LEN;
248 pTxPacket->cbPayloadLen = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400249
Philip Worralle25b75e2011-03-02 14:34:42 +0000250 /* log failure if sending failed */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000251 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
252 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet failed..\n");
Philip Worralle25b75e2011-03-02 14:34:42 +0000253 }
Forest Bond92b96792009-06-13 07:38:31 -0400254}
255
Philip Worrall7404eab2011-03-02 14:34:40 +0000256/*
Forest Bond92b96792009-06-13 07:38:31 -0400257 *
258 * Routine Description:
259 * Send NULL packet to AP for notification power state of STA
260 *
261 * Return Value:
262 * None.
263 *
Philip Worrall7404eab2011-03-02 14:34:40 +0000264 */
Andres More0cbd8d92010-05-06 20:34:29 -0300265
266BOOL PSbSendNullPacket(void *hDeviceContext)
Forest Bond92b96792009-06-13 07:38:31 -0400267{
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000268 PSDevice pDevice = (PSDevice)hDeviceContext;
269 PSTxMgmtPacket pTxPacket = NULL;
270 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
Philip Worrallb898cf22011-03-02 17:36:35 +0000271 u16 flags = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400272
Philip Worrall036dba12011-03-02 14:34:41 +0000273 if (pDevice->bLinkPass == FALSE)
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000274 return FALSE;
Forest Bond92b96792009-06-13 07:38:31 -0400275
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000276 if ((pDevice->bEnablePSMode == FALSE) &&
Philip Worrall036dba12011-03-02 14:34:41 +0000277 (pDevice->fTxDataInSleep == FALSE)) {
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000278 return FALSE;
279 }
Forest Bond92b96792009-06-13 07:38:31 -0400280
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000281 memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN);
282 pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
283 pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
Forest Bond92b96792009-06-13 07:38:31 -0400284
Philip Worrallb898cf22011-03-02 17:36:35 +0000285 flags = WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
286 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL);
287
288 if (pDevice->bEnablePSMode)
289 flags |= WLAN_SET_FC_PWRMGT(1);
290 else
291 flags |= WLAN_SET_FC_PWRMGT(0);
292
293 pTxPacket->p80211Header->sA3.wFrameCtl = cpu_to_le16(flags);
Andres Morefeaf03d2010-06-25 20:20:58 -0300294
Philip Worrallc5b0b5f2011-03-02 14:34:43 +0000295 if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA)
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000296 pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((WORD)WLAN_SET_FC_TODS(1));
Forest Bond92b96792009-06-13 07:38:31 -0400297
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000298 memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
299 memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
300 memcpy(pTxPacket->p80211Header->sA3.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
301 pTxPacket->cbMPDULen = WLAN_HDR_ADDR3_LEN;
302 pTxPacket->cbPayloadLen = 0;
Philip Worralle25b75e2011-03-02 14:34:42 +0000303 /* log error if sending failed */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000304 if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
305 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n");
306 return FALSE;
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000307 }
Philip Worralle25b75e2011-03-02 14:34:42 +0000308 return TRUE;
Forest Bond92b96792009-06-13 07:38:31 -0400309}
310
Philip Worrall7404eab2011-03-02 14:34:40 +0000311/*
Forest Bond92b96792009-06-13 07:38:31 -0400312 *
313 * Routine Description:
314 * Check if Next TBTT must wake up
315 *
316 * Return Value:
317 * None.
318 *
Philip Worrall7404eab2011-03-02 14:34:40 +0000319 */
Forest Bond92b96792009-06-13 07:38:31 -0400320
Andres More0cbd8d92010-05-06 20:34:29 -0300321BOOL PSbIsNextTBTTWakeUp(void *hDeviceContext)
Forest Bond92b96792009-06-13 07:38:31 -0400322{
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000323 PSDevice pDevice = (PSDevice)hDeviceContext;
324 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
325 BOOL bWakeUp = FALSE;
Forest Bond92b96792009-06-13 07:38:31 -0400326
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000327 if (pMgmt->wListenInterval >= 2) {
Philip Worrall036dba12011-03-02 14:34:41 +0000328 if (pMgmt->wCountToWakeUp == 0)
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000329 pMgmt->wCountToWakeUp = pMgmt->wListenInterval;
Forest Bond92b96792009-06-13 07:38:31 -0400330
Philip Worrallc5b0b5f2011-03-02 14:34:43 +0000331 pMgmt->wCountToWakeUp--;
Forest Bond92b96792009-06-13 07:38:31 -0400332
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000333 if (pMgmt->wCountToWakeUp == 1) {
Philip Worrall7404eab2011-03-02 14:34:40 +0000334 /* Turn on wake up to listen next beacon */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000335 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_LNBCN);
336 pDevice->bPSRxBeacon = FALSE;
337 bWakeUp = TRUE;
Philip Worrallc5b0b5f2011-03-02 14:34:43 +0000338 } else if (!pDevice->bPSRxBeacon) {
Philip Worrall7404eab2011-03-02 14:34:40 +0000339 /* Listen until RxBeacon */
Philip Worrallf9cfbe92011-03-02 14:34:39 +0000340 MACvRegBitsOn(pDevice, MAC_REG_PSCTL, PSCTL_LNBCN);
341 }
342 }
343 return bWakeUp;
Forest Bond92b96792009-06-13 07:38:31 -0400344}
345