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