blob: 36b7a68a8b129ef492476230ae80da23d9943dad [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh800d17a2016-08-26 17:00:49 +05302 * Copyright (c) 2012-2016 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"
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
77void
78limSendKeepAliveToPeer(tpAniSirGlobal pMac)
79{
80
Jeff Johnson295189b2012-06-20 16:38:30 -070081} /*** 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 -----------------------------------------------------------*/
94void
95limDeleteStaContext(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
96{
97 tpDeleteStaContext pMsg = (tpDeleteStaContext)limMsg->bodyptr;
98 tpDphHashNode pStaDs;
99 tpPESession psessionEntry ;
100 tANI_U8 sessionId;
101
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530102 if(NULL == pMsg)
103 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700104 PELOGE(limLog(pMac, LOGE,FL("Invalid body pointer in message"));)
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530105 return;
106 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700107 if((psessionEntry = peFindSessionByBssid(pMac,pMsg->bssId,&sessionId))== NULL)
108 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700109 PELOGE(limLog(pMac, LOGE,FL("session does not exist for given BSSId"));)
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530110 vos_mem_free(pMsg);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530111 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700112 }
113
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530114 switch(pMsg->reasonCode)
Jeff Johnson295189b2012-06-20 16:38:30 -0700115 {
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530116 case HAL_DEL_STA_REASON_CODE_KEEP_ALIVE:
117 case HAL_DEL_STA_REASON_CODE_TIM_BASED:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700118 PELOGE(limLog(pMac, LOGE, FL(" Deleting station: staId = %d, reasonCode = %d"), pMsg->staId, pMsg->reasonCode);)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700119 if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)
Mukul Sharma91947a22014-06-09 11:07:51 +0530120 {
121 vos_mem_free(pMsg);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700122 return;
Mukul Sharma91947a22014-06-09 11:07:51 +0530123 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700124
Gopichand Nakkala94253192013-03-28 15:35:48 -0700125 pStaDs = dphLookupAssocId(pMac, pMsg->staId, &pMsg->assocId, &psessionEntry->dph.dphHashTable);
Hoonki Leee6bfe942013-02-05 15:01:19 -0800126
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530127 if (!pStaDs)
128 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700129 PELOGE(limLog(pMac, LOGE, FL("Skip STA deletion (invalid STA) limSystemRole=%d"),psessionEntry->limSystemRole);)
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530130 vos_mem_free(pMsg);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530131 return;
132 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700133
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530134 /* 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 Lokere80007262013-03-18 19:45:50 -0700139 PELOGE(limLog(pMac, LOGE, FL("staid mismatch: %d vs %d "), pStaDs->staIndex, pMsg->staId);)
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530140 vos_mem_free(pMsg);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530141 return;
142 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700143
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530144 if((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) ||
145 (eLIM_AP_ROLE == psessionEntry->limSystemRole))
146 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530147 limLog(pMac, LOG1, FL("SAP:lim Delete Station Context (staId: %d, assocId: %d) "),
148 pMsg->staId, pMsg->assocId);
Sachin Ahuja876dade2014-07-15 17:07:35 +0530149 /*
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
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530169 {
170 limSendDisassocMgmtFrame(pMac,
171 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON,
172 pStaDs->staAddr, psessionEntry, FALSE);
Sachin Ahuja876dade2014-07-15 17:07:35 +0530173 limTriggerSTAdeletion(pMac, pStaDs, psessionEntry);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530174 }
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530175 }
176 else
177 {
Hoonki Leee6bfe942013-02-05 15:01:19 -0800178#ifdef FEATURE_WLAN_TDLS
179 if(eLIM_STA_ROLE == psessionEntry->limSystemRole &&
180 STA_ENTRY_TDLS_PEER == pStaDs->staType)
181 {
182 //TeardownLink with PEER
183 //Reason code HAL_DEL_STA_REASON_CODE_KEEP_ALIVE means
184 //eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE
185 limSendSmeTDLSDelStaInd(pMac, pStaDs, psessionEntry,
186 /*pMsg->reasonCode*/ eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE);
187 }
188 else
189 {
190#endif
191 //TearDownLink with AP
192 tLimMlmDeauthInd mlmDeauthInd;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700193 PELOGW(limLog(pMac, LOGW, FL("lim Delete Station Context (staId: %d, assocId: %d) "),
Hoonki Leee6bfe942013-02-05 15:01:19 -0800194 pMsg->staId, pMsg->assocId);)
Mukul Sharma91947a22014-06-09 11:07:51 +0530195 if ((pStaDs &&
196 ((pStaDs->mlmStaContext.mlmState !=
197 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
198 (pStaDs->mlmStaContext.mlmState !=
199 eLIM_MLM_WT_ASSOC_CNF_STATE) &&
200 (pStaDs->mlmStaContext.mlmState !=
201 eLIM_MLM_ASSOCIATED_STATE))))
202 {
203 /**
204 * Received WDA_DELETE_STA_CONTEXT_IND for STA that does not
205 * have context or in some transit state.
206 * Log error
207 */
208 PELOGE(limLog(pMac, LOGE,
209 FL("received WDA_DELETE_STA_CONTEXT_IND for STA that either has no context or in some transit state, Addr= "
210 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMsg->bssId));)
211 vos_mem_free(pMsg);
212 return;
213 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700214
Abhishek Singhaddb08b2014-06-06 14:16:36 +0530215 if( pMac->roam.configParam.sendDeauthBeforeCon )
216 {
217 tANI_U8 apCount = pMac->lim.gLimHeartBeatApMacIndex;
218
219 if(pMac->lim.gLimHeartBeatApMacIndex)
220 pMac->lim.gLimHeartBeatApMacIndex = 0;
221 else
222 pMac->lim.gLimHeartBeatApMacIndex = 1;
223
224 limLog(pMac, LOG1, FL("lim Delete Station Context for MAC "
225 MAC_ADDRESS_STR" Store it on Index %d"),
226 MAC_ADDR_ARRAY(pStaDs->staAddr),apCount);
227
228 sirCopyMacAddr(pMac->lim.gLimHeartBeatApMac[apCount],pStaDs->staAddr);
229 }
Deepthi Gowridf91a662014-12-17 17:14:35 +0530230 pStaDs->mlmStaContext.disassocReason =
231 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
Hoonki Leee6bfe942013-02-05 15:01:19 -0800232 pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
Padma, Santhosh Kumar6dc7be62015-08-07 18:13:31 +0530234 if (pStaDs->isDisassocDeauthInProgress)
235 {
236 limLog(pMac, LOGE, FL("No need to cleanup as already"
237 "disassoc or deauth in progress"));
238 return;
239 }
240 else
241 pStaDs->isDisassocDeauthInProgress++;
Mukul Sharma91947a22014-06-09 11:07:51 +0530242
Hoonki Leee6bfe942013-02-05 15:01:19 -0800243 // Issue Deauth Indication to SME.
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530244 vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr,
245 pStaDs->staAddr, sizeof(tSirMacAddr));
Hoonki Leee6bfe942013-02-05 15:01:19 -0800246 mlmDeauthInd.reasonCode = (tANI_U8) pStaDs->mlmStaContext.disassocReason;
247 mlmDeauthInd.deauthTrigger = pStaDs->mlmStaContext.cleanupTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -0700248
Gopichand Nakkalaca35d292013-03-05 11:06:03 -0800249#ifdef FEATURE_WLAN_TDLS
250 /* Delete all TDLS peers connected before leaving BSS*/
251 limDeleteTDLSPeers(pMac, psessionEntry);
252#endif
Hoonki Leee6bfe942013-02-05 15:01:19 -0800253 limPostSmeMessage(pMac, LIM_MLM_DEAUTH_IND, (tANI_U32 *) &mlmDeauthInd);
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530254
Hoonki Leee6bfe942013-02-05 15:01:19 -0800255 limSendSmeDeauthInd(pMac, pStaDs, psessionEntry);
256#ifdef FEATURE_WLAN_TDLS
257 }
258#endif
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530259 }
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700261
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530262 case HAL_DEL_STA_REASON_CODE_UNKNOWN_A2:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700263 PELOGE(limLog(pMac, LOGE, FL(" Deleting Unknown station "));)
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530264 limPrintMacAddr(pMac, pMsg->addr2, LOGE);
265 limSendDeauthMgmtFrame( pMac, eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON, pMsg->addr2, psessionEntry, FALSE);
266 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700267
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530268 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700269 PELOGE(limLog(pMac, LOGE, FL(" Unknown reason code "));)
Pratik Bhalgataa1ae392012-11-22 17:44:33 +0530270 break;
271
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 }
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530273 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 return;
275}
276
277
278/**
279 * limTriggerSTAdeletion()
280 *
281 *FUNCTION:
282 * This function is called to trigger STA context deletion
283 *
284 *LOGIC:
285 *
286 *ASSUMPTIONS:
287 *
288 *NOTE:
289 * NA
290 *
291 * @param pMac - Pointer to global MAC structure
292 * @param pStaDs - Pointer to internal STA Datastructure
293 * @return None
294 */
295void
296limTriggerSTAdeletion(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tpPESession psessionEntry)
297{
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530298 tLimMlmDisassocInd mlmDisassocInd;
Jeff Johnson295189b2012-06-20 16:38:30 -0700299
300
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530301 if (!pStaDs)
302 {
303 PELOGW(limLog(pMac, LOGW, FL("Skip STA deletion (invalid STA)"));)
304 return;
305 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700306
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530307 if ((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
Abhishek Singh71b1c1e2016-06-15 12:51:57 +0530308 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE)||
309 pStaDs->sta_deletion_in_progress) {
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530310 /* Already in the process of deleting context for the peer */
Abhishek Singh71b1c1e2016-06-15 12:51:57 +0530311 limLog(pMac, LOG1,
312 FL("Deletion is in progress (%d) for peer:%p in mlmState %d"),
313 pStaDs->sta_deletion_in_progress, pStaDs->staAddr,
314 pStaDs->mlmStaContext.mlmState);
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530315 return;
316 }
Abhishek Singh71b1c1e2016-06-15 12:51:57 +0530317 pStaDs->sta_deletion_in_progress = true;
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530318 pStaDs->mlmStaContext.disassocReason =
319 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
320 pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DISASSOC;
321 vos_mem_copy(&mlmDisassocInd.peerMacAddr, pStaDs->staAddr,
322 sizeof(tSirMacAddr));
323 mlmDisassocInd.reasonCode = eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
324 mlmDisassocInd.disassocTrigger = eLIM_LINK_MONITORING_DISASSOC;
325
326 /* Update PE session Id */
327 mlmDisassocInd.sessionId = psessionEntry->peSessionId;
328 limPostSmeMessage(pMac, LIM_MLM_DISASSOC_IND,
329 (tANI_U32 *) &mlmDisassocInd);
330 // Issue Disassoc Indication to SME.
331 limSendSmeDisassocInd(pMac, pStaDs, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700332} /*** end limTriggerSTAdeletion() ***/
333
334
335
336/**
337 * limTearDownLinkWithAp()
338 *
339 *FUNCTION:
340 * This function is called when heartbeat (beacon reception)
341 * fails on STA
342 *
343 *LOGIC:
344 *
345 *ASSUMPTIONS:
346 *
347 *NOTE:
348 *
349 * @param pMac - Pointer to Global MAC structure
350 * @return None
351 */
352
353void
354limTearDownLinkWithAp(tpAniSirGlobal pMac, tANI_U8 sessionId, tSirMacReasonCodes reasonCode)
355{
356 tpDphHashNode pStaDs = NULL;
357
358 //tear down the following sessionEntry
359 tpPESession psessionEntry;
360
361 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId))== NULL)
362 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700363 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 return;
365 }
366 /**
367 * Heart beat failed for upto threshold value
368 * and AP did not respond for Probe request.
369 * Trigger link tear down.
370 */
371
372 pMac->pmm.inMissedBeaconScenario = FALSE;
373 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700374 FL("No ProbeRsp from AP after HB failure. Tearing down link"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700375
376 // Deactivate heartbeat timer
377 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
378
379 // Announce loss of link to Roaming algorithm
380 // and cleanup by sending SME_DISASSOC_REQ to SME
381
382 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
383
384
385 if (pStaDs != NULL)
386 {
387 tLimMlmDeauthInd mlmDeauthInd;
388
Gopichand Nakkalae9b72e12013-02-27 20:51:16 -0800389#ifdef FEATURE_WLAN_TDLS
390 /* Delete all TDLS peers connected before leaving BSS*/
391 limDeleteTDLSPeers(pMac, psessionEntry);
392#endif
393
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 pStaDs->mlmStaContext.disassocReason = reasonCode;
395 pStaDs->mlmStaContext.cleanupTrigger = eLIM_LINK_MONITORING_DEAUTH;
396
397 /// Issue Deauth Indication to SME.
Bansidhar Gopalachari2f7395d2013-07-12 11:24:23 +0530398 vos_mem_copy((tANI_U8 *) &mlmDeauthInd.peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 pStaDs->staAddr,
400 sizeof(tSirMacAddr));
Abhishek Singhde51a412014-05-20 19:17:26 +0530401 /* if sendDeauthBeforeCon is enabled and reasoncode is Beacon Missed
402 * Store the MAC of AP in the flip flop buffer. This MAC will be
403 * used to send Deauth before connection, if we connect to same AP
404 * after HB failure.
405 */
406 if(pMac->roam.configParam.sendDeauthBeforeCon &&
407 eSIR_BEACON_MISSED == reasonCode)
408 {
409 int apCount = pMac->lim.gLimHeartBeatApMacIndex;
410
411 if(pMac->lim.gLimHeartBeatApMacIndex)
412 pMac->lim.gLimHeartBeatApMacIndex = 0;
413 else
414 pMac->lim.gLimHeartBeatApMacIndex = 1;
415
416 limLog(pMac, LOGE, FL("HB Failure on MAC "
417 MAC_ADDRESS_STR" Store it on Index %d"),
418 MAC_ADDR_ARRAY(pStaDs->staAddr),apCount);
419
420 sirCopyMacAddr(pMac->lim.gLimHeartBeatApMac[apCount],pStaDs->staAddr);
421 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 mlmDeauthInd.reasonCode = (tANI_U8) pStaDs->mlmStaContext.disassocReason;
423 mlmDeauthInd.deauthTrigger = pStaDs->mlmStaContext.cleanupTrigger;
424
425 limPostSmeMessage(pMac, LIM_MLM_DEAUTH_IND, (tANI_U32 *) &mlmDeauthInd);
426
427 limSendSmeDeauthInd(pMac, pStaDs, psessionEntry);
428 }
429} /*** limTearDownLinkWithAp() ***/
430
431
432
433
434/**
435 * limHandleHeartBeatFailure()
436 *
437 *FUNCTION:
438 * This function is called when heartbeat (beacon reception)
439 * fails on STA
440 *
441 *LOGIC:
442 *
443 *ASSUMPTIONS:
444 *
445 *NOTE:
446 *
447 * @param pMac - Pointer to Global MAC structure
448 * @return None
449 */
450
451void limHandleHeartBeatFailure(tpAniSirGlobal pMac,tpPESession psessionEntry)
452{
453
454#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
455 vos_log_beacon_update_pkt_type *log_ptr = NULL;
456#endif //FEATURE_WLAN_DIAG_SUPPORT
457
458 /* If gLimHeartBeatTimer fires between the interval of sending WDA_ENTER_BMPS_REQUEST
459 * to the HAL and receiving WDA_ENTER_BMPS_RSP from the HAL, then LIM (PE) tries to Process the
460 * SIR_LIM_HEAR_BEAT_TIMEOUT message but The PE state is ePMM_STATE_BMPS_SLEEP so PE dont
461 * want to handle heartbeat timeout in the BMPS, because Firmware handles it in BMPS.
462 * So just return from heartbeatfailure handler
463 */
Yathish9f22e662012-12-10 14:21:35 -0800464 if(!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE && (!limIsSystemInActiveState(pMac)))
465 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466
467#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
468 WLAN_VOS_DIAG_LOG_ALLOC(log_ptr, vos_log_beacon_update_pkt_type, LOG_WLAN_BEACON_UPDATE_C);
469 if(log_ptr)
470 log_ptr->bcn_rx_cnt = psessionEntry->LimRxedBeaconCntDuringHB;
471 WLAN_VOS_DIAG_LOG_REPORT(log_ptr);
472#endif //FEATURE_WLAN_DIAG_SUPPORT
473
474 /* Ensure HB Status for the session has been reseted */
475 psessionEntry->LimHBFailureStatus = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700476
Sushant Kaushikc14c4d82014-06-30 11:42:21 +0530477 if (((psessionEntry->limSystemRole == eLIM_STA_ROLE)||
478 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
479 (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)&&
480 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
481 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 {
483 if (!pMac->sys.gSysEnableLinkMonitorMode)
484 return;
Abhishek Singh800d17a2016-08-26 17:00:49 +0530485 /* Ignore HB if channel switch is in progress */
486 if (psessionEntry->gLimSpecMgmt.dot11hChanSwState ==
487 eLIM_11H_CHANSW_RUNNING) {
488 limLog(pMac, LOGE,
489 FL("Ignore Heartbeat failure as Channel switch is in progress"));
490 pMac->pmm.inMissedBeaconScenario = false;
491 return;
492 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
494 /**
495 * Beacon frame not received within heartbeat timeout.
496 */
Abhishek Singh800d17a2016-08-26 17:00:49 +0530497 limLog(pMac, LOGW, FL("Heartbeat Failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 pMac->lim.gLimHBfailureCntInLinkEstState++;
499
500 /**
501 * Check if connected on the DFS channel, if not connected on
502 * DFS channel then only send the probe request otherwise tear down the link
503 */
504 if(!limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
505 {
506 /*** Detected continuous Beacon Misses ***/
507 psessionEntry->LimHBFailureStatus= eANI_BOOLEAN_TRUE;
Abhishek Singh11761d02014-05-28 18:39:48 +0530508 /*Reset the HB packet count before sending probe*/
509 limResetHBPktCount(psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 /**
511 * Send Probe Request frame to AP to see if
512 * it is still around. Wait until certain
513 * timeout for Probe Response from AP.
514 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700515 PELOGW(limLog(pMac, LOGW, FL("Heart Beat missed from AP. Sending Probe Req"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 /* for searching AP, we don't include any additional IE */
517 limSendProbeReqMgmtFrame(pMac, &psessionEntry->ssId, psessionEntry->bssId,
518 psessionEntry->currentOperChannel,psessionEntry->selfMacAddr,
519 psessionEntry->dot11mode, 0, NULL);
520 }
521 else
522 {
Praveen Kumar Sirisillaedf67e82013-08-21 19:17:10 -0700523 PELOGW(limLog(pMac, LOGW,
524 FL("Heart Beat missed from AP on DFS chanel moving to passive"));)
525 if (psessionEntry->currentOperChannel < SIR_MAX_24G_5G_CHANNEL_RANGE){
526 limCovertChannelScanType(pMac, psessionEntry->currentOperChannel, false);
527 pMac->lim.dfschannelList.timeStamp[psessionEntry->currentOperChannel] = 0;
528 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 /* Connected on DFS channel so should not send the probe request
530 * tear down the link directly */
Abhishek Singhde51a412014-05-20 19:17:26 +0530531 limTearDownLinkWithAp(pMac, psessionEntry->peSessionId, eSIR_BEACON_MISSED);
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 }
533 }
534 else
535 {
536 /**
537 * Heartbeat timer may have timed out
538 * while we're doing background scanning/learning
539 * or in states other than link-established state.
540 * Log error.
541 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530542 limLog(pMac, LOG1, FL("received heartbeat timeout in state %d"),
543 psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 limPrintMlmState(pMac, LOG1, psessionEntry->limMlmState);
545 pMac->lim.gLimHBfailureCntInOtherStates++;
546 limReactivateHeartBeatTimer(pMac, psessionEntry);
547 }
548} /*** limHandleHeartBeatFailure() ***/