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