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) |
Mukul Sharma | 91947a2 | 2014-06-09 11:07:51 +0530 | [diff] [blame] | 120 | { |
| 121 | vos_mem_free(pMsg); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 122 | return; |
Mukul Sharma | 91947a2 | 2014-06-09 11:07:51 +0530 | [diff] [blame] | 123 | } |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 124 | |
Gopichand Nakkala | 9425319 | 2013-03-28 15:35:48 -0700 | [diff] [blame] | 125 | pStaDs = dphLookupAssocId(pMac, pMsg->staId, &pMsg->assocId, &psessionEntry->dph.dphHashTable); |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 126 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 127 | if (!pStaDs) |
| 128 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 129 | 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] | 130 | vos_mem_free(pMsg); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 131 | return; |
| 132 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 133 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 134 | /* check and see if same staId. This is to avoid the scenario |
| 135 | * where we're trying to delete a staId we just added. |
| 136 | */ |
| 137 | if (pStaDs->staIndex != pMsg->staId) |
| 138 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 139 | 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] | 140 | vos_mem_free(pMsg); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 141 | return; |
| 142 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 143 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 144 | if((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) || |
| 145 | (eLIM_AP_ROLE == psessionEntry->limSystemRole)) |
| 146 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 147 | 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] | 148 | pMsg->staId, pMsg->assocId);) |
Sachin Ahuja | 876dade | 2014-07-15 17:07:35 +0530 | [diff] [blame] | 149 | /* |
| 150 | * Check if Deauth/Disassoc is triggered from Host. |
| 151 | * If mlmState is in some transient state then |
| 152 | * don't trigger STA deletion to avoid the race |
| 153 | * condition. |
| 154 | */ |
| 155 | if ((pStaDs && |
| 156 | ((pStaDs->mlmStaContext.mlmState != |
| 157 | eLIM_MLM_LINK_ESTABLISHED_STATE) && |
| 158 | (pStaDs->mlmStaContext.mlmState != |
| 159 | eLIM_MLM_WT_ASSOC_CNF_STATE) && |
| 160 | (pStaDs->mlmStaContext.mlmState != |
| 161 | eLIM_MLM_ASSOCIATED_STATE)))) |
| 162 | { |
| 163 | PELOGE(limLog(pMac, LOGE, FL("SAP:received Del STA context in some transit state(staId: %d, assocId: %d)"), |
| 164 | pMsg->staId, pMsg->assocId);) |
| 165 | vos_mem_free(pMsg); |
| 166 | return; |
| 167 | } |
| 168 | else |
| 169 | limTriggerSTAdeletion(pMac, pStaDs, psessionEntry); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 170 | } |
| 171 | else |
| 172 | { |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 173 | #ifdef FEATURE_WLAN_TDLS |
| 174 | if(eLIM_STA_ROLE == psessionEntry->limSystemRole && |
| 175 | STA_ENTRY_TDLS_PEER == pStaDs->staType) |
| 176 | { |
| 177 | //TeardownLink with PEER |
| 178 | //Reason code HAL_DEL_STA_REASON_CODE_KEEP_ALIVE means |
| 179 | //eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE |
| 180 | limSendSmeTDLSDelStaInd(pMac, pStaDs, psessionEntry, |
| 181 | /*pMsg->reasonCode*/ eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE); |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | #endif |
| 186 | //TearDownLink with AP |
| 187 | tLimMlmDeauthInd mlmDeauthInd; |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 188 | 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] | 189 | pMsg->staId, pMsg->assocId);) |
Mukul Sharma | 91947a2 | 2014-06-09 11:07:51 +0530 | [diff] [blame] | 190 | if ((pStaDs && |
| 191 | ((pStaDs->mlmStaContext.mlmState != |
| 192 | eLIM_MLM_LINK_ESTABLISHED_STATE) && |
| 193 | (pStaDs->mlmStaContext.mlmState != |
| 194 | eLIM_MLM_WT_ASSOC_CNF_STATE) && |
| 195 | (pStaDs->mlmStaContext.mlmState != |
| 196 | eLIM_MLM_ASSOCIATED_STATE)))) |
| 197 | { |
| 198 | /** |
| 199 | * Received WDA_DELETE_STA_CONTEXT_IND for STA that does not |
| 200 | * have context or in some transit state. |
| 201 | * Log error |
| 202 | */ |
| 203 | PELOGE(limLog(pMac, LOGE, |
| 204 | FL("received WDA_DELETE_STA_CONTEXT_IND for STA that either has no context or in some transit state, Addr= " |
| 205 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMsg->bssId));) |
| 206 | vos_mem_free(pMsg); |
| 207 | return; |
| 208 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 209 | |
Abhishek Singh | addb08b | 2014-06-06 14:16:36 +0530 | [diff] [blame] | 210 | if( pMac->roam.configParam.sendDeauthBeforeCon ) |
| 211 | { |
| 212 | tANI_U8 apCount = pMac->lim.gLimHeartBeatApMacIndex; |
| 213 | |
| 214 | if(pMac->lim.gLimHeartBeatApMacIndex) |
| 215 | pMac->lim.gLimHeartBeatApMacIndex = 0; |
| 216 | else |
| 217 | pMac->lim.gLimHeartBeatApMacIndex = 1; |
| 218 | |
| 219 | limLog(pMac, LOG1, FL("lim Delete Station Context for MAC " |
| 220 | MAC_ADDRESS_STR" Store it on Index %d"), |
| 221 | MAC_ADDR_ARRAY(pStaDs->staAddr),apCount); |
| 222 | |
| 223 | sirCopyMacAddr(pMac->lim.gLimHeartBeatApMac[apCount],pStaDs->staAddr); |
| 224 | } |
Deepthi Gowri | df91a66 | 2014-12-17 17:14:35 +0530 | [diff] [blame^] | 225 | pStaDs->mlmStaContext.disassocReason = |
| 226 | eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON; |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 227 | pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 228 | |
Mukul Sharma | 91947a2 | 2014-06-09 11:07:51 +0530 | [diff] [blame] | 229 | /** Set state to mlm State to eLIM_MLM_WT_DEL_STA_RSP_STATE |
| 230 | * This is to address the issue of race condition between |
| 231 | * disconnect request from the HDD and deauth from |
| 232 | * Tx inactivity timer by FWR. This will make sure that we will not |
| 233 | * process disassoc if deauth is in progress for the station |
| 234 | * and thus mlmStaContext.cleanupTrigger will not be overwritten. |
| 235 | */ |
| 236 | pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE; |
| 237 | |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 238 | // Issue Deauth Indication to SME. |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 239 | vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr, |
| 240 | pStaDs->staAddr, sizeof(tSirMacAddr)); |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 241 | mlmDeauthInd.reasonCode = (tANI_U8) pStaDs->mlmStaContext.disassocReason; |
| 242 | mlmDeauthInd.deauthTrigger = pStaDs->mlmStaContext.cleanupTrigger; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 243 | |
Gopichand Nakkala | ca35d29 | 2013-03-05 11:06:03 -0800 | [diff] [blame] | 244 | #ifdef FEATURE_WLAN_TDLS |
| 245 | /* Delete all TDLS peers connected before leaving BSS*/ |
| 246 | limDeleteTDLSPeers(pMac, psessionEntry); |
| 247 | #endif |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 248 | limPostSmeMessage(pMac, LIM_MLM_DEAUTH_IND, (tANI_U32 *) &mlmDeauthInd); |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 249 | |
Hoonki Lee | e6bfe94 | 2013-02-05 15:01:19 -0800 | [diff] [blame] | 250 | limSendSmeDeauthInd(pMac, pStaDs, psessionEntry); |
| 251 | #ifdef FEATURE_WLAN_TDLS |
| 252 | } |
| 253 | #endif |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 254 | } |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 255 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 256 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 257 | case HAL_DEL_STA_REASON_CODE_UNKNOWN_A2: |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 258 | PELOGE(limLog(pMac, LOGE, FL(" Deleting Unknown station "));) |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 259 | limPrintMacAddr(pMac, pMsg->addr2, LOGE); |
| 260 | limSendDeauthMgmtFrame( pMac, eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON, pMsg->addr2, psessionEntry, FALSE); |
| 261 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 262 | |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 263 | default: |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 264 | PELOGE(limLog(pMac, LOGE, FL(" Unknown reason code "));) |
Pratik Bhalgat | aa1ae39 | 2012-11-22 17:44:33 +0530 | [diff] [blame] | 265 | break; |
| 266 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 267 | } |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 268 | vos_mem_free(pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 269 | return; |
| 270 | } |
| 271 | |
| 272 | |
| 273 | /** |
| 274 | * limTriggerSTAdeletion() |
| 275 | * |
| 276 | *FUNCTION: |
| 277 | * This function is called to trigger STA context deletion |
| 278 | * |
| 279 | *LOGIC: |
| 280 | * |
| 281 | *ASSUMPTIONS: |
| 282 | * |
| 283 | *NOTE: |
| 284 | * NA |
| 285 | * |
| 286 | * @param pMac - Pointer to global MAC structure |
| 287 | * @param pStaDs - Pointer to internal STA Datastructure |
| 288 | * @return None |
| 289 | */ |
| 290 | void |
| 291 | limTriggerSTAdeletion(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpPESession psessionEntry) |
| 292 | { |
| 293 | tSirSmeDeauthReq *pSmeDeauthReq; |
| 294 | tANI_U8 *pBuf; |
| 295 | tANI_U8 *pLen; |
| 296 | tANI_U16 msgLength = 0; |
| 297 | |
| 298 | if (! pStaDs) |
| 299 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 300 | PELOGW(limLog(pMac, LOGW, FL("Skip STA deletion (invalid STA)"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 301 | return; |
| 302 | } |
| 303 | /** |
| 304 | * MAC based Authentication was used. Trigger |
| 305 | * Deauthentication frame to peer since it will |
| 306 | * take care of disassociation as well. |
| 307 | */ |
| 308 | |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 309 | pSmeDeauthReq = vos_mem_malloc(sizeof(tSirSmeDeauthReq)); |
| 310 | if (NULL == pSmeDeauthReq) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | { |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 312 | limLog(pMac, LOGP, FL("AllocateMemory failed for eWNI_SME_DEAUTH_REQ ")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 313 | return; |
| 314 | } |
| 315 | |
| 316 | pBuf = (tANI_U8 *) &pSmeDeauthReq->messageType; |
| 317 | |
| 318 | //messageType |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 319 | limCopyU16((tANI_U8*)pBuf, eWNI_SME_DISASSOC_REQ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 320 | pBuf += sizeof(tANI_U16); |
| 321 | msgLength += sizeof(tANI_U16); |
| 322 | |
| 323 | //length |
| 324 | pLen = pBuf; |
| 325 | pBuf += sizeof(tANI_U16); |
| 326 | msgLength += sizeof(tANI_U16); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 327 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 328 | //sessionId |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 329 | *pBuf = psessionEntry->smeSessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 330 | pBuf++; |
| 331 | msgLength++; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 332 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 333 | //transactionId |
| 334 | limCopyU16((tANI_U8*)pBuf, psessionEntry->transactionId); |
| 335 | pBuf += sizeof(tANI_U16); |
| 336 | msgLength += sizeof(tANI_U16); |
| 337 | |
| 338 | //bssId |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 339 | vos_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 340 | pBuf += sizeof(tSirMacAddr); |
| 341 | msgLength += sizeof(tSirMacAddr); |
| 342 | |
| 343 | //peerMacAddr |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 344 | vos_mem_copy(pBuf, pStaDs->staAddr, sizeof(tSirMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 345 | pBuf += sizeof(tSirMacAddr); |
| 346 | msgLength += sizeof(tSirMacAddr); |
| 347 | |
| 348 | //reasonCode |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 349 | limCopyU16((tANI_U8*)pBuf, (tANI_U16)eLIM_LINK_MONITORING_DISASSOC); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 350 | pBuf += sizeof(tANI_U16); |
| 351 | msgLength += sizeof(tANI_U16); |
| 352 | |
| 353 | //Do not send disassoc OTA |
| 354 | //pBuf[0] = 1 means do not send the disassoc frame over the air |
| 355 | //pBuf[0] = 0 means send the disassoc frame over the air |
| 356 | pBuf[0]= 0; |
| 357 | pBuf += sizeof(tANI_U8); |
| 358 | msgLength += sizeof(tANI_U8); |
| 359 | |
| 360 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 361 | |
| 362 | //Fill in length |
Gopichand Nakkala | 114718f | 2013-03-25 19:19:46 -0700 | [diff] [blame] | 363 | limCopyU16((tANI_U8*)pLen , msgLength); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 364 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 365 | limPostSmeMessage(pMac, eWNI_SME_DISASSOC_REQ, (tANI_U32 *) pSmeDeauthReq); |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 366 | vos_mem_free(pSmeDeauthReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 367 | |
| 368 | } /*** end limTriggerSTAdeletion() ***/ |
| 369 | |
| 370 | |
| 371 | |
| 372 | /** |
| 373 | * limTearDownLinkWithAp() |
| 374 | * |
| 375 | *FUNCTION: |
| 376 | * This function is called when heartbeat (beacon reception) |
| 377 | * fails on STA |
| 378 | * |
| 379 | *LOGIC: |
| 380 | * |
| 381 | *ASSUMPTIONS: |
| 382 | * |
| 383 | *NOTE: |
| 384 | * |
| 385 | * @param pMac - Pointer to Global MAC structure |
| 386 | * @return None |
| 387 | */ |
| 388 | |
| 389 | void |
| 390 | limTearDownLinkWithAp(tpAniSirGlobal pMac, tANI_U8 sessionId, tSirMacReasonCodes reasonCode) |
| 391 | { |
| 392 | tpDphHashNode pStaDs = NULL; |
| 393 | |
| 394 | //tear down the following sessionEntry |
| 395 | tpPESession psessionEntry; |
| 396 | |
| 397 | if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL) |
| 398 | { |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 399 | limLog(pMac, LOGP,FL("Session Does not exist for given sessionID")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 400 | return; |
| 401 | } |
| 402 | /** |
| 403 | * Heart beat failed for upto threshold value |
| 404 | * and AP did not respond for Probe request. |
| 405 | * Trigger link tear down. |
| 406 | */ |
| 407 | |
| 408 | pMac->pmm.inMissedBeaconScenario = FALSE; |
| 409 | limLog(pMac, LOGW, |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 410 | FL("No ProbeRsp from AP after HB failure. Tearing down link")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 411 | |
| 412 | // Deactivate heartbeat timer |
| 413 | limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry); |
| 414 | |
| 415 | // Announce loss of link to Roaming algorithm |
| 416 | // and cleanup by sending SME_DISASSOC_REQ to SME |
| 417 | |
| 418 | pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable); |
| 419 | |
| 420 | |
| 421 | if (pStaDs != NULL) |
| 422 | { |
| 423 | tLimMlmDeauthInd mlmDeauthInd; |
| 424 | |
Gopichand Nakkala | e9b72e1 | 2013-02-27 20:51:16 -0800 | [diff] [blame] | 425 | #ifdef FEATURE_WLAN_TDLS |
| 426 | /* Delete all TDLS peers connected before leaving BSS*/ |
| 427 | limDeleteTDLSPeers(pMac, psessionEntry); |
| 428 | #endif |
| 429 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 430 | pStaDs->mlmStaContext.disassocReason = reasonCode; |
| 431 | pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH; |
| 432 | |
| 433 | /// Issue Deauth Indication to SME. |
Bansidhar Gopalachari | 2f7395d | 2013-07-12 11:24:23 +0530 | [diff] [blame] | 434 | vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 435 | pStaDs->staAddr, |
| 436 | sizeof(tSirMacAddr)); |
Abhishek Singh | de51a41 | 2014-05-20 19:17:26 +0530 | [diff] [blame] | 437 | /* if sendDeauthBeforeCon is enabled and reasoncode is Beacon Missed |
| 438 | * Store the MAC of AP in the flip flop buffer. This MAC will be |
| 439 | * used to send Deauth before connection, if we connect to same AP |
| 440 | * after HB failure. |
| 441 | */ |
| 442 | if(pMac->roam.configParam.sendDeauthBeforeCon && |
| 443 | eSIR_BEACON_MISSED == reasonCode) |
| 444 | { |
| 445 | int apCount = pMac->lim.gLimHeartBeatApMacIndex; |
| 446 | |
| 447 | if(pMac->lim.gLimHeartBeatApMacIndex) |
| 448 | pMac->lim.gLimHeartBeatApMacIndex = 0; |
| 449 | else |
| 450 | pMac->lim.gLimHeartBeatApMacIndex = 1; |
| 451 | |
| 452 | limLog(pMac, LOGE, FL("HB Failure on MAC " |
| 453 | MAC_ADDRESS_STR" Store it on Index %d"), |
| 454 | MAC_ADDR_ARRAY(pStaDs->staAddr),apCount); |
| 455 | |
| 456 | sirCopyMacAddr(pMac->lim.gLimHeartBeatApMac[apCount],pStaDs->staAddr); |
| 457 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 458 | mlmDeauthInd.reasonCode = (tANI_U8) pStaDs->mlmStaContext.disassocReason; |
| 459 | mlmDeauthInd.deauthTrigger = pStaDs->mlmStaContext.cleanupTrigger; |
| 460 | |
| 461 | limPostSmeMessage(pMac, LIM_MLM_DEAUTH_IND, (tANI_U32 *) &mlmDeauthInd); |
| 462 | |
| 463 | limSendSmeDeauthInd(pMac, pStaDs, psessionEntry); |
| 464 | } |
| 465 | } /*** limTearDownLinkWithAp() ***/ |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | /** |
| 471 | * limHandleHeartBeatFailure() |
| 472 | * |
| 473 | *FUNCTION: |
| 474 | * This function is called when heartbeat (beacon reception) |
| 475 | * fails on STA |
| 476 | * |
| 477 | *LOGIC: |
| 478 | * |
| 479 | *ASSUMPTIONS: |
| 480 | * |
| 481 | *NOTE: |
| 482 | * |
| 483 | * @param pMac - Pointer to Global MAC structure |
| 484 | * @return None |
| 485 | */ |
| 486 | |
| 487 | void limHandleHeartBeatFailure(tpAniSirGlobal pMac,tpPESession psessionEntry) |
| 488 | { |
| 489 | |
| 490 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT |
| 491 | vos_log_beacon_update_pkt_type *log_ptr = NULL; |
| 492 | #endif //FEATURE_WLAN_DIAG_SUPPORT |
| 493 | |
| 494 | /* If gLimHeartBeatTimer fires between the interval of sending WDA_ENTER_BMPS_REQUEST |
| 495 | * to the HAL and receiving WDA_ENTER_BMPS_RSP from the HAL, then LIM (PE) tries to Process the |
| 496 | * SIR_LIM_HEAR_BEAT_TIMEOUT message but The PE state is ePMM_STATE_BMPS_SLEEP so PE dont |
| 497 | * want to handle heartbeat timeout in the BMPS, because Firmware handles it in BMPS. |
| 498 | * So just return from heartbeatfailure handler |
| 499 | */ |
Yathish | 9f22e66 | 2012-12-10 14:21:35 -0800 | [diff] [blame] | 500 | if(!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE && (!limIsSystemInActiveState(pMac))) |
| 501 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 502 | |
| 503 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT |
| 504 | WLAN_VOS_DIAG_LOG_ALLOC(log_ptr, vos_log_beacon_update_pkt_type, LOG_WLAN_BEACON_UPDATE_C); |
| 505 | if(log_ptr) |
| 506 | log_ptr->bcn_rx_cnt = psessionEntry->LimRxedBeaconCntDuringHB; |
| 507 | WLAN_VOS_DIAG_LOG_REPORT(log_ptr); |
| 508 | #endif //FEATURE_WLAN_DIAG_SUPPORT |
| 509 | |
| 510 | /* Ensure HB Status for the session has been reseted */ |
| 511 | psessionEntry->LimHBFailureStatus = eANI_BOOLEAN_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 512 | |
Sushant Kaushik | c14c4d8 | 2014-06-30 11:42:21 +0530 | [diff] [blame] | 513 | if (((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| |
| 514 | (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&& |
| 515 | (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)&& |
| 516 | (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) && |
| 517 | (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 518 | { |
| 519 | if (!pMac->sys.gSysEnableLinkMonitorMode) |
| 520 | return; |
| 521 | |
| 522 | /** |
| 523 | * Beacon frame not received within heartbeat timeout. |
| 524 | */ |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 525 | PELOGW(limLog(pMac, LOGW, FL("Heartbeat Failure"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 526 | pMac->lim.gLimHBfailureCntInLinkEstState++; |
| 527 | |
| 528 | /** |
| 529 | * Check if connected on the DFS channel, if not connected on |
| 530 | * DFS channel then only send the probe request otherwise tear down the link |
| 531 | */ |
| 532 | if(!limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel)) |
| 533 | { |
| 534 | /*** Detected continuous Beacon Misses ***/ |
| 535 | psessionEntry->LimHBFailureStatus= eANI_BOOLEAN_TRUE; |
Abhishek Singh | 11761d0 | 2014-05-28 18:39:48 +0530 | [diff] [blame] | 536 | /*Reset the HB packet count before sending probe*/ |
| 537 | limResetHBPktCount(psessionEntry); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 538 | /** |
| 539 | * Send Probe Request frame to AP to see if |
| 540 | * it is still around. Wait until certain |
| 541 | * timeout for Probe Response from AP. |
| 542 | */ |
Kiran Kumar Lokere | 8000726 | 2013-03-18 19:45:50 -0700 | [diff] [blame] | 543 | 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] | 544 | /* for searching AP, we don't include any additional IE */ |
| 545 | limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId, |
| 546 | psessionEntry->currentOperChannel,psessionEntry->selfMacAddr, |
| 547 | psessionEntry->dot11mode, 0, NULL); |
| 548 | } |
| 549 | else |
| 550 | { |
Praveen Kumar Sirisilla | edf67e8 | 2013-08-21 19:17:10 -0700 | [diff] [blame] | 551 | PELOGW(limLog(pMac, LOGW, |
| 552 | FL("Heart Beat missed from AP on DFS chanel moving to passive"));) |
| 553 | if (psessionEntry->currentOperChannel < SIR_MAX_24G_5G_CHANNEL_RANGE){ |
| 554 | limCovertChannelScanType(pMac, psessionEntry->currentOperChannel, false); |
| 555 | pMac->lim.dfschannelList.timeStamp[psessionEntry->currentOperChannel] = 0; |
| 556 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 557 | /* Connected on DFS channel so should not send the probe request |
| 558 | * tear down the link directly */ |
Abhishek Singh | de51a41 | 2014-05-20 19:17:26 +0530 | [diff] [blame] | 559 | limTearDownLinkWithAp(pMac, psessionEntry->peSessionId, eSIR_BEACON_MISSED); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 560 | } |
| 561 | } |
| 562 | else |
| 563 | { |
| 564 | /** |
| 565 | * Heartbeat timer may have timed out |
| 566 | * while we're doing background scanning/learning |
| 567 | * or in states other than link-established state. |
| 568 | * Log error. |
| 569 | */ |
Sushant Kaushik | 1b64538 | 2014-10-13 16:39:36 +0530 | [diff] [blame] | 570 | PELOG1(limLog(pMac, LOG1, FL("received heartbeat timeout in state %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 571 | psessionEntry->limMlmState);) |
| 572 | limPrintMlmState(pMac, LOG1, psessionEntry->limMlmState); |
| 573 | pMac->lim.gLimHBfailureCntInOtherStates++; |
| 574 | limReactivateHeartBeatTimer(pMac, psessionEntry); |
| 575 | } |
| 576 | } /*** limHandleHeartBeatFailure() ***/ |