blob: b4ec3e6afbb8ae1b753dbf06e26c137b1371bd1f [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
42/*
43 * */
44/** ------------------------------------------------------------------------- *
45 ------------------------------------------------------------------------- *
46
47
48 \file csrNeighborRoam.c
49
50 Implementation for the simple roaming algorithm for 802.11r Fast transitions and Legacy roaming for Android platform.
51
52 Copyright (C) 2010 Qualcomm, Incorporated
53
54
55 ========================================================================== */
56
57/*===========================================================================
58
59 EDIT HISTORY FOR FILE
60
61
62 This section contains comments describing changes made to the module.
63 Notice that changes are listed in reverse chronological order.
64
65
66
67 when who what, where, why
68---------- --- --------------------------------------------------------
6908/01/10 Murali Created
70
71===========================================================================*/
72#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
73#include "wlan_qct_wda.h"
74#include "palApi.h"
75#include "csrInsideApi.h"
76#include "smsDebug.h"
77#include "logDump.h"
78#include "smeQosInternal.h"
79#include "wlan_qct_tl.h"
80#include "smeInside.h"
81#include "vos_diag_core_event.h"
82#include "vos_diag_core_log.h"
83#include "csrApi.h"
84#include "wlan_qct_tl.h"
85#include "sme_Api.h"
86#include "csrNeighborRoam.h"
87#ifdef FEATURE_WLAN_CCX
88#include "csrCcx.h"
89#endif
90
91#define WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG 1
92#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG
93#define NEIGHBOR_ROAM_DEBUG smsLog
94#else
95#define NEIGHBOR_ROAM_DEBUG(x...)
96#endif
97
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -070098static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo);
99static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac);
100static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac);
101static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac);
102
Jeff Johnson295189b2012-06-20 16:38:30 -0700103VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800104 v_PVOID_t pUserCtxt,
105 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700106VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800107 v_PVOID_t pUserCtxt,
108 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700109void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus);
110eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile );
111
112#ifdef WLAN_FEATURE_VOWIFI_11R
113static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac);
114VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac);
115#endif
116
117/* State Transition macro */
118#define CSR_NEIGHBOR_ROAM_STATE_TRANSITION(newState)\
119{\
120 pMac->roam.neighborRoamInfo.prevNeighborRoamState = pMac->roam.neighborRoamInfo.neighborRoamState;\
121 pMac->roam.neighborRoamInfo.neighborRoamState = newState;\
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700122 smsLog(pMac, LOG1, FL("Neighbor Roam Transition from state %d ==> %d"), pMac->roam.neighborRoamInfo.prevNeighborRoamState, newState);\
Jeff Johnson295189b2012-06-20 16:38:30 -0700123}
124
125/* ---------------------------------------------------------------------------
126
127 \fn csrNeighborRoamFreeNeighborRoamBSSNode
128
129 \brief This function frees all the internal pointers CSR NeighborRoam BSS Info
130 and also frees the node itself
131
132 \param pMac - The handle returned by macOpen.
133 neighborRoamBSSNode - Neighbor Roam BSS Node to be freed
134
135 \return VOID
136
137---------------------------------------------------------------------------*/
138void csrNeighborRoamFreeNeighborRoamBSSNode(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo neighborRoamBSSNode)
139{
140 if (neighborRoamBSSNode)
141 {
142 if (neighborRoamBSSNode->pBssDescription)
143 {
144 vos_mem_free(neighborRoamBSSNode->pBssDescription);
145 neighborRoamBSSNode->pBssDescription = NULL;
146 }
147 vos_mem_free(neighborRoamBSSNode);
148 neighborRoamBSSNode = NULL;
149 }
150
151 return;
152}
153
154/* ---------------------------------------------------------------------------
155
156 \fn csrNeighborRoamRemoveRoamableAPListEntry
157
158 \brief This function removes a given entry from the given list
159
160 \param pMac - The handle returned by macOpen.
161 pList - The list from which the entry should be removed
162 pNeighborEntry - Neighbor Roam BSS Node to be removed
163
164 \return TRUE if successfully removed, else FALSE
165
166---------------------------------------------------------------------------*/
167tANI_BOOLEAN csrNeighborRoamRemoveRoamableAPListEntry(tpAniSirGlobal pMac,
168 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
169{
170 if(pList)
171 {
172 return csrLLRemoveEntry(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
173 }
174
175 smsLog(pMac, LOGE, FL("Removing neighbor BSS node from list failed. Current count = %d\n"), csrLLCount(pList));
176
177 return eANI_BOOLEAN_FALSE;
178}
179
180/* ---------------------------------------------------------------------------
181
182 \fn csrNeighborRoamGetRoamableAPListNextEntry
183
184 \brief Gets the entry next to passed entry. If NULL is passed, return the entry in the head of the list
185
186 \param pMac - The handle returned by macOpen.
187 pList - The list from which the entry should be returned
188 pNeighborEntry - Neighbor Roam BSS Node whose next entry should be returned
189
190 \return Neighbor Roam BSS Node to be returned
191
192---------------------------------------------------------------------------*/
193tpCsrNeighborRoamBSSInfo csrNeighborRoamGetRoamableAPListNextEntry(tpAniSirGlobal pMac,
194 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
195{
196 tListElem *pEntry = NULL;
197 tpCsrNeighborRoamBSSInfo pResult = NULL;
198
199 if(pList)
200 {
201 if(NULL == pNeighborEntry)
202 {
203 pEntry = csrLLPeekHead(pList, LL_ACCESS_LOCK);
204 }
205 else
206 {
207 pEntry = csrLLNext(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
208 }
209 if(pEntry)
210 {
211 pResult = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
212 }
213 }
214
215 return pResult;
216}
217
218/* ---------------------------------------------------------------------------
219
220 \fn csrNeighborRoamFreeRoamableBSSList
221
222 \brief Empties and frees all the nodes in the roamable AP list
223
224 \param pMac - The handle returned by macOpen.
225 pList - Neighbor Roam BSS List to be emptied
226
227 \return VOID
228
229---------------------------------------------------------------------------*/
230void csrNeighborRoamFreeRoamableBSSList(tpAniSirGlobal pMac, tDblLinkList *pList)
231{
232 tpCsrNeighborRoamBSSInfo pResult = NULL;
233
Mohit Khanna23863762012-09-11 17:40:09 -0700234 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Emptying the BSS list. Current count = %d\n"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
236 /* Pick up the head, remove and free the node till the list becomes empty */
237 while ((pResult = csrNeighborRoamGetRoamableAPListNextEntry(pMac, pList, NULL)) != NULL)
238 {
239 csrNeighborRoamRemoveRoamableAPListEntry(pMac, pList, pResult);
240 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pResult);
241 }
242 return;
243}
244
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800245static void csrNeighborRoamTriggerHandoff(tpAniSirGlobal pMac,
246 tpCsrNeighborRoamControlInfo pNeighborRoamInfo)
247{
248#ifdef WLAN_FEATURE_VOWIFI_11R
249 if (pNeighborRoamInfo->is11rAssoc)
250 {
251 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
252 {
253 csrNeighborRoamIssuePreauthReq(pMac);
254 }
255 else
256 {
257 smsLog(pMac, LOGE, FL("11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
258 VOS_ASSERT(0);
259 }
260 }
261 else
262#endif
263
264#ifdef FEATURE_WLAN_CCX
265 if (pNeighborRoamInfo->isCCXAssoc)
266 {
267 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
268 {
269 csrNeighborRoamIssuePreauthReq(pMac);
270 }
271 else
272 {
273 smsLog(pMac, LOGE, FL("CCX Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
274 VOS_ASSERT(0);
275 }
276 }
277 else
278#endif
279#ifdef FEATURE_WLAN_LFR
280 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
281 {
282 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
283 {
284 csrNeighborRoamIssuePreauthReq(pMac);
285 }
286 else
287 {
288 smsLog(pMac, LOGE, FL("LFR Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
289 VOS_ASSERT(0);
290 }
291 }
292 else
293#endif
294 {
295 if (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pNeighborRoamInfo->neighborRoamState)
296 {
297 csrNeighborRoamRequestHandoff(pMac);
298 }
299 else
300 {
301 smsLog(pMac, LOGE, FL("Non-11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
302 VOS_ASSERT(0);
303 }
304 }
305}
306
Jeff Johnson295189b2012-06-20 16:38:30 -0700307/* ---------------------------------------------------------------------------
308
309 \fn csrNeighborRoamReassocIndCallback
310
311 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
312 Directly triggere HO in case of non-11r association
313 In case of 11R association, triggers a pre-auth eventually followed by actual HO
314
315 \param pAdapter - VOS Context
316 trafficStatus - UP/DOWN indication from TL
317 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
318
319 \return VOID
320
321---------------------------------------------------------------------------*/
322VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
323 v_U8_t trafficStatus,
Srinivasdaaec712012-12-12 15:59:44 -0800324 v_PVOID_t pUserCtxt,
325 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700326{
327 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
328 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
329 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
330
Srinivasdaaec712012-12-12 15:59:44 -0800331 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"),
332 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
333 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700334
335 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
336 WLANTL_HO_THRESHOLD_DOWN,
337 csrNeighborRoamReassocIndCallback,
338 VOS_MODULE_ID_SME);
339
340 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
341 {
342 //err msg
343 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
344 }
345
Srinivasdaaec712012-12-12 15:59:44 -0800346 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
347 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800348 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
349 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
350 WLANTL_HO_THRESHOLD_UP,
351 csrNeighborRoamNeighborLookupUPCallback,
352 VOS_MODULE_ID_SME);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353
354 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
355 {
356 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530357 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 }
359
360 /* We dont need to run this timer any more. */
361 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
362
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800363 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700364
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return VOS_STATUS_SUCCESS;
366}
367
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700368/*CleanUP Routines*/
369static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
370{
371 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
372 (rChInfo->currentChannelListInfo.numOfChannels))
373 {
374 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
375 rChInfo->currentChannelListInfo.numOfChannels = 0;
376
377 if (rChInfo->currentChannelListInfo.ChannelList)
378 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
379
380 rChInfo->currentChannelListInfo.ChannelList = NULL;
381 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
382 }
383 else
384 {
385 rChInfo->currentChanIndex = 0;
386 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
387 }
388}
389
390static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
391{
392 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
393
394 /* Stop neighbor scan timer */
395 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
396
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700397 /* Stop neighbor scan results refresh timer */
398 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
399
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700400 /* Abort any ongoing scan */
401 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
402 {
403 csrScanAbortMacScan(pMac);
404 }
405 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
406
407 /* Reset roam channel list information */
408 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
409}
410
411static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
412{
413 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
414
415#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
416 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
417 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
418 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId =
419 CSR_SESSION_ID_INVALID;
420 /* Purge pre-auth fail list */
421 csrNeighborRoamPurgePreauthFailedList(pMac);
422#endif
423
424 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
425 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
426#ifdef WLAN_FEATURE_VOWIFI_11R
427 /* Do not free up the preauth done list here */
428 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
429 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
430 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
431 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
432 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
433#endif
434}
435
436static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
437{
438 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
439 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
440
441 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
442 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800443 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700444
445 /* Deregister reassoc callback. Ignore return status */
446 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800447 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700448 WLANTL_HO_THRESHOLD_UP,
449 csrNeighborRoamNeighborLookupUPCallback,
450 VOS_MODULE_ID_SME);
451
452 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
453 {
454 smsLog(pMac, LOGW,
455 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
456 "with TL: Status = %d\n"), vosStatus);
457 }
458
459 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
460 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
461 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
462
463 /* Deregister reassoc callback. Ignore return status */
464 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
465 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
466 WLANTL_HO_THRESHOLD_DOWN,
467 csrNeighborRoamReassocIndCallback,
468 VOS_MODULE_ID_SME);
469
470 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
471 {
472 smsLog(pMac, LOGW,
473 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
474 "TL: Status = %d\n"), vosStatus);
475 }
476
477 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
478 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
479 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
480
481 /* Deregister neighbor lookup callback. Ignore return status */
482 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
483 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
484 WLANTL_HO_THRESHOLD_DOWN,
485 csrNeighborRoamNeighborLookupDOWNCallback,
486 VOS_MODULE_ID_SME);
487
488 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
489 {
490 smsLog(pMac, LOGW,
491 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
492 "with TL: Status = %d\n"), vosStatus);
493 }
494
495 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700496 pNeighborRoamInfo->currentNeighborLookupThreshold =
497 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800498#ifdef FEATURE_WLAN_LFR
499 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -0800500 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800501#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700502}
503
Jeff Johnson295189b2012-06-20 16:38:30 -0700504/* ---------------------------------------------------------------------------
505
506 \fn csrNeighborRoamResetConnectedStateControlInfo
507
508 \brief This function will reset the neighbor roam control info data structures.
509 This function should be invoked whenever we move to CONNECTED state from
510 any state other than INIT state
511
512 \param pMac - The handle returned by macOpen.
513
514 \return VOID
515
516---------------------------------------------------------------------------*/
517void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
518{
519 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
520
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700521 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700523
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700524 /* We dont need to run this timer any more. */
525 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700526
527#ifdef WLAN_FEATURE_VOWIFI_11R
528 /* Do not free up the preauth done list here */
529 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
530 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
531 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
532 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
533 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
534 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
535 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
536#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700537}
538
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700539void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700540{
541 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
543 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
544 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
545 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700546#ifdef FEATURE_WLAN_CCX
547 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
548 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
549 pNeighborRoamInfo->MinQBssLoadRequired = 0;
550#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700551
552 /* Stop scan refresh timer */
553 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700554 /* Purge roamable AP list */
555 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 return;
557}
558
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700559/* ---------------------------------------------------------------------------
560
561 \fn csrNeighborRoamResetInitStateControlInfo
562
563 \brief This function will reset the neighbor roam control info data structures.
564 This function should be invoked whenever we move to CONNECTED state from
565 INIT state
566
567 \param pMac - The handle returned by macOpen.
568
569 \return VOID
570
571---------------------------------------------------------------------------*/
572void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
573{
574 csrNeighborRoamResetConnectedStateControlInfo(pMac);
575
576 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
577 csrNeighborRoamResetReportScanStateControlInfo(pMac);
578}
579
580
581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582#ifdef WLAN_FEATURE_VOWIFI_11R
583/* ---------------------------------------------------------------------------
584
585 \fn csrNeighborRoamBssIdScanFilter
586
587 \brief This API is used to prepare a filter to obtain scan results when
588 we complete the scan in the REPORT_SCAN state after receiving a
589 valid neighbor report from AP. This filter includes BSSIDs received from
590 the neighbor report from the AP in addition to the other filter parameters
591 created from connected profile
592
593 \param pMac - The handle returned by macOpen.
594 pScanFilter - Scan filter to be filled and returned
595
596 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
597 code otherwise
598
599---------------------------------------------------------------------------*/
600static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
601{
602 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
603 tANI_U8 i = 0;
604
605 VOS_ASSERT(pScanFilter != NULL);
606 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
607
608 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
609 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
610 if (NULL == pScanFilter->BSSIDs.bssid)
611 {
612 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
613 return eHAL_STATUS_FAILED_ALLOC;
614 }
615
616 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
617
618 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
619 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
620 {
621 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
622 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
623 }
624
625 /* Fill other general scan filter params */
626 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
627}
628
629/* ---------------------------------------------------------------------------
630
631 \fn csrNeighborRoamPurgePreauthFailList
632
633 \brief This function empties the preauth fail list
634
635 \param pMac - The handle returned by macOpen.
636
637 \return VOID
638
639---------------------------------------------------------------------------*/
640void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
641{
642 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
643
644 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
645 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
646 {
647 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
648 sizeof(tSirMacAddr));
649 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
650 }
651 return;
652}
653
654/* ---------------------------------------------------------------------------
655
656 \fn csrNeighborRoamAddBssIdToPreauthFailList
657
658 \brief This function adds the given BSSID to the Preauth fail list
659
660 \param pMac - The handle returned by macOpen.
661 bssId - BSSID to be added to the preauth fail list
662
663 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
664
665---------------------------------------------------------------------------*/
666eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
667{
668 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
669
670 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL(" Added BSSID %02x:%02x:%02x:%02x:%02x:%02x to Preauth failed list\n"),
671 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
672
673
674 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
675 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
676 {
677 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
678 return eHAL_STATUS_FAILURE;
679 }
680 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
681 bssId, sizeof(tSirMacAddr));
682 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
683
684 return eHAL_STATUS_SUCCESS;
685}
686
687/* ---------------------------------------------------------------------------
688
689 \fn csrNeighborRoamIsPreauthCandidate
690
691 \brief This function checks whether the given MAC address is already
692 present in the preauth fail list and returns TRUE/FALSE accordingly
693
694 \param pMac - The handle returned by macOpen.
695
696 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
697
698---------------------------------------------------------------------------*/
699tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
700{
701 tANI_U8 i = 0;
702 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
703
704 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
705 return eANI_BOOLEAN_TRUE;
706
707 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
708 {
709 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
710 bssId, sizeof(tSirMacAddr)))
711 {
712 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
713 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
714 return eANI_BOOLEAN_FALSE;
715 }
716 }
717
718 return eANI_BOOLEAN_TRUE;
719}
720
721/* ---------------------------------------------------------------------------
722
723 \fn csrNeighborRoamIssuePreauthReq
724
725 \brief This function issues preauth request to PE with the 1st AP entry in the
726 roamable AP list
727
728 \param pMac - The handle returned by macOpen.
729
730 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
731
732---------------------------------------------------------------------------*/
733static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
734{
735 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
736 eHalStatus status = eHAL_STATUS_SUCCESS;
737 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
738
739 /* This must not be true here */
740 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
741
742 /* Issue Preauth request to PE here */
743 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
744 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
745 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
746 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
747
748 if (NULL == pNeighborBssNode)
749 {
750 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
751 return eHAL_STATUS_FAILURE;
752 }
753 else
754 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700755 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
756 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530757
758 smsLog(pMac, LOGE, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x %d"),
759 pNeighborBssNode->pBssDescription->bssId[0],
760 pNeighborBssNode->pBssDescription->bssId[1],
761 pNeighborBssNode->pBssDescription->bssId[2],
762 pNeighborBssNode->pBssDescription->bssId[3],
763 pNeighborBssNode->pBssDescription->bssId[4],
764 pNeighborBssNode->pBssDescription->bssId[5]);
765 smsLog(pMac, LOGE, FL("Before Pre-Auth: Channel %d\n"), (int)pNeighborBssNode->pBssDescription->channelId);
766
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 if (eHAL_STATUS_SUCCESS != status)
768 {
769 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d\n"), status);
770 return status;
771 }
772 }
773
774 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
775
776 /* Increment the preauth retry count */
777 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
778
779 /* Transition the state to preauthenticating */
780 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700781#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 /* Start the preauth rsp timer */
783 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer,
784 CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
785 eANI_BOOLEAN_FALSE);
786 if (eHAL_STATUS_SUCCESS != status)
787 {
788 smsLog(pMac, LOGE, FL("Preauth response wait timer start failed with status %d\n"), status);
789 return status;
790 }
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700791#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700792
793 return status;
794}
795
796/* ---------------------------------------------------------------------------
797
798 \fn csrNeighborRoamPreauthRspHandler
799
800 \brief This function handle the Preauth response from PE
801 Every preauth is allowed max 3 tries if it fails. If a bssid failed
802 for more than MAX_TRIES, we will remove it from the list and try
803 with the next node in the roamable AP list and add the BSSID to pre-auth failed
804 list. If no more entries present in
805 roamable AP list, transition to REPORT_SCAN state
806
807 \param pMac - The handle returned by macOpen.
808 vosStatus - VOS_STATUS_SUCCESS/FAILURE/TIMEOUT status from PE
809
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700810 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
811 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -0700812
813---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700814eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, VOS_STATUS vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700815{
816 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
817 eHalStatus status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700818 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700820
821 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
822 {
823
824 /* This can happen when we disconnect immediately
825 * after sending a pre-auth request. During processing
826 * of the disconnect command, we would have reset
827 * preauthRspPending and transitioned to INIT state.
828 */
829 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
830 FL("Unexpected pre-auth response in state %d\n"),
831 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700832 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700833 goto DEQ_PREAUTH;
834 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
836 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
838 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
839 {
Madan Mohan Koyyalamudi8186a9e2012-10-11 14:23:43 -0700840 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d\n"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700841 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700842 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700843 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 }
845
846 if (VOS_STATUS_E_TIMEOUT != vosStatus)
847 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700848#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 /* This means we got the response from PE. Hence stop the timer */
850 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700851#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
853 }
854
855 if (VOS_STATUS_SUCCESS == vosStatus)
856 {
857 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
858 }
859 if ((VOS_STATUS_SUCCESS == vosStatus) && (NULL != pPreauthRspNode))
860 {
861 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
862
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530863 smsLog(pMac, LOGE, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x\n"),
864 pPreauthRspNode->pBssDescription->bssId[0],
865 pPreauthRspNode->pBssDescription->bssId[1],
866 pPreauthRspNode->pBssDescription->bssId[2],
867 pPreauthRspNode->pBssDescription->bssId[3],
868 pPreauthRspNode->pBssDescription->bssId[4],
869 pPreauthRspNode->pBssDescription->bssId[5]);
870 smsLog(pMac, LOGE, FL("After Pre-Auth: Channel %d\n"), (int)pPreauthRspNode->pBssDescription->channelId);
871
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
873 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
874 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
875
876 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
877 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
878 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
879
880 /* The caller of this function would start a timer and by the time it expires, supplicant should
881 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
882 }
883 else
884 {
885 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
886 tListElem *pEntry;
887
888 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = %d\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, vosStatus);
889
890 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
891 if (pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >= CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES)
892 {
893 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
894 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
895
896 /* The one in the head of the list should be one with which we issued pre-auth and failed */
897 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
898 if(pEntry)
899 {
900 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
901 /* Add the BSSID to pre-auth fail list */
902 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
903 /* Now we can free this node */
904 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
905 }
906 }
907
908 /* Issue preauth request for the same/next entry */
909 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700910 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700911
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800912 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
913
914 /* Register Neighbor Lookup threshold callback with TL for UP event now */
915 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
916 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
917
918 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
919 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
920 WLANTL_HO_THRESHOLD_UP,
921 csrNeighborRoamNeighborLookupUPCallback,
922 VOS_MODULE_ID_SME, pMac);
923 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
924 {
925 //err msg
926 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
927 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700928
929 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
930 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
931 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
932 eANI_BOOLEAN_FALSE);
933 if (eHAL_STATUS_SUCCESS != status)
934 {
935 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 }
937 }
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700938
939DEQ_PREAUTH:
940 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700941 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700942}
943#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
944
945/* ---------------------------------------------------------------------------
946
947 \fn csrNeighborRoamPrepareScanProfileFilter
948
949 \brief This function creates a scan filter based on the currently connected profile.
950 Based on this filter, scan results are obtained
951
952 \param pMac - The handle returned by macOpen.
953 pScanFilter - Populated scan filter based on the connected profile
954
955 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
956
957---------------------------------------------------------------------------*/
958eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
959{
960 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
961 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
962 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
963 tANI_U8 i = 0;
964
965 VOS_ASSERT(pScanFilter != NULL);
966
967 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
968
969 /* We dont want to set BSSID based Filter */
970 pScanFilter->BSSIDs.numOfBSSIDs = 0;
971
972 /* Populate all the information from the connected profile */
973 pScanFilter->SSIDs.numOfSSIDs = 1;
974 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
975 if (NULL == pScanFilter->SSIDs.SSIDList)
976 {
977 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
978 return eHAL_STATUS_FAILED_ALLOC;
979 }
980 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
981 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
982 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
983 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
984
985 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering for SSID %s from scan results.. SSID Length = %d\n"),
986 pScanFilter->SSIDs.SSIDList->SSID.ssId, pScanFilter->SSIDs.SSIDList->SSID.length);
987 pScanFilter->authType.numEntries = 1;
988 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
989
990 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
991 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
992
993 pScanFilter->mcEncryptionType.numEntries = 1;
994 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
995
996 pScanFilter->BSSType = pCurProfile->BSSType;
997
998 /* We are intrested only in the scan results on channels that we scanned */
999 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
1000 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
1001 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1002 {
1003 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1004 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1005 pScanFilter->SSIDs.SSIDList = NULL;
1006 return eHAL_STATUS_FAILED_ALLOC;
1007 }
1008 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1009 {
1010 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1011 }
1012
1013#ifdef WLAN_FEATURE_VOWIFI_11R
1014 if (pNeighborRoamInfo->is11rAssoc)
1015 {
1016 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1017 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1018 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1019 }
1020#endif
1021
1022 return eHAL_STATUS_SUCCESS;
1023}
1024
Jeff Johnson43971f52012-07-17 12:26:56 -07001025tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1026{
1027 tCsrScanResultInfo *pScanResult;
1028 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1029 tANI_U32 CurrAPRssi = -125; /* We are setting this as default value to make sure we return this value,
1030 when we do not see this AP in the scan result for some reason.However,it is
1031 less likely that we are associated to an AP and do not see it in the scan list*/
1032
1033 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1034 {
1035
1036 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1037 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1038 {
1039 /* We got a match with the currently associated AP.
1040 * Capture the RSSI value and complete the while loop.
1041 * The while loop is completed in order to make the current entry go back to NULL,
1042 * and in the next while loop, it properly starts searching from the head of the list.
1043 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1044
1045 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1046
1047 } else {
1048 continue;
1049 }
1050 }
1051
1052 return CurrAPRssi;
1053
1054}
1055
Jeff Johnson295189b2012-06-20 16:38:30 -07001056/* ---------------------------------------------------------------------------
1057
1058 \fn csrNeighborRoamProcessScanResults
1059
1060 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1061 Assumed that the results are already sorted by RSSI by csrScanGetResult
1062
1063 \param pMac - The handle returned by macOpen.
1064 pScanResultList - Scan result result obtained from csrScanGetResult()
1065
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001066 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1067 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001068
1069---------------------------------------------------------------------------*/
1070
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001071static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1072 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001073{
1074 tCsrScanResultInfo *pScanResult;
1075 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1076 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001077 tANI_U32 CurrAPRssi;
1078 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001079#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1080 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1081#endif
1082 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001083
1084 /***************************************************************
1085 * Find out the Current AP RSSI and keep it handy to check if
1086 * it is better than the RSSI of the AP which we are
1087 * going to roam.If so, we are going to continue with the
1088 * current AP.
1089 ***************************************************************/
1090 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001091
1092 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1093 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1094 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1095 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1096 /* 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
1097 and rssi score are in the same order. This will be taken care later */
1098
1099 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1100 {
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001101 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1102 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d)"),
1103 pScanResult->BssDescriptor.bssId[0],
1104 pScanResult->BssDescriptor.bssId[1],
1105 pScanResult->BssDescriptor.bssId[2],
1106 pScanResult->BssDescriptor.bssId[3],
1107 pScanResult->BssDescriptor.bssId[4],
1108 pScanResult->BssDescriptor.bssId[5],
1109 abs(pScanResult->BssDescriptor.rssi));
Jeff Johnson295189b2012-06-20 16:38:30 -07001110
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001111 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1113 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001114 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001115 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1116 "SKIP-currently associated AP\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 continue;
1118 }
1119
Jeff Johnson43971f52012-07-17 12:26:56 -07001120 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1121 * is disabled and we continue to roam without any check*/
1122 if(RoamRssiDiff > 0)
1123 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001124 /*
1125 * If RSSI is lower than the lookup threshold, then continue.
1126 */
1127 if (abs(pScanResult->BssDescriptor.rssi) >
1128 pNeighborRoamInfo->currentNeighborLookupThreshold)
1129 {
1130 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1131 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)\n",
1132 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1133 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1134 continue;
1135 }
1136
Jeff Johnson43971f52012-07-17 12:26:56 -07001137 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1138 {
1139 /*Do not roam to an AP with worse RSSI than the current*/
1140 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1141 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d\n", __func__,
1142 CurrAPRssi,
1143 (int)pScanResult->BssDescriptor.rssi * (-1) );
1144 continue;
1145 } else {
1146 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1147 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1148 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1149 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001150 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1151 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d\n", __func__,
1152 CurrAPRssi,
1153 (int)pScanResult->BssDescriptor.rssi * (-1),
1154 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001155 continue;
1156 }
1157 else {
1158 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1159 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d\n", __func__,
1160 CurrAPRssi,
1161 (int)pScanResult->BssDescriptor.rssi * (-1) );
1162 }
1163 }
1164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166#ifdef WLAN_FEATURE_VOWIFI_11R
1167 if (pNeighborRoamInfo->is11rAssoc)
1168 {
1169 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1170 {
1171 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1172 continue;
1173 }
1174 }
1175#endif /* WLAN_FEATURE_VOWIFI_11R */
1176
1177#ifdef FEATURE_WLAN_CCX
1178 if (pNeighborRoamInfo->isCCXAssoc)
1179 {
1180 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1181 {
1182 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1183 continue;
1184 }
1185 }
1186 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1187 (pScanResult->BssDescriptor.QBSSLoad_avail))
1188 {
1189 if (pNeighborRoamInfo->isVOAdmitted)
1190 {
1191 smsLog(pMac, LOG1, FL("New AP has %x BW available\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1192 smsLog(pMac, LOG1, FL("We need %x BW available\n"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
1193 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1194 {
1195 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1196 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list\n",
1197 pScanResult->BssDescriptor.bssId[0],
1198 pScanResult->BssDescriptor.bssId[1],
1199 pScanResult->BssDescriptor.bssId[2],
1200 pScanResult->BssDescriptor.bssId[3],
1201 pScanResult->BssDescriptor.bssId[4],
1202 pScanResult->BssDescriptor.bssId[5]);
1203 continue;
1204 }
1205 }
1206 }
1207 else
1208 {
1209 smsLog(pMac, LOGE, FL("No QBss %x %x\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
1210 if (pNeighborRoamInfo->isVOAdmitted)
1211 {
1212 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1213 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no QBSSLoad IE, ignoring..not adding to roam list\n",
1214 pScanResult->BssDescriptor.bssId[0],
1215 pScanResult->BssDescriptor.bssId[1],
1216 pScanResult->BssDescriptor.bssId[2],
1217 pScanResult->BssDescriptor.bssId[3],
1218 pScanResult->BssDescriptor.bssId[4],
1219 pScanResult->BssDescriptor.bssId[5]);
1220 continue;
1221 }
1222 }
1223#endif /* FEATURE_WLAN_CCX */
1224
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001225#ifdef FEATURE_WLAN_LFR
1226 // If we are supporting legacy roaming, and
1227 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301228 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001229 {
1230 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1231 {
1232 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1233 continue;
1234 }
1235 }
1236#endif /* FEATURE_WLAN_LFR */
1237
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1239 * this result */
1240 if (pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1241 {
1242 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1243 continue;
1244 }
1245
1246 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1247 if (NULL == pBssInfo)
1248 {
1249 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1250 continue;
1251 }
1252
1253 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1254 if (pBssInfo->pBssDescription != NULL)
1255 {
1256 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1257 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1258 }
1259 else
1260 {
1261 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1262 vos_mem_free(pBssInfo);
1263 continue;
1264
1265 }
1266 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1267
1268 /* Just add to the end of the list as it is already sorted by RSSI */
1269 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001270
1271#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srikant Kuppa866893f2012-12-27 17:28:14 -08001272 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001273 {
1274 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1275 "%s: [INFOLOG] potential candidate to roam immediately (diff=%d, expected=%d)",
1276 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1277 immediateRoamRssiDiff);
1278 roamNow = eANI_BOOLEAN_TRUE;
1279 }
1280#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 }
1282
1283 /* 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 */
1284 csrScanResultPurge(pMac, *pScanResultList);
1285
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001286 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001287}
1288
1289/* ---------------------------------------------------------------------------
1290
1291 \fn csrNeighborRoamHandleEmptyScanResult
1292
1293 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1294 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001295 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001297 1. Stop the neighbor scan timer.
1298 2a. If this is the first time we encountered empty scan, then
1299 re-register with TL with modified lookup threshold.
1300 2b. Else if this is the second time we encountered empty scan,
1301 then start neighbor scan results refresh timer (20s).
1302 2c. Else, nothing more to do.
1303 NOTE: In LFR, channels selected for scanning is dervied from
1304 the occuped channel list. Scan cycle following one which
1305 yielded empty results is split into two halves: (i) scan on
1306 channels in the occupied list, and (ii) scan on channels not
1307 in the occupied list. This helps converging faster (while
1308 looking for candidates in the occupied list first), and also,
1309 adds channels to the occupied channel list upon finding candidates
1310 matching SSID profile of interest.
1311
1312 uEmptyScanCount Comments
1313 eFirstEmptyScan Previous scan was done on channels in the
1314 occupied list and yielded potential candidates.
1315 This scan cycle was likely triggered through
1316 receipt of lookup DOWN notification event.
1317 eSecondEmptyScan Previous scan was done on channels in the
1318 occupied list and yielded no candidates. This scan
1319 cycle was triggered through RSSI notification
1320 with modified lookup threshold.
1321 eThirdEmptyScan Previous scan was done on channels NOT in
1322 the occupied list and yielded no candidates. This
1323 scan cycle was triggered immediately after scanning
1324 channels in the occupied list and no candidates
1325 were found.
1326 eFourthEmptyScan Previous scan was done on channels in the
1327 occupied list and yielded no candidates. This scan
1328 cycle was triggered upon expiry of
1329 neighborScanResultsRefreshPeriod (=20s).
1330 eFifthEmptyScan Previous scan was done on channels NOT in
1331 the occupied list and yielded no candidates. This
1332 scan cycle was triggered immediately after scanning
1333 channels in the occupied list and no candidates
1334 were found.
1335
1336 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
1338 \param pMac - The handle returned by macOpen.
1339
1340 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1341
1342---------------------------------------------------------------------------*/
1343static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1344{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001345 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1347 eHalStatus status = eHAL_STATUS_SUCCESS;
1348
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001349 /* Stop neighbor scan timer */
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001351 if (eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 {
1353 smsLog(pMac, LOGW, FL(" palTimerStop failed with status %d\n"), status);
1354 }
1355
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001356 /*
1357 * Increase the neighbor lookup threshold by 3 dB
1358 * after every scan cycle. NOTE: uEmptyScanCount
1359 * would be either 1, 3 or 5 at the end of every
1360 * scan cycle.
1361 */
1362#ifdef FEATURE_WLAN_LFR
1363 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1364 {
1365 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1366 }
1367#endif
1368 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1369 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1370#ifdef FEATURE_WLAN_LFR
1371 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1372#endif
1373 )
1374 {
1375 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1376 }
1377
Jeff Johnson295189b2012-06-20 16:38:30 -07001378#ifdef WLAN_FEATURE_VOWIFI_11R
1379 /* Clear off the old neighbor report details */
1380 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1381#endif
1382
Srikant Kuppa866893f2012-12-27 17:28:14 -08001383 /* Transition to CONNECTED state */
1384 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1385
1386 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1387 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1388
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001389#ifdef FEATURE_WLAN_LFR
1390 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1391 {
1392#endif
1393 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001394 /* Re-register neighbor lookup DOWN threshold callback with TL */
1395 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1396 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1397 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1398
1399 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1400 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1401 WLANTL_HO_THRESHOLD_DOWN,
1402 csrNeighborRoamNeighborLookupDOWNCallback,
1403 VOS_MODULE_ID_SME, pMac);
1404
1405 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1406 {
1407 smsLog(pMac, LOGW,
1408 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
1409 " with TL: Status = %d\n"), status);
1410 }
1411#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08001412 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001413 }
1414 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1415 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1416 {
1417 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001418
1419 /* Immediately scan on channels in non-occupied list */
1420 csrNeighborRoamTransitToCFGChanScan(pMac);
1421 }
1422 else if (pNeighborRoamInfo->uEmptyScanCount == eThirdEmptyScan)
1423 {
1424 /* Empty scan results for the third time */
Srikant Kuppa866893f2012-12-27 17:28:14 -08001425
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001426 /* Start neighbor scan results refresh timer */
1427 if (eHAL_STATUS_SUCCESS !=
1428 palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001429 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001430 eANI_BOOLEAN_FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001432 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1433 status);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001434 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1435 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001436 vosStatus = VOS_STATUS_E_FAILURE;
1437 }
1438 else
1439 {
1440 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1441 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001444
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001445 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d",
1446 pNeighborRoamInfo->uEmptyScanCount);
1447#endif
1448 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001449}
1450
Jeff Johnson295189b2012-06-20 16:38:30 -07001451
Srikant Kuppa866893f2012-12-27 17:28:14 -08001452static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001453{
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 tCsrScanResultFilter scanFilter;
1456 tScanResultHandle scanResult;
1457 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001458 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001459 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001461#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1463 should use the BSSID filter made out of neighbor reports */
1464 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1465 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001466 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1467 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 -07001468 tempVal = 1;
1469 }
1470 else
1471#endif
1472 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001473 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1474 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 -07001475 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001476 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 {
1478 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1479 return eHAL_STATUS_FAILURE;
1480 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001481 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301482 if (hstatus != eHAL_STATUS_SUCCESS)
1483 {
1484 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001487 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
1489 /* Free the scan filter */
1490 csrFreeScanFilter(pMac, &scanFilter);
1491
1492 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1493
1494 switch(pNeighborRoamInfo->neighborRoamState)
1495 {
1496 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1497 if (tempVal)
1498 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001499#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001500 /*
1501 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001502 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001503 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001504 pNeighborRoamInfo->uEmptyScanCount = 0;
1505#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001506#ifdef WLAN_FEATURE_VOWIFI_11R
1507 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1508 APs in the roamable AP list */
1509 if (pNeighborRoamInfo->is11rAssoc)
1510 {
1511 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1512 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1513 }
1514 else
1515#endif
1516#ifdef FEATURE_WLAN_CCX
1517 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1518 APs in the roamable AP list */
1519 if (pNeighborRoamInfo->isCCXAssoc)
1520 {
1521 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1522 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1523 }
1524 else
1525#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001526#ifdef FEATURE_WLAN_LFR
1527 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1528 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301529 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001530 {
1531 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1532 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1533 }
1534 else
1535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 {
1537
1538 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1539 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1540 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1541 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1542 within certain duration */
1543
1544// palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
1545 }
1546 }
1547 else
1548 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001549 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1550 /* Handle it appropriately */
1551 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 }
1553 break;
1554#ifdef WLAN_FEATURE_VOWIFI_11R
1555 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1556 if (!tempVal)
1557 {
1558 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1559 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1560 csrNeighborRoamTransitToCFGChanScan(pMac);
1561 }
1562 break;
1563#endif /* WLAN_FEATURE_VOWIFI_11R */
1564 default:
1565 // Can come only in INIT state. Where in we are associated, we sent scan and user
1566 // in the meantime decides to disassoc, we will be in init state and still received call
1567 // back issued. Should not come here in any other state, printing just in case
1568 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1569 "%s: [INFOLOG] State %d\n", __func__, (pNeighborRoamInfo->neighborRoamState));
1570
1571 // Lets just exit out silently.
1572 return eHAL_STATUS_SUCCESS;
1573 }
1574
1575 if (tempVal)
1576 {
1577 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1578
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001579 if (roamNow)
1580 {
1581 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
1582 FL("Immediate roam-deregister UP indication. RSSI = %d"),
1583 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1584
1585 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
1586 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1587 WLANTL_HO_THRESHOLD_UP,
1588 csrNeighborRoamNeighborLookupUPCallback,
1589 VOS_MODULE_ID_SME);
1590
1591 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1592 {
1593 smsLog(pMac, LOGW,
1594 FL("Couldn't deregister lookup UP callback with TL: Status = %d\n"), vosStatus);
1595 }
1596
1597 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
1598 return eHAL_STATUS_SUCCESS;
1599 }
1600
Srikant Kuppa866893f2012-12-27 17:28:14 -08001601 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1602 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1603 eANI_BOOLEAN_FALSE);
1604
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
1606 * 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 -08001607 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08001609 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1611 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001612 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001614
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
1616 /* Register a reassoc Indication callback */
1617 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
1618 WLANTL_HO_THRESHOLD_DOWN,
1619 csrNeighborRoamReassocIndCallback,
1620 VOS_MODULE_ID_SME, pMac);
1621
1622 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1623 {
1624 //err msg
1625 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
1626 }
1627
1628 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08001629
1630 return eHAL_STATUS_SUCCESS;
1631
1632}
1633
1634
1635/* ---------------------------------------------------------------------------
1636
1637 \fn csrNeighborRoamScanRequestCallback
1638
1639 \brief This function is the callback function registered in csrScanRequest() to
1640 indicate the completion of scan. If scan is completed for all the channels in
1641 the channel list, this function gets the scan result and starts the refresh results
1642 timer to avoid having stale results. If scan is not completed on all the channels,
1643 it restarts the neighbor scan timer which on expiry issues scan on the next
1644 channel
1645
1646 \param halHandle - The handle returned by macOpen.
1647 pContext - not used
1648 scanId - not used
1649 status - not used
1650
1651 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1652
1653---------------------------------------------------------------------------*/
1654static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
1655 tANI_U32 scanId, eCsrScanStatus status)
1656{
1657 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1658 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1659 tANI_U8 currentChanIndex;
1660 eHalStatus hstatus;
1661
1662 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1663
1664 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1665 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1666 {
1667 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1668 return eHAL_STATUS_SUCCESS;
1669 }
1670
1671 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
1672 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
1673
1674 /* Validate inputs */
1675 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
1676 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
1677 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
1678 }
1679 else
1680 {
1681 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
1682 return eHAL_STATUS_SUCCESS;
1683 }
1684
1685 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1686 {
1687 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
1688 just to get the results and perform PREAUTH */
1689 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
1690 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
1691 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
1692 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
1693
1694 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1695
1696 if (eHAL_STATUS_SUCCESS != hstatus)
1697 {
1698 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1699 return eHAL_STATUS_FAILURE;
1700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 }
1702 else
1703 {
1704
1705 /* Restart the timer for the next scan sequence as scanning is not over */
Jeff Johnson43971f52012-07-17 12:26:56 -07001706 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
1708 eANI_BOOLEAN_FALSE);
1709
Jeff Johnson43971f52012-07-17 12:26:56 -07001710 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 {
1712 /* Timer start failed.. Should we ASSERT here??? */
1713 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
1714 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1715 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001716 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001717 }
1718 }
1719 return eHAL_STATUS_SUCCESS;
1720}
1721
Srikant Kuppa866893f2012-12-27 17:28:14 -08001722#ifdef FEATURE_WLAN_LFR
1723static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
1724 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
1725{
1726 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1727 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1728 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
1729
1730 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1731
1732 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1733 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1734 {
1735 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1736 return eHAL_STATUS_SUCCESS;
1737 }
1738
1739 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
1740 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1741
1742 if (eHAL_STATUS_SUCCESS != hstatus)
1743 {
1744 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1745 }
1746
1747 return hstatus;
1748}
1749#endif
1750
Jeff Johnson295189b2012-06-20 16:38:30 -07001751/* ---------------------------------------------------------------------------
1752
1753 \fn csrNeighborRoamIssueBgScanRequest
1754
1755 \brief This function issues CSR scan request after populating all the BG scan params
1756 passed
1757
1758 \param pMac - The handle returned by macOpen.
1759 pBgScanParams - Params that need to be populated into csr Scan request
1760
1761 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1762
1763---------------------------------------------------------------------------*/
Srikant Kuppa866893f2012-12-27 17:28:14 -08001764eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
1765 tCsrBGScanRequest *pBgScanParams,
1766 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07001767{
1768 eHalStatus status = eHAL_STATUS_SUCCESS;
1769 tANI_U32 scanId;
1770 tCsrScanRequest scanReq;
1771 tANI_U8 channel;
1772
Srikant Kuppa866893f2012-12-27 17:28:14 -08001773 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1774 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
1775 pBgScanParams->ChannelInfo.ChannelList[0],
1776 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001777
1778 //send down the scan req for 1 channel on the associated SSID
1779 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
1780 /* Fill in the SSID Info */
1781 scanReq.SSIDs.numOfSSIDs = 1;
1782 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1783 if(NULL == scanReq.SSIDs.SSIDList)
1784 {
1785 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301786 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 -07001787 return eHAL_STATUS_FAILURE;
1788 }
1789 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1790
1791 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
1792 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
1793 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
1794
1795 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001796 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1797 {
1798 channel = pBgScanParams->ChannelInfo.ChannelList[0];
1799 scanReq.ChannelInfo.ChannelList = &channel;
1800 }
1801 else
1802 {
1803 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
1804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001805
1806 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
1807 scanReq.scanType = eSIR_ACTIVE_SCAN;
1808 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
1809 scanReq.maxChnTime = pBgScanParams->maxChnTime;
1810 scanReq.minChnTime = pBgScanParams->minChnTime;
1811 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Srikant Kuppa866893f2012-12-27 17:28:14 -08001812 &scanId, callbackfn, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 if (eHAL_STATUS_SUCCESS != status)
1814 {
1815 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
1816 vos_mem_free(scanReq.SSIDs.SSIDList);
1817 return status;
1818 }
1819 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
1820
1821 vos_mem_free(scanReq.SSIDs.SSIDList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001822 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1823 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
1824 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
1825 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
1826
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 return status;
1828}
1829
Srikant Kuppa866893f2012-12-27 17:28:14 -08001830static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
1831 tpCsrBGScanRequest bgScanParams)
1832{
1833 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1834 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1835
1836 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
1837 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
1838 vos_mem_copy(bgScanParams->SSID.ssId,
1839 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
1840 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
1841
1842 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
1843 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
1844}
1845
Jeff Johnson295189b2012-06-20 16:38:30 -07001846/* ---------------------------------------------------------------------------
1847
1848 \fn csrNeighborRoamPerformBgScan
1849
1850 \brief This function is invoked on every expiry of neighborScanTimer till all
1851 the channels in the channel list are scanned. It populates necessary
1852 parameters for BG scan and calls appropriate AP to invoke the CSR scan
1853 request
1854
1855 \param pMac - The handle returned by macOpen.
1856
1857 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1858
1859---------------------------------------------------------------------------*/
1860eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac)
1861{
1862 eHalStatus status = eHAL_STATUS_SUCCESS;
1863 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1864 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 tANI_U8 channel = 0;
1866
1867 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1868 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301869 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 }
1871 else
1872 {
1873 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson902c9832012-12-10 14:28:09 -08001874 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 // When timer start is declared a failure, then we delete the list.
1876 // Should not happen now as we stop and then only start the scan timer.
1877 // still handle the unlikely case.
1878 csrNeighborRoamHandleEmptyScanResult(pMac);
1879 return status;
1880 }
1881 /* Need to perform scan here before getting the list */
Srikant Kuppa866893f2012-12-27 17:28:14 -08001882
1883 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07001884
1885 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
1886 bgScanParams.ChannelInfo.numOfChannels = 1;
1887 bgScanParams.ChannelInfo.ChannelList = &channel;
1888
Srikant Kuppa866893f2012-12-27 17:28:14 -08001889 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001890
Srikant Kuppa866893f2012-12-27 17:28:14 -08001891 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
1892 csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 if (eHAL_STATUS_SUCCESS != status)
1894 {
1895 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 }
1897
1898 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
1899 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
1900 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
1901 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301902 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
1904 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
1905 /* We have completed scanning all the channels */
1906 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
1907 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
1908 and select the best AP in the list */
1909 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1910 {
1911 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
1912 }
1913 }
1914
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08001915 if (eHAL_STATUS_SUCCESS != status)
1916 {
1917 /*
1918 * If the status is not success, we need to call the callback
1919 * routine so that the state machine does not get stuck.
1920 */
1921 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
1922 }
1923
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 return status;
1925}
1926
Srikant Kuppa866893f2012-12-27 17:28:14 -08001927#ifdef FEATURE_WLAN_LFR
1928eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac)
1929{
1930 eHalStatus status = eHAL_STATUS_SUCCESS;
1931 tCsrBGScanRequest bgScanParams;
1932 int numOfChannels = 0, i = 0;
1933 tANI_U8 *channelList = NULL;
1934
1935 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
1936
1937 /* Contiguously scan all channels from valid list */
1938 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
1939 numOfChannels = sizeof(pMac->roam.validChannelList);
1940
1941 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
1942 (tANI_U8 *)pMac->roam.validChannelList,
1943 (tANI_U32 *) &numOfChannels)))
1944 {
1945 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
1946 return eHAL_STATUS_FAILURE;
1947 }
1948
1949 channelList = vos_mem_malloc( numOfChannels );
1950 if( NULL == channelList )
1951 {
1952 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
1953 return eHAL_STATUS_FAILURE;
1954 }
1955 vos_mem_copy(channelList, (tANI_U8 *)pMac->roam.validChannelList,
1956 numOfChannels * sizeof(tANI_U8));
1957
1958 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
1959 bgScanParams.ChannelInfo.ChannelList = channelList;
1960 for (i = 0; i < numOfChannels; i++)
1961 {
1962 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d\n",
1963 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
1964 }
1965 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
1966
1967 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
1968 csrNeighborRoamContiguousScanRequestCallback);
1969
1970 vos_mem_free( channelList );
1971
1972 if (eHAL_STATUS_SUCCESS != status)
1973 {
1974 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
1975 }
1976
1977 return status;
1978}
1979#endif
1980
Jeff Johnson295189b2012-06-20 16:38:30 -07001981/* ---------------------------------------------------------------------------
1982
1983 \fn csrNeighborRoamNeighborScanTimerCallback
1984
1985 \brief This function is the neighbor scan timer callback function. It invokes
1986 the BG scan request based on the current and previous states
1987
1988 \param pv - CSR timer context info which includes pMac and session ID
1989
1990 \return VOID
1991
1992---------------------------------------------------------------------------*/
1993void csrNeighborRoamNeighborScanTimerCallback(void *pv)
1994{
1995 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
1996 tpAniSirGlobal pMac = pInfo->pMac;
1997 tANI_U32 sessionId = pInfo->sessionId;
1998 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1999
2000 // check if bg scan is on going, no need to send down the new params if true
2001 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2002 {
2003 //msg
2004 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending\n"));
2005 return;
2006 }
2007
2008 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
2009
2010 switch (pNeighborRoamInfo->neighborRoamState)
2011 {
2012#ifdef WLAN_FEATURE_VOWIFI_11R
2013 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2014 switch(pNeighborRoamInfo->prevNeighborRoamState)
2015 {
2016 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2017 csrNeighborRoamPerformBgScan(pMac);
2018 break;
2019 default:
2020 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
2021 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
2022 break;
2023 }
2024 break;
2025#endif /* WLAN_FEATURE_VOWIFI_11R */
2026 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
2027 csrNeighborRoamPerformBgScan(pMac);
2028 break;
2029 default:
2030 break;
2031 }
2032 return;
2033}
2034
2035/* ---------------------------------------------------------------------------
2036
2037 \fn csrNeighborRoamResultsRefreshTimerCallback
2038
2039 \brief This function is the timer callback function for results refresh timer.
2040 When this is invoked, it is as good as down event received from TL. So,
2041 clear off the roamable AP list and start the scan procedure based on 11R
2042 or non-11R association
2043
2044 \param context - CSR timer context info which includes pMac and session ID
2045
2046 \return VOID
2047
2048---------------------------------------------------------------------------*/
2049void csrNeighborRoamResultsRefreshTimerCallback(void *context)
2050{
2051 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2052 tpAniSirGlobal pMac = pInfo->pMac;
2053 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2054 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2055
2056 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2057
2058 /* Deregister reassoc callback. Ignore return status */
2059 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2060 WLANTL_HO_THRESHOLD_DOWN,
2061 csrNeighborRoamReassocIndCallback,
2062 VOS_MODULE_ID_SME);
2063
2064 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2065 {
2066 //err msg
2067 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
2068 }
2069
2070 /* Reset all the variables just as no scan had happened before */
2071 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2072
2073#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2074 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2075 {
2076 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2077 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2078 if (VOS_STATUS_SUCCESS != vosStatus)
2079 {
2080 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2081 return;
2082 }
2083 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2084 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2085 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2086 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2087 }
2088 else
2089#endif
2090 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002091 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2093 if (VOS_STATUS_SUCCESS != vosStatus)
2094 {
2095 return;
2096 }
2097 }
2098 return;
2099}
2100
2101#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2102/* ---------------------------------------------------------------------------
2103
2104 \fn csrNeighborRoamIssueNeighborRptRequest
2105
2106 \brief This function is invoked when TL issues a down event and the current assoc
2107 is a 11R association. It invokes SME RRM API to issue the neighbor request to
2108 the currently associated AP with the current SSID
2109
2110 \param pMac - The handle returned by macOpen.
2111
2112 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2113
2114---------------------------------------------------------------------------*/
2115VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
2116{
2117 tRrmNeighborRspCallbackInfo callbackInfo;
2118 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2119 tRrmNeighborReq neighborReq;
2120
2121
2122 neighborReq.no_ssid = 0;
2123
2124 /* Fill in the SSID */
2125 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2126 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2127 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2128
2129 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
2130 callbackInfo.neighborRspCallbackContext = pMac;
2131 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
2132
2133 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
2134}
2135
2136/* ---------------------------------------------------------------------------
2137
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002138 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002139
2140 \brief This function is used to merge two channel list.
2141 NB: If called with outputNumOfChannels == 0, this routines
2142 simply copies the input channel list to the output channel list.
2143
2144 \param pMac - The handle returned by macOpen.
2145 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
2146 \param inputNumOfChannels - The number of additional channels.
2147 \param pOutputChannelList - The place to put the "merged" channel list.
2148 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
2149 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
2150
2151 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2152
2153---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002154VOS_STATUS csrNeighborRoamMergeChannelLists(
2155 tpAniSirGlobal pMac,
2156 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002157 int inputNumOfChannels,
2158 tANI_U8 *pOutputChannelList,
2159 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002160 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002161 )
2162{
2163 int i = 0;
2164 int j = 0;
2165 int numChannels = outputNumOfChannels;
2166
2167 // Check for NULL pointer
2168 if (!pInputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2169
2170 // Check for NULL pointer
2171 if (!pOutputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2172
2173 // Add the "new" channels in the input list to the end of the output list.
2174 for (i = 0; i < inputNumOfChannels; i++)
2175 {
2176 for (j = 0; j < outputNumOfChannels; j++)
2177 {
2178 if (pInputChannelList[i] == pOutputChannelList[j])
2179 break;
2180 }
2181 if (j == outputNumOfChannels)
2182 {
2183 if (pInputChannelList[i])
2184 {
Madan Mohan Koyyalamudif5c368b2012-12-06 13:10:13 -08002185 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002186 "%s: [INFOLOG] Adding extra %d to Neighbor channel list\n", __func__,
2187 pInputChannelList[i]);
2188 pOutputChannelList[numChannels] = pInputChannelList[i];
2189 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002190 }
2191 }
2192 }
2193
2194 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002195 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002196
2197 return eHAL_STATUS_SUCCESS;
2198}
2199
2200/* ---------------------------------------------------------------------------
2201
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 \fn csrNeighborRoamCreateChanListFromNeighborReport
2203
2204 \brief This function is invoked when neighbor report is received for the
2205 neighbor request. Based on the channels present in the neighbor report,
2206 it generates channel list which will be used in REPORT_SCAN state to
2207 scan for these neighbor APs
2208
2209 \param pMac - The handle returned by macOpen.
2210
2211 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2212
2213---------------------------------------------------------------------------*/
2214VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2215{
2216 tpRrmNeighborReportDesc pNeighborBssDesc;
2217 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002218 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002220#if 0
2221 eHalStatus status = eHAL_STATUS_SUCCESS;
2222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002223
2224 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2225 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2226
2227 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2228
2229 while (pNeighborBssDesc)
2230 {
2231 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2232
2233 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2234 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2235 pNeighborBssDesc->pNeighborBssDescription->channel;
2236 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2237 (tANI_U8)pNeighborBssDesc->roamScore;
2238 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2239 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2240 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2241
2242 /* Saving the channel list non-redundantly */
2243 if (numChannels > 0)
2244 {
2245 for (i = 0; i < numChannels; i++)
2246 {
2247 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2248 break;
2249 }
2250
2251 }
2252 if (i == numChannels)
2253 {
2254 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2255 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2257 "%s: [INFOLOG] Adding %d to Neighbor channel list\n", __func__,
2258 pNeighborBssDesc->pNeighborBssDescription->channel);
2259 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2260 numChannels++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 }
2262 }
2263
2264 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2265 }
2266
2267 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2268 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002269#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002271 // we have a union of the IAPP and the already existing list.
2272 status = csrNeighborRoamMergeChannelLists(
2273 pMac,
2274 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2275 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2276 channelList,
2277 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002278 &numChannels );
2279#endif
2280
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2282 }
2283
2284 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2285 /* Store the obtained channel list to the Neighbor Control data structure */
2286 if (numChannels)
2287 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2288 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2289 {
2290 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2291 return VOS_STATUS_E_RESOURCES;
2292 }
2293
2294 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2295 channelList, (numChannels) * sizeof(tANI_U8));
2296 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2297 if (numChannels)
2298 {
2299 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
2300 pNeighborRoamInfo->neighborRoamState);
2301 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
2302 }
2303 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2304 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
2305
2306 return VOS_STATUS_SUCCESS;
2307}
2308
2309/* ---------------------------------------------------------------------------
2310
2311 \fn csrNeighborRoamRRMNeighborReportResult
2312
2313 \brief This function is the neighbor report callback that will be invoked by
2314 SME RRM on receiving a neighbor report or of neighbor report is not
2315 received after timeout. On receiving a valid report, it generates a
2316 channel list from the neighbor report and starts the
2317 neighbor scan timer
2318
2319 \param context - The handle returned by macOpen.
2320 vosStatus - Status of the callback(SUCCESS/FAILURE)
2321
2322 \return VOID
2323
2324---------------------------------------------------------------------------*/
2325void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
2326{
2327 tpAniSirGlobal pMac = PMAC_STRUCT(context);
2328 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2329 eHalStatus status = eHAL_STATUS_SUCCESS;
2330
2331 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d\n"), vosStatus);
2332 switch (pNeighborRoamInfo->neighborRoamState)
2333 {
2334 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2335 /* Reset the report pending variable */
2336 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
2337 if (VOS_STATUS_SUCCESS == vosStatus)
2338 {
2339 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
2340 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
2341 if (VOS_STATUS_SUCCESS == vosStatus)
2342 {
2343 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state\n"));
2344 }
2345
2346 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2347 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2348
2349 /* Now ready for neighbor scan based on the channel list created */
2350 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2351 what palTimerStart expects */
2352 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2353 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2354 eANI_BOOLEAN_FALSE);
2355 if (eHAL_STATUS_SUCCESS != status)
2356 {
2357 /* Timer start failed.. Should we ASSERT here??? */
2358 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
2359 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2360 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2361 return;
2362 }
2363 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2364 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
2365 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2366 }
2367 else
2368 {
2369 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
2370 reach the maxNeighborRetries or receiving a successful neighbor response */
2371 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d\n"),
2372 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
2373 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
2374 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
2375 {
2376 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. \n"));
2377 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2378 if (VOS_STATUS_SUCCESS != vosStatus)
2379 {
2380 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d \n"), vosStatus);
2381 return;
2382 }
2383 /* We transitioned to different state now. Reset the Neighbor report retry count */
2384 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2385 }
2386 else
2387 {
2388 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2389 if (VOS_STATUS_SUCCESS != vosStatus)
2390 {
2391 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2392 return;
2393 }
2394 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2395 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2396 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2397 }
2398 }
2399 break;
2400 default:
2401 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
2402 break;
2403 }
2404 return;
2405}
2406#endif /* WLAN_FEATURE_VOWIFI_11R */
2407
2408
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002409#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002410tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002411 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002412 tCsrRoamConnectedProfile *pCurProfile,
2413 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002414 tDot11fBeaconIEs *pIes)
2415{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002416 tCsrAuthList authType;
2417 tCsrEncryptionList uCEncryptionType;
2418 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002419 tANI_BOOLEAN fMatch = FALSE;
2420
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002421 authType.numEntries = 1;
2422 authType.authType[0] = pCurProfile->AuthType;
2423 uCEncryptionType.numEntries = 1;
2424 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
2425 mCEncryptionType.numEntries = 1;
2426 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002427
2428 if( pIes )
2429 {
2430 if(pIes->SSID.present)
2431 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002432 fMatch = csrIsSsidMatch( pMac,
2433 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
2434 pIes->SSID.ssid, pIes->SSID.num_ssid,
2435 eANI_BOOLEAN_TRUE );
2436 if(TRUE == fMatch)
2437 {
2438 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
2439 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
2440 return (fMatch);
2441 }
2442 else
2443 {
2444 return (fMatch);
2445 }
2446
2447 }
2448 else
2449 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002450 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002451 }
2452 }
2453 else
2454 {
2455 return FALSE; // Again, treat missing pIes as a non-match.
2456 }
2457}
2458
2459tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
2460 tpAniSirGlobal pMac)
2461{
2462 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2463 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2464 tCsrRoamConnectedProfile *pCurrProfile = NULL;
2465 tCsrRoamConnectedProfile *pPrevProfile = NULL;
2466 tDot11fBeaconIEs *pIes = NULL;
2467 tSirBssDescription *pBssDesc = NULL;
2468 tANI_BOOLEAN fNew = TRUE;
2469
2470 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
2471 {
2472 return (fNew);
2473 }
2474
2475 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2476 if( !pCurrProfile )
2477 {
2478 return (fNew);
2479}
2480
2481 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
2482 if( !pPrevProfile )
2483 {
2484 return (fNew);
2485 }
2486
2487 pBssDesc = pPrevProfile->pBssDesc;
2488 if (pBssDesc)
2489 {
2490 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
2491 pBssDesc, &pIes)) &&
2492 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
2493 {
2494 fNew = FALSE;
2495 }
2496 if (pIes) {
2497 palFreeMemory(pMac->hHdd, pIes);
2498 }
2499 }
2500
2501 if (fNew)
2502 {
2503 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
2504 csrRoamFreeConnectProfile(pMac, pPrevProfile);
2505 csrRoamGetConnectProfile(pMac, sessionId, pPrevProfile);
2506 }
2507 else
2508 {
2509 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
2510 }
2511
2512 return (fNew);
2513}
2514
2515tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
2516 tpAniSirGlobal pMac,
2517 tCsrScanResult *pResult,
2518 tDot11fBeaconIEs *pIes)
2519{
2520 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2521 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2522 tCsrRoamConnectedProfile *pCurProfile = NULL;
2523 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
2524
2525 if( !(pMac->roam.roamSession
2526 && CSR_IS_SESSION_VALID(pMac, sessionId)))
2527 {
2528 return FALSE;
2529 }
2530
2531 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2532
2533 if( !pCurProfile)
2534 {
2535 return FALSE;
2536 }
2537
2538 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002539}
2540
2541/* ---------------------------------------------------------------------------
2542
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002543 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002544
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002545 \brief This function is used to prepare a channel list that is derived from
2546 the list of valid channels and does not include those in the occupied
2547 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002548
2549 \param pMac - The handle returned by macOpen.
2550 \param pInputChannelList - The default channels list.
2551 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002552 \param pOutputChannelList - The place to put the non-occupied channel list.
2553 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002554
2555 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2556
2557---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002558VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002559 tpAniSirGlobal pMac,
2560 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002561 int numOfChannels,
2562 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002563 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002564 )
2565{
2566 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002567 int outputNumOfChannels = 0; // Clear the output number of channels
2568 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
2569 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
2570
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002571 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002572 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002573 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
2574 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002575 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002576 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002577 }
2578 }
2579
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002580 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
2581 "Number of channels in the non-occupied list list=%d"),
2582 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002583
2584 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002585 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002586
2587 return eHAL_STATUS_SUCCESS;
2588}
2589#endif /* FEATURE_WLAN_LFR */
2590
Jeff Johnson295189b2012-06-20 16:38:30 -07002591/* ---------------------------------------------------------------------------
2592
2593 \fn csrNeighborRoamTransitToCFGChanScan
2594
2595 \brief This function is called whenever there is a transition to CFG chan scan
2596 state from any state. It frees up the current channel list and allocates
2597 a new memory for the channels received from CFG item. It then starts the
2598 neighbor scan timer to perform the scan on each channel one by one
2599
2600 \param pMac - The handle returned by macOpen.
2601
2602 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2603
2604---------------------------------------------------------------------------*/
2605VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
2606{
2607 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2608 eHalStatus status = eHAL_STATUS_SUCCESS;
2609 int i = 0;
2610 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002611 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002612 tpCsrChannelInfo currChannelListInfo;
2613
2614 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002615
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002616 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07002617#ifdef FEATURE_WLAN_CCX
2618 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002619 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
2621#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002622 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002624 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002625
2626
2627 /* Free up the channel list and allocate a new memory. This is because we dont know how much
2628 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
2629 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002630 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002632 vos_mem_free(currChannelListInfo->ChannelList);
2633 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002635
2636 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
2637 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
2638 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002640 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
2641 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002642 status = csrNeighborRoamMergeChannelLists(
2643 pMac,
2644 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
2645 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
2646 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002647 0, //NB: If 0, simply copy the input channel list to the output list.
2648 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002649
2650 currChannelListInfo->ChannelList =
2651 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2652 if (NULL == currChannelListInfo->ChannelList)
2653 {
2654 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2655 return VOS_STATUS_E_RESOURCES;
2656 }
2657
2658 vos_mem_copy(currChannelListInfo->ChannelList,
2659 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002660 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002661#ifdef FEATURE_WLAN_LFR
2662 else if (abs(pNeighborRoamInfo->lookupDOWNRssi) >
2663 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold))
2664 {
2665 /*
2666 * Trigger a contiguous scan on all channels when the
2667 * RSSI in the lookup DOWN notification is below reassoc
2668 * threshold. This will help us find the best available
2669 * candidate and also update the channel cache.
2670 */
2671 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
2672 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
2673 pNeighborRoamInfo->lookupDOWNRssi,
2674 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
2675
2676 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2677
2678 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2679
2680 /* We are about to start a fresh scan cycle,
2681 * purge non-P2P results from the past */
2682 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
2683
2684 csrNeighborRoamPerformContiguousBgScan(pMac);
2685
2686 /* Transition to CFG_CHAN_LIST_SCAN */
2687 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
2688
2689 return VOS_STATUS_SUCCESS;
2690 }
2691#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002692 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002693 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002694 numOfChannels = pMac->scan.occupiedChannels.numChannels;
2695 if (numOfChannels
2696#ifdef FEATURE_WLAN_LFR
2697 && ((pNeighborRoamInfo->uEmptyScanCount == 0) ||
2698 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
2699#endif
2700 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002702 /*
2703 * Always scan channels in the occupied channel list
2704 * before scanning on the non-occupied list.
2705 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302706 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to occupied channel list");
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002707 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
2708 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels);
2709
2710 if (NULL == currChannelListInfo->ChannelList)
2711 {
2712 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2713 return VOS_STATUS_E_RESOURCES;
2714 }
2715 vos_mem_copy(currChannelListInfo->ChannelList,
2716 pMac->scan.occupiedChannels.channelList,
2717 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002718 }
2719 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002720 {
2721 /* Scan all channels from non-occupied list */
2722 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
2723 numOfChannels = sizeof(pMac->roam.validChannelList);
2724
2725 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2726 (tANI_U8 *)pMac->roam.validChannelList,
2727 (tANI_U32 *) &numOfChannels)))
2728 {
2729#ifdef FEATURE_WLAN_LFR
2730 /*
2731 * Prepare non-occupied channel list (channelList)
2732 * from the actual "valid channel list" information
2733 * formed by CSR.
2734 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302735 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
2736 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
2737 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002738 numOfChannels,
2739 channelList,
2740 &numOfChannels);
2741#else
2742 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
2743 status = csrNeighborRoamMergeChannelLists(
2744 pMac,
2745 (tANI_U8 *)pMac->roam.validChannelList,
2746 numOfChannels, // The number of channels in the validChannelList
2747 channelList,
2748 0, //NB: If 0, simply copy the input channel list to the output list.
2749 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
2750#endif
2751 }
2752 else
2753 {
2754 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002755 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002757 currChannelListInfo->ChannelList =
2758 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2759
2760 if (NULL == currChannelListInfo->ChannelList)
2761 {
2762 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2763 return VOS_STATUS_E_RESOURCES;
2764 }
2765#ifdef FEATURE_WLAN_LFR
2766 vos_mem_copy(currChannelListInfo->ChannelList,
2767 channelList, numOfChannels * sizeof(tANI_U8));
2768#else
2769 vos_mem_copy(currChannelListInfo->ChannelList,
2770 (tANI_U8 *)pMac->roam.validChannelList,
2771 numOfChannels * sizeof(tANI_U8));
2772#endif
2773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 }
2775
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002776 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002777 currChannelListInfo->numOfChannels = numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002778 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
2779 "Number of channels from CFG (or) (non-)occupied list=%d",
2780 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002781 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302783 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002784 "= %d\n", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 }
2786 }
2787
2788 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2789 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2790
2791 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2792 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2793 what palTimerStart expects */
2794 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2795 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2796 eANI_BOOLEAN_FALSE);
2797
2798 if (eHAL_STATUS_SUCCESS != status)
2799 {
2800 /* Timer start failed.. */
2801 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002802 vos_mem_free(currChannelListInfo->ChannelList);
2803 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 return VOS_STATUS_E_FAILURE;
2805 }
2806
2807 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2808 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302809 /* We are about to start a fresh scan cycle,
2810 * purge non-P2P results from the past */
2811 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002812
2813 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
2814 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
2815
2816 return VOS_STATUS_SUCCESS;
2817}
2818
2819/* ---------------------------------------------------------------------------
2820
2821 \fn csrNeighborRoamNeighborLookupUpEvent
2822
2823 \brief This function is called as soon as TL indicates that the current AP's
2824 RSSI is better than the neighbor lookup threshold. Here, we transition to
2825 CONNECTED state and reset all the scan parameters
2826
2827 \param pMac - The handle returned by macOpen.
2828
2829 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2830
2831---------------------------------------------------------------------------*/
2832VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
2833{
2834 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2835 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002836 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002837
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 /* Recheck whether the below check is needed. */
2839 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
2840 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Jeff Johnsone7245742012-09-05 17:12:55 -07002841
2842 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
2843 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2844
Jeff Johnson295189b2012-06-20 16:38:30 -07002845
2846 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2847 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
2848 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2849 WLANTL_HO_THRESHOLD_DOWN,
2850 csrNeighborRoamNeighborLookupDOWNCallback,
2851 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002852#ifdef FEATURE_WLAN_LFR
2853 pNeighborRoamInfo->lookupDOWNRssi = 0;
2854#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2856 {
2857 //err msg
2858 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d\n"), vosStatus);
2859 }
2860
2861
2862 return vosStatus;
2863}
2864
2865/* ---------------------------------------------------------------------------
2866
2867 \fn csrNeighborRoamNeighborLookupDownEvent
2868
2869 \brief This function is called as soon as TL indicates that the current AP's
2870 RSSI falls below the current eighbor lookup threshold. Here, we transition to
2871 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
2872 a non-11R association.
2873
2874 \param pMac - The handle returned by macOpen.
2875
2876 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2877
2878---------------------------------------------------------------------------*/
2879VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
2880{
2881 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2882 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2883 eHalStatus status = eHAL_STATUS_SUCCESS;
2884
2885 switch (pNeighborRoamInfo->neighborRoamState)
2886 {
2887 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
2888
2889 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
2890 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2891 /* De-register Neighbor Lookup threshold callback with TL */
2892 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2893 WLANTL_HO_THRESHOLD_DOWN,
2894 csrNeighborRoamNeighborLookupDOWNCallback,
2895 VOS_MODULE_ID_SME);
2896
2897 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2898 {
2899 //err msg
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002900 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 }
2902
2903
2904#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2905 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2906 {
2907
2908 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2909 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2910 if (VOS_STATUS_SUCCESS != vosStatus)
2911 {
2912 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2913 return vosStatus;
2914 }
2915 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2916 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2917 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2918 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2919 }
2920 else
2921#endif
2922 {
2923 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
2924
2925 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2926 if (VOS_STATUS_SUCCESS != vosStatus)
2927 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002928 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
2929 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 return vosStatus;
2931 }
2932 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002933 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 -07002934 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002935 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
2936 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 WLANTL_HO_THRESHOLD_UP,
2938 csrNeighborRoamNeighborLookupUPCallback,
2939 VOS_MODULE_ID_SME, pMac);
2940 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2941 {
2942 //err msg
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002943 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 }
2945 break;
2946 default:
2947 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
2948 break;
2949
2950 }
2951 return vosStatus;
2952}
2953
2954/* ---------------------------------------------------------------------------
2955
2956 \fn csrNeighborRoamNeighborLookupUPCallback
2957
2958 \brief This function is registered with TL to indicate whenever the RSSI
2959 gets better than the neighborLookup RSSI Threshold
2960
2961 \param pAdapter - VOS Context
2962 trafficStatus - UP/DOWN indication from TL
2963 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
2964
2965 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2966
2967---------------------------------------------------------------------------*/
2968VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08002969 v_PVOID_t pUserCtxt,
2970 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07002971{
2972 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
2973 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2974 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
2975
Srinivasdaaec712012-12-12 15:59:44 -08002976 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
2977 rssiNotification,
2978 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07002979
2980 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
2981 {
2982 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
2983 return VOS_STATUS_SUCCESS;
2984 }
2985
2986 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
2987 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
2988 return vosStatus;
2989}
2990
2991/* ---------------------------------------------------------------------------
2992
2993 \fn csrNeighborRoamNeighborLookupDOWNCallback
2994
2995 \brief This function is registered with TL to indicate whenever the RSSI
2996 falls below the current neighborLookup RSSI Threshold
2997
2998 \param pAdapter - VOS Context
2999 trafficStatus - UP/DOWN indication from TL
3000 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3001
3002 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3003
3004---------------------------------------------------------------------------*/
3005VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003006 v_PVOID_t pUserCtxt,
3007 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003008{
3009 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3010 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3011 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3012
Srinivasdaaec712012-12-12 15:59:44 -08003013 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
3014 rssiNotification,
3015 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003016
Srikant Kuppa866893f2012-12-27 17:28:14 -08003017#ifdef FEATURE_WLAN_LFR
3018 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
3019#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3021 {
3022 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
3023 return VOS_STATUS_SUCCESS;
3024 }
3025
3026 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
3027 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
3028
3029 return vosStatus;
3030}
3031
3032#ifdef RSSI_HACK
3033extern int dumpCmdRSSI;
3034#endif
3035
3036/* ---------------------------------------------------------------------------
3037
3038 \fn csrNeighborRoamIndicateDisconnect
3039
3040 \brief This function is called by CSR as soon as the station disconnects from
3041 the AP. This function does the necessary cleanup of neighbor roam data
3042 structures. Neighbor roam state transitions to INIT state whenever this
3043 function is called except if the current state is REASSOCIATING
3044
3045 \param pMac - The handle returned by macOpen.
3046 sessionId - CSR session id that got disconnected
3047
3048 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3049
3050---------------------------------------------------------------------------*/
3051eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
3052{
3053 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3054
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003055 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d (sub-state %d)"),
3056 sessionId, pNeighborRoamInfo->neighborRoamState,
3057 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003058
3059#ifdef FEATURE_WLAN_CCX
3060 {
3061 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
3062 if (pSession->connectedProfile.isCCXAssoc)
3063 {
3064 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
3065 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3066 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
3067 pSession->isPrevApInfoValid = TRUE;
3068 pSession->roamTS1 = vos_timer_get_system_time();
3069
3070 }
3071 }
3072#endif
3073
3074#ifdef RSSI_HACK
3075 dumpCmdRSSI = -40;
3076#endif
3077 switch (pNeighborRoamInfo->neighborRoamState)
3078 {
3079 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3080 // Stop scan and neighbor refresh timers.
3081 // These are indeed not required when we are in reassociating
3082 // state.
3083 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3084 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003085 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
3086 /*
3087 * Disconnect indication during Disassoc Handoff sub-state
3088 * is received when we are trying to disconnect with the old
3089 * AP during roam. BUT, if receive a disconnect indication
3090 * outside of Disassoc Handoff sub-state, then it means that
3091 * this is a genuine disconnect and we need to clean up.
3092 * Otherwise, we will be stuck in reassoc state which will
3093 * in-turn block scans (see csrIsScanAllowed).
3094 */
3095 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 break;
3098
3099 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 csrNeighborRoamResetInitStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003101 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 break;
3103
Srikant Kuppa866893f2012-12-27 17:28:14 -08003104 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3105 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3106 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3107 csrNeighborRoamDeregAllRssiIndication(pMac);
3108 break;
3109
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003110 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
3111 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3112 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
3113 csrNeighborRoamDeregAllRssiIndication(pMac);
3114 break;
3115
3116 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3117 /* Stop pre-auth to reassoc interval timer */
3118 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003119 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3120 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3121 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003122 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003123 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003124 csrNeighborRoamDeregAllRssiIndication(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003125 break;
3126
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003128 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
3129 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 }
3133 return eHAL_STATUS_SUCCESS;
3134}
3135
3136/* ---------------------------------------------------------------------------
3137
3138 \fn csrNeighborRoamIndicateConnect
3139
3140 \brief This function is called by CSR as soon as the station connects to an AP.
3141 This initializes all the necessary data structures related to the
3142 associated AP and transitions the state to CONNECTED state
3143
3144 \param pMac - The handle returned by macOpen.
3145 sessionId - CSR session id that got connected
3146 vosStatus - connect status SUCCESS/FAILURE
3147
3148 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3149
3150---------------------------------------------------------------------------*/
3151eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
3152{
3153 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3154 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07003155 VOS_STATUS vstatus;
3156
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003157#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 int init_ft_flag = FALSE;
3159#endif
3160
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003161 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003162
3163 switch (pNeighborRoamInfo->neighborRoamState)
3164 {
3165 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3166 if (VOS_STATUS_SUCCESS != vosStatus)
3167 {
3168 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
3169 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3170 break;
3171 }
3172 /* Fall through if the status is SUCCESS */
3173 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
3174 /* Reset all the data structures here */
3175 csrNeighborRoamResetInitStateControlInfo(pMac);
3176
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003178
3179#ifdef FEATURE_WLAN_LFR
3180 /*
3181 * Initialize the occupied list ONLY if we are
3182 * transitioning from INIT state to CONNECTED state.
3183 */
3184 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
3185 csrInitOccupiedChannelsList(pMac);
3186#endif
3187 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
3188
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
3190 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
3191 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
3192 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3193 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003194 pNeighborRoamInfo->currentNeighborLookupThreshold =
3195 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
3196#ifdef FEATURE_WLAN_LFR
3197 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08003198 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003199#endif
3200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003202#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 /* Now we can clear the preauthDone that was saved as we are connected afresh */
3204 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3205#endif
3206
3207#ifdef WLAN_FEATURE_VOWIFI_11R
3208 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003209 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
3210 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 {
3212 if (pMac->roam.configParam.isFastTransitionEnabled)
3213 init_ft_flag = TRUE;
3214 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
3215 }
3216 else
3217 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003218 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219#endif
3220
3221#ifdef FEATURE_WLAN_CCX
3222 // Based on the auth scheme tell if we are 11r
3223 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
3224 {
3225 if (pMac->roam.configParam.isFastTransitionEnabled)
3226 init_ft_flag = TRUE;
3227 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
3228 }
3229 else
3230 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003231 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
3232 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
3234#endif
3235
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003236#ifdef FEATURE_WLAN_LFR
3237 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303238 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003239 {
3240 init_ft_flag = TRUE;
3241 }
3242#endif
3243
3244#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 if ( init_ft_flag == TRUE )
3246 {
3247 /* Initialize all the data structures needed for the 11r FT Preauth */
3248 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
3249 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = sessionId;
3250 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3251 csrNeighborRoamPurgePreauthFailedList(pMac);
3252
3253 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
3254 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07003255 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 WLANTL_HO_THRESHOLD_DOWN,
3257 csrNeighborRoamNeighborLookupDOWNCallback,
3258 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003259#ifdef FEATURE_WLAN_LFR
3260 pNeighborRoamInfo->lookupDOWNRssi = 0;
3261#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07003262 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 {
3264 //err msg
Jeff Johnson43971f52012-07-17 12:26:56 -07003265 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d\n"), vstatus);
3266 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 }
3268 }
3269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 break;
3271 default:
3272 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3273 break;
3274 }
3275 return status;
3276}
3277
3278
3279#ifdef WLAN_FEATURE_VOWIFI_11R
3280/* ---------------------------------------------------------------------------
3281
3282 \fn csrNeighborRoamPreAuthResponseWaitTimerHandler
3283
3284 \brief If this function is invoked, that means the preauthentication response
3285 is timed out from the PE. Preauth rsp handler is called with status as
3286 TIMEOUT
3287
3288 \param context - CSR Timer info which holds pMac and session ID
3289
3290 \return VOID
3291
3292---------------------------------------------------------------------------*/
3293void csrNeighborRoamPreAuthResponseWaitTimerHandler(void *context)
3294{
3295 tCsrTimerInfo *pTimerInfo = (tCsrTimerInfo *)context;
3296 tpAniSirGlobal pMac = (tpAniSirGlobal)pTimerInfo->pMac;
3297 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3298
3299 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
3300
3301 csrNeighborRoamPreauthRspHandler(pMac, VOS_STATUS_E_TIMEOUT);
3302}
3303
3304/* ---------------------------------------------------------------------------
3305
3306 \fn csrNeighborRoamPurgePreauthFailedList
3307
3308 \brief This function purges all the MAC addresses in the pre-auth fail list
3309
3310 \param pMac - The handle returned by macOpen.
3311
3312 \return VOID
3313
3314---------------------------------------------------------------------------*/
3315void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
3316{
3317 tANI_U8 i;
3318
3319 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
3320 {
3321 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
3322 }
3323 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
3324
3325 return;
3326}
3327
3328/* ---------------------------------------------------------------------------
3329
3330 \fn csrNeighborRoamInit11rAssocInfo
3331
3332 \brief This function initializes 11r related neighbor roam data structures
3333
3334 \param pMac - The handle returned by macOpen.
3335
3336 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3337
3338---------------------------------------------------------------------------*/
3339eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
3340{
3341 eHalStatus status;
3342 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
3343
3344 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
3345 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
3346 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
3347 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
3348 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
3349 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
3350
3351 pFTRoamInfo->preAuthRspWaitTimerInfo.pMac = pMac;
3352 pFTRoamInfo->preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3353 status = palTimerAlloc(pMac->hHdd, &pFTRoamInfo->preAuthRspWaitTimer,
3354 csrNeighborRoamPreAuthResponseWaitTimerHandler, (void *)&pFTRoamInfo->preAuthRspWaitTimerInfo);
3355
3356 if (eHAL_STATUS_SUCCESS != status)
3357 {
3358 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3359 return eHAL_STATUS_RESOURCES;
3360 }
3361
3362 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3363 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3364 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3365 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3366
3367
3368 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
3369 if (eHAL_STATUS_SUCCESS != status)
3370 {
3371 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
3372 palTimerFree(pMac->hHdd, pFTRoamInfo->preAuthRspWaitTimer);
3373 return eHAL_STATUS_RESOURCES;
3374 }
3375 return status;
3376}
3377#endif /* WLAN_FEATURE_VOWIFI_11R */
3378
3379/* ---------------------------------------------------------------------------
3380
3381 \fn csrNeighborRoamInit
3382
3383 \brief This function initializes neighbor roam data structures
3384
3385 \param pMac - The handle returned by macOpen.
3386
3387 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3388
3389---------------------------------------------------------------------------*/
3390eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
3391{
3392 eHalStatus status;
3393 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3394
3395 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3396 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3397 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
3398 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
3399 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
3400 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
3401 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
3402 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
3403 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
3404 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
3405
3406 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
3407 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
3408
3409 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
3410 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3411
3412 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3413 {
3414 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
3415 return eHAL_STATUS_RESOURCES;
3416 }
3417
3418 /* Update the roam global structure from CFG */
3419 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3420 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
3421 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3422
3423 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
3424 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003425#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08003426 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003427 pNeighborRoamInfo->uEmptyScanCount = 0;
3428 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
3429 sizeof(tCsrRoamConnectedProfile));
3430#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
3432
3433 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3434 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3435 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborScanTimer,
3436 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3437
3438 if (eHAL_STATUS_SUCCESS != status)
3439 {
3440 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3441 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3442 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3443 return eHAL_STATUS_RESOURCES;
3444 }
3445
3446 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborResultsRefreshTimer,
3447 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3448
3449 if (eHAL_STATUS_SUCCESS != status)
3450 {
3451 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3452 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3453 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3454 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3455 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3456 return eHAL_STATUS_RESOURCES;
3457 }
3458
3459 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
3460 if (eHAL_STATUS_SUCCESS != status)
3461 {
3462 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3463 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3464 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3465 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3466 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3467 return eHAL_STATUS_RESOURCES;
3468 }
3469
3470 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3471 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3472 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3473 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3474 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3475
3476#ifdef WLAN_FEATURE_VOWIFI_11R
3477 status = csrNeighborRoamInit11rAssocInfo(pMac);
3478 if (eHAL_STATUS_SUCCESS != status)
3479 {
3480 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3481 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3482 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3483 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3484 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3485 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3486 return eHAL_STATUS_RESOURCES;
3487 }
3488#endif
3489 /* Initialize this with the current tick count */
3490 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3491
3492 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3493
3494 return eHAL_STATUS_SUCCESS;
3495}
3496
3497/* ---------------------------------------------------------------------------
3498
3499 \fn csrNeighborRoamClose
3500
3501 \brief This function closes/frees all the neighbor roam data structures
3502
3503 \param pMac - The handle returned by macOpen.
3504
3505 \return VOID
3506
3507---------------------------------------------------------------------------*/
3508void csrNeighborRoamClose(tpAniSirGlobal pMac)
3509{
3510 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3511
3512 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
3513 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07003514 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 return;
3516 }
3517
3518 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3519 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3520
3521 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3522
3523 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
3524 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3525 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3526 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3527
3528 /* Should free up the nodes in the list before closing the double Linked list */
3529 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
3530 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3531
3532 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3533 {
3534 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3535 }
3536
3537 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3538 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3539 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3540 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3541 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3542 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3543
3544 /* Free the profile.. */
3545 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003546#ifdef FEATURE_WLAN_LFR
Sandeep Pc2b00f62012-12-12 16:44:44 -08003547 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003548#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003549#ifdef WLAN_FEATURE_VOWIFI_11R
3550 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3551 palTimerFree(pMac->hHdd, pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimer);
3552 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.pMac = NULL;
3553 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3554 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3555 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3556 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3557 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3558 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3559#endif /* WLAN_FEATURE_VOWIFI_11R */
3560
3561 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
3562
3563 return;
3564}
3565
3566/* ---------------------------------------------------------------------------
3567
3568 \fn csrNeighborRoamRequestHandoff
3569
3570 \brief This function triggers actual switching from one AP to the new AP.
3571 It issues disassociate with reason code as Handoff and CSR as a part of
3572 handling disassoc rsp, issues reassociate to the new AP
3573
3574 \param pMac - The handle returned by macOpen.
3575
3576 \return VOID
3577
3578---------------------------------------------------------------------------*/
3579void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
3580{
3581
3582 tCsrRoamInfo roamInfo;
3583 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3584 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3585 tCsrNeighborRoamBSSInfo handoffNode;
3586 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
3587 tANI_U32 roamId = 0;
3588
3589 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
3590 {
3591 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
3592 pMac->roam.neighborRoamInfo.neighborRoamState);
3593 return;
3594 }
3595
3596 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3597 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
3598 eSIR_SME_SUCCESS);
3599
3600 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3601 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
3602
3603 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
3604 smsLog(pMac, LOGE, FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
3605 handoffNode.pBssDescription->bssId[0],
3606 handoffNode.pBssDescription->bssId[1],
3607 handoffNode.pBssDescription->bssId[2],
3608 handoffNode.pBssDescription->bssId[3],
3609 handoffNode.pBssDescription->bssId[4],
3610 handoffNode.pBssDescription->bssId[5]);
3611
3612 /* Free the profile.. Just to make sure we dont leak memory here */
3613 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
3614 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
3615 This should happen before issuing disconnect */
3616 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
3617 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
3618 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
3619
3620 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP\n");
3621
3622 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
3623 {
3624 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate\n");
3625 return;
3626 }
3627
3628 //notify HDD for handoff, providing the BSSID too
3629 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
3630
3631 vos_mem_copy(roamInfo.bssid,
3632 handoffNode.pBssDescription->bssId,
3633 sizeof( tCsrBssid ));
3634
3635 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
3636
3637
3638 return;
3639}
3640
3641/* ---------------------------------------------------------------------------
3642
3643 \fn csrNeighborRoamIsHandoffInProgress
3644
3645 \brief This function returns whether handoff is in progress or not based on
3646 the current neighbor roam state
3647
3648 \param pMac - The handle returned by macOpen.
3649 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
3650
3651 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
3652
3653---------------------------------------------------------------------------*/
3654tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
3655{
3656 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
3657 return eANI_BOOLEAN_TRUE;
3658
3659 return eANI_BOOLEAN_FALSE;
3660}
3661
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003662#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07003663/* ---------------------------------------------------------------------------
3664
3665 \fn csrNeighborRoamIs11rAssoc
3666
3667 \brief This function returns whether the current association is a 11r assoc or not
3668
3669 \param pMac - The handle returned by macOpen.
3670
3671 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
3672
3673---------------------------------------------------------------------------*/
3674tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
3675{
3676 return pMac->roam.neighborRoamInfo.is11rAssoc;
3677}
3678#endif /* WLAN_FEATURE_VOWIFI_11R */
3679
3680
3681/* ---------------------------------------------------------------------------
3682
3683 \fn csrNeighborRoamGetHandoffAPInfo
3684
3685 \brief This function returns the best possible AP for handoff. For 11R case, it
3686 returns the 1st entry from pre-auth done list. For non-11r case, it returns
3687 the 1st entry from roamable AP list
3688
3689 \param pMac - The handle returned by macOpen.
3690 pHandoffNode - AP node that is the handoff candidate returned
3691
3692 \return VOID
3693
3694---------------------------------------------------------------------------*/
3695void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
3696{
3697 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3698 tpCsrNeighborRoamBSSInfo pBssNode;
3699
3700 VOS_ASSERT(NULL != pHandoffNode);
3701
3702#ifdef WLAN_FEATURE_VOWIFI_11R
3703 if (pNeighborRoamInfo->is11rAssoc)
3704 {
3705 /* Always the BSS info in the head is the handoff candidate */
3706 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3707 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3708 }
3709 else
3710#endif
3711#ifdef FEATURE_WLAN_CCX
3712 if (pNeighborRoamInfo->isCCXAssoc)
3713 {
3714 /* Always the BSS info in the head is the handoff candidate */
3715 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3716 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3717 }
3718 else
3719#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003720#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303721 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003722 {
3723 /* Always the BSS info in the head is the handoff candidate */
3724 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3725 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3726 }
3727 else
3728#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 {
3730 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
3731 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
3732 }
3733 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
3734
3735 return;
3736}
3737
3738/* ---------------------------------------------------------------------------
3739 \brief This function returns TRUE if preauth is completed
3740
3741 \param pMac - The handle returned by macOpen.
3742
3743 \return boolean
3744
3745---------------------------------------------------------------------------*/
3746tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
3747{
3748 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
3749 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
3750}
3751
3752/* ---------------------------------------------------------------------------
3753 \brief In the event that we are associated with AP1 and we have
3754 completed pre auth with AP2. Then we receive a deauth/disassoc from
3755 AP1.
3756 At this point neighbor roam is in pre auth done state, pre auth timer
3757 is running. We now handle this case by stopping timer and clearing
3758 the pre-auth state. We basically clear up and just go to disconnected
3759 state.
3760
3761 \param pMac - The handle returned by macOpen.
3762
3763 \return boolean
3764---------------------------------------------------------------------------*/
3765void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
3766{
3767 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
3768 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
3769
3770 // Stop timer
3771 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
3772
3773 // Transition to init state
3774 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3775}
3776
3777#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */