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