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