blob: 2dd26a75d52b95ab746949288613754c0ba8bb3b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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 Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
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 Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * 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 Dash6f438272015-03-03 18:01:06 +053041#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "cfgApi.h"
43
Jeff Johnson295189b2012-06-20 16:38:30 -070044
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 Kumar071de2d2017-02-02 20:38:03 +053058#ifdef WLAN_FEATURE_LFR_MBB
59#include "lim_mbb.h"
60#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070061
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
80void
81limSendKeepAliveToPeer(tpAniSirGlobal pMac)
82{
83
Jeff Johnson295189b2012-06-20 16:38:30 -070084} /*** 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 -----------------------------------------------------------*/
97void
98limDeleteStaContext(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
99{
100 tpDeleteStaContext pMsg = (tpDeleteStaContext)limMsg->bodyptr;
101 tpDphHashNode pStaDs;
102 tpPESession psessionEntry ;
103 tANI_U8 sessionId;
104
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530105 if(NULL == pMsg)
106 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700107 PELOGE(limLog(pMac, LOGE,FL("Invalid body pointer in message"));)
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530108 return;
109 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700110 if((psessionEntry = peFindSessionByBssid(pMac,pMsg->bssId,&sessionId))== NULL)
111 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700112 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId"));)
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530113 vos_mem_free(pMsg);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530114 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700115 }
116
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +0530117#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 Bhalgataa1ae392012-11-22 17:44:33 +0530126 switch(pMsg->reasonCode)
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530128 case HAL_DEL_STA_REASON_CODE_KEEP_ALIVE:
129 case HAL_DEL_STA_REASON_CODE_TIM_BASED:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700130 PELOGE(limLog(pMac, LOGE, FL(" Deleting station: staId = %d, reasonCode = %d"), pMsg->staId, pMsg->reasonCode);)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700131 if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)
Mukul Sharma91947a22014-06-09 11:07:51 +0530132 {
133 vos_mem_free(pMsg);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700134 return;
Mukul Sharma91947a22014-06-09 11:07:51 +0530135 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700136
Gopichand Nakkala94253192013-03-28 15:35:48 -0700137 pStaDs = dphLookupAssocId(pMac, pMsg->staId, &pMsg->assocId, &psessionEntry->dph.dphHashTable);
Hoonki Leee6bfe942013-02-05 15:01:19 -0800138
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530139 if (!pStaDs)
140 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700141 PELOGE(limLog(pMac, LOGE, FL("Skip STA deletion (invalid STA) limSystemRole=%d"),psessionEntry->limSystemRole);)
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530142 vos_mem_free(pMsg);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530143 return;
144 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530146 /* 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 Lokere80007262013-03-18 19:45:50 -0700151 PELOGE(limLog(pMac, LOGE, FL("staid mismatch: %d vs %d "), pStaDs->staIndex, pMsg->staId);)
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530152 vos_mem_free(pMsg);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530153 return;
154 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700155
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530156 if((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) ||
157 (eLIM_AP_ROLE == psessionEntry->limSystemRole))
158 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530159 limLog(pMac, LOG1, FL("SAP:lim Delete Station Context (staId: %d, assocId: %d) "),
160 pMsg->staId, pMsg->assocId);
Sachin Ahuja876dade2014-07-15 17:07:35 +0530161 /*
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 Kumar03cf7ff2015-11-26 17:59:29 +0530181 {
182 limSendDisassocMgmtFrame(pMac,
183 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON,
184 pStaDs->staAddr, psessionEntry, FALSE);
Sachin Ahuja876dade2014-07-15 17:07:35 +0530185 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530186 }
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530187 }
188 else
189 {
Hoonki Leee6bfe942013-02-05 15:01:19 -0800190#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 Lokere80007262013-03-18 19:45:50 -0700205 PELOGW(limLog(pMac, LOGW, FL("lim Delete Station Context (staId: %d, assocId: %d) "),
Hoonki Leee6bfe942013-02-05 15:01:19 -0800206 pMsg->staId, pMsg->assocId);)
Mukul Sharma91947a22014-06-09 11:07:51 +0530207 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 Johnson295189b2012-06-20 16:38:30 -0700226
Abhishek Singhaddb08b2014-06-06 14:16:36 +0530227 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 Gowridf91a662014-12-17 17:14:35 +0530242 pStaDs->mlmStaContext.disassocReason =
243 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
Hoonki Leee6bfe942013-02-05 15:01:19 -0800244 pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700245
Padma, Santhosh Kumar6dc7be62015-08-07 18:13:31 +0530246 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 Sharma91947a22014-06-09 11:07:51 +0530254
Hoonki Leee6bfe942013-02-05 15:01:19 -0800255 // Issue Deauth Indication to SME.
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530256 vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr,
257 pStaDs->staAddr, sizeof(tSirMacAddr));
Hoonki Leee6bfe942013-02-05 15:01:19 -0800258 mlmDeauthInd.reasonCode = (tANI_U8) pStaDs->mlmStaContext.disassocReason;
259 mlmDeauthInd.deauthTrigger = pStaDs->mlmStaContext.cleanupTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -0700260
Gopichand Nakkalaca35d292013-03-05 11:06:03 -0800261#ifdef FEATURE_WLAN_TDLS
262 /* Delete all TDLS peers connected before leaving BSS*/
263 limDeleteTDLSPeers(pMac, psessionEntry);
264#endif
Hoonki Leee6bfe942013-02-05 15:01:19 -0800265 limPostSmeMessage(pMac, LIM_MLM_DEAUTH_IND, (tANI_U32 *) &mlmDeauthInd);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530266
Hoonki Leee6bfe942013-02-05 15:01:19 -0800267 limSendSmeDeauthInd(pMac, pStaDs, psessionEntry);
268#ifdef FEATURE_WLAN_TDLS
269 }
270#endif
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530271 }
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530272 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530274 case HAL_DEL_STA_REASON_CODE_UNKNOWN_A2:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700275 PELOGE(limLog(pMac, LOGE, FL(" Deleting Unknown station "));)
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530276 limPrintMacAddr(pMac, pMsg->addr2, LOGE);
277 limSendDeauthMgmtFrame( pMac, eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON, pMsg->addr2, psessionEntry, FALSE);
278 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530280 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700281 PELOGE(limLog(pMac, LOGE, FL(" Unknown reason code "));)
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530282 break;
283
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 }
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530285 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 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 */
307void
308limTriggerSTAdeletion(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpPESession psessionEntry)
309{
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530310 tLimMlmDisassocInd mlmDisassocInd;
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530313 if (!pStaDs)
314 {
315 PELOGW(limLog(pMac, LOGW, FL("Skip STA deletion (invalid STA)"));)
316 return;
317 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700318
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530319 if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
Abhishek Singh71b1c1e2016-06-15 12:51:57 +0530320 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE)||
321 pStaDs->sta_deletion_in_progress) {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530322 /* Already in the process of deleting context for the peer */
Abhishek Singh71b1c1e2016-06-15 12:51:57 +0530323 limLog(pMac, LOG1,
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700324 FL("Deletion is in progress (%d) for peer:%pK in mlmState %d"),
Abhishek Singh71b1c1e2016-06-15 12:51:57 +0530325 pStaDs->sta_deletion_in_progress, pStaDs->staAddr,
326 pStaDs->mlmStaContext.mlmState);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530327 return;
328 }
Abhishek Singh71b1c1e2016-06-15 12:51:57 +0530329 pStaDs->sta_deletion_in_progress = true;
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530330 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 Johnson295189b2012-06-20 16:38:30 -0700344} /*** 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
365void
366limTearDownLinkWithAp(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 Lokere80007262013-03-18 19:45:50 -0700375 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700376 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 Lokere80007262013-03-18 19:45:50 -0700386 FL("No ProbeRsp from AP after HB failure. Tearing down link"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700387
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 Nakkalae9b72e12013-02-27 20:51:16 -0800401#ifdef FEATURE_WLAN_TDLS
402 /* Delete all TDLS peers connected before leaving BSS*/
403 limDeleteTDLSPeers(pMac, psessionEntry);
404#endif
405
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 pStaDs->mlmStaContext.disassocReason = reasonCode;
407 pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH;
408
409 /// Issue Deauth Indication to SME.
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530410 vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 pStaDs->staAddr,
412 sizeof(tSirMacAddr));
Abhishek Singhde51a412014-05-20 19:17:26 +0530413 /* 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 Johnson295189b2012-06-20 16:38:30 -0700434 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
463void 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 */
Yathish9f22e662012-12-10 14:21:35 -0800476 if(!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE && (!limIsSystemInActiveState(pMac)))
477 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700478
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 Johnson295189b2012-06-20 16:38:30 -0700488
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +0530489#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 Kaushikc14c4d82014-06-30 11:42:21 +0530498 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 Johnson295189b2012-06-20 16:38:30 -0700503 {
504 if (!pMac->sys.gSysEnableLinkMonitorMode)
505 return;
Abhishek Singh800d17a2016-08-26 17:00:49 +0530506 /* 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 Johnson295189b2012-06-20 16:38:30 -0700514
515 /**
516 * Beacon frame not received within heartbeat timeout.
517 */
Abhishek Singh800d17a2016-08-26 17:00:49 +0530518 limLog(pMac, LOGW, FL("Heartbeat Failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 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 Singh11761d02014-05-28 18:39:48 +0530529 /*Reset the HB packet count before sending probe*/
530 limResetHBPktCount(psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 /**
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 Lokere80007262013-03-18 19:45:50 -0700536 PELOGW(limLog(pMac, LOGW, FL("Heart Beat missed from AP. Sending Probe Req"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 /* 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 Sirisillaedf67e82013-08-21 19:17:10 -0700544 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 Johnson295189b2012-06-20 16:38:30 -0700550 /* Connected on DFS channel so should not send the probe request
551 * tear down the link directly */
Abhishek Singhde51a412014-05-20 19:17:26 +0530552 limTearDownLinkWithAp(pMac, psessionEntry->peSessionId, eSIR_BEACON_MISSED);
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 }
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 Singh3cbf6052014-12-15 16:46:42 +0530563 limLog(pMac, LOG1, FL("received heartbeat timeout in state %d"),
564 psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 limPrintMlmState(pMac, LOG1, psessionEntry->limMlmState);
566 pMac->lim.gLimHBfailureCntInOtherStates++;
567 limReactivateHeartBeatTimer(pMac, psessionEntry);
568 }
569} /*** limHandleHeartBeatFailure() ***/