blob: 151df776a7c92914c29d4a95aae1b6122bbd606c [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
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800199 smsLog(pMac, LOGE, FL("Removing neighbor BSS node from list failed. Current count = %d"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
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
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800258 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Emptying the BSS list. Current count = %d"), 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
Srinivas Girigowdade697412013-02-14 16:31:48 -0800331VOS_STATUS csrNeighborRoamSetLookupRssiThreshold(tpAniSirGlobal pMac, v_U8_t neighborLookupRssiThreshold)
332{
333 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
334 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
335
336 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
337 {
338 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in CONNECTED state, so deregister all and re-register for DOWN event again"));
339 /* De-register existing lookup UP/DOWN, Rssi indications */
340 csrNeighborRoamDeregAllRssiIndication(pMac);
341 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
342 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
343
344 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
345 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
346 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
347 WLANTL_HO_THRESHOLD_DOWN,
348 csrNeighborRoamNeighborLookupDOWNCallback,
349 VOS_MODULE_ID_SME, pMac);
350 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
351 {
352 //err msg
353 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
354 vosStatus = VOS_STATUS_E_FAILURE;
355 }
356 }
357 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
358 {
359 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, safe to set lookupRssi threshold"));
360 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
361 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
362 }
363 else
364 {
365 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Unexpected state %d, returning failure"), pNeighborRoamInfo->neighborRoamState);
366 vosStatus = VOS_STATUS_E_FAILURE;
367 }
368 return vosStatus;
369}
370
Jeff Johnson295189b2012-06-20 16:38:30 -0700371/* ---------------------------------------------------------------------------
372
373 \fn csrNeighborRoamReassocIndCallback
374
375 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
376 Directly triggere HO in case of non-11r association
377 In case of 11R association, triggers a pre-auth eventually followed by actual HO
378
379 \param pAdapter - VOS Context
380 trafficStatus - UP/DOWN indication from TL
381 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
382
383 \return VOID
384
385---------------------------------------------------------------------------*/
386VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
387 v_U8_t trafficStatus,
Srinivasdaaec712012-12-12 15:59:44 -0800388 v_PVOID_t pUserCtxt,
389 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700390{
391 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
392 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
393 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
394
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800395 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"),
Srinivasdaaec712012-12-12 15:59:44 -0800396 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
397 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700398
399 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
400 WLANTL_HO_THRESHOLD_DOWN,
401 csrNeighborRoamReassocIndCallback,
402 VOS_MODULE_ID_SME);
403
404 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
405 {
406 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800407 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
409
Srinivasdaaec712012-12-12 15:59:44 -0800410 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
411 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800412 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
413 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
414 WLANTL_HO_THRESHOLD_UP,
415 csrNeighborRoamNeighborLookupUPCallback,
416 VOS_MODULE_ID_SME);
Jeff Johnson295189b2012-06-20 16:38:30 -0700417
418 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
419 {
420 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800421 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 }
423
424 /* We dont need to run this timer any more. */
425 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800426 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700427
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800428 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700429
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 return VOS_STATUS_SUCCESS;
431}
432
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700433/*CleanUP Routines*/
434static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
435{
436 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
437 (rChInfo->currentChannelListInfo.numOfChannels))
438 {
439 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
440 rChInfo->currentChannelListInfo.numOfChannels = 0;
441
442 if (rChInfo->currentChannelListInfo.ChannelList)
443 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
444
445 rChInfo->currentChannelListInfo.ChannelList = NULL;
446 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
447 }
448 else
449 {
450 rChInfo->currentChanIndex = 0;
451 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
452 }
453}
454
455static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
456{
457 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
458
459 /* Stop neighbor scan timer */
460 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
461
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700462 /* Stop neighbor scan results refresh timer */
463 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
464
Srinivas Girigowdade697412013-02-14 16:31:48 -0800465 /* Stop empty scan results refresh timer */
466 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
467
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700468 /* Abort any ongoing scan */
469 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
470 {
471 csrScanAbortMacScan(pMac);
472 }
473 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
474
475 /* Reset roam channel list information */
476 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
477}
478
479static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
480{
481 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
482
483#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
484 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700485 /* Purge pre-auth fail list */
486 csrNeighborRoamPurgePreauthFailedList(pMac);
487#endif
488
489 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
490 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
491#ifdef WLAN_FEATURE_VOWIFI_11R
492 /* Do not free up the preauth done list here */
493 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
494 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
495 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
496 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700497#endif
498}
499
500static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
501{
502 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
503 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
504
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800505 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700506 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800507 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700508
509 /* Deregister reassoc callback. Ignore return status */
510 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800511 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700512 WLANTL_HO_THRESHOLD_UP,
513 csrNeighborRoamNeighborLookupUPCallback,
514 VOS_MODULE_ID_SME);
515
516 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800518 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700519 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800520 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700521 }
522
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800523 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700524 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
525 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
526
527 /* Deregister reassoc callback. Ignore return status */
528 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
529 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
530 WLANTL_HO_THRESHOLD_DOWN,
531 csrNeighborRoamReassocIndCallback,
532 VOS_MODULE_ID_SME);
533
534 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800536 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700537 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800538 "TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700539 }
540
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800541 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700542 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
543 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
544
545 /* Deregister neighbor lookup callback. Ignore return status */
546 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
547 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
548 WLANTL_HO_THRESHOLD_DOWN,
549 csrNeighborRoamNeighborLookupDOWNCallback,
550 VOS_MODULE_ID_SME);
551
552 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800554 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700555 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800556 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700557 }
558
559 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700560 pNeighborRoamInfo->currentNeighborLookupThreshold =
561 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800562#ifdef FEATURE_WLAN_LFR
563 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -0800564 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -0800565 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800566#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700567}
568
Jeff Johnson295189b2012-06-20 16:38:30 -0700569/* ---------------------------------------------------------------------------
570
571 \fn csrNeighborRoamResetConnectedStateControlInfo
572
573 \brief This function will reset the neighbor roam control info data structures.
574 This function should be invoked whenever we move to CONNECTED state from
575 any state other than INIT state
576
577 \param pMac - The handle returned by macOpen.
578
579 \return VOID
580
581---------------------------------------------------------------------------*/
582void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
583{
584 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
585
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700586 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700589 /* We dont need to run this timer any more. */
590 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800591 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
593#ifdef WLAN_FEATURE_VOWIFI_11R
594 /* Do not free up the preauth done list here */
595 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
596 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
597 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
598 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
599 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
600 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700602}
603
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700604void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700605{
606 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
608 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
609 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
610 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700611#ifdef FEATURE_WLAN_CCX
612 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
613 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
614 pNeighborRoamInfo->MinQBssLoadRequired = 0;
615#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700616
617 /* Stop scan refresh timer */
618 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800619 /* Stop empty scan results refresh timer */
620 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700621 /* Purge roamable AP list */
622 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 return;
624}
625
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700626/* ---------------------------------------------------------------------------
627
628 \fn csrNeighborRoamResetInitStateControlInfo
629
630 \brief This function will reset the neighbor roam control info data structures.
631 This function should be invoked whenever we move to CONNECTED state from
632 INIT state
633
634 \param pMac - The handle returned by macOpen.
635
636 \return VOID
637
638---------------------------------------------------------------------------*/
639void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
640{
641 csrNeighborRoamResetConnectedStateControlInfo(pMac);
642
643 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
644 csrNeighborRoamResetReportScanStateControlInfo(pMac);
645}
646
647
648
Jeff Johnson295189b2012-06-20 16:38:30 -0700649#ifdef WLAN_FEATURE_VOWIFI_11R
650/* ---------------------------------------------------------------------------
651
652 \fn csrNeighborRoamBssIdScanFilter
653
654 \brief This API is used to prepare a filter to obtain scan results when
655 we complete the scan in the REPORT_SCAN state after receiving a
656 valid neighbor report from AP. This filter includes BSSIDs received from
657 the neighbor report from the AP in addition to the other filter parameters
658 created from connected profile
659
660 \param pMac - The handle returned by macOpen.
661 pScanFilter - Scan filter to be filled and returned
662
663 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
664 code otherwise
665
666---------------------------------------------------------------------------*/
667static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
668{
669 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
670 tANI_U8 i = 0;
671
672 VOS_ASSERT(pScanFilter != NULL);
673 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
674
675 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
676 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
677 if (NULL == pScanFilter->BSSIDs.bssid)
678 {
679 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
680 return eHAL_STATUS_FAILED_ALLOC;
681 }
682
683 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
684
685 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
686 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
687 {
688 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
689 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
690 }
691
692 /* Fill other general scan filter params */
693 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
694}
695
696/* ---------------------------------------------------------------------------
697
698 \fn csrNeighborRoamPurgePreauthFailList
699
700 \brief This function empties the preauth fail list
701
702 \param pMac - The handle returned by macOpen.
703
704 \return VOID
705
706---------------------------------------------------------------------------*/
707void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
708{
709 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
710
711 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
712 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
713 {
714 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
715 sizeof(tSirMacAddr));
716 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
717 }
718 return;
719}
720
721/* ---------------------------------------------------------------------------
722
723 \fn csrNeighborRoamAddBssIdToPreauthFailList
724
725 \brief This function adds the given BSSID to the Preauth fail list
726
727 \param pMac - The handle returned by macOpen.
728 bssId - BSSID to be added to the preauth fail list
729
730 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
731
732---------------------------------------------------------------------------*/
733eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
734{
735 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
736
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800737 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL(" Added BSSID %02x:%02x:%02x:%02x:%02x:%02x to Preauth failed list"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
739
740
741 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
742 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
743 {
744 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
745 return eHAL_STATUS_FAILURE;
746 }
747 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
748 bssId, sizeof(tSirMacAddr));
749 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
750
751 return eHAL_STATUS_SUCCESS;
752}
753
754/* ---------------------------------------------------------------------------
755
756 \fn csrNeighborRoamIsPreauthCandidate
757
758 \brief This function checks whether the given MAC address is already
759 present in the preauth fail list and returns TRUE/FALSE accordingly
760
761 \param pMac - The handle returned by macOpen.
762
763 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
764
765---------------------------------------------------------------------------*/
766tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
767{
768 tANI_U8 i = 0;
769 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
770
771 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
772 return eANI_BOOLEAN_TRUE;
773
774 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
775 {
776 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
777 bssId, sizeof(tSirMacAddr)))
778 {
779 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
780 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
781 return eANI_BOOLEAN_FALSE;
782 }
783 }
784
785 return eANI_BOOLEAN_TRUE;
786}
787
788/* ---------------------------------------------------------------------------
789
790 \fn csrNeighborRoamIssuePreauthReq
791
792 \brief This function issues preauth request to PE with the 1st AP entry in the
793 roamable AP list
794
795 \param pMac - The handle returned by macOpen.
796
797 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
798
799---------------------------------------------------------------------------*/
800static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
801{
802 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
803 eHalStatus status = eHAL_STATUS_SUCCESS;
804 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
805
806 /* This must not be true here */
807 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
808
809 /* Issue Preauth request to PE here */
810 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
811 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
812 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
813 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
814
815 if (NULL == pNeighborBssNode)
816 {
817 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
818 return eHAL_STATUS_FAILURE;
819 }
820 else
821 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700822 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
823 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530824
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800825 smsLog(pMac, LOG1, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530826 pNeighborBssNode->pBssDescription->bssId[0],
827 pNeighborBssNode->pBssDescription->bssId[1],
828 pNeighborBssNode->pBssDescription->bssId[2],
829 pNeighborBssNode->pBssDescription->bssId[3],
830 pNeighborBssNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800831 pNeighborBssNode->pBssDescription->bssId[5],
832 (int)pNeighborBssNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530833
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 if (eHAL_STATUS_SUCCESS != status)
835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800836 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 return status;
838 }
839 }
840
841 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
842
843 /* Increment the preauth retry count */
844 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
845
846 /* Transition the state to preauthenticating */
847 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Jeff Johnson295189b2012-06-20 16:38:30 -0700848
849 return status;
850}
851
852/* ---------------------------------------------------------------------------
853
854 \fn csrNeighborRoamPreauthRspHandler
855
856 \brief This function handle the Preauth response from PE
857 Every preauth is allowed max 3 tries if it fails. If a bssid failed
858 for more than MAX_TRIES, we will remove it from the list and try
859 with the next node in the roamable AP list and add the BSSID to pre-auth failed
860 list. If no more entries present in
861 roamable AP list, transition to REPORT_SCAN state
862
863 \param pMac - The handle returned by macOpen.
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800864 limStatus - eSIR_SUCCESS/eSIR_FAILURE/eSIR_LIM_MAX_STA_REACHED_ERROR/
865 eSIT_LIM_AUTH_RSP_TIMEOUT status from PE
Jeff Johnson295189b2012-06-20 16:38:30 -0700866
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700867 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
868 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -0700869
870---------------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800871eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, tSirRetStatus limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700872{
873 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
874 eHalStatus status = eHAL_STATUS_SUCCESS;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800875 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700876 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700878
879 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
880 {
881
882 /* This can happen when we disconnect immediately
883 * after sending a pre-auth request. During processing
884 * of the disconnect command, we would have reset
885 * preauthRspPending and transitioned to INIT state.
886 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800887 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
888 FL("Unexpected pre-auth response in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700889 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700890 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700891 goto DEQ_PREAUTH;
892 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700893
894 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
896 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
897 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800898 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700899 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700900 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700901 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 }
903
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800904 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700905
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800906 if (eSIR_SUCCESS == limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 {
908 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
909 }
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800910 if ((eSIR_SUCCESS == limStatus) && (NULL != pPreauthRspNode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800912 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800914 smsLog(pMac, LOG1, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530915 pPreauthRspNode->pBssDescription->bssId[0],
916 pPreauthRspNode->pBssDescription->bssId[1],
917 pPreauthRspNode->pBssDescription->bssId[2],
918 pPreauthRspNode->pBssDescription->bssId[3],
919 pPreauthRspNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800920 pPreauthRspNode->pBssDescription->bssId[5],
921 (int)pPreauthRspNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
924 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
925 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
926
927 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
928 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
929 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
930
931 /* The caller of this function would start a timer and by the time it expires, supplicant should
932 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
933 }
934 else
935 {
936 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
937 tListElem *pEntry;
938
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800939 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = 0x%x"),
940 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, limStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700941
942 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800943 if ((pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >=
944 CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES) ||
945 (eSIR_LIM_MAX_STA_REACHED_ERROR == limStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 {
947 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
948 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
949
950 /* The one in the head of the list should be one with which we issued pre-auth and failed */
951 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
952 if(pEntry)
953 {
954 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
955 /* Add the BSSID to pre-auth fail list */
956 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
957 /* Now we can free this node */
958 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
959 }
960 }
961
962 /* Issue preauth request for the same/next entry */
963 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700964 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700965
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800966 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
967
968 /* Register Neighbor Lookup threshold callback with TL for UP event now */
969 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
970 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
971
972 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
973 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
974 WLANTL_HO_THRESHOLD_UP,
975 csrNeighborRoamNeighborLookupUPCallback,
976 VOS_MODULE_ID_SME, pMac);
977 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
978 {
979 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800980 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800981 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
983 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
984 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
985 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
986 eANI_BOOLEAN_FALSE);
987 if (eHAL_STATUS_SUCCESS != status)
988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800989 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 }
991 }
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700992
993DEQ_PREAUTH:
994 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700995 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700996}
997#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
998
999/* ---------------------------------------------------------------------------
1000
1001 \fn csrNeighborRoamPrepareScanProfileFilter
1002
1003 \brief This function creates a scan filter based on the currently connected profile.
1004 Based on this filter, scan results are obtained
1005
1006 \param pMac - The handle returned by macOpen.
1007 pScanFilter - Populated scan filter based on the connected profile
1008
1009 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
1010
1011---------------------------------------------------------------------------*/
1012eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
1013{
1014 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1015 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
1016 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
1017 tANI_U8 i = 0;
1018
1019 VOS_ASSERT(pScanFilter != NULL);
1020
1021 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
1022
1023 /* We dont want to set BSSID based Filter */
1024 pScanFilter->BSSIDs.numOfBSSIDs = 0;
1025
1026 /* Populate all the information from the connected profile */
1027 pScanFilter->SSIDs.numOfSSIDs = 1;
1028 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
1029 if (NULL == pScanFilter->SSIDs.SSIDList)
1030 {
1031 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
1032 return eHAL_STATUS_FAILED_ALLOC;
1033 }
1034 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
1035 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
1036 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
1037 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
1038
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001039 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering for SSID %s from scan results.. SSID Length = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 pScanFilter->SSIDs.SSIDList->SSID.ssId, pScanFilter->SSIDs.SSIDList->SSID.length);
1041 pScanFilter->authType.numEntries = 1;
1042 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
1043
1044 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
1045 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
1046
1047 pScanFilter->mcEncryptionType.numEntries = 1;
1048 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
1049
1050 pScanFilter->BSSType = pCurProfile->BSSType;
1051
1052 /* We are intrested only in the scan results on channels that we scanned */
1053 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
1054 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
1055 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1056 {
1057 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1058 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1059 pScanFilter->SSIDs.SSIDList = NULL;
1060 return eHAL_STATUS_FAILED_ALLOC;
1061 }
1062 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1063 {
1064 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1065 }
1066
1067#ifdef WLAN_FEATURE_VOWIFI_11R
1068 if (pNeighborRoamInfo->is11rAssoc)
1069 {
1070 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1071 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1072 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1073 }
1074#endif
1075
1076 return eHAL_STATUS_SUCCESS;
1077}
1078
Jeff Johnson43971f52012-07-17 12:26:56 -07001079tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1080{
1081 tCsrScanResultInfo *pScanResult;
1082 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda2efea0e2013-01-24 17:40:41 -08001083#ifdef FEATURE_WLAN_LFR
1084 tANI_U32 CurrAPRssi = pNeighborRoamInfo->lookupDOWNRssi;
1085#else
1086 /* We are setting this as default value to make sure we return this value,
1087 when we do not see this AP in the scan result for some reason.However,it is
1088 less likely that we are associated to an AP and do not see it in the scan list */
1089 tANI_U32 CurrAPRssi = -125;
1090#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001091
1092 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1093 {
1094
1095 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1096 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1097 {
1098 /* We got a match with the currently associated AP.
1099 * Capture the RSSI value and complete the while loop.
1100 * The while loop is completed in order to make the current entry go back to NULL,
1101 * and in the next while loop, it properly starts searching from the head of the list.
1102 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1103
1104 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1105
1106 } else {
1107 continue;
1108 }
1109 }
1110
1111 return CurrAPRssi;
1112
1113}
1114
Jeff Johnson295189b2012-06-20 16:38:30 -07001115/* ---------------------------------------------------------------------------
1116
1117 \fn csrNeighborRoamProcessScanResults
1118
1119 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1120 Assumed that the results are already sorted by RSSI by csrScanGetResult
1121
1122 \param pMac - The handle returned by macOpen.
1123 pScanResultList - Scan result result obtained from csrScanGetResult()
1124
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001125 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1126 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001127
1128---------------------------------------------------------------------------*/
1129
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001130static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1131 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001132{
1133 tCsrScanResultInfo *pScanResult;
1134 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1135 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001136 tANI_U32 CurrAPRssi;
1137 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001138#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1139 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1140#endif
1141 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001142
1143 /***************************************************************
1144 * Find out the Current AP RSSI and keep it handy to check if
1145 * it is better than the RSSI of the AP which we are
1146 * going to roam.If so, we are going to continue with the
1147 * current AP.
1148 ***************************************************************/
1149 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001150
1151 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1152 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1153 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1154 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1155 /* 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
1156 and rssi score are in the same order. This will be taken care later */
1157
1158 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1159 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001160 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
1161 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d, Ch:%d)"),
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001162 pScanResult->BssDescriptor.bssId[0],
1163 pScanResult->BssDescriptor.bssId[1],
1164 pScanResult->BssDescriptor.bssId[2],
1165 pScanResult->BssDescriptor.bssId[3],
1166 pScanResult->BssDescriptor.bssId[4],
1167 pScanResult->BssDescriptor.bssId[5],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001168 abs(pScanResult->BssDescriptor.rssi),
1169 pScanResult->BssDescriptor.channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001170
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001171 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1173 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001174 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001175 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001176 "SKIP-currently associated AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 continue;
1178 }
1179
Jeff Johnson43971f52012-07-17 12:26:56 -07001180 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1181 * is disabled and we continue to roam without any check*/
1182 if(RoamRssiDiff > 0)
1183 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001184 /*
1185 * If RSSI is lower than the lookup threshold, then continue.
1186 */
1187 if (abs(pScanResult->BssDescriptor.rssi) >
1188 pNeighborRoamInfo->currentNeighborLookupThreshold)
1189 {
1190 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001191 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)",
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001192 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1193 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1194 continue;
1195 }
1196
Jeff Johnson43971f52012-07-17 12:26:56 -07001197 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1198 {
1199 /*Do not roam to an AP with worse RSSI than the current*/
1200 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001201 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001202 CurrAPRssi,
1203 (int)pScanResult->BssDescriptor.rssi * (-1) );
1204 continue;
1205 } else {
1206 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1207 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1208 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1209 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001210 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001211 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d", __func__,
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001212 CurrAPRssi,
1213 (int)pScanResult->BssDescriptor.rssi * (-1),
1214 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001215 continue;
1216 }
1217 else {
1218 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001219 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001220 CurrAPRssi,
1221 (int)pScanResult->BssDescriptor.rssi * (-1) );
1222 }
1223 }
1224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001225
1226#ifdef WLAN_FEATURE_VOWIFI_11R
1227 if (pNeighborRoamInfo->is11rAssoc)
1228 {
1229 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1230 {
1231 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1232 continue;
1233 }
1234 }
1235#endif /* WLAN_FEATURE_VOWIFI_11R */
1236
1237#ifdef FEATURE_WLAN_CCX
1238 if (pNeighborRoamInfo->isCCXAssoc)
1239 {
1240 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1241 {
1242 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1243 continue;
1244 }
1245 }
1246 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1247 (pScanResult->BssDescriptor.QBSSLoad_avail))
1248 {
1249 if (pNeighborRoamInfo->isVOAdmitted)
1250 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001251 smsLog(pMac, LOG1, FL("New AP has %x BW available"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1252 smsLog(pMac, LOG1, FL("We need %x BW available"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1254 {
1255 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001256 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list",
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 pScanResult->BssDescriptor.bssId[0],
1258 pScanResult->BssDescriptor.bssId[1],
1259 pScanResult->BssDescriptor.bssId[2],
1260 pScanResult->BssDescriptor.bssId[3],
1261 pScanResult->BssDescriptor.bssId[4],
1262 pScanResult->BssDescriptor.bssId[5]);
1263 continue;
1264 }
1265 }
1266 }
1267 else
1268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001269 smsLog(pMac, LOGE, FL("No QBss %x %x"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 if (pNeighborRoamInfo->isVOAdmitted)
1271 {
1272 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001273 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no QBSSLoad IE, ignoring..not adding to roam list",
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 pScanResult->BssDescriptor.bssId[0],
1275 pScanResult->BssDescriptor.bssId[1],
1276 pScanResult->BssDescriptor.bssId[2],
1277 pScanResult->BssDescriptor.bssId[3],
1278 pScanResult->BssDescriptor.bssId[4],
1279 pScanResult->BssDescriptor.bssId[5]);
1280 continue;
1281 }
1282 }
1283#endif /* FEATURE_WLAN_CCX */
1284
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001285#ifdef FEATURE_WLAN_LFR
1286 // If we are supporting legacy roaming, and
1287 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301288 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001289 {
1290 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1291 {
1292 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1293 continue;
1294 }
1295 }
1296#endif /* FEATURE_WLAN_LFR */
1297
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1299 * this result */
1300 if (pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1301 {
1302 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1303 continue;
1304 }
1305
1306 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1307 if (NULL == pBssInfo)
1308 {
1309 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1310 continue;
1311 }
1312
1313 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1314 if (pBssInfo->pBssDescription != NULL)
1315 {
1316 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1317 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1318 }
1319 else
1320 {
1321 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1322 vos_mem_free(pBssInfo);
1323 continue;
1324
1325 }
1326 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1327
1328 /* Just add to the end of the list as it is already sorted by RSSI */
1329 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001330
1331#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srikant Kuppa866893f2012-12-27 17:28:14 -08001332 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001333 {
1334 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1335 "%s: [INFOLOG] potential candidate to roam immediately (diff=%d, expected=%d)",
1336 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1337 immediateRoamRssiDiff);
1338 roamNow = eANI_BOOLEAN_TRUE;
1339 }
1340#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 }
1342
1343 /* 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 */
1344 csrScanResultPurge(pMac, *pScanResultList);
1345
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001346 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001347}
1348
1349/* ---------------------------------------------------------------------------
1350
1351 \fn csrNeighborRoamHandleEmptyScanResult
1352
1353 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1354 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001355 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001357 1. Stop the neighbor scan timer.
1358 2a. If this is the first time we encountered empty scan, then
1359 re-register with TL with modified lookup threshold.
1360 2b. Else if this is the second time we encountered empty scan,
1361 then start neighbor scan results refresh timer (20s).
1362 2c. Else, nothing more to do.
1363 NOTE: In LFR, channels selected for scanning is dervied from
1364 the occuped channel list. Scan cycle following one which
1365 yielded empty results is split into two halves: (i) scan on
1366 channels in the occupied list, and (ii) scan on channels not
1367 in the occupied list. This helps converging faster (while
1368 looking for candidates in the occupied list first), and also,
1369 adds channels to the occupied channel list upon finding candidates
1370 matching SSID profile of interest.
1371
1372 uEmptyScanCount Comments
1373 eFirstEmptyScan Previous scan was done on channels in the
1374 occupied list and yielded potential candidates.
1375 This scan cycle was likely triggered through
1376 receipt of lookup DOWN notification event.
1377 eSecondEmptyScan Previous scan was done on channels in the
1378 occupied list and yielded no candidates. This scan
1379 cycle was triggered through RSSI notification
1380 with modified lookup threshold.
1381 eThirdEmptyScan Previous scan was done on channels NOT in
1382 the occupied list and yielded no candidates. This
1383 scan cycle was triggered immediately after scanning
1384 channels in the occupied list and no candidates
1385 were found.
1386 eFourthEmptyScan Previous scan was done on channels in the
1387 occupied list and yielded no candidates. This scan
1388 cycle was triggered upon expiry of
1389 neighborScanResultsRefreshPeriod (=20s).
1390 eFifthEmptyScan Previous scan was done on channels NOT in
1391 the occupied list and yielded no candidates. This
1392 scan cycle was triggered immediately after scanning
1393 channels in the occupied list and no candidates
1394 were found.
1395
1396 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
1398 \param pMac - The handle returned by macOpen.
1399
1400 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1401
1402---------------------------------------------------------------------------*/
1403static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1404{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001405 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1407 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001408#ifdef FEATURE_WLAN_LFR
1409 tANI_BOOLEAN performPeriodicScan =
1410 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod) ? TRUE : FALSE;
1411#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001412
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001413 /* Stop neighbor scan timer */
Jeff Johnson295189b2012-06-20 16:38:30 -07001414 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001415 if (eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001417 smsLog(pMac, LOGW, FL("stopping neighborScanTimer failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 }
1419
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001420 /*
1421 * Increase the neighbor lookup threshold by 3 dB
1422 * after every scan cycle. NOTE: uEmptyScanCount
1423 * would be either 1, 3 or 5 at the end of every
1424 * scan cycle.
1425 */
1426#ifdef FEATURE_WLAN_LFR
1427 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1428 {
1429 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1430 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001431 if ((abs(pNeighborRoamInfo->lookupDOWNRssi) >
1432 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold)) &&
1433 ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1434 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan)))
1435 {
1436 /*
1437 * If the scan was triggered due to lookupDOWNRssi > reassoc threshold,
1438 * then it would be a contiguous scan on all valid non-DFS channels.
1439 * In this mode, there is no need to trigger an immediate scan upon
1440 * empty scan results for the second and fourth time (which would
1441 * be equivalent to scanning on channels in non-occupied list).
1442 * Incrementing uEmptyScanCount will correspond to skipping this step.
1443 * NOTE: double increment of uEmptyScanCount corresponds to completion
1444 * of scans on all valid channels.
1445 */
1446 ++pNeighborRoamInfo->uEmptyScanCount;
1447 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Extra increment of empty scan count (=%d)"
1448 " in contiguous scan mode", pNeighborRoamInfo->uEmptyScanCount);
1449 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001450#endif
1451 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1452 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1453#ifdef FEATURE_WLAN_LFR
1454 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1455#endif
1456 )
1457 {
1458 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1459 }
1460
Jeff Johnson295189b2012-06-20 16:38:30 -07001461#ifdef WLAN_FEATURE_VOWIFI_11R
1462 /* Clear off the old neighbor report details */
1463 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1464#endif
1465
Srikant Kuppa866893f2012-12-27 17:28:14 -08001466 /* Transition to CONNECTED state */
1467 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1468
1469 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1470 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1471
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001472#ifdef FEATURE_WLAN_LFR
1473 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1474 {
1475#endif
1476 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001477 /* Re-register neighbor lookup DOWN threshold callback with TL */
1478 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1479 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1480 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1481
1482 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1483 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1484 WLANTL_HO_THRESHOLD_DOWN,
1485 csrNeighborRoamNeighborLookupDOWNCallback,
1486 VOS_MODULE_ID_SME, pMac);
1487
1488 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1489 {
1490 smsLog(pMac, LOGW,
1491 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001492 " with TL: Status = %d"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001493 }
1494#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08001495 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001496 }
1497 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1498 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1499 {
1500 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001501
1502 /* Immediately scan on channels in non-occupied list */
1503 csrNeighborRoamTransitToCFGChanScan(pMac);
1504 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001505 else if (pNeighborRoamInfo->uEmptyScanCount >= eThirdEmptyScan)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001506 {
1507 /* Empty scan results for the third time */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001508 if (performPeriodicScan)
1509 {
1510 smsLog(pMac, LOGE, FL("Performing periodic scan, uEmptyScanCount=%d"),
1511 pNeighborRoamInfo->uEmptyScanCount);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001512
Srinivas Girigowdade697412013-02-14 16:31:48 -08001513 /*
1514 * Set uEmptyScanCount to MAX so that we always enter this
1515 * condition on subsequent empty scan results
1516 */
1517 pNeighborRoamInfo->uEmptyScanCount = eMaxEmptyScan;
1518
1519 /* From here on, ONLY scan on channels in the occupied list */
1520 pNeighborRoamInfo->uScanMode = SPLIT_SCAN_OCCUPIED_LIST;
1521
1522 /* Start empty scan refresh timer */
1523 if (eHAL_STATUS_SUCCESS !=
1524 palTimerStart(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer,
1525 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1526 eANI_BOOLEAN_FALSE))
1527 {
1528 smsLog(pMac, LOGE, FL("Empty scan refresh timer failed to start (%d)"),
1529 status);
1530 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1531 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1532 vosStatus = VOS_STATUS_E_FAILURE;
1533 }
1534 else
1535 {
1536 smsLog(pMac, LOGE, FL("Empty scan refresh timer started (%ld ms)"),
1537 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod));
1538 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001539 }
1540 else
1541 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001542 /* Start neighbor scan results refresh timer */
1543 if (eHAL_STATUS_SUCCESS !=
1544 palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1545 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1546 eANI_BOOLEAN_FALSE))
1547 {
1548 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1549 status);
1550 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1551 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1552 vosStatus = VOS_STATUS_E_FAILURE;
1553 }
1554 else
1555 {
1556 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1557 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1558 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001561
Srinivas Girigowdade697412013-02-14 16:31:48 -08001562 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d scan mode=%d",
1563 pNeighborRoamInfo->uEmptyScanCount, pNeighborRoamInfo->uScanMode);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001564#endif
1565 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001566}
1567
Jeff Johnson295189b2012-06-20 16:38:30 -07001568
Srikant Kuppa866893f2012-12-27 17:28:14 -08001569static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001570{
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 tCsrScanResultFilter scanFilter;
1573 tScanResultHandle scanResult;
1574 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001575 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001576 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001577
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001578#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1580 should use the BSSID filter made out of neighbor reports */
1581 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1582 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001583 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1584 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 -07001585 tempVal = 1;
1586 }
1587 else
1588#endif
1589 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001590 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1591 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 -07001592 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001593 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 {
1595 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1596 return eHAL_STATUS_FAILURE;
1597 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001598 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301599 if (hstatus != eHAL_STATUS_SUCCESS)
1600 {
1601 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001604 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001605
1606 /* Free the scan filter */
1607 csrFreeScanFilter(pMac, &scanFilter);
1608
1609 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1610
1611 switch(pNeighborRoamInfo->neighborRoamState)
1612 {
1613 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1614 if (tempVal)
1615 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001616#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001617 /*
1618 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001619 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001620 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001621 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001622 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001623#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001624#ifdef WLAN_FEATURE_VOWIFI_11R
1625 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1626 APs in the roamable AP list */
1627 if (pNeighborRoamInfo->is11rAssoc)
1628 {
1629 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1630 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1631 }
1632 else
1633#endif
1634#ifdef FEATURE_WLAN_CCX
1635 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1636 APs in the roamable AP list */
1637 if (pNeighborRoamInfo->isCCXAssoc)
1638 {
1639 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1640 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1641 }
1642 else
1643#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001644#ifdef FEATURE_WLAN_LFR
1645 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1646 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301647 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001648 {
1649 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1650 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1651 }
1652 else
1653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 {
1655
1656 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1657 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1658 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1659 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1660 within certain duration */
1661
1662// palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
1663 }
1664 }
1665 else
1666 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001667 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1668 /* Handle it appropriately */
1669 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 }
1671 break;
1672#ifdef WLAN_FEATURE_VOWIFI_11R
1673 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1674 if (!tempVal)
1675 {
1676 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1677 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1678 csrNeighborRoamTransitToCFGChanScan(pMac);
1679 }
1680 break;
1681#endif /* WLAN_FEATURE_VOWIFI_11R */
1682 default:
1683 // Can come only in INIT state. Where in we are associated, we sent scan and user
1684 // in the meantime decides to disassoc, we will be in init state and still received call
1685 // back issued. Should not come here in any other state, printing just in case
1686 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001687 "%s: [INFOLOG] State %d", __func__, (pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001688
1689 // Lets just exit out silently.
1690 return eHAL_STATUS_SUCCESS;
1691 }
1692
1693 if (tempVal)
1694 {
1695 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1696
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001697 if (roamNow)
1698 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001699 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001700 FL("Immediate roam-deregister UP indication. RSSI = %d"),
1701 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1702
1703 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
1704 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1705 WLANTL_HO_THRESHOLD_UP,
1706 csrNeighborRoamNeighborLookupUPCallback,
1707 VOS_MODULE_ID_SME);
1708
1709 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001711 smsLog(pMac, LOGW,
1712 FL("Couldn't deregister lookup UP callback with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001713 }
1714
1715 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
1716 return eHAL_STATUS_SUCCESS;
1717 }
1718
Srikant Kuppa866893f2012-12-27 17:28:14 -08001719 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1720 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1721 eANI_BOOLEAN_FALSE);
1722
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
1724 * 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 -08001725 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08001727 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1729 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001730 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001732
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
1734 /* Register a reassoc Indication callback */
1735 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
1736 WLANTL_HO_THRESHOLD_DOWN,
1737 csrNeighborRoamReassocIndCallback,
1738 VOS_MODULE_ID_SME, pMac);
1739
1740 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1741 {
1742 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001743 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 }
1745
1746 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08001747
1748 return eHAL_STATUS_SUCCESS;
1749
1750}
1751
1752
1753/* ---------------------------------------------------------------------------
1754
1755 \fn csrNeighborRoamScanRequestCallback
1756
1757 \brief This function is the callback function registered in csrScanRequest() to
1758 indicate the completion of scan. If scan is completed for all the channels in
1759 the channel list, this function gets the scan result and starts the refresh results
1760 timer to avoid having stale results. If scan is not completed on all the channels,
1761 it restarts the neighbor scan timer which on expiry issues scan on the next
1762 channel
1763
1764 \param halHandle - The handle returned by macOpen.
1765 pContext - not used
1766 scanId - not used
1767 status - not used
1768
1769 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1770
1771---------------------------------------------------------------------------*/
1772static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
1773 tANI_U32 scanId, eCsrScanStatus status)
1774{
1775 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1776 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1777 tANI_U8 currentChanIndex;
1778 eHalStatus hstatus;
1779
1780 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1781
1782 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1783 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1784 {
1785 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1786 return eHAL_STATUS_SUCCESS;
1787 }
1788
1789 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
1790 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
1791
1792 /* Validate inputs */
1793 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001794 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08001795 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
1796 }
1797 else
1798 {
1799 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
1800 return eHAL_STATUS_SUCCESS;
1801 }
1802
1803 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1804 {
1805 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
1806 just to get the results and perform PREAUTH */
1807 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
1808 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
1809 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
1810 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
1811
1812 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1813
1814 if (eHAL_STATUS_SUCCESS != hstatus)
1815 {
1816 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1817 return eHAL_STATUS_FAILURE;
1818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 }
1820 else
1821 {
1822
1823 /* Restart the timer for the next scan sequence as scanning is not over */
Jeff Johnson43971f52012-07-17 12:26:56 -07001824 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
1826 eANI_BOOLEAN_FALSE);
1827
Jeff Johnson43971f52012-07-17 12:26:56 -07001828 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 {
1830 /* Timer start failed.. Should we ASSERT here??? */
1831 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
1832 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1833 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001834 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 }
1836 }
1837 return eHAL_STATUS_SUCCESS;
1838}
1839
Srikant Kuppa866893f2012-12-27 17:28:14 -08001840#ifdef FEATURE_WLAN_LFR
1841static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
1842 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
1843{
1844 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1845 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1846 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
1847
1848 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1849
1850 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1851 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1852 {
1853 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1854 return eHAL_STATUS_SUCCESS;
1855 }
1856
Srinivas Girigowdade697412013-02-14 16:31:48 -08001857 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
1858 {
1859 smsLog(pMac, LOGE, FL("Received in INIT state. Must have disconnected. Ignore it"));
1860 return eHAL_STATUS_SUCCESS;
1861 }
1862
Srikant Kuppa866893f2012-12-27 17:28:14 -08001863 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
1864 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1865
1866 if (eHAL_STATUS_SUCCESS != hstatus)
1867 {
1868 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1869 }
1870
1871 return hstatus;
1872}
1873#endif
1874
Jeff Johnson295189b2012-06-20 16:38:30 -07001875/* ---------------------------------------------------------------------------
1876
1877 \fn csrNeighborRoamIssueBgScanRequest
1878
1879 \brief This function issues CSR scan request after populating all the BG scan params
1880 passed
1881
1882 \param pMac - The handle returned by macOpen.
1883 pBgScanParams - Params that need to be populated into csr Scan request
1884
1885 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1886
1887---------------------------------------------------------------------------*/
Srikant Kuppa866893f2012-12-27 17:28:14 -08001888eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
1889 tCsrBGScanRequest *pBgScanParams,
1890 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07001891{
1892 eHalStatus status = eHAL_STATUS_SUCCESS;
1893 tANI_U32 scanId;
1894 tCsrScanRequest scanReq;
1895 tANI_U8 channel;
1896
Srikant Kuppa866893f2012-12-27 17:28:14 -08001897 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001898 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08001899 pBgScanParams->ChannelInfo.ChannelList[0],
1900 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001901
1902 //send down the scan req for 1 channel on the associated SSID
1903 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
1904 /* Fill in the SSID Info */
1905 scanReq.SSIDs.numOfSSIDs = 1;
1906 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1907 if(NULL == scanReq.SSIDs.SSIDList)
1908 {
1909 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001910 smsLog(pMac, LOGE, FL("Couldn't allocate memory for the SSID..Freeing memory allocated for Channel List"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 return eHAL_STATUS_FAILURE;
1912 }
1913 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1914
1915 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
1916 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
1917 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
1918
1919 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001920 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1921 {
1922 channel = pBgScanParams->ChannelInfo.ChannelList[0];
1923 scanReq.ChannelInfo.ChannelList = &channel;
1924 }
1925 else
1926 {
1927 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
1928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001929
1930 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
1931 scanReq.scanType = eSIR_ACTIVE_SCAN;
1932 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
1933 scanReq.maxChnTime = pBgScanParams->maxChnTime;
1934 scanReq.minChnTime = pBgScanParams->minChnTime;
1935 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Srikant Kuppa866893f2012-12-27 17:28:14 -08001936 &scanId, callbackfn, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 if (eHAL_STATUS_SUCCESS != status)
1938 {
1939 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
1940 vos_mem_free(scanReq.SSIDs.SSIDList);
1941 return status;
1942 }
1943 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
1944
1945 vos_mem_free(scanReq.SSIDs.SSIDList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001946 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001947 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08001948 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
1949 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
1950
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 return status;
1952}
1953
Srikant Kuppa866893f2012-12-27 17:28:14 -08001954static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
1955 tpCsrBGScanRequest bgScanParams)
1956{
1957 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1958 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1959
1960 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
1961 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
1962 vos_mem_copy(bgScanParams->SSID.ssId,
1963 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
1964 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
1965
1966 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
1967 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
1968}
1969
Jeff Johnson295189b2012-06-20 16:38:30 -07001970/* ---------------------------------------------------------------------------
1971
1972 \fn csrNeighborRoamPerformBgScan
1973
1974 \brief This function is invoked on every expiry of neighborScanTimer till all
1975 the channels in the channel list are scanned. It populates necessary
1976 parameters for BG scan and calls appropriate AP to invoke the CSR scan
1977 request
1978
1979 \param pMac - The handle returned by macOpen.
1980
1981 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1982
1983---------------------------------------------------------------------------*/
1984eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac)
1985{
1986 eHalStatus status = eHAL_STATUS_SUCCESS;
1987 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1988 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 tANI_U8 channel = 0;
1990
1991 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1992 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301993 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001994 }
1995 else
1996 {
1997 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson902c9832012-12-10 14:28:09 -08001998 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 // When timer start is declared a failure, then we delete the list.
2000 // Should not happen now as we stop and then only start the scan timer.
2001 // still handle the unlikely case.
2002 csrNeighborRoamHandleEmptyScanResult(pMac);
2003 return status;
2004 }
2005 /* Need to perform scan here before getting the list */
Srikant Kuppa866893f2012-12-27 17:28:14 -08002006
2007 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07002008
2009 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
2010 bgScanParams.ChannelInfo.numOfChannels = 1;
2011 bgScanParams.ChannelInfo.ChannelList = &channel;
2012
Srikant Kuppa866893f2012-12-27 17:28:14 -08002013 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002014
Srikant Kuppa866893f2012-12-27 17:28:14 -08002015 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2016 csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 if (eHAL_STATUS_SUCCESS != status)
2018 {
2019 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 }
2021
2022 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
2023 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
2024 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2025 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302026 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002027 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
2028 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
2029 /* We have completed scanning all the channels */
2030 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2031 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
2032 and select the best AP in the list */
2033 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2034 {
2035 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
2036 }
2037 }
2038
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08002039 if (eHAL_STATUS_SUCCESS != status)
2040 {
2041 /*
2042 * If the status is not success, we need to call the callback
2043 * routine so that the state machine does not get stuck.
2044 */
2045 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
2046 }
2047
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 return status;
2049}
2050
Srikant Kuppa866893f2012-12-27 17:28:14 -08002051#ifdef FEATURE_WLAN_LFR
2052eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac)
2053{
2054 eHalStatus status = eHAL_STATUS_SUCCESS;
2055 tCsrBGScanRequest bgScanParams;
2056 int numOfChannels = 0, i = 0;
2057 tANI_U8 *channelList = NULL;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002058 tANI_U8 *pInChannelList = NULL;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002059
2060 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
2061
2062 /* Contiguously scan all channels from valid list */
2063 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002064
2065 if (NULL != pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList)
Srikant Kuppa866893f2012-12-27 17:28:14 -08002066 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002067 /* this list is filled only if the country code is set to KR */
2068 numOfChannels = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
2069 pInChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002070 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002071 else
2072 {
2073 numOfChannels = sizeof(pMac->roam.validChannelList);
2074
2075 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2076 (tANI_U8 *)pMac->roam.validChannelList,
2077 (tANI_U32 *) &numOfChannels)))
2078 {
2079 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
2080 return eHAL_STATUS_FAILURE;
2081 }
2082 pInChannelList = pMac->roam.validChannelList;
2083 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002084 channelList = vos_mem_malloc( numOfChannels );
2085 if( NULL == channelList )
2086 {
2087 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
2088 return eHAL_STATUS_FAILURE;
2089 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002090 vos_mem_copy(channelList, (tANI_U8 *)pInChannelList,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002091 numOfChannels * sizeof(tANI_U8));
2092
2093 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
2094 bgScanParams.ChannelInfo.ChannelList = channelList;
2095 for (i = 0; i < numOfChannels; i++)
2096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002097 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d",
Srikant Kuppa866893f2012-12-27 17:28:14 -08002098 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
2099 }
2100 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
2101
2102 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2103 csrNeighborRoamContiguousScanRequestCallback);
2104
2105 vos_mem_free( channelList );
2106
2107 if (eHAL_STATUS_SUCCESS != status)
2108 {
2109 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
2110 }
2111
2112 return status;
2113}
2114#endif
2115
Jeff Johnson295189b2012-06-20 16:38:30 -07002116/* ---------------------------------------------------------------------------
2117
2118 \fn csrNeighborRoamNeighborScanTimerCallback
2119
2120 \brief This function is the neighbor scan timer callback function. It invokes
2121 the BG scan request based on the current and previous states
2122
2123 \param pv - CSR timer context info which includes pMac and session ID
2124
2125 \return VOID
2126
2127---------------------------------------------------------------------------*/
2128void csrNeighborRoamNeighborScanTimerCallback(void *pv)
2129{
2130 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
2131 tpAniSirGlobal pMac = pInfo->pMac;
2132 tANI_U32 sessionId = pInfo->sessionId;
2133 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2134
2135 // check if bg scan is on going, no need to send down the new params if true
2136 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2137 {
2138 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002139 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 return;
2141 }
2142
2143 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
2144
2145 switch (pNeighborRoamInfo->neighborRoamState)
2146 {
2147#ifdef WLAN_FEATURE_VOWIFI_11R
2148 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2149 switch(pNeighborRoamInfo->prevNeighborRoamState)
2150 {
2151 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2152 csrNeighborRoamPerformBgScan(pMac);
2153 break;
2154 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002155 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
2157 break;
2158 }
2159 break;
2160#endif /* WLAN_FEATURE_VOWIFI_11R */
2161 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
2162 csrNeighborRoamPerformBgScan(pMac);
2163 break;
2164 default:
2165 break;
2166 }
2167 return;
2168}
2169
Srinivas Girigowdade697412013-02-14 16:31:48 -08002170void csrNeighborRoamEmptyScanRefreshTimerCallback(void *context)
2171{
2172 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2173 tpAniSirGlobal pMac = pInfo->pMac;
2174 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2175 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2176
2177 /* Reset all the variables just as no scan had happened before */
2178 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2179
2180#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2181 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2182 {
2183 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2184 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2185 if (VOS_STATUS_SUCCESS != vosStatus)
2186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002187 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002188 return;
2189 }
2190 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2191 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2192 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2193 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2194 }
2195 else
2196#endif
2197 {
2198 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:empty scan refresh timer expired"));
2199 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2200 if (VOS_STATUS_SUCCESS != vosStatus)
2201 {
2202 return;
2203 }
2204 }
2205 return;
2206}
2207
Jeff Johnson295189b2012-06-20 16:38:30 -07002208/* ---------------------------------------------------------------------------
2209
2210 \fn csrNeighborRoamResultsRefreshTimerCallback
2211
2212 \brief This function is the timer callback function for results refresh timer.
2213 When this is invoked, it is as good as down event received from TL. So,
2214 clear off the roamable AP list and start the scan procedure based on 11R
2215 or non-11R association
2216
2217 \param context - CSR timer context info which includes pMac and session ID
2218
2219 \return VOID
2220
2221---------------------------------------------------------------------------*/
2222void csrNeighborRoamResultsRefreshTimerCallback(void *context)
2223{
2224 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2225 tpAniSirGlobal pMac = pInfo->pMac;
2226 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2227 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2228
2229 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2230
2231 /* Deregister reassoc callback. Ignore return status */
2232 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2233 WLANTL_HO_THRESHOLD_DOWN,
2234 csrNeighborRoamReassocIndCallback,
2235 VOS_MODULE_ID_SME);
2236
2237 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2238 {
2239 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002240 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 }
2242
2243 /* Reset all the variables just as no scan had happened before */
2244 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2245
2246#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2247 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2248 {
2249 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2250 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2251 if (VOS_STATUS_SUCCESS != vosStatus)
2252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002253 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 return;
2255 }
2256 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2257 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2258 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2259 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2260 }
2261 else
2262#endif
2263 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002264 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2266 if (VOS_STATUS_SUCCESS != vosStatus)
2267 {
2268 return;
2269 }
2270 }
2271 return;
2272}
2273
2274#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2275/* ---------------------------------------------------------------------------
2276
2277 \fn csrNeighborRoamIssueNeighborRptRequest
2278
2279 \brief This function is invoked when TL issues a down event and the current assoc
2280 is a 11R association. It invokes SME RRM API to issue the neighbor request to
2281 the currently associated AP with the current SSID
2282
2283 \param pMac - The handle returned by macOpen.
2284
2285 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2286
2287---------------------------------------------------------------------------*/
2288VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
2289{
2290 tRrmNeighborRspCallbackInfo callbackInfo;
2291 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2292 tRrmNeighborReq neighborReq;
2293
2294
2295 neighborReq.no_ssid = 0;
2296
2297 /* Fill in the SSID */
2298 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2299 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2300 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2301
2302 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
2303 callbackInfo.neighborRspCallbackContext = pMac;
2304 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
2305
2306 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
2307}
2308
2309/* ---------------------------------------------------------------------------
2310
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002311 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002312
2313 \brief This function is used to merge two channel list.
2314 NB: If called with outputNumOfChannels == 0, this routines
2315 simply copies the input channel list to the output channel list.
2316
2317 \param pMac - The handle returned by macOpen.
2318 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
2319 \param inputNumOfChannels - The number of additional channels.
2320 \param pOutputChannelList - The place to put the "merged" channel list.
2321 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
2322 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
2323
2324 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2325
2326---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002327VOS_STATUS csrNeighborRoamMergeChannelLists(
2328 tpAniSirGlobal pMac,
2329 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002330 int inputNumOfChannels,
2331 tANI_U8 *pOutputChannelList,
2332 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002333 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002334 )
2335{
2336 int i = 0;
2337 int j = 0;
2338 int numChannels = outputNumOfChannels;
2339
2340 // Check for NULL pointer
2341 if (!pInputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2342
2343 // Check for NULL pointer
2344 if (!pOutputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2345
2346 // Add the "new" channels in the input list to the end of the output list.
2347 for (i = 0; i < inputNumOfChannels; i++)
2348 {
2349 for (j = 0; j < outputNumOfChannels; j++)
2350 {
2351 if (pInputChannelList[i] == pOutputChannelList[j])
2352 break;
2353 }
2354 if (j == outputNumOfChannels)
2355 {
2356 if (pInputChannelList[i])
2357 {
Madan Mohan Koyyalamudif5c368b2012-12-06 13:10:13 -08002358 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002359 "%s: [INFOLOG] Adding extra %d to Neighbor channel list", __func__,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002360 pInputChannelList[i]);
2361 pOutputChannelList[numChannels] = pInputChannelList[i];
2362 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002363 }
2364 }
2365 }
2366
2367 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002368 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002369
2370 return eHAL_STATUS_SUCCESS;
2371}
2372
2373/* ---------------------------------------------------------------------------
2374
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 \fn csrNeighborRoamCreateChanListFromNeighborReport
2376
2377 \brief This function is invoked when neighbor report is received for the
2378 neighbor request. Based on the channels present in the neighbor report,
2379 it generates channel list which will be used in REPORT_SCAN state to
2380 scan for these neighbor APs
2381
2382 \param pMac - The handle returned by macOpen.
2383
2384 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2385
2386---------------------------------------------------------------------------*/
2387VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2388{
2389 tpRrmNeighborReportDesc pNeighborBssDesc;
2390 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002391 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002393#if 0
2394 eHalStatus status = eHAL_STATUS_SUCCESS;
2395#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002396
2397 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2398 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2399
2400 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2401
2402 while (pNeighborBssDesc)
2403 {
2404 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2405
2406 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2407 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2408 pNeighborBssDesc->pNeighborBssDescription->channel;
2409 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2410 (tANI_U8)pNeighborBssDesc->roamScore;
2411 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2412 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2413 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2414
2415 /* Saving the channel list non-redundantly */
2416 if (numChannels > 0)
2417 {
2418 for (i = 0; i < numChannels; i++)
2419 {
2420 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2421 break;
2422 }
2423
2424 }
2425 if (i == numChannels)
2426 {
2427 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2428 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002430 "%s: [INFOLOG] Adding %d to Neighbor channel list", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 pNeighborBssDesc->pNeighborBssDescription->channel);
2432 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2433 numChannels++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 }
2435 }
2436
2437 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2438 }
2439
2440 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2441 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002442#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002444 // we have a union of the IAPP and the already existing list.
2445 status = csrNeighborRoamMergeChannelLists(
2446 pMac,
2447 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2448 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2449 channelList,
2450 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002451 &numChannels );
2452#endif
2453
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2455 }
2456
2457 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2458 /* Store the obtained channel list to the Neighbor Control data structure */
2459 if (numChannels)
2460 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2461 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2462 {
2463 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2464 return VOS_STATUS_E_RESOURCES;
2465 }
2466
2467 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2468 channelList, (numChannels) * sizeof(tANI_U8));
2469 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2470 if (numChannels)
2471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002472 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 pNeighborRoamInfo->neighborRoamState);
2474 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
2475 }
2476 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2477 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
2478
2479 return VOS_STATUS_SUCCESS;
2480}
2481
2482/* ---------------------------------------------------------------------------
2483
2484 \fn csrNeighborRoamRRMNeighborReportResult
2485
2486 \brief This function is the neighbor report callback that will be invoked by
2487 SME RRM on receiving a neighbor report or of neighbor report is not
2488 received after timeout. On receiving a valid report, it generates a
2489 channel list from the neighbor report and starts the
2490 neighbor scan timer
2491
2492 \param context - The handle returned by macOpen.
2493 vosStatus - Status of the callback(SUCCESS/FAILURE)
2494
2495 \return VOID
2496
2497---------------------------------------------------------------------------*/
2498void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
2499{
2500 tpAniSirGlobal pMac = PMAC_STRUCT(context);
2501 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2502 eHalStatus status = eHAL_STATUS_SUCCESS;
2503
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002504 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 switch (pNeighborRoamInfo->neighborRoamState)
2506 {
2507 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2508 /* Reset the report pending variable */
2509 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
2510 if (VOS_STATUS_SUCCESS == vosStatus)
2511 {
2512 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
2513 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
2514 if (VOS_STATUS_SUCCESS == vosStatus)
2515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002516 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 }
2518
2519 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2520 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2521
2522 /* Now ready for neighbor scan based on the channel list created */
2523 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2524 what palTimerStart expects */
2525 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2526 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2527 eANI_BOOLEAN_FALSE);
2528 if (eHAL_STATUS_SUCCESS != status)
2529 {
2530 /* Timer start failed.. Should we ASSERT here??? */
2531 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
2532 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2533 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2534 return;
2535 }
2536 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2537 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
2538 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2539 }
2540 else
2541 {
2542 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
2543 reach the maxNeighborRetries or receiving a successful neighbor response */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002544 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
2546 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
2547 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
2548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002549 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2551 if (VOS_STATUS_SUCCESS != vosStatus)
2552 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002553 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d "), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 return;
2555 }
2556 /* We transitioned to different state now. Reset the Neighbor report retry count */
2557 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2558 }
2559 else
2560 {
2561 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2562 if (VOS_STATUS_SUCCESS != vosStatus)
2563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002564 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 return;
2566 }
2567 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2568 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2569 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2570 }
2571 }
2572 break;
2573 default:
2574 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
2575 break;
2576 }
2577 return;
2578}
2579#endif /* WLAN_FEATURE_VOWIFI_11R */
2580
2581
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002582#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002583tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002584 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002585 tCsrRoamConnectedProfile *pCurProfile,
2586 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002587 tDot11fBeaconIEs *pIes)
2588{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002589 tCsrAuthList authType;
2590 tCsrEncryptionList uCEncryptionType;
2591 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002592 tANI_BOOLEAN fMatch = FALSE;
2593
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002594 authType.numEntries = 1;
2595 authType.authType[0] = pCurProfile->AuthType;
2596 uCEncryptionType.numEntries = 1;
2597 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
2598 mCEncryptionType.numEntries = 1;
2599 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002600
2601 if( pIes )
2602 {
2603 if(pIes->SSID.present)
2604 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002605 fMatch = csrIsSsidMatch( pMac,
2606 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
2607 pIes->SSID.ssid, pIes->SSID.num_ssid,
2608 eANI_BOOLEAN_TRUE );
2609 if(TRUE == fMatch)
2610 {
2611 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
2612 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
2613 return (fMatch);
2614 }
2615 else
2616 {
2617 return (fMatch);
2618 }
2619
2620 }
2621 else
2622 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002623 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002624 }
2625 }
2626 else
2627 {
2628 return FALSE; // Again, treat missing pIes as a non-match.
2629 }
2630}
2631
2632tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
2633 tpAniSirGlobal pMac)
2634{
2635 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2636 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2637 tCsrRoamConnectedProfile *pCurrProfile = NULL;
2638 tCsrRoamConnectedProfile *pPrevProfile = NULL;
2639 tDot11fBeaconIEs *pIes = NULL;
2640 tSirBssDescription *pBssDesc = NULL;
2641 tANI_BOOLEAN fNew = TRUE;
2642
2643 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
2644 {
2645 return (fNew);
2646 }
2647
2648 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2649 if( !pCurrProfile )
2650 {
2651 return (fNew);
2652}
2653
2654 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
2655 if( !pPrevProfile )
2656 {
2657 return (fNew);
2658 }
2659
2660 pBssDesc = pPrevProfile->pBssDesc;
2661 if (pBssDesc)
2662 {
2663 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
2664 pBssDesc, &pIes)) &&
2665 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
2666 {
2667 fNew = FALSE;
2668 }
2669 if (pIes) {
2670 palFreeMemory(pMac->hHdd, pIes);
2671 }
2672 }
2673
2674 if (fNew)
2675 {
2676 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
2677 csrRoamFreeConnectProfile(pMac, pPrevProfile);
2678 csrRoamGetConnectProfile(pMac, sessionId, pPrevProfile);
2679 }
2680 else
2681 {
2682 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
2683 }
2684
2685 return (fNew);
2686}
2687
2688tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
2689 tpAniSirGlobal pMac,
2690 tCsrScanResult *pResult,
2691 tDot11fBeaconIEs *pIes)
2692{
2693 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2694 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2695 tCsrRoamConnectedProfile *pCurProfile = NULL;
2696 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
2697
2698 if( !(pMac->roam.roamSession
2699 && CSR_IS_SESSION_VALID(pMac, sessionId)))
2700 {
2701 return FALSE;
2702 }
2703
2704 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2705
2706 if( !pCurProfile)
2707 {
2708 return FALSE;
2709 }
2710
2711 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002712}
2713
2714/* ---------------------------------------------------------------------------
2715
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002716 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002717
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002718 \brief This function is used to prepare a channel list that is derived from
2719 the list of valid channels and does not include those in the occupied
2720 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002721
2722 \param pMac - The handle returned by macOpen.
2723 \param pInputChannelList - The default channels list.
2724 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002725 \param pOutputChannelList - The place to put the non-occupied channel list.
2726 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002727
2728 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2729
2730---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002731VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002732 tpAniSirGlobal pMac,
2733 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002734 int numOfChannels,
2735 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002736 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002737 )
2738{
2739 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002740 int outputNumOfChannels = 0; // Clear the output number of channels
2741 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
2742 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
2743
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002744 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002745 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002746 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
2747 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002748 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002749 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002750 }
2751 }
2752
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002753 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
2754 "Number of channels in the non-occupied list list=%d"),
2755 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002756
2757 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002758 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002759
2760 return eHAL_STATUS_SUCCESS;
2761}
2762#endif /* FEATURE_WLAN_LFR */
2763
Jeff Johnson295189b2012-06-20 16:38:30 -07002764/* ---------------------------------------------------------------------------
2765
2766 \fn csrNeighborRoamTransitToCFGChanScan
2767
2768 \brief This function is called whenever there is a transition to CFG chan scan
2769 state from any state. It frees up the current channel list and allocates
2770 a new memory for the channels received from CFG item. It then starts the
2771 neighbor scan timer to perform the scan on each channel one by one
2772
2773 \param pMac - The handle returned by macOpen.
2774
2775 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2776
2777---------------------------------------------------------------------------*/
2778VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
2779{
2780 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2781 eHalStatus status = eHAL_STATUS_SUCCESS;
2782 int i = 0;
2783 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002784 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002785 tpCsrChannelInfo currChannelListInfo;
2786
2787 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002788
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002789 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07002790#ifdef FEATURE_WLAN_CCX
2791 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002792 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
2794#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002795 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002797 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002798
2799
2800 /* Free up the channel list and allocate a new memory. This is because we dont know how much
2801 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
2802 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002803 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002805 vos_mem_free(currChannelListInfo->ChannelList);
2806 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002808
2809 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
2810 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
2811 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002813 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
2814 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002815 status = csrNeighborRoamMergeChannelLists(
2816 pMac,
2817 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
2818 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
2819 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002820 0, //NB: If 0, simply copy the input channel list to the output list.
2821 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002822
2823 currChannelListInfo->ChannelList =
2824 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2825 if (NULL == currChannelListInfo->ChannelList)
2826 {
2827 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2828 return VOS_STATUS_E_RESOURCES;
2829 }
2830
2831 vos_mem_copy(currChannelListInfo->ChannelList,
2832 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002833 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002834#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08002835 else if ((pNeighborRoamInfo->uScanMode == DEFAULT_SCAN) &&
2836 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
2837 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold)))
Srikant Kuppa866893f2012-12-27 17:28:14 -08002838 {
2839 /*
2840 * Trigger a contiguous scan on all channels when the
2841 * RSSI in the lookup DOWN notification is below reassoc
2842 * threshold. This will help us find the best available
2843 * candidate and also update the channel cache.
2844 */
2845 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
2846 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
2847 pNeighborRoamInfo->lookupDOWNRssi,
2848 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
2849
2850 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2851
2852 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2853
2854 /* We are about to start a fresh scan cycle,
2855 * purge non-P2P results from the past */
2856 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
2857
2858 csrNeighborRoamPerformContiguousBgScan(pMac);
2859
2860 /* Transition to CFG_CHAN_LIST_SCAN */
2861 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
2862
2863 return VOS_STATUS_SUCCESS;
2864 }
2865#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002866 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002867 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002868 numOfChannels = pMac->scan.occupiedChannels.numChannels;
2869 if (numOfChannels
2870#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08002871 && ((pNeighborRoamInfo->uScanMode == SPLIT_SCAN_OCCUPIED_LIST) ||
2872 (pNeighborRoamInfo->uEmptyScanCount == 0) ||
2873 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002874#endif
2875 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002877 /*
2878 * Always scan channels in the occupied channel list
2879 * before scanning on the non-occupied list.
2880 */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002881 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Switching to occupied channel list"
2882#ifdef FEATURE_WLAN_LFR
2883 "-uScanMode=%d, uEmptyScanCount=%d",
2884 pNeighborRoamInfo->uScanMode,
2885 pNeighborRoamInfo->uEmptyScanCount
2886#endif
2887 );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002888 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
2889 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels);
2890
2891 if (NULL == currChannelListInfo->ChannelList)
2892 {
2893 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2894 return VOS_STATUS_E_RESOURCES;
2895 }
2896 vos_mem_copy(currChannelListInfo->ChannelList,
2897 pMac->scan.occupiedChannels.channelList,
2898 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002899 }
2900 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002901 {
2902 /* Scan all channels from non-occupied list */
2903 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
2904 numOfChannels = sizeof(pMac->roam.validChannelList);
2905
2906 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2907 (tANI_U8 *)pMac->roam.validChannelList,
2908 (tANI_U32 *) &numOfChannels)))
2909 {
2910#ifdef FEATURE_WLAN_LFR
2911 /*
2912 * Prepare non-occupied channel list (channelList)
2913 * from the actual "valid channel list" information
2914 * formed by CSR.
2915 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302916 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
Srinivas Girigowdade697412013-02-14 16:31:48 -08002917 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
2918 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002919 numOfChannels,
2920 channelList,
2921 &numOfChannels);
2922#else
2923 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
2924 status = csrNeighborRoamMergeChannelLists(
2925 pMac,
2926 (tANI_U8 *)pMac->roam.validChannelList,
2927 numOfChannels, // The number of channels in the validChannelList
2928 channelList,
2929 0, //NB: If 0, simply copy the input channel list to the output list.
2930 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
2931#endif
2932 }
2933 else
2934 {
2935 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002936 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002938 currChannelListInfo->ChannelList =
2939 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2940
2941 if (NULL == currChannelListInfo->ChannelList)
2942 {
2943 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2944 return VOS_STATUS_E_RESOURCES;
2945 }
2946#ifdef FEATURE_WLAN_LFR
2947 vos_mem_copy(currChannelListInfo->ChannelList,
2948 channelList, numOfChannels * sizeof(tANI_U8));
2949#else
2950 vos_mem_copy(currChannelListInfo->ChannelList,
2951 (tANI_U8 *)pMac->roam.validChannelList,
2952 numOfChannels * sizeof(tANI_U8));
2953#endif
2954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 }
2956
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002957 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002958 currChannelListInfo->numOfChannels = numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002959 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
2960 "Number of channels from CFG (or) (non-)occupied list=%d",
2961 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002962 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302964 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002965 "= %d", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 }
2967 }
2968
2969 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2970 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2971
2972 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2973 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2974 what palTimerStart expects */
2975 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2976 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2977 eANI_BOOLEAN_FALSE);
2978
2979 if (eHAL_STATUS_SUCCESS != status)
2980 {
2981 /* Timer start failed.. */
2982 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002983 vos_mem_free(currChannelListInfo->ChannelList);
2984 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 return VOS_STATUS_E_FAILURE;
2986 }
2987
2988 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2989 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302990 /* We are about to start a fresh scan cycle,
2991 * purge non-P2P results from the past */
2992 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
James Zmuda5ba36d02013-03-14 17:39:07 -07002993
2994 /* We are about to start a fresh scan cycle,
2995 * purge failed pre-auth results from the past */
2996 csrNeighborRoamPurgePreauthFailedList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002997
2998 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
2999 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
3000
3001 return VOS_STATUS_SUCCESS;
3002}
3003
3004/* ---------------------------------------------------------------------------
3005
3006 \fn csrNeighborRoamNeighborLookupUpEvent
3007
3008 \brief This function is called as soon as TL indicates that the current AP's
3009 RSSI is better than the neighbor lookup threshold. Here, we transition to
3010 CONNECTED state and reset all the scan parameters
3011
3012 \param pMac - The handle returned by macOpen.
3013
3014 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3015
3016---------------------------------------------------------------------------*/
3017VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
3018{
3019 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3020 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003021 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003022
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 /* Recheck whether the below check is needed. */
3024 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
3025 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Jeff Johnsone7245742012-09-05 17:12:55 -07003026
3027 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
3028 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3029
Jeff Johnson295189b2012-06-20 16:38:30 -07003030
3031 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3032 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
3033 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3034 WLANTL_HO_THRESHOLD_DOWN,
3035 csrNeighborRoamNeighborLookupDOWNCallback,
3036 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003037#ifdef FEATURE_WLAN_LFR
3038 pNeighborRoamInfo->lookupDOWNRssi = 0;
3039#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3041 {
3042 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003043 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 }
3045
3046
3047 return vosStatus;
3048}
3049
3050/* ---------------------------------------------------------------------------
3051
3052 \fn csrNeighborRoamNeighborLookupDownEvent
3053
3054 \brief This function is called as soon as TL indicates that the current AP's
3055 RSSI falls below the current eighbor lookup threshold. Here, we transition to
3056 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
3057 a non-11R association.
3058
3059 \param pMac - The handle returned by macOpen.
3060
3061 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3062
3063---------------------------------------------------------------------------*/
3064VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
3065{
3066 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3067 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3068 eHalStatus status = eHAL_STATUS_SUCCESS;
3069
3070 switch (pNeighborRoamInfo->neighborRoamState)
3071 {
3072 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3073
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003074 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3076 /* De-register Neighbor Lookup threshold callback with TL */
3077 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3078 WLANTL_HO_THRESHOLD_DOWN,
3079 csrNeighborRoamNeighborLookupDOWNCallback,
3080 VOS_MODULE_ID_SME);
3081
3082 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3083 {
3084 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003085 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 }
3087
3088
3089#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
3090 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
3091 {
3092
3093 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
3094 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3095 if (VOS_STATUS_SUCCESS != vosStatus)
3096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003097 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 return vosStatus;
3099 }
3100 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3101 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3102 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3103 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
3104 }
3105 else
3106#endif
3107 {
3108 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
3109
3110 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3111 if (VOS_STATUS_SUCCESS != vosStatus)
3112 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08003113 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
3114 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 return vosStatus;
3116 }
3117 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003118 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 -07003119 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003120 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
3121 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 WLANTL_HO_THRESHOLD_UP,
3123 csrNeighborRoamNeighborLookupUPCallback,
3124 VOS_MODULE_ID_SME, pMac);
3125 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3126 {
3127 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003128 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 }
3130 break;
3131 default:
3132 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3133 break;
3134
3135 }
3136 return vosStatus;
3137}
3138
3139/* ---------------------------------------------------------------------------
3140
3141 \fn csrNeighborRoamNeighborLookupUPCallback
3142
3143 \brief This function is registered with TL to indicate whenever the RSSI
3144 gets better than the neighborLookup RSSI Threshold
3145
3146 \param pAdapter - VOS Context
3147 trafficStatus - UP/DOWN indication from TL
3148 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3149
3150 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3151
3152---------------------------------------------------------------------------*/
3153VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003154 v_PVOID_t pUserCtxt,
3155 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003156{
3157 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3158 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3159 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3160
Srinivasdaaec712012-12-12 15:59:44 -08003161 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
3162 rssiNotification,
3163 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003164
3165 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3166 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003167 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 return VOS_STATUS_SUCCESS;
3169 }
3170
3171 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
3172 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
3173 return vosStatus;
3174}
3175
3176/* ---------------------------------------------------------------------------
3177
3178 \fn csrNeighborRoamNeighborLookupDOWNCallback
3179
3180 \brief This function is registered with TL to indicate whenever the RSSI
3181 falls below the current neighborLookup RSSI Threshold
3182
3183 \param pAdapter - VOS Context
3184 trafficStatus - UP/DOWN indication from TL
3185 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3186
3187 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3188
3189---------------------------------------------------------------------------*/
3190VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003191 v_PVOID_t pUserCtxt,
3192 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003193{
3194 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3195 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3196 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3197
Srinivasdaaec712012-12-12 15:59:44 -08003198 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
3199 rssiNotification,
3200 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003201
Srikant Kuppa866893f2012-12-27 17:28:14 -08003202#ifdef FEATURE_WLAN_LFR
3203 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
3204#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003207 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 return VOS_STATUS_SUCCESS;
3209 }
3210
3211 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
3212 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
3213
3214 return vosStatus;
3215}
3216
3217#ifdef RSSI_HACK
3218extern int dumpCmdRSSI;
3219#endif
3220
3221/* ---------------------------------------------------------------------------
3222
3223 \fn csrNeighborRoamIndicateDisconnect
3224
3225 \brief This function is called by CSR as soon as the station disconnects from
3226 the AP. This function does the necessary cleanup of neighbor roam data
3227 structures. Neighbor roam state transitions to INIT state whenever this
3228 function is called except if the current state is REASSOCIATING
3229
3230 \param pMac - The handle returned by macOpen.
3231 sessionId - CSR session id that got disconnected
3232
3233 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3234
3235---------------------------------------------------------------------------*/
3236eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
3237{
3238 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3239
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003240 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d (sub-state %d)"),
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003241 sessionId, pNeighborRoamInfo->neighborRoamState,
3242 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243
3244#ifdef FEATURE_WLAN_CCX
3245 {
3246 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
3247 if (pSession->connectedProfile.isCCXAssoc)
3248 {
3249 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
3250 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3251 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
3252 pSession->isPrevApInfoValid = TRUE;
3253 pSession->roamTS1 = vos_timer_get_system_time();
3254
3255 }
3256 }
3257#endif
3258
3259#ifdef RSSI_HACK
3260 dumpCmdRSSI = -40;
3261#endif
3262 switch (pNeighborRoamInfo->neighborRoamState)
3263 {
3264 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3265 // Stop scan and neighbor refresh timers.
3266 // These are indeed not required when we are in reassociating
3267 // state.
3268 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3269 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003270 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003271 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
3272 /*
3273 * Disconnect indication during Disassoc Handoff sub-state
3274 * is received when we are trying to disconnect with the old
3275 * AP during roam. BUT, if receive a disconnect indication
3276 * outside of Disassoc Handoff sub-state, then it means that
3277 * this is a genuine disconnect and we need to clean up.
3278 * Otherwise, we will be stuck in reassoc state which will
3279 * in-turn block scans (see csrIsScanAllowed).
3280 */
3281 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 break;
3284
3285 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 csrNeighborRoamResetInitStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003287 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 break;
3289
Srikant Kuppa866893f2012-12-27 17:28:14 -08003290 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3291 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3292 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3293 csrNeighborRoamDeregAllRssiIndication(pMac);
3294 break;
3295
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003296 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
3297 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3298 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
3299 csrNeighborRoamDeregAllRssiIndication(pMac);
3300 break;
3301
3302 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3303 /* Stop pre-auth to reassoc interval timer */
3304 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003305 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3306 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3307 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003308 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003309 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003310 csrNeighborRoamDeregAllRssiIndication(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003311 break;
3312
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003314 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
3315 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003317 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 }
3319 return eHAL_STATUS_SUCCESS;
3320}
3321
3322/* ---------------------------------------------------------------------------
3323
3324 \fn csrNeighborRoamIndicateConnect
3325
3326 \brief This function is called by CSR as soon as the station connects to an AP.
3327 This initializes all the necessary data structures related to the
3328 associated AP and transitions the state to CONNECTED state
3329
3330 \param pMac - The handle returned by macOpen.
3331 sessionId - CSR session id that got connected
3332 vosStatus - connect status SUCCESS/FAILURE
3333
3334 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3335
3336---------------------------------------------------------------------------*/
3337eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
3338{
3339 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3340 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07003341 VOS_STATUS vstatus;
3342
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003343#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 int init_ft_flag = FALSE;
3345#endif
3346
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003347 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003348
3349 switch (pNeighborRoamInfo->neighborRoamState)
3350 {
3351 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3352 if (VOS_STATUS_SUCCESS != vosStatus)
3353 {
3354 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
3355 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3356 break;
3357 }
3358 /* Fall through if the status is SUCCESS */
3359 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
3360 /* Reset all the data structures here */
3361 csrNeighborRoamResetInitStateControlInfo(pMac);
3362
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003364
3365#ifdef FEATURE_WLAN_LFR
3366 /*
3367 * Initialize the occupied list ONLY if we are
3368 * transitioning from INIT state to CONNECTED state.
3369 */
3370 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
3371 csrInitOccupiedChannelsList(pMac);
3372#endif
3373 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
3374
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
3376 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
3377 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
3378 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3379 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003380 pNeighborRoamInfo->currentNeighborLookupThreshold =
3381 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
3382#ifdef FEATURE_WLAN_LFR
3383 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08003384 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08003385 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003386#endif
3387
Jeff Johnson295189b2012-06-20 16:38:30 -07003388
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003389#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 /* Now we can clear the preauthDone that was saved as we are connected afresh */
3391 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3392#endif
3393
3394#ifdef WLAN_FEATURE_VOWIFI_11R
3395 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003396 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
3397 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 {
3399 if (pMac->roam.configParam.isFastTransitionEnabled)
3400 init_ft_flag = TRUE;
3401 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
3402 }
3403 else
3404 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003405 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003406#endif
3407
3408#ifdef FEATURE_WLAN_CCX
3409 // Based on the auth scheme tell if we are 11r
3410 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
3411 {
3412 if (pMac->roam.configParam.isFastTransitionEnabled)
3413 init_ft_flag = TRUE;
3414 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
3415 }
3416 else
3417 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003418 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
3419 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07003420
3421#endif
3422
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003423#ifdef FEATURE_WLAN_LFR
3424 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303425 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003426 {
3427 init_ft_flag = TRUE;
3428 }
3429#endif
3430
3431#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 if ( init_ft_flag == TRUE )
3433 {
3434 /* Initialize all the data structures needed for the 11r FT Preauth */
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3436 csrNeighborRoamPurgePreauthFailedList(pMac);
3437
3438 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
3439 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07003440 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 WLANTL_HO_THRESHOLD_DOWN,
3442 csrNeighborRoamNeighborLookupDOWNCallback,
3443 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003444#ifdef FEATURE_WLAN_LFR
3445 pNeighborRoamInfo->lookupDOWNRssi = 0;
3446#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07003447 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 {
3449 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003450 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vstatus);
Jeff Johnson43971f52012-07-17 12:26:56 -07003451 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 }
3453 }
3454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 break;
3456 default:
3457 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3458 break;
3459 }
3460 return status;
3461}
3462
3463
3464#ifdef WLAN_FEATURE_VOWIFI_11R
3465/* ---------------------------------------------------------------------------
3466
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 \fn csrNeighborRoamPurgePreauthFailedList
3468
3469 \brief This function purges all the MAC addresses in the pre-auth fail list
3470
3471 \param pMac - The handle returned by macOpen.
3472
3473 \return VOID
3474
3475---------------------------------------------------------------------------*/
3476void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
3477{
3478 tANI_U8 i;
3479
3480 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
3481 {
3482 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
3483 }
3484 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
3485
3486 return;
3487}
3488
3489/* ---------------------------------------------------------------------------
3490
3491 \fn csrNeighborRoamInit11rAssocInfo
3492
3493 \brief This function initializes 11r related neighbor roam data structures
3494
3495 \param pMac - The handle returned by macOpen.
3496
3497 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3498
3499---------------------------------------------------------------------------*/
3500eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
3501{
3502 eHalStatus status;
3503 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
3504
3505 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
3506 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
3507 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
3508 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
3509 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
3510 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
3511
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3513 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3514 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3515 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3516
3517
3518 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
3519 if (eHAL_STATUS_SUCCESS != status)
3520 {
3521 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 return eHAL_STATUS_RESOURCES;
3523 }
3524 return status;
3525}
3526#endif /* WLAN_FEATURE_VOWIFI_11R */
3527
3528/* ---------------------------------------------------------------------------
3529
3530 \fn csrNeighborRoamInit
3531
3532 \brief This function initializes neighbor roam data structures
3533
3534 \param pMac - The handle returned by macOpen.
3535
3536 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3537
3538---------------------------------------------------------------------------*/
3539eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
3540{
3541 eHalStatus status;
3542 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3543
3544 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3545 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3546 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
3547 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
3548 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
3549 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
3550 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
3551 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
3552 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
3553 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
Srinivas Girigowdade697412013-02-14 16:31:48 -08003554 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
3555
3556#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3557 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = SME_KR_25;
3558 pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList = NULL;
3559 pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels = 0;
3560
3561 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
3562 {
3563 csrInitCountryValidChannelList(pMac, SME_KR_25);
3564 }
3565#endif
3566
3567 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
3569
Srinivas Girigowdade697412013-02-14 16:31:48 -08003570 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3572
3573 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3574 {
3575 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
3576 return eHAL_STATUS_RESOURCES;
3577 }
3578
3579 /* Update the roam global structure from CFG */
Srinivas Girigowdade697412013-02-14 16:31:48 -08003580 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
3582 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3583
3584 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
3585 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003586#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08003587 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003588 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08003589 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003590 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
3591 sizeof(tCsrRoamConnectedProfile));
3592#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
3594
3595 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3596 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3597 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborScanTimer,
3598 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3599
3600 if (eHAL_STATUS_SUCCESS != status)
3601 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08003602 smsLog(pMac, LOGE, FL("Neighbor scan timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3604 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3605 return eHAL_STATUS_RESOURCES;
3606 }
3607
3608 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborResultsRefreshTimer,
3609 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3610
3611 if (eHAL_STATUS_SUCCESS != status)
3612 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08003613 smsLog(pMac, LOGE, FL("Neighbor results refresh timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3615 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3616 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3617 return eHAL_STATUS_RESOURCES;
3618 }
3619
Srinivas Girigowdade697412013-02-14 16:31:48 -08003620 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->emptyScanRefreshTimer,
3621 csrNeighborRoamEmptyScanRefreshTimerCallback,
3622 (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3623
3624 if (eHAL_STATUS_SUCCESS != status)
3625 {
3626 smsLog(pMac, LOGE, FL("Empty scan refresh timer allocation failed"));
3627 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3628 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3629 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3630 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3631 return eHAL_STATUS_RESOURCES;
3632 }
3633
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
3635 if (eHAL_STATUS_SUCCESS != status)
3636 {
3637 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3638 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3639 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3640 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3641 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003642 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 return eHAL_STATUS_RESOURCES;
3644 }
3645
3646 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3647 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3648 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3649 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3650 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3651
3652#ifdef WLAN_FEATURE_VOWIFI_11R
3653 status = csrNeighborRoamInit11rAssocInfo(pMac);
3654 if (eHAL_STATUS_SUCCESS != status)
3655 {
3656 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3657 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3658 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3659 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3660 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003661 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3663 return eHAL_STATUS_RESOURCES;
3664 }
3665#endif
3666 /* Initialize this with the current tick count */
3667 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3668
3669 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3670
3671 return eHAL_STATUS_SUCCESS;
3672}
3673
3674/* ---------------------------------------------------------------------------
3675
3676 \fn csrNeighborRoamClose
3677
3678 \brief This function closes/frees all the neighbor roam data structures
3679
3680 \param pMac - The handle returned by macOpen.
3681
3682 \return VOID
3683
3684---------------------------------------------------------------------------*/
3685void csrNeighborRoamClose(tpAniSirGlobal pMac)
3686{
3687 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3688
3689 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
3690 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07003691 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 return;
3693 }
3694
3695 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3696 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3697
3698 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3699
3700 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
3701 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3702 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3703 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003704 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003705
3706 /* Should free up the nodes in the list before closing the double Linked list */
3707 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
3708 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3709
3710 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3711 {
3712 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3713 }
3714
3715 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3716 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3717 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3718 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3719 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3720 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3721
3722 /* Free the profile.. */
3723 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003724#ifdef FEATURE_WLAN_LFR
Sandeep Pc2b00f62012-12-12 16:44:44 -08003725 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003726#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003727#ifdef WLAN_FEATURE_VOWIFI_11R
3728 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3730 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3731 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3732 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3733 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3734#endif /* WLAN_FEATURE_VOWIFI_11R */
3735
3736 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
3737
3738 return;
3739}
3740
3741/* ---------------------------------------------------------------------------
3742
3743 \fn csrNeighborRoamRequestHandoff
3744
3745 \brief This function triggers actual switching from one AP to the new AP.
3746 It issues disassociate with reason code as Handoff and CSR as a part of
3747 handling disassoc rsp, issues reassociate to the new AP
3748
3749 \param pMac - The handle returned by macOpen.
3750
3751 \return VOID
3752
3753---------------------------------------------------------------------------*/
3754void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
3755{
3756
3757 tCsrRoamInfo roamInfo;
3758 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3759 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3760 tCsrNeighborRoamBSSInfo handoffNode;
3761 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
3762 tANI_U32 roamId = 0;
3763
3764 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
3765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003766 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 pMac->roam.neighborRoamInfo.neighborRoamState);
3768 return;
3769 }
3770
3771 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3772 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
3773 eSIR_SME_SUCCESS);
3774
3775 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3776 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
3777
3778 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003779 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
3780 FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 handoffNode.pBssDescription->bssId[0],
3782 handoffNode.pBssDescription->bssId[1],
3783 handoffNode.pBssDescription->bssId[2],
3784 handoffNode.pBssDescription->bssId[3],
3785 handoffNode.pBssDescription->bssId[4],
3786 handoffNode.pBssDescription->bssId[5]);
3787
3788 /* Free the profile.. Just to make sure we dont leak memory here */
3789 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
3790 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
3791 This should happen before issuing disconnect */
3792 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
3793 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
3794 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
3795
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003796 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07003797
3798 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
3799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003800 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate");
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 return;
3802 }
3803
3804 //notify HDD for handoff, providing the BSSID too
3805 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
3806
3807 vos_mem_copy(roamInfo.bssid,
3808 handoffNode.pBssDescription->bssId,
3809 sizeof( tCsrBssid ));
3810
3811 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
3812
3813
3814 return;
3815}
3816
3817/* ---------------------------------------------------------------------------
3818
3819 \fn csrNeighborRoamIsHandoffInProgress
3820
3821 \brief This function returns whether handoff is in progress or not based on
3822 the current neighbor roam state
3823
3824 \param pMac - The handle returned by macOpen.
3825 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
3826
3827 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
3828
3829---------------------------------------------------------------------------*/
3830tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
3831{
3832 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
3833 return eANI_BOOLEAN_TRUE;
3834
3835 return eANI_BOOLEAN_FALSE;
3836}
3837
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003838#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07003839/* ---------------------------------------------------------------------------
3840
3841 \fn csrNeighborRoamIs11rAssoc
3842
3843 \brief This function returns whether the current association is a 11r assoc or not
3844
3845 \param pMac - The handle returned by macOpen.
3846
3847 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
3848
3849---------------------------------------------------------------------------*/
3850tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
3851{
3852 return pMac->roam.neighborRoamInfo.is11rAssoc;
3853}
3854#endif /* WLAN_FEATURE_VOWIFI_11R */
3855
3856
3857/* ---------------------------------------------------------------------------
3858
3859 \fn csrNeighborRoamGetHandoffAPInfo
3860
3861 \brief This function returns the best possible AP for handoff. For 11R case, it
3862 returns the 1st entry from pre-auth done list. For non-11r case, it returns
3863 the 1st entry from roamable AP list
3864
3865 \param pMac - The handle returned by macOpen.
3866 pHandoffNode - AP node that is the handoff candidate returned
3867
3868 \return VOID
3869
3870---------------------------------------------------------------------------*/
3871void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
3872{
3873 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3874 tpCsrNeighborRoamBSSInfo pBssNode;
3875
3876 VOS_ASSERT(NULL != pHandoffNode);
3877
3878#ifdef WLAN_FEATURE_VOWIFI_11R
3879 if (pNeighborRoamInfo->is11rAssoc)
3880 {
3881 /* Always the BSS info in the head is the handoff candidate */
3882 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3883 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3884 }
3885 else
3886#endif
3887#ifdef FEATURE_WLAN_CCX
3888 if (pNeighborRoamInfo->isCCXAssoc)
3889 {
3890 /* Always the BSS info in the head is the handoff candidate */
3891 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3892 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3893 }
3894 else
3895#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003896#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303897 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003898 {
3899 /* Always the BSS info in the head is the handoff candidate */
3900 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3901 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3902 }
3903 else
3904#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 {
3906 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
3907 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
3908 }
3909 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
3910
3911 return;
3912}
3913
3914/* ---------------------------------------------------------------------------
3915 \brief This function returns TRUE if preauth is completed
3916
3917 \param pMac - The handle returned by macOpen.
3918
3919 \return boolean
3920
3921---------------------------------------------------------------------------*/
3922tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
3923{
3924 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
3925 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
3926}
3927
3928/* ---------------------------------------------------------------------------
3929 \brief In the event that we are associated with AP1 and we have
3930 completed pre auth with AP2. Then we receive a deauth/disassoc from
3931 AP1.
3932 At this point neighbor roam is in pre auth done state, pre auth timer
3933 is running. We now handle this case by stopping timer and clearing
3934 the pre-auth state. We basically clear up and just go to disconnected
3935 state.
3936
3937 \param pMac - The handle returned by macOpen.
3938
3939 \return boolean
3940---------------------------------------------------------------------------*/
3941void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
3942{
3943 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
3944 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
3945
3946 // Stop timer
3947 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
3948
3949 // Transition to init state
3950 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3951}
3952
Srikant Kuppafef66a72013-01-30 17:32:44 -08003953/* ---------------------------------------------------------------------------
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08003954 \brief This function returns TRUE if background scan triggered by
3955 LFR is in progress.
Srikant Kuppafef66a72013-01-30 17:32:44 -08003956
3957 \param halHandle - The handle from HDD context.
3958
3959 \return boolean
3960
3961---------------------------------------------------------------------------*/
3962tANI_BOOLEAN csrNeighborRoamScanRspPending (tHalHandle hHal)
3963{
3964 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3965 return (pMac->roam.neighborRoamInfo.scanRspPending);
3966}
3967
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08003968/* ---------------------------------------------------------------------------
3969 \brief This function returns TRUE if STA is in the middle of roaming states
3970
3971 \param halHandle - The handle from HDD context.
3972
3973 \return boolean
3974
3975---------------------------------------------------------------------------*/
3976tANI_BOOLEAN csrNeighborMiddleOfRoaming (tHalHandle hHal)
3977{
3978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3979 tANI_BOOLEAN val = (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3980 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3981 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3982 (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3983 (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState);
3984 return (val);
3985}
3986
Jeff Johnson295189b2012-06-20 16:38:30 -07003987#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */