blob: 9b0b3316f24bdec99da795715aba2b5c0b8840e4 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * 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 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/******************************************************************************
43*
44* Name: pmc.h
45*
46* Description: Power Management Control (PMC) internal definitions.
47*
48* Copyright 2008 (c) Qualcomm, Incorporated.
49 All Rights Reserved.
50* Qualcomm Confidential and Proprietary.
51*
52******************************************************************************/
53
54#ifndef __PMC_H__
55#define __PMC_H__
56
57
58#include "palTimer.h"
59#include "csrLinkList.h"
60#include "pmcApi.h"
61#include "smeInternal.h"
62
63
64//Change PMC_ABORT to no-op for now. We need to define it as VOS_ASSERT(0) once we
65//cleanup the usage.
66#define PMC_ABORT
67
68/* Host power sources. */
69typedef enum ePowerSource
70{
71 AC_POWER, /* host is operating from AC power */
72 BATTERY_POWER /* host is operating from battery power */
73} tPowerSource;
74
75
76/* Power save check routine list entry. */
77typedef struct sPowerSaveCheckEntry
78{
79 tListElem link; /* list links */
80 tANI_BOOLEAN (*checkRoutine) (void *checkContext); /* power save check routine */
81 void *checkContext; /* value to be passed as parameter to routine specified above */
82} tPowerSaveCheckEntry, *tpPowerSaveCheckEntry;
83
84
85/* Device Power State update indication list entry. */
86typedef struct sDeviceStateUpdateIndEntry
87{
88 tListElem link; /* list links */
89 void (*callbackRoutine) (void *callbackContext, tPmcState pmcState); /* Callback routine to be invoked when pmc changes device state */
90 void *callbackContext; /* value to be passed as parameter to routine specified above */
91} tDeviceStateUpdateIndEntry, *tpDeviceStateUpdateIndEntry;
92
93/* Request full power callback routine list entry. */
94typedef struct sRequestFullPowerEntry
95{
96 tListElem link; /* list links */
97 void (*callbackRoutine) (void *callbackContext, eHalStatus status); /* routine to call when full power is restored */
98 void *callbackContext; /* value to be passed as parameter to routine specified above */
99} tRequestFullPowerEntry, *tpRequestFullPowerEntry;
100
101
102/* Request BMPS callback routine list entry. */
103typedef struct sRequestBmpsEntry
104{
105 tListElem link; /* list links */
106
107 /* routine to call when BMPS request succeeded/failed */
108 void (*callbackRoutine) (void *callbackContext, eHalStatus status);
109
110 /* value to be passed as parameter to routine specified above */
111 void *callbackContext;
112
113} tRequestBmpsEntry, *tpRequestBmpsEntry;
114
115
116/* Start U-APSD callback routine list entry. */
117typedef struct sStartUapsdEntry
118{
119 tListElem link; /* list links */
120
121 /* routine to call when Uapsd Start succeeded/failed*/
122 void (*callbackRoutine) (void *callbackContext, eHalStatus status);
123
124 /* value to be passed as parameter to routine specified above */
125 void *callbackContext;
126
127} tStartUapsdEntry, *tpStartUapsdEntry;
128
129typedef struct sPmcDeferredMsg
130{
131 tListElem link;
132 tpAniSirGlobal pMac;
133 tANI_U16 messageType;
134 tANI_U16 size; //number of bytes in u.data
135 union
136 {
137 tSirPowerSaveCfg powerSaveConfig;
138 tSirWowlAddBcastPtrn wowlAddPattern;
139 tSirWowlDelBcastPtrn wowlDelPattern;
140 tANI_U8 data[1]; //a place holder
141 }u;
142} tPmcDeferredMsg;
143
144
145
146/* Current PMC information for a particular device. */
147typedef struct sPmcInfo
148{
149 tPowerSource powerSource; /* host power source */
150 tPmcSwitchState hwWlanSwitchState; /* Hardware WLAN Switch state */
151 tPmcSwitchState swWlanSwitchState; /* Software WLAN Switch state */
152 tPmcState pmcState; /* PMC state */
153 tANI_BOOLEAN requestFullPowerPending; /* TRUE if a request for full power is pending */
154 tRequestFullPowerReason requestFullPowerReason; /* reason for requesting full power */
155 tPmcImpsConfigParams impsConfig; /* IMPS configuration */
156 tPmcBmpsConfigParams bmpsConfig; /* BMPS configuration */
157 tPmcSmpsConfigParams smpsConfig; /* SMPS configuration */
158 tANI_BOOLEAN impsEnabled; /* TRUE if IMPS is enabled */
159 tANI_BOOLEAN bmpsEnabled; /* TRUE if BMPS is enabled */
160 tANI_BOOLEAN autoBmpsEntryEnabled; /* TRUE if auto BMPS entry is enabled. If set to TRUE, PMC will
161 attempt to put the device into BMPS on entry into full Power */
162 tANI_BOOLEAN bmpsRequestedByHdd; /*TRUE if BMPS mode has been requested by HDD */
163 tANI_BOOLEAN bmpsRequestQueued; /*If a enter BMPS request is queued*/
164 tANI_BOOLEAN smpsEnabled; /* TRUE if SMPS is enabled */
165 tANI_BOOLEAN remainInPowerActiveTillDHCP; /* Remain in Power active till DHCP completes */
166 tANI_U32 remainInPowerActiveThreshold; /*Remain in Power active till DHCP threshold*/
167 tANI_U32 impsPeriod; /* amount of time to remain in IMPS */
168 void (*impsCallbackRoutine) (void *callbackContext, eHalStatus status); /* routine to call when IMPS period
169 has finished */
170 void *impsCallbackContext; /* value to be passed as parameter to routine specified above */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530171 vos_timer_t hImpsTimer; /* timer to use with IMPS */
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 vos_timer_t hTrafficTimer; /* timer to measure traffic for BMPS */
173#ifdef FEATURE_WLAN_DIAG_SUPPORT
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530174 vos_timer_t hDiagEvtTimer; /* timer to report PMC state through DIAG event */
Jeff Johnson295189b2012-06-20 16:38:30 -0700175#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530176 vos_timer_t hExitPowerSaveTimer; /* timer for deferred exiting of power save mode */
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 tDblLinkList powerSaveCheckList; /* power save check routine list */
178 tDblLinkList requestFullPowerList; /* request full power callback routine list */
179 tANI_U32 cLastTxUnicastFrames; /* transmit unicast frame count at last BMPS traffic timer expiration */
180 tANI_U32 cLastRxUnicastFrames; /* receive unicast frame count at last BMPS traffic timer expiration */
181
182
183 tANI_BOOLEAN uapsdEnabled; /* TRUE if UAPSD is enabled */
184 tANI_BOOLEAN uapsdSessionRequired; /* TRUE if device should go to UAPSD on entering BMPS*/
185 tDblLinkList requestBmpsList; /* request Bmps callback routine list */
186 tDblLinkList requestStartUapsdList; /* request start Uapsd callback routine list */
187 tANI_BOOLEAN standbyEnabled; /* TRUE if Standby is enabled */
188 void (*standbyCallbackRoutine) (void *callbackContext, eHalStatus status); /* routine to call for standby request */
189 void *standbyCallbackContext;/* value to be passed as parameter to routine specified above */
190 tDblLinkList deviceStateUpdateIndList; /*update device state indication list */
191 tANI_BOOLEAN pmcReady; /*whether eWNI_SME_SYS_READY_IND has been sent to PE or not */
192 tANI_BOOLEAN wowlEnabled; /* TRUE if WoWL is enabled */
193 tANI_BOOLEAN wowlModeRequired; /* TRUE if device should go to WOWL on entering BMPS */
194 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status); /* routine to call for wowl request */
195 void *enterWowlCallbackContext;/* value to be passed as parameter to routine specified above */
196 tSirSmeWowlEnterParams wowlEnterParams; /* WOWL mode configuration */
197 tDblLinkList deferredMsgList; //The message in here are deferred and DONOT expect response from PE
198 tANI_BOOLEAN rfSuppliesVotedOff; //Whether RF supplies are voted off or not.
199#ifdef FEATURE_WLAN_SCAN_PNO
200 preferredNetworkFoundIndCallback prefNetwFoundCB; /* routine to call for Preferred Network Found Indication */
201 void *preferredNetworkFoundIndCallbackContext;/* value to be passed as parameter to routine specified above */
202#endif // FEATURE_WLAN_SCAN_PNO
203#ifdef WLAN_FEATURE_PACKET_FILTERING
204 FilterMatchCountCallback FilterMatchCountCB; /* routine to call for Packet Coalescing Filter Match Count */
205 void *FilterMatchCountCBContext;/* value to be passed as parameter to routine specified above */
206#endif // WLAN_FEATURE_PACKET_FILTERING
207#ifdef WLAN_FEATURE_GTK_OFFLOAD
208 GTKOffloadGetInfoCallback GtkOffloadGetInfoCB; /* routine to call for GTK Offload Information */
209 void *GtkOffloadGetInfoCBContext; /* value to be passed as parameter to routine specified above */
210#endif // WLAN_FEATURE_GTK_OFFLOAD
211
212#ifdef WLAN_WAKEUP_EVENTS
213 void (*wakeReasonIndCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd); /* routine to call for Wake Reason Indication */
214 void *wakeReasonIndCBContext; /* value to be passed as parameter to routine specified above */
215#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +0530216
217/* If TRUE driver will go to BMPS only if host operatiing system asks to enter BMPS.
218* For android wlan_hdd_cfg80211_set_power_mgmt API will be used to set host powersave*/
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -0700219 v_BOOL_t isHostPsEn;
220 v_BOOL_t ImpsReqFailed;
221 v_BOOL_t ImpsReqTimerFailed;
222 tANI_U8 ImpsReqFailCnt;
223 tANI_U8 ImpsReqTimerfailCnt;
Rajeev79dbe4c2013-10-05 11:03:42 +0530224
225#ifdef FEATURE_WLAN_BATCH_SCAN
226 /*HDD callback to be called after receiving SET BATCH SCAN RSP from FW*/
227 hddSetBatchScanReqCallback setBatchScanReqCallback;
228 void * setBatchScanReqCallbackContext;
229 /*HDD callback to be called after receiving BATCH SCAN iRESULT IND from FW*/
230 hddTriggerBatchScanResultIndCallback batchScanResultCallback;
231 void * batchScanResultCallbackContext;
232#endif
233
234
Jeff Johnson295189b2012-06-20 16:38:30 -0700235} tPmcInfo, *tpPmcInfo;
236
237
238//MACRO
239#define PMC_IS_READY(pMac) ( ((pMac)->pmc.pmcReady) && (STOPPED != (pMac)->pmc.pmcState) )
240
241
242/* Routine definitions. */
243extern eHalStatus pmcEnterLowPowerState (tHalHandle hHal);
244extern eHalStatus pmcExitLowPowerState (tHalHandle hHal);
245extern eHalStatus pmcEnterFullPowerState (tHalHandle hHal);
246extern eHalStatus pmcEnterRequestFullPowerState (tHalHandle hHal, tRequestFullPowerReason fullPowerReason);
247extern eHalStatus pmcEnterRequestImpsState (tHalHandle hHal);
248extern eHalStatus pmcEnterImpsState (tHalHandle hHal);
249extern eHalStatus pmcEnterRequestBmpsState (tHalHandle hHal);
250extern eHalStatus pmcEnterBmpsState (tHalHandle hHal);
251extern eHalStatus pmcEnterRequestStartUapsdState (tHalHandle hHal);
252extern eHalStatus pmcEnterUapsdState (tHalHandle hHal);
253extern eHalStatus pmcEnterRequestStopUapsdState (tHalHandle hHal);
254extern eHalStatus pmcEnterRequestStandbyState (tHalHandle hHal);
255extern eHalStatus pmcEnterStandbyState (tHalHandle hHal);
256extern tANI_BOOLEAN pmcPowerSaveCheck (tHalHandle hHal);
257extern eHalStatus pmcSendPowerSaveConfigMessage (tHalHandle hHal);
258extern eHalStatus pmcSendMessage (tpAniSirGlobal pMac, tANI_U16 messageType, void *pMessageData, tANI_U32 messageSize);
259extern void pmcDoCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
260extern void pmcDoBmpsCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
261extern void pmcDoStartUapsdCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
262extern void pmcDoStandbyCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
263extern eHalStatus pmcStartTrafficTimer (tHalHandle hHal, tANI_U32 expirationTime);
264extern void pmcStopTrafficTimer (tHalHandle hHal);
265extern void pmcImpsTimerExpired (tHalHandle hHal);
266extern void pmcTrafficTimerExpired (tHalHandle hHal);
267
268#ifdef FEATURE_WLAN_DIAG_SUPPORT
269extern eHalStatus pmcStartDiagEvtTimer (tHalHandle hHal);
270extern void pmcStopDiagEvtTimer (tHalHandle hHal);
271extern void pmcDiagEvtTimerExpired (tHalHandle hHal);
272#endif
273
274extern void pmcExitPowerSaveTimerExpired (tHalHandle hHal);
275extern tPmcState pmcGetPmcState (tHalHandle hHal);
276extern const char* pmcGetPmcStateStr(tPmcState state);
277extern void pmcDoDeviceStateUpdateCallbacks (tHalHandle hHal, tPmcState state);
278extern eHalStatus pmcRequestEnterWowlState(tHalHandle hHal, tpSirSmeWowlEnterParams wowlEnterParams);
279extern eHalStatus pmcEnterWowlState (tHalHandle hHal);
280extern eHalStatus pmcRequestExitWowlState(tHalHandle hHal);
281extern void pmcDoEnterWowlCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
282//The function will request for full power as well in addition to defer the message
283extern eHalStatus pmcDeferMsg( tpAniSirGlobal pMac, tANI_U16 messageType,
284 void *pData, tANI_U32 size);
285extern eHalStatus pmcIssueCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
286 tANI_U32 size, tANI_BOOLEAN fPutToListHead );
287extern eHalStatus pmcEnterImpsCheck( tpAniSirGlobal pMac );
288extern eHalStatus pmcEnterBmpsCheck( tpAniSirGlobal pMac );
289extern tANI_BOOLEAN pmcShouldBmpsTimerRun( tpAniSirGlobal pMac );
290#endif