blob: 0afe5676ac1cf3cec2b6f9b031ebe44b72511427 [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 */
c_hpothu01484c02014-05-16 14:05:15 +0530180 tWowlExitSource wowlExitSrc; /*WoWl exiting because of wakeup pkt or user explicitly disabling WoWL*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 void (*enterWowlCallbackRoutine) (void *callbackContext, eHalStatus status); /* routine to call for wowl request */
182 void *enterWowlCallbackContext;/* value to be passed as parameter to routine specified above */
183 tSirSmeWowlEnterParams wowlEnterParams; /* WOWL mode configuration */
184 tDblLinkList deferredMsgList; //The message in here are deferred and DONOT expect response from PE
185 tANI_BOOLEAN rfSuppliesVotedOff; //Whether RF supplies are voted off or not.
186#ifdef FEATURE_WLAN_SCAN_PNO
187 preferredNetworkFoundIndCallback prefNetwFoundCB; /* routine to call for Preferred Network Found Indication */
188 void *preferredNetworkFoundIndCallbackContext;/* value to be passed as parameter to routine specified above */
189#endif // FEATURE_WLAN_SCAN_PNO
190#ifdef WLAN_FEATURE_PACKET_FILTERING
191 FilterMatchCountCallback FilterMatchCountCB; /* routine to call for Packet Coalescing Filter Match Count */
192 void *FilterMatchCountCBContext;/* value to be passed as parameter to routine specified above */
193#endif // WLAN_FEATURE_PACKET_FILTERING
194#ifdef WLAN_FEATURE_GTK_OFFLOAD
195 GTKOffloadGetInfoCallback GtkOffloadGetInfoCB; /* routine to call for GTK Offload Information */
196 void *GtkOffloadGetInfoCBContext; /* value to be passed as parameter to routine specified above */
197#endif // WLAN_FEATURE_GTK_OFFLOAD
198
199#ifdef WLAN_WAKEUP_EVENTS
200 void (*wakeReasonIndCB) (void *callbackContext, tpSirWakeReasonInd pWakeReasonInd); /* routine to call for Wake Reason Indication */
201 void *wakeReasonIndCBContext; /* value to be passed as parameter to routine specified above */
202#endif // WLAN_WAKEUP_EVENTS
Madan Mohan Koyyalamudi69b34182013-01-16 08:51:40 +0530203
204/* If TRUE driver will go to BMPS only if host operatiing system asks to enter BMPS.
205* For android wlan_hdd_cfg80211_set_power_mgmt API will be used to set host powersave*/
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -0700206 v_BOOL_t isHostPsEn;
207 v_BOOL_t ImpsReqFailed;
208 v_BOOL_t ImpsReqTimerFailed;
209 tANI_U8 ImpsReqFailCnt;
210 tANI_U8 ImpsReqTimerfailCnt;
Rajeev79dbe4c2013-10-05 11:03:42 +0530211
212#ifdef FEATURE_WLAN_BATCH_SCAN
213 /*HDD callback to be called after receiving SET BATCH SCAN RSP from FW*/
214 hddSetBatchScanReqCallback setBatchScanReqCallback;
215 void * setBatchScanReqCallbackContext;
216 /*HDD callback to be called after receiving BATCH SCAN iRESULT IND from FW*/
217 hddTriggerBatchScanResultIndCallback batchScanResultCallback;
218 void * batchScanResultCallbackContext;
219#endif
220
221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222} tPmcInfo, *tpPmcInfo;
223
224
225//MACRO
226#define PMC_IS_READY(pMac) ( ((pMac)->pmc.pmcReady) && (STOPPED != (pMac)->pmc.pmcState) )
227
228
229/* Routine definitions. */
230extern eHalStatus pmcEnterLowPowerState (tHalHandle hHal);
231extern eHalStatus pmcExitLowPowerState (tHalHandle hHal);
232extern eHalStatus pmcEnterFullPowerState (tHalHandle hHal);
233extern eHalStatus pmcEnterRequestFullPowerState (tHalHandle hHal, tRequestFullPowerReason fullPowerReason);
234extern eHalStatus pmcEnterRequestImpsState (tHalHandle hHal);
235extern eHalStatus pmcEnterImpsState (tHalHandle hHal);
236extern eHalStatus pmcEnterRequestBmpsState (tHalHandle hHal);
237extern eHalStatus pmcEnterBmpsState (tHalHandle hHal);
238extern eHalStatus pmcEnterRequestStartUapsdState (tHalHandle hHal);
239extern eHalStatus pmcEnterUapsdState (tHalHandle hHal);
240extern eHalStatus pmcEnterRequestStopUapsdState (tHalHandle hHal);
241extern eHalStatus pmcEnterRequestStandbyState (tHalHandle hHal);
242extern eHalStatus pmcEnterStandbyState (tHalHandle hHal);
243extern tANI_BOOLEAN pmcPowerSaveCheck (tHalHandle hHal);
244extern eHalStatus pmcSendPowerSaveConfigMessage (tHalHandle hHal);
245extern eHalStatus pmcSendMessage (tpAniSirGlobal pMac, tANI_U16 messageType, void *pMessageData, tANI_U32 messageSize);
246extern void pmcDoCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
247extern void pmcDoBmpsCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
248extern void pmcDoStartUapsdCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
249extern void pmcDoStandbyCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
250extern eHalStatus pmcStartTrafficTimer (tHalHandle hHal, tANI_U32 expirationTime);
251extern void pmcStopTrafficTimer (tHalHandle hHal);
252extern void pmcImpsTimerExpired (tHalHandle hHal);
253extern void pmcTrafficTimerExpired (tHalHandle hHal);
254
255#ifdef FEATURE_WLAN_DIAG_SUPPORT
256extern eHalStatus pmcStartDiagEvtTimer (tHalHandle hHal);
257extern void pmcStopDiagEvtTimer (tHalHandle hHal);
258extern void pmcDiagEvtTimerExpired (tHalHandle hHal);
259#endif
260
261extern void pmcExitPowerSaveTimerExpired (tHalHandle hHal);
262extern tPmcState pmcGetPmcState (tHalHandle hHal);
263extern const char* pmcGetPmcStateStr(tPmcState state);
264extern void pmcDoDeviceStateUpdateCallbacks (tHalHandle hHal, tPmcState state);
265extern eHalStatus pmcRequestEnterWowlState(tHalHandle hHal, tpSirSmeWowlEnterParams wowlEnterParams);
266extern eHalStatus pmcEnterWowlState (tHalHandle hHal);
267extern eHalStatus pmcRequestExitWowlState(tHalHandle hHal);
268extern void pmcDoEnterWowlCallbacks (tHalHandle hHal, eHalStatus callbackStatus);
269//The function will request for full power as well in addition to defer the message
270extern eHalStatus pmcDeferMsg( tpAniSirGlobal pMac, tANI_U16 messageType,
271 void *pData, tANI_U32 size);
272extern eHalStatus pmcIssueCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam,
273 tANI_U32 size, tANI_BOOLEAN fPutToListHead );
274extern eHalStatus pmcEnterImpsCheck( tpAniSirGlobal pMac );
275extern eHalStatus pmcEnterBmpsCheck( tpAniSirGlobal pMac );
276extern tANI_BOOLEAN pmcShouldBmpsTimerRun( tpAniSirGlobal pMac );
277#endif