blob: e9217aa58390e72a398d918cfcf46bb4a7215a40 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala9c070ad2013-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,
Madan Mohan Koyyalamudi313a5932012-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,
Madan Mohan Koyyalamudi313a5932012-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 Yeturu9163b672013-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 Yeturu9163b672013-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 Lokere4bccb762013-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 Lokere4bccb762013-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 Koyyalamudif4289db2012-12-03 16:45:39 -0800269static void csrNeighborRoamTriggerHandoff(tpAniSirGlobal pMac,
270 tpCsrNeighborRoamControlInfo pNeighborRoamInfo)
271{
272#ifdef WLAN_FEATURE_VOWIFI_11R
Varun Reddy Yeturu08614702013-04-15 21:58:13 -0700273 if ((pNeighborRoamInfo->is11rAssoc)
274#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
275 && !csrRoamIsRoamOffloadScanEnabled(pMac)
276#endif
277 )
Madan Mohan Koyyalamudif4289db2012-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 Yeturu08614702013-04-15 21:58:13 -0700293 if ((pNeighborRoamInfo->isCCXAssoc)
294#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
295 && !csrRoamIsRoamOffloadScanEnabled(pMac)
296#endif
297 )
Madan Mohan Koyyalamudif4289db2012-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 Yeturu08614702013-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 Koyyalamudif4289db2012-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 Girigowda392c1692013-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 Koyyalamudif4289db2012-12-03 16:45:39 -0800339 }
340 }
341}
342
Srinivas Girigowda9a1c4ce2013-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 Yeturu09a634e2013-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 Girigowda9a1c4ce2013-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 Yeturu09a634e2013-05-08 14:15:35 -0700371#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
372 }
373#endif
Srinivas Girigowda9a1c4ce2013-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 Yeturu09a634e2013-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 Girigowda9a1c4ce2013-03-21 12:34:46 -0700385 csrNeighborRoamDeregAllRssiIndication(pMac);
Varun Reddy Yeturu09a634e2013-05-08 14:15:35 -0700386#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
387 }
388#endif
Srinivas Girigowda9a1c4ce2013-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 Yeturu09a634e2013-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 Girigowda9a1c4ce2013-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 Yeturu09a634e2013-05-08 14:15:35 -0700432#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
433 }
434#endif
Srinivas Girigowda9a1c4ce2013-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 Yeturu09a634e2013-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 Girigowda9a1c4ce2013-03-21 12:34:46 -0700446 csrNeighborRoamDeregAllRssiIndication(pMac);
Varun Reddy Yeturu09a634e2013-05-08 14:15:35 -0700447#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
448 }
449#endif
Srinivas Girigowda9a1c4ce2013-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 Girigowda6fa58662013-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"));
Srinivas Girigowda18190732013-08-14 11:38:29 -0700475
476 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
477 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
478
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800479 /* De-register existing lookup UP/DOWN, Rssi indications */
Varun Reddy Yeturu071b51f2013-06-05 14:09:58 -0700480#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
481 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
482 {
Srinivas Girigowda18190732013-08-14 11:38:29 -0700483 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_LOOKUP_THRESH_CHANGED);
Varun Reddy Yeturu071b51f2013-06-05 14:09:58 -0700484 }
485 else
486 {
487#endif
488 csrNeighborRoamDeregAllRssiIndication(pMac);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800489
Varun Reddy Yeturu071b51f2013-06-05 14:09:58 -0700490 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
491 FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"),
492 pNeighborRoamInfo->currentNeighborLookupThreshold);
493 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
494 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
495 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
496 WLANTL_HO_THRESHOLD_DOWN,
497 csrNeighborRoamNeighborLookupDOWNCallback,
498 VOS_MODULE_ID_SME, pMac);
499 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
500 {
501 //err msg
502 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vosStatus);
503 vosStatus = VOS_STATUS_E_FAILURE;
504 }
505#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
506 }
507#endif
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800508 }
509 else if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
510 {
511 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Currently in INIT state, safe to set lookupRssi threshold"));
512 pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold = neighborLookupRssiThreshold;
513 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
514 }
515 else
516 {
517 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Unexpected state %d, returning failure"), pNeighborRoamInfo->neighborRoamState);
518 vosStatus = VOS_STATUS_E_FAILURE;
519 }
520 return vosStatus;
521}
522
Jeff Johnson295189b2012-06-20 16:38:30 -0700523/* ---------------------------------------------------------------------------
524
525 \fn csrNeighborRoamReassocIndCallback
526
527 \brief Reassoc callback invoked by TL on crossing the registered re-assoc threshold.
528 Directly triggere HO in case of non-11r association
529 In case of 11R association, triggers a pre-auth eventually followed by actual HO
530
531 \param pAdapter - VOS Context
532 trafficStatus - UP/DOWN indication from TL
533 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
534
535 \return VOID
536
537---------------------------------------------------------------------------*/
538VOS_STATUS csrNeighborRoamReassocIndCallback(v_PVOID_t pAdapter,
539 v_U8_t trafficStatus,
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -0800540 v_PVOID_t pUserCtxt,
541 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -0700542{
543 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
544 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
545 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
546
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800547 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. Threshold RSSI = %d Reported RSSI = %d"),
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -0800548 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
549 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550
551 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
552 WLANTL_HO_THRESHOLD_DOWN,
553 csrNeighborRoamReassocIndCallback,
554 VOS_MODULE_ID_SME);
555
556 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
557 {
558 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800559 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
561
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -0800562 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Rcvd reassoc notification-deregister UP indication. Threshold RSSI = %d Reported RSSI = %d"),
563 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1), avgRssi);
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -0800564 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
565 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
566 WLANTL_HO_THRESHOLD_UP,
567 csrNeighborRoamNeighborLookupUPCallback,
568 VOS_MODULE_ID_SME);
Jeff Johnson295189b2012-06-20 16:38:30 -0700569
570 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
571 {
572 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800573 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamNeighborLookupUPCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 }
575
576 /* We dont need to run this timer any more. */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +0530577 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
578 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -0800580 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 return VOS_STATUS_SUCCESS;
583}
584
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700585/*CleanUP Routines*/
586static void csrNeighborRoamResetChannelInfo(tpCsrNeighborRoamChannelInfo rChInfo)
587{
588 if ((rChInfo->IAPPNeighborListReceived == FALSE) &&
589 (rChInfo->currentChannelListInfo.numOfChannels))
590 {
591 rChInfo->currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
592 rChInfo->currentChannelListInfo.numOfChannels = 0;
593
594 if (rChInfo->currentChannelListInfo.ChannelList)
595 vos_mem_free(rChInfo->currentChannelListInfo.ChannelList);
596
597 rChInfo->currentChannelListInfo.ChannelList = NULL;
598 rChInfo->chanListScanInProgress = eANI_BOOLEAN_FALSE;
599 }
600 else
601 {
602 rChInfo->currentChanIndex = 0;
603 rChInfo->chanListScanInProgress = eANI_BOOLEAN_TRUE;
604 }
605}
606
607static void csrNeighborRoamResetCfgListChanScanControlInfo(tpAniSirGlobal pMac)
608{
609 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
610
611 /* Stop neighbor scan timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +0530612 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700613
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700614 /* Stop neighbor scan results refresh timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +0530615 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -0700616
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800617 /* Stop empty scan results refresh timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +0530618 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800619
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700620 /* Abort any ongoing scan */
621 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
622 {
Madan Mohan Koyyalamudi78f17402013-06-13 14:47:55 +0530623 csrScanAbortMacScan(pMac, pNeighborRoamInfo->csrSessionId);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700624 }
625 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
626
627 /* Reset roam channel list information */
628 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
629}
630
631static void csrNeighborRoamResetPreauthControlInfo(tpAniSirGlobal pMac)
632{
633 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
634
635#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
636 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700637 /* Purge pre-auth fail list */
638 csrNeighborRoamPurgePreauthFailedList(pMac);
639#endif
640
641 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
642 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
643#ifdef WLAN_FEATURE_VOWIFI_11R
644 /* Do not free up the preauth done list here */
645 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
646 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
647 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
648 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700649#endif
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -0700650#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
651 pNeighborRoamInfo->uOsRequestedHandoff = 0;
652 vos_mem_zero(&pNeighborRoamInfo->handoffReqInfo, sizeof(tCsrHandoffRequest));
653#endif
654
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700655}
656
657static void csrNeighborRoamDeregAllRssiIndication(tpAniSirGlobal pMac)
658{
659 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
660 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
661
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800662 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700663 FL("Deregister neighbor lookup UP callback with TL. RSSI = %d"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800664 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700665
666 /* Deregister reassoc callback. Ignore return status */
667 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800668 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700669 WLANTL_HO_THRESHOLD_UP,
670 csrNeighborRoamNeighborLookupUPCallback,
671 VOS_MODULE_ID_SME);
672
673 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
674 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800675 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700676 FL("Couldn't deregister csrNeighborRoamNeighborLookupUPCallback "
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800677 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700678 }
679
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800680 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700681 FL("Deregistering reassoc DOWN callback with TL. RSSI = %d"),
682 pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
683
684 /* Deregister reassoc callback. Ignore return status */
685 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
686 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
687 WLANTL_HO_THRESHOLD_DOWN,
688 csrNeighborRoamReassocIndCallback,
689 VOS_MODULE_ID_SME);
690
691 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
692 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800693 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700694 FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with "
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800695 "TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700696 }
697
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800698 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700699 FL("Deregistering neighborLookup DOWN callback with TL. RSSI = %d"),
700 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
701
702 /* Deregister neighbor lookup callback. Ignore return status */
703 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
704 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
705 WLANTL_HO_THRESHOLD_DOWN,
706 csrNeighborRoamNeighborLookupDOWNCallback,
707 VOS_MODULE_ID_SME);
708
709 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
710 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800711 smsLog(pMac, LOGW,
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700712 FL(" Couldn't deregister csrNeighborRoamNeighborLookupDOWNCallback "
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800713 "with TL: Status = %d"), vosStatus);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700714 }
715
716 /* Reset thresholds only after deregistering DOWN event from TL */
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700717 pNeighborRoamInfo->currentNeighborLookupThreshold =
718 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800719#ifdef FEATURE_WLAN_LFR
720 pNeighborRoamInfo->uEmptyScanCount = 0;
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -0800721 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800722 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -0800723#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700724}
725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726/* ---------------------------------------------------------------------------
727
728 \fn csrNeighborRoamResetConnectedStateControlInfo
729
730 \brief This function will reset the neighbor roam control info data structures.
731 This function should be invoked whenever we move to CONNECTED state from
732 any state other than INIT state
733
734 \param pMac - The handle returned by macOpen.
735
736 \return VOID
737
738---------------------------------------------------------------------------*/
739void csrNeighborRoamResetConnectedStateControlInfo(tpAniSirGlobal pMac)
740{
741 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
742
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700743 csrNeighborRoamResetChannelInfo(&pNeighborRoamInfo->roamChannelInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700746 /* We dont need to run this timer any more. */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +0530747 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
748 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700749
750#ifdef WLAN_FEATURE_VOWIFI_11R
751 /* Do not free up the preauth done list here */
752 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
753 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
754 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
755 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
756 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = 0;
757 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
Jeff Johnson295189b2012-06-20 16:38:30 -0700758#endif
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -0700759#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
760 pNeighborRoamInfo->uOsRequestedHandoff = 0;
761 vos_mem_zero(&pNeighborRoamInfo->handoffReqInfo, sizeof(tCsrHandoffRequest));
762#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700763}
764
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700765void csrNeighborRoamResetReportScanStateControlInfo(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700766{
767 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
769 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
770 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
771 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700772#ifdef FEATURE_WLAN_CCX
773 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
774 pNeighborRoamInfo->isVOAdmitted = eANI_BOOLEAN_FALSE;
775 pNeighborRoamInfo->MinQBssLoadRequired = 0;
776#endif
Madan Mohan Koyyalamudi595208a2012-10-05 12:48:38 -0700777
778 /* Stop scan refresh timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +0530779 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800780 /* Stop empty scan results refresh timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +0530781 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -0700782 /* Purge roamable AP list */
783 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 return;
785}
786
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -0700787/* ---------------------------------------------------------------------------
788
789 \fn csrNeighborRoamResetInitStateControlInfo
790
791 \brief This function will reset the neighbor roam control info data structures.
792 This function should be invoked whenever we move to CONNECTED state from
793 INIT state
794
795 \param pMac - The handle returned by macOpen.
796
797 \return VOID
798
799---------------------------------------------------------------------------*/
800void csrNeighborRoamResetInitStateControlInfo(tpAniSirGlobal pMac)
801{
802 csrNeighborRoamResetConnectedStateControlInfo(pMac);
803
804 /* In addition to the above resets, we should clear off the curAPBssId/Session ID in the timers */
805 csrNeighborRoamResetReportScanStateControlInfo(pMac);
806}
807
808
809
Jeff Johnson295189b2012-06-20 16:38:30 -0700810#ifdef WLAN_FEATURE_VOWIFI_11R
811/* ---------------------------------------------------------------------------
812
813 \fn csrNeighborRoamBssIdScanFilter
814
815 \brief This API is used to prepare a filter to obtain scan results when
816 we complete the scan in the REPORT_SCAN state after receiving a
817 valid neighbor report from AP. This filter includes BSSIDs received from
818 the neighbor report from the AP in addition to the other filter parameters
819 created from connected profile
820
821 \param pMac - The handle returned by macOpen.
822 pScanFilter - Scan filter to be filled and returned
823
824 \return eHAL_STATUS_SUCCESS on succesful filter creation, corresponding error
825 code otherwise
826
827---------------------------------------------------------------------------*/
828static eHalStatus csrNeighborRoamBssIdScanFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
829{
830 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
831 tANI_U8 i = 0;
832
833 VOS_ASSERT(pScanFilter != NULL);
Gopichand Nakkalab264aea2013-03-29 01:07:54 +0530834 if (pScanFilter == NULL)
835 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
837
838 pScanFilter->BSSIDs.numOfBSSIDs = pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport;
839 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
840 if (NULL == pScanFilter->BSSIDs.bssid)
841 {
842 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
843 return eHAL_STATUS_FAILED_ALLOC;
844 }
845
846 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
847
848 /* Populate the BSSID from Neighbor BSS info received from neighbor report */
849 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
850 {
851 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
852 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[i].neighborBssId, sizeof(tSirMacAddr));
853 }
854
855 /* Fill other general scan filter params */
856 return csrNeighborRoamPrepareScanProfileFilter(pMac, pScanFilter);
857}
858
859/* ---------------------------------------------------------------------------
860
861 \fn csrNeighborRoamPurgePreauthFailList
862
863 \brief This function empties the preauth fail list
864
865 \param pMac - The handle returned by macOpen.
866
867 \return VOID
868
869---------------------------------------------------------------------------*/
870void csrNeighborRoamPurgePreauthFailList(tpAniSirGlobal pMac)
871{
872 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
873
874 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Purging the preauth fail list"));
875 while (pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
876 {
877 vos_mem_zero(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress-1],
878 sizeof(tSirMacAddr));
879 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress--;
880 }
881 return;
882}
883
884/* ---------------------------------------------------------------------------
885
886 \fn csrNeighborRoamAddBssIdToPreauthFailList
887
888 \brief This function adds the given BSSID to the Preauth fail list
889
890 \param pMac - The handle returned by macOpen.
891 bssId - BSSID to be added to the preauth fail list
892
893 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
894
895---------------------------------------------------------------------------*/
896eHalStatus csrNeighborRoamAddBssIdToPreauthFailList(tpAniSirGlobal pMac, tSirMacAddr bssId)
897{
898 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
899
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -0800900 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 -0700901 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
902
903
904 if ((pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress + 1) >
905 MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS)
906 {
907 smsLog(pMac, LOGE, FL("Preauth fail list already full.. Cannot add new one"));
908 return eHAL_STATUS_FAILURE;
909 }
910 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress],
911 bssId, sizeof(tSirMacAddr));
912 pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress++;
913
914 return eHAL_STATUS_SUCCESS;
915}
916
917/* ---------------------------------------------------------------------------
918
919 \fn csrNeighborRoamIsPreauthCandidate
920
921 \brief This function checks whether the given MAC address is already
922 present in the preauth fail list and returns TRUE/FALSE accordingly
923
924 \param pMac - The handle returned by macOpen.
925
926 \return eANI_BOOLEAN_TRUE if preauth candidate, eANI_BOOLEAN_FALSE otherwise
927
928---------------------------------------------------------------------------*/
929tANI_BOOLEAN csrNeighborRoamIsPreauthCandidate(tpAniSirGlobal pMac, tSirMacAddr bssId)
930{
931 tANI_U8 i = 0;
932 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
933
Varun Reddy Yeturu08614702013-04-15 21:58:13 -0700934#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
935 if (csrRoamIsRoamOffloadScanEnabled(pMac))
936 {
937 return eANI_BOOLEAN_TRUE;
938 }
939#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 if (0 == pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress)
941 return eANI_BOOLEAN_TRUE;
942
943 for (i = 0; i < pNeighborRoamInfo->FTRoamInfo.preAuthFailList.numMACAddress; i++)
944 {
945 if (VOS_TRUE == vos_mem_compare(pNeighborRoamInfo->FTRoamInfo.preAuthFailList.macAddress[i],
946 bssId, sizeof(tSirMacAddr)))
947 {
948 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("BSSID %02x:%02x:%02x:%02x:%02x:%02x already present in preauth fail list"),
949 bssId[0], bssId[1], bssId[2], bssId[3], bssId[4], bssId[5]);
950 return eANI_BOOLEAN_FALSE;
951 }
952 }
953
954 return eANI_BOOLEAN_TRUE;
955}
956
957/* ---------------------------------------------------------------------------
958
959 \fn csrNeighborRoamIssuePreauthReq
960
961 \brief This function issues preauth request to PE with the 1st AP entry in the
962 roamable AP list
963
964 \param pMac - The handle returned by macOpen.
965
966 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
967
968---------------------------------------------------------------------------*/
969static eHalStatus csrNeighborRoamIssuePreauthReq(tpAniSirGlobal pMac)
970{
971 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
972 eHalStatus status = eHAL_STATUS_SUCCESS;
973 tpCsrNeighborRoamBSSInfo pNeighborBssNode;
974
975 /* This must not be true here */
976 VOS_ASSERT(pNeighborRoamInfo->FTRoamInfo.preauthRspPending == eANI_BOOLEAN_FALSE);
977
978 /* Issue Preauth request to PE here */
979 /* Need to issue the preauth request with the BSSID that is there in the head of the roamable AP list */
980 /* Parameters that should be passed are BSSID, Channel number and the neighborScanPeriod(probably) */
981 /* If roamableAPList gets empty, should transition to REPORT_SCAN state */
982 pNeighborBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
983
984 if (NULL == pNeighborBssNode)
985 {
986 smsLog(pMac, LOG1, FL("Roamable AP list is empty.. "));
987 return eHAL_STATUS_FAILURE;
988 }
989 else
990 {
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700991 status = csrRoamEnqueuePreauth(pMac, pNeighborRoamInfo->csrSessionId, pNeighborBssNode->pBssDescription,
992 eCsrPerformPreauth, eANI_BOOLEAN_TRUE);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530993
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -0800994 smsLog(pMac, LOG1, FL("Before Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +0530995 pNeighborBssNode->pBssDescription->bssId[0],
996 pNeighborBssNode->pBssDescription->bssId[1],
997 pNeighborBssNode->pBssDescription->bssId[2],
998 pNeighborBssNode->pBssDescription->bssId[3],
999 pNeighborBssNode->pBssDescription->bssId[4],
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08001000 pNeighborBssNode->pBssDescription->bssId[5],
1001 (int)pNeighborBssNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301002
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 if (eHAL_STATUS_SUCCESS != status)
1004 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001005 smsLog(pMac, LOGE, FL("Send Preauth request to PE failed with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 return status;
1007 }
1008 }
1009
1010 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_TRUE;
1011
1012 /* Increment the preauth retry count */
1013 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries++;
1014
1015 /* Transition the state to preauthenticating */
1016 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING)
Jeff Johnson295189b2012-06-20 16:38:30 -07001017
1018 return status;
1019}
1020
1021/* ---------------------------------------------------------------------------
1022
1023 \fn csrNeighborRoamPreauthRspHandler
1024
1025 \brief This function handle the Preauth response from PE
1026 Every preauth is allowed max 3 tries if it fails. If a bssid failed
1027 for more than MAX_TRIES, we will remove it from the list and try
1028 with the next node in the roamable AP list and add the BSSID to pre-auth failed
1029 list. If no more entries present in
1030 roamable AP list, transition to REPORT_SCAN state
1031
1032 \param pMac - The handle returned by macOpen.
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001033 limStatus - eSIR_SUCCESS/eSIR_FAILURE/eSIR_LIM_MAX_STA_REACHED_ERROR/
1034 eSIT_LIM_AUTH_RSP_TIMEOUT status from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07001035
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001036 \return eHAL_STATUS_SUCCESS on success (i.e. pre-auth processed),
1037 eHAL_STATUS_FAILURE otherwise
Jeff Johnson295189b2012-06-20 16:38:30 -07001038
1039---------------------------------------------------------------------------*/
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001040eHalStatus csrNeighborRoamPreauthRspHandler(tpAniSirGlobal pMac, tSirRetStatus limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001041{
1042 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1043 eHalStatus status = eHAL_STATUS_SUCCESS;
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001044 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001045 eHalStatus preauthProcessed = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 tpCsrNeighborRoamBSSInfo pPreauthRspNode = NULL;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001047
1048 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->FTRoamInfo.preauthRspPending)
1049 {
1050
1051 /* This can happen when we disconnect immediately
1052 * after sending a pre-auth request. During processing
1053 * of the disconnect command, we would have reset
1054 * preauthRspPending and transitioned to INIT state.
1055 */
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001056 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
1057 FL("Unexpected pre-auth response in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001058 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001059 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001060 goto DEQ_PREAUTH;
1061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001062
1063 // We can receive it in these 2 states.
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 if ((pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING) &&
1065 (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN))
1066 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001067 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Preauth response received in state %d"),
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001068 pNeighborRoamInfo->neighborRoamState);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001069 preauthProcessed = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001070 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 }
1072
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001073 pNeighborRoamInfo->FTRoamInfo.preauthRspPending = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001074
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001075 if (eSIR_SUCCESS == limStatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 {
1077 pPreauthRspNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
1078 }
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001079 if ((eSIR_SUCCESS == limStatus) && (NULL != pPreauthRspNode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001081 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Preauth completed successfully after %d tries"), pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries);
Jeff Johnson295189b2012-06-20 16:38:30 -07001082
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08001083 smsLog(pMac, LOG1, FL("After Pre-Auth: BSSID %02x:%02x:%02x:%02x:%02x:%02x, Ch:%d"),
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301084 pPreauthRspNode->pBssDescription->bssId[0],
1085 pPreauthRspNode->pBssDescription->bssId[1],
1086 pPreauthRspNode->pBssDescription->bssId[2],
1087 pPreauthRspNode->pBssDescription->bssId[3],
1088 pPreauthRspNode->pBssDescription->bssId[4],
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08001089 pPreauthRspNode->pBssDescription->bssId[5],
1090 (int)pPreauthRspNode->pBssDescription->channelId);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301091
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 /* Preauth competer successfully. Insert the preauthenticated node to tail of preAuthDoneList */
1093 csrNeighborRoamRemoveRoamableAPListEntry(pMac, &pNeighborRoamInfo->roamableAPList, pPreauthRspNode);
1094 csrLLInsertTail(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, &pPreauthRspNode->List, LL_ACCESS_LOCK);
1095
1096 /* Pre-auth completed successfully. Transition to PREAUTH Done state */
1097 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
1098 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
1099
1100 /* The caller of this function would start a timer and by the time it expires, supplicant should
1101 have provided the updated FTIEs to SME. So, when it expires, handoff will be triggered then */
1102 }
1103 else
1104 {
1105 tpCsrNeighborRoamBSSInfo pNeighborBssNode = NULL;
1106 tListElem *pEntry;
1107
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001108 smsLog(pMac, LOGE, FL("Preauth failed retry number %d, status = 0x%x"),
1109 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries, limStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110
1111 /* Preauth failed. Add the bssId to the preAuth failed list MAC Address. Also remove the AP from roamable AP list */
Srikant Kuppa40b3c142013-02-20 07:24:43 -08001112 if ((pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries >=
1113 CSR_NEIGHBOR_ROAM_MAX_NUM_PREAUTH_RETRIES) ||
1114 (eSIR_LIM_MAX_STA_REACHED_ERROR == limStatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 {
1116 /* We are going to remove the node as it fails for more than MAX tries. Reset this count to 0 */
1117 pNeighborRoamInfo->FTRoamInfo.numPreAuthRetries = 0;
1118
1119 /* The one in the head of the list should be one with which we issued pre-auth and failed */
1120 pEntry = csrLLRemoveHead(&pNeighborRoamInfo->roamableAPList, LL_ACCESS_LOCK);
1121 if(pEntry)
1122 {
1123 pNeighborBssNode = GET_BASE_ADDR(pEntry, tCsrNeighborRoamBSSInfo, List);
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07001124 /* Add the BSSID to pre-auth fail list if it is not requested by HDD */
1125#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1126 if(!pNeighborRoamInfo->uOsRequestedHandoff)
1127#endif
1128 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 status = csrNeighborRoamAddBssIdToPreauthFailList(pMac, pNeighborBssNode->pBssDescription->bssId);
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07001130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 /* Now we can free this node */
1132 csrNeighborRoamFreeNeighborRoamBSSNode(pMac, pNeighborBssNode);
1133 }
1134 }
1135
1136 /* Issue preauth request for the same/next entry */
1137 if (eHAL_STATUS_SUCCESS == csrNeighborRoamIssuePreauthReq(pMac))
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001138 goto DEQ_PREAUTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07001139
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001140#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1141 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001142 {
Varun Reddy Yeturu6fc169c2013-06-07 00:56:52 -07001143 if(pNeighborRoamInfo->uOsRequestedHandoff)
1144 {
1145 pNeighborRoamInfo->uOsRequestedHandoff = 0;
1146 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_PREAUTH_FAILED_FOR_ALL);
1147 }
1148 else
1149 {
1150 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_RESTART, REASON_PREAUTH_FAILED_FOR_ALL);
1151 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001152 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1153 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 {
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001155#endif
1156 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN);
1157
1158 /* Register Neighbor Lookup threshold callback with TL for UP event now */
1159 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No more pre-auth candidates-"
1160 "register UP indication with TL. RSSI = %d,"), NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1161
1162 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1163 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1164 WLANTL_HO_THRESHOLD_UP,
1165 csrNeighborRoamNeighborLookupUPCallback,
1166 VOS_MODULE_ID_SME, pMac);
1167 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1168 {
1169 //err msg
1170 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
1171 }
1172
1173 /* Start the neighbor results refresh timer and transition to REPORT_SCAN state to perform scan again */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05301174 status = vos_timer_start(&pNeighborRoamInfo->neighborResultsRefreshTimer,
1175 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod);
1176 if ( status != eHAL_STATUS_SUCCESS )
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001177 {
1178 smsLog(pMac, LOGE, FL("Neighbor results refresh timer start failed with status %d"), status);
1179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001181#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001183#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07001184
1185DEQ_PREAUTH:
1186 csrRoamDequeuePreauth(pMac);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -07001187 return preauthProcessed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001188}
1189#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
1190
1191/* ---------------------------------------------------------------------------
1192
1193 \fn csrNeighborRoamPrepareScanProfileFilter
1194
1195 \brief This function creates a scan filter based on the currently connected profile.
1196 Based on this filter, scan results are obtained
1197
1198 \param pMac - The handle returned by macOpen.
1199 pScanFilter - Populated scan filter based on the connected profile
1200
1201 \return eHAL_STATUS_SUCCESS on success, eHAL_STATUS_FAILURE otherwise
1202
1203---------------------------------------------------------------------------*/
1204eHalStatus csrNeighborRoamPrepareScanProfileFilter(tpAniSirGlobal pMac, tCsrScanResultFilter *pScanFilter)
1205{
1206 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1207 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
1208 tCsrRoamConnectedProfile *pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
1209 tANI_U8 i = 0;
1210
1211 VOS_ASSERT(pScanFilter != NULL);
Gopichand Nakkalab264aea2013-03-29 01:07:54 +05301212 if (pScanFilter == NULL)
1213 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001214
1215 vos_mem_zero(pScanFilter, sizeof(tCsrScanResultFilter));
1216
1217 /* We dont want to set BSSID based Filter */
1218 pScanFilter->BSSIDs.numOfBSSIDs = 0;
1219
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07001220 //only for HDD requested handoff fill in the BSSID in the filter
1221#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1222 if (pNeighborRoamInfo->uOsRequestedHandoff)
1223 {
1224 pScanFilter->BSSIDs.numOfBSSIDs = 1;
1225 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
1226 if (NULL == pScanFilter->BSSIDs.bssid)
1227 {
1228 smsLog(pMac, LOGE, FL("Scan Filter BSSID mem alloc failed"));
1229 return eHAL_STATUS_FAILED_ALLOC;
1230 }
1231
1232 vos_mem_zero(pScanFilter->BSSIDs.bssid, sizeof(tSirMacAddr) * pScanFilter->BSSIDs.numOfBSSIDs);
1233
1234 /* Populate the BSSID from handoff info received from HDD */
1235 for (i = 0; i < pScanFilter->BSSIDs.numOfBSSIDs; i++)
1236 {
1237 vos_mem_copy(&pScanFilter->BSSIDs.bssid[i],
1238 pNeighborRoamInfo->handoffReqInfo.bssid, sizeof(tSirMacAddr));
1239 }
1240 }
1241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 /* Populate all the information from the connected profile */
1243 pScanFilter->SSIDs.numOfSSIDs = 1;
1244 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
1245 if (NULL == pScanFilter->SSIDs.SSIDList)
1246 {
1247 smsLog(pMac, LOGE, FL("Scan Filter SSID mem alloc failed"));
1248 return eHAL_STATUS_FAILED_ALLOC;
1249 }
1250 pScanFilter->SSIDs.SSIDList->handoffPermitted = 1;
1251 pScanFilter->SSIDs.SSIDList->ssidHidden = 0;
1252 pScanFilter->SSIDs.SSIDList->SSID.length = pCurProfile->SSID.length;
1253 vos_mem_copy((void *)pScanFilter->SSIDs.SSIDList->SSID.ssId, (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length);
1254
Sanjay Devnania7114092013-06-24 11:46:56 -07001255 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Filtering for SSID %.*s from scan results,"
1256 "length of SSID = %u"),
1257 pScanFilter->SSIDs.SSIDList->SSID.length,
1258 pScanFilter->SSIDs.SSIDList->SSID.ssId,
1259 pScanFilter->SSIDs.SSIDList->SSID.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 pScanFilter->authType.numEntries = 1;
1261 pScanFilter->authType.authType[0] = pCurProfile->AuthType;
1262
1263 pScanFilter->EncryptionType.numEntries = 1; //This must be 1
1264 pScanFilter->EncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
1265
1266 pScanFilter->mcEncryptionType.numEntries = 1;
1267 pScanFilter->mcEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
1268
1269 pScanFilter->BSSType = pCurProfile->BSSType;
1270
1271 /* We are intrested only in the scan results on channels that we scanned */
1272 pScanFilter->ChannelInfo.numOfChannels = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels;
1273 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(pScanFilter->ChannelInfo.numOfChannels * sizeof(tANI_U8));
1274 if (NULL == pScanFilter->ChannelInfo.ChannelList)
1275 {
1276 smsLog(pMac, LOGE, FL("Scan Filter Channel list mem alloc failed"));
1277 vos_mem_free(pScanFilter->SSIDs.SSIDList);
1278 pScanFilter->SSIDs.SSIDList = NULL;
1279 return eHAL_STATUS_FAILED_ALLOC;
1280 }
1281 for (i = 0; i < pScanFilter->ChannelInfo.numOfChannels; i++)
1282 {
1283 pScanFilter->ChannelInfo.ChannelList[i] = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[i];
1284 }
1285
1286#ifdef WLAN_FEATURE_VOWIFI_11R
1287 if (pNeighborRoamInfo->is11rAssoc)
1288 {
1289 /* MDIE should be added as a part of profile. This should be added as a part of filter as well */
1290 pScanFilter->MDID.mdiePresent = pCurProfile->MDID.mdiePresent;
1291 pScanFilter->MDID.mobilityDomain = pCurProfile->MDID.mobilityDomain;
1292 }
1293#endif
1294
1295 return eHAL_STATUS_SUCCESS;
1296}
1297
Jeff Johnson43971f52012-07-17 12:26:56 -07001298tANI_U32 csrGetCurrentAPRssi(tpAniSirGlobal pMac, tScanResultHandle *pScanResultList)
1299{
1300 tCsrScanResultInfo *pScanResult;
1301 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Srinivas Girigowda4d641342013-01-24 17:40:41 -08001302#ifdef FEATURE_WLAN_LFR
1303 tANI_U32 CurrAPRssi = pNeighborRoamInfo->lookupDOWNRssi;
1304#else
1305 /* We are setting this as default value to make sure we return this value,
1306 when we do not see this AP in the scan result for some reason.However,it is
1307 less likely that we are associated to an AP and do not see it in the scan list */
1308 tANI_U32 CurrAPRssi = -125;
1309#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001310
1311 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1312 {
1313
1314 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1315 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1316 {
1317 /* We got a match with the currently associated AP.
1318 * Capture the RSSI value and complete the while loop.
1319 * The while loop is completed in order to make the current entry go back to NULL,
1320 * and in the next while loop, it properly starts searching from the head of the list.
1321 * TODO: Can also try setting the current entry directly to NULL as soon as we find the new AP*/
1322
1323 CurrAPRssi = (int)pScanResult->BssDescriptor.rssi * (-1) ;
1324
1325 } else {
1326 continue;
1327 }
1328 }
1329
1330 return CurrAPRssi;
1331
1332}
1333
Jeff Johnson295189b2012-06-20 16:38:30 -07001334/* ---------------------------------------------------------------------------
1335
1336 \fn csrNeighborRoamProcessScanResults
1337
1338 \brief This function extracts scan results, sorts on the basis of neighbor score(todo).
1339 Assumed that the results are already sorted by RSSI by csrScanGetResult
1340
1341 \param pMac - The handle returned by macOpen.
1342 pScanResultList - Scan result result obtained from csrScanGetResult()
1343
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001344 \return tANI_BOOLEAN - return TRUE if we have a candidate we can immediately
1345 roam to. Otherwise, return FALSE.
Jeff Johnson295189b2012-06-20 16:38:30 -07001346
1347---------------------------------------------------------------------------*/
1348
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001349static tANI_BOOLEAN csrNeighborRoamProcessScanResults(tpAniSirGlobal pMac,
1350 tScanResultHandle *pScanResultList)
Jeff Johnson295189b2012-06-20 16:38:30 -07001351{
1352 tCsrScanResultInfo *pScanResult;
1353 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1354 tpCsrNeighborRoamBSSInfo pBssInfo;
Jeff Johnson43971f52012-07-17 12:26:56 -07001355 tANI_U32 CurrAPRssi;
1356 tANI_U8 RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001357#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1358 tANI_U8 immediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1359#endif
1360 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Jeff Johnson43971f52012-07-17 12:26:56 -07001361
1362 /***************************************************************
1363 * Find out the Current AP RSSI and keep it handy to check if
1364 * it is better than the RSSI of the AP which we are
1365 * going to roam.If so, we are going to continue with the
1366 * current AP.
1367 ***************************************************************/
1368 CurrAPRssi = csrGetCurrentAPRssi(pMac, pScanResultList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001369
1370 /* Expecting the scan result already to be in the sorted order based on the RSSI */
1371 /* Based on the previous state we need to check whether the list should be sorted again taking neighbor score into consideration */
1372 /* If previous state is CFG_CHAN_LIST_SCAN, there should not be any neighbor score associated with any of the BSS.
1373 If the previous state is REPORT_QUERY, then there will be neighbor score for each of the APs */
1374 /* 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
1375 and rssi score are in the same order. This will be taken care later */
1376
1377 while (NULL != (pScanResult = csrScanResultGetNext(pMac, *pScanResultList)))
1378 {
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08001379 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
1380 FL("Scan result: BSSID %02x:%02x:%02x:%02x:%02x:%02x (Rssi %d, Ch:%d)"),
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001381 pScanResult->BssDescriptor.bssId[0],
1382 pScanResult->BssDescriptor.bssId[1],
1383 pScanResult->BssDescriptor.bssId[2],
1384 pScanResult->BssDescriptor.bssId[3],
1385 pScanResult->BssDescriptor.bssId[4],
1386 pScanResult->BssDescriptor.bssId[5],
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08001387 abs(pScanResult->BssDescriptor.rssi),
1388 pScanResult->BssDescriptor.channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001390 if (VOS_TRUE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 pNeighborRoamInfo->currAPbssid, sizeof(tSirMacAddr)))
1392 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001393 /* currently associated AP. Do not have this in the roamable AP list */
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001394 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001395 "SKIP-currently associated AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 continue;
1397 }
1398
Tushnim Bhattacharyya4207db02013-06-26 23:23:18 -07001399#ifdef FEATURE_WLAN_LFR
1400#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1401 /* In case of reassoc requested by upper layer, look for exact match of bssid & channel;
1402 csr cache might have duplicates*/
1403 if ((pNeighborRoamInfo->uOsRequestedHandoff) &&
1404 ((VOS_FALSE == vos_mem_compare(pScanResult->BssDescriptor.bssId,
1405 pNeighborRoamInfo->handoffReqInfo.bssid,
1406 sizeof(tSirMacAddr)))||
1407 (pScanResult->BssDescriptor.channelId != pNeighborRoamInfo->handoffReqInfo.channel)))
1408
1409 {
1410 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1411 "SKIP-not a candidate AP for OS requested roam");
1412 continue;
1413 }
1414#endif
1415#endif
1416
Jeff Johnson43971f52012-07-17 12:26:56 -07001417 /* This condition is to ensure to roam to an AP with better RSSI. if the value of RoamRssiDiff is Zero, this feature
1418 * is disabled and we continue to roam without any check*/
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001419 if ((RoamRssiDiff > 0)
1420#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1421 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1422#endif
1423 )
Jeff Johnson43971f52012-07-17 12:26:56 -07001424 {
Madan Mohan Koyyalamudi281e80c2012-12-03 16:37:39 -08001425 /*
1426 * If RSSI is lower than the lookup threshold, then continue.
1427 */
1428 if (abs(pScanResult->BssDescriptor.rssi) >
1429 pNeighborRoamInfo->currentNeighborLookupThreshold)
1430 {
1431 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001432 "%s: [INFOLOG] new ap rssi (%d) lower than lookup threshold (%d)",
Madan Mohan Koyyalamudi281e80c2012-12-03 16:37:39 -08001433 __func__, (int)pScanResult->BssDescriptor.rssi * (-1),
1434 (int)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1435 continue;
1436 }
1437
Jeff Johnson43971f52012-07-17 12:26:56 -07001438 if (abs(CurrAPRssi) < abs(pScanResult->BssDescriptor.rssi))
1439 {
1440 /*Do not roam to an AP with worse RSSI than the current*/
1441 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001442 "%s: [INFOLOG]Current AP rssi=%d new ap rssi worse=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001443 CurrAPRssi,
1444 (int)pScanResult->BssDescriptor.rssi * (-1) );
1445 continue;
1446 } else {
1447 /*Do not roam to an AP which is having better RSSI than the current AP, but still less than the
1448 * margin that is provided by user from the ini file (RoamRssiDiff)*/
1449 if (abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) < RoamRssiDiff)
1450 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001451 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001452 "%s: [INFOLOG]Current AP rssi=%d new ap rssi=%d not good enough, roamRssiDiff=%d", __func__,
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08001453 CurrAPRssi,
1454 (int)pScanResult->BssDescriptor.rssi * (-1),
1455 RoamRssiDiff);
Jeff Johnson43971f52012-07-17 12:26:56 -07001456 continue;
1457 }
1458 else {
1459 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001460 "%s: [INFOLOG]Current AP rssi=%d new ap rssi better=%d", __func__,
Jeff Johnson43971f52012-07-17 12:26:56 -07001461 CurrAPRssi,
1462 (int)pScanResult->BssDescriptor.rssi * (-1) );
1463 }
1464 }
1465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001466
1467#ifdef WLAN_FEATURE_VOWIFI_11R
1468 if (pNeighborRoamInfo->is11rAssoc)
1469 {
1470 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1471 {
1472 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1473 continue;
1474 }
1475 }
1476#endif /* WLAN_FEATURE_VOWIFI_11R */
1477
1478#ifdef FEATURE_WLAN_CCX
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001479#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1480 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 {
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001482#endif
1483 if (pNeighborRoamInfo->isCCXAssoc)
1484 {
1485 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1486 {
1487 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1488 continue;
1489 }
1490 }
1491 if ((pScanResult->BssDescriptor.QBSSLoad_present) &&
1492 (pScanResult->BssDescriptor.QBSSLoad_avail))
1493 {
1494 if (pNeighborRoamInfo->isVOAdmitted)
1495 {
1496 smsLog(pMac, LOG1, FL("New AP has %x BW available"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail);
1497 smsLog(pMac, LOG1, FL("We need %x BW available"),(unsigned int)pNeighborRoamInfo->MinQBssLoadRequired);
1498 if (pScanResult->BssDescriptor.QBSSLoad_avail < pNeighborRoamInfo->MinQBssLoadRequired)
1499 {
1500 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1501 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no bandwidth ignoring..not adding to roam list",
1502 pScanResult->BssDescriptor.bssId[0],
1503 pScanResult->BssDescriptor.bssId[1],
1504 pScanResult->BssDescriptor.bssId[2],
1505 pScanResult->BssDescriptor.bssId[3],
1506 pScanResult->BssDescriptor.bssId[4],
1507 pScanResult->BssDescriptor.bssId[5]);
1508 continue;
1509 }
1510 }
1511 }
1512 else
1513 {
1514 smsLog(pMac, LOGE, FL("No QBss %x %x"), (unsigned int)pScanResult->BssDescriptor.QBSSLoad_avail, (unsigned int)pScanResult->BssDescriptor.QBSSLoad_present);
1515 if (pNeighborRoamInfo->isVOAdmitted)
1516 {
1517 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1518 "[INFOLOG]BSSID : %02x:%02x:%02x:%02x:%02x:%02x has no QBSSLoad IE, ignoring..not adding to roam list",
1519 pScanResult->BssDescriptor.bssId[0],
1520 pScanResult->BssDescriptor.bssId[1],
1521 pScanResult->BssDescriptor.bssId[2],
1522 pScanResult->BssDescriptor.bssId[3],
1523 pScanResult->BssDescriptor.bssId[4],
1524 pScanResult->BssDescriptor.bssId[5]);
1525 continue;
1526 }
1527 }
1528#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001530#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001531#endif /* FEATURE_WLAN_CCX */
1532
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001533#ifdef FEATURE_WLAN_LFR
1534 // If we are supporting legacy roaming, and
1535 // if the candidate is on the "pre-auth failed" list, ignore it.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301536 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001537 {
1538 if (!csrNeighborRoamIsPreauthCandidate(pMac, pScanResult->BssDescriptor.bssId))
1539 {
1540 smsLog(pMac, LOGE, FL("BSSID present in pre-auth fail list.. Ignoring"));
1541 continue;
1542 }
1543 }
1544#endif /* FEATURE_WLAN_LFR */
1545
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 /* If the received timestamp in BSS description is earlier than the scan request timestamp, skip
1547 * this result */
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001548 if ((pNeighborRoamInfo->scanRequestTimeStamp >= pScanResult->BssDescriptor.nReceivedTime)
1549#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1550 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1551#endif
1552 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 {
1554 smsLog(pMac, LOGE, FL("Ignoring BSS as it is older than the scan request timestamp"));
1555 continue;
1556 }
1557
1558 pBssInfo = vos_mem_malloc(sizeof(tCsrNeighborRoamBSSInfo));
1559 if (NULL == pBssInfo)
1560 {
1561 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Info failed.. Just ignoring"));
1562 continue;
1563 }
1564
1565 pBssInfo->pBssDescription = vos_mem_malloc(pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1566 if (pBssInfo->pBssDescription != NULL)
1567 {
1568 vos_mem_copy(pBssInfo->pBssDescription, &pScanResult->BssDescriptor,
1569 pScanResult->BssDescriptor.length + sizeof(pScanResult->BssDescriptor.length));
1570 }
1571 else
1572 {
1573 smsLog(pMac, LOGE, FL("Memory allocation for Neighbor Roam BSS Descriptor failed.. Just ignoring"));
1574 vos_mem_free(pBssInfo);
1575 continue;
1576
1577 }
1578 pBssInfo->apPreferenceVal = 10; //some value for now. Need to calculate the actual score based on RSSI and neighbor AP score
1579
1580 /* Just add to the end of the list as it is already sorted by RSSI */
1581 csrLLInsertTail(&pNeighborRoamInfo->roamableAPList, &pBssInfo->List, LL_ACCESS_LOCK);
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001582
1583#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001584 if ((abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)) >= immediateRoamRssiDiff)
1585#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1586 && !csrRoamIsRoamOffloadScanEnabled(pMac)
1587#endif
1588 )
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001589 {
1590 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1591 "%s: [INFOLOG] potential candidate to roam immediately (diff=%d, expected=%d)",
1592 __func__, abs(abs(CurrAPRssi) - abs(pScanResult->BssDescriptor.rssi)),
1593 immediateRoamRssiDiff);
1594 roamNow = eANI_BOOLEAN_TRUE;
1595 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001596#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1597 /* If we are here means, FW already found candidates to roam, so we are
1598 good to go with pre-auth */
1599 if(csrRoamIsRoamOffloadScanEnabled(pMac))
1600 {
1601 roamNow = eANI_BOOLEAN_TRUE;
1602 }
1603#endif
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001604#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 }
1606
1607 /* 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 */
1608 csrScanResultPurge(pMac, *pScanResultList);
1609
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001610 return roamNow;
Jeff Johnson295189b2012-06-20 16:38:30 -07001611}
1612
1613/* ---------------------------------------------------------------------------
1614
1615 \fn csrNeighborRoamHandleEmptyScanResult
1616
1617 \brief This function will be invoked in CFG_CHAN_LIST_SCAN state when
1618 there are no valid APs in the scan result for roaming. This means
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001619 our AP is the best and no other AP is around. No point in scanning
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 again and again. Performing the following here.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001621 1. Stop the neighbor scan timer.
1622 2a. If this is the first time we encountered empty scan, then
1623 re-register with TL with modified lookup threshold.
1624 2b. Else if this is the second time we encountered empty scan,
1625 then start neighbor scan results refresh timer (20s).
1626 2c. Else, nothing more to do.
1627 NOTE: In LFR, channels selected for scanning is dervied from
1628 the occuped channel list. Scan cycle following one which
1629 yielded empty results is split into two halves: (i) scan on
1630 channels in the occupied list, and (ii) scan on channels not
1631 in the occupied list. This helps converging faster (while
1632 looking for candidates in the occupied list first), and also,
1633 adds channels to the occupied channel list upon finding candidates
1634 matching SSID profile of interest.
1635
1636 uEmptyScanCount Comments
1637 eFirstEmptyScan Previous scan was done on channels in the
1638 occupied list and yielded potential candidates.
1639 This scan cycle was likely triggered through
1640 receipt of lookup DOWN notification event.
1641 eSecondEmptyScan Previous scan was done on channels in the
1642 occupied list and yielded no candidates. This scan
1643 cycle was triggered through RSSI notification
1644 with modified lookup threshold.
1645 eThirdEmptyScan Previous scan was done on channels NOT in
1646 the occupied list and yielded no candidates. This
1647 scan cycle was triggered immediately after scanning
1648 channels in the occupied list and no candidates
1649 were found.
1650 eFourthEmptyScan Previous scan was done on channels in the
1651 occupied list and yielded no candidates. This scan
1652 cycle was triggered upon expiry of
1653 neighborScanResultsRefreshPeriod (=20s).
1654 eFifthEmptyScan Previous scan was done on channels NOT in
1655 the occupied list and yielded no candidates. This
1656 scan cycle was triggered immediately after scanning
1657 channels in the occupied list and no candidates
1658 were found.
1659
1660 [1], [2,3] and [4,5] together form one discrete set of scan cycle.
Jeff Johnson295189b2012-06-20 16:38:30 -07001661
1662 \param pMac - The handle returned by macOpen.
1663
1664 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
1665
1666---------------------------------------------------------------------------*/
1667static VOS_STATUS csrNeighborRoamHandleEmptyScanResult(tpAniSirGlobal pMac)
1668{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001669 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1671 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001672#ifdef FEATURE_WLAN_LFR
1673 tANI_BOOLEAN performPeriodicScan =
1674 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod) ? TRUE : FALSE;
1675#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001676
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001677 /* Stop neighbor scan timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05301678 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001680 /*
1681 * Increase the neighbor lookup threshold by 3 dB
1682 * after every scan cycle. NOTE: uEmptyScanCount
1683 * would be either 1, 3 or 5 at the end of every
1684 * scan cycle.
1685 */
1686#ifdef FEATURE_WLAN_LFR
1687 if ((++pNeighborRoamInfo->uEmptyScanCount) > eFifthEmptyScan)
1688 {
1689 pNeighborRoamInfo->uEmptyScanCount = eFifthEmptyScan;
1690 }
Srikant Kuppa8f9b1022013-05-09 15:09:24 -07001691 if (((0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) ||
1692 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
1693 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold))) &&
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001694 ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1695 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan)))
1696 {
1697 /*
1698 * If the scan was triggered due to lookupDOWNRssi > reassoc threshold,
1699 * then it would be a contiguous scan on all valid non-DFS channels.
Srikant Kuppa8f9b1022013-05-09 15:09:24 -07001700 * If channels are configured in INI, then only those channels need
1701 * to be scanned.
1702 * In either of these modes, there is no need to trigger an immediate
1703 * scan upon empty scan results for the second and fourth time (which
1704 * would be equivalent to scanning on channels in non-occupied list).
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001705 * Incrementing uEmptyScanCount will correspond to skipping this step.
1706 * NOTE: double increment of uEmptyScanCount corresponds to completion
1707 * of scans on all valid channels.
1708 */
1709 ++pNeighborRoamInfo->uEmptyScanCount;
1710 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Extra increment of empty scan count (=%d)"
1711 " in contiguous scan mode", pNeighborRoamInfo->uEmptyScanCount);
1712 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001713#endif
1714 if (((pNeighborRoamInfo->currentNeighborLookupThreshold+3) <
1715 pNeighborRoamInfo->cfgParams.neighborReassocThreshold)
1716#ifdef FEATURE_WLAN_LFR
1717 && ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1)
1718#endif
1719 )
1720 {
1721 pNeighborRoamInfo->currentNeighborLookupThreshold += 3;
1722 }
1723
Jeff Johnson295189b2012-06-20 16:38:30 -07001724#ifdef WLAN_FEATURE_VOWIFI_11R
1725 /* Clear off the old neighbor report details */
1726 vos_mem_zero(&pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo, sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
1727#endif
1728
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08001729 /* Transition to CONNECTED state */
1730 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
1731
1732 /* Reset all the necessary variables before transitioning to the CONNECTED state */
1733 csrNeighborRoamResetConnectedStateControlInfo(pMac);
1734
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001735#ifdef FEATURE_WLAN_LFR
1736 if (pNeighborRoamInfo->uEmptyScanCount == eFirstEmptyScan)
1737 {
1738#endif
1739 /* Empty scan results for the first time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001740 /* Re-register neighbor lookup DOWN threshold callback with TL */
1741 NEIGHBOR_ROAM_DEBUG(pMac, LOGE,
1742 FL("Registering DOWN event neighbor lookup callback with TL for RSSI = %d"),
1743 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
1744
1745 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
1746 (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
1747 WLANTL_HO_THRESHOLD_DOWN,
1748 csrNeighborRoamNeighborLookupDOWNCallback,
1749 VOS_MODULE_ID_SME, pMac);
1750
1751 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1752 {
1753 smsLog(pMac, LOGW,
1754 FL("Couldn't re-register csrNeighborRoamNeighborLookupDOWNCallback"
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001755 " with TL: Status = %d"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001756 }
1757#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08001758 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001759 }
1760 else if ((pNeighborRoamInfo->uEmptyScanCount == eSecondEmptyScan) ||
1761 (pNeighborRoamInfo->uEmptyScanCount == eFourthEmptyScan))
1762 {
1763 /* Empty scan results for the second or fourth time */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001764
1765 /* Immediately scan on channels in non-occupied list */
1766 csrNeighborRoamTransitToCFGChanScan(pMac);
1767 }
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001768 else if (pNeighborRoamInfo->uEmptyScanCount >= eThirdEmptyScan)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001769 {
1770 /* Empty scan results for the third time */
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001771 if (performPeriodicScan)
1772 {
1773 smsLog(pMac, LOGE, FL("Performing periodic scan, uEmptyScanCount=%d"),
1774 pNeighborRoamInfo->uEmptyScanCount);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08001775
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001776 /*
1777 * Set uEmptyScanCount to MAX so that we always enter this
1778 * condition on subsequent empty scan results
1779 */
1780 pNeighborRoamInfo->uEmptyScanCount = eMaxEmptyScan;
1781
1782 /* From here on, ONLY scan on channels in the occupied list */
1783 pNeighborRoamInfo->uScanMode = SPLIT_SCAN_OCCUPIED_LIST;
1784
1785 /* Start empty scan refresh timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05301786 if (VOS_STATUS_SUCCESS !=
1787 vos_timer_start(&pNeighborRoamInfo->emptyScanRefreshTimer,
1788 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod))
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001789 {
1790 smsLog(pMac, LOGE, FL("Empty scan refresh timer failed to start (%d)"),
1791 status);
1792 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1793 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07001794 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001795 vosStatus = VOS_STATUS_E_FAILURE;
1796 }
1797 else
1798 {
1799 smsLog(pMac, LOGE, FL("Empty scan refresh timer started (%ld ms)"),
1800 (pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod));
1801 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001802 }
Srikant Kuppa8f9b1022013-05-09 15:09:24 -07001803 else if (eThirdEmptyScan == pNeighborRoamInfo->uEmptyScanCount)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001804 {
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001805 /* Start neighbor scan results refresh timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05301806 if (VOS_STATUS_SUCCESS !=
1807 vos_timer_start(&pNeighborRoamInfo->neighborResultsRefreshTimer,
1808 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod))
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001809 {
1810 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start (%d)"),
1811 status);
1812 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1813 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07001814 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001815 vosStatus = VOS_STATUS_E_FAILURE;
1816 }
1817 else
1818 {
1819 smsLog(pMac, LOG2, FL("Neighbor results refresh timer started (%ld ms)"),
1820 (pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod * PAL_TIMER_TO_MS_UNIT));
1821 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 }
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001824
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001825 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Neighbor roam empty scan count=%d scan mode=%d",
1826 pNeighborRoamInfo->uEmptyScanCount, pNeighborRoamInfo->uScanMode);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001827#endif
1828 return vosStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001829}
1830
Jeff Johnson295189b2012-06-20 16:38:30 -07001831
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08001832static eHalStatus csrNeighborRoamProcessScanComplete (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07001833{
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 tCsrScanResultFilter scanFilter;
1836 tScanResultHandle scanResult;
1837 tANI_U32 tempVal = 0;
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001838 tANI_BOOLEAN roamNow = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08001839 eHalStatus hstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001840
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001841#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 /* If the state is REPORT_SCAN, then this must be the scan after the REPORT_QUERY state. So, we
1843 should use the BSSID filter made out of neighbor reports */
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001844 if ((eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pNeighborRoamInfo->neighborRoamState)
1845#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1846 && (!csrRoamIsRoamOffloadScanEnabled(pMac))
1847#endif
1848 )
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001850 hstatus = csrNeighborRoamBssIdScanFilter(pMac, &scanFilter);
1851 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 -07001852 tempVal = 1;
1853 }
1854 else
1855#endif
1856 {
Jeff Johnson43971f52012-07-17 12:26:56 -07001857 hstatus = csrNeighborRoamPrepareScanProfileFilter(pMac, &scanFilter);
1858 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 -07001859 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001860 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 {
1862 smsLog(pMac, LOGE, FL("Scan Filter preparation failed for Assoc type %d.. Bailing out.."), tempVal);
1863 return eHAL_STATUS_FAILURE;
1864 }
Jeff Johnson43971f52012-07-17 12:26:56 -07001865 hstatus = csrScanGetResult(pMac, &scanFilter, &scanResult);
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05301866 if (hstatus != eHAL_STATUS_SUCCESS)
1867 {
1868 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Get Scan Result status code %d"), hstatus);
1869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 /* Process the scan results and update roamable AP list */
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001871 roamNow = csrNeighborRoamProcessScanResults(pMac, &scanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001872
1873 /* Free the scan filter */
1874 csrFreeScanFilter(pMac, &scanFilter);
1875
1876 tempVal = csrLLCount(&pNeighborRoamInfo->roamableAPList);
1877
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001878#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1879 if(!csrRoamIsRoamOffloadScanEnabled(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 {
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001881#endif
1882 switch(pNeighborRoamInfo->neighborRoamState)
1883 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
1885 if (tempVal)
1886 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001887#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001888 /*
1889 * Since there are non-zero candidates found
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001890 * after the scan, reset empty scan count.
Madan Mohan Koyyalamudi04039a12012-10-21 12:24:56 -07001891 */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001892 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001893 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08001894#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001895#ifdef WLAN_FEATURE_VOWIFI_11R
1896 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1897 APs in the roamable AP list */
1898 if (pNeighborRoamInfo->is11rAssoc)
1899 {
1900 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1901 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1902 }
1903 else
1904#endif
1905#ifdef FEATURE_WLAN_CCX
1906 /* If this is a non-11r association, then we can register the reassoc callback here as we have some
1907 APs in the roamable AP list */
1908 if (pNeighborRoamInfo->isCCXAssoc)
1909 {
1910 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1911 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1912 }
1913 else
1914#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001915#ifdef FEATURE_WLAN_LFR
1916 /* If LFR is enabled, then we can register the reassoc callback here as we have some
1917 APs in the roamable AP list */
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05301918 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001919 {
1920 /* Valid APs are found after scan. Now we can initiate pre-authentication */
1921 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
1922 }
1923 else
1924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 {
1926
1927 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Completed scanning of CFG CHAN LIST in non-11r association. Registering reassoc callback"));
1928 /* Nothing much to do now. Will continue to remain in this state in case of non-11r association */
1929 /* Stop the timer. But how long the roamable AP list will be valid in here. At some point of time, we
1930 need to restart the CFG CHAN list scan procedure if reassoc callback is not invoked from TL
1931 within certain duration */
1932
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05301933// vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 }
1935 }
1936 else
1937 {
Madan Mohan Koyyalamudib40e5582012-10-11 16:48:42 -07001938 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1939 /* Handle it appropriately */
1940 csrNeighborRoamHandleEmptyScanResult(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07001941 }
1942 break;
1943#ifdef WLAN_FEATURE_VOWIFI_11R
1944 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
1945 if (!tempVal)
1946 {
1947 smsLog(pMac, LOGE, FL("No candidate found after scanning in state %d.. "), pNeighborRoamInfo->neighborRoamState);
1948 /* Stop the timer here as the same timer will be started again in CFG_CHAN_SCAN_STATE */
1949 csrNeighborRoamTransitToCFGChanScan(pMac);
1950 }
1951 break;
1952#endif /* WLAN_FEATURE_VOWIFI_11R */
1953 default:
1954 // Can come only in INIT state. Where in we are associated, we sent scan and user
1955 // in the meantime decides to disassoc, we will be in init state and still received call
1956 // back issued. Should not come here in any other state, printing just in case
1957 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08001958 "%s: [INFOLOG] State %d", __func__, (pNeighborRoamInfo->neighborRoamState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001959
1960 // Lets just exit out silently.
1961 return eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001962 }
1963#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001965#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001966
1967 if (tempVal)
1968 {
1969 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
1970
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001971 if (roamNow)
1972 {
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001973#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1974 if(!csrRoamIsRoamOffloadScanEnabled(pMac))
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001975 {
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001976#endif
1977 NEIGHBOR_ROAM_DEBUG(pMac, LOG2,
1978 FL("Immediate roam-deregister UP indication. RSSI = %d"),
1979 NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1));
1980
1981 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext,
1982 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
1983 WLANTL_HO_THRESHOLD_UP,
1984 csrNeighborRoamNeighborLookupUPCallback,
1985 VOS_MODULE_ID_SME);
1986
1987 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
1988 {
1989 smsLog(pMac, LOGW,
1990 FL("Couldn't deregister lookup UP callback with TL: Status = %d"), vosStatus);
1991 }
1992#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001993 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07001994#endif
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001995
1996 csrNeighborRoamTriggerHandoff(pMac, pNeighborRoamInfo);
1997 return eHAL_STATUS_SUCCESS;
1998 }
1999
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05302000 hstatus = vos_timer_start(&pNeighborRoamInfo->neighborResultsRefreshTimer,
2001 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002002
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 /* This timer should be started before registering the Reassoc callback with TL. This is because, it is very likely
2004 * that the callback getting called immediately and the timer would never be stopped when pre-auth is in progress */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05302005 if( hstatus != eHAL_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 {
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002007 smsLog(pMac, LOGE, FL("Neighbor results refresh timer failed to start, status = %d"), hstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2009 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07002010 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson43971f52012-07-17 12:26:56 -07002011 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 }
Jeff Johnson43971f52012-07-17 12:26:56 -07002013
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event Reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2015 /* Register a reassoc Indication callback */
2016 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2017 WLANTL_HO_THRESHOLD_DOWN,
2018 csrNeighborRoamReassocIndCallback,
2019 VOS_MODULE_ID_SME, pMac);
2020
2021 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2022 {
2023 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002024 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 }
2026
2027 }
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002028
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07002029#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2030if (csrRoamIsRoamOffloadScanEnabled(pMac))
2031 {
2032 if (!tempVal || !roamNow)
2033 {
Varun Reddy Yeturu6fc169c2013-06-07 00:56:52 -07002034 if (pNeighborRoamInfo->uOsRequestedHandoff)
2035 {
2036 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
2037 pNeighborRoamInfo->uOsRequestedHandoff = 0;
2038 }
2039 else
2040 {
2041 /* There is no candidate or We are not roaming Now.
2042 * Inform the FW to restart Roam Offload Scan */
2043 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_RESTART, REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
2044 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07002045 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
2046 }
2047 }
2048#endif
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002049 return eHAL_STATUS_SUCCESS;
2050
2051}
2052
2053
2054/* ---------------------------------------------------------------------------
2055
2056 \fn csrNeighborRoamScanRequestCallback
2057
2058 \brief This function is the callback function registered in csrScanRequest() to
2059 indicate the completion of scan. If scan is completed for all the channels in
2060 the channel list, this function gets the scan result and starts the refresh results
2061 timer to avoid having stale results. If scan is not completed on all the channels,
2062 it restarts the neighbor scan timer which on expiry issues scan on the next
2063 channel
2064
2065 \param halHandle - The handle returned by macOpen.
2066 pContext - not used
2067 scanId - not used
2068 status - not used
2069
2070 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2071
2072---------------------------------------------------------------------------*/
2073static eHalStatus csrNeighborRoamScanRequestCallback(tHalHandle halHandle, void *pContext,
2074 tANI_U32 scanId, eCsrScanStatus status)
2075{
2076 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2077 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2078 tANI_U8 currentChanIndex;
2079 eHalStatus hstatus;
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002080#ifdef FEATURE_WLAN_LFR
2081 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002082
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002083 if (NULL != pContext)
2084 {
2085 sessionId = *((tANI_U32*)pContext);
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002086
2087 if (!csrRoamIsStaMode(pMac, sessionId))
2088 {
2089 smsLog(pMac, LOGE, FL("%s: Ignoring scan request callback on non-infra session %d in state %d"),
2090 __FUNCTION__, sessionId, pNeighborRoamInfo->neighborRoamState);
2091 vos_mem_free(pContext);
2092 return eHAL_STATUS_SUCCESS;
2093 }
2094
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002095 if (!csrRoamIsFastRoamEnabled(pMac,sessionId))
2096 {
2097 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
2098 vos_mem_free(pContext);
2099 return eHAL_STATUS_SUCCESS;
2100 }
2101 }
2102#endif
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002103 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
2104
2105 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
2106 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
2107 {
2108 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002109 if (NULL != pContext)
2110 vos_mem_free(pContext);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002111 return eHAL_STATUS_SUCCESS;
2112 }
2113
2114 /* -1 is done because the chanIndex would have got incremented after issuing a successful scan request */
2115 currentChanIndex = (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex) ? (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex - 1) : 0;
2116
2117 /* Validate inputs */
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002118 if (pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList) {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002119 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("csrNeighborRoamScanRequestCallback received for Channel = %d, ChanIndex = %d"),
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002120 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[currentChanIndex], currentChanIndex);
2121 }
2122 else
2123 {
2124 smsLog(pMac, LOG1, FL("Received during clean-up. Silently ignore scan completion event."));
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002125 if (NULL != pContext)
2126 vos_mem_free(pContext);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002127 return eHAL_STATUS_SUCCESS;
2128 }
2129
2130 if (eANI_BOOLEAN_FALSE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2131 {
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002132 /* Scan is completed in the CFG_CHAN_SCAN state. We can transition to REPORT_SCAN state
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002133 just to get the results and perform PREAUTH */
2134 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
2135 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
2136 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel list scan completed. Current chan index = %d"), currentChanIndex);
2137 VOS_ASSERT(pNeighborRoamInfo->roamChannelInfo.currentChanIndex == 0);
2138
2139 hstatus = csrNeighborRoamProcessScanComplete(pMac);
2140
2141 if (eHAL_STATUS_SUCCESS != hstatus)
2142 {
2143 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002144 if (NULL != pContext)
2145 vos_mem_free(pContext);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002146 return eHAL_STATUS_FAILURE;
2147 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 }
2149 else
2150 {
2151
2152 /* Restart the timer for the next scan sequence as scanning is not over */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05302153 hstatus = vos_timer_start(&pNeighborRoamInfo->neighborScanTimer,
2154 pNeighborRoamInfo->cfgParams.neighborScanPeriod);
Jeff Johnson43971f52012-07-17 12:26:56 -07002155 if (eHAL_STATUS_SUCCESS != hstatus)
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 {
2157 /* Timer start failed.. Should we ASSERT here??? */
2158 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
2159 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2160 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07002161 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002162 if (NULL != pContext)
2163 vos_mem_free(pContext);
Jeff Johnson43971f52012-07-17 12:26:56 -07002164 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 }
2166 }
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002167
2168 if (NULL != pContext)
2169 vos_mem_free(pContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 return eHAL_STATUS_SUCCESS;
2171}
2172
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07002173#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2174/* ---------------------------------------------------------------------------
2175
2176 \fn csrNeighborRoamScanResultRequestCallback
2177
2178 \brief This function is the callback function registered in csrScanRequestLfrResult() to
2179 indicate the completion of scan. If scan is completed for all the channels in
2180 the channel list, this function gets the scan result and treats them as candidates
2181
2182 \param halHandle - The handle returned by macOpen.
2183 pContext - not used
2184 scanId - not used
2185 status - not used
2186
2187 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2188
2189---------------------------------------------------------------------------*/
2190static eHalStatus csrNeighborRoamScanResultRequestCallback(tHalHandle halHandle, void *pContext,
2191 tANI_U32 scanId, eCsrScanStatus status)
2192{
2193 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2194 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2195 eHalStatus hstatus;
2196
2197 smsLog(pMac, LOG2, FL("called "));
2198 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
2199
2200 /* we must be in connected state, if not ignore it */
2201 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
2202 {
2203 smsLog(pMac, LOGW, FL("Received in not CONNECTED state. Ignore it"));
2204 return eHAL_STATUS_SUCCESS;
2205 }
2206
2207 /* Now we have completed scanning the channel list. We have get the result by applying appropriate filter
2208 sort the results based on neighborScore and RSSI and select the best candidate out of the list */
2209
2210 hstatus = csrNeighborRoamProcessScanComplete(pMac);
2211
2212 if (eHAL_STATUS_SUCCESS != hstatus)
2213 {
2214 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
2215 return eHAL_STATUS_FAILURE;
2216 }
2217 return eHAL_STATUS_SUCCESS;
2218}
2219#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2220
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002221#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002222static eHalStatus csrNeighborRoamContiguousScanRequestCallback(tHalHandle halHandle,
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002223 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
2224{
2225 tpAniSirGlobal pMac = (tpAniSirGlobal) halHandle;
2226 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2227 eHalStatus hstatus = eHAL_STATUS_SUCCESS;
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002228 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
2229
2230 if (NULL != pContext)
2231 {
2232 sessionId = *((tANI_U32*)pContext);
2233 if (!csrRoamIsFastRoamEnabled(pMac,sessionId))
2234 {
2235 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
2236 vos_mem_free(pContext);
2237 return eHAL_STATUS_SUCCESS;
2238 }
2239 }
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002240
2241 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_FALSE;
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002242
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002243 /* This can happen when we receive a UP event from TL in any of the scan states. Silently ignore it */
2244 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED == pNeighborRoamInfo->neighborRoamState)
2245 {
2246 smsLog(pMac, LOGE, FL("Received in CONNECTED state. Must be because a UP event from TL after issuing scan request. Ignore it"));
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002247 if (NULL != pContext)
2248 vos_mem_free(pContext);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002249 return eHAL_STATUS_SUCCESS;
2250 }
2251
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002252 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
2253 {
2254 smsLog(pMac, LOGE, FL("Received in INIT state. Must have disconnected. Ignore it"));
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002255 if (NULL != pContext)
2256 vos_mem_free(pContext);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002257 return eHAL_STATUS_SUCCESS;
2258 }
2259
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002260 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: process scan results", __func__);
2261 hstatus = csrNeighborRoamProcessScanComplete(pMac);
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002262
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002263 if (eHAL_STATUS_SUCCESS != hstatus)
2264 {
2265 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
2266 }
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002267
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002268 if (NULL != pContext)
2269 vos_mem_free(pContext);
2270
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002271 return hstatus;
2272}
2273#endif
2274
Jeff Johnson295189b2012-06-20 16:38:30 -07002275/* ---------------------------------------------------------------------------
2276
2277 \fn csrNeighborRoamIssueBgScanRequest
2278
2279 \brief This function issues CSR scan request after populating all the BG scan params
2280 passed
2281
2282 \param pMac - The handle returned by macOpen.
2283 pBgScanParams - Params that need to be populated into csr Scan request
2284
2285 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2286
2287---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002288eHalStatus csrNeighborRoamIssueBgScanRequest(tpAniSirGlobal pMac,
2289 tCsrBGScanRequest *pBgScanParams,
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002290 tANI_U32 sessionId,
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002291 csrScanCompleteCallback callbackfn)
Jeff Johnson295189b2012-06-20 16:38:30 -07002292{
2293 eHalStatus status = eHAL_STATUS_SUCCESS;
2294 tANI_U32 scanId;
2295 tCsrScanRequest scanReq;
2296 tANI_U8 channel;
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002297 void * userData = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002298
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002299 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002300 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Channel = %d, ChanIndex = %d"),
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002301 pBgScanParams->ChannelInfo.ChannelList[0],
2302 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
Jeff Johnson295189b2012-06-20 16:38:30 -07002303
2304 //send down the scan req for 1 channel on the associated SSID
2305 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
2306 /* Fill in the SSID Info */
2307 scanReq.SSIDs.numOfSSIDs = 1;
2308 scanReq.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
2309 if(NULL == scanReq.SSIDs.SSIDList)
2310 {
2311 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002312 smsLog(pMac, LOGE, FL("Couldn't allocate memory for the SSID..Freeing memory allocated for Channel List"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 return eHAL_STATUS_FAILURE;
2314 }
2315 vos_mem_zero(scanReq.SSIDs.SSIDList, sizeof(tCsrSSIDInfo) * scanReq.SSIDs.numOfSSIDs);
2316
2317 scanReq.SSIDs.SSIDList[0].handoffPermitted = eANI_BOOLEAN_TRUE;
2318 scanReq.SSIDs.SSIDList[0].ssidHidden = eANI_BOOLEAN_TRUE;
2319 vos_mem_copy((void *)&scanReq.SSIDs.SSIDList[0].SSID, (void *)&pBgScanParams->SSID, sizeof(pBgScanParams->SSID));
2320
2321 scanReq.ChannelInfo.numOfChannels = pBgScanParams->ChannelInfo.numOfChannels;
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002322 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
2323 {
2324 channel = pBgScanParams->ChannelInfo.ChannelList[0];
2325 scanReq.ChannelInfo.ChannelList = &channel;
2326 }
2327 else
2328 {
2329 scanReq.ChannelInfo.ChannelList = pBgScanParams->ChannelInfo.ChannelList;
2330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002331
2332 scanReq.BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
2333 scanReq.scanType = eSIR_ACTIVE_SCAN;
2334 scanReq.requestType = eCSR_SCAN_HO_BG_SCAN;
2335 scanReq.maxChnTime = pBgScanParams->maxChnTime;
2336 scanReq.minChnTime = pBgScanParams->minChnTime;
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002337
2338 userData = vos_mem_malloc(sizeof(tANI_U32));
2339 if (NULL == userData)
2340 {
2341 smsLog(pMac, LOGE, FL("Failed to allocate memory for scan request"));
2342 vos_mem_free(scanReq.SSIDs.SSIDList);
2343 return eHAL_STATUS_FAILURE;
2344 }
2345 *((tANI_U32*)userData) = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002347 &scanId, callbackfn, (void *) userData);
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 if (eHAL_STATUS_SUCCESS != status)
2349 {
2350 smsLog(pMac, LOGE, FL("CSR Scan Request failed with status %d"), status);
2351 vos_mem_free(scanReq.SSIDs.SSIDList);
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002352 vos_mem_free(userData);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 return status;
2354 }
2355 pMac->roam.neighborRoamInfo.scanRspPending = eANI_BOOLEAN_TRUE;
2356
2357 vos_mem_free(scanReq.SSIDs.SSIDList);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002358 if (1 == pBgScanParams->ChannelInfo.numOfChannels)
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002359 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x, Actual index = %d"),
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002360 &pMac->roam.neighborRoamInfo.roamChannelInfo.currentChannelListInfo.ChannelList[0],
2361 pMac->roam.neighborRoamInfo.roamChannelInfo.currentChanIndex);
2362
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 return status;
2364}
2365
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002366static void csrNeighborRoamFillNonChannelBgScanParams (tpAniSirGlobal pMac,
2367 tpCsrBGScanRequest bgScanParams)
2368{
2369 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2370 tANI_U8 broadcastBssid[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
2371
2372 vos_mem_copy(bgScanParams->bssid, broadcastBssid, sizeof(tCsrBssid));
2373 bgScanParams->SSID.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2374 vos_mem_copy(bgScanParams->SSID.ssId,
2375 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2376 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2377
2378 bgScanParams->minChnTime = pNeighborRoamInfo->cfgParams.minChannelScanTime;
2379 bgScanParams->maxChnTime = pNeighborRoamInfo->cfgParams.maxChannelScanTime;
2380}
2381
Jeff Johnson295189b2012-06-20 16:38:30 -07002382/* ---------------------------------------------------------------------------
2383
2384 \fn csrNeighborRoamPerformBgScan
2385
2386 \brief This function is invoked on every expiry of neighborScanTimer till all
2387 the channels in the channel list are scanned. It populates necessary
2388 parameters for BG scan and calls appropriate AP to invoke the CSR scan
2389 request
2390
2391 \param pMac - The handle returned by macOpen.
2392
2393 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
2394
2395---------------------------------------------------------------------------*/
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002396eHalStatus csrNeighborRoamPerformBgScan(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07002397{
2398 eHalStatus status = eHAL_STATUS_SUCCESS;
2399 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2400 tCsrBGScanRequest bgScanParams;
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 tANI_U8 channel = 0;
2402
2403 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2404 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302405 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Channel List Address = %08x"), &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 }
2407 else
2408 {
2409 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List Empty"));
Jeff Johnson1920a722012-12-10 14:28:09 -08002410 // Go back and restart. Mostly timer start failure has occurred.
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 // When timer start is declared a failure, then we delete the list.
2412 // Should not happen now as we stop and then only start the scan timer.
2413 // still handle the unlikely case.
2414 csrNeighborRoamHandleEmptyScanResult(pMac);
2415 return status;
2416 }
James Zmudaac3ad1b2013-04-18 18:20:54 -07002417
2418 /* Validate the currentChanIndex value before using it to index the ChannelList array */
2419 if ( pNeighborRoamInfo->roamChannelInfo.currentChanIndex
2420 > pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2421 {
2422 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Invalid channel index: %d"), pNeighborRoamInfo->roamChannelInfo.currentChanIndex);
2423 // Go back and restart.
2424 csrNeighborRoamHandleEmptyScanResult(pMac);
2425 return status;
2426 }
2427
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 /* Need to perform scan here before getting the list */
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002429
2430 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07002431
2432 channel = pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList[pNeighborRoamInfo->roamChannelInfo.currentChanIndex];
2433 bgScanParams.ChannelInfo.numOfChannels = 1;
2434 bgScanParams.ChannelInfo.ChannelList = &channel;
2435
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002436 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002437
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002438 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
2439 sessionId, csrNeighborRoamScanRequestCallback);
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 if (eHAL_STATUS_SUCCESS != status)
2441 {
2442 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 }
2444
2445 pNeighborRoamInfo->roamChannelInfo.currentChanIndex++;
2446 if (pNeighborRoamInfo->roamChannelInfo.currentChanIndex >=
2447 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels)
2448 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05302449 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Completed scanning channels in Channel List: CurrChanIndex = %d, Num Channels = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 pNeighborRoamInfo->roamChannelInfo.currentChanIndex,
2451 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels);
2452 /* We have completed scanning all the channels */
2453 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2454 /* We are no longer scanning the channel list. Next timer firing should be used to get the scan results
2455 and select the best AP in the list */
2456 if (eANI_BOOLEAN_TRUE == pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress)
2457 {
2458 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
2459 }
2460 }
2461
Gopichand Nakkala72d193a2012-12-31 14:07:19 -08002462 if (eHAL_STATUS_SUCCESS != status)
2463 {
2464 /*
2465 * If the status is not success, we need to call the callback
2466 * routine so that the state machine does not get stuck.
2467 */
2468 csrNeighborRoamScanRequestCallback(pMac, NULL, 0, eCSR_SCAN_FAILURE);
2469 }
2470
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 return status;
2472}
2473
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002474#ifdef FEATURE_WLAN_LFR
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002475eHalStatus csrNeighborRoamPerformContiguousBgScan(tpAniSirGlobal pMac, tANI_U32 sessionId)
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002476{
2477 eHalStatus status = eHAL_STATUS_SUCCESS;
2478 tCsrBGScanRequest bgScanParams;
2479 int numOfChannels = 0, i = 0;
2480 tANI_U8 *channelList = NULL;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002481 tANI_U8 *pInChannelList = NULL;
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002482 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002483
2484 palZeroMemory(pMac->hHdd, &bgScanParams, sizeof(tCsrBGScanRequest));
2485
2486 /* Contiguously scan all channels from valid list */
2487 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "%s: get valid channel list", __func__);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002488
Srinivas Girigowda7f79f462013-08-20 14:00:50 -07002489 numOfChannels = sizeof(pMac->roam.validChannelList);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002490
Srinivas Girigowda7f79f462013-08-20 14:00:50 -07002491 if(!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2492 (tANI_U8 *)pMac->roam.validChannelList,
2493 (tANI_U32 *) &numOfChannels)))
2494 {
2495 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
2496 return eHAL_STATUS_FAILURE;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002497 }
Srinivas Girigowda7f79f462013-08-20 14:00:50 -07002498 pInChannelList = pMac->roam.validChannelList;
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002499
2500 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
2501 {
2502 csrNeighborRoamChannelsFilterByCurrentBand(
2503 pMac,
2504 pInChannelList,
2505 numOfChannels,
2506 tmpChannelList,
2507 &numOfChannels);
2508 pInChannelList = tmpChannelList;
2509 }
2510
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002511 channelList = vos_mem_malloc( numOfChannels );
2512 if( NULL == channelList )
2513 {
2514 smsLog(pMac, LOGE, FL("could not allocate memory for channelList"));
2515 return eHAL_STATUS_FAILURE;
2516 }
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002517 vos_mem_copy(channelList, (tANI_U8 *)pInChannelList,
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002518 numOfChannels * sizeof(tANI_U8));
2519
2520 bgScanParams.ChannelInfo.numOfChannels = numOfChannels;
2521 bgScanParams.ChannelInfo.ChannelList = channelList;
2522 for (i = 0; i < numOfChannels; i++)
2523 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002524 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "%s: valid channel list = %d",
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002525 __func__, bgScanParams.ChannelInfo.ChannelList[i]);
2526 }
2527 csrNeighborRoamFillNonChannelBgScanParams(pMac, &bgScanParams);
2528
2529 status = csrNeighborRoamIssueBgScanRequest(pMac, &bgScanParams,
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002530 sessionId, csrNeighborRoamContiguousScanRequestCallback);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002531
2532 vos_mem_free( channelList );
2533
2534 if (eHAL_STATUS_SUCCESS != status)
2535 {
2536 smsLog(pMac, LOGE, FL("Issue of BG Scan request failed: Status = %d"), status);
2537 }
2538
2539 return status;
2540}
2541#endif
2542
Jeff Johnson295189b2012-06-20 16:38:30 -07002543/* ---------------------------------------------------------------------------
2544
2545 \fn csrNeighborRoamNeighborScanTimerCallback
2546
2547 \brief This function is the neighbor scan timer callback function. It invokes
2548 the BG scan request based on the current and previous states
2549
2550 \param pv - CSR timer context info which includes pMac and session ID
2551
2552 \return VOID
2553
2554---------------------------------------------------------------------------*/
2555void csrNeighborRoamNeighborScanTimerCallback(void *pv)
2556{
2557 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
2558 tpAniSirGlobal pMac = pInfo->pMac;
2559 tANI_U32 sessionId = pInfo->sessionId;
2560 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2561
2562 // check if bg scan is on going, no need to send down the new params if true
2563 if(eANI_BOOLEAN_TRUE == pNeighborRoamInfo->scanRspPending)
2564 {
2565 //msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002566 smsLog(pMac, LOGW, FL("Already BgScanRsp is Pending"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 return;
2568 }
2569
2570 VOS_ASSERT(sessionId == pNeighborRoamInfo->csrSessionId);
2571
2572 switch (pNeighborRoamInfo->neighborRoamState)
2573 {
2574#ifdef WLAN_FEATURE_VOWIFI_11R
2575 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2576 switch(pNeighborRoamInfo->prevNeighborRoamState)
2577 {
2578 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002579 csrNeighborRoamPerformBgScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 break;
2581 default:
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002582 smsLog(pMac, LOGE, FL("Neighbor scan callback received in state %d, prev state = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 pNeighborRoamInfo->neighborRoamState, pNeighborRoamInfo->prevNeighborRoamState);
2584 break;
2585 }
2586 break;
2587#endif /* WLAN_FEATURE_VOWIFI_11R */
2588 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07002589 csrNeighborRoamPerformBgScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 break;
2591 default:
2592 break;
2593 }
2594 return;
2595}
2596
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002597void csrNeighborRoamEmptyScanRefreshTimerCallback(void *context)
2598{
2599 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2600 tpAniSirGlobal pMac = pInfo->pMac;
2601 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2602 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2603
2604 /* Reset all the variables just as no scan had happened before */
2605 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2606
2607#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2608 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2609 {
2610 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2611 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2612 if (VOS_STATUS_SUCCESS != vosStatus)
2613 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002614 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08002615 return;
2616 }
2617 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2618 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2619 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2620 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2621 }
2622 else
2623#endif
2624 {
2625 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:empty scan refresh timer expired"));
2626 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2627 if (VOS_STATUS_SUCCESS != vosStatus)
2628 {
2629 return;
2630 }
2631 }
2632 return;
2633}
2634
Jeff Johnson295189b2012-06-20 16:38:30 -07002635/* ---------------------------------------------------------------------------
2636
2637 \fn csrNeighborRoamResultsRefreshTimerCallback
2638
2639 \brief This function is the timer callback function for results refresh timer.
2640 When this is invoked, it is as good as down event received from TL. So,
2641 clear off the roamable AP list and start the scan procedure based on 11R
2642 or non-11R association
2643
2644 \param context - CSR timer context info which includes pMac and session ID
2645
2646 \return VOID
2647
2648---------------------------------------------------------------------------*/
2649void csrNeighborRoamResultsRefreshTimerCallback(void *context)
2650{
2651 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)context;
2652 tpAniSirGlobal pMac = pInfo->pMac;
2653 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
2654 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2655
2656 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event reassoc callback with TL. RSSI = %d"), pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1));
2657
2658 /* Deregister reassoc callback. Ignore return status */
2659 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->cfgParams.neighborReassocThreshold * (-1),
2660 WLANTL_HO_THRESHOLD_DOWN,
2661 csrNeighborRoamReassocIndCallback,
2662 VOS_MODULE_ID_SME);
2663
2664 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
2665 {
2666 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002667 smsLog(pMac, LOGW, FL(" Couldn't deregister csrNeighborRoamReassocIndCallback with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 }
2669
2670 /* Reset all the variables just as no scan had happened before */
2671 csrNeighborRoamResetConnectedStateControlInfo(pMac);
2672
2673#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2674 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
2675 {
2676 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
2677 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
2678 if (VOS_STATUS_SUCCESS != vosStatus)
2679 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002680 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 return;
2682 }
2683 /* Increment the neighbor report retry count after sending the neighbor request successfully */
2684 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
2685 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
2686 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
2687 }
2688 else
2689#endif
2690 {
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08002691 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Non 11R or CCX Association:results refresh timer expired"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
2693 if (VOS_STATUS_SUCCESS != vosStatus)
2694 {
2695 return;
2696 }
2697 }
2698 return;
2699}
2700
2701#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
2702/* ---------------------------------------------------------------------------
2703
2704 \fn csrNeighborRoamIssueNeighborRptRequest
2705
2706 \brief This function is invoked when TL issues a down event and the current assoc
2707 is a 11R association. It invokes SME RRM API to issue the neighbor request to
2708 the currently associated AP with the current SSID
2709
2710 \param pMac - The handle returned by macOpen.
2711
2712 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2713
2714---------------------------------------------------------------------------*/
2715VOS_STATUS csrNeighborRoamIssueNeighborRptRequest(tpAniSirGlobal pMac)
2716{
2717 tRrmNeighborRspCallbackInfo callbackInfo;
2718 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2719 tRrmNeighborReq neighborReq;
2720
2721
2722 neighborReq.no_ssid = 0;
2723
2724 /* Fill in the SSID */
2725 neighborReq.ssid.length = pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length;
2726 vos_mem_copy(neighborReq.ssid.ssId, pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.ssId,
2727 pMac->roam.roamSession[pNeighborRoamInfo->csrSessionId].connectedProfile.SSID.length);
2728
2729 callbackInfo.neighborRspCallback = csrNeighborRoamRRMNeighborReportResult;
2730 callbackInfo.neighborRspCallbackContext = pMac;
2731 callbackInfo.timeout = pNeighborRoamInfo->FTRoamInfo.neighborReportTimeout;
2732
2733 return sme_NeighborReportRequest(pMac,(tANI_U8) pNeighborRoamInfo->csrSessionId, &neighborReq, &callbackInfo);
2734}
2735
2736/* ---------------------------------------------------------------------------
2737
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002738 \fn csrNeighborRoamChannelsFilterByCurrentBand
2739
2740 \brief This function is used to filter out the channels
2741 based on the currently associated AP channel
2742
2743 \param pMac - The handle returned by macOpen.
2744 \param pInputChannelList - The input channel list
2745 \param inputNumOfChannels - The number of channels in input channel list
2746 \param pOutputChannelList - The output channel list
2747 \param outputNumOfChannels - The number of channels in output channel list
2748 \param pMergedOutputNumOfChannels - The final number of channels in the output channel list.
2749
2750 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2751
2752---------------------------------------------------------------------------*/
2753
2754VOS_STATUS csrNeighborRoamChannelsFilterByCurrentBand(
2755 tpAniSirGlobal pMac,
2756 tANI_U8* pInputChannelList,
2757 int inputNumOfChannels,
2758 tANI_U8* pOutputChannelList,
2759 int* pMergedOutputNumOfChannels
2760 )
2761{
2762 int i = 0;
2763 int numChannels = 0;
2764 tANI_U8 currAPoperationChannel = pMac->roam.neighborRoamInfo.currAPoperationChannel;
2765 // Check for NULL pointer
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302766 if (!pInputChannelList) return VOS_STATUS_E_INVAL;
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002767
2768 // Check for NULL pointer
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302769 if (!pOutputChannelList) return VOS_STATUS_E_INVAL;
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002770
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302771 if (inputNumOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2772 {
2773 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2774 "%s: Wrong Number of Input Channels %d",
2775 __func__, inputNumOfChannels);
2776 return VOS_STATUS_E_INVAL;
2777 }
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002778 for (i = 0; i < inputNumOfChannels; i++)
2779 {
2780 if (GetRFBand(currAPoperationChannel) == GetRFBand(pInputChannelList[i]))
2781 {
2782 pOutputChannelList[numChannels] = pInputChannelList[i];
2783 numChannels++;
2784 }
2785 }
2786
2787 // Return final number of channels
2788 *pMergedOutputNumOfChannels = numChannels;
2789
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302790 return VOS_STATUS_SUCCESS;
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002791}
2792
2793/* ---------------------------------------------------------------------------
2794
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002795 \fn csrNeighborRoamMergeChannelLists
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002796
2797 \brief This function is used to merge two channel list.
2798 NB: If called with outputNumOfChannels == 0, this routines
2799 simply copies the input channel list to the output channel list.
2800
2801 \param pMac - The handle returned by macOpen.
2802 \param pInputChannelList - The addtional channels to merge in to the "merged" channels list.
2803 \param inputNumOfChannels - The number of additional channels.
2804 \param pOutputChannelList - The place to put the "merged" channel list.
2805 \param outputNumOfChannels - The original number of channels in the "merged" channels list.
2806 \param pMergedOutputNumOfChannels - The final number of channels in the "merged" channel list.
2807
2808 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2809
2810---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002811VOS_STATUS csrNeighborRoamMergeChannelLists(
2812 tpAniSirGlobal pMac,
2813 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002814 int inputNumOfChannels,
2815 tANI_U8 *pOutputChannelList,
2816 int outputNumOfChannels,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002817 int *pMergedOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002818 )
2819{
2820 int i = 0;
2821 int j = 0;
2822 int numChannels = outputNumOfChannels;
2823
2824 // Check for NULL pointer
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302825 if (!pInputChannelList) return VOS_STATUS_E_INVAL;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002826
2827 // Check for NULL pointer
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302828 if (!pOutputChannelList) return VOS_STATUS_E_INVAL;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002829
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302830 if (inputNumOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2831 {
2832 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2833 "%s: Wrong Number of Input Channels %d",
2834 __func__, inputNumOfChannels);
2835 return VOS_STATUS_E_INVAL;
2836 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002837 // Add the "new" channels in the input list to the end of the output list.
2838 for (i = 0; i < inputNumOfChannels; i++)
2839 {
2840 for (j = 0; j < outputNumOfChannels; j++)
2841 {
2842 if (pInputChannelList[i] == pOutputChannelList[j])
2843 break;
2844 }
2845 if (j == outputNumOfChannels)
2846 {
2847 if (pInputChannelList[i])
2848 {
Madan Mohan Koyyalamudi1ebd3fc2012-12-06 13:10:13 -08002849 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002850 "%s: [INFOLOG] Adding extra %d to Neighbor channel list", __func__,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002851 pInputChannelList[i]);
2852 pOutputChannelList[numChannels] = pInputChannelList[i];
2853 numChannels++;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002854 }
2855 }
2856 }
2857
2858 // Return final number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002859 *pMergedOutputNumOfChannels = numChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002860
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05302861 return VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002862}
2863
2864/* ---------------------------------------------------------------------------
2865
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 \fn csrNeighborRoamCreateChanListFromNeighborReport
2867
2868 \brief This function is invoked when neighbor report is received for the
2869 neighbor request. Based on the channels present in the neighbor report,
2870 it generates channel list which will be used in REPORT_SCAN state to
2871 scan for these neighbor APs
2872
2873 \param pMac - The handle returned by macOpen.
2874
2875 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
2876
2877---------------------------------------------------------------------------*/
2878VOS_STATUS csrNeighborRoamCreateChanListFromNeighborReport(tpAniSirGlobal pMac)
2879{
2880 tpRrmNeighborReportDesc pNeighborBssDesc;
2881 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002882 tANI_U8 numChannels = 0, i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 tANI_U8 channelList[MAX_BSS_IN_NEIGHBOR_RPT];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002884#if 0
2885 eHalStatus status = eHAL_STATUS_SUCCESS;
2886#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002887
2888 /* This should always start from 0 whenever we create a channel list out of neighbor AP list */
2889 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport = 0;
2890
2891 pNeighborBssDesc = smeRrmGetFirstBssEntryFromNeighborCache(pMac);
2892
2893 while (pNeighborBssDesc)
2894 {
2895 if (pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport >= MAX_BSS_IN_NEIGHBOR_RPT) break;
2896
2897 /* Update the neighbor BSS Info in the 11r FT Roam Info */
2898 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].channelNum =
2899 pNeighborBssDesc->pNeighborBssDescription->channel;
2900 pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborScore =
2901 (tANI_U8)pNeighborBssDesc->roamScore;
2902 vos_mem_copy(pNeighborRoamInfo->FTRoamInfo.neighboReportBssInfo[pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport].neighborBssId,
2903 pNeighborBssDesc->pNeighborBssDescription->bssId, sizeof(tSirMacAddr));
2904 pNeighborRoamInfo->FTRoamInfo.numBssFromNeighborReport++;
2905
2906 /* Saving the channel list non-redundantly */
2907 if (numChannels > 0)
2908 {
2909 for (i = 0; i < numChannels; i++)
2910 {
2911 if (pNeighborBssDesc->pNeighborBssDescription->channel == channelList[i])
2912 break;
2913 }
2914
2915 }
2916 if (i == numChannels)
2917 {
2918 if (pNeighborBssDesc->pNeighborBssDescription->channel)
2919 {
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002920 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
2921 {
2922 // Make sure to add only if its the same band
2923 if (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
2924 GetRFBand(pNeighborBssDesc->pNeighborBssDescription->channel))
2925 {
2926 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2927 "%s: [INFOLOG] Adding %d to Neighbor channel list (Same band)\n", __func__,
2928 pNeighborBssDesc->pNeighborBssDescription->channel);
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2930 numChannels++;
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07002931 }
2932 }
2933 else
2934 {
2935 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
2936 "%s: [INFOLOG] Adding %d to Neighbor channel list\n", __func__,
2937 pNeighborBssDesc->pNeighborBssDescription->channel);
2938 channelList[numChannels] = pNeighborBssDesc->pNeighborBssDescription->channel;
2939 numChannels++;
2940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 }
2942 }
2943
2944 pNeighborBssDesc = smeRrmGetNextBssEntryFromNeighborCache(pMac, pNeighborBssDesc);
2945 }
2946
2947 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2948 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002949#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 // Before we free the existing channel list for a safety net make sure
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07002951 // we have a union of the IAPP and the already existing list.
2952 status = csrNeighborRoamMergeChannelLists(
2953 pMac,
2954 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2955 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels,
2956 channelList,
2957 numChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002958 &numChannels );
2959#endif
2960
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
2962 }
2963
2964 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07002965 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 /* Store the obtained channel list to the Neighbor Control data structure */
2967 if (numChannels)
2968 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = vos_mem_malloc((numChannels) * sizeof(tANI_U8));
2969 if (NULL == pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
2970 {
2971 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed.. TL event ignored"));
2972 return VOS_STATUS_E_RESOURCES;
2973 }
2974
2975 vos_mem_copy(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList,
2976 channelList, (numChannels) * sizeof(tANI_U8));
2977 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = numChannels;
2978 if (numChannels)
2979 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08002980 smsLog(pMac, LOG1, FL("IAPP Neighbor list callback received as expected in state %d."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 pNeighborRoamInfo->neighborRoamState);
2982 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_TRUE;
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07002983#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda392c1692013-06-13 19:44:16 -07002984 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07002985 {
2986 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, REASON_CHANNEL_LIST_CHANGED);
2987 }
2988#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
2990 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
2991 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
2992
2993 return VOS_STATUS_SUCCESS;
2994}
2995
2996/* ---------------------------------------------------------------------------
2997
2998 \fn csrNeighborRoamRRMNeighborReportResult
2999
3000 \brief This function is the neighbor report callback that will be invoked by
3001 SME RRM on receiving a neighbor report or of neighbor report is not
3002 received after timeout. On receiving a valid report, it generates a
3003 channel list from the neighbor report and starts the
3004 neighbor scan timer
3005
3006 \param context - The handle returned by macOpen.
3007 vosStatus - Status of the callback(SUCCESS/FAILURE)
3008
3009 \return VOID
3010
3011---------------------------------------------------------------------------*/
3012void csrNeighborRoamRRMNeighborReportResult(void *context, VOS_STATUS vosStatus)
3013{
3014 tpAniSirGlobal pMac = PMAC_STRUCT(context);
3015 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3016 eHalStatus status = eHAL_STATUS_SUCCESS;
3017
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003018 smsLog(pMac, LOG1, FL("Neighbor report result callback with status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 switch (pNeighborRoamInfo->neighborRoamState)
3020 {
3021 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY:
3022 /* Reset the report pending variable */
3023 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_FALSE;
3024 if (VOS_STATUS_SUCCESS == vosStatus)
3025 {
3026 /* Need to create channel list based on the neighbor AP list and transition to REPORT_SCAN state */
3027 vosStatus = csrNeighborRoamCreateChanListFromNeighborReport(pMac);
3028 if (VOS_STATUS_SUCCESS == vosStatus)
3029 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003030 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("Channel List created from Neighbor report, Transitioning to NEIGHBOR_SCAN state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 }
3032
3033 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
3034 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3035
3036 /* Now ready for neighbor scan based on the channel list created */
3037 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
3038 what palTimerStart expects */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05303039 status = vos_timer_start(&pNeighborRoamInfo->neighborScanTimer,
3040 pNeighborRoamInfo->cfgParams.neighborScanPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 if (eHAL_STATUS_SUCCESS != status)
3042 {
3043 /* Timer start failed.. Should we ASSERT here??? */
3044 smsLog(pMac, LOGE, FL("PAL Timer start for neighbor scan timer failed, status = %d, Ignoring state transition"), status);
3045 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
3046 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07003047 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 return;
3049 }
3050 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3051 /* Neighbor scan timer started. Transition to REPORT_SCAN state */
3052 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN)
3053 }
3054 else
3055 {
3056 /* Neighbor report timeout happened in SME RRM. We can try sending more neighbor requests until we
3057 reach the maxNeighborRetries or receiving a successful neighbor response */
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003058 smsLog(pMac, LOGE, FL("Neighbor report result failed after %d retries, MAX RETRIES = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum, pNeighborRoamInfo->cfgParams.maxNeighborRetries);
3060 if (pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum >=
3061 pNeighborRoamInfo->cfgParams.maxNeighborRetries)
3062 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003063 smsLog(pMac, LOGE, FL("Bailing out to CFG Channel list scan.. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3065 if (VOS_STATUS_SUCCESS != vosStatus)
3066 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003067 smsLog(pMac, LOGE, FL("Transit to CFG Channel list scan state failed with status %d "), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 return;
3069 }
3070 /* We transitioned to different state now. Reset the Neighbor report retry count */
3071 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
3072 }
3073 else
3074 {
3075 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3076 if (VOS_STATUS_SUCCESS != vosStatus)
3077 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003078 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 return;
3080 }
3081 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3082 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3083 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3084 }
3085 }
3086 break;
3087 default:
3088 smsLog(pMac, LOGE, FL("Neighbor result callback not expected in state %d, Ignoring.."), pNeighborRoamInfo->neighborRoamState);
3089 break;
3090 }
3091 return;
3092}
3093#endif /* WLAN_FEATURE_VOWIFI_11R */
3094
3095
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003096#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003097tANI_BOOLEAN csrNeighborRoamIsSsidAndSecurityMatch(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003098 tpAniSirGlobal pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003099 tCsrRoamConnectedProfile *pCurProfile,
3100 tSirBssDescription *pBssDesc,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003101 tDot11fBeaconIEs *pIes)
3102{
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003103 tCsrAuthList authType;
3104 tCsrEncryptionList uCEncryptionType;
3105 tCsrEncryptionList mCEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003106 tANI_BOOLEAN fMatch = FALSE;
3107
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003108 authType.numEntries = 1;
3109 authType.authType[0] = pCurProfile->AuthType;
3110 uCEncryptionType.numEntries = 1;
3111 uCEncryptionType.encryptionType[0] = pCurProfile->EncryptionType;
3112 mCEncryptionType.numEntries = 1;
3113 mCEncryptionType.encryptionType[0] = pCurProfile->mcEncryptionType;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003114
3115 if( pIes )
3116 {
3117 if(pIes->SSID.present)
3118 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003119 fMatch = csrIsSsidMatch( pMac,
3120 (void *)pCurProfile->SSID.ssId, pCurProfile->SSID.length,
3121 pIes->SSID.ssid, pIes->SSID.num_ssid,
3122 eANI_BOOLEAN_TRUE );
3123 if(TRUE == fMatch)
3124 {
3125 fMatch = csrIsSecurityMatch( pMac, &authType, &uCEncryptionType,
3126 &mCEncryptionType, pBssDesc, pIes, NULL, NULL, NULL );
3127 return (fMatch);
3128 }
3129 else
3130 {
3131 return (fMatch);
3132 }
3133
3134 }
3135 else
3136 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003137 return FALSE; // Treat a missing SSID as a non-match.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003138 }
3139 }
3140 else
3141 {
3142 return FALSE; // Again, treat missing pIes as a non-match.
3143 }
3144}
3145
3146tANI_BOOLEAN csrNeighborRoamIsNewConnectedProfile(
3147 tpAniSirGlobal pMac)
3148{
3149 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3150 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
3151 tCsrRoamConnectedProfile *pCurrProfile = NULL;
3152 tCsrRoamConnectedProfile *pPrevProfile = NULL;
3153 tDot11fBeaconIEs *pIes = NULL;
3154 tSirBssDescription *pBssDesc = NULL;
3155 tANI_BOOLEAN fNew = TRUE;
3156
3157 if(!(pMac->roam.roamSession && CSR_IS_SESSION_VALID(pMac, sessionId)))
3158 {
3159 return (fNew);
3160 }
3161
3162 pCurrProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
3163 if( !pCurrProfile )
3164 {
3165 return (fNew);
3166}
3167
3168 pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
3169 if( !pPrevProfile )
3170 {
3171 return (fNew);
3172 }
3173
3174 pBssDesc = pPrevProfile->pBssDesc;
3175 if (pBssDesc)
3176 {
3177 if (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
3178 pBssDesc, &pIes)) &&
3179 csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurrProfile, pBssDesc, pIes))
3180 {
3181 fNew = FALSE;
3182 }
3183 if (pIes) {
3184 palFreeMemory(pMac->hHdd, pIes);
3185 }
3186 }
3187
3188 if (fNew)
3189 {
3190 smsLog(pMac, LOG1, FL("Prev roam profile did not match current"));
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003191 }
3192 else
3193 {
3194 smsLog(pMac, LOG1, FL("Prev roam profile matches current"));
3195 }
3196
3197 return (fNew);
3198}
3199
3200tANI_BOOLEAN csrNeighborRoamConnectedProfileMatch(
3201 tpAniSirGlobal pMac,
3202 tCsrScanResult *pResult,
3203 tDot11fBeaconIEs *pIes)
3204{
3205 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3206 tANI_U8 sessionId = (tANI_U8)pNeighborRoamInfo->csrSessionId;
3207 tCsrRoamConnectedProfile *pCurProfile = NULL;
3208 tSirBssDescription *pBssDesc = &pResult->Result.BssDescriptor;
3209
3210 if( !(pMac->roam.roamSession
3211 && CSR_IS_SESSION_VALID(pMac, sessionId)))
3212 {
3213 return FALSE;
3214 }
3215
3216 pCurProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
3217
3218 if( !pCurProfile)
3219 {
3220 return FALSE;
3221 }
3222
3223 return csrNeighborRoamIsSsidAndSecurityMatch(pMac, pCurProfile, pBssDesc, pIes);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003224}
3225
3226/* ---------------------------------------------------------------------------
3227
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003228 \fn csrNeighborRoamPrepareNonOccupiedChannelList
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003229
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003230 \brief This function is used to prepare a channel list that is derived from
3231 the list of valid channels and does not include those in the occupied
3232 list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003233
3234 \param pMac - The handle returned by macOpen.
3235 \param pInputChannelList - The default channels list.
3236 \param numOfChannels - The number of channels in the default channels list.
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003237 \param pOutputChannelList - The place to put the non-occupied channel list.
3238 \param pOutputNumOfChannels - The number of channels in the non-occupied channel list.
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003239
3240 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3241
3242---------------------------------------------------------------------------*/
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003243VOS_STATUS csrNeighborRoamPrepareNonOccupiedChannelList(
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003244 tpAniSirGlobal pMac,
3245 tANI_U8 *pInputChannelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003246 int numOfChannels,
3247 tANI_U8 *pOutputChannelList,
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003248 int *pOutputNumOfChannels
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003249 )
3250{
3251 int i = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003252 int outputNumOfChannels = 0; // Clear the output number of channels
3253 tANI_U8 numOccupiedChannels = pMac->scan.occupiedChannels.numChannels;
3254 tANI_U8 *pOccupiedChannelList = pMac->scan.occupiedChannels.channelList;
3255
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003256 for (i = 0; i < numOfChannels; i++)
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003257 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003258 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels,
3259 pInputChannelList[i]))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003260 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003261 pOutputChannelList[outputNumOfChannels++] = pInputChannelList[i];
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003262 }
3263 }
3264
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003265 smsLog(pMac, LOG2, FL("Number of channels in the valid channel list=%d; "
3266 "Number of channels in the non-occupied list list=%d"),
3267 numOfChannels, outputNumOfChannels);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003268
3269 // Return the number of channels
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003270 *pOutputNumOfChannels = outputNumOfChannels;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003271
3272 return eHAL_STATUS_SUCCESS;
3273}
3274#endif /* FEATURE_WLAN_LFR */
3275
Jeff Johnson295189b2012-06-20 16:38:30 -07003276/* ---------------------------------------------------------------------------
3277
3278 \fn csrNeighborRoamTransitToCFGChanScan
3279
3280 \brief This function is called whenever there is a transition to CFG chan scan
3281 state from any state. It frees up the current channel list and allocates
3282 a new memory for the channels received from CFG item. It then starts the
3283 neighbor scan timer to perform the scan on each channel one by one
3284
3285 \param pMac - The handle returned by macOpen.
3286
3287 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3288
3289---------------------------------------------------------------------------*/
3290VOS_STATUS csrNeighborRoamTransitToCFGChanScan(tpAniSirGlobal pMac)
3291{
3292 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3293 eHalStatus status = eHAL_STATUS_SUCCESS;
3294 int i = 0;
3295 int numOfChannels = 0;
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003296 tANI_U8 channelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003297 tpCsrChannelInfo currChannelListInfo;
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003298#ifdef FEATURE_WLAN_LFR
3299 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
3300#endif
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003301 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003302
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003303 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003304#ifdef FEATURE_WLAN_CCX
3305 ((pNeighborRoamInfo->isCCXAssoc) &&
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003306 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived == eANI_BOOLEAN_FALSE)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
3308#endif // CCX
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003309 currChannelListInfo->numOfChannels == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003311 smsLog(pMac, LOGW, FL("Building channel list to scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003312
3313
3314 /* Free up the channel list and allocate a new memory. This is because we dont know how much
3315 was allocated last time. If we directly copy more number of bytes than allocated earlier, this might
3316 result in memory corruption */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003317 if (NULL != currChannelListInfo->ChannelList)
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003319 vos_mem_free(currChannelListInfo->ChannelList);
3320 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07003321 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003323
3324 // Now obtain the contents for "channelList" (the "default valid channel list") from EITHER
3325 // the gNeighborScanChannelList in "cfg.ini", OR the actual "valid channel list" information formed by CSR.
3326 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003328 // Copy the "default valid channel list" (channelList) from the gNeighborScanChannelList in "cfg.ini".
3329 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, "Using the channel list from cfg.ini");
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003330 status = csrNeighborRoamMergeChannelLists(
3331 pMac,
3332 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3333 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
3334 channelList,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003335 0, //NB: If 0, simply copy the input channel list to the output list.
3336 &numOfChannels );
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003337
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003338 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3339 {
3340 csrNeighborRoamChannelsFilterByCurrentBand(
3341 pMac,
3342 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
3343 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels,
3344 channelList,
3345 &numOfChannels);
3346 }
Gopichand Nakkala68d1a002013-04-19 21:52:58 +05303347 if(numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3348 {
3349 smsLog(pMac, LOGE, FL("Received wrong number of Channel list"));
3350 return VOS_STATUS_E_INVAL;
3351 }
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003352 currChannelListInfo->ChannelList =
3353 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
3354 if (NULL == currChannelListInfo->ChannelList)
3355 {
3356 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3357 return VOS_STATUS_E_RESOURCES;
3358 }
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003359 vos_mem_copy(currChannelListInfo->ChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003360 channelList, numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi596e4fb2012-10-05 11:39:52 -07003361 }
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003362#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08003363 else if ((pNeighborRoamInfo->uScanMode == DEFAULT_SCAN) &&
3364 (abs(pNeighborRoamInfo->lookupDOWNRssi) >
3365 abs(pNeighborRoamInfo->cfgParams.neighborReassocThreshold)))
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003366 {
3367 /*
3368 * Trigger a contiguous scan on all channels when the
3369 * RSSI in the lookup DOWN notification is below reassoc
3370 * threshold. This will help us find the best available
3371 * candidate and also update the channel cache.
3372 */
3373 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Triggering contiguous scan "
3374 "(lookupDOWNRssi=%d,reassocThreshold=%d)",
3375 pNeighborRoamInfo->lookupDOWNRssi,
3376 pNeighborRoamInfo->cfgParams.neighborReassocThreshold*(-1));
3377
3378 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3379
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05303380 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003381
3382 /* We are about to start a fresh scan cycle,
3383 * purge non-P2P results from the past */
3384 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
Krunal Sonie86aca82013-05-15 17:46:41 -07003385
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003386 csrNeighborRoamPerformContiguousBgScan(pMac, sessionId);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003387
3388 /* Transition to CFG_CHAN_LIST_SCAN */
3389 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN);
Krunal Sonie86aca82013-05-15 17:46:41 -07003390
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003391 return VOS_STATUS_SUCCESS;
3392 }
3393#endif
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003394 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003395 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003396 numOfChannels = pMac->scan.occupiedChannels.numChannels;
3397 if (numOfChannels
3398#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08003399 && ((pNeighborRoamInfo->uScanMode == SPLIT_SCAN_OCCUPIED_LIST) ||
3400 (pNeighborRoamInfo->uEmptyScanCount == 0) ||
3401 ((pNeighborRoamInfo->uEmptyScanCount % 2) == 1))
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003402#endif
3403 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 {
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003405 /*
3406 * Always scan channels in the occupied channel list
3407 * before scanning on the non-occupied list.
3408 */
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08003409 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Switching to occupied channel list"
3410#ifdef FEATURE_WLAN_LFR
3411 "-uScanMode=%d, uEmptyScanCount=%d",
3412 pNeighborRoamInfo->uScanMode,
3413 pNeighborRoamInfo->uEmptyScanCount
3414#endif
3415 );
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003416 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3417 {
3418 csrNeighborRoamChannelsFilterByCurrentBand(
3419 pMac,
3420 pMac->scan.occupiedChannels.channelList,
3421 numOfChannels,
3422 channelList,
3423 &numOfChannels);
3424 }
3425 else
3426 {
Krunal Soni974de8e2013-05-01 01:08:22 -07003427 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3428 {
3429 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3430 }
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003431 vos_mem_copy(channelList,
3432 pMac->scan.occupiedChannels.channelList,
3433 numOfChannels * sizeof(tANI_U8));
3434 }
3435
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003436 VOS_ASSERT(currChannelListInfo->ChannelList == NULL);
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003437 currChannelListInfo->ChannelList = vos_mem_malloc(numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003438
3439 if (NULL == currChannelListInfo->ChannelList)
3440 {
3441 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3442 return VOS_STATUS_E_RESOURCES;
3443 }
Krunal Sonie86aca82013-05-15 17:46:41 -07003444 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3445 {
3446 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3447 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003448 vos_mem_copy(currChannelListInfo->ChannelList,
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003449 channelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003450 numOfChannels * sizeof(tANI_U8));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003451 }
3452 else
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003453 {
3454 /* Scan all channels from non-occupied list */
3455 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Get valid channel list");
3456 numOfChannels = sizeof(pMac->roam.validChannelList);
3457
3458 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
3459 (tANI_U8 *)pMac->roam.validChannelList,
3460 (tANI_U32 *) &numOfChannels)))
3461 {
3462#ifdef FEATURE_WLAN_LFR
3463 /*
3464 * Prepare non-occupied channel list (channelList)
3465 * from the actual "valid channel list" information
3466 * formed by CSR.
3467 */
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05303468 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, "Switching to non-occupied channel list");
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08003469 status = csrNeighborRoamPrepareNonOccupiedChannelList(pMac,
3470 (tANI_U8 *)pMac->roam.validChannelList,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003471 numOfChannels,
3472 channelList,
3473 &numOfChannels);
3474#else
3475 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, "Merging channel list");
3476 status = csrNeighborRoamMergeChannelLists(
3477 pMac,
3478 (tANI_U8 *)pMac->roam.validChannelList,
3479 numOfChannels, // The number of channels in the validChannelList
3480 channelList,
3481 0, //NB: If 0, simply copy the input channel list to the output list.
3482 &numOfChannels ); // The final number of channels in the output list. Will be numOfChannels
3483#endif
3484 }
3485 else
3486 {
3487 smsLog(pMac, LOGE, FL("Could not get valid channel list"));
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003488 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 }
Srinivas Girigowda9a1c4ce2013-03-21 12:34:46 -07003490
3491 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
3492 {
3493 csrNeighborRoamChannelsFilterByCurrentBand(
3494 pMac,
3495 (tANI_U8 *)pMac->roam.validChannelList,
3496 numOfChannels,
3497 channelList,
3498 &numOfChannels);
3499 }
3500
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003501 currChannelListInfo->ChannelList =
3502 vos_mem_malloc(numOfChannels*sizeof(tANI_U8));
3503
3504 if (NULL == currChannelListInfo->ChannelList)
3505 {
3506 smsLog(pMac, LOGE, FL("Memory allocation for Channel list failed"));
3507 return VOS_STATUS_E_RESOURCES;
3508 }
3509#ifdef FEATURE_WLAN_LFR
3510 vos_mem_copy(currChannelListInfo->ChannelList,
3511 channelList, numOfChannels * sizeof(tANI_U8));
3512#else
Krunal Soni974de8e2013-05-01 01:08:22 -07003513 if (numOfChannels > WNI_CFG_VALID_CHANNEL_LIST_LEN)
3514 {
3515 numOfChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3516 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003517 vos_mem_copy(currChannelListInfo->ChannelList,
3518 (tANI_U8 *)pMac->roam.validChannelList,
3519 numOfChannels * sizeof(tANI_U8));
3520#endif
3521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 }
3523
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07003524 /* Adjust for the actual number that are used */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003525 currChannelListInfo->numOfChannels = numOfChannels;
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003526 NEIGHBOR_ROAM_DEBUG(pMac, LOGW,
3527 "Number of channels from CFG (or) (non-)occupied list=%d",
3528 currChannelListInfo->numOfChannels);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003529 for (i = 0; i < currChannelListInfo->numOfChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 {
Madan Mohan Koyyalamudi22f27082012-11-27 19:11:12 +05303531 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, "Channel List from CFG (or) (non-)occupied list"
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003532 "= %d", currChannelListInfo->ChannelList[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 }
3534 }
3535
3536 /* We are gonna scan now. Remember the time stamp to filter out results only after this timestamp */
3537 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
3538
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05303539 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 /* Start Neighbor scan timer now. Multiplication by PAL_TIMER_TO_MS_UNIT is to convert ms to us which is
3541 what palTimerStart expects */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05303542 status = vos_timer_start(&pNeighborRoamInfo->neighborScanTimer,
3543 pNeighborRoamInfo->cfgParams.neighborScanPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07003544
3545 if (eHAL_STATUS_SUCCESS != status)
3546 {
3547 /* Timer start failed.. */
3548 smsLog(pMac, LOGE, FL("Neighbor scan PAL Timer start failed, status = %d, Ignoring state transition"), status);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003549 vos_mem_free(currChannelListInfo->ChannelList);
3550 currChannelListInfo->ChannelList = NULL;
Kiran Kumar Lokereb4cc85e2013-03-19 22:06:52 -07003551 currChannelListInfo->numOfChannels = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 return VOS_STATUS_E_FAILURE;
3553 }
3554
3555 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = 0;
3556 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05303557 /* We are about to start a fresh scan cycle,
3558 * purge non-P2P results from the past */
3559 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
James Zmuda2e4df9b2013-03-14 17:39:07 -07003560
3561 /* We are about to start a fresh scan cycle,
3562 * purge failed pre-auth results from the past */
3563 csrNeighborRoamPurgePreauthFailedList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003564
3565 /* Transition to CFG_CHAN_LIST_SCAN_STATE */
3566 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN)
3567
3568 return VOS_STATUS_SUCCESS;
3569}
3570
3571/* ---------------------------------------------------------------------------
3572
3573 \fn csrNeighborRoamNeighborLookupUpEvent
3574
3575 \brief This function is called as soon as TL indicates that the current AP's
3576 RSSI is better than the neighbor lookup threshold. Here, we transition to
3577 CONNECTED state and reset all the scan parameters
3578
3579 \param pMac - The handle returned by macOpen.
3580
3581 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3582
3583---------------------------------------------------------------------------*/
3584VOS_STATUS csrNeighborRoamNeighborLookupUpEvent(tpAniSirGlobal pMac)
3585{
3586 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3587 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003588 csrNeighborRoamDeregAllRssiIndication(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003589
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 /* Recheck whether the below check is needed. */
3591 if (pNeighborRoamInfo->neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
3592 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003593#ifdef FEATURE_WLAN_LFR
3594 if (!csrRoamIsFastRoamEnabled(pMac,pMac->roam.neighborRoamInfo.csrSessionId))
3595 {
3596 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
3597 return eHAL_STATUS_SUCCESS;
3598 }
3599#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003600 /* Reset all the neighbor roam info control variables. Free all the allocated memory. It is like we are just associated now */
3601 csrNeighborRoamResetConnectedStateControlInfo(pMac);
3602
Jeff Johnson295189b2012-06-20 16:38:30 -07003603
3604 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering DOWN event neighbor lookup callback with TL. RSSI = %d,"), pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3605 /* Register Neighbor Lookup threshold callback with TL for DOWN event now */
3606 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3607 WLANTL_HO_THRESHOLD_DOWN,
3608 csrNeighborRoamNeighborLookupDOWNCallback,
3609 VOS_MODULE_ID_SME, pMac);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003610#ifdef FEATURE_WLAN_LFR
3611 pNeighborRoamInfo->lookupDOWNRssi = 0;
3612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3614 {
3615 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003616 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback DOWN event with TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 }
3618
3619
3620 return vosStatus;
3621}
3622
3623/* ---------------------------------------------------------------------------
3624
3625 \fn csrNeighborRoamNeighborLookupDownEvent
3626
3627 \brief This function is called as soon as TL indicates that the current AP's
3628 RSSI falls below the current eighbor lookup threshold. Here, we transition to
3629 REPORT_QUERY for 11r association and CFG_CHAN_LIST_SCAN state if the assoc is
3630 a non-11R association.
3631
3632 \param pMac - The handle returned by macOpen.
3633
3634 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3635
3636---------------------------------------------------------------------------*/
3637VOS_STATUS csrNeighborRoamNeighborLookupDownEvent(tpAniSirGlobal pMac)
3638{
3639 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3640 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
3641 eHalStatus status = eHAL_STATUS_SUCCESS;
3642
3643 switch (pNeighborRoamInfo->neighborRoamState)
3644 {
3645 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3646
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003647 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Deregistering DOWN event neighbor lookup callback with TL. RSSI = %d,"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 pNeighborRoamInfo->currentNeighborLookupThreshold * (-1));
3649 /* De-register Neighbor Lookup threshold callback with TL */
3650 vosStatus = WLANTL_DeregRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
3651 WLANTL_HO_THRESHOLD_DOWN,
3652 csrNeighborRoamNeighborLookupDOWNCallback,
3653 VOS_MODULE_ID_SME);
3654
3655 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3656 {
3657 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003658 smsLog(pMac, LOGW, FL(" Couldn't Deregister csrNeighborRoamNeighborLookupCallback DOWN event from TL: Status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 }
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003660#ifdef FEATURE_WLAN_LFR
3661 if (!csrRoamIsFastRoamEnabled(pMac,pMac->roam.neighborRoamInfo.csrSessionId))
3662 {
3663 smsLog(pMac, LOGE, FL("Received when fast roam is disabled. Ignore it"));
3664 return eHAL_STATUS_SUCCESS;
3665 }
3666#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003667
3668#if defined WLAN_FEATURE_VOWIFI_11R && defined WLAN_FEATURE_VOWIFI
3669 if ((pNeighborRoamInfo->is11rAssoc) && (pMac->rrm.rrmSmeContext.rrmConfig.rrmEnabled))
3670 {
3671
3672 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("11R Association:Neighbor Lookup Down event received in CONNECTED state"));
3673 vosStatus = csrNeighborRoamIssueNeighborRptRequest(pMac);
3674 if (VOS_STATUS_SUCCESS != vosStatus)
3675 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003676 smsLog(pMac, LOGE, FL("Neighbor report request failed. status = %d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 return vosStatus;
3678 }
3679 /* Increment the neighbor report retry count after sending the neighbor request successfully */
3680 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum++;
3681 pNeighborRoamInfo->FTRoamInfo.neighborRptPending = eANI_BOOLEAN_TRUE;
3682 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REPORT_QUERY)
3683 }
3684 else
3685#endif
3686 {
3687 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Non 11R or CCX Association:Neighbor Lookup Down event received in CONNECTED state"));
3688
3689 vosStatus = csrNeighborRoamTransitToCFGChanScan(pMac);
3690 if (VOS_STATUS_SUCCESS != vosStatus)
3691 {
Madan Mohan Koyyalamudi4450acc2012-11-15 17:24:31 -08003692 NEIGHBOR_ROAM_DEBUG(pMac, LOGE, FL("csrNeighborRoamTransitToCFGChanScan failed"
3693 " with status=%d"), vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 return vosStatus;
3695 }
3696 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003697 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 -07003698 /* Register Neighbor Lookup threshold callback with TL for UP event now */
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08003699 vosStatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext,
3700 (v_S7_t)NEIGHBOR_ROAM_LOOKUP_UP_THRESHOLD * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 WLANTL_HO_THRESHOLD_UP,
3702 csrNeighborRoamNeighborLookupUPCallback,
3703 VOS_MODULE_ID_SME, pMac);
3704 if(!VOS_IS_STATUS_SUCCESS(vosStatus))
3705 {
3706 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003707 smsLog(pMac, LOGE, FL(" Couldn't register csrNeighborRoamNeighborLookupCallback UP event with TL: Status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 }
3709 break;
3710 default:
3711 smsLog(pMac, LOGE, FL("DOWN event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
3712 break;
3713
3714 }
3715 return vosStatus;
3716}
3717
3718/* ---------------------------------------------------------------------------
3719
3720 \fn csrNeighborRoamNeighborLookupUPCallback
3721
3722 \brief This function is registered with TL to indicate whenever the RSSI
3723 gets better than the neighborLookup RSSI Threshold
3724
3725 \param pAdapter - VOS Context
3726 trafficStatus - UP/DOWN indication from TL
3727 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3728
3729 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3730
3731---------------------------------------------------------------------------*/
3732VOS_STATUS csrNeighborRoamNeighborLookupUPCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -08003733 v_PVOID_t pUserCtxt,
3734 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003735{
3736 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3737 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3738 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3739
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -08003740 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup UP indication callback called with notification %d Reported RSSI = %d"),
3741 rssiNotification,
3742 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003743
3744 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3745 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003746 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 return VOS_STATUS_SUCCESS;
3748 }
3749
3750 VOS_ASSERT(WLANTL_HO_THRESHOLD_UP == rssiNotification);
3751 vosStatus = csrNeighborRoamNeighborLookupUpEvent(pMac);
3752 return vosStatus;
3753}
3754
3755/* ---------------------------------------------------------------------------
3756
3757 \fn csrNeighborRoamNeighborLookupDOWNCallback
3758
3759 \brief This function is registered with TL to indicate whenever the RSSI
3760 falls below the current neighborLookup RSSI Threshold
3761
3762 \param pAdapter - VOS Context
3763 trafficStatus - UP/DOWN indication from TL
3764 pUserCtxt - Parameter for callback registered during callback registration. Should be pMac
3765
3766 \return VOS_STATUS_SUCCESS on success, corresponding error code otherwise
3767
3768---------------------------------------------------------------------------*/
3769VOS_STATUS csrNeighborRoamNeighborLookupDOWNCallback (v_PVOID_t pAdapter, v_U8_t rssiNotification,
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -08003770 v_PVOID_t pUserCtxt,
3771 v_S7_t avgRssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07003772{
3773 tpAniSirGlobal pMac = PMAC_STRUCT( pUserCtxt );
3774 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3775 VOS_STATUS vosStatus = eHAL_STATUS_SUCCESS;
3776
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -08003777 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Neighbor Lookup DOWN indication callback called with notification %d Reported RSSI = %d"),
3778 rssiNotification,
3779 avgRssi);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003781#ifdef FEATURE_WLAN_LFR
3782 pNeighborRoamInfo->lookupDOWNRssi = avgRssi;
3783#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 if(!csrIsConnStateConnectedInfra(pMac, pNeighborRoamInfo->csrSessionId))
3785 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08003786 smsLog(pMac, LOGW, "Ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 return VOS_STATUS_SUCCESS;
3788 }
3789
3790 VOS_ASSERT(WLANTL_HO_THRESHOLD_DOWN == rssiNotification);
3791 vosStatus = csrNeighborRoamNeighborLookupDownEvent(pMac);
3792
3793 return vosStatus;
3794}
3795
3796#ifdef RSSI_HACK
3797extern int dumpCmdRSSI;
3798#endif
3799
3800/* ---------------------------------------------------------------------------
3801
3802 \fn csrNeighborRoamIndicateDisconnect
3803
3804 \brief This function is called by CSR as soon as the station disconnects from
3805 the AP. This function does the necessary cleanup of neighbor roam data
3806 structures. Neighbor roam state transitions to INIT state whenever this
3807 function is called except if the current state is REASSOCIATING
3808
3809 \param pMac - The handle returned by macOpen.
3810 sessionId - CSR session id that got disconnected
3811
3812 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3813
3814---------------------------------------------------------------------------*/
3815eHalStatus csrNeighborRoamIndicateDisconnect(tpAniSirGlobal pMac, tANI_U8 sessionId)
3816{
3817 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003818#ifdef FEATURE_WLAN_LFR
3819 tCsrRoamConnectedProfile *pPrevProfile = &pNeighborRoamInfo->prevConnProfile;
3820#endif
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003821 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003822
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003823 smsLog(pMac, LOGE, FL("Disconnect indication on session %d in state %d"),
3824 sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003825
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003826#ifdef FEATURE_WLAN_LFR
3827 /*Free the current previous profile and move the current profile to prev profile.*/
3828 csrRoamFreeConnectProfile(pMac, pPrevProfile);
Srinivas Girigowdac9713872013-06-25 17:54:33 -07003829 csrRoamCopyConnectProfile(pMac, sessionId, pPrevProfile);
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003830#endif
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003831 if (NULL != pSession)
3832 {
3833 if (NULL != pSession->pCurRoamProfile)
3834 {
3835 if (VOS_STA_MODE != pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona)
3836 {
3837 smsLog(pMac, LOGE, FL("Ignoring Disconnect indication received from a non STA persona."
3838 "sessionId: %d, csrPersonna %d"), sessionId,
3839 (int)pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona);
3840 return eHAL_STATUS_SUCCESS;
3841 }
3842 }
3843 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003844
Jeff Johnson295189b2012-06-20 16:38:30 -07003845#ifdef FEATURE_WLAN_CCX
3846 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 if (pSession->connectedProfile.isCCXAssoc)
3848 {
3849 vos_mem_copy(&pSession->prevApSSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
3850 vos_mem_copy(pSession->prevApBssid, pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
3851 pSession->prevOpChannel = pSession->connectedProfile.operationChannel;
3852 pSession->isPrevApInfoValid = TRUE;
3853 pSession->roamTS1 = vos_timer_get_system_time();
3854
3855 }
3856 }
3857#endif
3858
3859#ifdef RSSI_HACK
3860 dumpCmdRSSI = -40;
3861#endif
3862 switch (pNeighborRoamInfo->neighborRoamState)
3863 {
3864 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
3865 // Stop scan and neighbor refresh timers.
3866 // These are indeed not required when we are in reassociating
3867 // state.
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05303868 vos_timer_stop(&pNeighborRoamInfo->neighborScanTimer);
3869 vos_timer_stop(&pNeighborRoamInfo->neighborResultsRefreshTimer);
3870 vos_timer_stop(&pNeighborRoamInfo->emptyScanRefreshTimer);
Madan Mohan Koyyalamudi5ad3dff2012-10-21 11:32:02 -07003871 if (!CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId )) {
3872 /*
3873 * Disconnect indication during Disassoc Handoff sub-state
3874 * is received when we are trying to disconnect with the old
3875 * AP during roam. BUT, if receive a disconnect indication
3876 * outside of Disassoc Handoff sub-state, then it means that
3877 * this is a genuine disconnect and we need to clean up.
3878 * Otherwise, we will be stuck in reassoc state which will
3879 * in-turn block scans (see csrIsScanAllowed).
3880 */
3881 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 break;
3884
3885 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 csrNeighborRoamResetInitStateControlInfo(pMac);
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003887#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda392c1692013-06-13 19:44:16 -07003888 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003889 {
3890#endif
3891 csrNeighborRoamDeregAllRssiIndication(pMac);
3892#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3893 }
3894#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 break;
3896
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003897 case eCSR_NEIGHBOR_ROAM_STATE_CONNECTED:
3898 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
3899 csrNeighborRoamResetConnectedStateControlInfo(pMac);
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003900#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda392c1692013-06-13 19:44:16 -07003901 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003902 {
3903#endif
3904 csrNeighborRoamDeregAllRssiIndication(pMac);
3905#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3906 }
3907#endif
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08003908 break;
3909
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003910 case eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN:
3911 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT);
3912 csrNeighborRoamResetCfgListChanScanControlInfo(pMac);
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003913#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda392c1692013-06-13 19:44:16 -07003914 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003915 {
3916#endif
3917 csrNeighborRoamDeregAllRssiIndication(pMac);
3918#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3919 }
3920#endif
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003921 break;
3922
3923 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
3924 /* Stop pre-auth to reassoc interval timer */
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05303925 vos_timer_stop(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003926 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
3927 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
3928 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudiedee8aa2012-10-15 15:36:40 -07003929 csrNeighborRoamResetPreauthControlInfo(pMac);
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003930 csrNeighborRoamResetReportScanStateControlInfo(pMac);
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003931#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda392c1692013-06-13 19:44:16 -07003932 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003933 {
3934#endif
3935 csrNeighborRoamDeregAllRssiIndication(pMac);
3936#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3937 }
3938#endif
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003939 break;
3940
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 default:
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07003942 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Received disconnect event in state %d"), pNeighborRoamInfo->neighborRoamState);
3943 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, FL("Transitioning to INIT state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
Madan Mohan Koyyalamudi4f292df2012-09-18 17:27:40 -07003945 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003947#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3948 /*Inform the Firmware to STOP Scanning as the host has a disconnect.*/
3949 if (csrRoamIsStaMode(pMac, sessionId))
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07003950 {
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003951 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP, REASON_DISCONNECTED);
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07003952 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07003953#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 return eHAL_STATUS_SUCCESS;
3955}
3956
3957/* ---------------------------------------------------------------------------
3958
3959 \fn csrNeighborRoamIndicateConnect
3960
3961 \brief This function is called by CSR as soon as the station connects to an AP.
3962 This initializes all the necessary data structures related to the
3963 associated AP and transitions the state to CONNECTED state
3964
3965 \param pMac - The handle returned by macOpen.
3966 sessionId - CSR session id that got connected
3967 vosStatus - connect status SUCCESS/FAILURE
3968
3969 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
3970
3971---------------------------------------------------------------------------*/
3972eHalStatus csrNeighborRoamIndicateConnect(tpAniSirGlobal pMac, tANI_U8 sessionId, VOS_STATUS vosStatus)
3973{
3974 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
3975 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07003976 VOS_STATUS vstatus;
3977
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003978#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 int init_ft_flag = FALSE;
3980#endif
3981
krunal sonif7702fa2013-07-16 16:20:19 -07003982 // if session id invalid then we need return failure
3983 if (NULL == pNeighborRoamInfo || !CSR_IS_SESSION_VALID(pMac, sessionId) ||
3984 (NULL == pMac->roam.roamSession[sessionId].pCurRoamProfile))
krunal sonic67f7ef2013-06-13 12:24:10 -07003985 {
3986 return eHAL_STATUS_FAILURE;
3987 }
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003988 smsLog(pMac, LOG2, FL("Connect indication received with session id %d in state %d"), sessionId, pNeighborRoamInfo->neighborRoamState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003989
Srinivas Girigowda392c1692013-06-13 19:44:16 -07003990 // Bail out if this is NOT a STA persona
3991 if (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona != VOS_STA_MODE)
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003992 {
3993 smsLog(pMac, LOGE, FL("Ignoring Connect indication received from a non STA persona."
Srinivas Girigowda392c1692013-06-13 19:44:16 -07003994 "sessionId: %d, csrPersonna %d"),
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003995 sessionId,
Srinivas Girigowda392c1692013-06-13 19:44:16 -07003996 (int)pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona);
Dhanashri Atre2ff77b12013-05-02 11:11:05 -07003997 return eHAL_STATUS_SUCCESS;
3998 }
3999
Srinivas Girigowda392c1692013-06-13 19:44:16 -07004000 // if a concurrent session is running
4001#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4002 if (eANI_BOOLEAN_FALSE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4003 {
4004#endif
4005 if (csrIsConcurrentSessionRunning(pMac))
4006 {
4007 smsLog(pMac, LOGE, FL("Ignoring Connect indication received in multisession %d"),
4008 csrIsConcurrentSessionRunning(pMac));
4009 return eHAL_STATUS_SUCCESS;
4010 }
4011#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4012 }
4013#endif
4014
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 switch (pNeighborRoamInfo->neighborRoamState)
4016 {
4017 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
4018 if (VOS_STATUS_SUCCESS != vosStatus)
4019 {
4020 /* Just transition the state to INIT state. Rest of the clean up happens when we get next connect indication */
4021 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
4022 break;
4023 }
4024 /* Fall through if the status is SUCCESS */
4025 case eCSR_NEIGHBOR_ROAM_STATE_INIT:
4026 /* Reset all the data structures here */
4027 csrNeighborRoamResetInitStateControlInfo(pMac);
4028
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 pNeighborRoamInfo->csrSessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004030
4031#ifdef FEATURE_WLAN_LFR
4032 /*
4033 * Initialize the occupied list ONLY if we are
4034 * transitioning from INIT state to CONNECTED state.
4035 */
4036 if (eCSR_NEIGHBOR_ROAM_STATE_INIT == pNeighborRoamInfo->neighborRoamState)
4037 csrInitOccupiedChannelsList(pMac);
4038#endif
4039 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CONNECTED);
4040
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 vos_mem_copy(pNeighborRoamInfo->currAPbssid,
4042 pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tCsrBssid));
4043 pNeighborRoamInfo->currAPoperationChannel = pMac->roam.roamSession[sessionId].connectedProfile.operationChannel;
4044 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
4045 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = sessionId;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004046 pNeighborRoamInfo->currentNeighborLookupThreshold =
4047 pNeighborRoamInfo->cfgParams.neighborLookupThreshold;
4048#ifdef FEATURE_WLAN_LFR
4049 pNeighborRoamInfo->uEmptyScanCount = 0;
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08004050 pNeighborRoamInfo->lookupDOWNRssi = 0;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004051 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004052#endif
4053
Jeff Johnson295189b2012-06-20 16:38:30 -07004054
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004055#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 /* Now we can clear the preauthDone that was saved as we are connected afresh */
4057 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4058#endif
4059
4060#ifdef WLAN_FEATURE_VOWIFI_11R
4061 // Based on the auth scheme tell if we are 11r
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08004062 if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType,
4063 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 {
4065 if (pMac->roam.configParam.isFastTransitionEnabled)
4066 init_ft_flag = TRUE;
4067 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_TRUE;
4068 }
4069 else
4070 pNeighborRoamInfo->is11rAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004071 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("11rAssoc is = %d"), pNeighborRoamInfo->is11rAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -07004072#endif
4073
4074#ifdef FEATURE_WLAN_CCX
4075 // Based on the auth scheme tell if we are 11r
4076 if (pMac->roam.roamSession[sessionId].connectedProfile.isCCXAssoc)
4077 {
4078 if (pMac->roam.configParam.isFastTransitionEnabled)
4079 init_ft_flag = TRUE;
4080 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_TRUE;
4081 }
4082 else
4083 pNeighborRoamInfo->isCCXAssoc = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004084 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("isCCXAssoc is = %d ft = %d"),
4085 pNeighborRoamInfo->isCCXAssoc, init_ft_flag);
Jeff Johnson295189b2012-06-20 16:38:30 -07004086
4087#endif
4088
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004089#ifdef FEATURE_WLAN_LFR
4090 // If "Legacy Fast Roaming" is enabled
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304091 if (csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004092 {
4093 init_ft_flag = TRUE;
4094 }
4095#endif
4096
4097#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 if ( init_ft_flag == TRUE )
4099 {
4100 /* Initialize all the data structures needed for the 11r FT Preauth */
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 pNeighborRoamInfo->FTRoamInfo.currentNeighborRptRetryNum = 0;
4102 csrNeighborRoamPurgePreauthFailedList(pMac);
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004103#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Srinivas Girigowda392c1692013-06-13 19:44:16 -07004104 if (csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004105 {
4106 /*If this is not a INFRA type BSS, then do not send the command
4107 * down to firmware.Do not send the START command for other session
4108 * connections.*/
4109 if(csrRoamIsStaMode(pMac, sessionId))
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004110 {
4111 pNeighborRoamInfo->uOsRequestedHandoff = 0;
Srinivas Girigowda392c1692013-06-13 19:44:16 -07004112 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_CONNECT);
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004113 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004114 } else {
4115#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004116
4117 NEIGHBOR_ROAM_DEBUG(pMac, LOG2, FL("Registering neighbor lookup DOWN event with TL, RSSI = %d"), pNeighborRoamInfo->currentNeighborLookupThreshold);
4118 /* Register Neighbor Lookup threshold callback with TL for DOWN event only */
Jeff Johnson43971f52012-07-17 12:26:56 -07004119 vstatus = WLANTL_RegRSSIIndicationCB(pMac->roam.gVosContext, (v_S7_t)pNeighborRoamInfo->currentNeighborLookupThreshold * (-1),
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 WLANTL_HO_THRESHOLD_DOWN,
4121 csrNeighborRoamNeighborLookupDOWNCallback,
4122 VOS_MODULE_ID_SME, pMac);
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08004123#ifdef FEATURE_WLAN_LFR
4124 pNeighborRoamInfo->lookupDOWNRssi = 0;
4125#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07004126 if(!VOS_IS_STATUS_SUCCESS(vstatus))
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 {
4128 //err msg
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08004129 smsLog(pMac, LOGW, FL(" Couldn't register csrNeighborRoamNeighborLookupDOWNCallback with TL: Status = %d"), vstatus);
Jeff Johnson43971f52012-07-17 12:26:56 -07004130 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 }
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004132#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4133 }
4134#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 }
4136#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 break;
4138 default:
4139 smsLog(pMac, LOGE, FL("Connect event received in invalid state %d..Ignoring..."), pNeighborRoamInfo->neighborRoamState);
4140 break;
4141 }
4142 return status;
4143}
4144
4145
4146#ifdef WLAN_FEATURE_VOWIFI_11R
4147/* ---------------------------------------------------------------------------
4148
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 \fn csrNeighborRoamPurgePreauthFailedList
4150
4151 \brief This function purges all the MAC addresses in the pre-auth fail list
4152
4153 \param pMac - The handle returned by macOpen.
4154
4155 \return VOID
4156
4157---------------------------------------------------------------------------*/
4158void csrNeighborRoamPurgePreauthFailedList(tpAniSirGlobal pMac)
4159{
4160 tANI_U8 i;
4161
4162 for (i = 0; i < pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress; i++)
4163 {
4164 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.macAddress[i], sizeof(tSirMacAddr));
4165 }
4166 pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthFailList.numMACAddress = 0;
4167
4168 return;
4169}
4170
4171/* ---------------------------------------------------------------------------
4172
4173 \fn csrNeighborRoamInit11rAssocInfo
4174
4175 \brief This function initializes 11r related neighbor roam data structures
4176
4177 \param pMac - The handle returned by macOpen.
4178
4179 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4180
4181---------------------------------------------------------------------------*/
4182eHalStatus csrNeighborRoamInit11rAssocInfo(tpAniSirGlobal pMac)
4183{
4184 eHalStatus status;
4185 tpCsr11rAssocNeighborInfo pFTRoamInfo = &pMac->roam.neighborRoamInfo.FTRoamInfo;
4186
4187 pMac->roam.neighborRoamInfo.is11rAssoc = eANI_BOOLEAN_FALSE;
4188 pMac->roam.neighborRoamInfo.cfgParams.maxNeighborRetries = pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries;
4189 pFTRoamInfo->neighborReportTimeout = CSR_NEIGHBOR_ROAM_REPORT_QUERY_TIMEOUT;
4190 pFTRoamInfo->PEPreauthRespTimeout = CSR_NEIGHBOR_ROAM_PREAUTH_RSP_WAIT_MULTIPLIER * pMac->roam.neighborRoamInfo.cfgParams.neighborScanPeriod;
4191 pFTRoamInfo->neighborRptPending = eANI_BOOLEAN_FALSE;
4192 pFTRoamInfo->preauthRspPending = eANI_BOOLEAN_FALSE;
4193
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
4195 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
4196 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
4197 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
4198
4199
4200 status = csrLLOpen(pMac->hHdd, &pFTRoamInfo->preAuthDoneList);
4201 if (eHAL_STATUS_SUCCESS != status)
4202 {
4203 smsLog(pMac, LOGE, FL("LL Open of preauth done AP List failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 return eHAL_STATUS_RESOURCES;
4205 }
4206 return status;
4207}
4208#endif /* WLAN_FEATURE_VOWIFI_11R */
4209
4210/* ---------------------------------------------------------------------------
4211
4212 \fn csrNeighborRoamInit
4213
4214 \brief This function initializes neighbor roam data structures
4215
4216 \param pMac - The handle returned by macOpen.
4217
4218 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4219
4220---------------------------------------------------------------------------*/
4221eHalStatus csrNeighborRoamInit(tpAniSirGlobal pMac)
4222{
4223 eHalStatus status;
4224 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4225
4226 pNeighborRoamInfo->neighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
4227 pNeighborRoamInfo->prevNeighborRoamState = eCSR_NEIGHBOR_ROAM_STATE_CLOSED;
4228 pNeighborRoamInfo->csrSessionId = CSR_SESSION_ID_INVALID;
4229 pNeighborRoamInfo->cfgParams.maxChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime;
4230 pNeighborRoamInfo->cfgParams.minChannelScanTime = pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime;
4231 pNeighborRoamInfo->cfgParams.maxNeighborRetries = 0;
4232 pNeighborRoamInfo->cfgParams.neighborLookupThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold;
4233 pNeighborRoamInfo->cfgParams.neighborReassocThreshold = pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold;
4234 pNeighborRoamInfo->cfgParams.neighborScanPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod;
4235 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004236 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod = pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod;
4237
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004238 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels;
4240
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004241 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 vos_mem_malloc(pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
4243
4244 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
4245 {
4246 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
4247 return eHAL_STATUS_RESOURCES;
4248 }
4249
4250 /* Update the roam global structure from CFG */
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004251 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList,
4253 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
4254
4255 vos_mem_set(pNeighborRoamInfo->currAPbssid, sizeof(tCsrBssid), 0);
4256 pNeighborRoamInfo->currentNeighborLookupThreshold = pMac->roam.neighborRoamInfo.cfgParams.neighborLookupThreshold;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004257#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi91482b82012-12-27 17:28:14 -08004258 pNeighborRoamInfo->lookupDOWNRssi = 0;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004259 pNeighborRoamInfo->uEmptyScanCount = 0;
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004260 pNeighborRoamInfo->uScanMode = DEFAULT_SCAN;
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004261 palZeroMemory(pMac->hHdd, &pNeighborRoamInfo->prevConnProfile,
4262 sizeof(tCsrRoamConnectedProfile));
4263#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 pNeighborRoamInfo->scanRspPending = eANI_BOOLEAN_FALSE;
4265
4266 pNeighborRoamInfo->neighborScanTimerInfo.pMac = pMac;
4267 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304268 status = vos_timer_init(&pNeighborRoamInfo->neighborScanTimer, VOS_TIMER_TYPE_SW,
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 csrNeighborRoamNeighborScanTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
4270
4271 if (eHAL_STATUS_SUCCESS != status)
4272 {
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004273 smsLog(pMac, LOGE, FL("Neighbor scan timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4275 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4276 return eHAL_STATUS_RESOURCES;
4277 }
4278
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304279 status = vos_timer_init(&pNeighborRoamInfo->neighborResultsRefreshTimer, VOS_TIMER_TYPE_SW,
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 csrNeighborRoamResultsRefreshTimerCallback, (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
4281
4282 if (eHAL_STATUS_SUCCESS != status)
4283 {
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004284 smsLog(pMac, LOGE, FL("Neighbor results refresh timer allocation failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4286 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304287 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 return eHAL_STATUS_RESOURCES;
4289 }
4290
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304291 status = vos_timer_init(&pNeighborRoamInfo->emptyScanRefreshTimer, VOS_TIMER_TYPE_SW,
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004292 csrNeighborRoamEmptyScanRefreshTimerCallback,
4293 (void *)&pNeighborRoamInfo->neighborScanTimerInfo);
4294
4295 if (eHAL_STATUS_SUCCESS != status)
4296 {
4297 smsLog(pMac, LOGE, FL("Empty scan refresh timer allocation failed"));
4298 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4299 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304300 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4301 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08004302 return eHAL_STATUS_RESOURCES;
4303 }
4304
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 status = csrLLOpen(pMac->hHdd, &pNeighborRoamInfo->roamableAPList);
4306 if (eHAL_STATUS_SUCCESS != status)
4307 {
4308 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
4309 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4310 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304311 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4312 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4313 vos_timer_destroy(&pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 return eHAL_STATUS_RESOURCES;
4315 }
4316
4317 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
4318 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
4319 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4320 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
4321 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
4322
4323#ifdef WLAN_FEATURE_VOWIFI_11R
4324 status = csrNeighborRoamInit11rAssocInfo(pMac);
4325 if (eHAL_STATUS_SUCCESS != status)
4326 {
4327 smsLog(pMac, LOGE, FL("LL Open of roamable AP List failed"));
4328 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4329 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304330 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4331 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4332 vos_timer_destroy(&pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 csrLLClose(&pNeighborRoamInfo->roamableAPList);
4334 return eHAL_STATUS_RESOURCES;
4335 }
4336#endif
4337 /* Initialize this with the current tick count */
4338 pNeighborRoamInfo->scanRequestTimeStamp = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
4339
4340 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
4341
4342 return eHAL_STATUS_SUCCESS;
4343}
4344
4345/* ---------------------------------------------------------------------------
4346
4347 \fn csrNeighborRoamClose
4348
4349 \brief This function closes/frees all the neighbor roam data structures
4350
4351 \param pMac - The handle returned by macOpen.
4352
4353 \return VOID
4354
4355---------------------------------------------------------------------------*/
4356void csrNeighborRoamClose(tpAniSirGlobal pMac)
4357{
4358 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4359
4360 if (eCSR_NEIGHBOR_ROAM_STATE_CLOSED == pNeighborRoamInfo->neighborRoamState)
4361 {
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -07004362 smsLog(pMac, LOGW, FL("Neighbor Roam Algorithm Already Closed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 return;
4364 }
4365
4366 if (pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
4367 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
4368
4369 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
4370
4371 pNeighborRoamInfo->neighborScanTimerInfo.pMac = NULL;
4372 pNeighborRoamInfo->neighborScanTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304373 vos_timer_destroy(&pNeighborRoamInfo->neighborScanTimer);
4374 vos_timer_destroy(&pNeighborRoamInfo->neighborResultsRefreshTimer);
4375 vos_timer_destroy(&pNeighborRoamInfo->emptyScanRefreshTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004376
4377 /* Should free up the nodes in the list before closing the double Linked list */
4378 csrNeighborRoamFreeRoamableBSSList(pMac, &pNeighborRoamInfo->roamableAPList);
4379 csrLLClose(&pNeighborRoamInfo->roamableAPList);
4380
4381 if (pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
4382 {
4383 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
4384 }
4385
4386 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4387 pNeighborRoamInfo->roamChannelInfo.currentChanIndex = CSR_NEIGHBOR_ROAM_INVALID_CHANNEL_INDEX;
4388 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
4389 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
4390 pNeighborRoamInfo->roamChannelInfo.chanListScanInProgress = eANI_BOOLEAN_FALSE;
4391 pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived = eANI_BOOLEAN_FALSE;
4392
4393 /* Free the profile.. */
4394 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
Madan Mohan Koyyalamudi6d04f892012-12-13 14:19:25 -08004395#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudie0424d52012-12-12 16:44:44 -08004396 csrRoamFreeConnectProfile(pMac, &pNeighborRoamInfo->prevConnProfile);
Madan Mohan Koyyalamudi6d04f892012-12-13 14:19:25 -08004397#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004398#ifdef WLAN_FEATURE_VOWIFI_11R
4399 pMac->roam.neighborRoamInfo.FTRoamInfo.currentNeighborRptRetryNum = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 pMac->roam.neighborRoamInfo.FTRoamInfo.numBssFromNeighborReport = 0;
4401 vos_mem_zero(pMac->roam.neighborRoamInfo.FTRoamInfo.neighboReportBssInfo,
4402 sizeof(tCsrNeighborReportBssInfo) * MAX_BSS_IN_NEIGHBOR_RPT);
4403 csrNeighborRoamFreeRoamableBSSList(pMac, &pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4404 csrLLClose(&pMac->roam.neighborRoamInfo.FTRoamInfo.preAuthDoneList);
4405#endif /* WLAN_FEATURE_VOWIFI_11R */
4406
4407 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_CLOSED)
4408
4409 return;
4410}
4411
4412/* ---------------------------------------------------------------------------
4413
4414 \fn csrNeighborRoamRequestHandoff
4415
4416 \brief This function triggers actual switching from one AP to the new AP.
4417 It issues disassociate with reason code as Handoff and CSR as a part of
4418 handling disassoc rsp, issues reassociate to the new AP
4419
4420 \param pMac - The handle returned by macOpen.
4421
4422 \return VOID
4423
4424---------------------------------------------------------------------------*/
4425void csrNeighborRoamRequestHandoff(tpAniSirGlobal pMac)
4426{
4427
4428 tCsrRoamInfo roamInfo;
4429 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4430 tANI_U32 sessionId = pNeighborRoamInfo->csrSessionId;
4431 tCsrNeighborRoamBSSInfo handoffNode;
4432 extern void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeDisassocRsp );
4433 tANI_U32 roamId = 0;
4434
4435 if (pMac->roam.neighborRoamInfo.neighborRoamState != eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE)
4436 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08004437 smsLog(pMac, LOGE, FL("Roam requested when Neighbor roam is in %d state"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 pMac->roam.neighborRoamInfo.neighborRoamState);
4439 return;
4440 }
4441
4442 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
4443 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId, &roamInfo, roamId, eCSR_ROAM_FT_START,
4444 eSIR_SME_SUCCESS);
4445
4446 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
4447 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING)
4448
4449 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08004450 VOS_TRACE (VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
4451 FL("HANDOFF CANDIDATE BSSID %02x:%02x:%02x:%02x:%02x:%02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 handoffNode.pBssDescription->bssId[0],
4453 handoffNode.pBssDescription->bssId[1],
4454 handoffNode.pBssDescription->bssId[2],
4455 handoffNode.pBssDescription->bssId[3],
4456 handoffNode.pBssDescription->bssId[4],
4457 handoffNode.pBssDescription->bssId[5]);
4458
4459 /* Free the profile.. Just to make sure we dont leak memory here */
4460 csrReleaseProfile(pMac, &pNeighborRoamInfo->csrNeighborRoamProfile);
4461 /* Create the Handoff AP profile. Copy the currently connected profile and update only the BSSID and channel number
4462 This should happen before issuing disconnect */
4463 csrRoamCopyConnectedProfile(pMac, pNeighborRoamInfo->csrSessionId, &pNeighborRoamInfo->csrNeighborRoamProfile);
4464 vos_mem_copy(pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, handoffNode.pBssDescription->bssId, sizeof(tSirMacAddr));
4465 pNeighborRoamInfo->csrNeighborRoamProfile.ChannelInfo.ChannelList[0] = handoffNode.pBssDescription->channelId;
4466
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08004467 NEIGHBOR_ROAM_DEBUG(pMac, LOGW, " csrRoamHandoffRequested: disassociating with current AP");
Jeff Johnson295189b2012-06-20 16:38:30 -07004468
4469 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_HANDOFF)))
4470 {
Kiran Kumar Lokere4bccb762013-03-07 12:36:05 -08004471 smsLog(pMac, LOGW, "csrRoamHandoffRequested: fail to issue disassociate");
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 return;
4473 }
4474
4475 //notify HDD for handoff, providing the BSSID too
4476 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
4477
4478 vos_mem_copy(roamInfo.bssid,
4479 handoffNode.pBssDescription->bssId,
4480 sizeof( tCsrBssid ));
4481
4482 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4483
4484
4485 return;
4486}
4487
4488/* ---------------------------------------------------------------------------
4489
4490 \fn csrNeighborRoamIsHandoffInProgress
4491
4492 \brief This function returns whether handoff is in progress or not based on
4493 the current neighbor roam state
4494
4495 \param pMac - The handle returned by macOpen.
4496 is11rReassoc - Return whether reassoc is of type 802.11r reassoc
4497
4498 \return eANI_BOOLEAN_TRUE if reassoc in progress, eANI_BOOLEAN_FALSE otherwise
4499
4500---------------------------------------------------------------------------*/
4501tANI_BOOLEAN csrNeighborRoamIsHandoffInProgress(tpAniSirGlobal pMac)
4502{
4503 if (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState)
4504 return eANI_BOOLEAN_TRUE;
4505
4506 return eANI_BOOLEAN_FALSE;
4507}
4508
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08004509#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
Jeff Johnson295189b2012-06-20 16:38:30 -07004510/* ---------------------------------------------------------------------------
4511
4512 \fn csrNeighborRoamIs11rAssoc
4513
4514 \brief This function returns whether the current association is a 11r assoc or not
4515
4516 \param pMac - The handle returned by macOpen.
4517
4518 \return eANI_BOOLEAN_TRUE if current assoc is 11r, eANI_BOOLEAN_FALSE otherwise
4519
4520---------------------------------------------------------------------------*/
4521tANI_BOOLEAN csrNeighborRoamIs11rAssoc(tpAniSirGlobal pMac)
4522{
4523 return pMac->roam.neighborRoamInfo.is11rAssoc;
4524}
4525#endif /* WLAN_FEATURE_VOWIFI_11R */
4526
4527
4528/* ---------------------------------------------------------------------------
4529
4530 \fn csrNeighborRoamGetHandoffAPInfo
4531
4532 \brief This function returns the best possible AP for handoff. For 11R case, it
4533 returns the 1st entry from pre-auth done list. For non-11r case, it returns
4534 the 1st entry from roamable AP list
4535
4536 \param pMac - The handle returned by macOpen.
4537 pHandoffNode - AP node that is the handoff candidate returned
4538
4539 \return VOID
4540
4541---------------------------------------------------------------------------*/
4542void csrNeighborRoamGetHandoffAPInfo(tpAniSirGlobal pMac, tpCsrNeighborRoamBSSInfo pHandoffNode)
4543{
4544 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4545 tpCsrNeighborRoamBSSInfo pBssNode;
4546
4547 VOS_ASSERT(NULL != pHandoffNode);
4548
4549#ifdef WLAN_FEATURE_VOWIFI_11R
4550 if (pNeighborRoamInfo->is11rAssoc)
4551 {
4552 /* Always the BSS info in the head is the handoff candidate */
4553 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
4554 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
4555 }
4556 else
4557#endif
4558#ifdef FEATURE_WLAN_CCX
4559 if (pNeighborRoamInfo->isCCXAssoc)
4560 {
4561 /* Always the BSS info in the head is the handoff candidate */
4562 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
4563 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
4564 }
4565 else
4566#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004567#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304568 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004569 {
4570 /* Always the BSS info in the head is the handoff candidate */
4571 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->FTRoamInfo.preAuthDoneList, NULL);
4572 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->FTRoamInfo.preAuthDoneList));
4573 }
4574 else
4575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 {
4577 pBssNode = csrNeighborRoamGetRoamableAPListNextEntry(pMac, &pNeighborRoamInfo->roamableAPList, NULL);
4578 NEIGHBOR_ROAM_DEBUG(pMac, LOG1, FL("Number of Handoff candidates = %d"), csrLLCount(&pNeighborRoamInfo->roamableAPList));
4579 }
4580 vos_mem_copy(pHandoffNode, pBssNode, sizeof(tCsrNeighborRoamBSSInfo));
4581
4582 return;
4583}
4584
4585/* ---------------------------------------------------------------------------
4586 \brief This function returns TRUE if preauth is completed
4587
4588 \param pMac - The handle returned by macOpen.
4589
4590 \return boolean
4591
4592---------------------------------------------------------------------------*/
4593tANI_BOOLEAN csrNeighborRoamStatePreauthDone(tpAniSirGlobal pMac)
4594{
4595 return (pMac->roam.neighborRoamInfo.neighborRoamState ==
4596 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE);
4597}
4598
4599/* ---------------------------------------------------------------------------
4600 \brief In the event that we are associated with AP1 and we have
4601 completed pre auth with AP2. Then we receive a deauth/disassoc from
4602 AP1.
4603 At this point neighbor roam is in pre auth done state, pre auth timer
4604 is running. We now handle this case by stopping timer and clearing
4605 the pre-auth state. We basically clear up and just go to disconnected
4606 state.
4607
4608 \param pMac - The handle returned by macOpen.
4609
4610 \return boolean
4611---------------------------------------------------------------------------*/
4612void csrNeighborRoamTranistionPreauthDoneToDisconnected(tpAniSirGlobal pMac)
4613{
4614 if (pMac->roam.neighborRoamInfo.neighborRoamState !=
4615 eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE) return;
4616
4617 // Stop timer
Madan Mohan Koyyalamudi0dea29e2013-07-11 12:01:37 +05304618 vos_timer_stop(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07004619
4620 // Transition to init state
4621 CSR_NEIGHBOR_ROAM_STATE_TRANSITION(eCSR_NEIGHBOR_ROAM_STATE_INIT)
4622}
4623
Srikant Kuppacf820b62013-01-30 17:32:44 -08004624/* ---------------------------------------------------------------------------
Srikant Kuppa40b3c142013-02-20 07:24:43 -08004625 \brief This function returns TRUE if background scan triggered by
4626 LFR is in progress.
Srikant Kuppacf820b62013-01-30 17:32:44 -08004627
4628 \param halHandle - The handle from HDD context.
4629
4630 \return boolean
4631
4632---------------------------------------------------------------------------*/
4633tANI_BOOLEAN csrNeighborRoamScanRspPending (tHalHandle hHal)
4634{
4635 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4636 return (pMac->roam.neighborRoamInfo.scanRspPending);
4637}
4638
Srinivas Girigowdaad03e7e2013-03-07 19:42:52 -08004639/* ---------------------------------------------------------------------------
4640 \brief This function returns TRUE if STA is in the middle of roaming states
4641
4642 \param halHandle - The handle from HDD context.
4643
4644 \return boolean
4645
4646---------------------------------------------------------------------------*/
4647tANI_BOOLEAN csrNeighborMiddleOfRoaming (tHalHandle hHal)
4648{
4649 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4650 tANI_BOOLEAN val = (eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4651 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4652 (eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4653 (eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState) ||
4654 (eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN == pMac->roam.neighborRoamInfo.neighborRoamState);
4655 return (val);
4656}
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004657#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4658/* ---------------------------------------------------------------------------
Srinivas Girigowdaad03e7e2013-03-07 19:42:52 -08004659
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004660 \fn csrNeighborRoamCandidateFoundIndHdlr
4661
4662 \brief This function is called by CSR as soon as TL posts the candidate
4663 found indication to SME via MC thread
4664
4665 \param pMac - The handle returned by macOpen.
4666 pMsg - Msg sent by PE
4667
4668 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4669
4670---------------------------------------------------------------------------*/
4671eHalStatus csrNeighborRoamCandidateFoundIndHdlr(tpAniSirGlobal pMac, void* pMsg)
4672{
4673 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4674 eHalStatus status = eHAL_STATUS_SUCCESS;
4675 /* we must be in connected state, if not ignore it */
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004676 if ((eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4677 || (pNeighborRoamInfo->uOsRequestedHandoff))
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004678 {
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004679 smsLog(pMac, LOGE, FL("Received in not CONNECTED state OR uOsRequestedHandoff is set. Ignore it"));
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004680 status = eHAL_STATUS_FAILURE;
4681 }
4682 else
4683 {
4684 /* We are about to start a fresh scan cycle,
4685 * purge non-P2P results from the past */
4686 csrScanFlushSelectiveResult(pMac, VOS_FALSE);
4687 /* Once it gets the candidates found indication from PE, will issue a scan
4688 - req to PE with “freshScan” in scanreq structure set as follows:
4689 0x42 - Return & purge LFR scan results
4690 */
4691 status = csrScanRequestLfrResult(pMac, pNeighborRoamInfo->csrSessionId,
4692 csrNeighborRoamScanResultRequestCallback, pMac);
4693 }
4694
4695 return status;
4696}
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004697
4698/* ---------------------------------------------------------------------------
4699
4700 \fn csrNeighborRoamProcessHandoffReq
4701
4702 \brief This function is called start with the handoff process. First do a
4703 SSID scan for the BSSID provided
4704
4705 \param pMac - The handle returned by macOpen.
4706
4707 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4708
4709---------------------------------------------------------------------------*/
4710eHalStatus csrNeighborRoamProcessHandoffReq(tpAniSirGlobal pMac)
4711{
4712 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4713 eHalStatus status = eHAL_STATUS_SUCCESS;
4714 tANI_U32 roamId;
4715 tCsrRoamProfile *pProfile = NULL;
4716 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pNeighborRoamInfo->csrSessionId );
4717 tANI_U8 i = 0;
4718
4719 do
4720 {
4721 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
4722 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
4723 if(!HAL_STATUS_SUCCESS(status))
4724 {
4725 smsLog(pMac, LOGE, FL("Memory alloc failed"));
4726 break;
4727 }
4728 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
4729 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
4730 if(!HAL_STATUS_SUCCESS(status))
4731 {
4732 smsLog(pMac, LOGE, FL("Profile copy failed"));
4733 break;
4734 }
4735
4736 //Add the BSSID & Channel
4737 pProfile->BSSIDs.numOfBSSIDs = 1;
4738 pProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs);
4739 if (NULL == pProfile->BSSIDs.bssid)
4740 {
4741 smsLog(pMac, LOGE, FL("mem alloc failed for BSSID"));
4742 status = eHAL_STATUS_FAILURE;
4743 break;
4744 }
4745
4746 vos_mem_zero(pProfile->BSSIDs.bssid, sizeof(tSirMacAddr) * pProfile->BSSIDs.numOfBSSIDs);
4747
4748 /* Populate the BSSID from handoff info received from HDD */
4749 for (i = 0; i < pProfile->BSSIDs.numOfBSSIDs; i++)
4750 {
4751 vos_mem_copy(&pProfile->BSSIDs.bssid[i],
4752 pNeighborRoamInfo->handoffReqInfo.bssid, sizeof(tSirMacAddr));
4753 }
4754
4755 pProfile->ChannelInfo.numOfChannels = 1;
4756 pProfile->ChannelInfo.ChannelList =
4757 vos_mem_malloc(sizeof(*pProfile->ChannelInfo.ChannelList) *
4758 pProfile->ChannelInfo.numOfChannels);
4759 if (NULL == pProfile->ChannelInfo.ChannelList)
4760 {
4761 smsLog(pMac, LOGE, FL("mem alloc failed for ChannelList"));
4762 status = eHAL_STATUS_FAILURE;
4763 break;
4764 }
4765 pProfile->ChannelInfo.ChannelList[0] = pNeighborRoamInfo->handoffReqInfo.channel;
4766
4767 //clean up csr cache first
4768 //csrScanFlushSelectiveResult(pMac, VOS_FALSE);
4769 //do a SSID scan
4770 status = csrScanForSSID(pMac, pNeighborRoamInfo->csrSessionId, pProfile, roamId, FALSE);
4771 if(!HAL_STATUS_SUCCESS(status))
4772 {
4773 smsLog(pMac, LOGE, FL("SSID scan failed"));
4774 }
4775 }while(0);
4776
4777 if(NULL != pProfile)
4778 {
4779 csrReleaseProfile(pMac, pProfile);
4780 palFreeMemory(pMac->hHdd, pProfile);
4781 }
4782
4783 return status;
4784}
4785
4786/* ---------------------------------------------------------------------------
4787
4788 \fn csrNeighborRoamSssidScanDone
4789
4790 \brief This function is called once SSID scan is done. If SSID scan failed
4791 to find our candidate add an entry to csr scan cache ourself before starting
4792 the handoff process
4793
4794 \param pMac - The handle returned by macOpen.
4795
4796 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4797
4798---------------------------------------------------------------------------*/
4799eHalStatus csrNeighborRoamSssidScanDone(tpAniSirGlobal pMac, eHalStatus status)
4800{
4801 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4802 eHalStatus hstatus;
4803
4804 smsLog(pMac, LOGE, FL("called "));
4805
4806 /* we must be in connected state, if not ignore it */
4807 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4808 {
4809 smsLog(pMac, LOGE, FL("Received in not CONNECTED state. Ignore it"));
4810 return eHAL_STATUS_FAILURE;
4811 }
4812
4813 //if SSID scan failed to find our candidate add an entry to csr scan cache ourself
4814 if(!HAL_STATUS_SUCCESS(status))
4815 {
4816 smsLog(pMac, LOGE, FL("Add an entry to csr scan cache"));
4817 hstatus = csrScanCreateEntryInScanCache(pMac, pNeighborRoamInfo->csrSessionId,
4818 pNeighborRoamInfo->handoffReqInfo.bssid,
4819 pNeighborRoamInfo->handoffReqInfo.channel);
4820 if (eHAL_STATUS_SUCCESS != hstatus)
4821 {
4822 smsLog(pMac, LOGE, FL("csrScanCreateEntryInScanCache failed with status %d"), hstatus);
4823 return eHAL_STATUS_FAILURE;
4824 }
4825 }
4826
4827 /* Now we have completed scanning for the candidate provided by HDD. Let move on to HO*/
4828 hstatus = csrNeighborRoamProcessScanComplete(pMac);
4829
4830 if (eHAL_STATUS_SUCCESS != hstatus)
4831 {
4832 smsLog(pMac, LOGE, FL("Neighbor scan process complete failed with status %d"), hstatus);
4833 return eHAL_STATUS_FAILURE;
4834 }
4835 return eHAL_STATUS_SUCCESS;
4836}
4837
4838/* ---------------------------------------------------------------------------
4839
4840 \fn csrNeighborRoamHandoffReqHdlr
4841
4842 \brief This function is called by CSR as soon as it gets a handoff request
4843 to SME via MC thread
4844
4845 \param pMac - The handle returned by macOpen.
4846 pMsg - Msg sent by HDD
4847
4848 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4849
4850---------------------------------------------------------------------------*/
4851eHalStatus csrNeighborRoamHandoffReqHdlr(tpAniSirGlobal pMac, void* pMsg)
4852{
4853 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4854 tAniHandoffReq *pHandoffReqInfo;
4855 eHalStatus status = eHAL_STATUS_SUCCESS;
4856 /* we must be in connected state, if not ignore it */
4857 if (eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4858 {
4859 smsLog(pMac, LOGE, FL("Received in not CONNECTED state. Ignore it"));
4860 status = eHAL_STATUS_FAILURE;
4861 }
4862 else
4863 {
4864 //save the handoff info came from HDD as part of the reassoc req
4865 pHandoffReqInfo = (tAniHandoffReq *)pMsg;
4866 if (NULL != pHandoffReqInfo)
4867 {
4868 //sanity check
4869 if (VOS_FALSE == vos_mem_compare(pHandoffReqInfo->bssid,
4870 pNeighborRoamInfo->currAPbssid,
4871 sizeof(tSirMacAddr)))
4872 {
4873
4874 pNeighborRoamInfo->handoffReqInfo.channel = pHandoffReqInfo->channel;
4875 vos_mem_copy(pNeighborRoamInfo->handoffReqInfo.bssid,
4876 pHandoffReqInfo->bssid,
4877 6);
4878 pNeighborRoamInfo->uOsRequestedHandoff = 1;
4879 status = csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_STOP,
4880 REASON_OS_REQUESTED_ROAMING_NOW);
4881 if (eHAL_STATUS_SUCCESS != status)
4882 {
4883 smsLog(pMac, LOGE, FL("csrRoamOffloadScan failed"));
4884 pNeighborRoamInfo->uOsRequestedHandoff = 0;
4885 }
4886 }
4887 else
4888 {
4889 smsLog(pMac, LOGE, FL("Received req has same BSSID as current AP!!"));
4890 status = eHAL_STATUS_FAILURE;
4891 }
4892 }
4893 else
4894 {
4895 smsLog(pMac, LOGE, FL("Received msg is NULL"));
4896 status = eHAL_STATUS_FAILURE;
4897 }
4898 }
4899
4900 return status;
4901}
4902
4903/* ---------------------------------------------------------------------------
4904
4905 \fn csrNeighborRoamProceedWithHandoffReq
4906
4907 \brief This function is called by CSR as soon as it gets rsp back for
4908 ROAM_SCAN_OFFLOAD_STOP with reason REASON_OS_REQUESTED_ROAMING_NOW
4909
4910 \param pMac - The handle returned by macOpen.
4911
4912 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4913
4914---------------------------------------------------------------------------*/
4915eHalStatus csrNeighborRoamProceedWithHandoffReq(tpAniSirGlobal pMac)
4916{
4917 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4918 eHalStatus status = eHAL_STATUS_SUCCESS;
4919 /* we must be in connected state, if not ignore it */
4920 if ((eCSR_NEIGHBOR_ROAM_STATE_CONNECTED != pNeighborRoamInfo->neighborRoamState)
4921 || (!pNeighborRoamInfo->uOsRequestedHandoff))
4922 {
4923 smsLog(pMac, LOGE, FL("Received in not CONNECTED state or uOsRequestedHandoff is not set. Ignore it"));
4924 status = eHAL_STATUS_FAILURE;
4925 }
4926 else
4927 {
4928 //Let's go ahead with handoff
4929 status = csrNeighborRoamProcessHandoffReq(pMac);
4930 }
4931 if(!HAL_STATUS_SUCCESS(status))
4932 {
4933 pNeighborRoamInfo->uOsRequestedHandoff = 0;
4934 }
4935 return status;
4936}
4937
4938/* ---------------------------------------------------------------------------
4939
Varun Reddy Yeturu6fc169c2013-06-07 00:56:52 -07004940 \fn csrNeighborRoamStartLfrScan
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004941
4942 \brief This function is called if HDD requested handoff failed for some
Varun Reddy Yeturu6fc169c2013-06-07 00:56:52 -07004943 reason. start the LFR logic at that point.By the time, this function is
4944 called, a STOP command has already been issued.
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004945
4946 \param pMac - The handle returned by macOpen.
4947
4948 \return eHAL_STATUS_SUCCESS on success, corresponding error code otherwise
4949
4950---------------------------------------------------------------------------*/
Varun Reddy Yeturu6fc169c2013-06-07 00:56:52 -07004951eHalStatus csrNeighborRoamStartLfrScan(tpAniSirGlobal pMac)
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004952{
4953 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
4954 pNeighborRoamInfo->uOsRequestedHandoff = 0;
4955 /* There is no candidate or We are not roaming Now.
4956 * Inform the FW to restart Roam Offload Scan */
Varun Reddy Yeturu6fc169c2013-06-07 00:56:52 -07004957 csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_START, REASON_NO_CAND_FOUND_OR_NOT_ROAMING_NOW);
Varun Reddy Yeturu2c35a7d2013-05-20 11:47:10 -07004958
4959 return eHAL_STATUS_SUCCESS;
4960}
Varun Reddy Yeturu08614702013-04-15 21:58:13 -07004961#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07004962#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */