blob: 3a1b758eac5ff3c69407b83dc8c3500063b01a4a [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);
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +0530673 if (pScanFilter == NULL)
674 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
676
677 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
678 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
679 if (NULL == pScanFilter->BSSIDs.bssid)
680 {
681 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
682 return eHAL_STATUS_FAILED_ALLOC;
683 }
684
685 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
686
687 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
688 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
689 {
690 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
691 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
692 }
693
694 /* Fill other general scan filter params */
695 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
696}
697
698/* ---------------------------------------------------------------------------
699
700 \fn csrNeighborRoamPurgePreauthFailList
701
702 \brief This function empties the preauth fail list
703
704 \param pMac - The handle returned by macOpen.
705
706 \return VOID
707
708---------------------------------------------------------------------------*/
709void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
710{
711 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
712
713 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
714 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
715 {
716 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
717 sizeof(tSirMacAddr));
718 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
719 }
720 return;
721}
722
723/* ---------------------------------------------------------------------------
724
725 \fn csrNeighborRoamAddBssIdToPreauthFailList
726
727 \brief This function adds the given BSSID to the Preauth fail list
728
729 \param pMac - The handle returned by macOpen.
730 bssId - BSSID to be added to the preauth fail list
731
732 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
733
734---------------------------------------------------------------------------*/
735eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
736{
737 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
738
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800739 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 -0700740 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
741
742
743 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
744 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
745 {
746 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
747 return eHAL_STATUS_FAILURE;
748 }
749 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
750 bssId, sizeof(tSirMacAddr));
751 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
752
753 return eHAL_STATUS_SUCCESS;
754}
755
756/* ---------------------------------------------------------------------------
757
758 \fn csrNeighborRoamIsPreauthCandidate
759
760 \brief This function checks whether the given MAC address is already
761 present in the preauth fail list and returns TRUE/FALSE accordingly
762
763 \param pMac - The handle returned by macOpen.
764
765 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
766
767---------------------------------------------------------------------------*/
768tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
769{
770 tANI_U8 i = 0;
771 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
772
773 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
774 return eANI_BOOLEAN_TRUE;
775
776 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
777 {
778 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
779 bssId, sizeof(tSirMacAddr)))
780 {
781 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
782 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
783 return eANI_BOOLEAN_FALSE;
784 }
785 }
786
787 return eANI_BOOLEAN_TRUE;
788}
789
790/* ---------------------------------------------------------------------------
791
792 \fn csrNeighborRoamIssuePreauthReq
793
794 \brief This function issues preauth request to PE with the 1st AP entry in the
795 roamable AP list
796
797 \param pMac - The handle returned by macOpen.
798
799 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
800
801---------------------------------------------------------------------------*/
802static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
803{
804 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
805 eHalStatus status = eHAL_STATUS_SUCCESS;
806 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
807
808 /* This must not be true here */
809 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
810
811 /* Issue Preauth request to PE here */
812 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
813 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
814 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
815 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
816
817 if (NULL == pNeighborBssNode)
818 {
819 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
820 return eHAL_STATUS_FAILURE;
821 }
822 else
823 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700824 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
825 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530826
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800827 smsLog(pMac, LOG1, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530828 pNeighborBssNode->pBssDescription->bssId[0],
829 pNeighborBssNode->pBssDescription->bssId[1],
830 pNeighborBssNode->pBssDescription->bssId[2],
831 pNeighborBssNode->pBssDescription->bssId[3],
832 pNeighborBssNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800833 pNeighborBssNode->pBssDescription->bssId[5],
834 (int)pNeighborBssNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530835
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 if (eHAL_STATUS_SUCCESS != status)
837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800838 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 return status;
840 }
841 }
842
843 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
844
845 /* Increment the preauth retry count */
846 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
847
848 /* Transition the state to preauthenticating */
849 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Jeff Johnson295189b2012-06-20 16:38:30 -0700850
851 return status;
852}
853
854/* ---------------------------------------------------------------------------
855
856 \fn csrNeighborRoamPreauthRspHandler
857
858 \brief This function handle the Preauth response from PE
859 Every preauth is allowed max 3 tries if it fails. If a bssid failed
860 for more than MAX_TRIES, we will remove it from the list and try
861 with the next node in the roamable AP list and add the BSSID to pre-auth failed
862 list. If no more entries present in
863 roamable AP list, transition to REPORT_SCAN state
864
865 \param pMac - The handle returned by macOpen.
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800866 limStatus - eSIR_SUCCESS/eSIR_FAILURE/eSIR_LIM_MAX_STA_REACHED_ERROR/
867 eSIT_LIM_AUTH_RSP_TIMEOUT status from PE
Jeff Johnson295189b2012-06-20 16:38:30 -0700868
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700869 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
870 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -0700871
872---------------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800873eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, tSirRetStatus limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700874{
875 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
876 eHalStatus status = eHAL_STATUS_SUCCESS;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800877 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700878 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700880
881 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
882 {
883
884 /* This can happen when we disconnect immediately
885 * after sending a pre-auth request. During processing
886 * of the disconnect command, we would have reset
887 * preauthRspPending and transitioned to INIT state.
888 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800889 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
890 FL("Unexpected pre-auth response in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700891 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700892 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700893 goto DEQ_PREAUTH;
894 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700895
896 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
898 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
899 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800900 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700901 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700902 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700903 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 }
905
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800906 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700907
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800908 if (eSIR_SUCCESS == limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 {
910 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
911 }
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800912 if ((eSIR_SUCCESS == limStatus) && (NULL != pPreauthRspNode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800914 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
Jeff Johnson295189b2012-06-20 16:38:30 -0700915
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800916 smsLog(pMac, LOG1, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530917 pPreauthRspNode->pBssDescription->bssId[0],
918 pPreauthRspNode->pBssDescription->bssId[1],
919 pPreauthRspNode->pBssDescription->bssId[2],
920 pPreauthRspNode->pBssDescription->bssId[3],
921 pPreauthRspNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800922 pPreauthRspNode->pBssDescription->bssId[5],
923 (int)pPreauthRspNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
926 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
927 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
928
929 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
930 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
931 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
932
933 /* The caller of this function would start a timer and by the time it expires, supplicant should
934 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
935 }
936 else
937 {
938 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
939 tListElem *pEntry;
940
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800941 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = 0x%x"),
942 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, limStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700943
944 /* 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 -0800945 if ((pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >=
946 CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES) ||
947 (eSIR_LIM_MAX_STA_REACHED_ERROR == limStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 {
949 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
950 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
951
952 /* The one in the head of the list should be one with which we issued pre-auth and failed */
953 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
954 if(pEntry)
955 {
956 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
957 /* Add the BSSID to pre-auth fail list */
958 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
959 /* Now we can free this node */
960 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
961 }
962 }
963
964 /* Issue preauth request for the same/next entry */
965 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700966 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700967
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800968 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
969
970 /* Register Neighbor Lookup threshold callback with TL for UP event now */
971 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
972 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
973
974 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
975 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
976 WLANTL_HO_THRESHOLD_UP,
977 csrNeighborRoamNeighborLookupUPCallback,
978 VOS_MODULE_ID_SME, pMac);
979 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
980 {
981 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800982 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800983 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
986 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
987 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
988 eANI_BOOLEAN_FALSE);
989 if (eHAL_STATUS_SUCCESS != status)
990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800991 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 }
993 }
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700994
995DEQ_PREAUTH:
996 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700997 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700998}
999#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
1000
1001/* ---------------------------------------------------------------------------
1002
1003 \fn csrNeighborRoamPrepareScanProfileFilter
1004
1005 \brief This function creates a scan filter based on the currently connected profile.
1006 Based on this filter, scan results are obtained
1007
1008 \param pMac - The handle returned by macOpen.
1009 pScanFilter - Populated scan filter based on the connected profile
1010
1011 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
1012
1013---------------------------------------------------------------------------*/
1014eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
1015{
1016 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1017 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
1018 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
1019 tANI_U8 i = 0;
1020
1021 VOS_ASSERT(pScanFilter != NULL);
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05301022 if (pScanFilter == NULL)
1023 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001024
1025 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
1026
1027 /* We dont want to set BSSID based Filter */
1028 pScanFilter->BSSIDs.numOfBSSIDs = 0;
1029
1030 /* Populate all the information from the connected profile */
1031 pScanFilter->SSIDs.numOfSSIDs = 1;
1032 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
1033 if (NULL == pScanFilter->SSIDs.SSIDList)
1034 {
1035 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
1036 return eHAL_STATUS_FAILED_ALLOC;
1037 }
1038 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
1039 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
1040 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
1041 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
1042
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001043 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering for SSID %s from scan results.. SSID Length = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 pScanFilter->SSIDs.SSIDList->SSID.ssId, pScanFilter->SSIDs.SSIDList->SSID.length);
1045 pScanFilter->authType.numEntries = 1;
1046 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
1047
1048 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
1049 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
1050
1051 pScanFilter->mcEncryptionType.numEntries = 1;
1052 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
1053
1054 pScanFilter->BSSType = pCurProfile->BSSType;
1055
1056 /* We are intrested only in the scan results on channels that we scanned */
1057 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
1058 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
1059 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1060 {
1061 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1062 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1063 pScanFilter->SSIDs.SSIDList = NULL;
1064 return eHAL_STATUS_FAILED_ALLOC;
1065 }
1066 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1067 {
1068 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1069 }
1070
1071#ifdef WLAN_FEATURE_VOWIFI_11R
1072 if (pNeighborRoamInfo->is11rAssoc)
1073 {
1074 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1075 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1076 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1077 }
1078#endif
1079
1080 return eHAL_STATUS_SUCCESS;
1081}
1082
Jeff Johnson43971f52012-07-17 12:26:56 -07001083tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1084{
1085 tCsrScanResultInfo *pScanResult;
1086 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda2efea0e2013-01-24 17:40:41 -08001087#ifdef FEATURE_WLAN_LFR
1088 tANI_U32 CurrAPRssi = pNeighborRoamInfo->lookupDOWNRssi;
1089#else
1090 /* We are setting this as default value to make sure we return this value,
1091 when we do not see this AP in the scan result for some reason.However,it is
1092 less likely that we are associated to an AP and do not see it in the scan list */
1093 tANI_U32 CurrAPRssi = -125;
1094#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001095
1096 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1097 {
1098
1099 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1100 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1101 {
1102 /* We got a match with the currently associated AP.
1103 * Capture the RSSI value and complete the while loop.
1104 * The while loop is completed in order to make the current entry go back to NULL,
1105 * and in the next while loop, it properly starts searching from the head of the list.
1106 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1107
1108 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1109
1110 } else {
1111 continue;
1112 }
1113 }
1114
1115 return CurrAPRssi;
1116
1117}
1118
Jeff Johnson295189b2012-06-20 16:38:30 -07001119/* ---------------------------------------------------------------------------
1120
1121 \fn csrNeighborRoamProcessScanResults
1122
1123 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1124 Assumed that the results are already sorted by RSSI by csrScanGetResult
1125
1126 \param pMac - The handle returned by macOpen.
1127 pScanResultList - Scan result result obtained from csrScanGetResult()
1128
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001129 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1130 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001131
1132---------------------------------------------------------------------------*/
1133
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001134static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1135 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001136{
1137 tCsrScanResultInfo *pScanResult;
1138 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1139 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001140 tANI_U32 CurrAPRssi;
1141 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001142#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1143 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1144#endif
1145 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001146
1147 /***************************************************************
1148 * Find out the Current AP RSSI and keep it handy to check if
1149 * it is better than the RSSI of the AP which we are
1150 * going to roam.If so, we are going to continue with the
1151 * current AP.
1152 ***************************************************************/
1153 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
1155 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1156 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1157 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1158 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1159 /* 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
1160 and rssi score are in the same order. This will be taken care later */
1161
1162 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1163 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001164 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
1165 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d, Ch:%d)"),
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001166 pScanResult->BssDescriptor.bssId[0],
1167 pScanResult->BssDescriptor.bssId[1],
1168 pScanResult->BssDescriptor.bssId[2],
1169 pScanResult->BssDescriptor.bssId[3],
1170 pScanResult->BssDescriptor.bssId[4],
1171 pScanResult->BssDescriptor.bssId[5],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001172 abs(pScanResult->BssDescriptor.rssi),
1173 pScanResult->BssDescriptor.channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001174
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001175 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1177 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001178 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001179 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001180 "SKIP-currently associated AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 continue;
1182 }
1183
Jeff Johnson43971f52012-07-17 12:26:56 -07001184 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1185 * is disabled and we continue to roam without any check*/
1186 if(RoamRssiDiff > 0)
1187 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001188 /*
1189 * If RSSI is lower than the lookup threshold, then continue.
1190 */
1191 if (abs(pScanResult->BssDescriptor.rssi) >
1192 pNeighborRoamInfo->currentNeighborLookupThreshold)
1193 {
1194 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001195 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)",
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001196 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1197 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1198 continue;
1199 }
1200
Jeff Johnson43971f52012-07-17 12:26:56 -07001201 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1202 {
1203 /*Do not roam to an AP with worse RSSI than the current*/
1204 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001205 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001206 CurrAPRssi,
1207 (int)pScanResult->BssDescriptor.rssi * (-1) );
1208 continue;
1209 } else {
1210 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1211 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1212 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1213 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001214 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001215 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d", __func__,
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001216 CurrAPRssi,
1217 (int)pScanResult->BssDescriptor.rssi * (-1),
1218 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001219 continue;
1220 }
1221 else {
1222 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001223 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001224 CurrAPRssi,
1225 (int)pScanResult->BssDescriptor.rssi * (-1) );
1226 }
1227 }
1228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001229
1230#ifdef WLAN_FEATURE_VOWIFI_11R
1231 if (pNeighborRoamInfo->is11rAssoc)
1232 {
1233 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1234 {
1235 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1236 continue;
1237 }
1238 }
1239#endif /* WLAN_FEATURE_VOWIFI_11R */
1240
1241#ifdef FEATURE_WLAN_CCX
1242 if (pNeighborRoamInfo->isCCXAssoc)
1243 {
1244 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1245 {
1246 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1247 continue;
1248 }
1249 }
1250 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1251 (pScanResult->BssDescriptor.QBSSLoad_avail))
1252 {
1253 if (pNeighborRoamInfo->isVOAdmitted)
1254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001255 smsLog(pMac, LOG1, FL("New AP has %x BW available"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1256 smsLog(pMac, LOG1, FL("We need %x BW available"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1258 {
1259 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001260 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list",
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 pScanResult->BssDescriptor.bssId[0],
1262 pScanResult->BssDescriptor.bssId[1],
1263 pScanResult->BssDescriptor.bssId[2],
1264 pScanResult->BssDescriptor.bssId[3],
1265 pScanResult->BssDescriptor.bssId[4],
1266 pScanResult->BssDescriptor.bssId[5]);
1267 continue;
1268 }
1269 }
1270 }
1271 else
1272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001273 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 -07001274 if (pNeighborRoamInfo->isVOAdmitted)
1275 {
1276 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001277 "[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 -07001278 pScanResult->BssDescriptor.bssId[0],
1279 pScanResult->BssDescriptor.bssId[1],
1280 pScanResult->BssDescriptor.bssId[2],
1281 pScanResult->BssDescriptor.bssId[3],
1282 pScanResult->BssDescriptor.bssId[4],
1283 pScanResult->BssDescriptor.bssId[5]);
1284 continue;
1285 }
1286 }
1287#endif /* FEATURE_WLAN_CCX */
1288
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001289#ifdef FEATURE_WLAN_LFR
1290 // If we are supporting legacy roaming, and
1291 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301292 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001293 {
1294 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1295 {
1296 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1297 continue;
1298 }
1299 }
1300#endif /* FEATURE_WLAN_LFR */
1301
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1303 * this result */
1304 if (pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1305 {
1306 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1307 continue;
1308 }
1309
1310 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1311 if (NULL == pBssInfo)
1312 {
1313 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1314 continue;
1315 }
1316
1317 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1318 if (pBssInfo->pBssDescription != NULL)
1319 {
1320 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1321 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1322 }
1323 else
1324 {
1325 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1326 vos_mem_free(pBssInfo);
1327 continue;
1328
1329 }
1330 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1331
1332 /* Just add to the end of the list as it is already sorted by RSSI */
1333 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001334
1335#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srikant Kuppa866893f2012-12-27 17:28:14 -08001336 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001337 {
1338 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1339 "%s: [INFOLOG] potential candidate to roam immediately (diff=%d, expected=%d)",
1340 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1341 immediateRoamRssiDiff);
1342 roamNow = eANI_BOOLEAN_TRUE;
1343 }
1344#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 }
1346
1347 /* 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 */
1348 csrScanResultPurge(pMac, *pScanResultList);
1349
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001350 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001351}
1352
1353/* ---------------------------------------------------------------------------
1354
1355 \fn csrNeighborRoamHandleEmptyScanResult
1356
1357 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1358 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001359 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001361 1. Stop the neighbor scan timer.
1362 2a. If this is the first time we encountered empty scan, then
1363 re-register with TL with modified lookup threshold.
1364 2b. Else if this is the second time we encountered empty scan,
1365 then start neighbor scan results refresh timer (20s).
1366 2c. Else, nothing more to do.
1367 NOTE: In LFR, channels selected for scanning is dervied from
1368 the occuped channel list. Scan cycle following one which
1369 yielded empty results is split into two halves: (i) scan on
1370 channels in the occupied list, and (ii) scan on channels not
1371 in the occupied list. This helps converging faster (while
1372 looking for candidates in the occupied list first), and also,
1373 adds channels to the occupied channel list upon finding candidates
1374 matching SSID profile of interest.
1375
1376 uEmptyScanCount Comments
1377 eFirstEmptyScan Previous scan was done on channels in the
1378 occupied list and yielded potential candidates.
1379 This scan cycle was likely triggered through
1380 receipt of lookup DOWN notification event.
1381 eSecondEmptyScan Previous scan was done on channels in the
1382 occupied list and yielded no candidates. This scan
1383 cycle was triggered through RSSI notification
1384 with modified lookup threshold.
1385 eThirdEmptyScan Previous scan was done on channels NOT in
1386 the occupied list and yielded no candidates. This
1387 scan cycle was triggered immediately after scanning
1388 channels in the occupied list and no candidates
1389 were found.
1390 eFourthEmptyScan Previous scan was done on channels in the
1391 occupied list and yielded no candidates. This scan
1392 cycle was triggered upon expiry of
1393 neighborScanResultsRefreshPeriod (=20s).
1394 eFifthEmptyScan Previous scan was done on channels NOT in
1395 the occupied list and yielded no candidates. This
1396 scan cycle was triggered immediately after scanning
1397 channels in the occupied list and no candidates
1398 were found.
1399
1400 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001401
1402 \param pMac - The handle returned by macOpen.
1403
1404 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1405
1406---------------------------------------------------------------------------*/
1407static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1408{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001409 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1411 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001412#ifdef FEATURE_WLAN_LFR
1413 tANI_BOOLEAN performPeriodicScan =
1414 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod) ? TRUE : FALSE;
1415#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001416
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001417 /* Stop neighbor scan timer */
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001419 if (eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001421 smsLog(pMac, LOGW, FL("stopping neighborScanTimer failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 }
1423
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001424 /*
1425 * Increase the neighbor lookup threshold by 3 dB
1426 * after every scan cycle. NOTE: uEmptyScanCount
1427 * would be either 1, 3 or 5 at the end of every
1428 * scan cycle.
1429 */
1430#ifdef FEATURE_WLAN_LFR
1431 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1432 {
1433 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1434 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001435 if ((abs(pNeighborRoamInfo->lookupDOWNRssi) >
1436 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold)) &&
1437 ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1438 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan)))
1439 {
1440 /*
1441 * If the scan was triggered due to lookupDOWNRssi > reassoc threshold,
1442 * then it would be a contiguous scan on all valid non-DFS channels.
1443 * In this mode, there is no need to trigger an immediate scan upon
1444 * empty scan results for the second and fourth time (which would
1445 * be equivalent to scanning on channels in non-occupied list).
1446 * Incrementing uEmptyScanCount will correspond to skipping this step.
1447 * NOTE: double increment of uEmptyScanCount corresponds to completion
1448 * of scans on all valid channels.
1449 */
1450 ++pNeighborRoamInfo->uEmptyScanCount;
1451 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Extra increment of empty scan count (=%d)"
1452 " in contiguous scan mode", pNeighborRoamInfo->uEmptyScanCount);
1453 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001454#endif
1455 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1456 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1457#ifdef FEATURE_WLAN_LFR
1458 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1459#endif
1460 )
1461 {
1462 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1463 }
1464
Jeff Johnson295189b2012-06-20 16:38:30 -07001465#ifdef WLAN_FEATURE_VOWIFI_11R
1466 /* Clear off the old neighbor report details */
1467 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1468#endif
1469
Srikant Kuppa866893f2012-12-27 17:28:14 -08001470 /* Transition to CONNECTED state */
1471 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1472
1473 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1474 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1475
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001476#ifdef FEATURE_WLAN_LFR
1477 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1478 {
1479#endif
1480 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001481 /* Re-register neighbor lookup DOWN threshold callback with TL */
1482 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1483 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1484 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1485
1486 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1487 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1488 WLANTL_HO_THRESHOLD_DOWN,
1489 csrNeighborRoamNeighborLookupDOWNCallback,
1490 VOS_MODULE_ID_SME, pMac);
1491
1492 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1493 {
1494 smsLog(pMac, LOGW,
1495 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001496 " with TL: Status = %d"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001497 }
1498#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08001499 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001500 }
1501 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1502 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1503 {
1504 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001505
1506 /* Immediately scan on channels in non-occupied list */
1507 csrNeighborRoamTransitToCFGChanScan(pMac);
1508 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001509 else if (pNeighborRoamInfo->uEmptyScanCount >= eThirdEmptyScan)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001510 {
1511 /* Empty scan results for the third time */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001512 if (performPeriodicScan)
1513 {
1514 smsLog(pMac, LOGE, FL("Performing periodic scan, uEmptyScanCount=%d"),
1515 pNeighborRoamInfo->uEmptyScanCount);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001516
Srinivas Girigowdade697412013-02-14 16:31:48 -08001517 /*
1518 * Set uEmptyScanCount to MAX so that we always enter this
1519 * condition on subsequent empty scan results
1520 */
1521 pNeighborRoamInfo->uEmptyScanCount = eMaxEmptyScan;
1522
1523 /* From here on, ONLY scan on channels in the occupied list */
1524 pNeighborRoamInfo->uScanMode = SPLIT_SCAN_OCCUPIED_LIST;
1525
1526 /* Start empty scan refresh timer */
1527 if (eHAL_STATUS_SUCCESS !=
1528 palTimerStart(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer,
1529 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1530 eANI_BOOLEAN_FALSE))
1531 {
1532 smsLog(pMac, LOGE, FL("Empty scan refresh timer failed to start (%d)"),
1533 status);
1534 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1535 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001536 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001537 vosStatus = VOS_STATUS_E_FAILURE;
1538 }
1539 else
1540 {
1541 smsLog(pMac, LOGE, FL("Empty scan refresh timer started (%ld ms)"),
1542 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod));
1543 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001544 }
1545 else
1546 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001547 /* Start neighbor scan results refresh timer */
1548 if (eHAL_STATUS_SUCCESS !=
1549 palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1550 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1551 eANI_BOOLEAN_FALSE))
1552 {
1553 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1554 status);
1555 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1556 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001557 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001558 vosStatus = VOS_STATUS_E_FAILURE;
1559 }
1560 else
1561 {
1562 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1563 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1564 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001567
Srinivas Girigowdade697412013-02-14 16:31:48 -08001568 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d scan mode=%d",
1569 pNeighborRoamInfo->uEmptyScanCount, pNeighborRoamInfo->uScanMode);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001570#endif
1571 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001572}
1573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574
Srikant Kuppa866893f2012-12-27 17:28:14 -08001575static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001576{
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 tCsrScanResultFilter scanFilter;
1579 tScanResultHandle scanResult;
1580 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001581 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001582 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001583
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001584#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1586 should use the BSSID filter made out of neighbor reports */
1587 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1588 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001589 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1590 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 -07001591 tempVal = 1;
1592 }
1593 else
1594#endif
1595 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001596 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1597 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 -07001598 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001599 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 {
1601 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1602 return eHAL_STATUS_FAILURE;
1603 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001604 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301605 if (hstatus != eHAL_STATUS_SUCCESS)
1606 {
1607 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001610 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611
1612 /* Free the scan filter */
1613 csrFreeScanFilter(pMac, &scanFilter);
1614
1615 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1616
1617 switch(pNeighborRoamInfo->neighborRoamState)
1618 {
1619 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1620 if (tempVal)
1621 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001622#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001623 /*
1624 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001625 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001626 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001627 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001628 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001629#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001630#ifdef WLAN_FEATURE_VOWIFI_11R
1631 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1632 APs in the roamable AP list */
1633 if (pNeighborRoamInfo->is11rAssoc)
1634 {
1635 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1636 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1637 }
1638 else
1639#endif
1640#ifdef FEATURE_WLAN_CCX
1641 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1642 APs in the roamable AP list */
1643 if (pNeighborRoamInfo->isCCXAssoc)
1644 {
1645 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1646 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1647 }
1648 else
1649#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001650#ifdef FEATURE_WLAN_LFR
1651 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1652 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301653 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001654 {
1655 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1656 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1657 }
1658 else
1659#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 {
1661
1662 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1663 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1664 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1665 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1666 within certain duration */
1667
1668// palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
1669 }
1670 }
1671 else
1672 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001673 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1674 /* Handle it appropriately */
1675 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 }
1677 break;
1678#ifdef WLAN_FEATURE_VOWIFI_11R
1679 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1680 if (!tempVal)
1681 {
1682 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1683 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1684 csrNeighborRoamTransitToCFGChanScan(pMac);
1685 }
1686 break;
1687#endif /* WLAN_FEATURE_VOWIFI_11R */
1688 default:
1689 // Can come only in INIT state. Where in we are associated, we sent scan and user
1690 // in the meantime decides to disassoc, we will be in init state and still received call
1691 // back issued. Should not come here in any other state, printing just in case
1692 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001693 "%s: [INFOLOG] State %d", __func__, (pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001694
1695 // Lets just exit out silently.
1696 return eHAL_STATUS_SUCCESS;
1697 }
1698
1699 if (tempVal)
1700 {
1701 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1702
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001703 if (roamNow)
1704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001705 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001706 FL("Immediate roam-deregister UP indication. RSSI = %d"),
1707 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1708
1709 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
1710 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1711 WLANTL_HO_THRESHOLD_UP,
1712 csrNeighborRoamNeighborLookupUPCallback,
1713 VOS_MODULE_ID_SME);
1714
1715 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001717 smsLog(pMac, LOGW,
1718 FL("Couldn't deregister lookup UP callback with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001719 }
1720
1721 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
1722 return eHAL_STATUS_SUCCESS;
1723 }
1724
Srikant Kuppa866893f2012-12-27 17:28:14 -08001725 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1726 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1727 eANI_BOOLEAN_FALSE);
1728
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
1730 * 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 -08001731 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08001733 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1735 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001736 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson43971f52012-07-17 12:26:56 -07001737 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001739
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
1741 /* Register a reassoc Indication callback */
1742 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
1743 WLANTL_HO_THRESHOLD_DOWN,
1744 csrNeighborRoamReassocIndCallback,
1745 VOS_MODULE_ID_SME, pMac);
1746
1747 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1748 {
1749 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001750 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 }
1752
1753 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08001754
1755 return eHAL_STATUS_SUCCESS;
1756
1757}
1758
1759
1760/* ---------------------------------------------------------------------------
1761
1762 \fn csrNeighborRoamScanRequestCallback
1763
1764 \brief This function is the callback function registered in csrScanRequest() to
1765 indicate the completion of scan. If scan is completed for all the channels in
1766 the channel list, this function gets the scan result and starts the refresh results
1767 timer to avoid having stale results. If scan is not completed on all the channels,
1768 it restarts the neighbor scan timer which on expiry issues scan on the next
1769 channel
1770
1771 \param halHandle - The handle returned by macOpen.
1772 pContext - not used
1773 scanId - not used
1774 status - not used
1775
1776 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1777
1778---------------------------------------------------------------------------*/
1779static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
1780 tANI_U32 scanId, eCsrScanStatus status)
1781{
1782 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1783 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1784 tANI_U8 currentChanIndex;
1785 eHalStatus hstatus;
1786
1787 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1788
1789 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1790 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1791 {
1792 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1793 return eHAL_STATUS_SUCCESS;
1794 }
1795
1796 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
1797 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
1798
1799 /* Validate inputs */
1800 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001801 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08001802 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
1803 }
1804 else
1805 {
1806 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
1807 return eHAL_STATUS_SUCCESS;
1808 }
1809
1810 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1811 {
1812 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
1813 just to get the results and perform PREAUTH */
1814 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
1815 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
1816 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
1817 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
1818
1819 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1820
1821 if (eHAL_STATUS_SUCCESS != hstatus)
1822 {
1823 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1824 return eHAL_STATUS_FAILURE;
1825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 }
1827 else
1828 {
1829
1830 /* Restart the timer for the next scan sequence as scanning is not over */
Jeff Johnson43971f52012-07-17 12:26:56 -07001831 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
1833 eANI_BOOLEAN_FALSE);
1834
Jeff Johnson43971f52012-07-17 12:26:56 -07001835 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 {
1837 /* Timer start failed.. Should we ASSERT here??? */
1838 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
1839 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1840 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001841 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson43971f52012-07-17 12:26:56 -07001842 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 }
1844 }
1845 return eHAL_STATUS_SUCCESS;
1846}
1847
Srikant Kuppa866893f2012-12-27 17:28:14 -08001848#ifdef FEATURE_WLAN_LFR
1849static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
1850 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
1851{
1852 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1853 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1854 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
1855
1856 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1857
1858 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1859 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1860 {
1861 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1862 return eHAL_STATUS_SUCCESS;
1863 }
1864
Srinivas Girigowdade697412013-02-14 16:31:48 -08001865 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
1866 {
1867 smsLog(pMac, LOGE, FL("Received in INIT state. Must have disconnected. Ignore it"));
1868 return eHAL_STATUS_SUCCESS;
1869 }
1870
Srikant Kuppa866893f2012-12-27 17:28:14 -08001871 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
1872 hstatus = csrNeighborRoamProcessScanComplete(pMac);
1873
1874 if (eHAL_STATUS_SUCCESS != hstatus)
1875 {
1876 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
1877 }
1878
1879 return hstatus;
1880}
1881#endif
1882
Jeff Johnson295189b2012-06-20 16:38:30 -07001883/* ---------------------------------------------------------------------------
1884
1885 \fn csrNeighborRoamIssueBgScanRequest
1886
1887 \brief This function issues CSR scan request after populating all the BG scan params
1888 passed
1889
1890 \param pMac - The handle returned by macOpen.
1891 pBgScanParams - Params that need to be populated into csr Scan request
1892
1893 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1894
1895---------------------------------------------------------------------------*/
Srikant Kuppa866893f2012-12-27 17:28:14 -08001896eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
1897 tCsrBGScanRequest *pBgScanParams,
1898 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07001899{
1900 eHalStatus status = eHAL_STATUS_SUCCESS;
1901 tANI_U32 scanId;
1902 tCsrScanRequest scanReq;
1903 tANI_U8 channel;
1904
Srikant Kuppa866893f2012-12-27 17:28:14 -08001905 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001906 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08001907 pBgScanParams->ChannelInfo.ChannelList[0],
1908 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07001909
1910 //send down the scan req for 1 channel on the associated SSID
1911 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
1912 /* Fill in the SSID Info */
1913 scanReq.SSIDs.numOfSSIDs = 1;
1914 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1915 if(NULL == scanReq.SSIDs.SSIDList)
1916 {
1917 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001918 smsLog(pMac, LOGE, FL("Couldn't allocate memory for the SSID..Freeing memory allocated for Channel List"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 return eHAL_STATUS_FAILURE;
1920 }
1921 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1922
1923 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
1924 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
1925 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
1926
1927 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001928 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
1929 {
1930 channel = pBgScanParams->ChannelInfo.ChannelList[0];
1931 scanReq.ChannelInfo.ChannelList = &channel;
1932 }
1933 else
1934 {
1935 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
1936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001937
1938 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
1939 scanReq.scanType = eSIR_ACTIVE_SCAN;
1940 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
1941 scanReq.maxChnTime = pBgScanParams->maxChnTime;
1942 scanReq.minChnTime = pBgScanParams->minChnTime;
1943 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Srikant Kuppa866893f2012-12-27 17:28:14 -08001944 &scanId, callbackfn, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 if (eHAL_STATUS_SUCCESS != status)
1946 {
1947 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
1948 vos_mem_free(scanReq.SSIDs.SSIDList);
1949 return status;
1950 }
1951 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
1952
1953 vos_mem_free(scanReq.SSIDs.SSIDList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001954 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001955 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08001956 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
1957 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
1958
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 return status;
1960}
1961
Srikant Kuppa866893f2012-12-27 17:28:14 -08001962static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
1963 tpCsrBGScanRequest bgScanParams)
1964{
1965 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1966 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1967
1968 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
1969 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
1970 vos_mem_copy(bgScanParams->SSID.ssId,
1971 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
1972 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
1973
1974 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
1975 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
1976}
1977
Jeff Johnson295189b2012-06-20 16:38:30 -07001978/* ---------------------------------------------------------------------------
1979
1980 \fn csrNeighborRoamPerformBgScan
1981
1982 \brief This function is invoked on every expiry of neighborScanTimer till all
1983 the channels in the channel list are scanned. It populates necessary
1984 parameters for BG scan and calls appropriate AP to invoke the CSR scan
1985 request
1986
1987 \param pMac - The handle returned by macOpen.
1988
1989 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1990
1991---------------------------------------------------------------------------*/
1992eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac)
1993{
1994 eHalStatus status = eHAL_STATUS_SUCCESS;
1995 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1996 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 tANI_U8 channel = 0;
1998
1999 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2000 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302001 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 }
2003 else
2004 {
2005 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson902c9832012-12-10 14:28:09 -08002006 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 // When timer start is declared a failure, then we delete the list.
2008 // Should not happen now as we stop and then only start the scan timer.
2009 // still handle the unlikely case.
2010 csrNeighborRoamHandleEmptyScanResult(pMac);
2011 return status;
2012 }
2013 /* Need to perform scan here before getting the list */
Srikant Kuppa866893f2012-12-27 17:28:14 -08002014
2015 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07002016
2017 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
2018 bgScanParams.ChannelInfo.numOfChannels = 1;
2019 bgScanParams.ChannelInfo.ChannelList = &channel;
2020
Srikant Kuppa866893f2012-12-27 17:28:14 -08002021 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002022
Srikant Kuppa866893f2012-12-27 17:28:14 -08002023 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2024 csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 if (eHAL_STATUS_SUCCESS != status)
2026 {
2027 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 }
2029
2030 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
2031 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
2032 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2033 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302034 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
2036 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
2037 /* We have completed scanning all the channels */
2038 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2039 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
2040 and select the best AP in the list */
2041 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2042 {
2043 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
2044 }
2045 }
2046
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08002047 if (eHAL_STATUS_SUCCESS != status)
2048 {
2049 /*
2050 * If the status is not success, we need to call the callback
2051 * routine so that the state machine does not get stuck.
2052 */
2053 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
2054 }
2055
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 return status;
2057}
2058
Srikant Kuppa866893f2012-12-27 17:28:14 -08002059#ifdef FEATURE_WLAN_LFR
2060eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac)
2061{
2062 eHalStatus status = eHAL_STATUS_SUCCESS;
2063 tCsrBGScanRequest bgScanParams;
2064 int numOfChannels = 0, i = 0;
2065 tANI_U8 *channelList = NULL;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002066 tANI_U8 *pInChannelList = NULL;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002067
2068 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
2069
2070 /* Contiguously scan all channels from valid list */
2071 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002072
2073 if (NULL != pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList)
Srikant Kuppa866893f2012-12-27 17:28:14 -08002074 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002075 /* this list is filled only if the country code is set to KR */
2076 numOfChannels = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
2077 pInChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002078 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002079 else
2080 {
2081 numOfChannels = sizeof(pMac->roam.validChannelList);
2082
2083 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2084 (tANI_U8 *)pMac->roam.validChannelList,
2085 (tANI_U32 *) &numOfChannels)))
2086 {
2087 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
2088 return eHAL_STATUS_FAILURE;
2089 }
2090 pInChannelList = pMac->roam.validChannelList;
2091 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002092 channelList = vos_mem_malloc( numOfChannels );
2093 if( NULL == channelList )
2094 {
2095 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
2096 return eHAL_STATUS_FAILURE;
2097 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002098 vos_mem_copy(channelList, (tANI_U8 *)pInChannelList,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002099 numOfChannels * sizeof(tANI_U8));
2100
2101 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
2102 bgScanParams.ChannelInfo.ChannelList = channelList;
2103 for (i = 0; i < numOfChannels; i++)
2104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002105 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d",
Srikant Kuppa866893f2012-12-27 17:28:14 -08002106 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
2107 }
2108 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
2109
2110 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2111 csrNeighborRoamContiguousScanRequestCallback);
2112
2113 vos_mem_free( channelList );
2114
2115 if (eHAL_STATUS_SUCCESS != status)
2116 {
2117 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
2118 }
2119
2120 return status;
2121}
2122#endif
2123
Jeff Johnson295189b2012-06-20 16:38:30 -07002124/* ---------------------------------------------------------------------------
2125
2126 \fn csrNeighborRoamNeighborScanTimerCallback
2127
2128 \brief This function is the neighbor scan timer callback function. It invokes
2129 the BG scan request based on the current and previous states
2130
2131 \param pv - CSR timer context info which includes pMac and session ID
2132
2133 \return VOID
2134
2135---------------------------------------------------------------------------*/
2136void csrNeighborRoamNeighborScanTimerCallback(void *pv)
2137{
2138 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
2139 tpAniSirGlobal pMac = pInfo->pMac;
2140 tANI_U32 sessionId = pInfo->sessionId;
2141 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2142
2143 // check if bg scan is on going, no need to send down the new params if true
2144 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2145 {
2146 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002147 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 return;
2149 }
2150
2151 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
2152
2153 switch (pNeighborRoamInfo->neighborRoamState)
2154 {
2155#ifdef WLAN_FEATURE_VOWIFI_11R
2156 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2157 switch(pNeighborRoamInfo->prevNeighborRoamState)
2158 {
2159 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2160 csrNeighborRoamPerformBgScan(pMac);
2161 break;
2162 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002163 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
2165 break;
2166 }
2167 break;
2168#endif /* WLAN_FEATURE_VOWIFI_11R */
2169 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
2170 csrNeighborRoamPerformBgScan(pMac);
2171 break;
2172 default:
2173 break;
2174 }
2175 return;
2176}
2177
Srinivas Girigowdade697412013-02-14 16:31:48 -08002178void csrNeighborRoamEmptyScanRefreshTimerCallback(void *context)
2179{
2180 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2181 tpAniSirGlobal pMac = pInfo->pMac;
2182 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2183 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2184
2185 /* Reset all the variables just as no scan had happened before */
2186 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2187
2188#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2189 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2190 {
2191 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2192 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2193 if (VOS_STATUS_SUCCESS != vosStatus)
2194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002195 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002196 return;
2197 }
2198 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2199 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2200 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2201 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2202 }
2203 else
2204#endif
2205 {
2206 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:empty scan refresh timer expired"));
2207 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2208 if (VOS_STATUS_SUCCESS != vosStatus)
2209 {
2210 return;
2211 }
2212 }
2213 return;
2214}
2215
Jeff Johnson295189b2012-06-20 16:38:30 -07002216/* ---------------------------------------------------------------------------
2217
2218 \fn csrNeighborRoamResultsRefreshTimerCallback
2219
2220 \brief This function is the timer callback function for results refresh timer.
2221 When this is invoked, it is as good as down event received from TL. So,
2222 clear off the roamable AP list and start the scan procedure based on 11R
2223 or non-11R association
2224
2225 \param context - CSR timer context info which includes pMac and session ID
2226
2227 \return VOID
2228
2229---------------------------------------------------------------------------*/
2230void csrNeighborRoamResultsRefreshTimerCallback(void *context)
2231{
2232 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2233 tpAniSirGlobal pMac = pInfo->pMac;
2234 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2235 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2236
2237 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2238
2239 /* Deregister reassoc callback. Ignore return status */
2240 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2241 WLANTL_HO_THRESHOLD_DOWN,
2242 csrNeighborRoamReassocIndCallback,
2243 VOS_MODULE_ID_SME);
2244
2245 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2246 {
2247 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002248 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 }
2250
2251 /* Reset all the variables just as no scan had happened before */
2252 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2253
2254#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2255 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2256 {
2257 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2258 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2259 if (VOS_STATUS_SUCCESS != vosStatus)
2260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002261 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 return;
2263 }
2264 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2265 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2266 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2267 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2268 }
2269 else
2270#endif
2271 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002272 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2274 if (VOS_STATUS_SUCCESS != vosStatus)
2275 {
2276 return;
2277 }
2278 }
2279 return;
2280}
2281
2282#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2283/* ---------------------------------------------------------------------------
2284
2285 \fn csrNeighborRoamIssueNeighborRptRequest
2286
2287 \brief This function is invoked when TL issues a down event and the current assoc
2288 is a 11R association. It invokes SME RRM API to issue the neighbor request to
2289 the currently associated AP with the current SSID
2290
2291 \param pMac - The handle returned by macOpen.
2292
2293 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2294
2295---------------------------------------------------------------------------*/
2296VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
2297{
2298 tRrmNeighborRspCallbackInfo callbackInfo;
2299 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2300 tRrmNeighborReq neighborReq;
2301
2302
2303 neighborReq.no_ssid = 0;
2304
2305 /* Fill in the SSID */
2306 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2307 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2308 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2309
2310 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
2311 callbackInfo.neighborRspCallbackContext = pMac;
2312 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
2313
2314 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
2315}
2316
2317/* ---------------------------------------------------------------------------
2318
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002319 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002320
2321 \brief This function is used to merge two channel list.
2322 NB: If called with outputNumOfChannels == 0, this routines
2323 simply copies the input channel list to the output channel list.
2324
2325 \param pMac - The handle returned by macOpen.
2326 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
2327 \param inputNumOfChannels - The number of additional channels.
2328 \param pOutputChannelList - The place to put the "merged" channel list.
2329 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
2330 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
2331
2332 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2333
2334---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002335VOS_STATUS csrNeighborRoamMergeChannelLists(
2336 tpAniSirGlobal pMac,
2337 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002338 int inputNumOfChannels,
2339 tANI_U8 *pOutputChannelList,
2340 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002341 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002342 )
2343{
2344 int i = 0;
2345 int j = 0;
2346 int numChannels = outputNumOfChannels;
2347
2348 // Check for NULL pointer
2349 if (!pInputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2350
2351 // Check for NULL pointer
2352 if (!pOutputChannelList) return eHAL_STATUS_E_NULL_VALUE;
2353
2354 // Add the "new" channels in the input list to the end of the output list.
2355 for (i = 0; i < inputNumOfChannels; i++)
2356 {
2357 for (j = 0; j < outputNumOfChannels; j++)
2358 {
2359 if (pInputChannelList[i] == pOutputChannelList[j])
2360 break;
2361 }
2362 if (j == outputNumOfChannels)
2363 {
2364 if (pInputChannelList[i])
2365 {
Madan Mohan Koyyalamudif5c368b2012-12-06 13:10:13 -08002366 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002367 "%s: [INFOLOG] Adding extra %d to Neighbor channel list", __func__,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002368 pInputChannelList[i]);
2369 pOutputChannelList[numChannels] = pInputChannelList[i];
2370 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002371 }
2372 }
2373 }
2374
2375 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002376 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002377
2378 return eHAL_STATUS_SUCCESS;
2379}
2380
2381/* ---------------------------------------------------------------------------
2382
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 \fn csrNeighborRoamCreateChanListFromNeighborReport
2384
2385 \brief This function is invoked when neighbor report is received for the
2386 neighbor request. Based on the channels present in the neighbor report,
2387 it generates channel list which will be used in REPORT_SCAN state to
2388 scan for these neighbor APs
2389
2390 \param pMac - The handle returned by macOpen.
2391
2392 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2393
2394---------------------------------------------------------------------------*/
2395VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2396{
2397 tpRrmNeighborReportDesc pNeighborBssDesc;
2398 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002399 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002401#if 0
2402 eHalStatus status = eHAL_STATUS_SUCCESS;
2403#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002404
2405 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2406 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2407
2408 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2409
2410 while (pNeighborBssDesc)
2411 {
2412 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2413
2414 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2415 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2416 pNeighborBssDesc->pNeighborBssDescription->channel;
2417 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2418 (tANI_U8)pNeighborBssDesc->roamScore;
2419 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2420 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2421 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2422
2423 /* Saving the channel list non-redundantly */
2424 if (numChannels > 0)
2425 {
2426 for (i = 0; i < numChannels; i++)
2427 {
2428 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2429 break;
2430 }
2431
2432 }
2433 if (i == numChannels)
2434 {
2435 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2436 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002438 "%s: [INFOLOG] Adding %d to Neighbor channel list", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 pNeighborBssDesc->pNeighborBssDescription->channel);
2440 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2441 numChannels++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 }
2443 }
2444
2445 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2446 }
2447
2448 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2449 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002450#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002452 // we have a union of the IAPP and the already existing list.
2453 status = csrNeighborRoamMergeChannelLists(
2454 pMac,
2455 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2456 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2457 channelList,
2458 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002459 &numChannels );
2460#endif
2461
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2463 }
2464
2465 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002466 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 /* Store the obtained channel list to the Neighbor Control data structure */
2468 if (numChannels)
2469 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2470 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2471 {
2472 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2473 return VOS_STATUS_E_RESOURCES;
2474 }
2475
2476 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2477 channelList, (numChannels) * sizeof(tANI_U8));
2478 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2479 if (numChannels)
2480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002481 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 pNeighborRoamInfo->neighborRoamState);
2483 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
2484 }
2485 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2486 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
2487
2488 return VOS_STATUS_SUCCESS;
2489}
2490
2491/* ---------------------------------------------------------------------------
2492
2493 \fn csrNeighborRoamRRMNeighborReportResult
2494
2495 \brief This function is the neighbor report callback that will be invoked by
2496 SME RRM on receiving a neighbor report or of neighbor report is not
2497 received after timeout. On receiving a valid report, it generates a
2498 channel list from the neighbor report and starts the
2499 neighbor scan timer
2500
2501 \param context - The handle returned by macOpen.
2502 vosStatus - Status of the callback(SUCCESS/FAILURE)
2503
2504 \return VOID
2505
2506---------------------------------------------------------------------------*/
2507void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
2508{
2509 tpAniSirGlobal pMac = PMAC_STRUCT(context);
2510 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2511 eHalStatus status = eHAL_STATUS_SUCCESS;
2512
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002513 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 switch (pNeighborRoamInfo->neighborRoamState)
2515 {
2516 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2517 /* Reset the report pending variable */
2518 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
2519 if (VOS_STATUS_SUCCESS == vosStatus)
2520 {
2521 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
2522 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
2523 if (VOS_STATUS_SUCCESS == vosStatus)
2524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002525 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 }
2527
2528 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2529 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2530
2531 /* Now ready for neighbor scan based on the channel list created */
2532 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2533 what palTimerStart expects */
2534 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2535 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2536 eANI_BOOLEAN_FALSE);
2537 if (eHAL_STATUS_SUCCESS != status)
2538 {
2539 /* Timer start failed.. Should we ASSERT here??? */
2540 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
2541 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2542 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002543 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 return;
2545 }
2546 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2547 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
2548 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2549 }
2550 else
2551 {
2552 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
2553 reach the maxNeighborRetries or receiving a successful neighbor response */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002554 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
2556 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
2557 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
2558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002559 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2561 if (VOS_STATUS_SUCCESS != vosStatus)
2562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002563 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d "), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 return;
2565 }
2566 /* We transitioned to different state now. Reset the Neighbor report retry count */
2567 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2568 }
2569 else
2570 {
2571 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2572 if (VOS_STATUS_SUCCESS != vosStatus)
2573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002574 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 return;
2576 }
2577 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2578 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2579 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2580 }
2581 }
2582 break;
2583 default:
2584 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
2585 break;
2586 }
2587 return;
2588}
2589#endif /* WLAN_FEATURE_VOWIFI_11R */
2590
2591
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002592#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002593tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002594 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002595 tCsrRoamConnectedProfile *pCurProfile,
2596 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002597 tDot11fBeaconIEs *pIes)
2598{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002599 tCsrAuthList authType;
2600 tCsrEncryptionList uCEncryptionType;
2601 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002602 tANI_BOOLEAN fMatch = FALSE;
2603
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002604 authType.numEntries = 1;
2605 authType.authType[0] = pCurProfile->AuthType;
2606 uCEncryptionType.numEntries = 1;
2607 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
2608 mCEncryptionType.numEntries = 1;
2609 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002610
2611 if( pIes )
2612 {
2613 if(pIes->SSID.present)
2614 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002615 fMatch = csrIsSsidMatch( pMac,
2616 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
2617 pIes->SSID.ssid, pIes->SSID.num_ssid,
2618 eANI_BOOLEAN_TRUE );
2619 if(TRUE == fMatch)
2620 {
2621 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
2622 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
2623 return (fMatch);
2624 }
2625 else
2626 {
2627 return (fMatch);
2628 }
2629
2630 }
2631 else
2632 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002633 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002634 }
2635 }
2636 else
2637 {
2638 return FALSE; // Again, treat missing pIes as a non-match.
2639 }
2640}
2641
2642tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
2643 tpAniSirGlobal pMac)
2644{
2645 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2646 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2647 tCsrRoamConnectedProfile *pCurrProfile = NULL;
2648 tCsrRoamConnectedProfile *pPrevProfile = NULL;
2649 tDot11fBeaconIEs *pIes = NULL;
2650 tSirBssDescription *pBssDesc = NULL;
2651 tANI_BOOLEAN fNew = TRUE;
2652
2653 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
2654 {
2655 return (fNew);
2656 }
2657
2658 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2659 if( !pCurrProfile )
2660 {
2661 return (fNew);
2662}
2663
2664 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
2665 if( !pPrevProfile )
2666 {
2667 return (fNew);
2668 }
2669
2670 pBssDesc = pPrevProfile->pBssDesc;
2671 if (pBssDesc)
2672 {
2673 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
2674 pBssDesc, &pIes)) &&
2675 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
2676 {
2677 fNew = FALSE;
2678 }
2679 if (pIes) {
2680 palFreeMemory(pMac->hHdd, pIes);
2681 }
2682 }
2683
2684 if (fNew)
2685 {
2686 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
2687 csrRoamFreeConnectProfile(pMac, pPrevProfile);
2688 csrRoamGetConnectProfile(pMac, sessionId, pPrevProfile);
2689 }
2690 else
2691 {
2692 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
2693 }
2694
2695 return (fNew);
2696}
2697
2698tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
2699 tpAniSirGlobal pMac,
2700 tCsrScanResult *pResult,
2701 tDot11fBeaconIEs *pIes)
2702{
2703 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2704 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2705 tCsrRoamConnectedProfile *pCurProfile = NULL;
2706 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
2707
2708 if( !(pMac->roam.roamSession
2709 && CSR_IS_SESSION_VALID(pMac, sessionId)))
2710 {
2711 return FALSE;
2712 }
2713
2714 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2715
2716 if( !pCurProfile)
2717 {
2718 return FALSE;
2719 }
2720
2721 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002722}
2723
2724/* ---------------------------------------------------------------------------
2725
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002726 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002727
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002728 \brief This function is used to prepare a channel list that is derived from
2729 the list of valid channels and does not include those in the occupied
2730 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002731
2732 \param pMac - The handle returned by macOpen.
2733 \param pInputChannelList - The default channels list.
2734 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002735 \param pOutputChannelList - The place to put the non-occupied channel list.
2736 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002737
2738 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2739
2740---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002741VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002742 tpAniSirGlobal pMac,
2743 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002744 int numOfChannels,
2745 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002746 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002747 )
2748{
2749 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002750 int outputNumOfChannels = 0; // Clear the output number of channels
2751 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
2752 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
2753
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002754 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002755 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002756 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
2757 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002758 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002759 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002760 }
2761 }
2762
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002763 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
2764 "Number of channels in the non-occupied list list=%d"),
2765 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002766
2767 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002768 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002769
2770 return eHAL_STATUS_SUCCESS;
2771}
2772#endif /* FEATURE_WLAN_LFR */
2773
Jeff Johnson295189b2012-06-20 16:38:30 -07002774/* ---------------------------------------------------------------------------
2775
2776 \fn csrNeighborRoamTransitToCFGChanScan
2777
2778 \brief This function is called whenever there is a transition to CFG chan scan
2779 state from any state. It frees up the current channel list and allocates
2780 a new memory for the channels received from CFG item. It then starts the
2781 neighbor scan timer to perform the scan on each channel one by one
2782
2783 \param pMac - The handle returned by macOpen.
2784
2785 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2786
2787---------------------------------------------------------------------------*/
2788VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
2789{
2790 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2791 eHalStatus status = eHAL_STATUS_SUCCESS;
2792 int i = 0;
2793 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002794 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002795 tpCsrChannelInfo currChannelListInfo;
2796
2797 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002798
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002799 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07002800#ifdef FEATURE_WLAN_CCX
2801 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002802 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
2804#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002805 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002807 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002808
2809
2810 /* Free up the channel list and allocate a new memory. This is because we dont know how much
2811 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
2812 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002813 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002815 vos_mem_free(currChannelListInfo->ChannelList);
2816 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002817 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002819
2820 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
2821 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
2822 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002824 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
2825 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002826 status = csrNeighborRoamMergeChannelLists(
2827 pMac,
2828 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
2829 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
2830 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002831 0, //NB: If 0, simply copy the input channel list to the output list.
2832 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002833
2834 currChannelListInfo->ChannelList =
2835 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2836 if (NULL == currChannelListInfo->ChannelList)
2837 {
2838 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2839 return VOS_STATUS_E_RESOURCES;
2840 }
2841
2842 vos_mem_copy(currChannelListInfo->ChannelList,
2843 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002844 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002845#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08002846 else if ((pNeighborRoamInfo->uScanMode == DEFAULT_SCAN) &&
2847 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
2848 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold)))
Srikant Kuppa866893f2012-12-27 17:28:14 -08002849 {
2850 /*
2851 * Trigger a contiguous scan on all channels when the
2852 * RSSI in the lookup DOWN notification is below reassoc
2853 * threshold. This will help us find the best available
2854 * candidate and also update the channel cache.
2855 */
2856 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
2857 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
2858 pNeighborRoamInfo->lookupDOWNRssi,
2859 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
2860
2861 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2862
2863 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2864
2865 /* We are about to start a fresh scan cycle,
2866 * purge non-P2P results from the past */
2867 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
2868
2869 csrNeighborRoamPerformContiguousBgScan(pMac);
2870
2871 /* Transition to CFG_CHAN_LIST_SCAN */
2872 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
2873
2874 return VOS_STATUS_SUCCESS;
2875 }
2876#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002877 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002878 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002879 numOfChannels = pMac->scan.occupiedChannels.numChannels;
2880 if (numOfChannels
2881#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08002882 && ((pNeighborRoamInfo->uScanMode == SPLIT_SCAN_OCCUPIED_LIST) ||
2883 (pNeighborRoamInfo->uEmptyScanCount == 0) ||
2884 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002885#endif
2886 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002888 /*
2889 * Always scan channels in the occupied channel list
2890 * before scanning on the non-occupied list.
2891 */
Srinivas Girigowdade697412013-02-14 16:31:48 -08002892 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Switching to occupied channel list"
2893#ifdef FEATURE_WLAN_LFR
2894 "-uScanMode=%d, uEmptyScanCount=%d",
2895 pNeighborRoamInfo->uScanMode,
2896 pNeighborRoamInfo->uEmptyScanCount
2897#endif
2898 );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002899 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
2900 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels);
2901
2902 if (NULL == currChannelListInfo->ChannelList)
2903 {
2904 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2905 return VOS_STATUS_E_RESOURCES;
2906 }
2907 vos_mem_copy(currChannelListInfo->ChannelList,
2908 pMac->scan.occupiedChannels.channelList,
2909 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002910 }
2911 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002912 {
2913 /* Scan all channels from non-occupied list */
2914 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
2915 numOfChannels = sizeof(pMac->roam.validChannelList);
2916
2917 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2918 (tANI_U8 *)pMac->roam.validChannelList,
2919 (tANI_U32 *) &numOfChannels)))
2920 {
2921#ifdef FEATURE_WLAN_LFR
2922 /*
2923 * Prepare non-occupied channel list (channelList)
2924 * from the actual "valid channel list" information
2925 * formed by CSR.
2926 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302927 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
Srinivas Girigowdade697412013-02-14 16:31:48 -08002928 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
2929 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002930 numOfChannels,
2931 channelList,
2932 &numOfChannels);
2933#else
2934 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
2935 status = csrNeighborRoamMergeChannelLists(
2936 pMac,
2937 (tANI_U8 *)pMac->roam.validChannelList,
2938 numOfChannels, // The number of channels in the validChannelList
2939 channelList,
2940 0, //NB: If 0, simply copy the input channel list to the output list.
2941 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
2942#endif
2943 }
2944 else
2945 {
2946 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002947 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002949 currChannelListInfo->ChannelList =
2950 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2951
2952 if (NULL == currChannelListInfo->ChannelList)
2953 {
2954 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2955 return VOS_STATUS_E_RESOURCES;
2956 }
2957#ifdef FEATURE_WLAN_LFR
2958 vos_mem_copy(currChannelListInfo->ChannelList,
2959 channelList, numOfChannels * sizeof(tANI_U8));
2960#else
2961 vos_mem_copy(currChannelListInfo->ChannelList,
2962 (tANI_U8 *)pMac->roam.validChannelList,
2963 numOfChannels * sizeof(tANI_U8));
2964#endif
2965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 }
2967
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002968 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002969 currChannelListInfo->numOfChannels = numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002970 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
2971 "Number of channels from CFG (or) (non-)occupied list=%d",
2972 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002973 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302975 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002976 "= %d", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 }
2978 }
2979
2980 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2981 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2982
2983 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2984 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2985 what palTimerStart expects */
2986 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2987 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2988 eANI_BOOLEAN_FALSE);
2989
2990 if (eHAL_STATUS_SUCCESS != status)
2991 {
2992 /* Timer start failed.. */
2993 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002994 vos_mem_free(currChannelListInfo->ChannelList);
2995 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002996 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 return VOS_STATUS_E_FAILURE;
2998 }
2999
3000 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
3001 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05303002 /* We are about to start a fresh scan cycle,
3003 * purge non-P2P results from the past */
3004 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
James Zmuda5ba36d02013-03-14 17:39:07 -07003005
3006 /* We are about to start a fresh scan cycle,
3007 * purge failed pre-auth results from the past */
3008 csrNeighborRoamPurgePreauthFailedList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003009
3010 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
3011 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
3012
3013 return VOS_STATUS_SUCCESS;
3014}
3015
3016/* ---------------------------------------------------------------------------
3017
3018 \fn csrNeighborRoamNeighborLookupUpEvent
3019
3020 \brief This function is called as soon as TL indicates that the current AP's
3021 RSSI is better than the neighbor lookup threshold. Here, we transition to
3022 CONNECTED state and reset all the scan parameters
3023
3024 \param pMac - The handle returned by macOpen.
3025
3026 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3027
3028---------------------------------------------------------------------------*/
3029VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
3030{
3031 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3032 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003033 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003034
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 /* Recheck whether the below check is needed. */
3036 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
3037 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Jeff Johnsone7245742012-09-05 17:12:55 -07003038
3039 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
3040 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3041
Jeff Johnson295189b2012-06-20 16:38:30 -07003042
3043 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3044 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
3045 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3046 WLANTL_HO_THRESHOLD_DOWN,
3047 csrNeighborRoamNeighborLookupDOWNCallback,
3048 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003049#ifdef FEATURE_WLAN_LFR
3050 pNeighborRoamInfo->lookupDOWNRssi = 0;
3051#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3053 {
3054 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003055 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 }
3057
3058
3059 return vosStatus;
3060}
3061
3062/* ---------------------------------------------------------------------------
3063
3064 \fn csrNeighborRoamNeighborLookupDownEvent
3065
3066 \brief This function is called as soon as TL indicates that the current AP's
3067 RSSI falls below the current eighbor lookup threshold. Here, we transition to
3068 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
3069 a non-11R association.
3070
3071 \param pMac - The handle returned by macOpen.
3072
3073 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3074
3075---------------------------------------------------------------------------*/
3076VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
3077{
3078 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3079 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3080 eHalStatus status = eHAL_STATUS_SUCCESS;
3081
3082 switch (pNeighborRoamInfo->neighborRoamState)
3083 {
3084 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3085
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003086 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3088 /* De-register Neighbor Lookup threshold callback with TL */
3089 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3090 WLANTL_HO_THRESHOLD_DOWN,
3091 csrNeighborRoamNeighborLookupDOWNCallback,
3092 VOS_MODULE_ID_SME);
3093
3094 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3095 {
3096 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003097 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 }
3099
3100
3101#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
3102 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
3103 {
3104
3105 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
3106 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3107 if (VOS_STATUS_SUCCESS != vosStatus)
3108 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003109 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 return vosStatus;
3111 }
3112 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3113 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3114 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3115 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
3116 }
3117 else
3118#endif
3119 {
3120 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
3121
3122 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3123 if (VOS_STATUS_SUCCESS != vosStatus)
3124 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08003125 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
3126 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 return vosStatus;
3128 }
3129 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003130 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 -07003131 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003132 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
3133 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 WLANTL_HO_THRESHOLD_UP,
3135 csrNeighborRoamNeighborLookupUPCallback,
3136 VOS_MODULE_ID_SME, pMac);
3137 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3138 {
3139 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003140 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 }
3142 break;
3143 default:
3144 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3145 break;
3146
3147 }
3148 return vosStatus;
3149}
3150
3151/* ---------------------------------------------------------------------------
3152
3153 \fn csrNeighborRoamNeighborLookupUPCallback
3154
3155 \brief This function is registered with TL to indicate whenever the RSSI
3156 gets better than the neighborLookup RSSI Threshold
3157
3158 \param pAdapter - VOS Context
3159 trafficStatus - UP/DOWN indication from TL
3160 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3161
3162 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3163
3164---------------------------------------------------------------------------*/
3165VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003166 v_PVOID_t pUserCtxt,
3167 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003168{
3169 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3170 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3171 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3172
Srinivasdaaec712012-12-12 15:59:44 -08003173 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
3174 rssiNotification,
3175 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003176
3177 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003179 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 return VOS_STATUS_SUCCESS;
3181 }
3182
3183 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
3184 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
3185 return vosStatus;
3186}
3187
3188/* ---------------------------------------------------------------------------
3189
3190 \fn csrNeighborRoamNeighborLookupDOWNCallback
3191
3192 \brief This function is registered with TL to indicate whenever the RSSI
3193 falls below the current neighborLookup RSSI Threshold
3194
3195 \param pAdapter - VOS Context
3196 trafficStatus - UP/DOWN indication from TL
3197 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3198
3199 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3200
3201---------------------------------------------------------------------------*/
3202VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003203 v_PVOID_t pUserCtxt,
3204 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003205{
3206 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3207 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3208 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3209
Srinivasdaaec712012-12-12 15:59:44 -08003210 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
3211 rssiNotification,
3212 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003213
Srikant Kuppa866893f2012-12-27 17:28:14 -08003214#ifdef FEATURE_WLAN_LFR
3215 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
3216#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003219 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 return VOS_STATUS_SUCCESS;
3221 }
3222
3223 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
3224 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
3225
3226 return vosStatus;
3227}
3228
3229#ifdef RSSI_HACK
3230extern int dumpCmdRSSI;
3231#endif
3232
3233/* ---------------------------------------------------------------------------
3234
3235 \fn csrNeighborRoamIndicateDisconnect
3236
3237 \brief This function is called by CSR as soon as the station disconnects from
3238 the AP. This function does the necessary cleanup of neighbor roam data
3239 structures. Neighbor roam state transitions to INIT state whenever this
3240 function is called except if the current state is REASSOCIATING
3241
3242 \param pMac - The handle returned by macOpen.
3243 sessionId - CSR session id that got disconnected
3244
3245 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3246
3247---------------------------------------------------------------------------*/
3248eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
3249{
3250 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3251
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003252 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d (sub-state %d)"),
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003253 sessionId, pNeighborRoamInfo->neighborRoamState,
3254 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003255
3256#ifdef FEATURE_WLAN_CCX
3257 {
3258 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
3259 if (pSession->connectedProfile.isCCXAssoc)
3260 {
3261 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
3262 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3263 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
3264 pSession->isPrevApInfoValid = TRUE;
3265 pSession->roamTS1 = vos_timer_get_system_time();
3266
3267 }
3268 }
3269#endif
3270
3271#ifdef RSSI_HACK
3272 dumpCmdRSSI = -40;
3273#endif
3274 switch (pNeighborRoamInfo->neighborRoamState)
3275 {
3276 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3277 // Stop scan and neighbor refresh timers.
3278 // These are indeed not required when we are in reassociating
3279 // state.
3280 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3281 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003282 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003283 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
3284 /*
3285 * Disconnect indication during Disassoc Handoff sub-state
3286 * is received when we are trying to disconnect with the old
3287 * AP during roam. BUT, if receive a disconnect indication
3288 * outside of Disassoc Handoff sub-state, then it means that
3289 * this is a genuine disconnect and we need to clean up.
3290 * Otherwise, we will be stuck in reassoc state which will
3291 * in-turn block scans (see csrIsScanAllowed).
3292 */
3293 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3294 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 break;
3296
3297 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 csrNeighborRoamResetInitStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003299 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 break;
3301
Srikant Kuppa866893f2012-12-27 17:28:14 -08003302 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3303 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3304 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3305 csrNeighborRoamDeregAllRssiIndication(pMac);
3306 break;
3307
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003308 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
3309 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3310 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
3311 csrNeighborRoamDeregAllRssiIndication(pMac);
3312 break;
3313
3314 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3315 /* Stop pre-auth to reassoc interval timer */
3316 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003317 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3318 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3319 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003320 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003321 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003322 csrNeighborRoamDeregAllRssiIndication(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003323 break;
3324
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003326 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
3327 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003329 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 }
3331 return eHAL_STATUS_SUCCESS;
3332}
3333
3334/* ---------------------------------------------------------------------------
3335
3336 \fn csrNeighborRoamIndicateConnect
3337
3338 \brief This function is called by CSR as soon as the station connects to an AP.
3339 This initializes all the necessary data structures related to the
3340 associated AP and transitions the state to CONNECTED state
3341
3342 \param pMac - The handle returned by macOpen.
3343 sessionId - CSR session id that got connected
3344 vosStatus - connect status SUCCESS/FAILURE
3345
3346 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3347
3348---------------------------------------------------------------------------*/
3349eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
3350{
3351 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3352 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07003353 VOS_STATUS vstatus;
3354
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003355#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 int init_ft_flag = FALSE;
3357#endif
3358
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003359 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360
3361 switch (pNeighborRoamInfo->neighborRoamState)
3362 {
3363 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3364 if (VOS_STATUS_SUCCESS != vosStatus)
3365 {
3366 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
3367 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3368 break;
3369 }
3370 /* Fall through if the status is SUCCESS */
3371 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
3372 /* Reset all the data structures here */
3373 csrNeighborRoamResetInitStateControlInfo(pMac);
3374
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003376
3377#ifdef FEATURE_WLAN_LFR
3378 /*
3379 * Initialize the occupied list ONLY if we are
3380 * transitioning from INIT state to CONNECTED state.
3381 */
3382 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
3383 csrInitOccupiedChannelsList(pMac);
3384#endif
3385 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
3386
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
3388 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
3389 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
3390 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3391 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003392 pNeighborRoamInfo->currentNeighborLookupThreshold =
3393 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
3394#ifdef FEATURE_WLAN_LFR
3395 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08003396 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08003397 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003398#endif
3399
Jeff Johnson295189b2012-06-20 16:38:30 -07003400
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003401#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 /* Now we can clear the preauthDone that was saved as we are connected afresh */
3403 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3404#endif
3405
3406#ifdef WLAN_FEATURE_VOWIFI_11R
3407 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003408 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
3409 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 {
3411 if (pMac->roam.configParam.isFastTransitionEnabled)
3412 init_ft_flag = TRUE;
3413 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
3414 }
3415 else
3416 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003417 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418#endif
3419
3420#ifdef FEATURE_WLAN_CCX
3421 // Based on the auth scheme tell if we are 11r
3422 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
3423 {
3424 if (pMac->roam.configParam.isFastTransitionEnabled)
3425 init_ft_flag = TRUE;
3426 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
3427 }
3428 else
3429 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003430 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
3431 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07003432
3433#endif
3434
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003435#ifdef FEATURE_WLAN_LFR
3436 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303437 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003438 {
3439 init_ft_flag = TRUE;
3440 }
3441#endif
3442
3443#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 if ( init_ft_flag == TRUE )
3445 {
3446 /* Initialize all the data structures needed for the 11r FT Preauth */
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3448 csrNeighborRoamPurgePreauthFailedList(pMac);
3449
3450 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
3451 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07003452 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 WLANTL_HO_THRESHOLD_DOWN,
3454 csrNeighborRoamNeighborLookupDOWNCallback,
3455 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003456#ifdef FEATURE_WLAN_LFR
3457 pNeighborRoamInfo->lookupDOWNRssi = 0;
3458#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07003459 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 {
3461 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003462 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vstatus);
Jeff Johnson43971f52012-07-17 12:26:56 -07003463 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 }
3465 }
3466#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 break;
3468 default:
3469 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3470 break;
3471 }
3472 return status;
3473}
3474
3475
3476#ifdef WLAN_FEATURE_VOWIFI_11R
3477/* ---------------------------------------------------------------------------
3478
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 \fn csrNeighborRoamPurgePreauthFailedList
3480
3481 \brief This function purges all the MAC addresses in the pre-auth fail list
3482
3483 \param pMac - The handle returned by macOpen.
3484
3485 \return VOID
3486
3487---------------------------------------------------------------------------*/
3488void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
3489{
3490 tANI_U8 i;
3491
3492 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
3493 {
3494 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
3495 }
3496 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
3497
3498 return;
3499}
3500
3501/* ---------------------------------------------------------------------------
3502
3503 \fn csrNeighborRoamInit11rAssocInfo
3504
3505 \brief This function initializes 11r related neighbor roam data structures
3506
3507 \param pMac - The handle returned by macOpen.
3508
3509 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3510
3511---------------------------------------------------------------------------*/
3512eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
3513{
3514 eHalStatus status;
3515 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
3516
3517 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
3518 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
3519 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
3520 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
3521 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
3522 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
3523
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3525 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3526 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3527 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3528
3529
3530 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
3531 if (eHAL_STATUS_SUCCESS != status)
3532 {
3533 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 return eHAL_STATUS_RESOURCES;
3535 }
3536 return status;
3537}
3538#endif /* WLAN_FEATURE_VOWIFI_11R */
3539
3540/* ---------------------------------------------------------------------------
3541
3542 \fn csrNeighborRoamInit
3543
3544 \brief This function initializes neighbor roam data structures
3545
3546 \param pMac - The handle returned by macOpen.
3547
3548 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3549
3550---------------------------------------------------------------------------*/
3551eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
3552{
3553 eHalStatus status;
3554 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3555
3556 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3557 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3558 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
3559 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
3560 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
3561 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
3562 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
3563 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
3564 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
3565 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
Srinivas Girigowdade697412013-02-14 16:31:48 -08003566 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
3567
3568#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
3569 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = SME_KR_25;
3570 pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList = NULL;
3571 pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels = 0;
3572
3573 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
3574 {
3575 csrInitCountryValidChannelList(pMac, SME_KR_25);
3576 }
3577#endif
3578
3579 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
3581
Srinivas Girigowdade697412013-02-14 16:31:48 -08003582 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3584
3585 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3586 {
3587 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
3588 return eHAL_STATUS_RESOURCES;
3589 }
3590
3591 /* Update the roam global structure from CFG */
Srinivas Girigowdade697412013-02-14 16:31:48 -08003592 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
3594 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3595
3596 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
3597 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003598#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08003599 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003600 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08003601 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003602 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
3603 sizeof(tCsrRoamConnectedProfile));
3604#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
3606
3607 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3608 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3609 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborScanTimer,
3610 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3611
3612 if (eHAL_STATUS_SUCCESS != status)
3613 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08003614 smsLog(pMac, LOGE, FL("Neighbor scan timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3616 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3617 return eHAL_STATUS_RESOURCES;
3618 }
3619
3620 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborResultsRefreshTimer,
3621 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3622
3623 if (eHAL_STATUS_SUCCESS != status)
3624 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08003625 smsLog(pMac, LOGE, FL("Neighbor results refresh timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3627 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3628 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3629 return eHAL_STATUS_RESOURCES;
3630 }
3631
Srinivas Girigowdade697412013-02-14 16:31:48 -08003632 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->emptyScanRefreshTimer,
3633 csrNeighborRoamEmptyScanRefreshTimerCallback,
3634 (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3635
3636 if (eHAL_STATUS_SUCCESS != status)
3637 {
3638 smsLog(pMac, LOGE, FL("Empty scan refresh timer allocation failed"));
3639 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3640 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3641 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3642 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3643 return eHAL_STATUS_RESOURCES;
3644 }
3645
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
3647 if (eHAL_STATUS_SUCCESS != status)
3648 {
3649 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3650 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3651 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3652 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3653 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003654 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 return eHAL_STATUS_RESOURCES;
3656 }
3657
3658 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3659 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3660 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3661 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3662 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3663
3664#ifdef WLAN_FEATURE_VOWIFI_11R
3665 status = csrNeighborRoamInit11rAssocInfo(pMac);
3666 if (eHAL_STATUS_SUCCESS != status)
3667 {
3668 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3669 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3670 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3671 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3672 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003673 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3675 return eHAL_STATUS_RESOURCES;
3676 }
3677#endif
3678 /* Initialize this with the current tick count */
3679 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3680
3681 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3682
3683 return eHAL_STATUS_SUCCESS;
3684}
3685
3686/* ---------------------------------------------------------------------------
3687
3688 \fn csrNeighborRoamClose
3689
3690 \brief This function closes/frees all the neighbor roam data structures
3691
3692 \param pMac - The handle returned by macOpen.
3693
3694 \return VOID
3695
3696---------------------------------------------------------------------------*/
3697void csrNeighborRoamClose(tpAniSirGlobal pMac)
3698{
3699 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3700
3701 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
3702 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07003703 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 return;
3705 }
3706
3707 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3708 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3709
3710 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3711
3712 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
3713 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3714 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3715 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003716 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003717
3718 /* Should free up the nodes in the list before closing the double Linked list */
3719 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
3720 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3721
3722 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3723 {
3724 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3725 }
3726
3727 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3728 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3729 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3730 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3731 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3732 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3733
3734 /* Free the profile.. */
3735 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003736#ifdef FEATURE_WLAN_LFR
Sandeep Pc2b00f62012-12-12 16:44:44 -08003737 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08003738#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003739#ifdef WLAN_FEATURE_VOWIFI_11R
3740 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3742 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3743 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3744 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3745 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3746#endif /* WLAN_FEATURE_VOWIFI_11R */
3747
3748 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
3749
3750 return;
3751}
3752
3753/* ---------------------------------------------------------------------------
3754
3755 \fn csrNeighborRoamRequestHandoff
3756
3757 \brief This function triggers actual switching from one AP to the new AP.
3758 It issues disassociate with reason code as Handoff and CSR as a part of
3759 handling disassoc rsp, issues reassociate to the new AP
3760
3761 \param pMac - The handle returned by macOpen.
3762
3763 \return VOID
3764
3765---------------------------------------------------------------------------*/
3766void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
3767{
3768
3769 tCsrRoamInfo roamInfo;
3770 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3771 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3772 tCsrNeighborRoamBSSInfo handoffNode;
3773 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
3774 tANI_U32 roamId = 0;
3775
3776 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
3777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003778 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 pMac->roam.neighborRoamInfo.neighborRoamState);
3780 return;
3781 }
3782
3783 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3784 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
3785 eSIR_SME_SUCCESS);
3786
3787 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3788 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
3789
3790 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003791 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
3792 FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 handoffNode.pBssDescription->bssId[0],
3794 handoffNode.pBssDescription->bssId[1],
3795 handoffNode.pBssDescription->bssId[2],
3796 handoffNode.pBssDescription->bssId[3],
3797 handoffNode.pBssDescription->bssId[4],
3798 handoffNode.pBssDescription->bssId[5]);
3799
3800 /* Free the profile.. Just to make sure we dont leak memory here */
3801 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
3802 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
3803 This should happen before issuing disconnect */
3804 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
3805 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
3806 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
3807
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003808 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07003809
3810 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
3811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003812 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate");
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 return;
3814 }
3815
3816 //notify HDD for handoff, providing the BSSID too
3817 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
3818
3819 vos_mem_copy(roamInfo.bssid,
3820 handoffNode.pBssDescription->bssId,
3821 sizeof( tCsrBssid ));
3822
3823 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
3824
3825
3826 return;
3827}
3828
3829/* ---------------------------------------------------------------------------
3830
3831 \fn csrNeighborRoamIsHandoffInProgress
3832
3833 \brief This function returns whether handoff is in progress or not based on
3834 the current neighbor roam state
3835
3836 \param pMac - The handle returned by macOpen.
3837 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
3838
3839 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
3840
3841---------------------------------------------------------------------------*/
3842tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
3843{
3844 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
3845 return eANI_BOOLEAN_TRUE;
3846
3847 return eANI_BOOLEAN_FALSE;
3848}
3849
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003850#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07003851/* ---------------------------------------------------------------------------
3852
3853 \fn csrNeighborRoamIs11rAssoc
3854
3855 \brief This function returns whether the current association is a 11r assoc or not
3856
3857 \param pMac - The handle returned by macOpen.
3858
3859 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
3860
3861---------------------------------------------------------------------------*/
3862tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
3863{
3864 return pMac->roam.neighborRoamInfo.is11rAssoc;
3865}
3866#endif /* WLAN_FEATURE_VOWIFI_11R */
3867
3868
3869/* ---------------------------------------------------------------------------
3870
3871 \fn csrNeighborRoamGetHandoffAPInfo
3872
3873 \brief This function returns the best possible AP for handoff. For 11R case, it
3874 returns the 1st entry from pre-auth done list. For non-11r case, it returns
3875 the 1st entry from roamable AP list
3876
3877 \param pMac - The handle returned by macOpen.
3878 pHandoffNode - AP node that is the handoff candidate returned
3879
3880 \return VOID
3881
3882---------------------------------------------------------------------------*/
3883void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
3884{
3885 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3886 tpCsrNeighborRoamBSSInfo pBssNode;
3887
3888 VOS_ASSERT(NULL != pHandoffNode);
3889
3890#ifdef WLAN_FEATURE_VOWIFI_11R
3891 if (pNeighborRoamInfo->is11rAssoc)
3892 {
3893 /* Always the BSS info in the head is the handoff candidate */
3894 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3895 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3896 }
3897 else
3898#endif
3899#ifdef FEATURE_WLAN_CCX
3900 if (pNeighborRoamInfo->isCCXAssoc)
3901 {
3902 /* Always the BSS info in the head is the handoff candidate */
3903 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3904 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3905 }
3906 else
3907#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003908#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303909 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003910 {
3911 /* Always the BSS info in the head is the handoff candidate */
3912 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3913 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3914 }
3915 else
3916#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 {
3918 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
3919 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
3920 }
3921 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
3922
3923 return;
3924}
3925
3926/* ---------------------------------------------------------------------------
3927 \brief This function returns TRUE if preauth is completed
3928
3929 \param pMac - The handle returned by macOpen.
3930
3931 \return boolean
3932
3933---------------------------------------------------------------------------*/
3934tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
3935{
3936 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
3937 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
3938}
3939
3940/* ---------------------------------------------------------------------------
3941 \brief In the event that we are associated with AP1 and we have
3942 completed pre auth with AP2. Then we receive a deauth/disassoc from
3943 AP1.
3944 At this point neighbor roam is in pre auth done state, pre auth timer
3945 is running. We now handle this case by stopping timer and clearing
3946 the pre-auth state. We basically clear up and just go to disconnected
3947 state.
3948
3949 \param pMac - The handle returned by macOpen.
3950
3951 \return boolean
3952---------------------------------------------------------------------------*/
3953void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
3954{
3955 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
3956 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
3957
3958 // Stop timer
3959 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
3960
3961 // Transition to init state
3962 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3963}
3964
Srikant Kuppafef66a72013-01-30 17:32:44 -08003965/* ---------------------------------------------------------------------------
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08003966 \brief This function returns TRUE if background scan triggered by
3967 LFR is in progress.
Srikant Kuppafef66a72013-01-30 17:32:44 -08003968
3969 \param halHandle - The handle from HDD context.
3970
3971 \return boolean
3972
3973---------------------------------------------------------------------------*/
3974tANI_BOOLEAN csrNeighborRoamScanRspPending (tHalHandle hHal)
3975{
3976 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3977 return (pMac->roam.neighborRoamInfo.scanRspPending);
3978}
3979
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08003980/* ---------------------------------------------------------------------------
3981 \brief This function returns TRUE if STA is in the middle of roaming states
3982
3983 \param halHandle - The handle from HDD context.
3984
3985 \return boolean
3986
3987---------------------------------------------------------------------------*/
3988tANI_BOOLEAN csrNeighborMiddleOfRoaming (tHalHandle hHal)
3989{
3990 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3991 tANI_BOOLEAN val = (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3992 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3993 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3994 (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState) ||
3995 (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState);
3996 return (val);
3997}
3998
Jeff Johnson295189b2012-06-20 16:38:30 -07003999#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */