blob: 38b8a3ff51a43da8a126da3f277761a21bf0b688 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Satyanarayana Dash6f438272015-03-03 18:01:06 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Jeff Johnson295189b2012-06-20 16:38:30 -070020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
Jeff Johnson295189b2012-06-20 16:38:30 -070022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file pmmApi.cc contains functions related to the API exposed
30 * by power management module
31 *
32 * Author: Sandesh Goel
33 * Date: 02/25/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 *
38 */
39
40#include "palTypes.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053041#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042
43#include "sirCommon.h"
44#include "aniGlobal.h"
45
46#include "schApi.h"
47#include "limApi.h"
48#include "limSendMessages.h"
49#include "cfgApi.h"
50#include "limSessionUtils.h"
51#include "limFT.h"
52
53
54#include "pmmApi.h"
55#include "pmmDebug.h"
56#include "sirApi.h"
57#include "wmmApsd.h"
58
59#include "limSendSmeRspMessages.h"
60#include "limTimerUtils.h"
61#include "limTrace.h"
62#include "limUtils.h"
63#include "VossWrapper.h"
64#ifdef INTEGRATION_READY
65#include "vos_status.h" //VOS_STATUS
66#include "vos_mq.h" //vos_mq_post_message()
67#endif
68
69#include "wlan_qct_wda.h"
70
Mukul Sharma7c86d712014-03-21 15:43:09 +053071#define LIM_ADMIT_MASK_FLAG_ACBE 1
72#define LIM_ADMIT_MASK_FLAG_ACBK 2
73#define LIM_ADMIT_MASK_FLAG_ACVI 4
74#define LIM_ADMIT_MASK_FLAG_ACVO 8
75
Jeff Johnson295189b2012-06-20 16:38:30 -070076// --------------------------------------------------------------------
77/**
78 * pmmInitialize
79 *
80 * FUNCTION:
81 * Initialize PMM module
82 *
83 * LOGIC:
84 *
85 * ASSUMPTIONS:
86 *
87 * NOTE:
88 *
89 * @param mode
90 * @param rate
91 * @return None
92 */
93
94tSirRetStatus
95pmmInitialize(tpAniSirGlobal pMac)
96{
97
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99 pmmResetStats(pMac);
100
101 pMac->pmm.gPmmBeaconInterval = WNI_CFG_BEACON_INTERVAL_STADEF;
102 pMac->pmm.gPmmState = ePMM_STATE_READY;
103
104
Jeff Johnson295189b2012-06-20 16:38:30 -0700105
106 pMac->pmm.inMissedBeaconScenario = FALSE;
107
108 return eSIR_SUCCESS;
109}
110
111// --------------------------------------------------------------------
112/**
113 * pmmResetStats
114 *
115 * FUNCTION:
116 * Resets the statistics
117 *
118 * LOGIC:
119 *
120 * ASSUMPTIONS:
121 *
122 * NOTE:
123 *
124 * @param pMac
125 *
126 * @return None
127 */
128
129void
130pmmResetStats(void *pvMac)
131{
132 tpAniSirGlobal pMac = (tpAniSirGlobal)pvMac;
133
134 pMac->pmm.BmpsmaxSleepTime = 0;
135 pMac->pmm.BmpsavgSleepTime = 0;
136 pMac->pmm.BmpsminSleepTime = 0;
137 pMac->pmm.BmpscntSleep = 0;
138
139 pMac->pmm.BmpsmaxTimeAwake = 0;
140 pMac->pmm.BmpsavgTimeAwake = 0;
141 pMac->pmm.BmpsminTimeAwake = 0;
142 pMac->pmm.BmpscntAwake = 0;
143
144 pMac->pmm.BmpsWakeupTimeStamp = 0;
145 pMac->pmm.BmpsSleepTimeStamp = 0;
146
147 pMac->pmm.BmpsHalReqFailCnt = 0;
148 pMac->pmm.BmpsInitFailCnt = 0;
149 pMac->pmm.BmpsInitFailCnt= 0;
150 pMac->pmm.BmpsInvStateCnt= 0;
151 pMac->pmm.BmpsPktDrpInSleepMode= 0;
152 pMac->pmm.BmpsReqInInvalidRoleCnt= 0;
153 pMac->pmm.BmpsSleeReqFailCnt= 0;
154 pMac->pmm.BmpsWakeupIndCnt= 0;
155
156 pMac->pmm.ImpsWakeupTimeStamp = 0;
157 pMac->pmm.ImpsSleepTimeStamp = 0;
158 pMac->pmm.ImpsMaxTimeAwake = 0;
159 pMac->pmm.ImpsMinTimeAwake = 0;
160 pMac->pmm.ImpsAvgTimeAwake = 0;
161 pMac->pmm.ImpsCntAwake = 0;
162
163 pMac->pmm.ImpsCntSleep = 0;
164 pMac->pmm.ImpsMaxSleepTime = 0;
165 pMac->pmm.ImpsMinSleepTime = 0;
166 pMac->pmm.ImpsAvgSleepTime = 0;
167
168 pMac->pmm.ImpsSleepErrCnt = 0;
169 pMac->pmm.ImpsWakeupErrCnt = 0;
170 pMac->pmm.ImpsLastErr = 0;
171 pMac->pmm.ImpsInvalidStateCnt = 0;
172
173 return;
174}
175
176
177
178// --------------------------------------------------------------------
179/**
180 * pmmInitBmpsResponseHandler
181 *
182 * FUNCTION:
183 * This function processes the SIR_HAL_ENTER_BMPS_RSP from HAL.
184 * If the response is successful, it puts PMM in ePMM_STATE_BMP_SLEEP state
185 * and sends back success response to PMC.
186 *
187 * LOGIC:
188 *
189 * ASSUMPTIONS:
190 *
191 * NOTE:
192 *
193 * @param
194 * @return None
195 */
196
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700197void pmmInitBmpsResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -0700198{
199
200
201 tPmmState nextState = pMac->pmm.gPmmState;
202 tSirResultCodes retStatus = eSIR_SME_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700203 tpPESession psessionEntry;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700204 tpEnterBmpsParams pEnterBmpsParams;
Jeff Johnson295189b2012-06-20 16:38:30 -0700205
206 /* we need to process all the deferred messages enqueued since
207 * the initiating the SIR_HAL_ENTER_BMPS_REQ.
208 */
209 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
210
211 if(pMac->pmm.gPmmState != ePMM_STATE_BMPS_WT_INIT_RSP)
212 {
213 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700214 FL("pmmBmps: Received 'InitPwrSaveRsp' while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 pMac->pmm.gPmmState);)
216
217 retStatus = eSIR_SME_INVALID_PMM_STATE;
218 pmmBmpsUpdateInvalidStateCnt(pMac);
219 goto failure;
220 }
221
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700222 if (NULL == limMsg->bodyptr)
223 {
224 PELOGE(pmmLog(pMac, LOGE, FL("pmmBmps: Received SIR_HAL_ENTER_BMPS_RSP with NULL "));)
225 goto failure;
226 }
227 pEnterBmpsParams = (tpEnterBmpsParams)(limMsg->bodyptr);
228
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 //if response is success, then set PMM to BMPS_SLEEP state and send response back to PMC.
230 //If response is failure, then send the response back to PMC and reset its state.
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700231 if(pEnterBmpsParams->status == eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 {
Abhishek Singh525045c2014-12-15 17:18:45 +0530233 pmmLog(pMac, LOG1,
234 FL("pmmBmps: Received successful response from HAL to enter BMPS_POWER_SAVE "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
236 pMac->pmm.gPmmState = ePMM_STATE_BMPS_SLEEP;
237
238 // Update sleep statistics
239 pmmUpdatePwrSaveStats(pMac);
240
241 // Disable background scan mode
242 pMac->sys.gSysEnableScanMode = false;
243
244 if (pMac->lim.gLimTimersCreated)
245 {
246 /* Disable heartbeat timer as well */
247 if(pMac->lim.limTimers.gLimHeartBeatTimer.pMac)
248 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700249 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, NO_SESSION, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 tx_timer_deactivate(&pMac->lim.limTimers.gLimHeartBeatTimer);
251 }
252 }
253 limSendSmeRsp(pMac, eWNI_PMC_ENTER_BMPS_RSP, retStatus, 0, 0);
254 }
255 else
256 {
257 //if init req failed, then go back to WAKEUP state.
258 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700259 FL("pmmBmps: BMPS_INIT_PWR_SAVE_REQ failed, informing SME"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700260
261 pmmBmpsUpdateInitFailureCnt(pMac);
262 nextState = ePMM_STATE_BMPS_WAKEUP;
263 retStatus = eSIR_SME_BMPS_REQ_FAILED;
264 goto failure;
265 }
266 return;
267
268failure:
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700269 psessionEntry = peGetValidPowerSaveSession(pMac);
270 if(psessionEntry != NULL)
271 {
272 if (pMac->lim.gLimTimersCreated && pMac->lim.limTimers.gLimHeartBeatTimer.pMac)
273 {
274 if(VOS_TRUE != tx_timer_running(&pMac->lim.limTimers.gLimHeartBeatTimer))
275 {
276 PELOGE(pmmLog(pMac, LOGE, FL("Unexpected heartbeat timer not running"));)
277 limReactivateHeartBeatTimer(pMac, psessionEntry);
278 }
279 }
280 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
282 //Generate an error response back to PMC
283 pMac->pmm.gPmmState = nextState;
284 pmmBmpsUpdateSleepReqFailureCnt(pMac);
285 limSendSmeRsp(pMac, eWNI_PMC_ENTER_BMPS_RSP, retStatus, 0, 0);
286 return;
287
288}
289
290// --------------------------------------------------------------------
291/**
292 * pmmExitBmpsRequestHandler
293 *
294 * FUNCTION:
295 * This function will send the wakeup message to HAL
296 *
297 * LOGIC:
298 *
299 * ASSUMPTIONS:
300 *
301 * NOTE:
302 *
303 * @param pMac pointer to Global Mac structure.
304
305 * @return None
306 */
307
308void pmmExitBmpsRequestHandler(tpAniSirGlobal pMac, tpExitBmpsInfo pExitBmpsInfo)
309{
310 tSirResultCodes respStatus = eSIR_SME_SUCCESS;
311
312 tPmmState origState = pMac->pmm.gPmmState;
313
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 if (NULL == pExitBmpsInfo)
315 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700316 respStatus = eSIR_SME_BMPS_REQ_REJECT;
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700317 PELOGW(pmmLog(pMac, LOGW, FL("pmmBmps: Rcvd EXIT_BMPS with NULL body"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 goto failure;
319 }
320
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -0700321#ifdef FEATURE_WLAN_DIAG_SUPPORT
322 limDiagEventReport(pMac, WLAN_PE_DIAG_EXIT_BMPS_REQ_EVENT,
323 peGetValidPowerSaveSession(pMac), 0,
324 (tANI_U16)pExitBmpsInfo->exitBmpsReason);
325#endif //FEATURE_WLAN_DIAG_SUPPORT
326
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 /* PMC is not aware of Background scan, which is done in
328 * BMPS mode while Nth Beacon is delivered. Essentially, PMC
329 * can request the device to get out of power-save while
330 * background scanning is happening. since, the device is already
331 * out of powersave, just inform that device is out of powersave
332 */
333 if(limIsSystemInScanState(pMac))
334 {
335 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700336 FL("pmmBmps: Device is already awake and scanning, returning success to PMC "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 limSendSmeRsp(pMac, eWNI_PMC_EXIT_BMPS_RSP, respStatus, 0, 0);
338 return;
339 }
340
341 /* send wakeup request, only when in sleep state */
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700342 PELOGW(pmmLog(pMac, LOGW, FL("pmmBmps: Sending eWNI_PMC_EXIT_BMPS_REQ to HAL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 if (pMac->pmm.gPmmState == ePMM_STATE_BMPS_SLEEP)
344 {
345 /* Store the reason code for exiting BMPS. This value will be
346 * checked when PMM receives SIR_HAL_EXIT_BMPS_RSP from HAL
347 */
348 pMac->pmm.gPmmExitBmpsReasonCode = pExitBmpsInfo->exitBmpsReason;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530349 vos_mem_free(pExitBmpsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350
351 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700352 FL("pmmBmps: Rcvd EXIT_BMPS with reason code%d "), pMac->pmm.gPmmExitBmpsReasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700353
354
355 // Set PMM to BMPS_WT_WAKEUP_RSP state
356 pMac->pmm.gPmmState = ePMM_STATE_BMPS_WT_WAKEUP_RSP;
357 if(pmmSendChangePowerSaveMsg(pMac) != eSIR_SUCCESS)
358 {
359 /* Wakeup request failed */
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700360 respStatus = eSIR_SME_BMPS_REQ_REJECT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 pmmBmpsUpdateHalReqFailureCnt(pMac);
362 goto failure;
363 }
364 else
365 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530366 pmmLog(pMac, LOG1,
367 FL("pmmBmps: eWNI_PMC_EXIT_BMPS_REQ was successfully sent to HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 }
369 }
370 else
371 {
372 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700373 FL("pmmBmps: eWNI_PMC_EXIT_BMPS_REQ received in invalid state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 pMac->pmm.gPmmState );)
375
376 respStatus = eSIR_SME_INVALID_PMM_STATE;
377 pmmBmpsUpdateInvalidStateCnt(pMac);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530378 vos_mem_free(pExitBmpsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 goto failure;
380 }
381 return;
382
383failure:
384 pMac->pmm.gPmmState = origState;
385 pmmBmpsUpdateWakeupReqFailureCnt(pMac);
386 limSendSmeRsp(pMac, eWNI_PMC_EXIT_BMPS_RSP, respStatus, 0, 0);
387}
388
389
390// --------------------------------------------------------------------
391/**
392 * pmmInitBmpsPwrSave
393 *
394 * FUNCTION:
395 * This function process the eWNI_PMC_ENTER_PMC_REQ from PMC.
396 * It checks for certain conditions before it puts PMM into
397 * BMPS power save state: ePMM_STATE_BMPS_WT_INIT_RSP
398 * It also invokes pmmSendInitPowerSaveMsg() to send ENTER_BMPS_REQ
399 * to HAL.
400 *
401 * LOGIC:
402 *
403 * ASSUMPTIONS:
404 *
405 * NOTE:
406 *
407 * @param mode can be either 0(sleep mode) or 1 (active mode)
408 * @param pMac pointer to Global Mac structure.
409
410 * @return None
411 */
412
413
414void pmmInitBmpsPwrSave(tpAniSirGlobal pMac)
415{
416 tSirRetStatus retStatus = eSIR_SUCCESS;
417 tSirResultCodes respStatus = eSIR_SME_SUCCESS;
418 tpPESession psessionEntry;
419
420 tPmmState origState = pMac->pmm.gPmmState;
421
422 if((psessionEntry = peGetValidPowerSaveSession(pMac))== NULL)
423 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700424 respStatus = eSIR_SME_BMPS_REQ_REJECT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 goto failure;
426 }
Yathish9f22e662012-12-10 14:21:35 -0800427#ifndef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
Madan Mohan Koyyalamudia84edda2012-10-15 14:58:25 -0700428 // sending beacon filtering information down to HAL
429 if (limSendBeaconFilterInfo(pMac, psessionEntry) != eSIR_SUCCESS)
430 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700431 pmmLog(pMac, LOGE, FL("Fail to send Beacon Filter Info "));
Madan Mohan Koyyalamudia84edda2012-10-15 14:58:25 -0700432 }
Gopichand Nakkala13675ce2013-03-04 12:28:06 +0530433#else
434 if(!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
435 {
436 if (limSendBeaconFilterInfo(pMac, psessionEntry) != eSIR_SUCCESS)
437 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700438 pmmLog(pMac, LOGE, FL("Fail to send Beacon Filter Info "));
Gopichand Nakkala13675ce2013-03-04 12:28:06 +0530439 }
440 }
Yathish9f22e662012-12-10 14:21:35 -0800441#endif
Madan Mohan Koyyalamudia84edda2012-10-15 14:58:25 -0700442
Jeff Johnson295189b2012-06-20 16:38:30 -0700443#ifdef FEATURE_WLAN_DIAG_SUPPORT
444 limDiagEventReport(pMac, WLAN_PE_DIAG_ENTER_BMPS_REQ_EVENT, psessionEntry, 0, 0);
445#endif //FEATURE_WLAN_DIAG_SUPPORT
446
447 if ( ((pMac->pmm.gPmmState != ePMM_STATE_READY) &&
448 (pMac->pmm.gPmmState != ePMM_STATE_BMPS_WAKEUP)) ||
449 limIsSystemInScanState(pMac) ||
Jeff Johnsone7245742012-09-05 17:12:55 -0700450 limIsChanSwitchRunning(pMac) ||
451 limIsInQuietDuration(pMac) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 {
453 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700454 FL("pmmBmps: BMPS Request received in invalid state PMM=%d, SME=%d, rejecting the initpwrsave request"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 pMac->pmm.gPmmState, pMac->lim.gLimSmeState);)
456
457 respStatus = eSIR_SME_INVALID_PMM_STATE;
458 pmmBmpsUpdateInvalidStateCnt(pMac);
459 goto failure;
460 }
461
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700462 //If we are in a missed beacon scenario, we should not be attempting to enter BMPS as heartbeat probe is going on
463 if(pMac->pmm.inMissedBeaconScenario)
464 {
465 if (pMac->lim.gLimTimersCreated && pMac->lim.limTimers.gLimHeartBeatTimer.pMac)
466 {
467 if(VOS_TRUE != tx_timer_running(&pMac->lim.limTimers.gLimHeartBeatTimer))
468 {
469 PELOGE(pmmLog(pMac, LOGE, FL("Unexpected heartbeat timer not running"));)
470 limReactivateHeartBeatTimer(pMac, psessionEntry);
471 }
472 }
473 respStatus = eSIR_SME_BMPS_REQ_REJECT;
474 goto failure;
475 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700476
477 /* At this point, device is associated and PMM is not in BMPS_SLEEP state.
478 * Heartbeat timer not running is an indication that PE have detected a
479 * loss of link. In this case, reject BMPS request.
480 */
481 /* TODO : We need to have a better check. This check is not valid */
482#if 0
483 if ( (pMac->sys.gSysEnableLinkMonitorMode) && (pMac->lim.limTimers.gLimHeartBeatTimer.pMac) )
484 {
485 if(VOS_TRUE != tx_timer_running(&pMac->lim.limTimers.gLimHeartBeatTimer))
486 {
487 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700488 FL("Reject BMPS_REQ because HeartBeatTimer is not running. "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 respStatus = eSIR_SME_BMPS_REQ_FAILED;
490 goto failure;
491 }
492 }
493#endif
494
495 //If the following function returns SUCCESS, then PMM will wait for an explicit
496 //response message from softmac.
497
498 //changing PMM state before posting message to HAL, as this is a synchronous call to HAL
499 pMac->pmm.gPmmState = ePMM_STATE_BMPS_WT_INIT_RSP;
500 if((retStatus = pmmSendInitPowerSaveMsg(pMac,psessionEntry)) != eSIR_SUCCESS)
501 {
502 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700503 FL("pmmBmps: Init Power Save Request Failed: Sending Response: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 retStatus);)
505
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700506 respStatus = eSIR_SME_BMPS_REQ_REJECT;
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 pmmBmpsUpdateHalReqFailureCnt(pMac);
508 goto failure;
509 }
510 //Update the powerSave sessionId
511 pMac->pmm.sessionId = psessionEntry->peSessionId;
512 return;
513
514failure:
515
516 // Change the state back to original state
517 pMac->pmm.gPmmState =origState;
518 limSendSmeRsp(pMac, eWNI_PMC_ENTER_BMPS_RSP, respStatus, 0, 0);
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +0530519
520 // update the BMPS pwr save Error Stats
521 pmmBmpsUpdateSleepReqFailureCnt(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 return;
523}
524
525
526/**
527 * pmmSendChangePowerSaveMsg()
528 *
529 *FUNCTION:
530 * This function is called to send SIR_HAL_EXIT_BMPS_REQ to HAL.
531 * This message will trigger HAL to program HW to wake up.
532 *
533 *LOGIC:
534 *
535 *ASSUMPTIONS:
536 * NA
537 *
538 *NOTE:
539 * NA
540 *
541 * @param pMac pointer to Global Mac structure.
542 * @return success if message send is ok, else false.
543 */
544tSirRetStatus pmmSendChangePowerSaveMsg(tpAniSirGlobal pMac)
545{
546 tSirRetStatus retStatus = eSIR_SUCCESS;
547 tpExitBmpsParams pExitBmpsParams;
548 tSirMsgQ msgQ;
Jeff Johnsone7245742012-09-05 17:12:55 -0700549 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 tANI_U8 currentOperatingChannel = limGetCurrentOperatingChannel(pMac);
551
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530552 pExitBmpsParams = vos_mem_malloc(sizeof(*pExitBmpsParams));
553 if ( NULL == pExitBmpsParams )
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530555 pmmLog(pMac, LOGW, FL("Failed to allocate memory"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 retStatus = eSIR_MEM_ALLOC_FAILED;
557 return retStatus;
558 }
559
Jeff Johnsone7245742012-09-05 17:12:55 -0700560 if((psessionEntry = peGetValidPowerSaveSession(pMac)) == NULL )
561 {
562 retStatus = eSIR_FAILURE;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530563 vos_mem_free(pExitBmpsParams);
Jeff Johnsone7245742012-09-05 17:12:55 -0700564 return retStatus;
565 }
566
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530567 vos_mem_set( (tANI_U8 *)pExitBmpsParams, sizeof(*pExitBmpsParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 msgQ.type = WDA_EXIT_BMPS_REQ;
569 msgQ.reserved = 0;
570 msgQ.bodyptr = pExitBmpsParams;
571 msgQ.bodyval = 0;
572
573 /* If reason for full power is disconnecting (ie. link is
574 * disconnected) or becasue of channel switch or full power requested
575 * because of beacon miss and connected on DFS channel
576 * then we should not send data null.
577 * For all other reason code, send data null.
578 */
579 if ( !(SIR_IS_FULL_POWER_REASON_DISCONNECTED(pMac->pmm.gPmmExitBmpsReasonCode) ||
580 ( (eSME_MISSED_BEACON_IND_RCVD == pMac->pmm.gPmmExitBmpsReasonCode) &&
581 limIsconnectedOnDFSChannel(currentOperatingChannel))))
582 pExitBmpsParams->sendDataNull = 1;
583
Jeff Johnsone7245742012-09-05 17:12:55 -0700584 pExitBmpsParams->bssIdx = psessionEntry->bssIdx;
585
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 /* we need to defer any incoming messages until we
587 * get a WDA_EXIT_BMPS_RSP from HAL.
588 */
589 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -0700590 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 retStatus = wdaPostCtrlMsg( pMac, &msgQ);
592 if( eSIR_SUCCESS != retStatus )
593 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700594 PELOGE(pmmLog( pMac, LOGE, FL("Sending WDA_EXIT_BMPS_REQ failed, reason=%X "), retStatus );)
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530595 vos_mem_free(pExitBmpsParams);
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 return retStatus;
597 }
598
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530599 pmmLog(pMac, LOG1, FL("WDA_EXIT_BMPS_REQ has been successfully sent to HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 return retStatus;
601}
602
603
604/**
605 * pmmSendInitPowerSaveMsg()
606 *
607 *FUNCTION:
608 * This function is called to send ENTER_BMPS_REQ message to HAL.
609 * This message is sent to intialize the process of bringing the
610 * station into power save state.
611 *
612 *LOGIC:
613 *
614 *ASSUMPTIONS:
615 * NA
616 *
617 *NOTE:
618 * NA
619 *
620 * @param pMac pointer to Global Mac structure.
621 * @param mode The Power Save or Active State
622 *
623 * @return success if message send is ok, else false.
624 */
625
626tSirRetStatus pmmSendInitPowerSaveMsg(tpAniSirGlobal pMac,tpPESession psessionEntry)
627{
628 tSirRetStatus retCode = eSIR_SUCCESS;
629 tSirMsgQ msgQ;
630 tpEnterBmpsParams pBmpsParams = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 tANI_U32 rssiFilterPeriod = 5;
Srinivas Girigowdaba173692013-08-07 11:55:38 -0700632 tANI_U32 numBeaconPerRssiAverage = 20;
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 tANI_U32 bRssiFilterEnable = FALSE;
634
Tushnim Bhattacharyyafe9feb72013-03-28 17:34:45 -0700635 if(psessionEntry->currentBssBeaconCnt == 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700637 PELOGE(pmmLog( pMac, LOGE, FL("Beacon count is zero, can not retrieve the TSF, failing the Enter Bmps Request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 return eSIR_FAILURE;
639 }
640
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530641 pBmpsParams = vos_mem_malloc(sizeof(tEnterBmpsParams));
642 if ( NULL == pBmpsParams )
Jeff Johnson295189b2012-06-20 16:38:30 -0700643 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700644 pmmLog(pMac, LOGP, "PMM: Not able to allocate memory for Enter Bmps");
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 return eSIR_FAILURE;
646 }
647
648 pMac->pmm.inMissedBeaconScenario = FALSE;
649 pBmpsParams->respReqd = TRUE;
650
651 pBmpsParams->tbtt = psessionEntry->lastBeaconTimeStamp;
652 pBmpsParams->dtimCount = psessionEntry->lastBeaconDtimCount;
653 pBmpsParams->dtimPeriod = psessionEntry->lastBeaconDtimPeriod;
654 pBmpsParams->bssIdx = psessionEntry->bssIdx;
655
Srinivas Girigowdaba173692013-08-07 11:55:38 -0700656 /* TODO: Config parameters (Rssi filter period, FW RSSI Monitoring
657 and Number of beacons per RSSI average) values sent down to FW during
658 initial exchange (driver load) is same as ENTER_BMPS_REQ.
659 Sending these values again in ENTER_BMPS_REQ is not required
660 (can be removed). This is kept as-is for now to support
661 backward compatibility with the older host running on new FW. */
662
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 if(wlan_cfgGetInt(pMac, WNI_CFG_RSSI_FILTER_PERIOD, &rssiFilterPeriod) != eSIR_SUCCESS)
664 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for Rssi filter period"));
Srinivas Girigowdaba173692013-08-07 11:55:38 -0700665 pBmpsParams->rssiFilterPeriod = (tANI_U8)rssiFilterPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 if(wlan_cfgGetInt(pMac, WNI_CFG_PS_ENABLE_RSSI_MONITOR, &bRssiFilterEnable) != eSIR_SUCCESS)
668 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for Rssi monitor enable flag"));
669 pBmpsParams->bRssiFilterEnable = bRssiFilterEnable;
670
Srinivas Girigowdaba173692013-08-07 11:55:38 -0700671 /* The numBeaconPerRssiAverage should be less than
672 the max allowed (default set to 20 in CFG) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 if(wlan_cfgGetInt(pMac, WNI_CFG_NUM_BEACON_PER_RSSI_AVERAGE, &numBeaconPerRssiAverage) != eSIR_SUCCESS)
674 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for num beacon per rssi"));
675
Srinivas Girigowdade697412013-02-14 16:31:48 -0800676 pBmpsParams->numBeaconPerRssiAverage =
Pratik Bhalgat7177d332012-11-22 17:27:33 +0530677 (tANI_U8)GET_MIN_VALUE((tANI_U8) numBeaconPerRssiAverage, WNI_CFG_NUM_BEACON_PER_RSSI_AVERAGE_STAMAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700678
679 pmmLog (pMac, LOG1,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700680 "%s: [INFOLOG]RssiFilterInfo..%d %x %x", __func__, (int)pBmpsParams->bRssiFilterEnable,
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 (unsigned int)pBmpsParams->rssiFilterPeriod, (unsigned int)pBmpsParams->numBeaconPerRssiAverage);
682
683 msgQ.type = WDA_ENTER_BMPS_REQ;
684 msgQ.reserved = 0;
685 msgQ.bodyptr = pBmpsParams;
686 msgQ.bodyval = 0;
687
Abhishek Singh525045c2014-12-15 17:18:45 +0530688 pmmLog( pMac, LOG1,
689 FL( "pmmBmps: Sending WDA_ENTER_BMPS_REQ" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
691 /* we need to defer any incoming messages until we get a
692 * WDA_ENTER_BMPS_RSP from HAL.
693 */
694 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
695
Jeff Johnsone7245742012-09-05 17:12:55 -0700696 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
698 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530699 vos_mem_free(pBmpsParams);
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 PELOGE(pmmLog( pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700701 FL("Posting WDA_ENTER_BMPS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 retCode );)
703 }
704
705 return retCode;
706}
707
708/**
709 * pmmSendPowerSaveCfg()
710 *
711 *FUNCTION:
712 * This function is called to send power save configurtion.
713 *
714 *NOTE:
715 *
716 * @param pMac pointer to Global Mac structure.
717 * @param mode The Power Save or Active State
718 *
719 * @return success if message send is ok, else false.
720 */
721tSirRetStatus pmmSendPowerSaveCfg(tpAniSirGlobal pMac, tpSirPowerSaveCfg pUpdatedPwrSaveCfg)
722{
723 tSirRetStatus retCode = eSIR_SUCCESS;
724 tSirMsgQ msgQ;
725 tANI_U32 listenInterval;
726 tANI_U32 HeartBeatCount = 1;
727 tANI_U32 maxPsPoll;
728 tANI_U32 numBeaconPerRssiAverage;
729 tANI_U32 minRssiThreshold;
730 tANI_U32 nthBeaconFilter;
731 tANI_U32 broadcastFrameFilter;
732 tANI_U32 rssiFilterPeriod;
733 tANI_U32 ignoreDtim;
734
735 if (NULL == pUpdatedPwrSaveCfg)
736 goto returnFailure;
737
738 if(pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE )
739 {
740 pmmLog(pMac, LOGE,
Jeff Johnsone7245742012-09-05 17:12:55 -0700741 FL("pmmCfg: Power Save Configuration received in invalid global sme state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 pMac->lim.gLimSmeState);
743 retCode = eSIR_SME_INVALID_STATE;
744 goto returnFailure;
745 }
746
747 // Get power save configuration CFG values
748 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
749 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for listen interval"));
750 pUpdatedPwrSaveCfg->listenInterval = (tANI_U16)listenInterval;
751
752 if(wlan_cfgGetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, &HeartBeatCount) != eSIR_SUCCESS)
753 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for heart beat thresh"));
754
755 pMac->lim.gLimHeartBeatCount = HeartBeatCount;
756 pUpdatedPwrSaveCfg->HeartBeatCount = HeartBeatCount;
757
758 if(wlan_cfgGetInt(pMac, WNI_CFG_NTH_BEACON_FILTER, &nthBeaconFilter) != eSIR_SUCCESS)
759 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for Nth beacon filter"));
760 pUpdatedPwrSaveCfg->nthBeaconFilter = nthBeaconFilter;
761
762 if(wlan_cfgGetInt(pMac, WNI_CFG_MAX_PS_POLL, &maxPsPoll) != eSIR_SUCCESS)
763 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for max poll"));
764 pUpdatedPwrSaveCfg->maxPsPoll = maxPsPoll;
765
766 if(wlan_cfgGetInt(pMac, WNI_CFG_MIN_RSSI_THRESHOLD, &minRssiThreshold) != eSIR_SUCCESS)
767 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for min RSSI Threshold"));
768 pUpdatedPwrSaveCfg->minRssiThreshold = minRssiThreshold;
769
770 if(wlan_cfgGetInt(pMac, WNI_CFG_NUM_BEACON_PER_RSSI_AVERAGE, &numBeaconPerRssiAverage) != eSIR_SUCCESS)
771 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for num beacon per rssi"));
772 pUpdatedPwrSaveCfg->numBeaconPerRssiAverage = (tANI_U8) numBeaconPerRssiAverage;
773
774 if(wlan_cfgGetInt(pMac, WNI_CFG_RSSI_FILTER_PERIOD, &rssiFilterPeriod) != eSIR_SUCCESS)
775 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for Rssi filter period"));
776 pUpdatedPwrSaveCfg->rssiFilterPeriod = (tANI_U8) rssiFilterPeriod;
777
778 if(wlan_cfgGetInt(pMac, WNI_CFG_BROADCAST_FRAME_FILTER_ENABLE, &broadcastFrameFilter) != eSIR_SUCCESS)
779 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for Nth beacon filter"));
780 pUpdatedPwrSaveCfg->broadcastFrameFilter = (tANI_U8) broadcastFrameFilter;
781
782 if(wlan_cfgGetInt(pMac, WNI_CFG_IGNORE_DTIM, &ignoreDtim) != eSIR_SUCCESS)
783 pmmLog(pMac, LOGP, FL("pmmCfg: cfgGet failed for ignoreDtim"));
784 pUpdatedPwrSaveCfg->ignoreDtim = (tANI_U8) ignoreDtim;
785
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 //Save a copy of the CFG in global pmm context.
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530787 vos_mem_copy( (tANI_U8 *) &pMac->pmm.gPmmCfg, pUpdatedPwrSaveCfg, sizeof(tSirPowerSaveCfg));
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
789
790 msgQ.type = WDA_PWR_SAVE_CFG;
791 msgQ.reserved = 0;
792 msgQ.bodyptr = pUpdatedPwrSaveCfg;
793 msgQ.bodyval = 0;
794
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530795 pmmLog( pMac, LOG1, FL( "pmmBmps: Sending WDA_PWR_SAVE_CFG to HAL"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700796 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
798 {
799 pmmLog( pMac, LOGP,
800 FL("Posting WDA_PWR_SAVE_CFG to HAL failed, reason=%X"),
801 retCode );
802 goto returnFailure;
803 }
804 return retCode;
805
806returnFailure:
807
808 /* In case of failure, we need to free the memory */
809 if (NULL != pUpdatedPwrSaveCfg)
810 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530811 vos_mem_free(pUpdatedPwrSaveCfg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 }
813 return retCode;
814}
815
816/**
817 * pmmExitBmpsResponseHandler
818 *
819 *FUNCTION:
820 * This function processes the Wakeup Rsp from HAL and if successfull,
821 * sends a respnose back to PMC layer.
822 *LOGIC:
823 *
824 *ASSUMPTIONS:
825 * NA
826 *
827 *NOTE:
828 * NA
829 *
830 * @param pMac pointer to Global Mac structure.
831 * @param rspStatus Status of the response, Success or an error code.
832 *
833 * @return none.
834 */
835void pmmExitBmpsResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
836{
837 tpExitBmpsParams pExitBmpsRsp;
838 eHalStatus rspStatus;
839 tANI_U8 PowersavesessionId;
840 tpPESession psessionEntry;
841 tSirResultCodes retStatus = eSIR_SME_SUCCESS;
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +0530842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 /* Copy the power save sessionId to the local variable */
844 PowersavesessionId = pMac->pmm.sessionId;
845
846 /* we need to process all the deferred messages enqueued since
847 * the initiating the SIR_HAL_EXIT_BMPS_REQ.
848 */
849
850 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
851
852 if((psessionEntry = peFindSessionBySessionId(pMac,PowersavesessionId))==NULL)
853 {
Katya Nigam70d68332013-09-16 16:49:45 +0530854 pmmLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 return;
856 }
857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858
859 if (NULL == limMsg->bodyptr)
860 {
861 pmmLog(pMac, LOGE, FL("Received SIR_HAL_EXIT_BMPS_RSP with NULL "));
862 return;
863 }
864 pExitBmpsRsp = (tpExitBmpsParams)(limMsg->bodyptr);
865 rspStatus = pExitBmpsRsp->status;
866
867 if(pMac->pmm.gPmmState != ePMM_STATE_BMPS_WT_WAKEUP_RSP)
868 {
869 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700870 FL("Received SIR_HAL_EXIT_BMPS_RSP while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 pMac->pmm.gPmmState);)
872
873 retStatus = eSIR_SME_INVALID_PMM_STATE;
874 pmmBmpsUpdateInvalidStateCnt(pMac);
875 }
876 else
877 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700878 PELOGW(pmmLog(pMac, LOGW, FL("Received SIR_HAL_EXIT_BMPS_RSP in correct state. "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 }
880
881 /* PE is going to wakeup irrespective of whether
882 * SIR_HAL_EXIT_BMPS_REQ was successful or not
883 */
884 switch (rspStatus)
885 {
886 case eHAL_STATUS_SUCCESS:
887 retStatus = eSIR_SME_SUCCESS;
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +0530888 /* Update wakeup statistics */
889 pmmUpdateWakeupStats(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 break;
891
892 default:
893 {
894 /* PE is going to be awake irrespective of whether EXIT_BMPS_REQ
895 * failed or not. This is mainly to eliminate the dead-lock condition
896 * But, PMC will be informed about the error.
897 */
898 retStatus = eSIR_SME_BMPS_REQ_FAILED;
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +0530899 pmmBmpsUpdateWakeupReqFailureCnt(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 }
901 break;
902
903 }
904
905 pMac->pmm.gPmmState = ePMM_STATE_BMPS_WAKEUP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700906
907 // turn on background scan
908 pMac->sys.gSysEnableScanMode = true;
909
910 // send response to PMC
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700911 if(IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) )
Jeff Johnsone7245742012-09-05 17:12:55 -0700912 {
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +0530913 limSendSmeRsp(pMac, eWNI_PMC_EXIT_BMPS_RSP, retStatus,
Jeff Johnsone7245742012-09-05 17:12:55 -0700914 psessionEntry->smeSessionId, psessionEntry->transactionId);
915 }
916 else
917 {
918 limSendSmeRsp(pMac, eWNI_PMC_EXIT_BMPS_RSP, retStatus, 0, 0);
919 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700920
921 if ( pMac->pmm.gPmmExitBmpsReasonCode == eSME_MISSED_BEACON_IND_RCVD)
922 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700923 PELOGW(pmmLog(pMac, LOGW, FL("Rcvd SIR_HAL_EXIT_BMPS_RSP with MISSED_BEACON"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 pmmMissedBeaconHandler(pMac);
925 }
926 else if(pMac->pmm.inMissedBeaconScenario)
927 {
928 PELOGW(pmmLog(pMac, LOGW, FL("Rcvd SIR_HAL_EXIT_BMPS_RSP in missed beacon scenario but reason code not correct"));)
929 pmmMissedBeaconHandler(pMac);
930 }
931 else
932 {
933 // Enable heartbeat timer
934 limReactivateHeartBeatTimer(pMac, psessionEntry);
935 }
936 return;
937}
938
939
940/**
941 * pmmMissedBeaconHandler()
942 *
943 *FUNCTION:
944 * This function is called when PMM receives an eWNI_PMC_EXIT_BMPS_REQ
945 * with reason code being eSME_MISSED_BEACON_IND_RCVD.
946 *
947 *NOTE:
948 * @param pMac pointer to Global Mac structure.
949 * @return none
950 */
951void pmmMissedBeaconHandler(tpAniSirGlobal pMac)
952{
953 tANI_U8 pwrSaveSessionId;
954 tANI_U32 beaconInterval = 0;
955 tANI_U32 heartBeatInterval = pMac->lim.gLimHeartBeatCount;
956 tpPESession psessionEntry;
957
958 /* Copy the power save sessionId to the local variable */
959 pwrSaveSessionId = pMac->pmm.sessionId;
960
961 if((psessionEntry = peFindSessionBySessionId(pMac,pwrSaveSessionId))==NULL)
962 {
Katya Nigam70d68332013-09-16 16:49:45 +0530963 pmmLog(pMac, LOGE,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 return;
965 }
966
967
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700968 PELOGE(pmmLog(pMac, LOG1, FL("The device woke up due to MISSED BEACON "));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700969
970 /* Proceed only if HeartBeat timer is created */
971 if((pMac->lim.limTimers.gLimHeartBeatTimer.pMac) &&
972 (pMac->lim.gLimTimersCreated))
973 {
974 if (wlan_cfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &beaconInterval) != eSIR_SUCCESS)
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530975 pmmLog(pMac, LOG1, FL("Fail to get BEACON_INTERVAL value"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700976
977 /* Change timer to reactivate it in future */
978 heartBeatInterval= SYS_MS_TO_TICKS(beaconInterval * heartBeatInterval);
979
980 if( tx_timer_change(&pMac->lim.limTimers.gLimHeartBeatTimer,
981 (tANI_U32)heartBeatInterval, 0) != TX_SUCCESS)
982 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530983 pmmLog(pMac, LOG1, FL("Fail to change HeartBeat timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 }
985
986 /* update some statistics */
987 if(LIM_IS_CONNECTION_ACTIVE(psessionEntry))
988 {
989 if(psessionEntry->LimRxedBeaconCntDuringHB < MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL)
990 pMac->lim.gLimHeartBeatBeaconStats[psessionEntry->LimRxedBeaconCntDuringHB]++;
991 else
992 pMac->lim.gLimHeartBeatBeaconStats[0]++;
993 }
994
995 /* To handle the missed beacon failure, message is being posted to self as if the
996 * actual timer has expired. This is done to make sure that there exists one
997 * common entry and exit points
998 */
999 //limResetHBPktCount(pMac); // 090805: Where did this come from?
1000 limResetHBPktCount(psessionEntry); // 090805: This is what it SHOULD be. If we even need it.
1001 pmmSendMessageToLim(pMac, SIR_LIM_HEART_BEAT_TIMEOUT);
1002 }
1003 else
1004 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001005 PELOGE(pmmLog(pMac, LOGE, FL("HeartBeat Timer is not created, cannot re-activate"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 }
1007
1008 return;
1009}
1010
1011
1012/**
1013 * pmmExitBmpsIndicationHandler
1014 *
1015 *FUNCTION:
1016 * This function sends a Power Save Indication. back to PMC layer.
1017 * This indication is originated from softmac and will occur in the following two
1018 * scenarios:
1019 * 1) When softmac is in sleep state and wakes up to parse TIM and finds that
1020 * AP has the data pending for this STA, then it sends this indication to let PMC know
1021 * that it is going to be awake and pass the control over to PMC
1022 * 2) When softmac is in sleep state and wakes up to parse TIM and determines that
1023 * current TIM is DTIM and AP has buffered broadcast/multicast frames.
1024 * In this scenario, softmac needs to remain awake for broadcast/multicast frames and it
1025 * sends an indication to PMC that it is awake and passes the control over to PMC.
1026 * 3) If station is awake and 'fEnablePwrSaveImmediately' flag is set, then softmac will transmit all
1027 * frames in its queues and go to sleep. Before going to sleep it sends the notification to PMC that
1028 * it is going to sleep.
1029 *LOGIC:
1030 *
1031 *ASSUMPTIONS:
1032 * NA
1033 *
1034 *NOTE:
1035 * NA
1036 *
1037 * @param pMac pointer to Global Mac structure.
1038 * @param rspStatus Status of the response, Success or an error code.
1039 *
1040 * @return none.
1041 */
1042
1043void pmmExitBmpsIndicationHandler(tpAniSirGlobal pMac, tANI_U8 mode, eHalStatus rspStatus)
1044{
1045
1046 tANI_U32 beaconInterval = 0;
1047 tANI_U32 heartBeatInterval = pMac->lim.gLimHeartBeatCount;
1048 tANI_U8 powersavesessionId;
1049 tpPESession psessionEntry;
1050
1051 /* Copy the power save sessionId to the local variable */
1052 powersavesessionId = pMac->pmm.sessionId;
1053
1054 psessionEntry = peFindSessionBySessionId(pMac,powersavesessionId);
1055
1056 if(psessionEntry == NULL)
1057 {
Katya Nigam70d68332013-09-16 16:49:45 +05301058 PELOGE(pmmLog(pMac, LOGE,
1059 FL("Session does Not exist with given sessionId :%d "),powersavesessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 return;
1061 }
1062
1063 /* Since, the hardware is already wokenup, PE also wakesup and informs
1064 * the upper layers that the system is waking up. Hence always Success is
1065 * sent in the reason code for the message sent to PMC
1066 */
1067
1068 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001069 FL("pmmBmps: Received SIR_HAL_EXIT_BMPS_IND from HAL, Exiting BMPS sleep mode")); )
Jeff Johnson295189b2012-06-20 16:38:30 -07001070
1071
1072 pMac->pmm.gPmmState = ePMM_STATE_BMPS_WAKEUP;
1073 pmmUpdateWakeupStats(pMac);
1074
1075 /* turn on background scan */
1076 pMac->sys.gSysEnableScanMode = true;
1077
1078 pmmBmpsUpdateWakeupIndCnt(pMac);
1079
1080 /* Inform SME about the system awake state */
1081 limSendSmeRsp(pMac,
1082 eWNI_PMC_EXIT_BMPS_IND,
1083 eSIR_SME_SUCCESS, 0, 0);
1084
1085 switch(rspStatus)
1086 {
1087
1088 /* The SoftMAC sends wakeup indication even when Heart-Beat timer expired
1089 * The PE should start taking action against this as soon as it identifies
1090 * that the SoftMAC has identified heart-beat miss
1091 */
1092 case eHAL_STATUS_HEARTBEAT_TMOUT:
1093 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301094 pmmLog(pMac, LOG1,
1095 FL("pmmBmps: The device woke up due to HeartBeat Timeout"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001096
1097 /* Proceed only if HeartBeat timer is created */
1098 if((pMac->lim.limTimers.gLimHeartBeatTimer.pMac) &&
1099 (pMac->lim.gLimTimersCreated))
1100 {
1101
1102 /* Read the beacon interval from sessionTable */
1103 beaconInterval = psessionEntry->beaconParams.beaconInterval;
1104
1105 /* Change timer to reactivate it in future */
1106 heartBeatInterval= SYS_MS_TO_TICKS(beaconInterval * heartBeatInterval);
1107
1108 if(tx_timer_change(&pMac->lim.limTimers.gLimHeartBeatTimer,
1109 (tANI_U32)heartBeatInterval, 0) != TX_SUCCESS)
1110 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301111 pmmLog(pMac, LOG1,
1112 FL("pmmBmps: Unable to change HeartBeat timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 }
1114
1115 /* update some statistics */
1116 if(LIM_IS_CONNECTION_ACTIVE(psessionEntry))
1117 {
1118 if(psessionEntry->LimRxedBeaconCntDuringHB < MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL)
1119 pMac->lim.gLimHeartBeatBeaconStats[psessionEntry->LimRxedBeaconCntDuringHB]++;
1120 else
1121 pMac->lim.gLimHeartBeatBeaconStats[0]++;
1122 }
1123
1124 /* To handle the heartbeat failure, message is being posted to self as if the
1125 * actual timer has expired. This is done to make sure that there exists one
1126 * common entry and exit points
1127 */
1128 pmmSendMessageToLim(pMac, SIR_LIM_HEART_BEAT_TIMEOUT);
1129
1130 }
1131 else
1132 {
1133
1134 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001135 FL("pmmBmps: HeartBeat Timer is not created, cannot re-activate"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 }
1137 }
1138 break;
1139
1140 case eHAL_STATUS_NTH_BEACON_DELIVERY:
1141 break;
1142
1143 default:
1144 break;
1145
1146 }
1147
1148 return;
1149
1150}
1151
1152
1153// --------------------------------------------------------------------
1154/**
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 * pmmProcessMessage
1156 *
1157 * FUNCTION: Processes the next received Power Management message
1158 *
1159 * LOGIC:
1160 *
1161 * ASSUMPTIONS:
1162 *
1163 * NOTE:
1164 *
1165 * @param None
1166 * @return None
1167 */
1168
1169void pmmProcessMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1170{
1171 switch (pMsg->type)
1172 {
1173 case eWNI_PMC_PWR_SAVE_CFG:
1174 {
1175 tpSirPowerSaveCfg pPSCfg;
1176 tSirMbMsg *pMbMsg = (tSirMbMsg *)pMsg->bodyptr;
1177
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301178 pPSCfg = vos_mem_malloc(sizeof(tSirPowerSaveCfg));
1179 if ( NULL == pPSCfg )
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001181 pmmLog(pMac, LOGP, "PMM: Not able to allocate memory for PMC Config");
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301183 (void) vos_mem_copy(pPSCfg, pMbMsg->data, sizeof(tSirPowerSaveCfg));
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 (void) pmmSendPowerSaveCfg(pMac, pPSCfg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 }
1186 break;
1187
1188 case eWNI_PMC_ENTER_BMPS_REQ:
1189 pmmInitBmpsPwrSave(pMac);
1190 break;
1191
1192 case WDA_ENTER_BMPS_RSP:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001193 pmmInitBmpsResponseHandler(pMac, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 break;
1195
1196 case eWNI_PMC_EXIT_BMPS_REQ:
1197 {
1198 tpExitBmpsInfo pExitBmpsInfo;
1199 tSirMbMsg *pMbMsg = (tSirMbMsg *)pMsg->bodyptr;
1200
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301201 pExitBmpsInfo = vos_mem_malloc(sizeof(tExitBmpsInfo));
1202 if ( NULL == pExitBmpsInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001204 pmmLog(pMac, LOGP, "PMM: Failed to allocate memory for Exit BMPS Info ");
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301206 (void) vos_mem_copy(pExitBmpsInfo, pMbMsg->data, sizeof(tExitBmpsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 (void) pmmExitBmpsRequestHandler(pMac, pExitBmpsInfo);
1208 }
1209 break;
1210
1211 case WDA_EXIT_BMPS_RSP:
1212 pmmExitBmpsResponseHandler(pMac, pMsg);
1213 break;
1214
1215 case WDA_EXIT_BMPS_IND:
1216 pmmExitBmpsIndicationHandler(pMac, SIR_PM_ACTIVE_MODE, (eHalStatus)pMsg->bodyval);
1217 break;
1218
1219 case eWNI_PMC_ENTER_IMPS_REQ:
1220 pmmEnterImpsRequestHandler(pMac);
1221 break;
1222
1223 case WDA_ENTER_IMPS_RSP:
1224 pmmEnterImpsResponseHandler(pMac, (eHalStatus)pMsg->bodyval);
1225 break;
1226
1227 case eWNI_PMC_EXIT_IMPS_REQ:
1228 pmmExitImpsRequestHandler(pMac);
1229 break;
1230
1231 case WDA_EXIT_IMPS_RSP:
1232 pmmExitImpsResponseHandler(pMac, (eHalStatus)pMsg->bodyval);
1233 break;
1234
1235 case eWNI_PMC_ENTER_UAPSD_REQ:
1236 pmmEnterUapsdRequestHandler(pMac);
1237 break;
1238
1239 case WDA_ENTER_UAPSD_RSP:
1240 pmmEnterUapsdResponseHandler(pMac, pMsg);
1241 break;
1242
1243 case eWNI_PMC_EXIT_UAPSD_REQ:
1244 pmmExitUapsdRequestHandler(pMac);
1245 break;
1246
1247 case WDA_EXIT_UAPSD_RSP:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001248 pmmExitUapsdResponseHandler(pMac, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 break;
1250
1251 case eWNI_PMC_WOWL_ADD_BCAST_PTRN:
1252 pmmSendWowlAddBcastPtrn(pMac, pMsg);
1253 break;
1254
1255 case eWNI_PMC_WOWL_DEL_BCAST_PTRN:
1256 pmmSendWowlDelBcastPtrn(pMac, pMsg);
1257 break;
1258
1259 case eWNI_PMC_ENTER_WOWL_REQ:
1260 pmmEnterWowlRequestHandler(pMac, pMsg);
1261 break;
1262
1263 case WDA_WOWL_ENTER_RSP:
1264 pmmEnterWowlanResponseHandler(pMac, pMsg);
1265 break;
1266
1267 case eWNI_PMC_EXIT_WOWL_REQ:
1268 pmmExitWowlanRequestHandler(pMac);
1269 break;
1270
1271 case WDA_WOWL_EXIT_RSP:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001272 pmmExitWowlanResponseHandler(pMac, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 break;
1274#ifdef WLAN_FEATURE_PACKET_FILTERING
1275 case WDA_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP:
1276 pmmFilterMatchCountResponseHandler(pMac, pMsg);
1277 break;
1278#endif // WLAN_FEATURE_PACKET_FILTERING
1279
1280
1281#ifdef WLAN_FEATURE_GTK_OFFLOAD
1282 case WDA_GTK_OFFLOAD_GETINFO_RSP:
1283 pmmGTKOffloadGetInfoResponseHandler(pMac, pMsg);
1284 break;
1285#endif // WLAN_FEATURE_GTK_OFFLOAD
1286
1287 default:
1288 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001289 FL("PMM: Unknown message in pmmMsgQ type %d, potential memory leak!!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 pMsg->type);)
1291 }
1292
1293 if (NULL != pMsg->bodyptr)
1294 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05301295 vos_mem_free(pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 pMsg->bodyptr = NULL;
1297 }
1298}
1299
1300
1301
1302
1303
1304
1305// --------------------------------------------------------------------
1306/**
1307 * pmmPostMessage
1308 *
1309 * FUNCTION:
1310 * Post a message to the pmm message queue
1311 *
1312 * LOGIC:
1313 *
1314 * ASSUMPTIONS:
1315 *
1316 * NOTE:
1317 *
1318 * @param pMsg pointer to message
1319 * @return None
1320 */
1321
1322tSirRetStatus
1323pmmPostMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1324{
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 VOS_STATUS vosStatus;
1326 vosStatus = vos_mq_post_message(VOS_MQ_ID_PE, (vos_msg_t *) pMsg);
1327 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1328 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001329 pmmLog(pMac, LOGP, FL("vos_mq_post_message failed with status code %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 return eSIR_FAILURE;
1331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001332
1333 return eSIR_SUCCESS;
1334}
1335
1336
1337
1338
1339
1340/**
1341 * pmmUpdatePwrSaveStats
1342 *
1343 * FUNCTION: updated BMPS stats, when Station is going into power save state.
1344 *
1345 * LOGIC:
1346 *
1347 * ASSUMPTIONS:
1348 *
1349 * NOTE:
1350 *
1351 * @param pMac pointer to Global MAC Structure.
1352 * @return None
1353 */
1354
1355void pmmUpdatePwrSaveStats(tpAniSirGlobal pMac)
1356{
1357/*
1358 tANI_U64 TimeAwake = 0;
1359
1360 pMac->pmm.BmpsSleepTimeStamp = vos_timer_get_system_ticks();
1361
1362 if (pMac->pmm.BmpsWakeupTimeStamp)
1363 TimeAwake = (pMac->pmm.BmpsSleepTimeStamp - pMac->pmm.BmpsWakeupTimeStamp) /10;
1364 else
1365 TimeAwake = 0; // very first time
1366
1367 if (TimeAwake > pMac->pmm.BmpsmaxTimeAwake)
1368 {
1369 pMac->pmm.BmpsmaxTimeAwake = TimeAwake;
1370 }
1371
1372 if ((!pMac->pmm.BmpsminTimeAwake) || (TimeAwake < pMac->pmm.BmpsminTimeAwake))
1373 {
1374 pMac->pmm.BmpsminTimeAwake = TimeAwake;
1375 }
1376
1377 pMac->pmm.BmpsavgTimeAwake = ( ( (pMac->pmm.BmpsavgTimeAwake * pMac->pmm.BmpscntSleep) + TimeAwake ) / (pMac->pmm.BmpscntSleep + 1) );
1378
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05301379*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 pMac->pmm.BmpscntSleep++;
1381 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001382}
1383
1384
1385
1386
1387/**
1388 * pmmUpdatePwrSaveStats
1389 *
1390 * FUNCTION: updated BMPS stats, when Station is waking up.
1391 *
1392 * LOGIC:
1393 *
1394 * ASSUMPTIONS:
1395 *
1396 * NOTE:
1397 *
1398 * @param pMac pointer to Global MAC Structure.
1399 * @return None
1400 */
1401
1402void pmmUpdateWakeupStats(tpAniSirGlobal pMac)
1403{
1404/*
1405
1406 tANI_U64 SleepTime = 0;
1407
1408 pMac->pmm.BmpsWakeupTimeStamp = vos_timer_get_system_ticks();
1409 SleepTime = (pMac->pmm.BmpsWakeupTimeStamp - pMac->pmm.BmpsSleepTimeStamp) / 10;
1410
1411 if (SleepTime > pMac->pmm.BmpsmaxSleepTime)
1412 {
1413 pMac->pmm.BmpsmaxSleepTime = SleepTime;
1414 }
1415
1416 if ((!pMac->pmm.BmpsminSleepTime) || (SleepTime < pMac->pmm.BmpsminSleepTime))
1417 {
1418 pMac->pmm.BmpsminSleepTime = SleepTime;
1419 }
1420
1421 pMac->pmm.BmpsavgSleepTime = ( ( (pMac->pmm.BmpsavgSleepTime * pMac->pmm.BmpscntAwake) + SleepTime ) / (pMac->pmm.BmpscntAwake + 1) );
1422
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05301423*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 pMac->pmm.BmpscntAwake++;
1425 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001426}
1427
1428// --------------------------------------------------------------------
1429/**
1430 * pmmEnterImpsRequestHandler
1431 *
1432 * FUNCTION:
1433 * This function sends the idle mode power save request from host device
1434 * drive to HAL. This function is called from pmmProcessMsg()
1435 *
1436 * LOGIC:
1437 *
1438 * ASSUMPTIONS:
1439 * None
1440 *
1441 * NOTE:
1442 *
1443 * @param Global handle to MAC
1444 * @return None
1445 */
1446void pmmEnterImpsRequestHandler (tpAniSirGlobal pMac)
1447{
1448
1449 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
1450 tSirRetStatus retStatus = eSIR_SUCCESS;
1451 tPmmState origState = pMac->pmm.gPmmState;
1452
1453#ifdef FEATURE_WLAN_DIAG_SUPPORT
1454 limDiagEventReport(pMac, WLAN_PE_DIAG_ENTER_IMPS_REQ_EVENT, peGetValidPowerSaveSession(pMac), 0, 0);
1455#endif //FEATURE_WLAN_DIAG_SUPPORT
1456
1457 /*Returns True even single active session present */
1458 if(peIsAnySessionActive(pMac))
1459 {
Abhishek Singh9c1262f2014-02-26 14:48:36 +05301460 /* Print active pesession and tracedump once in every 16
1461 * continous error.
1462 */
1463 if (!(pMac->pmc.ImpsReqFailCnt & 0xF))
1464 {
1465 pePrintActiveSession(pMac);
1466 vosTraceDumpAll(pMac,0,0,100,0);
1467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 resultCode = eSIR_SME_INVALID_STATE;
Abhishek Singh9c1262f2014-02-26 14:48:36 +05301469 pmmLog(pMac, LOGE, FL("Session is active go to failure resultCode = "
1470 "eSIR_SME_INVALID_STATE (%d)"),resultCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 goto failure;
1472 }
1473
1474 if ( ((pMac->pmm.gPmmState != ePMM_STATE_READY) &&
1475 (pMac->pmm.gPmmState != ePMM_STATE_IMPS_WAKEUP)) ||
1476 ((pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE) &&
1477 (pMac->lim.gLimSmeState != eLIM_SME_JOIN_FAILURE_STATE)) ||
1478 (pMac->lim.gLimMlmState != eLIM_MLM_IDLE_STATE) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001479 limIsChanSwitchRunning (pMac) ||
1480 limIsInQuietDuration (pMac) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 {
1482 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001483 FL("pmmImps: PMM State = %d, Global MLM State = %d, Global SME State = %d, rejecting the sleep mode request"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 pMac->pmm.gPmmState, pMac->lim.gLimMlmState, pMac->lim.gLimSmeState);)
1485
1486 resultCode = eSIR_SME_INVALID_PMM_STATE;
1487 pmmImpsUpdateErrStateStats(pMac);
1488 goto failure;
1489 }
1490
1491 // change PE state and send the request to HAL
1492 pMac->pmm.gPmmState = ePMM_STATE_IMPS_WT_SLEEP_RSP;
1493 if( (retStatus = pmmImpsSendChangePwrSaveMsg(pMac, SIR_PM_SLEEP_MODE)) != eSIR_SUCCESS)
1494 {
1495 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001496 FL("pmmImps: IMPS Sleep Request failed: sending response: %x"), retStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001497
1498 resultCode = eSIR_SME_IMPS_REQ_FAILED;
1499 goto failure;
1500 }
1501 else
1502 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301503 pmmLog(pMac, LOG1,
1504 FL("pmmImps: Waiting for SoftMac response for IMPS request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 }
1506 return;
1507
1508failure:
1509 pMac->pmm.gPmmState = origState;
1510 pmmImpsUpdateSleepErrStats(pMac, retStatus);
1511
1512 limSendSmeRsp(pMac,
1513 eWNI_PMC_ENTER_IMPS_RSP,
1514 resultCode, 0, 0);
1515
1516}
1517
1518// --------------------------------------------------------------------
1519/**
1520 * pmmEnterImpsResponseHandler
1521 *
1522 * FUNCTION:
1523 * This function receives the response from HAL layer for the idle mode
1524 * power save request sent. The function is also responsible for checking
1525 * the correctness of the system state before configuring the new state
1526 * on success. This function is called by pmmProcessMsg()
1527 *
1528 * LOGIC:
1529 *
1530 * ASSUMPTIONS:
1531 * None
1532 *
1533 * NOTE:
1534 *
1535 * @param Global handle to MAC, Status code
1536 * @return None
1537 */
1538void pmmEnterImpsResponseHandler (tpAniSirGlobal pMac, eHalStatus rspStatus)
1539{
1540 tPmmState nextState = pMac->pmm.gPmmState;
1541 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
1542
1543 /* we need to process all the deferred messages enqueued since
1544 * the initiating the WDA_ENTER_IMPS_REQ.
1545 */
1546 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1547
1548 if(pMac->pmm.gPmmState != ePMM_STATE_IMPS_WT_SLEEP_RSP)
1549 {
1550 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001551 FL("pmmImps: Receives IMPS sleep rsp in invalid state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 pMac->pmm.gPmmState);)
1553
1554 resultCode = eSIR_SME_INVALID_PMM_STATE;
1555 pmmImpsUpdateErrStateStats(pMac);
1556
1557 goto failure;
1558 }
1559
1560 if(eHAL_STATUS_SUCCESS == rspStatus)
1561 {
1562 //if success, change the state to IMPS sleep mode
1563 pMac->pmm.gPmmState = ePMM_STATE_IMPS_SLEEP;
1564
Abhishek Singh525045c2014-12-15 17:18:45 +05301565 pmmLog(pMac, LOG1,
1566 FL("pmmImps: Received successful WDA_ENTER_IMPS_RSP from HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001567
1568 //update power save statistics
1569 pmmImpsUpdatePwrSaveStats(pMac);
1570
1571 limSendSmeRsp(pMac,
1572 eWNI_PMC_ENTER_IMPS_RSP,
1573 resultCode, 0, 0);
1574 }
1575 else
1576 {
1577 // go back to previous state if request failed
1578 nextState = ePMM_STATE_IMPS_WAKEUP;
1579 resultCode = eSIR_SME_CANNOT_ENTER_IMPS;
1580 goto failure;
1581 }
1582 return;
1583
1584failure:
1585 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001586 FL("pmmImpsSleepRsp failed, Ret Code: %d, next state will be: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 rspStatus,
1588 pMac->pmm.gPmmState);)
1589
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05301590 pmmImpsUpdateSleepErrStats(pMac, rspStatus);
1591
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 pMac->pmm.gPmmState = nextState;
1593
1594 limSendSmeRsp(pMac,
1595 eWNI_PMC_ENTER_IMPS_RSP,
1596 resultCode, 0, 0);
1597}
1598
1599
1600// --------------------------------------------------------------------
1601/**
1602 * pmmExitImpsRequestHandler
1603 *
1604 * FUNCTION:
1605 * This function is called by pmmProcessMsg(). The function sends a request
1606 * to HAL to wakeup the device from idle mode power save mode.
1607 *
1608 * LOGIC:
1609 *
1610 * ASSUMPTIONS:
1611 * None
1612 *
1613 * NOTE:
1614 *
1615 * @param Global handle to MAC
1616 * @return None
1617 */
1618void pmmExitImpsRequestHandler (tpAniSirGlobal pMac)
1619{
1620 tSirRetStatus retStatus = eSIR_SUCCESS;
1621 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
1622
1623 tPmmState origState = pMac->pmm.gPmmState;
1624
1625#ifdef FEATURE_WLAN_DIAG_SUPPORT
1626 limDiagEventReport(pMac, WLAN_PE_DIAG_EXIT_IMPS_REQ_EVENT, peGetValidPowerSaveSession(pMac), 0, 0);
1627#endif //FEATURE_WLAN_DIAG_SUPPORT
1628
1629 if (ePMM_STATE_IMPS_SLEEP == pMac->pmm.gPmmState)
1630 {
1631 pMac->pmm.gPmmState = ePMM_STATE_IMPS_WT_WAKEUP_RSP;
1632 if( (retStatus = pmmImpsSendChangePwrSaveMsg(pMac, SIR_PM_ACTIVE_MODE)) !=
1633 eSIR_SUCCESS)
1634 {
1635 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001636 FL("pmmImps: Wakeup request message sent to SoftMac failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 resultCode = eSIR_SME_IMPS_REQ_FAILED;
1638 goto failure;
1639 }
1640 }
1641 else
1642 {
1643 // PE in invalid state
1644 PELOGE(pmmLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05301645 FL("pmmImps: Wakeup Req received in invalid state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 pMac->pmm.gPmmState);)
1647
1648 resultCode = eSIR_SME_INVALID_PMM_STATE;
1649 pmmImpsUpdateErrStateStats(pMac);
1650
1651 goto failure;
1652 }
1653 return;
1654
1655failure:
1656 PELOGE(pmmLog (pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001657 FL("pmmImps: Changing to IMPS wakeup mode failed, Ret Code: %d, Next State: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 retStatus, pMac->pmm.gPmmState);)
1659
1660 pMac->pmm.gPmmState = origState;
1661 pmmImpsUpdateWakeupErrStats(pMac, retStatus);
1662
1663 limSendSmeRsp(pMac,
1664 eWNI_PMC_EXIT_IMPS_RSP,
1665 resultCode, 0, 0);
1666}
1667
1668
1669// --------------------------------------------------------------------
1670/**
1671 * pmmExitImpsResponseHandler
1672 *
1673 * FUNCTION:
1674 * This function receives the response from HAL layer for the idle mode
1675 * power save request sent. The function is also responsible for checking
1676 * the correctness of the system state before configuring the new state
1677 * on success. This function is called by pmmProcessMsg()
1678 *
1679 * LOGIC:
1680 *
1681 * ASSUMPTIONS:
1682 * None
1683 *
1684 * NOTE:
1685 *
1686 * @param Global handle to MAC
1687 * @return None
1688 */
1689void pmmExitImpsResponseHandler(tpAniSirGlobal pMac, eHalStatus rspStatus)
1690{
1691 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
1692
1693 /* we need to process all the deferred messages enqueued since
1694 * the initiating the WDA_EXIT_IMPS_REQ.
1695 */
1696 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1697
1698 if (pMac->pmm.gPmmState != ePMM_STATE_IMPS_WT_WAKEUP_RSP)
1699 {
1700 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001701 FL("pmmImps: Received 'Wakeup' response in invalid state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 pMac->pmm.gPmmState);)
1703
1704 resultCode = eSIR_SME_INVALID_PMM_STATE;
1705 pmmImpsUpdateErrStateStats(pMac);
1706 }
1707
1708 switch(rspStatus)
1709 {
1710 case eHAL_STATUS_SUCCESS:
1711 {
1712 resultCode = eSIR_SME_SUCCESS;
Abhishek Singh0ff4dc02014-04-08 12:04:17 +05301713 pMac->pmm.gPmmState = ePMM_STATE_IMPS_WAKEUP;
Abhishek Singh525045c2014-12-15 17:18:45 +05301714 pmmLog(pMac, LOG1,
1715 FL("pmmImps: Received WDA_EXIT_IMPS_RSP with Successful response from HAL"));
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05301716 //update power save statistics
1717 pmmImpsUpdateWakeupStats(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 }
1719 break;
1720
1721 default:
1722 {
1723 resultCode = eSIR_SME_IMPS_REQ_FAILED;
Abhishek Singh0ff4dc02014-04-08 12:04:17 +05301724 /* Set the status back to IMPS SLEEP as we failed
1725 * to come out of sleep
1726 */
1727 pMac->pmm.gPmmState = ePMM_STATE_IMPS_SLEEP;
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001729 FL("pmmImps: Received WDA_EXIT_IMPS_RSP with Failure Status from HAL"));)
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05301730 // update th power save error stats
1731 pmmImpsUpdateWakeupErrStats(pMac, rspStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 }
1733 break;
1734
1735 }
1736
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05301737
Jeff Johnson295189b2012-06-20 16:38:30 -07001738
1739 limSendSmeRsp(pMac,
1740 eWNI_PMC_EXIT_IMPS_RSP,
1741 resultCode, 0, 0);
1742 return;
1743
1744}
1745
1746// --------------------------------------------------------------------
1747/**
1748 * pmmEnterUapsdRequestHandler
1749 *
1750 * FUNCTION:
1751 * This function process the eWNI_PMC_ENTER_UAPSD_REQ from PMC,
1752 * checks the correctness of the system state before configuring
1753 * PMM to the new ePMM_STATE_UAPSD_WT_SLEEP_RSP state, and invokes
1754 * invokes pmmUapsdSendChangePwrSaveMsg() to send
1755 * WDA_ENTER_UAPSD_REQ to HAL.
1756 *
1757 * NOTE:
1758 *
1759 * @param Global handle to MAC
1760 * @return None
1761 */
1762void pmmEnterUapsdRequestHandler (tpAniSirGlobal pMac)
1763{
1764 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
1765 tSirRetStatus retStatus = eSIR_SUCCESS;
1766
1767 tPmmState origState = pMac->pmm.gPmmState;
1768
1769#ifdef FEATURE_WLAN_DIAG_SUPPORT
1770 limDiagEventReport(pMac, WLAN_PE_DIAG_ENTER_UAPSD_REQ_EVENT, peGetValidPowerSaveSession(pMac), 0, 0);
1771#endif //FEATURE_WLAN_DIAG_SUPPORT
1772
1773 if ( (pMac->pmm.gPmmState != ePMM_STATE_BMPS_SLEEP) ||
1774 limIsSystemInScanState(pMac) )
1775 {
1776 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001777 FL("pmmUapsd: PMM State = %d, Global MLM State = %d, Global SME State = %d, rejecting the sleep mode request"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 pMac->pmm.gPmmState, pMac->lim.gLimMlmState, pMac->lim.gLimSmeState);)
1779
1780 resultCode = eSIR_SME_INVALID_PMM_STATE;
1781 goto failure;
1782 }
1783
1784 pMac->pmm.gPmmState = ePMM_STATE_UAPSD_WT_SLEEP_RSP;
1785
1786 if( (retStatus = pmmUapsdSendChangePwrSaveMsg(pMac, SIR_PM_SLEEP_MODE)) != eSIR_SUCCESS)
1787 {
1788 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001789 FL("pmmUapsd: HAL_ENTER_UAPSD_REQ failed with response: %x"), retStatus);)
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +05301790 if (retStatus == eSIR_PMM_INVALID_REQ)
1791 resultCode = eSIR_SME_UAPSD_REQ_INVALID;
1792 else
1793 resultCode = eSIR_SME_UAPSD_REQ_FAILED;
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 goto failure;
1795 }
1796
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301797 pmmLog(pMac, LOG1, FL("pmmUapsd: Waiting for WDA_ENTER_UAPSD_RSP "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 return;
1799
1800failure:
1801 pMac->pmm.gPmmState = origState;
1802 limSendSmeRsp(pMac, eWNI_PMC_ENTER_UAPSD_RSP, resultCode, 0, 0);
1803 return;
1804}
1805
1806
1807// --------------------------------------------------------------------
1808/**
1809 * pmmEnterUapsdResponseHandler
1810 *
1811 * FUNCTION:
1812 * This function processes the SIR_HAL_ENTER_UAPSD_RSP from HAL.
1813 * If the response is successful, it puts PMM into ePMM_STATE_UAPSD_SLEEP
1814 * state and sends back success response to PMC.
1815 *
1816 * NOTE:
1817 *
1818 * @param limMsg
1819 * @return None
1820 */
1821void pmmEnterUapsdResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1822{
1823 tpUapsdParams pUapsdRspMsg;
1824 tSirResultCodes retStatus = eSIR_SME_SUCCESS;
1825
Jeff Johnsone7245742012-09-05 17:12:55 -07001826 tANI_U8 PowersavesessionId;
1827 tpPESession psessionEntry;
1828
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 /* we need to process all the deferred messages enqueued since
1830 * the initiating the SIR_HAL_ENTER_UAPSD_REQ.
1831 */
1832 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1833
Jeff Johnsone7245742012-09-05 17:12:55 -07001834 /* Copy the power save sessionId to the local variable */
1835 PowersavesessionId = pMac->pmm.sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001836
1837 if (NULL == limMsg->bodyptr)
1838 {
1839 PELOGE(pmmLog(pMac, LOGE, FL("pmmUapsd: Received SIR_HAL_ENTER_UAPSD_RSP with NULL "));)
1840 return;
1841 }
1842
1843 pUapsdRspMsg = (tpUapsdParams)(limMsg->bodyptr);
1844
Jeff Johnsone7245742012-09-05 17:12:55 -07001845 if((psessionEntry = peFindSessionBySessionId(pMac,PowersavesessionId))==NULL)
1846 {
Katya Nigam70d68332013-09-16 16:49:45 +05301847 pmmLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001848 return;
1849 }
1850
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 if(pMac->pmm.gPmmState != ePMM_STATE_UAPSD_WT_SLEEP_RSP)
1852 {
1853 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001854 FL("pmmUapsd: Received SIR_HAL_ENTER_UAPSD_RSP while in incorrect state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 pMac->pmm.gPmmState);)
1856 limSendSmeRsp(pMac, eWNI_PMC_ENTER_UAPSD_RSP, eSIR_SME_INVALID_PMM_STATE, 0, 0);
1857 return;
1858 }
1859
Jeff Johnson43971f52012-07-17 12:26:56 -07001860 if(pUapsdRspMsg->status == eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 {
1862 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001863 FL("pmmUapsd: Received successful response from HAL to enter UAPSD mode "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 pMac->pmm.gPmmState = ePMM_STATE_UAPSD_SLEEP;
1865 }
1866 else
1867 {
1868 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001869 FL("pmmUapsd: SIR_HAL_ENTER_UAPSD_RSP failed, informing SME"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 pMac->pmm.gPmmState = ePMM_STATE_BMPS_SLEEP;
1871 retStatus = eSIR_SME_UAPSD_REQ_FAILED;
1872 }
1873
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001874 if(IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION))
Jeff Johnsone7245742012-09-05 17:12:55 -07001875 {
1876 limSendSmeRsp(pMac, eWNI_PMC_ENTER_UAPSD_RSP, retStatus,
1877 psessionEntry->smeSessionId, psessionEntry->transactionId);
1878 }
1879 else
1880 {
1881 limSendSmeRsp(pMac, eWNI_PMC_ENTER_UAPSD_RSP, retStatus, 0, 0);
1882 }
1883
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 return;
1885}
1886
1887
1888// --------------------------------------------------------------------
1889/**
1890 * pmmExitUapsdRequestHandler
1891 *
1892 * FUNCTION:
1893 * This function process the eWNI_PMC_EXIT_UAPSD_REQ from PMC,
1894 * checks the correctness of the system state before configuring
1895 * PMM to the new ePMM_STATE_UAPSD_WT_WAKEUP_RSP state, and
1896 * invokes pmmUapsdSendChangePwrSaveMsg() to send
1897 * SIR_HAL_EXIT_UAPSD_REQ to HAL.
1898 *
1899 * NOTE:
1900 *
1901 * @param Global handle to MAC
1902 * @return None
1903 */
1904void pmmExitUapsdRequestHandler(tpAniSirGlobal pMac)
1905{
1906 tSirRetStatus retStatus = eSIR_SUCCESS;
1907 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
1908
1909 tPmmState origState = pMac->pmm.gPmmState;
1910
1911#ifdef FEATURE_WLAN_DIAG_SUPPORT
1912 limDiagEventReport(pMac, WLAN_PE_DIAG_EXIT_UAPSD_REQ_EVENT, peGetValidPowerSaveSession(pMac), 0, 0);
1913#endif //FEATURE_WLAN_DIAG_SUPPORT
1914
1915 if (ePMM_STATE_UAPSD_SLEEP == pMac->pmm.gPmmState)
1916 {
1917 pMac->pmm.gPmmState = ePMM_STATE_UAPSD_WT_WAKEUP_RSP;
1918 if( (retStatus = pmmUapsdSendChangePwrSaveMsg(pMac, SIR_PM_ACTIVE_MODE)) !=
1919 eSIR_SUCCESS)
1920 {
1921 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001922 FL("pmmUapsd: sending EXIT_UAPSD to HAL failed "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 resultCode = eSIR_SME_UAPSD_REQ_FAILED;
1924 goto failure;
1925 }
1926 }
1927 else
1928 {
1929 PELOGE(pmmLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05301930 FL("pmmUapsd: Rcv EXIT_UAPSD from PMC in invalid state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 pMac->pmm.gPmmState);)
1932
1933 resultCode = eSIR_SME_INVALID_PMM_STATE;
1934 goto failure;
1935 }
1936 return;
1937
1938failure:
1939 pMac->pmm.gPmmState = origState;
1940 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001941 FL("pmmUapsd: Waking up from UAPSD mode failed, Ret Code: %d, Next State: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 retStatus, pMac->pmm.gPmmState);)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001943 limSendSmeRsp(pMac, eWNI_PMC_EXIT_UAPSD_RSP, resultCode, 0, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001944}
1945
1946
1947// --------------------------------------------------------------------
1948/**
1949 * pmmExitUapsdResponseHandler
1950 *
1951 * FUNCTION:
1952 * This function receives the SIR_HAL_EXIT_UAPSD_RSP from HAL and is
1953 * responsible for checking the correctness of the system state
1954 * before configuring PMM to the new ePMM_STATE_BMPS_SLEEP state
1955 * and send eWNI_PMC_EXIT_UAPSD_RSP to PMC.
1956 *
1957 * NOTE:
1958 *
1959 * @param Global handle to MAC
1960 * @return None
1961 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001962void pmmExitUapsdResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07001963{
1964 tSirResultCodes resultCode = eSIR_SME_SUCCESS;
Jeff Johnsone7245742012-09-05 17:12:55 -07001965 tANI_U8 PowersavesessionId;
1966 tpPESession psessionEntry;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001967 tUapsdParams *pUapsdExitRspParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07001968
1969 /* we need to process all the deferred messages enqueued since
1970 * the initiating the SIR_HAL_EXIT_UAPSD_REQ.
1971 */
1972 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1973
1974 if (pMac->pmm.gPmmState != ePMM_STATE_UAPSD_WT_WAKEUP_RSP)
1975 {
1976 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001977 FL("Received HAL_EXIT_UAPSD_RSP in invalid state: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 pMac->pmm.gPmmState);)
1979 limSendSmeRsp(pMac, eWNI_PMC_EXIT_UAPSD_RSP, eSIR_SME_INVALID_PMM_STATE, 0, 0);
1980 return;
1981 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001982 pUapsdExitRspParams = (tUapsdParams *)(limMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07001983
Jeff Johnsone7245742012-09-05 17:12:55 -07001984 PowersavesessionId = pMac->pmm.sessionId;
1985 if((psessionEntry = peFindSessionBySessionId(pMac,PowersavesessionId))==NULL)
1986 {
Katya Nigam70d68332013-09-16 16:49:45 +05301987 pmmLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001988 return;
1989 }
1990
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001991 if(NULL == pUapsdExitRspParams )
1992 {
1993 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07001994 FL("Received HAL_EXIT_UAPSD_RSP message with zero parameters:"));)
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001995 limSendSmeRsp(pMac, eWNI_PMC_EXIT_UAPSD_RSP, eSIR_SME_UAPSD_REQ_FAILED, 0, 0);
1996 return;
1997 }
1998 switch(pUapsdExitRspParams->status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 {
2000 case eHAL_STATUS_SUCCESS:
2001 resultCode = eSIR_SME_SUCCESS;
2002 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002003 FL("Received SIR_HAL_EXIT_UAPSD_RSP with Successful response "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 break;
2005 default:
2006 resultCode = eSIR_SME_UAPSD_REQ_FAILED;
2007 PELOGE(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002008 FL("Received SIR_HAL_EXIT_UAPSD_RSP with Failure Status"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 break;
2010 }
2011
2012 pMac->pmm.gPmmState = ePMM_STATE_BMPS_SLEEP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002013
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002014 if(IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION))
Jeff Johnsone7245742012-09-05 17:12:55 -07002015 {
2016 limSendSmeRsp(pMac, eWNI_PMC_EXIT_UAPSD_RSP, resultCode, psessionEntry->smeSessionId,
2017 psessionEntry->transactionId);
2018 }
2019 else
2020 {
2021 limSendSmeRsp(pMac, eWNI_PMC_EXIT_UAPSD_RSP, resultCode, 0, 0);
2022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 return;
2024}
2025
2026/** ------------------------------------------------------------
2027\fn pmmSendWowlAddBcastPtrn
2028\brief This function sends a SIR_HAL_WOWL_ADD_BCAST_PTRN
2029\ message to HAL.
2030\param tpAniSirGlobal pMac
2031\param tpSirMsgQ pMsg
2032\return None
2033 --------------------------------------------------------------*/
2034void pmmSendWowlAddBcastPtrn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2035{
2036 tpSirWowlAddBcastPtrn pBcastPtrn;
2037 tSirMbMsg *pMbMsg = (tSirMbMsg *)pMsg->bodyptr;
2038 tSirRetStatus retCode = eSIR_SUCCESS;
2039 tSirMsgQ msgQ;
2040
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302041 pBcastPtrn = vos_mem_malloc(sizeof(*pBcastPtrn));
2042 if ( NULL == pBcastPtrn )
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002044 pmmLog(pMac, LOGP, FL("Fail to allocate memory for WoWLAN Add Bcast Pattern "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 return;
2046 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302047 (void) vos_mem_copy(pBcastPtrn, pMbMsg->data, sizeof(*pBcastPtrn));
Jeff Johnson295189b2012-06-20 16:38:30 -07002048
2049 if (NULL == pBcastPtrn)
2050 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002051 pmmLog(pMac, LOGE, FL("Add broadcast pattern message is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 return;
2053 }
2054
2055 msgQ.type = WDA_WOWL_ADD_BCAST_PTRN;
2056 msgQ.reserved = 0;
2057 msgQ.bodyptr = pBcastPtrn;
2058 msgQ.bodyval = 0;
2059
2060 pmmLog(pMac, LOG1, FL( "Sending WDA_WOWL_ADD_BCAST_PTRN to HAL"));
2061#ifdef FEATURE_WLAN_DIAG_SUPPORT
2062 limDiagEventReport(pMac, WLAN_PE_DIAG_WOWL_ADD_BCAST_PTRN_EVENT, NULL, 0, 0);
2063#endif //FEATURE_WLAN_DIAG_SUPPORT
2064
2065 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2066 {
2067 if (pBcastPtrn != NULL)
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302068 vos_mem_free(pBcastPtrn);
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 pmmLog( pMac, LOGP, FL("Posting WDA_WOWL_ADD_BCAST_PTRN failed, reason=%X"), retCode );
2070 }
2071 return;
2072}
2073
2074/** ------------------------------------------------------------
2075\fn pmmSendWowlDelBcastPtrn
2076\brief This function sends a SIR_HAL_WOWL_DEL_BCAST_PTRN
2077\ message to HAL.
2078\param tpAniSirGlobal pMac
2079\param tpSirMsgQ pMsg
2080\return None
2081 --------------------------------------------------------------*/
2082void pmmSendWowlDelBcastPtrn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2083{
2084 tpSirWowlDelBcastPtrn pDeletePtrn;
2085 tSirMbMsg *pMbMsg = (tSirMbMsg *)pMsg->bodyptr;
2086 tSirRetStatus retCode = eSIR_SUCCESS;
2087 tSirMsgQ msgQ;
2088
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302089 pDeletePtrn = vos_mem_malloc(sizeof(*pDeletePtrn));
2090 if ( NULL == pDeletePtrn )
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002092 pmmLog(pMac, LOGP, FL("Fail to allocate memory for WoWLAN Delete Bcast Pattern "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 return;
2094 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302095 (void) vos_mem_copy(pDeletePtrn, pMbMsg->data, sizeof(*pDeletePtrn));
Jeff Johnson295189b2012-06-20 16:38:30 -07002096
2097 if (NULL == pDeletePtrn)
2098 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002099 pmmLog(pMac, LOGE, FL("Delete broadcast pattern message is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 return;
2101 }
2102
2103 msgQ.type = WDA_WOWL_DEL_BCAST_PTRN;
2104 msgQ.reserved = 0;
2105 msgQ.bodyptr = pDeletePtrn;
2106 msgQ.bodyval = 0;
2107
2108 pmmLog(pMac, LOG1, FL( "Sending WDA_WOWL_DEL_BCAST_PTRN"));
2109#ifdef FEATURE_WLAN_DIAG_SUPPORT
2110 limDiagEventReport(pMac, WLAN_PE_DIAG_WOWL_DEL_BCAST_PTRN_EVENT, NULL, 0, 0);
2111#endif //FEATURE_WLAN_DIAG_SUPPORT
2112
2113 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2114 {
2115 if (NULL != pDeletePtrn)
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302116 vos_mem_free(pDeletePtrn);
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 pmmLog( pMac, LOGP, FL("Posting WDA_WOWL_DEL_BCAST_PTRN failed, reason=%X"), retCode );
2118 }
2119 return;
2120}
2121
2122/** ---------------------------------------------------------
2123\fn pmmEnterWowlRequestHandler
2124\brief LIM process the eWNI_PMC_ENTER_WOWL_REQ message, and
2125\ invokes pmmSendWowlEnterRequest() to send
2126\ WDA_WOWL_ENTER_REQ message to HAL.
2127\param tpAniSirGlobal pMac
2128\param tpSirMsgQ pMsg
2129\return None
2130 ------------------------------------------------------------*/
2131void pmmEnterWowlRequestHandler(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
2132{
2133 tpSirSmeWowlEnterParams pSmeWowlParams = NULL;
2134 tpSirHalWowlEnterParams pHalWowlParams = NULL;
2135 tSirRetStatus retCode = eSIR_SUCCESS;
2136 tANI_U32 cfgValue = 0;
2137 tSirMbMsg *pMbMsg = (tSirMbMsg *)pMsg->bodyptr;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002138 tpPESession pSessionEntry = NULL;
2139 tANI_U8 peSessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002140
2141#ifdef FEATURE_WLAN_DIAG_SUPPORT
2142 limDiagEventReport(pMac, WLAN_PE_DIAG_ENTER_WOWL_REQ_EVENT, NULL, 0, 0);
2143#endif //FEATURE_WLAN_DIAG_SUPPORT
2144
2145 pSmeWowlParams = (tpSirSmeWowlEnterParams)(pMbMsg->data);
Jeff Johnsonb86e5362013-04-08 11:06:44 -07002146 if (NULL == pSmeWowlParams)
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002147 {
Katya Nigam70d68332013-09-16 16:49:45 +05302148 pmmLog(pMac, LOGE,
Jeff Johnsonb86e5362013-04-08 11:06:44 -07002149 FL("NULL message received"));
2150 return;
2151 }
2152
2153 pSessionEntry = peFindSessionByBssid(pMac, pSmeWowlParams->bssId,
2154 &peSessionId);
2155 if (NULL == pSessionEntry)
2156 {
Katya Nigam70d68332013-09-16 16:49:45 +05302157 pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002158 FL("session does not exist for given BSSId"));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002159 goto end;
2160 }
2161 pMac->pmm.sessionId = peSessionId;
2162
Jeff Johnson295189b2012-06-20 16:38:30 -07002163// Need to fix it ASAP - TBH
2164#if 0
2165 if (pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_STATE)
2166 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002167 pmmLog(pMac, LOGE, FL("Rcvd PMC_ENTER_WOWL_REQ when station is not associated "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 limSendSmeRsp(pMac, eWNI_PMC_ENTER_WOWL_RSP, eSIR_SME_STA_NOT_ASSOCIATED, 0, 0);
2169 goto end;
2170 }
2171#endif
2172
2173
2174 if ((pMac->pmm.gPmmState != ePMM_STATE_BMPS_SLEEP) && (pMac->pmm.gPmmState != ePMM_STATE_WOWLAN))
2175 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002176 pmmLog(pMac, LOGE, FL("Rcvd PMC_ENTER_WOWL_REQ in invalid Power Save state "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 limSendSmeRsp(pMac, eWNI_PMC_ENTER_WOWL_RSP, eSIR_SME_INVALID_PMM_STATE, 0, 0);
2178 goto end;
2179 }
2180
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302181 pHalWowlParams = vos_mem_malloc(sizeof(*pHalWowlParams));
2182 if ( NULL == pHalWowlParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002184 pmmLog(pMac, LOGP, FL("Fail to allocate memory for Enter Wowl Request "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 goto end;
2186 }
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302187 (void) vos_mem_set((tANI_U8 *)pHalWowlParams, sizeof(*pHalWowlParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002188
2189 // fill in the message field
2190 pHalWowlParams->ucMagicPktEnable = pSmeWowlParams->ucMagicPktEnable;
2191 pHalWowlParams->ucPatternFilteringEnable = pSmeWowlParams->ucPatternFilteringEnable;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302192 (void)vos_mem_copy( (tANI_U8 *)pHalWowlParams->magicPtrn, (tANI_U8 *)pSmeWowlParams->magicPtrn,
2193 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002194
2195#ifdef WLAN_WAKEUP_EVENTS
2196 pHalWowlParams->ucWoWEAPIDRequestEnable = pSmeWowlParams->ucWoWEAPIDRequestEnable;
2197 pHalWowlParams->ucWoWEAPOL4WayEnable = pSmeWowlParams->ucWoWEAPOL4WayEnable;
2198 pHalWowlParams->ucWowNetScanOffloadMatch = pSmeWowlParams->ucWowNetScanOffloadMatch;
2199 pHalWowlParams->ucWowGTKRekeyError = pSmeWowlParams->ucWowGTKRekeyError;
2200 pHalWowlParams->ucWoWBSSConnLoss = pSmeWowlParams->ucWoWBSSConnLoss;
2201#endif // WLAN_WAKEUP_EVENTS
2202
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002203 pHalWowlParams->bssIdx = pSessionEntry->bssIdx;
2204
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 if(wlan_cfgGetInt(pMac, WNI_CFG_WOWLAN_UCAST_PATTERN_FILTER_ENABLE, &cfgValue) != eSIR_SUCCESS)
2206 {
Katya Nigam70d68332013-09-16 16:49:45 +05302207 pmmLog(pMac, LOGP, FL("cfgGet failed for WNI_CFG_WOWLAN_UCAST_PATTERN_FILTER_ENABLE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 goto end;
2209 }
2210 pHalWowlParams->ucUcastPatternFilteringEnable = (tANI_U8)cfgValue;
2211
2212 if(wlan_cfgGetInt(pMac, WNI_CFG_WOWLAN_CHANNEL_SWITCH_ENABLE, &cfgValue) != eSIR_SUCCESS)
2213 {
Katya Nigam70d68332013-09-16 16:49:45 +05302214 pmmLog(pMac, LOGP, FL("cfgGet failed for WNI_CFG_WOWLAN_CHANNEL_SWITCH_ENABLE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 goto end;
2216 }
2217 pHalWowlParams->ucWowChnlSwitchRcv = (tANI_U8)cfgValue;
2218
2219 if(wlan_cfgGetInt(pMac, WNI_CFG_WOWLAN_DEAUTH_ENABLE, &cfgValue) != eSIR_SUCCESS)
2220 {
Katya Nigam70d68332013-09-16 16:49:45 +05302221 pmmLog(pMac, LOGP, FL("cfgGet failed for WNI_CFG_WOWLAN_DEAUTH_ENABLE "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 goto end;
2223 }
2224 pHalWowlParams->ucWowDeauthRcv = (tANI_U8)cfgValue;
2225
2226 if(wlan_cfgGetInt(pMac, WNI_CFG_WOWLAN_DISASSOC_ENABLE, &cfgValue) != eSIR_SUCCESS)
2227 {
Katya Nigam70d68332013-09-16 16:49:45 +05302228 pmmLog(pMac, LOGP, FL("cfgGet failed for WNI_CFG_WOWLAN_DEAUTH_ENABLE "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 goto end;
2230 }
2231 pHalWowlParams->ucWowDisassocRcv = (tANI_U8)cfgValue;
2232
2233 if(wlan_cfgGetInt(pMac, WNI_CFG_WOWLAN_MAX_MISSED_BEACON, &cfgValue) != eSIR_SUCCESS)
2234 {
Katya Nigam70d68332013-09-16 16:49:45 +05302235 pmmLog(pMac, LOGP, FL("cfgGet failed for WNI_CFG_WOWLAN_MAX_MISSED_BEACON "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 goto end;
2237 }
2238 pHalWowlParams->ucWowMaxMissedBeacons = (tANI_U8)cfgValue;
2239
2240 if(wlan_cfgGetInt(pMac, WNI_CFG_WOWLAN_MAX_SLEEP_PERIOD, &cfgValue) != eSIR_SUCCESS)
2241 {
Katya Nigam70d68332013-09-16 16:49:45 +05302242 pmmLog(pMac, LOGP, FL("cfgGet failed for WNI_CFG_WOWLAN_MAX_SLEEP_PERIOD "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 goto end;
2244 }
2245 pHalWowlParams->ucWowMaxSleepUsec = (tANI_U8)cfgValue;
2246
2247 //Send message to HAL
2248 if( eSIR_SUCCESS != (retCode = pmmSendWowlEnterRequest( pMac, pHalWowlParams)))
2249 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002250 pmmLog(pMac, LOGE, FL("Send ENTER_WOWL_REQ to HAL failed, reasonCode %d "), retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 limSendSmeRsp(pMac, eWNI_PMC_ENTER_WOWL_RSP, eSIR_SME_WOWL_ENTER_REQ_FAILED, 0, 0);
2252 goto end;
2253 }
2254 return;
2255
2256end:
2257 if (pHalWowlParams != NULL)
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302258 vos_mem_free(pHalWowlParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 return;
2260}
2261
2262
2263/** ------------------------------------------------------------
2264\fn pmmSendWowlEnterRequest
2265\brief LIM sends a WDA_WOWL_ENTER_REQ message to HAL with
2266\ the message structure pHalWowlParams. HAL shall later
2267\ send a WDA_WOWL_ENTER_RSP with the same pointer
2268\ to the message structure back to PMM.
2269\param tpAniSirGlobal pMac
2270\param tpSirHalWowlEnterParams pHalWowlParams
2271\return tSirRetStatus
2272 --------------------------------------------------------------*/
2273tSirRetStatus pmmSendWowlEnterRequest(tpAniSirGlobal pMac, tpSirHalWowlEnterParams pHalWowlParams)
2274{
2275 tSirRetStatus retCode = eSIR_SUCCESS;
2276 tSirMsgQ msgQ;
2277
2278 if (NULL == pHalWowlParams)
2279 return eSIR_FAILURE;
2280
2281 msgQ.type = WDA_WOWL_ENTER_REQ;
2282 msgQ.reserved = 0;
2283 msgQ.bodyptr = pHalWowlParams;
2284 msgQ.bodyval = 0;
2285
2286 /* Defer any incoming message until we get
2287 * a WDA_WOWL_ENTER_RSP from HAL
2288 */
2289 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2290
2291 retCode = wdaPostCtrlMsg(pMac, &msgQ);
2292 if( eSIR_SUCCESS != retCode )
2293 {
2294 pmmLog( pMac, LOGE, FL("Posting WDA_WOWL_ENTER_REQ failed, reason=%X"), retCode );
2295 return retCode;
2296 }
2297 return retCode;
2298}
2299
2300/** ---------------------------------------------------------
2301\fn pmmEnterWowlanResponseHandler
2302\brief LIM process the WDA_WOWL_ENTER_RSP message.
2303\ and sends eWNI_PMC_ENTER_WOWL_RSP to SME.
2304\param tpAniSirGlobal pMac
2305\param tpSirMsgQ limMsg
2306\return None
2307 ------------------------------------------------------------*/
2308void pmmEnterWowlanResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
2309{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002310 tpSirHalWowlEnterParams pWowlEnterParams;
2311 eHalStatus rspStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 tSirResultCodes smeRspCode = eSIR_SME_SUCCESS;
2313
2314 /* we need to process all the deferred messages enqueued
2315 * since the initiating the WDA_WOWL_ENTER_REQ.
2316 */
2317 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
2318
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002319 pWowlEnterParams = (tpSirHalWowlEnterParams)(limMsg->bodyptr);
2320 if (NULL == pWowlEnterParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 {
2322 pmmLog(pMac, LOGE, FL("Recvd WDA_WOWL_ENTER_RSP with NULL msg "));
2323 smeRspCode = eSIR_SME_WOWL_ENTER_REQ_FAILED;
2324 }
2325 else
2326 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002327 rspStatus = pWowlEnterParams->status;
2328
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 if(rspStatus == eHAL_STATUS_SUCCESS)
2330 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002331 pmmLog(pMac, LOGW, FL("Rcv successful response from HAL to enter WOWLAN "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 pMac->pmm.gPmmState = ePMM_STATE_WOWLAN;
2333 }
2334 else
2335 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002336 pmmLog(pMac, LOGE, FL("HAL enter WOWLAN failed, informing SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 smeRspCode = eSIR_SME_WOWL_ENTER_REQ_FAILED;
2338 }
2339 }
2340
2341 limSendSmeRsp(pMac, eWNI_PMC_ENTER_WOWL_RSP, smeRspCode, 0, 0);
2342 return;
2343}
2344
2345/** ---------------------------------------------------------
2346\fn pmmExitWowlanRequestHandler
2347\brief PE process the eWNI_PMC_EXIT_WOWL_REQ message.
2348\ and sends WDA_WOWL_EXIT_REQ to HAL.
2349\param tpAniSirGlobal pMac
2350\return None
2351 ------------------------------------------------------------*/
2352void pmmExitWowlanRequestHandler(tpAniSirGlobal pMac)
2353{
2354 tSirRetStatus retStatus = eSIR_SUCCESS;
2355 tSirResultCodes smeRspCode = eSIR_SME_SUCCESS;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002356 tpPESession pSessionEntry;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07002357 tpSirHalWowlExitParams pHalWowlMsg = NULL;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002358 tANI_U8 PowersavesessionId = 0;
2359
2360 PowersavesessionId = pMac->pmm.sessionId;
2361
2362 if((pSessionEntry = peFindSessionBySessionId(pMac,PowersavesessionId)) == NULL )
2363 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302364 PELOGW(pmmLog(pMac, LOGE, FL("pmmWowl : failed to allocate memory"));)
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002365 smeRspCode = eSIR_SME_WOWL_EXIT_REQ_FAILED;
2366 goto failure;
2367 }
2368
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302369 pHalWowlMsg = vos_mem_malloc(sizeof(*pHalWowlMsg));
2370 if ( NULL == pHalWowlMsg )
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002371 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002372 pmmLog(pMac, LOGP, FL("Fail to allocate memory for WoWLAN Add Bcast Pattern "));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002373 smeRspCode = eSIR_SME_WOWL_EXIT_REQ_FAILED;
2374 goto failure;
2375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002376
2377#ifdef FEATURE_WLAN_DIAG_SUPPORT
2378 limDiagEventReport(pMac, WLAN_PE_DIAG_EXIT_WOWL_REQ_EVENT, NULL, 0, 0);
2379#endif //FEATURE_WLAN_DIAG_SUPPORT
2380
2381 if ( pMac->pmm.gPmmState != ePMM_STATE_WOWLAN )
2382 {
2383 pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002384 FL("Exit WOWLAN Request received in invalid state PMM=%d "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 pMac->pmm.gPmmState);
2386 smeRspCode = eSIR_SME_INVALID_PMM_STATE;
2387 goto failure;
2388 }
2389
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302390 (void) vos_mem_set((tANI_U8 *)pHalWowlMsg, sizeof(*pHalWowlMsg), 0);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002391 pHalWowlMsg->bssIdx = pSessionEntry->bssIdx;
2392
2393 if((retStatus = pmmSendExitWowlReq(pMac, pHalWowlMsg)) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 {
2395 pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002396 FL("Fail to send WDA_WOWL_EXIT_REQ, reason code %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 retStatus);
2398 smeRspCode = eSIR_SME_WOWL_EXIT_REQ_FAILED;
2399 goto failure;
2400 }
2401 return;
2402
2403failure:
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002404 if (pHalWowlMsg != NULL)
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302405 vos_mem_free(pHalWowlMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 limSendSmeRsp(pMac, eWNI_PMC_EXIT_WOWL_RSP, smeRspCode, 0, 0);
2407 return;
2408}
2409
2410/** ---------------------------------------------------------
2411\fn pmmSendExitWowlReq
2412\brief This function sends the WDA_WOWL_EXIT_REQ
2413\ message to HAL.
2414\param tpAniSirGlobal pMac
2415\return None
2416 ------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002417tSirRetStatus pmmSendExitWowlReq(tpAniSirGlobal pMac, tpSirHalWowlExitParams pHalWowlParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002418{
2419 tSirRetStatus retCode = eSIR_SUCCESS;
2420 tSirMsgQ msgQ;
2421
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002422 if (NULL == pHalWowlParams)
2423 return eSIR_FAILURE;
2424
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 msgQ.type = WDA_WOWL_EXIT_REQ;
2426 msgQ.reserved = 0;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002427 msgQ.bodyptr = pHalWowlParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 msgQ.bodyval = 0;
2429
2430 pmmLog(pMac, LOGW, FL("Sending WDA_WOWL_EXIT_REQ"));
2431
2432 /* we need to defer any incoming messages until
2433 * we get a WDA_WOWL_EXIT_RSP from HAL.
2434 */
2435 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2436
2437 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2438 pmmLog( pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002439 FL("Posting WDA_WOWL_EXIT_REQ failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 retCode );
2441
2442 return retCode;
2443}
2444
2445/** ---------------------------------------------------------
2446\fn pmmExitWowlanResponseHandler
2447\brief This function process the WDA_WOWL_EXIT_RSP message.
2448\ and sends back eWNI_PMC_EXIT_WOWL_RSP to SME.
2449\param tpAniSirGlobal pMac
2450\return None
2451 ------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002452void pmmExitWowlanResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
Jeff Johnson295189b2012-06-20 16:38:30 -07002453{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002454
2455 tpSirHalWowlExitParams pHalWowlRspMsg;
2456 eHalStatus rspStatus = eHAL_STATUS_FAILURE;
2457
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 /* we need to process all the deferred messages enqueued
2459 * since the initiating the WDA_WOWL_EXIT_REQ.
2460 */
2461 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
2462
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002463 pHalWowlRspMsg = (tpSirHalWowlExitParams)(limMsg->bodyptr);
2464 if (NULL == pHalWowlRspMsg)
2465 {
2466 pmmLog(pMac, LOGE, FL("Recvd WDA_WOWL_ENTER_RSP with NULL msg "));
2467 }
2468 else
2469 {
2470 // restore PMM state to BMPS mode
2471 pMac->pmm.gPmmState = ePMM_STATE_BMPS_SLEEP;
2472 rspStatus = pHalWowlRspMsg->status;
2473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002474
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002475 if( rspStatus == eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002477 pmmLog(pMac, LOGW, FL("Rcvd successful rsp from HAL to exit WOWLAN "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 limSendSmeRsp(pMac, eWNI_PMC_EXIT_WOWL_RSP, eSIR_SME_SUCCESS, 0, 0);
2479 }
2480 else
2481 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002482 pmmLog(pMac, LOGE, FL("Rcvd failure rsp from HAL to exit WOWLAN "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 limSendSmeRsp(pMac, eWNI_PMC_EXIT_WOWL_RSP, eSIR_SME_WOWL_EXIT_REQ_FAILED, 0, 0);
2484 }
2485 return;
2486}
2487
2488
2489// --------------------------------------------------------------------
2490/**
2491 * pmmImpsSendChangePwrSaveMsg
2492 *
2493 * FUNCTION:
2494 * This function is called to toggle the Idle mode power save mode
2495 *
2496 * LOGIC:
2497 *
2498 * ASSUMPTIONS:
2499 * None
2500 *
2501 * NOTE:
2502 *
2503 * @param Global handle to MAC
2504 * @param mode to be configured
2505 * @return None
2506 */
2507
2508tSirRetStatus pmmImpsSendChangePwrSaveMsg(tpAniSirGlobal pMac, tANI_U8 mode)
2509{
2510 tSirRetStatus retStatus = eSIR_SUCCESS;
2511 tSirMsgQ msgQ;
2512
2513 if (SIR_PM_SLEEP_MODE == mode)
2514 {
2515 msgQ.type = WDA_ENTER_IMPS_REQ;
Abhishek Singh525045c2014-12-15 17:18:45 +05302516 pmmLog (pMac, LOG1, FL("Sending WDA_ENTER_IMPS_REQ to HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 }
2518 else
2519 {
2520 msgQ.type = WDA_EXIT_IMPS_REQ;
Abhishek Singh525045c2014-12-15 17:18:45 +05302521 pmmLog (pMac, LOG1, FL("Sending WDA_EXIT_IMPS_REQ to HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 }
2523
2524 msgQ.reserved = 0;
2525 msgQ.bodyptr = NULL;
2526 msgQ.bodyval = 0;
2527
2528 /* we need to defer any incoming messages until we get a
2529 * WDA_ENTER_IMPS_REQ or WDA_EXIT_IMPS_RSP from HAL.
2530 */
2531 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002532 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 retStatus = wdaPostCtrlMsg(pMac, &msgQ);
2534 if ( eSIR_SUCCESS != retStatus )
2535 {
2536 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002537 FL("WDA_ENTER/EXIT_IMPS_REQ to HAL failed, reason=%X"), retStatus);)
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 }
2539
2540 return retStatus;
2541}
2542
2543// --------------------------------------------------------------------
2544/**
2545 * pmmUapsdSendChangePwrSaveMsg
2546 *
2547 * FUNCTION:
2548 * This function is called to send either WDA_ENTER_UAPSD_REQ
2549 * or WDA_EXIT_UAPSD_REQ to HAL.
2550 *
2551 * NOTE:
2552 *
2553 * @param pMac Global handle to MAC
2554 * @param mode mode to be configured
2555 * @return tSirRetStatus
2556 */
2557tSirRetStatus pmmUapsdSendChangePwrSaveMsg (tpAniSirGlobal pMac, tANI_U8 mode)
2558{
2559 tSirRetStatus retStatus = eSIR_SUCCESS;
2560 tpUapsdParams pUapsdParams = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 tSirMsgQ msgQ;
Jeff Johnsone7245742012-09-05 17:12:55 -07002562 tpPESession pSessionEntry;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002563 tpExitUapsdParams pExitUapsdParams = NULL;
2564
2565 if((pSessionEntry = peGetValidPowerSaveSession(pMac)) == NULL )
2566 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302567 PELOGW(pmmLog(pMac, LOGW, FL("pmmUapsd : failed to allocate memory"));)
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002568 retStatus = eSIR_FAILURE;
2569 return retStatus;
2570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002571
2572 if (SIR_PM_SLEEP_MODE == mode)
2573 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302574 pUapsdParams = vos_mem_malloc(sizeof(tUapsdParams));
2575 if ( NULL == pUapsdParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302577 PELOGW(pmmLog(pMac, LOGW, FL("pmmUapsd : failed to allocate memory"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 retStatus = eSIR_MEM_ALLOC_FAILED;
2579 return retStatus;
2580 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002581
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302582 vos_mem_set( (tANI_U8 *)pUapsdParams, sizeof(tUapsdParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 msgQ.type = WDA_ENTER_UAPSD_REQ;
2584 msgQ.bodyptr = pUapsdParams;
2585
Mukul Sharma7c86d712014-03-21 15:43:09 +05302586 /*
2587 * An AC is delivery enabled AC if the bit for that AC is set into the
2588 * gAcAdmitMask[SIR_MAC_DIRECTION_DLINK],it is not set then we will take Static values.
2589 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002590
Mukul Sharma7c86d712014-03-21 15:43:09 +05302591 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] & LIM_ADMIT_MASK_FLAG_ACBE)
2592 {
2593 pUapsdParams->beDeliveryEnabled = LIM_UAPSD_GET(ACBE, pMac->lim.gUapsdPerAcDeliveryEnableMask);
2594 }
2595 else
2596 {
2597 pUapsdParams->beDeliveryEnabled = LIM_UAPSD_GET(ACBE, pMac->lim.gUapsdPerAcBitmask);
2598 }
2599 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] & LIM_ADMIT_MASK_FLAG_ACBK)
2600 {
2601 pUapsdParams->bkDeliveryEnabled = LIM_UAPSD_GET(ACBK, pMac->lim.gUapsdPerAcDeliveryEnableMask);
2602 }
2603 else
2604 {
2605 pUapsdParams->bkDeliveryEnabled = LIM_UAPSD_GET(ACBK, pMac->lim.gUapsdPerAcBitmask);
2606 }
2607 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] & LIM_ADMIT_MASK_FLAG_ACVI)
2608 {
2609 pUapsdParams->viDeliveryEnabled = LIM_UAPSD_GET(ACVI, pMac->lim.gUapsdPerAcDeliveryEnableMask);
2610 }
2611 else
2612 {
2613 pUapsdParams->viDeliveryEnabled = LIM_UAPSD_GET(ACVI, pMac->lim.gUapsdPerAcBitmask);
2614 }
2615
2616 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] & LIM_ADMIT_MASK_FLAG_ACVO)
2617 {
2618 pUapsdParams->voDeliveryEnabled = LIM_UAPSD_GET(ACVO, pMac->lim.gUapsdPerAcDeliveryEnableMask);
2619 }
2620 else
2621 {
2622 pUapsdParams->voDeliveryEnabled = LIM_UAPSD_GET(ACVO, pMac->lim.gUapsdPerAcBitmask);
2623 }
2624
2625 /*
2626 * An AC is trigger enabled AC if the bit for that AC is set into the
2627 * gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK],it is not set then we will take Static values.
2628 */
2629
2630 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] & LIM_ADMIT_MASK_FLAG_ACBE)
2631 {
2632 pUapsdParams->beTriggerEnabled = LIM_UAPSD_GET(ACBE, pMac->lim.gUapsdPerAcTriggerEnableMask);
2633 }
2634 else
2635 {
2636 pUapsdParams->beTriggerEnabled = LIM_UAPSD_GET(ACBE, pMac->lim.gUapsdPerAcBitmask);
2637 }
2638 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] & LIM_ADMIT_MASK_FLAG_ACBK)
2639 {
2640 pUapsdParams->bkTriggerEnabled = LIM_UAPSD_GET(ACBK, pMac->lim.gUapsdPerAcTriggerEnableMask);
2641 }
2642 else
2643 {
2644 pUapsdParams->bkTriggerEnabled = LIM_UAPSD_GET(ACBK, pMac->lim.gUapsdPerAcBitmask);
2645 }
2646 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] & LIM_ADMIT_MASK_FLAG_ACVI)
2647 {
2648 pUapsdParams->viTriggerEnabled = LIM_UAPSD_GET(ACVI, pMac->lim.gUapsdPerAcTriggerEnableMask);
2649 }
2650 else
2651 {
2652 pUapsdParams->viTriggerEnabled = LIM_UAPSD_GET(ACVI, pMac->lim.gUapsdPerAcBitmask);
2653 }
2654
2655 if ( pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] & LIM_ADMIT_MASK_FLAG_ACVO)
2656 {
2657 pUapsdParams->voTriggerEnabled = LIM_UAPSD_GET(ACVO, pMac->lim.gUapsdPerAcTriggerEnableMask);
2658 }
2659 else
2660 {
2661 pUapsdParams->voTriggerEnabled = LIM_UAPSD_GET(ACVO, pMac->lim.gUapsdPerAcBitmask);
2662 }
2663
Jeff Johnsone7245742012-09-05 17:12:55 -07002664 pUapsdParams->bssIdx = pSessionEntry->bssIdx;
2665
Madan Mohan Koyyalamudic0a75a42013-10-07 04:20:49 +05302666 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002667 FL("UAPSD Mask: static = 0x%x, DeliveryEnabled = 0x%x, TriggerEnabled = 0x%x "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 pMac->lim.gUapsdPerAcBitmask,
2669 pMac->lim.gUapsdPerAcDeliveryEnableMask,
2670 pMac->lim.gUapsdPerAcTriggerEnableMask);)
2671
Madan Mohan Koyyalamudic0a75a42013-10-07 04:20:49 +05302672 PELOGW(pmmLog(pMac, LOGW, FL("Delivery Enabled: BK=%d, BE=%d, Vi=%d, Vo=%d "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 pUapsdParams->bkDeliveryEnabled,
2674 pUapsdParams->beDeliveryEnabled,
2675 pUapsdParams->viDeliveryEnabled,
2676 pUapsdParams->voDeliveryEnabled);)
2677
Madan Mohan Koyyalamudic0a75a42013-10-07 04:20:49 +05302678 PELOGW(pmmLog(pMac, LOGW, FL("Trigger Enabled: BK=%d, BE=%d, Vi=%d, Vo=%d "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 pUapsdParams->bkTriggerEnabled,
2680 pUapsdParams->beTriggerEnabled,
2681 pUapsdParams->viTriggerEnabled,
2682 pUapsdParams->voTriggerEnabled);)
2683
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +05302684 if (pUapsdParams->bkDeliveryEnabled == 0 &&
2685 pUapsdParams->beDeliveryEnabled == 0 &&
2686 pUapsdParams->viDeliveryEnabled == 0 &&
2687 pUapsdParams->voDeliveryEnabled == 0 &&
2688 pUapsdParams->bkTriggerEnabled == 0 &&
2689 pUapsdParams->beTriggerEnabled == 0 &&
2690 pUapsdParams->viTriggerEnabled == 0 &&
2691 pUapsdParams->voTriggerEnabled == 0)
2692 {
2693 limLog(pMac, LOGW, FL("No Need to enter UAPSD since Trigger "
2694 "Enabled and Delivery Enabled Mask is zero for all ACs"));
2695 retStatus = eSIR_PMM_INVALID_REQ;
2696 return retStatus;
2697 }
2698
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002699 PELOGW(pmmLog (pMac, LOGW, FL("pmmUapsd: Sending WDA_ENTER_UAPSD_REQ to HAL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 }
2701 else
2702 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302703 pExitUapsdParams = vos_mem_malloc(sizeof(tExitUapsdParams));
2704 if ( NULL == pExitUapsdParams )
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002705 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302706 PELOGW(pmmLog(pMac, LOGW, FL("pmmUapsd : failed to allocate memory"));)
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002707 retStatus = eSIR_MEM_ALLOC_FAILED;
2708 return retStatus;
2709 }
2710
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302711 vos_mem_set( (tANI_U8 *)pExitUapsdParams, sizeof(tExitUapsdParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 msgQ.type = WDA_EXIT_UAPSD_REQ;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002713 msgQ.bodyptr = pExitUapsdParams;
2714 pExitUapsdParams->bssIdx = pSessionEntry->bssIdx;
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002715 PELOGW(pmmLog (pMac, LOGW, FL("pmmUapsd: Sending WDA_EXIT_UAPSD_REQ to HAL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 }
2717
2718 /* we need to defer any incoming messages until we get a
2719 * WDA_ENTER/EXIT_UAPSD_RSP from HAL.
2720 */
2721 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2722
2723 msgQ.reserved = 0;
2724 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002725 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 retStatus = wdaPostCtrlMsg(pMac, &msgQ);
2727 if ( eSIR_SUCCESS != retStatus )
2728 {
2729 PELOGE(pmmLog(pMac, LOGE,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002730 FL("pmmUapsd: WDA_ENTER/EXIT_UAPSD_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 retStatus);)
2732 if (SIR_PM_SLEEP_MODE == mode)
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302733 vos_mem_free(pUapsdParams);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002734 else
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +05302735 vos_mem_free(pExitUapsdParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 }
2737
2738 return retStatus;
2739}
2740
2741
2742// --------------------------------------------------------------------
2743/**
2744 * pmmUpdateImpsPwrSaveStats
2745 *
2746 * FUNCTION:
2747 * This function is called to update the power save statistics in MAC
2748 * for Idle mode power save
2749 *
2750 * LOGIC:
2751 *
2752 * ASSUMPTIONS:
2753 * None
2754 *
2755 * NOTE:
2756 *
2757 * @param Global handle to MAC
2758 * @return None
2759 */
2760
2761void pmmImpsUpdatePwrSaveStats(tpAniSirGlobal pMac)
2762{
2763/*
2764 tANI_U64 TimeAwake = 0;
2765
2766 pMac->pmm.ImpsSleepTimeStamp = vos_timer_get_system_ticks();
2767
2768 if (pMac->pmm.ImpsWakeupTimeStamp)
2769 {
2770 TimeAwake = (pMac->pmm.ImpsSleepTimeStamp - pMac->pmm.ImpsWakeupTimeStamp) / 10 ;
2771 }
2772 else
2773 {
2774 TimeAwake = 0;
2775 }
2776
2777 if (TimeAwake > pMac->pmm.ImpsMaxTimeAwake)
2778 {
2779 pMac->pmm.ImpsMaxTimeAwake = TimeAwake;
2780 }
2781
2782 if ((!pMac->pmm.ImpsMinTimeAwake) || (TimeAwake < pMac->pmm.ImpsMinTimeAwake))
2783 {
2784 pMac->pmm.ImpsMinTimeAwake = TimeAwake;
2785 }
2786
2787 pMac->pmm.ImpsAvgTimeAwake = ((pMac->pmm.ImpsAvgTimeAwake * pMac->pmm.ImpsCntSleep) + TimeAwake) / (pMac->pmm.ImpsCntSleep + 1);
2788
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05302789*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 (pMac->pmm.ImpsCntSleep)++;
2791
2792 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002793}
2794
2795
2796// --------------------------------------------------------------------
2797/**
2798 * pmmImpsUpdateWakeupStats
2799 *
2800 * FUNCTION:
2801 * This function is called to update the Wake up statistics in MAC
2802 * for Idle mode power save
2803 *
2804 * LOGIC:
2805 *
2806 * ASSUMPTIONS:
2807 * None
2808 *
2809 * NOTE:
2810 *
2811 * @param Global handle to MAC
2812 * @return None
2813 */
2814
2815void pmmImpsUpdateWakeupStats (tpAniSirGlobal pMac)
2816{
2817/*
2818 tANI_U64 SleepTime = 0;
2819
2820 pMac->pmm.ImpsWakeupTimeStamp = vos_timer_get_system_ticks();
2821
2822 SleepTime = (pMac->pmm.ImpsWakeupTimeStamp - pMac->pmm.ImpsSleepTimeStamp) / 10;
2823
2824 if (SleepTime > pMac->pmm.ImpsMaxSleepTime)
2825 {
2826 pMac->pmm.ImpsMaxSleepTime = SleepTime;
2827 }
2828
2829 if ((!pMac->pmm.ImpsMinSleepTime) || (SleepTime < pMac->pmm.ImpsMinSleepTime))
2830 {
2831 pMac->pmm.ImpsMinSleepTime = SleepTime;
2832 }
2833
2834 pMac->pmm.ImpsAvgSleepTime = ( ( (pMac->pmm.ImpsAvgSleepTime * pMac->pmm.ImpsCntAwake) + SleepTime) / (pMac->pmm.ImpsCntAwake + 1));
2835
Sandeep Puligilla383bbfc2014-05-01 15:06:09 +05302836*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 (pMac->pmm.ImpsCntAwake)++;
2838
2839 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002840}
2841
2842// Collects number of times error occurred while going to sleep mode
2843void pmmImpsUpdateSleepErrStats(tpAniSirGlobal pMac,
2844 tSirRetStatus retStatus)
2845{
2846 pMac->pmm.ImpsSleepErrCnt++;
2847 pMac->pmm.ImpsLastErr = retStatus;
2848 return;
2849}
2850
2851// Collects number of times error occurred while waking up from sleep mode
2852void pmmImpsUpdateWakeupErrStats(tpAniSirGlobal pMac,
2853 tSirRetStatus retStatus)
2854{
2855 pMac->pmm.ImpsWakeupErrCnt++;
2856 pMac->pmm.ImpsLastErr = retStatus;
2857 return;
2858}
2859
2860
2861// Collects number of times the system has received request or
2862// response in an invalid state
2863void pmmImpsUpdateErrStateStats(tpAniSirGlobal pMac)
2864{
2865 pMac->pmm.ImpsInvalidStateCnt++;
2866 return;
2867}
2868
2869// Collects number of packets dropped while in IMPS mode
2870void pmmImpsUpdatePktDropStats(tpAniSirGlobal pMac)
2871{
2872
2873 pMac->pmm.ImpsPktDrpInSleepMode++;
2874 return;
2875}
2876
2877// Collects number of packets dropped while in BMPS mode
2878void pmmBmpsUpdatePktDropStats(tpAniSirGlobal pMac)
2879{
2880
2881 pMac->pmm.BmpsPktDrpInSleepMode++;
2882 return;
2883}
2884
2885// Collects statistics for number of times BMPS init failed
2886void pmmBmpsUpdateInitFailureCnt(tpAniSirGlobal pMac)
2887{
2888
2889 pMac->pmm.BmpsInitFailCnt++;
2890 return;
2891}
2892
2893// Collects statistics for number of times sleep request failed
2894void pmmBmpsUpdateSleepReqFailureCnt(tpAniSirGlobal pMac)
2895{
2896
2897 pMac->pmm.BmpsSleeReqFailCnt++;
2898 return;
2899}
2900
2901// Collects statistics for number of times Wakeup request failed
2902void pmmBmpsUpdateWakeupReqFailureCnt(tpAniSirGlobal pMac)
2903{
2904
2905 pMac->pmm.BmpsWakeupReqFailCnt++;
2906 return;
2907}
2908
2909// Collects statistics for number of times request / response received in invalid state
2910void pmmBmpsUpdateInvalidStateCnt(tpAniSirGlobal pMac)
2911{
2912
2913 pMac->pmm.BmpsInvStateCnt++;
2914 return;
2915}
2916
2917// Collects statistics for number of times wakeup indications received
2918void pmmBmpsUpdateWakeupIndCnt(tpAniSirGlobal pMac)
2919{
2920 pMac->pmm.BmpsWakeupIndCnt++;
2921 return;
2922}
2923
2924// Collects statistics for number of times wakeup indications received
2925void pmmBmpsUpdateHalReqFailureCnt(tpAniSirGlobal pMac)
2926{
2927 pMac->pmm.BmpsHalReqFailCnt++;
2928 return;
2929}
2930
2931// Collects statistics for number of times requests received from HDD in
2932// invalid device role
2933void pmmBmpsUpdateReqInInvalidRoleCnt(tpAniSirGlobal pMac)
2934{
2935 pMac->pmm.BmpsReqInInvalidRoleCnt++;
2936 return;
2937}
2938
2939#if 0
2940// Update the sleep statistics
2941void pmmUpdateDroppedPktStats(tpAniSirGlobal pMac)
2942{
2943 switch (pMac->pmm.gPmmState)
2944 {
2945 case ePMM_STATE_BMPS_SLEEP:
2946 pmmBmpsUpdatePktDropStats(pMac);
2947 break;
2948
2949 case ePMM_STATE_IMPS_SLEEP:
2950 pmmImpsUpdatePktDropStats(pMac);
2951 break;
2952
2953 default:
2954 break;
2955 }
2956 return;
2957
2958}
2959#endif
2960
2961// Resets PMM state ePMM_STATE_READY
2962void pmmResetPmmState(tpAniSirGlobal pMac)
2963{
2964 pMac->pmm.gPmmState = ePMM_STATE_READY;
2965
2966 pMac->pmm.inMissedBeaconScenario = FALSE;
2967 return;
2968}
2969
2970/* Sends Background scan message back to Lim */
2971void pmmSendMessageToLim(tpAniSirGlobal pMac,
2972 tANI_U32 msgId)
2973{
2974 tSirMsgQ limMsg;
2975 tANI_U32 statusCode;
2976
2977 limMsg.type = (tANI_U16) msgId;
2978 limMsg.bodyptr = NULL;
2979 limMsg.bodyval = 0;
2980
2981 if ((statusCode = limPostMsgApi(pMac, &limMsg)) != eSIR_SUCCESS)
2982 {
2983 PELOGW(pmmLog(pMac, LOGW,
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07002984 FL("posting message %X to LIM failed, reason=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 limMsg.type, statusCode);)
2986 }
2987}
2988
2989#ifdef WLAN_FEATURE_PACKET_FILTERING
2990void pmmFilterMatchCountResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
2991{
2992 tpSirRcvFltPktMatchRsp pRcvFltPktMatchCntRsp;
2993 eHalStatus rspStatus;
2994 tSirResultCodes smeRspCode = eSIR_SME_SUCCESS;
2995
2996 /* we need to process all the deferred messages enqueued
2997 * since the initiating the WDA_PACKET_COALESCING_FILTER_MATCH_COUNT_REQ.
2998 */
2999 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3000
3001 pRcvFltPktMatchCntRsp = (tpSirRcvFltPktMatchRsp)(limMsg->bodyptr);
3002 if (NULL == pRcvFltPktMatchCntRsp)
3003 {
3004 pmmLog(pMac, LOGE, FL("Received "
3005 "WDA_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP with NULL msg "));
3006 smeRspCode = eSIR_SME_PC_FILTER_MATCH_COUNT_REQ_FAILED;
3007 }
3008 else
3009 {
3010 rspStatus = pRcvFltPktMatchCntRsp->status;
3011 if (eHAL_STATUS_SUCCESS == rspStatus)
3012 {
3013 pmmLog(pMac, LOGE, FL("Rcv successful response from HAL to get "
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07003014 "Packet Coalescing Filter Match Count"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 }
3016 else
3017 {
3018 pmmLog(pMac, LOGE, FL("HAL failed to get Packet Coalescing "
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07003019 "Filter Match Count, informing SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 smeRspCode = eSIR_SME_PC_FILTER_MATCH_COUNT_REQ_FAILED;
3021 }
3022 }
3023
3024 limSendSmeRsp(pMac, eWNI_PMC_PACKET_COALESCING_FILTER_MATCH_COUNT_RSP,
3025 smeRspCode, 0, 0);
3026 return;
3027}
3028#endif // WLAN_FEATURE_PACKET_FILTERING
3029
3030#ifdef WLAN_FEATURE_GTK_OFFLOAD
3031void pmmGTKOffloadGetInfoResponseHandler(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
3032{
3033 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRspParams;
3034 eHalStatus rspStatus;
3035 tSirResultCodes smeRspCode = eSIR_SME_SUCCESS;
3036
3037 /* we need to process all the deferred messages enqueued
3038 * since the initiating the WDA_GTK_OFFLOAD_GETINFO_REQ.
3039 */
3040 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3041
3042 pGtkOffloadGetInfoRspParams = (tpSirGtkOffloadGetInfoRspParams)(limMsg->bodyptr);
3043 if (NULL == pGtkOffloadGetInfoRspParams)
3044 {
3045 pmmLog(pMac, LOGE, FL("Received WDA_GTK_OFFLOAD_GETINFO_RSP with NULL msg "));
3046 smeRspCode = eSIR_SME_GTK_OFFLOAD_GETINFO_REQ_FAILED;
3047 }
3048 else
3049 {
3050 rspStatus = pGtkOffloadGetInfoRspParams->ulStatus;
3051 if(rspStatus == eHAL_STATUS_SUCCESS)
3052 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07003053 pmmLog(pMac, LOGW, FL("Rcv successful response from HAL to get GTK Offload Information"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 }
3055 else
3056 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -07003057 pmmLog(pMac, LOGE, FL("HAL failed to get GTK Offload Information, informing SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 smeRspCode = eSIR_SME_GTK_OFFLOAD_GETINFO_REQ_FAILED;
3059 }
3060 }
3061
3062 limSendSmeRsp(pMac, eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP, smeRspCode, 0, 0);
3063 return;
3064}
3065#endif // WLAN_FEATURE_GTK_OFFLOAD