blob: 4fdd077180847f0406acb7152450890ed247b353 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * 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.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
44
45
46 \file csrNeighborRoam.c
47
48 Implementation for the simple roaming algorithm for 802.11r Fast transitions and Legacy roaming for Android platform.
49
50 Copyright (C) 2010 Qualcomm, Incorporated
51
52
53 ========================================================================== */
54
55/*===========================================================================
56
57 EDIT HISTORY FOR FILE
58
59
60 This section contains comments describing changes made to the module.
61 Notice that changes are listed in reverse chronological order.
62
63
64
65 when who what, where, why
66---------- --- --------------------------------------------------------
6708/01/10 Murali Created
68
69===========================================================================*/
70#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
71#include "wlan_qct_wda.h"
72#include "palApi.h"
73#include "csrInsideApi.h"
74#include "smsDebug.h"
75#include "logDump.h"
76#include "smeQosInternal.h"
77#include "wlan_qct_tl.h"
78#include "smeInside.h"
79#include "vos_diag_core_event.h"
80#include "vos_diag_core_log.h"
81#include "csrApi.h"
82#include "wlan_qct_tl.h"
83#include "sme_Api.h"
84#include "csrNeighborRoam.h"
85#ifdef FEATURE_WLAN_CCX
86#include "csrCcx.h"
87#endif
88
89#define WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG 1
90#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG
91#define NEIGHBOR_ROAM_DEBUG smsLog
92#else
93#define NEIGHBOR_ROAM_DEBUG(x...)
94#endif
95
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -070096static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo);
97static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac);
98static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac);
99static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac);
100
Jeff Johnson295189b2012-06-20 16:38:30 -0700101VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800102 v_PVOID_t pUserCtxt,
103 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700104VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800105 v_PVOID_t pUserCtxt,
106 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700107void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus);
108eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile );
109
110#ifdef WLAN_FEATURE_VOWIFI_11R
111static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac);
112VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac);
113#endif
114
115/* State Transition macro */
116#define CSR_NEIGHBOR_ROAM_STATE_TRANSITION(newState)\
117{\
118 pMac->roam.neighborRoamInfo.prevNeighborRoamState = pMac->roam.neighborRoamInfo.neighborRoamState;\
119 pMac->roam.neighborRoamInfo.neighborRoamState = newState;\
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700120 smsLog(pMac, LOG1, FL("Neighbor Roam Transition from state %d ==> %d"), pMac->roam.neighborRoamInfo.prevNeighborRoamState, newState);\
Jeff Johnson295189b2012-06-20 16:38:30 -0700121}
122
123/* ---------------------------------------------------------------------------
124
125 \fn csrNeighborRoamFreeNeighborRoamBSSNode
126
127 \brief This function frees all the internal pointers CSR NeighborRoam BSS Info
128 and also frees the node itself
129
130 \param pMac - The handle returned by macOpen.
131 neighborRoamBSSNode - Neighbor Roam BSS Node to be freed
132
133 \return VOID
134
135---------------------------------------------------------------------------*/
136void csrNeighborRoamFreeNeighborRoamBSSNode(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo neighborRoamBSSNode)
137{
138 if (neighborRoamBSSNode)
139 {
140 if (neighborRoamBSSNode->pBssDescription)
141 {
142 vos_mem_free(neighborRoamBSSNode->pBssDescription);
143 neighborRoamBSSNode->pBssDescription = NULL;
144 }
145 vos_mem_free(neighborRoamBSSNode);
146 neighborRoamBSSNode = NULL;
147 }
148
149 return;
150}
151
152/* ---------------------------------------------------------------------------
153
154 \fn csrNeighborRoamRemoveRoamableAPListEntry
155
156 \brief This function removes a given entry from the given list
157
158 \param pMac - The handle returned by macOpen.
159 pList - The list from which the entry should be removed
160 pNeighborEntry - Neighbor Roam BSS Node to be removed
161
162 \return TRUE if successfully removed, else FALSE
163
164---------------------------------------------------------------------------*/
165tANI_BOOLEAN csrNeighborRoamRemoveRoamableAPListEntry(tpAniSirGlobal pMac,
166 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
167{
168 if(pList)
169 {
170 return csrLLRemoveEntry(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
171 }
172
173 smsLog(pMac, LOGE, FL("Removing neighbor BSS node from list failed. Current count = %d\n"), csrLLCount(pList));
174
175 return eANI_BOOLEAN_FALSE;
176}
177
178/* ---------------------------------------------------------------------------
179
180 \fn csrNeighborRoamGetRoamableAPListNextEntry
181
182 \brief Gets the entry next to passed entry. If NULL is passed, return the entry in the head of the list
183
184 \param pMac - The handle returned by macOpen.
185 pList - The list from which the entry should be returned
186 pNeighborEntry - Neighbor Roam BSS Node whose next entry should be returned
187
188 \return Neighbor Roam BSS Node to be returned
189
190---------------------------------------------------------------------------*/
191tpCsrNeighborRoamBSSInfo csrNeighborRoamGetRoamableAPListNextEntry(tpAniSirGlobal pMac,
192 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
193{
194 tListElem *pEntry = NULL;
195 tpCsrNeighborRoamBSSInfo pResult = NULL;
196
197 if(pList)
198 {
199 if(NULL == pNeighborEntry)
200 {
201 pEntry = csrLLPeekHead(pList, LL_ACCESS_LOCK);
202 }
203 else
204 {
205 pEntry = csrLLNext(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
206 }
207 if(pEntry)
208 {
209 pResult = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
210 }
211 }
212
213 return pResult;
214}
215
216/* ---------------------------------------------------------------------------
217
218 \fn csrNeighborRoamFreeRoamableBSSList
219
220 \brief Empties and frees all the nodes in the roamable AP list
221
222 \param pMac - The handle returned by macOpen.
223 pList - Neighbor Roam BSS List to be emptied
224
225 \return VOID
226
227---------------------------------------------------------------------------*/
228void csrNeighborRoamFreeRoamableBSSList(tpAniSirGlobal pMac, tDblLinkList *pList)
229{
230 tpCsrNeighborRoamBSSInfo pResult = NULL;
231
Mohit Khanna23863762012-09-11 17:40:09 -0700232 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Emptying the BSS list. Current count = %d\n"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700233
234 /* Pick up the head, remove and free the node till the list becomes empty */
235 while ((pResult = csrNeighborRoamGetRoamableAPListNextEntry(pMac, pList, NULL)) != NULL)
236 {
237 csrNeighborRoamRemoveRoamableAPListEntry(pMac, pList, pResult);
238 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pResult);
239 }
240 return;
241}
242
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800243static void csrNeighborRoamTriggerHandoff(tpAniSirGlobal pMac,
244 tpCsrNeighborRoamControlInfo pNeighborRoamInfo)
245{
246#ifdef WLAN_FEATURE_VOWIFI_11R
247 if (pNeighborRoamInfo->is11rAssoc)
248 {
249 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
250 {
251 csrNeighborRoamIssuePreauthReq(pMac);
252 }
253 else
254 {
255 smsLog(pMac, LOGE, FL("11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
256 VOS_ASSERT(0);
257 }
258 }
259 else
260#endif
261
262#ifdef FEATURE_WLAN_CCX
263 if (pNeighborRoamInfo->isCCXAssoc)
264 {
265 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
266 {
267 csrNeighborRoamIssuePreauthReq(pMac);
268 }
269 else
270 {
271 smsLog(pMac, LOGE, FL("CCX Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
272 VOS_ASSERT(0);
273 }
274 }
275 else
276#endif
277#ifdef FEATURE_WLAN_LFR
278 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
279 {
280 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
281 {
282 csrNeighborRoamIssuePreauthReq(pMac);
283 }
284 else
285 {
286 smsLog(pMac, LOGE, FL("LFR Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
287 VOS_ASSERT(0);
288 }
289 }
290 else
291#endif
292 {
293 if (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pNeighborRoamInfo->neighborRoamState)
294 {
295 csrNeighborRoamRequestHandoff(pMac);
296 }
297 else
298 {
299 smsLog(pMac, LOGE, FL("Non-11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
300 VOS_ASSERT(0);
301 }
302 }
303}
304
Jeff Johnson295189b2012-06-20 16:38:30 -0700305/* ---------------------------------------------------------------------------
306
307 \fn csrNeighborRoamReassocIndCallback
308
309 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
310 Directly triggere HO in case of non-11r association
311 In case of 11R association, triggers a pre-auth eventually followed by actual HO
312
313 \param pAdapter - VOS Context
314 trafficStatus - UP/DOWN indication from TL
315 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
316
317 \return VOID
318
319---------------------------------------------------------------------------*/
320VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
321 v_U8_t trafficStatus,
Srinivasdaaec712012-12-12 15:59:44 -0800322 v_PVOID_t pUserCtxt,
323 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700324{
325 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
326 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
327 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
328
Srinivasdaaec712012-12-12 15:59:44 -0800329 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"),
330 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
331 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700332
333 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
334 WLANTL_HO_THRESHOLD_DOWN,
335 csrNeighborRoamReassocIndCallback,
336 VOS_MODULE_ID_SME);
337
338 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
339 {
340 //err msg
341 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
342 }
343
Srinivasdaaec712012-12-12 15:59:44 -0800344 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
345 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800346 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
347 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
348 WLANTL_HO_THRESHOLD_UP,
349 csrNeighborRoamNeighborLookupUPCallback,
350 VOS_MODULE_ID_SME);
Jeff Johnson295189b2012-06-20 16:38:30 -0700351
352 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
353 {
354 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530355 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 }
357
358 /* We dont need to run this timer any more. */
359 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
360
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800361 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700362
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 return VOS_STATUS_SUCCESS;
364}
365
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700366/*CleanUP Routines*/
367static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
368{
369 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
370 (rChInfo->currentChannelListInfo.numOfChannels))
371 {
372 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
373 rChInfo->currentChannelListInfo.numOfChannels = 0;
374
375 if (rChInfo->currentChannelListInfo.ChannelList)
376 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
377
378 rChInfo->currentChannelListInfo.ChannelList = NULL;
379 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
380 }
381 else
382 {
383 rChInfo->currentChanIndex = 0;
384 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
385 }
386}
387
388static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
389{
390 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
391
392 /* Stop neighbor scan timer */
393 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
394
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700395 /* Stop neighbor scan results refresh timer */
396 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
397
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700398 /* Abort any ongoing scan */
399 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
400 {
401 csrScanAbortMacScan(pMac);
402 }
403 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
404
405 /* Reset roam channel list information */
406 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
407}
408
409static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
410{
411 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
412
413#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
414 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
415 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
416 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId =
417 CSR_SESSION_ID_INVALID;
418 /* Purge pre-auth fail list */
419 csrNeighborRoamPurgePreauthFailedList(pMac);
420#endif
421
422 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
423 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
424#ifdef WLAN_FEATURE_VOWIFI_11R
425 /* Do not free up the preauth done list here */
426 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
427 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
428 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
429 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
430 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
431#endif
432}
433
434static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
435{
436 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
437 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
438
439 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
440 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800441 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700442
443 /* Deregister reassoc callback. Ignore return status */
444 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800445 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700446 WLANTL_HO_THRESHOLD_UP,
447 csrNeighborRoamNeighborLookupUPCallback,
448 VOS_MODULE_ID_SME);
449
450 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
451 {
452 smsLog(pMac, LOGW,
453 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
454 "with TL: Status = %d\n"), vosStatus);
455 }
456
457 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
458 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
459 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
460
461 /* Deregister reassoc callback. Ignore return status */
462 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
463 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
464 WLANTL_HO_THRESHOLD_DOWN,
465 csrNeighborRoamReassocIndCallback,
466 VOS_MODULE_ID_SME);
467
468 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
469 {
470 smsLog(pMac, LOGW,
471 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
472 "TL: Status = %d\n"), vosStatus);
473 }
474
475 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
476 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
477 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
478
479 /* Deregister neighbor lookup callback. Ignore return status */
480 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
481 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
482 WLANTL_HO_THRESHOLD_DOWN,
483 csrNeighborRoamNeighborLookupDOWNCallback,
484 VOS_MODULE_ID_SME);
485
486 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
487 {
488 smsLog(pMac, LOGW,
489 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
490 "with TL: Status = %d\n"), vosStatus);
491 }
492
493 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700494 pNeighborRoamInfo->currentNeighborLookupThreshold =
495 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800496#ifdef FEATURE_WLAN_LFR
497 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -0800498 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800499#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700500}
501
Jeff Johnson295189b2012-06-20 16:38:30 -0700502/* ---------------------------------------------------------------------------
503
504 \fn csrNeighborRoamResetConnectedStateControlInfo
505
506 \brief This function will reset the neighbor roam control info data structures.
507 This function should be invoked whenever we move to CONNECTED state from
508 any state other than INIT state
509
510 \param pMac - The handle returned by macOpen.
511
512 \return VOID
513
514---------------------------------------------------------------------------*/
515void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
516{
517 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
518
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700519 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700520 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700521
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700522 /* We dont need to run this timer any more. */
523 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700524
525#ifdef WLAN_FEATURE_VOWIFI_11R
526 /* Do not free up the preauth done list here */
527 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
528 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
529 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
530 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
531 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
532 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
533 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
534#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700535}
536
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700537void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700538{
539 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
541 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
542 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
543 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700544#ifdef FEATURE_WLAN_CCX
545 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
546 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
547 pNeighborRoamInfo->MinQBssLoadRequired = 0;
548#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700549
550 /* Stop scan refresh timer */
551 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700552 /* Purge roamable AP list */
553 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 return;
555}
556
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700557/* ---------------------------------------------------------------------------
558
559 \fn csrNeighborRoamResetInitStateControlInfo
560
561 \brief This function will reset the neighbor roam control info data structures.
562 This function should be invoked whenever we move to CONNECTED state from
563 INIT state
564
565 \param pMac - The handle returned by macOpen.
566
567 \return VOID
568
569---------------------------------------------------------------------------*/
570void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
571{
572 csrNeighborRoamResetConnectedStateControlInfo(pMac);
573
574 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
575 csrNeighborRoamResetReportScanStateControlInfo(pMac);
576}
577
578
579
Jeff Johnson295189b2012-06-20 16:38:30 -0700580#ifdef WLAN_FEATURE_VOWIFI_11R
581/* ---------------------------------------------------------------------------
582
583 \fn csrNeighborRoamBssIdScanFilter
584
585 \brief This API is used to prepare a filter to obtain scan results when
586 we complete the scan in the REPORT_SCAN state after receiving a
587 valid neighbor report from AP. This filter includes BSSIDs received from
588 the neighbor report from the AP in addition to the other filter parameters
589 created from connected profile
590
591 \param pMac - The handle returned by macOpen.
592 pScanFilter - Scan filter to be filled and returned
593
594 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
595 code otherwise
596
597---------------------------------------------------------------------------*/
598static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
599{
600 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
601 tANI_U8 i = 0;
602
603 VOS_ASSERT(pScanFilter != NULL);
604 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
605
606 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
607 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
608 if (NULL == pScanFilter->BSSIDs.bssid)
609 {
610 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
611 return eHAL_STATUS_FAILED_ALLOC;
612 }
613
614 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
615
616 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
617 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
618 {
619 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
620 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
621 }
622
623 /* Fill other general scan filter params */
624 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
625}
626
627/* ---------------------------------------------------------------------------
628
629 \fn csrNeighborRoamPurgePreauthFailList
630
631 \brief This function empties the preauth fail list
632
633 \param pMac - The handle returned by macOpen.
634
635 \return VOID
636
637---------------------------------------------------------------------------*/
638void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
639{
640 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
641
642 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
643 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
644 {
645 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
646 sizeof(tSirMacAddr));
647 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
648 }
649 return;
650}
651
652/* ---------------------------------------------------------------------------
653
654 \fn csrNeighborRoamAddBssIdToPreauthFailList
655
656 \brief This function adds the given BSSID to the Preauth fail list
657
658 \param pMac - The handle returned by macOpen.
659 bssId - BSSID to be added to the preauth fail list
660
661 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
662
663---------------------------------------------------------------------------*/
664eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
665{
666 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
667
668 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL(" Added BSSID %02x:%02x:%02x:%02x:%02x:%02x to Preauth failed list\n"),
669 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
670
671
672 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
673 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
674 {
675 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
676 return eHAL_STATUS_FAILURE;
677 }
678 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
679 bssId, sizeof(tSirMacAddr));
680 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
681
682 return eHAL_STATUS_SUCCESS;
683}
684
685/* ---------------------------------------------------------------------------
686
687 \fn csrNeighborRoamIsPreauthCandidate
688
689 \brief This function checks whether the given MAC address is already
690 present in the preauth fail list and returns TRUE/FALSE accordingly
691
692 \param pMac - The handle returned by macOpen.
693
694 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
695
696---------------------------------------------------------------------------*/
697tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
698{
699 tANI_U8 i = 0;
700 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
701
702 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
703 return eANI_BOOLEAN_TRUE;
704
705 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
706 {
707 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
708 bssId, sizeof(tSirMacAddr)))
709 {
710 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
711 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
712 return eANI_BOOLEAN_FALSE;
713 }
714 }
715
716 return eANI_BOOLEAN_TRUE;
717}
718
719/* ---------------------------------------------------------------------------
720
721 \fn csrNeighborRoamIssuePreauthReq
722
723 \brief This function issues preauth request to PE with the 1st AP entry in the
724 roamable AP list
725
726 \param pMac - The handle returned by macOpen.
727
728 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
729
730---------------------------------------------------------------------------*/
731static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
732{
733 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
734 eHalStatus status = eHAL_STATUS_SUCCESS;
735 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
736
737 /* This must not be true here */
738 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
739
740 /* Issue Preauth request to PE here */
741 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
742 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
743 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
744 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
745
746 if (NULL == pNeighborBssNode)
747 {
748 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
749 return eHAL_STATUS_FAILURE;
750 }
751 else
752 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700753 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
754 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530755
756 smsLog(pMac, LOGE, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x %d"),
757 pNeighborBssNode->pBssDescription->bssId[0],
758 pNeighborBssNode->pBssDescription->bssId[1],
759 pNeighborBssNode->pBssDescription->bssId[2],
760 pNeighborBssNode->pBssDescription->bssId[3],
761 pNeighborBssNode->pBssDescription->bssId[4],
762 pNeighborBssNode->pBssDescription->bssId[5]);
763 smsLog(pMac, LOGE, FL("Before Pre-Auth: Channel %d\n"), (int)pNeighborBssNode->pBssDescription->channelId);
764
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 if (eHAL_STATUS_SUCCESS != status)
766 {
767 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d\n"), status);
768 return status;
769 }
770 }
771
772 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
773
774 /* Increment the preauth retry count */
775 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
776
777 /* Transition the state to preauthenticating */
778 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700779#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 /* Start the preauth rsp timer */
781 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer,
782 CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
783 eANI_BOOLEAN_FALSE);
784 if (eHAL_STATUS_SUCCESS != status)
785 {
786 smsLog(pMac, LOGE, FL("Preauth response wait timer start failed with status %d\n"), status);
787 return status;
788 }
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700789#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700790
791 return status;
792}
793
794/* ---------------------------------------------------------------------------
795
796 \fn csrNeighborRoamPreauthRspHandler
797
798 \brief This function handle the Preauth response from PE
799 Every preauth is allowed max 3 tries if it fails. If a bssid failed
800 for more than MAX_TRIES, we will remove it from the list and try
801 with the next node in the roamable AP list and add the BSSID to pre-auth failed
802 list. If no more entries present in
803 roamable AP list, transition to REPORT_SCAN state
804
805 \param pMac - The handle returned by macOpen.
806 vosStatus - VOS_STATUS_SUCCESS/FAILURE/TIMEOUT status from PE
807
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700808 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
809 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -0700810
811---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700812eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, VOS_STATUS vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700813{
814 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
815 eHalStatus status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700816 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700818
819 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
820 {
821
822 /* This can happen when we disconnect immediately
823 * after sending a pre-auth request. During processing
824 * of the disconnect command, we would have reset
825 * preauthRspPending and transitioned to INIT state.
826 */
827 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
828 FL("Unexpected pre-auth response in state %d\n"),
829 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700830 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700831 goto DEQ_PREAUTH;
832 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700833
834 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
836 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
837 {
Madan Mohan Koyyalamudi8186a9e2012-10-11 14:23:43 -0700838 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d\n"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700839 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700840 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700841 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 }
843
844 if (VOS_STATUS_E_TIMEOUT != vosStatus)
845 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700846#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 /* This means we got the response from PE. Hence stop the timer */
848 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700849#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
851 }
852
853 if (VOS_STATUS_SUCCESS == vosStatus)
854 {
855 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
856 }
857 if ((VOS_STATUS_SUCCESS == vosStatus) && (NULL != pPreauthRspNode))
858 {
859 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
860
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530861 smsLog(pMac, LOGE, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x\n"),
862 pPreauthRspNode->pBssDescription->bssId[0],
863 pPreauthRspNode->pBssDescription->bssId[1],
864 pPreauthRspNode->pBssDescription->bssId[2],
865 pPreauthRspNode->pBssDescription->bssId[3],
866 pPreauthRspNode->pBssDescription->bssId[4],
867 pPreauthRspNode->pBssDescription->bssId[5]);
868 smsLog(pMac, LOGE, FL("After Pre-Auth: Channel %d\n"), (int)pPreauthRspNode->pBssDescription->channelId);
869
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
871 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
872 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
873
874 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
875 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
876 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
877
878 /* The caller of this function would start a timer and by the time it expires, supplicant should
879 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
880 }
881 else
882 {
883 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
884 tListElem *pEntry;
885
886 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = %d\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, vosStatus);
887
888 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
889 if (pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >= CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES)
890 {
891 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
892 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
893
894 /* The one in the head of the list should be one with which we issued pre-auth and failed */
895 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
896 if(pEntry)
897 {
898 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
899 /* Add the BSSID to pre-auth fail list */
900 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
901 /* Now we can free this node */
902 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
903 }
904 }
905
906 /* Issue preauth request for the same/next entry */
907 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700908 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700909
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800910 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
911
912 /* Register Neighbor Lookup threshold callback with TL for UP event now */
913 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
914 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
915
916 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
917 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
918 WLANTL_HO_THRESHOLD_UP,
919 csrNeighborRoamNeighborLookupUPCallback,
920 VOS_MODULE_ID_SME, pMac);
921 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
922 {
923 //err msg
924 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
925 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700926
927 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
928 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
929 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
930 eANI_BOOLEAN_FALSE);
931 if (eHAL_STATUS_SUCCESS != status)
932 {
933 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 }
935 }
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700936
937DEQ_PREAUTH:
938 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700939 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700940}
941#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
942
943/* ---------------------------------------------------------------------------
944
945 \fn csrNeighborRoamPrepareScanProfileFilter
946
947 \brief This function creates a scan filter based on the currently connected profile.
948 Based on this filter, scan results are obtained
949
950 \param pMac - The handle returned by macOpen.
951 pScanFilter - Populated scan filter based on the connected profile
952
953 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
954
955---------------------------------------------------------------------------*/
956eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
957{
958 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
959 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
960 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
961 tANI_U8 i = 0;
962
963 VOS_ASSERT(pScanFilter != NULL);
964
965 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
966
967 /* We dont want to set BSSID based Filter */
968 pScanFilter->BSSIDs.numOfBSSIDs = 0;
969
970 /* Populate all the information from the connected profile */
971 pScanFilter->SSIDs.numOfSSIDs = 1;
972 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
973 if (NULL == pScanFilter->SSIDs.SSIDList)
974 {
975 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
976 return eHAL_STATUS_FAILED_ALLOC;
977 }
978 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
979 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
980 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
981 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
982
983 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering for SSID %s from scan results.. SSID Length = %d\n"),
984 pScanFilter->SSIDs.SSIDList->SSID.ssId, pScanFilter->SSIDs.SSIDList->SSID.length);
985 pScanFilter->authType.numEntries = 1;
986 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
987
988 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
989 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
990
991 pScanFilter->mcEncryptionType.numEntries = 1;
992 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
993
994 pScanFilter->BSSType = pCurProfile->BSSType;
995
996 /* We are intrested only in the scan results on channels that we scanned */
997 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
998 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
999 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1000 {
1001 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1002 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1003 pScanFilter->SSIDs.SSIDList = NULL;
1004 return eHAL_STATUS_FAILED_ALLOC;
1005 }
1006 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1007 {
1008 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1009 }
1010
1011#ifdef WLAN_FEATURE_VOWIFI_11R
1012 if (pNeighborRoamInfo->is11rAssoc)
1013 {
1014 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1015 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1016 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1017 }
1018#endif
1019
1020 return eHAL_STATUS_SUCCESS;
1021}
1022
Jeff Johnson43971f52012-07-17 12:26:56 -07001023tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1024{
1025 tCsrScanResultInfo *pScanResult;
1026 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda2efea0e2013-01-24 17:40:41 -08001027#ifdef FEATURE_WLAN_LFR
1028 tANI_U32 CurrAPRssi = pNeighborRoamInfo->lookupDOWNRssi;
1029#else
1030 /* We are setting this as default value to make sure we return this value,
1031 when we do not see this AP in the scan result for some reason.However,it is
1032 less likely that we are associated to an AP and do not see it in the scan list */
1033 tANI_U32 CurrAPRssi = -125;
1034#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001035
1036 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1037 {
1038
1039 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1040 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1041 {
1042 /* We got a match with the currently associated AP.
1043 * Capture the RSSI value and complete the while loop.
1044 * The while loop is completed in order to make the current entry go back to NULL,
1045 * and in the next while loop, it properly starts searching from the head of the list.
1046 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1047
1048 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1049
1050 } else {
1051 continue;
1052 }
1053 }
1054
1055 return CurrAPRssi;
1056
1057}
1058
Jeff Johnson295189b2012-06-20 16:38:30 -07001059/* ---------------------------------------------------------------------------
1060
1061 \fn csrNeighborRoamProcessScanResults
1062
1063 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1064 Assumed that the results are already sorted by RSSI by csrScanGetResult
1065
1066 \param pMac - The handle returned by macOpen.
1067 pScanResultList - Scan result result obtained from csrScanGetResult()
1068
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001069 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1070 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001071
1072---------------------------------------------------------------------------*/
1073
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001074static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1075 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001076{
1077 tCsrScanResultInfo *pScanResult;
1078 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1079 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001080 tANI_U32 CurrAPRssi;
1081 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001082#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1083 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1084#endif
1085 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001086
1087 /***************************************************************
1088 * Find out the Current AP RSSI and keep it handy to check if
1089 * it is better than the RSSI of the AP which we are
1090 * going to roam.If so, we are going to continue with the
1091 * current AP.
1092 ***************************************************************/
1093 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001094
1095 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1096 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1097 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1098 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1099 /* For now, let us take the top of the list provided as it is by the CSR Scan result API. This means it is assumed that neighbor score
1100 and rssi score are in the same order. This will be taken care later */
1101
1102 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1103 {
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001104 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1105 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d)"),
1106 pScanResult->BssDescriptor.bssId[0],
1107 pScanResult->BssDescriptor.bssId[1],
1108 pScanResult->BssDescriptor.bssId[2],
1109 pScanResult->BssDescriptor.bssId[3],
1110 pScanResult->BssDescriptor.bssId[4],
1111 pScanResult->BssDescriptor.bssId[5],
1112 abs(pScanResult->BssDescriptor.rssi));
Jeff Johnson295189b2012-06-20 16:38:30 -07001113
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001114 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1116 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001117 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001118 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1119 "SKIP-currently associated AP\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 continue;
1121 }
1122
Jeff Johnson43971f52012-07-17 12:26:56 -07001123 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1124 * is disabled and we continue to roam without any check*/
1125 if(RoamRssiDiff > 0)
1126 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001127 /*
1128 * If RSSI is lower than the lookup threshold, then continue.
1129 */
1130 if (abs(pScanResult->BssDescriptor.rssi) >
1131 pNeighborRoamInfo->currentNeighborLookupThreshold)
1132 {
1133 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1134 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)\n",
1135 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1136 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1137 continue;
1138 }
1139
Jeff Johnson43971f52012-07-17 12:26:56 -07001140 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1141 {
1142 /*Do not roam to an AP with worse RSSI than the current*/
1143 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1144 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d\n", __func__,
1145 CurrAPRssi,
1146 (int)pScanResult->BssDescriptor.rssi * (-1) );
1147 continue;
1148 } else {
1149 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1150 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1151 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1152 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001153 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1154 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d\n", __func__,
1155 CurrAPRssi,
1156 (int)pScanResult->BssDescriptor.rssi * (-1),
1157 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001158 continue;
1159 }
1160 else {
1161 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1162 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d\n", __func__,
1163 CurrAPRssi,
1164 (int)pScanResult->BssDescriptor.rssi * (-1) );
1165 }
1166 }
1167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001168
1169#ifdef WLAN_FEATURE_VOWIFI_11R
1170 if (pNeighborRoamInfo->is11rAssoc)
1171 {
1172 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1173 {
1174 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1175 continue;
1176 }
1177 }
1178#endif /* WLAN_FEATURE_VOWIFI_11R */
1179
1180#ifdef FEATURE_WLAN_CCX
1181 if (pNeighborRoamInfo->isCCXAssoc)
1182 {
1183 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1184 {
1185 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1186 continue;
1187 }
1188 }
1189 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1190 (pScanResult->BssDescriptor.QBSSLoad_avail))
1191 {
1192 if (pNeighborRoamInfo->isVOAdmitted)
1193 {
1194 smsLog(pMac, LOG1, FL("New AP has %x BW available\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1195 smsLog(pMac, LOG1, FL("We need %x BW available\n"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
1196 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1197 {
1198 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1199 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list\n",
1200 pScanResult->BssDescriptor.bssId[0],
1201 pScanResult->BssDescriptor.bssId[1],
1202 pScanResult->BssDescriptor.bssId[2],
1203 pScanResult->BssDescriptor.bssId[3],
1204 pScanResult->BssDescriptor.bssId[4],
1205 pScanResult->BssDescriptor.bssId[5]);
1206 continue;
1207 }
1208 }
1209 }
1210 else
1211 {
1212 smsLog(pMac, LOGE, FL("No QBss %x %x\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
1213 if (pNeighborRoamInfo->isVOAdmitted)
1214 {
1215 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1216 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no QBSSLoad IE, ignoring..not adding to roam list\n",
1217 pScanResult->BssDescriptor.bssId[0],
1218 pScanResult->BssDescriptor.bssId[1],
1219 pScanResult->BssDescriptor.bssId[2],
1220 pScanResult->BssDescriptor.bssId[3],
1221 pScanResult->BssDescriptor.bssId[4],
1222 pScanResult->BssDescriptor.bssId[5]);
1223 continue;
1224 }
1225 }
1226#endif /* FEATURE_WLAN_CCX */
1227
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001228#ifdef FEATURE_WLAN_LFR
1229 // If we are supporting legacy roaming, and
1230 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301231 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001232 {
1233 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1234 {
1235 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1236 continue;
1237 }
1238 }
1239#endif /* FEATURE_WLAN_LFR */
1240
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1242 * this result */
1243 if (pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1244 {
1245 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1246 continue;
1247 }
1248
1249 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1250 if (NULL == pBssInfo)
1251 {
1252 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1253 continue;
1254 }
1255
1256 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1257 if (pBssInfo->pBssDescription != NULL)
1258 {
1259 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1260 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1261 }
1262 else
1263 {
1264 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1265 vos_mem_free(pBssInfo);
1266 continue;
1267
1268 }
1269 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1270
1271 /* Just add to the end of the list as it is already sorted by RSSI */
1272 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001273
1274#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srikant Kuppa866893f2012-12-27 17:28:14 -08001275 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001276 {
1277 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1278 "%s: [INFOLOG] potential candidate to roam immediately (diff=%d, expected=%d)",
1279 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1280 immediateRoamRssiDiff);
1281 roamNow = eANI_BOOLEAN_TRUE;
1282 }
1283#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 }
1285
1286 /* Now we have all the scan results in our local list. Good time to free up the the list we got as a part of csrGetScanResult */
1287 csrScanResultPurge(pMac, *pScanResultList);
1288
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001289 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001290}
1291
1292/* ---------------------------------------------------------------------------
1293
1294 \fn csrNeighborRoamHandleEmptyScanResult
1295
1296 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1297 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001298 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001300 1. Stop the neighbor scan timer.
1301 2a. If this is the first time we encountered empty scan, then
1302 re-register with TL with modified lookup threshold.
1303 2b. Else if this is the second time we encountered empty scan,
1304 then start neighbor scan results refresh timer (20s).
1305 2c. Else, nothing more to do.
1306 NOTE: In LFR, channels selected for scanning is dervied from
1307 the occuped channel list. Scan cycle following one which
1308 yielded empty results is split into two halves: (i) scan on
1309 channels in the occupied list, and (ii) scan on channels not
1310 in the occupied list. This helps converging faster (while
1311 looking for candidates in the occupied list first), and also,
1312 adds channels to the occupied channel list upon finding candidates
1313 matching SSID profile of interest.
1314
1315 uEmptyScanCount Comments
1316 eFirstEmptyScan Previous scan was done on channels in the
1317 occupied list and yielded potential candidates.
1318 This scan cycle was likely triggered through
1319 receipt of lookup DOWN notification event.
1320 eSecondEmptyScan Previous scan was done on channels in the
1321 occupied list and yielded no candidates. This scan
1322 cycle was triggered through RSSI notification
1323 with modified lookup threshold.
1324 eThirdEmptyScan Previous scan was done on channels NOT in
1325 the occupied list and yielded no candidates. This
1326 scan cycle was triggered immediately after scanning
1327 channels in the occupied list and no candidates
1328 were found.
1329 eFourthEmptyScan Previous scan was done on channels in the
1330 occupied list and yielded no candidates. This scan
1331 cycle was triggered upon expiry of
1332 neighborScanResultsRefreshPeriod (=20s).
1333 eFifthEmptyScan Previous scan was done on channels NOT in
1334 the occupied list and yielded no candidates. This
1335 scan cycle was triggered immediately after scanning
1336 channels in the occupied list and no candidates
1337 were found.
1338
1339 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001340
1341 \param pMac - The handle returned by macOpen.
1342
1343 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1344
1345---------------------------------------------------------------------------*/
1346static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1347{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001348 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1350 eHalStatus status = eHAL_STATUS_SUCCESS;
1351
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001352 /* Stop neighbor scan timer */
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001354 if (eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 {
1356 smsLog(pMac, LOGW, FL(" palTimerStop failed with status %d\n"), status);
1357 }
1358
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001359 /*
1360 * Increase the neighbor lookup threshold by 3 dB
1361 * after every scan cycle. NOTE: uEmptyScanCount
1362 * would be either 1, 3 or 5 at the end of every
1363 * scan cycle.
1364 */
1365#ifdef FEATURE_WLAN_LFR
1366 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1367 {
1368 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1369 }
1370#endif
1371 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1372 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1373#ifdef FEATURE_WLAN_LFR
1374 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1375#endif
1376 )
1377 {
1378 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1379 }
1380
Jeff Johnson295189b2012-06-20 16:38:30 -07001381#ifdef WLAN_FEATURE_VOWIFI_11R
1382 /* Clear off the old neighbor report details */
1383 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1384#endif
1385
Srikant Kuppa866893f2012-12-27 17:28:14 -08001386 /* Transition to CONNECTED state */
1387 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1388
1389 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1390 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1391
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001392#ifdef FEATURE_WLAN_LFR
1393 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1394 {
1395#endif
1396 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001397 /* Re-register neighbor lookup DOWN threshold callback with TL */
1398 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1399 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1400 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1401
1402 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1403 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1404 WLANTL_HO_THRESHOLD_DOWN,
1405 csrNeighborRoamNeighborLookupDOWNCallback,
1406 VOS_MODULE_ID_SME, pMac);
1407
1408 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1409 {
1410 smsLog(pMac, LOGW,
1411 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
1412 " with TL: Status = %d\n"), status);
1413 }
1414#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08001415 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001416 }
1417 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1418 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1419 {
1420 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001421
1422 /* Immediately scan on channels in non-occupied list */
1423 csrNeighborRoamTransitToCFGChanScan(pMac);
1424 }
1425 else if (pNeighborRoamInfo->uEmptyScanCount == eThirdEmptyScan)
1426 {
1427 /* Empty scan results for the third time */
Srikant Kuppa866893f2012-12-27 17:28:14 -08001428
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001429 /* Start neighbor scan results refresh timer */
1430 if (eHAL_STATUS_SUCCESS !=
1431 palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001432 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001433 eANI_BOOLEAN_FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001434 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001435 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1436 status);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001437 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1438 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001439 vosStatus = VOS_STATUS_E_FAILURE;
1440 }
1441 else
1442 {
1443 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1444 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001447
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001448 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d",
1449 pNeighborRoamInfo->uEmptyScanCount);
1450#endif
1451 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001452}
1453
Jeff Johnson295189b2012-06-20 16:38:30 -07001454
Srikant Kuppa866893f2012-12-27 17:28:14 -08001455static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001456{
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 tCsrScanResultFilter scanFilter;
1459 tScanResultHandle scanResult;
1460 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001461 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001462 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001464#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1466 should use the BSSID filter made out of neighbor reports */
1467 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1468 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001469 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1470 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R or CCX Association: Prepare scan filter status with neighbor AP = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 tempVal = 1;
1472 }
1473 else
1474#endif
1475 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001476 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1477 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("11R/CCX/Other Association: Prepare scan to find neighbor AP filter status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001479 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 {
1481 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1482 return eHAL_STATUS_FAILURE;
1483 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001484 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301485 if (hstatus != eHAL_STATUS_SUCCESS)
1486 {
1487 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001490 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001491
1492 /* Free the scan filter */
1493 csrFreeScanFilter(pMac, &scanFilter);
1494
1495 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1496
1497 switch(pNeighborRoamInfo->neighborRoamState)
1498 {
1499 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1500 if (tempVal)
1501 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001502#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001503 /*
1504 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001505 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001506 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001507 pNeighborRoamInfo->uEmptyScanCount = 0;
1508#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001509#ifdef WLAN_FEATURE_VOWIFI_11R
1510 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1511 APs in the roamable AP list */
1512 if (pNeighborRoamInfo->is11rAssoc)
1513 {
1514 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1515 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1516 }
1517 else
1518#endif
1519#ifdef FEATURE_WLAN_CCX
1520 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1521 APs in the roamable AP list */
1522 if (pNeighborRoamInfo->isCCXAssoc)
1523 {
1524 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1525 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1526 }
1527 else
1528#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001529#ifdef FEATURE_WLAN_LFR
1530 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1531 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301532 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001533 {
1534 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1535 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1536 }
1537 else
1538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 {
1540
1541 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1542 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1543 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1544 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1545 within certain duration */
1546
1547// palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
1548 }
1549 }
1550 else
1551 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001552 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1553 /* Handle it appropriately */
1554 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 }
1556 break;
1557#ifdef WLAN_FEATURE_VOWIFI_11R
1558 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1559 if (!tempVal)
1560 {
1561 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1562 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1563 csrNeighborRoamTransitToCFGChanScan(pMac);
1564 }
1565 break;
1566#endif /* WLAN_FEATURE_VOWIFI_11R */
1567 default:
1568 // Can come only in INIT state. Where in we are associated, we sent scan and user
1569 // in the meantime decides to disassoc, we will be in init state and still received call
1570 // back issued. Should not come here in any other state, printing just in case
1571 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1572 "%s: [INFOLOG] State %d\n", __func__, (pNeighborRoamInfo->neighborRoamState));
1573
1574 // Lets just exit out silently.
1575 return eHAL_STATUS_SUCCESS;
1576 }
1577
1578 if (tempVal)
1579 {
1580 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1581
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001582 if (roamNow)
1583 {
1584 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
1585 FL("Immediate roam-deregister UP indication. RSSI = %d"),
1586 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1587
1588 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
1589 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1590 WLANTL_HO_THRESHOLD_UP,
1591 csrNeighborRoamNeighborLookupUPCallback,
1592 VOS_MODULE_ID_SME);
1593
1594 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1595 {
1596 smsLog(pMac, LOGW,
1597 FL("Couldn't deregister lookup UP callback with TL: Status = %d\n"), vosStatus);
1598 }
1599
1600 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
1601 return eHAL_STATUS_SUCCESS;
1602 }
1603
Srikant Kuppa866893f2012-12-27 17:28:14 -08001604 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1605 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1606 eANI_BOOLEAN_FALSE);
1607
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
1609 * that the callback getting called immediately and the timer would never be stopped when pre-auth is in progress */
Srikant Kuppa866893f2012-12-27 17:28:14 -08001610 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08001612 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1614 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001615 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001617
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
1619 /* Register a reassoc Indication callback */
1620 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
1621 WLANTL_HO_THRESHOLD_DOWN,
1622 csrNeighborRoamReassocIndCallback,
1623 VOS_MODULE_ID_SME, pMac);
1624
1625 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1626 {
1627 //err msg
1628 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
1629 }
1630
1631 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08001632
1633 return eHAL_STATUS_SUCCESS;
1634
1635}
1636
1637
1638/* ---------------------------------------------------------------------------
1639
1640 \fn csrNeighborRoamScanRequestCallback
1641
1642 \brief This function is the callback function registered in csrScanRequest() to
1643 indicate the completion of scan. If scan is completed for all the channels in
1644 the channel list, this function gets the scan result and starts the refresh results
1645 timer to avoid having stale results. If scan is not completed on all the channels,
1646 it restarts the neighbor scan timer which on expiry issues scan on the next
1647 channel
1648
1649 \param halHandle - The handle returned by macOpen.
1650 pContext - not used
1651 scanId - not used
1652 status - not used
1653
1654 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1655
1656---------------------------------------------------------------------------*/
1657static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
1658 tANI_U32 scanId, eCsrScanStatus status)
1659{
1660 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1661 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1662 tANI_U8 currentChanIndex;
1663 eHalStatus hstatus;
1664
1665 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1666
1667 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1668 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1669 {
1670 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1671 return eHAL_STATUS_SUCCESS;
1672 }
1673
1674 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
1675 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
1676
1677 /* Validate inputs */
1678 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
1679 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
1680 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
1681 }
1682 else
1683 {
1684 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
1685 return eHAL_STATUS_SUCCESS;
1686 }
1687
1688 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1689 {
1690 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
1691 just to get the results and perform PREAUTH */
1692 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
1693 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
1694 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
1695 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
1696
1697 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1698
1699 if (eHAL_STATUS_SUCCESS != hstatus)
1700 {
1701 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1702 return eHAL_STATUS_FAILURE;
1703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 }
1705 else
1706 {
1707
1708 /* Restart the timer for the next scan sequence as scanning is not over */
Jeff Johnson43971f52012-07-17 12:26:56 -07001709 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
1711 eANI_BOOLEAN_FALSE);
1712
Jeff Johnson43971f52012-07-17 12:26:56 -07001713 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 {
1715 /* Timer start failed.. Should we ASSERT here??? */
1716 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
1717 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1718 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001719 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 }
1721 }
1722 return eHAL_STATUS_SUCCESS;
1723}
1724
Srikant Kuppa866893f2012-12-27 17:28:14 -08001725#ifdef FEATURE_WLAN_LFR
1726static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
1727 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
1728{
1729 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1730 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1731 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
1732
1733 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1734
1735 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1736 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1737 {
1738 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1739 return eHAL_STATUS_SUCCESS;
1740 }
1741
1742 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
1743 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1744
1745 if (eHAL_STATUS_SUCCESS != hstatus)
1746 {
1747 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1748 }
1749
1750 return hstatus;
1751}
1752#endif
1753
Jeff Johnson295189b2012-06-20 16:38:30 -07001754/* ---------------------------------------------------------------------------
1755
1756 \fn csrNeighborRoamIssueBgScanRequest
1757
1758 \brief This function issues CSR scan request after populating all the BG scan params
1759 passed
1760
1761 \param pMac - The handle returned by macOpen.
1762 pBgScanParams - Params that need to be populated into csr Scan request
1763
1764 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1765
1766---------------------------------------------------------------------------*/
Srikant Kuppa866893f2012-12-27 17:28:14 -08001767eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
1768 tCsrBGScanRequest *pBgScanParams,
1769 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07001770{
1771 eHalStatus status = eHAL_STATUS_SUCCESS;
1772 tANI_U32 scanId;
1773 tCsrScanRequest scanReq;
1774 tANI_U8 channel;
1775
Srikant Kuppa866893f2012-12-27 17:28:14 -08001776 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1777 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
1778 pBgScanParams->ChannelInfo.ChannelList[0],
1779 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001780
1781 //send down the scan req for 1 channel on the associated SSID
1782 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
1783 /* Fill in the SSID Info */
1784 scanReq.SSIDs.numOfSSIDs = 1;
1785 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1786 if(NULL == scanReq.SSIDs.SSIDList)
1787 {
1788 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301789 smsLog(pMac, LOGE, FL("Couldn't allocate memory for the SSID..Freeing memory allocated for Channel List\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 return eHAL_STATUS_FAILURE;
1791 }
1792 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1793
1794 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
1795 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
1796 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
1797
1798 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001799 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1800 {
1801 channel = pBgScanParams->ChannelInfo.ChannelList[0];
1802 scanReq.ChannelInfo.ChannelList = &channel;
1803 }
1804 else
1805 {
1806 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
1807 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001808
1809 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
1810 scanReq.scanType = eSIR_ACTIVE_SCAN;
1811 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
1812 scanReq.maxChnTime = pBgScanParams->maxChnTime;
1813 scanReq.minChnTime = pBgScanParams->minChnTime;
1814 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Srikant Kuppa866893f2012-12-27 17:28:14 -08001815 &scanId, callbackfn, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 if (eHAL_STATUS_SUCCESS != status)
1817 {
1818 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
1819 vos_mem_free(scanReq.SSIDs.SSIDList);
1820 return status;
1821 }
1822 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
1823
1824 vos_mem_free(scanReq.SSIDs.SSIDList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001825 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1826 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
1827 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
1828 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
1829
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 return status;
1831}
1832
Srikant Kuppa866893f2012-12-27 17:28:14 -08001833static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
1834 tpCsrBGScanRequest bgScanParams)
1835{
1836 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1837 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1838
1839 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
1840 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
1841 vos_mem_copy(bgScanParams->SSID.ssId,
1842 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
1843 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
1844
1845 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
1846 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
1847}
1848
Jeff Johnson295189b2012-06-20 16:38:30 -07001849/* ---------------------------------------------------------------------------
1850
1851 \fn csrNeighborRoamPerformBgScan
1852
1853 \brief This function is invoked on every expiry of neighborScanTimer till all
1854 the channels in the channel list are scanned. It populates necessary
1855 parameters for BG scan and calls appropriate AP to invoke the CSR scan
1856 request
1857
1858 \param pMac - The handle returned by macOpen.
1859
1860 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1861
1862---------------------------------------------------------------------------*/
1863eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac)
1864{
1865 eHalStatus status = eHAL_STATUS_SUCCESS;
1866 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1867 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 tANI_U8 channel = 0;
1869
1870 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1871 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301872 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 }
1874 else
1875 {
1876 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson902c9832012-12-10 14:28:09 -08001877 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 // When timer start is declared a failure, then we delete the list.
1879 // Should not happen now as we stop and then only start the scan timer.
1880 // still handle the unlikely case.
1881 csrNeighborRoamHandleEmptyScanResult(pMac);
1882 return status;
1883 }
1884 /* Need to perform scan here before getting the list */
Srikant Kuppa866893f2012-12-27 17:28:14 -08001885
1886 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07001887
1888 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
1889 bgScanParams.ChannelInfo.numOfChannels = 1;
1890 bgScanParams.ChannelInfo.ChannelList = &channel;
1891
Srikant Kuppa866893f2012-12-27 17:28:14 -08001892 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001893
Srikant Kuppa866893f2012-12-27 17:28:14 -08001894 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
1895 csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 if (eHAL_STATUS_SUCCESS != status)
1897 {
1898 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 }
1900
1901 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
1902 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
1903 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
1904 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301905 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
1907 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
1908 /* We have completed scanning all the channels */
1909 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
1910 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
1911 and select the best AP in the list */
1912 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1913 {
1914 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
1915 }
1916 }
1917
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08001918 if (eHAL_STATUS_SUCCESS != status)
1919 {
1920 /*
1921 * If the status is not success, we need to call the callback
1922 * routine so that the state machine does not get stuck.
1923 */
1924 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
1925 }
1926
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 return status;
1928}
1929
Srikant Kuppa866893f2012-12-27 17:28:14 -08001930#ifdef FEATURE_WLAN_LFR
1931eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac)
1932{
1933 eHalStatus status = eHAL_STATUS_SUCCESS;
1934 tCsrBGScanRequest bgScanParams;
1935 int numOfChannels = 0, i = 0;
1936 tANI_U8 *channelList = NULL;
1937
1938 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
1939
1940 /* Contiguously scan all channels from valid list */
1941 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
1942 numOfChannels = sizeof(pMac->roam.validChannelList);
1943
1944 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
1945 (tANI_U8 *)pMac->roam.validChannelList,
1946 (tANI_U32 *) &numOfChannels)))
1947 {
1948 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
1949 return eHAL_STATUS_FAILURE;
1950 }
1951
1952 channelList = vos_mem_malloc( numOfChannels );
1953 if( NULL == channelList )
1954 {
1955 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
1956 return eHAL_STATUS_FAILURE;
1957 }
1958 vos_mem_copy(channelList, (tANI_U8 *)pMac->roam.validChannelList,
1959 numOfChannels * sizeof(tANI_U8));
1960
1961 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
1962 bgScanParams.ChannelInfo.ChannelList = channelList;
1963 for (i = 0; i < numOfChannels; i++)
1964 {
1965 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d\n",
1966 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
1967 }
1968 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
1969
1970 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
1971 csrNeighborRoamContiguousScanRequestCallback);
1972
1973 vos_mem_free( channelList );
1974
1975 if (eHAL_STATUS_SUCCESS != status)
1976 {
1977 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
1978 }
1979
1980 return status;
1981}
1982#endif
1983
Jeff Johnson295189b2012-06-20 16:38:30 -07001984/* ---------------------------------------------------------------------------
1985
1986 \fn csrNeighborRoamNeighborScanTimerCallback
1987
1988 \brief This function is the neighbor scan timer callback function. It invokes
1989 the BG scan request based on the current and previous states
1990
1991 \param pv - CSR timer context info which includes pMac and session ID
1992
1993 \return VOID
1994
1995---------------------------------------------------------------------------*/
1996void csrNeighborRoamNeighborScanTimerCallback(void *pv)
1997{
1998 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
1999 tpAniSirGlobal pMac = pInfo->pMac;
2000 tANI_U32 sessionId = pInfo->sessionId;
2001 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2002
2003 // check if bg scan is on going, no need to send down the new params if true
2004 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2005 {
2006 //msg
2007 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending\n"));
2008 return;
2009 }
2010
2011 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
2012
2013 switch (pNeighborRoamInfo->neighborRoamState)
2014 {
2015#ifdef WLAN_FEATURE_VOWIFI_11R
2016 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2017 switch(pNeighborRoamInfo->prevNeighborRoamState)
2018 {
2019 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2020 csrNeighborRoamPerformBgScan(pMac);
2021 break;
2022 default:
2023 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
2024 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
2025 break;
2026 }
2027 break;
2028#endif /* WLAN_FEATURE_VOWIFI_11R */
2029 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
2030 csrNeighborRoamPerformBgScan(pMac);
2031 break;
2032 default:
2033 break;
2034 }
2035 return;
2036}
2037
2038/* ---------------------------------------------------------------------------
2039
2040 \fn csrNeighborRoamResultsRefreshTimerCallback
2041
2042 \brief This function is the timer callback function for results refresh timer.
2043 When this is invoked, it is as good as down event received from TL. So,
2044 clear off the roamable AP list and start the scan procedure based on 11R
2045 or non-11R association
2046
2047 \param context - CSR timer context info which includes pMac and session ID
2048
2049 \return VOID
2050
2051---------------------------------------------------------------------------*/
2052void csrNeighborRoamResultsRefreshTimerCallback(void *context)
2053{
2054 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2055 tpAniSirGlobal pMac = pInfo->pMac;
2056 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2057 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2058
2059 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2060
2061 /* Deregister reassoc callback. Ignore return status */
2062 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2063 WLANTL_HO_THRESHOLD_DOWN,
2064 csrNeighborRoamReassocIndCallback,
2065 VOS_MODULE_ID_SME);
2066
2067 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2068 {
2069 //err msg
2070 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
2071 }
2072
2073 /* Reset all the variables just as no scan had happened before */
2074 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2075
2076#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2077 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2078 {
2079 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2080 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2081 if (VOS_STATUS_SUCCESS != vosStatus)
2082 {
2083 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2084 return;
2085 }
2086 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2087 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2088 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2089 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2090 }
2091 else
2092#endif
2093 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002094 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2096 if (VOS_STATUS_SUCCESS != vosStatus)
2097 {
2098 return;
2099 }
2100 }
2101 return;
2102}
2103
2104#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2105/* ---------------------------------------------------------------------------
2106
2107 \fn csrNeighborRoamIssueNeighborRptRequest
2108
2109 \brief This function is invoked when TL issues a down event and the current assoc
2110 is a 11R association. It invokes SME RRM API to issue the neighbor request to
2111 the currently associated AP with the current SSID
2112
2113 \param pMac - The handle returned by macOpen.
2114
2115 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2116
2117---------------------------------------------------------------------------*/
2118VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
2119{
2120 tRrmNeighborRspCallbackInfo callbackInfo;
2121 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2122 tRrmNeighborReq neighborReq;
2123
2124
2125 neighborReq.no_ssid = 0;
2126
2127 /* Fill in the SSID */
2128 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2129 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2130 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2131
2132 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
2133 callbackInfo.neighborRspCallbackContext = pMac;
2134 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
2135
2136 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
2137}
2138
2139/* ---------------------------------------------------------------------------
2140
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002141 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002142
2143 \brief This function is used to merge two channel list.
2144 NB: If called with outputNumOfChannels == 0, this routines
2145 simply copies the input channel list to the output channel list.
2146
2147 \param pMac - The handle returned by macOpen.
2148 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
2149 \param inputNumOfChannels - The number of additional channels.
2150 \param pOutputChannelList - The place to put the "merged" channel list.
2151 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
2152 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
2153
2154 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2155
2156---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002157VOS_STATUS csrNeighborRoamMergeChannelLists(
2158 tpAniSirGlobal pMac,
2159 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002160 int inputNumOfChannels,
2161 tANI_U8 *pOutputChannelList,
2162 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002163 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002164 )
2165{
2166 int i = 0;
2167 int j = 0;
2168 int numChannels = outputNumOfChannels;
2169
2170 // Check for NULL pointer
2171 if (!pInputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2172
2173 // Check for NULL pointer
2174 if (!pOutputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2175
2176 // Add the "new" channels in the input list to the end of the output list.
2177 for (i = 0; i < inputNumOfChannels; i++)
2178 {
2179 for (j = 0; j < outputNumOfChannels; j++)
2180 {
2181 if (pInputChannelList[i] == pOutputChannelList[j])
2182 break;
2183 }
2184 if (j == outputNumOfChannels)
2185 {
2186 if (pInputChannelList[i])
2187 {
Madan Mohan Koyyalamudif5c368b2012-12-06 13:10:13 -08002188 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002189 "%s: [INFOLOG] Adding extra %d to Neighbor channel list\n", __func__,
2190 pInputChannelList[i]);
2191 pOutputChannelList[numChannels] = pInputChannelList[i];
2192 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002193 }
2194 }
2195 }
2196
2197 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002198 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002199
2200 return eHAL_STATUS_SUCCESS;
2201}
2202
2203/* ---------------------------------------------------------------------------
2204
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 \fn csrNeighborRoamCreateChanListFromNeighborReport
2206
2207 \brief This function is invoked when neighbor report is received for the
2208 neighbor request. Based on the channels present in the neighbor report,
2209 it generates channel list which will be used in REPORT_SCAN state to
2210 scan for these neighbor APs
2211
2212 \param pMac - The handle returned by macOpen.
2213
2214 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2215
2216---------------------------------------------------------------------------*/
2217VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2218{
2219 tpRrmNeighborReportDesc pNeighborBssDesc;
2220 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002221 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002223#if 0
2224 eHalStatus status = eHAL_STATUS_SUCCESS;
2225#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002226
2227 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2228 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2229
2230 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2231
2232 while (pNeighborBssDesc)
2233 {
2234 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2235
2236 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2237 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2238 pNeighborBssDesc->pNeighborBssDescription->channel;
2239 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2240 (tANI_U8)pNeighborBssDesc->roamScore;
2241 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2242 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2243 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2244
2245 /* Saving the channel list non-redundantly */
2246 if (numChannels > 0)
2247 {
2248 for (i = 0; i < numChannels; i++)
2249 {
2250 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2251 break;
2252 }
2253
2254 }
2255 if (i == numChannels)
2256 {
2257 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2258 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2260 "%s: [INFOLOG] Adding %d to Neighbor channel list\n", __func__,
2261 pNeighborBssDesc->pNeighborBssDescription->channel);
2262 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2263 numChannels++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 }
2265 }
2266
2267 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2268 }
2269
2270 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2271 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002272#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002274 // we have a union of the IAPP and the already existing list.
2275 status = csrNeighborRoamMergeChannelLists(
2276 pMac,
2277 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2278 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2279 channelList,
2280 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002281 &numChannels );
2282#endif
2283
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2285 }
2286
2287 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2288 /* Store the obtained channel list to the Neighbor Control data structure */
2289 if (numChannels)
2290 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2291 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2292 {
2293 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2294 return VOS_STATUS_E_RESOURCES;
2295 }
2296
2297 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2298 channelList, (numChannels) * sizeof(tANI_U8));
2299 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2300 if (numChannels)
2301 {
2302 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
2303 pNeighborRoamInfo->neighborRoamState);
2304 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
2305 }
2306 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2307 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
2308
2309 return VOS_STATUS_SUCCESS;
2310}
2311
2312/* ---------------------------------------------------------------------------
2313
2314 \fn csrNeighborRoamRRMNeighborReportResult
2315
2316 \brief This function is the neighbor report callback that will be invoked by
2317 SME RRM on receiving a neighbor report or of neighbor report is not
2318 received after timeout. On receiving a valid report, it generates a
2319 channel list from the neighbor report and starts the
2320 neighbor scan timer
2321
2322 \param context - The handle returned by macOpen.
2323 vosStatus - Status of the callback(SUCCESS/FAILURE)
2324
2325 \return VOID
2326
2327---------------------------------------------------------------------------*/
2328void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
2329{
2330 tpAniSirGlobal pMac = PMAC_STRUCT(context);
2331 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2332 eHalStatus status = eHAL_STATUS_SUCCESS;
2333
2334 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d\n"), vosStatus);
2335 switch (pNeighborRoamInfo->neighborRoamState)
2336 {
2337 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2338 /* Reset the report pending variable */
2339 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
2340 if (VOS_STATUS_SUCCESS == vosStatus)
2341 {
2342 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
2343 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
2344 if (VOS_STATUS_SUCCESS == vosStatus)
2345 {
2346 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state\n"));
2347 }
2348
2349 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2350 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2351
2352 /* Now ready for neighbor scan based on the channel list created */
2353 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2354 what palTimerStart expects */
2355 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2356 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2357 eANI_BOOLEAN_FALSE);
2358 if (eHAL_STATUS_SUCCESS != status)
2359 {
2360 /* Timer start failed.. Should we ASSERT here??? */
2361 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
2362 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2363 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2364 return;
2365 }
2366 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2367 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
2368 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2369 }
2370 else
2371 {
2372 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
2373 reach the maxNeighborRetries or receiving a successful neighbor response */
2374 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d\n"),
2375 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
2376 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
2377 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
2378 {
2379 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. \n"));
2380 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2381 if (VOS_STATUS_SUCCESS != vosStatus)
2382 {
2383 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d \n"), vosStatus);
2384 return;
2385 }
2386 /* We transitioned to different state now. Reset the Neighbor report retry count */
2387 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2388 }
2389 else
2390 {
2391 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2392 if (VOS_STATUS_SUCCESS != vosStatus)
2393 {
2394 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2395 return;
2396 }
2397 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2398 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2399 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2400 }
2401 }
2402 break;
2403 default:
2404 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
2405 break;
2406 }
2407 return;
2408}
2409#endif /* WLAN_FEATURE_VOWIFI_11R */
2410
2411
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002412#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002413tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002414 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002415 tCsrRoamConnectedProfile *pCurProfile,
2416 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002417 tDot11fBeaconIEs *pIes)
2418{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002419 tCsrAuthList authType;
2420 tCsrEncryptionList uCEncryptionType;
2421 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002422 tANI_BOOLEAN fMatch = FALSE;
2423
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002424 authType.numEntries = 1;
2425 authType.authType[0] = pCurProfile->AuthType;
2426 uCEncryptionType.numEntries = 1;
2427 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
2428 mCEncryptionType.numEntries = 1;
2429 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002430
2431 if( pIes )
2432 {
2433 if(pIes->SSID.present)
2434 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002435 fMatch = csrIsSsidMatch( pMac,
2436 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
2437 pIes->SSID.ssid, pIes->SSID.num_ssid,
2438 eANI_BOOLEAN_TRUE );
2439 if(TRUE == fMatch)
2440 {
2441 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
2442 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
2443 return (fMatch);
2444 }
2445 else
2446 {
2447 return (fMatch);
2448 }
2449
2450 }
2451 else
2452 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002453 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002454 }
2455 }
2456 else
2457 {
2458 return FALSE; // Again, treat missing pIes as a non-match.
2459 }
2460}
2461
2462tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
2463 tpAniSirGlobal pMac)
2464{
2465 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2466 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2467 tCsrRoamConnectedProfile *pCurrProfile = NULL;
2468 tCsrRoamConnectedProfile *pPrevProfile = NULL;
2469 tDot11fBeaconIEs *pIes = NULL;
2470 tSirBssDescription *pBssDesc = NULL;
2471 tANI_BOOLEAN fNew = TRUE;
2472
2473 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
2474 {
2475 return (fNew);
2476 }
2477
2478 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2479 if( !pCurrProfile )
2480 {
2481 return (fNew);
2482}
2483
2484 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
2485 if( !pPrevProfile )
2486 {
2487 return (fNew);
2488 }
2489
2490 pBssDesc = pPrevProfile->pBssDesc;
2491 if (pBssDesc)
2492 {
2493 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
2494 pBssDesc, &pIes)) &&
2495 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
2496 {
2497 fNew = FALSE;
2498 }
2499 if (pIes) {
2500 palFreeMemory(pMac->hHdd, pIes);
2501 }
2502 }
2503
2504 if (fNew)
2505 {
2506 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
2507 csrRoamFreeConnectProfile(pMac, pPrevProfile);
2508 csrRoamGetConnectProfile(pMac, sessionId, pPrevProfile);
2509 }
2510 else
2511 {
2512 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
2513 }
2514
2515 return (fNew);
2516}
2517
2518tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
2519 tpAniSirGlobal pMac,
2520 tCsrScanResult *pResult,
2521 tDot11fBeaconIEs *pIes)
2522{
2523 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2524 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2525 tCsrRoamConnectedProfile *pCurProfile = NULL;
2526 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
2527
2528 if( !(pMac->roam.roamSession
2529 && CSR_IS_SESSION_VALID(pMac, sessionId)))
2530 {
2531 return FALSE;
2532 }
2533
2534 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2535
2536 if( !pCurProfile)
2537 {
2538 return FALSE;
2539 }
2540
2541 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002542}
2543
2544/* ---------------------------------------------------------------------------
2545
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002546 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002547
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002548 \brief This function is used to prepare a channel list that is derived from
2549 the list of valid channels and does not include those in the occupied
2550 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002551
2552 \param pMac - The handle returned by macOpen.
2553 \param pInputChannelList - The default channels list.
2554 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002555 \param pOutputChannelList - The place to put the non-occupied channel list.
2556 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002557
2558 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2559
2560---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002561VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002562 tpAniSirGlobal pMac,
2563 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002564 int numOfChannels,
2565 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002566 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002567 )
2568{
2569 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002570 int outputNumOfChannels = 0; // Clear the output number of channels
2571 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
2572 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
2573
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002574 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002575 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002576 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
2577 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002578 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002579 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002580 }
2581 }
2582
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002583 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
2584 "Number of channels in the non-occupied list list=%d"),
2585 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002586
2587 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002588 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002589
2590 return eHAL_STATUS_SUCCESS;
2591}
2592#endif /* FEATURE_WLAN_LFR */
2593
Jeff Johnson295189b2012-06-20 16:38:30 -07002594/* ---------------------------------------------------------------------------
2595
2596 \fn csrNeighborRoamTransitToCFGChanScan
2597
2598 \brief This function is called whenever there is a transition to CFG chan scan
2599 state from any state. It frees up the current channel list and allocates
2600 a new memory for the channels received from CFG item. It then starts the
2601 neighbor scan timer to perform the scan on each channel one by one
2602
2603 \param pMac - The handle returned by macOpen.
2604
2605 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2606
2607---------------------------------------------------------------------------*/
2608VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
2609{
2610 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2611 eHalStatus status = eHAL_STATUS_SUCCESS;
2612 int i = 0;
2613 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002614 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002615 tpCsrChannelInfo currChannelListInfo;
2616
2617 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002618
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002619 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07002620#ifdef FEATURE_WLAN_CCX
2621 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002622 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
2624#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002625 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002627 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002628
2629
2630 /* Free up the channel list and allocate a new memory. This is because we dont know how much
2631 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
2632 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002633 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002635 vos_mem_free(currChannelListInfo->ChannelList);
2636 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002638
2639 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
2640 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
2641 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002643 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
2644 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002645 status = csrNeighborRoamMergeChannelLists(
2646 pMac,
2647 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
2648 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
2649 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002650 0, //NB: If 0, simply copy the input channel list to the output list.
2651 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002652
2653 currChannelListInfo->ChannelList =
2654 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2655 if (NULL == currChannelListInfo->ChannelList)
2656 {
2657 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2658 return VOS_STATUS_E_RESOURCES;
2659 }
2660
2661 vos_mem_copy(currChannelListInfo->ChannelList,
2662 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002663 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002664#ifdef FEATURE_WLAN_LFR
2665 else if (abs(pNeighborRoamInfo->lookupDOWNRssi) >
2666 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold))
2667 {
2668 /*
2669 * Trigger a contiguous scan on all channels when the
2670 * RSSI in the lookup DOWN notification is below reassoc
2671 * threshold. This will help us find the best available
2672 * candidate and also update the channel cache.
2673 */
2674 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
2675 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
2676 pNeighborRoamInfo->lookupDOWNRssi,
2677 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
2678
2679 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2680
2681 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2682
2683 /* We are about to start a fresh scan cycle,
2684 * purge non-P2P results from the past */
2685 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
2686
2687 csrNeighborRoamPerformContiguousBgScan(pMac);
2688
2689 /* Transition to CFG_CHAN_LIST_SCAN */
2690 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
2691
2692 return VOS_STATUS_SUCCESS;
2693 }
2694#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002695 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002696 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002697 numOfChannels = pMac->scan.occupiedChannels.numChannels;
2698 if (numOfChannels
2699#ifdef FEATURE_WLAN_LFR
2700 && ((pNeighborRoamInfo->uEmptyScanCount == 0) ||
2701 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
2702#endif
2703 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002705 /*
2706 * Always scan channels in the occupied channel list
2707 * before scanning on the non-occupied list.
2708 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302709 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to occupied channel list");
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002710 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
2711 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels);
2712
2713 if (NULL == currChannelListInfo->ChannelList)
2714 {
2715 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2716 return VOS_STATUS_E_RESOURCES;
2717 }
2718 vos_mem_copy(currChannelListInfo->ChannelList,
2719 pMac->scan.occupiedChannels.channelList,
2720 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002721 }
2722 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002723 {
2724 /* Scan all channels from non-occupied list */
2725 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
2726 numOfChannels = sizeof(pMac->roam.validChannelList);
2727
2728 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2729 (tANI_U8 *)pMac->roam.validChannelList,
2730 (tANI_U32 *) &numOfChannels)))
2731 {
2732#ifdef FEATURE_WLAN_LFR
2733 /*
2734 * Prepare non-occupied channel list (channelList)
2735 * from the actual "valid channel list" information
2736 * formed by CSR.
2737 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302738 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
2739 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
2740 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002741 numOfChannels,
2742 channelList,
2743 &numOfChannels);
2744#else
2745 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
2746 status = csrNeighborRoamMergeChannelLists(
2747 pMac,
2748 (tANI_U8 *)pMac->roam.validChannelList,
2749 numOfChannels, // The number of channels in the validChannelList
2750 channelList,
2751 0, //NB: If 0, simply copy the input channel list to the output list.
2752 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
2753#endif
2754 }
2755 else
2756 {
2757 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002758 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002760 currChannelListInfo->ChannelList =
2761 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2762
2763 if (NULL == currChannelListInfo->ChannelList)
2764 {
2765 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2766 return VOS_STATUS_E_RESOURCES;
2767 }
2768#ifdef FEATURE_WLAN_LFR
2769 vos_mem_copy(currChannelListInfo->ChannelList,
2770 channelList, numOfChannels * sizeof(tANI_U8));
2771#else
2772 vos_mem_copy(currChannelListInfo->ChannelList,
2773 (tANI_U8 *)pMac->roam.validChannelList,
2774 numOfChannels * sizeof(tANI_U8));
2775#endif
2776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 }
2778
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002779 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002780 currChannelListInfo->numOfChannels = numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002781 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
2782 "Number of channels from CFG (or) (non-)occupied list=%d",
2783 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002784 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302786 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002787 "= %d\n", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 }
2789 }
2790
2791 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2792 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2793
2794 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2795 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2796 what palTimerStart expects */
2797 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2798 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2799 eANI_BOOLEAN_FALSE);
2800
2801 if (eHAL_STATUS_SUCCESS != status)
2802 {
2803 /* Timer start failed.. */
2804 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002805 vos_mem_free(currChannelListInfo->ChannelList);
2806 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 return VOS_STATUS_E_FAILURE;
2808 }
2809
2810 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2811 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302812 /* We are about to start a fresh scan cycle,
2813 * purge non-P2P results from the past */
2814 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002815
2816 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
2817 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
2818
2819 return VOS_STATUS_SUCCESS;
2820}
2821
2822/* ---------------------------------------------------------------------------
2823
2824 \fn csrNeighborRoamNeighborLookupUpEvent
2825
2826 \brief This function is called as soon as TL indicates that the current AP's
2827 RSSI is better than the neighbor lookup threshold. Here, we transition to
2828 CONNECTED state and reset all the scan parameters
2829
2830 \param pMac - The handle returned by macOpen.
2831
2832 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2833
2834---------------------------------------------------------------------------*/
2835VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
2836{
2837 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2838 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002839 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002840
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 /* Recheck whether the below check is needed. */
2842 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
2843 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Jeff Johnsone7245742012-09-05 17:12:55 -07002844
2845 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
2846 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2847
Jeff Johnson295189b2012-06-20 16:38:30 -07002848
2849 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2850 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
2851 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2852 WLANTL_HO_THRESHOLD_DOWN,
2853 csrNeighborRoamNeighborLookupDOWNCallback,
2854 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002855#ifdef FEATURE_WLAN_LFR
2856 pNeighborRoamInfo->lookupDOWNRssi = 0;
2857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2859 {
2860 //err msg
2861 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d\n"), vosStatus);
2862 }
2863
2864
2865 return vosStatus;
2866}
2867
2868/* ---------------------------------------------------------------------------
2869
2870 \fn csrNeighborRoamNeighborLookupDownEvent
2871
2872 \brief This function is called as soon as TL indicates that the current AP's
2873 RSSI falls below the current eighbor lookup threshold. Here, we transition to
2874 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
2875 a non-11R association.
2876
2877 \param pMac - The handle returned by macOpen.
2878
2879 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2880
2881---------------------------------------------------------------------------*/
2882VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
2883{
2884 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2885 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2886 eHalStatus status = eHAL_STATUS_SUCCESS;
2887
2888 switch (pNeighborRoamInfo->neighborRoamState)
2889 {
2890 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
2891
2892 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
2893 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2894 /* De-register Neighbor Lookup threshold callback with TL */
2895 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2896 WLANTL_HO_THRESHOLD_DOWN,
2897 csrNeighborRoamNeighborLookupDOWNCallback,
2898 VOS_MODULE_ID_SME);
2899
2900 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2901 {
2902 //err msg
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002903 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 }
2905
2906
2907#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2908 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2909 {
2910
2911 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2912 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2913 if (VOS_STATUS_SUCCESS != vosStatus)
2914 {
2915 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2916 return vosStatus;
2917 }
2918 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2919 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2920 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2921 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2922 }
2923 else
2924#endif
2925 {
2926 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
2927
2928 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2929 if (VOS_STATUS_SUCCESS != vosStatus)
2930 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002931 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
2932 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002933 return vosStatus;
2934 }
2935 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002936 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering UP event neighbor lookup callback with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002938 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
2939 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 WLANTL_HO_THRESHOLD_UP,
2941 csrNeighborRoamNeighborLookupUPCallback,
2942 VOS_MODULE_ID_SME, pMac);
2943 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2944 {
2945 //err msg
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002946 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 }
2948 break;
2949 default:
2950 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
2951 break;
2952
2953 }
2954 return vosStatus;
2955}
2956
2957/* ---------------------------------------------------------------------------
2958
2959 \fn csrNeighborRoamNeighborLookupUPCallback
2960
2961 \brief This function is registered with TL to indicate whenever the RSSI
2962 gets better than the neighborLookup RSSI Threshold
2963
2964 \param pAdapter - VOS Context
2965 trafficStatus - UP/DOWN indication from TL
2966 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
2967
2968 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2969
2970---------------------------------------------------------------------------*/
2971VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08002972 v_PVOID_t pUserCtxt,
2973 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07002974{
2975 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
2976 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2977 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
2978
Srinivasdaaec712012-12-12 15:59:44 -08002979 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
2980 rssiNotification,
2981 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07002982
2983 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
2984 {
2985 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
2986 return VOS_STATUS_SUCCESS;
2987 }
2988
2989 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
2990 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
2991 return vosStatus;
2992}
2993
2994/* ---------------------------------------------------------------------------
2995
2996 \fn csrNeighborRoamNeighborLookupDOWNCallback
2997
2998 \brief This function is registered with TL to indicate whenever the RSSI
2999 falls below the current neighborLookup RSSI Threshold
3000
3001 \param pAdapter - VOS Context
3002 trafficStatus - UP/DOWN indication from TL
3003 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3004
3005 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3006
3007---------------------------------------------------------------------------*/
3008VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003009 v_PVOID_t pUserCtxt,
3010 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003011{
3012 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3013 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3014 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3015
Srinivasdaaec712012-12-12 15:59:44 -08003016 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
3017 rssiNotification,
3018 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003019
Srikant Kuppa866893f2012-12-27 17:28:14 -08003020#ifdef FEATURE_WLAN_LFR
3021 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
3022#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3024 {
3025 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
3026 return VOS_STATUS_SUCCESS;
3027 }
3028
3029 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
3030 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
3031
3032 return vosStatus;
3033}
3034
3035#ifdef RSSI_HACK
3036extern int dumpCmdRSSI;
3037#endif
3038
3039/* ---------------------------------------------------------------------------
3040
3041 \fn csrNeighborRoamIndicateDisconnect
3042
3043 \brief This function is called by CSR as soon as the station disconnects from
3044 the AP. This function does the necessary cleanup of neighbor roam data
3045 structures. Neighbor roam state transitions to INIT state whenever this
3046 function is called except if the current state is REASSOCIATING
3047
3048 \param pMac - The handle returned by macOpen.
3049 sessionId - CSR session id that got disconnected
3050
3051 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3052
3053---------------------------------------------------------------------------*/
3054eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
3055{
3056 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3057
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003058 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d (sub-state %d)"),
3059 sessionId, pNeighborRoamInfo->neighborRoamState,
3060 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003061
3062#ifdef FEATURE_WLAN_CCX
3063 {
3064 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
3065 if (pSession->connectedProfile.isCCXAssoc)
3066 {
3067 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
3068 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3069 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
3070 pSession->isPrevApInfoValid = TRUE;
3071 pSession->roamTS1 = vos_timer_get_system_time();
3072
3073 }
3074 }
3075#endif
3076
3077#ifdef RSSI_HACK
3078 dumpCmdRSSI = -40;
3079#endif
3080 switch (pNeighborRoamInfo->neighborRoamState)
3081 {
3082 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3083 // Stop scan and neighbor refresh timers.
3084 // These are indeed not required when we are in reassociating
3085 // state.
3086 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3087 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003088 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
3089 /*
3090 * Disconnect indication during Disassoc Handoff sub-state
3091 * is received when we are trying to disconnect with the old
3092 * AP during roam. BUT, if receive a disconnect indication
3093 * outside of Disassoc Handoff sub-state, then it means that
3094 * this is a genuine disconnect and we need to clean up.
3095 * Otherwise, we will be stuck in reassoc state which will
3096 * in-turn block scans (see csrIsScanAllowed).
3097 */
3098 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 break;
3101
3102 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 csrNeighborRoamResetInitStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003104 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 break;
3106
Srikant Kuppa866893f2012-12-27 17:28:14 -08003107 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3108 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3109 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3110 csrNeighborRoamDeregAllRssiIndication(pMac);
3111 break;
3112
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003113 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
3114 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3115 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
3116 csrNeighborRoamDeregAllRssiIndication(pMac);
3117 break;
3118
3119 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3120 /* Stop pre-auth to reassoc interval timer */
3121 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003122 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3123 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3124 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003125 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003126 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003127 csrNeighborRoamDeregAllRssiIndication(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003128 break;
3129
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003131 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
3132 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003134 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 }
3136 return eHAL_STATUS_SUCCESS;
3137}
3138
3139/* ---------------------------------------------------------------------------
3140
3141 \fn csrNeighborRoamIndicateConnect
3142
3143 \brief This function is called by CSR as soon as the station connects to an AP.
3144 This initializes all the necessary data structures related to the
3145 associated AP and transitions the state to CONNECTED state
3146
3147 \param pMac - The handle returned by macOpen.
3148 sessionId - CSR session id that got connected
3149 vosStatus - connect status SUCCESS/FAILURE
3150
3151 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3152
3153---------------------------------------------------------------------------*/
3154eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
3155{
3156 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3157 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07003158 VOS_STATUS vstatus;
3159
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003160#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 int init_ft_flag = FALSE;
3162#endif
3163
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003164 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003165
3166 switch (pNeighborRoamInfo->neighborRoamState)
3167 {
3168 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3169 if (VOS_STATUS_SUCCESS != vosStatus)
3170 {
3171 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
3172 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3173 break;
3174 }
3175 /* Fall through if the status is SUCCESS */
3176 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
3177 /* Reset all the data structures here */
3178 csrNeighborRoamResetInitStateControlInfo(pMac);
3179
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003181
3182#ifdef FEATURE_WLAN_LFR
3183 /*
3184 * Initialize the occupied list ONLY if we are
3185 * transitioning from INIT state to CONNECTED state.
3186 */
3187 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
3188 csrInitOccupiedChannelsList(pMac);
3189#endif
3190 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
3191
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
3193 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
3194 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
3195 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3196 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003197 pNeighborRoamInfo->currentNeighborLookupThreshold =
3198 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
3199#ifdef FEATURE_WLAN_LFR
3200 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08003201 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003202#endif
3203
Jeff Johnson295189b2012-06-20 16:38:30 -07003204
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003205#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 /* Now we can clear the preauthDone that was saved as we are connected afresh */
3207 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3208#endif
3209
3210#ifdef WLAN_FEATURE_VOWIFI_11R
3211 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003212 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
3213 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 {
3215 if (pMac->roam.configParam.isFastTransitionEnabled)
3216 init_ft_flag = TRUE;
3217 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
3218 }
3219 else
3220 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003221 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222#endif
3223
3224#ifdef FEATURE_WLAN_CCX
3225 // Based on the auth scheme tell if we are 11r
3226 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
3227 {
3228 if (pMac->roam.configParam.isFastTransitionEnabled)
3229 init_ft_flag = TRUE;
3230 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
3231 }
3232 else
3233 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003234 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
3235 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07003236
3237#endif
3238
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003239#ifdef FEATURE_WLAN_LFR
3240 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303241 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003242 {
3243 init_ft_flag = TRUE;
3244 }
3245#endif
3246
3247#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 if ( init_ft_flag == TRUE )
3249 {
3250 /* Initialize all the data structures needed for the 11r FT Preauth */
3251 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
3252 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = sessionId;
3253 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3254 csrNeighborRoamPurgePreauthFailedList(pMac);
3255
3256 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
3257 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07003258 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 WLANTL_HO_THRESHOLD_DOWN,
3260 csrNeighborRoamNeighborLookupDOWNCallback,
3261 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003262#ifdef FEATURE_WLAN_LFR
3263 pNeighborRoamInfo->lookupDOWNRssi = 0;
3264#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07003265 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 {
3267 //err msg
Jeff Johnson43971f52012-07-17 12:26:56 -07003268 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d\n"), vstatus);
3269 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 }
3271 }
3272#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 break;
3274 default:
3275 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3276 break;
3277 }
3278 return status;
3279}
3280
3281
3282#ifdef WLAN_FEATURE_VOWIFI_11R
3283/* ---------------------------------------------------------------------------
3284
3285 \fn csrNeighborRoamPreAuthResponseWaitTimerHandler
3286
3287 \brief If this function is invoked, that means the preauthentication response
3288 is timed out from the PE. Preauth rsp handler is called with status as
3289 TIMEOUT
3290
3291 \param context - CSR Timer info which holds pMac and session ID
3292
3293 \return VOID
3294
3295---------------------------------------------------------------------------*/
3296void csrNeighborRoamPreAuthResponseWaitTimerHandler(void *context)
3297{
3298 tCsrTimerInfo *pTimerInfo = (tCsrTimerInfo *)context;
3299 tpAniSirGlobal pMac = (tpAniSirGlobal)pTimerInfo->pMac;
3300 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3301
3302 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
3303
3304 csrNeighborRoamPreauthRspHandler(pMac, VOS_STATUS_E_TIMEOUT);
3305}
3306
3307/* ---------------------------------------------------------------------------
3308
3309 \fn csrNeighborRoamPurgePreauthFailedList
3310
3311 \brief This function purges all the MAC addresses in the pre-auth fail list
3312
3313 \param pMac - The handle returned by macOpen.
3314
3315 \return VOID
3316
3317---------------------------------------------------------------------------*/
3318void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
3319{
3320 tANI_U8 i;
3321
3322 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
3323 {
3324 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
3325 }
3326 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
3327
3328 return;
3329}
3330
3331/* ---------------------------------------------------------------------------
3332
3333 \fn csrNeighborRoamInit11rAssocInfo
3334
3335 \brief This function initializes 11r related neighbor roam data structures
3336
3337 \param pMac - The handle returned by macOpen.
3338
3339 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3340
3341---------------------------------------------------------------------------*/
3342eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
3343{
3344 eHalStatus status;
3345 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
3346
3347 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
3348 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
3349 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
3350 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
3351 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
3352 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
3353
3354 pFTRoamInfo->preAuthRspWaitTimerInfo.pMac = pMac;
3355 pFTRoamInfo->preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3356 status = palTimerAlloc(pMac->hHdd, &pFTRoamInfo->preAuthRspWaitTimer,
3357 csrNeighborRoamPreAuthResponseWaitTimerHandler, (void *)&pFTRoamInfo->preAuthRspWaitTimerInfo);
3358
3359 if (eHAL_STATUS_SUCCESS != status)
3360 {
3361 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3362 return eHAL_STATUS_RESOURCES;
3363 }
3364
3365 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3366 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3367 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3368 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3369
3370
3371 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
3372 if (eHAL_STATUS_SUCCESS != status)
3373 {
3374 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
3375 palTimerFree(pMac->hHdd, pFTRoamInfo->preAuthRspWaitTimer);
3376 return eHAL_STATUS_RESOURCES;
3377 }
3378 return status;
3379}
3380#endif /* WLAN_FEATURE_VOWIFI_11R */
3381
3382/* ---------------------------------------------------------------------------
3383
3384 \fn csrNeighborRoamInit
3385
3386 \brief This function initializes neighbor roam data structures
3387
3388 \param pMac - The handle returned by macOpen.
3389
3390 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3391
3392---------------------------------------------------------------------------*/
3393eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
3394{
3395 eHalStatus status;
3396 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3397
3398 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3399 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3400 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
3401 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
3402 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
3403 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
3404 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
3405 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
3406 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
3407 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
3408
3409 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
3410 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
3411
3412 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
3413 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3414
3415 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3416 {
3417 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
3418 return eHAL_STATUS_RESOURCES;
3419 }
3420
3421 /* Update the roam global structure from CFG */
3422 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3423 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
3424 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3425
3426 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
3427 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003428#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08003429 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003430 pNeighborRoamInfo->uEmptyScanCount = 0;
3431 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
3432 sizeof(tCsrRoamConnectedProfile));
3433#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
3435
3436 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3437 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3438 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborScanTimer,
3439 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3440
3441 if (eHAL_STATUS_SUCCESS != status)
3442 {
3443 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3444 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3445 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3446 return eHAL_STATUS_RESOURCES;
3447 }
3448
3449 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborResultsRefreshTimer,
3450 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3451
3452 if (eHAL_STATUS_SUCCESS != status)
3453 {
3454 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3455 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3456 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3457 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3458 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3459 return eHAL_STATUS_RESOURCES;
3460 }
3461
3462 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
3463 if (eHAL_STATUS_SUCCESS != status)
3464 {
3465 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3466 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3467 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3468 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3469 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3470 return eHAL_STATUS_RESOURCES;
3471 }
3472
3473 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3474 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3475 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3476 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3477 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3478
3479#ifdef WLAN_FEATURE_VOWIFI_11R
3480 status = csrNeighborRoamInit11rAssocInfo(pMac);
3481 if (eHAL_STATUS_SUCCESS != status)
3482 {
3483 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3484 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3485 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3486 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3487 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3488 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3489 return eHAL_STATUS_RESOURCES;
3490 }
3491#endif
3492 /* Initialize this with the current tick count */
3493 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3494
3495 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3496
3497 return eHAL_STATUS_SUCCESS;
3498}
3499
3500/* ---------------------------------------------------------------------------
3501
3502 \fn csrNeighborRoamClose
3503
3504 \brief This function closes/frees all the neighbor roam data structures
3505
3506 \param pMac - The handle returned by macOpen.
3507
3508 \return VOID
3509
3510---------------------------------------------------------------------------*/
3511void csrNeighborRoamClose(tpAniSirGlobal pMac)
3512{
3513 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3514
3515 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
3516 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07003517 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 return;
3519 }
3520
3521 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3522 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3523
3524 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3525
3526 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
3527 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3528 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3529 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3530
3531 /* Should free up the nodes in the list before closing the double Linked list */
3532 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
3533 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3534
3535 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3536 {
3537 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3538 }
3539
3540 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3541 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3542 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3543 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3544 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3545 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3546
3547 /* Free the profile.. */
3548 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003549#ifdef FEATURE_WLAN_LFR
Sandeep Pc2b00f62012-12-12 16:44:44 -08003550 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003551#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003552#ifdef WLAN_FEATURE_VOWIFI_11R
3553 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3554 palTimerFree(pMac->hHdd, pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimer);
3555 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.pMac = NULL;
3556 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3557 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3558 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3559 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3560 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3561 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3562#endif /* WLAN_FEATURE_VOWIFI_11R */
3563
3564 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
3565
3566 return;
3567}
3568
3569/* ---------------------------------------------------------------------------
3570
3571 \fn csrNeighborRoamRequestHandoff
3572
3573 \brief This function triggers actual switching from one AP to the new AP.
3574 It issues disassociate with reason code as Handoff and CSR as a part of
3575 handling disassoc rsp, issues reassociate to the new AP
3576
3577 \param pMac - The handle returned by macOpen.
3578
3579 \return VOID
3580
3581---------------------------------------------------------------------------*/
3582void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
3583{
3584
3585 tCsrRoamInfo roamInfo;
3586 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3587 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3588 tCsrNeighborRoamBSSInfo handoffNode;
3589 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
3590 tANI_U32 roamId = 0;
3591
3592 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
3593 {
3594 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
3595 pMac->roam.neighborRoamInfo.neighborRoamState);
3596 return;
3597 }
3598
3599 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3600 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
3601 eSIR_SME_SUCCESS);
3602
3603 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3604 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
3605
3606 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
3607 smsLog(pMac, LOGE, FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
3608 handoffNode.pBssDescription->bssId[0],
3609 handoffNode.pBssDescription->bssId[1],
3610 handoffNode.pBssDescription->bssId[2],
3611 handoffNode.pBssDescription->bssId[3],
3612 handoffNode.pBssDescription->bssId[4],
3613 handoffNode.pBssDescription->bssId[5]);
3614
3615 /* Free the profile.. Just to make sure we dont leak memory here */
3616 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
3617 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
3618 This should happen before issuing disconnect */
3619 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
3620 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
3621 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
3622
3623 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP\n");
3624
3625 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
3626 {
3627 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate\n");
3628 return;
3629 }
3630
3631 //notify HDD for handoff, providing the BSSID too
3632 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
3633
3634 vos_mem_copy(roamInfo.bssid,
3635 handoffNode.pBssDescription->bssId,
3636 sizeof( tCsrBssid ));
3637
3638 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
3639
3640
3641 return;
3642}
3643
3644/* ---------------------------------------------------------------------------
3645
3646 \fn csrNeighborRoamIsHandoffInProgress
3647
3648 \brief This function returns whether handoff is in progress or not based on
3649 the current neighbor roam state
3650
3651 \param pMac - The handle returned by macOpen.
3652 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
3653
3654 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
3655
3656---------------------------------------------------------------------------*/
3657tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
3658{
3659 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
3660 return eANI_BOOLEAN_TRUE;
3661
3662 return eANI_BOOLEAN_FALSE;
3663}
3664
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003665#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07003666/* ---------------------------------------------------------------------------
3667
3668 \fn csrNeighborRoamIs11rAssoc
3669
3670 \brief This function returns whether the current association is a 11r assoc or not
3671
3672 \param pMac - The handle returned by macOpen.
3673
3674 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
3675
3676---------------------------------------------------------------------------*/
3677tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
3678{
3679 return pMac->roam.neighborRoamInfo.is11rAssoc;
3680}
3681#endif /* WLAN_FEATURE_VOWIFI_11R */
3682
3683
3684/* ---------------------------------------------------------------------------
3685
3686 \fn csrNeighborRoamGetHandoffAPInfo
3687
3688 \brief This function returns the best possible AP for handoff. For 11R case, it
3689 returns the 1st entry from pre-auth done list. For non-11r case, it returns
3690 the 1st entry from roamable AP list
3691
3692 \param pMac - The handle returned by macOpen.
3693 pHandoffNode - AP node that is the handoff candidate returned
3694
3695 \return VOID
3696
3697---------------------------------------------------------------------------*/
3698void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
3699{
3700 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3701 tpCsrNeighborRoamBSSInfo pBssNode;
3702
3703 VOS_ASSERT(NULL != pHandoffNode);
3704
3705#ifdef WLAN_FEATURE_VOWIFI_11R
3706 if (pNeighborRoamInfo->is11rAssoc)
3707 {
3708 /* Always the BSS info in the head is the handoff candidate */
3709 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3710 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3711 }
3712 else
3713#endif
3714#ifdef FEATURE_WLAN_CCX
3715 if (pNeighborRoamInfo->isCCXAssoc)
3716 {
3717 /* Always the BSS info in the head is the handoff candidate */
3718 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3719 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3720 }
3721 else
3722#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003723#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303724 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003725 {
3726 /* Always the BSS info in the head is the handoff candidate */
3727 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3728 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3729 }
3730 else
3731#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 {
3733 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
3734 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
3735 }
3736 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
3737
3738 return;
3739}
3740
3741/* ---------------------------------------------------------------------------
3742 \brief This function returns TRUE if preauth is completed
3743
3744 \param pMac - The handle returned by macOpen.
3745
3746 \return boolean
3747
3748---------------------------------------------------------------------------*/
3749tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
3750{
3751 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
3752 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
3753}
3754
3755/* ---------------------------------------------------------------------------
3756 \brief In the event that we are associated with AP1 and we have
3757 completed pre auth with AP2. Then we receive a deauth/disassoc from
3758 AP1.
3759 At this point neighbor roam is in pre auth done state, pre auth timer
3760 is running. We now handle this case by stopping timer and clearing
3761 the pre-auth state. We basically clear up and just go to disconnected
3762 state.
3763
3764 \param pMac - The handle returned by macOpen.
3765
3766 \return boolean
3767---------------------------------------------------------------------------*/
3768void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
3769{
3770 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
3771 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
3772
3773 // Stop timer
3774 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
3775
3776 // Transition to init state
3777 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3778}
3779
3780#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */