Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Rajeev Kumar Sirasanagandla | 646afd2 | 2017-06-27 21:08:30 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, 2016-2017 The Linux Foundation. All rights reserved. |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 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 Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 21 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | /****************************************************************************** |
| 29 | * |
| 30 | * Name: pmc.h |
| 31 | * |
| 32 | * Description: Power Management Control (PMC) internal definitions. |
| 33 | * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 34 | * |
| 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. */ |
| 52 | typedef 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. */ |
| 60 | typedef 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. */ |
| 69 | typedef 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. */ |
| 77 | typedef 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. */ |
| 86 | typedef 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. */ |
| 100 | typedef 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 | |
| 112 | typedef 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. */ |
| 130 | typedef 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 Singh | 2a04e9c | 2016-09-26 10:56:51 +0530 | [diff] [blame] | 149 | /* Remain in Power active till set key is done */ |
| 150 | bool full_power_till_set_key; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 151 | 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 Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 156 | vos_timer_t hImpsTimer; /* timer to use with IMPS */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 157 | vos_timer_t hTrafficTimer; /* timer to measure traffic for BMPS */ |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 158 | vos_timer_t hExitPowerSaveTimer; /* timer for deferred exiting of power save mode */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 159 | 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_hpothu | 01484c0 | 2014-05-16 14:05:15 +0530 | [diff] [blame] | 176 | tWowlExitSource wowlExitSrc; /*WoWl exiting because of wakeup pkt or user explicitly disabling WoWL*/ |
Rajeev Kumar Sirasanagandla | 646afd2 | 2017-06-27 21:08:30 +0530 | [diff] [blame] | 177 | tANI_BOOLEAN isAPWOWExit; /* TRUE if last WOW exit is from soft ap */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 178 | 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 Koyyalamudi | 69b3418 | 2013-01-16 08:51:40 +0530 | [diff] [blame] | 200 | |
| 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 Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 203 | v_BOOL_t isHostPsEn; |
| 204 | v_BOOL_t ImpsReqFailed; |
| 205 | v_BOOL_t ImpsReqTimerFailed; |
| 206 | tANI_U8 ImpsReqFailCnt; |
| 207 | tANI_U8 ImpsReqTimerfailCnt; |
Ratheesh S P | 789f063 | 2015-10-06 14:36:26 +0530 | [diff] [blame] | 208 | tANI_U8 ImpsRspFailCnt; |
Rajeev | 79dbe4c | 2013-10-05 11:03:42 +0530 | [diff] [blame] | 209 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 220 | } tPmcInfo, *tpPmcInfo; |
| 221 | |
| 222 | |
| 223 | //MACRO |
| 224 | #define PMC_IS_READY(pMac) ( ((pMac)->pmc.pmcReady) && (STOPPED != (pMac)->pmc.pmcState) ) |
| 225 | |
| 226 | |
| 227 | /* Routine definitions. */ |
| 228 | extern eHalStatus pmcEnterLowPowerState (tHalHandle hHal); |
| 229 | extern eHalStatus pmcExitLowPowerState (tHalHandle hHal); |
| 230 | extern eHalStatus pmcEnterFullPowerState (tHalHandle hHal); |
| 231 | extern eHalStatus pmcEnterRequestFullPowerState (tHalHandle hHal, tRequestFullPowerReason fullPowerReason); |
| 232 | extern eHalStatus pmcEnterRequestImpsState (tHalHandle hHal); |
| 233 | extern eHalStatus pmcEnterImpsState (tHalHandle hHal); |
| 234 | extern eHalStatus pmcEnterRequestBmpsState (tHalHandle hHal); |
| 235 | extern eHalStatus pmcEnterBmpsState (tHalHandle hHal); |
| 236 | extern eHalStatus pmcEnterRequestStartUapsdState (tHalHandle hHal); |
| 237 | extern eHalStatus pmcEnterUapsdState (tHalHandle hHal); |
| 238 | extern eHalStatus pmcEnterRequestStopUapsdState (tHalHandle hHal); |
| 239 | extern eHalStatus pmcEnterRequestStandbyState (tHalHandle hHal); |
| 240 | extern eHalStatus pmcEnterStandbyState (tHalHandle hHal); |
| 241 | extern tANI_BOOLEAN pmcPowerSaveCheck (tHalHandle hHal); |
| 242 | extern eHalStatus pmcSendPowerSaveConfigMessage (tHalHandle hHal); |
| 243 | extern eHalStatus pmcSendMessage (tpAniSirGlobal pMac, tANI_U16 messageType, void *pMessageData, tANI_U32 messageSize); |
| 244 | extern void pmcDoCallbacks (tHalHandle hHal, eHalStatus callbackStatus); |
| 245 | extern void pmcDoBmpsCallbacks (tHalHandle hHal, eHalStatus callbackStatus); |
| 246 | extern void pmcDoStartUapsdCallbacks (tHalHandle hHal, eHalStatus callbackStatus); |
| 247 | extern void pmcDoStandbyCallbacks (tHalHandle hHal, eHalStatus callbackStatus); |
| 248 | extern eHalStatus pmcStartTrafficTimer (tHalHandle hHal, tANI_U32 expirationTime); |
| 249 | extern void pmcStopTrafficTimer (tHalHandle hHal); |
| 250 | extern void pmcImpsTimerExpired (tHalHandle hHal); |
| 251 | extern void pmcTrafficTimerExpired (tHalHandle hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 252 | extern void pmcExitPowerSaveTimerExpired (tHalHandle hHal); |
| 253 | extern tPmcState pmcGetPmcState (tHalHandle hHal); |
| 254 | extern const char* pmcGetPmcStateStr(tPmcState state); |
| 255 | extern void pmcDoDeviceStateUpdateCallbacks (tHalHandle hHal, tPmcState state); |
| 256 | extern eHalStatus pmcRequestEnterWowlState(tHalHandle hHal, tpSirSmeWowlEnterParams wowlEnterParams); |
| 257 | extern eHalStatus pmcEnterWowlState (tHalHandle hHal); |
| 258 | extern eHalStatus pmcRequestExitWowlState(tHalHandle hHal); |
| 259 | extern void pmcDoEnterWowlCallbacks (tHalHandle hHal, eHalStatus callbackStatus); |
| 260 | //The function will request for full power as well in addition to defer the message |
| 261 | extern eHalStatus pmcDeferMsg( tpAniSirGlobal pMac, tANI_U16 messageType, |
| 262 | void *pData, tANI_U32 size); |
| 263 | extern eHalStatus pmcIssueCommand( tpAniSirGlobal pMac, eSmeCommandType cmdType, void *pvParam, |
| 264 | tANI_U32 size, tANI_BOOLEAN fPutToListHead ); |
| 265 | extern eHalStatus pmcEnterImpsCheck( tpAniSirGlobal pMac ); |
| 266 | extern eHalStatus pmcEnterBmpsCheck( tpAniSirGlobal pMac ); |
| 267 | extern tANI_BOOLEAN pmcShouldBmpsTimerRun( tpAniSirGlobal pMac ); |
| 268 | #endif |