Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 5 | */ |
| 6 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7 | * This file limLinkMonitoringAlgo.cc contains the code for |
| 8 | * Link monitoring algorithm on AP and heart beat failure |
| 9 | * handling on STA. |
| 10 | * Author: Chandra Modumudi |
| 11 | * Date: 03/01/02 |
| 12 | * History:- |
| 13 | * Date Modified by Modification Information |
| 14 | * -------------------------------------------------------------------- |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #include "aniGlobal.h" |
Jeff Johnson | 62c2798 | 2013-02-27 17:53:55 -0800 | [diff] [blame] | 19 | #include "wniCfgSta.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 20 | #include "cfgApi.h" |
| 21 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 22 | |
| 23 | #include "schApi.h" |
| 24 | #include "pmmApi.h" |
| 25 | #include "utilsApi.h" |
| 26 | #include "limAssocUtils.h" |
| 27 | #include "limTypes.h" |
| 28 | #include "limUtils.h" |
| 29 | #include "limPropExtsUtils.h" |
| 30 | |
| 31 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT |
| 32 | #include "vos_diag_core_log.h" |
| 33 | #endif //FEATURE_WLAN_DIAG_SUPPORT |
| 34 | #include "limSession.h" |
| 35 | #include "limSerDesUtils.h" |
| 36 | |
| 37 | |
| 38 | /** |
| 39 | * limSendKeepAliveToPeer() |
| 40 | * |
| 41 | *FUNCTION: |
| 42 | * This function is called to send Keep alive message to peer |
| 43 | * |
| 44 | *LOGIC: |
| 45 | * |
| 46 | *ASSUMPTIONS: |
| 47 | * |
| 48 | *NOTE: |
| 49 | * NA |
| 50 | * |
| 51 | * @param pMac - Pointer to Global MAC structure |
| 52 | * @return None |
| 53 | */ |
| 54 | |
| 55 | void |
| 56 | limSendKeepAliveToPeer(tpAniSirGlobal pMac) |
| 57 | { |
| 58 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 59 | } /*** limSendKeepAliveToPeer() ***/ |
| 60 | |
| 61 | |
| 62 | /** --------------------------------------------------------- |
| 63 | \fn limDeleteStaContext |
| 64 | \brief This function handles the message from HAL: |
| 65 | \ WDA_DELETE_STA_CONTEXT_IND. This function |
| 66 | \ validates that the given station id exist, and if so, |
| 67 | \ deletes the station by calling limTriggerSTAdeletion. |
| 68 | \param tpAniSirGlobal pMac |
| 69 | \param tpSirMsgQ limMsg |
| 70 | \return none |
| 71 | -----------------------------------------------------------*/ |
| 72 | void |
| 73 | limDeleteStaContext(tpAniSirGlobal pMac, tpSirMsgQ limMsg) |
| 74 | { |
| 75 | tpDeleteStaContext pMsg = (tpDeleteStaContext)limMsg->bodyptr; |
| 76 | tpDphHashNode pStaDs; |
| 77 | tpPESession psessionEntry ; |
| 78 | tANI_U8 sessionId; |
| 79 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 80 | if(NULL == pMsg) |
| 81 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 82 | PELOGE(limLog(pMac, LOGE,FL("Invalid body pointer in message"));) |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 83 | return; |
| 84 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | if((psessionEntry = peFindSessionByBssid(pMac,pMsg->bssId,&sessionId))== NULL) |
| 86 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 87 | PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId"));) |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 88 | vos_mem_free(pMsg); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 89 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 92 | switch(pMsg->reasonCode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 93 | { |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 94 | case HAL_DEL_STA_REASON_CODE_KEEP_ALIVE: |
| 95 | case HAL_DEL_STA_REASON_CODE_TIM_BASED: |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 96 | PELOGE(limLog(pMac, LOGE, FL(" Deleting station: staId = %d, reasonCode = %d"), pMsg->staId, pMsg->reasonCode);) |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 97 | if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole) |
| 98 | return; |
| 99 | |
Gopichand Nakkala | 9425319 | 2013-03-28 15:35:48 -0700 | [diff] [blame] | 100 | pStaDs = dphLookupAssocId(pMac, pMsg->staId, &pMsg->assocId, &psessionEntry->dph.dphHashTable); |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 101 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 102 | if (!pStaDs) |
| 103 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 104 | PELOGE(limLog(pMac, LOGE, FL("Skip STA deletion (invalid STA) limSystemRole=%d"),psessionEntry->limSystemRole);) |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 105 | vos_mem_free(pMsg); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 106 | return; |
| 107 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 108 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 109 | /* check and see if same staId. This is to avoid the scenario |
| 110 | * where we're trying to delete a staId we just added. |
| 111 | */ |
| 112 | if (pStaDs->staIndex != pMsg->staId) |
| 113 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 114 | PELOGE(limLog(pMac, LOGE, FL("staid mismatch: %d vs %d "), pStaDs->staIndex, pMsg->staId);) |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 115 | vos_mem_free(pMsg); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 116 | return; |
| 117 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 118 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 119 | if((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) || |
| 120 | (eLIM_AP_ROLE == psessionEntry->limSystemRole)) |
| 121 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 122 | PELOG1(limLog(pMac, LOG1, FL("SAP:lim Delete Station Context (staId: %d, assocId: %d) "), |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 123 | pMsg->staId, pMsg->assocId);) |
| 124 | limTriggerSTAdeletion(pMac, pStaDs, psessionEntry); |
| 125 | } |
| 126 | else |
| 127 | { |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 128 | #ifdef FEATURE_WLAN_TDLS |
| 129 | if(eLIM_STA_ROLE == psessionEntry->limSystemRole && |
| 130 | STA_ENTRY_TDLS_PEER == pStaDs->staType) |
| 131 | { |
| 132 | //TeardownLink with PEER |
| 133 | //Reason code HAL_DEL_STA_REASON_CODE_KEEP_ALIVE means |
| 134 | //eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE |
| 135 | limSendSmeTDLSDelStaInd(pMac, pStaDs, psessionEntry, |
| 136 | /*pMsg->reasonCode*/ eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE); |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | #endif |
| 141 | //TearDownLink with AP |
| 142 | tLimMlmDeauthInd mlmDeauthInd; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 143 | PELOGW(limLog(pMac, LOGW, FL("lim Delete Station Context (staId: %d, assocId: %d) "), |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 144 | pMsg->staId, pMsg->assocId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 145 | |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 146 | pStaDs->mlmStaContext.disassocReason = eSIR_MAC_UNSPEC_FAILURE_REASON; |
| 147 | pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 148 | |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 149 | // Issue Deauth Indication to SME. |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 150 | vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr, |
| 151 | pStaDs->staAddr, sizeof(tSirMacAddr)); |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 152 | mlmDeauthInd.reasonCode = (tANI_U8) pStaDs->mlmStaContext.disassocReason; |
| 153 | mlmDeauthInd.deauthTrigger = pStaDs->mlmStaContext.cleanupTrigger; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 154 | |
Gopichand Nakkala | ca35d29 | 2013-03-05 11:06:03 -0800 | [diff] [blame] | 155 | #ifdef FEATURE_WLAN_TDLS |
| 156 | /* Delete all TDLS peers connected before leaving BSS*/ |
| 157 | limDeleteTDLSPeers(pMac, psessionEntry); |
| 158 | #endif |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 159 | limPostSmeMessage(pMac, LIM_MLM_DEAUTH_IND, (tANI_U32 *) &mlmDeauthInd); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 160 | |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 161 | limSendSmeDeauthInd(pMac, pStaDs, psessionEntry); |
| 162 | #ifdef FEATURE_WLAN_TDLS |
| 163 | } |
| 164 | #endif |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 165 | } |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 166 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 167 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 168 | case HAL_DEL_STA_REASON_CODE_UNKNOWN_A2: |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 169 | PELOGE(limLog(pMac, LOGE, FL(" Deleting Unknown station "));) |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 170 | limPrintMacAddr(pMac, pMsg->addr2, LOGE); |
| 171 | limSendDeauthMgmtFrame( pMac, eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON, pMsg->addr2, psessionEntry, FALSE); |
| 172 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 173 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 174 | default: |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 175 | PELOGE(limLog(pMac, LOGE, FL(" Unknown reason code "));) |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 176 | break; |
| 177 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 178 | } |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 179 | vos_mem_free(pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 180 | return; |
| 181 | } |
| 182 | |
| 183 | |
| 184 | /** |
| 185 | * limTriggerSTAdeletion() |
| 186 | * |
| 187 | *FUNCTION: |
| 188 | * This function is called to trigger STA context deletion |
| 189 | * |
| 190 | *LOGIC: |
| 191 | * |
| 192 | *ASSUMPTIONS: |
| 193 | * |
| 194 | *NOTE: |
| 195 | * NA |
| 196 | * |
| 197 | * @param pMac - Pointer to global MAC structure |
| 198 | * @param pStaDs - Pointer to internal STA Datastructure |
| 199 | * @return None |
| 200 | */ |
| 201 | void |
| 202 | limTriggerSTAdeletion(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpPESession psessionEntry) |
| 203 | { |
| 204 | tSirSmeDeauthReq *pSmeDeauthReq; |
| 205 | tANI_U8 *pBuf; |
| 206 | tANI_U8 *pLen; |
| 207 | tANI_U16 msgLength = 0; |
| 208 | |
| 209 | if (! pStaDs) |
| 210 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 211 | PELOGW(limLog(pMac, LOGW, FL("Skip STA deletion (invalid STA)"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 212 | return; |
| 213 | } |
| 214 | /** |
| 215 | * MAC based Authentication was used. Trigger |
| 216 | * Deauthentication frame to peer since it will |
| 217 | * take care of disassociation as well. |
| 218 | */ |
| 219 | |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 220 | pSmeDeauthReq = vos_mem_malloc(sizeof(tSirSmeDeauthReq)); |
| 221 | if (NULL == pSmeDeauthReq) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 222 | { |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 223 | limLog(pMac, LOGP, FL("AllocateMemory failed for eWNI_SME_DEAUTH_REQ ")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 224 | return; |
| 225 | } |
| 226 | |
| 227 | pBuf = (tANI_U8 *) &pSmeDeauthReq->messageType; |
| 228 | |
| 229 | //messageType |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 230 | limCopyU16((tANI_U8*)pBuf, eWNI_SME_DISASSOC_REQ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 231 | pBuf += sizeof(tANI_U16); |
| 232 | msgLength += sizeof(tANI_U16); |
| 233 | |
| 234 | //length |
| 235 | pLen = pBuf; |
| 236 | pBuf += sizeof(tANI_U16); |
| 237 | msgLength += sizeof(tANI_U16); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 238 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | //sessionId |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 240 | *pBuf = psessionEntry->smeSessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 241 | pBuf++; |
| 242 | msgLength++; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 243 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 244 | //transactionId |
| 245 | limCopyU16((tANI_U8*)pBuf, psessionEntry->transactionId); |
| 246 | pBuf += sizeof(tANI_U16); |
| 247 | msgLength += sizeof(tANI_U16); |
| 248 | |
| 249 | //bssId |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 250 | vos_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 251 | pBuf += sizeof(tSirMacAddr); |
| 252 | msgLength += sizeof(tSirMacAddr); |
| 253 | |
| 254 | //peerMacAddr |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 255 | vos_mem_copy(pBuf, pStaDs->staAddr, sizeof(tSirMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 256 | pBuf += sizeof(tSirMacAddr); |
| 257 | msgLength += sizeof(tSirMacAddr); |
| 258 | |
| 259 | //reasonCode |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 260 | limCopyU16((tANI_U8*)pBuf, (tANI_U16)eLIM_LINK_MONITORING_DISASSOC); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 261 | pBuf += sizeof(tANI_U16); |
| 262 | msgLength += sizeof(tANI_U16); |
| 263 | |
| 264 | //Do not send disassoc OTA |
| 265 | //pBuf[0] = 1 means do not send the disassoc frame over the air |
| 266 | //pBuf[0] = 0 means send the disassoc frame over the air |
| 267 | pBuf[0]= 0; |
| 268 | pBuf += sizeof(tANI_U8); |
| 269 | msgLength += sizeof(tANI_U8); |
| 270 | |
| 271 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 272 | |
| 273 | //Fill in length |
Gopichand Nakkala | 114718f | 2013-03-25 19:19:46 -0700 | [diff] [blame] | 274 | limCopyU16((tANI_U8*)pLen , msgLength); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 275 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 276 | limPostSmeMessage(pMac, eWNI_SME_DISASSOC_REQ, (tANI_U32 *) pSmeDeauthReq); |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 277 | vos_mem_free(pSmeDeauthReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 278 | |
| 279 | } /*** end limTriggerSTAdeletion() ***/ |
| 280 | |
| 281 | |
| 282 | |
| 283 | /** |
| 284 | * limTearDownLinkWithAp() |
| 285 | * |
| 286 | *FUNCTION: |
| 287 | * This function is called when heartbeat (beacon reception) |
| 288 | * fails on STA |
| 289 | * |
| 290 | *LOGIC: |
| 291 | * |
| 292 | *ASSUMPTIONS: |
| 293 | * |
| 294 | *NOTE: |
| 295 | * |
| 296 | * @param pMac - Pointer to Global MAC structure |
| 297 | * @return None |
| 298 | */ |
| 299 | |
| 300 | void |
| 301 | limTearDownLinkWithAp(tpAniSirGlobal pMac, tANI_U8 sessionId, tSirMacReasonCodes reasonCode) |
| 302 | { |
| 303 | tpDphHashNode pStaDs = NULL; |
| 304 | |
| 305 | //tear down the following sessionEntry |
| 306 | tpPESession psessionEntry; |
| 307 | |
| 308 | if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL) |
| 309 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 310 | limLog(pMac, LOGP,FL("Session Does not exist for given sessionID")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | return; |
| 312 | } |
| 313 | /** |
| 314 | * Heart beat failed for upto threshold value |
| 315 | * and AP did not respond for Probe request. |
| 316 | * Trigger link tear down. |
| 317 | */ |
| 318 | |
| 319 | pMac->pmm.inMissedBeaconScenario = FALSE; |
| 320 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 321 | FL("No ProbeRsp from AP after HB failure. Tearing down link")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 322 | |
| 323 | // Deactivate heartbeat timer |
| 324 | limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry); |
| 325 | |
| 326 | // Announce loss of link to Roaming algorithm |
| 327 | // and cleanup by sending SME_DISASSOC_REQ to SME |
| 328 | |
| 329 | pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable); |
| 330 | |
| 331 | |
| 332 | if (pStaDs != NULL) |
| 333 | { |
| 334 | tLimMlmDeauthInd mlmDeauthInd; |
| 335 | |
Gopichand Nakkala | e9b72e1 | 2013-02-27 20:51:16 -0800 | [diff] [blame] | 336 | #ifdef FEATURE_WLAN_TDLS |
| 337 | /* Delete all TDLS peers connected before leaving BSS*/ |
| 338 | limDeleteTDLSPeers(pMac, psessionEntry); |
| 339 | #endif |
| 340 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 341 | pStaDs->mlmStaContext.disassocReason = reasonCode; |
| 342 | pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH; |
| 343 | |
| 344 | /// Issue Deauth Indication to SME. |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 345 | vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 346 | pStaDs->staAddr, |
| 347 | sizeof(tSirMacAddr)); |
| 348 | mlmDeauthInd.reasonCode = (tANI_U8) pStaDs->mlmStaContext.disassocReason; |
| 349 | mlmDeauthInd.deauthTrigger = pStaDs->mlmStaContext.cleanupTrigger; |
| 350 | |
| 351 | limPostSmeMessage(pMac, LIM_MLM_DEAUTH_IND, (tANI_U32 *) &mlmDeauthInd); |
| 352 | |
| 353 | limSendSmeDeauthInd(pMac, pStaDs, psessionEntry); |
| 354 | } |
| 355 | } /*** limTearDownLinkWithAp() ***/ |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | /** |
| 361 | * limHandleHeartBeatFailure() |
| 362 | * |
| 363 | *FUNCTION: |
| 364 | * This function is called when heartbeat (beacon reception) |
| 365 | * fails on STA |
| 366 | * |
| 367 | *LOGIC: |
| 368 | * |
| 369 | *ASSUMPTIONS: |
| 370 | * |
| 371 | *NOTE: |
| 372 | * |
| 373 | * @param pMac - Pointer to Global MAC structure |
| 374 | * @return None |
| 375 | */ |
| 376 | |
| 377 | void limHandleHeartBeatFailure(tpAniSirGlobal pMac,tpPESession psessionEntry) |
| 378 | { |
| 379 | |
| 380 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT |
| 381 | vos_log_beacon_update_pkt_type *log_ptr = NULL; |
| 382 | #endif //FEATURE_WLAN_DIAG_SUPPORT |
| 383 | |
| 384 | /* If gLimHeartBeatTimer fires between the interval of sending WDA_ENTER_BMPS_REQUEST |
| 385 | * to the HAL and receiving WDA_ENTER_BMPS_RSP from the HAL, then LIM (PE) tries to Process the |
| 386 | * SIR_LIM_HEAR_BEAT_TIMEOUT message but The PE state is ePMM_STATE_BMPS_SLEEP so PE dont |
| 387 | * want to handle heartbeat timeout in the BMPS, because Firmware handles it in BMPS. |
| 388 | * So just return from heartbeatfailure handler |
| 389 | */ |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 390 | if(!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE && (!limIsSystemInActiveState(pMac))) |
| 391 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 392 | |
| 393 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT |
| 394 | WLAN_VOS_DIAG_LOG_ALLOC(log_ptr, vos_log_beacon_update_pkt_type, LOG_WLAN_BEACON_UPDATE_C); |
| 395 | if(log_ptr) |
| 396 | log_ptr->bcn_rx_cnt = psessionEntry->LimRxedBeaconCntDuringHB; |
| 397 | WLAN_VOS_DIAG_LOG_REPORT(log_ptr); |
| 398 | #endif //FEATURE_WLAN_DIAG_SUPPORT |
| 399 | |
| 400 | /* Ensure HB Status for the session has been reseted */ |
| 401 | psessionEntry->LimHBFailureStatus = eANI_BOOLEAN_FALSE; |
| 402 | /** Re Activate Timer if the system is Waiting for ReAssoc Response*/ |
| 403 | if(((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) || |
| 404 | (psessionEntry->limSystemRole == eLIM_STA_ROLE) || |
| 405 | (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) && |
| 406 | (LIM_IS_CONNECTION_ACTIVE(psessionEntry) || |
| 407 | (limIsReassocInProgress(pMac, psessionEntry)))) |
| 408 | { |
| 409 | if(psessionEntry->LimRxedBeaconCntDuringHB < MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL) |
| 410 | pMac->lim.gLimHeartBeatBeaconStats[psessionEntry->LimRxedBeaconCntDuringHB]++; |
| 411 | else |
| 412 | pMac->lim.gLimHeartBeatBeaconStats[0]++; |
| 413 | |
| 414 | /****** |
| 415 | * Note: Use this code once you have converted all |
| 416 | * limReactivateHeartBeatTimer() calls to |
| 417 | * limReactivateTimer() calls. |
| 418 | * |
| 419 | ******/ |
| 420 | //limReactivateTimer(pMac, eLIM_HEART_BEAT_TIMER, psessionEntry); |
| 421 | limReactivateHeartBeatTimer(pMac, psessionEntry); |
| 422 | |
| 423 | // Reset number of beacons received |
| 424 | limResetHBPktCount(psessionEntry); |
| 425 | return; |
| 426 | } |
| 427 | if (((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&& |
| 428 | (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)) |
| 429 | { |
| 430 | if (!pMac->sys.gSysEnableLinkMonitorMode) |
| 431 | return; |
| 432 | |
| 433 | /** |
| 434 | * Beacon frame not received within heartbeat timeout. |
| 435 | */ |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 436 | PELOGW(limLog(pMac, LOGW, FL("Heartbeat Failure"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 437 | pMac->lim.gLimHBfailureCntInLinkEstState++; |
| 438 | |
| 439 | /** |
| 440 | * Check if connected on the DFS channel, if not connected on |
| 441 | * DFS channel then only send the probe request otherwise tear down the link |
| 442 | */ |
| 443 | if(!limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel)) |
| 444 | { |
| 445 | /*** Detected continuous Beacon Misses ***/ |
| 446 | psessionEntry->LimHBFailureStatus= eANI_BOOLEAN_TRUE; |
| 447 | /** |
| 448 | * Send Probe Request frame to AP to see if |
| 449 | * it is still around. Wait until certain |
| 450 | * timeout for Probe Response from AP. |
| 451 | */ |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 452 | PELOGW(limLog(pMac, LOGW, FL("Heart Beat missed from AP. Sending Probe Req"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 453 | /* for searching AP, we don't include any additional IE */ |
| 454 | limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId, |
| 455 | psessionEntry->currentOperChannel,psessionEntry->selfMacAddr, |
| 456 | psessionEntry->dot11mode, 0, NULL); |
| 457 | } |
| 458 | else |
| 459 | { |
Praveen Kumar Sirisilla | edf67e8 | 2013-08-21 19:17:10 -0700 | [diff] [blame] | 460 | PELOGW(limLog(pMac, LOGW, |
| 461 | FL("Heart Beat missed from AP on DFS chanel moving to passive"));) |
| 462 | if (psessionEntry->currentOperChannel < SIR_MAX_24G_5G_CHANNEL_RANGE){ |
| 463 | limCovertChannelScanType(pMac, psessionEntry->currentOperChannel, false); |
| 464 | pMac->lim.dfschannelList.timeStamp[psessionEntry->currentOperChannel] = 0; |
| 465 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 466 | /* Connected on DFS channel so should not send the probe request |
| 467 | * tear down the link directly */ |
| 468 | limTearDownLinkWithAp(pMac, psessionEntry->peSessionId, eSIR_MAC_UNSPEC_FAILURE_REASON); |
| 469 | } |
| 470 | } |
| 471 | else |
| 472 | { |
| 473 | /** |
| 474 | * Heartbeat timer may have timed out |
| 475 | * while we're doing background scanning/learning |
| 476 | * or in states other than link-established state. |
| 477 | * Log error. |
| 478 | */ |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 479 | PELOG1(limLog(pMac, LOG1, FL("received heartbeat timeout in state %X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 480 | psessionEntry->limMlmState);) |
| 481 | limPrintMlmState(pMac, LOG1, psessionEntry->limMlmState); |
| 482 | pMac->lim.gLimHBfailureCntInOtherStates++; |
| 483 | limReactivateHeartBeatTimer(pMac, psessionEntry); |
| 484 | } |
| 485 | } /*** limHandleHeartBeatFailure() ***/ |