blob: 9047fe92341648356b10f8d6201825d66ee18b1a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
Jeff Johnson295189b2012-06-20 16:38:30 -070042/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
44
45
46 \file csrNeighborRoam.c
47
48 Implementation for the simple roaming algorithm for 802.11r Fast transitions and Legacy roaming for Android platform.
49
50 Copyright (C) 2010 Qualcomm, Incorporated
51
52
53 ========================================================================== */
54
55/*===========================================================================
56
57 EDIT HISTORY FOR FILE
58
59
60 This section contains comments describing changes made to the module.
61 Notice that changes are listed in reverse chronological order.
62
63
64
65 when who what, where, why
66---------- --- --------------------------------------------------------
6708/01/10 Murali Created
68
69===========================================================================*/
70#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
71#include "wlan_qct_wda.h"
72#include "palApi.h"
73#include "csrInsideApi.h"
74#include "smsDebug.h"
75#include "logDump.h"
76#include "smeQosInternal.h"
77#include "wlan_qct_tl.h"
78#include "smeInside.h"
79#include "vos_diag_core_event.h"
80#include "vos_diag_core_log.h"
81#include "csrApi.h"
82#include "wlan_qct_tl.h"
83#include "sme_Api.h"
84#include "csrNeighborRoam.h"
85#ifdef FEATURE_WLAN_CCX
86#include "csrCcx.h"
87#endif
88
89#define WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG 1
90#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING_DEBUG
91#define NEIGHBOR_ROAM_DEBUG smsLog
92#else
93#define NEIGHBOR_ROAM_DEBUG(x...)
94#endif
95
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -070096static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo);
97static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac);
98static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac);
99static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac);
100
Jeff Johnson295189b2012-06-20 16:38:30 -0700101VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800102 v_PVOID_t pUserCtxt,
103 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700104VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -0800105 v_PVOID_t pUserCtxt,
106 v_S7_t avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700107void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus);
108eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile );
109
110#ifdef WLAN_FEATURE_VOWIFI_11R
111static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac);
112VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac);
113#endif
114
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800115#define ROAM_STATE_RETURN_STRING( str )\
116 case ( ( str ) ): return( #str )
117
118
119v_U8_t *csrNeighborRoamStateToString(v_U8_t state)
120{
121 switch(state)
122 {
123 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CLOSED );
124 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_INIT );
125 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CONNECTED );
126 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN );
127 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING );
128 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY );
129 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN );
130 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING );
131 ROAM_STATE_RETURN_STRING( eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE );
132 default:
133 return "eCSR_NEIGHBOR_ROAM_STATE_UNKNOWN";
134 }
135
136}
137
Jeff Johnson295189b2012-06-20 16:38:30 -0700138/* State Transition macro */
139#define CSR_NEIGHBOR_ROAM_STATE_TRANSITION(newState)\
140{\
141 pMac->roam.neighborRoamInfo.prevNeighborRoamState = pMac->roam.neighborRoamInfo.neighborRoamState;\
142 pMac->roam.neighborRoamInfo.neighborRoamState = newState;\
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800143 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, \
144 FL("Neighbor Roam Transition from state %s ==> %s"), \
145 csrNeighborRoamStateToString (pMac->roam.neighborRoamInfo.prevNeighborRoamState), \
146 csrNeighborRoamStateToString (newState));\
Jeff Johnson295189b2012-06-20 16:38:30 -0700147}
148
149/* ---------------------------------------------------------------------------
150
151 \fn csrNeighborRoamFreeNeighborRoamBSSNode
152
153 \brief This function frees all the internal pointers CSR NeighborRoam BSS Info
154 and also frees the node itself
155
156 \param pMac - The handle returned by macOpen.
157 neighborRoamBSSNode - Neighbor Roam BSS Node to be freed
158
159 \return VOID
160
161---------------------------------------------------------------------------*/
162void csrNeighborRoamFreeNeighborRoamBSSNode(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo neighborRoamBSSNode)
163{
164 if (neighborRoamBSSNode)
165 {
166 if (neighborRoamBSSNode->pBssDescription)
167 {
168 vos_mem_free(neighborRoamBSSNode->pBssDescription);
169 neighborRoamBSSNode->pBssDescription = NULL;
170 }
171 vos_mem_free(neighborRoamBSSNode);
172 neighborRoamBSSNode = NULL;
173 }
174
175 return;
176}
177
178/* ---------------------------------------------------------------------------
179
180 \fn csrNeighborRoamRemoveRoamableAPListEntry
181
182 \brief This function removes a given entry from the given list
183
184 \param pMac - The handle returned by macOpen.
185 pList - The list from which the entry should be removed
186 pNeighborEntry - Neighbor Roam BSS Node to be removed
187
188 \return TRUE if successfully removed, else FALSE
189
190---------------------------------------------------------------------------*/
191tANI_BOOLEAN csrNeighborRoamRemoveRoamableAPListEntry(tpAniSirGlobal pMac,
192 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
193{
194 if(pList)
195 {
196 return csrLLRemoveEntry(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
197 }
198
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800199 smsLog(pMac, LOGE, FL("Removing neighbor BSS node from list failed. Current count = %d"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700200
201 return eANI_BOOLEAN_FALSE;
202}
203
204/* ---------------------------------------------------------------------------
205
206 \fn csrNeighborRoamGetRoamableAPListNextEntry
207
208 \brief Gets the entry next to passed entry. If NULL is passed, return the entry in the head of the list
209
210 \param pMac - The handle returned by macOpen.
211 pList - The list from which the entry should be returned
212 pNeighborEntry - Neighbor Roam BSS Node whose next entry should be returned
213
214 \return Neighbor Roam BSS Node to be returned
215
216---------------------------------------------------------------------------*/
217tpCsrNeighborRoamBSSInfo csrNeighborRoamGetRoamableAPListNextEntry(tpAniSirGlobal pMac,
218 tDblLinkList *pList, tpCsrNeighborRoamBSSInfo pNeighborEntry)
219{
220 tListElem *pEntry = NULL;
221 tpCsrNeighborRoamBSSInfo pResult = NULL;
222
223 if(pList)
224 {
225 if(NULL == pNeighborEntry)
226 {
227 pEntry = csrLLPeekHead(pList, LL_ACCESS_LOCK);
228 }
229 else
230 {
231 pEntry = csrLLNext(pList, &pNeighborEntry->List, LL_ACCESS_LOCK);
232 }
233 if(pEntry)
234 {
235 pResult = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
236 }
237 }
238
239 return pResult;
240}
241
242/* ---------------------------------------------------------------------------
243
244 \fn csrNeighborRoamFreeRoamableBSSList
245
246 \brief Empties and frees all the nodes in the roamable AP list
247
248 \param pMac - The handle returned by macOpen.
249 pList - Neighbor Roam BSS List to be emptied
250
251 \return VOID
252
253---------------------------------------------------------------------------*/
254void csrNeighborRoamFreeRoamableBSSList(tpAniSirGlobal pMac, tDblLinkList *pList)
255{
256 tpCsrNeighborRoamBSSInfo pResult = NULL;
257
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800258 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Emptying the BSS list. Current count = %d"), csrLLCount(pList));
Jeff Johnson295189b2012-06-20 16:38:30 -0700259
260 /* Pick up the head, remove and free the node till the list becomes empty */
261 while ((pResult = csrNeighborRoamGetRoamableAPListNextEntry(pMac, pList, NULL)) != NULL)
262 {
263 csrNeighborRoamRemoveRoamableAPListEntry(pMac, pList, pResult);
264 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pResult);
265 }
266 return;
267}
268
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800269static void csrNeighborRoamTriggerHandoff(tpAniSirGlobal pMac,
270 tpCsrNeighborRoamControlInfo pNeighborRoamInfo)
271{
272#ifdef WLAN_FEATURE_VOWIFI_11R
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700273 if ((pNeighborRoamInfo->is11rAssoc)
274#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
275 && !csrRoamIsRoamOffloadScanEnabled(pMac)
276#endif
277 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800278 {
279 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
280 {
281 csrNeighborRoamIssuePreauthReq(pMac);
282 }
283 else
284 {
285 smsLog(pMac, LOGE, FL("11R Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
286 VOS_ASSERT(0);
287 }
288 }
289 else
290#endif
291
292#ifdef FEATURE_WLAN_CCX
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700293 if ((pNeighborRoamInfo->isCCXAssoc)
294#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
295 && !csrRoamIsRoamOffloadScanEnabled(pMac)
296#endif
297 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800298 {
299 if (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
300 {
301 csrNeighborRoamIssuePreauthReq(pMac);
302 }
303 else
304 {
305 smsLog(pMac, LOGE, FL("CCX Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
306 VOS_ASSERT(0);
307 }
308 }
309 else
310#endif
311#ifdef FEATURE_WLAN_LFR
312 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
313 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700314 if ((eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
315#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
316 || csrRoamIsRoamOffloadScanEnabled(pMac)
317#endif
318 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800319 {
320 csrNeighborRoamIssuePreauthReq(pMac);
321 }
322 else
323 {
324 smsLog(pMac, LOGE, FL("LFR Reassoc indication received in unexpected state %d"), pNeighborRoamInfo->neighborRoamState);
325 VOS_ASSERT(0);
326 }
327 }
328 else
329#endif
330 {
331 if (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pNeighborRoamInfo->neighborRoamState)
332 {
333 csrNeighborRoamRequestHandoff(pMac);
334 }
335 else
336 {
Srinivas Girigowda830bbd02013-06-13 19:44:16 -0700337 smsLog(pMac, LOGE, FL("Non-11R Reassoc indication received in unexpected state %d"
338 " or Roaming is disabled"), pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800339 }
340 }
341}
342
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700343VOS_STATUS csrNeighborRoamUpdateFastRoamingEnabled(tpAniSirGlobal pMac, const v_BOOL_t fastRoamEnabled)
344{
345 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
346 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
347
348 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
349 {
350 if (VOS_TRUE == fastRoamEnabled)
351 {
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700352#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
353 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
354 {
355 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
356 } else {
357#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700358 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"),
359 pNeighborRoamInfo->currentNeighborLookupThreshold);
360 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
361 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
362 WLANTL_HO_THRESHOLD_DOWN,
363 csrNeighborRoamNeighborLookupDOWNCallback,
364 VOS_MODULE_ID_SME, pMac);
365 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
366 {
367 //err msg
368 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
369 vosStatus = VOS_STATUS_E_FAILURE;
370 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700371#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
372 }
373#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700374 }
375 else if (VOS_FALSE == fastRoamEnabled)
376 {
377 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in CONNECTED state, so deregister all events"));
378 /* De-register existing lookup UP/DOWN, Rssi indications */
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700379#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
380 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
381 {
382 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
383 } else {
384#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700385 csrNeighborRoamDeregAllRssiIndication(pMac);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700386#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
387 }
388#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700389 }
390 }
391 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
392 {
393 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, Nothing to do"));
394 }
395 else
396 {
397 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Unexpected state %d, returning failure"), pNeighborRoamInfo->neighborRoamState);
398 vosStatus = VOS_STATUS_E_FAILURE;
399 }
400 return vosStatus;
401}
402
403#ifdef FEATURE_WLAN_CCX
404VOS_STATUS csrNeighborRoamUpdateCcxModeEnabled(tpAniSirGlobal pMac, const v_BOOL_t ccxMode)
405{
406 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
407 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
408
409 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
410 {
411 if (VOS_TRUE == ccxMode)
412 {
413 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"),
414 pNeighborRoamInfo->currentNeighborLookupThreshold);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700415#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
416 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
417 {
418 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
419 } else {
420#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700421 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
422 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
423 WLANTL_HO_THRESHOLD_DOWN,
424 csrNeighborRoamNeighborLookupDOWNCallback,
425 VOS_MODULE_ID_SME, pMac);
426 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
427 {
428 //err msg
429 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
430 vosStatus = VOS_STATUS_E_FAILURE;
431 }
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700432#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
433 }
434#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700435 }
436 else if (VOS_FALSE == ccxMode)
437 {
438 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in CONNECTED state, so deregister all events"));
439 /* De-register existing lookup UP/DOWN, Rssi indications */
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700440#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
441 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
442 {
443 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
444 } else {
445#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700446 csrNeighborRoamDeregAllRssiIndication(pMac);
Varun Reddy Yeturu6d99ac82013-05-08 14:15:35 -0700447#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
448 }
449#endif
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -0700450 }
451 }
452 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
453 {
454 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, Nothing to do"));
455 }
456 else
457 {
458 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Unexpected state %d, returning failure"), pNeighborRoamInfo->neighborRoamState);
459 vosStatus = VOS_STATUS_E_FAILURE;
460 }
461 return vosStatus;
462}
463
464#endif
465
466
Srinivas Girigowdade697412013-02-14 16:31:48 -0800467VOS_STATUS csrNeighborRoamSetLookupRssiThreshold(tpAniSirGlobal pMac, v_U8_t neighborLookupRssiThreshold)
468{
469 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
470 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
471
472 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
473 {
474 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in CONNECTED state, so deregister all and re-register for DOWN event again"));
475 /* De-register existing lookup UP/DOWN, Rssi indications */
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700476#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
477 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
478 {
479 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
480 }
481 else
482 {
483#endif
484 csrNeighborRoamDeregAllRssiIndication(pMac);
485#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
486 }
487#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -0800488 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
489 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
490
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700491#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
492 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Srinivas Girigowdade697412013-02-14 16:31:48 -0800493 {
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700494 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800495 }
Varun Reddy Yeturuce114f72013-06-05 14:09:58 -0700496 else
497 {
498#endif
499 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
500 FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"),
501 pNeighborRoamInfo->currentNeighborLookupThreshold);
502 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
503 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
504 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
505 WLANTL_HO_THRESHOLD_DOWN,
506 csrNeighborRoamNeighborLookupDOWNCallback,
507 VOS_MODULE_ID_SME, pMac);
508 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
509 {
510 //err msg
511 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
512 vosStatus = VOS_STATUS_E_FAILURE;
513 }
514#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
515 }
516#endif
Srinivas Girigowdade697412013-02-14 16:31:48 -0800517 }
518 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
519 {
520 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, safe to set lookupRssi threshold"));
521 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
522 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
523 }
524 else
525 {
526 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Unexpected state %d, returning failure"), pNeighborRoamInfo->neighborRoamState);
527 vosStatus = VOS_STATUS_E_FAILURE;
528 }
529 return vosStatus;
530}
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532/* ---------------------------------------------------------------------------
533
534 \fn csrNeighborRoamReassocIndCallback
535
536 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
537 Directly triggere HO in case of non-11r association
538 In case of 11R association, triggers a pre-auth eventually followed by actual HO
539
540 \param pAdapter - VOS Context
541 trafficStatus - UP/DOWN indication from TL
542 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
543
544 \return VOID
545
546---------------------------------------------------------------------------*/
547VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
548 v_U8_t trafficStatus,
Srinivasdaaec712012-12-12 15:59:44 -0800549 v_PVOID_t pUserCtxt,
550 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700551{
552 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
553 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
554 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
555
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800556 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"),
Srinivasdaaec712012-12-12 15:59:44 -0800557 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
558 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700559
560 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
561 WLANTL_HO_THRESHOLD_DOWN,
562 csrNeighborRoamReassocIndCallback,
563 VOS_MODULE_ID_SME);
564
565 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
566 {
567 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800568 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 }
570
Srinivasdaaec712012-12-12 15:59:44 -0800571 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
572 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800573 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
574 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
575 WLANTL_HO_THRESHOLD_UP,
576 csrNeighborRoamNeighborLookupUPCallback,
577 VOS_MODULE_ID_SME);
Jeff Johnson295189b2012-06-20 16:38:30 -0700578
579 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
580 {
581 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800582 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 }
584
585 /* We dont need to run this timer any more. */
586 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800587 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -0800589 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 return VOS_STATUS_SUCCESS;
592}
593
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700594/*CleanUP Routines*/
595static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
596{
597 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
598 (rChInfo->currentChannelListInfo.numOfChannels))
599 {
600 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
601 rChInfo->currentChannelListInfo.numOfChannels = 0;
602
603 if (rChInfo->currentChannelListInfo.ChannelList)
604 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
605
606 rChInfo->currentChannelListInfo.ChannelList = NULL;
607 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
608 }
609 else
610 {
611 rChInfo->currentChanIndex = 0;
612 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
613 }
614}
615
616static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
617{
618 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
619
620 /* Stop neighbor scan timer */
621 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
622
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700623 /* Stop neighbor scan results refresh timer */
624 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
625
Srinivas Girigowdade697412013-02-14 16:31:48 -0800626 /* Stop empty scan results refresh timer */
627 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
628
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700629 /* Abort any ongoing scan */
630 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
631 {
632 csrScanAbortMacScan(pMac);
633 }
634 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
635
636 /* Reset roam channel list information */
637 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
638}
639
640static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
641{
642 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
643
644#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
645 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700646 /* Purge pre-auth fail list */
647 csrNeighborRoamPurgePreauthFailedList(pMac);
648#endif
649
650 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
651 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
652#ifdef WLAN_FEATURE_VOWIFI_11R
653 /* Do not free up the preauth done list here */
654 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
655 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
656 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
657 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700658#endif
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -0700659#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
660 pNeighborRoamInfo->uOsRequestedHandoff = 0;
661 vos_mem_zero(&pNeighborRoamInfo->handoffReqInfo, sizeof(tCsrHandoffRequest));
662#endif
663
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700664}
665
666static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
667{
668 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
669 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
670
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800671 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700672 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800673 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700674
675 /* Deregister reassoc callback. Ignore return status */
676 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800677 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700678 WLANTL_HO_THRESHOLD_UP,
679 csrNeighborRoamNeighborLookupUPCallback,
680 VOS_MODULE_ID_SME);
681
682 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800684 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700685 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800686 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700687 }
688
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800689 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700690 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
691 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
692
693 /* Deregister reassoc callback. Ignore return status */
694 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
695 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
696 WLANTL_HO_THRESHOLD_DOWN,
697 csrNeighborRoamReassocIndCallback,
698 VOS_MODULE_ID_SME);
699
700 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800702 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700703 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800704 "TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700705 }
706
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800707 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700708 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
709 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
710
711 /* Deregister neighbor lookup callback. Ignore return status */
712 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
713 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
714 WLANTL_HO_THRESHOLD_DOWN,
715 csrNeighborRoamNeighborLookupDOWNCallback,
716 VOS_MODULE_ID_SME);
717
718 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800720 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700721 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800722 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700723 }
724
725 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700726 pNeighborRoamInfo->currentNeighborLookupThreshold =
727 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800728#ifdef FEATURE_WLAN_LFR
729 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -0800730 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -0800731 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800732#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700733}
734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735/* ---------------------------------------------------------------------------
736
737 \fn csrNeighborRoamResetConnectedStateControlInfo
738
739 \brief This function will reset the neighbor roam control info data structures.
740 This function should be invoked whenever we move to CONNECTED state from
741 any state other than INIT state
742
743 \param pMac - The handle returned by macOpen.
744
745 \return VOID
746
747---------------------------------------------------------------------------*/
748void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
749{
750 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
751
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700752 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700754
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700755 /* We dont need to run this timer any more. */
756 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800757 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758
759#ifdef WLAN_FEATURE_VOWIFI_11R
760 /* Do not free up the preauth done list here */
761 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
762 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
763 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
764 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
765 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
766 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767#endif
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -0700768#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
769 pNeighborRoamInfo->uOsRequestedHandoff = 0;
770 vos_mem_zero(&pNeighborRoamInfo->handoffReqInfo, sizeof(tCsrHandoffRequest));
771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700772}
773
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700774void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700775{
776 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
778 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
779 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
780 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700781#ifdef FEATURE_WLAN_CCX
782 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
783 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
784 pNeighborRoamInfo->MinQBssLoadRequired = 0;
785#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700786
787 /* Stop scan refresh timer */
788 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -0800789 /* Stop empty scan results refresh timer */
790 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700791 /* Purge roamable AP list */
792 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 return;
794}
795
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700796/* ---------------------------------------------------------------------------
797
798 \fn csrNeighborRoamResetInitStateControlInfo
799
800 \brief This function will reset the neighbor roam control info data structures.
801 This function should be invoked whenever we move to CONNECTED state from
802 INIT state
803
804 \param pMac - The handle returned by macOpen.
805
806 \return VOID
807
808---------------------------------------------------------------------------*/
809void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
810{
811 csrNeighborRoamResetConnectedStateControlInfo(pMac);
812
813 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
814 csrNeighborRoamResetReportScanStateControlInfo(pMac);
815}
816
817
818
Jeff Johnson295189b2012-06-20 16:38:30 -0700819#ifdef WLAN_FEATURE_VOWIFI_11R
820/* ---------------------------------------------------------------------------
821
822 \fn csrNeighborRoamBssIdScanFilter
823
824 \brief This API is used to prepare a filter to obtain scan results when
825 we complete the scan in the REPORT_SCAN state after receiving a
826 valid neighbor report from AP. This filter includes BSSIDs received from
827 the neighbor report from the AP in addition to the other filter parameters
828 created from connected profile
829
830 \param pMac - The handle returned by macOpen.
831 pScanFilter - Scan filter to be filled and returned
832
833 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
834 code otherwise
835
836---------------------------------------------------------------------------*/
837static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
838{
839 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
840 tANI_U8 i = 0;
841
842 VOS_ASSERT(pScanFilter != NULL);
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +0530843 if (pScanFilter == NULL)
844 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
846
847 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
848 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
849 if (NULL == pScanFilter->BSSIDs.bssid)
850 {
851 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
852 return eHAL_STATUS_FAILED_ALLOC;
853 }
854
855 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
856
857 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
858 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
859 {
860 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
861 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
862 }
863
864 /* Fill other general scan filter params */
865 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
866}
867
868/* ---------------------------------------------------------------------------
869
870 \fn csrNeighborRoamPurgePreauthFailList
871
872 \brief This function empties the preauth fail list
873
874 \param pMac - The handle returned by macOpen.
875
876 \return VOID
877
878---------------------------------------------------------------------------*/
879void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
880{
881 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
882
883 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
884 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
885 {
886 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
887 sizeof(tSirMacAddr));
888 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
889 }
890 return;
891}
892
893/* ---------------------------------------------------------------------------
894
895 \fn csrNeighborRoamAddBssIdToPreauthFailList
896
897 \brief This function adds the given BSSID to the Preauth fail list
898
899 \param pMac - The handle returned by macOpen.
900 bssId - BSSID to be added to the preauth fail list
901
902 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
903
904---------------------------------------------------------------------------*/
905eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
906{
907 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
908
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800909 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL(" Added BSSID %02x:%02x:%02x:%02x:%02x:%02x to Preauth failed list"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
911
912
913 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
914 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
915 {
916 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
917 return eHAL_STATUS_FAILURE;
918 }
919 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
920 bssId, sizeof(tSirMacAddr));
921 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
922
923 return eHAL_STATUS_SUCCESS;
924}
925
926/* ---------------------------------------------------------------------------
927
928 \fn csrNeighborRoamIsPreauthCandidate
929
930 \brief This function checks whether the given MAC address is already
931 present in the preauth fail list and returns TRUE/FALSE accordingly
932
933 \param pMac - The handle returned by macOpen.
934
935 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
936
937---------------------------------------------------------------------------*/
938tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
939{
940 tANI_U8 i = 0;
941 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
942
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700943#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
944 if (csrRoamIsRoamOffloadScanEnabled(pMac))
945 {
946 return eANI_BOOLEAN_TRUE;
947 }
948#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
950 return eANI_BOOLEAN_TRUE;
951
952 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
953 {
954 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
955 bssId, sizeof(tSirMacAddr)))
956 {
957 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
958 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
959 return eANI_BOOLEAN_FALSE;
960 }
961 }
962
963 return eANI_BOOLEAN_TRUE;
964}
965
966/* ---------------------------------------------------------------------------
967
968 \fn csrNeighborRoamIssuePreauthReq
969
970 \brief This function issues preauth request to PE with the 1st AP entry in the
971 roamable AP list
972
973 \param pMac - The handle returned by macOpen.
974
975 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
976
977---------------------------------------------------------------------------*/
978static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
979{
980 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
981 eHalStatus status = eHAL_STATUS_SUCCESS;
982 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
983
984 /* This must not be true here */
985 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
986
987 /* Issue Preauth request to PE here */
988 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
989 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
990 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
991 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
992
993 if (NULL == pNeighborBssNode)
994 {
995 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
996 return eHAL_STATUS_FAILURE;
997 }
998 else
999 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001000 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
1001 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301002
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001003 smsLog(pMac, LOG1, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301004 pNeighborBssNode->pBssDescription->bssId[0],
1005 pNeighborBssNode->pBssDescription->bssId[1],
1006 pNeighborBssNode->pBssDescription->bssId[2],
1007 pNeighborBssNode->pBssDescription->bssId[3],
1008 pNeighborBssNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001009 pNeighborBssNode->pBssDescription->bssId[5],
1010 (int)pNeighborBssNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301011
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 if (eHAL_STATUS_SUCCESS != status)
1013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001014 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001015 return status;
1016 }
1017 }
1018
1019 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
1020
1021 /* Increment the preauth retry count */
1022 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
1023
1024 /* Transition the state to preauthenticating */
1025 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Jeff Johnson295189b2012-06-20 16:38:30 -07001026
1027 return status;
1028}
1029
1030/* ---------------------------------------------------------------------------
1031
1032 \fn csrNeighborRoamPreauthRspHandler
1033
1034 \brief This function handle the Preauth response from PE
1035 Every preauth is allowed max 3 tries if it fails. If a bssid failed
1036 for more than MAX_TRIES, we will remove it from the list and try
1037 with the next node in the roamable AP list and add the BSSID to pre-auth failed
1038 list. If no more entries present in
1039 roamable AP list, transition to REPORT_SCAN state
1040
1041 \param pMac - The handle returned by macOpen.
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001042 limStatus - eSIR_SUCCESS/eSIR_FAILURE/eSIR_LIM_MAX_STA_REACHED_ERROR/
1043 eSIT_LIM_AUTH_RSP_TIMEOUT status from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07001044
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001045 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
1046 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -07001047
1048---------------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001049eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, tSirRetStatus limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001050{
1051 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1052 eHalStatus status = eHAL_STATUS_SUCCESS;
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001053 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001054 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001056
1057 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
1058 {
1059
1060 /* This can happen when we disconnect immediately
1061 * after sending a pre-auth request. During processing
1062 * of the disconnect command, we would have reset
1063 * preauthRspPending and transitioned to INIT state.
1064 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001065 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
1066 FL("Unexpected pre-auth response in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001067 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001068 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001069 goto DEQ_PREAUTH;
1070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001071
1072 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
1074 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
1075 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001076 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001077 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001078 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001079 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 }
1081
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001082 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001083
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001084 if (eSIR_SUCCESS == limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 {
1086 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
1087 }
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001088 if ((eSIR_SUCCESS == limStatus) && (NULL != pPreauthRspNode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001090 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
Jeff Johnson295189b2012-06-20 16:38:30 -07001091
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001092 smsLog(pMac, LOG1, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301093 pPreauthRspNode->pBssDescription->bssId[0],
1094 pPreauthRspNode->pBssDescription->bssId[1],
1095 pPreauthRspNode->pBssDescription->bssId[2],
1096 pPreauthRspNode->pBssDescription->bssId[3],
1097 pPreauthRspNode->pBssDescription->bssId[4],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001098 pPreauthRspNode->pBssDescription->bssId[5],
1099 (int)pPreauthRspNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301100
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
1102 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
1103 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
1104
1105 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
1106 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
1107 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
1108
1109 /* The caller of this function would start a timer and by the time it expires, supplicant should
1110 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
1111 }
1112 else
1113 {
1114 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
1115 tListElem *pEntry;
1116
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001117 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = 0x%x"),
1118 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, limStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001119
1120 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001121 if ((pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >=
1122 CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES) ||
1123 (eSIR_LIM_MAX_STA_REACHED_ERROR == limStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 {
1125 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
1126 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
1127
1128 /* The one in the head of the list should be one with which we issued pre-auth and failed */
1129 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
1130 if(pEntry)
1131 {
1132 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001133 /* Add the BSSID to pre-auth fail list if it is not requested by HDD */
1134#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1135 if(!pNeighborRoamInfo->uOsRequestedHandoff)
1136#endif
1137 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 /* Now we can free this node */
1141 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
1142 }
1143 }
1144
1145 /* Issue preauth request for the same/next entry */
1146 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001147 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07001148
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001149#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1150 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001151 {
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07001152 if(pNeighborRoamInfo->uOsRequestedHandoff)
1153 {
1154 pNeighborRoamInfo->uOsRequestedHandoff = 0;
1155 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_PREAUTH_FAILED_FOR_ALL);
1156 }
1157 else
1158 {
1159 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_RESTART, REASON_PREAUTH_FAILED_FOR_ALL);
1160 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001161 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1162 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001164#endif
1165 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
1166
1167 /* Register Neighbor Lookup threshold callback with TL for UP event now */
1168 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
1169 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1170
1171 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1172 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1173 WLANTL_HO_THRESHOLD_UP,
1174 csrNeighborRoamNeighborLookupUPCallback,
1175 VOS_MODULE_ID_SME, pMac);
1176 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1177 {
1178 //err msg
1179 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
1180 }
1181
1182 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
1183 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1184 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1185 eANI_BOOLEAN_FALSE);
1186 if (eHAL_STATUS_SUCCESS != status)
1187 {
1188 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d"), status);
1189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001191#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001193#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001194
1195DEQ_PREAUTH:
1196 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001197 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001198}
1199#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
1200
1201/* ---------------------------------------------------------------------------
1202
1203 \fn csrNeighborRoamPrepareScanProfileFilter
1204
1205 \brief This function creates a scan filter based on the currently connected profile.
1206 Based on this filter, scan results are obtained
1207
1208 \param pMac - The handle returned by macOpen.
1209 pScanFilter - Populated scan filter based on the connected profile
1210
1211 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
1212
1213---------------------------------------------------------------------------*/
1214eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
1215{
1216 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1217 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
1218 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
1219 tANI_U8 i = 0;
1220
1221 VOS_ASSERT(pScanFilter != NULL);
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05301222 if (pScanFilter == NULL)
1223 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001224
1225 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
1226
1227 /* We dont want to set BSSID based Filter */
1228 pScanFilter->BSSIDs.numOfBSSIDs = 0;
1229
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001230 //only for HDD requested handoff fill in the BSSID in the filter
1231#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1232 if (pNeighborRoamInfo->uOsRequestedHandoff)
1233 {
1234 pScanFilter->BSSIDs.numOfBSSIDs = 1;
1235 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
1236 if (NULL == pScanFilter->BSSIDs.bssid)
1237 {
1238 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
1239 return eHAL_STATUS_FAILED_ALLOC;
1240 }
1241
1242 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
1243
1244 /* Populate the BSSID from handoff info received from HDD */
1245 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
1246 {
1247 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
1248 pNeighborRoamInfo->handoffReqInfo.bssid, sizeof(tSirMacAddr));
1249 }
1250 }
1251#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 /* Populate all the information from the connected profile */
1253 pScanFilter->SSIDs.numOfSSIDs = 1;
1254 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
1255 if (NULL == pScanFilter->SSIDs.SSIDList)
1256 {
1257 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
1258 return eHAL_STATUS_FAILED_ALLOC;
1259 }
1260 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
1261 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
1262 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
1263 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
1264
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301265 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering from scan results for"
1266 "SSID = 0x%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx\nSSID Length = %d"),
1267 pScanFilter->SSIDs.SSIDList->SSID.ssId[0],
1268 pScanFilter->SSIDs.SSIDList->SSID.ssId[4],
1269 pScanFilter->SSIDs.SSIDList->SSID.ssId[8],
1270 pScanFilter->SSIDs.SSIDList->SSID.ssId[12],
1271 pScanFilter->SSIDs.SSIDList->SSID.ssId[16],
1272 pScanFilter->SSIDs.SSIDList->SSID.ssId[20],
1273 pScanFilter->SSIDs.SSIDList->SSID.ssId[24],
1274 pScanFilter->SSIDs.SSIDList->SSID.ssId[28],
1275 pScanFilter->SSIDs.SSIDList->SSID.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 pScanFilter->authType.numEntries = 1;
1277 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
1278
1279 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
1280 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
1281
1282 pScanFilter->mcEncryptionType.numEntries = 1;
1283 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
1284
1285 pScanFilter->BSSType = pCurProfile->BSSType;
1286
1287 /* We are intrested only in the scan results on channels that we scanned */
1288 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
1289 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
1290 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1291 {
1292 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1293 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1294 pScanFilter->SSIDs.SSIDList = NULL;
1295 return eHAL_STATUS_FAILED_ALLOC;
1296 }
1297 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1298 {
1299 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1300 }
1301
1302#ifdef WLAN_FEATURE_VOWIFI_11R
1303 if (pNeighborRoamInfo->is11rAssoc)
1304 {
1305 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1306 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1307 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1308 }
1309#endif
1310
1311 return eHAL_STATUS_SUCCESS;
1312}
1313
Jeff Johnson43971f52012-07-17 12:26:56 -07001314tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1315{
1316 tCsrScanResultInfo *pScanResult;
1317 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda2efea0e2013-01-24 17:40:41 -08001318#ifdef FEATURE_WLAN_LFR
1319 tANI_U32 CurrAPRssi = pNeighborRoamInfo->lookupDOWNRssi;
1320#else
1321 /* We are setting this as default value to make sure we return this value,
1322 when we do not see this AP in the scan result for some reason.However,it is
1323 less likely that we are associated to an AP and do not see it in the scan list */
1324 tANI_U32 CurrAPRssi = -125;
1325#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001326
1327 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1328 {
1329
1330 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1331 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1332 {
1333 /* We got a match with the currently associated AP.
1334 * Capture the RSSI value and complete the while loop.
1335 * The while loop is completed in order to make the current entry go back to NULL,
1336 * and in the next while loop, it properly starts searching from the head of the list.
1337 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1338
1339 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1340
1341 } else {
1342 continue;
1343 }
1344 }
1345
1346 return CurrAPRssi;
1347
1348}
1349
Jeff Johnson295189b2012-06-20 16:38:30 -07001350/* ---------------------------------------------------------------------------
1351
1352 \fn csrNeighborRoamProcessScanResults
1353
1354 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1355 Assumed that the results are already sorted by RSSI by csrScanGetResult
1356
1357 \param pMac - The handle returned by macOpen.
1358 pScanResultList - Scan result result obtained from csrScanGetResult()
1359
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001360 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1361 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363---------------------------------------------------------------------------*/
1364
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001365static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1366 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001367{
1368 tCsrScanResultInfo *pScanResult;
1369 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1370 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001371 tANI_U32 CurrAPRssi;
1372 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001373#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1374 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1375#endif
1376 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001377
1378 /***************************************************************
1379 * Find out the Current AP RSSI and keep it handy to check if
1380 * it is better than the RSSI of the AP which we are
1381 * going to roam.If so, we are going to continue with the
1382 * current AP.
1383 ***************************************************************/
1384 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001385
1386 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1387 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1388 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1389 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1390 /* 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
1391 and rssi score are in the same order. This will be taken care later */
1392
1393 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1394 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001395 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
1396 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d, Ch:%d)"),
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001397 pScanResult->BssDescriptor.bssId[0],
1398 pScanResult->BssDescriptor.bssId[1],
1399 pScanResult->BssDescriptor.bssId[2],
1400 pScanResult->BssDescriptor.bssId[3],
1401 pScanResult->BssDescriptor.bssId[4],
1402 pScanResult->BssDescriptor.bssId[5],
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001403 abs(pScanResult->BssDescriptor.rssi),
1404 pScanResult->BssDescriptor.channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001405
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001406 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1408 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001409 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001410 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001411 "SKIP-currently associated AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 continue;
1413 }
1414
Jeff Johnson43971f52012-07-17 12:26:56 -07001415 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1416 * is disabled and we continue to roam without any check*/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001417 if ((RoamRssiDiff > 0)
1418#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1419 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1420#endif
1421 )
Jeff Johnson43971f52012-07-17 12:26:56 -07001422 {
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001423 /*
1424 * If RSSI is lower than the lookup threshold, then continue.
1425 */
1426 if (abs(pScanResult->BssDescriptor.rssi) >
1427 pNeighborRoamInfo->currentNeighborLookupThreshold)
1428 {
1429 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001430 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)",
Madan Mohan Koyyalamudif553b742012-12-03 16:37:39 -08001431 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1432 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1433 continue;
1434 }
1435
Jeff Johnson43971f52012-07-17 12:26:56 -07001436 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1437 {
1438 /*Do not roam to an AP with worse RSSI than the current*/
1439 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001440 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001441 CurrAPRssi,
1442 (int)pScanResult->BssDescriptor.rssi * (-1) );
1443 continue;
1444 } else {
1445 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1446 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1447 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1448 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001449 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001450 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d", __func__,
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001451 CurrAPRssi,
1452 (int)pScanResult->BssDescriptor.rssi * (-1),
1453 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001454 continue;
1455 }
1456 else {
1457 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001458 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001459 CurrAPRssi,
1460 (int)pScanResult->BssDescriptor.rssi * (-1) );
1461 }
1462 }
1463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001464
1465#ifdef WLAN_FEATURE_VOWIFI_11R
1466 if (pNeighborRoamInfo->is11rAssoc)
1467 {
1468 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1469 {
1470 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1471 continue;
1472 }
1473 }
1474#endif /* WLAN_FEATURE_VOWIFI_11R */
1475
1476#ifdef FEATURE_WLAN_CCX
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001477#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1478 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001480#endif
1481 if (pNeighborRoamInfo->isCCXAssoc)
1482 {
1483 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1484 {
1485 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1486 continue;
1487 }
1488 }
1489 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1490 (pScanResult->BssDescriptor.QBSSLoad_avail))
1491 {
1492 if (pNeighborRoamInfo->isVOAdmitted)
1493 {
1494 smsLog(pMac, LOG1, FL("New AP has %x BW available"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1495 smsLog(pMac, LOG1, FL("We need %x BW available"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
1496 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1497 {
1498 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1499 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list",
1500 pScanResult->BssDescriptor.bssId[0],
1501 pScanResult->BssDescriptor.bssId[1],
1502 pScanResult->BssDescriptor.bssId[2],
1503 pScanResult->BssDescriptor.bssId[3],
1504 pScanResult->BssDescriptor.bssId[4],
1505 pScanResult->BssDescriptor.bssId[5]);
1506 continue;
1507 }
1508 }
1509 }
1510 else
1511 {
1512 smsLog(pMac, LOGE, FL("No QBss %x %x"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
1513 if (pNeighborRoamInfo->isVOAdmitted)
1514 {
1515 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1516 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no QBSSLoad IE, ignoring..not adding to roam list",
1517 pScanResult->BssDescriptor.bssId[0],
1518 pScanResult->BssDescriptor.bssId[1],
1519 pScanResult->BssDescriptor.bssId[2],
1520 pScanResult->BssDescriptor.bssId[3],
1521 pScanResult->BssDescriptor.bssId[4],
1522 pScanResult->BssDescriptor.bssId[5]);
1523 continue;
1524 }
1525 }
1526#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001528#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001529#endif /* FEATURE_WLAN_CCX */
1530
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001531#ifdef FEATURE_WLAN_LFR
1532 // If we are supporting legacy roaming, and
1533 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301534 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001535 {
1536 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1537 {
1538 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1539 continue;
1540 }
1541 }
1542#endif /* FEATURE_WLAN_LFR */
1543
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1545 * this result */
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001546 if ((pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1547#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1548 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1549#endif
1550 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001551 {
1552 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1553 continue;
1554 }
1555
1556 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1557 if (NULL == pBssInfo)
1558 {
1559 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1560 continue;
1561 }
1562
1563 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1564 if (pBssInfo->pBssDescription != NULL)
1565 {
1566 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1567 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1568 }
1569 else
1570 {
1571 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1572 vos_mem_free(pBssInfo);
1573 continue;
1574
1575 }
1576 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1577
1578 /* Just add to the end of the list as it is already sorted by RSSI */
1579 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001580
1581#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001582 if ((abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
1583#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1584 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1585#endif
1586 )
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001587 {
1588 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1589 "%s: [INFOLOG] potential candidate to roam immediately (diff=%d, expected=%d)",
1590 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1591 immediateRoamRssiDiff);
1592 roamNow = eANI_BOOLEAN_TRUE;
1593 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001594#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1595 /* If we are here means, FW already found candidates to roam, so we are
1596 good to go with pre-auth */
1597 if(csrRoamIsRoamOffloadScanEnabled(pMac))
1598 {
1599 roamNow = eANI_BOOLEAN_TRUE;
1600 }
1601#endif
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001602#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 }
1604
1605 /* 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 */
1606 csrScanResultPurge(pMac, *pScanResultList);
1607
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001608 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609}
1610
1611/* ---------------------------------------------------------------------------
1612
1613 \fn csrNeighborRoamHandleEmptyScanResult
1614
1615 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1616 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001617 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001619 1. Stop the neighbor scan timer.
1620 2a. If this is the first time we encountered empty scan, then
1621 re-register with TL with modified lookup threshold.
1622 2b. Else if this is the second time we encountered empty scan,
1623 then start neighbor scan results refresh timer (20s).
1624 2c. Else, nothing more to do.
1625 NOTE: In LFR, channels selected for scanning is dervied from
1626 the occuped channel list. Scan cycle following one which
1627 yielded empty results is split into two halves: (i) scan on
1628 channels in the occupied list, and (ii) scan on channels not
1629 in the occupied list. This helps converging faster (while
1630 looking for candidates in the occupied list first), and also,
1631 adds channels to the occupied channel list upon finding candidates
1632 matching SSID profile of interest.
1633
1634 uEmptyScanCount Comments
1635 eFirstEmptyScan Previous scan was done on channels in the
1636 occupied list and yielded potential candidates.
1637 This scan cycle was likely triggered through
1638 receipt of lookup DOWN notification event.
1639 eSecondEmptyScan Previous scan was done on channels in the
1640 occupied list and yielded no candidates. This scan
1641 cycle was triggered through RSSI notification
1642 with modified lookup threshold.
1643 eThirdEmptyScan Previous scan was done on channels NOT in
1644 the occupied list and yielded no candidates. This
1645 scan cycle was triggered immediately after scanning
1646 channels in the occupied list and no candidates
1647 were found.
1648 eFourthEmptyScan Previous scan was done on channels in the
1649 occupied list and yielded no candidates. This scan
1650 cycle was triggered upon expiry of
1651 neighborScanResultsRefreshPeriod (=20s).
1652 eFifthEmptyScan Previous scan was done on channels NOT in
1653 the occupied list and yielded no candidates. This
1654 scan cycle was triggered immediately after scanning
1655 channels in the occupied list and no candidates
1656 were found.
1657
1658 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001659
1660 \param pMac - The handle returned by macOpen.
1661
1662 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1663
1664---------------------------------------------------------------------------*/
1665static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1666{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001667 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1669 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001670#ifdef FEATURE_WLAN_LFR
1671 tANI_BOOLEAN performPeriodicScan =
1672 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod) ? TRUE : FALSE;
1673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001674
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001675 /* Stop neighbor scan timer */
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 status = palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001677 if (eHAL_STATUS_SUCCESS != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001679 smsLog(pMac, LOGW, FL("stopping neighborScanTimer failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 }
1681
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001682 /*
1683 * Increase the neighbor lookup threshold by 3 dB
1684 * after every scan cycle. NOTE: uEmptyScanCount
1685 * would be either 1, 3 or 5 at the end of every
1686 * scan cycle.
1687 */
1688#ifdef FEATURE_WLAN_LFR
1689 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1690 {
1691 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1692 }
Srikant Kuppa327c52e2013-05-09 15:09:24 -07001693 if (((0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) ||
1694 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
1695 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold))) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001696 ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1697 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan)))
1698 {
1699 /*
1700 * If the scan was triggered due to lookupDOWNRssi > reassoc threshold,
1701 * then it would be a contiguous scan on all valid non-DFS channels.
Srikant Kuppa327c52e2013-05-09 15:09:24 -07001702 * If channels are configured in INI, then only those channels need
1703 * to be scanned.
1704 * In either of these modes, there is no need to trigger an immediate
1705 * scan upon empty scan results for the second and fourth time (which
1706 * would be equivalent to scanning on channels in non-occupied list).
Srinivas Girigowdade697412013-02-14 16:31:48 -08001707 * Incrementing uEmptyScanCount will correspond to skipping this step.
1708 * NOTE: double increment of uEmptyScanCount corresponds to completion
1709 * of scans on all valid channels.
1710 */
1711 ++pNeighborRoamInfo->uEmptyScanCount;
1712 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Extra increment of empty scan count (=%d)"
1713 " in contiguous scan mode", pNeighborRoamInfo->uEmptyScanCount);
1714 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001715#endif
1716 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1717 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1718#ifdef FEATURE_WLAN_LFR
1719 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1720#endif
1721 )
1722 {
1723 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1724 }
1725
Jeff Johnson295189b2012-06-20 16:38:30 -07001726#ifdef WLAN_FEATURE_VOWIFI_11R
1727 /* Clear off the old neighbor report details */
1728 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1729#endif
1730
Srikant Kuppa866893f2012-12-27 17:28:14 -08001731 /* Transition to CONNECTED state */
1732 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1733
1734 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1735 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1736
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001737#ifdef FEATURE_WLAN_LFR
1738 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1739 {
1740#endif
1741 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001742 /* Re-register neighbor lookup DOWN threshold callback with TL */
1743 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1744 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1745 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1746
1747 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1748 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1749 WLANTL_HO_THRESHOLD_DOWN,
1750 csrNeighborRoamNeighborLookupDOWNCallback,
1751 VOS_MODULE_ID_SME, pMac);
1752
1753 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1754 {
1755 smsLog(pMac, LOGW,
1756 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001757 " with TL: Status = %d"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001758 }
1759#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08001760 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001761 }
1762 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1763 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1764 {
1765 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001766
1767 /* Immediately scan on channels in non-occupied list */
1768 csrNeighborRoamTransitToCFGChanScan(pMac);
1769 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001770 else if (pNeighborRoamInfo->uEmptyScanCount >= eThirdEmptyScan)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001771 {
1772 /* Empty scan results for the third time */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001773 if (performPeriodicScan)
1774 {
1775 smsLog(pMac, LOGE, FL("Performing periodic scan, uEmptyScanCount=%d"),
1776 pNeighborRoamInfo->uEmptyScanCount);
Srikant Kuppa866893f2012-12-27 17:28:14 -08001777
Srinivas Girigowdade697412013-02-14 16:31:48 -08001778 /*
1779 * Set uEmptyScanCount to MAX so that we always enter this
1780 * condition on subsequent empty scan results
1781 */
1782 pNeighborRoamInfo->uEmptyScanCount = eMaxEmptyScan;
1783
1784 /* From here on, ONLY scan on channels in the occupied list */
1785 pNeighborRoamInfo->uScanMode = SPLIT_SCAN_OCCUPIED_LIST;
1786
1787 /* Start empty scan refresh timer */
1788 if (eHAL_STATUS_SUCCESS !=
1789 palTimerStart(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer,
1790 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1791 eANI_BOOLEAN_FALSE))
1792 {
1793 smsLog(pMac, LOGE, FL("Empty scan refresh timer failed to start (%d)"),
1794 status);
1795 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1796 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001797 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001798 vosStatus = VOS_STATUS_E_FAILURE;
1799 }
1800 else
1801 {
1802 smsLog(pMac, LOGE, FL("Empty scan refresh timer started (%ld ms)"),
1803 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod));
1804 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001805 }
Srikant Kuppa327c52e2013-05-09 15:09:24 -07001806 else if (eThirdEmptyScan == pNeighborRoamInfo->uEmptyScanCount)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001807 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001808 /* Start neighbor scan results refresh timer */
1809 if (eHAL_STATUS_SUCCESS !=
1810 palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
1811 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
1812 eANI_BOOLEAN_FALSE))
1813 {
1814 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1815 status);
1816 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1817 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07001818 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001819 vosStatus = VOS_STATUS_E_FAILURE;
1820 }
1821 else
1822 {
1823 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1824 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1825 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001828
Srinivas Girigowdade697412013-02-14 16:31:48 -08001829 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d scan mode=%d",
1830 pNeighborRoamInfo->uEmptyScanCount, pNeighborRoamInfo->uScanMode);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001831#endif
1832 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001833}
1834
Jeff Johnson295189b2012-06-20 16:38:30 -07001835
Srikant Kuppa866893f2012-12-27 17:28:14 -08001836static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001837{
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 tCsrScanResultFilter scanFilter;
1840 tScanResultHandle scanResult;
1841 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001842 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Srikant Kuppa866893f2012-12-27 17:28:14 -08001843 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001844
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001845#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1847 should use the BSSID filter made out of neighbor reports */
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001848 if ((eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1849#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1850 && (!csrRoamIsRoamOffloadScanEnabled(pMac))
1851#endif
1852 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001854 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1855 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 -07001856 tempVal = 1;
1857 }
1858 else
1859#endif
1860 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001861 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1862 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 -07001863 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001864 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 {
1866 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1867 return eHAL_STATUS_FAILURE;
1868 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001869 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301870 if (hstatus != eHAL_STATUS_SUCCESS)
1871 {
1872 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001875 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876
1877 /* Free the scan filter */
1878 csrFreeScanFilter(pMac, &scanFilter);
1879
1880 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1881
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001882#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1883 if(!csrRoamIsRoamOffloadScanEnabled(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001885#endif
1886 switch(pNeighborRoamInfo->neighborRoamState)
1887 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1889 if (tempVal)
1890 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001891#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001892 /*
1893 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001894 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001895 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001896 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001897 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001898#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001899#ifdef WLAN_FEATURE_VOWIFI_11R
1900 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1901 APs in the roamable AP list */
1902 if (pNeighborRoamInfo->is11rAssoc)
1903 {
1904 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1905 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1906 }
1907 else
1908#endif
1909#ifdef FEATURE_WLAN_CCX
1910 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1911 APs in the roamable AP list */
1912 if (pNeighborRoamInfo->isCCXAssoc)
1913 {
1914 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1915 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1916 }
1917 else
1918#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001919#ifdef FEATURE_WLAN_LFR
1920 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1921 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301922 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001923 {
1924 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1925 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1926 }
1927 else
1928#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 {
1930
1931 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1932 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1933 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1934 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1935 within certain duration */
1936
1937// palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
1938 }
1939 }
1940 else
1941 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001942 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1943 /* Handle it appropriately */
1944 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 }
1946 break;
1947#ifdef WLAN_FEATURE_VOWIFI_11R
1948 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1949 if (!tempVal)
1950 {
1951 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1952 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1953 csrNeighborRoamTransitToCFGChanScan(pMac);
1954 }
1955 break;
1956#endif /* WLAN_FEATURE_VOWIFI_11R */
1957 default:
1958 // Can come only in INIT state. Where in we are associated, we sent scan and user
1959 // in the meantime decides to disassoc, we will be in init state and still received call
1960 // back issued. Should not come here in any other state, printing just in case
1961 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001962 "%s: [INFOLOG] State %d", __func__, (pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001963
1964 // Lets just exit out silently.
1965 return eHAL_STATUS_SUCCESS;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001966 }
1967#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001969#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001970
1971 if (tempVal)
1972 {
1973 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1974
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001975 if (roamNow)
1976 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001977#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1978 if(!csrRoamIsRoamOffloadScanEnabled(pMac))
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001979 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001980#endif
1981 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
1982 FL("Immediate roam-deregister UP indication. RSSI = %d"),
1983 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1984
1985 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
1986 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1987 WLANTL_HO_THRESHOLD_UP,
1988 csrNeighborRoamNeighborLookupUPCallback,
1989 VOS_MODULE_ID_SME);
1990
1991 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1992 {
1993 smsLog(pMac, LOGW,
1994 FL("Couldn't deregister lookup UP callback with TL: Status = %d"), vosStatus);
1995 }
1996#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001997 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001998#endif
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001999
2000 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
2001 return eHAL_STATUS_SUCCESS;
2002 }
2003
Srikant Kuppa866893f2012-12-27 17:28:14 -08002004 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer,
2005 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT,
2006 eANI_BOOLEAN_FALSE);
2007
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
2009 * that the callback getting called immediately and the timer would never be stopped when pre-auth is in progress */
Srikant Kuppa866893f2012-12-27 17:28:14 -08002010 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002012 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2014 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002015 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson43971f52012-07-17 12:26:56 -07002016 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002018
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2020 /* Register a reassoc Indication callback */
2021 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2022 WLANTL_HO_THRESHOLD_DOWN,
2023 csrNeighborRoamReassocIndCallback,
2024 VOS_MODULE_ID_SME, pMac);
2025
2026 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2027 {
2028 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002029 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 }
2031
2032 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002033
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002034#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2035if (csrRoamIsRoamOffloadScanEnabled(pMac))
2036 {
2037 if (!tempVal || !roamNow)
2038 {
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07002039 if (pNeighborRoamInfo->uOsRequestedHandoff)
2040 {
2041 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
2042 pNeighborRoamInfo->uOsRequestedHandoff = 0;
2043 }
2044 else
2045 {
2046 /* There is no candidate or We are not roaming Now.
2047 * Inform the FW to restart Roam Offload Scan */
2048 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_RESTART, REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
2049 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002050 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
2051 }
2052 }
2053#endif
Srikant Kuppa866893f2012-12-27 17:28:14 -08002054 return eHAL_STATUS_SUCCESS;
2055
2056}
2057
2058
2059/* ---------------------------------------------------------------------------
2060
2061 \fn csrNeighborRoamScanRequestCallback
2062
2063 \brief This function is the callback function registered in csrScanRequest() to
2064 indicate the completion of scan. If scan is completed for all the channels in
2065 the channel list, this function gets the scan result and starts the refresh results
2066 timer to avoid having stale results. If scan is not completed on all the channels,
2067 it restarts the neighbor scan timer which on expiry issues scan on the next
2068 channel
2069
2070 \param halHandle - The handle returned by macOpen.
2071 pContext - not used
2072 scanId - not used
2073 status - not used
2074
2075 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2076
2077---------------------------------------------------------------------------*/
2078static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
2079 tANI_U32 scanId, eCsrScanStatus status)
2080{
2081 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2082 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2083 tANI_U8 currentChanIndex;
2084 eHalStatus hstatus;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002085#ifdef FEATURE_WLAN_LFR
2086 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002087
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002088 if (NULL != pContext)
2089 {
2090 sessionId = *((tANI_U32*)pContext);
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002091
2092 if (!csrRoamIsStaMode(pMac, sessionId))
2093 {
2094 smsLog(pMac, LOGE, FL("%s: Ignoring scan request callback on non-infra session %d in state %d"),
2095 __FUNCTION__, sessionId, pNeighborRoamInfo->neighborRoamState);
2096 vos_mem_free(pContext);
2097 return eHAL_STATUS_SUCCESS;
2098 }
2099
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002100 if (!csrRoamIsFastRoamEnabled(pMac,sessionId))
2101 {
2102 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
2103 vos_mem_free(pContext);
2104 return eHAL_STATUS_SUCCESS;
2105 }
2106 }
2107#endif
Srikant Kuppa866893f2012-12-27 17:28:14 -08002108 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
2109
2110 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
2111 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
2112 {
2113 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002114 if (NULL != pContext)
2115 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002116 return eHAL_STATUS_SUCCESS;
2117 }
2118
2119 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
2120 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
2121
2122 /* Validate inputs */
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002123 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002124 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08002125 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
2126 }
2127 else
2128 {
2129 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002130 if (NULL != pContext)
2131 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002132 return eHAL_STATUS_SUCCESS;
2133 }
2134
2135 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2136 {
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002137 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
Srikant Kuppa866893f2012-12-27 17:28:14 -08002138 just to get the results and perform PREAUTH */
2139 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
2140 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
2141 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
2142 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
2143
2144 hstatus = csrNeighborRoamProcessScanComplete(pMac);
2145
2146 if (eHAL_STATUS_SUCCESS != hstatus)
2147 {
2148 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002149 if (NULL != pContext)
2150 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002151 return eHAL_STATUS_FAILURE;
2152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 }
2154 else
2155 {
2156
2157 /* Restart the timer for the next scan sequence as scanning is not over */
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002158 hstatus = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
2159 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 eANI_BOOLEAN_FALSE);
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002161
Jeff Johnson43971f52012-07-17 12:26:56 -07002162 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 {
2164 /* Timer start failed.. Should we ASSERT here??? */
2165 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
2166 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2167 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002168 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002169 if (NULL != pContext)
2170 vos_mem_free(pContext);
Jeff Johnson43971f52012-07-17 12:26:56 -07002171 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 }
2173 }
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002174
2175 if (NULL != pContext)
2176 vos_mem_free(pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 return eHAL_STATUS_SUCCESS;
2178}
2179
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002180#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2181/* ---------------------------------------------------------------------------
2182
2183 \fn csrNeighborRoamScanResultRequestCallback
2184
2185 \brief This function is the callback function registered in csrScanRequestLfrResult() to
2186 indicate the completion of scan. If scan is completed for all the channels in
2187 the channel list, this function gets the scan result and treats them as candidates
2188
2189 \param halHandle - The handle returned by macOpen.
2190 pContext - not used
2191 scanId - not used
2192 status - not used
2193
2194 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2195
2196---------------------------------------------------------------------------*/
2197static eHalStatus csrNeighborRoamScanResultRequestCallback(tHalHandle halHandle, void *pContext,
2198 tANI_U32 scanId, eCsrScanStatus status)
2199{
2200 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2201 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2202 eHalStatus hstatus;
2203
2204 smsLog(pMac, LOG2, FL("called "));
2205 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
2206
2207 /* we must be in connected state, if not ignore it */
2208 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
2209 {
2210 smsLog(pMac, LOGW, FL("Received in not CONNECTED state. Ignore it"));
2211 return eHAL_STATUS_SUCCESS;
2212 }
2213
2214 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
2215 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
2216
2217 hstatus = csrNeighborRoamProcessScanComplete(pMac);
2218
2219 if (eHAL_STATUS_SUCCESS != hstatus)
2220 {
2221 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
2222 return eHAL_STATUS_FAILURE;
2223 }
2224 return eHAL_STATUS_SUCCESS;
2225}
2226#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2227
Srikant Kuppa866893f2012-12-27 17:28:14 -08002228#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002229static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002230 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
2231{
2232 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2233 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2234 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002235 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
2236
2237 if (NULL != pContext)
2238 {
2239 sessionId = *((tANI_U32*)pContext);
2240 if (!csrRoamIsFastRoamEnabled(pMac,sessionId))
2241 {
2242 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
2243 vos_mem_free(pContext);
2244 return eHAL_STATUS_SUCCESS;
2245 }
2246 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08002247
2248 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002249
Srikant Kuppa866893f2012-12-27 17:28:14 -08002250 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
2251 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
2252 {
2253 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002254 if (NULL != pContext)
2255 vos_mem_free(pContext);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002256 return eHAL_STATUS_SUCCESS;
2257 }
2258
Srinivas Girigowdade697412013-02-14 16:31:48 -08002259 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
2260 {
2261 smsLog(pMac, LOGE, FL("Received in INIT state. Must have disconnected. Ignore it"));
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002262 if (NULL != pContext)
2263 vos_mem_free(pContext);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002264 return eHAL_STATUS_SUCCESS;
2265 }
2266
Srikant Kuppa866893f2012-12-27 17:28:14 -08002267 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
2268 hstatus = csrNeighborRoamProcessScanComplete(pMac);
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002269
Srikant Kuppa866893f2012-12-27 17:28:14 -08002270 if (eHAL_STATUS_SUCCESS != hstatus)
2271 {
2272 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
2273 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002274
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002275 if (NULL != pContext)
2276 vos_mem_free(pContext);
2277
Srikant Kuppa866893f2012-12-27 17:28:14 -08002278 return hstatus;
2279}
2280#endif
2281
Jeff Johnson295189b2012-06-20 16:38:30 -07002282/* ---------------------------------------------------------------------------
2283
2284 \fn csrNeighborRoamIssueBgScanRequest
2285
2286 \brief This function issues CSR scan request after populating all the BG scan params
2287 passed
2288
2289 \param pMac - The handle returned by macOpen.
2290 pBgScanParams - Params that need to be populated into csr Scan request
2291
2292 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2293
2294---------------------------------------------------------------------------*/
Srikant Kuppa866893f2012-12-27 17:28:14 -08002295eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
2296 tCsrBGScanRequest *pBgScanParams,
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002297 tANI_U32 sessionId,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002298 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07002299{
2300 eHalStatus status = eHAL_STATUS_SUCCESS;
2301 tANI_U32 scanId;
2302 tCsrScanRequest scanReq;
2303 tANI_U8 channel;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002304 void * userData = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002305
Srikant Kuppa866893f2012-12-27 17:28:14 -08002306 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002307 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08002308 pBgScanParams->ChannelInfo.ChannelList[0],
2309 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07002310
2311 //send down the scan req for 1 channel on the associated SSID
2312 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
2313 /* Fill in the SSID Info */
2314 scanReq.SSIDs.numOfSSIDs = 1;
2315 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
2316 if(NULL == scanReq.SSIDs.SSIDList)
2317 {
2318 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002319 smsLog(pMac, LOGE, FL("Couldn't allocate memory for the SSID..Freeing memory allocated for Channel List"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 return eHAL_STATUS_FAILURE;
2321 }
2322 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
2323
2324 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
2325 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
2326 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
2327
2328 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002329 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
2330 {
2331 channel = pBgScanParams->ChannelInfo.ChannelList[0];
2332 scanReq.ChannelInfo.ChannelList = &channel;
2333 }
2334 else
2335 {
2336 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
2337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002338
2339 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2340 scanReq.scanType = eSIR_ACTIVE_SCAN;
2341 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
2342 scanReq.maxChnTime = pBgScanParams->maxChnTime;
2343 scanReq.minChnTime = pBgScanParams->minChnTime;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002344
2345 userData = vos_mem_malloc(sizeof(tANI_U32));
2346 if (NULL == userData)
2347 {
2348 smsLog(pMac, LOGE, FL("Failed to allocate memory for scan request"));
2349 vos_mem_free(scanReq.SSIDs.SSIDList);
2350 return eHAL_STATUS_FAILURE;
2351 }
2352 *((tANI_U32*)userData) = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002354 &scanId, callbackfn, (void *) userData);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 if (eHAL_STATUS_SUCCESS != status)
2356 {
2357 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
2358 vos_mem_free(scanReq.SSIDs.SSIDList);
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002359 vos_mem_free(userData);
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 return status;
2361 }
2362 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
2363
2364 vos_mem_free(scanReq.SSIDs.SSIDList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002365 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002366 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
Srikant Kuppa866893f2012-12-27 17:28:14 -08002367 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
2368 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
2369
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 return status;
2371}
2372
Srikant Kuppa866893f2012-12-27 17:28:14 -08002373static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
2374 tpCsrBGScanRequest bgScanParams)
2375{
2376 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2377 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
2378
2379 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
2380 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2381 vos_mem_copy(bgScanParams->SSID.ssId,
2382 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2383 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2384
2385 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
2386 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
2387}
2388
Jeff Johnson295189b2012-06-20 16:38:30 -07002389/* ---------------------------------------------------------------------------
2390
2391 \fn csrNeighborRoamPerformBgScan
2392
2393 \brief This function is invoked on every expiry of neighborScanTimer till all
2394 the channels in the channel list are scanned. It populates necessary
2395 parameters for BG scan and calls appropriate AP to invoke the CSR scan
2396 request
2397
2398 \param pMac - The handle returned by macOpen.
2399
2400 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2401
2402---------------------------------------------------------------------------*/
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002403eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002404{
2405 eHalStatus status = eHAL_STATUS_SUCCESS;
2406 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2407 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 tANI_U8 channel = 0;
2409
2410 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2411 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302412 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 }
2414 else
2415 {
2416 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson902c9832012-12-10 14:28:09 -08002417 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 // When timer start is declared a failure, then we delete the list.
2419 // Should not happen now as we stop and then only start the scan timer.
2420 // still handle the unlikely case.
2421 csrNeighborRoamHandleEmptyScanResult(pMac);
2422 return status;
2423 }
James Zmuda9ea1edd2013-04-18 18:20:54 -07002424
2425 /* Validate the currentChanIndex value before using it to index the ChannelList array */
2426 if ( pNeighborRoamInfo->roamChannelInfo.currentChanIndex
2427 > pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2428 {
2429 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Invalid channel index: %d"), pNeighborRoamInfo->roamChannelInfo.currentChanIndex);
2430 // Go back and restart.
2431 csrNeighborRoamHandleEmptyScanResult(pMac);
2432 return status;
2433 }
2434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 /* Need to perform scan here before getting the list */
Srikant Kuppa866893f2012-12-27 17:28:14 -08002436
2437 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07002438
2439 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
2440 bgScanParams.ChannelInfo.numOfChannels = 1;
2441 bgScanParams.ChannelInfo.ChannelList = &channel;
2442
Srikant Kuppa866893f2012-12-27 17:28:14 -08002443 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002444
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002445 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2446 sessionId, csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 if (eHAL_STATUS_SUCCESS != status)
2448 {
2449 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 }
2451
2452 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
2453 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
2454 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2455 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302456 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
2458 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
2459 /* We have completed scanning all the channels */
2460 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2461 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
2462 and select the best AP in the list */
2463 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2464 {
2465 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
2466 }
2467 }
2468
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08002469 if (eHAL_STATUS_SUCCESS != status)
2470 {
2471 /*
2472 * If the status is not success, we need to call the callback
2473 * routine so that the state machine does not get stuck.
2474 */
2475 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
2476 }
2477
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 return status;
2479}
2480
Srikant Kuppa866893f2012-12-27 17:28:14 -08002481#ifdef FEATURE_WLAN_LFR
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002482eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac, tANI_U32 sessionId)
Srikant Kuppa866893f2012-12-27 17:28:14 -08002483{
2484 eHalStatus status = eHAL_STATUS_SUCCESS;
2485 tCsrBGScanRequest bgScanParams;
2486 int numOfChannels = 0, i = 0;
2487 tANI_U8 *channelList = NULL;
Srinivas Girigowdade697412013-02-14 16:31:48 -08002488 tANI_U8 *pInChannelList = NULL;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002489 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Srikant Kuppa866893f2012-12-27 17:28:14 -08002490
2491 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
2492
2493 /* Contiguously scan all channels from valid list */
2494 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002495
2496 if (NULL != pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList)
Srikant Kuppa866893f2012-12-27 17:28:14 -08002497 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08002498 /* this list is filled only if the country code is set to KR */
2499 numOfChannels = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
2500 pInChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srikant Kuppa866893f2012-12-27 17:28:14 -08002501 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002502 else
2503 {
2504 numOfChannels = sizeof(pMac->roam.validChannelList);
2505
2506 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2507 (tANI_U8 *)pMac->roam.validChannelList,
2508 (tANI_U32 *) &numOfChannels)))
2509 {
2510 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
2511 return eHAL_STATUS_FAILURE;
2512 }
2513 pInChannelList = pMac->roam.validChannelList;
2514 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002515
2516 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
2517 {
2518 csrNeighborRoamChannelsFilterByCurrentBand(
2519 pMac,
2520 pInChannelList,
2521 numOfChannels,
2522 tmpChannelList,
2523 &numOfChannels);
2524 pInChannelList = tmpChannelList;
2525 }
2526
Srikant Kuppa866893f2012-12-27 17:28:14 -08002527 channelList = vos_mem_malloc( numOfChannels );
2528 if( NULL == channelList )
2529 {
2530 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
2531 return eHAL_STATUS_FAILURE;
2532 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08002533 vos_mem_copy(channelList, (tANI_U8 *)pInChannelList,
Srikant Kuppa866893f2012-12-27 17:28:14 -08002534 numOfChannels * sizeof(tANI_U8));
2535
2536 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
2537 bgScanParams.ChannelInfo.ChannelList = channelList;
2538 for (i = 0; i < numOfChannels; i++)
2539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002540 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d",
Srikant Kuppa866893f2012-12-27 17:28:14 -08002541 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
2542 }
2543 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
2544
2545 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002546 sessionId, csrNeighborRoamContiguousScanRequestCallback);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002547
2548 vos_mem_free( channelList );
2549
2550 if (eHAL_STATUS_SUCCESS != status)
2551 {
2552 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
2553 }
2554
2555 return status;
2556}
2557#endif
2558
Jeff Johnson295189b2012-06-20 16:38:30 -07002559/* ---------------------------------------------------------------------------
2560
2561 \fn csrNeighborRoamNeighborScanTimerCallback
2562
2563 \brief This function is the neighbor scan timer callback function. It invokes
2564 the BG scan request based on the current and previous states
2565
2566 \param pv - CSR timer context info which includes pMac and session ID
2567
2568 \return VOID
2569
2570---------------------------------------------------------------------------*/
2571void csrNeighborRoamNeighborScanTimerCallback(void *pv)
2572{
2573 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
2574 tpAniSirGlobal pMac = pInfo->pMac;
2575 tANI_U32 sessionId = pInfo->sessionId;
2576 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2577
2578 // check if bg scan is on going, no need to send down the new params if true
2579 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2580 {
2581 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002582 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 return;
2584 }
2585
2586 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
2587
2588 switch (pNeighborRoamInfo->neighborRoamState)
2589 {
2590#ifdef WLAN_FEATURE_VOWIFI_11R
2591 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2592 switch(pNeighborRoamInfo->prevNeighborRoamState)
2593 {
2594 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002595 csrNeighborRoamPerformBgScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 break;
2597 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002598 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
2600 break;
2601 }
2602 break;
2603#endif /* WLAN_FEATURE_VOWIFI_11R */
2604 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07002605 csrNeighborRoamPerformBgScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 break;
2607 default:
2608 break;
2609 }
2610 return;
2611}
2612
Srinivas Girigowdade697412013-02-14 16:31:48 -08002613void csrNeighborRoamEmptyScanRefreshTimerCallback(void *context)
2614{
2615 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2616 tpAniSirGlobal pMac = pInfo->pMac;
2617 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2618 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2619
2620 /* Reset all the variables just as no scan had happened before */
2621 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2622
2623#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2624 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2625 {
2626 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2627 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2628 if (VOS_STATUS_SUCCESS != vosStatus)
2629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002630 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Srinivas Girigowdade697412013-02-14 16:31:48 -08002631 return;
2632 }
2633 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2634 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2635 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2636 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2637 }
2638 else
2639#endif
2640 {
2641 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:empty scan refresh timer expired"));
2642 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2643 if (VOS_STATUS_SUCCESS != vosStatus)
2644 {
2645 return;
2646 }
2647 }
2648 return;
2649}
2650
Jeff Johnson295189b2012-06-20 16:38:30 -07002651/* ---------------------------------------------------------------------------
2652
2653 \fn csrNeighborRoamResultsRefreshTimerCallback
2654
2655 \brief This function is the timer callback function for results refresh timer.
2656 When this is invoked, it is as good as down event received from TL. So,
2657 clear off the roamable AP list and start the scan procedure based on 11R
2658 or non-11R association
2659
2660 \param context - CSR timer context info which includes pMac and session ID
2661
2662 \return VOID
2663
2664---------------------------------------------------------------------------*/
2665void csrNeighborRoamResultsRefreshTimerCallback(void *context)
2666{
2667 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2668 tpAniSirGlobal pMac = pInfo->pMac;
2669 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2670 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2671
2672 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2673
2674 /* Deregister reassoc callback. Ignore return status */
2675 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2676 WLANTL_HO_THRESHOLD_DOWN,
2677 csrNeighborRoamReassocIndCallback,
2678 VOS_MODULE_ID_SME);
2679
2680 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2681 {
2682 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002683 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 }
2685
2686 /* Reset all the variables just as no scan had happened before */
2687 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2688
2689#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2690 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2691 {
2692 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2693 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2694 if (VOS_STATUS_SUCCESS != vosStatus)
2695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002696 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 return;
2698 }
2699 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2700 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2701 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2702 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2703 }
2704 else
2705#endif
2706 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002707 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2709 if (VOS_STATUS_SUCCESS != vosStatus)
2710 {
2711 return;
2712 }
2713 }
2714 return;
2715}
2716
2717#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2718/* ---------------------------------------------------------------------------
2719
2720 \fn csrNeighborRoamIssueNeighborRptRequest
2721
2722 \brief This function is invoked when TL issues a down event and the current assoc
2723 is a 11R association. It invokes SME RRM API to issue the neighbor request to
2724 the currently associated AP with the current SSID
2725
2726 \param pMac - The handle returned by macOpen.
2727
2728 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2729
2730---------------------------------------------------------------------------*/
2731VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
2732{
2733 tRrmNeighborRspCallbackInfo callbackInfo;
2734 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2735 tRrmNeighborReq neighborReq;
2736
2737
2738 neighborReq.no_ssid = 0;
2739
2740 /* Fill in the SSID */
2741 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2742 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2743 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2744
2745 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
2746 callbackInfo.neighborRspCallbackContext = pMac;
2747 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
2748
2749 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
2750}
2751
2752/* ---------------------------------------------------------------------------
2753
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002754 \fn csrNeighborRoamChannelsFilterByCurrentBand
2755
2756 \brief This function is used to filter out the channels
2757 based on the currently associated AP channel
2758
2759 \param pMac - The handle returned by macOpen.
2760 \param pInputChannelList - The input channel list
2761 \param inputNumOfChannels - The number of channels in input channel list
2762 \param pOutputChannelList - The output channel list
2763 \param outputNumOfChannels - The number of channels in output channel list
2764 \param pMergedOutputNumOfChannels - The final number of channels in the output channel list.
2765
2766 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2767
2768---------------------------------------------------------------------------*/
2769
2770VOS_STATUS csrNeighborRoamChannelsFilterByCurrentBand(
2771 tpAniSirGlobal pMac,
2772 tANI_U8* pInputChannelList,
2773 int inputNumOfChannels,
2774 tANI_U8* pOutputChannelList,
2775 int* pMergedOutputNumOfChannels
2776 )
2777{
2778 int i = 0;
2779 int numChannels = 0;
2780 tANI_U8 currAPoperationChannel = pMac->roam.neighborRoamInfo.currAPoperationChannel;
2781 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302782 if (!pInputChannelList) return VOS_STATUS_E_INVAL;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002783
2784 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302785 if (!pOutputChannelList) return VOS_STATUS_E_INVAL;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002786
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302787 if (inputNumOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2788 {
2789 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2790 "%s: Wrong Number of Input Channels %d",
2791 __func__, inputNumOfChannels);
2792 return VOS_STATUS_E_INVAL;
2793 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002794 for (i = 0; i < inputNumOfChannels; i++)
2795 {
2796 if (GetRFBand(currAPoperationChannel) == GetRFBand(pInputChannelList[i]))
2797 {
2798 pOutputChannelList[numChannels] = pInputChannelList[i];
2799 numChannels++;
2800 }
2801 }
2802
2803 // Return final number of channels
2804 *pMergedOutputNumOfChannels = numChannels;
2805
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302806 return VOS_STATUS_SUCCESS;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002807}
2808
2809/* ---------------------------------------------------------------------------
2810
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002811 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002812
2813 \brief This function is used to merge two channel list.
2814 NB: If called with outputNumOfChannels == 0, this routines
2815 simply copies the input channel list to the output channel list.
2816
2817 \param pMac - The handle returned by macOpen.
2818 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
2819 \param inputNumOfChannels - The number of additional channels.
2820 \param pOutputChannelList - The place to put the "merged" channel list.
2821 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
2822 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
2823
2824 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2825
2826---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002827VOS_STATUS csrNeighborRoamMergeChannelLists(
2828 tpAniSirGlobal pMac,
2829 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002830 int inputNumOfChannels,
2831 tANI_U8 *pOutputChannelList,
2832 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002833 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002834 )
2835{
2836 int i = 0;
2837 int j = 0;
2838 int numChannels = outputNumOfChannels;
2839
2840 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302841 if (!pInputChannelList) return VOS_STATUS_E_INVAL;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002842
2843 // Check for NULL pointer
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302844 if (!pOutputChannelList) return VOS_STATUS_E_INVAL;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002845
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302846 if (inputNumOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2847 {
2848 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2849 "%s: Wrong Number of Input Channels %d",
2850 __func__, inputNumOfChannels);
2851 return VOS_STATUS_E_INVAL;
2852 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002853 // Add the "new" channels in the input list to the end of the output list.
2854 for (i = 0; i < inputNumOfChannels; i++)
2855 {
2856 for (j = 0; j < outputNumOfChannels; j++)
2857 {
2858 if (pInputChannelList[i] == pOutputChannelList[j])
2859 break;
2860 }
2861 if (j == outputNumOfChannels)
2862 {
2863 if (pInputChannelList[i])
2864 {
Madan Mohan Koyyalamudif5c368b2012-12-06 13:10:13 -08002865 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002866 "%s: [INFOLOG] Adding extra %d to Neighbor channel list", __func__,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002867 pInputChannelList[i]);
2868 pOutputChannelList[numChannels] = pInputChannelList[i];
2869 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002870 }
2871 }
2872 }
2873
2874 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002875 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002876
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05302877 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002878}
2879
2880/* ---------------------------------------------------------------------------
2881
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 \fn csrNeighborRoamCreateChanListFromNeighborReport
2883
2884 \brief This function is invoked when neighbor report is received for the
2885 neighbor request. Based on the channels present in the neighbor report,
2886 it generates channel list which will be used in REPORT_SCAN state to
2887 scan for these neighbor APs
2888
2889 \param pMac - The handle returned by macOpen.
2890
2891 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2892
2893---------------------------------------------------------------------------*/
2894VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2895{
2896 tpRrmNeighborReportDesc pNeighborBssDesc;
2897 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002898 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002900#if 0
2901 eHalStatus status = eHAL_STATUS_SUCCESS;
2902#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002903
2904 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2905 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2906
2907 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2908
2909 while (pNeighborBssDesc)
2910 {
2911 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2912
2913 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2914 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2915 pNeighborBssDesc->pNeighborBssDescription->channel;
2916 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2917 (tANI_U8)pNeighborBssDesc->roamScore;
2918 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2919 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2920 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2921
2922 /* Saving the channel list non-redundantly */
2923 if (numChannels > 0)
2924 {
2925 for (i = 0; i < numChannels; i++)
2926 {
2927 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2928 break;
2929 }
2930
2931 }
2932 if (i == numChannels)
2933 {
2934 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2935 {
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002936 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
2937 {
2938 // Make sure to add only if its the same band
2939 if (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
2940 GetRFBand(pNeighborBssDesc->pNeighborBssDescription->channel))
2941 {
2942 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2943 "%s: [INFOLOG] Adding %d to Neighbor channel list (Same band)\n", __func__,
2944 pNeighborBssDesc->pNeighborBssDescription->channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2946 numChannels++;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07002947 }
2948 }
2949 else
2950 {
2951 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2952 "%s: [INFOLOG] Adding %d to Neighbor channel list\n", __func__,
2953 pNeighborBssDesc->pNeighborBssDescription->channel);
2954 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2955 numChannels++;
2956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 }
2958 }
2959
2960 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2961 }
2962
2963 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2964 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002965#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002967 // we have a union of the IAPP and the already existing list.
2968 status = csrNeighborRoamMergeChannelLists(
2969 pMac,
2970 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2971 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2972 channelList,
2973 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002974 &numChannels );
2975#endif
2976
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2978 }
2979
2980 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07002981 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 /* Store the obtained channel list to the Neighbor Control data structure */
2983 if (numChannels)
2984 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2985 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2986 {
2987 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2988 return VOS_STATUS_E_RESOURCES;
2989 }
2990
2991 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2992 channelList, (numChannels) * sizeof(tANI_U8));
2993 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2994 if (numChannels)
2995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002996 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 pNeighborRoamInfo->neighborRoamState);
2998 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002999#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07003000 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003001 {
3002 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
3003 }
3004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 }
3006 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
3007 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
3008
3009 return VOS_STATUS_SUCCESS;
3010}
3011
3012/* ---------------------------------------------------------------------------
3013
3014 \fn csrNeighborRoamRRMNeighborReportResult
3015
3016 \brief This function is the neighbor report callback that will be invoked by
3017 SME RRM on receiving a neighbor report or of neighbor report is not
3018 received after timeout. On receiving a valid report, it generates a
3019 channel list from the neighbor report and starts the
3020 neighbor scan timer
3021
3022 \param context - The handle returned by macOpen.
3023 vosStatus - Status of the callback(SUCCESS/FAILURE)
3024
3025 \return VOID
3026
3027---------------------------------------------------------------------------*/
3028void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
3029{
3030 tpAniSirGlobal pMac = PMAC_STRUCT(context);
3031 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3032 eHalStatus status = eHAL_STATUS_SUCCESS;
3033
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003034 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 switch (pNeighborRoamInfo->neighborRoamState)
3036 {
3037 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
3038 /* Reset the report pending variable */
3039 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
3040 if (VOS_STATUS_SUCCESS == vosStatus)
3041 {
3042 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
3043 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
3044 if (VOS_STATUS_SUCCESS == vosStatus)
3045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003046 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 }
3048
3049 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
3050 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3051
3052 /* Now ready for neighbor scan based on the channel list created */
3053 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
3054 what palTimerStart expects */
3055 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
3056 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
3057 eANI_BOOLEAN_FALSE);
3058 if (eHAL_STATUS_SUCCESS != status)
3059 {
3060 /* Timer start failed.. Should we ASSERT here??? */
3061 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
3062 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3063 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07003064 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 return;
3066 }
3067 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3068 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
3069 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
3070 }
3071 else
3072 {
3073 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
3074 reach the maxNeighborRetries or receiving a successful neighbor response */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003075 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
3077 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
3078 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
3079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003080 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3082 if (VOS_STATUS_SUCCESS != vosStatus)
3083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003084 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d "), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 return;
3086 }
3087 /* We transitioned to different state now. Reset the Neighbor report retry count */
3088 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3089 }
3090 else
3091 {
3092 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3093 if (VOS_STATUS_SUCCESS != vosStatus)
3094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003095 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 return;
3097 }
3098 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3099 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3100 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3101 }
3102 }
3103 break;
3104 default:
3105 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
3106 break;
3107 }
3108 return;
3109}
3110#endif /* WLAN_FEATURE_VOWIFI_11R */
3111
3112
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003113#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003114tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003115 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003116 tCsrRoamConnectedProfile *pCurProfile,
3117 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003118 tDot11fBeaconIEs *pIes)
3119{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003120 tCsrAuthList authType;
3121 tCsrEncryptionList uCEncryptionType;
3122 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003123 tANI_BOOLEAN fMatch = FALSE;
3124
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003125 authType.numEntries = 1;
3126 authType.authType[0] = pCurProfile->AuthType;
3127 uCEncryptionType.numEntries = 1;
3128 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
3129 mCEncryptionType.numEntries = 1;
3130 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003131
3132 if( pIes )
3133 {
3134 if(pIes->SSID.present)
3135 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003136 fMatch = csrIsSsidMatch( pMac,
3137 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
3138 pIes->SSID.ssid, pIes->SSID.num_ssid,
3139 eANI_BOOLEAN_TRUE );
3140 if(TRUE == fMatch)
3141 {
3142 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
3143 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
3144 return (fMatch);
3145 }
3146 else
3147 {
3148 return (fMatch);
3149 }
3150
3151 }
3152 else
3153 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003154 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003155 }
3156 }
3157 else
3158 {
3159 return FALSE; // Again, treat missing pIes as a non-match.
3160 }
3161}
3162
3163tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
3164 tpAniSirGlobal pMac)
3165{
3166 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3167 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
3168 tCsrRoamConnectedProfile *pCurrProfile = NULL;
3169 tCsrRoamConnectedProfile *pPrevProfile = NULL;
3170 tDot11fBeaconIEs *pIes = NULL;
3171 tSirBssDescription *pBssDesc = NULL;
3172 tANI_BOOLEAN fNew = TRUE;
3173
3174 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
3175 {
3176 return (fNew);
3177 }
3178
3179 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
3180 if( !pCurrProfile )
3181 {
3182 return (fNew);
3183}
3184
3185 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
3186 if( !pPrevProfile )
3187 {
3188 return (fNew);
3189 }
3190
3191 pBssDesc = pPrevProfile->pBssDesc;
3192 if (pBssDesc)
3193 {
3194 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
3195 pBssDesc, &pIes)) &&
3196 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
3197 {
3198 fNew = FALSE;
3199 }
3200 if (pIes) {
3201 palFreeMemory(pMac->hHdd, pIes);
3202 }
3203 }
3204
3205 if (fNew)
3206 {
3207 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003208 }
3209 else
3210 {
3211 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
3212 }
3213
3214 return (fNew);
3215}
3216
3217tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
3218 tpAniSirGlobal pMac,
3219 tCsrScanResult *pResult,
3220 tDot11fBeaconIEs *pIes)
3221{
3222 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3223 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
3224 tCsrRoamConnectedProfile *pCurProfile = NULL;
3225 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
3226
3227 if( !(pMac->roam.roamSession
3228 && CSR_IS_SESSION_VALID(pMac, sessionId)))
3229 {
3230 return FALSE;
3231 }
3232
3233 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
3234
3235 if( !pCurProfile)
3236 {
3237 return FALSE;
3238 }
3239
3240 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003241}
3242
3243/* ---------------------------------------------------------------------------
3244
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003245 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003246
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003247 \brief This function is used to prepare a channel list that is derived from
3248 the list of valid channels and does not include those in the occupied
3249 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003250
3251 \param pMac - The handle returned by macOpen.
3252 \param pInputChannelList - The default channels list.
3253 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003254 \param pOutputChannelList - The place to put the non-occupied channel list.
3255 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003256
3257 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3258
3259---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003260VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003261 tpAniSirGlobal pMac,
3262 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003263 int numOfChannels,
3264 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003265 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003266 )
3267{
3268 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003269 int outputNumOfChannels = 0; // Clear the output number of channels
3270 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
3271 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
3272
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003273 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003274 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003275 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
3276 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003277 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003278 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003279 }
3280 }
3281
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003282 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
3283 "Number of channels in the non-occupied list list=%d"),
3284 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003285
3286 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003287 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003288
3289 return eHAL_STATUS_SUCCESS;
3290}
3291#endif /* FEATURE_WLAN_LFR */
3292
Jeff Johnson295189b2012-06-20 16:38:30 -07003293/* ---------------------------------------------------------------------------
3294
3295 \fn csrNeighborRoamTransitToCFGChanScan
3296
3297 \brief This function is called whenever there is a transition to CFG chan scan
3298 state from any state. It frees up the current channel list and allocates
3299 a new memory for the channels received from CFG item. It then starts the
3300 neighbor scan timer to perform the scan on each channel one by one
3301
3302 \param pMac - The handle returned by macOpen.
3303
3304 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3305
3306---------------------------------------------------------------------------*/
3307VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
3308{
3309 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3310 eHalStatus status = eHAL_STATUS_SUCCESS;
3311 int i = 0;
3312 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003313 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003314 tpCsrChannelInfo currChannelListInfo;
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003315#ifdef FEATURE_WLAN_LFR
3316 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3317#endif
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003318 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003320 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003321#ifdef FEATURE_WLAN_CCX
3322 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003323 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
3325#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003326 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003328 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
3330
3331 /* Free up the channel list and allocate a new memory. This is because we dont know how much
3332 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
3333 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003334 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003336 vos_mem_free(currChannelListInfo->ChannelList);
3337 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07003338 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003340
3341 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
3342 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
3343 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003345 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
3346 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003347 status = csrNeighborRoamMergeChannelLists(
3348 pMac,
3349 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3350 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
3351 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003352 0, //NB: If 0, simply copy the input channel list to the output list.
3353 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003354
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003355 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3356 {
3357 csrNeighborRoamChannelsFilterByCurrentBand(
3358 pMac,
3359 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3360 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
3361 channelList,
3362 &numOfChannels);
3363 }
Gopichand Nakkala9cd573c2013-04-19 21:52:58 +05303364 if(numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3365 {
3366 smsLog(pMac, LOGE, FL("Received wrong number of Channel list"));
3367 return VOS_STATUS_E_INVAL;
3368 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003369 currChannelListInfo->ChannelList =
3370 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
3371 if (NULL == currChannelListInfo->ChannelList)
3372 {
3373 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3374 return VOS_STATUS_E_RESOURCES;
3375 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003376 vos_mem_copy(currChannelListInfo->ChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003377 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003378 }
Srikant Kuppa866893f2012-12-27 17:28:14 -08003379#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08003380 else if ((pNeighborRoamInfo->uScanMode == DEFAULT_SCAN) &&
3381 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
3382 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold)))
Srikant Kuppa866893f2012-12-27 17:28:14 -08003383 {
3384 /*
3385 * Trigger a contiguous scan on all channels when the
3386 * RSSI in the lookup DOWN notification is below reassoc
3387 * threshold. This will help us find the best available
3388 * candidate and also update the channel cache.
3389 */
3390 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
3391 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
3392 pNeighborRoamInfo->lookupDOWNRssi,
3393 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
3394
3395 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3396
3397 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3398
3399 /* We are about to start a fresh scan cycle,
3400 * purge non-P2P results from the past */
3401 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
Krunal Soni81b24262013-05-15 17:46:41 -07003402
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003403 csrNeighborRoamPerformContiguousBgScan(pMac, sessionId);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003404
3405 /* Transition to CFG_CHAN_LIST_SCAN */
3406 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
Krunal Soni81b24262013-05-15 17:46:41 -07003407
Srikant Kuppa866893f2012-12-27 17:28:14 -08003408 return VOS_STATUS_SUCCESS;
3409 }
3410#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003411 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003412 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003413 numOfChannels = pMac->scan.occupiedChannels.numChannels;
3414 if (numOfChannels
3415#ifdef FEATURE_WLAN_LFR
Srinivas Girigowdade697412013-02-14 16:31:48 -08003416 && ((pNeighborRoamInfo->uScanMode == SPLIT_SCAN_OCCUPIED_LIST) ||
3417 (pNeighborRoamInfo->uEmptyScanCount == 0) ||
3418 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003419#endif
3420 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003422 /*
3423 * Always scan channels in the occupied channel list
3424 * before scanning on the non-occupied list.
3425 */
Srinivas Girigowdade697412013-02-14 16:31:48 -08003426 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Switching to occupied channel list"
3427#ifdef FEATURE_WLAN_LFR
3428 "-uScanMode=%d, uEmptyScanCount=%d",
3429 pNeighborRoamInfo->uScanMode,
3430 pNeighborRoamInfo->uEmptyScanCount
3431#endif
3432 );
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003433 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3434 {
3435 csrNeighborRoamChannelsFilterByCurrentBand(
3436 pMac,
3437 pMac->scan.occupiedChannels.channelList,
3438 numOfChannels,
3439 channelList,
3440 &numOfChannels);
3441 }
3442 else
3443 {
Krunal Sonia75019a2013-05-01 01:08:22 -07003444 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3445 {
3446 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3447 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003448 vos_mem_copy(channelList,
3449 pMac->scan.occupiedChannels.channelList,
3450 numOfChannels * sizeof(tANI_U8));
3451 }
3452
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003453 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003454 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003455
3456 if (NULL == currChannelListInfo->ChannelList)
3457 {
3458 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3459 return VOS_STATUS_E_RESOURCES;
3460 }
Krunal Soni81b24262013-05-15 17:46:41 -07003461 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3462 {
3463 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3464 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003465 vos_mem_copy(currChannelListInfo->ChannelList,
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003466 channelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003467 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003468 }
3469 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003470 {
3471 /* Scan all channels from non-occupied list */
3472 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
3473 numOfChannels = sizeof(pMac->roam.validChannelList);
3474
3475 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
3476 (tANI_U8 *)pMac->roam.validChannelList,
3477 (tANI_U32 *) &numOfChannels)))
3478 {
3479#ifdef FEATURE_WLAN_LFR
3480 /*
3481 * Prepare non-occupied channel list (channelList)
3482 * from the actual "valid channel list" information
3483 * formed by CSR.
3484 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05303485 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
Srinivas Girigowdade697412013-02-14 16:31:48 -08003486 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
3487 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003488 numOfChannels,
3489 channelList,
3490 &numOfChannels);
3491#else
3492 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
3493 status = csrNeighborRoamMergeChannelLists(
3494 pMac,
3495 (tANI_U8 *)pMac->roam.validChannelList,
3496 numOfChannels, // The number of channels in the validChannelList
3497 channelList,
3498 0, //NB: If 0, simply copy the input channel list to the output list.
3499 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
3500#endif
3501 }
3502 else
3503 {
3504 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003505 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 }
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07003507
3508 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3509 {
3510 csrNeighborRoamChannelsFilterByCurrentBand(
3511 pMac,
3512 (tANI_U8 *)pMac->roam.validChannelList,
3513 numOfChannels,
3514 channelList,
3515 &numOfChannels);
3516 }
3517
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003518 currChannelListInfo->ChannelList =
3519 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
3520
3521 if (NULL == currChannelListInfo->ChannelList)
3522 {
3523 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3524 return VOS_STATUS_E_RESOURCES;
3525 }
3526#ifdef FEATURE_WLAN_LFR
3527 vos_mem_copy(currChannelListInfo->ChannelList,
3528 channelList, numOfChannels * sizeof(tANI_U8));
3529#else
Krunal Sonia75019a2013-05-01 01:08:22 -07003530 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3531 {
3532 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3533 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003534 vos_mem_copy(currChannelListInfo->ChannelList,
3535 (tANI_U8 *)pMac->roam.validChannelList,
3536 numOfChannels * sizeof(tANI_U8));
3537#endif
3538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 }
3540
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003541 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003542 currChannelListInfo->numOfChannels = numOfChannels;
Srikant Kuppa866893f2012-12-27 17:28:14 -08003543 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
3544 "Number of channels from CFG (or) (non-)occupied list=%d",
3545 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003546 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05303548 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003549 "= %d", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 }
3551 }
3552
3553 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
3554 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3555
3556 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3557 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
3558 what palTimerStart expects */
3559 status = palTimerStart(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer,
3560 pNeighborRoamInfo->cfgParams.neighborScanPeriod * PAL_TIMER_TO_MS_UNIT,
3561 eANI_BOOLEAN_FALSE);
3562
3563 if (eHAL_STATUS_SUCCESS != status)
3564 {
3565 /* Timer start failed.. */
3566 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003567 vos_mem_free(currChannelListInfo->ChannelList);
3568 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokeref0bd4382013-03-19 22:06:52 -07003569 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 return VOS_STATUS_E_FAILURE;
3571 }
3572
3573 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
3574 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05303575 /* We are about to start a fresh scan cycle,
3576 * purge non-P2P results from the past */
3577 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
James Zmuda5ba36d02013-03-14 17:39:07 -07003578
3579 /* We are about to start a fresh scan cycle,
3580 * purge failed pre-auth results from the past */
3581 csrNeighborRoamPurgePreauthFailedList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003582
3583 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
3584 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
3585
3586 return VOS_STATUS_SUCCESS;
3587}
3588
3589/* ---------------------------------------------------------------------------
3590
3591 \fn csrNeighborRoamNeighborLookupUpEvent
3592
3593 \brief This function is called as soon as TL indicates that the current AP's
3594 RSSI is better than the neighbor lookup threshold. Here, we transition to
3595 CONNECTED state and reset all the scan parameters
3596
3597 \param pMac - The handle returned by macOpen.
3598
3599 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3600
3601---------------------------------------------------------------------------*/
3602VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
3603{
3604 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3605 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003606 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003607
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 /* Recheck whether the below check is needed. */
3609 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
3610 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003611#ifdef FEATURE_WLAN_LFR
3612 if (!csrRoamIsFastRoamEnabled(pMac,pMac->roam.neighborRoamInfo.csrSessionId))
3613 {
3614 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
3615 return eHAL_STATUS_SUCCESS;
3616 }
3617#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003618 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
3619 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3620
Jeff Johnson295189b2012-06-20 16:38:30 -07003621
3622 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3623 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
3624 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3625 WLANTL_HO_THRESHOLD_DOWN,
3626 csrNeighborRoamNeighborLookupDOWNCallback,
3627 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08003628#ifdef FEATURE_WLAN_LFR
3629 pNeighborRoamInfo->lookupDOWNRssi = 0;
3630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3632 {
3633 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003634 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 }
3636
3637
3638 return vosStatus;
3639}
3640
3641/* ---------------------------------------------------------------------------
3642
3643 \fn csrNeighborRoamNeighborLookupDownEvent
3644
3645 \brief This function is called as soon as TL indicates that the current AP's
3646 RSSI falls below the current eighbor lookup threshold. Here, we transition to
3647 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
3648 a non-11R association.
3649
3650 \param pMac - The handle returned by macOpen.
3651
3652 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3653
3654---------------------------------------------------------------------------*/
3655VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
3656{
3657 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3658 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3659 eHalStatus status = eHAL_STATUS_SUCCESS;
3660
3661 switch (pNeighborRoamInfo->neighborRoamState)
3662 {
3663 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3664
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003665 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003666 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3667 /* De-register Neighbor Lookup threshold callback with TL */
3668 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3669 WLANTL_HO_THRESHOLD_DOWN,
3670 csrNeighborRoamNeighborLookupDOWNCallback,
3671 VOS_MODULE_ID_SME);
3672
3673 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3674 {
3675 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003676 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 }
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003678#ifdef FEATURE_WLAN_LFR
3679 if (!csrRoamIsFastRoamEnabled(pMac,pMac->roam.neighborRoamInfo.csrSessionId))
3680 {
3681 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
3682 return eHAL_STATUS_SUCCESS;
3683 }
3684#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003685
3686#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
3687 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
3688 {
3689
3690 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
3691 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3692 if (VOS_STATUS_SUCCESS != vosStatus)
3693 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003694 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 return vosStatus;
3696 }
3697 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3698 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3699 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3700 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
3701 }
3702 else
3703#endif
3704 {
3705 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
3706
3707 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3708 if (VOS_STATUS_SUCCESS != vosStatus)
3709 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08003710 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
3711 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 return vosStatus;
3713 }
3714 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003715 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 -07003716 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003717 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
3718 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 WLANTL_HO_THRESHOLD_UP,
3720 csrNeighborRoamNeighborLookupUPCallback,
3721 VOS_MODULE_ID_SME, pMac);
3722 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3723 {
3724 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003725 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 }
3727 break;
3728 default:
3729 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3730 break;
3731
3732 }
3733 return vosStatus;
3734}
3735
3736/* ---------------------------------------------------------------------------
3737
3738 \fn csrNeighborRoamNeighborLookupUPCallback
3739
3740 \brief This function is registered with TL to indicate whenever the RSSI
3741 gets better than the neighborLookup RSSI Threshold
3742
3743 \param pAdapter - VOS Context
3744 trafficStatus - UP/DOWN indication from TL
3745 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3746
3747 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3748
3749---------------------------------------------------------------------------*/
3750VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003751 v_PVOID_t pUserCtxt,
3752 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003753{
3754 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3755 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3756 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3757
Srinivasdaaec712012-12-12 15:59:44 -08003758 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
3759 rssiNotification,
3760 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003761
3762 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003764 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 return VOS_STATUS_SUCCESS;
3766 }
3767
3768 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
3769 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
3770 return vosStatus;
3771}
3772
3773/* ---------------------------------------------------------------------------
3774
3775 \fn csrNeighborRoamNeighborLookupDOWNCallback
3776
3777 \brief This function is registered with TL to indicate whenever the RSSI
3778 falls below the current neighborLookup RSSI Threshold
3779
3780 \param pAdapter - VOS Context
3781 trafficStatus - UP/DOWN indication from TL
3782 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3783
3784 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3785
3786---------------------------------------------------------------------------*/
3787VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Srinivasdaaec712012-12-12 15:59:44 -08003788 v_PVOID_t pUserCtxt,
3789 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003790{
3791 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3792 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3793 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3794
Srinivasdaaec712012-12-12 15:59:44 -08003795 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
3796 rssiNotification,
3797 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003798
Srikant Kuppa866893f2012-12-27 17:28:14 -08003799#ifdef FEATURE_WLAN_LFR
3800 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
3801#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3803 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003804 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 return VOS_STATUS_SUCCESS;
3806 }
3807
3808 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
3809 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
3810
3811 return vosStatus;
3812}
3813
3814#ifdef RSSI_HACK
3815extern int dumpCmdRSSI;
3816#endif
3817
3818/* ---------------------------------------------------------------------------
3819
3820 \fn csrNeighborRoamIndicateDisconnect
3821
3822 \brief This function is called by CSR as soon as the station disconnects from
3823 the AP. This function does the necessary cleanup of neighbor roam data
3824 structures. Neighbor roam state transitions to INIT state whenever this
3825 function is called except if the current state is REASSOCIATING
3826
3827 \param pMac - The handle returned by macOpen.
3828 sessionId - CSR session id that got disconnected
3829
3830 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3831
3832---------------------------------------------------------------------------*/
3833eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
3834{
3835 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003836#ifdef FEATURE_WLAN_LFR
3837 tCsrRoamConnectedProfile *pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
3838#endif
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003839 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003840
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003841 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d"),
3842 sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003843
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003844#ifdef FEATURE_WLAN_LFR
3845 /*Free the current previous profile and move the current profile to prev profile.*/
3846 csrRoamFreeConnectProfile(pMac, pPrevProfile);
3847 csrRoamGetConnectProfile(pMac, sessionId, pPrevProfile);
3848#endif
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07003849 if (NULL != pSession)
3850 {
3851 if (NULL != pSession->pCurRoamProfile)
3852 {
3853 if (VOS_STA_MODE != pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona)
3854 {
3855 smsLog(pMac, LOGE, FL("Ignoring Disconnect indication received from a non STA persona."
3856 "sessionId: %d, csrPersonna %d"), sessionId,
3857 (int)pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona);
3858 return eHAL_STATUS_SUCCESS;
3859 }
3860 }
3861 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003862
Jeff Johnson295189b2012-06-20 16:38:30 -07003863#ifdef FEATURE_WLAN_CCX
3864 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 if (pSession->connectedProfile.isCCXAssoc)
3866 {
3867 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
3868 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3869 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
3870 pSession->isPrevApInfoValid = TRUE;
3871 pSession->roamTS1 = vos_timer_get_system_time();
3872
3873 }
3874 }
3875#endif
3876
3877#ifdef RSSI_HACK
3878 dumpCmdRSSI = -40;
3879#endif
3880 switch (pNeighborRoamInfo->neighborRoamState)
3881 {
3882 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3883 // Stop scan and neighbor refresh timers.
3884 // These are indeed not required when we are in reassociating
3885 // state.
3886 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
3887 palTimerStop(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08003888 palTimerStop(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003889 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
3890 /*
3891 * Disconnect indication during Disassoc Handoff sub-state
3892 * is received when we are trying to disconnect with the old
3893 * AP during roam. BUT, if receive a disconnect indication
3894 * outside of Disassoc Handoff sub-state, then it means that
3895 * this is a genuine disconnect and we need to clean up.
3896 * Otherwise, we will be stuck in reassoc state which will
3897 * in-turn block scans (see csrIsScanAllowed).
3898 */
3899 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 break;
3902
3903 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 csrNeighborRoamResetInitStateControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003905#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07003906 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003907 {
3908#endif
3909 csrNeighborRoamDeregAllRssiIndication(pMac);
3910#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3911 }
3912#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 break;
3914
Srikant Kuppa866893f2012-12-27 17:28:14 -08003915 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3916 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3917 csrNeighborRoamResetConnectedStateControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003918#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07003919 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003920 {
3921#endif
3922 csrNeighborRoamDeregAllRssiIndication(pMac);
3923#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3924 }
3925#endif
Srikant Kuppa866893f2012-12-27 17:28:14 -08003926 break;
3927
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003928 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
3929 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3930 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003931#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07003932 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003933 {
3934#endif
3935 csrNeighborRoamDeregAllRssiIndication(pMac);
3936#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3937 }
3938#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003939 break;
3940
3941 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3942 /* Stop pre-auth to reassoc interval timer */
3943 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003944 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3945 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3946 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003947 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003948 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003949#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07003950 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003951 {
3952#endif
3953 csrNeighborRoamDeregAllRssiIndication(pMac);
3954#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3955 }
3956#endif
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003957 break;
3958
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003960 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
3961 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003965#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3966 /*Inform the Firmware to STOP Scanning as the host has a disconnect.*/
3967 if (csrRoamIsStaMode(pMac, sessionId))
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003968 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003969 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07003970 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003971#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 return eHAL_STATUS_SUCCESS;
3973}
3974
3975/* ---------------------------------------------------------------------------
3976
3977 \fn csrNeighborRoamIndicateConnect
3978
3979 \brief This function is called by CSR as soon as the station connects to an AP.
3980 This initializes all the necessary data structures related to the
3981 associated AP and transitions the state to CONNECTED state
3982
3983 \param pMac - The handle returned by macOpen.
3984 sessionId - CSR session id that got connected
3985 vosStatus - connect status SUCCESS/FAILURE
3986
3987 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3988
3989---------------------------------------------------------------------------*/
3990eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
3991{
3992 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3993 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07003994 VOS_STATUS vstatus;
3995
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003996#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 int init_ft_flag = FALSE;
3998#endif
3999
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004000 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004001
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004002 // Bail out if this is NOT a STA persona
4003 if (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona != VOS_STA_MODE)
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004004 {
4005 smsLog(pMac, LOGE, FL("Ignoring Connect indication received from a non STA persona."
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004006 "sessionId: %d, csrPersonna %d"),
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004007 sessionId,
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004008 (int)pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona);
Dhanashri Atre9ae0dd12013-05-02 11:11:05 -07004009 return eHAL_STATUS_SUCCESS;
4010 }
4011
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004012 // if a concurrent session is running
4013#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4014 if (eANI_BOOLEAN_FALSE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4015 {
4016#endif
4017 if (csrIsConcurrentSessionRunning(pMac))
4018 {
4019 smsLog(pMac, LOGE, FL("Ignoring Connect indication received in multisession %d"),
4020 csrIsConcurrentSessionRunning(pMac));
4021 return eHAL_STATUS_SUCCESS;
4022 }
4023#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4024 }
4025#endif
4026
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 switch (pNeighborRoamInfo->neighborRoamState)
4028 {
4029 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
4030 if (VOS_STATUS_SUCCESS != vosStatus)
4031 {
4032 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
4033 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
4034 break;
4035 }
4036 /* Fall through if the status is SUCCESS */
4037 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
4038 /* Reset all the data structures here */
4039 csrNeighborRoamResetInitStateControlInfo(pMac);
4040
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004042
4043#ifdef FEATURE_WLAN_LFR
4044 /*
4045 * Initialize the occupied list ONLY if we are
4046 * transitioning from INIT state to CONNECTED state.
4047 */
4048 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
4049 csrInitOccupiedChannelsList(pMac);
4050#endif
4051 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
4052
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
4054 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
4055 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
4056 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
4057 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004058 pNeighborRoamInfo->currentNeighborLookupThreshold =
4059 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
4060#ifdef FEATURE_WLAN_LFR
4061 pNeighborRoamInfo->uEmptyScanCount = 0;
Srikant Kuppa866893f2012-12-27 17:28:14 -08004062 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004063 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004064#endif
4065
Jeff Johnson295189b2012-06-20 16:38:30 -07004066
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004067#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 /* Now we can clear the preauthDone that was saved as we are connected afresh */
4069 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4070#endif
4071
4072#ifdef WLAN_FEATURE_VOWIFI_11R
4073 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08004074 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
4075 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 {
4077 if (pMac->roam.configParam.isFastTransitionEnabled)
4078 init_ft_flag = TRUE;
4079 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
4080 }
4081 else
4082 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004083 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004084#endif
4085
4086#ifdef FEATURE_WLAN_CCX
4087 // Based on the auth scheme tell if we are 11r
4088 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
4089 {
4090 if (pMac->roam.configParam.isFastTransitionEnabled)
4091 init_ft_flag = TRUE;
4092 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
4093 }
4094 else
4095 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004096 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
4097 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07004098
4099#endif
4100
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004101#ifdef FEATURE_WLAN_LFR
4102 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304103 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004104 {
4105 init_ft_flag = TRUE;
4106 }
4107#endif
4108
4109#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 if ( init_ft_flag == TRUE )
4111 {
4112 /* Initialize all the data structures needed for the 11r FT Preauth */
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
4114 csrNeighborRoamPurgePreauthFailedList(pMac);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004115#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004116 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004117 {
4118 /*If this is not a INFRA type BSS, then do not send the command
4119 * down to firmware.Do not send the START command for other session
4120 * connections.*/
4121 if(csrRoamIsStaMode(pMac, sessionId))
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004122 {
4123 pNeighborRoamInfo->uOsRequestedHandoff = 0;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004124 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004125 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004126 } else {
4127#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004128
4129 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
4130 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07004131 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 WLANTL_HO_THRESHOLD_DOWN,
4133 csrNeighborRoamNeighborLookupDOWNCallback,
4134 VOS_MODULE_ID_SME, pMac);
Srikant Kuppa866893f2012-12-27 17:28:14 -08004135#ifdef FEATURE_WLAN_LFR
4136 pNeighborRoamInfo->lookupDOWNRssi = 0;
4137#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07004138 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 {
4140 //err msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004141 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vstatus);
Jeff Johnson43971f52012-07-17 12:26:56 -07004142 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004144#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4145 }
4146#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 }
4148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 break;
4150 default:
4151 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
4152 break;
4153 }
4154 return status;
4155}
4156
4157
4158#ifdef WLAN_FEATURE_VOWIFI_11R
4159/* ---------------------------------------------------------------------------
4160
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 \fn csrNeighborRoamPurgePreauthFailedList
4162
4163 \brief This function purges all the MAC addresses in the pre-auth fail list
4164
4165 \param pMac - The handle returned by macOpen.
4166
4167 \return VOID
4168
4169---------------------------------------------------------------------------*/
4170void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
4171{
4172 tANI_U8 i;
4173
4174 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
4175 {
4176 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
4177 }
4178 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
4179
4180 return;
4181}
4182
4183/* ---------------------------------------------------------------------------
4184
4185 \fn csrNeighborRoamInit11rAssocInfo
4186
4187 \brief This function initializes 11r related neighbor roam data structures
4188
4189 \param pMac - The handle returned by macOpen.
4190
4191 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4192
4193---------------------------------------------------------------------------*/
4194eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
4195{
4196 eHalStatus status;
4197 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
4198
4199 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
4200 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
4201 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
4202 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
4203 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
4204 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
4205
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
4207 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
4208 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
4209 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
4210
4211
4212 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
4213 if (eHAL_STATUS_SUCCESS != status)
4214 {
4215 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 return eHAL_STATUS_RESOURCES;
4217 }
4218 return status;
4219}
4220#endif /* WLAN_FEATURE_VOWIFI_11R */
4221
4222/* ---------------------------------------------------------------------------
4223
4224 \fn csrNeighborRoamInit
4225
4226 \brief This function initializes neighbor roam data structures
4227
4228 \param pMac - The handle returned by macOpen.
4229
4230 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4231
4232---------------------------------------------------------------------------*/
4233eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
4234{
4235 eHalStatus status;
4236 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4237
4238 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
4239 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
4240 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
4241 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
4242 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
4243 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
4244 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
4245 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
4246 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
4247 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004248 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
4249
4250#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
4251 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = SME_KR_25;
4252 pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList = NULL;
4253 pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels = 0;
4254
4255 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
4256 {
4257 csrInitCountryValidChannelList(pMac, SME_KR_25);
4258 }
4259#endif
4260
4261 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
4263
Srinivas Girigowdade697412013-02-14 16:31:48 -08004264 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
4266
4267 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
4268 {
4269 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
4270 return eHAL_STATUS_RESOURCES;
4271 }
4272
4273 /* Update the roam global structure from CFG */
Srinivas Girigowdade697412013-02-14 16:31:48 -08004274 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
4276 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
4277
4278 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
4279 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004280#ifdef FEATURE_WLAN_LFR
Srikant Kuppa866893f2012-12-27 17:28:14 -08004281 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004282 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08004283 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004284 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
4285 sizeof(tCsrRoamConnectedProfile));
4286#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
4288
4289 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
4290 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
4291 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborScanTimer,
4292 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
4293
4294 if (eHAL_STATUS_SUCCESS != status)
4295 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08004296 smsLog(pMac, LOGE, FL("Neighbor scan timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4298 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4299 return eHAL_STATUS_RESOURCES;
4300 }
4301
4302 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->neighborResultsRefreshTimer,
4303 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
4304
4305 if (eHAL_STATUS_SUCCESS != status)
4306 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08004307 smsLog(pMac, LOGE, FL("Neighbor results refresh timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4309 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4310 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
4311 return eHAL_STATUS_RESOURCES;
4312 }
4313
Srinivas Girigowdade697412013-02-14 16:31:48 -08004314 status = palTimerAlloc(pMac->hHdd, &pNeighborRoamInfo->emptyScanRefreshTimer,
4315 csrNeighborRoamEmptyScanRefreshTimerCallback,
4316 (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
4317
4318 if (eHAL_STATUS_SUCCESS != status)
4319 {
4320 smsLog(pMac, LOGE, FL("Empty scan refresh timer allocation failed"));
4321 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4322 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4323 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
4324 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
4325 return eHAL_STATUS_RESOURCES;
4326 }
4327
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
4329 if (eHAL_STATUS_SUCCESS != status)
4330 {
4331 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
4332 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4333 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4334 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
4335 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08004336 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 return eHAL_STATUS_RESOURCES;
4338 }
4339
4340 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
4341 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
4342 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4343 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
4344 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
4345
4346#ifdef WLAN_FEATURE_VOWIFI_11R
4347 status = csrNeighborRoamInit11rAssocInfo(pMac);
4348 if (eHAL_STATUS_SUCCESS != status)
4349 {
4350 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
4351 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4352 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4353 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
4354 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08004355 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 csrLLClose(&pNeighborRoamInfo->roamableAPList);
4357 return eHAL_STATUS_RESOURCES;
4358 }
4359#endif
4360 /* Initialize this with the current tick count */
4361 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
4362
4363 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
4364
4365 return eHAL_STATUS_SUCCESS;
4366}
4367
4368/* ---------------------------------------------------------------------------
4369
4370 \fn csrNeighborRoamClose
4371
4372 \brief This function closes/frees all the neighbor roam data structures
4373
4374 \param pMac - The handle returned by macOpen.
4375
4376 \return VOID
4377
4378---------------------------------------------------------------------------*/
4379void csrNeighborRoamClose(tpAniSirGlobal pMac)
4380{
4381 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4382
4383 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
4384 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07004385 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 return;
4387 }
4388
4389 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
4390 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4391
4392 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4393
4394 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
4395 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
4396 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborScanTimer);
4397 palTimerFree(pMac->hHdd, pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowdade697412013-02-14 16:31:48 -08004398 palTimerFree(pMac->hHdd, pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399
4400 /* Should free up the nodes in the list before closing the double Linked list */
4401 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
4402 csrLLClose(&pNeighborRoamInfo->roamableAPList);
4403
4404 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
4405 {
4406 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
4407 }
4408
4409 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4410 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
4411 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
4412 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4413 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
4414 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
4415
4416 /* Free the profile.. */
4417 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08004418#ifdef FEATURE_WLAN_LFR
Sandeep Pc2b00f62012-12-12 16:44:44 -08004419 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Sandeep Pc4818ef2012-12-13 14:19:25 -08004420#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004421#ifdef WLAN_FEATURE_VOWIFI_11R
4422 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
4424 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
4425 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
4426 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4427 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4428#endif /* WLAN_FEATURE_VOWIFI_11R */
4429
4430 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
4431
4432 return;
4433}
4434
4435/* ---------------------------------------------------------------------------
4436
4437 \fn csrNeighborRoamRequestHandoff
4438
4439 \brief This function triggers actual switching from one AP to the new AP.
4440 It issues disassociate with reason code as Handoff and CSR as a part of
4441 handling disassoc rsp, issues reassociate to the new AP
4442
4443 \param pMac - The handle returned by macOpen.
4444
4445 \return VOID
4446
4447---------------------------------------------------------------------------*/
4448void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
4449{
4450
4451 tCsrRoamInfo roamInfo;
4452 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4453 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
4454 tCsrNeighborRoamBSSInfo handoffNode;
4455 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
4456 tANI_U32 roamId = 0;
4457
4458 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
4459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004460 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 pMac->roam.neighborRoamInfo.neighborRoamState);
4462 return;
4463 }
4464
4465 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
4466 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
4467 eSIR_SME_SUCCESS);
4468
4469 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
4470 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
4471
4472 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004473 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
4474 FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 handoffNode.pBssDescription->bssId[0],
4476 handoffNode.pBssDescription->bssId[1],
4477 handoffNode.pBssDescription->bssId[2],
4478 handoffNode.pBssDescription->bssId[3],
4479 handoffNode.pBssDescription->bssId[4],
4480 handoffNode.pBssDescription->bssId[5]);
4481
4482 /* Free the profile.. Just to make sure we dont leak memory here */
4483 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
4484 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
4485 This should happen before issuing disconnect */
4486 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
4487 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
4488 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
4489
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004490 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07004491
4492 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
4493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004494 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate");
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 return;
4496 }
4497
4498 //notify HDD for handoff, providing the BSSID too
4499 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
4500
4501 vos_mem_copy(roamInfo.bssid,
4502 handoffNode.pBssDescription->bssId,
4503 sizeof( tCsrBssid ));
4504
4505 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4506
4507
4508 return;
4509}
4510
4511/* ---------------------------------------------------------------------------
4512
4513 \fn csrNeighborRoamIsHandoffInProgress
4514
4515 \brief This function returns whether handoff is in progress or not based on
4516 the current neighbor roam state
4517
4518 \param pMac - The handle returned by macOpen.
4519 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
4520
4521 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
4522
4523---------------------------------------------------------------------------*/
4524tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
4525{
4526 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
4527 return eANI_BOOLEAN_TRUE;
4528
4529 return eANI_BOOLEAN_FALSE;
4530}
4531
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08004532#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07004533/* ---------------------------------------------------------------------------
4534
4535 \fn csrNeighborRoamIs11rAssoc
4536
4537 \brief This function returns whether the current association is a 11r assoc or not
4538
4539 \param pMac - The handle returned by macOpen.
4540
4541 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
4542
4543---------------------------------------------------------------------------*/
4544tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
4545{
4546 return pMac->roam.neighborRoamInfo.is11rAssoc;
4547}
4548#endif /* WLAN_FEATURE_VOWIFI_11R */
4549
4550
4551/* ---------------------------------------------------------------------------
4552
4553 \fn csrNeighborRoamGetHandoffAPInfo
4554
4555 \brief This function returns the best possible AP for handoff. For 11R case, it
4556 returns the 1st entry from pre-auth done list. For non-11r case, it returns
4557 the 1st entry from roamable AP list
4558
4559 \param pMac - The handle returned by macOpen.
4560 pHandoffNode - AP node that is the handoff candidate returned
4561
4562 \return VOID
4563
4564---------------------------------------------------------------------------*/
4565void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
4566{
4567 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4568 tpCsrNeighborRoamBSSInfo pBssNode;
4569
4570 VOS_ASSERT(NULL != pHandoffNode);
4571
4572#ifdef WLAN_FEATURE_VOWIFI_11R
4573 if (pNeighborRoamInfo->is11rAssoc)
4574 {
4575 /* Always the BSS info in the head is the handoff candidate */
4576 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
4577 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
4578 }
4579 else
4580#endif
4581#ifdef FEATURE_WLAN_CCX
4582 if (pNeighborRoamInfo->isCCXAssoc)
4583 {
4584 /* Always the BSS info in the head is the handoff candidate */
4585 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
4586 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
4587 }
4588 else
4589#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004590#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304591 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004592 {
4593 /* Always the BSS info in the head is the handoff candidate */
4594 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
4595 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
4596 }
4597 else
4598#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 {
4600 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
4601 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
4602 }
4603 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
4604
4605 return;
4606}
4607
4608/* ---------------------------------------------------------------------------
4609 \brief This function returns TRUE if preauth is completed
4610
4611 \param pMac - The handle returned by macOpen.
4612
4613 \return boolean
4614
4615---------------------------------------------------------------------------*/
4616tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
4617{
4618 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
4619 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
4620}
4621
4622/* ---------------------------------------------------------------------------
4623 \brief In the event that we are associated with AP1 and we have
4624 completed pre auth with AP2. Then we receive a deauth/disassoc from
4625 AP1.
4626 At this point neighbor roam is in pre auth done state, pre auth timer
4627 is running. We now handle this case by stopping timer and clearing
4628 the pre-auth state. We basically clear up and just go to disconnected
4629 state.
4630
4631 \param pMac - The handle returned by macOpen.
4632
4633 \return boolean
4634---------------------------------------------------------------------------*/
4635void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
4636{
4637 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
4638 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
4639
4640 // Stop timer
4641 palTimerStop(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
4642
4643 // Transition to init state
4644 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
4645}
4646
Srikant Kuppafef66a72013-01-30 17:32:44 -08004647/* ---------------------------------------------------------------------------
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08004648 \brief This function returns TRUE if background scan triggered by
4649 LFR is in progress.
Srikant Kuppafef66a72013-01-30 17:32:44 -08004650
4651 \param halHandle - The handle from HDD context.
4652
4653 \return boolean
4654
4655---------------------------------------------------------------------------*/
4656tANI_BOOLEAN csrNeighborRoamScanRspPending (tHalHandle hHal)
4657{
4658 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4659 return (pMac->roam.neighborRoamInfo.scanRspPending);
4660}
4661
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08004662/* ---------------------------------------------------------------------------
4663 \brief This function returns TRUE if STA is in the middle of roaming states
4664
4665 \param halHandle - The handle from HDD context.
4666
4667 \return boolean
4668
4669---------------------------------------------------------------------------*/
4670tANI_BOOLEAN csrNeighborMiddleOfRoaming (tHalHandle hHal)
4671{
4672 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4673 tANI_BOOLEAN val = (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4674 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4675 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4676 (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4677 (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState);
4678 return (val);
4679}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004680#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4681/* ---------------------------------------------------------------------------
Srinivas Girigowdaa553c462013-03-07 19:42:52 -08004682
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004683 \fn csrNeighborRoamCandidateFoundIndHdlr
4684
4685 \brief This function is called by CSR as soon as TL posts the candidate
4686 found indication to SME via MC thread
4687
4688 \param pMac - The handle returned by macOpen.
4689 pMsg - Msg sent by PE
4690
4691 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4692
4693---------------------------------------------------------------------------*/
4694eHalStatus csrNeighborRoamCandidateFoundIndHdlr(tpAniSirGlobal pMac, void* pMsg)
4695{
4696 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4697 eHalStatus status = eHAL_STATUS_SUCCESS;
4698 /* we must be in connected state, if not ignore it */
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004699 if ((eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4700 || (pNeighborRoamInfo->uOsRequestedHandoff))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004701 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004702 smsLog(pMac, LOGE, FL("Received in not CONNECTED state OR uOsRequestedHandoff is set. Ignore it"));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004703 status = eHAL_STATUS_FAILURE;
4704 }
4705 else
4706 {
4707 /* We are about to start a fresh scan cycle,
4708 * purge non-P2P results from the past */
4709 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
4710 /* Once it gets the candidates found indication from PE, will issue a scan
4711 - req to PE with “freshScan” in scanreq structure set as follows:
4712 0x42 - Return & purge LFR scan results
4713 */
4714 status = csrScanRequestLfrResult(pMac, pNeighborRoamInfo->csrSessionId,
4715 csrNeighborRoamScanResultRequestCallback, pMac);
4716 }
4717
4718 return status;
4719}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004720
4721/* ---------------------------------------------------------------------------
4722
4723 \fn csrNeighborRoamProcessHandoffReq
4724
4725 \brief This function is called start with the handoff process. First do a
4726 SSID scan for the BSSID provided
4727
4728 \param pMac - The handle returned by macOpen.
4729
4730 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4731
4732---------------------------------------------------------------------------*/
4733eHalStatus csrNeighborRoamProcessHandoffReq(tpAniSirGlobal pMac)
4734{
4735 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4736 eHalStatus status = eHAL_STATUS_SUCCESS;
4737 tANI_U32 roamId;
4738 tCsrRoamProfile *pProfile = NULL;
4739 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pNeighborRoamInfo->csrSessionId );
4740 tANI_U8 i = 0;
4741
4742 do
4743 {
4744 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
4745 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
4746 if(!HAL_STATUS_SUCCESS(status))
4747 {
4748 smsLog(pMac, LOGE, FL("Memory alloc failed"));
4749 break;
4750 }
4751 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
4752 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
4753 if(!HAL_STATUS_SUCCESS(status))
4754 {
4755 smsLog(pMac, LOGE, FL("Profile copy failed"));
4756 break;
4757 }
4758
4759 //Add the BSSID & Channel
4760 pProfile->BSSIDs.numOfBSSIDs = 1;
4761 pProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs);
4762 if (NULL == pProfile->BSSIDs.bssid)
4763 {
4764 smsLog(pMac, LOGE, FL("mem alloc failed for BSSID"));
4765 status = eHAL_STATUS_FAILURE;
4766 break;
4767 }
4768
4769 vos_mem_zero(pProfile->BSSIDs.bssid, sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs);
4770
4771 /* Populate the BSSID from handoff info received from HDD */
4772 for (i = 0; i < pProfile->BSSIDs.numOfBSSIDs; i++)
4773 {
4774 vos_mem_copy(&pProfile->BSSIDs.bssid[i],
4775 pNeighborRoamInfo->handoffReqInfo.bssid, sizeof(tSirMacAddr));
4776 }
4777
4778 pProfile->ChannelInfo.numOfChannels = 1;
4779 pProfile->ChannelInfo.ChannelList =
4780 vos_mem_malloc(sizeof(*pProfile->ChannelInfo.ChannelList) *
4781 pProfile->ChannelInfo.numOfChannels);
4782 if (NULL == pProfile->ChannelInfo.ChannelList)
4783 {
4784 smsLog(pMac, LOGE, FL("mem alloc failed for ChannelList"));
4785 status = eHAL_STATUS_FAILURE;
4786 break;
4787 }
4788 pProfile->ChannelInfo.ChannelList[0] = pNeighborRoamInfo->handoffReqInfo.channel;
4789
4790 //clean up csr cache first
4791 //csrScanFlushSelectiveResult(pMac, VOS_FALSE);
4792 //do a SSID scan
4793 status = csrScanForSSID(pMac, pNeighborRoamInfo->csrSessionId, pProfile, roamId, FALSE);
4794 if(!HAL_STATUS_SUCCESS(status))
4795 {
4796 smsLog(pMac, LOGE, FL("SSID scan failed"));
4797 }
4798 }while(0);
4799
4800 if(NULL != pProfile)
4801 {
4802 csrReleaseProfile(pMac, pProfile);
4803 palFreeMemory(pMac->hHdd, pProfile);
4804 }
4805
4806 return status;
4807}
4808
4809/* ---------------------------------------------------------------------------
4810
4811 \fn csrNeighborRoamSssidScanDone
4812
4813 \brief This function is called once SSID scan is done. If SSID scan failed
4814 to find our candidate add an entry to csr scan cache ourself before starting
4815 the handoff process
4816
4817 \param pMac - The handle returned by macOpen.
4818
4819 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4820
4821---------------------------------------------------------------------------*/
4822eHalStatus csrNeighborRoamSssidScanDone(tpAniSirGlobal pMac, eHalStatus status)
4823{
4824 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4825 eHalStatus hstatus;
4826
4827 smsLog(pMac, LOGE, FL("called "));
4828
4829 /* we must be in connected state, if not ignore it */
4830 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4831 {
4832 smsLog(pMac, LOGE, FL("Received in not CONNECTED state. Ignore it"));
4833 return eHAL_STATUS_FAILURE;
4834 }
4835
4836 //if SSID scan failed to find our candidate add an entry to csr scan cache ourself
4837 if(!HAL_STATUS_SUCCESS(status))
4838 {
4839 smsLog(pMac, LOGE, FL("Add an entry to csr scan cache"));
4840 hstatus = csrScanCreateEntryInScanCache(pMac, pNeighborRoamInfo->csrSessionId,
4841 pNeighborRoamInfo->handoffReqInfo.bssid,
4842 pNeighborRoamInfo->handoffReqInfo.channel);
4843 if (eHAL_STATUS_SUCCESS != hstatus)
4844 {
4845 smsLog(pMac, LOGE, FL("csrScanCreateEntryInScanCache failed with status %d"), hstatus);
4846 return eHAL_STATUS_FAILURE;
4847 }
4848 }
4849
4850 /* Now we have completed scanning for the candidate provided by HDD. Let move on to HO*/
4851 hstatus = csrNeighborRoamProcessScanComplete(pMac);
4852
4853 if (eHAL_STATUS_SUCCESS != hstatus)
4854 {
4855 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
4856 return eHAL_STATUS_FAILURE;
4857 }
4858 return eHAL_STATUS_SUCCESS;
4859}
4860
4861/* ---------------------------------------------------------------------------
4862
4863 \fn csrNeighborRoamHandoffReqHdlr
4864
4865 \brief This function is called by CSR as soon as it gets a handoff request
4866 to SME via MC thread
4867
4868 \param pMac - The handle returned by macOpen.
4869 pMsg - Msg sent by HDD
4870
4871 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4872
4873---------------------------------------------------------------------------*/
4874eHalStatus csrNeighborRoamHandoffReqHdlr(tpAniSirGlobal pMac, void* pMsg)
4875{
4876 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4877 tAniHandoffReq *pHandoffReqInfo;
4878 eHalStatus status = eHAL_STATUS_SUCCESS;
4879 /* we must be in connected state, if not ignore it */
4880 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4881 {
4882 smsLog(pMac, LOGE, FL("Received in not CONNECTED state. Ignore it"));
4883 status = eHAL_STATUS_FAILURE;
4884 }
4885 else
4886 {
4887 //save the handoff info came from HDD as part of the reassoc req
4888 pHandoffReqInfo = (tAniHandoffReq *)pMsg;
4889 if (NULL != pHandoffReqInfo)
4890 {
4891 //sanity check
4892 if (VOS_FALSE == vos_mem_compare(pHandoffReqInfo->bssid,
4893 pNeighborRoamInfo->currAPbssid,
4894 sizeof(tSirMacAddr)))
4895 {
4896
4897 pNeighborRoamInfo->handoffReqInfo.channel = pHandoffReqInfo->channel;
4898 vos_mem_copy(pNeighborRoamInfo->handoffReqInfo.bssid,
4899 pHandoffReqInfo->bssid,
4900 6);
4901 pNeighborRoamInfo->uOsRequestedHandoff = 1;
4902 status = csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP,
4903 REASON_OS_REQUESTED_ROAMING_NOW);
4904 if (eHAL_STATUS_SUCCESS != status)
4905 {
4906 smsLog(pMac, LOGE, FL("csrRoamOffloadScan failed"));
4907 pNeighborRoamInfo->uOsRequestedHandoff = 0;
4908 }
4909 }
4910 else
4911 {
4912 smsLog(pMac, LOGE, FL("Received req has same BSSID as current AP!!"));
4913 status = eHAL_STATUS_FAILURE;
4914 }
4915 }
4916 else
4917 {
4918 smsLog(pMac, LOGE, FL("Received msg is NULL"));
4919 status = eHAL_STATUS_FAILURE;
4920 }
4921 }
4922
4923 return status;
4924}
4925
4926/* ---------------------------------------------------------------------------
4927
4928 \fn csrNeighborRoamProceedWithHandoffReq
4929
4930 \brief This function is called by CSR as soon as it gets rsp back for
4931 ROAM_SCAN_OFFLOAD_STOP with reason REASON_OS_REQUESTED_ROAMING_NOW
4932
4933 \param pMac - The handle returned by macOpen.
4934
4935 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4936
4937---------------------------------------------------------------------------*/
4938eHalStatus csrNeighborRoamProceedWithHandoffReq(tpAniSirGlobal pMac)
4939{
4940 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4941 eHalStatus status = eHAL_STATUS_SUCCESS;
4942 /* we must be in connected state, if not ignore it */
4943 if ((eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4944 || (!pNeighborRoamInfo->uOsRequestedHandoff))
4945 {
4946 smsLog(pMac, LOGE, FL("Received in not CONNECTED state or uOsRequestedHandoff is not set. Ignore it"));
4947 status = eHAL_STATUS_FAILURE;
4948 }
4949 else
4950 {
4951 //Let's go ahead with handoff
4952 status = csrNeighborRoamProcessHandoffReq(pMac);
4953 }
4954 if(!HAL_STATUS_SUCCESS(status))
4955 {
4956 pNeighborRoamInfo->uOsRequestedHandoff = 0;
4957 }
4958 return status;
4959}
4960
4961/* ---------------------------------------------------------------------------
4962
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07004963 \fn csrNeighborRoamStartLfrScan
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004964
4965 \brief This function is called if HDD requested handoff failed for some
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07004966 reason. start the LFR logic at that point.By the time, this function is
4967 called, a STOP command has already been issued.
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004968
4969 \param pMac - The handle returned by macOpen.
4970
4971 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4972
4973---------------------------------------------------------------------------*/
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07004974eHalStatus csrNeighborRoamStartLfrScan(tpAniSirGlobal pMac)
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004975{
4976 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4977 pNeighborRoamInfo->uOsRequestedHandoff = 0;
4978 /* There is no candidate or We are not roaming Now.
4979 * Inform the FW to restart Roam Offload Scan */
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07004980 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07004981
4982 return eHAL_STATUS_SUCCESS;
4983}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004984#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07004985#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */