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