blob: c0602513d1d7485eb9a59be6a52fb6ece9b5c782 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
44
45
46 \file csrNeighborRoam.c
47
48 Implementation for the simple roaming algorithm for 802.11r Fast transitions and Legacy roaming for Android platform.
49
50 Copyright (C) 2010 Qualcomm, Incorporated
51
52
53 ========================================================================== */
54
55/*===========================================================================
56
57 EDIT HISTORY FOR FILE
58
59
60 This section contains comments describing changes made to the module.
61 Notice that changes are listed in reverse chronological order.
62
63
64
65 when who what, where, why
66---------- --- --------------------------------------------------------
6708/01/10 Murali Created
68
69===========================================================================*/
70#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
71#include "wlan_qct_wda.h"
72#include "palApi.h"
73#include "csrInsideApi.h"
74#include "smsDebug.h"
75#include "logDump.h"
76#include "smeQosInternal.h"
77#include "wlan_qct_tl.h"
78#include "smeInside.h"
79#include "vos_diag_core_event.h"
80#include "vos_diag_core_log.h"
81#include "csrApi.h"
82#include "wlan_qct_tl.h"
83#include "sme_Api.h"
84#include "csrNeighborRoam.h"
85#ifdef FEATURE_WLAN_CCX
86#include "csrCcx.h"
87#endif
88
89#define WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG 1
90#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG
91#define NEIGHBOR_ROAM_DEBUG smsLog
92#else
93#define NEIGHBOR_ROAM_DEBUG(x...)
94#endif
95
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -070096static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo);
97static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac);
98static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac);
99static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac);
100
Jeff Johnson295189b2012-06-20 16:38:30 -0700101VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800102 v_PVOID_t pUserCtxt,
103 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700104VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800105 v_PVOID_t pUserCtxt,
106 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700107void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus);
108eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile );
109
110#ifdef WLAN_FEATURE_VOWIFI_11R
111static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac);
112VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac);
113#endif
114
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800115#define ROAM_STATE_RETURN_STRING( str )\
116 case ( ( str ) ): return( #str )
117
118
119v_U8_t *csrNeighborRoamStateToString(v_U8_t state)
120{
121 switch(state)
122 {
123 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CLOSED );
124 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_INIT );
125 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CONNECTED );
126 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN );
127 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING );
128 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY );
129 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN );
130 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING );
131 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE );
132 default:
133 return "eCSR_NEIGHBOR_ROAM_STATE_UNKNOWN";
134 }
135
136}
137
Jeff Johnson295189b2012-06-20 16:38:30 -0700138/* State Transition macro */
139#define CSR_NEIGHBOR_ROAM_STATE_TRANSITION(newState)\
140{\
141 pMac->roam.neighborRoamInfo.prevNeighborRoamState = pMac->roam.neighborRoamInfo.neighborRoamState;\
142 pMac->roam.neighborRoamInfo.neighborRoamState = newState;\
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800143 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, \
144 FL("Neighbor Roam Transition from state %s ==> %s"), \
145 csrNeighborRoamStateToString (pMac->roam.neighborRoamInfo.prevNeighborRoamState), \
146 csrNeighborRoamStateToString (newState));\
Jeff Johnson295189b2012-06-20 16:38:30 -0700147}
148
149/* ---------------------------------------------------------------------------
150
151 \fn csrNeighborRoamFreeNeighborRoamBSSNode
152
153 \brief This function frees all the internal pointers CSR NeighborRoam BSS Info
154 and also frees the node itself
155
156 \param pMac - The handle returned by macOpen.
157 neighborRoamBSSNode - Neighbor Roam BSS Node to be freed
158
159 \return VOID
160
161---------------------------------------------------------------------------*/
162void csrNeighborRoamFreeNeighborRoamBSSNode(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo neighborRoamBSSNode)
163{
164 if (neighborRoamBSSNode)
165 {
166 if (neighborRoamBSSNode->pBssDescription)
167 {
168 vos_mem_free(neighborRoamBSSNode->pBssDescription);
169 neighborRoamBSSNode->pBssDescription = NULL;
170 }
171 vos_mem_free(neighborRoamBSSNode);
172 neighborRoamBSSNode = NULL;
173 }
174
175 return;
176}
177
178/* ---------------------------------------------------------------------------
179
180 \fn csrNeighborRoamRemoveRoamableAPListEntry
181
182 \brief This function removes a given entry from the given list
183
184 \param pMac - The handle returned by macOpen.
185 pList - The list from which the entry should be removed
186 pNeighborEntry - Neighbor Roam BSS Node to be removed
187
188 \return TRUE if successfully removed, else FALSE
189
190---------------------------------------------------------------------------*/
191tANI_BOOLEAN csrNeighborRoamRemoveRoamableAPListEntry(tpAniSirGlobal pMac,
192 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
193{
194 if(pList)
195 {
196 return csrLLRemoveEntry(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
197 }
198
199 smsLog(pMac, LOGE, FL("Removing neighbor BSS node from list failed. Current count = %d\n"), csrLLCount(pList));
200
201 return eANI_BOOLEAN_FALSE;
202}
203
204/* ---------------------------------------------------------------------------
205
206 \fn csrNeighborRoamGetRoamableAPListNextEntry
207
208 \brief Gets the entry next to passed entry. If NULL is passed, return the entry in the head of the list
209
210 \param pMac - The handle returned by macOpen.
211 pList - The list from which the entry should be returned
212 pNeighborEntry - Neighbor Roam BSS Node whose next entry should be returned
213
214 \return Neighbor Roam BSS Node to be returned
215
216---------------------------------------------------------------------------*/
217tpCsrNeighborRoamBSSInfo csrNeighborRoamGetRoamableAPListNextEntry(tpAniSirGlobal pMac,
218 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
219{
220 tListElem *pEntry = NULL;
221 tpCsrNeighborRoamBSSInfo pResult = NULL;
222
223 if(pList)
224 {
225 if(NULL == pNeighborEntry)
226 {
227 pEntry = csrLLPeekHead(pList, LL_ACCESS_LOCK);
228 }
229 else
230 {
231 pEntry = csrLLNext(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
232 }
233 if(pEntry)
234 {
235 pResult = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
236 }
237 }
238
239 return pResult;
240}
241
242/* ---------------------------------------------------------------------------
243
244 \fn csrNeighborRoamFreeRoamableBSSList
245
246 \brief Empties and frees all the nodes in the roamable AP list
247
248 \param pMac - The handle returned by macOpen.
249 pList - Neighbor Roam BSS List to be emptied
250
251 \return VOID
252
253---------------------------------------------------------------------------*/
254void csrNeighborRoamFreeRoamableBSSList(tpAniSirGlobal pMac, tDblLinkList *pList)
255{
256 tpCsrNeighborRoamBSSInfo pResult = NULL;
257
Mohit Khanna23863762012-09-11 17:40:09 -0700258 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Emptying the BSS list. Current count = %d\n"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700259
260 /* Pick up the head, remove and free the node till the list becomes empty */
261 while ((pResult = csrNeighborRoamGetRoamableAPListNextEntry(pMac, pList, NULL)) != NULL)
262 {
263 csrNeighborRoamRemoveRoamableAPListEntry(pMac, pList, pResult);
264 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pResult);
265 }
266 return;
267}
268
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800269static void csrNeighborRoamTriggerHandoff(tpAniSirGlobal pMac,
270 tpCsrNeighborRoamControlInfo pNeighborRoamInfo)
271{
272#ifdef WLAN_FEATURE_VOWIFI_11R
273 if (pNeighborRoamInfo->is11rAssoc)
274 {
275 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
276 {
277 csrNeighborRoamIssuePreauthReq(pMac);
278 }
279 else
280 {
281 smsLog(pMac, LOGE, FL("11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
282 VOS_ASSERT(0);
283 }
284 }
285 else
286#endif
287
288#ifdef FEATURE_WLAN_CCX
289 if (pNeighborRoamInfo->isCCXAssoc)
290 {
291 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
292 {
293 csrNeighborRoamIssuePreauthReq(pMac);
294 }
295 else
296 {
297 smsLog(pMac, LOGE, FL("CCX Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
298 VOS_ASSERT(0);
299 }
300 }
301 else
302#endif
303#ifdef FEATURE_WLAN_LFR
304 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
305 {
306 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
307 {
308 csrNeighborRoamIssuePreauthReq(pMac);
309 }
310 else
311 {
312 smsLog(pMac, LOGE, FL("LFR Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
313 VOS_ASSERT(0);
314 }
315 }
316 else
317#endif
318 {
319 if (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pNeighborRoamInfo->neighborRoamState)
320 {
321 csrNeighborRoamRequestHandoff(pMac);
322 }
323 else
324 {
325 smsLog(pMac, LOGE, FL("Non-11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
326 VOS_ASSERT(0);
327 }
328 }
329}
330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331/* ---------------------------------------------------------------------------
332
333 \fn csrNeighborRoamReassocIndCallback
334
335 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
336 Directly triggere HO in case of non-11r association
337 In case of 11R association, triggers a pre-auth eventually followed by actual HO
338
339 \param pAdapter - VOS Context
340 trafficStatus - UP/DOWN indication from TL
341 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
342
343 \return VOID
344
345---------------------------------------------------------------------------*/
346VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
347 v_U8_t trafficStatus,
Srinivasdaaec712012-12-12 15:59:44 -0800348 v_PVOID_t pUserCtxt,
349 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700350{
351 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
352 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
353 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
354
Srinivasdaaec712012-12-12 15:59:44 -0800355 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"),
356 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
357 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700358
359 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
360 WLANTL_HO_THRESHOLD_DOWN,
361 csrNeighborRoamReassocIndCallback,
362 VOS_MODULE_ID_SME);
363
364 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
365 {
366 //err msg
367 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
368 }
369
Srinivasdaaec712012-12-12 15:59:44 -0800370 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
371 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800372 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
373 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
374 WLANTL_HO_THRESHOLD_UP,
375 csrNeighborRoamNeighborLookupUPCallback,
376 VOS_MODULE_ID_SME);
Jeff Johnson295189b2012-06-20 16:38:30 -0700377
378 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
379 {
380 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530381 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 }
383
384 /* We dont need to run this timer any more. */
385 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
386
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800387 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 return VOS_STATUS_SUCCESS;
390}
391
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700392/*CleanUP Routines*/
393static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
394{
395 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
396 (rChInfo->currentChannelListInfo.numOfChannels))
397 {
398 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
399 rChInfo->currentChannelListInfo.numOfChannels = 0;
400
401 if (rChInfo->currentChannelListInfo.ChannelList)
402 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
403
404 rChInfo->currentChannelListInfo.ChannelList = NULL;
405 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
406 }
407 else
408 {
409 rChInfo->currentChanIndex = 0;
410 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
411 }
412}
413
414static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
415{
416 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
417
418 /* Stop neighbor scan timer */
419 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
420
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700421 /* Stop neighbor scan results refresh timer */
422 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
423
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700424 /* Abort any ongoing scan */
425 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
426 {
427 csrScanAbortMacScan(pMac);
428 }
429 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
430
431 /* Reset roam channel list information */
432 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
433}
434
435static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
436{
437 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
438
439#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
440 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
441 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
442 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId =
443 CSR_SESSION_ID_INVALID;
444 /* Purge pre-auth fail list */
445 csrNeighborRoamPurgePreauthFailedList(pMac);
446#endif
447
448 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
449 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
450#ifdef WLAN_FEATURE_VOWIFI_11R
451 /* Do not free up the preauth done list here */
452 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
453 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
454 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
455 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
456 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
457#endif
458}
459
460static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
461{
462 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
463 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
464
465 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
466 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800467 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700468
469 /* Deregister reassoc callback. Ignore return status */
470 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800471 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700472 WLANTL_HO_THRESHOLD_UP,
473 csrNeighborRoamNeighborLookupUPCallback,
474 VOS_MODULE_ID_SME);
475
476 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
477 {
478 smsLog(pMac, LOGW,
479 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
480 "with TL: Status = %d\n"), vosStatus);
481 }
482
483 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
484 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
485 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
486
487 /* Deregister reassoc callback. Ignore return status */
488 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
489 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
490 WLANTL_HO_THRESHOLD_DOWN,
491 csrNeighborRoamReassocIndCallback,
492 VOS_MODULE_ID_SME);
493
494 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
495 {
496 smsLog(pMac, LOGW,
497 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
498 "TL: Status = %d\n"), vosStatus);
499 }
500
501 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
502 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
503 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
504
505 /* Deregister neighbor lookup callback. Ignore return status */
506 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
507 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
508 WLANTL_HO_THRESHOLD_DOWN,
509 csrNeighborRoamNeighborLookupDOWNCallback,
510 VOS_MODULE_ID_SME);
511
512 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
513 {
514 smsLog(pMac, LOGW,
515 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
516 "with TL: Status = %d\n"), vosStatus);
517 }
518
519 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700520 pNeighborRoamInfo->currentNeighborLookupThreshold =
521 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800522#ifdef FEATURE_WLAN_LFR
523 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -0800524 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800525#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700526}
527
Jeff Johnson295189b2012-06-20 16:38:30 -0700528/* ---------------------------------------------------------------------------
529
530 \fn csrNeighborRoamResetConnectedStateControlInfo
531
532 \brief This function will reset the neighbor roam control info data structures.
533 This function should be invoked whenever we move to CONNECTED state from
534 any state other than INIT state
535
536 \param pMac - The handle returned by macOpen.
537
538 \return VOID
539
540---------------------------------------------------------------------------*/
541void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
542{
543 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
544
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700545 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700548 /* We dont need to run this timer any more. */
549 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550
551#ifdef WLAN_FEATURE_VOWIFI_11R
552 /* Do not free up the preauth done list here */
553 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
554 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
555 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
556 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
557 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
558 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
559 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700561}
562
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700563void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700564{
565 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
567 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
568 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
569 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700570#ifdef FEATURE_WLAN_CCX
571 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
572 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
573 pNeighborRoamInfo->MinQBssLoadRequired = 0;
574#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700575
576 /* Stop scan refresh timer */
577 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700578 /* Purge roamable AP list */
579 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 return;
581}
582
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700583/* ---------------------------------------------------------------------------
584
585 \fn csrNeighborRoamResetInitStateControlInfo
586
587 \brief This function will reset the neighbor roam control info data structures.
588 This function should be invoked whenever we move to CONNECTED state from
589 INIT state
590
591 \param pMac - The handle returned by macOpen.
592
593 \return VOID
594
595---------------------------------------------------------------------------*/
596void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
597{
598 csrNeighborRoamResetConnectedStateControlInfo(pMac);
599
600 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
601 csrNeighborRoamResetReportScanStateControlInfo(pMac);
602}
603
604
605
Jeff Johnson295189b2012-06-20 16:38:30 -0700606#ifdef WLAN_FEATURE_VOWIFI_11R
607/* ---------------------------------------------------------------------------
608
609 \fn csrNeighborRoamBssIdScanFilter
610
611 \brief This API is used to prepare a filter to obtain scan results when
612 we complete the scan in the REPORT_SCAN state after receiving a
613 valid neighbor report from AP. This filter includes BSSIDs received from
614 the neighbor report from the AP in addition to the other filter parameters
615 created from connected profile
616
617 \param pMac - The handle returned by macOpen.
618 pScanFilter - Scan filter to be filled and returned
619
620 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
621 code otherwise
622
623---------------------------------------------------------------------------*/
624static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
625{
626 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
627 tANI_U8 i = 0;
628
629 VOS_ASSERT(pScanFilter != NULL);
630 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
631
632 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
633 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
634 if (NULL == pScanFilter->BSSIDs.bssid)
635 {
636 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
637 return eHAL_STATUS_FAILED_ALLOC;
638 }
639
640 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
641
642 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
643 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
644 {
645 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
646 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
647 }
648
649 /* Fill other general scan filter params */
650 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
651}
652
653/* ---------------------------------------------------------------------------
654
655 \fn csrNeighborRoamPurgePreauthFailList
656
657 \brief This function empties the preauth fail list
658
659 \param pMac - The handle returned by macOpen.
660
661 \return VOID
662
663---------------------------------------------------------------------------*/
664void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
665{
666 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
667
668 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
669 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
670 {
671 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
672 sizeof(tSirMacAddr));
673 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
674 }
675 return;
676}
677
678/* ---------------------------------------------------------------------------
679
680 \fn csrNeighborRoamAddBssIdToPreauthFailList
681
682 \brief This function adds the given BSSID to the Preauth fail list
683
684 \param pMac - The handle returned by macOpen.
685 bssId - BSSID to be added to the preauth fail list
686
687 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
688
689---------------------------------------------------------------------------*/
690eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
691{
692 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
693
694 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL(" Added BSSID %02x:%02x:%02x:%02x:%02x:%02x to Preauth failed list\n"),
695 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
696
697
698 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
699 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
700 {
701 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
702 return eHAL_STATUS_FAILURE;
703 }
704 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
705 bssId, sizeof(tSirMacAddr));
706 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
707
708 return eHAL_STATUS_SUCCESS;
709}
710
711/* ---------------------------------------------------------------------------
712
713 \fn csrNeighborRoamIsPreauthCandidate
714
715 \brief This function checks whether the given MAC address is already
716 present in the preauth fail list and returns TRUE/FALSE accordingly
717
718 \param pMac - The handle returned by macOpen.
719
720 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
721
722---------------------------------------------------------------------------*/
723tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
724{
725 tANI_U8 i = 0;
726 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
727
728 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
729 return eANI_BOOLEAN_TRUE;
730
731 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
732 {
733 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
734 bssId, sizeof(tSirMacAddr)))
735 {
736 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
737 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
738 return eANI_BOOLEAN_FALSE;
739 }
740 }
741
742 return eANI_BOOLEAN_TRUE;
743}
744
745/* ---------------------------------------------------------------------------
746
747 \fn csrNeighborRoamIssuePreauthReq
748
749 \brief This function issues preauth request to PE with the 1st AP entry in the
750 roamable AP list
751
752 \param pMac - The handle returned by macOpen.
753
754 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
755
756---------------------------------------------------------------------------*/
757static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
758{
759 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
760 eHalStatus status = eHAL_STATUS_SUCCESS;
761 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
762
763 /* This must not be true here */
764 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
765
766 /* Issue Preauth request to PE here */
767 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
768 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
769 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
770 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
771
772 if (NULL == pNeighborBssNode)
773 {
774 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
775 return eHAL_STATUS_FAILURE;
776 }
777 else
778 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700779 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
780 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530781
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800782 smsLog(pMac, LOG1, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530783 pNeighborBssNode->pBssDescription->bssId[0],
784 pNeighborBssNode->pBssDescription->bssId[1],
785 pNeighborBssNode->pBssDescription->bssId[2],
786 pNeighborBssNode->pBssDescription->bssId[3],
787 pNeighborBssNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800788 pNeighborBssNode->pBssDescription->bssId[5],
789 (int)pNeighborBssNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530790
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 if (eHAL_STATUS_SUCCESS != status)
792 {
793 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d\n"), status);
794 return status;
795 }
796 }
797
798 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
799
800 /* Increment the preauth retry count */
801 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
802
803 /* Transition the state to preauthenticating */
804 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700805#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 /* Start the preauth rsp timer */
807 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer,
808 CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
809 eANI_BOOLEAN_FALSE);
810 if (eHAL_STATUS_SUCCESS != status)
811 {
812 smsLog(pMac, LOGE, FL("Preauth response wait timer start failed with status %d\n"), status);
813 return status;
814 }
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700815#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700816
817 return status;
818}
819
820/* ---------------------------------------------------------------------------
821
822 \fn csrNeighborRoamPreauthRspHandler
823
824 \brief This function handle the Preauth response from PE
825 Every preauth is allowed max 3 tries if it fails. If a bssid failed
826 for more than MAX_TRIES, we will remove it from the list and try
827 with the next node in the roamable AP list and add the BSSID to pre-auth failed
828 list. If no more entries present in
829 roamable AP list, transition to REPORT_SCAN state
830
831 \param pMac - The handle returned by macOpen.
832 vosStatus - VOS_STATUS_SUCCESS/FAILURE/TIMEOUT status from PE
833
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700834 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
835 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -0700836
837---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700838eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, VOS_STATUS vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700839{
840 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
841 eHalStatus status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700842 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700844
845 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
846 {
847
848 /* This can happen when we disconnect immediately
849 * after sending a pre-auth request. During processing
850 * of the disconnect command, we would have reset
851 * preauthRspPending and transitioned to INIT state.
852 */
853 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
854 FL("Unexpected pre-auth response in state %d\n"),
855 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700856 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700857 goto DEQ_PREAUTH;
858 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700859
860 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
862 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
863 {
Madan Mohan Koyyalamudi8186a9e2012-10-11 14:23:43 -0700864 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d\n"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700865 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700866 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700867 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 }
869
870 if (VOS_STATUS_E_TIMEOUT != vosStatus)
871 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700872#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 /* This means we got the response from PE. Hence stop the timer */
874 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700875#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
877 }
878
879 if (VOS_STATUS_SUCCESS == vosStatus)
880 {
881 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
882 }
883 if ((VOS_STATUS_SUCCESS == vosStatus) && (NULL != pPreauthRspNode))
884 {
885 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
886
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800887 smsLog(pMac, LOG1, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530888 pPreauthRspNode->pBssDescription->bssId[0],
889 pPreauthRspNode->pBssDescription->bssId[1],
890 pPreauthRspNode->pBssDescription->bssId[2],
891 pPreauthRspNode->pBssDescription->bssId[3],
892 pPreauthRspNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800893 pPreauthRspNode->pBssDescription->bssId[5],
894 (int)pPreauthRspNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530895
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
897 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
898 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
899
900 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
901 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
902 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
903
904 /* The caller of this function would start a timer and by the time it expires, supplicant should
905 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
906 }
907 else
908 {
909 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
910 tListElem *pEntry;
911
912 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = %d\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, vosStatus);
913
914 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
915 if (pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >= CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES)
916 {
917 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
918 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
919
920 /* The one in the head of the list should be one with which we issued pre-auth and failed */
921 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
922 if(pEntry)
923 {
924 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
925 /* Add the BSSID to pre-auth fail list */
926 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
927 /* Now we can free this node */
928 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
929 }
930 }
931
932 /* Issue preauth request for the same/next entry */
933 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700934 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700935
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800936 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
937
938 /* Register Neighbor Lookup threshold callback with TL for UP event now */
939 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
940 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
941
942 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
943 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
944 WLANTL_HO_THRESHOLD_UP,
945 csrNeighborRoamNeighborLookupUPCallback,
946 VOS_MODULE_ID_SME, pMac);
947 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
948 {
949 //err msg
950 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
951 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700952
953 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
954 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
955 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
956 eANI_BOOLEAN_FALSE);
957 if (eHAL_STATUS_SUCCESS != status)
958 {
959 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 }
961 }
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700962
963DEQ_PREAUTH:
964 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700965 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700966}
967#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
968
969/* ---------------------------------------------------------------------------
970
971 \fn csrNeighborRoamPrepareScanProfileFilter
972
973 \brief This function creates a scan filter based on the currently connected profile.
974 Based on this filter, scan results are obtained
975
976 \param pMac - The handle returned by macOpen.
977 pScanFilter - Populated scan filter based on the connected profile
978
979 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
980
981---------------------------------------------------------------------------*/
982eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
983{
984 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
985 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
986 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
987 tANI_U8 i = 0;
988
989 VOS_ASSERT(pScanFilter != NULL);
990
991 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
992
993 /* We dont want to set BSSID based Filter */
994 pScanFilter->BSSIDs.numOfBSSIDs = 0;
995
996 /* Populate all the information from the connected profile */
997 pScanFilter->SSIDs.numOfSSIDs = 1;
998 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
999 if (NULL == pScanFilter->SSIDs.SSIDList)
1000 {
1001 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
1002 return eHAL_STATUS_FAILED_ALLOC;
1003 }
1004 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
1005 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
1006 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
1007 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
1008
1009 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering for SSID %s from scan results.. SSID Length = %d\n"),
1010 pScanFilter->SSIDs.SSIDList->SSID.ssId, pScanFilter->SSIDs.SSIDList->SSID.length);
1011 pScanFilter->authType.numEntries = 1;
1012 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
1013
1014 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
1015 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
1016
1017 pScanFilter->mcEncryptionType.numEntries = 1;
1018 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
1019
1020 pScanFilter->BSSType = pCurProfile->BSSType;
1021
1022 /* We are intrested only in the scan results on channels that we scanned */
1023 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
1024 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
1025 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1026 {
1027 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1028 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1029 pScanFilter->SSIDs.SSIDList = NULL;
1030 return eHAL_STATUS_FAILED_ALLOC;
1031 }
1032 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1033 {
1034 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1035 }
1036
1037#ifdef WLAN_FEATURE_VOWIFI_11R
1038 if (pNeighborRoamInfo->is11rAssoc)
1039 {
1040 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1041 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1042 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1043 }
1044#endif
1045
1046 return eHAL_STATUS_SUCCESS;
1047}
1048
Jeff Johnson43971f52012-07-17 12:26:56 -07001049tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1050{
1051 tCsrScanResultInfo *pScanResult;
1052 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda2efea0e2013-01-24 17:40:41 -08001053#ifdef FEATURE_WLAN_LFR
1054 tANI_U32 CurrAPRssi = pNeighborRoamInfo->lookupDOWNRssi;
1055#else
1056 /* We are setting this as default value to make sure we return this value,
1057 when we do not see this AP in the scan result for some reason.However,it is
1058 less likely that we are associated to an AP and do not see it in the scan list */
1059 tANI_U32 CurrAPRssi = -125;
1060#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001061
1062 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1063 {
1064
1065 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1066 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1067 {
1068 /* We got a match with the currently associated AP.
1069 * Capture the RSSI value and complete the while loop.
1070 * The while loop is completed in order to make the current entry go back to NULL,
1071 * and in the next while loop, it properly starts searching from the head of the list.
1072 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1073
1074 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1075
1076 } else {
1077 continue;
1078 }
1079 }
1080
1081 return CurrAPRssi;
1082
1083}
1084
Jeff Johnson295189b2012-06-20 16:38:30 -07001085/* ---------------------------------------------------------------------------
1086
1087 \fn csrNeighborRoamProcessScanResults
1088
1089 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1090 Assumed that the results are already sorted by RSSI by csrScanGetResult
1091
1092 \param pMac - The handle returned by macOpen.
1093 pScanResultList - Scan result result obtained from csrScanGetResult()
1094
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001095 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1096 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001097
1098---------------------------------------------------------------------------*/
1099
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001100static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1101 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001102{
1103 tCsrScanResultInfo *pScanResult;
1104 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1105 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001106 tANI_U32 CurrAPRssi;
1107 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001108#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1109 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1110#endif
1111 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001112
1113 /***************************************************************
1114 * Find out the Current AP RSSI and keep it handy to check if
1115 * it is better than the RSSI of the AP which we are
1116 * going to roam.If so, we are going to continue with the
1117 * current AP.
1118 ***************************************************************/
1119 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001120
1121 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1122 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1123 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1124 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1125 /* 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
1126 and rssi score are in the same order. This will be taken care later */
1127
1128 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1129 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001130 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
1131 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d, Ch:%d)"),
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001132 pScanResult->BssDescriptor.bssId[0],
1133 pScanResult->BssDescriptor.bssId[1],
1134 pScanResult->BssDescriptor.bssId[2],
1135 pScanResult->BssDescriptor.bssId[3],
1136 pScanResult->BssDescriptor.bssId[4],
1137 pScanResult->BssDescriptor.bssId[5],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001138 abs(pScanResult->BssDescriptor.rssi),
1139 pScanResult->BssDescriptor.channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001140
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001141 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1143 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001144 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001145 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1146 "SKIP-currently associated AP\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 continue;
1148 }
1149
Jeff Johnson43971f52012-07-17 12:26:56 -07001150 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1151 * is disabled and we continue to roam without any check*/
1152 if(RoamRssiDiff > 0)
1153 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001154 /*
1155 * If RSSI is lower than the lookup threshold, then continue.
1156 */
1157 if (abs(pScanResult->BssDescriptor.rssi) >
1158 pNeighborRoamInfo->currentNeighborLookupThreshold)
1159 {
1160 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1161 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)\n",
1162 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1163 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1164 continue;
1165 }
1166
Jeff Johnson43971f52012-07-17 12:26:56 -07001167 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1168 {
1169 /*Do not roam to an AP with worse RSSI than the current*/
1170 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1171 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d\n", __func__,
1172 CurrAPRssi,
1173 (int)pScanResult->BssDescriptor.rssi * (-1) );
1174 continue;
1175 } else {
1176 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1177 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1178 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1179 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001180 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1181 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d\n", __func__,
1182 CurrAPRssi,
1183 (int)pScanResult->BssDescriptor.rssi * (-1),
1184 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001185 continue;
1186 }
1187 else {
1188 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1189 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d\n", __func__,
1190 CurrAPRssi,
1191 (int)pScanResult->BssDescriptor.rssi * (-1) );
1192 }
1193 }
1194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001195
1196#ifdef WLAN_FEATURE_VOWIFI_11R
1197 if (pNeighborRoamInfo->is11rAssoc)
1198 {
1199 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1200 {
1201 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1202 continue;
1203 }
1204 }
1205#endif /* WLAN_FEATURE_VOWIFI_11R */
1206
1207#ifdef FEATURE_WLAN_CCX
1208 if (pNeighborRoamInfo->isCCXAssoc)
1209 {
1210 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1211 {
1212 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1213 continue;
1214 }
1215 }
1216 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1217 (pScanResult->BssDescriptor.QBSSLoad_avail))
1218 {
1219 if (pNeighborRoamInfo->isVOAdmitted)
1220 {
1221 smsLog(pMac, LOG1, FL("New AP has %x BW available\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1222 smsLog(pMac, LOG1, FL("We need %x BW available\n"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
1223 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1224 {
1225 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1226 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list\n",
1227 pScanResult->BssDescriptor.bssId[0],
1228 pScanResult->BssDescriptor.bssId[1],
1229 pScanResult->BssDescriptor.bssId[2],
1230 pScanResult->BssDescriptor.bssId[3],
1231 pScanResult->BssDescriptor.bssId[4],
1232 pScanResult->BssDescriptor.bssId[5]);
1233 continue;
1234 }
1235 }
1236 }
1237 else
1238 {
1239 smsLog(pMac, LOGE, FL("No QBss %x %x\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
1240 if (pNeighborRoamInfo->isVOAdmitted)
1241 {
1242 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1243 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no QBSSLoad IE, ignoring..not adding to roam list\n",
1244 pScanResult->BssDescriptor.bssId[0],
1245 pScanResult->BssDescriptor.bssId[1],
1246 pScanResult->BssDescriptor.bssId[2],
1247 pScanResult->BssDescriptor.bssId[3],
1248 pScanResult->BssDescriptor.bssId[4],
1249 pScanResult->BssDescriptor.bssId[5]);
1250 continue;
1251 }
1252 }
1253#endif /* FEATURE_WLAN_CCX */
1254
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001255#ifdef FEATURE_WLAN_LFR
1256 // If we are supporting legacy roaming, and
1257 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301258 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001259 {
1260 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1261 {
1262 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1263 continue;
1264 }
1265 }
1266#endif /* FEATURE_WLAN_LFR */
1267
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1269 * this result */
1270 if (pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1271 {
1272 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1273 continue;
1274 }
1275
1276 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1277 if (NULL == pBssInfo)
1278 {
1279 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1280 continue;
1281 }
1282
1283 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1284 if (pBssInfo->pBssDescription != NULL)
1285 {
1286 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1287 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1288 }
1289 else
1290 {
1291 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1292 vos_mem_free(pBssInfo);
1293 continue;
1294
1295 }
1296 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1297
1298 /* Just add to the end of the list as it is already sorted by RSSI */
1299 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001300
1301#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srikant Kuppa866893f2012-12-27 17:28:14 -08001302 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001303 {
1304 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1305 "%s: [INFOLOG] potential candidate to roam immediately (diff=%d, expected=%d)",
1306 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1307 immediateRoamRssiDiff);
1308 roamNow = eANI_BOOLEAN_TRUE;
1309 }
1310#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 }
1312
1313 /* 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 */
1314 csrScanResultPurge(pMac, *pScanResultList);
1315
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001316 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001317}
1318
1319/* ---------------------------------------------------------------------------
1320
1321 \fn csrNeighborRoamHandleEmptyScanResult
1322
1323 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1324 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001325 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001327 1. Stop the neighbor scan timer.
1328 2a. If this is the first time we encountered empty scan, then
1329 re-register with TL with modified lookup threshold.
1330 2b. Else if this is the second time we encountered empty scan,
1331 then start neighbor scan results refresh timer (20s).
1332 2c. Else, nothing more to do.
1333 NOTE: In LFR, channels selected for scanning is dervied from
1334 the occuped channel list. Scan cycle following one which
1335 yielded empty results is split into two halves: (i) scan on
1336 channels in the occupied list, and (ii) scan on channels not
1337 in the occupied list. This helps converging faster (while
1338 looking for candidates in the occupied list first), and also,
1339 adds channels to the occupied channel list upon finding candidates
1340 matching SSID profile of interest.
1341
1342 uEmptyScanCount Comments
1343 eFirstEmptyScan Previous scan was done on channels in the
1344 occupied list and yielded potential candidates.
1345 This scan cycle was likely triggered through
1346 receipt of lookup DOWN notification event.
1347 eSecondEmptyScan Previous scan was done on channels in the
1348 occupied list and yielded no candidates. This scan
1349 cycle was triggered through RSSI notification
1350 with modified lookup threshold.
1351 eThirdEmptyScan Previous scan was done on channels NOT in
1352 the occupied list and yielded no candidates. This
1353 scan cycle was triggered immediately after scanning
1354 channels in the occupied list and no candidates
1355 were found.
1356 eFourthEmptyScan Previous scan was done on channels in the
1357 occupied list and yielded no candidates. This scan
1358 cycle was triggered upon expiry of
1359 neighborScanResultsRefreshPeriod (=20s).
1360 eFifthEmptyScan Previous scan was done on channels NOT in
1361 the occupied list and yielded no candidates. This
1362 scan cycle was triggered immediately after scanning
1363 channels in the occupied list and no candidates
1364 were found.
1365
1366 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
1368 \param pMac - The handle returned by macOpen.
1369
1370 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1371
1372---------------------------------------------------------------------------*/
1373static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1374{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001375 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1377 eHalStatus status = eHAL_STATUS_SUCCESS;
1378
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001379 /* Stop neighbor scan timer */
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001381 if (eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 {
1383 smsLog(pMac, LOGW, FL(" palTimerStop failed with status %d\n"), status);
1384 }
1385
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001386 /*
1387 * Increase the neighbor lookup threshold by 3 dB
1388 * after every scan cycle. NOTE: uEmptyScanCount
1389 * would be either 1, 3 or 5 at the end of every
1390 * scan cycle.
1391 */
1392#ifdef FEATURE_WLAN_LFR
1393 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1394 {
1395 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1396 }
1397#endif
1398 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1399 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1400#ifdef FEATURE_WLAN_LFR
1401 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1402#endif
1403 )
1404 {
1405 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1406 }
1407
Jeff Johnson295189b2012-06-20 16:38:30 -07001408#ifdef WLAN_FEATURE_VOWIFI_11R
1409 /* Clear off the old neighbor report details */
1410 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1411#endif
1412
Srikant Kuppa866893f2012-12-27 17:28:14 -08001413 /* Transition to CONNECTED state */
1414 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1415
1416 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1417 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1418
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001419#ifdef FEATURE_WLAN_LFR
1420 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1421 {
1422#endif
1423 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001424 /* Re-register neighbor lookup DOWN threshold callback with TL */
1425 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1426 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1427 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1428
1429 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1430 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1431 WLANTL_HO_THRESHOLD_DOWN,
1432 csrNeighborRoamNeighborLookupDOWNCallback,
1433 VOS_MODULE_ID_SME, pMac);
1434
1435 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1436 {
1437 smsLog(pMac, LOGW,
1438 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
1439 " with TL: Status = %d\n"), status);
1440 }
1441#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08001442 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001443 }
1444 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1445 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1446 {
1447 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001448
1449 /* Immediately scan on channels in non-occupied list */
1450 csrNeighborRoamTransitToCFGChanScan(pMac);
1451 }
1452 else if (pNeighborRoamInfo->uEmptyScanCount == eThirdEmptyScan)
1453 {
1454 /* Empty scan results for the third time */
Srikant Kuppa866893f2012-12-27 17:28:14 -08001455
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001456 /* Start neighbor scan results refresh timer */
1457 if (eHAL_STATUS_SUCCESS !=
1458 palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001459 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001460 eANI_BOOLEAN_FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001462 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1463 status);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001464 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1465 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001466 vosStatus = VOS_STATUS_E_FAILURE;
1467 }
1468 else
1469 {
1470 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1471 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001474
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001475 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d",
1476 pNeighborRoamInfo->uEmptyScanCount);
1477#endif
1478 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001479}
1480
Jeff Johnson295189b2012-06-20 16:38:30 -07001481
Srikant Kuppa866893f2012-12-27 17:28:14 -08001482static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001483{
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 tCsrScanResultFilter scanFilter;
1486 tScanResultHandle scanResult;
1487 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001488 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001489 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001491#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1493 should use the BSSID filter made out of neighbor reports */
1494 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1495 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001496 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1497 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 -07001498 tempVal = 1;
1499 }
1500 else
1501#endif
1502 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001503 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1504 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 -07001505 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001506 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 {
1508 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1509 return eHAL_STATUS_FAILURE;
1510 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001511 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301512 if (hstatus != eHAL_STATUS_SUCCESS)
1513 {
1514 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001517 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518
1519 /* Free the scan filter */
1520 csrFreeScanFilter(pMac, &scanFilter);
1521
1522 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1523
1524 switch(pNeighborRoamInfo->neighborRoamState)
1525 {
1526 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1527 if (tempVal)
1528 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001529#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001530 /*
1531 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001532 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001533 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001534 pNeighborRoamInfo->uEmptyScanCount = 0;
1535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001536#ifdef WLAN_FEATURE_VOWIFI_11R
1537 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1538 APs in the roamable AP list */
1539 if (pNeighborRoamInfo->is11rAssoc)
1540 {
1541 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1542 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1543 }
1544 else
1545#endif
1546#ifdef FEATURE_WLAN_CCX
1547 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1548 APs in the roamable AP list */
1549 if (pNeighborRoamInfo->isCCXAssoc)
1550 {
1551 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1552 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1553 }
1554 else
1555#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001556#ifdef FEATURE_WLAN_LFR
1557 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1558 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301559 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001560 {
1561 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1562 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1563 }
1564 else
1565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 {
1567
1568 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1569 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1570 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1571 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1572 within certain duration */
1573
1574// palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
1575 }
1576 }
1577 else
1578 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001579 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1580 /* Handle it appropriately */
1581 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 }
1583 break;
1584#ifdef WLAN_FEATURE_VOWIFI_11R
1585 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1586 if (!tempVal)
1587 {
1588 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1589 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1590 csrNeighborRoamTransitToCFGChanScan(pMac);
1591 }
1592 break;
1593#endif /* WLAN_FEATURE_VOWIFI_11R */
1594 default:
1595 // Can come only in INIT state. Where in we are associated, we sent scan and user
1596 // in the meantime decides to disassoc, we will be in init state and still received call
1597 // back issued. Should not come here in any other state, printing just in case
1598 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1599 "%s: [INFOLOG] State %d\n", __func__, (pNeighborRoamInfo->neighborRoamState));
1600
1601 // Lets just exit out silently.
1602 return eHAL_STATUS_SUCCESS;
1603 }
1604
1605 if (tempVal)
1606 {
1607 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1608
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001609 if (roamNow)
1610 {
1611 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
1612 FL("Immediate roam-deregister UP indication. RSSI = %d"),
1613 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1614
1615 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
1616 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1617 WLANTL_HO_THRESHOLD_UP,
1618 csrNeighborRoamNeighborLookupUPCallback,
1619 VOS_MODULE_ID_SME);
1620
1621 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1622 {
1623 smsLog(pMac, LOGW,
1624 FL("Couldn't deregister lookup UP callback with TL: Status = %d\n"), vosStatus);
1625 }
1626
1627 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
1628 return eHAL_STATUS_SUCCESS;
1629 }
1630
Srikant Kuppa866893f2012-12-27 17:28:14 -08001631 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1632 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1633 eANI_BOOLEAN_FALSE);
1634
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
1636 * 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 -08001637 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08001639 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1641 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001642 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001644
Jeff Johnson295189b2012-06-20 16:38:30 -07001645 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
1646 /* Register a reassoc Indication callback */
1647 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
1648 WLANTL_HO_THRESHOLD_DOWN,
1649 csrNeighborRoamReassocIndCallback,
1650 VOS_MODULE_ID_SME, pMac);
1651
1652 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1653 {
1654 //err msg
1655 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
1656 }
1657
1658 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08001659
1660 return eHAL_STATUS_SUCCESS;
1661
1662}
1663
1664
1665/* ---------------------------------------------------------------------------
1666
1667 \fn csrNeighborRoamScanRequestCallback
1668
1669 \brief This function is the callback function registered in csrScanRequest() to
1670 indicate the completion of scan. If scan is completed for all the channels in
1671 the channel list, this function gets the scan result and starts the refresh results
1672 timer to avoid having stale results. If scan is not completed on all the channels,
1673 it restarts the neighbor scan timer which on expiry issues scan on the next
1674 channel
1675
1676 \param halHandle - The handle returned by macOpen.
1677 pContext - not used
1678 scanId - not used
1679 status - not used
1680
1681 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1682
1683---------------------------------------------------------------------------*/
1684static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
1685 tANI_U32 scanId, eCsrScanStatus status)
1686{
1687 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1688 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1689 tANI_U8 currentChanIndex;
1690 eHalStatus hstatus;
1691
1692 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1693
1694 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1695 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1696 {
1697 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1698 return eHAL_STATUS_SUCCESS;
1699 }
1700
1701 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
1702 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
1703
1704 /* Validate inputs */
1705 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
1706 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
1707 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
1708 }
1709 else
1710 {
1711 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
1712 return eHAL_STATUS_SUCCESS;
1713 }
1714
1715 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1716 {
1717 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
1718 just to get the results and perform PREAUTH */
1719 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
1720 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
1721 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
1722 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
1723
1724 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1725
1726 if (eHAL_STATUS_SUCCESS != hstatus)
1727 {
1728 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1729 return eHAL_STATUS_FAILURE;
1730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 }
1732 else
1733 {
1734
1735 /* Restart the timer for the next scan sequence as scanning is not over */
Jeff Johnson43971f52012-07-17 12:26:56 -07001736 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
1738 eANI_BOOLEAN_FALSE);
1739
Jeff Johnson43971f52012-07-17 12:26:56 -07001740 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 {
1742 /* Timer start failed.. Should we ASSERT here??? */
1743 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
1744 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1745 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001746 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 }
1748 }
1749 return eHAL_STATUS_SUCCESS;
1750}
1751
Srikant Kuppa866893f2012-12-27 17:28:14 -08001752#ifdef FEATURE_WLAN_LFR
1753static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
1754 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
1755{
1756 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1757 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1758 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
1759
1760 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1761
1762 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1763 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1764 {
1765 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1766 return eHAL_STATUS_SUCCESS;
1767 }
1768
1769 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
1770 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1771
1772 if (eHAL_STATUS_SUCCESS != hstatus)
1773 {
1774 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1775 }
1776
1777 return hstatus;
1778}
1779#endif
1780
Jeff Johnson295189b2012-06-20 16:38:30 -07001781/* ---------------------------------------------------------------------------
1782
1783 \fn csrNeighborRoamIssueBgScanRequest
1784
1785 \brief This function issues CSR scan request after populating all the BG scan params
1786 passed
1787
1788 \param pMac - The handle returned by macOpen.
1789 pBgScanParams - Params that need to be populated into csr Scan request
1790
1791 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1792
1793---------------------------------------------------------------------------*/
Srikant Kuppa866893f2012-12-27 17:28:14 -08001794eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
1795 tCsrBGScanRequest *pBgScanParams,
1796 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07001797{
1798 eHalStatus status = eHAL_STATUS_SUCCESS;
1799 tANI_U32 scanId;
1800 tCsrScanRequest scanReq;
1801 tANI_U8 channel;
1802
Srikant Kuppa866893f2012-12-27 17:28:14 -08001803 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1804 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
1805 pBgScanParams->ChannelInfo.ChannelList[0],
1806 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001807
1808 //send down the scan req for 1 channel on the associated SSID
1809 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
1810 /* Fill in the SSID Info */
1811 scanReq.SSIDs.numOfSSIDs = 1;
1812 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1813 if(NULL == scanReq.SSIDs.SSIDList)
1814 {
1815 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301816 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 -07001817 return eHAL_STATUS_FAILURE;
1818 }
1819 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1820
1821 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
1822 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
1823 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
1824
1825 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001826 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1827 {
1828 channel = pBgScanParams->ChannelInfo.ChannelList[0];
1829 scanReq.ChannelInfo.ChannelList = &channel;
1830 }
1831 else
1832 {
1833 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
1834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001835
1836 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
1837 scanReq.scanType = eSIR_ACTIVE_SCAN;
1838 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
1839 scanReq.maxChnTime = pBgScanParams->maxChnTime;
1840 scanReq.minChnTime = pBgScanParams->minChnTime;
1841 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Srikant Kuppa866893f2012-12-27 17:28:14 -08001842 &scanId, callbackfn, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 if (eHAL_STATUS_SUCCESS != status)
1844 {
1845 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
1846 vos_mem_free(scanReq.SSIDs.SSIDList);
1847 return status;
1848 }
1849 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
1850
1851 vos_mem_free(scanReq.SSIDs.SSIDList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001852 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1853 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
1854 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
1855 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
1856
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 return status;
1858}
1859
Srikant Kuppa866893f2012-12-27 17:28:14 -08001860static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
1861 tpCsrBGScanRequest bgScanParams)
1862{
1863 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1864 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1865
1866 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
1867 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
1868 vos_mem_copy(bgScanParams->SSID.ssId,
1869 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
1870 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
1871
1872 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
1873 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
1874}
1875
Jeff Johnson295189b2012-06-20 16:38:30 -07001876/* ---------------------------------------------------------------------------
1877
1878 \fn csrNeighborRoamPerformBgScan
1879
1880 \brief This function is invoked on every expiry of neighborScanTimer till all
1881 the channels in the channel list are scanned. It populates necessary
1882 parameters for BG scan and calls appropriate AP to invoke the CSR scan
1883 request
1884
1885 \param pMac - The handle returned by macOpen.
1886
1887 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1888
1889---------------------------------------------------------------------------*/
1890eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac)
1891{
1892 eHalStatus status = eHAL_STATUS_SUCCESS;
1893 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1894 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 tANI_U8 channel = 0;
1896
1897 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1898 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301899 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 }
1901 else
1902 {
1903 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson902c9832012-12-10 14:28:09 -08001904 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07001905 // When timer start is declared a failure, then we delete the list.
1906 // Should not happen now as we stop and then only start the scan timer.
1907 // still handle the unlikely case.
1908 csrNeighborRoamHandleEmptyScanResult(pMac);
1909 return status;
1910 }
1911 /* Need to perform scan here before getting the list */
Srikant Kuppa866893f2012-12-27 17:28:14 -08001912
1913 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07001914
1915 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
1916 bgScanParams.ChannelInfo.numOfChannels = 1;
1917 bgScanParams.ChannelInfo.ChannelList = &channel;
1918
Srikant Kuppa866893f2012-12-27 17:28:14 -08001919 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07001920
Srikant Kuppa866893f2012-12-27 17:28:14 -08001921 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
1922 csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 if (eHAL_STATUS_SUCCESS != status)
1924 {
1925 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 }
1927
1928 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
1929 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
1930 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
1931 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301932 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
1934 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
1935 /* We have completed scanning all the channels */
1936 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
1937 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
1938 and select the best AP in the list */
1939 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1940 {
1941 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
1942 }
1943 }
1944
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08001945 if (eHAL_STATUS_SUCCESS != status)
1946 {
1947 /*
1948 * If the status is not success, we need to call the callback
1949 * routine so that the state machine does not get stuck.
1950 */
1951 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
1952 }
1953
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 return status;
1955}
1956
Srikant Kuppa866893f2012-12-27 17:28:14 -08001957#ifdef FEATURE_WLAN_LFR
1958eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac)
1959{
1960 eHalStatus status = eHAL_STATUS_SUCCESS;
1961 tCsrBGScanRequest bgScanParams;
1962 int numOfChannels = 0, i = 0;
1963 tANI_U8 *channelList = NULL;
1964
1965 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
1966
1967 /* Contiguously scan all channels from valid list */
1968 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
1969 numOfChannels = sizeof(pMac->roam.validChannelList);
1970
1971 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
1972 (tANI_U8 *)pMac->roam.validChannelList,
1973 (tANI_U32 *) &numOfChannels)))
1974 {
1975 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
1976 return eHAL_STATUS_FAILURE;
1977 }
1978
1979 channelList = vos_mem_malloc( numOfChannels );
1980 if( NULL == channelList )
1981 {
1982 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
1983 return eHAL_STATUS_FAILURE;
1984 }
1985 vos_mem_copy(channelList, (tANI_U8 *)pMac->roam.validChannelList,
1986 numOfChannels * sizeof(tANI_U8));
1987
1988 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
1989 bgScanParams.ChannelInfo.ChannelList = channelList;
1990 for (i = 0; i < numOfChannels; i++)
1991 {
1992 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d\n",
1993 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
1994 }
1995 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
1996
1997 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
1998 csrNeighborRoamContiguousScanRequestCallback);
1999
2000 vos_mem_free( channelList );
2001
2002 if (eHAL_STATUS_SUCCESS != status)
2003 {
2004 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
2005 }
2006
2007 return status;
2008}
2009#endif
2010
Jeff Johnson295189b2012-06-20 16:38:30 -07002011/* ---------------------------------------------------------------------------
2012
2013 \fn csrNeighborRoamNeighborScanTimerCallback
2014
2015 \brief This function is the neighbor scan timer callback function. It invokes
2016 the BG scan request based on the current and previous states
2017
2018 \param pv - CSR timer context info which includes pMac and session ID
2019
2020 \return VOID
2021
2022---------------------------------------------------------------------------*/
2023void csrNeighborRoamNeighborScanTimerCallback(void *pv)
2024{
2025 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
2026 tpAniSirGlobal pMac = pInfo->pMac;
2027 tANI_U32 sessionId = pInfo->sessionId;
2028 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2029
2030 // check if bg scan is on going, no need to send down the new params if true
2031 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2032 {
2033 //msg
2034 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending\n"));
2035 return;
2036 }
2037
2038 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
2039
2040 switch (pNeighborRoamInfo->neighborRoamState)
2041 {
2042#ifdef WLAN_FEATURE_VOWIFI_11R
2043 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2044 switch(pNeighborRoamInfo->prevNeighborRoamState)
2045 {
2046 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2047 csrNeighborRoamPerformBgScan(pMac);
2048 break;
2049 default:
2050 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
2051 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
2052 break;
2053 }
2054 break;
2055#endif /* WLAN_FEATURE_VOWIFI_11R */
2056 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
2057 csrNeighborRoamPerformBgScan(pMac);
2058 break;
2059 default:
2060 break;
2061 }
2062 return;
2063}
2064
2065/* ---------------------------------------------------------------------------
2066
2067 \fn csrNeighborRoamResultsRefreshTimerCallback
2068
2069 \brief This function is the timer callback function for results refresh timer.
2070 When this is invoked, it is as good as down event received from TL. So,
2071 clear off the roamable AP list and start the scan procedure based on 11R
2072 or non-11R association
2073
2074 \param context - CSR timer context info which includes pMac and session ID
2075
2076 \return VOID
2077
2078---------------------------------------------------------------------------*/
2079void csrNeighborRoamResultsRefreshTimerCallback(void *context)
2080{
2081 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2082 tpAniSirGlobal pMac = pInfo->pMac;
2083 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2084 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2085
2086 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2087
2088 /* Deregister reassoc callback. Ignore return status */
2089 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2090 WLANTL_HO_THRESHOLD_DOWN,
2091 csrNeighborRoamReassocIndCallback,
2092 VOS_MODULE_ID_SME);
2093
2094 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2095 {
2096 //err msg
2097 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
2098 }
2099
2100 /* Reset all the variables just as no scan had happened before */
2101 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2102
2103#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2104 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2105 {
2106 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2107 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2108 if (VOS_STATUS_SUCCESS != vosStatus)
2109 {
2110 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2111 return;
2112 }
2113 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2114 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2115 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2116 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2117 }
2118 else
2119#endif
2120 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002121 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2123 if (VOS_STATUS_SUCCESS != vosStatus)
2124 {
2125 return;
2126 }
2127 }
2128 return;
2129}
2130
2131#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2132/* ---------------------------------------------------------------------------
2133
2134 \fn csrNeighborRoamIssueNeighborRptRequest
2135
2136 \brief This function is invoked when TL issues a down event and the current assoc
2137 is a 11R association. It invokes SME RRM API to issue the neighbor request to
2138 the currently associated AP with the current SSID
2139
2140 \param pMac - The handle returned by macOpen.
2141
2142 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2143
2144---------------------------------------------------------------------------*/
2145VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
2146{
2147 tRrmNeighborRspCallbackInfo callbackInfo;
2148 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2149 tRrmNeighborReq neighborReq;
2150
2151
2152 neighborReq.no_ssid = 0;
2153
2154 /* Fill in the SSID */
2155 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2156 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2157 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2158
2159 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
2160 callbackInfo.neighborRspCallbackContext = pMac;
2161 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
2162
2163 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
2164}
2165
2166/* ---------------------------------------------------------------------------
2167
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002168 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002169
2170 \brief This function is used to merge two channel list.
2171 NB: If called with outputNumOfChannels == 0, this routines
2172 simply copies the input channel list to the output channel list.
2173
2174 \param pMac - The handle returned by macOpen.
2175 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
2176 \param inputNumOfChannels - The number of additional channels.
2177 \param pOutputChannelList - The place to put the "merged" channel list.
2178 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
2179 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
2180
2181 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2182
2183---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002184VOS_STATUS csrNeighborRoamMergeChannelLists(
2185 tpAniSirGlobal pMac,
2186 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002187 int inputNumOfChannels,
2188 tANI_U8 *pOutputChannelList,
2189 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002190 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002191 )
2192{
2193 int i = 0;
2194 int j = 0;
2195 int numChannels = outputNumOfChannels;
2196
2197 // Check for NULL pointer
2198 if (!pInputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2199
2200 // Check for NULL pointer
2201 if (!pOutputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2202
2203 // Add the "new" channels in the input list to the end of the output list.
2204 for (i = 0; i < inputNumOfChannels; i++)
2205 {
2206 for (j = 0; j < outputNumOfChannels; j++)
2207 {
2208 if (pInputChannelList[i] == pOutputChannelList[j])
2209 break;
2210 }
2211 if (j == outputNumOfChannels)
2212 {
2213 if (pInputChannelList[i])
2214 {
Madan Mohan Koyyalamudif5c368b2012-12-06 13:10:13 -08002215 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002216 "%s: [INFOLOG] Adding extra %d to Neighbor channel list\n", __func__,
2217 pInputChannelList[i]);
2218 pOutputChannelList[numChannels] = pInputChannelList[i];
2219 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002220 }
2221 }
2222 }
2223
2224 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002225 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002226
2227 return eHAL_STATUS_SUCCESS;
2228}
2229
2230/* ---------------------------------------------------------------------------
2231
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 \fn csrNeighborRoamCreateChanListFromNeighborReport
2233
2234 \brief This function is invoked when neighbor report is received for the
2235 neighbor request. Based on the channels present in the neighbor report,
2236 it generates channel list which will be used in REPORT_SCAN state to
2237 scan for these neighbor APs
2238
2239 \param pMac - The handle returned by macOpen.
2240
2241 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2242
2243---------------------------------------------------------------------------*/
2244VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2245{
2246 tpRrmNeighborReportDesc pNeighborBssDesc;
2247 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002248 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002250#if 0
2251 eHalStatus status = eHAL_STATUS_SUCCESS;
2252#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002253
2254 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2255 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2256
2257 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2258
2259 while (pNeighborBssDesc)
2260 {
2261 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2262
2263 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2264 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2265 pNeighborBssDesc->pNeighborBssDescription->channel;
2266 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2267 (tANI_U8)pNeighborBssDesc->roamScore;
2268 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2269 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2270 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2271
2272 /* Saving the channel list non-redundantly */
2273 if (numChannels > 0)
2274 {
2275 for (i = 0; i < numChannels; i++)
2276 {
2277 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2278 break;
2279 }
2280
2281 }
2282 if (i == numChannels)
2283 {
2284 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2285 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2287 "%s: [INFOLOG] Adding %d to Neighbor channel list\n", __func__,
2288 pNeighborBssDesc->pNeighborBssDescription->channel);
2289 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2290 numChannels++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 }
2292 }
2293
2294 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2295 }
2296
2297 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2298 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002299#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002301 // we have a union of the IAPP and the already existing list.
2302 status = csrNeighborRoamMergeChannelLists(
2303 pMac,
2304 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2305 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2306 channelList,
2307 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002308 &numChannels );
2309#endif
2310
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2312 }
2313
2314 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2315 /* Store the obtained channel list to the Neighbor Control data structure */
2316 if (numChannels)
2317 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2318 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2319 {
2320 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2321 return VOS_STATUS_E_RESOURCES;
2322 }
2323
2324 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2325 channelList, (numChannels) * sizeof(tANI_U8));
2326 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2327 if (numChannels)
2328 {
2329 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
2330 pNeighborRoamInfo->neighborRoamState);
2331 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
2332 }
2333 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2334 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
2335
2336 return VOS_STATUS_SUCCESS;
2337}
2338
2339/* ---------------------------------------------------------------------------
2340
2341 \fn csrNeighborRoamRRMNeighborReportResult
2342
2343 \brief This function is the neighbor report callback that will be invoked by
2344 SME RRM on receiving a neighbor report or of neighbor report is not
2345 received after timeout. On receiving a valid report, it generates a
2346 channel list from the neighbor report and starts the
2347 neighbor scan timer
2348
2349 \param context - The handle returned by macOpen.
2350 vosStatus - Status of the callback(SUCCESS/FAILURE)
2351
2352 \return VOID
2353
2354---------------------------------------------------------------------------*/
2355void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
2356{
2357 tpAniSirGlobal pMac = PMAC_STRUCT(context);
2358 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2359 eHalStatus status = eHAL_STATUS_SUCCESS;
2360
2361 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d\n"), vosStatus);
2362 switch (pNeighborRoamInfo->neighborRoamState)
2363 {
2364 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2365 /* Reset the report pending variable */
2366 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
2367 if (VOS_STATUS_SUCCESS == vosStatus)
2368 {
2369 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
2370 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
2371 if (VOS_STATUS_SUCCESS == vosStatus)
2372 {
2373 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state\n"));
2374 }
2375
2376 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2377 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2378
2379 /* Now ready for neighbor scan based on the channel list created */
2380 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2381 what palTimerStart expects */
2382 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2383 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2384 eANI_BOOLEAN_FALSE);
2385 if (eHAL_STATUS_SUCCESS != status)
2386 {
2387 /* Timer start failed.. Should we ASSERT here??? */
2388 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
2389 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2390 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2391 return;
2392 }
2393 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2394 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
2395 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2396 }
2397 else
2398 {
2399 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
2400 reach the maxNeighborRetries or receiving a successful neighbor response */
2401 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d\n"),
2402 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
2403 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
2404 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
2405 {
2406 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. \n"));
2407 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2408 if (VOS_STATUS_SUCCESS != vosStatus)
2409 {
2410 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d \n"), vosStatus);
2411 return;
2412 }
2413 /* We transitioned to different state now. Reset the Neighbor report retry count */
2414 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2415 }
2416 else
2417 {
2418 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2419 if (VOS_STATUS_SUCCESS != vosStatus)
2420 {
2421 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2422 return;
2423 }
2424 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2425 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2426 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2427 }
2428 }
2429 break;
2430 default:
2431 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
2432 break;
2433 }
2434 return;
2435}
2436#endif /* WLAN_FEATURE_VOWIFI_11R */
2437
2438
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002439#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002440tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002441 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002442 tCsrRoamConnectedProfile *pCurProfile,
2443 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002444 tDot11fBeaconIEs *pIes)
2445{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002446 tCsrAuthList authType;
2447 tCsrEncryptionList uCEncryptionType;
2448 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002449 tANI_BOOLEAN fMatch = FALSE;
2450
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002451 authType.numEntries = 1;
2452 authType.authType[0] = pCurProfile->AuthType;
2453 uCEncryptionType.numEntries = 1;
2454 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
2455 mCEncryptionType.numEntries = 1;
2456 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002457
2458 if( pIes )
2459 {
2460 if(pIes->SSID.present)
2461 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002462 fMatch = csrIsSsidMatch( pMac,
2463 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
2464 pIes->SSID.ssid, pIes->SSID.num_ssid,
2465 eANI_BOOLEAN_TRUE );
2466 if(TRUE == fMatch)
2467 {
2468 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
2469 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
2470 return (fMatch);
2471 }
2472 else
2473 {
2474 return (fMatch);
2475 }
2476
2477 }
2478 else
2479 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002480 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002481 }
2482 }
2483 else
2484 {
2485 return FALSE; // Again, treat missing pIes as a non-match.
2486 }
2487}
2488
2489tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
2490 tpAniSirGlobal pMac)
2491{
2492 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2493 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2494 tCsrRoamConnectedProfile *pCurrProfile = NULL;
2495 tCsrRoamConnectedProfile *pPrevProfile = NULL;
2496 tDot11fBeaconIEs *pIes = NULL;
2497 tSirBssDescription *pBssDesc = NULL;
2498 tANI_BOOLEAN fNew = TRUE;
2499
2500 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
2501 {
2502 return (fNew);
2503 }
2504
2505 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2506 if( !pCurrProfile )
2507 {
2508 return (fNew);
2509}
2510
2511 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
2512 if( !pPrevProfile )
2513 {
2514 return (fNew);
2515 }
2516
2517 pBssDesc = pPrevProfile->pBssDesc;
2518 if (pBssDesc)
2519 {
2520 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
2521 pBssDesc, &pIes)) &&
2522 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
2523 {
2524 fNew = FALSE;
2525 }
2526 if (pIes) {
2527 palFreeMemory(pMac->hHdd, pIes);
2528 }
2529 }
2530
2531 if (fNew)
2532 {
2533 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
2534 csrRoamFreeConnectProfile(pMac, pPrevProfile);
2535 csrRoamGetConnectProfile(pMac, sessionId, pPrevProfile);
2536 }
2537 else
2538 {
2539 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
2540 }
2541
2542 return (fNew);
2543}
2544
2545tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
2546 tpAniSirGlobal pMac,
2547 tCsrScanResult *pResult,
2548 tDot11fBeaconIEs *pIes)
2549{
2550 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2551 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2552 tCsrRoamConnectedProfile *pCurProfile = NULL;
2553 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
2554
2555 if( !(pMac->roam.roamSession
2556 && CSR_IS_SESSION_VALID(pMac, sessionId)))
2557 {
2558 return FALSE;
2559 }
2560
2561 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2562
2563 if( !pCurProfile)
2564 {
2565 return FALSE;
2566 }
2567
2568 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002569}
2570
2571/* ---------------------------------------------------------------------------
2572
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002573 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002574
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002575 \brief This function is used to prepare a channel list that is derived from
2576 the list of valid channels and does not include those in the occupied
2577 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002578
2579 \param pMac - The handle returned by macOpen.
2580 \param pInputChannelList - The default channels list.
2581 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002582 \param pOutputChannelList - The place to put the non-occupied channel list.
2583 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002584
2585 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2586
2587---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002588VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002589 tpAniSirGlobal pMac,
2590 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002591 int numOfChannels,
2592 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002593 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002594 )
2595{
2596 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002597 int outputNumOfChannels = 0; // Clear the output number of channels
2598 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
2599 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
2600
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002601 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002602 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002603 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
2604 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002605 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002606 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002607 }
2608 }
2609
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002610 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
2611 "Number of channels in the non-occupied list list=%d"),
2612 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002613
2614 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002615 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002616
2617 return eHAL_STATUS_SUCCESS;
2618}
2619#endif /* FEATURE_WLAN_LFR */
2620
Jeff Johnson295189b2012-06-20 16:38:30 -07002621/* ---------------------------------------------------------------------------
2622
2623 \fn csrNeighborRoamTransitToCFGChanScan
2624
2625 \brief This function is called whenever there is a transition to CFG chan scan
2626 state from any state. It frees up the current channel list and allocates
2627 a new memory for the channels received from CFG item. It then starts the
2628 neighbor scan timer to perform the scan on each channel one by one
2629
2630 \param pMac - The handle returned by macOpen.
2631
2632 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2633
2634---------------------------------------------------------------------------*/
2635VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
2636{
2637 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2638 eHalStatus status = eHAL_STATUS_SUCCESS;
2639 int i = 0;
2640 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002641 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002642 tpCsrChannelInfo currChannelListInfo;
2643
2644 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002645
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002646 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07002647#ifdef FEATURE_WLAN_CCX
2648 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002649 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
2651#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002652 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002654 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002655
2656
2657 /* Free up the channel list and allocate a new memory. This is because we dont know how much
2658 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
2659 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002660 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002662 vos_mem_free(currChannelListInfo->ChannelList);
2663 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002665
2666 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
2667 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
2668 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002670 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
2671 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002672 status = csrNeighborRoamMergeChannelLists(
2673 pMac,
2674 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
2675 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
2676 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002677 0, //NB: If 0, simply copy the input channel list to the output list.
2678 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002679
2680 currChannelListInfo->ChannelList =
2681 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2682 if (NULL == currChannelListInfo->ChannelList)
2683 {
2684 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2685 return VOS_STATUS_E_RESOURCES;
2686 }
2687
2688 vos_mem_copy(currChannelListInfo->ChannelList,
2689 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002690 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002691#ifdef FEATURE_WLAN_LFR
2692 else if (abs(pNeighborRoamInfo->lookupDOWNRssi) >
2693 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold))
2694 {
2695 /*
2696 * Trigger a contiguous scan on all channels when the
2697 * RSSI in the lookup DOWN notification is below reassoc
2698 * threshold. This will help us find the best available
2699 * candidate and also update the channel cache.
2700 */
2701 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
2702 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
2703 pNeighborRoamInfo->lookupDOWNRssi,
2704 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
2705
2706 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2707
2708 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2709
2710 /* We are about to start a fresh scan cycle,
2711 * purge non-P2P results from the past */
2712 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
2713
2714 csrNeighborRoamPerformContiguousBgScan(pMac);
2715
2716 /* Transition to CFG_CHAN_LIST_SCAN */
2717 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
2718
2719 return VOS_STATUS_SUCCESS;
2720 }
2721#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002722 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002723 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002724 numOfChannels = pMac->scan.occupiedChannels.numChannels;
2725 if (numOfChannels
2726#ifdef FEATURE_WLAN_LFR
2727 && ((pNeighborRoamInfo->uEmptyScanCount == 0) ||
2728 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
2729#endif
2730 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002732 /*
2733 * Always scan channels in the occupied channel list
2734 * before scanning on the non-occupied list.
2735 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302736 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to occupied channel list");
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002737 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
2738 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels);
2739
2740 if (NULL == currChannelListInfo->ChannelList)
2741 {
2742 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2743 return VOS_STATUS_E_RESOURCES;
2744 }
2745 vos_mem_copy(currChannelListInfo->ChannelList,
2746 pMac->scan.occupiedChannels.channelList,
2747 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002748 }
2749 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002750 {
2751 /* Scan all channels from non-occupied list */
2752 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
2753 numOfChannels = sizeof(pMac->roam.validChannelList);
2754
2755 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2756 (tANI_U8 *)pMac->roam.validChannelList,
2757 (tANI_U32 *) &numOfChannels)))
2758 {
2759#ifdef FEATURE_WLAN_LFR
2760 /*
2761 * Prepare non-occupied channel list (channelList)
2762 * from the actual "valid channel list" information
2763 * formed by CSR.
2764 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302765 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
2766 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
2767 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002768 numOfChannels,
2769 channelList,
2770 &numOfChannels);
2771#else
2772 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
2773 status = csrNeighborRoamMergeChannelLists(
2774 pMac,
2775 (tANI_U8 *)pMac->roam.validChannelList,
2776 numOfChannels, // The number of channels in the validChannelList
2777 channelList,
2778 0, //NB: If 0, simply copy the input channel list to the output list.
2779 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
2780#endif
2781 }
2782 else
2783 {
2784 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002785 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002787 currChannelListInfo->ChannelList =
2788 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2789
2790 if (NULL == currChannelListInfo->ChannelList)
2791 {
2792 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2793 return VOS_STATUS_E_RESOURCES;
2794 }
2795#ifdef FEATURE_WLAN_LFR
2796 vos_mem_copy(currChannelListInfo->ChannelList,
2797 channelList, numOfChannels * sizeof(tANI_U8));
2798#else
2799 vos_mem_copy(currChannelListInfo->ChannelList,
2800 (tANI_U8 *)pMac->roam.validChannelList,
2801 numOfChannels * sizeof(tANI_U8));
2802#endif
2803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 }
2805
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002806 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002807 currChannelListInfo->numOfChannels = numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002808 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
2809 "Number of channels from CFG (or) (non-)occupied list=%d",
2810 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002811 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302813 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002814 "= %d\n", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 }
2816 }
2817
2818 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2819 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2820
2821 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2822 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2823 what palTimerStart expects */
2824 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2825 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2826 eANI_BOOLEAN_FALSE);
2827
2828 if (eHAL_STATUS_SUCCESS != status)
2829 {
2830 /* Timer start failed.. */
2831 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002832 vos_mem_free(currChannelListInfo->ChannelList);
2833 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 return VOS_STATUS_E_FAILURE;
2835 }
2836
2837 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2838 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302839 /* We are about to start a fresh scan cycle,
2840 * purge non-P2P results from the past */
2841 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002842
2843 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
2844 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
2845
2846 return VOS_STATUS_SUCCESS;
2847}
2848
2849/* ---------------------------------------------------------------------------
2850
2851 \fn csrNeighborRoamNeighborLookupUpEvent
2852
2853 \brief This function is called as soon as TL indicates that the current AP's
2854 RSSI is better than the neighbor lookup threshold. Here, we transition to
2855 CONNECTED state and reset all the scan parameters
2856
2857 \param pMac - The handle returned by macOpen.
2858
2859 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2860
2861---------------------------------------------------------------------------*/
2862VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
2863{
2864 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2865 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002866 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 /* Recheck whether the below check is needed. */
2869 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
2870 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Jeff Johnsone7245742012-09-05 17:12:55 -07002871
2872 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
2873 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2874
Jeff Johnson295189b2012-06-20 16:38:30 -07002875
2876 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2877 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
2878 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2879 WLANTL_HO_THRESHOLD_DOWN,
2880 csrNeighborRoamNeighborLookupDOWNCallback,
2881 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002882#ifdef FEATURE_WLAN_LFR
2883 pNeighborRoamInfo->lookupDOWNRssi = 0;
2884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2886 {
2887 //err msg
2888 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d\n"), vosStatus);
2889 }
2890
2891
2892 return vosStatus;
2893}
2894
2895/* ---------------------------------------------------------------------------
2896
2897 \fn csrNeighborRoamNeighborLookupDownEvent
2898
2899 \brief This function is called as soon as TL indicates that the current AP's
2900 RSSI falls below the current eighbor lookup threshold. Here, we transition to
2901 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
2902 a non-11R association.
2903
2904 \param pMac - The handle returned by macOpen.
2905
2906 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2907
2908---------------------------------------------------------------------------*/
2909VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
2910{
2911 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2912 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2913 eHalStatus status = eHAL_STATUS_SUCCESS;
2914
2915 switch (pNeighborRoamInfo->neighborRoamState)
2916 {
2917 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
2918
2919 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
2920 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2921 /* De-register Neighbor Lookup threshold callback with TL */
2922 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2923 WLANTL_HO_THRESHOLD_DOWN,
2924 csrNeighborRoamNeighborLookupDOWNCallback,
2925 VOS_MODULE_ID_SME);
2926
2927 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2928 {
2929 //err msg
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002930 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 }
2932
2933
2934#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2935 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2936 {
2937
2938 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2939 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2940 if (VOS_STATUS_SUCCESS != vosStatus)
2941 {
2942 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2943 return vosStatus;
2944 }
2945 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2946 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2947 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2948 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2949 }
2950 else
2951#endif
2952 {
2953 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
2954
2955 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2956 if (VOS_STATUS_SUCCESS != vosStatus)
2957 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002958 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
2959 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 return vosStatus;
2961 }
2962 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002963 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 -07002964 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002965 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
2966 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 WLANTL_HO_THRESHOLD_UP,
2968 csrNeighborRoamNeighborLookupUPCallback,
2969 VOS_MODULE_ID_SME, pMac);
2970 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2971 {
2972 //err msg
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002973 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 }
2975 break;
2976 default:
2977 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
2978 break;
2979
2980 }
2981 return vosStatus;
2982}
2983
2984/* ---------------------------------------------------------------------------
2985
2986 \fn csrNeighborRoamNeighborLookupUPCallback
2987
2988 \brief This function is registered with TL to indicate whenever the RSSI
2989 gets better than the neighborLookup RSSI Threshold
2990
2991 \param pAdapter - VOS Context
2992 trafficStatus - UP/DOWN indication from TL
2993 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
2994
2995 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2996
2997---------------------------------------------------------------------------*/
2998VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08002999 v_PVOID_t pUserCtxt,
3000 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003001{
3002 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3003 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3004 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3005
Srinivasdaaec712012-12-12 15:59:44 -08003006 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
3007 rssiNotification,
3008 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003009
3010 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3011 {
3012 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
3013 return VOS_STATUS_SUCCESS;
3014 }
3015
3016 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
3017 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
3018 return vosStatus;
3019}
3020
3021/* ---------------------------------------------------------------------------
3022
3023 \fn csrNeighborRoamNeighborLookupDOWNCallback
3024
3025 \brief This function is registered with TL to indicate whenever the RSSI
3026 falls below the current neighborLookup RSSI Threshold
3027
3028 \param pAdapter - VOS Context
3029 trafficStatus - UP/DOWN indication from TL
3030 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3031
3032 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3033
3034---------------------------------------------------------------------------*/
3035VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003036 v_PVOID_t pUserCtxt,
3037 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003038{
3039 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3040 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3041 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3042
Srinivasdaaec712012-12-12 15:59:44 -08003043 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
3044 rssiNotification,
3045 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003046
Srikant Kuppa866893f2012-12-27 17:28:14 -08003047#ifdef FEATURE_WLAN_LFR
3048 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
3049#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3051 {
3052 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
3053 return VOS_STATUS_SUCCESS;
3054 }
3055
3056 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
3057 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
3058
3059 return vosStatus;
3060}
3061
3062#ifdef RSSI_HACK
3063extern int dumpCmdRSSI;
3064#endif
3065
3066/* ---------------------------------------------------------------------------
3067
3068 \fn csrNeighborRoamIndicateDisconnect
3069
3070 \brief This function is called by CSR as soon as the station disconnects from
3071 the AP. This function does the necessary cleanup of neighbor roam data
3072 structures. Neighbor roam state transitions to INIT state whenever this
3073 function is called except if the current state is REASSOCIATING
3074
3075 \param pMac - The handle returned by macOpen.
3076 sessionId - CSR session id that got disconnected
3077
3078 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3079
3080---------------------------------------------------------------------------*/
3081eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
3082{
3083 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3084
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003085 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d (sub-state %d)"),
3086 sessionId, pNeighborRoamInfo->neighborRoamState,
3087 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003088
3089#ifdef FEATURE_WLAN_CCX
3090 {
3091 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
3092 if (pSession->connectedProfile.isCCXAssoc)
3093 {
3094 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
3095 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3096 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
3097 pSession->isPrevApInfoValid = TRUE;
3098 pSession->roamTS1 = vos_timer_get_system_time();
3099
3100 }
3101 }
3102#endif
3103
3104#ifdef RSSI_HACK
3105 dumpCmdRSSI = -40;
3106#endif
3107 switch (pNeighborRoamInfo->neighborRoamState)
3108 {
3109 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3110 // Stop scan and neighbor refresh timers.
3111 // These are indeed not required when we are in reassociating
3112 // state.
3113 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3114 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003115 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
3116 /*
3117 * Disconnect indication during Disassoc Handoff sub-state
3118 * is received when we are trying to disconnect with the old
3119 * AP during roam. BUT, if receive a disconnect indication
3120 * outside of Disassoc Handoff sub-state, then it means that
3121 * this is a genuine disconnect and we need to clean up.
3122 * Otherwise, we will be stuck in reassoc state which will
3123 * in-turn block scans (see csrIsScanAllowed).
3124 */
3125 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 break;
3128
3129 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 csrNeighborRoamResetInitStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003131 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 break;
3133
Srikant Kuppa866893f2012-12-27 17:28:14 -08003134 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3135 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3136 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3137 csrNeighborRoamDeregAllRssiIndication(pMac);
3138 break;
3139
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003140 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
3141 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3142 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
3143 csrNeighborRoamDeregAllRssiIndication(pMac);
3144 break;
3145
3146 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3147 /* Stop pre-auth to reassoc interval timer */
3148 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003149 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3150 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3151 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003152 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003153 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003154 csrNeighborRoamDeregAllRssiIndication(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003155 break;
3156
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003158 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
3159 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 }
3163 return eHAL_STATUS_SUCCESS;
3164}
3165
3166/* ---------------------------------------------------------------------------
3167
3168 \fn csrNeighborRoamIndicateConnect
3169
3170 \brief This function is called by CSR as soon as the station connects to an AP.
3171 This initializes all the necessary data structures related to the
3172 associated AP and transitions the state to CONNECTED state
3173
3174 \param pMac - The handle returned by macOpen.
3175 sessionId - CSR session id that got connected
3176 vosStatus - connect status SUCCESS/FAILURE
3177
3178 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3179
3180---------------------------------------------------------------------------*/
3181eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
3182{
3183 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3184 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07003185 VOS_STATUS vstatus;
3186
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003187#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 int init_ft_flag = FALSE;
3189#endif
3190
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003191 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003192
3193 switch (pNeighborRoamInfo->neighborRoamState)
3194 {
3195 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3196 if (VOS_STATUS_SUCCESS != vosStatus)
3197 {
3198 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
3199 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3200 break;
3201 }
3202 /* Fall through if the status is SUCCESS */
3203 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
3204 /* Reset all the data structures here */
3205 csrNeighborRoamResetInitStateControlInfo(pMac);
3206
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003208
3209#ifdef FEATURE_WLAN_LFR
3210 /*
3211 * Initialize the occupied list ONLY if we are
3212 * transitioning from INIT state to CONNECTED state.
3213 */
3214 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
3215 csrInitOccupiedChannelsList(pMac);
3216#endif
3217 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
3218
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
3220 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
3221 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
3222 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3223 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003224 pNeighborRoamInfo->currentNeighborLookupThreshold =
3225 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
3226#ifdef FEATURE_WLAN_LFR
3227 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08003228 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003229#endif
3230
Jeff Johnson295189b2012-06-20 16:38:30 -07003231
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003232#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 /* Now we can clear the preauthDone that was saved as we are connected afresh */
3234 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3235#endif
3236
3237#ifdef WLAN_FEATURE_VOWIFI_11R
3238 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003239 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
3240 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 {
3242 if (pMac->roam.configParam.isFastTransitionEnabled)
3243 init_ft_flag = TRUE;
3244 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
3245 }
3246 else
3247 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003248 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003249#endif
3250
3251#ifdef FEATURE_WLAN_CCX
3252 // Based on the auth scheme tell if we are 11r
3253 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
3254 {
3255 if (pMac->roam.configParam.isFastTransitionEnabled)
3256 init_ft_flag = TRUE;
3257 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
3258 }
3259 else
3260 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003261 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
3262 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07003263
3264#endif
3265
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003266#ifdef FEATURE_WLAN_LFR
3267 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303268 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003269 {
3270 init_ft_flag = TRUE;
3271 }
3272#endif
3273
3274#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 if ( init_ft_flag == TRUE )
3276 {
3277 /* Initialize all the data structures needed for the 11r FT Preauth */
3278 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
3279 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = sessionId;
3280 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3281 csrNeighborRoamPurgePreauthFailedList(pMac);
3282
3283 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
3284 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07003285 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 WLANTL_HO_THRESHOLD_DOWN,
3287 csrNeighborRoamNeighborLookupDOWNCallback,
3288 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003289#ifdef FEATURE_WLAN_LFR
3290 pNeighborRoamInfo->lookupDOWNRssi = 0;
3291#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07003292 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 {
3294 //err msg
Jeff Johnson43971f52012-07-17 12:26:56 -07003295 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d\n"), vstatus);
3296 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 }
3298 }
3299#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 break;
3301 default:
3302 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3303 break;
3304 }
3305 return status;
3306}
3307
3308
3309#ifdef WLAN_FEATURE_VOWIFI_11R
3310/* ---------------------------------------------------------------------------
3311
3312 \fn csrNeighborRoamPreAuthResponseWaitTimerHandler
3313
3314 \brief If this function is invoked, that means the preauthentication response
3315 is timed out from the PE. Preauth rsp handler is called with status as
3316 TIMEOUT
3317
3318 \param context - CSR Timer info which holds pMac and session ID
3319
3320 \return VOID
3321
3322---------------------------------------------------------------------------*/
3323void csrNeighborRoamPreAuthResponseWaitTimerHandler(void *context)
3324{
3325 tCsrTimerInfo *pTimerInfo = (tCsrTimerInfo *)context;
3326 tpAniSirGlobal pMac = (tpAniSirGlobal)pTimerInfo->pMac;
3327 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3328
3329 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
3330
3331 csrNeighborRoamPreauthRspHandler(pMac, VOS_STATUS_E_TIMEOUT);
3332}
3333
3334/* ---------------------------------------------------------------------------
3335
3336 \fn csrNeighborRoamPurgePreauthFailedList
3337
3338 \brief This function purges all the MAC addresses in the pre-auth fail list
3339
3340 \param pMac - The handle returned by macOpen.
3341
3342 \return VOID
3343
3344---------------------------------------------------------------------------*/
3345void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
3346{
3347 tANI_U8 i;
3348
3349 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
3350 {
3351 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
3352 }
3353 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
3354
3355 return;
3356}
3357
3358/* ---------------------------------------------------------------------------
3359
3360 \fn csrNeighborRoamInit11rAssocInfo
3361
3362 \brief This function initializes 11r related neighbor roam data structures
3363
3364 \param pMac - The handle returned by macOpen.
3365
3366 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3367
3368---------------------------------------------------------------------------*/
3369eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
3370{
3371 eHalStatus status;
3372 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
3373
3374 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
3375 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
3376 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
3377 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
3378 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
3379 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
3380
3381 pFTRoamInfo->preAuthRspWaitTimerInfo.pMac = pMac;
3382 pFTRoamInfo->preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3383 status = palTimerAlloc(pMac->hHdd, &pFTRoamInfo->preAuthRspWaitTimer,
3384 csrNeighborRoamPreAuthResponseWaitTimerHandler, (void *)&pFTRoamInfo->preAuthRspWaitTimerInfo);
3385
3386 if (eHAL_STATUS_SUCCESS != status)
3387 {
3388 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3389 return eHAL_STATUS_RESOURCES;
3390 }
3391
3392 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3393 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3394 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3395 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3396
3397
3398 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
3399 if (eHAL_STATUS_SUCCESS != status)
3400 {
3401 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
3402 palTimerFree(pMac->hHdd, pFTRoamInfo->preAuthRspWaitTimer);
3403 return eHAL_STATUS_RESOURCES;
3404 }
3405 return status;
3406}
3407#endif /* WLAN_FEATURE_VOWIFI_11R */
3408
3409/* ---------------------------------------------------------------------------
3410
3411 \fn csrNeighborRoamInit
3412
3413 \brief This function initializes neighbor roam data structures
3414
3415 \param pMac - The handle returned by macOpen.
3416
3417 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3418
3419---------------------------------------------------------------------------*/
3420eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
3421{
3422 eHalStatus status;
3423 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3424
3425 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3426 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3427 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
3428 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
3429 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
3430 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
3431 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
3432 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
3433 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
3434 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
3435
3436 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
3437 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
3438
3439 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
3440 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3441
3442 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3443 {
3444 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
3445 return eHAL_STATUS_RESOURCES;
3446 }
3447
3448 /* Update the roam global structure from CFG */
3449 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3450 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
3451 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3452
3453 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
3454 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003455#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08003456 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003457 pNeighborRoamInfo->uEmptyScanCount = 0;
3458 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
3459 sizeof(tCsrRoamConnectedProfile));
3460#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
3462
3463 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3464 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3465 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborScanTimer,
3466 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3467
3468 if (eHAL_STATUS_SUCCESS != status)
3469 {
3470 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3471 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3472 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3473 return eHAL_STATUS_RESOURCES;
3474 }
3475
3476 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborResultsRefreshTimer,
3477 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3478
3479 if (eHAL_STATUS_SUCCESS != status)
3480 {
3481 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3482 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3483 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3484 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3485 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3486 return eHAL_STATUS_RESOURCES;
3487 }
3488
3489 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
3490 if (eHAL_STATUS_SUCCESS != status)
3491 {
3492 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3493 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3494 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3495 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3496 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3497 return eHAL_STATUS_RESOURCES;
3498 }
3499
3500 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3501 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3502 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3503 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3504 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3505
3506#ifdef WLAN_FEATURE_VOWIFI_11R
3507 status = csrNeighborRoamInit11rAssocInfo(pMac);
3508 if (eHAL_STATUS_SUCCESS != status)
3509 {
3510 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3511 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3512 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3513 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3514 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3515 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3516 return eHAL_STATUS_RESOURCES;
3517 }
3518#endif
3519 /* Initialize this with the current tick count */
3520 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3521
3522 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3523
3524 return eHAL_STATUS_SUCCESS;
3525}
3526
3527/* ---------------------------------------------------------------------------
3528
3529 \fn csrNeighborRoamClose
3530
3531 \brief This function closes/frees all the neighbor roam data structures
3532
3533 \param pMac - The handle returned by macOpen.
3534
3535 \return VOID
3536
3537---------------------------------------------------------------------------*/
3538void csrNeighborRoamClose(tpAniSirGlobal pMac)
3539{
3540 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3541
3542 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
3543 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07003544 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 return;
3546 }
3547
3548 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3549 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3550
3551 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3552
3553 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
3554 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3555 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3556 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3557
3558 /* Should free up the nodes in the list before closing the double Linked list */
3559 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
3560 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3561
3562 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3563 {
3564 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3565 }
3566
3567 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3568 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3569 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3570 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3571 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3572 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3573
3574 /* Free the profile.. */
3575 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003576#ifdef FEATURE_WLAN_LFR
Sandeep Pc2b00f62012-12-12 16:44:44 -08003577 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003578#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003579#ifdef WLAN_FEATURE_VOWIFI_11R
3580 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3581 palTimerFree(pMac->hHdd, pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimer);
3582 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.pMac = NULL;
3583 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3584 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3585 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3586 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3587 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3588 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3589#endif /* WLAN_FEATURE_VOWIFI_11R */
3590
3591 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
3592
3593 return;
3594}
3595
3596/* ---------------------------------------------------------------------------
3597
3598 \fn csrNeighborRoamRequestHandoff
3599
3600 \brief This function triggers actual switching from one AP to the new AP.
3601 It issues disassociate with reason code as Handoff and CSR as a part of
3602 handling disassoc rsp, issues reassociate to the new AP
3603
3604 \param pMac - The handle returned by macOpen.
3605
3606 \return VOID
3607
3608---------------------------------------------------------------------------*/
3609void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
3610{
3611
3612 tCsrRoamInfo roamInfo;
3613 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3614 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3615 tCsrNeighborRoamBSSInfo handoffNode;
3616 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
3617 tANI_U32 roamId = 0;
3618
3619 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
3620 {
3621 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
3622 pMac->roam.neighborRoamInfo.neighborRoamState);
3623 return;
3624 }
3625
3626 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3627 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
3628 eSIR_SME_SUCCESS);
3629
3630 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3631 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
3632
3633 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003634 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
3635 FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 handoffNode.pBssDescription->bssId[0],
3637 handoffNode.pBssDescription->bssId[1],
3638 handoffNode.pBssDescription->bssId[2],
3639 handoffNode.pBssDescription->bssId[3],
3640 handoffNode.pBssDescription->bssId[4],
3641 handoffNode.pBssDescription->bssId[5]);
3642
3643 /* Free the profile.. Just to make sure we dont leak memory here */
3644 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
3645 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
3646 This should happen before issuing disconnect */
3647 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
3648 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
3649 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
3650
3651 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP\n");
3652
3653 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
3654 {
3655 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate\n");
3656 return;
3657 }
3658
3659 //notify HDD for handoff, providing the BSSID too
3660 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
3661
3662 vos_mem_copy(roamInfo.bssid,
3663 handoffNode.pBssDescription->bssId,
3664 sizeof( tCsrBssid ));
3665
3666 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
3667
3668
3669 return;
3670}
3671
3672/* ---------------------------------------------------------------------------
3673
3674 \fn csrNeighborRoamIsHandoffInProgress
3675
3676 \brief This function returns whether handoff is in progress or not based on
3677 the current neighbor roam state
3678
3679 \param pMac - The handle returned by macOpen.
3680 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
3681
3682 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
3683
3684---------------------------------------------------------------------------*/
3685tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
3686{
3687 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
3688 return eANI_BOOLEAN_TRUE;
3689
3690 return eANI_BOOLEAN_FALSE;
3691}
3692
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003693#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07003694/* ---------------------------------------------------------------------------
3695
3696 \fn csrNeighborRoamIs11rAssoc
3697
3698 \brief This function returns whether the current association is a 11r assoc or not
3699
3700 \param pMac - The handle returned by macOpen.
3701
3702 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
3703
3704---------------------------------------------------------------------------*/
3705tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
3706{
3707 return pMac->roam.neighborRoamInfo.is11rAssoc;
3708}
3709#endif /* WLAN_FEATURE_VOWIFI_11R */
3710
3711
3712/* ---------------------------------------------------------------------------
3713
3714 \fn csrNeighborRoamGetHandoffAPInfo
3715
3716 \brief This function returns the best possible AP for handoff. For 11R case, it
3717 returns the 1st entry from pre-auth done list. For non-11r case, it returns
3718 the 1st entry from roamable AP list
3719
3720 \param pMac - The handle returned by macOpen.
3721 pHandoffNode - AP node that is the handoff candidate returned
3722
3723 \return VOID
3724
3725---------------------------------------------------------------------------*/
3726void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
3727{
3728 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3729 tpCsrNeighborRoamBSSInfo pBssNode;
3730
3731 VOS_ASSERT(NULL != pHandoffNode);
3732
3733#ifdef WLAN_FEATURE_VOWIFI_11R
3734 if (pNeighborRoamInfo->is11rAssoc)
3735 {
3736 /* Always the BSS info in the head is the handoff candidate */
3737 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3738 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3739 }
3740 else
3741#endif
3742#ifdef FEATURE_WLAN_CCX
3743 if (pNeighborRoamInfo->isCCXAssoc)
3744 {
3745 /* Always the BSS info in the head is the handoff candidate */
3746 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3747 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3748 }
3749 else
3750#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003751#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303752 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003753 {
3754 /* Always the BSS info in the head is the handoff candidate */
3755 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3756 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3757 }
3758 else
3759#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 {
3761 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
3762 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
3763 }
3764 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
3765
3766 return;
3767}
3768
3769/* ---------------------------------------------------------------------------
3770 \brief This function returns TRUE if preauth is completed
3771
3772 \param pMac - The handle returned by macOpen.
3773
3774 \return boolean
3775
3776---------------------------------------------------------------------------*/
3777tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
3778{
3779 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
3780 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
3781}
3782
3783/* ---------------------------------------------------------------------------
3784 \brief In the event that we are associated with AP1 and we have
3785 completed pre auth with AP2. Then we receive a deauth/disassoc from
3786 AP1.
3787 At this point neighbor roam is in pre auth done state, pre auth timer
3788 is running. We now handle this case by stopping timer and clearing
3789 the pre-auth state. We basically clear up and just go to disconnected
3790 state.
3791
3792 \param pMac - The handle returned by macOpen.
3793
3794 \return boolean
3795---------------------------------------------------------------------------*/
3796void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
3797{
3798 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
3799 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
3800
3801 // Stop timer
3802 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
3803
3804 // Transition to init state
3805 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3806}
3807
Srikant Kuppafef66a72013-01-30 17:32:44 -08003808/* ---------------------------------------------------------------------------
3809 \brief This function returns TRUE if preauth is completed
3810
3811 \param halHandle - The handle from HDD context.
3812
3813 \return boolean
3814
3815---------------------------------------------------------------------------*/
3816tANI_BOOLEAN csrNeighborRoamScanRspPending (tHalHandle hHal)
3817{
3818 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3819 return (pMac->roam.neighborRoamInfo.scanRspPending);
3820}
3821
Jeff Johnson295189b2012-06-20 16:38:30 -07003822#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */