blob: d031e256ce5d78ba942dedac3c492f27002fa9d4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala746a9452013-06-11 12:45:54 +05302 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
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.
20*/
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080021/*
Gopichand Nakkala746a9452013-06-11 12:45:54 +053022* Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
23* All Rights Reserved.
24* Qualcomm Atheros Confidential and Proprietary.
25*/
Jeff Johnson295189b2012-06-20 16:38:30 -070026
27/******************************************************************************
28*
29* Name: pmcApi.c
30*
31* Description: Routines that make up the Power Management Control (PMC) API.
32*
Gopichand Nakkala746a9452013-06-11 12:45:54 +053033* Copyright 2008 (c) Qualcomm Technologies, Inc.
Jeff Johnson295189b2012-06-20 16:38:30 -070034* All Rights Reserved.
Gopichand Nakkala746a9452013-06-11 12:45:54 +053035* Qualcomm Technologies Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -070036*
37******************************************************************************/
38
39#include "palTypes.h"
40#include "aniGlobal.h"
41#include "palTimer.h"
42#include "csrLinkList.h"
43#include "smsDebug.h"
44#include "pmcApi.h"
45#include "pmc.h"
46#include "cfgApi.h"
47#include "smeInside.h"
48#include "csrInsideApi.h"
49#include "wlan_ps_wow_diag.h"
50#include "wlan_qct_wda.h"
51#include "limSessionUtils.h"
52#include "csrInsideApi.h"
53
54extern void pmcReleaseCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand );
55
56void pmcCloseDeferredMsgList(tpAniSirGlobal pMac);
57void pmcCloseDeviceStateUpdateList(tpAniSirGlobal pMac);
58void pmcCloseRequestStartUapsdList(tpAniSirGlobal pMac);
59void pmcCloseRequestBmpsList(tpAniSirGlobal pMac);
60void pmcCloseRequestFullPowerList(tpAniSirGlobal pMac);
61void pmcClosePowerSaveCheckList(tpAniSirGlobal pMac);
62
63/******************************************************************************
64*
65* Name: pmcOpen
66*
67* Description:
68* Does a PMC open operation on the device.
69*
70* Parameters:
71* hHal - HAL handle for device
72*
73* Returns:
74* eHAL_STATUS_SUCCESS - open successful
75* eHAL_STATUS_FAILURE - open not successful
76*
77******************************************************************************/
78eHalStatus pmcOpen (tHalHandle hHal)
79{
80 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
81
Katya Nigam70d68332013-09-16 16:49:45 +053082 pmcLog(pMac, LOG2, FL("Entering pmcOpen"));
Jeff Johnson295189b2012-06-20 16:38:30 -070083
84 /* Initialize basic PMC information about device. */
85 pMac->pmc.powerSource = BATTERY_POWER;
86 pMac->pmc.pmcState = STOPPED;
87 pMac->pmc.pmcReady = FALSE;
88
89 /* Initialize Power Save Modes */
90 pMac->pmc.impsEnabled = FALSE;
91 pMac->pmc.autoBmpsEntryEnabled = FALSE;
92 pMac->pmc.smpsEnabled = FALSE;
93 pMac->pmc.uapsdEnabled = TRUE;
94 pMac->pmc.bmpsEnabled = TRUE;
95 pMac->pmc.standbyEnabled = TRUE;
96 pMac->pmc.wowlEnabled = TRUE;
97 pMac->pmc.rfSuppliesVotedOff= FALSE;
98
99 palZeroMemory(pMac->hHdd, &(pMac->pmc.bmpsConfig), sizeof(tPmcBmpsConfigParams));
100 palZeroMemory(pMac->hHdd, &(pMac->pmc.impsConfig), sizeof(tPmcImpsConfigParams));
101 palZeroMemory(pMac->hHdd, &(pMac->pmc.smpsConfig), sizeof(tPmcSmpsConfigParams));
102
103 /* Allocate a timer to use with IMPS. */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530104 if (vos_timer_init(&pMac->pmc.hImpsTimer, VOS_TIMER_TYPE_SW, pmcImpsTimerExpired, hHal) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700105 {
Katya Nigam70d68332013-09-16 16:49:45 +0530106 pmcLog(pMac, LOGE, FL("Cannot allocate timer for IMPS"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700107 return eHAL_STATUS_FAILURE;
108 }
109
110 /* Allocate a timer used in Full Power State to measure traffic
111 levels and determine when to enter BMPS. */
112 if (!VOS_IS_STATUS_SUCCESS(vos_timer_init(&pMac->pmc.hTrafficTimer,
113 VOS_TIMER_TYPE_SW, pmcTrafficTimerExpired, hHal)))
114 {
Katya Nigam70d68332013-09-16 16:49:45 +0530115 pmcLog(pMac, LOGE, FL("Cannot allocate timer for traffic measurement"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700116 return eHAL_STATUS_FAILURE;
117 }
118
119#ifdef FEATURE_WLAN_DIAG_SUPPORT
120 /* Allocate a timer used to report current PMC state through periodic DIAG event */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530121 if (vos_timer_init(&pMac->pmc.hDiagEvtTimer, VOS_TIMER_TYPE_SW, pmcDiagEvtTimerExpired, hHal) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700122 {
Katya Nigam70d68332013-09-16 16:49:45 +0530123 pmcLog(pMac, LOGE, FL("Cannot allocate timer for diag event reporting"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700124 return eHAL_STATUS_FAILURE;
125 }
126#endif
127
128 //Initialize the default value for Bmps related config.
129 pMac->pmc.bmpsConfig.trafficMeasurePeriod = BMPS_TRAFFIC_TIMER_DEFAULT;
130 pMac->pmc.bmpsConfig.bmpsPeriod = WNI_CFG_LISTEN_INTERVAL_STADEF;
131
132 /* Allocate a timer used to schedule a deferred power save mode exit. */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530133 if (vos_timer_init(&pMac->pmc.hExitPowerSaveTimer, VOS_TIMER_TYPE_SW,
134 pmcExitPowerSaveTimerExpired, hHal) !=VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 {
Katya Nigam70d68332013-09-16 16:49:45 +0530136 pmcLog(pMac, LOGE, FL("Cannot allocate exit power save mode timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 PMC_ABORT;
138 return eHAL_STATUS_FAILURE;
139 }
140
141 /* Initialize lists for power save check routines and request full power callback routines. */
142 if (csrLLOpen(pMac->hHdd, &pMac->pmc.powerSaveCheckList) != eHAL_STATUS_SUCCESS)
143 {
Katya Nigam70d68332013-09-16 16:49:45 +0530144 pmcLog(pMac, LOGE, FL("Cannot initialize power save check routine list"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 PMC_ABORT;
146 return eHAL_STATUS_FAILURE;
147 }
148 if (csrLLOpen(pMac->hHdd, &pMac->pmc.requestFullPowerList) != eHAL_STATUS_SUCCESS)
149 {
Katya Nigam70d68332013-09-16 16:49:45 +0530150 pmcLog(pMac, LOGE, FL("Cannot initialize request full power callback routine list"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 PMC_ABORT;
152 return eHAL_STATUS_FAILURE;
153 }
154
155 /* Initialize lists for request BMPS callback routines. */
156 if (csrLLOpen(pMac->hHdd, &pMac->pmc.requestBmpsList) !=
157 eHAL_STATUS_SUCCESS)
158 {
Katya Nigam70d68332013-09-16 16:49:45 +0530159 pmcLog(pMac, LOGE, "PMC: cannot initialize request BMPS callback routine list");
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 return eHAL_STATUS_FAILURE;
161 }
162
163 /* Initialize lists for request start UAPSD callback routines. */
164 if (csrLLOpen(pMac->hHdd, &pMac->pmc.requestStartUapsdList) != eHAL_STATUS_SUCCESS)
165 {
Katya Nigam70d68332013-09-16 16:49:45 +0530166 pmcLog(pMac, LOGE, "PMC: cannot initialize request start UAPSD callback routine list");
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 return eHAL_STATUS_FAILURE;
168 }
169
170 /* Initialize lists for device state update indication callback routines. */
171 if (csrLLOpen(pMac->hHdd, &pMac->pmc.deviceStateUpdateIndList) != eHAL_STATUS_SUCCESS)
172 {
Katya Nigam70d68332013-09-16 16:49:45 +0530173 pmcLog(pMac, LOGE, "PMC: cannot initialize device state update indication callback list");
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 return eHAL_STATUS_FAILURE;
175 }
176
177 if (csrLLOpen(pMac->hHdd, &pMac->pmc.deferredMsgList) != eHAL_STATUS_SUCCESS)
178 {
Katya Nigam70d68332013-09-16 16:49:45 +0530179 pmcLog(pMac, LOGE, FL("Cannot initialize deferred msg list"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 PMC_ABORT;
181 return eHAL_STATUS_FAILURE;
182 }
183
184 return eHAL_STATUS_SUCCESS;
185}
186
187
188/******************************************************************************
189*
190* Name: pmcStart
191*
192* Description:
193* Does a PMC start operation on the device.
194*
195* Parameters:
196* hHal - HAL handle for device
197*
198* Returns:
199* eHAL_STATUS_SUCCESS - start successful
200* eHAL_STATUS_FAILURE - start not successful
201*
202******************************************************************************/
203eHalStatus pmcStart (tHalHandle hHal)
204{
205 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
206 tSirMacHTMIMOPowerSaveState htMimoPowerSaveState;
207
Katya Nigam70d68332013-09-16 16:49:45 +0530208 pmcLog(pMac, LOG2, FL("Entering pmcStart"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700209
210 /* Initialize basic PMC information about device. */
211 pMac->pmc.pmcState = FULL_POWER;
212 pMac->pmc.requestFullPowerPending = FALSE;
213 pMac->pmc.uapsdSessionRequired = FALSE;
214 pMac->pmc.wowlModeRequired = FALSE;
215 pMac->pmc.bmpsRequestedByHdd = FALSE;
216 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
217 pMac->pmc.remainInPowerActiveThreshold = 0;
218
219 /* WLAN Switch initial states. */
220 pMac->pmc.hwWlanSwitchState = ePMC_SWITCH_ON;
221 pMac->pmc.swWlanSwitchState = ePMC_SWITCH_ON;
222
223 /* No IMPS callback routine yet. */
224 pMac->pmc.impsCallbackRoutine = NULL;
225
226 /* No STANDBY callback routine yet. */
227 pMac->pmc.standbyCallbackRoutine = NULL;
228
229 /* No WOWL callback routine yet. */
230 pMac->pmc.enterWowlCallbackRoutine = NULL;
231
232 /* Initialize BMPS traffic counts. */
233 pMac->pmc.cLastTxUnicastFrames = 0;
234 pMac->pmc.cLastRxUnicastFrames = 0;
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -0700235 pMac->pmc.ImpsReqFailed = VOS_FALSE;
236 pMac->pmc.ImpsReqFailCnt = 0;
237 pMac->pmc.ImpsReqTimerFailed = 0;
238 pMac->pmc.ImpsReqTimerfailCnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700239
240 /* Configure SMPS. */
241 if (pMac->pmc.smpsEnabled && (pMac->pmc.powerSource != AC_POWER || pMac->pmc.smpsConfig.enterOnAc))
242 {
243 if (pMac->pmc.smpsConfig.mode == ePMC_DYNAMIC_SMPS)
244 htMimoPowerSaveState = eSIR_HT_MIMO_PS_DYNAMIC;
245 if (pMac->pmc.smpsConfig.mode == ePMC_STATIC_SMPS)
246 htMimoPowerSaveState = eSIR_HT_MIMO_PS_STATIC;
247 }
248 else
249 htMimoPowerSaveState = eSIR_HT_MIMO_PS_NO_LIMIT;
250
251 if (pmcSendMessage(hHal, eWNI_PMC_SMPS_STATE_IND, &htMimoPowerSaveState,
252 sizeof(tSirMacHTMIMOPowerSaveState)) != eHAL_STATUS_SUCCESS)
253 return eHAL_STATUS_FAILURE;
254
255#ifdef FEATURE_WLAN_DIAG_SUPPORT
256 if (pmcStartDiagEvtTimer(hHal) != eHAL_STATUS_SUCCESS)
257 {
258 return eHAL_STATUS_FAILURE;
259 }
260#endif
261
262#if defined(ANI_LOGDUMP)
263 pmcDumpInit(hHal);
264#endif
265
266 return eHAL_STATUS_SUCCESS;
267}
268
269
270/******************************************************************************
271*
272* Name: pmcStop
273*
274* Description:
275* Does a PMC stop operation on the device.
276*
277* Parameters:
278* hHal - HAL handle for device
279*
280* Returns:
281* eHAL_STATUS_SUCCESS - stop successful
282* eHAL_STATUS_FAILURE - stop not successful
283*
284******************************************************************************/
285eHalStatus pmcStop (tHalHandle hHal)
286{
287 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
288 tListElem *pEntry;
289 tPmcDeferredMsg *pDeferredMsg;
290
Katya Nigam70d68332013-09-16 16:49:45 +0530291 pmcLog(pMac, LOG2, FL("Entering pmcStop"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700292
293 /* Cancel any running timers. */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530294 if (vos_timer_stop(&pMac->pmc.hImpsTimer) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 {
Katya Nigam70d68332013-09-16 16:49:45 +0530296 pmcLog(pMac, LOGE, FL("Cannot cancel IMPS timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 }
298
299 pmcStopTrafficTimer(hHal);
300
301#ifdef FEATURE_WLAN_DIAG_SUPPORT
302 pmcStopDiagEvtTimer(hHal);
303#endif
304
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530305 if (vos_timer_stop(&pMac->pmc.hExitPowerSaveTimer) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 {
Katya Nigam70d68332013-09-16 16:49:45 +0530307 pmcLog(pMac, LOGE, FL("Cannot cancel exit power save mode timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 }
309
310 /* Do all the callbacks. */
311 pmcDoCallbacks(hHal, eHAL_STATUS_FAILURE);
312 pmcDoBmpsCallbacks(hHal, eHAL_STATUS_FAILURE);
313 pMac->pmc.uapsdSessionRequired = FALSE;
314 pmcDoStartUapsdCallbacks(hHal, eHAL_STATUS_FAILURE);
315 pmcDoStandbyCallbacks(hHal, eHAL_STATUS_FAILURE);
316
317 //purge the deferred msg list
318 csrLLLock( &pMac->pmc.deferredMsgList );
319 while( NULL != ( pEntry = csrLLRemoveHead( &pMac->pmc.deferredMsgList, eANI_BOOLEAN_FALSE ) ) )
320 {
321 pDeferredMsg = GET_BASE_ADDR( pEntry, tPmcDeferredMsg, link );
322 palFreeMemory( pMac->hHdd, pDeferredMsg );
323 }
324 csrLLUnlock( &pMac->pmc.deferredMsgList );
325
326 /* PMC is stopped. */
327 pMac->pmc.pmcState = STOPPED;
328 pMac->pmc.pmcReady = FALSE;
329
330 return eHAL_STATUS_SUCCESS;
331}
332
333
334/******************************************************************************
335*
336* Name: pmcClose
337*
338* Description:
339* Does a PMC close operation on the device.
340*
341* Parameters:
342* hHal - HAL handle for device
343*
344* Returns:
345* eHAL_STATUS_SUCCESS - close successful
346* eHAL_STATUS_FAILURE - close not successful
347*
348******************************************************************************/
349eHalStatus pmcClose (tHalHandle hHal)
350{
351 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
352
Katya Nigam70d68332013-09-16 16:49:45 +0530353 pmcLog(pMac, LOG2, FL("Entering pmcClose"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700354
355 /* Free up allocated resources. */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530356 if (vos_timer_destroy(&pMac->pmc.hImpsTimer) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 {
Katya Nigam70d68332013-09-16 16:49:45 +0530358 pmcLog(pMac, LOGE, FL("Cannot deallocate IMPS timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 }
360 if (!VOS_IS_STATUS_SUCCESS(vos_timer_destroy(&pMac->pmc.hTrafficTimer)))
361 {
Katya Nigam70d68332013-09-16 16:49:45 +0530362 pmcLog(pMac, LOGE, FL("Cannot deallocate traffic timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 }
364#ifdef FEATURE_WLAN_DIAG_SUPPORT
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530365 if (vos_timer_destroy(&pMac->pmc.hDiagEvtTimer) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 {
Katya Nigam70d68332013-09-16 16:49:45 +0530367 pmcLog(pMac, LOGE, FL("Cannot deallocate timer for diag event reporting"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 }
369#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530370 if (vos_timer_destroy(&pMac->pmc.hExitPowerSaveTimer) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700371 {
Katya Nigam70d68332013-09-16 16:49:45 +0530372 pmcLog(pMac, LOGE, FL("Cannot deallocate exit power save mode timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 }
374
375 /*
376 The following list's entries are dynamically allocated so they need their own
377 cleanup function
378 */
379 pmcClosePowerSaveCheckList(pMac);
380 pmcCloseRequestFullPowerList(pMac);
381 pmcCloseRequestBmpsList(pMac);
382 pmcCloseRequestStartUapsdList(pMac);
383 pmcCloseDeviceStateUpdateList(pMac);
384 pmcCloseDeferredMsgList(pMac);
385
386 return eHAL_STATUS_SUCCESS;
387}
388
389
390/******************************************************************************
391*
392* Name: pmcSignalPowerEvent
393*
394* Description:
395* Signals to PMC that a power event has occurred.
396*
397* Parameters:
398* hHal - HAL handle for device
399* event - the event that has occurred
400*
401* Returns:
402* eHAL_STATUS_SUCCESS - signaling successful
403* eHAL_STATUS_FAILURE - signaling not successful
404*
405******************************************************************************/
406eHalStatus pmcSignalPowerEvent (tHalHandle hHal, tPmcPowerEvent event)
407{
408 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
409#ifndef GEN6_ONWARDS
410 tSirMacHTMIMOPowerSaveState htMimoPowerSaveState;
411#endif
412
Katya Nigam70d68332013-09-16 16:49:45 +0530413 pmcLog(pMac, LOG2, FL("Entering pmcSignalPowerEvent, event %d"), event);
Jeff Johnson295189b2012-06-20 16:38:30 -0700414
415 /* Take action based on the event being signaled. */
416 switch (event)
417 {
418#ifndef GEN6_ONWARDS
419 case ePMC_SYSTEM_HIBERNATE:
420 return pmcEnterLowPowerState(hHal);
421
422 case ePMC_SYSTEM_RESUME:
423 return pmcExitLowPowerState(hHal);
424
425 case ePMC_HW_WLAN_SWITCH_OFF:
426 pMac->pmc.hwWlanSwitchState = ePMC_SWITCH_OFF;
427 return pmcEnterLowPowerState(hHal);
428
429 case ePMC_HW_WLAN_SWITCH_ON:
430 pMac->pmc.hwWlanSwitchState = ePMC_SWITCH_ON;
431 return pmcExitLowPowerState(hHal);
432
433 case ePMC_SW_WLAN_SWITCH_OFF:
434 pMac->pmc.swWlanSwitchState = ePMC_SWITCH_OFF;
435 return pmcEnterLowPowerState(hHal);
436
437 case ePMC_SW_WLAN_SWITCH_ON:
438 pMac->pmc.swWlanSwitchState = ePMC_SWITCH_ON;
439 return pmcExitLowPowerState(hHal);
440
441 case ePMC_BATTERY_OPERATION:
442 pMac->pmc.powerSource = BATTERY_POWER;
443
444 /* Turn on SMPS. */
445 if (pMac->pmc.smpsEnabled)
446 {
447 if (pMac->pmc.smpsConfig.mode == ePMC_DYNAMIC_SMPS)
448 htMimoPowerSaveState = eSIR_HT_MIMO_PS_DYNAMIC;
449 if (pMac->pmc.smpsConfig.mode == ePMC_STATIC_SMPS)
450 htMimoPowerSaveState = eSIR_HT_MIMO_PS_STATIC;
451 if (pmcSendMessage(hHal, eWNI_PMC_SMPS_STATE_IND, &htMimoPowerSaveState,
452 sizeof(tSirMacHTMIMOPowerSaveState)) != eHAL_STATUS_SUCCESS)
453 return eHAL_STATUS_FAILURE;
454 }
455 return eHAL_STATUS_SUCCESS;
456
457 case ePMC_AC_OPERATION:
458 pMac->pmc.powerSource = AC_POWER;
459
460 /* Turn off SMPS. */
461 if (!pMac->pmc.smpsConfig.enterOnAc)
462 {
463 htMimoPowerSaveState = eSIR_HT_MIMO_PS_NO_LIMIT;
464 if (pmcSendMessage(hHal, eWNI_PMC_SMPS_STATE_IND, &htMimoPowerSaveState,
465 sizeof(tSirMacHTMIMOPowerSaveState)) != eHAL_STATUS_SUCCESS)
466 return eHAL_STATUS_FAILURE;
467 }
468 return eHAL_STATUS_SUCCESS;
469#endif //GEN6_ONWARDS
470 default:
Katya Nigam70d68332013-09-16 16:49:45 +0530471 pmcLog(pMac, LOGE, FL("Invalid event %d"), event);
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 PMC_ABORT;
473 return eHAL_STATUS_FAILURE;
474 }
475}
476
477
478/******************************************************************************
479*
480* Name: pmcSetConfigPowerSave
481*
482* Description:
483* Configures one of the power saving modes.
484*
485* Parameters:
486* hHal - HAL handle for device
487* psMode - the power saving mode to configure
488* pConfigParams - pointer to configuration parameters specific to the
489* power saving mode
490*
491* Returns:
492* eHAL_STATUS_SUCCESS - configuration successful
493* eHAL_STATUS_FAILURE - configuration not successful
494*
495******************************************************************************/
496eHalStatus pmcSetConfigPowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode, void *pConfigParams)
497{
498 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
499
500#ifdef FEATURE_WLAN_DIAG_SUPPORT
501 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
502#endif
503
Katya Nigam70d68332013-09-16 16:49:45 +0530504 pmcLog(pMac, LOG2, FL("Entering pmcSetConfigPowerSave, power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700505
506 /* Configure the specified power saving mode. */
507 switch (psMode)
508 {
509
510 case ePMC_IDLE_MODE_POWER_SAVE:
511 pMac->pmc.impsConfig = *(tpPmcImpsConfigParams)pConfigParams;
Katya Nigam70d68332013-09-16 16:49:45 +0530512 pmcLog(pMac, LOG3, FL("IMPS configuration"));
513 pmcLog(pMac, LOG3, " enter on AC: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 pMac->pmc.impsConfig.enterOnAc);
515 break;
516
517 case ePMC_BEACON_MODE_POWER_SAVE:
518 pMac->pmc.bmpsConfig = *(tpPmcBmpsConfigParams)pConfigParams;
Katya Nigam70d68332013-09-16 16:49:45 +0530519 pmcLog(pMac, LOG3, FL("BMPS configuration"));
520 pmcLog(pMac, LOG3, " enter on AC: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 pMac->pmc.bmpsConfig.enterOnAc);
Katya Nigam70d68332013-09-16 16:49:45 +0530522 pmcLog(pMac, LOG3, " TX threshold: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 pMac->pmc.bmpsConfig.txThreshold);
Katya Nigam70d68332013-09-16 16:49:45 +0530524 pmcLog(pMac, LOG3, " RX threshold: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 pMac->pmc.bmpsConfig.rxThreshold);
Katya Nigam70d68332013-09-16 16:49:45 +0530526 pmcLog(pMac, LOG3, " traffic measurement period (ms): %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 pMac->pmc.bmpsConfig.trafficMeasurePeriod);
Katya Nigam70d68332013-09-16 16:49:45 +0530528 pmcLog(pMac, LOG3, " BMPS period: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 pMac->pmc.bmpsConfig.bmpsPeriod);
Katya Nigam70d68332013-09-16 16:49:45 +0530530 pmcLog(pMac, LOG3, " beacons to forward code: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 pMac->pmc.bmpsConfig.forwardBeacons);
Katya Nigam70d68332013-09-16 16:49:45 +0530532 pmcLog(pMac, LOG3, " value of N: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 pMac->pmc.bmpsConfig.valueOfN);
Katya Nigam70d68332013-09-16 16:49:45 +0530534 pmcLog(pMac, LOG3, " use PS poll: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 pMac->pmc.bmpsConfig.usePsPoll);
Katya Nigam70d68332013-09-16 16:49:45 +0530536 pmcLog(pMac, LOG3, " set PM on last frame: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 pMac->pmc.bmpsConfig.setPmOnLastFrame);
Katya Nigam70d68332013-09-16 16:49:45 +0530538 pmcLog(pMac, LOG3, " value of enableBeaconEarlyTermination: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 pMac->pmc.bmpsConfig.enableBeaconEarlyTermination);
Katya Nigam70d68332013-09-16 16:49:45 +0530540 pmcLog(pMac, LOG3, " value of bcnEarlyTermWakeInterval: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 pMac->pmc.bmpsConfig.bcnEarlyTermWakeInterval);
542
543#ifdef FEATURE_WLAN_DIAG_SUPPORT
544 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
545 psRequest.event_subtype = WLAN_BMPS_SET_CONFIG;
546 /* possible loss of data due to mismatch but expectation is that
547 values can reasonably be expected to fit in target widths */
548 psRequest.bmps_auto_timer_duration = (v_U16_t)pMac->pmc.bmpsConfig.trafficMeasurePeriod;
549 psRequest.bmps_period = (v_U16_t)pMac->pmc.bmpsConfig.bmpsPeriod;
550
551 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
552#endif
553
554
555 break;
556
557 case ePMC_SPATIAL_MULTIPLEX_POWER_SAVE:
558 pMac->pmc.smpsConfig = *(tpPmcSmpsConfigParams)pConfigParams;
Katya Nigam70d68332013-09-16 16:49:45 +0530559 pmcLog(pMac, LOG3, FL("SMPS configuration"));
560 pmcLog(pMac, LOG3, " mode: %d", pMac->pmc.smpsConfig.mode);
561 pmcLog(pMac, LOG3, " enter on AC: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 pMac->pmc.smpsConfig.enterOnAc);
563 break;
564
565 default:
Katya Nigam70d68332013-09-16 16:49:45 +0530566 pmcLog(pMac, LOGE, FL("Invalid power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 PMC_ABORT;
568 return eHAL_STATUS_FAILURE;
569 }
570
571 //Send the power save config down to PE/HAL/FW if BMPS mode is being configured
572 //and pmcReady has been invoked
573 if(PMC_IS_READY(pMac) && psMode == ePMC_BEACON_MODE_POWER_SAVE)
574 {
575 if (pmcSendPowerSaveConfigMessage(hHal) != eHAL_STATUS_SUCCESS)
576 return eHAL_STATUS_FAILURE;
577 }
578
579 return eHAL_STATUS_SUCCESS;
580}
581
582/******************************************************************************
583*
584* Name: pmcGetConfigPowerSave
585*
586* Description:
587* Get the config for the specified power save mode
588*
589* Parameters:
590* hHal - HAL handle for device
591* psMode - the power saving mode to configure
592* pConfigParams - pointer to configuration parameters specific to the
593* power saving mode
594*
595* Returns:
596* eHAL_STATUS_SUCCESS - configuration successful
597* eHAL_STATUS_FAILURE - configuration not successful
598*
599******************************************************************************/
600eHalStatus pmcGetConfigPowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode, void *pConfigParams)
601{
602 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
603
Katya Nigam70d68332013-09-16 16:49:45 +0530604 pmcLog(pMac, LOG2, FL("Entering pmcGetConfigPowerSave, power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700605
606 /* Configure the specified power saving mode. */
607 switch (psMode)
608 {
609
610 case ePMC_IDLE_MODE_POWER_SAVE:
611 *(tpPmcImpsConfigParams)pConfigParams = pMac->pmc.impsConfig;
612 break;
613
614 case ePMC_BEACON_MODE_POWER_SAVE:
615 *(tpPmcBmpsConfigParams)pConfigParams = pMac->pmc.bmpsConfig;
616 break;
617
618 case ePMC_SPATIAL_MULTIPLEX_POWER_SAVE:
619 *(tpPmcSmpsConfigParams)pConfigParams = pMac->pmc.smpsConfig;
620 break;
621
622 default:
Katya Nigam70d68332013-09-16 16:49:45 +0530623 pmcLog(pMac, LOGE, FL("Invalid power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 return eHAL_STATUS_FAILURE;
625 }
626
627 return eHAL_STATUS_SUCCESS;
628}
629/******************************************************************************
630*
631* Name: pmcEnablePowerSave
632*
633* Description:
634* Enables one of the power saving modes.
635*
636* Parameters:
637* hHal - HAL handle for device
638* psMode - the power saving mode to enable
639*
640* Returns:
641* eHAL_STATUS_SUCCESS - successfully enabled
642* eHAL_STATUS_FAILURE - not successfully enabled
643*
644******************************************************************************/
645eHalStatus pmcEnablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
646{
647 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
648 tSirMacHTMIMOPowerSaveState htMimoPowerSaveState;
649
650#ifdef FEATURE_WLAN_DIAG_SUPPORT
651 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
652
653 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
654 psRequest.event_subtype = WLAN_PS_MODE_ENABLE_REQ;
655 psRequest.enable_disable_powersave_mode = psMode;
656
657 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
658#endif
659
Katya Nigam70d68332013-09-16 16:49:45 +0530660 pmcLog(pMac, LOG2, FL("Entering pmcEnablePowerSave, power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661
662 /* Enable the specified power saving mode. */
663 switch (psMode)
664 {
665
666 case ePMC_IDLE_MODE_POWER_SAVE:
667 pMac->pmc.impsEnabled = TRUE;
668 break;
669
670 case ePMC_BEACON_MODE_POWER_SAVE:
671 pMac->pmc.bmpsEnabled = TRUE;
672 break;
673
674 case ePMC_SPATIAL_MULTIPLEX_POWER_SAVE:
675 pMac->pmc.smpsEnabled = TRUE;
676
677 /* If PMC already started, then turn on SMPS. */
678 if (pMac->pmc.pmcState != STOPPED)
679 if (pMac->pmc.powerSource != AC_POWER ||
680 pMac->pmc.smpsConfig.enterOnAc)
681 {
682 if (pMac->pmc.smpsConfig.mode == ePMC_DYNAMIC_SMPS)
683 htMimoPowerSaveState = eSIR_HT_MIMO_PS_DYNAMIC;
684 if (pMac->pmc.smpsConfig.mode == ePMC_STATIC_SMPS)
685 htMimoPowerSaveState = eSIR_HT_MIMO_PS_STATIC;
686 if (pmcSendMessage(hHal, eWNI_PMC_SMPS_STATE_IND, &htMimoPowerSaveState,
687 sizeof(tSirMacHTMIMOPowerSaveState)) != eHAL_STATUS_SUCCESS)
688 return eHAL_STATUS_FAILURE;
689 }
690 break;
691
692 case ePMC_UAPSD_MODE_POWER_SAVE:
693 pMac->pmc.uapsdEnabled = TRUE;
694 break;
695
696 case ePMC_STANDBY_MODE_POWER_SAVE:
697 pMac->pmc.standbyEnabled = TRUE;
698 break;
699
700 case ePMC_WOWL_MODE_POWER_SAVE:
701 pMac->pmc.wowlEnabled = TRUE;
702 break;
703
704 default:
Katya Nigam70d68332013-09-16 16:49:45 +0530705 pmcLog(pMac, LOGE, FL("Invalid power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 PMC_ABORT;
707 return eHAL_STATUS_FAILURE;
708 }
709
710 return eHAL_STATUS_SUCCESS;
711}
712/* ---------------------------------------------------------------------------
713 \fn pmcStartAutoBmpsTimer
714 \brief Starts a timer that periodically polls all the registered
715 module for entry into Bmps mode. This timer is started only if BMPS is
716 enabled and whenever the device is in full power.
717 \param hHal - The handle returned by macOpen.
718 \return eHalStatus
719 ---------------------------------------------------------------------------*/
720eHalStatus pmcStartAutoBmpsTimer (tHalHandle hHal)
721{
722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
723
724#ifdef FEATURE_WLAN_DIAG_SUPPORT
725 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
726
727 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
728 psRequest.event_subtype = WLAN_START_BMPS_AUTO_TIMER_REQ;
729
730 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
731#endif
732
Katya Nigam70d68332013-09-16 16:49:45 +0530733 pmcLog(pMac, LOG2, FL("Entering pmcStartAutoBmpsTimer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700734
735 /* Check if BMPS is enabled. */
736 if (!pMac->pmc.bmpsEnabled)
737 {
Katya Nigam70d68332013-09-16 16:49:45 +0530738 pmcLog(pMac, LOGE, "PMC: Cannot enable BMPS timer. BMPS is disabled");
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 return eHAL_STATUS_FAILURE;
740 }
741
742 pMac->pmc.autoBmpsEntryEnabled = TRUE;
743
744 /* Check if there is an Infra session. If there is no Infra session, timer will be started
745 when STA associates to AP */
746
747 if (pmcShouldBmpsTimerRun(pMac))
748 {
749 if (pmcStartTrafficTimer(hHal, pMac->pmc.bmpsConfig.trafficMeasurePeriod) != eHAL_STATUS_SUCCESS)
750 return eHAL_STATUS_FAILURE;
751 }
752
753
754
755 return eHAL_STATUS_SUCCESS;
756}
757
758/* ---------------------------------------------------------------------------
759 \fn pmcStopAutoBmpsTimer
760 \brief Stops the Auto BMPS Timer that was started using sme_startAutoBmpsTimer
761 Stopping the timer does not cause a device state change. Only the timer
762 is stopped. If "Full Power" is desired, use the pmcRequestFullPower API
763 \param hHal - The handle returned by macOpen.
764 \return eHalStatus
765 ---------------------------------------------------------------------------*/
766eHalStatus pmcStopAutoBmpsTimer (tHalHandle hHal)
767{
768 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
769
770#ifdef FEATURE_WLAN_DIAG_SUPPORT
771 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
772
773 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
774 psRequest.event_subtype = WLAN_STOP_BMPS_AUTO_TIMER_REQ;
775
776 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
777#endif
778
Katya Nigam70d68332013-09-16 16:49:45 +0530779 pmcLog(pMac, LOG2, FL("Entering pmcStopAutoBmpsTimer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700780
781 pMac->pmc.autoBmpsEntryEnabled = FALSE;
782 /* If uapsd session is not required or HDD has not requested BMPS, stop the auto bmps timer.*/
783 if (!pMac->pmc.uapsdSessionRequired && !pMac->pmc.bmpsRequestedByHdd)
784 pmcStopTrafficTimer(hHal);
785
786 return eHAL_STATUS_SUCCESS;
787}
788
789/******************************************************************************
790*
791* Name: pmcDisablePowerSave
792*
793* Description:
794* Disables one of the power saving modes.
795*
796* Parameters:
797* hHal - HAL handle for device
798* psMode - the power saving mode to disable
799*
800* Returns:
801* eHAL_STATUS_SUCCESS - successfully disabled
802* eHAL_STATUS_FAILURE - not successfully disabled
803*
804******************************************************************************/
805eHalStatus pmcDisablePowerSave (tHalHandle hHal, tPmcPowerSavingMode psMode)
806{
807 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
808 tSirMacHTMIMOPowerSaveState htMimoPowerSaveState;
809
810#ifdef FEATURE_WLAN_DIAG_SUPPORT
811 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
812
813 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
814 psRequest.event_subtype = WLAN_PS_MODE_DISABLE_REQ;
815 psRequest.enable_disable_powersave_mode = psMode;
816
817 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
818#endif
819
Katya Nigam70d68332013-09-16 16:49:45 +0530820 pmcLog(pMac, LOG2, FL("Entering pmcDisablePowerSave, power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821
822 /* Disable the specified power saving mode. */
823 switch (psMode)
824 {
825
826 case ePMC_IDLE_MODE_POWER_SAVE:
827 pMac->pmc.impsEnabled = FALSE;
828 break;
829
830 case ePMC_BEACON_MODE_POWER_SAVE:
831 pMac->pmc.bmpsEnabled = FALSE;
832 break;
833
834 case ePMC_SPATIAL_MULTIPLEX_POWER_SAVE:
835 pMac->pmc.smpsEnabled = FALSE;
836
837 /* Turn off SMPS. */
838 htMimoPowerSaveState = eSIR_HT_MIMO_PS_NO_LIMIT;
839 if (pmcSendMessage(hHal, eWNI_PMC_SMPS_STATE_IND, &htMimoPowerSaveState,
840 sizeof(tSirMacHTMIMOPowerSaveState)) != eHAL_STATUS_SUCCESS)
841 return eHAL_STATUS_FAILURE;
842 break;
843
844 case ePMC_UAPSD_MODE_POWER_SAVE:
845 pMac->pmc.uapsdEnabled = FALSE;
846 break;
847
848 case ePMC_STANDBY_MODE_POWER_SAVE:
849 pMac->pmc.standbyEnabled = FALSE;
850 break;
851
852 case ePMC_WOWL_MODE_POWER_SAVE:
853 pMac->pmc.wowlEnabled = FALSE;
854 break;
855
856 default:
Katya Nigam70d68332013-09-16 16:49:45 +0530857 pmcLog(pMac, LOGE, FL("Invalid power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 PMC_ABORT;
859 return eHAL_STATUS_FAILURE;
860 }
861
862 return eHAL_STATUS_SUCCESS;
863}
864
865
866/******************************************************************************
867*
868* Name: pmcQueryPowerState
869*
870* Description:
871* Returns the current power state of the device.
872*
873* Parameters:
874* hHal - HAL handle for device
875* pPowerState - pointer to location to return power state
876* pHwWlanSwitchState - pointer to location to return Hardware WLAN
877* Switch state
878* pSwWlanSwitchState - pointer to location to return Software WLAN
879* Switch state
880*
881* Returns:
882* eHAL_STATUS_SUCCESS - power state successfully returned
883* eHAL_STATUS_FAILURE - power state not successfully returned
884*
885******************************************************************************/
886eHalStatus pmcQueryPowerState (tHalHandle hHal, tPmcPowerState *pPowerState,
887 tPmcSwitchState *pHwWlanSwitchState, tPmcSwitchState *pSwWlanSwitchState)
888{
889 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
890
Katya Nigam70d68332013-09-16 16:49:45 +0530891 pmcLog(pMac, LOG2, FL("Entering pmcQueryPowerState"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700892
893 /* Return current power state based on PMC state. */
894 if(pPowerState != NULL)
895 {
896 /* Return current power state based on PMC state. */
897 switch (pMac->pmc.pmcState)
898 {
899
900 case FULL_POWER:
901 *pPowerState = ePMC_FULL_POWER;
902 break;
903
904 default:
905 *pPowerState = ePMC_LOW_POWER;
906 break;
907 }
908 }
909
910 /* Return current switch settings. */
911 if(pHwWlanSwitchState != NULL)
912 *pHwWlanSwitchState = pMac->pmc.hwWlanSwitchState;
913 if(pSwWlanSwitchState != NULL)
914 *pSwWlanSwitchState = pMac->pmc.swWlanSwitchState;
915
916 return eHAL_STATUS_SUCCESS;
917}
918
919
920/******************************************************************************
921*
922* Name: pmcIsPowerSaveEnabled
923*
924* Description:
925* Checks if the device is able to enter one of the power save modes.
926* "Able to enter" means the power save mode is enabled for the device
927* and the host is using the correct power source for entry into the
928* power save mode. This routine does not indicate whether the device
929* is actually in the power save mode at a particular point in time.
930*
931* Parameters:
932* hHal - HAL handle for device
933* psMode - the power saving mode
934*
935* Returns:
936* TRUE if device is able to enter the power save mode, FALSE otherwise
937*
938******************************************************************************/
939tANI_BOOLEAN pmcIsPowerSaveEnabled (tHalHandle hHal, tPmcPowerSavingMode psMode)
940{
941 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
942
Katya Nigam70d68332013-09-16 16:49:45 +0530943 pmcLog(pMac, LOG2, FL("Entering pmcIsPowerSaveEnabled, power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700944
945 /* Check ability to enter based on the specified power saving mode. */
946 switch (psMode)
947 {
948
949 case ePMC_IDLE_MODE_POWER_SAVE:
950 return pMac->pmc.impsEnabled && (pMac->pmc.powerSource != AC_POWER || pMac->pmc.impsConfig.enterOnAc);
951
952 case ePMC_BEACON_MODE_POWER_SAVE:
953 return pMac->pmc.bmpsEnabled;
954
955 case ePMC_SPATIAL_MULTIPLEX_POWER_SAVE:
956 return pMac->pmc.smpsEnabled && (pMac->pmc.powerSource != AC_POWER || pMac->pmc.smpsConfig.enterOnAc);
957
958 case ePMC_UAPSD_MODE_POWER_SAVE:
959 return pMac->pmc.uapsdEnabled;
960
961 case ePMC_STANDBY_MODE_POWER_SAVE:
962 return pMac->pmc.standbyEnabled;
963
964 case ePMC_WOWL_MODE_POWER_SAVE:
965 return pMac->pmc.wowlEnabled;
966 break;
967
968 default:
Katya Nigam70d68332013-09-16 16:49:45 +0530969 pmcLog(pMac, LOGE, FL("Invalid power save mode %d"), psMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 PMC_ABORT;
971 return FALSE;
972 }
973}
974
975
976/******************************************************************************
977*
978* Name: pmcRequestFullPower
979*
980* Description:
981* Request that the device be brought to full power state.
982*
983* Parameters:
984* hHal - HAL handle for device
985* callbackRoutine - routine to call when device actually achieves full
986* power state if "eHAL_STATUS_PMC_PENDING" is returned
987* callbackContext - value to be passed as parameter to routine specified
988* above
989* fullPowerReason - Reason for requesting full power mode. This is used
990* by PE to decide whether data null should be sent to
991* AP when exiting BMPS mode. Caller should use the
992* eSME_LINK_DISCONNECTED reason if link is disconnected
993* and there is no need to tell the AP that we are going
994* out of power save.
995*
996* Returns:
997* eHAL_STATUS_SUCCESS - device brought to full power state
998* eHAL_STATUS_FAILURE - device cannot be brought to full power state
999* eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
1000* callbackRoutine will be called when completed
1001*
1002******************************************************************************/
1003eHalStatus pmcRequestFullPower (tHalHandle hHal, void (*callbackRoutine) (void *callbackContext, eHalStatus status),
1004 void *callbackContext, tRequestFullPowerReason fullPowerReason)
1005{
1006 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1007 tpRequestFullPowerEntry pEntry;
1008
1009#ifdef FEATURE_WLAN_DIAG_SUPPORT
1010 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
1011
1012 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
1013 psRequest.event_subtype = WLAN_ENTER_FULL_POWER_REQ;
1014 psRequest.full_power_request_reason = fullPowerReason;
1015
1016 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
1017#endif
1018
Katya Nigam70d68332013-09-16 16:49:45 +05301019 pmcLog(pMac, LOG2, FL("Entering pmcRequestFullPower"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001020
1021 if( !PMC_IS_READY(pMac) )
1022 {
Katya Nigam70d68332013-09-16 16:49:45 +05301023 pmcLog(pMac, LOGE, FL("Requesting Full Power when PMC not ready"));
1024 pmcLog(pMac, LOGE, FL("pmcReady = %d pmcState = %s"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 pMac->pmc.pmcReady, pmcGetPmcStateStr(pMac->pmc.pmcState));
1026 return eHAL_STATUS_FAILURE;
1027 }
1028
1029 /* If HDD is requesting full power, clear any buffered requests for WOWL and BMPS that were
1030 requested by HDD previously */
1031 if(SIR_IS_FULL_POWER_NEEDED_BY_HDD(fullPowerReason))
1032 {
1033 pMac->pmc.bmpsRequestedByHdd = FALSE;
1034 pMac->pmc.wowlModeRequired = FALSE;
1035 }
1036
1037 /* If already in full power, just return. */
1038 if (pMac->pmc.pmcState == FULL_POWER)
1039 return eHAL_STATUS_SUCCESS;
1040
1041 /* If in IMPS State, then cancel the timer. */
1042 if (pMac->pmc.pmcState == IMPS)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05301043 if (vos_timer_stop(&pMac->pmc.hImpsTimer) != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 {
Katya Nigam70d68332013-09-16 16:49:45 +05301045 pmcLog(pMac, LOGE, FL("Cannot cancel IMPS timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 /* Enter Request Full Power State. */
1048 if (pmcEnterRequestFullPowerState(hHal, fullPowerReason) != eHAL_STATUS_SUCCESS)
1049 return eHAL_STATUS_FAILURE;
1050
1051 /* If able to enter Request Full Power State, then request is pending.
1052 Allocate entry for request full power callback routine list. */
1053 //If caller doesn't need a callback, simply waits up the chip.
1054 if( callbackRoutine )
1055 {
1056 if (palAllocateMemory(pMac->hHdd, (void **)&pEntry, sizeof(tRequestFullPowerEntry)) != eHAL_STATUS_SUCCESS)
1057 {
Katya Nigam70d68332013-09-16 16:49:45 +05301058 pmcLog(pMac, LOGE, FL("Cannot allocate memory for request full power routine list entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 PMC_ABORT;
1060 return eHAL_STATUS_FAILURE;
1061 }
1062
1063 /* Store routine and context in entry. */
1064 pEntry->callbackRoutine = callbackRoutine;
1065 pEntry->callbackContext = callbackContext;
1066
1067 /* Add entry to list. */
1068 csrLLInsertTail(&pMac->pmc.requestFullPowerList, &pEntry->link, TRUE);
1069 }
1070
1071 return eHAL_STATUS_PMC_PENDING;
1072}
1073
1074
1075/******************************************************************************
1076*
1077* Name: pmcRequestImps
1078*
1079* Description:
1080* Request that the device be placed in Idle Mode Power Save (IMPS).
1081* The Common Scan/Roam Module makes this request. The device will be
1082* placed into IMPS for the specified amount of time, and then returned
1083* to full power.
1084*
1085* Parameters:
1086* hHal - HAL handle for device
1087* impsPeriod - amount of time to remain in IMPS (milliseconds)
1088* callbackRoutine - routine to call when IMPS period has finished and
1089* the device has been brought to full power
1090* callbackContext - value to be passed as parameter to routine specified
1091* above
1092*
1093* Returns:
1094* eHAL_STATUS_SUCCESS - device will enter IMPS
1095* eHAL_STATUS_PMC_DISABLED - IMPS is disabled
1096* eHAL_STATUS_PMC_NOT_NOW - another module is prohibiting entering IMPS
1097* at this time
1098* eHAL_STATUS_PMC_AC_POWER - IMPS is disabled when host operating from
1099* AC power
1100* eHAL_STATUS_PMC_ALREADY_IN_IMPS - device is already in IMPS
1101* eHAL_STATUS_PMC_SYS_ERROR - system error that prohibits entering IMPS
1102*
1103******************************************************************************/
1104eHalStatus pmcRequestImps (tHalHandle hHal, tANI_U32 impsPeriod,
1105 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
1106 void *callbackContext)
1107{
1108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1109 eHalStatus status;
1110
1111#ifdef FEATURE_WLAN_DIAG_SUPPORT
1112 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
1113
1114 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
1115 psRequest.event_subtype = WLAN_IMPS_ENTER_REQ;
1116 psRequest.imps_period = impsPeriod;
1117
1118 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
1119#endif
1120
1121
Katya Nigam70d68332013-09-16 16:49:45 +05301122 pmcLog(pMac, LOG2, FL("Entering pmcRequestImps"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001123
1124 status = pmcEnterImpsCheck( pMac );
1125 if( HAL_STATUS_SUCCESS( status ) )
1126 {
1127 /* Enter Request IMPS State. */
1128 status = pmcEnterRequestImpsState( hHal );
1129 if (HAL_STATUS_SUCCESS( status ))
1130 {
1131 /* Save the period and callback routine for when we need it. */
1132 pMac->pmc.impsPeriod = impsPeriod;
1133 pMac->pmc.impsCallbackRoutine = callbackRoutine;
1134 pMac->pmc.impsCallbackContext = callbackContext;
1135
1136 }
1137 else
1138 {
1139 status = eHAL_STATUS_PMC_SYS_ERROR;
1140 }
1141 }
1142
1143 return status;
1144}
1145
1146
1147/******************************************************************************
1148*
1149* Name: pmcRegisterPowerSaveCheck
1150*
1151* Description:
1152* Allows a routine to be registered so that the routine is called whenever
1153* the device is about to enter one of the power save modes. This routine
1154* will say whether the device is allowed to enter the power save mode at
1155* the time of the call.
1156*
1157* Parameters:
1158* hHal - HAL handle for device
1159* checkRoutine - routine to call before entering a power save mode, should
1160* return TRUE if the device is allowed to enter the power
1161* save mode, FALSE otherwise
1162* checkContext - value to be passed as parameter to routine specified above
1163*
1164* Returns:
1165* eHAL_STATUS_SUCCESS - successfully registered
1166* eHAL_STATUS_FAILURE - not successfully registered
1167*
1168******************************************************************************/
1169eHalStatus pmcRegisterPowerSaveCheck (tHalHandle hHal, tANI_BOOLEAN (*checkRoutine) (void *checkContext),
1170 void *checkContext)
1171{
1172 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1173 tpPowerSaveCheckEntry pEntry;
1174
Katya Nigam70d68332013-09-16 16:49:45 +05301175 pmcLog(pMac, LOG2, FL("Entering pmcRegisterPowerSaveCheck"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001176
1177 /* Allocate entry for power save check routine list. */
1178 if (palAllocateMemory(pMac->hHdd, (void **)&pEntry, sizeof(tPowerSaveCheckEntry)) != eHAL_STATUS_SUCCESS)
1179 {
Katya Nigam70d68332013-09-16 16:49:45 +05301180 pmcLog(pMac, LOGE, FL("Cannot allocate memory for power save check routine list entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 PMC_ABORT;
1182 return eHAL_STATUS_FAILURE;
1183 }
1184
1185 /* Store routine and context in entry. */
1186 pEntry->checkRoutine = checkRoutine;
1187 pEntry->checkContext = checkContext;
1188
1189 /* Add entry to list. */
1190 csrLLInsertTail(&pMac->pmc.powerSaveCheckList, &pEntry->link, FALSE);
1191
1192 return eHAL_STATUS_SUCCESS;
1193}
1194
1195
1196/******************************************************************************
1197*
1198* Name: pmcDeregisterPowerSaveCheck
1199*
1200* Description:
1201* Reregisters a routine that was previously registered with
1202* pmcRegisterPowerSaveCheck.
1203*
1204* Parameters:
1205* hHal - HAL handle for device
1206* checkRoutine - routine to deregister
1207*
1208* Returns:
1209* eHAL_STATUS_SUCCESS - successfully deregistered
1210* eHAL_STATUS_FAILURE - not successfully deregistered
1211*
1212******************************************************************************/
1213eHalStatus pmcDeregisterPowerSaveCheck (tHalHandle hHal, tANI_BOOLEAN (*checkRoutine) (void *checkContext))
1214{
1215 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1216 tListElem *pEntry;
1217 tpPowerSaveCheckEntry pPowerSaveCheckEntry;
1218
Katya Nigam70d68332013-09-16 16:49:45 +05301219 pmcLog(pMac, LOG2, FL("Entering pmcDeregisterPowerSaveCheck"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001220
1221 /* Find entry in the power save check routine list that matches
1222 the specified routine and remove it. */
1223 pEntry = csrLLPeekHead(&pMac->pmc.powerSaveCheckList, FALSE);
1224 while (pEntry != NULL)
1225 {
1226 pPowerSaveCheckEntry = GET_BASE_ADDR(pEntry, tPowerSaveCheckEntry, link);
1227 if (pPowerSaveCheckEntry->checkRoutine == checkRoutine)
1228 {
1229 if (csrLLRemoveEntry(&pMac->pmc.powerSaveCheckList, pEntry, FALSE))
1230 {
1231 if (palFreeMemory(pMac->hHdd, pPowerSaveCheckEntry) != eHAL_STATUS_SUCCESS)
1232 {
Katya Nigam70d68332013-09-16 16:49:45 +05301233 pmcLog(pMac, LOGE, FL("Cannot free memory for power save check routine list entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 PMC_ABORT;
1235 return eHAL_STATUS_FAILURE;
1236 }
1237 }
1238 else
1239 {
Katya Nigam70d68332013-09-16 16:49:45 +05301240 pmcLog(pMac, LOGE, FL("Cannot remove power save check routine list entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 return eHAL_STATUS_FAILURE;
1242 }
1243 return eHAL_STATUS_SUCCESS;
1244 }
1245 pEntry = csrLLNext(&pMac->pmc.powerSaveCheckList, pEntry, FALSE);
1246 }
1247
1248 /* Could not find matching entry. */
1249 return eHAL_STATUS_FAILURE;
1250}
1251
1252
1253static void pmcProcessResponse( tpAniSirGlobal pMac, tSirSmeRsp *pMsg )
1254{
1255 tListElem *pEntry = NULL;
1256 tSmeCmd *pCommand = NULL;
1257 tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE;
1258
1259 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
1260 if(pEntry)
1261 {
1262 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
1263
Katya Nigam70d68332013-09-16 16:49:45 +05301264 pmcLog(pMac, LOG2, FL("process message = %d"), pMsg->messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
1266 /* Process each different type of message. */
1267 switch (pMsg->messageType)
1268 {
1269
1270 /* We got a response to our IMPS request. */
1271 case eWNI_PMC_ENTER_IMPS_RSP:
Katya Nigam70d68332013-09-16 16:49:45 +05301272 pmcLog(pMac, LOG2, FL("Rcvd eWNI_PMC_ENTER_IMPS_RSP with status = %d"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 if( (eSmeCommandEnterImps != pCommand->command) && (eSmeCommandEnterStandby != pCommand->command) )
1274 {
Katya Nigam70d68332013-09-16 16:49:45 +05301275 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_ENTER_IMPS_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 fRemoveCommand = eANI_BOOLEAN_FALSE;
1277 break;
1278 }
1279 if(pMac->pmc.pmcState == REQUEST_IMPS)
1280 {
1281 /* Enter IMPS State if response indicates success. */
1282 if (pMsg->statusCode == eSIR_SME_SUCCESS)
1283 {
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07001284 pMac->pmc.ImpsReqFailed = VOS_FALSE;
1285 pmcEnterImpsState(pMac);
1286 if (!(pMac->pmc.ImpsReqFailed || pMac->pmc.ImpsReqTimerFailed) && pMac->pmc.ImpsReqFailCnt)
1287 {
Katya Nigam70d68332013-09-16 16:49:45 +05301288 pmcLog(pMac, LOGE,
1289 FL("Response message to request to enter IMPS was failed %d times before success"),
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07001290 pMac->pmc.ImpsReqFailCnt);
1291 pMac->pmc.ImpsReqFailCnt = 0;
1292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 }
1294
1295 /* If response is failure, then we stay in Full Power State and tell everyone that we aren't going into IMPS. */
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07001296 else
1297 {
1298 pMac->pmc.ImpsReqFailed = VOS_TRUE;
1299 if (!(pMac->pmc.ImpsReqFailCnt & 0xF))
1300 {
Katya Nigam70d68332013-09-16 16:49:45 +05301301 pmcLog(pMac, LOGE,
1302 FL("Response message to request to enter IMPS indicates failure, status %x, FailCnt - %d"),
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07001303 pMsg->statusCode, ++pMac->pmc.ImpsReqFailCnt);
1304 }
1305 else
1306 {
1307 pMac->pmc.ImpsReqFailCnt++;
1308 }
1309 pmcEnterFullPowerState(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 }
1311 }
1312 else if (pMac->pmc.pmcState == REQUEST_STANDBY)
1313 {
1314 /* Enter STANDBY State if response indicates success. */
1315 if (pMsg->statusCode == eSIR_SME_SUCCESS)
1316 {
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07001317 pmcEnterStandbyState(pMac);
1318 pmcDoStandbyCallbacks(pMac, eHAL_STATUS_SUCCESS);
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 }
1320
1321 /* If response is failure, then we stay in Full Power State
1322 and tell everyone that we aren't going into STANDBY. */
1323 else
1324 {
Katya Nigam70d68332013-09-16 16:49:45 +05301325 pmcLog(pMac, LOGE, "PMC: response message to request to enter "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001326 "standby indicates failure, status %x", pMsg->statusCode);
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07001327 pmcEnterFullPowerState(pMac);
1328 pmcDoStandbyCallbacks(pMac, eHAL_STATUS_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 }
1330 }
1331 else
1332 {
Katya Nigam70d68332013-09-16 16:49:45 +05301333 pmcLog(pMac, LOGE, "PMC: Enter IMPS rsp rcvd when device is "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001334 "in %d state", pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 }
1336 break;
1337
1338 /* We got a response to our wake from IMPS request. */
1339 case eWNI_PMC_EXIT_IMPS_RSP:
Katya Nigam70d68332013-09-16 16:49:45 +05301340 pmcLog(pMac, LOG2, FL("Rcvd eWNI_PMC_EXIT_IMPS_RSP with status = %d"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 if( eSmeCommandExitImps != pCommand->command )
1342 {
Katya Nigam70d68332013-09-16 16:49:45 +05301343 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_EXIT_IMPS_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001344 fRemoveCommand = eANI_BOOLEAN_FALSE;
1345 break;
1346 }
1347 /* Check that we are in the correct state for this message. */
1348 if (pMac->pmc.pmcState != REQUEST_FULL_POWER)
1349 {
Katya Nigam70d68332013-09-16 16:49:45 +05301350 pmcLog(pMac, LOGE, FL("Got Exit IMPS Response Message while "
Madan Mohan Koyyalamudic1de66f2013-07-26 18:33:00 +05301351 "in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 break;
1353 }
1354
1355 /* Enter Full Power State. */
1356 if (pMsg->statusCode != eSIR_SME_SUCCESS)
1357 {
Katya Nigam70d68332013-09-16 16:49:45 +05301358 pmcLog(pMac, LOGE, FL("Response message to request to exit "
Madan Mohan Koyyalamudic1de66f2013-07-26 18:33:00 +05301359 "IMPS indicates failure, status %x"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 }
1361 pmcEnterFullPowerState(pMac);
1362 break;
1363
1364 /* We got a response to our BMPS request. */
1365 case eWNI_PMC_ENTER_BMPS_RSP:
Katya Nigam70d68332013-09-16 16:49:45 +05301366 pmcLog(pMac, LOG2, FL("Rcvd eWNI_PMC_ENTER_BMPS_RSP with status = %d"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 if( eSmeCommandEnterBmps != pCommand->command )
1368 {
Katya Nigam70d68332013-09-16 16:49:45 +05301369 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_ENTER_BMPS_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 fRemoveCommand = eANI_BOOLEAN_FALSE;
1371 break;
1372 }
1373 pMac->pmc.bmpsRequestQueued = eANI_BOOLEAN_FALSE;
1374 /* Check that we are in the correct state for this message. */
1375 if (pMac->pmc.pmcState != REQUEST_BMPS)
1376 {
Katya Nigam70d68332013-09-16 16:49:45 +05301377 pmcLog(pMac, LOGE,
1378 FL("Got Enter BMPS Response Message while in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 break;
1380 }
1381
1382 /* Enter BMPS State if response indicates success. */
1383 if (pMsg->statusCode == eSIR_SME_SUCCESS)
1384 {
1385 pmcEnterBmpsState(pMac);
1386 /* Note: If BMPS was requested because of start UAPSD,
1387 there will no entries for BMPS callback routines and
1388 pmcDoBmpsCallbacks will be a No-Op*/
1389 pmcDoBmpsCallbacks(pMac, eHAL_STATUS_SUCCESS);
1390 }
1391 /* If response is failure, then we stay in Full Power State and tell everyone that we aren't going into BMPS. */
1392 else
1393 {
Katya Nigam70d68332013-09-16 16:49:45 +05301394 pmcLog(pMac, LOGE,
1395 FL("Response message to request to enter BMPS indicates failure, status %x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 pMsg->statusCode);
1397 pmcEnterFullPowerState(pMac);
1398 //Do not call UAPSD callback here since it may be re-entered
1399 pmcDoBmpsCallbacks(pMac, eHAL_STATUS_FAILURE);
1400 }
1401 break;
1402
1403 /* We got a response to our wake from BMPS request. */
1404 case eWNI_PMC_EXIT_BMPS_RSP:
Katya Nigam70d68332013-09-16 16:49:45 +05301405 pmcLog(pMac, LOG2, FL("Rcvd eWNI_PMC_EXIT_BMPS_RSP with status = %d"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 if( eSmeCommandExitBmps != pCommand->command )
1407 {
Katya Nigam70d68332013-09-16 16:49:45 +05301408 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_EXIT_BMPS_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 fRemoveCommand = eANI_BOOLEAN_FALSE;
1410 break;
1411 }
1412 /* Check that we are in the correct state for this message. */
1413 if (pMac->pmc.pmcState != REQUEST_FULL_POWER)
1414 {
Katya Nigam70d68332013-09-16 16:49:45 +05301415 pmcLog(pMac, LOGE,
1416 FL("Got Exit BMPS Response Message while in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 break;
1418 }
1419
1420 /* Enter Full Power State. */
1421 if (pMsg->statusCode != eSIR_SME_SUCCESS)
1422 {
Katya Nigam70d68332013-09-16 16:49:45 +05301423 pmcLog(pMac, LOGP,
1424 FL("Response message to request to exit BMPS indicates failure, status %x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 pMsg->statusCode);
1426 }
1427 pmcEnterFullPowerState(pMac);
1428 break;
1429
1430 /* We got a response to our Start UAPSD request. */
1431 case eWNI_PMC_ENTER_UAPSD_RSP:
Katya Nigam70d68332013-09-16 16:49:45 +05301432 pmcLog(pMac, LOG2, FL("Rcvd eWNI_PMC_ENTER_UAPSD_RSP with status = %d"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 if( eSmeCommandEnterUapsd != pCommand->command )
1434 {
Katya Nigam70d68332013-09-16 16:49:45 +05301435 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_ENTER_UAPSD_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 fRemoveCommand = eANI_BOOLEAN_FALSE;
1437 break;
1438 }
1439 /* Check that we are in the correct state for this message. */
1440 if (pMac->pmc.pmcState != REQUEST_START_UAPSD)
1441 {
Katya Nigam70d68332013-09-16 16:49:45 +05301442 pmcLog(pMac, LOGE,
1443 FL("Got Enter Uapsd rsp Message while in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 break;
1445 }
1446
1447 /* Enter UAPSD State if response indicates success. */
1448 if (pMsg->statusCode == eSIR_SME_SUCCESS)
1449 {
1450 pmcEnterUapsdState(pMac);
1451 pmcDoStartUapsdCallbacks(pMac, eHAL_STATUS_SUCCESS);
1452 }
1453 /* If response is failure, then we try to put the chip back in
1454 BMPS mode*/
1455 else {
Katya Nigam70d68332013-09-16 16:49:45 +05301456 pmcLog(pMac, LOGE, "PMC: response message to request to enter "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001457 "UAPSD indicates failure, status %x", pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 //Need to reset the UAPSD flag so pmcEnterBmpsState won't try to enter UAPSD.
1459 pMac->pmc.uapsdSessionRequired = FALSE;
1460 pmcEnterBmpsState(pMac);
1461 //UAPSD will not be retied in this case so tell requester we are done with failure
1462 pmcDoStartUapsdCallbacks(pMac, eHAL_STATUS_FAILURE);
1463 }
1464 break;
1465
1466 /* We got a response to our Stop UAPSD request. */
1467 case eWNI_PMC_EXIT_UAPSD_RSP:
Katya Nigam70d68332013-09-16 16:49:45 +05301468 pmcLog(pMac, LOG2, FL("Rcvd eWNI_PMC_EXIT_UAPSD_RSP with status = %d"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 if( eSmeCommandExitUapsd != pCommand->command )
1470 {
Katya Nigam70d68332013-09-16 16:49:45 +05301471 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_EXIT_UAPSD_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 fRemoveCommand = eANI_BOOLEAN_FALSE;
1473 break;
1474 }
1475 /* Check that we are in the correct state for this message. */
1476 if (pMac->pmc.pmcState != REQUEST_STOP_UAPSD)
1477 {
Katya Nigam70d68332013-09-16 16:49:45 +05301478 pmcLog(pMac, LOGE,
1479 FL("Got Exit Uapsd rsp Message while in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 break;
1481 }
1482
1483 /* Enter BMPS State */
1484 if (pMsg->statusCode != eSIR_SME_SUCCESS) {
Katya Nigam70d68332013-09-16 16:49:45 +05301485 pmcLog(pMac, LOGP, "PMC: response message to request to exit "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001486 "UAPSD indicates failure, status %x", pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 }
1488 pmcEnterBmpsState(pMac);
1489 break;
1490
1491 /* We got a response to our enter WOWL request. */
1492 case eWNI_PMC_ENTER_WOWL_RSP:
1493
1494 if( eSmeCommandEnterWowl != pCommand->command )
1495 {
Katya Nigam70d68332013-09-16 16:49:45 +05301496 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_ENTER_WOWL_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 fRemoveCommand = eANI_BOOLEAN_FALSE;
1498 break;
1499 }
1500 /* Check that we are in the correct state for this message. */
1501 if (pMac->pmc.pmcState != REQUEST_ENTER_WOWL)
1502 {
Katya Nigam70d68332013-09-16 16:49:45 +05301503 pmcLog(pMac, LOGE, FL("Got eWNI_PMC_ENTER_WOWL_RSP while in state %s"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 pmcGetPmcStateStr(pMac->pmc.pmcState));
1505 break;
1506 }
1507
1508 /* Enter WOWL State if response indicates success. */
1509 if (pMsg->statusCode == eSIR_SME_SUCCESS) {
1510 pmcEnterWowlState(pMac);
1511 pmcDoEnterWowlCallbacks(pMac, eHAL_STATUS_SUCCESS);
1512 }
1513
1514 /* If response is failure, then we try to put the chip back in
1515 BMPS mode*/
1516 else {
Katya Nigam70d68332013-09-16 16:49:45 +05301517 pmcLog(pMac, LOGE, "PMC: response message to request to enter "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001518 "WOWL indicates failure, status %x", pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 pmcEnterBmpsState(pMac);
1520 pmcDoEnterWowlCallbacks(pMac, eHAL_STATUS_FAILURE);
1521 }
1522 break;
1523
1524 /* We got a response to our exit WOWL request. */
1525 case eWNI_PMC_EXIT_WOWL_RSP:
1526
1527 if( eSmeCommandExitWowl != pCommand->command )
1528 {
Katya Nigam70d68332013-09-16 16:49:45 +05301529 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_EXIT_WOWL_RSP without request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 fRemoveCommand = eANI_BOOLEAN_FALSE;
1531 break;
1532 }
1533 /* Check that we are in the correct state for this message. */
1534 if (pMac->pmc.pmcState != REQUEST_EXIT_WOWL)
1535 {
Katya Nigam70d68332013-09-16 16:49:45 +05301536 pmcLog(pMac, LOGE, FL("Got Exit WOWL rsp Message while in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 break;
1538 }
1539
1540 /* Enter BMPS State */
1541 if (pMsg->statusCode != eSIR_SME_SUCCESS) {
Katya Nigam70d68332013-09-16 16:49:45 +05301542 pmcLog(pMac, LOGP, "PMC: response message to request to exit "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001543 "WOWL indicates failure, status %x", pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 }
1545 pmcEnterBmpsState(pMac);
1546 break;
1547
1548 default:
Katya Nigam70d68332013-09-16 16:49:45 +05301549 pmcLog(pMac, LOGE, FL("Invalid message type %d received"), pMsg->messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 PMC_ABORT;
1551 break;
1552 }//switch
1553
1554 if( fRemoveCommand )
1555 {
1556 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
1557 {
1558 pmcReleaseCommand( pMac, pCommand );
1559 smeProcessPendingQueue( pMac );
1560 }
1561 }
1562 }
1563 else
1564 {
Katya Nigam70d68332013-09-16 16:49:45 +05301565 pmcLog(pMac, LOGE, FL("message type %d received but no request is found"), pMsg->messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 }
1567}
1568
1569
1570/******************************************************************************
1571*
1572* Name: pmcMessageProcessor
1573*
1574* Description:
1575* Process a message received by PMC.
1576*
1577* Parameters:
1578* hHal - HAL handle for device
1579* pMsg - pointer to received message
1580*
1581* Returns:
1582* nothing
1583*
1584******************************************************************************/
1585void pmcMessageProcessor (tHalHandle hHal, tSirSmeRsp *pMsg)
1586{
1587 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1588
Katya Nigam70d68332013-09-16 16:49:45 +05301589 pmcLog(pMac, LOG2, FL("Entering pmcMessageProcessor, message type %d"), pMsg->messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001590
1591 switch( pMsg->messageType )
1592 {
1593 case eWNI_PMC_EXIT_BMPS_IND:
1594 //When PMC needs to handle more indication from PE, they need to be added here.
1595 {
1596 /* Device left BMPS on its own. */
Katya Nigam70d68332013-09-16 16:49:45 +05301597 pmcLog(pMac, LOGW, FL("Rcvd eWNI_PMC_EXIT_BMPS_IND with status = %d"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 /* Check that we are in the correct state for this message. */
1599 switch(pMac->pmc.pmcState)
1600 {
1601 case BMPS:
1602 case REQUEST_START_UAPSD:
1603 case UAPSD:
1604 case REQUEST_STOP_UAPSD:
1605 case REQUEST_ENTER_WOWL:
1606 case WOWL:
1607 case REQUEST_EXIT_WOWL:
1608 case REQUEST_FULL_POWER:
Katya Nigam70d68332013-09-16 16:49:45 +05301609 pmcLog(pMac, LOGW, FL("Got eWNI_PMC_EXIT_BMPS_IND while in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 break;
1611 default:
Katya Nigam70d68332013-09-16 16:49:45 +05301612 pmcLog(pMac, LOGE, FL("Got eWNI_PMC_EXIT_BMPS_IND while in state %d"), pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 PMC_ABORT;
1614 break;
1615 }
1616
1617 /* Enter Full Power State. */
1618 if (pMsg->statusCode != eSIR_SME_SUCCESS)
1619 {
Katya Nigam70d68332013-09-16 16:49:45 +05301620 pmcLog(pMac, LOGP, FL("Exit BMPS indication indicates failure, status %x"), pMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 }
1622 else
1623 {
1624 tpSirSmeExitBmpsInd pExitBmpsInd = (tpSirSmeExitBmpsInd)pMsg;
1625 pmcEnterRequestFullPowerState(hHal, pExitBmpsInd->exitBmpsReason);
1626 }
1627 break;
1628 }
1629
1630 default:
1631 pmcProcessResponse( pMac, pMsg );
1632 break;
1633 }
1634
1635}
1636
1637
1638tANI_BOOLEAN pmcValidateConnectState( tHalHandle hHal )
1639{
1640 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1641
1642 if ( !csrIsInfraConnected( pMac ) )
1643 {
Katya Nigam70d68332013-09-16 16:49:45 +05301644 pmcLog(pMac, LOGW, "PMC: STA not associated. BMPS cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001645 return eANI_BOOLEAN_FALSE;
1646 }
1647
1648 //Cannot have other session
1649 if ( csrIsIBSSStarted( pMac ) )
1650 {
Katya Nigam70d68332013-09-16 16:49:45 +05301651 pmcLog(pMac, LOGW, "PMC: IBSS started. BMPS cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 return eANI_BOOLEAN_FALSE;
1653 }
1654 if ( csrIsBTAMPStarted( pMac ) )
1655 {
Katya Nigam70d68332013-09-16 16:49:45 +05301656 pmcLog(pMac, LOGW, "PMC: BT-AMP exists. BMPS cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 return eANI_BOOLEAN_FALSE;
1658 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001659 if ((vos_concurrent_sessions_running()) &&
1660 (csrIsConcurrentInfraConnected( pMac ) ||
1661 (vos_get_concurrency_mode()& VOS_SAP) ||
1662 (vos_get_concurrency_mode()& VOS_P2P_GO)))
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 {
Katya Nigam70d68332013-09-16 16:49:45 +05301664 pmcLog(pMac, LOGW, "PMC: Multiple active sessions exists. BMPS cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 return eANI_BOOLEAN_FALSE;
1666 }
1667 return eANI_BOOLEAN_TRUE;
1668}
1669
1670tANI_BOOLEAN pmcAllowImps( tHalHandle hHal )
1671{
1672 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1673
1674 //Cannot have other session like IBSS or BT AMP running
1675 if ( csrIsIBSSStarted( pMac ) )
1676 {
Katya Nigam70d68332013-09-16 16:49:45 +05301677 pmcLog(pMac, LOGW, "PMC: IBSS started. IMPS cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 return eANI_BOOLEAN_FALSE;
1679 }
1680 if ( csrIsBTAMPStarted( pMac ) )
1681 {
Katya Nigam70d68332013-09-16 16:49:45 +05301682 pmcLog(pMac, LOGW, "PMC: BT-AMP exists. IMPS cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 return eANI_BOOLEAN_FALSE;
1684 }
1685
1686 //All sessions must be disconnected to allow IMPS
1687 if ( !csrIsAllSessionDisconnected( pMac ) )
1688 {
Katya Nigam70d68332013-09-16 16:49:45 +05301689 pmcLog(pMac, LOGW, "PMC: Atleast one connected session. IMPS cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 return eANI_BOOLEAN_FALSE;
1691 }
1692
1693 return eANI_BOOLEAN_TRUE;
1694}
1695
1696/******************************************************************************
1697*
1698* Name: pmcRequestBmps
1699*
1700* Description:
1701* Request that the device be put in BMPS state.
1702*
1703* Parameters:
1704* hHal - HAL handle for device
1705* callbackRoutine - Callback routine invoked in case of success/failure
1706* callbackContext - value to be passed as parameter to routine specified
1707* above
1708*
1709* Returns:
1710* eHAL_STATUS_SUCCESS - device is in BMPS state
1711* eHAL_STATUS_FAILURE - device cannot be brought to BMPS state
1712* eHAL_STATUS_PMC_PENDING - device is being brought to BMPS state,
1713*
1714******************************************************************************/
1715eHalStatus pmcRequestBmps (
1716 tHalHandle hHal,
1717 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
1718 void *callbackContext)
1719{
1720 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1721 tpRequestBmpsEntry pEntry;
1722 eHalStatus status;
1723
1724#ifdef FEATURE_WLAN_DIAG_SUPPORT
1725 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
1726
1727 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
1728 psRequest.event_subtype = WLAN_BMPS_ENTER_REQ;
1729
1730 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
1731#endif
1732
Katya Nigam70d68332013-09-16 16:49:45 +05301733 pmcLog(pMac, LOG2, "PMC: entering pmcRequestBmps");
Jeff Johnson295189b2012-06-20 16:38:30 -07001734
1735 /* If already in BMPS, just return. */
1736 if (pMac->pmc.pmcState == BMPS || REQUEST_START_UAPSD == pMac->pmc.pmcState || UAPSD == pMac->pmc.pmcState)
1737 {
Katya Nigam70d68332013-09-16 16:49:45 +05301738 pmcLog(pMac, LOG2, "PMC: Device already in BMPS pmcState %d", pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 pMac->pmc.bmpsRequestedByHdd = TRUE;
1740 return eHAL_STATUS_SUCCESS;
1741 }
1742
1743 status = pmcEnterBmpsCheck( pMac );
1744 if(HAL_STATUS_SUCCESS( status ))
1745 {
1746 status = pmcEnterRequestBmpsState(hHal);
1747 /* Enter Request BMPS State. */
1748 if ( HAL_STATUS_SUCCESS( status ) )
1749 {
1750 /* Remember that HDD requested BMPS. This flag will be used to put the
1751 device back into BMPS if any module other than HDD (e.g. CSR, QoS, or BAP)
1752 requests full power for any reason */
1753 pMac->pmc.bmpsRequestedByHdd = TRUE;
1754
1755 /* If able to enter Request BMPS State, then request is pending.
1756 Allocate entry for request BMPS callback routine list. */
1757 if (palAllocateMemory(
1758 pMac->hHdd, (void **)&pEntry,
1759 sizeof(tRequestBmpsEntry)) != eHAL_STATUS_SUCCESS)
1760 {
Katya Nigam70d68332013-09-16 16:49:45 +05301761 pmcLog(pMac, LOGE, "PMC: cannot allocate memory for request "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001762 "BMPS routine list entry");
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 return eHAL_STATUS_FAILURE;
1764 }
1765
1766 /* Store routine and context in entry. */
1767 pEntry->callbackRoutine = callbackRoutine;
1768 pEntry->callbackContext = callbackContext;
1769
1770 /* Add entry to list. */
1771 csrLLInsertTail(&pMac->pmc.requestBmpsList, &pEntry->link, FALSE);
1772
1773 status = eHAL_STATUS_PMC_PENDING;
1774 }
1775 else
1776 {
1777 status = eHAL_STATUS_FAILURE;
1778 }
1779 }
Gopichand Nakkala7c513ee2013-04-24 20:01:55 +05301780 /* Retry to enter the BMPS if the
1781 status = eHAL_STATUS_PMC_NOT_NOW */
1782 else if (status == eHAL_STATUS_PMC_NOT_NOW)
1783 {
1784 pmcStopTrafficTimer(hHal);
Katya Nigam70d68332013-09-16 16:49:45 +05301785 pmcLog(pMac, LOG1, FL("Can't enter BMPS+++"));
Gopichand Nakkala7c513ee2013-04-24 20:01:55 +05301786 if (pmcShouldBmpsTimerRun(pMac))
1787 {
1788 if (pmcStartTrafficTimer(pMac,
1789 pMac->pmc.bmpsConfig.trafficMeasurePeriod)
1790 != eHAL_STATUS_SUCCESS)
1791 {
Katya Nigam70d68332013-09-16 16:49:45 +05301792 pmcLog(pMac, LOG1, FL("Cannot start BMPS Retry timer"));
Gopichand Nakkala7c513ee2013-04-24 20:01:55 +05301793 }
Katya Nigam70d68332013-09-16 16:49:45 +05301794 pmcLog(pMac, LOG1,
Gopichand Nakkala7c513ee2013-04-24 20:01:55 +05301795 FL("BMPS Retry Timer already running or started"));
1796 }
1797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 return status;
1800}
1801
1802/******************************************************************************
1803*
1804* Name: pmcStartUapsd
1805*
1806* Description:
1807* Request that the device be put in UAPSD state.
1808*
1809* Parameters:
1810* hHal - HAL handle for device
1811* callbackRoutine - Callback routine invoked in case of success/failure
1812* callbackContext - value to be passed as parameter to routine specified
1813* above
1814*
1815* Returns:
1816* eHAL_STATUS_SUCCESS - device is in UAPSD state
1817* eHAL_STATUS_FAILURE - device cannot be brought to UAPSD state
1818* eHAL_STATUS_PMC_PENDING - device is being brought to UAPSD state
1819* eHAL_STATUS_PMC_DISABLED - UAPSD is disabled or BMPS mode is disabled
1820*
1821******************************************************************************/
1822eHalStatus pmcStartUapsd (
1823 tHalHandle hHal,
1824 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
1825 void *callbackContext)
1826{
1827 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1828 tpStartUapsdEntry pEntry;
1829
1830#ifdef FEATURE_WLAN_DIAG_SUPPORT
1831 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
1832
1833 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
1834 psRequest.event_subtype = WLAN_UAPSD_START_REQ;
1835
1836 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
1837#endif
1838
Katya Nigam70d68332013-09-16 16:49:45 +05301839 pmcLog(pMac, LOG2, "PMC: entering pmcStartUapsd");
Jeff Johnson295189b2012-06-20 16:38:30 -07001840
1841 if( !PMC_IS_READY(pMac) )
1842 {
Katya Nigam70d68332013-09-16 16:49:45 +05301843 pmcLog(pMac, LOGE, FL("Requesting UAPSD when PMC not ready"));
1844 pmcLog(pMac, LOGE, FL("pmcReady = %d pmcState = %s"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 pMac->pmc.pmcReady, pmcGetPmcStateStr(pMac->pmc.pmcState));
1846 return eHAL_STATUS_FAILURE;
1847 }
1848
1849 /* Check if BMPS is enabled. */
1850 if (!pMac->pmc.bmpsEnabled)
1851 {
Katya Nigam70d68332013-09-16 16:49:45 +05301852 pmcLog(pMac, LOGE, "PMC: Cannot enter UAPSD. BMPS is disabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 return eHAL_STATUS_PMC_DISABLED;
1854 }
1855
1856 /* Check if UAPSD is enabled. */
1857 if (!pMac->pmc.uapsdEnabled)
1858 {
Katya Nigam70d68332013-09-16 16:49:45 +05301859 pmcLog(pMac, LOGE, "PMC: Cannot enter UAPSD. UAPSD is disabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 return eHAL_STATUS_PMC_DISABLED;
1861 }
1862
1863 /* If already in UAPSD, just return. */
1864 if (pMac->pmc.pmcState == UAPSD)
1865 return eHAL_STATUS_SUCCESS;
1866
1867 /* Check that we are associated. */
1868 if (!pmcValidateConnectState( pMac ))
1869 {
Katya Nigam70d68332013-09-16 16:49:45 +05301870 pmcLog(pMac, LOGE, "PMC: STA not associated with an AP. UAPSD cannot be entered");
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 return eHAL_STATUS_FAILURE;
1872 }
1873
1874 /* Enter REQUEST_START_UAPSD State. */
1875 if (pmcEnterRequestStartUapsdState(hHal) != eHAL_STATUS_SUCCESS)
1876 return eHAL_STATUS_FAILURE;
1877
1878 if( NULL != callbackRoutine )
1879 {
1880 /* If success then request is pending. Allocate entry for callback routine list. */
1881 if (palAllocateMemory(pMac->hHdd, (void **)&pEntry,
1882 sizeof(tStartUapsdEntry)) != eHAL_STATUS_SUCCESS)
1883 {
Katya Nigam70d68332013-09-16 16:49:45 +05301884 pmcLog(pMac, LOGE, "PMC: cannot allocate memory for request "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001885 "start UAPSD routine list entry");
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 return eHAL_STATUS_FAILURE;
1887 }
1888
1889 /* Store routine and context in entry. */
1890 pEntry->callbackRoutine = callbackRoutine;
1891 pEntry->callbackContext = callbackContext;
1892
1893 /* Add entry to list. */
1894 csrLLInsertTail(&pMac->pmc.requestStartUapsdList, &pEntry->link, FALSE);
1895 }
1896
1897 return eHAL_STATUS_PMC_PENDING;
1898}
1899
1900/******************************************************************************
1901*
1902* Name: pmcStopUapsd
1903*
1904* Description:
1905* Request that the device be put out of UAPSD state.
1906*
1907* Parameters:
1908* hHal - HAL handle for device
1909*
1910* Returns:
1911* eHAL_STATUS_SUCCESS - device is put out of UAPSD and back in BMPS state
1912* eHAL_STATUS_FAILURE - device cannot be brought out of UAPSD state
1913*
1914******************************************************************************/
1915eHalStatus pmcStopUapsd (tHalHandle hHal)
1916{
1917 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1918
1919#ifdef FEATURE_WLAN_DIAG_SUPPORT
1920 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
1921
1922 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
1923 psRequest.event_subtype = WLAN_UAPSD_STOP_REQ;
1924
1925 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
1926#endif
1927
Katya Nigam70d68332013-09-16 16:49:45 +05301928 pmcLog(pMac, LOG2, "PMC: entering pmcStopUapsd");
Jeff Johnson295189b2012-06-20 16:38:30 -07001929
1930 /* Clear any buffered command for entering UAPSD */
1931 pMac->pmc.uapsdSessionRequired = FALSE;
1932
1933 /* Nothing to be done if we are already out of UAPSD. This can happen if
1934 some other module (HDD, BT-AMP) requested Full Power.*/
1935 if (pMac->pmc.pmcState != UAPSD && pMac->pmc.pmcState != REQUEST_STOP_UAPSD)
1936 {
Katya Nigam70d68332013-09-16 16:49:45 +05301937 pmcLog(pMac, LOGW, "PMC: Device is already out of UAPSD "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08001938 "state. Current state is %d", pMac->pmc.pmcState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 return eHAL_STATUS_SUCCESS;
1940 }
1941
1942 /* Enter REQUEST_STOP_UAPSD State*/
1943 if (pmcEnterRequestStopUapsdState(hHal) != eHAL_STATUS_SUCCESS)
1944 return eHAL_STATUS_FAILURE;
1945
1946 return eHAL_STATUS_SUCCESS;
1947}
1948
1949/* ---------------------------------------------------------------------------
1950 \fn pmcRequestStandby
1951 \brief Request that the device be put in standby.
1952 \param hHal - The handle returned by macOpen.
1953 \param callbackRoutine - Callback routine invoked in case of success/failure
1954 \param callbackContext - value to be passed as parameter to callback
1955 \return eHalStatus
1956 eHAL_STATUS_SUCCESS - device is in Standby mode
1957 eHAL_STATUS_FAILURE - device cannot be put in standby mode
1958 eHAL_STATUS_PMC_PENDING - device is being put in standby mode
1959 ---------------------------------------------------------------------------*/
1960extern eHalStatus pmcRequestStandby (
1961 tHalHandle hHal,
1962 void (*callbackRoutine) (void *callbackContext, eHalStatus status),
1963 void *callbackContext)
1964{
1965 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1966
1967#ifdef FEATURE_WLAN_DIAG_SUPPORT
1968 WLAN_VOS_DIAG_EVENT_DEF(psRequest, vos_event_wlan_powersave_payload_type);
1969
1970 vos_mem_zero(&psRequest, sizeof(vos_event_wlan_powersave_payload_type));
1971 psRequest.event_subtype = WLAN_ENTER_STANDBY_REQ;
1972
1973 WLAN_VOS_DIAG_EVENT_REPORT(&psRequest, EVENT_WLAN_POWERSAVE_GENERIC);
1974#endif
1975
Katya Nigam70d68332013-09-16 16:49:45 +05301976 pmcLog(pMac, LOG2, "PMC: entering pmcRequestStandby");
Jeff Johnson295189b2012-06-20 16:38:30 -07001977
1978 /* Check if standby is enabled. */
1979 if (!pMac->pmc.standbyEnabled)
1980 {
Katya Nigam70d68332013-09-16 16:49:45 +05301981 pmcLog(pMac, LOGE, "PMC: Cannot enter standby. Standby is disabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 return eHAL_STATUS_PMC_DISABLED;
1983 }
1984
1985 if( !PMC_IS_READY(pMac) )
1986 {
Katya Nigam70d68332013-09-16 16:49:45 +05301987 pmcLog(pMac, LOGE, FL("Requesting standby when PMC not ready"));
1988 pmcLog(pMac, LOGE, FL("pmcReady = %d pmcState = %s"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 pMac->pmc.pmcReady, pmcGetPmcStateStr(pMac->pmc.pmcState));
1990 return eHAL_STATUS_FAILURE;
1991 }
1992
1993 /* If already in STANDBY, just return. */
1994 if (pMac->pmc.pmcState == STANDBY)
1995 return eHAL_STATUS_SUCCESS;
1996
1997
1998 if (csrIsIBSSStarted(pMac) || csrIsBTAMPStarted(pMac))
1999 {
2000 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
2001 "WLAN: IBSS or BT-AMP session present. Cannot honor standby request");
2002 return eHAL_STATUS_PMC_NOT_NOW;
2003 }
2004
2005 /* Enter Request Standby State. */
2006 if (pmcEnterRequestStandbyState(hHal) != eHAL_STATUS_SUCCESS)
2007 return eHAL_STATUS_FAILURE;
2008
2009 /* Save the callback routine for when we need it. */
2010 pMac->pmc.standbyCallbackRoutine = callbackRoutine;
2011 pMac->pmc.standbyCallbackContext = callbackContext;
2012
2013 return eHAL_STATUS_PMC_PENDING;
2014}
2015
2016/* ---------------------------------------------------------------------------
2017 \fn pmcRegisterDeviceStateUpdateInd
2018 \brief Register a callback routine that is called whenever
2019 the device enters a new device state (Full Power, BMPS, UAPSD)
2020 \param hHal - The handle returned by macOpen.
2021 \param callbackRoutine - Callback routine to be registered
2022 \param callbackContext - Cookie to be passed back during callback
2023 \return eHalStatus
2024 eHAL_STATUS_SUCCESS - successfully registered
2025 eHAL_STATUS_FAILURE - not successfully registered
2026 ---------------------------------------------------------------------------*/
2027extern eHalStatus pmcRegisterDeviceStateUpdateInd (tHalHandle hHal,
2028 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState),
2029 void *callbackContext)
2030{
2031
2032 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2033 tpDeviceStateUpdateIndEntry pEntry;
2034
Katya Nigam70d68332013-09-16 16:49:45 +05302035 pmcLog(pMac, LOG2, FL("Entering pmcRegisterDeviceStateUpdateInd"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 /* Allocate entry for device power state update indication. */
2038 if (palAllocateMemory(pMac->hHdd, (void **)&pEntry, sizeof(tDeviceStateUpdateIndEntry)) != eHAL_STATUS_SUCCESS)
2039 {
Katya Nigam70d68332013-09-16 16:49:45 +05302040 pmcLog(pMac, LOGE, FL("Cannot allocate memory for device power state update indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 PMC_ABORT;
2042 return eHAL_STATUS_FAILURE;
2043 }
2044
2045 /* Store routine in entry. */
2046 pEntry->callbackRoutine = callbackRoutine;
2047 pEntry->callbackContext = callbackContext;
2048
2049 /* Add entry to list. */
2050 csrLLInsertTail(&pMac->pmc.deviceStateUpdateIndList, &pEntry->link, FALSE);
2051
2052 return eHAL_STATUS_SUCCESS;
2053}
2054
2055/* ---------------------------------------------------------------------------
2056 \fn pmcDeregisterDeviceStateUpdateInd
2057 \brief Deregister a routine that was registered for device state changes
2058 \param hHal - The handle returned by macOpen.
2059 \param callbackRoutine - Callback routine to be deregistered
2060 \return eHalStatus
2061 eHAL_STATUS_SUCCESS - successfully deregistered
2062 eHAL_STATUS_FAILURE - not successfully deregistered
2063 ---------------------------------------------------------------------------*/
2064eHalStatus pmcDeregisterDeviceStateUpdateInd (tHalHandle hHal,
2065 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState))
2066{
2067 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2068 tListElem *pEntry;
2069 tpDeviceStateUpdateIndEntry pDeviceStateUpdateIndEntry;
2070
Katya Nigam70d68332013-09-16 16:49:45 +05302071 pmcLog(pMac, LOG2, FL("Entering pmcDeregisterDeviceStateUpdateInd"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002072
2073 /* Find entry in the power save update routine list that matches
2074 the specified routine and remove it. */
2075 pEntry = csrLLPeekHead(&pMac->pmc.deviceStateUpdateIndList, FALSE);
2076 while (pEntry != NULL)
2077 {
2078 pDeviceStateUpdateIndEntry = GET_BASE_ADDR(pEntry, tDeviceStateUpdateIndEntry, link);
2079 if (pDeviceStateUpdateIndEntry->callbackRoutine == callbackRoutine)
2080 {
2081 if (!csrLLRemoveEntry(&pMac->pmc.deviceStateUpdateIndList, pEntry, FALSE))
2082 {
Katya Nigam70d68332013-09-16 16:49:45 +05302083 pmcLog(pMac, LOGE, FL("Cannot remove device state update ind entry from list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 return eHAL_STATUS_FAILURE;
2085 }
2086 if (palFreeMemory(pMac->hHdd, pDeviceStateUpdateIndEntry) != eHAL_STATUS_SUCCESS)
2087 {
Katya Nigam70d68332013-09-16 16:49:45 +05302088 pmcLog(pMac, LOGE, FL("Cannot free memory for device state update ind routine list entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 PMC_ABORT;
2090 return eHAL_STATUS_FAILURE;
2091 }
2092 return eHAL_STATUS_SUCCESS;
2093 }
2094 pEntry = csrLLNext(&pMac->pmc.deviceStateUpdateIndList, pEntry, FALSE);
2095 }
2096
2097 /* Could not find matching entry. */
2098 return eHAL_STATUS_FAILURE;
2099}
2100
2101/* ---------------------------------------------------------------------------
2102 \fn pmcReady
2103 \brief fn to inform PMC that eWNI_SME_SYS_READY_IND has been sent to PE.
2104 This acts as a trigger to send a message to PE to update the power
2105 save related conig to FW. Note that if HDD configures any power save
2106 related stuff before this API is invoked, PMC will buffer all the
2107 configutaion.
2108 \param hHal - The handle returned by macOpen.
2109 \return eHalStatus
2110 ---------------------------------------------------------------------------*/
2111eHalStatus pmcReady(tHalHandle hHal)
2112{
2113 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2114
Katya Nigam70d68332013-09-16 16:49:45 +05302115 pmcLog(pMac, LOG2, FL("Entering pmcReady"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002116
2117 if(pMac->pmc.pmcState == STOPPED)
2118 {
Katya Nigam70d68332013-09-16 16:49:45 +05302119 pmcLog(pMac, LOGP, FL("pmcReady is invoked even before pmcStart"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 return eHAL_STATUS_FAILURE;
2121 }
2122
2123 pMac->pmc.pmcReady = TRUE;
2124 if (pmcSendPowerSaveConfigMessage(hHal) != eHAL_STATUS_SUCCESS)
2125 {
2126 return eHAL_STATUS_FAILURE;
2127 }
2128
2129 return eHAL_STATUS_SUCCESS;
2130}
2131
2132/* ---------------------------------------------------------------------------
2133 \fn pmcWowlAddBcastPattern
2134 \brief Add a pattern for Pattern Byte Matching in Wowl mode. Firmware will
2135 do a pattern match on these patterns when Wowl is enabled during BMPS
2136 mode. Note that Firmware performs the pattern matching only on
2137 broadcast frames and while Libra is in BMPS mode.
2138 \param hHal - The handle returned by macOpen.
2139 \param pattern - Pointer to the pattern to be added
2140 \return eHalStatus
2141 eHAL_STATUS_FAILURE Cannot add pattern
2142 eHAL_STATUS_SUCCESS Request accepted.
2143 ---------------------------------------------------------------------------*/
2144eHalStatus pmcWowlAddBcastPattern (
2145 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002146 tpSirWowlAddBcastPtrn pattern,
2147 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002148{
2149 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002150 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002151
2152#ifdef FEATURE_WLAN_DIAG_SUPPORT
2153 vos_log_powersave_wow_add_ptrn_pkt_type *log_ptr = NULL;
2154 WLAN_VOS_DIAG_LOG_ALLOC(log_ptr, vos_log_powersave_wow_add_ptrn_pkt_type, LOG_WLAN_POWERSAVE_WOW_ADD_PTRN_C);
2155#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT
2156
Katya Nigam70d68332013-09-16 16:49:45 +05302157 pmcLog(pMac, LOG2, "PMC: entering pmcWowlAddBcastPattern");
Jeff Johnson295189b2012-06-20 16:38:30 -07002158
2159 if(pattern == NULL)
2160 {
Katya Nigam70d68332013-09-16 16:49:45 +05302161 pmcLog(pMac, LOGE, FL("Null broadcast pattern being passed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 return eHAL_STATUS_FAILURE;
2163 }
2164
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002165 if( pSession == NULL)
2166 {
Katya Nigam70d68332013-09-16 16:49:45 +05302167 pmcLog(pMac, LOGE, FL("Session not found "));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002168 return eHAL_STATUS_FAILURE;
2169 }
2170
Jeff Johnson295189b2012-06-20 16:38:30 -07002171#ifdef FEATURE_WLAN_DIAG_SUPPORT
2172 if( log_ptr )
2173 {
2174 log_ptr->pattern_id = pattern->ucPatternId;
2175 log_ptr->pattern_byte_offset = pattern->ucPatternByteOffset;
2176 log_ptr->pattern_size = pattern->ucPatternSize;
2177 log_ptr->pattern_mask_size = pattern->ucPatternMaskSize;
2178
2179 vos_mem_copy(log_ptr->pattern, pattern->ucPattern, SIR_WOWL_BCAST_PATTERN_MAX_SIZE);
2180 /* 1 bit in the pattern mask denotes 1 byte of pattern hence pattern mask size is 1/8 */
2181 vos_mem_copy(log_ptr->pattern_mask, pattern->ucPatternMask, SIR_WOWL_BCAST_PATTERN_MAX_SIZE >> 3);
2182 }
2183
2184 WLAN_VOS_DIAG_LOG_REPORT(log_ptr);
2185#endif
2186
2187
2188 if(pattern->ucPatternId >= SIR_WOWL_BCAST_MAX_NUM_PATTERNS )
2189 {
Katya Nigam70d68332013-09-16 16:49:45 +05302190 pmcLog(pMac, LOGE, FL("Pattern Id must range from 0 to %d"), SIR_WOWL_BCAST_MAX_NUM_PATTERNS-1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 return eHAL_STATUS_FAILURE;
2192 }
2193
2194 if( pMac->pmc.pmcState == STANDBY || pMac->pmc.pmcState == REQUEST_STANDBY )
2195 {
Katya Nigam70d68332013-09-16 16:49:45 +05302196 pmcLog(pMac, LOGE, FL("Cannot add WoWL Pattern as chip is in %s state"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 pmcGetPmcStateStr(pMac->pmc.pmcState));
2198 return eHAL_STATUS_FAILURE;
2199 }
Kumar Anandaca924e2013-07-22 14:35:34 -07002200
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 if( pMac->pmc.pmcState == IMPS || pMac->pmc.pmcState == REQUEST_IMPS )
2202 {
Katya Nigam70d68332013-09-16 16:49:45 +05302203 pmcLog(pMac, LOGE, FL("Cannot add WoWL Pattern as chip is in %s state"),
Kumar Anandaca924e2013-07-22 14:35:34 -07002204 pmcGetPmcStateStr(pMac->pmc.pmcState));
2205 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 }
2207
Kumar Anandaca924e2013-07-22 14:35:34 -07002208 if( !csrIsConnStateConnected(pMac, sessionId) )
2209 {
Katya Nigam70d68332013-09-16 16:49:45 +05302210 pmcLog(pMac, LOGE, FL("Cannot add WoWL Pattern session in %d state"),
Kumar Anandaca924e2013-07-22 14:35:34 -07002211 pSession->connectState);
2212 return eHAL_STATUS_FAILURE;
2213 }
2214
2215 vos_mem_copy(pattern->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
2216
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 if (pmcSendMessage(hHal, eWNI_PMC_WOWL_ADD_BCAST_PTRN, pattern, sizeof(tSirWowlAddBcastPtrn))
2218 != eHAL_STATUS_SUCCESS)
2219 {
Katya Nigam70d68332013-09-16 16:49:45 +05302220 pmcLog(pMac, LOGE, FL("Send of eWNI_PMC_WOWL_ADD_BCAST_PTRN to PE failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 return eHAL_STATUS_FAILURE;
2222 }
2223
2224 return eHAL_STATUS_SUCCESS;
2225}
2226
2227/* ---------------------------------------------------------------------------
2228 \fn pmcWowlDelBcastPattern
2229 \brief Delete a pattern that was added for Pattern Byte Matching.
2230 \param hHal - The handle returned by macOpen.
2231 \param pattern - Pattern to be deleted
2232 \return eHalStatus
2233 eHAL_STATUS_FAILURE Cannot delete pattern
2234 eHAL_STATUS_SUCCESS Request accepted.
2235 ---------------------------------------------------------------------------*/
2236eHalStatus pmcWowlDelBcastPattern (
2237 tHalHandle hHal,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002238 tpSirWowlDelBcastPtrn pattern,
2239 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002240{
2241 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002242 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002243
2244#ifdef FEATURE_WLAN_DIAG_SUPPORT
2245 WLAN_VOS_DIAG_EVENT_DEF(wowRequest, vos_event_wlan_powersave_wow_payload_type);
2246
2247 vos_mem_zero(&wowRequest, sizeof(vos_event_wlan_powersave_wow_payload_type));
2248 wowRequest.event_subtype = WLAN_WOW_DEL_PTRN_REQ;
2249 wowRequest.wow_del_ptrn_id = pattern->ucPatternId;
2250
2251 WLAN_VOS_DIAG_EVENT_REPORT(&wowRequest, EVENT_WLAN_POWERSAVE_WOW);
2252#endif
2253
Katya Nigam70d68332013-09-16 16:49:45 +05302254 pmcLog(pMac, LOG2, "PMC: entering pmcWowlDelBcastPattern");
Jeff Johnson295189b2012-06-20 16:38:30 -07002255
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002256 if( NULL == pSession )
2257 {
Katya Nigam70d68332013-09-16 16:49:45 +05302258 pmcLog(pMac, LOGE, FL("Session not found "));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002259 return eHAL_STATUS_FAILURE;
2260 }
2261
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 if(pattern->ucPatternId >= SIR_WOWL_BCAST_MAX_NUM_PATTERNS )
2263 {
Katya Nigam70d68332013-09-16 16:49:45 +05302264 pmcLog(pMac, LOGE, FL("Pattern Id must range from 0 to %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 SIR_WOWL_BCAST_MAX_NUM_PATTERNS-1);
2266 return eHAL_STATUS_FAILURE;
2267 }
2268
2269 if(pMac->pmc.pmcState == STANDBY || pMac->pmc.pmcState == REQUEST_STANDBY)
2270 {
Katya Nigam70d68332013-09-16 16:49:45 +05302271 pmcLog(pMac, LOGE, FL("Cannot delete WoWL Pattern as chip is in %s state"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 pmcGetPmcStateStr(pMac->pmc.pmcState));
2273 return eHAL_STATUS_FAILURE;
2274 }
2275
Yue Ma6b2bdf72013-08-15 16:27:04 -07002276 vos_mem_copy(pattern->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
2277
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 if( pMac->pmc.pmcState == IMPS || pMac->pmc.pmcState == REQUEST_IMPS )
2279 {
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002280 eHalStatus status;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002281
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 //Wake up the chip first
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002283 status = pmcDeferMsg( pMac, eWNI_PMC_WOWL_DEL_BCAST_PTRN,
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 pattern, sizeof(tSirWowlDelBcastPtrn) );
2285
2286 if( eHAL_STATUS_PMC_PENDING == status )
2287 {
2288 return eHAL_STATUS_SUCCESS;
2289 }
2290 else
2291 {
2292 //either fail or already in full power
2293 if( !HAL_STATUS_SUCCESS( status ) )
2294 {
2295 return ( status );
2296 }
2297 //else let it through because it is in full power state
2298 }
2299 }
2300
2301 if (pmcSendMessage(hHal, eWNI_PMC_WOWL_DEL_BCAST_PTRN, pattern, sizeof(tSirWowlDelBcastPtrn))
2302 != eHAL_STATUS_SUCCESS)
2303 {
Katya Nigam70d68332013-09-16 16:49:45 +05302304 pmcLog(pMac, LOGE, FL("Send of eWNI_PMC_WOWL_DEL_BCAST_PTRN to PE failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 return eHAL_STATUS_FAILURE;
2306 }
2307
2308 return eHAL_STATUS_SUCCESS;
2309}
2310
2311/* ---------------------------------------------------------------------------
2312 \fn pmcEnterWowl
2313 \brief Request that the device be brought to full power state.
2314 Note 1: If "fullPowerReason" specificied in this API is set to
2315 eSME_FULL_PWR_NEEDED_BY_HDD, PMC will clear any "buffered wowl" requests
2316 and also clear any "buffered BMPS requests by HDD". Assumption is that since
2317 HDD is requesting full power, we need to undo any previous HDD requests for
2318 BMPS (using sme_RequestBmps) or WoWL (using sme_EnterWoWL). If the reason is
2319 specified anything other than above, the buffered requests for BMPS and WoWL
2320 will not be cleared.
2321 Note 2: Requesting full power (no matter what the fullPowerReason is) doesn't
2322 disable the "auto bmps timer" (if it is enabled) or clear any "buffered uapsd
2323 request".
2324 Note 3: When the device finally enters Full Power PMC will start a timer
2325 if any of the following holds true:
2326 - Auto BMPS mode is enabled
2327 - Uapsd request is pending
2328 - HDD's request for BMPS is pending
2329 - HDD's request for WoWL is pending
2330 On timer expiry PMC will attempt to put the device in BMPS mode if following
2331 (in addition to those listed above) holds true:
2332 - Polling of all modules through the Power Save Check routine passes
2333 - STA is associated to an access point
2334 \param hHal - The handle returned by macOpen.
2335 \param - enterWowlCallbackRoutine Callback routine invoked in case of success/failure
2336 \param - enterWowlCallbackContext - Cookie to be passed back during callback
2337 \param - wakeReasonIndCB Callback routine invoked for Wake Reason Indication
2338 \param - wakeReasonIndCBContext - Cookie to be passed back during callback
2339 \param - fullPowerReason - Reason why this API is being invoked. SME needs to
2340 distinguish between BAP and HDD requests
2341 \return eHalStatus - status
2342 eHAL_STATUS_SUCCESS - device brought to full power state
2343 eHAL_STATUS_FAILURE - device cannot be brought to full power state
2344 eHAL_STATUS_PMC_PENDING - device is being brought to full power state,
2345 ---------------------------------------------------------------------------*/
2346eHalStatus pmcEnterWowl (
2347 tHalHandle hHal,
2348 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status),
2349 void *enterWowlCallbackContext,
2350#ifdef WLAN_WAKEUP_EVENTS
2351 void (*wakeReasonIndCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd),
2352 void *wakeReasonIndCBContext,
2353#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002354 tpSirSmeWowlEnterParams wowlEnterParams, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002355{
2356 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002358
2359#ifdef FEATURE_WLAN_DIAG_SUPPORT
2360 WLAN_VOS_DIAG_EVENT_DEF(wowRequest, vos_event_wlan_powersave_wow_payload_type);
2361
2362 vos_mem_zero(&wowRequest, sizeof(vos_event_wlan_powersave_wow_payload_type));
2363 wowRequest.event_subtype = WLAN_WOW_ENTER_REQ;
2364 wowRequest.wow_type = 0;
2365
2366 if(wowlEnterParams->ucMagicPktEnable)
2367 {
2368 wowRequest.wow_type |= 1;
2369 vos_mem_copy(wowRequest.wow_magic_pattern, (tANI_U8 *)wowlEnterParams->magicPtrn, 6);
2370 }
2371
2372 if(wowlEnterParams->ucPatternFilteringEnable)
2373 {
2374 wowRequest.wow_type |= 2;
2375 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 WLAN_VOS_DIAG_EVENT_REPORT(&wowRequest, EVENT_WLAN_POWERSAVE_WOW);
2377#endif
2378
Katya Nigam70d68332013-09-16 16:49:45 +05302379 pmcLog(pMac, LOG2, FL("PMC: entering pmcEnterWowl"));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002380
2381 if( NULL == pSession )
2382 {
Katya Nigam70d68332013-09-16 16:49:45 +05302383 pmcLog(pMac, LOGE, FL("Session not found "));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002384 return eHAL_STATUS_FAILURE;
2385 }
2386
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 if( !PMC_IS_READY(pMac) )
2388 {
Katya Nigam70d68332013-09-16 16:49:45 +05302389 pmcLog(pMac, LOGE, FL("Requesting WoWL when PMC not ready"));
2390 pmcLog(pMac, LOGE, FL("pmcReady = %d pmcState = %s"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 pMac->pmc.pmcReady, pmcGetPmcStateStr(pMac->pmc.pmcState));
2392 return eHAL_STATUS_FAILURE;
2393 }
2394
2395 /* Check if BMPS is enabled. */
2396 if (!pMac->pmc.bmpsEnabled)
2397 {
Katya Nigam70d68332013-09-16 16:49:45 +05302398 pmcLog(pMac, LOGE, "PMC: Cannot enter WoWL. BMPS is disabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 return eHAL_STATUS_PMC_DISABLED;
2400 }
2401
2402 /* Check if WoWL is enabled. */
2403 if (!pMac->pmc.wowlEnabled)
2404 {
Katya Nigam70d68332013-09-16 16:49:45 +05302405 pmcLog(pMac, LOGE, "PMC: Cannot enter WoWL. WoWL is disabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 return eHAL_STATUS_PMC_DISABLED;
2407 }
2408
2409 /* Check that we are associated with single Session. */
2410 if (!pmcValidateConnectState( pMac ))
2411 {
Katya Nigam70d68332013-09-16 16:49:45 +05302412 pmcLog(pMac, LOGE, "PMC: Cannot enable WOWL. STA not associated "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002413 "with an Access Point in Infra Mode with single active session");
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 return eHAL_STATUS_FAILURE;
2415 }
2416
2417 /* Is there a pending UAPSD request? HDD should have triggered QoS
2418 module to do the necessary cleanup before triggring WOWL*/
2419 if(pMac->pmc.uapsdSessionRequired)
2420 {
Katya Nigam70d68332013-09-16 16:49:45 +05302421 pmcLog(pMac, LOGE, "PMC: Cannot request WOWL. Pending UAPSD request");
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 return eHAL_STATUS_FAILURE;
2423 }
2424
2425 /* Check that entry into a power save mode is allowed at this time. */
2426 if (pMac->pmc.pmcState == FULL_POWER && !pmcPowerSaveCheck(hHal))
2427 {
Katya Nigam70d68332013-09-16 16:49:45 +05302428 pmcLog(pMac, LOGE, "PMC: Power save check failed. WOWL request "
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002429 "will not be accepted");
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 return eHAL_STATUS_FAILURE;
2431 }
2432
Kumar Anandaca924e2013-07-22 14:35:34 -07002433 vos_mem_copy(wowlEnterParams->bssId, pSession->connectedProfile.bssid,
2434 sizeof(tSirMacAddr));
2435
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 // To avoid race condition, set callback routines before sending message.
2437 /* cache the WOWL information */
2438 pMac->pmc.wowlEnterParams = *wowlEnterParams;
2439 pMac->pmc.enterWowlCallbackRoutine = enterWowlCallbackRoutine;
2440 pMac->pmc.enterWowlCallbackContext = enterWowlCallbackContext;
2441#ifdef WLAN_WAKEUP_EVENTS
2442 /* Cache the Wake Reason Indication callback information */
2443 pMac->pmc.wakeReasonIndCB = wakeReasonIndCB;
2444 pMac->pmc.wakeReasonIndCBContext = wakeReasonIndCBContext;
2445#endif // WLAN_WAKEUP_EVENTS
2446
2447 /* Enter Request WOWL State. */
2448 if (pmcRequestEnterWowlState(hHal, wowlEnterParams) != eHAL_STATUS_SUCCESS)
2449 return eHAL_STATUS_FAILURE;
2450
2451 pMac->pmc.wowlModeRequired = TRUE;
2452
2453 return eHAL_STATUS_PMC_PENDING;
2454}
2455
2456/* ---------------------------------------------------------------------------
2457 \fn pmcExitWowl
2458 \brief This is the SME API exposed to HDD to request exit from WoWLAN mode.
2459 SME will initiate exit from WoWLAN mode and device will be put in BMPS
2460 mode.
2461 \param hHal - The handle returned by macOpen.
2462 \return eHalStatus
2463 eHAL_STATUS_FAILURE Device cannot exit WoWLAN mode.
2464 eHAL_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
2465 ---------------------------------------------------------------------------*/
2466eHalStatus pmcExitWowl (tHalHandle hHal)
2467{
2468 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2469
2470#ifdef FEATURE_WLAN_DIAG_SUPPORT
2471 WLAN_VOS_DIAG_EVENT_DEF(wowRequest, vos_event_wlan_powersave_wow_payload_type);
2472
2473 vos_mem_zero(&wowRequest, sizeof(vos_event_wlan_powersave_wow_payload_type));
2474 wowRequest.event_subtype = WLAN_WOW_EXIT_REQ;
2475
2476 WLAN_VOS_DIAG_EVENT_REPORT(&wowRequest, EVENT_WLAN_POWERSAVE_WOW);
2477#endif
2478
Katya Nigam70d68332013-09-16 16:49:45 +05302479 pmcLog(pMac, LOG2, "PMC: entering pmcExitWowl");
Jeff Johnson295189b2012-06-20 16:38:30 -07002480
2481 /* Clear any buffered command for entering WOWL */
2482 pMac->pmc.wowlModeRequired = FALSE;
2483
2484 /* Enter REQUEST_EXIT_WOWL State*/
2485 if (pmcRequestExitWowlState(hHal) != eHAL_STATUS_SUCCESS)
2486 return eHAL_STATUS_FAILURE;
2487
2488 /* Clear the callback routines */
2489 pMac->pmc.enterWowlCallbackRoutine = NULL;
2490 pMac->pmc.enterWowlCallbackContext = NULL;
2491
2492 return eHAL_STATUS_SUCCESS;
2493}
2494
2495
2496
2497/* ---------------------------------------------------------------------------
2498 \fn pmcSetHostOffload
2499 \brief Set the host offload feature.
2500 \param hHal - The handle returned by macOpen.
2501 \param pRequest - Pointer to the offload request.
2502 \return eHalStatus
2503 eHAL_STATUS_FAILURE Cannot set the offload.
2504 eHAL_STATUS_SUCCESS Request accepted.
2505 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002506eHalStatus pmcSetHostOffload (tHalHandle hHal, tpSirHostOffloadReq pRequest,
2507 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002508{
2509 tpSirHostOffloadReq pRequestBuf;
2510 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07002511 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002512 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002513
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002514 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: IP address = %d.%d.%d.%d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 pRequest->params.hostIpv4Addr[0], pRequest->params.hostIpv4Addr[1],
2516 pRequest->params.hostIpv4Addr[2], pRequest->params.hostIpv4Addr[3]);
2517
Leela Venkata Kiran Kumar Reddy Chirala0ed2f332013-03-21 13:33:34 -07002518 if(NULL == pSession )
2519 {
2520 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: SESSION not Found\n", __func__);
2521 return eHAL_STATUS_FAILURE;
2522 }
2523
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 pRequestBuf = vos_mem_malloc(sizeof(tSirHostOffloadReq));
2525 if (NULL == pRequestBuf)
2526 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002527 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for host offload request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 return eHAL_STATUS_FAILED_ALLOC;
2529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002530
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002531 vos_mem_copy(pRequest->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
2532
2533 vos_mem_copy(pRequestBuf, pRequest, sizeof(tSirHostOffloadReq));
Jeff Johnsone7245742012-09-05 17:12:55 -07002534
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 msg.type = WDA_SET_HOST_OFFLOAD;
2536 msg.reserved = 0;
2537 msg.bodyptr = pRequestBuf;
2538 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
2539 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002540 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_HOST_OFFLOAD message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 vos_mem_free(pRequestBuf);
2542 return eHAL_STATUS_FAILURE;
2543 }
2544
2545 return eHAL_STATUS_SUCCESS;
2546}
2547
2548/* ---------------------------------------------------------------------------
2549 \fn pmcSetKeepAlive
2550 \brief Set the Keep Alive feature.
2551 \param hHal - The handle returned by macOpen.
2552 \param pRequest - Pointer to the Keep Alive.
2553 \return eHalStatus
2554 eHAL_STATUS_FAILURE Cannot set the keepalive.
2555 eHAL_STATUS_SUCCESS Request accepted.
2556 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002557eHalStatus pmcSetKeepAlive (tHalHandle hHal, tpSirKeepAliveReq pRequest, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002558{
2559 tpSirKeepAliveReq pRequestBuf;
2560 vos_msg_t msg;
Jeff Johnsone7245742012-09-05 17:12:55 -07002561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002562 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002563
2564 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_LOW, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002565 "WDA_SET_KEEP_ALIVE message", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002566
Leela Venkata Kiran Kumar Reddy Chirala0ed2f332013-03-21 13:33:34 -07002567 if(pSession == NULL )
2568 {
2569 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
2570 " Session not Found", __func__);
2571 return eHAL_STATUS_FAILURE;
2572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 pRequestBuf = vos_mem_malloc(sizeof(tSirKeepAliveReq));
2574 if (NULL == pRequestBuf)
2575 {
2576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
2577 "Not able to allocate memory for keep alive request",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002578 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 return eHAL_STATUS_FAILED_ALLOC;
2580 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002581
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002582 vos_mem_copy(pRequest->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
2583 vos_mem_copy(pRequestBuf, pRequest, sizeof(tSirKeepAliveReq));
Jeff Johnsone7245742012-09-05 17:12:55 -07002584
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_LOW, "buff TP %d "
2586 "input TP %d ", pRequestBuf->timePeriod, pRequest->timePeriod);
2587
2588 msg.type = WDA_SET_KEEP_ALIVE;
2589 msg.reserved = 0;
2590 msg.bodyptr = pRequestBuf;
2591 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
2592 {
2593 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: "
2594 "Not able to post WDA_SET_KEEP_ALIVE message to WDA",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002595 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 vos_mem_free(pRequestBuf);
2597 return eHAL_STATUS_FAILURE;
2598 }
2599
2600 return eHAL_STATUS_SUCCESS;
2601}
2602
2603
2604#ifdef WLAN_NS_OFFLOAD
2605
2606/* ---------------------------------------------------------------------------
2607 \fn pmcSetNSOffload
2608 \brief Set the host offload feature.
2609 \param hHal - The handle returned by macOpen.
2610 \param pRequest - Pointer to the offload request.
2611 \return eHalStatus
2612 eHAL_STATUS_FAILURE Cannot set the offload.
2613 eHAL_STATUS_SUCCESS Request accepted.
2614 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002615eHalStatus pmcSetNSOffload (tHalHandle hHal, tpSirHostOffloadReq pRequest,
2616 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002617{
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002618 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 tpSirHostOffloadReq pRequestBuf;
2620 vos_msg_t msg;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002621 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2622
2623 if( NULL == pSession )
Jeff Johnsone7245742012-09-05 17:12:55 -07002624 {
Katya Nigam70d68332013-09-16 16:49:45 +05302625 pmcLog(pMac, LOGE, FL("Session not found "));
Jeff Johnsone7245742012-09-05 17:12:55 -07002626 return eHAL_STATUS_FAILURE;
2627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002628
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07002629 vos_mem_copy(pRequest->bssId, pSession->connectedProfile.bssid,
2630 sizeof(tSirMacAddr));
2631
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 pRequestBuf = vos_mem_malloc(sizeof(tSirHostOffloadReq));
2633 if (NULL == pRequestBuf)
2634 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002635 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for NS offload request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 return eHAL_STATUS_FAILED_ALLOC;
2637 }
2638 vos_mem_copy(pRequestBuf, pRequest, sizeof(tSirHostOffloadReq));
2639
2640 msg.type = WDA_SET_NS_OFFLOAD;
2641 msg.reserved = 0;
2642 msg.bodyptr = pRequestBuf;
2643 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
2644 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002645 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post SIR_HAL_SET_HOST_OFFLOAD message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 vos_mem_free(pRequestBuf);
2647 return eHAL_STATUS_FAILURE;
2648 }
2649
2650 return eHAL_STATUS_SUCCESS;
2651}
2652
2653#endif //WLAN_NS_OFFLOAD
2654
2655
2656void pmcClosePowerSaveCheckList(tpAniSirGlobal pMac)
2657{
2658 tListElem *pEntry;
2659 tpPowerSaveCheckEntry pPowerSaveCheckEntry;
2660
2661 csrLLLock(&pMac->pmc.powerSaveCheckList);
2662 while ( (pEntry = csrLLRemoveHead(&pMac->pmc.powerSaveCheckList, FALSE)) )
2663 {
2664 pPowerSaveCheckEntry = GET_BASE_ADDR(pEntry, tPowerSaveCheckEntry, link);
2665 if (palFreeMemory(pMac->hHdd, pPowerSaveCheckEntry) != eHAL_STATUS_SUCCESS)
2666 {
Katya Nigam70d68332013-09-16 16:49:45 +05302667 pmcLog(pMac, LOGE, FL("Cannot free memory "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 PMC_ABORT;
2669 break;
2670 }
2671 }
2672 csrLLUnlock(&pMac->pmc.powerSaveCheckList);
2673 csrLLClose(&pMac->pmc.powerSaveCheckList);
2674}
2675
2676
2677void pmcCloseRequestFullPowerList(tpAniSirGlobal pMac)
2678{
2679 tListElem *pEntry;
2680 tpRequestFullPowerEntry pRequestFullPowerEntry;
2681
2682 csrLLLock(&pMac->pmc.requestFullPowerList);
2683 while ( (pEntry = csrLLRemoveHead(&pMac->pmc.requestFullPowerList, FALSE)) )
2684 {
2685 pRequestFullPowerEntry = GET_BASE_ADDR(pEntry, tRequestFullPowerEntry, link);
2686 if (palFreeMemory(pMac->hHdd, pRequestFullPowerEntry) != eHAL_STATUS_SUCCESS)
2687 {
Katya Nigam70d68332013-09-16 16:49:45 +05302688 pmcLog(pMac, LOGE, FL("Cannot free memory "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 PMC_ABORT;
2690 break;
2691 }
2692 }
2693 csrLLUnlock(&pMac->pmc.requestFullPowerList);
2694 csrLLClose(&pMac->pmc.requestFullPowerList);
2695}
2696
2697
2698void pmcCloseRequestBmpsList(tpAniSirGlobal pMac)
2699{
2700 tListElem *pEntry;
2701 tpRequestBmpsEntry pRequestBmpsEntry;
2702
2703 csrLLLock(&pMac->pmc.requestBmpsList);
2704 while ( (pEntry = csrLLRemoveHead(&pMac->pmc.requestBmpsList, FALSE)) )
2705 {
2706 pRequestBmpsEntry = GET_BASE_ADDR(pEntry, tRequestBmpsEntry, link);
2707 if (palFreeMemory(pMac->hHdd, pRequestBmpsEntry) != eHAL_STATUS_SUCCESS)
2708 {
Katya Nigam70d68332013-09-16 16:49:45 +05302709 pmcLog(pMac, LOGE, FL("Cannot free memory "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 PMC_ABORT;
2711 break;
2712 }
2713 }
2714 csrLLUnlock(&pMac->pmc.requestBmpsList);
2715 csrLLClose(&pMac->pmc.requestBmpsList);
2716}
2717
2718
2719void pmcCloseRequestStartUapsdList(tpAniSirGlobal pMac)
2720{
2721 tListElem *pEntry;
2722 tpStartUapsdEntry pStartUapsdEntry;
2723
2724 csrLLLock(&pMac->pmc.requestStartUapsdList);
2725 while ( (pEntry = csrLLRemoveHead(&pMac->pmc.requestStartUapsdList, FALSE)) )
2726 {
2727 pStartUapsdEntry = GET_BASE_ADDR(pEntry, tStartUapsdEntry, link);
2728 if (palFreeMemory(pMac->hHdd, pStartUapsdEntry) != eHAL_STATUS_SUCCESS)
2729 {
Katya Nigam70d68332013-09-16 16:49:45 +05302730 pmcLog(pMac, LOGE, FL("Cannot free memory "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 PMC_ABORT;
2732 break;
2733 }
2734 }
2735 csrLLUnlock(&pMac->pmc.requestStartUapsdList);
2736 csrLLClose(&pMac->pmc.requestStartUapsdList);
2737}
2738
2739
2740void pmcCloseDeviceStateUpdateList(tpAniSirGlobal pMac)
2741{
2742 tListElem *pEntry;
2743 tpDeviceStateUpdateIndEntry pDeviceStateUpdateIndEntry;
2744
2745 csrLLLock(&pMac->pmc.deviceStateUpdateIndList);
2746 while ( (pEntry = csrLLRemoveHead(&pMac->pmc.deviceStateUpdateIndList, FALSE)) )
2747 {
2748 pDeviceStateUpdateIndEntry = GET_BASE_ADDR(pEntry, tDeviceStateUpdateIndEntry, link);
2749 if (palFreeMemory(pMac->hHdd, pDeviceStateUpdateIndEntry) != eHAL_STATUS_SUCCESS)
2750 {
Katya Nigam70d68332013-09-16 16:49:45 +05302751 pmcLog(pMac, LOGE, FL("Cannot free memory "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 PMC_ABORT;
2753 break;
2754 }
2755 }
2756 csrLLUnlock(&pMac->pmc.deviceStateUpdateIndList);
2757 csrLLClose(&pMac->pmc.deviceStateUpdateIndList);
2758}
2759
2760
2761void pmcCloseDeferredMsgList(tpAniSirGlobal pMac)
2762{
2763 tListElem *pEntry;
2764 tPmcDeferredMsg *pDeferredMsg;
2765
2766 csrLLLock(&pMac->pmc.deferredMsgList);
2767 while ( (pEntry = csrLLRemoveHead(&pMac->pmc.deferredMsgList, FALSE)) )
2768 {
2769 pDeferredMsg = GET_BASE_ADDR(pEntry, tPmcDeferredMsg, link);
2770 if (palFreeMemory(pMac->hHdd, pDeferredMsg) != eHAL_STATUS_SUCCESS)
2771 {
Katya Nigam70d68332013-09-16 16:49:45 +05302772 pmcLog(pMac, LOGE, FL("Cannot free memory "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 PMC_ABORT;
2774 break;
2775 }
2776 }
2777 csrLLUnlock(&pMac->pmc.deferredMsgList);
2778 csrLLClose(&pMac->pmc.deferredMsgList);
2779}
2780
2781
2782#ifdef FEATURE_WLAN_SCAN_PNO
2783
2784static tSirRetStatus
2785pmcPopulateMacHeader( tpAniSirGlobal pMac,
2786 tANI_U8* pBD,
2787 tANI_U8 type,
2788 tANI_U8 subType,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302789 tSirMacAddr peerAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 tSirMacAddr selfMacAddr)
2791{
2792 tSirRetStatus statusCode = eSIR_SUCCESS;
2793 tpSirMacMgmtHdr pMacHdr;
2794
2795 /// Prepare MAC management header
2796 pMacHdr = (tpSirMacMgmtHdr) (pBD);
2797
2798 // Prepare FC
2799 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
2800 pMacHdr->fc.type = type;
2801 pMacHdr->fc.subType = subType;
2802
2803 // Prepare Address 1
2804 palCopyMemory( pMac->hHdd,
2805 (tANI_U8 *) pMacHdr->da,
2806 (tANI_U8 *) peerAddr,
2807 sizeof( tSirMacAddr ));
2808
2809 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
2810
2811 // Prepare Address 3
2812 palCopyMemory( pMac->hHdd,
2813 (tANI_U8 *) pMacHdr->bssId,
2814 (tANI_U8 *) peerAddr,
2815 sizeof( tSirMacAddr ));
2816 return statusCode;
2817} /*** pmcPopulateMacHeader() ***/
2818
2819
2820static tSirRetStatus
2821pmcPrepareProbeReqTemplate(tpAniSirGlobal pMac,
2822 tANI_U8 nChannelNum,
2823 tANI_U32 dot11mode,
2824 tSirMacAddr selfMacAddr,
2825 tANI_U8 *pFrame,
2826 tANI_U16 *pusLen)
2827{
2828 tDot11fProbeRequest pr;
2829 tANI_U32 nStatus, nBytes, nPayload;
2830 tSirRetStatus nSirStatus;
2831 /*Bcast tx*/
2832 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
2833 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2834
2835 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
2836 // and then hand it off to 'dot11fPackProbeRequest' (for
2837 // serialization). We start by zero-initializing the structure:
2838 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
2839
2840 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
2841
2842 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
2843 {
2844 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
2845 }
2846
2847
2848 if (IS_DOT11_MODE_HT(dot11mode))
2849 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002850 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 }
2852
2853 // That's it-- now we pack it. First, how much space are we going to
2854 // need?
2855 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
2856 if ( DOT11F_FAILED( nStatus ) )
2857 {
2858 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2859 "Failed to calculate the packed size f"
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002860 "or a Probe Request (0x%08x).", nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002861
2862 // We'll fall back on the worst case scenario:
2863 nPayload = sizeof( tDot11fProbeRequest );
2864 }
2865 else if ( DOT11F_WARNED( nStatus ) )
2866 {
2867 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2868 "There were warnings while calculating"
2869 "the packed size for a Probe Request ("
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002870 "0x%08x).", nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 }
2872
2873 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2874
2875 /* Prepare outgoing frame*/
2876 palZeroMemory( pMac->hHdd, pFrame, nBytes );
2877
2878 // Next, we fill out the buffer descriptor:
2879 nSirStatus = pmcPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302880 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -07002881
2882 if ( eSIR_SUCCESS != nSirStatus )
2883 {
2884 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002885 "Failed to populate the buffer descriptor for a Probe Request (%d).",
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 nSirStatus );
2887 return nSirStatus; // allocated!
2888 }
2889
2890 // That done, pack the Probe Request:
2891 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
2892 sizeof( tSirMacMgmtHdr ),
2893 nPayload, &nPayload );
2894 if ( DOT11F_FAILED( nStatus ) )
2895 {
2896 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere691dde12013-03-06 17:00:31 -08002897 "Failed to pack a Probe Request (0x%08x).", nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 return eSIR_FAILURE; // allocated!
2899 }
2900 else if ( DOT11F_WARNED( nStatus ) )
2901 {
2902 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05302903 "There were warnings while packing a Probe Request" );
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 }
2905
2906 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
2907 return eSIR_SUCCESS;
2908} // End pmcPrepareProbeReqTemplate.
2909
2910
2911eHalStatus pmcSetPreferredNetworkList
2912(
2913 tHalHandle hHal,
2914 tpSirPNOScanReq pRequest,
2915 tANI_U8 sessionId,
2916 preferredNetworkFoundIndCallback callbackRoutine,
2917 void *callbackContext
2918)
2919{
2920 tpSirPNOScanReq pRequestBuf;
2921 vos_msg_t msg;
2922 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2923 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Amar Singhal751e6072013-01-24 16:02:56 -08002924 tANI_U8 ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002925
Amar Singhal751e6072013-01-24 16:02:56 -08002926 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2927 "%s: SSID = 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx, "
2928 "0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx", __func__,
2929 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[0]),
2930 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[4]),
2931 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[8]),
2932 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[12]),
2933 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[16]),
2934 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[20]),
2935 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[24]),
2936 *((v_U32_t *) &pRequest->aNetworks[0].ssId.ssId[28]),
2937 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[0]),
2938 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[4]),
2939 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[8]),
2940 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[12]),
2941 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[16]),
2942 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[20]),
2943 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[24]),
2944 *((v_U32_t *) &pRequest->aNetworks[1].ssId.ssId[28]));
2945
Jeff Johnson295189b2012-06-20 16:38:30 -07002946
2947 pRequestBuf = vos_mem_malloc(sizeof(tSirPNOScanReq));
2948 if (NULL == pRequestBuf)
2949 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002950 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for PNO request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 return eHAL_STATUS_FAILED_ALLOC;
2952 }
2953
2954 vos_mem_copy(pRequestBuf, pRequest, sizeof(tSirPNOScanReq));
2955
2956 /*Must translate the mode first*/
2957 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
2958 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
2959
2960 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05302961 if (eSIR_SUCCESS == pmcPrepareProbeReqTemplate(pMac, SIR_PNO_24G_DEFAULT_CH,
2962 ucDot11Mode, pSession->selfMacAddr,
2963 pRequestBuf->p24GProbeTemplate,
2964 &pRequestBuf->us24GProbeTemplateLen))
2965 {
2966 /* Append IE passed by supplicant(if any) to probe request */
2967 if ((0 < pRequest->us24GProbeTemplateLen) &&
2968 ((pRequestBuf->us24GProbeTemplateLen +
2969 pRequest->us24GProbeTemplateLen) < SIR_PNO_MAX_PB_REQ_SIZE ))
2970 {
2971 vos_mem_copy((tANI_U8 *)&pRequestBuf->p24GProbeTemplate +
2972 pRequestBuf->us24GProbeTemplateLen,
2973 (tANI_U8 *)&pRequest->p24GProbeTemplate,
2974 pRequest->us24GProbeTemplateLen);
2975 pRequestBuf->us24GProbeTemplateLen +=
2976 pRequest->us24GProbeTemplateLen;
2977 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2978 "%s: pRequest->us24GProbeTemplateLen = %d", __func__,
2979 pRequest->us24GProbeTemplateLen);
2980 }
2981 else
2982 {
2983 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2984 "%s: Extra ie discarded on 2.4G, IE length = %d", __func__,
2985 pRequest->us24GProbeTemplateLen);
2986 }
2987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002988
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05302989 if (eSIR_SUCCESS == pmcPrepareProbeReqTemplate(pMac, SIR_PNO_5G_DEFAULT_CH,
2990 ucDot11Mode, pSession->selfMacAddr,
2991 pRequestBuf->p5GProbeTemplate,
2992 &pRequestBuf->us5GProbeTemplateLen))
2993 {
2994 /* Append IE passed by supplicant(if any) to probe request */
2995 if ((0 < pRequest->us5GProbeTemplateLen ) &&
2996 ((pRequestBuf->us5GProbeTemplateLen +
2997 pRequest->us5GProbeTemplateLen) < SIR_PNO_MAX_PB_REQ_SIZE ))
2998 {
2999 vos_mem_copy((tANI_U8 *)&pRequestBuf->p5GProbeTemplate +
3000 pRequestBuf->us5GProbeTemplateLen,
3001 (tANI_U8 *)&pRequest->p5GProbeTemplate,
3002 pRequest->us5GProbeTemplateLen);
3003 pRequestBuf->us5GProbeTemplateLen += pRequest->us5GProbeTemplateLen;
3004 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3005 "%s: pRequestBuf->us5GProbeTemplateLen = %d", __func__,
3006 pRequest->us5GProbeTemplateLen);
3007 }
3008 else
3009 {
3010 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3011 "%s: Extra IE discarded on 5G, IE length = %d", __func__,
3012 pRequest->us5GProbeTemplateLen);
3013 }
3014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003015
3016 msg.type = WDA_SET_PNO_REQ;
3017 msg.reserved = 0;
3018 msg.bodyptr = pRequestBuf;
3019 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3020 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003021 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_PNO_REQ message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 vos_mem_free(pRequestBuf);
3023 return eHAL_STATUS_FAILURE;
3024 }
3025
3026 /* Cache the Preferred Network Found Indication callback information */
3027 pMac->pmc.prefNetwFoundCB = callbackRoutine;
3028 pMac->pmc.preferredNetworkFoundIndCallbackContext = callbackContext;
3029
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003030 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "-%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003031
3032 return eHAL_STATUS_SUCCESS;
3033}
3034
3035eHalStatus pmcSetRssiFilter(tHalHandle hHal, v_U8_t rssiThreshold)
3036{
3037 tpSirSetRSSIFilterReq pRequestBuf;
3038 vos_msg_t msg;
3039
3040
3041 pRequestBuf = vos_mem_malloc(sizeof(tpSirSetRSSIFilterReq));
3042 if (NULL == pRequestBuf)
3043 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003044 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for PNO request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 return eHAL_STATUS_FAILED_ALLOC;
3046 }
3047
3048
3049 pRequestBuf->rssiThreshold = rssiThreshold;
3050
3051 msg.type = WDA_SET_RSSI_FILTER_REQ;
3052 msg.reserved = 0;
3053 msg.bodyptr = pRequestBuf;
3054 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3055 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003056 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_PNO_REQ message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 vos_mem_free(pRequestBuf);
3058 return eHAL_STATUS_FAILURE;
3059 }
3060
3061 return eHAL_STATUS_SUCCESS;
3062}
3063
3064
3065eHalStatus pmcUpdateScanParams(tHalHandle hHal, tCsrConfig *pRequest, tCsrChannel *pChannelList, tANI_U8 b11dResolved)
3066{
3067 tpSirUpdateScanParams pRequestBuf;
3068 vos_msg_t msg;
3069 int i;
3070
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003071 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s started", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003072
3073 pRequestBuf = vos_mem_malloc(sizeof(tSirUpdateScanParams));
3074 if (NULL == pRequestBuf)
3075 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003076 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for UpdateScanParams request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 return eHAL_STATUS_FAILED_ALLOC;
3078 }
3079
3080 //
3081 // Fill pRequestBuf structure from pRequest
3082 //
3083 pRequestBuf->b11dEnabled = pRequest->Is11eSupportEnabled;
3084 pRequestBuf->b11dResolved = b11dResolved;
3085 pRequestBuf->ucChannelCount =
Pratik Bhalgatd4404592012-11-22 17:49:14 +05303086 ( pChannelList->numChannels < SIR_PNO_MAX_NETW_CHANNELS_EX )?
3087 pChannelList->numChannels:SIR_PNO_MAX_NETW_CHANNELS_EX;
Jeff Johnson295189b2012-06-20 16:38:30 -07003088
Pratik Bhalgatd4404592012-11-22 17:49:14 +05303089 for (i=0; i < pRequestBuf->ucChannelCount; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 {
Pratik Bhalgatd4404592012-11-22 17:49:14 +05303091 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3092 "%s: Channel List %d: %d", __FUNCTION__, i, pChannelList->channelList[i] );
3093
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 pRequestBuf->aChannels[i] = pChannelList->channelList[i];
3095 }
3096 pRequestBuf->usPassiveMinChTime = pRequest->nPassiveMinChnTime;
3097 pRequestBuf->usPassiveMaxChTime = pRequest->nPassiveMaxChnTime;
3098 pRequestBuf->usActiveMinChTime = pRequest->nActiveMinChnTime;
3099 pRequestBuf->usActiveMaxChTime = pRequest->nActiveMaxChnTime;
3100 pRequestBuf->ucCBState = PHY_SINGLE_CHANNEL_CENTERED;
3101
3102 msg.type = WDA_UPDATE_SCAN_PARAMS_REQ;
3103 msg.reserved = 0;
3104 msg.bodyptr = pRequestBuf;
3105 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3106 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003107 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_UPDATE_SCAN_PARAMS message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 vos_mem_free(pRequestBuf);
3109 return eHAL_STATUS_FAILURE;
3110 }
3111
3112 return eHAL_STATUS_SUCCESS;
3113}
3114#endif // FEATURE_WLAN_SCAN_PNO
3115
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08003116eHalStatus pmcSetPowerParams(tHalHandle hHal, tSirSetPowerParamsReq* pwParams, tANI_BOOLEAN forced)
Jeff Johnson295189b2012-06-20 16:38:30 -07003117{
3118 tSirSetPowerParamsReq* pRequestBuf;
3119 vos_msg_t msg;
3120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3121 tpPESession psessionEntry;
3122
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08003123 psessionEntry = peGetValidPowerSaveSession(pMac);
3124 if (!forced && (psessionEntry == NULL))
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 {
3126 return eHAL_STATUS_NOT_INITIALIZED;
3127 }
3128
3129 pRequestBuf = vos_mem_malloc(sizeof(tSirSetPowerParamsReq));
3130 if (NULL == pRequestBuf)
3131 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003132 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Power Paramrequest", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 return eHAL_STATUS_FAILED_ALLOC;
3134 }
3135
3136
3137 vos_mem_copy(pRequestBuf, pwParams, sizeof(*pRequestBuf));
3138
3139
3140 msg.type = WDA_SET_POWER_PARAMS_REQ;
3141 msg.reserved = 0;
3142 msg.bodyptr = pRequestBuf;
3143
3144 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
3145 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003146 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_SET_POWER_PARAMS_REQ message to WDA", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 vos_mem_free(pRequestBuf);
3148 return eHAL_STATUS_FAILURE;
3149 }
3150
3151 return eHAL_STATUS_SUCCESS;
3152}
3153
3154#ifdef WLAN_FEATURE_PACKET_FILTERING
3155eHalStatus pmcGetFilterMatchCount
3156(
3157 tHalHandle hHal,
3158 FilterMatchCountCallback callbackRoutine,
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003159 void *callbackContext,
3160 tANI_U8 sessionId
Jeff Johnson295189b2012-06-20 16:38:30 -07003161)
3162{
3163 tpSirRcvFltPktMatchRsp pRequestBuf;
3164 vos_msg_t msg;
3165 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003167
3168 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303169 "%s", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003170
Leela Venkata Kiran Kumar Reddy Chirala0ed2f332013-03-21 13:33:34 -07003171 if(NULL == pSession )
3172 {
3173 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3174 "%s: Session not found ", __func__);
3175 return eHAL_STATUS_FAILURE;
3176 }
3177
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 pRequestBuf = vos_mem_malloc(sizeof(tSirRcvFltPktMatchRsp));
3179 if (NULL == pRequestBuf)
3180 {
Leela Venkata Kiran Kumar Reddy Chirala0ed2f332013-03-21 13:33:34 -07003181 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 "%s: Not able to allocate "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003183 "memory for Get PC Filter Match Count request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 return eHAL_STATUS_FAILED_ALLOC;
3185 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003186
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003187 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003188
3189 msg.type = WDA_PACKET_COALESCING_FILTER_MATCH_COUNT_REQ;
3190 msg.reserved = 0;
3191 msg.bodyptr = pRequestBuf;
3192
3193 /* Cache the Packet Coalescing Filter Match Count callback information */
3194 if (NULL != pMac->pmc.FilterMatchCountCB)
3195 {
3196 // Do we need to check if the callback is in use?
3197 // Because we are not sending the same message again when it is pending,
3198 // the only case when the callback is not NULL is that the previous message
3199 //was timed out or failed.
3200 // So, it will be safe to set the callback in this case.
3201 }
3202
3203 pMac->pmc.FilterMatchCountCB = callbackRoutine;
3204 pMac->pmc.FilterMatchCountCBContext = callbackContext;
3205
3206 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
3207 {
3208 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3209 "%s: Not able to post WDA_PACKET_COALESCING_FILTER_MATCH_COUNT_REQ "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003210 "message to WDA", __func__);
Gopichand Nakkala114718f2013-03-25 19:19:46 -07003211 vos_mem_free(pRequestBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 return eHAL_STATUS_FAILURE;
3213 }
3214
3215 return eHAL_STATUS_SUCCESS;
3216}
3217#endif // WLAN_FEATURE_PACKET_FILTERING
3218
3219#ifdef WLAN_FEATURE_GTK_OFFLOAD
3220/* ---------------------------------------------------------------------------
3221 \fn pmcSetGTKOffload
3222 \brief Set GTK offload feature.
3223 \param hHal - The handle returned by macOpen.
3224 \param pGtkOffload - Pointer to the GTK offload request.
3225 \return eHalStatus
3226 eHAL_STATUS_FAILURE Cannot set the offload.
3227 eHAL_STATUS_SUCCESS Request accepted.
3228 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003229eHalStatus pmcSetGTKOffload (tHalHandle hHal, tpSirGtkOffloadParams pGtkOffload,
3230 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003231{
3232 tpSirGtkOffloadParams pRequestBuf;
3233 vos_msg_t msg;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003234 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3235 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003236
3237 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s: KeyReplayCounter: %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003238 __func__, pGtkOffload->ullKeyReplayCounter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003239
Leela Venkata Kiran Kumar Reddy Chirala0ed2f332013-03-21 13:33:34 -07003240 if(NULL == pSession )
3241 {
3242 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3243 "%s: Session not found ", __func__);
3244 return eHAL_STATUS_FAILURE;
3245 }
3246
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 pRequestBuf = (tpSirGtkOffloadParams)vos_mem_malloc(sizeof(tSirGtkOffloadParams));
3248 if (NULL == pRequestBuf)
3249 {
3250 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003251 "memory for GTK offload request", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 return eHAL_STATUS_FAILED_ALLOC;
3253 }
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003254
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003255 vos_mem_copy(pGtkOffload->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256
3257 vos_mem_copy(pRequestBuf, pGtkOffload, sizeof(tSirGtkOffloadParams));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003258
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 msg.type = WDA_GTK_OFFLOAD_REQ;
3260 msg.reserved = 0;
3261 msg.bodyptr = pRequestBuf;
3262 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3263 {
3264 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003265 "SIR_HAL_SET_GTK_OFFLOAD message to HAL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 vos_mem_free(pRequestBuf);
3267 return eHAL_STATUS_FAILURE;
3268 }
3269
3270 return eHAL_STATUS_SUCCESS;
3271}
3272
3273/* ---------------------------------------------------------------------------
3274 \fn pmcGetGTKOffload
3275 \brief Get GTK offload information.
3276 \param hHal - The handle returned by macOpen.
3277 \param callbackRoutine - Pointer to the GTK Offload Get Info response callback routine.
3278 \return eHalStatus
3279 eHAL_STATUS_FAILURE Cannot set the offload.
3280 eHAL_STATUS_SUCCESS Request accepted.
3281 ---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003282eHalStatus pmcGetGTKOffload(tHalHandle hHal, GTKOffloadGetInfoCallback callbackRoutine,
3283 void *callbackContext, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07003284{
3285 tpSirGtkOffloadGetInfoRspParams pRequestBuf;
3286 vos_msg_t msg;
3287 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003289
3290 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%s: filterId = %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003291 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003292
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003293 if(NULL == pSession )
3294 {
3295 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003296 "%s: Session not found ", __func__);
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003297 return eHAL_STATUS_FAILURE;
3298 }
3299
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05303300 pRequestBuf = (tpSirGtkOffloadGetInfoRspParams)
3301 vos_mem_malloc(sizeof (tSirGtkOffloadGetInfoRspParams));
Leela Venkata Kiran Kumar Reddy Chirala0ed2f332013-03-21 13:33:34 -07003302 if (NULL == pRequestBuf)
3303 {
3304 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate "
3305 "memory for Get GTK offload request", __func__);
3306 return eHAL_STATUS_FAILED_ALLOC;
3307 }
3308
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07003309 vos_mem_copy(pRequestBuf->bssId, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3310
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 msg.type = WDA_GTK_OFFLOAD_GETINFO_REQ;
3312 msg.reserved = 0;
3313 msg.bodyptr = pRequestBuf;
3314
3315 /* Cache the Get GTK Offload callback information */
3316 if (NULL != pMac->pmc.GtkOffloadGetInfoCB)
3317 {
3318 // Do we need to check if the callback is in use?
3319 // Because we are not sending the same message again when it is pending,
3320 // the only case when the callback is not NULL is that the previous message was timed out or failed.
3321 // So, it will be safe to set the callback in this case.
3322 }
3323
3324 pMac->pmc.GtkOffloadGetInfoCB = callbackRoutine;
3325 pMac->pmc.GtkOffloadGetInfoCBContext = callbackContext;
3326
3327 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3328 {
3329 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_GTK_OFFLOAD_GETINFO_REQ message to WDA",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003330 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 vos_mem_free(pRequestBuf);
3332 return eHAL_STATUS_FAILURE;
3333 }
3334
3335 return eHAL_STATUS_SUCCESS;
3336}
3337#endif // WLAN_FEATURE_GTK_OFFLOAD
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07003338
3339v_BOOL_t IsPmcImpsReqFailed (tHalHandle hHal)
3340{
3341 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3342 v_BOOL_t impsReqFailStatus;
3343
3344 impsReqFailStatus = (pMac->pmc.ImpsReqFailed || pMac->pmc.ImpsReqTimerFailed);
3345
3346 return impsReqFailStatus;
3347
3348}
3349
3350void pmcResetImpsFailStatus (tHalHandle hHal)
3351{
3352 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3353 pMac->pmc.ImpsReqFailed = VOS_FALSE;
3354 pMac->pmc.ImpsReqTimerFailed = VOS_FALSE;
3355}
Rajeev79dbe4c2013-10-05 11:03:42 +05303356
3357#ifdef FEATURE_WLAN_BATCH_SCAN
3358/* -----------------------------------------------------------------------------
3359 \fn pmcSetBatchScanReq
3360 \brief setting batch scan request in FW
3361 \param hHal - The handle returned by macOpen.
3362 \param sessionId - session ID
3363 \param callbackRoutine - Pointer to set batch scan request callback routine
3364 \param callbackContext - Pointer to set batch scan request callback context
3365 \return eHalStatus
3366 eHAL_STATUS_FAILURE Cannot set batch scan request
3367 eHAL_STATUS_SUCCESS Request accepted.
3368 -----------------------------------------------------------------------------*/
3369
3370eHalStatus pmcSetBatchScanReq(tHalHandle hHal, tSirSetBatchScanReq *pRequest,
3371 tANI_U8 sessionId, hddSetBatchScanReqCallback callbackRoutine,
3372 void *callbackContext)
3373{
3374 tpSirSetBatchScanReq pRequestBuf;
3375 vos_msg_t msg;
3376 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3377
3378 pRequestBuf = vos_mem_malloc(sizeof(tSirSetBatchScanReq));
3379 if (NULL == pRequestBuf)
3380 {
3381 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3382 "%s: Not able to allocate memory for SET BATCH SCAN req", __func__);
3383 return eHAL_STATUS_FAILED_ALLOC;
3384 }
3385
3386 /* Cache HDD callback information*/
3387 pMac->pmc.setBatchScanReqCallback = callbackRoutine;
3388 pMac->pmc.setBatchScanReqCallbackContext = callbackContext;
3389
3390 pRequestBuf->scanFrequency = pRequest->scanFrequency;
3391 pRequestBuf->numberOfScansToBatch = pRequest->numberOfScansToBatch;
3392 pRequestBuf->bestNetwork = pRequest->bestNetwork;
3393 pRequestBuf->rfBand = pRequest->rfBand;
3394 pRequestBuf->rtt = pRequest->rtt;
3395
3396 msg.type = WDA_SET_BATCH_SCAN_REQ;
3397 msg.reserved = 0;
3398 msg.bodyptr = pRequestBuf;
3399 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3400 {
3401 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3402 "%s: Not able to post WDA_SET_BATCH_SCAN_REQ message to WDA",
3403 __func__);
3404 vos_mem_free(pRequestBuf);
3405 return eHAL_STATUS_FAILURE;
3406 }
3407
3408 return eHAL_STATUS_SUCCESS;
3409}
3410
3411/* -----------------------------------------------------------------------------
3412 \fn pmcTriggerBatchScanResultInd
3413 \brief API to trigger batch scan results indications from FW
3414 \param hHal - The handle returned by macOpen.
3415 \param sessionId - session ID
3416 \param callbackRoutine - Pointer to get batch scan request callback routine
3417 \param callbackContext - Pointer to get batch scan request callback context
3418 \return eHalStatus
3419 eHAL_STATUS_FAILURE Cannot set batch scan request
3420 eHAL_STATUS_SUCCESS Request accepted.
3421 -----------------------------------------------------------------------------*/
3422
3423eHalStatus pmcTriggerBatchScanResultInd
3424(
3425 tHalHandle hHal, tSirTriggerBatchScanResultInd *pRequest, tANI_U8 sessionId,
3426 hddTriggerBatchScanResultIndCallback callbackRoutine, void *callbackContext
3427)
3428{
3429 tpSirTriggerBatchScanResultInd pRequestBuf;
3430 vos_msg_t msg;
3431 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3432
3433 pRequestBuf = vos_mem_malloc(sizeof(tSirTriggerBatchScanResultInd));
3434 if (NULL == pRequestBuf)
3435 {
3436 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3437 "%s: Not able to allocate memory for WDA_TRIGGER_BATCH_SCAN_RESULT_IND",
3438 __func__);
3439 return eHAL_STATUS_FAILED_ALLOC;
3440 }
3441
3442 /*HDD callback to be called after getting batch scan result ind from FW*/
3443 pMac->pmc.batchScanResultCallback = callbackRoutine;
3444 pMac->pmc.batchScanResultCallbackContext = callbackContext;
3445
3446 pRequestBuf->param = pRequest->param;
3447
3448 msg.type = WDA_TRIGGER_BATCH_SCAN_RESULT_IND;
3449 msg.reserved = 0;
3450 msg.bodyptr = pRequestBuf;
3451 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3452 {
3453 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3454 "%s: Not able to post WDA_TRIGGER_BATCH_SCAN_RESULT_IND message"
3455 " to WDA", __func__);
3456 vos_mem_free(pRequestBuf);
3457 return eHAL_STATUS_FAILURE;
3458 }
3459
3460 return eHAL_STATUS_SUCCESS;
3461}
3462
3463/* -----------------------------------------------------------------------------
3464 \fn pmcStopBatchScanInd
3465 \brief Stoping batch scan request in FW
3466 \param hHal - The handle returned by macOpen.
3467 \param callbackRoutine - Pointer to stop batch scan request callback routine
3468 \return eHalStatus
3469 eHAL_STATUS_FAILURE Cannot set batch scan request
3470 eHAL_STATUS_SUCCESS Request accepted.
3471 -----------------------------------------------------------------------------*/
3472
3473eHalStatus pmcStopBatchScanInd(tHalHandle hHal, tSirStopBatchScanInd *pRequest,
3474 tANI_U8 sessionId)
3475{
3476 tSirStopBatchScanInd *pRequestBuf;
3477 vos_msg_t msg;
3478
3479 pRequestBuf = vos_mem_malloc(sizeof(tSirStopBatchScanInd));
3480 if (NULL == pRequestBuf)
3481 {
3482 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3483 "%s: Not able to allocate memory for STOP BATCH SCAN IND", __func__);
3484 return eHAL_STATUS_FAILED_ALLOC;
3485 }
3486
3487 pRequestBuf->param = pRequest->param;
3488
3489 msg.type = WDA_STOP_BATCH_SCAN_IND;
3490 msg.reserved = 0;
3491 msg.bodyptr = pRequestBuf;
3492 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
3493 {
3494 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
3495 "%s: Not able to post WDA_TOP_BATCH_SCAN_IND message to WDA", __func__);
3496 vos_mem_free(pRequestBuf);
3497 return eHAL_STATUS_FAILURE;
3498 }
3499
3500 return eHAL_STATUS_SUCCESS;
3501}
3502
3503#endif