blob: 6b0b2394d0de4aa9a58637863886a0eb92f82afa [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
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
22/*
23 * */
24/** ------------------------------------------------------------------------- *
25 ------------------------------------------------------------------------- *
26
27
28 \file csrNeighborRoam.c
29
30 Implementation for the simple roaming algorithm for 802.11r Fast transitions and Legacy roaming for Android platform.
31
32 Copyright (C) 2010 Qualcomm, Incorporated
33
34
35 ========================================================================== */
36
37/*===========================================================================
38
39 EDIT HISTORY FOR FILE
40
41
42 This section contains comments describing changes made to the module.
43 Notice that changes are listed in reverse chronological order.
44
45
46
47 when who what, where, why
48---------- --- --------------------------------------------------------
4908/01/10 Murali Created
50
51===========================================================================*/
52#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
53#include "wlan_qct_wda.h"
54#include "palApi.h"
55#include "csrInsideApi.h"
56#include "smsDebug.h"
57#include "logDump.h"
58#include "smeQosInternal.h"
59#include "wlan_qct_tl.h"
60#include "smeInside.h"
61#include "vos_diag_core_event.h"
62#include "vos_diag_core_log.h"
63#include "csrApi.h"
64#include "wlan_qct_tl.h"
65#include "sme_Api.h"
66#include "csrNeighborRoam.h"
67#ifdef FEATURE_WLAN_CCX
68#include "csrCcx.h"
69#endif
70
71#define WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG 1
72#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG
73#define NEIGHBOR_ROAM_DEBUG smsLog
74#else
75#define NEIGHBOR_ROAM_DEBUG(x...)
76#endif
77
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -070078static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo);
79static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac);
80static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac);
81static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac);
82
Jeff Johnson295189b2012-06-20 16:38:30 -070083VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
84 v_PVOID_t pUserCtxt);
85VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
86 v_PVOID_t pUserCtxt);
87void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus);
88eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile );
89
90#ifdef WLAN_FEATURE_VOWIFI_11R
91static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac);
92VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac);
93#endif
94
95/* State Transition macro */
96#define CSR_NEIGHBOR_ROAM_STATE_TRANSITION(newState)\
97{\
98 pMac->roam.neighborRoamInfo.prevNeighborRoamState = pMac->roam.neighborRoamInfo.neighborRoamState;\
99 pMac->roam.neighborRoamInfo.neighborRoamState = newState;\
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700100 smsLog(pMac, LOG1, FL("Neighbor Roam Transition from state %d ==> %d"), pMac->roam.neighborRoamInfo.prevNeighborRoamState, newState);\
Jeff Johnson295189b2012-06-20 16:38:30 -0700101}
102
103/* ---------------------------------------------------------------------------
104
105 \fn csrNeighborRoamFreeNeighborRoamBSSNode
106
107 \brief This function frees all the internal pointers CSR NeighborRoam BSS Info
108 and also frees the node itself
109
110 \param pMac - The handle returned by macOpen.
111 neighborRoamBSSNode - Neighbor Roam BSS Node to be freed
112
113 \return VOID
114
115---------------------------------------------------------------------------*/
116void csrNeighborRoamFreeNeighborRoamBSSNode(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo neighborRoamBSSNode)
117{
118 if (neighborRoamBSSNode)
119 {
120 if (neighborRoamBSSNode->pBssDescription)
121 {
122 vos_mem_free(neighborRoamBSSNode->pBssDescription);
123 neighborRoamBSSNode->pBssDescription = NULL;
124 }
125 vos_mem_free(neighborRoamBSSNode);
126 neighborRoamBSSNode = NULL;
127 }
128
129 return;
130}
131
132/* ---------------------------------------------------------------------------
133
134 \fn csrNeighborRoamRemoveRoamableAPListEntry
135
136 \brief This function removes a given entry from the given list
137
138 \param pMac - The handle returned by macOpen.
139 pList - The list from which the entry should be removed
140 pNeighborEntry - Neighbor Roam BSS Node to be removed
141
142 \return TRUE if successfully removed, else FALSE
143
144---------------------------------------------------------------------------*/
145tANI_BOOLEAN csrNeighborRoamRemoveRoamableAPListEntry(tpAniSirGlobal pMac,
146 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
147{
148 if(pList)
149 {
150 return csrLLRemoveEntry(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
151 }
152
153 smsLog(pMac, LOGE, FL("Removing neighbor BSS node from list failed. Current count = %d\n"), csrLLCount(pList));
154
155 return eANI_BOOLEAN_FALSE;
156}
157
158/* ---------------------------------------------------------------------------
159
160 \fn csrNeighborRoamGetRoamableAPListNextEntry
161
162 \brief Gets the entry next to passed entry. If NULL is passed, return the entry in the head of the list
163
164 \param pMac - The handle returned by macOpen.
165 pList - The list from which the entry should be returned
166 pNeighborEntry - Neighbor Roam BSS Node whose next entry should be returned
167
168 \return Neighbor Roam BSS Node to be returned
169
170---------------------------------------------------------------------------*/
171tpCsrNeighborRoamBSSInfo csrNeighborRoamGetRoamableAPListNextEntry(tpAniSirGlobal pMac,
172 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
173{
174 tListElem *pEntry = NULL;
175 tpCsrNeighborRoamBSSInfo pResult = NULL;
176
177 if(pList)
178 {
179 if(NULL == pNeighborEntry)
180 {
181 pEntry = csrLLPeekHead(pList, LL_ACCESS_LOCK);
182 }
183 else
184 {
185 pEntry = csrLLNext(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
186 }
187 if(pEntry)
188 {
189 pResult = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
190 }
191 }
192
193 return pResult;
194}
195
196/* ---------------------------------------------------------------------------
197
198 \fn csrNeighborRoamFreeRoamableBSSList
199
200 \brief Empties and frees all the nodes in the roamable AP list
201
202 \param pMac - The handle returned by macOpen.
203 pList - Neighbor Roam BSS List to be emptied
204
205 \return VOID
206
207---------------------------------------------------------------------------*/
208void csrNeighborRoamFreeRoamableBSSList(tpAniSirGlobal pMac, tDblLinkList *pList)
209{
210 tpCsrNeighborRoamBSSInfo pResult = NULL;
211
Mohit Khanna23863762012-09-11 17:40:09 -0700212 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Emptying the BSS list. Current count = %d\n"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700213
214 /* Pick up the head, remove and free the node till the list becomes empty */
215 while ((pResult = csrNeighborRoamGetRoamableAPListNextEntry(pMac, pList, NULL)) != NULL)
216 {
217 csrNeighborRoamRemoveRoamableAPListEntry(pMac, pList, pResult);
218 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pResult);
219 }
220 return;
221}
222
223/* ---------------------------------------------------------------------------
224
225 \fn csrNeighborRoamReassocIndCallback
226
227 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
228 Directly triggere HO in case of non-11r association
229 In case of 11R association, triggers a pre-auth eventually followed by actual HO
230
231 \param pAdapter - VOS Context
232 trafficStatus - UP/DOWN indication from TL
233 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
234
235 \return VOID
236
237---------------------------------------------------------------------------*/
238VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
239 v_U8_t trafficStatus,
240 v_PVOID_t pUserCtxt)
241{
242 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
243 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
244 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
245
Jeff Johnson295189b2012-06-20 16:38:30 -0700246 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
247
248
249 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
250 WLANTL_HO_THRESHOLD_DOWN,
251 csrNeighborRoamReassocIndCallback,
252 VOS_MODULE_ID_SME);
253
254 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
255 {
256 //err msg
257 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
258 }
259
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800260 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. RSSI = %d"),
261 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
262 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
263 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
264 WLANTL_HO_THRESHOLD_UP,
265 csrNeighborRoamNeighborLookupUPCallback,
266 VOS_MODULE_ID_SME);
Jeff Johnson295189b2012-06-20 16:38:30 -0700267
268 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
269 {
270 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530271 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 }
273
274 /* We dont need to run this timer any more. */
275 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
276
277#ifdef WLAN_FEATURE_VOWIFI_11R
278 if (pNeighborRoamInfo->is11rAssoc)
279 {
280 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
281 {
282 csrNeighborRoamIssuePreauthReq(pMac);
283 }
284 else
285 {
286 smsLog(pMac, LOGE, FL("11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
287 VOS_ASSERT(0);
288 }
289 }
290 else
291#endif
292
293#ifdef FEATURE_WLAN_CCX
294 if (pNeighborRoamInfo->isCCXAssoc)
295 {
296 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
297 {
298 csrNeighborRoamIssuePreauthReq(pMac);
299 }
300 else
301 {
302 smsLog(pMac, LOGE, FL("CCX Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
303 VOS_ASSERT(0);
304 }
305 }
306 else
307#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700308#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +0530309 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700310 {
311 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
312 {
313 csrNeighborRoamIssuePreauthReq(pMac);
314 }
315 else
316 {
317 smsLog(pMac, LOGE, FL("LFR Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
318 VOS_ASSERT(0);
319 }
320 }
321 else
322#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 {
324 if (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pNeighborRoamInfo->neighborRoamState)
325 {
326 csrNeighborRoamRequestHandoff(pMac);
327 }
328 else
329 {
330 smsLog(pMac, LOGE, FL("Non-11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
331 VOS_ASSERT(0);
332 }
333 }
334 return VOS_STATUS_SUCCESS;
335}
336
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700337/*CleanUP Routines*/
338static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
339{
340 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
341 (rChInfo->currentChannelListInfo.numOfChannels))
342 {
343 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
344 rChInfo->currentChannelListInfo.numOfChannels = 0;
345
346 if (rChInfo->currentChannelListInfo.ChannelList)
347 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
348
349 rChInfo->currentChannelListInfo.ChannelList = NULL;
350 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
351 }
352 else
353 {
354 rChInfo->currentChanIndex = 0;
355 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
356 }
357}
358
359static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
360{
361 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
362
363 /* Stop neighbor scan timer */
364 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
365
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700366 /* Stop neighbor scan results refresh timer */
367 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
368
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700369 /* Abort any ongoing scan */
370 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
371 {
372 csrScanAbortMacScan(pMac);
373 }
374 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
375
376 /* Reset roam channel list information */
377 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
378}
379
380static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
381{
382 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
383
384#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
385 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
386 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
387 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId =
388 CSR_SESSION_ID_INVALID;
389 /* Purge pre-auth fail list */
390 csrNeighborRoamPurgePreauthFailedList(pMac);
391#endif
392
393 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
394 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
395#ifdef WLAN_FEATURE_VOWIFI_11R
396 /* Do not free up the preauth done list here */
397 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
398 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
399 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
400 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
401 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
402#endif
403}
404
405static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
406{
407 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
408 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
409
410 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
411 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800412 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700413
414 /* Deregister reassoc callback. Ignore return status */
415 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800416 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700417 WLANTL_HO_THRESHOLD_UP,
418 csrNeighborRoamNeighborLookupUPCallback,
419 VOS_MODULE_ID_SME);
420
421 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
422 {
423 smsLog(pMac, LOGW,
424 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
425 "with TL: Status = %d\n"), vosStatus);
426 }
427
428 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
429 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
430 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
431
432 /* Deregister reassoc callback. Ignore return status */
433 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
434 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
435 WLANTL_HO_THRESHOLD_DOWN,
436 csrNeighborRoamReassocIndCallback,
437 VOS_MODULE_ID_SME);
438
439 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
440 {
441 smsLog(pMac, LOGW,
442 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
443 "TL: Status = %d\n"), vosStatus);
444 }
445
446 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
447 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
448 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
449
450 /* Deregister neighbor lookup callback. Ignore return status */
451 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
452 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
453 WLANTL_HO_THRESHOLD_DOWN,
454 csrNeighborRoamNeighborLookupDOWNCallback,
455 VOS_MODULE_ID_SME);
456
457 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
458 {
459 smsLog(pMac, LOGW,
460 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
461 "with TL: Status = %d\n"), vosStatus);
462 }
463
464 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700465 pNeighborRoamInfo->currentNeighborLookupThreshold =
466 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800467#ifdef FEATURE_WLAN_LFR
468 pNeighborRoamInfo->uEmptyScanCount = 0;
469#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700470}
471
Jeff Johnson295189b2012-06-20 16:38:30 -0700472/* ---------------------------------------------------------------------------
473
474 \fn csrNeighborRoamResetConnectedStateControlInfo
475
476 \brief This function will reset the neighbor roam control info data structures.
477 This function should be invoked whenever we move to CONNECTED state from
478 any state other than INIT state
479
480 \param pMac - The handle returned by macOpen.
481
482 \return VOID
483
484---------------------------------------------------------------------------*/
485void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
486{
487 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
488
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700489 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700491
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700492 /* We dont need to run this timer any more. */
493 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700494
495#ifdef WLAN_FEATURE_VOWIFI_11R
496 /* Do not free up the preauth done list here */
497 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
498 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
499 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
500 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
501 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
502 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
503 palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
504#endif
505
506}
507
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700508void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700509{
510 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
512 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
513 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
514 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700515#ifdef FEATURE_WLAN_CCX
516 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
517 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
518 pNeighborRoamInfo->MinQBssLoadRequired = 0;
519#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700520
521 /* Stop scan refresh timer */
522 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700523 /* Purge roamable AP list */
524 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 return;
526}
527
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700528/* ---------------------------------------------------------------------------
529
530 \fn csrNeighborRoamResetInitStateControlInfo
531
532 \brief This function will reset the neighbor roam control info data structures.
533 This function should be invoked whenever we move to CONNECTED state from
534 INIT state
535
536 \param pMac - The handle returned by macOpen.
537
538 \return VOID
539
540---------------------------------------------------------------------------*/
541void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
542{
543 csrNeighborRoamResetConnectedStateControlInfo(pMac);
544
545 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
546 csrNeighborRoamResetReportScanStateControlInfo(pMac);
547}
548
549
550
Jeff Johnson295189b2012-06-20 16:38:30 -0700551#ifdef WLAN_FEATURE_VOWIFI_11R
552/* ---------------------------------------------------------------------------
553
554 \fn csrNeighborRoamBssIdScanFilter
555
556 \brief This API is used to prepare a filter to obtain scan results when
557 we complete the scan in the REPORT_SCAN state after receiving a
558 valid neighbor report from AP. This filter includes BSSIDs received from
559 the neighbor report from the AP in addition to the other filter parameters
560 created from connected profile
561
562 \param pMac - The handle returned by macOpen.
563 pScanFilter - Scan filter to be filled and returned
564
565 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
566 code otherwise
567
568---------------------------------------------------------------------------*/
569static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
570{
571 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
572 tANI_U8 i = 0;
573
574 VOS_ASSERT(pScanFilter != NULL);
575 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
576
577 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
578 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
579 if (NULL == pScanFilter->BSSIDs.bssid)
580 {
581 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
582 return eHAL_STATUS_FAILED_ALLOC;
583 }
584
585 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
586
587 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
588 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
589 {
590 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
591 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
592 }
593
594 /* Fill other general scan filter params */
595 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
596}
597
598/* ---------------------------------------------------------------------------
599
600 \fn csrNeighborRoamPurgePreauthFailList
601
602 \brief This function empties the preauth fail list
603
604 \param pMac - The handle returned by macOpen.
605
606 \return VOID
607
608---------------------------------------------------------------------------*/
609void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
610{
611 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
612
613 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
614 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
615 {
616 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
617 sizeof(tSirMacAddr));
618 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
619 }
620 return;
621}
622
623/* ---------------------------------------------------------------------------
624
625 \fn csrNeighborRoamAddBssIdToPreauthFailList
626
627 \brief This function adds the given BSSID to the Preauth fail list
628
629 \param pMac - The handle returned by macOpen.
630 bssId - BSSID to be added to the preauth fail list
631
632 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
633
634---------------------------------------------------------------------------*/
635eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
636{
637 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
638
639 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL(" Added BSSID %02x:%02x:%02x:%02x:%02x:%02x to Preauth failed list\n"),
640 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
641
642
643 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
644 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
645 {
646 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
647 return eHAL_STATUS_FAILURE;
648 }
649 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
650 bssId, sizeof(tSirMacAddr));
651 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
652
653 return eHAL_STATUS_SUCCESS;
654}
655
656/* ---------------------------------------------------------------------------
657
658 \fn csrNeighborRoamIsPreauthCandidate
659
660 \brief This function checks whether the given MAC address is already
661 present in the preauth fail list and returns TRUE/FALSE accordingly
662
663 \param pMac - The handle returned by macOpen.
664
665 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
666
667---------------------------------------------------------------------------*/
668tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
669{
670 tANI_U8 i = 0;
671 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
672
673 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
674 return eANI_BOOLEAN_TRUE;
675
676 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
677 {
678 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
679 bssId, sizeof(tSirMacAddr)))
680 {
681 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
682 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
683 return eANI_BOOLEAN_FALSE;
684 }
685 }
686
687 return eANI_BOOLEAN_TRUE;
688}
689
690/* ---------------------------------------------------------------------------
691
692 \fn csrNeighborRoamIssuePreauthReq
693
694 \brief This function issues preauth request to PE with the 1st AP entry in the
695 roamable AP list
696
697 \param pMac - The handle returned by macOpen.
698
699 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
700
701---------------------------------------------------------------------------*/
702static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
703{
704 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
705 eHalStatus status = eHAL_STATUS_SUCCESS;
706 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
707
708 /* This must not be true here */
709 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
710
711 /* Issue Preauth request to PE here */
712 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
713 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
714 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
715 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
716
717 if (NULL == pNeighborBssNode)
718 {
719 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
720 return eHAL_STATUS_FAILURE;
721 }
722 else
723 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700724 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
725 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530726
727 smsLog(pMac, LOGE, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x %d"),
728 pNeighborBssNode->pBssDescription->bssId[0],
729 pNeighborBssNode->pBssDescription->bssId[1],
730 pNeighborBssNode->pBssDescription->bssId[2],
731 pNeighborBssNode->pBssDescription->bssId[3],
732 pNeighborBssNode->pBssDescription->bssId[4],
733 pNeighborBssNode->pBssDescription->bssId[5]);
734 smsLog(pMac, LOGE, FL("Before Pre-Auth: Channel %d\n"), (int)pNeighborBssNode->pBssDescription->channelId);
735
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 if (eHAL_STATUS_SUCCESS != status)
737 {
738 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d\n"), status);
739 return status;
740 }
741 }
742
743 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
744
745 /* Increment the preauth retry count */
746 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
747
748 /* Transition the state to preauthenticating */
749 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700750#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 /* Start the preauth rsp timer */
752 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer,
753 CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
754 eANI_BOOLEAN_FALSE);
755 if (eHAL_STATUS_SUCCESS != status)
756 {
757 smsLog(pMac, LOGE, FL("Preauth response wait timer start failed with status %d\n"), status);
758 return status;
759 }
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700760#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
762 return status;
763}
764
765/* ---------------------------------------------------------------------------
766
767 \fn csrNeighborRoamPreauthRspHandler
768
769 \brief This function handle the Preauth response from PE
770 Every preauth is allowed max 3 tries if it fails. If a bssid failed
771 for more than MAX_TRIES, we will remove it from the list and try
772 with the next node in the roamable AP list and add the BSSID to pre-auth failed
773 list. If no more entries present in
774 roamable AP list, transition to REPORT_SCAN state
775
776 \param pMac - The handle returned by macOpen.
777 vosStatus - VOS_STATUS_SUCCESS/FAILURE/TIMEOUT status from PE
778
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700779 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
780 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -0700781
782---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700783eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, VOS_STATUS vosStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -0700784{
785 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
786 eHalStatus status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700787 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700789
790 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
791 {
792
793 /* This can happen when we disconnect immediately
794 * after sending a pre-auth request. During processing
795 * of the disconnect command, we would have reset
796 * preauthRspPending and transitioned to INIT state.
797 */
798 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
799 FL("Unexpected pre-auth response in state %d\n"),
800 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700801 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700802 goto DEQ_PREAUTH;
803 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700804
805 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
807 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
808 {
Madan Mohan Koyyalamudi8186a9e2012-10-11 14:23:43 -0700809 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d\n"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700810 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700811 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700812 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 }
814
815 if (VOS_STATUS_E_TIMEOUT != vosStatus)
816 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700817#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 /* This means we got the response from PE. Hence stop the timer */
819 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimer);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
822 }
823
824 if (VOS_STATUS_SUCCESS == vosStatus)
825 {
826 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
827 }
828 if ((VOS_STATUS_SUCCESS == vosStatus) && (NULL != pPreauthRspNode))
829 {
830 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
831
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530832 smsLog(pMac, LOGE, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x\n"),
833 pPreauthRspNode->pBssDescription->bssId[0],
834 pPreauthRspNode->pBssDescription->bssId[1],
835 pPreauthRspNode->pBssDescription->bssId[2],
836 pPreauthRspNode->pBssDescription->bssId[3],
837 pPreauthRspNode->pBssDescription->bssId[4],
838 pPreauthRspNode->pBssDescription->bssId[5]);
839 smsLog(pMac, LOGE, FL("After Pre-Auth: Channel %d\n"), (int)pPreauthRspNode->pBssDescription->channelId);
840
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
842 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
843 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
844
845 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
846 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
847 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
848
849 /* The caller of this function would start a timer and by the time it expires, supplicant should
850 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
851 }
852 else
853 {
854 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
855 tListElem *pEntry;
856
857 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = %d\n"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, vosStatus);
858
859 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
860 if (pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >= CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES)
861 {
862 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
863 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
864
865 /* The one in the head of the list should be one with which we issued pre-auth and failed */
866 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
867 if(pEntry)
868 {
869 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
870 /* Add the BSSID to pre-auth fail list */
871 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
872 /* Now we can free this node */
873 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
874 }
875 }
876
877 /* Issue preauth request for the same/next entry */
878 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700879 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700880
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800881 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
882
883 /* Register Neighbor Lookup threshold callback with TL for UP event now */
884 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
885 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
886
887 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
888 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
889 WLANTL_HO_THRESHOLD_UP,
890 csrNeighborRoamNeighborLookupUPCallback,
891 VOS_MODULE_ID_SME, pMac);
892 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
893 {
894 //err msg
895 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
896 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700897
898 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
899 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
900 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
901 eANI_BOOLEAN_FALSE);
902 if (eHAL_STATUS_SUCCESS != status)
903 {
904 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 }
906 }
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700907
908DEQ_PREAUTH:
909 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -0700910 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700911}
912#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
913
914/* ---------------------------------------------------------------------------
915
916 \fn csrNeighborRoamPrepareScanProfileFilter
917
918 \brief This function creates a scan filter based on the currently connected profile.
919 Based on this filter, scan results are obtained
920
921 \param pMac - The handle returned by macOpen.
922 pScanFilter - Populated scan filter based on the connected profile
923
924 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
925
926---------------------------------------------------------------------------*/
927eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
928{
929 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
930 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
931 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
932 tANI_U8 i = 0;
933
934 VOS_ASSERT(pScanFilter != NULL);
935
936 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
937
938 /* We dont want to set BSSID based Filter */
939 pScanFilter->BSSIDs.numOfBSSIDs = 0;
940
941 /* Populate all the information from the connected profile */
942 pScanFilter->SSIDs.numOfSSIDs = 1;
943 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
944 if (NULL == pScanFilter->SSIDs.SSIDList)
945 {
946 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
947 return eHAL_STATUS_FAILED_ALLOC;
948 }
949 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
950 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
951 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
952 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
953
954 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering for SSID %s from scan results.. SSID Length = %d\n"),
955 pScanFilter->SSIDs.SSIDList->SSID.ssId, pScanFilter->SSIDs.SSIDList->SSID.length);
956 pScanFilter->authType.numEntries = 1;
957 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
958
959 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
960 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
961
962 pScanFilter->mcEncryptionType.numEntries = 1;
963 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
964
965 pScanFilter->BSSType = pCurProfile->BSSType;
966
967 /* We are intrested only in the scan results on channels that we scanned */
968 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
969 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
970 if (NULL == pScanFilter->ChannelInfo.ChannelList)
971 {
972 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
973 vos_mem_free(pScanFilter->SSIDs.SSIDList);
974 pScanFilter->SSIDs.SSIDList = NULL;
975 return eHAL_STATUS_FAILED_ALLOC;
976 }
977 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
978 {
979 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
980 }
981
982#ifdef WLAN_FEATURE_VOWIFI_11R
983 if (pNeighborRoamInfo->is11rAssoc)
984 {
985 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
986 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
987 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
988 }
989#endif
990
991 return eHAL_STATUS_SUCCESS;
992}
993
Jeff Johnson43971f52012-07-17 12:26:56 -0700994tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
995{
996 tCsrScanResultInfo *pScanResult;
997 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
998 tANI_U32 CurrAPRssi = -125; /* We are setting this as default value to make sure we return this value,
999 when we do not see this AP in the scan result for some reason.However,it is
1000 less likely that we are associated to an AP and do not see it in the scan list*/
1001
1002 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1003 {
1004
1005 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1006 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1007 {
1008 /* We got a match with the currently associated AP.
1009 * Capture the RSSI value and complete the while loop.
1010 * The while loop is completed in order to make the current entry go back to NULL,
1011 * and in the next while loop, it properly starts searching from the head of the list.
1012 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1013
1014 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1015
1016 } else {
1017 continue;
1018 }
1019 }
1020
1021 return CurrAPRssi;
1022
1023}
1024
Jeff Johnson295189b2012-06-20 16:38:30 -07001025/* ---------------------------------------------------------------------------
1026
1027 \fn csrNeighborRoamProcessScanResults
1028
1029 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1030 Assumed that the results are already sorted by RSSI by csrScanGetResult
1031
1032 \param pMac - The handle returned by macOpen.
1033 pScanResultList - Scan result result obtained from csrScanGetResult()
1034
1035 \return VOID
1036
1037---------------------------------------------------------------------------*/
1038
1039static void csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1040{
1041 tCsrScanResultInfo *pScanResult;
1042 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1043 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001044 tANI_U32 CurrAPRssi;
1045 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1046
1047 /***************************************************************
1048 * Find out the Current AP RSSI and keep it handy to check if
1049 * it is better than the RSSI of the AP which we are
1050 * going to roam.If so, we are going to continue with the
1051 * current AP.
1052 ***************************************************************/
1053 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001054
1055 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1056 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1057 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1058 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1059 /* 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
1060 and rssi score are in the same order. This will be taken care later */
1061
1062 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1063 {
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001064 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1065 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d)"),
1066 pScanResult->BssDescriptor.bssId[0],
1067 pScanResult->BssDescriptor.bssId[1],
1068 pScanResult->BssDescriptor.bssId[2],
1069 pScanResult->BssDescriptor.bssId[3],
1070 pScanResult->BssDescriptor.bssId[4],
1071 pScanResult->BssDescriptor.bssId[5],
1072 abs(pScanResult->BssDescriptor.rssi));
Jeff Johnson295189b2012-06-20 16:38:30 -07001073
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001074 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1076 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001077 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001078 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1079 "SKIP-currently associated AP\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 continue;
1081 }
1082
Jeff Johnson43971f52012-07-17 12:26:56 -07001083 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1084 * is disabled and we continue to roam without any check*/
1085 if(RoamRssiDiff > 0)
1086 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001087 /*
1088 * If RSSI is lower than the lookup threshold, then continue.
1089 */
1090 if (abs(pScanResult->BssDescriptor.rssi) >
1091 pNeighborRoamInfo->currentNeighborLookupThreshold)
1092 {
1093 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1094 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)\n",
1095 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1096 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1097 continue;
1098 }
1099
Jeff Johnson43971f52012-07-17 12:26:56 -07001100 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1101 {
1102 /*Do not roam to an AP with worse RSSI than the current*/
1103 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1104 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d\n", __func__,
1105 CurrAPRssi,
1106 (int)pScanResult->BssDescriptor.rssi * (-1) );
1107 continue;
1108 } else {
1109 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1110 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1111 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1112 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001113 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1114 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d\n", __func__,
1115 CurrAPRssi,
1116 (int)pScanResult->BssDescriptor.rssi * (-1),
1117 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001118 continue;
1119 }
1120 else {
1121 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1122 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d\n", __func__,
1123 CurrAPRssi,
1124 (int)pScanResult->BssDescriptor.rssi * (-1) );
1125 }
1126 }
1127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001128
1129#ifdef WLAN_FEATURE_VOWIFI_11R
1130 if (pNeighborRoamInfo->is11rAssoc)
1131 {
1132 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1133 {
1134 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1135 continue;
1136 }
1137 }
1138#endif /* WLAN_FEATURE_VOWIFI_11R */
1139
1140#ifdef FEATURE_WLAN_CCX
1141 if (pNeighborRoamInfo->isCCXAssoc)
1142 {
1143 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1144 {
1145 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1146 continue;
1147 }
1148 }
1149 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1150 (pScanResult->BssDescriptor.QBSSLoad_avail))
1151 {
1152 if (pNeighborRoamInfo->isVOAdmitted)
1153 {
1154 smsLog(pMac, LOG1, FL("New AP has %x BW available\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1155 smsLog(pMac, LOG1, FL("We need %x BW available\n"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
1156 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1157 {
1158 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1159 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list\n",
1160 pScanResult->BssDescriptor.bssId[0],
1161 pScanResult->BssDescriptor.bssId[1],
1162 pScanResult->BssDescriptor.bssId[2],
1163 pScanResult->BssDescriptor.bssId[3],
1164 pScanResult->BssDescriptor.bssId[4],
1165 pScanResult->BssDescriptor.bssId[5]);
1166 continue;
1167 }
1168 }
1169 }
1170 else
1171 {
1172 smsLog(pMac, LOGE, FL("No QBss %x %x\n"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
1173 if (pNeighborRoamInfo->isVOAdmitted)
1174 {
1175 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1176 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no QBSSLoad IE, ignoring..not adding to roam list\n",
1177 pScanResult->BssDescriptor.bssId[0],
1178 pScanResult->BssDescriptor.bssId[1],
1179 pScanResult->BssDescriptor.bssId[2],
1180 pScanResult->BssDescriptor.bssId[3],
1181 pScanResult->BssDescriptor.bssId[4],
1182 pScanResult->BssDescriptor.bssId[5]);
1183 continue;
1184 }
1185 }
1186#endif /* FEATURE_WLAN_CCX */
1187
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001188#ifdef FEATURE_WLAN_LFR
1189 // If we are supporting legacy roaming, and
1190 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301191 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001192 {
1193 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1194 {
1195 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1196 continue;
1197 }
1198 }
1199#endif /* FEATURE_WLAN_LFR */
1200
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1202 * this result */
1203 if (pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1204 {
1205 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1206 continue;
1207 }
1208
1209 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1210 if (NULL == pBssInfo)
1211 {
1212 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1213 continue;
1214 }
1215
1216 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1217 if (pBssInfo->pBssDescription != NULL)
1218 {
1219 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1220 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1221 }
1222 else
1223 {
1224 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1225 vos_mem_free(pBssInfo);
1226 continue;
1227
1228 }
1229 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1230
1231 /* Just add to the end of the list as it is already sorted by RSSI */
1232 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
1233 }
1234
1235 /* 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 */
1236 csrScanResultPurge(pMac, *pScanResultList);
1237
1238 return;
1239}
1240
1241/* ---------------------------------------------------------------------------
1242
1243 \fn csrNeighborRoamHandleEmptyScanResult
1244
1245 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1246 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001247 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001249 1. Stop the neighbor scan timer.
1250 2a. If this is the first time we encountered empty scan, then
1251 re-register with TL with modified lookup threshold.
1252 2b. Else if this is the second time we encountered empty scan,
1253 then start neighbor scan results refresh timer (20s).
1254 2c. Else, nothing more to do.
1255 NOTE: In LFR, channels selected for scanning is dervied from
1256 the occuped channel list. Scan cycle following one which
1257 yielded empty results is split into two halves: (i) scan on
1258 channels in the occupied list, and (ii) scan on channels not
1259 in the occupied list. This helps converging faster (while
1260 looking for candidates in the occupied list first), and also,
1261 adds channels to the occupied channel list upon finding candidates
1262 matching SSID profile of interest.
1263
1264 uEmptyScanCount Comments
1265 eFirstEmptyScan Previous scan was done on channels in the
1266 occupied list and yielded potential candidates.
1267 This scan cycle was likely triggered through
1268 receipt of lookup DOWN notification event.
1269 eSecondEmptyScan Previous scan was done on channels in the
1270 occupied list and yielded no candidates. This scan
1271 cycle was triggered through RSSI notification
1272 with modified lookup threshold.
1273 eThirdEmptyScan Previous scan was done on channels NOT in
1274 the occupied list and yielded no candidates. This
1275 scan cycle was triggered immediately after scanning
1276 channels in the occupied list and no candidates
1277 were found.
1278 eFourthEmptyScan Previous scan was done on channels in the
1279 occupied list and yielded no candidates. This scan
1280 cycle was triggered upon expiry of
1281 neighborScanResultsRefreshPeriod (=20s).
1282 eFifthEmptyScan Previous scan was done on channels NOT in
1283 the occupied list and yielded no candidates. This
1284 scan cycle was triggered immediately after scanning
1285 channels in the occupied list and no candidates
1286 were found.
1287
1288 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001289
1290 \param pMac - The handle returned by macOpen.
1291
1292 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1293
1294---------------------------------------------------------------------------*/
1295static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1296{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001297 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1299 eHalStatus status = eHAL_STATUS_SUCCESS;
1300
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001301 /* Stop neighbor scan timer */
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001303 if (eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 {
1305 smsLog(pMac, LOGW, FL(" palTimerStop failed with status %d\n"), status);
1306 }
1307
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001308 /*
1309 * Increase the neighbor lookup threshold by 3 dB
1310 * after every scan cycle. NOTE: uEmptyScanCount
1311 * would be either 1, 3 or 5 at the end of every
1312 * scan cycle.
1313 */
1314#ifdef FEATURE_WLAN_LFR
1315 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1316 {
1317 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1318 }
1319#endif
1320 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1321 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1322#ifdef FEATURE_WLAN_LFR
1323 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1324#endif
1325 )
1326 {
1327 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1328 }
1329
Jeff Johnson295189b2012-06-20 16:38:30 -07001330#ifdef WLAN_FEATURE_VOWIFI_11R
1331 /* Clear off the old neighbor report details */
1332 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1333#endif
1334
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001335#ifdef FEATURE_WLAN_LFR
1336 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1337 {
1338#endif
1339 /* Empty scan results for the first time */
1340 /* Transition to CONNECTED state */
1341 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1342
1343 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1344 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1345
1346 /* Re-register neighbor lookup DOWN threshold callback with TL */
1347 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1348 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1349 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1350
1351 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1352 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1353 WLANTL_HO_THRESHOLD_DOWN,
1354 csrNeighborRoamNeighborLookupDOWNCallback,
1355 VOS_MODULE_ID_SME, pMac);
1356
1357 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1358 {
1359 smsLog(pMac, LOGW,
1360 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
1361 " with TL: Status = %d\n"), status);
1362 }
1363#ifdef FEATURE_WLAN_LFR
1364 }
1365 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1366 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1367 {
1368 /* Empty scan results for the second or fourth time */
1369 /* Transition to CONNECTED state */
1370 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1371
1372 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1373 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1374
1375 /* Immediately scan on channels in non-occupied list */
1376 csrNeighborRoamTransitToCFGChanScan(pMac);
1377 }
1378 else if (pNeighborRoamInfo->uEmptyScanCount == eThirdEmptyScan)
1379 {
1380 /* Empty scan results for the third time */
1381 /* Remain in eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN */
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001382 /* Start neighbor scan results refresh timer */
1383 if (eHAL_STATUS_SUCCESS !=
1384 palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001385 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001386 eANI_BOOLEAN_FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001388 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1389 status);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001390 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1391 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001392 vosStatus = VOS_STATUS_E_FAILURE;
1393 }
1394 else
1395 {
1396 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1397 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001400 else
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001401 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001402 /* Do nothing */
1403 /* Transition to CONNECTED state */
1404 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1405
1406 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1407 csrNeighborRoamResetConnectedStateControlInfo(pMac);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001408 }
1409
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001410 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d",
1411 pNeighborRoamInfo->uEmptyScanCount);
1412#endif
1413 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001414}
1415
1416/* ---------------------------------------------------------------------------
1417
1418 \fn csrNeighborRoamScanRequestCallback
1419
1420 \brief This function is the callback function registered in csrScanRequest() to
1421 indicate the completion of scan. If scan is completed for all the channels in
1422 the channel list, this function gets the scan result and starts the refresh results
1423 timer to avoid having stale results. If scan is not completed on all the channels,
1424 it restarts the neighbor scan timer which on expiry issues scan on the next
1425 channel
1426
1427 \param halHandle - The handle returned by macOpen.
1428 pContext - not used
1429 scanId - not used
1430 status - not used
1431
1432 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1433
1434---------------------------------------------------------------------------*/
1435static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
1436 tANI_U32 scanId, eCsrScanStatus status)
1437{
1438 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
1439 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1440 tANI_U8 currentChanIndex;
1441 tCsrScanResultFilter scanFilter;
1442 tScanResultHandle scanResult;
1443 tANI_U32 tempVal = 0;
Jeff Johnson43971f52012-07-17 12:26:56 -07001444 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001445
1446 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
1447
1448 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
1449 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
1450 {
1451 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
1452 return eHAL_STATUS_SUCCESS;
1453 }
1454
1455 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
1456 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
1457
1458 /* Validate inputs */
1459 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
1460 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
1461 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
1462 }
1463 else
1464 {
1465 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
1466 return eHAL_STATUS_SUCCESS;
1467 }
1468
1469 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1470 {
1471 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
1472 just to get the results and perform PREAUTH */
1473 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
1474 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
1475 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
1476 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
1477
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001478#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1480 should use the BSSID filter made out of neighbor reports */
1481 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1482 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001483 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1484 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 -07001485 tempVal = 1;
1486 }
1487 else
1488#endif
1489 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001490 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1491 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 -07001492 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001493 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 {
1495 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1496 return eHAL_STATUS_FAILURE;
1497 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001498 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301499 if (hstatus != eHAL_STATUS_SUCCESS)
1500 {
1501 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 /* Process the scan results and update roamable AP list */
1504 csrNeighborRoamProcessScanResults(pMac, &scanResult);
1505
1506 /* Free the scan filter */
1507 csrFreeScanFilter(pMac, &scanFilter);
1508
1509 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1510
1511 switch(pNeighborRoamInfo->neighborRoamState)
1512 {
1513 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1514 if (tempVal)
1515 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001516#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001517 /*
1518 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001519 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001520 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001521 pNeighborRoamInfo->uEmptyScanCount = 0;
1522#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001523#ifdef WLAN_FEATURE_VOWIFI_11R
1524 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1525 APs in the roamable AP list */
1526 if (pNeighborRoamInfo->is11rAssoc)
1527 {
1528 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1529 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1530 }
1531 else
1532#endif
1533#ifdef FEATURE_WLAN_CCX
1534 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1535 APs in the roamable AP list */
1536 if (pNeighborRoamInfo->isCCXAssoc)
1537 {
1538 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1539 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1540 }
1541 else
1542#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001543#ifdef FEATURE_WLAN_LFR
1544 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1545 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301546 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001547 {
1548 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1549 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1550 }
1551 else
1552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 {
1554
1555 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1556 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1557 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1558 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1559 within certain duration */
1560
1561// palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
1562 }
1563 }
1564 else
1565 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001566 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1567 /* Handle it appropriately */
1568 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 }
1570 break;
1571#ifdef WLAN_FEATURE_VOWIFI_11R
1572 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1573 if (!tempVal)
1574 {
1575 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1576 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1577 csrNeighborRoamTransitToCFGChanScan(pMac);
1578 }
1579 break;
1580#endif /* WLAN_FEATURE_VOWIFI_11R */
1581 default:
1582 // Can come only in INIT state. Where in we are associated, we sent scan and user
1583 // in the meantime decides to disassoc, we will be in init state and still received call
1584 // back issued. Should not come here in any other state, printing just in case
1585 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1586 "%s: [INFOLOG] State %d\n", __func__, (pNeighborRoamInfo->neighborRoamState));
1587
1588 // Lets just exit out silently.
1589 return eHAL_STATUS_SUCCESS;
1590 }
1591
1592 if (tempVal)
1593 {
1594 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1595
1596 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
1597 * that the callback getting called immediately and the timer would never be stopped when pre-auth is in progress */
1598 if (eHAL_STATUS_SUCCESS != palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1599 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1600 eANI_BOOLEAN_FALSE))
1601 {
1602 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), status);
1603 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1604 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001605 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001607
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
1609 /* Register a reassoc Indication callback */
1610 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
1611 WLANTL_HO_THRESHOLD_DOWN,
1612 csrNeighborRoamReassocIndCallback,
1613 VOS_MODULE_ID_SME, pMac);
1614
1615 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1616 {
1617 //err msg
1618 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
1619 }
1620
1621 }
1622 }
1623 else
1624 {
1625
1626 /* Restart the timer for the next scan sequence as scanning is not over */
Jeff Johnson43971f52012-07-17 12:26:56 -07001627 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
1629 eANI_BOOLEAN_FALSE);
1630
Jeff Johnson43971f52012-07-17 12:26:56 -07001631 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 {
1633 /* Timer start failed.. Should we ASSERT here??? */
1634 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
1635 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1636 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Jeff Johnson43971f52012-07-17 12:26:56 -07001637 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 }
1639 }
1640 return eHAL_STATUS_SUCCESS;
1641}
1642
1643/* ---------------------------------------------------------------------------
1644
1645 \fn csrNeighborRoamIssueBgScanRequest
1646
1647 \brief This function issues CSR scan request after populating all the BG scan params
1648 passed
1649
1650 \param pMac - The handle returned by macOpen.
1651 pBgScanParams - Params that need to be populated into csr Scan request
1652
1653 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1654
1655---------------------------------------------------------------------------*/
1656eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac, tCsrBGScanRequest *pBgScanParams)
1657{
1658 eHalStatus status = eHAL_STATUS_SUCCESS;
1659 tANI_U32 scanId;
1660 tCsrScanRequest scanReq;
1661 tANI_U8 channel;
1662
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301663 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamIssueBgScanRequest for Channel = %d, ChanIndex = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 pBgScanParams->ChannelInfo.ChannelList[0], pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
1665
1666
1667 //send down the scan req for 1 channel on the associated SSID
1668 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
1669 /* Fill in the SSID Info */
1670 scanReq.SSIDs.numOfSSIDs = 1;
1671 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1672 if(NULL == scanReq.SSIDs.SSIDList)
1673 {
1674 //err msg
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301675 smsLog(pMac, LOGE, FL("Couldn't allocate memory for the SSID..Freeing memory allocated for Channel List\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 return eHAL_STATUS_FAILURE;
1677 }
1678 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
1679
1680 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
1681 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
1682 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
1683
1684 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
1685
1686 channel = pBgScanParams->ChannelInfo.ChannelList[0];
1687 scanReq.ChannelInfo.ChannelList = &channel;
1688
1689 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
1690 scanReq.scanType = eSIR_ACTIVE_SCAN;
1691 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
1692 scanReq.maxChnTime = pBgScanParams->maxChnTime;
1693 scanReq.minChnTime = pBgScanParams->minChnTime;
1694 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
1695 &scanId, csrNeighborRoamScanRequestCallback, NULL);
1696 if (eHAL_STATUS_SUCCESS != status)
1697 {
1698 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
1699 vos_mem_free(scanReq.SSIDs.SSIDList);
1700 return status;
1701 }
1702 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
1703
1704 vos_mem_free(scanReq.SSIDs.SSIDList);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301705 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
1707 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
1708 return status;
1709}
1710
1711/* ---------------------------------------------------------------------------
1712
1713 \fn csrNeighborRoamPerformBgScan
1714
1715 \brief This function is invoked on every expiry of neighborScanTimer till all
1716 the channels in the channel list are scanned. It populates necessary
1717 parameters for BG scan and calls appropriate AP to invoke the CSR scan
1718 request
1719
1720 \param pMac - The handle returned by macOpen.
1721
1722 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
1723
1724---------------------------------------------------------------------------*/
1725eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac)
1726{
1727 eHalStatus status = eHAL_STATUS_SUCCESS;
1728 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1729 tCsrBGScanRequest bgScanParams;
1730 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1731 tANI_U8 channel = 0;
1732
1733 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1734 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301735 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 }
1737 else
1738 {
1739 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
1740 // Go back and restart. Mostly timer start failure has occured.
1741 // When timer start is declared a failure, then we delete the list.
1742 // Should not happen now as we stop and then only start the scan timer.
1743 // still handle the unlikely case.
1744 csrNeighborRoamHandleEmptyScanResult(pMac);
1745 return status;
1746 }
1747 /* Need to perform scan here before getting the list */
1748 vos_mem_copy(bgScanParams.bssid, broadcastBssid, sizeof(tCsrBssid));
1749 bgScanParams.SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
1750 vos_mem_copy(bgScanParams.SSID.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
1751 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
1752
1753 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
1754 bgScanParams.ChannelInfo.numOfChannels = 1;
1755 bgScanParams.ChannelInfo.ChannelList = &channel;
1756
1757 bgScanParams.minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
1758 bgScanParams.maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
1759
1760 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams);
1761 if (eHAL_STATUS_SUCCESS != status)
1762 {
1763 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
1764 return status;
1765 }
1766
1767 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
1768 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
1769 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
1770 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301771 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
1773 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
1774 /* We have completed scanning all the channels */
1775 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
1776 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
1777 and select the best AP in the list */
1778 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
1779 {
1780 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
1781 }
1782 }
1783
1784 return status;
1785}
1786
1787/* ---------------------------------------------------------------------------
1788
1789 \fn csrNeighborRoamNeighborScanTimerCallback
1790
1791 \brief This function is the neighbor scan timer callback function. It invokes
1792 the BG scan request based on the current and previous states
1793
1794 \param pv - CSR timer context info which includes pMac and session ID
1795
1796 \return VOID
1797
1798---------------------------------------------------------------------------*/
1799void csrNeighborRoamNeighborScanTimerCallback(void *pv)
1800{
1801 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
1802 tpAniSirGlobal pMac = pInfo->pMac;
1803 tANI_U32 sessionId = pInfo->sessionId;
1804 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1805
1806 // check if bg scan is on going, no need to send down the new params if true
1807 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
1808 {
1809 //msg
1810 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending\n"));
1811 return;
1812 }
1813
1814 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
1815
1816 switch (pNeighborRoamInfo->neighborRoamState)
1817 {
1818#ifdef WLAN_FEATURE_VOWIFI_11R
1819 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1820 switch(pNeighborRoamInfo->prevNeighborRoamState)
1821 {
1822 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
1823 csrNeighborRoamPerformBgScan(pMac);
1824 break;
1825 default:
1826 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
1827 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
1828 break;
1829 }
1830 break;
1831#endif /* WLAN_FEATURE_VOWIFI_11R */
1832 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1833 csrNeighborRoamPerformBgScan(pMac);
1834 break;
1835 default:
1836 break;
1837 }
1838 return;
1839}
1840
1841/* ---------------------------------------------------------------------------
1842
1843 \fn csrNeighborRoamResultsRefreshTimerCallback
1844
1845 \brief This function is the timer callback function for results refresh timer.
1846 When this is invoked, it is as good as down event received from TL. So,
1847 clear off the roamable AP list and start the scan procedure based on 11R
1848 or non-11R association
1849
1850 \param context - CSR timer context info which includes pMac and session ID
1851
1852 \return VOID
1853
1854---------------------------------------------------------------------------*/
1855void csrNeighborRoamResultsRefreshTimerCallback(void *context)
1856{
1857 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
1858 tpAniSirGlobal pMac = pInfo->pMac;
1859 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1860 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1861
1862 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
1863
1864 /* Deregister reassoc callback. Ignore return status */
1865 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
1866 WLANTL_HO_THRESHOLD_DOWN,
1867 csrNeighborRoamReassocIndCallback,
1868 VOS_MODULE_ID_SME);
1869
1870 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1871 {
1872 //err msg
1873 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d\n"), vosStatus);
1874 }
1875
1876 /* Reset all the variables just as no scan had happened before */
1877 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1878
1879#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
1880 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
1881 {
1882 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
1883 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
1884 if (VOS_STATUS_SUCCESS != vosStatus)
1885 {
1886 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
1887 return;
1888 }
1889 /* Increment the neighbor report retry count after sending the neighbor request successfully */
1890 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
1891 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
1892 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
1893 }
1894 else
1895#endif
1896 {
1897 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
1898 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
1899 if (VOS_STATUS_SUCCESS != vosStatus)
1900 {
1901 return;
1902 }
1903 }
1904 return;
1905}
1906
1907#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
1908/* ---------------------------------------------------------------------------
1909
1910 \fn csrNeighborRoamIssueNeighborRptRequest
1911
1912 \brief This function is invoked when TL issues a down event and the current assoc
1913 is a 11R association. It invokes SME RRM API to issue the neighbor request to
1914 the currently associated AP with the current SSID
1915
1916 \param pMac - The handle returned by macOpen.
1917
1918 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1919
1920---------------------------------------------------------------------------*/
1921VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
1922{
1923 tRrmNeighborRspCallbackInfo callbackInfo;
1924 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1925 tRrmNeighborReq neighborReq;
1926
1927
1928 neighborReq.no_ssid = 0;
1929
1930 /* Fill in the SSID */
1931 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
1932 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
1933 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
1934
1935 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
1936 callbackInfo.neighborRspCallbackContext = pMac;
1937 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
1938
1939 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
1940}
1941
1942/* ---------------------------------------------------------------------------
1943
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07001944 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07001945
1946 \brief This function is used to merge two channel list.
1947 NB: If called with outputNumOfChannels == 0, this routines
1948 simply copies the input channel list to the output channel list.
1949
1950 \param pMac - The handle returned by macOpen.
1951 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
1952 \param inputNumOfChannels - The number of additional channels.
1953 \param pOutputChannelList - The place to put the "merged" channel list.
1954 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
1955 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
1956
1957 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1958
1959---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07001960VOS_STATUS csrNeighborRoamMergeChannelLists(
1961 tpAniSirGlobal pMac,
1962 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07001963 int inputNumOfChannels,
1964 tANI_U8 *pOutputChannelList,
1965 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07001966 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07001967 )
1968{
1969 int i = 0;
1970 int j = 0;
1971 int numChannels = outputNumOfChannels;
1972
1973 // Check for NULL pointer
1974 if (!pInputChannelList) return eHAL_STATUS_E_NULL_VALUE;
1975
1976 // Check for NULL pointer
1977 if (!pOutputChannelList) return eHAL_STATUS_E_NULL_VALUE;
1978
1979 // Add the "new" channels in the input list to the end of the output list.
1980 for (i = 0; i < inputNumOfChannels; i++)
1981 {
1982 for (j = 0; j < outputNumOfChannels; j++)
1983 {
1984 if (pInputChannelList[i] == pOutputChannelList[j])
1985 break;
1986 }
1987 if (j == outputNumOfChannels)
1988 {
1989 if (pInputChannelList[i])
1990 {
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07001991 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1992 "%s: [INFOLOG] Adding extra %d to Neighbor channel list\n", __func__,
1993 pInputChannelList[i]);
1994 pOutputChannelList[numChannels] = pInputChannelList[i];
1995 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07001996 }
1997 }
1998 }
1999
2000 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002001 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002002
2003 return eHAL_STATUS_SUCCESS;
2004}
2005
2006/* ---------------------------------------------------------------------------
2007
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 \fn csrNeighborRoamCreateChanListFromNeighborReport
2009
2010 \brief This function is invoked when neighbor report is received for the
2011 neighbor request. Based on the channels present in the neighbor report,
2012 it generates channel list which will be used in REPORT_SCAN state to
2013 scan for these neighbor APs
2014
2015 \param pMac - The handle returned by macOpen.
2016
2017 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2018
2019---------------------------------------------------------------------------*/
2020VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2021{
2022 tpRrmNeighborReportDesc pNeighborBssDesc;
2023 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002024 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002026#if 0
2027 eHalStatus status = eHAL_STATUS_SUCCESS;
2028#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002029
2030 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2031 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2032
2033 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2034
2035 while (pNeighborBssDesc)
2036 {
2037 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2038
2039 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2040 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2041 pNeighborBssDesc->pNeighborBssDescription->channel;
2042 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2043 (tANI_U8)pNeighborBssDesc->roamScore;
2044 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2045 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2046 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2047
2048 /* Saving the channel list non-redundantly */
2049 if (numChannels > 0)
2050 {
2051 for (i = 0; i < numChannels; i++)
2052 {
2053 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2054 break;
2055 }
2056
2057 }
2058 if (i == numChannels)
2059 {
2060 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2061 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2063 "%s: [INFOLOG] Adding %d to Neighbor channel list\n", __func__,
2064 pNeighborBssDesc->pNeighborBssDescription->channel);
2065 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2066 numChannels++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 }
2068 }
2069
2070 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2071 }
2072
2073 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2074 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002075#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002077 // we have a union of the IAPP and the already existing list.
2078 status = csrNeighborRoamMergeChannelLists(
2079 pMac,
2080 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2081 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2082 channelList,
2083 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002084 &numChannels );
2085#endif
2086
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2088 }
2089
2090 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2091 /* Store the obtained channel list to the Neighbor Control data structure */
2092 if (numChannels)
2093 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2094 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2095 {
2096 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2097 return VOS_STATUS_E_RESOURCES;
2098 }
2099
2100 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2101 channelList, (numChannels) * sizeof(tANI_U8));
2102 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2103 if (numChannels)
2104 {
2105 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
2106 pNeighborRoamInfo->neighborRoamState);
2107 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
2108 }
2109 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2110 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
2111
2112 return VOS_STATUS_SUCCESS;
2113}
2114
2115/* ---------------------------------------------------------------------------
2116
2117 \fn csrNeighborRoamRRMNeighborReportResult
2118
2119 \brief This function is the neighbor report callback that will be invoked by
2120 SME RRM on receiving a neighbor report or of neighbor report is not
2121 received after timeout. On receiving a valid report, it generates a
2122 channel list from the neighbor report and starts the
2123 neighbor scan timer
2124
2125 \param context - The handle returned by macOpen.
2126 vosStatus - Status of the callback(SUCCESS/FAILURE)
2127
2128 \return VOID
2129
2130---------------------------------------------------------------------------*/
2131void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
2132{
2133 tpAniSirGlobal pMac = PMAC_STRUCT(context);
2134 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2135 eHalStatus status = eHAL_STATUS_SUCCESS;
2136
2137 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d\n"), vosStatus);
2138 switch (pNeighborRoamInfo->neighborRoamState)
2139 {
2140 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
2141 /* Reset the report pending variable */
2142 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
2143 if (VOS_STATUS_SUCCESS == vosStatus)
2144 {
2145 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
2146 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
2147 if (VOS_STATUS_SUCCESS == vosStatus)
2148 {
2149 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state\n"));
2150 }
2151
2152 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2153 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2154
2155 /* Now ready for neighbor scan based on the channel list created */
2156 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2157 what palTimerStart expects */
2158 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2159 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2160 eANI_BOOLEAN_FALSE);
2161 if (eHAL_STATUS_SUCCESS != status)
2162 {
2163 /* Timer start failed.. Should we ASSERT here??? */
2164 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
2165 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2166 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
2167 return;
2168 }
2169 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2170 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
2171 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
2172 }
2173 else
2174 {
2175 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
2176 reach the maxNeighborRetries or receiving a successful neighbor response */
2177 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d\n"),
2178 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
2179 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
2180 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
2181 {
2182 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. \n"));
2183 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2184 if (VOS_STATUS_SUCCESS != vosStatus)
2185 {
2186 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d \n"), vosStatus);
2187 return;
2188 }
2189 /* We transitioned to different state now. Reset the Neighbor report retry count */
2190 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
2191 }
2192 else
2193 {
2194 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2195 if (VOS_STATUS_SUCCESS != vosStatus)
2196 {
2197 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2198 return;
2199 }
2200 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2201 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2202 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2203 }
2204 }
2205 break;
2206 default:
2207 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
2208 break;
2209 }
2210 return;
2211}
2212#endif /* WLAN_FEATURE_VOWIFI_11R */
2213
2214
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002215#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002216tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002217 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002218 tCsrRoamConnectedProfile *pCurProfile,
2219 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002220 tDot11fBeaconIEs *pIes)
2221{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002222 tCsrAuthList authType;
2223 tCsrEncryptionList uCEncryptionType;
2224 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002225 tANI_BOOLEAN fMatch = FALSE;
2226
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002227 authType.numEntries = 1;
2228 authType.authType[0] = pCurProfile->AuthType;
2229 uCEncryptionType.numEntries = 1;
2230 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
2231 mCEncryptionType.numEntries = 1;
2232 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002233
2234 if( pIes )
2235 {
2236 if(pIes->SSID.present)
2237 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002238 fMatch = csrIsSsidMatch( pMac,
2239 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
2240 pIes->SSID.ssid, pIes->SSID.num_ssid,
2241 eANI_BOOLEAN_TRUE );
2242 if(TRUE == fMatch)
2243 {
2244 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
2245 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
2246 return (fMatch);
2247 }
2248 else
2249 {
2250 return (fMatch);
2251 }
2252
2253 }
2254 else
2255 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002256 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002257 }
2258 }
2259 else
2260 {
2261 return FALSE; // Again, treat missing pIes as a non-match.
2262 }
2263}
2264
2265tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
2266 tpAniSirGlobal pMac)
2267{
2268 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2269 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2270 tCsrRoamConnectedProfile *pCurrProfile = NULL;
2271 tCsrRoamConnectedProfile *pPrevProfile = NULL;
2272 tDot11fBeaconIEs *pIes = NULL;
2273 tSirBssDescription *pBssDesc = NULL;
2274 tANI_BOOLEAN fNew = TRUE;
2275
2276 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
2277 {
2278 return (fNew);
2279 }
2280
2281 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2282 if( !pCurrProfile )
2283 {
2284 return (fNew);
2285}
2286
2287 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
2288 if( !pPrevProfile )
2289 {
2290 return (fNew);
2291 }
2292
2293 pBssDesc = pPrevProfile->pBssDesc;
2294 if (pBssDesc)
2295 {
2296 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
2297 pBssDesc, &pIes)) &&
2298 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
2299 {
2300 fNew = FALSE;
2301 }
2302 if (pIes) {
2303 palFreeMemory(pMac->hHdd, pIes);
2304 }
2305 }
2306
2307 if (fNew)
2308 {
2309 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
2310 csrRoamFreeConnectProfile(pMac, pPrevProfile);
2311 csrRoamGetConnectProfile(pMac, sessionId, pPrevProfile);
2312 }
2313 else
2314 {
2315 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
2316 }
2317
2318 return (fNew);
2319}
2320
2321tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
2322 tpAniSirGlobal pMac,
2323 tCsrScanResult *pResult,
2324 tDot11fBeaconIEs *pIes)
2325{
2326 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2327 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
2328 tCsrRoamConnectedProfile *pCurProfile = NULL;
2329 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
2330
2331 if( !(pMac->roam.roamSession
2332 && CSR_IS_SESSION_VALID(pMac, sessionId)))
2333 {
2334 return FALSE;
2335 }
2336
2337 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
2338
2339 if( !pCurProfile)
2340 {
2341 return FALSE;
2342 }
2343
2344 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002345}
2346
2347/* ---------------------------------------------------------------------------
2348
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002349 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002350
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002351 \brief This function is used to prepare a channel list that is derived from
2352 the list of valid channels and does not include those in the occupied
2353 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002354
2355 \param pMac - The handle returned by macOpen.
2356 \param pInputChannelList - The default channels list.
2357 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002358 \param pOutputChannelList - The place to put the non-occupied channel list.
2359 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002360
2361 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2362
2363---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002364VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002365 tpAniSirGlobal pMac,
2366 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002367 int numOfChannels,
2368 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002369 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002370 )
2371{
2372 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002373 int outputNumOfChannels = 0; // Clear the output number of channels
2374 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
2375 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
2376
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002377 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002378 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002379 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
2380 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002381 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002382 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002383 }
2384 }
2385
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002386 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
2387 "Number of channels in the non-occupied list list=%d"),
2388 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002389
2390 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002391 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002392
2393 return eHAL_STATUS_SUCCESS;
2394}
2395#endif /* FEATURE_WLAN_LFR */
2396
Jeff Johnson295189b2012-06-20 16:38:30 -07002397/* ---------------------------------------------------------------------------
2398
2399 \fn csrNeighborRoamTransitToCFGChanScan
2400
2401 \brief This function is called whenever there is a transition to CFG chan scan
2402 state from any state. It frees up the current channel list and allocates
2403 a new memory for the channels received from CFG item. It then starts the
2404 neighbor scan timer to perform the scan on each channel one by one
2405
2406 \param pMac - The handle returned by macOpen.
2407
2408 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2409
2410---------------------------------------------------------------------------*/
2411VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
2412{
2413 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2414 eHalStatus status = eHAL_STATUS_SUCCESS;
2415 int i = 0;
2416 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002417 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002418 tpCsrChannelInfo currChannelListInfo;
2419
2420 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002421
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002422 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07002423#ifdef FEATURE_WLAN_CCX
2424 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002425 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
2427#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002428 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002430 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002431
2432
2433 /* Free up the channel list and allocate a new memory. This is because we dont know how much
2434 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
2435 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002436 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002438 vos_mem_free(currChannelListInfo->ChannelList);
2439 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002441
2442 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
2443 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
2444 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002446 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
2447 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002448 status = csrNeighborRoamMergeChannelLists(
2449 pMac,
2450 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
2451 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
2452 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002453 0, //NB: If 0, simply copy the input channel list to the output list.
2454 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002455
2456 currChannelListInfo->ChannelList =
2457 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2458 if (NULL == currChannelListInfo->ChannelList)
2459 {
2460 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2461 return VOS_STATUS_E_RESOURCES;
2462 }
2463
2464 vos_mem_copy(currChannelListInfo->ChannelList,
2465 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002466 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002467 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002468 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002469 /* Get current list of valid channels. */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002470 numOfChannels = pMac->scan.occupiedChannels.numChannels;
2471 if (numOfChannels
2472#ifdef FEATURE_WLAN_LFR
2473 && ((pNeighborRoamInfo->uEmptyScanCount == 0) ||
2474 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
2475#endif
2476 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002478 /*
2479 * Always scan channels in the occupied channel list
2480 * before scanning on the non-occupied list.
2481 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302482 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to occupied channel list");
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002483 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
2484 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels);
2485
2486 if (NULL == currChannelListInfo->ChannelList)
2487 {
2488 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2489 return VOS_STATUS_E_RESOURCES;
2490 }
2491 vos_mem_copy(currChannelListInfo->ChannelList,
2492 pMac->scan.occupiedChannels.channelList,
2493 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002494 }
2495 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002496 {
2497 /* Scan all channels from non-occupied list */
2498 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
2499 numOfChannels = sizeof(pMac->roam.validChannelList);
2500
2501 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2502 (tANI_U8 *)pMac->roam.validChannelList,
2503 (tANI_U32 *) &numOfChannels)))
2504 {
2505#ifdef FEATURE_WLAN_LFR
2506 /*
2507 * Prepare non-occupied channel list (channelList)
2508 * from the actual "valid channel list" information
2509 * formed by CSR.
2510 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302511 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
2512 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
2513 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002514 numOfChannels,
2515 channelList,
2516 &numOfChannels);
2517#else
2518 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
2519 status = csrNeighborRoamMergeChannelLists(
2520 pMac,
2521 (tANI_U8 *)pMac->roam.validChannelList,
2522 numOfChannels, // The number of channels in the validChannelList
2523 channelList,
2524 0, //NB: If 0, simply copy the input channel list to the output list.
2525 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
2526#endif
2527 }
2528 else
2529 {
2530 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002531 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002533 currChannelListInfo->ChannelList =
2534 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
2535
2536 if (NULL == currChannelListInfo->ChannelList)
2537 {
2538 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
2539 return VOS_STATUS_E_RESOURCES;
2540 }
2541#ifdef FEATURE_WLAN_LFR
2542 vos_mem_copy(currChannelListInfo->ChannelList,
2543 channelList, numOfChannels * sizeof(tANI_U8));
2544#else
2545 vos_mem_copy(currChannelListInfo->ChannelList,
2546 (tANI_U8 *)pMac->roam.validChannelList,
2547 numOfChannels * sizeof(tANI_U8));
2548#endif
2549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 }
2551
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002552 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002553 currChannelListInfo->numOfChannels = numOfChannels;
2554 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302556 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002557 "= %d\n", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
2559 }
2560
2561 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
2562 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
2563
2564 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2565 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
2566 what palTimerStart expects */
2567 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2568 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
2569 eANI_BOOLEAN_FALSE);
2570
2571 if (eHAL_STATUS_SUCCESS != status)
2572 {
2573 /* Timer start failed.. */
2574 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002575 vos_mem_free(currChannelListInfo->ChannelList);
2576 currChannelListInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 return VOS_STATUS_E_FAILURE;
2578 }
2579
2580 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2581 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302582 /* We are about to start a fresh scan cycle,
2583 * purge non-P2P results from the past */
2584 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002585
2586 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
2587 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
2588
2589 return VOS_STATUS_SUCCESS;
2590}
2591
2592/* ---------------------------------------------------------------------------
2593
2594 \fn csrNeighborRoamNeighborLookupUpEvent
2595
2596 \brief This function is called as soon as TL indicates that the current AP's
2597 RSSI is better than the neighbor lookup threshold. Here, we transition to
2598 CONNECTED state and reset all the scan parameters
2599
2600 \param pMac - The handle returned by macOpen.
2601
2602 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2603
2604---------------------------------------------------------------------------*/
2605VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
2606{
2607 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2608 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002609 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 /* Recheck whether the below check is needed. */
2612 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
2613 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Jeff Johnsone7245742012-09-05 17:12:55 -07002614
2615 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
2616 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2617
Jeff Johnson295189b2012-06-20 16:38:30 -07002618
2619 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2620 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
2621 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2622 WLANTL_HO_THRESHOLD_DOWN,
2623 csrNeighborRoamNeighborLookupDOWNCallback,
2624 VOS_MODULE_ID_SME, pMac);
2625 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2626 {
2627 //err msg
2628 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d\n"), vosStatus);
2629 }
2630
2631
2632 return vosStatus;
2633}
2634
2635/* ---------------------------------------------------------------------------
2636
2637 \fn csrNeighborRoamNeighborLookupDownEvent
2638
2639 \brief This function is called as soon as TL indicates that the current AP's
2640 RSSI falls below the current eighbor lookup threshold. Here, we transition to
2641 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
2642 a non-11R association.
2643
2644 \param pMac - The handle returned by macOpen.
2645
2646 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2647
2648---------------------------------------------------------------------------*/
2649VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
2650{
2651 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2652 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2653 eHalStatus status = eHAL_STATUS_SUCCESS;
2654
2655 switch (pNeighborRoamInfo->neighborRoamState)
2656 {
2657 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
2658
2659 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
2660 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
2661 /* De-register Neighbor Lookup threshold callback with TL */
2662 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
2663 WLANTL_HO_THRESHOLD_DOWN,
2664 csrNeighborRoamNeighborLookupDOWNCallback,
2665 VOS_MODULE_ID_SME);
2666
2667 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2668 {
2669 //err msg
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002670 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d\n"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 }
2672
2673
2674#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2675 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2676 {
2677
2678 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2679 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2680 if (VOS_STATUS_SUCCESS != vosStatus)
2681 {
2682 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d\n"), vosStatus);
2683 return vosStatus;
2684 }
2685 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2686 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2687 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2688 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2689 }
2690 else
2691#endif
2692 {
2693 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
2694
2695 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2696 if (VOS_STATUS_SUCCESS != vosStatus)
2697 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002698 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
2699 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 return vosStatus;
2701 }
2702 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002703 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 -07002704 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002705 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
2706 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 WLANTL_HO_THRESHOLD_UP,
2708 csrNeighborRoamNeighborLookupUPCallback,
2709 VOS_MODULE_ID_SME, pMac);
2710 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2711 {
2712 //err msg
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08002713 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 }
2715 break;
2716 default:
2717 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
2718 break;
2719
2720 }
2721 return vosStatus;
2722}
2723
2724/* ---------------------------------------------------------------------------
2725
2726 \fn csrNeighborRoamNeighborLookupUPCallback
2727
2728 \brief This function is registered with TL to indicate whenever the RSSI
2729 gets better than the neighborLookup RSSI Threshold
2730
2731 \param pAdapter - VOS Context
2732 trafficStatus - UP/DOWN indication from TL
2733 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
2734
2735 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2736
2737---------------------------------------------------------------------------*/
2738VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
2739 v_PVOID_t pUserCtxt)
2740{
2741 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
2742 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2743 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
2744
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302745 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d"), rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -07002746
2747 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
2748 {
2749 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
2750 return VOS_STATUS_SUCCESS;
2751 }
2752
2753 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
2754 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
2755 return vosStatus;
2756}
2757
2758/* ---------------------------------------------------------------------------
2759
2760 \fn csrNeighborRoamNeighborLookupDOWNCallback
2761
2762 \brief This function is registered with TL to indicate whenever the RSSI
2763 falls below the current neighborLookup RSSI Threshold
2764
2765 \param pAdapter - VOS Context
2766 trafficStatus - UP/DOWN indication from TL
2767 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
2768
2769 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2770
2771---------------------------------------------------------------------------*/
2772VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
2773 v_PVOID_t pUserCtxt)
2774{
2775 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
2776 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2777 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
2778
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302779 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d"), rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
2781 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
2782 {
2783 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected\n");
2784 return VOS_STATUS_SUCCESS;
2785 }
2786
2787 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
2788 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
2789
2790 return vosStatus;
2791}
2792
2793#ifdef RSSI_HACK
2794extern int dumpCmdRSSI;
2795#endif
2796
2797/* ---------------------------------------------------------------------------
2798
2799 \fn csrNeighborRoamIndicateDisconnect
2800
2801 \brief This function is called by CSR as soon as the station disconnects from
2802 the AP. This function does the necessary cleanup of neighbor roam data
2803 structures. Neighbor roam state transitions to INIT state whenever this
2804 function is called except if the current state is REASSOCIATING
2805
2806 \param pMac - The handle returned by macOpen.
2807 sessionId - CSR session id that got disconnected
2808
2809 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2810
2811---------------------------------------------------------------------------*/
2812eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
2813{
2814 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2815
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07002816 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d (sub-state %d)"),
2817 sessionId, pNeighborRoamInfo->neighborRoamState,
2818 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002819
2820#ifdef FEATURE_WLAN_CCX
2821 {
2822 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
2823 if (pSession->connectedProfile.isCCXAssoc)
2824 {
2825 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
2826 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
2827 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
2828 pSession->isPrevApInfoValid = TRUE;
2829 pSession->roamTS1 = vos_timer_get_system_time();
2830
2831 }
2832 }
2833#endif
2834
2835#ifdef RSSI_HACK
2836 dumpCmdRSSI = -40;
2837#endif
2838 switch (pNeighborRoamInfo->neighborRoamState)
2839 {
2840 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
2841 // Stop scan and neighbor refresh timers.
2842 // These are indeed not required when we are in reassociating
2843 // state.
2844 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
2845 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07002846 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
2847 /*
2848 * Disconnect indication during Disassoc Handoff sub-state
2849 * is received when we are trying to disconnect with the old
2850 * AP during roam. BUT, if receive a disconnect indication
2851 * outside of Disassoc Handoff sub-state, then it means that
2852 * this is a genuine disconnect and we need to clean up.
2853 * Otherwise, we will be stuck in reassoc state which will
2854 * in-turn block scans (see csrIsScanAllowed).
2855 */
2856 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
2857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 break;
2859
2860 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 csrNeighborRoamResetInitStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002862 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 break;
2864
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002865 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
2866 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
2867 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
2868 csrNeighborRoamDeregAllRssiIndication(pMac);
2869 break;
2870
2871 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
2872 /* Stop pre-auth to reassoc interval timer */
2873 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07002874 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2875 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
2876 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002877 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07002878 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07002879 csrNeighborRoamDeregAllRssiIndication(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07002880 break;
2881
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002883 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
2884 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07002886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 }
2888 return eHAL_STATUS_SUCCESS;
2889}
2890
2891/* ---------------------------------------------------------------------------
2892
2893 \fn csrNeighborRoamIndicateConnect
2894
2895 \brief This function is called by CSR as soon as the station connects to an AP.
2896 This initializes all the necessary data structures related to the
2897 associated AP and transitions the state to CONNECTED state
2898
2899 \param pMac - The handle returned by macOpen.
2900 sessionId - CSR session id that got connected
2901 vosStatus - connect status SUCCESS/FAILURE
2902
2903 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2904
2905---------------------------------------------------------------------------*/
2906eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
2907{
2908 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2909 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002910 VOS_STATUS vstatus;
2911
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002912#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 int init_ft_flag = FALSE;
2914#endif
2915
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002916 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002917
2918 switch (pNeighborRoamInfo->neighborRoamState)
2919 {
2920 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
2921 if (VOS_STATUS_SUCCESS != vosStatus)
2922 {
2923 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
2924 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
2925 break;
2926 }
2927 /* Fall through if the status is SUCCESS */
2928 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
2929 /* Reset all the data structures here */
2930 csrNeighborRoamResetInitStateControlInfo(pMac);
2931
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002933
2934#ifdef FEATURE_WLAN_LFR
2935 /*
2936 * Initialize the occupied list ONLY if we are
2937 * transitioning from INIT state to CONNECTED state.
2938 */
2939 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
2940 csrInitOccupiedChannelsList(pMac);
2941#endif
2942 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
2943
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
2945 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
2946 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
2947 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
2948 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002949 pNeighborRoamInfo->currentNeighborLookupThreshold =
2950 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
2951#ifdef FEATURE_WLAN_LFR
2952 pNeighborRoamInfo->uEmptyScanCount = 0;
2953#endif
2954
Jeff Johnson295189b2012-06-20 16:38:30 -07002955
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002956#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 /* Now we can clear the preauthDone that was saved as we are connected afresh */
2958 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
2959#endif
2960
2961#ifdef WLAN_FEATURE_VOWIFI_11R
2962 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002963 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
2964 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07002965 {
2966 if (pMac->roam.configParam.isFastTransitionEnabled)
2967 init_ft_flag = TRUE;
2968 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
2969 }
2970 else
2971 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002972 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07002973#endif
2974
2975#ifdef FEATURE_WLAN_CCX
2976 // Based on the auth scheme tell if we are 11r
2977 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
2978 {
2979 if (pMac->roam.configParam.isFastTransitionEnabled)
2980 init_ft_flag = TRUE;
2981 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
2982 }
2983 else
2984 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002985 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
2986 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07002987
2988#endif
2989
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002990#ifdef FEATURE_WLAN_LFR
2991 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05302992 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002993 {
2994 init_ft_flag = TRUE;
2995 }
2996#endif
2997
2998#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 if ( init_ft_flag == TRUE )
3000 {
3001 /* Initialize all the data structures needed for the 11r FT Preauth */
3002 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.pMac = pMac;
3003 pNeighborRoamInfo->FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = sessionId;
3004 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3005 csrNeighborRoamPurgePreauthFailedList(pMac);
3006
3007 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
3008 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07003009 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 WLANTL_HO_THRESHOLD_DOWN,
3011 csrNeighborRoamNeighborLookupDOWNCallback,
3012 VOS_MODULE_ID_SME, pMac);
3013
Jeff Johnson43971f52012-07-17 12:26:56 -07003014 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 {
3016 //err msg
Jeff Johnson43971f52012-07-17 12:26:56 -07003017 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d\n"), vstatus);
3018 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 }
3020 }
3021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 break;
3023 default:
3024 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3025 break;
3026 }
3027 return status;
3028}
3029
3030
3031#ifdef WLAN_FEATURE_VOWIFI_11R
3032/* ---------------------------------------------------------------------------
3033
3034 \fn csrNeighborRoamPreAuthResponseWaitTimerHandler
3035
3036 \brief If this function is invoked, that means the preauthentication response
3037 is timed out from the PE. Preauth rsp handler is called with status as
3038 TIMEOUT
3039
3040 \param context - CSR Timer info which holds pMac and session ID
3041
3042 \return VOID
3043
3044---------------------------------------------------------------------------*/
3045void csrNeighborRoamPreAuthResponseWaitTimerHandler(void *context)
3046{
3047 tCsrTimerInfo *pTimerInfo = (tCsrTimerInfo *)context;
3048 tpAniSirGlobal pMac = (tpAniSirGlobal)pTimerInfo->pMac;
3049 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3050
3051 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
3052
3053 csrNeighborRoamPreauthRspHandler(pMac, VOS_STATUS_E_TIMEOUT);
3054}
3055
3056/* ---------------------------------------------------------------------------
3057
3058 \fn csrNeighborRoamPurgePreauthFailedList
3059
3060 \brief This function purges all the MAC addresses in the pre-auth fail list
3061
3062 \param pMac - The handle returned by macOpen.
3063
3064 \return VOID
3065
3066---------------------------------------------------------------------------*/
3067void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
3068{
3069 tANI_U8 i;
3070
3071 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
3072 {
3073 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
3074 }
3075 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
3076
3077 return;
3078}
3079
3080/* ---------------------------------------------------------------------------
3081
3082 \fn csrNeighborRoamInit11rAssocInfo
3083
3084 \brief This function initializes 11r related neighbor roam data structures
3085
3086 \param pMac - The handle returned by macOpen.
3087
3088 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3089
3090---------------------------------------------------------------------------*/
3091eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
3092{
3093 eHalStatus status;
3094 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
3095
3096 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
3097 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
3098 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
3099 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
3100 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
3101 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
3102
3103 pFTRoamInfo->preAuthRspWaitTimerInfo.pMac = pMac;
3104 pFTRoamInfo->preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3105 status = palTimerAlloc(pMac->hHdd, &pFTRoamInfo->preAuthRspWaitTimer,
3106 csrNeighborRoamPreAuthResponseWaitTimerHandler, (void *)&pFTRoamInfo->preAuthRspWaitTimerInfo);
3107
3108 if (eHAL_STATUS_SUCCESS != status)
3109 {
3110 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3111 return eHAL_STATUS_RESOURCES;
3112 }
3113
3114 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3115 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3116 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3117 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3118
3119
3120 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
3121 if (eHAL_STATUS_SUCCESS != status)
3122 {
3123 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
3124 palTimerFree(pMac->hHdd, pFTRoamInfo->preAuthRspWaitTimer);
3125 return eHAL_STATUS_RESOURCES;
3126 }
3127 return status;
3128}
3129#endif /* WLAN_FEATURE_VOWIFI_11R */
3130
3131/* ---------------------------------------------------------------------------
3132
3133 \fn csrNeighborRoamInit
3134
3135 \brief This function initializes neighbor roam data structures
3136
3137 \param pMac - The handle returned by macOpen.
3138
3139 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3140
3141---------------------------------------------------------------------------*/
3142eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
3143{
3144 eHalStatus status;
3145 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3146
3147 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3148 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
3149 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
3150 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
3151 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
3152 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
3153 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
3154 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
3155 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
3156 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
3157
3158 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
3159 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
3160
3161 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
3162 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3163
3164 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3165 {
3166 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
3167 return eHAL_STATUS_RESOURCES;
3168 }
3169
3170 /* Update the roam global structure from CFG */
3171 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3172 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
3173 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
3174
3175 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
3176 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003177#ifdef FEATURE_WLAN_LFR
3178 pNeighborRoamInfo->uEmptyScanCount = 0;
3179 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
3180 sizeof(tCsrRoamConnectedProfile));
3181#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
3183
3184 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
3185 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3186 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborScanTimer,
3187 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3188
3189 if (eHAL_STATUS_SUCCESS != status)
3190 {
3191 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3192 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3193 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3194 return eHAL_STATUS_RESOURCES;
3195 }
3196
3197 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborResultsRefreshTimer,
3198 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
3199
3200 if (eHAL_STATUS_SUCCESS != status)
3201 {
3202 smsLog(pMac, LOGE, FL("Response wait Timer allocation failed"));
3203 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3204 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3205 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3206 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3207 return eHAL_STATUS_RESOURCES;
3208 }
3209
3210 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
3211 if (eHAL_STATUS_SUCCESS != status)
3212 {
3213 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3214 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3215 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3216 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3217 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3218 return eHAL_STATUS_RESOURCES;
3219 }
3220
3221 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3222 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3223 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3224 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3225 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3226
3227#ifdef WLAN_FEATURE_VOWIFI_11R
3228 status = csrNeighborRoamInit11rAssocInfo(pMac);
3229 if (eHAL_STATUS_SUCCESS != status)
3230 {
3231 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
3232 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3233 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3234 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3235 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3236 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3237 return eHAL_STATUS_RESOURCES;
3238 }
3239#endif
3240 /* Initialize this with the current tick count */
3241 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3242
3243 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3244
3245 return eHAL_STATUS_SUCCESS;
3246}
3247
3248/* ---------------------------------------------------------------------------
3249
3250 \fn csrNeighborRoamClose
3251
3252 \brief This function closes/frees all the neighbor roam data structures
3253
3254 \param pMac - The handle returned by macOpen.
3255
3256 \return VOID
3257
3258---------------------------------------------------------------------------*/
3259void csrNeighborRoamClose(tpAniSirGlobal pMac)
3260{
3261 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3262
3263 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
3264 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07003265 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 return;
3267 }
3268
3269 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
3270 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
3271
3272 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
3273
3274 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
3275 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3276 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3277 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
3278
3279 /* Should free up the nodes in the list before closing the double Linked list */
3280 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
3281 csrLLClose(&pNeighborRoamInfo->roamableAPList);
3282
3283 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
3284 {
3285 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3286 }
3287
3288 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3289 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
3290 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
3291 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
3292 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
3293 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
3294
3295 /* Free the profile.. */
3296 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
3297
3298#ifdef WLAN_FEATURE_VOWIFI_11R
3299 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
3300 palTimerFree(pMac->hHdd, pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimer);
3301 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.pMac = NULL;
3302 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthRspWaitTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
3303 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
3304 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
3305 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
3306 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3307 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
3308#endif /* WLAN_FEATURE_VOWIFI_11R */
3309
3310 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
3311
3312 return;
3313}
3314
3315/* ---------------------------------------------------------------------------
3316
3317 \fn csrNeighborRoamRequestHandoff
3318
3319 \brief This function triggers actual switching from one AP to the new AP.
3320 It issues disassociate with reason code as Handoff and CSR as a part of
3321 handling disassoc rsp, issues reassociate to the new AP
3322
3323 \param pMac - The handle returned by macOpen.
3324
3325 \return VOID
3326
3327---------------------------------------------------------------------------*/
3328void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
3329{
3330
3331 tCsrRoamInfo roamInfo;
3332 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3333 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3334 tCsrNeighborRoamBSSInfo handoffNode;
3335 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
3336 tANI_U32 roamId = 0;
3337
3338 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
3339 {
3340 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
3341 pMac->roam.neighborRoamInfo.neighborRoamState);
3342 return;
3343 }
3344
3345 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3346 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
3347 eSIR_SME_SUCCESS);
3348
3349 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
3350 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
3351
3352 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
3353 smsLog(pMac, LOGE, FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
3354 handoffNode.pBssDescription->bssId[0],
3355 handoffNode.pBssDescription->bssId[1],
3356 handoffNode.pBssDescription->bssId[2],
3357 handoffNode.pBssDescription->bssId[3],
3358 handoffNode.pBssDescription->bssId[4],
3359 handoffNode.pBssDescription->bssId[5]);
3360
3361 /* Free the profile.. Just to make sure we dont leak memory here */
3362 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
3363 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
3364 This should happen before issuing disconnect */
3365 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
3366 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
3367 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
3368
3369 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP\n");
3370
3371 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
3372 {
3373 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate\n");
3374 return;
3375 }
3376
3377 //notify HDD for handoff, providing the BSSID too
3378 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
3379
3380 vos_mem_copy(roamInfo.bssid,
3381 handoffNode.pBssDescription->bssId,
3382 sizeof( tCsrBssid ));
3383
3384 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
3385
3386
3387 return;
3388}
3389
3390/* ---------------------------------------------------------------------------
3391
3392 \fn csrNeighborRoamIsHandoffInProgress
3393
3394 \brief This function returns whether handoff is in progress or not based on
3395 the current neighbor roam state
3396
3397 \param pMac - The handle returned by macOpen.
3398 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
3399
3400 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
3401
3402---------------------------------------------------------------------------*/
3403tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
3404{
3405 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
3406 return eANI_BOOLEAN_TRUE;
3407
3408 return eANI_BOOLEAN_FALSE;
3409}
3410
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003411#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07003412/* ---------------------------------------------------------------------------
3413
3414 \fn csrNeighborRoamIs11rAssoc
3415
3416 \brief This function returns whether the current association is a 11r assoc or not
3417
3418 \param pMac - The handle returned by macOpen.
3419
3420 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
3421
3422---------------------------------------------------------------------------*/
3423tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
3424{
3425 return pMac->roam.neighborRoamInfo.is11rAssoc;
3426}
3427#endif /* WLAN_FEATURE_VOWIFI_11R */
3428
3429
3430/* ---------------------------------------------------------------------------
3431
3432 \fn csrNeighborRoamGetHandoffAPInfo
3433
3434 \brief This function returns the best possible AP for handoff. For 11R case, it
3435 returns the 1st entry from pre-auth done list. For non-11r case, it returns
3436 the 1st entry from roamable AP list
3437
3438 \param pMac - The handle returned by macOpen.
3439 pHandoffNode - AP node that is the handoff candidate returned
3440
3441 \return VOID
3442
3443---------------------------------------------------------------------------*/
3444void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
3445{
3446 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3447 tpCsrNeighborRoamBSSInfo pBssNode;
3448
3449 VOS_ASSERT(NULL != pHandoffNode);
3450
3451#ifdef WLAN_FEATURE_VOWIFI_11R
3452 if (pNeighborRoamInfo->is11rAssoc)
3453 {
3454 /* Always the BSS info in the head is the handoff candidate */
3455 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3456 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3457 }
3458 else
3459#endif
3460#ifdef FEATURE_WLAN_CCX
3461 if (pNeighborRoamInfo->isCCXAssoc)
3462 {
3463 /* Always the BSS info in the head is the handoff candidate */
3464 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3465 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3466 }
3467 else
3468#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003469#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05303470 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003471 {
3472 /* Always the BSS info in the head is the handoff candidate */
3473 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
3474 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
3475 }
3476 else
3477#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 {
3479 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
3480 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
3481 }
3482 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
3483
3484 return;
3485}
3486
3487/* ---------------------------------------------------------------------------
3488 \brief This function returns TRUE if preauth is completed
3489
3490 \param pMac - The handle returned by macOpen.
3491
3492 \return boolean
3493
3494---------------------------------------------------------------------------*/
3495tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
3496{
3497 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
3498 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
3499}
3500
3501/* ---------------------------------------------------------------------------
3502 \brief In the event that we are associated with AP1 and we have
3503 completed pre auth with AP2. Then we receive a deauth/disassoc from
3504 AP1.
3505 At this point neighbor roam is in pre auth done state, pre auth timer
3506 is running. We now handle this case by stopping timer and clearing
3507 the pre-auth state. We basically clear up and just go to disconnected
3508 state.
3509
3510 \param pMac - The handle returned by macOpen.
3511
3512 \return boolean
3513---------------------------------------------------------------------------*/
3514void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
3515{
3516 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
3517 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
3518
3519 // Stop timer
3520 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
3521
3522 // Transition to init state
3523 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3524}
3525
3526#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */